@milaboratories/graph-maker 1.1.92 → 1.1.93

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.
@@ -15183,11 +15183,11 @@ void main() {
15183
15183
  Q ${a},${o} ${a-ao},${o}
15184
15184
  H ${Ss}
15185
15185
  L 0,0 z`}function w2t(e,t,n,r,a){switch(n){case"left":return m2t(e,t,a);case"right":return v2t(e,t,a);case"top":return g2t(e,t,r);case"bottom":return y2t(e,t,r);default:vA(n,"Unknown tooltip direction")}}function C2t(e,t,n,r,a,i,o){return o?i.right-n-a-Ss>e?"right":"left":i.top+r-a-Ss>t?"top":"bottom"}function b2t(e,t,n,r,a,i){return e==="left"||e==="right"?`translate(${e==="left"?-(r+Ss+t):r+Ss},${-n/2+i})`:`translate(${-t/2+a},${e==="top"?-(n+r+Ss):r+Ss})`}function E2t(e,t){return e==="left"||e==="right"?`translate(${e==="left"?-t:t},0)`:`translate(0,${e==="top"?-t:t})`}function x2t(e,t,n,r){if(e==="left"||e==="right")return 0;let a=t.right-n,i=t.left+n;return a<r/2?a-r/2:i<r/2?r/2-i:0}function S2t(e,t,n,r){if(e==="top"||e==="bottom")return 0;let a=t.top+n,i=t.bottom-n;return a<r/2?r/2-a:i<r/2?i-r/2:0}function oc({content:e,x:t,y:n,active:r,container:a,sideDistances:i,offset:o=A2t,horizontal:s=!0}){if(!r||!a&&a!==null)return null;let c=h2t(e),f=p2t(e),A=C2t(c,f,t,n,o,i,s),h=x2t(A,i,t,c),m=S2t(A,i,n,f),g=le.jsxs("g",{transform:`translate(${i.left+t},${i.top+n})`,opacity:r?1:0,stroke:"none",fill:"none",style:{pointerEvents:"none"},children:[le.jsx("path",{transform:E2t(A,o),d:w2t(c,f,A,h,m),fill:Zt}),le.jsx("g",{fontSize:"14px",fontFamily:"Manrope",fill:"white",transform:b2t(A,c,f,o,h,m),children:e.map((b,C)=>le.jsx("text",{x:GX,y:jX+wP*C+wP/2,dominantBaseline:"central",children:b},C))})]});return a===null?g:HB.createPortal(g,a)}function B2t(e){if(e===null)return"null";if(typeof e=="number"){let t=Math.floor(e),n=e-t;return t+Number(n.toPrecision(2))}return e}function k2t(e,t){return[`X: ${t[e.x]}`,`Node: ${e.y}`,`Value: ${B2t(e.value)}`]}function T2t({heatmapData:e,scales:t,step:n,colorScale:r,tooltipsContainer:a,chartSizes:i,selectedNode:o,labels:s}){let{xKeys:c,yKeys:f,cells:A,meta:h}=e,[m,g]=Vn.useState(null),b={left:i.treeWidth+30+ic.LEFT,right:i.heatmapWidth+ic.RIGHT,top:ic.TOP,bottom:i.heatmapHeight+ic.BOTTOM};return le.jsxs("g",{onMouseLeave:()=>g(null),children:[s.length&&le.jsx("g",{transform:"translate(0,-8)",children:c.map((C,x)=>le.jsxs("text",{x:t.x(C)+2,fontWeight:"500",children:[le.jsx("title",{children:h.xLabels[C]}),s[x]]},C))}),c.map(C=>f.map(x=>{var _;let k=(_=A==null?void 0:A[C])==null?void 0:_[x];return le.jsx("rect",{x:t.x(C),y:t.y(x),width:n.x,height:n.y,stroke:"white",strokeWidth:"1px",fill:k?r(k==null?void 0:k.value):o3t,onMouseOver:()=>{(k==null?void 0:k.value)!==null&&typeof(k==null?void 0:k.value)<"u"?g(k):g(null)},opacity:o&&o.data.rawData[0].id!==(k==null?void 0:k.data.id)?AP:1},k?k.id:`${C}_${x}`)})),s.length&&le.jsx("line",{x1:"0",x2:i.heatmapWidth,y1:"0",y2:"0",stroke:Zt,strokeWidth:"1px"}),m&&a&&le.jsx(oc,{content:k2t(m,e.meta.xLabels),x:t.x(m.x)+n.x/2,y:t.y(m.y)+n.y/2,offset:c.length>1?n.x/2:0,active:!0,sideDistances:b,container:a})]})}function _2t(e,t,n){let{source:r,target:a}=e,i=n==="top";return t==="rectangle"?i?`M ${r.x},${r.y} L ${a.x},${r.y} L${a.x},${a.y}`:`M ${r.y},${r.x} L ${r.y},${a.x} L${a.y},${a.x}`:t==="curve"?N2e(i?I2e:H2e).x(o=>i?o.x:o.y).y(o=>i?o.y:o.x).source(o=>o.target).target(o=>o.source)(e)??"":i?`M ${r.x},${r.y} L${a.x},${a.y}`:`M ${r.y},${r.x} L${a.y},${a.x}`}function YX({links:e,connectionType:t,rootPosition:n,edgeInheritance:r,aesGetters:a,selected:i}){return le.jsx(le.Fragment,{children:e.map(o=>{let{source:s,target:c}=o,f=(r==="up"?s:c).data.rawData[0];return le.jsx("path",{d:_2t(o,t,n),stroke:i?l3t:a.lineColor(f),strokeWidth:i?2:1,fill:"none"},`${o.source.id},${o.target.id}`)})})}function d9(e){return Da().domain([0,1]).range([e,Zt])(.25)}var F8=1.4;function Af(e,t=6,n=Zt,r=null){switch(e){case null:return"";case"0":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z`,fill:"none",stroke:n});case"1":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z`,fill:"none",stroke:n});case"2":return le.jsx("path",{d:`M0,-${t}L ${2*t*Math.tan(Math.PI/6)},${t}L ${-2*t*Math.tan(Math.PI/6)},${t}z`,fill:"none",stroke:n});case"3":return le.jsx("path",{d:`M0,-${t}L 0,${t} M -${t},0 L ${t},0`,fill:"none",stroke:n});case"4":return le.jsx("path",{d:`M-${t},-${t}L ${t},${t} M ${t},-${t} L -${t},${t}`,fill:"none",stroke:n});case"5":{let a=t*F8;return le.jsx("path",{d:`M0,-${a}L ${a},0 L 0,${a} L -${a},0z`,fill:"none",stroke:n})}case"6":return le.jsx("path",{d:`M${-2*t*Math.tan(Math.PI/6)},-${t}L ${2*t*Math.tan(Math.PI/6)},-${t}L0,${t}z`,fill:"none",stroke:n});case"7":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z M-${t},-${t}L ${t},${t} M ${t},-${t} L -${t},${t}`,fill:"none",stroke:n});case"8":{let a=t*2*Math.cos(Math.PI/4);return le.jsx("path",{d:`M0,-${a}L 0,${a} M -${a},0 L ${a},0 M-${t},-${t}L ${t},${t} M ${t},-${t} L -${t},${t}`,fill:"none",stroke:n})}case"9":{let a=t*F8;return le.jsx("path",{d:`M0,-${a}L ${a},0 L 0,${a} L -${a},0z M0,-${a}L 0,${a} M -${a},0 L ${a},0`,fill:"none",stroke:n})}case"10":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z M0,-${t}L 0,${t} M -${t},0 L ${t},0`,fill:"none",stroke:n});case"11":{let a=2*t*Math.tan(Math.PI/6);return le.jsx("path",{d:`M-${a},-${t}L${a},-${t}L0,${-t+2*a}z
15186
- M-${a},${t}L0,${t-2*a}L${a},${t}z`,fill:"none",stroke:n})}case"12":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z M0,-${t}L 0,${t} M -${t},0 L ${t},0`,fill:"none",stroke:n});case"13":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z M-${t},-${t}L ${t},${t} M ${t},-${t} L -${t},${t}`,fill:"none",stroke:n});case"14":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z M-${t},${t}L0,${-t}L${t},${t}`,fill:"none",stroke:n});case"15":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z`,fill:n,stroke:n});case"16":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z`,fill:n,stroke:n});case"17":return le.jsx("path",{d:`M0,-${t}L ${2*t*Math.tan(Math.PI/6)},${t}L ${-2*t*Math.tan(Math.PI/6)},${t}z`,fill:n,stroke:n});case"18":{let a=t*F8;return le.jsx("path",{d:`M0,-${a}L ${a},0 L 0,${a} L -${a},0z`,fill:n,stroke:n})}case"20":{let a=t*2/3;return le.jsx("path",{d:`M -${a},0 a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 -${a*2},0z`,fill:n,stroke:n})}case"22":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z`,fill:n,stroke:r??d9(n)});case"21":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z`,fill:n,stroke:r??d9(n)});case"24":return le.jsx("path",{d:`M0,-${t}L ${2*t*Math.tan(Math.PI/6)},${t}L ${-2*t*Math.tan(Math.PI/6)},${t}z`,fill:n,stroke:r??d9(n)});case"23":{let a=t*F8;return le.jsx("path",{d:`M0,-${a}L ${a},0 L 0,${a} L -${a},0z`,fill:n,stroke:r??d9(n)})}case"25":return le.jsx("path",{d:`M${-2*t*Math.tan(Math.PI/6)},-${t}L ${2*t*Math.tan(Math.PI/6)},-${t}L0,${t}z`,fill:n,stroke:r??d9(n)});default:vA(e,`Unknown point shape ${e}`)}}var P2t=12;function WX({nodes:e,rootPosition:t,showLeavesLabels:n,showNodesLabels:r,aesGetters:a,selectedNodeId:i,onClick:o,onSelectedUpdate:s}){let c=t==="top",[f,A]=Vn.useState(null);return Vn.useEffect(()=>{A(null)},[i]),le.jsxs(le.Fragment,{children:[le.jsx("g",{children:e.map(h=>{let m=h.data.rawData[0],g=a.nodeSize(m),b=a.nodeColor(m),C=c?h.x:h.y,x=c?h.y:h.x;return le.jsx("g",{transform:`translate(${C},${x})`,style:{cursor:"pointer"},onClick:k=>{k.stopPropagation(),o({x:C+ic.LEFT,y:x+ic.TOP,info:h.data.rawData}),s(h)},children:le.jsx("g",{children:le.jsx("circle",{cx:0,cy:0,r:g+P2t,fill:i===h.id?IX:f===h.id?b:"transparent",opacity:AP,onMouseOver:()=>A(h.id??null),onMouseLeave:()=>A(null)})})},h.id)})}),le.jsx("g",{children:e.map(h=>{let m=h.data.rawData[0],g=a.nodeShape(m),b=a.nodeSize(m),C=a.nodeColor(m),x=c?h.x:h.y,k=c?h.y:h.x;return le.jsx("g",{transform:`translate(${x},${k})`,style:{cursor:"pointer"},onClick:_=>{_.stopPropagation(),o({x:x+ic.LEFT,y:k+ic.TOP,info:h.data.rawData}),s(h)},children:le.jsx("g",{onMouseOver:()=>A(h.id??null),onMouseLeave:()=>A(null),children:Af(g,b,i===h.id?IX:C)})},h.id)})}),le.jsx("g",{children:e.map(h=>{let m=h.data.rawData[0],g=a.nodeSize(m),b=c?h.x:h.y,C=c?h.y:h.x;return le.jsx("g",{transform:`translate(${b},${C})`,style:{pointerEvents:"none"},children:(r&&h.children||n&&!h.children)&&le.jsx("text",{x:g+4,y:"4",paintOrder:"stroke",stroke:"white",strokeWidth:"3",children:h.data.label})},h.id)})})]})}var XX=14,V8=12,A9=12,O8=-12;function M2t({aes:e,label:t}){let n=Af(e.shape,e.size,e.color);return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${A9/2},${A9/2})`,children:n}),le.jsx("text",{x:A9+8,y:A9/2,dominantBaseline:"central",fontWeight:500,children:t})]})}function D2t({legendData:e}){let t=e.items.filter(n=>n.type==="continuous");return le.jsxs("g",{children:[le.jsx("defs",{children:t.map(n=>le.jsx("linearGradient",{id:n.id,gradientTransform:"rotate(90)",children:n.scale.domain().map(r=>{let a=n.scale.domain(),i=a[a.length-1]-a[0],o=i>0?(r-a[0])/i*100:0;return le.jsx("stop",{offset:`${o}%`,stopColor:n.scale(r)},r)})},n.id))}),e.items.map(n=>{if(n.type==="continuous"){let r=Math.min(...n.values),a=Math.max(...n.values);return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:O8,children:n.title}),le.jsx("rect",{x:"0",y:"0",width:XX,height:n.height,stroke:Zt,fill:`url(#${n.id})`}),le.jsx("g",{transform:`translate(${XX},0)`,children:n.values.map(i=>{let o=a-r,s=o>0?n.height*(i-r)/o:0;return le.jsxs("g",{transform:`translate(0,${s})`,children:[le.jsx("line",{x1:"0",x2:-4,stroke:Zt}),le.jsx("text",{x:8,y:4,children:i})]},i)})}),!1]},n.id)}if(n.type==="discrete")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:O8,children:n.title}),n.values.map((r,a)=>le.jsxs("g",{transform:`translate(0, ${a*(V8+4)})`,children:[le.jsx("rect",{x:"0",y:"0",width:V8,height:V8,fill:n.scale(r),rx:"1",ry:"1"}),le.jsx("text",{x:V8+8,y:10,children:r})]},r)),!1]},n.id);if(n.type==="nodes")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:O8,children:n.title}),n.values.map((r,a)=>le.jsx("g",{transform:`translate(0, ${a*(A9+4)})`,children:le.jsx(M2t,{aes:n.scale(r),label:n.labels[r]})},r)),!1]},n.id);if(n.type==="size"){let r=n.height/n.values.length;return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:O8,children:n.title}),n.values.map((a,i)=>{let o=n.scale(a);return le.jsxs("g",{transform:`translate(0, ${i*r})`,children:[le.jsx("circle",{r:o,cx:r/2,cy:r/2,fill:Zt}),le.jsx("text",{x:r+4,y:r/2,alignmentBaseline:"central",children:n.labels[a]})]},a)}),!1]},n.id)}})]})}function KX(e){if(!e)return null;let t=new Set,n=e;for(;n;)t.add(n.id),n=n.parent;return t}function H2t({chartSettings:e,chartSizes:t,nodes:n,links:r,connectionType:a,rootPosition:i,edgeInheritance:o,showNodes:s,showEdges:c,showLeavesLabels:f,showNodesLabels:A,aesGetters:h,labels:m,heatmapData:g,heatmapScales:b,heatmapStep:C,heatmapColor:x,heatmapLabels:k,legendData:_,onClick:D}){let O=Vn.useRef(null),[I,$]=Vn.useState(null),Q=Vn.useRef(null);Vn.useEffect(()=>{Q.current&&$(Q.current);function X(){K(null),U(null)}function oe(me){Object.entries(me.detail).forEach(([ae,ye])=>{if(ae==="selectedNode"){let Ce=n.find(ce=>ce.data.rawData[0].id===ye)??null;K(KX(Ce)),U(Ce)}})}return document.addEventListener("click",X),document.addEventListener(pP,oe),()=>{document.removeEventListener("click",X),document.removeEventListener(pP,oe)}},[]);let[ee,K]=gb.useState(null),[re,U]=gb.useState(null),G=ee!==null,Z={connectionType:a,rootPosition:i,edgeInheritance:o,aesGetters:h},Y={rootPosition:i,showLeavesLabels:f,showNodesLabels:A,aesGetters:h,labels:m,onClick:D,selectedNodeId:re==null?void 0:re.id,onSelectedUpdate:X=>{K(KX(X)),U(X)}};return le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${t.totalWidth} ${t.totalHeight}`,ref:O,width:t.totalWidth,height:t.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${ic.LEFT},${ic.TOP})`,fontFamily:"Manrope",children:[le.jsx("text",{x:"0",y:"-12",fontSize:"20",children:e.title.name}),le.jsxs("g",{opacity:G?AP:1,children:[c&&le.jsx(YX,{links:r.filter(X=>{let{source:oe,target:me}=X;return!ee||!(ee.has(oe.id??"")&&ee.has(me.id??""))}),selected:!1,...Z}),s&&le.jsx(WX,{nodes:n.filter(X=>!X.data.isFake&&!(ee!=null&&ee.has(X.id??""))),...Y})]}),G&&le.jsxs("g",{children:[c&&le.jsx(YX,{links:r.filter(X=>{let{source:oe,target:me}=X;return ee.has(oe.id??"")&&ee.has(me.id??"")}),selected:!0,...Z}),s&&le.jsx(WX,{nodes:n.filter(X=>!X.data.isFake&&(ee==null?void 0:ee.has(X.id??""))),...Y})]}),g!==null&&le.jsx("g",{transform:`translate(${t.treeWidth+30},0)`,children:le.jsx(T2t,{heatmapData:g,scales:b,step:C,colorScale:x,chartSizes:t,labels:k,selectedNode:re,tooltipsContainer:I})}),e.legend.show&&le.jsx("g",{transform:`translate(${t.treeWidth+30+t.heatmapWidth+30},0)`,children:le.jsx(D2t,{legendData:_})})]}),le.jsx("g",{ref:Q})]})}function Fm({message:e}){return le.jsx("div",{style:{width:"500px",height:"400px",color:"#ee1616",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"25px",fontFamily:"Arial",border:"1px solid"},children:e})}function p9(e){if(RX(e))return t=>e.valuesMap[String(t[e.columnName.value])];if($m(e)){let{domain:t,range:n}=e,r=Ny().domain(t).range(n);return a=>{let i=r(Number(a[e.columnName.value]));return Math.max(1,i)}}return t=>e}function I2t(e){return{nodeShape:p9(e.nodeShape),nodeColor:p9(e.nodeColor),nodeSize:p9(e.nodeSize),lineShape:p9(e.lineShape),lineColor:p9(e.lineColor)}}var L2t=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function R2t(e,t=1,n,r){let a=(e<16?40:e<49?32:24)*t;return Math.max(Math.min(a,r??1/0),n??-1/0)}var N2t=class{constructor(){Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"chartSizes",{treeWidth:600,treeHeight:350,heatmapWidth:0,heatmapHeight:0,totalWidth:1200+ic.LEFT+ic.RIGHT,totalHeight:350+ic.TOP+ic.BOTTOM,labelsOffset:0});Me(this,"legend",{width:0,height:0,items:[]});Me(this,"heatmapScales",{x:Hl().domain(["null"]).range([1]),y:Hl().domain(["null"]).range([1])});Me(this,"heatmapStep",{x:0,y:0});Me(this,"heatmapColorScale",{scale:Hl([]),getter:()=>"white"});Me(this,"heatmapLabels",[])}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateHeatmapScales(e,t,n){if(e===null){this.chartSizes.heatmapWidth=0;return}let{xKeysByGroups:r,xGroupKeys:a,xKeys:i,yKeys:o}=e,s=5,c=a.map(x=>r[x].length),f=c.reduce((x,k)=>x+k,0),A=this.chartSizes.treeHeight/o.length,h=Math.min(Math.max((400-(c.filter(x=>x>0).length-1)*s)/f,n.minCellWidth),n.maxCellWidth),m=[],g=0;a.forEach(x=>{let k=r[x];k.forEach(()=>{m.push(g),g+=h}),k.length>0&&(g+=s)}),this.heatmapScales.x=Hl().domain(i).range(m),this.heatmapScales.y=Hl().domain(o).range(o.map((x,k)=>k*A)),this.heatmapStep.x=h,this.heatmapStep.y=A;let{colorsList:b,colorsMap:C}=t.aes;if(t.valueType==="continuous"&&b){let x=Da().domain(L2t(b.length,e.meta.valueExtent)).range(b);this.heatmapColorScale={scale:x,getter:k=>x(k)}}if(t.valueType==="discrete"&&C){let x=Object.keys(C).filter(k=>e.meta.uniqueValues.has(k));this.heatmapColorScale={scale:Hl(x,x.map(k=>C[k])).unknown(s9),getter:k=>k?C[k]??s9:s9}}if(t.valueType==="stringSource"&&b){let x=[...e.meta.uniqueValues],k=Hl(x,x.map((_,D)=>b[D%b.length])).unknown(s9);this.heatmapColorScale={scale:k,getter:_=>_?k(_):s9}}this.chartSizes.heatmapWidth=this.heatmapScales.x(e.xKeys[e.xKeys.length-1])+this.heatmapStep.x}updateLegendSize(e,t,n,r,a,i){if(!e.show){this.legend={width:0,height:0,items:[]};return}let o=new Dc("600 14px Arial"),s=16,c=48,f=20,A=24;function h(O,I){return Math.max(...O.map($=>o.getTextWidth(String($))+f),o.getTextWidth(I))}let m=[];[n.nodeColor,n.nodeShape,n.lineColor].filter(RX).map(O=>O.columnName).forEach(O=>{let I=t[O.value];if(I.usedAes.length===0||!I.aesMap)return;let $=O.label??O.value,Q=I.values,ee={};Q.forEach(K=>{ee[K]||(ee[K]={...mP}),I.usedAes.forEach(re=>{var U,G,Z;(re==="dotFill"||re==="lineColor")&&(ee[K].color=((U=I.aesMap[K])==null?void 0:U[re])??Zt),re==="dotShape"&&(ee[K].shape=((G=I.aesMap[K])==null?void 0:G[re])??"21"),re==="dotSize"&&(ee[K].size=((Z=I.aesMap[K])==null?void 0:Z[re])??3)})}),m.push({columnKey:$,data:ee,values:I.values,labels:I.labels})});let g=[],b=0,C=0,x=0,k=Math.min(this.chartSizes.treeHeight,400);if(r&&a){let O=i.valueType,I=r.label??r.value;if(O==="continuous"){let $=this.heatmapColorScale.scale,Q=a2($,a.meta.valueExtent,4),ee={id:"heatmapValue",type:"continuous",width:UX(Q,I),height:k,left:0,top:0,title:I,scale:$,values:Q,labels:{}};g.push(ee),C=ee.height+c,b=ee.width}else{let $=this.heatmapColorScale.scale,Q=d2t($,I),ee=$.domain(),K=ee.length*s,re={id:"heatmapValue",type:"discrete",width:Q,height:K,left:0,top:0,title:I,scale:$,values:ee,labels:{}};g.push(re),C=re.height+c,b=re.width}}if(m.map(({columnKey:O,labels:I,values:$,data:Q})=>{C>k&&(C=0,x+=b+A);let ee=O,K=h($.map(Y=>I[Y]),ee),re=$.length*s;re>k&&(k=re);let U=Hl().domain($).range($.map(Y=>Q[Y])),G=x,Z=C;g.push({id:O,type:"nodes",width:K,height:re,left:G,top:Z,title:ee,scale:U,values:$,labels:I}),b=K,C+=re+c}),$m(n.nodeSize)){C>k&&(C=0,x+=b+A);let{columnName:O,domain:I,range:$}=n.nodeSize,Q=O.label??O.value,ee=Ny(I,$),K=ee.ticks(3),re=ee.tickFormat(3),U=K.reduce((oe,me)=>(oe[String(me)]=re(me),oe),{}),G=h(K.map(oe=>U[oe]),Q),Z=(ee(Math.max(...K))*2+4)*K.length;Z>k&&(k=Z);let Y=x,X=C;g.push({id:O.value,type:"size",width:G,height:Z,left:Y,top:X,title:Q,scale:ee,values:K,labels:U}),b=G,C+=Z+c}let _=x+b+2*yP,D=k;this.legend={width:_,height:D,items:g}}updateChartSizes(e,t,n){let r=n.leaves().length;this.chartSizes.treeWidth=t?e.width/2:e.width;let a=R2t(r,e.scale,e.minCellHeight,e.maxCellHeight)*r;this.chartSizes.treeHeight=a,this.chartSizes.heatmapHeight=a}updateTotalSizes(e){this.chartSizes.totalWidth=this.chartSizes.treeWidth+this.chartSizes.heatmapWidth+this.legend.width+ic.LEFT+ic.RIGHT,e&&(this.chartSizes.totalWidth+=30),this.legend.width>0&&(this.chartSizes.totalWidth+=30),this.chartSizes.totalHeight=Math.max(this.chartSizes.treeHeight,this.legend.height)+ic.TOP+ic.BOTTOM}prepareTableLabels(e){let t=new Dc("bold 14px Arial"),n="…";if(this.heatmapStep.x<12||!e){this.heatmapLabels=[];return}let r=this.heatmapStep.x-4;this.heatmapLabels=e.xKeys.map(a=>{let i=e.meta.xLabels[a],o=t.getTextWidth(i);if(o<r)return i;let s=i,c=s==null?void 0:s.length;for(;o>r&&c>0;)c--,s=(i==null?void 0:i.substring(0,c))+n,o=t.getTextWidth(s);return c>0?s:""})}addLabelsWidthToTreeArea(e,t){if(!t)return;let n=e.leaves(),r=new Dc("bold 14px Manrope"),a=0;n.forEach(i=>{if(!i.data.label)return;let o=r.getTextWidth(i.data.label),s=i.y+o-this.chartSizes.treeWidth+8;s>a&&(a=s)}),this.chartSizes.treeWidth+=a}render(e,t,n,r,a,i,o,s,c,f,A,h,m,g,b,C,x){var I;this.updateChartSizes(e.size,m,t),this.updateHeatmapScales(m,g,e.size),this.updateLegendSize(e.legend,b,f,h,m,g),this.prepareTableLabels(m);let k=r==="top"?[this.chartSizes.treeWidth,this.chartSizes.treeHeight]:[this.chartSizes.treeHeight,this.chartSizes.treeWidth];xB().size(k).separation(()=>1)(t);let _=t;d3t(_,r==="top"?this.chartSizes.treeHeight:this.chartSizes.treeWidth,C==="alignLeavesToLine"),A3t(_),this.addLabelsWidthToTreeArea(_,s),this.updateTotalSizes(m);let D=I2t(f),O=le.jsx(H2t,{chartSizes:this.chartSizes,chartSettings:e,nodes:_.descendants(),links:_.links(),connectionType:n,rootPosition:r,edgeInheritance:a,showNodes:i,showEdges:o,showLeavesLabels:s,showNodesLabels:c,aesGetters:D,labels:A,heatmapData:m,heatmapScales:this.heatmapScales,heatmapStep:this.heatmapStep,heatmapColor:this.heatmapColorScale.getter,heatmapLabels:this.heatmapLabels,legendData:this.legend,onClick:x});this.component=O,(I=this.reactRoot)==null||I.render(O)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},$2t=N2t,ZX=class{constructor(e){Me(this,"type","dendro");Me(this,"chartSettings");Me(this,"mode");Me(this,"leavesMode");Me(this,"id");Me(this,"parentId");Me(this,"height",null);Me(this,"labels");Me(this,"heatmapAnnotation");Me(this,"heatmapAxis");Me(this,"heatmapGroup");Me(this,"heatmapSettings");Me(this,"connectionType","rectangle");Me(this,"edgeInheritance","up");Me(this,"rootPosition","top");Me(this,"showNodes",!0);Me(this,"showEdges",!0);Me(this,"showLeavesLabels",!0);Me(this,"showNodesLabels",!0);Me(this,"aes",{nodeShape:"21",nodeColor:Zt,nodeSize:3,lineShape:"solid",lineColor:Zt});var t,n,r,a,i,o,s,c,f,A;r2t.parse(e),this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(e.facetSettings?400:560),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(e.facetSettings?250:350),scale:((r=e==null?void 0:e.size)==null?void 0:r.scale)??1,minCellWidth:((a=e==null?void 0:e.size)==null?void 0:a.minCellWidth)??a3t,maxCellWidth:((i=e==null?void 0:e.size)==null?void 0:i.maxCellWidth)??i3t,minCellHeight:(o=e==null?void 0:e.size)==null?void 0:o.minCellHeight,maxCellHeight:(s=e==null?void 0:e.size)==null?void 0:s.maxCellHeight},title:{position:"center",show:!0,...e.title,name:((c=e.title)==null?void 0:c.name)??"Dendrogram"},legend:{show:!0,position:"right",...e.legend}},this.mode=e.mode??"normal",this.leavesMode=e.leavesMode??"normal",this.id=e.id,this.parentId=e.parentId,this.height=e.height??null,this.labels=e.labels??this.id,this.heatmapAnnotation=e.heatmapAnnotation??null,this.heatmapAxis=e.heatmapAxis??null,this.heatmapGroup=e.heatmapGroup??[],this.heatmapSettings={valueType:((f=e.heatmapSettings)==null?void 0:f.valueType)??"continuous",aes:{colorsList:["#FFF680","#53D788","#36739D","#4A005C"],...(A=e.heatmapSettings)==null?void 0:A.aes}},this.connectionType=e.connectionType??this.connectionType,this.edgeInheritance=e.edgeInheritance??this.edgeInheritance,this.showNodes=e.showNodes??this.showNodes,this.showEdges=e.showEdges??this.showEdges,this.showLeavesLabels=e.showLeavesLabels??this.showLeavesLabels,this.showNodesLabels=e.showNodesLabels??this.showNodesLabels,this.rootPosition=e.rootPosition??this.rootPosition,this.aes={...this.aes,...e.aes}}};function Q8(e){return typeof e!="object"?!1:"valuesMap"in e}function JX(e,t){let{nodeColor:n,nodeShape:r,lineColor:a}=t,i=[n,r,a].filter(Q8);return Ir.uniqBy(i,o=>o.columnName.value).reduce((o,s)=>{let{columnName:c}=s,f=Ir.uniqBy(e.rows,b=>b[c.value]),A=b=>String(b[c.value]),h=b=>c.valueLabels?String(b[c.valueLabels]):A(b),m=new Set,g=f.reduce((b,C)=>{let x=A(C);return b[x]||(b[x]={}),b},{});return Q8(n)&&c.value===n.columnName.value&&(m.add("dotFill"),f.forEach(b=>{let C=A(b);g[C].dotFill=n.valuesMap[C]})),Q8(r)&&c.value===r.columnName.value&&(m.add("dotShape"),f.forEach(b=>{let C=A(b);g[C].dotShape=r.valuesMap[C]})),Q8(a)&&c.value===a.columnName.value&&(m.add("lineColor"),f.forEach(b=>{let C=A(b);g[C].lineColor=a.valuesMap[C]})),o[c.value]={values:f.map(A).sort(),usedAes:[...m],aesMap:g,labels:f.reduce((b,C)=>(b[A(C)]=h(C),b),{})},o},{})}var F2t=class extends Sg{constructor(t,n,r){super(t,n);Me(this,"settings");Me(this,"onClick",()=>Kx);Me(this,"chartRenderer",new $2t);Me(this,"calculatedData",null);this.settings=new ZX(n),r&&(this.onClick=r[0])}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new ZX(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){if(document){let r=new CustomEvent(pP,{detail:{[t]:n}});document.dispatchEvent(r)}}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var A,h;let{mode:r,id:a,parentId:i,heatmapAnnotation:o,heatmapAxis:s,heatmapGroup:c}=n;function f(m,g){return m.length!==g.length||m.some((b,C)=>b.value!==g[C].value)}return t.mode!==r||t.id.value!==a.value||t.parentId.value!==i.value||((A=t.heatmapAnnotation)==null?void 0:A.value)!==(o==null?void 0:o.value)||((h=t.heatmapAxis)==null?void 0:h.value)!==(s==null?void 0:s.value)||f(t.heatmapGroup,c)}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{mode:t,id:n,parentId:r,aes:a,heatmapAnnotation:i,heatmapAxis:o,heatmapGroup:s,heatmapSettings:c,height:f,labels:A}=this.settings,h=f3t(n.value,r.value,(f==null?void 0:f.value)??null,A.valueLabels??A.value??null,this.data.rows,t==="useAllNodesAsLeaves"),m=s3t(this.data,c.valueType,i,o,s,n,h),g=JX(this.data,a);this.calculatedData={chartSizes:this.chartRenderer.chartSizes,hierarchy:h,heatmapData:m,legendLabels:g}}_updateAesInData(){this.calculatedData&&(this.calculatedData.legendLabels=JX(this.data,this.settings.aes))}_updateChart(){if(!this.calculatedData)return;let{heatmapAnnotation:t,chartSettings:n,connectionType:r,edgeInheritance:a,rootPosition:i,showNodes:o,showEdges:s,showLeavesLabels:c,showNodesLabels:f,aes:A,labels:h,heatmapSettings:m,leavesMode:g}=this.settings;this.chartRenderer.render(n,this.calculatedData.hierarchy,r,i,a,o,s,c,f,A,h,t,this.calculatedData.heatmapData,m,this.calculatedData.legendLabels,g,this.onClick)}};function V2t(e,t,n,r,a,i){let o=-1/0;return{type:"logo",geoms:t.reduce((s,c)=>{let f=c.join("_");return s[f]=[],n.forEach(A=>{let h=0,m={};r.forEach(b=>{let C=a.getRowsByGrouping([...c,A,b]);if(!C.length)return;let x=Sc(C,k=>Number(k[i.value]));m[b]={height:x,key:b},h+=x});let g=h;e.normalize&&r.forEach(b=>{m[b]&&(m[b].height=m[b].height/g*100)}),o=Math.max(o,h),s[f].push({key:`logo_${A}`,valuesMap:m,primaryGrouping:A,boundsY:{min:0,max:e.normalize?g:100}})}),s},{}),meta:{minY:0,maxY:e.normalize?100:o,normalize:e.normalize},aes:e.aes}}var h9={TOP:30,BOTTOM:30},l1=30,O2t=6,m9=20,CP=15,z8=24,i2=25,Q2t=12,qX={fillColor:"white",lineColor:Zt,lineWidth:1,lineShape:"solid",dotSize:3,dotFill:Zt,dotShape:"21"},bP=20,eK=4,ed=4,tK=25,z2t=15,_g=8,Vm=30,U2t=48,j2t=24,o2=16,l2=4,U8=4,j8=20,G2t=16,Qd=16,s2=8,s1={left:["annotations","axis","groups","axisTitle","dendro"],right:["annotations","axis","groups","axisTitle","dendro"],top:["annotations","axis","groups","axisTitle","dendro","facetTitle"],bottom:["annotations","axis","groups","axisTitle","dendro"]},nK={fillColor:"white",lineColor:Zt,lineWidth:1,lineShape:"solid",dotSize:3,dotFill:Zt,dotShape:"21"};function Y2t(e){return`translate(${e},0)`}function W2t(e){return`translate(0,${e})`}var v9=21;function X2t(e,t){if(e==="45deg"){let n=t==="left"?-v9/2:0,r=t==="bottom"?v9/2:-v9/2;return`translate(${n},${r}) rotate(-45)`}return e==="90deg"&&t==="bottom"?`translate(${-v9/2},${ed+v9/2}) rotate(-90)`:t==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function K2t(e,t){return t==="left"||t==="bottom"&&e==="90deg"?"central":e==="center"?"hanging":"auto"}function Z2t(e,t){return t==="left"||t==="bottom"&&e!=="center"?"end":"middle"}var rK=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",labelsPosition:a="center",labels:i={},offset:o=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function s(x,k){return x.bandwidth&&(k=Math.max(0,x.bandwidth()-k*2)/2),x!=null&&x.round()&&(k=Math.round(k)),_=>{let D=x(_);return D===void 0?0:D+k}}let c=e.domain(),f=x=>i[x]??[x],A=Math.max(t,0)+n,h=s(e.copy(),o),m=r==="bottom"?Y2t:W2t,g=r==="left"?-1:1,b={[(r==="left"?"x":"y")+"2"]:g*t},C={[r==="left"?"x":"y"]:g*A};return le.jsx("g",{children:c.map((x,k)=>le.jsxs("g",{className:"tick",transform:m(h(x)+o),children:[le.jsx("line",{stroke:Zt,...b}),le.jsx("g",{transform:X2t(a,r),children:f(x).map((_,D)=>le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:K2t(a,r),textAnchor:Z2t(a,r),dy:20*D,...C,children:_},`${_}_${D}`))})]},k))})};function aK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function J2t({scales:e,orientation:t,bar:n,aes:r}){let a=t==="vertical",i=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,o=e.xSecondary.bandwidth(),s=r.width==="auto"?o*.8:Math.min(o,r.width),c=Math.abs(e.y(n.value)-e.y(0)),f=aK(e,"lineColor",r.lineColor,n),A=aK(e,"fillColor",r.fillColor,n);return le.jsx("g",{transform:a?`translate(${i},0)`:`translate(0, ${i})`,opacity:r.opacity,stroke:f,strokeWidth:r.lineWidth,children:le.jsx("rect",{width:a?s:c,height:a?c:s,x:a?-s/2:e.y(n.boundsY.min),y:a?e.y(n.boundsY.max):-s/2,fill:A})})}function Ki(e){return isNaN(e)?"?":e===0?"0":Math.abs(e)<.01?j5(".1e")(e):j5(".2f")(e)}function iK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function q2t({scales:e,orientation:t,geom:n,aes:r,min:a,max:i,binsCount:o,hasKeyFromColumn:s,sideDistances:c,showTooltips:f,tooltipsContainer:A}){let[h,m]=Vn.useState(null),g=t==="vertical",b=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,C=iK(e,"lineColor",r.lineColor,n),x=iK(e,"fillColor",r.fillColor,n),k=n.bins,_=r.dotSize?r.dotSize:Math.abs(e.y(i)-e.y(a))/o/2;return le.jsx("g",{transform:g?`translate(${b},0)`:`translate(0, ${b})`,stroke:C,fill:x,strokeWidth:r.lineWidth,children:k.map(({x:D,count:O,dots:I})=>le.jsx("g",{transform:g?`translate(0,${e.y(D)})`:`translate(${e.y(D)},0)`,children:I.map(($,Q)=>{let ee=(Q-O/2)*2*_+_,K=g?ee:0,re=g?0:ee;return le.jsxs("g",{children:[le.jsx("circle",{opacity:r.opacity,cx:K,cy:re,r:_,onMouseOver:()=>m($.key),onMouseLeave:()=>m(null)}),f&&le.jsx(oc,{content:s?[$.key,Ki($.value)]:[Ki($.value)],x:(g?b:e.y(D))+K,y:(g?e.y(D):b)+re,sideDistances:c,horizontal:g,offset:_,active:h===$.key,container:A})]},$.key)})},D))})}function td(e=null){switch(e){case null:return"";case"solid":return"";case"dashed":return"6 6";case"dotted":return"1.5 4";case"dotdash":return"1.4 4 8 4";case"longdash":return"10 4";case"twodash":return"3 3 9 3";default:vA(e,`Unknown line shape ${e}`)}}function G8(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function e5t(e,t){return t?[e.id,`${Ki(e.y)}`]:[`${Ki(e.y)}`]}function t5t({scales:e,orientation:t,box:n,aes:r,hasKeyFromColumn:a,sideDistances:i,showTooltips:o,elementsAmount:s,tooltipsContainer:c}){let[f,A]=Vn.useState(!1),[h,m]=Vn.useState(null),g=t==="vertical",b=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,C=e.xSecondary.bandwidth(),x=r.boxWidth==="auto"?C*.8:Math.min(C,r.boxWidth),k=Math.abs(e.y(n.lower)-e.y(n.upper)),_=G8(e,"lineColor",r.lineColor,n),D=G8(e,"fillColor",r.fillColor,n),O=G8(e,"dotShape",r.dotShape,n),I=G8(e,"dotSize",r.dotSize,n),$=Af(O,I,_),Q=Math.abs(e.y.range()[0]-e.y.range()[1]);return le.jsxs("g",{transform:g?`translate(${b},0)`:`translate(0, ${b})`,opacity:r.opacity,stroke:_,strokeWidth:r.lineWidth,strokeDasharray:td(r.lineShape),children:[le.jsx("line",{x1:g?0:e.y(n.min),x2:g?0:e.y(n.lower),y1:g?e.y(n.min):0,y2:g?e.y(n.lower):0}),le.jsx("line",{x1:g?0:e.y(n.upper),x2:g?0:e.y(n.max),y1:g?e.y(n.upper):0,y2:g?e.y(n.max):0}),le.jsx("rect",{width:g?x:k,height:g?k:x,x:g?-x/2:e.y(n.lower),y:g?e.y(n.upper):-x/2,fill:D}),le.jsx("line",{x1:g?-x/2:e.y(n.middle),x2:g?x/2:e.y(n.middle),y1:g?e.y(n.middle):-x/2,y2:g?e.y(n.middle):x/2}),o&&c&&le.jsx("rect",{onMouseOver:()=>A(!0),onMouseLeave:()=>A(!1),width:g?C:Q,x:g?-C/2:0,y:g?0:-C/2,height:g?Q:C,fill:"transparent",stroke:"none"}),r.showOutliers&&n.outliers.map(ee=>le.jsxs("g",{transform:g?`translate(0,${e.y(ee.y)})`:`translate(${e.y(ee.y)},0)`,strokeDasharray:"0",children:[$,o&&c&&le.jsx("circle",{onMouseOver:()=>m(ee.id),onMouseLeave:()=>m(null),r:"15",fill:"transparent",stroke:"none"}),o&&le.jsx(oc,{content:e5t(ee,a),x:g?b:e.y(ee.y),y:g?e.y(ee.y):b,sideDistances:i,horizontal:!0,active:h===ee.id,container:c})]},ee.id)),o&&le.jsx(oc,{content:[`Max = ${Ki(n.max)}`,`Upper = ${Ki(n.upper)}`,`Median = ${Ki(n.middle)}`,`Lower = ${Ki(n.lower)}`,`Min = ${Ki(n.min)}`],x:g?b:e.y(n.middle),y:g?e.y(n.middle):b,sideDistances:i,horizontal:g,active:f,offset:s>1?C/2:C/4,container:c})]})}function EP(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function n5t(e,t,n){return n?[t,`${Ki(e)}`]:[`${Ki(e)}`]}function r5t({scales:e,orientation:t,geom:n,aes:r,hasKeyFromColumn:a,sideDistances:i,showTooltips:o,tooltipsContainer:s}){let[c,f]=Vn.useState(null),A=t==="vertical",h=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,m=e.xSecondary.bandwidth()*r.jitter,g=_=>(1-_*2)*(m/2),b=EP(e,"lineColor",r.lineColor,n),C=EP(e,"dotFill",r.dotFill,n),x=EP(e,"dotShape",r.dotShape,n),k=Af(x,r.dotSize,C);return le.jsx("g",{transform:A?`translate(${h},0)`:`translate(0, ${h})`,stroke:b,children:n.values.map(({y:_,jitter:D,id:O})=>le.jsxs("g",{opacity:r.opacity,transform:A?`translate(${g(D)},${e.y(_)})`:`translate(${e.y(_)},${g(D)})`,children:[k,o&&s&&le.jsx("circle",{onMouseOver:()=>f(O),onMouseLeave:()=>f(null),r:"4",fill:"transparent",stroke:"none"}),o&&le.jsx(oc,{content:n5t(_,O,a),x:h+g(D),y:e.y(_),active:c===O,sideDistances:i,container:s})]},O))})}function xP(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function a5t({scales:e,orientation:t,errorBar:n,aes:r,sideDistances:a,showTooltips:i,tooltipsContainer:o}){let[s,c]=Vn.useState(!1),f=t==="vertical",A=xP(e,"lineColor",r.lineColor,n),h=xP(e,"fillColor",r.fillColor,n),m=xP(e,"dotShape",r.dotShape,n),g=(e.xPrimary(n.primaryGrouping)??0)+e.xPrimary.bandwidth()/2,b=r.width==="auto"?e.xPrimary.bandwidth()*.2:r.width,C=e.y(n.min),x=e.y(n.max),k=e.y(n.value),_=Af(m,r.dotSize,h);return le.jsxs("g",{opacity:r.opacity,stroke:A,fill:"none",transform:f?`translate(${g},0)`:`translate(0,${g})`,strokeWidth:r.lineWidth,children:[le.jsx("line",{x1:f?0:C,x2:f?0:x,y1:f?C:0,y2:f?x:0}),le.jsx("line",{x1:f?-b/2:C,x2:f?b/2:C,y1:f?C:-b/2,y2:f?C:b/2}),le.jsx("line",{x1:f?-b/2:x,x2:f?b/2:x,y1:f?x:-b/2,y2:f?x:b/2}),r.showDots&&le.jsxs("g",{transform:f?`translate(0,${k})`:`translate(${k},0)`,children:[_,i&&o&&le.jsx("circle",{onMouseOver:()=>c(!0),onMouseLeave:()=>c(!1),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[Ki(n.value)],x:f?g:k,y:f?k:g,sideDistances:a,horizontal:!0,active:s,container:o})]})]})}function Y8(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")throw new Error("Line cannot have aesthetics by primary grouping");if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.key)[t]}return n}function i5t(e,t,n){let r=n.xPrimary.bandwidth()/2;return t.map(a=>[(n.xPrimary(a)??0)+r,n.y(e[a]),a,e[a]])}function o5t({scales:e,orientation:t,line:n,aes:r,sideDistances:a,showTooltips:i,secondaryGrouping:o,tooltipsContainer:s}){let[c,f]=Vn.useState(null),A=t==="vertical",h=Y8(e,"lineColor",r.lineColor,n),m=Y8(e,"dotFill",r.fillColor,n),g=Y8(e,"lineShape",r.lineShape,n),b=Y8(e,"dotShape",r.dotShape,n),C=i5t(n.dots,e.xPrimary.domain(),e),x=Af(b,r.dotSize,m);return le.jsxs("g",{opacity:r.opacity,stroke:h,strokeDasharray:td(g),strokeWidth:r.lineWidth,children:[le.jsx("polyline",{points:C.map(([k,_])=>A?[k,_]:[_,k]).join(" "),stroke:h,fill:"none"},n.key),r.dotShape!==null&&le.jsx("g",{children:C.map(([k,_,D,O])=>le.jsxs("g",{transform:A?`translate(${k},${_})`:`translate(${_},${k})`,strokeDasharray:"none",stroke:"none",children:[x,i&&s&&le.jsx("circle",{onMouseOver:()=>f(D),onMouseLeave:()=>f(null),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[o.valueLabels[n.key],Ki(O)],x:A?k:_,y:A?_:k,sideDistances:a,horizontal:!0,active:c===D,container:s})]},D))})]})}var l5t={A:rr.A,B:rr.B,C:rr.C,D:rr.D,E:rr.E,F:rr.F,G:rr.G,H:rr.H,I:rr.I,J:rr.J,K:rr.K,L:rr.L,M:rr.M,N:rr.N,O:rr.O,P:rr.P,Q:rr.Q,R:rr.R,S:rr.S,T:rr.T,U:rr.U,V:rr.V,W:rr.W,X:rr.X,Y:rr.Y,Z:rr.Z,a:rr.LC_a,b:rr.LC_b,c:rr.LC_c,d:rr.LC_d,e:rr.LC_e,f:rr.LC_f,g:rr.LC_g,h:rr.LC_h,i:rr.LC_i,j:rr.LC_j,k:rr.LC_k,l:rr.LC_l,m:rr.LC_m,n:rr.LC_n,o:rr.LC_o,p:rr.LC_p,q:rr.LC_q,r:rr.LC_r,s:rr.LC_s,t:rr.LC_t,u:rr.LC_u,v:rr.LC_v,w:rr.LC_w,x:rr.LC_x,y:rr.LC_y,z:rr.LC_z,N0:rr.N0,N1:rr.N1,N2:rr.N2,N3:rr.N3,N4:rr.N4,N5:rr.N5,N6:rr.N6,N7:rr.N7,N8:rr.N8,N9:rr.N9};function s5t({scales:e,orientation:t,geom:n,aes:r,sideDistances:a,showTooltips:i,elementsAmount:o,tooltipsContainer:s,normalize:c}){let[f,A]=Vn.useState(null),h=t==="vertical",m=e.xPrimary.bandwidth(),g=(e.xPrimary(n.primaryGrouping)??0)+m/2,b=r.width==="auto"?m*.9:Math.min(m,r.width),C=[...e.xSecondary.domain()].filter(_=>n.valuesMap[_]).sort((_,D)=>{let O=n.valuesMap[_],I=n.valuesMap[D];return O.height-I.height}),x={},k=0;return C.forEach(_=>{if(!n.valuesMap[_])return;let D=n.valuesMap[_].height;x[_]={y1:k,y2:k+D},k+=D}),le.jsx("g",{transform:h?`translate(${g},0)`:`translate(0, ${g})`,opacity:r.opacity,children:C.map(_=>{if(!n.valuesMap[_])return null;let{y1:D,y2:O}=x[_],I=e.y(D),$=e.y(O),Q=Math.abs(I-$),ee=typeof r.fillColor=="string"?r.fillColor:r.fillColor[_],K=h?-b/2:Math.min(I,$),re=h?Math.min(I,$):-b/2,U=l5t[_];if(U)return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${K},${re})`,children:le.jsx("g",{transform:h?`scale(${b/100},${Q/100})`:`scale(${Q/100},${b/100})`,fill:ee,onMouseOver:()=>A(_),onMouseLeave:()=>A(null),children:le.jsx(U,{})})}),i&&le.jsx(oc,{content:[_,Ki(n.valuesMap[_].height)+(c?"%":"")],x:h?g:(I+$)/2,y:h?(I+$)/2:g,sideDistances:a,horizontal:h,offset:o>1?m/2:m/4,active:f===_,container:s})]},_)})})}function u2(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r)[t]}return n}function u5t({scales:e,orientation:t,geom:n,aes:r,sideDistances:a,showTooltips:i,tooltipsContainer:o}){let[s,c]=Vn.useState(null),f=t==="vertical",A=u2(e,"lineColor",r.lineColor,n.id),h=u2(e,"lineShape",r.lineShape,n.id),m=u2(e,"fillColor",r.dotFill,n.key1),g=u2(e,"dotShape",r.dotShape,n.key1),b=u2(e,"fillColor",r.dotFill,n.key2),C=u2(e,"dotShape",r.dotShape,n.key2),x=Af(g,r.dotSize,m),k=Af(C,r.dotSize,b);function _(D){return n.grouping==="primary"?(e.xPrimary(D)??0)+e.xPrimary.bandwidth()/2:(e.xPrimary(n.id)??0)+(e.xSecondary(D)??0)+e.xSecondary.bandwidth()/2}return le.jsx("g",{opacity:r.opacity,children:n.pairs.map(D=>{let O=f?_(n.key1):e.y(D.key1.value),I=f?_(n.key2):e.y(D.key2.value),$=f?e.y(D.key1.value):_(n.key1),Q=f?e.y(D.key2.value):_(n.key2);return le.jsxs("g",{children:[le.jsx("line",{x1:O,y1:$,x2:I,y2:Q,stroke:A,strokeDasharray:td(h),strokeWidth:r.lineWidth,fill:"none"}),le.jsxs("g",{transform:`translate(${O},${$})`,children:[x,i&&o&&le.jsx("circle",{onMouseOver:()=>c(D.key1.id),onMouseLeave:()=>c(null),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[D.id,Ki(D.key1.value)],x:O,y:$,sideDistances:a,horizontal:!0,active:s===D.key1.id,container:o})]}),le.jsxs("g",{transform:`translate(${I},${Q})`,children:[k,i&&o&&le.jsx("circle",{onMouseOver:()=>c(D.key2.id),onMouseLeave:()=>c(null),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[D.id,Ki(D.key2.value)],x:I,y:Q,sideDistances:a,horizontal:!0,active:s===D.key2.id,container:o})]})]},D.id)})})}function oK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function c5t(e,t,n){return n?[t,`${Ki(e)}`]:[`${Ki(e)}`]}function f5t({scales:e,orientation:t,geom:n,aes:r,hasKeyFromColumn:a,sideDistances:i,showTooltips:o,tooltipsContainer:s}){let[c,f]=Vn.useState(null),A=t==="vertical",h=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,m=e.xSecondary.bandwidth(),g=r.width==="auto"?m*.8:Math.min(m,r.width),b=_=>(1-_*2)*(g/2),C=oK(e,"dotFill",r.dotFill,n),x=oK(e,"dotShape",r.dotShape,n),k=Af(x,r.dotSize,C);return le.jsx("g",{transform:A?`translate(${h},0)`:`translate(0, ${h})`,children:n.points.map(({x:_,y:D,jitter:O,id:I})=>{let $=A?D*b(O):e.y(_),Q=A?e.y(_):D*b(O);return le.jsxs("g",{opacity:r.opacity,transform:`translate(${$},${Q})`,children:[k,o&&s&&le.jsx("circle",{onMouseOver:()=>f(I),onMouseLeave:()=>f(null),r:"4",fill:"transparent",stroke:"none"}),o&&le.jsx(oc,{content:c5t(D,I,a),x:h+$,y:Q,active:c===I,sideDistances:i,container:s})]},I)})})}function lK(e,t,n,r,a){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(a)[t]}return n}function d5t({scales:e,orientation:t,geom:n,aes:r,sideDistances:a,showTooltips:i,elementsAmount:o,tooltipsContainer:s,normalize:c,secondaryGrouping:f}){let[A,h]=Vn.useState(null),m=t==="vertical",g=e.xPrimary.bandwidth(),b=(e.xPrimary(n.primaryGrouping)??0)+g/2,C=r.width==="auto"?g*.8:Math.min(g,r.width),x=e.xSecondary.domain().reverse(),k={},_=0;return x.forEach(D=>{if(!n.valuesMap[D])return;let O=n.valuesMap[D].height;k[D]={y1:_,y2:_+O},_+=O}),le.jsx("g",{transform:m?`translate(${b},0)`:`translate(0, ${b})`,opacity:r.opacity,strokeWidth:r.lineWidth,children:x.map(D=>{if(!n.valuesMap[D])return null;let{y1:O,y2:I}=k[D],$=e.y(O),Q=e.y(I),ee=Math.abs($-Q),K=lK(e,"lineColor",r.lineColor,n.primaryGrouping,D),re=lK(e,"fillColor",r.fillColor,n.primaryGrouping,D);return le.jsxs("g",{children:[le.jsx("rect",{width:m?C:ee,height:m?ee:C,x:m?-C/2:Math.min($,Q),y:m?Math.min($,Q):-C/2,fill:re,stroke:K,onMouseOver:()=>h(D),onMouseLeave:()=>h(null)}),i&&le.jsx(oc,{content:[f.valueLabels[D],Ki(n.valuesMap[D].height)+(c?"%":"")],x:m?b:($+Q)/2,y:m?($+Q)/2:b,sideDistances:a,horizontal:m,offset:o>1?g/2:g/4,active:A===D,container:s})]},D)})})}function sK(e,t,n,r){let a=t.reduce((i,o,s)=>(i[o]=s,i),{});return e.filter(([,i])=>r?i<=n.one:!0).sort(([[i,o]],[[s,c]])=>i!==o?a[o]-a[i]:a[c]-a[s])}function A5t(e,t){let n=t.reduce((a,i,o)=>(a[i]=o,a),{}),r=[];return e.map(([[a,i]])=>{let o=n[a],s=n[i];for(let c=0;c<r.length;c++)if(r[c]<o)return r[c]=s,c;return r.push(s),r.length-1})}function uK(e,t,n,r){let a=t.reduce((o,s,c)=>(o[s]=c,o),{}),i=[];return sK(e,t,n,!r).forEach(([[o,s]])=>{let c=a[o],f=a[s];for(let A=0;A<i.length;A++)if(i[A]<c){i[A]=f;return}i.push(f)}),i.length}var p5t={ttest:"TTest",anova:"ANOVA",kruskalWallis:"Kruskal-Wallis",wilcoxon:"Wilcoxon"};function h5t(e,t){return e<=t.three?"***":e<=t.two?"**":e<=t.one?"*":"ns"}function SP(e,t,n,r){return!r&&e>n.one?"":t==="significance"?h5t(e,n):Ki(e)}var c2=18,BP=12;function m5t({orientation:e,scales:t,testMethod:n,values:r,statType:a,format:i,ns:o,significanceLevels:s,yShift:c}){if(!r.length)return null;let f=k=>(t.xPrimary(k)??0)+t.xPrimary.bandwidth()/2,A=e==="vertical",h=Math.abs(t.xPrimary.range()[1]-t.xPrimary.range()[0]),m=Math.abs(t.y.range()[1]-t.y.range()[0]),g=t.xPrimary.domain(),b=a==="pairwise"?sK(r,g,s,!o):r,C=a==="pairwise"?A5t(b,g):[],x=Math.max(...C);return le.jsxs("g",{fontSize:"14px",transform:A?`translate(0,${c})`:`translate(${m-c},0)`,children:[a==="overall"&&le.jsx("text",{x:A?h/2:-c2,y:A?c2:h/2,transform:A?"":`rotate(90,${-c2},${h/2})`,textAnchor:"middle",children:`${p5t[n]}, p = ${SP(r[0][1],"pValue",s,!0)}`}),a==="referenceGroup"&&le.jsx("g",{children:r.map(([[k],_])=>le.jsx("text",{x:A?f(k):-c2,y:A?c2:f(k),transform:A?"":`rotate(90,${-c2},${f(k)})`,textAnchor:"middle",children:SP(_,i,s,o)},k))}),a==="pairwise"&&le.jsx("g",{children:b.map(([[k,_],D],O)=>{let I=f(k),$=f(_),Q=(I+$)/2;return le.jsxs("g",{transform:A?`translate(0,${(x-C[O])*i2})`:`translate(${-(x-C[O])*i2},0)`,children:[le.jsx("text",{x:A?Q:-BP,y:A?BP:Q,transform:A?"":`rotate(90,${-BP},${Q})`,textAnchor:"middle",children:SP(D,i,s,o)}),le.jsx("path",{d:A?`M ${I},21 v-4 h ${$-I} v4`:`M -21,${I} h 4 v ${$-I} h-4`,fill:"none",stroke:Zt})]},`${k}_${_}`)})})]})}function v5t(e){return`translate(${e},0)`}function g5t(e){return`translate(0,${e})`}function y5t(e){return e==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function w5t(e){return e==="bottom"?"hanging":"central"}function C5t(e){return e==="bottom"?"middle":"end"}var cK=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",onlyPositive:a=!1,offset:i=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function o(_){return D=>{let O=_(D);return O===void 0?0:+O}}let s=Math.abs(e.range()[0]-e.range()[1]),c=Math.min(Math.floor(s/tK),10),f=e.ticks(c).filter(_=>a&&_>=0||!a),A=f.some(_=>Math.abs(_)<1e-4&&_!==0||_>1e4)?",e":",f",h=_=>e.tickFormat(c,A)(_),m=Math.max(t,0)+n,g=o(e.copy()),b=r==="bottom"?v5t:g5t,C=r==="left"?-1:1,x={[(r==="left"?"x":"y")+"2"]:C*t},k={[r==="left"?"x":"y"]:C*m};return le.jsx("g",{children:f.map((_,D)=>le.jsxs("g",{className:"tick",transform:b(g(_)+i),children:[le.jsx("line",{stroke:Zt,...x}),le.jsx("g",{transform:y5t(r),children:le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:w5t(r),textAnchor:C5t(r),...k,children:h(_)})})]},D))})};function fK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function b5t({scales:e,orientation:t,violin:n,aes:r,maxViolinDensity:a,showTooltips:i,sideDistances:o,elementsAmount:s,tooltipsContainer:c}){let[f,A]=Vn.useState(!1),h=t==="vertical",m=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,g=e.xSecondary.bandwidth(),b=r.width==="auto"?g*.8:Math.min(g,r.width),C=fK(e,"lineColor",r.lineColor,n),x=fK(e,"fillColor",r.fillColor,n),k=n.getArea(t,e.y,b,a)??"",_=n.getLine(t,e.y,b,a)??"",D=Math.abs(e.y.range()[0]-e.y.range()[1]);return le.jsxs("g",{transform:h?`translate(${m},0)`:`translate(0, ${m})`,opacity:r.opacity,stroke:C,fill:x,strokeWidth:r.lineWidth,strokeDasharray:td(r.lineShape),children:[le.jsx("clipPath",{id:`violin_${n.key}`,children:le.jsx("path",{d:k})}),le.jsx("path",{d:k,stroke:"none"}),r.showQuartiles&&le.jsxs("g",{"clip-path":`url(#violin_${n.key})`,strokeWidth:r.lineWidth,stroke:C,children:[le.jsx("line",{x1:h?-b/2:e.y(n.quartiles.q1),x2:h?b/2:e.y(n.quartiles.q1),y1:h?e.y(n.quartiles.q1):-b/2,y2:h?e.y(n.quartiles.q1):b/2,strokeDasharray:td(r.quartilesLineStyle)}),le.jsx("line",{x1:h?-b/2:e.y(n.quartiles.q2),x2:h?b/2:e.y(n.quartiles.q2),y1:h?e.y(n.quartiles.q2):-b/2,y2:h?e.y(n.quartiles.q2):b/2,strokeDasharray:td(r.medianLineStyle)}),le.jsx("line",{x1:h?-b/2:e.y(n.quartiles.q3),x2:h?b/2:e.y(n.quartiles.q3),y1:h?e.y(n.quartiles.q3):-b/2,y2:h?e.y(n.quartiles.q3):b/2,strokeDasharray:td(r.quartilesLineStyle)})]}),le.jsx("path",{d:_,fill:"none"}),i&&c&&le.jsx("rect",{onMouseOver:()=>A(!0),onMouseLeave:()=>A(!1),width:h?g:D,x:h?-g/2:0,y:h?0:-g/2,height:h?D:g,fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[`Quartile 3 = ${Ki(n.quartiles.q3)}`,`Median = ${Ki(n.quartiles.q2)}`,`Quartile 1 = ${Ki(n.quartiles.q1)}`],x:h?m:e.y(n.quartiles.q2),y:h?e.y(n.quartiles.q2):m,sideDistances:o,horizontal:h,active:f,offset:s>1?b/2:b/4,container:c})]})}var E5t=1;function x5t({scaleX:e,scaleY:t,orientation:n,width:r,height:a,axisX:i,axisY:o,frameType:s}){let[c,f]=Vn.useState(e.domain()),A=Math.abs(t.range()[0]-t.range()[1]),h=Math.min(Math.floor(A/tK),10),[m,g]=Vn.useState(t.ticks(h)),b=e.bandwidth()/2,C=_=>(e(_)??0)+b,x=_=>t(_),k=n==="vertical";return Vn.useEffect(()=>{let _=e.domain(),D=t.ticks(h);f(_),g(D)},[e,t]),le.jsxs("g",{stroke:Jf,children:[i.showGrid&&c.map(_=>{let D=C(_)+(i.linesBetweenCategories?b:0);return le.jsx("line",{x1:k?D:0,x2:k?D:r,y1:k?0:D,y2:k?a:D},`x_${_}`)}),o.showGrid&&m.map(_=>{let D=x(_);return le.jsx("line",{x1:k?0:D,x2:k?r:D,y1:k?D:0,y2:k?D:a},`y_${_}`)}),s!=="empty"&&le.jsxs("g",{strokeWidth:E5t,children:[(i.showGrid||s!=="left")&&le.jsx("line",{stroke:s==="left"?Jf:Zt,x1:"0",x2:r,y1:a,y2:a}),(i.showGrid||s!=="bottom")&&le.jsx("line",{stroke:s==="bottom"?Jf:Zt,x1:"0",x2:"0",y1:"0",y2:a}),(i.showGrid||s==="full")&&le.jsx("line",{stroke:s==="full"?Zt:Jf,x1:r,x2:r,y1:"0",y2:a}),(o.showGrid||s==="full")&&le.jsx("line",{stroke:s==="full"?Zt:Jf,x1:"0",x2:r,y1:"0",y2:"0"})]})]})}function S5t(e,t,n){if(!e.length)return[];let r=[0];for(let a=0;a<e.length-1;a++){let i=e[a];if(i.meta.statType==="pairwise"){let o=uK(i.values[n],t,i.meta.significanceLevels,i.meta.ns);r.push(r[r.length-1]+i2*o)}else r.push(r[r.length-1]+i2)}return r}function dK(e){return typeof e=="string"?e:e.value}function B5t({facetSettings:e,facetTitle:t,dimensions:n,scales:r,orientation:a,layersData:i,statsData:o,facetKey:s,xAxis:c,yAxis:f,frameType:A,tooltips:h,tooltipsContainer:m,keyColumn:g,chartSizes:b,margins:C,xLabels:x,onlyPositive:k,secondaryGrouping:_}){let D=a==="vertical",O=S5t(o,r.xPrimary.domain(),s),I=c.showTicks?eK:0,$=f.showTicks?eK:0,Q=dK(c.title),ee=dK(f.title),K=n.chartEdgeSides.includes("left")||D&&!(e!=null&&e.sharedY)||!D&&!(e!=null&&e.sharedX),re=n.chartEdgeSides.includes("bottom")||D&&!(e!=null&&e.sharedX)||!D&&!(e!=null&&e.sharedY),U=n.chartEdgeSides.includes("left"),G=n.chartEdgeSides.includes("bottom"),{width:Z,height:Y}=n.inner,{left:X,top:oe,padding:me}=n,ae={left:C.left+X+me.left,right:b.totalWidth-(C.left+X+me.left),top:C.top+oe+me.top,bottom:b.totalHeight-(C.top+oe+me.top)},ye=`translate(${X+me.left},${oe+me.top})`,Ce=!1;return le.jsxs("g",{transform:ye,children:[Ce,t.length&&le.jsxs("g",{children:[A==="full"&&le.jsx("rect",{x:"0",y:-me.top,height:me.top,width:Z,fill:"#F7F8FA",stroke:Zt}),t.map((ce,ge)=>{let ze=t.length,Ne=(me.top-m9*ze)/2;return le.jsx("text",{fontSize:"14px",fontWeight:"500",fill:Zt,x:Z/2,dy:Ne+m9/2-me.top,y:ge*m9,textAnchor:"middle",dominantBaseline:"central",children:ce},ge)})]}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[G&&le.jsx("text",{x:Z/2,y:Y+me.bottom-l1/2,children:D?Q:ee}),G&&Ce&&le.jsx("rect",{x:"0",y:Y+me.bottom-l1,width:Z,height:l1,fill:"none",stroke:"black"}),U&&le.jsx("text",{x:-me.left+l1/2,y:Y/2,transform:`rotate(-90,${-me.left+l1/2},${Y/2})`,children:D?ee:Q}),U&&Ce&&le.jsx("rect",{x:-me.left,y:"0",width:l1,height:Y,fill:"none",stroke:"black"})]}),le.jsx(x5t,{orientation:a,width:Z,height:Y,scaleX:r.xPrimary,scaleY:r.y,axisX:c,axisY:f,frameType:A}),re&&le.jsx("g",{transform:`translate(0,${Y})`,children:D?le.jsx(rK,{scale:r.xPrimary,orient:"bottom",labelsPosition:c.labelsPosition,tickSize:I,labels:x}):le.jsx(cK,{scale:r.y,onlyPositive:k,orient:"bottom",tickSize:$})}),K&&le.jsx("g",{children:D?le.jsx(cK,{scale:r.y,onlyPositive:k,orient:"left",tickSize:$}):le.jsx(rK,{scale:r.xPrimary,orient:"left",labelsPosition:c.labelsPosition,tickSize:I,labels:x})}),le.jsxs("g",{children:[i.map(ce=>le.jsxs("g",{children:[ce.type==="box"&&ce.geoms[s].map(ge=>le.jsx(t5t,{box:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,aes:ce.aes,hasKeyFromColumn:g!==null,sideDistances:ae,showTooltips:h.box.show,tooltipsContainer:m},ge.key)),ce.type==="violin"&&ce.geoms[s].map(ge=>le.jsx(b5t,{violin:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,maxViolinDensity:ce.meta.maxDensity,aes:ce.aes,sideDistances:ae,showTooltips:h.violin.show,tooltipsContainer:m},ge.key)),ce.type==="dot"&&ce.geoms[s].map(ge=>le.jsx(r5t,{geom:ge,scales:r,orientation:a,aes:ce.aes,hasKeyFromColumn:g!==null,sideDistances:ae,showTooltips:h.dot.show,tooltipsContainer:m},ge.key)),ce.type==="line"&&ce.geoms[s].map(ge=>le.jsx(o5t,{line:ge,scales:r,orientation:a,sideDistances:ae,aes:ce.aes,showTooltips:h.line.show,secondaryGrouping:_,tooltipsContainer:m},ge.key)),ce.type==="errorbar"&&ce.geoms[s].map(ge=>le.jsx(a5t,{errorBar:ge,scales:r,orientation:a,aes:ce.aes,sideDistances:ae,showTooltips:h.errorBar.show,tooltipsContainer:m},ge.key)),ce.type==="bar"&&ce.geoms[s].map(ge=>le.jsx(J2t,{bar:ge,scales:r,orientation:a,aes:ce.aes},ge.key)),ce.type==="stackedBar"&&ce.geoms[s].map(ge=>le.jsx(d5t,{geom:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,aes:ce.aes,normalize:ce.meta.normalize,sideDistances:ae,showTooltips:h.stackedBar.show,secondaryGrouping:_,tooltipsContainer:m},ge.key)),ce.type==="binnedDots"&&ce.geoms[s].map(ge=>le.jsx(q2t,{geom:ge,scales:r,orientation:a,aes:ce.aes,binsCount:ce.meta.binsCount,min:ce.meta.minY,max:ce.meta.maxY,hasKeyFromColumn:ce.meta.hasKeyFromColumn,sideDistances:ae,showTooltips:h.stackedBar.show,tooltipsContainer:m},ge.key)),ce.type==="pairedPoints"&&ce.geoms[s].map(ge=>le.jsx(u5t,{geom:ge,scales:r,orientation:a,sideDistances:ae,aes:ce.aes,showTooltips:h.pairedPoints.show,tooltipsContainer:m},ge.id)),ce.type==="sina"&&ce.geoms[s].map(ge=>le.jsx(f5t,{geom:ge,scales:r,orientation:a,sideDistances:ae,aes:ce.aes,hasKeyFromColumn:g!==null,showTooltips:!1,tooltipsContainer:m},ge.key)),ce.type==="logo"&&ce.geoms[s].map(ge=>le.jsx(s5t,{geom:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,aes:ce.aes,normalize:ce.meta.normalize,sideDistances:ae,showTooltips:!0,tooltipsContainer:m},ge.key))]},ce.type)),o.map((ce,ge)=>le.jsx(m5t,{yShift:O[ge],scales:r,orientation:a,statType:ce.meta.statType,values:ce.values[s],testMethod:ce.meta.testMethod,format:ce.meta.format,ns:ce.meta.ns,significanceLevels:ce.meta.significanceLevels},`${ce.meta.statType}_${ce.meta.testMethod}`))]})]})}var f2=class extends gb.Component{constructor(e){super(e),this.state={hasError:!1,message:""}}static getDerivedStateFromError(e){return{hasError:!0,message:e.message}}componentDidUpdate(e){e.dataId!==this.props.dataId&&this.setState({hasError:!1,message:"error.message"})}componentDidCatch(e,t){console.log(t)}render(){return this.state.hasError?le.jsx(Fm,{message:this.state.message}):this.props.children}};function k5t(e,t,n,r){return e==="left"?n:e==="right"?t-r:(t-(n+r))/2+n}function T5t(e){return e==="left"?"start":e==="right"?"end":"middle"}function d2({show:e,position:t,title:n,chartsWidth:r,leftPadding:a,rightPadding:i}){return e?le.jsx("g",{children:n.map((o,s)=>le.jsx("text",{x:k5t(t,r,a,i),textAnchor:T5t(t),y:-(n.length-s-1)*24-24-24/2,fontSize:"20px",fontFamily:"Manrope",fontWeight:"500",dominantBaseline:"central",children:o},`${o}_${s}`))}):null}var Hc=12,g9=-12,AK=14;function _5t(e=null){return e==="dashed"?"M1 11.25H6V12.75H1V11.25ZM9.5 11.25H14.5V12.75H9.5V11.25ZM18 11.25H23V12.75H18V11.25Z":e==="dotted"?"M2.75 11.25H1.25V12.75H2.75V11.25Z M11.25 11.25H12.75V12.75H11.25V11.25Z M22.75 11.25H21.25V12.75H22.75V11.25Z M7.75 11.25H6.25V12.75H7.75V11.25Z M16.25 11.25H17.75V12.75H16.25V11.25Z":e==="longdash"?"M1 11.25H10V12.75H1V11.25ZM14 11.25H23V12.75H14V11.25Z":e==="dotdash"?"M1 11.25H2.5V12.75H1V11.25ZM17 12.75H7V11.25H17V12.75ZM21.5 12.75V11.25H23V12.75H21.5Z":e==="twodash"?"M1 11.25H4V12.75H1V11.25ZM17.0261 12.75H7V11.25H17.0261V12.75ZM20 12.75V11.25H23V12.75H20Z":"M1 11.25H23V12.75H1V11.25Z"}var P5t=3,M5t=24;function D5t({aes:e,label:t,usedAes:n}){let r=n.lineShape,a=n.dotShape,i=n.fillColor||n.lineColor&&!n.lineShape||n.dotFill&&!n.dotShape,o=a?Af(e.dotShape??"21",P5t,i?Zt:e.dotFill??Zt):null,s=(a&&r?2*Hc:0)-6,c=r?s+M5t+8:Hc+8;return le.jsxs("g",{children:[i&&le.jsx("rect",{width:Hc,height:Hc,stroke:e.fillColor??e.lineColor,fill:e.fillColor??e.lineColor,rx:"1",ry:"1"}),a&&le.jsx("g",{transform:`translate(${Hc/2},${Hc/2})`,children:o}),r&&le.jsx("path",{transform:`translate(${s},-5)`,fillRule:"evenodd",clipRule:"evenodd",d:_5t(e.lineShape),fill:e.lineColor}),le.jsx("text",{x:c,y:Hc/2,dominantBaseline:"central",fontWeight:500,children:t})]})}function H5t({aes:e,label:t}){let n=Af(e.shape,e.size,e.color);return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${Hc/2},${Hc/2})`,children:n}),le.jsx("text",{x:Hc+8,y:Hc/2,dominantBaseline:"central",fontWeight:500,children:t})]})}function y9({legendData:e}){let t=e.items.filter(n=>n.type==="continuous");return le.jsxs("g",{children:[le.jsx("defs",{children:t.map(n=>le.jsx("linearGradient",{id:n.id,gradientTransform:"rotate(90)",children:n.scale.domain().reverse().map(r=>{let a=n.scale.domain(),i=a[a.length-1]-a[0],o=i>0?100-(r-a[0])/i*100:0;return le.jsx("stop",{offset:`${o}%`,stopColor:n.scale(r)},r)})},n.id))}),e.items.map(n=>{if(n.type==="continuous")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:g9,children:n.title}),le.jsx("rect",{x:"0",y:"0",width:AK,height:n.height,stroke:Zt,fill:`url(#${n.id})`}),le.jsx("g",{transform:`translate(${AK},0)`,children:n.values.map(r=>{let a=n.tickPositionScale(r)??0;return le.jsxs("g",{transform:`translate(0,${a})`,children:[le.jsx("line",{x1:"0",x2:-4,stroke:Zt}),le.jsx("text",{x:8,y:4,children:r})]},r)})}),!1]},n.id);if(n.type==="discreteColor")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:g9,children:n.title}),n.values.map((r,a)=>le.jsxs("g",{transform:`translate(0, ${a*(Hc+4)})`,children:[le.jsx("rect",{x:"0",y:"0",width:Hc,height:Hc,fill:n.scale(r),rx:"1",ry:"1",stroke:Zt}),le.jsx("text",{x:Hc+8,y:10,children:r})]},r)),!1]},n.id);if(n.type==="discreteMulti")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:600,y:g9,children:n.title}),n.values.map((r,a)=>le.jsx("g",{transform:`translate(0, ${a*(Hc+4)})`,children:le.jsx(D5t,{aes:n.scale(r),label:n.labels[r],usedAes:n.usedAes})},r)),!1]},n.id);if(n.type==="dots")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:g9,children:n.title}),n.values.map((r,a)=>le.jsx("g",{transform:`translate(0, ${a*(Hc+4)})`,children:le.jsx(H5t,{aes:n.scale(r),label:n.labels[r]})},r)),!1]},n.id);if(n.type==="size"){let r=n.height/n.values.length;return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:g9,children:n.title}),n.values.map((a,i)=>{let o=n.scale(a);return le.jsxs("g",{transform:`translate(0, ${i*r})`,children:[le.jsx("circle",{r:o,cx:r/2,cy:r/2,fill:Zt}),le.jsx("text",{x:r+4,y:r/2,alignmentBaseline:"central",children:n.labels[a]})]},a)}),!1]},n.id)}})]})}function I5t({settingsId:e,chartSettings:t,chartSizes:n,chartsDimensions:r,facetKeys:a,facetTitles:i,facetSettings:o,scales:s,layersData:c,statsData:f,legendData:A,margins:h,columnsCount:m,keyColumn:g,xLabels:b,chartTitle:C,onlyPositive:x,secondaryGrouping:k}){let[_,D]=Vn.useState(),{orientation:O,xAxis:I,yAxis:$,title:Q,legend:ee,frame:K}=t,re=r[a[0]].padding,U=r[a[m-1]].padding,G=n.chartsWidth+j8,Z=re.top;return le.jsx(f2,{dataId:e,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${n.totalWidth} ${n.totalHeight}`,width:n.totalWidth,height:n.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${h.left},${h.top})`,fontFamily:"Manrope",children:[le.jsx(d2,{title:C,show:Q.show,position:Q.position,leftPadding:re.left,rightPadding:U.right,chartsWidth:n.chartsWidth}),a.map(Y=>le.jsx(B5t,{facetKey:Y,facetTitle:i[Y],facetSettings:o,orientation:O,scales:{...s,xPrimary:s.xPrimary[Y],xSecondary:s.xSecondary[Y],y:s.y[Y]},chartSizes:n,margins:h,dimensions:r[Y],layersData:c,statsData:f,xAxis:I,yAxis:$,frameType:K.type,tooltips:t.tooltips,tooltipsContainer:_,keyColumn:g,xLabels:b[Y],onlyPositive:x,secondaryGrouping:k},Y)),ee.show&&le.jsx("g",{transform:`translate(${G},${Z})`,children:le.jsx(y9,{legendData:A})})]}),le.jsx("g",{ref:Y=>{Y&&!_&&D(Y)}})]})})}function pK(e,t){let n=Object.keys(e.values),r=e.reduce((a,i)=>{if(i.meta.statType==="pairwise"){let o=Object.values(i.values).map(s=>uK(s,t,i.meta.significanceLevels,i.meta.ns));return a+i2*Math.max(...o)}return(i.meta.ns?t.length>0:n.some(o=>i.values[o].some(([,s])=>s<i.meta.significanceLevels.one)))?a+i2:a},Q2t);return Math.max(h9.TOP,r)}function A2(e,t,n=r=>r){let r=A=>t==="log"?Math.log10(A):A,a=A=>t==="log"?Math.pow(10,A):A,i=e.map(n).map(r).sort((A,h)=>A-h),o=Dp(i,.25),s=Dp(i,.75),c=s-o,f=1.5;return[a(o-f*c),a(s+f*c)]}function L5t(e,t,n,r=14){let a=new Dc(`600 ${r}px Manrope`),i=[];e.split(new RegExp("(?=[_-])|(?<=[_-])")).forEach(h=>{a.getTextWidth(h)>n?i.push(...h.split("")):i.push(h)});let o="",s=0,c=0,f="";for(;s<=t;){let h=a.getTextWidth(o+i[c]);h<t&&(o+=i[c],f=o,c++),s=h}o="",s=0;let A=[];for(c;c<i.length;c++){let h=a.getTextWidth(o+i[c]);h<n?(o+=i[c],s=h):(A.push(o),o=i[c],s=a.getTextWidth(i[c]))}return{firstPart:f,lines:A,lastPart:o,lastPartLength:s}}function Om(e,t,n){let r=new Dc(`600 ${n}px Manrope`);if(e.trim()==="")return[];if(r.getTextWidth(e)<=t)return[e];let a=e.split(/\s+/),i=[],o="",s=0;for(let c=0;c<a.length;c++){let f=`${o} ${a[c]}`,A=r.getTextWidth(f);if(A<=t)o=f,s=A;else{let h=r.getTextWidth(a[c]);if(h>t){let{firstPart:m,lines:g,lastPart:b,lastPartLength:C}=L5t(a[c],t-s,t,n);i.push(`${o} ${m}`),i.push(...g),o=b,s=C}else i.push(o),o=a[c],s=h}}return i.push(o),i.filter(c=>c.length>0)}var hK=new Dc("600 14px Manrope"),R5t=16,kP=48,N5t=20,Pg=24;function TP(e,t){return Math.max(...e.map(n=>hK.getTextWidth(String(n))+N5t),hK.getTextWidth(t))}function $5t(e,t,n,r){let a=[[]],i=0,o=t,s=0;return e.forEach(c=>{i+r<=o?(a[s].push(c),i+=r):(a.push([c]),s++,i=r,o=n)}),a}function w9(e,t,n){let r=n??t,a=0,i=0,o=0;e.sort((c,f)=>c.type==="continuous"&&f.type!=="continuous"?-1:f.type==="continuous"&&c.type!=="continuous"?1:c.type==="dots"&&f.type!=="dots"?-1:f.type==="dots"&&c.type!=="dots"?1:0);let s=[];return e.forEach(c=>{let{type:f,values:A,title:h,id:m,scale:g}=c;if(f==="continuous"){let b=UX(A,h),C=r;t-i<C&&(o+=a+Pg,a=0,i=0);let x=o,k=i;b>a&&(a=b),i+=C+kP,i>=t&&(o+=a+Pg,a=0,i=0),s.push({...c,width:b,height:C,left:x,top:k})}else if(f==="size"){let{labels:b}=c,C=g(Math.max(...A))*2+4,x=TP(A.map(O=>b[O]),h),k=A.length*C;t-i<k&&(o+=a+Pg,a=0,i=0);let _=o,D=i;x>a&&(a=x),i+=k+kP,i>=t&&(o+=a+Pg,a=0,i=0),s.push({...c,width:x,height:k,left:_,top:D})}else{let{labels:b}=c,C=R5t,x=t-i;x<C&&(x=t,o+=a+Pg,a=0,i=0);let k=$5t(A,x,t,C),_=TP([],h),D=a===0,O=o+_+Pg;k.forEach((I,$)=>{let Q=$===k.length-1,ee=$>0?"":h,K=$>0?`${m}_${$}`:m,re=TP(I.map(Y=>b[Y]),D?"":ee),U=I.length*C,G=o,Z=i;re>a&&(a=re),Q?i+=U+kP:i=t,i>=t&&(o+=a+Pg,D&&Q&&o<O&&(o=O),a=0,i=0),s.push({...c,id:K,title:ee,width:re,height:U,left:G,top:Z,values:I})})}}),s}function F5t(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function V5t(e,t,n,r,a,i,o,s,c,f){let A=e==="vertical",h=o.includes("left")||A&&!(s!=null&&s.sharedY)||!A&&!(s!=null&&s.sharedX),m=o.includes("left")&&n.title!=="",g=o.includes("bottom")||A&&!(s!=null&&s.sharedX)||!A&&!(s!=null&&s.sharedY),b=o.includes("bottom")&&t.title!=="",C=r.yAxisCaptionsWidth,x=(n.showTicks?t2:0)+ed,k=m?l1:0,_=r.xAxisCaptionsWidthByRows[A?c:f],D=(t.showTicks?t2:0)+ed,O=b?l1:0,I=A?C+x+k:_+D+O,$=A?D+_+O:x+2*l1,Q=Math.max(...a.map(ee=>i[ee].length));return{left:h?I:CP,top:Q===0?0:O2t*2+Q*m9,bottom:g?$:CP,right:CP}}function O5t(e,t,n){let r=new Array(n).fill(null).map(()=>[]);for(let a=0;a<n;a++)for(let i=0;i<t;i++)i*n+a<e.length&&r[a].push(e[i*n+a]);return r}function mK(e,t,n){let r=[];for(let a=0;a<t;a++)r.push(e.slice(a*n,a*n+n));return r}function Q5t(e,t){let n=Math.floor(e/t),r=e-n*t;return[n,r]}function z5t(e){return typeof e=="object"&&"type"in e}var U5t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{xPrimary:{null:F5().range([0,600]).domain(["1"])},xSecondary:{null:F5().range([0,600]).domain(["1"])},y:{null:Da().domain([0,10]).range([350,0]).nice()},xPrimaryAes:Hl().unknown(qX),xSecondaryAes:Hl().unknown(qX)});Me(this,"facetTitles",{});Me(this,"mainTitle",[]);Me(this,"axisLabelsX",{});Me(this,"captionsSizes",{xAxisCaptionsWidthByRows:[],xCaptionsTail:0,yAxisCaptionsWidth:100});Me(this,"legend",{width:0,height:0,items:[]});Me(this,"margins",{left:0,right:0,top:0,bottom:0})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateChartSize(e,t,n,r,a,i){let o=pK(i,r),s=t.length,c=Math.min((n==null?void 0:n.nRows)??s,s),f=Math.min((n==null?void 0:n.nCols)??s,s);this.columnsCount=n!=null&&n.nRows?Math.ceil(s/c):f,this.rowsCount=Math.ceil(s/this.columnsCount);let{width:A,height:h}=e;a==="vertical"&&o>h9.TOP&&(h+=o),a==="horizontal"&&o>h9.TOP&&(A+=o),this.chartSizes.chartWidth=A,this.chartSizes.chartHeight=h}updateChartDimensions(e,t,n,r,a){let{chartWidth:i,chartHeight:o}=this.chartSizes,s=0,c=0;this.chartsDimensions=e.reduce((h,m,g)=>{let[b,C]=Q5t(g,this.columnsCount),x=F5t(g,e.length,this.columnsCount,this.rowsCount),k=V5t(n,r,a,this.captionsSizes,mK(e,this.rowsCount,this.columnsCount)[b],this.facetTitles,x,t,b,C),_=i+k.left+k.right,D=o+k.top+k.bottom;return h[m]={left:s,top:c,chartEdgeSides:x,padding:k,inner:{width:i,height:o},outer:{width:_,height:D}},s+=_,C===this.columnsCount-1&&(s=0,c+=D),h},{});let f=Math.max(...e.map(h=>this.chartsDimensions[h].outer.width+this.chartsDimensions[h].left)),A=Math.max(...e.map(h=>this.chartsDimensions[h].outer.height+this.chartsDimensions[h].top));this.chartSizes.chartsWidth=f,this.chartSizes.chartsHeight=A}updateViewport(e,t,n,r,a,i,o,s,c){let f=e==="vertical",A=pK(s,t),h=a===null||a.sharedX,m=a===null||a.sharedY,{chartHeight:g,chartWidth:b}=this.chartSizes;r.forEach(C=>{let x=i.scale==="log"?Rv():Da(),k=Math.min(...m?o.map(({meta:I})=>I.minY):o.map(({geoms:I})=>Math.min(...I[C].map(({boundsY:$})=>$.min)))),_=Math.max(...m?o.map(({meta:I})=>I.maxY):o.map(({geoms:I})=>Math.max(...I[C].map(({boundsY:$})=>$.max)))),D=x.copy().domain([k,_]).range(f?[g-h9.BOTTOM,A]:[h9.BOTTOM,b-A]);x.domain([D.invert(f?g:0),D.invert(f?0:b)]).range(f?[g,0]:[0,b]),this.scales.y[C]=x;let O=h?t:c[C];this.scales.xPrimary[C]=F5().domain(O).range(f?[0,b]:[g,0]),this.scales.xSecondary[C]=F5().domain(n).range([0,this.scales.xPrimary[C].bandwidth()])})}createFacetTitles(e,t){this.facetTitles=e.reduce((n,r,a)=>(t[a].length===1&&t[a][0]==="null"?n[r]=[]:n[r]=Om(t[a].join(", "),this.chartSizes.chartWidth,14),n),{})}createMainTitle(e,t){let n=this.chartsDimensions[e[0]],r=this.chartsDimensions[e[e.length-1]];this.mainTitle=Om(t.name,this.chartSizes.chartsWidth-n.padding.left-r.padding.right,20)}createAxisLabels(e,t,n,r){let a={center:120,"45deg":256,"90deg":320},i=r==="vertical";function o(s,c){return s==="center"?1/0:Math.floor(s==="45deg"?c*Math.sin(Math.PI/4)/bP:c/bP)}this.axisLabelsX=e.reduce((s,c)=>{let f=this.scales.xPrimary[c],A=f.bandwidth(),h=a[t.labelsPosition],m=t.labelsPosition==="center"?Math.min(h,A):h,g=n.valueLabels;return s[c]=f.domain().reduce((b,C)=>{let x=g[C];if(!i)b[C]=[x];else{let k=o(t.labelsPosition,A),_=Om(x,m,14);b[C]=_.length>k?[x]:_}return b},{}),s},{})}updateAesScales(e,t){if(e.inheritedAes){let{inheritedAes:n,keys:r}=e;this.scales.xPrimaryAes.domain(r).range(r.map(a=>n[a]))}else this.scales.xPrimaryAes.domain([]).range([]);if(t.inheritedAes){let{inheritedAes:n,keys:r}=t;this.scales.xSecondaryAes.domain(r).range(r.map(a=>n[a]))}else this.scales.xSecondaryAes.domain([]).range([])}updateCaptionsSize(e,t,n){let r=new Dc("600 14px Manrope"),a=e==="vertical";function i(g){return g.length?Math.max(...g.map(b=>r.getTextWidth(b))):0}function o(g){return g.length?Math.max(...g.map(i)):0}let s=[],c=0,f=mK(t,this.rowsCount,this.columnsCount),A=O5t(t,this.rowsCount,this.columnsCount);if(!a)s=A.map(g=>Math.max(...g.map(b=>o(this.scales.xPrimary[b].domain().map(C=>this.axisLabelsX[b][C])))));else{if(n.labelsPosition==="center"&&(s=f.map(g=>Math.max(...g.map(b=>Math.max(...this.scales.xPrimary[b].domain().map(C=>C?this.axisLabelsX[b][C].length*bP:0)))))),n.labelsPosition==="45deg"){let g=Math.sin(Math.PI/4);s=f.map(b=>Math.max(...b.map(C=>{let x=this.scales.xPrimary[C].domain().map(_=>this.axisLabelsX[C][_]),k=o(x);return k>0?k*g+14:0}))),c=Math.max(...A[0].map(b=>{let C=this.scales.xPrimary[b].domain(),x=this.axisLabelsX[b][C[0]];return Math.max(i(x)*g-this.scales.xPrimary[b].bandwidth()/2+14,0)}))}n.labelsPosition==="90deg"&&(s=f.map(g=>Math.max(...g.map(b=>o(this.scales.xPrimary[b].domain().map(C=>this.axisLabelsX[b][C]))))))}let h=Ir.flatten(t.map(g=>{let b=this.scales.y[g],C=b.ticks(),x=C.some(_=>Math.abs(_)<1e-4&&_!==0||_>1e4)?",e":",f",k=b.tickFormat(10,x);return C.map(k)})),m=i(h);this.captionsSizes={xCaptionsTail:c,xAxisCaptionsWidthByRows:s,yAxisCaptionsWidth:m}}updateMargins(e,t){let n=this.chartsDimensions[t[0]],r=this.chartsDimensions[t[t.length-1]],a=e==="vertical";this.margins={left:Math.max(z8,a?this.captionsSizes.xCaptionsTail-n.padding.left:0),right:Math.max(this.legend.width,z8),top:Math.max(24*this.mainTitle.length+24*2,z8),bottom:Math.max(z8,a?0:this.captionsSizes.xCaptionsTail-r.padding.bottom)},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight,this.legend.height)+this.margins.bottom}updateLegendSize(e,t,n,r){if(!e.show){this.legend={width:0,height:0,items:[]};return}let a=this.chartSizes.chartHeight,i={width:0,height:0,left:0,top:0},o=[];function s(b,C){return r.some(x=>{let k=x.aes[C];return k&&z5t(k)&&k.type===b})}function c(b){return{dotFill:s(b,"dotFill"),fillColor:s(b,"fillColor"),lineColor:s(b,"lineColor"),dotShape:s(b,"dotShape"),lineShape:s(b,"lineShape")}}let f=c("primaryGrouping"),A=c("secondaryGrouping");if(Object.values(f).some(b=>b)&&t.inheritedAes&&o.push({type:"discreteMulti",id:"primary",title:t.label,scale:this.scales.xPrimaryAes,values:t.keys,labels:t.valueLabels,usedAes:f,...i}),Object.values(A).some(b=>b)&&n.inheritedAes&&o.push({type:"discreteMulti",id:"secondary",title:n.label,scale:this.scales.xSecondaryAes,values:n.keys,labels:n.valueLabels,usedAes:A,...i}),!o.length){this.legend={width:0,height:0,items:[]};return}let h=w9(o,this.chartSizes.chartHeight),m=h[h.length-1],g=m.left+m.width+2*j8;this.legend={width:g,height:a,items:h}}render(e,t,n,r,a,i,o,s,c,f,A,h){var k;let{orientation:m,xAxis:g,yAxis:b,size:C}=t;this.updateChartSize(C,i,a,n.keys,m,c),this.updateViewport(m,n.keys,r.keys,i,a,b,s,c,A),this.createAxisLabels(i,g,n,m),this.createFacetTitles(i,o),this.updateCaptionsSize(m,i,g),this.updateChartDimensions(i,a,m,g,b),this.updateLegendSize(t.legend,n,r,s),this.createMainTitle(i,t.title),this.updateMargins(m,i),this.updateAesScales(n,r);let x=le.jsx(I5t,{settingsId:e,chartSettings:t,facetKeys:i,facetSettings:a,facetTitles:this.facetTitles,chartSizes:this.chartSizes,chartsDimensions:this.chartsDimensions,scales:this.scales,layersData:s,statsData:c,legendData:this.legend,margins:this.margins,columnsCount:this.columnsCount,keyColumn:f,xLabels:this.axisLabelsX,chartTitle:this.mainTitle,onlyPositive:h,secondaryGrouping:r});this.component=x,(k=this.reactRoot)==null||k.render(x)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},j5t=U5t;function G5t(e,t,n,r=!1){let a=e.map(t).sort((i,o)=>i-o);if(r){let i=Ir.find(a,o=>o>0);if(!i)throw Error("Group with all zeros in log scale");return a.map(o=>o===0?i:o).map(n)}return a.map(n)}var Y5t=class{constructor(e,t,n,r,a,i,o,s,c,f,A=!0){Me(this,"lower");Me(this,"middle");Me(this,"upper");Me(this,"min");Me(this,"max");Me(this,"outliers");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"key");Me(this,"boundsY");if(e.length===0)throw Error("Unable to create box on empty data");if(o>s||o>c||s>c)throw Error(`Invalid box bounds values: lower=${o}, middle=${s}, upper=${c}`);if(f<0)throw Error(`Invalid box whiskers coefficient: k=${f}. It should be positive`);let h=I=>Number(I[t]);this.primaryGrouping=a===null?"":String(a),this.secondaryGrouping=i===null?"":String(i),this.key=`box_${this.primaryGrouping}_${this.secondaryGrouping}`;let m=I=>r==="log"?Math.log10(I):I,g=I=>r==="log"?Math.pow(10,I):I,b=G5t(e,h,m,r==="log"),C=Dp(b,o),x=Dp(b,s),k=Dp(b,c),_=k-C;this.upper=g(k),this.middle=g(x),this.lower=g(C),this.min=Math.max(mC(e,h),g(C-f*_)),this.max=Math.min(Ih(e,h),g(k+f*_)),this.outliers=e.filter(I=>h(I)<this.min||h(I)>this.max).map((I,$)=>({y:h(I),data:I,id:String(n?I[n]:$)}));let[D=1/0,O=-1/0]=$A(this.outliers,I=>I.y);this.boundsY={min:A?Math.min(this.min,D):this.min,max:A?Math.max(this.max,O):this.max}}};function W5t(e,t,n,r,a,i,o,s){let c=1/0,f=-1/0;return{type:"box",geoms:t.reduce((A,h)=>{let m=h.join("_");return A[m]=[],n.forEach(g=>{r.forEach(b=>{let C=a.getRowsByGrouping([...h,g,b]);if(!C.length)return;let x=new Y5t(C,i.value,(o==null?void 0:o.value)??null,s.scale,g,b,e.stat.lower,e.stat.medium,e.stat.upper,e.stat.k,e.aes.showOutliers);x.boundsY.min<c&&(c=x.boundsY.min),x.boundsY.max>f&&(f=x.boundsY.max),A[m].push(x)})}),A},{}),meta:{minY:c,maxY:f},aes:e.aes}}var vK=40;function X5t(e,t){return function(n){return t.map(function(r){return[r,tu(n,a=>e(r-a))]})}}function K5t(e){return function(t){return 1/Math.sqrt(2*Math.PI)*Math.pow(Math.E,-.5*Math.pow(t/e,2))}}function Z5t(e){let t=tu(e);return tu(e.map(n=>Math.pow(n-t,2)))}function J5t(e){return Math.sqrt(Z5t(e))}function q5t(e,t,n){let r=(n-t)/1.34,a=J5t(e);return 1.06*Math.min(a,r)*Math.pow(e.length,-1/5)}var e7t=class{constructor(e,t,n,r,a,i){Me(this,"getArea");Me(this,"getLine");Me(this,"maxDensity");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"key");Me(this,"boundsY");Me(this,"quartiles");if(e.length===0)throw Error("Unable to calculate violin on empty data");if(r!=="auto"&&r<1)throw Error(`Unable to calculate violin with ${r} steps`);this.primaryGrouping=a===null?"":String(a),this.secondaryGrouping=i===null?"":String(i),this.key=`violin_${this.primaryGrouping}_${this.secondaryGrouping}`;let o=I=>t==="log"?Math.log10(I):I,s=I=>t==="log"?Math.pow(10,I):I,c=e.filter(I=>t==="log"&&Number(I)===0?(console.warn("Value = 0 on chart with log scale, it was removed from calculation"),!1):!0).map(o).sort((I,$)=>I-$),f=c[0],A=c[c.length-1],h=A-f,m=Dp(c,.25),g=Dp(c,.5),b=Dp(c,.75);this.quartiles={q1:s(m),q2:s(g),q3:s(b)};let C=q5t(c,m,b),x=r!=="auto"?r:C/3>h/vK?vK:h/(C/3),k=n?f:f-3*C,_=n?A:A+3*C,D=Da().domain([k,_]).ticks(x);this.boundsY={min:s(D[0]),max:s(D[D.length-1])};let O=X5t(K5t(C),D)(c).map(([I,$])=>[s(I),$]);this.maxDensity=Ih(O,([,I])=>I),this.getArea=(I,$,Q,ee)=>{let K=I==="vertical",re=ee??this.maxDensity,U=Da().domain([-re,re]).range([-Q/2,Q/2]);return K?VB().curve(A3).x0(G=>U(G[1])).x1(G=>U(-G[1])).y(G=>$(G[0]))(O):VB().curve(A3).y0(G=>U(G[1])).y1(G=>U(-G[1])).x(G=>$(G[0]))(O)},this.getLine=(I,$,Q,ee)=>{let K=I==="vertical",re=ee??this.maxDensity,U=Da().domain([-re,re]).range([-Q/2,Q/2]);return d3().curve(A3).x(K?G=>U(G[1]):G=>$(G[0])).y(K?G=>$(G[0]):G=>U(G[1]))(O)+" "+d3().curve(A3).x(K?G=>U(-G[1]):G=>$(G[0])).y(K?G=>$(G[0]):G=>U(-G[1]))(O)}}};function t7t(e,t,n,r,a,i,o){let s=0,c=1/0,f=-1/0;return{type:"violin",geoms:t.reduce((A,h)=>{let m=h.join("_");return A[m]=[],n.forEach(g=>{r.forEach(b=>{let C=a.getColumnByGrouping([...h,g,b],i.value);if(!C.length)return;let x=new e7t(C,o.scale,e.stat.trim,e.stat.stepsCount,g,b);x.maxDensity>s&&(s=x.maxDensity),x.boundsY.min<c&&(c=x.boundsY.min),x.boundsY.max>f&&(f=x.boundsY.max),A[m].push(x)})}),A},{}),meta:{maxDensity:s,minY:c,maxY:f},aes:e.aes}}var n7t=30;function r7t(e,t){return function(n){return t.map(function(r){return tu(n,a=>e(r-a))})}}function a7t(e){return function(t){return 1/Math.sqrt(2*Math.PI)*Math.pow(Math.E,-.5*Math.pow(t/e,2))}}function i7t(e){let t=tu(e);return tu(e.map(n=>Math.pow(n-t,2)))}function o7t(e){return Math.sqrt(i7t(e))}function l7t(e){let t=Dp(e,.25),n=(Dp(e,.75)-t)/1.34,r=o7t(e);return 1.06*Math.min(r,n)*Math.pow(e.length,-1/5)}var s7t=class{constructor(e,t,n,r,a,i){Me(this,"key");Me(this,"maxDensity");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"points");Me(this,"boundsY");let o=n7t;if(e.length===0)throw Error("Unable to calculate sina on empty data");this.primaryGrouping=r===null?"":String(r),this.secondaryGrouping=a===null?"":String(a),this.key=`sina_${this.primaryGrouping}_${this.secondaryGrouping}`;let s=D=>n==="log"?Math.log10(D):D,c=D=>n==="log"?Math.pow(10,D):D,f=D=>Number(D[t.value]),A=e.filter(D=>n==="log"&&f(D)===0?(console.warn("Value = 0 on chart with log scale, it was removed from calculation"),!1):!0).sort((D,O)=>s(f(D))-s(f(O))),h=A.map(D=>s(f(D))),m=h[0],g=h[A.length-1],b=(g-m)/o,C=l7t(h),x=Ir.range(m+b,g,b);this.boundsY={min:c(m),max:c(g)};let k=r7t(a7t(C),x)(h),_=Da().domain(x).range(k).clamp(!0);this.maxDensity=Ih(k),this.points=A.map((D,O)=>({x:f(D),y:_(s(f(D)))/this.maxDensity,id:String(O),jitter:i(),data:D}))}};function u7t(e,t,n,r,a,i,o){let s=0,c=1/0,f=-1/0,A=nF(1);return{type:"sina",geoms:t.reduce((h,m)=>{let g=m.join("_");return h[g]=[],n.forEach(b=>{r.forEach(C=>{let x=a.getRowsByGrouping([...m,b,C]);if(!x.length)return;let k=x;if(!e.aes.showOutliers){let D=$=>Number($[i.value]),[O,I]=A2(x,o.scale,D);k=x.filter($=>{let Q=D($);return Q>=O&&Q<=I})}let _=new s7t(k,i,o.scale,b,C,A);_.maxDensity>s&&(s=_.maxDensity),_.boundsY.min<c&&(c=_.boundsY.min),_.boundsY.max>f&&(f=_.boundsY.max),h[g].push(_)})}),h},{}),meta:{maxDensity:s,minY:c,maxY:f},aes:e.aes}}function c7t(e,t,n,r,a,i,o,s){let c=1/0,f=-1/0,A=nF(1);return{type:"dot",geoms:t.reduce((h,m)=>{let g=m.join("_");return h[g]=[],n.forEach(b=>{r.forEach(C=>{let x=a.getRowsByGrouping([...m,b,C]);if(!x.length)return;let k=I=>Number(I[i.value]),_=x.map((I,$)=>({y:k(I),jitter:A(),id:String(s?I[s.value]:$),data:I}));if(!e.aes.showOutliers){let[I,$]=A2(x,o.scale,k);_=_.filter(({y:Q})=>Q>=I&&Q<=$)}let[D=1/0,O=-1/0]=$A(_,I=>I.y);D<c&&(c=D),O>f&&(f=O),h[g].push({key:`dots_${b}_${C}`,values:_,primaryGrouping:b,secondaryGrouping:C,boundsY:{min:D,max:O}})})}),h},{}),meta:{minY:c,maxY:f},aes:e.aes}}function f7t(e,t){if(t==="median")return mL(e,.5);if(t==="mean")return tu(e);vA(t,`Unknown line points calculation for dot layer: ${t}`)}function d7t(e,t,n,r,a,i,o){let s=1/0,c=-1/0;return{type:"line",geoms:t.reduce((f,A)=>{let h=A.join("_");f[h]=[];let m=-1/0,g=1/0;return e.aes.showOutliers||([m,g]=A2(a.getColumnByGrouping([...A],i.value),o.scale)),r.forEach(b=>{let C={key:`${b}`,boundsY:{min:1/0,max:-1/0},dots:{}},x=!1,k=D=>o.scale==="log"?Math.log10(D):D,_=D=>o.scale==="log"?Math.pow(10,D):D;n.forEach(D=>{let O=a.getColumnByGrouping([...A,D,b],i.value);if(!O.length){x=!0;return}let I=O;if(e.aes.showOutliers||(I=O.filter(Q=>Q>=m&&Q<=g)),!I.length){x=!0;return}let $=_(f7t(I.map(k),e.pointsValues));C.dots[D]=$,$<s&&(s=$),$>c&&(c=$),$<C.boundsY.min&&(C.boundsY.min=$),$>C.boundsY.max&&(C.boundsY.max=$)}),x||f[h].push(C)}),f},{}),meta:{minY:s,maxY:c},aes:e.aes}}function A7t(e){let t=tu(e);return tu(e.map(n=>Math.pow(n-t,2)))}function _P(e){return Math.sqrt(A7t(e))}function p7t(e){return _P(e)/Math.sqrt(e.length)}function h7t(e){return 1.96*_P(e)}function m7t(e,t){if(t==="median")return mL(e,.5);if(t==="mean")return tu(e);vA(t,"Unknown points calculation")}function v7t(e,t){if(t==="sd")return _P(e);if(t==="se")return p7t(e);if(t==="ci")return h7t(e);vA(t,"Unknown error interval calculation")}function g7t(e,t,n,r,a,i,o){let s=1/0,c=-1/0;return{type:"errorbar",geoms:t.reduce((f,A)=>{let h=A.join("_");f[h]=[];let m=b=>o.scale==="log"?Math.log10(b):b,g=b=>o.scale==="log"?Math.pow(10,b):b;return n.forEach(b=>{r.forEach(C=>{let x=a.getColumnByGrouping([...A,b,C],i.value);if(!x.length)return;let k=x.map(m),_=g(m7t(k,e.pointsValues)),D=g(v7t(k,e.interval)),O=_-D,I=_+D;O<s&&(s=O),I>c&&(c=I),f[h].push({key:`errorbar_${b}_${C}`,primaryGrouping:b,secondaryGrouping:C,value:_,min:O,max:I,boundsY:{min:O,max:I}})})}),f},{}),meta:{minY:s,maxY:c},aes:e.aes}}function y7t(e,t,n,r){if(e.length===0)throw Error("Unable to create bar on empty data");let a=s=>t==="log"?Math.log10(s):s,i=s=>t==="log"?Math.pow(10,s):s,o=s=>{let c=Number(s[n]);if(t==="log"&&c<1)throw Error(`Value < 1 in log scale: ${c}`);return c};switch(r){case"max":return Ih(e,o)??o(e[0]);case"min":return mC(e,o)??o(e[0]);case"median":{let s=e.map(c=>Number(c[n])).map(a).sort((c,f)=>c-f);return i(Dp(s,.5))}case"mean":return tu(e,o)??o(e[0]);default:vA(r,`Unknown bar height function ${r}`)}}function w7t(e,t,n,r,a,i,o){let s=-1/0,c=1/0;return{type:"bar",geoms:t.reduce((f,A)=>{let h=A.join("_");return f[h]=[],n.forEach(m=>{r.forEach(g=>{let b=a.getRowsByGrouping([...A,m,g]);if(!b.length)return;let C=y7t(b,o.scale,i.value,e.height);s=Math.max(s,C,0),c=Math.min(c,C,0),f[h].push({key:`bar_${m}_${g}`,value:C,primaryGrouping:m,secondaryGrouping:g,boundsY:{min:Math.min(0,C),max:Math.max(0,C)}})})}),f},{}),meta:{minY:c,maxY:s},aes:e.aes}}function C7t(e,t,n,r,a,i){let o=-1/0,s=1/0;return{type:"stackedBar",geoms:t.reduce((c,f)=>{let A=f.join("_");return c[A]=[],n.forEach(h=>{let m=0,g={};r.forEach(x=>{let k=a.getRowsByGrouping([...f,h,x]);if(!k.length)return;let _=Sc(k,D=>Number(D[i.value]));g[x]={height:_,key:x},m+=_});let b=m;e.normalize&&r.forEach(x=>{g[x]&&(g[x].height=g[x].height/b*100)}),o=Math.max(o,0,m),s=Math.min(s,0,m);let C=e.normalize?100:b;c[A].push({key:`stackedBar_${h}`,valuesMap:g,primaryGrouping:h,boundsY:{min:Math.min(C,0),max:Math.max(C,0)}})}),c},{}),meta:{minY:e.normalize?0:s,maxY:e.normalize?100:o,normalize:e.normalize},aes:e.aes}}var gK=30;function b7t(e,t,n,r,a,i){let o=e.map(m=>n(a(m))),s=e.length,c=e.map(A),f=[];function A(m,g){return{key:i(m,g),value:a(m)}}let h=0;for(let m=1;m<s;++m){let g=o[h],b=o[m],C=o[m-1];if(b>=g+t){let x=Math.min((g+C)/2,b-t);o.fill(x,h,m),f.push({x:r(x),count:m-h,dots:c.slice(h,m)}),h=m}}return o.fill((o[h]+o[s-1])/2,h,s),f.push({x:r((o[h]+o[s-1])/2),count:s-h,dots:c.slice(h,s)}),f}var E7t=class{constructor(e,t,n,r,a,i,o,s,c,f){Me(this,"bins");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"key");Me(this,"boundsY");this.primaryGrouping=n===null?"":String(n),this.secondaryGrouping=r===null?"":String(r),this.key=`binnedDots_${this.primaryGrouping}_${this.secondaryGrouping}`;let A=e.filter(h=>s(h)===0&&c==="log"?(console.warn(`Item with ${t} = 0 is not shown on chart with log scale`),!1):!0).sort((h,m)=>i(s(h))-i(s(m)));this.bins=b7t(A,a,i,o,s,(h,m)=>String(f?h[f.value]:m)),this.boundsY={min:this.bins[0].x,max:this.bins[this.bins.length-1].x}}};function x7t(e,t,n,r,a,i,o){let s=x=>o.scale==="log"?Math.log10(x):x,c=x=>o.scale==="log"?Math.pow(10,x):x,f=x=>Number(x[i.value]),A=1/0,h=-1/0,m=a.getRowsByGrouping([]),[g=f(m[0]),b=f(m[0])]=$A(m.filter(x=>Number(x[i.value])===0&&o.scale==="log"?(console.warn(`Item with ${i.value} = 0 is not shown on chart with log scale`),!1):!0),x=>Number(x[i.value])),C=Math.abs(s(g)-s(b))/gK;return{type:"binnedDots",geoms:t.reduce((x,k)=>{let _=k.join("_");return x[_]=[],n.forEach(D=>{r.forEach(O=>{let I=a.getRowsByGrouping([...k,D,O]);if(!I.length)return;let $=I;if(!e.aes.showOutliers){let[ee,K]=A2(I,o.scale,f);$=I.filter(re=>{let U=f(re);return U>=ee&&U<=K})}let Q=new E7t($,i.value,D,O,C,s,c,f,o.scale,e.keyColumn);Q.boundsY.min<A&&(A=Q.boundsY.min),Q.boundsY.max>h&&(h=Q.boundsY.max),x[_].push(Q)})}),x},{}),meta:{minY:Math.min(g,b,A),maxY:Math.max(g,b,h),binsCount:gK,hasKeyFromColumn:e.keyColumn!==null},aes:e.aes}}function S7t(e,t){if(t.length===2)return"secondary";if(e.length===2&&t.length<2)return"primary";throw Error("Too many groups for paired points layer")}function yK(e,t,n,r,a,i,o,s,c){let f=Ir.groupBy(n,D=>D[a.value]),A=Ir.groupBy(r,D=>D[a.value]),h=Object.keys(f),m=Object.keys(A);if(Ir.uniq(h).length!==h.length||Ir.uniq(m).length!==m.length)throw Error(`Non unique keys in groups ${e}, ${t} for paired points layer`);if(h.length!==m.length||Ir.intersection(h,m).length!==h.length)throw Error(`Keys in groups ${e}, ${t} not match for paired points layer`);let g=D=>Number(D[i.value]),b=1/0,C=-1/0,x=!1,k=c==="log",_=h.map(D=>{let O=f[D][0],I=A[D][0],$=g(O),Q=g(I);return($===0||Q===0)&&(x=!0),b=Math.min(b,k&&$===0?1/0:$,k&&Q===0?1/0:Q),C=Math.max(C,k&&$===0?-1/0:$,k&&Q===0?-1/0:Q),{id:D,key1:{id:`${D}_${e}`,value:$,data:O},key2:{id:`${D}_${t}`,value:Q,data:I}}});if(!s){b=1/0,C=-1/0;let[D,O]=A2(n,c,g),[I,$]=A2(r,c,g);_=_.filter(({key1:Q,key2:ee})=>Q.value<D||Q.value>O||ee.value<I||ee.value>$?!1:(b=Math.min(b,k&&Q.value===0?1/0:Q.value,k&&ee.value===0?1/0:ee.value),C=Math.max(C,k&&Q.value===0?-1/0:Q.value,k&&ee.value===0?-1/0:ee.value),!0))}return b=x?b/10:b,C=Math.max(C,b),{id:`${e}_${t}`,key1:e,key2:t,pairs:_.map(D=>({...D,key1:{...D.key1,value:D.key1.value===0?b:D.key1.value},key2:{...D.key2,value:D.key2.value===0?b:D.key2.value}})),grouping:o,boundsY:{min:b,max:C}}}function B7t(e,t,n,r,a,i,o){let s=S7t(n,r),c=1/0,f=-1/0;return{type:"pairedPoints",geoms:t.reduce((A,h)=>{let m=h.join("_");if(A[m]=[],s==="primary"){let[g,b]=n,C=a.getRowsByGrouping([...h,g]),x=a.getRowsByGrouping([...h,b]),k=yK(g,b,C,x,e.linkColumn,i,s,e.aes.showOutliers,o.scale);c=Math.min(c,k.boundsY.min),f=Math.max(f,k.boundsY.max),A[m].push(k)}else s==="secondary"&&n.forEach(g=>{let[b,C]=r,x=a.getRowsByGrouping([...h,g,b]),k=a.getRowsByGrouping([...h,g,C]),_=yK(b,C,x,k,e.linkColumn,i,s,e.aes.showOutliers,o.scale);c=Math.min(c,_.boundsY.min),f=Math.max(f,_.boundsY.max),A[m].push(_)});return A},{}),meta:{minY:c,maxY:f},aes:e.aes}}function wK(e,t){let n;if(e==t){n=new Array(t+1);for(let r=0;r<n.length;++r)n[r]=r+1}else if(e<t){n=new Array(t-e+1);for(let r=0;r<n.length;++r)n[r]=e+r}else{n=new Array(e-t+1);for(let r=0;r<n.length;++r)n[r]=e-r}return n}function p2(e,t){return Ir.orderBy(e.map((n,r)=>[n,r]),([n])=>n,[t?"desc":"asc"]).map(([,n])=>n)}function k7t(e){if(e.length<1)throw new Error("cummin requires at least one element");let t=new Array(e.length),n=e[0];for(let r=0;r<e.length;++r)e[r]<n&&(n=e[r]),t[r]=n;return t}function T7t(e){if(e.length<1)throw new Error("cummax requires at least one element");let t=new Array(e.length),n=e[0];for(let r=0;r<e.length;++r)e[r]>n&&(n=e[r]),t[r]=n;return t}function CK(e,t){if(e.length<1)throw new Error("pmin requires at least one element");return e.map(n=>Math.min(n,t))}function _7t(e){if(e.length<1)throw new Error("pAdjust requires at least one element");return Math.min(...e)}function P7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=new Array(t);for(let r=0;r<t;++r){let a=e[r]*t;if(a>=1)n[r]=1;else if(0<=a)n[r]=a;else throw new Error(`${a} is outside [0, 1)`)}return n}function M7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=p2(e,!1),r=n.slice(),a=new Array(t).fill(0);for(let f=0;f<t;++f)a[f]=(t-f)*e[n[f]];let i=p2(r,!1),o=T7t(a),s=CK(o,1),c=new Array(t);for(let f=0;f<t;++f)c[f]=s[i[f]];return c}function D7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=wK(t,t),r=p2(e,!1),a=new Array(t);for(let h=0;h<t;++h)a[h]=e[r[h]];let i=r.slice(),o=p2(i,!1),s=new Array(t),c=new Array(t),f=new Array(t);for(let h=0;h<t;++h)f[h]=a[h]*t/n[h];let A=_7t(f);s.fill(A),c.fill(A);for(let h=t;h>=2;--h){let m=wK(1,t-h+1);for(let x=0;x<t-h+1;++x)m[x]--;let g=h-1,b=new Array(g);for(let x=0;x<g;++x)b[x]=t-h+2+x-1;let C=h*a[b[0]]/2;for(let x=1;x<g;++x){let k=a[b[x]]*h/(2+x);k<C&&(C=k)}for(let x=0;x<t-h+1;++x)s[m[x]]=Math.min(a[m[x]]*h,C);for(let x=0;x<g;++x)s[b[x]]=s[t-h];for(let x=0;x<t;++x)c[x]<s[x]&&(c[x]=s[x])}for(let h=0;h<t;++h)s[h]=c[o[h]];return s}var H7t=class{constructor(e,t,n){this.ni=e,this.o=t,this.ro=n}result(e){let t=k7t(e),n=CK(t,1),r=new Array(e.length);for(let a=0;a<e.length;++a)r[a]=n[this.ro[a]];return r}};function PP(e){let t=e.length,n=new Array(t),r=p2(e,!0);for(let i=0;i<t;++i){if(e[i]<0||e[i]>1)throw new Error("array["+i+"] = "+e[i]+" is outside [0, 1]");n[i]=t/(t-i)}let a=p2(r,!1);return new H7t(n,r,a)}function I7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=PP(e),r=new Array(t);for(let a=0;a<t;++a)r[a]=n.ni[a]*e[n.o[a]];return n.result(r)}function L7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=PP(e),r=new Array(t),a=0;for(let i=1;i<t+1;++i)a+=1/i;for(let i=0;i<t;++i)r[i]=a*n.ni[i]*e[n.o[i]];return n.result(r)}function R7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=PP(e),r=new Array(t);for(let a=0;a<t;++a)r[a]=(a+1)*e[n.o[a]];return n.result(r)}function bK(e,t){switch(t){case"BenjaminiHochberg":return I7t(e);case"BenjaminiYekutieli":return L7t(e);case"Bonferroni":return P7t(e);case"Hochberg":return R7t(e);case"Holm":return M7t(e);case"Hommel":return D7t(e);case null:return e;default:throw new Error(`Unknown p-value correction method: ${t}`)}}function N7t(e){let t=Math.abs(e),n=1/(1+t/2),r=n*Math.exp(-t*t-1.26551223+n*(1.00002368+n*(.37409196+n*(.09678418+n*(-.18628806+n*(.27886807+n*(-1.13520398+n*(1.48851587+n*(-.82215223+n*.17087277)))))))));return e>=0?r:2-r}function $7t(e){return .5*N7t(-e/Math.sqrt(2))}var F7t=class{constructor(e,t){this.value=e,this.position=t}getValue(){return this.value}getPosition(){return this.position}};function V7t(e){let t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=new F7t(e[o],o);let n=Q7t(t);t.sort((o,s)=>o.getValue()-s.getValue());let r=new Array(t.length),a=1;r[t[0].getPosition()]=a;let i=[];i.push(t[0].getPosition());for(let o=1;o<t.length;o++)t[o].getValue()>t[o-1].getValue()&&(a=o+1,i.length>1&&EK(r,i),i=[]),i.push(t[o].getPosition()),r[t[o].getPosition()]=a;return i.length>1&&EK(r,i),O7t(r,n),r}function EK(e,t){let n=(2*e[t[0]]+t.length-1)/2;t.forEach(r=>{e[r]=n})}function O7t(e,t){t.forEach(n=>{e[n]=NaN})}function Q7t(e){let t=[];for(let n=0;n<e.length;n++)isNaN(e[n].getValue())&&t.push(n);return t}var z7t=class{constructor(){Me(this,"SMALL_SAMPLE_SIZE",50)}mannWhitneyU(e,t){let n=[...e,...t],r=V7t(n),a=0;for(let s=0;s<e.length;s++)a+=r[s];let i=a-e.length*(e.length+1)/2,o=e.length*t.length-i;return Math.min(i,o)}mannWhitneyUTest(e,t,n){if(typeof n>"u")return e.length+t.length<=this.SMALL_SAMPLE_SIZE&&Object.keys(this.tiesMap(e,t)).length===0?this.mannWhitneyUTest(e,t,!0):this.mannWhitneyUTest(e,t,!1);let r=this.tiesMap(e,t),a=this.mannWhitneyU(e,t);if(n){if(Object.keys(r).length!==0)throw new Error;return this.exactP(e.length,t.length,a)}return this.approximateP(a,e.length,t.length,this.varU(e.length,t.length,r))}approximateP(e,t,n,r){let a=t*n/2;if(a==e)return 1;let i=-Math.abs(e-a+.5)/Math.sqrt(r);return 2*$7t(i)}exactP(e,t,n){let r=t*e;if(n>r)return 1;let a=n<r/2?n:r/2-n,i=0,o=0;for(;o<=a;)i+=this.uDensity(e,t,o),o++;return 2*i}uDensity(e,t,n){if(n<0||n>t*e)return 0;let r=this.uFrequencies(e,t);return r[Math.round(n+1)]/Ir.sum(r)}uFrequencies(e,t){let n=Math.max(t,e);if(n>100)throw Error("n or m > 100");let r=Math.min(t,e),a=new Array(e*t+2),i=new Array(e*t+2);for(let s=1;s<a.length;s++)a[s]=s<=n+1?1:0;i[1]=0;let o=n;for(let s=2;s<=r;s++){i[s]=0,o=o+n;let c=o+2,f=1+o/2,A=s;for(let h=1;h<=f;h++){A++,c=c-1;let m=a[h]+i[h];a[h]=m,i[A]=m-a[c],a[c]=m}}return a}varU(e,t,n){let r=e*t;if(Object.keys(n).length===0)return r*(e+t+1)/12;let a=Ir.sum(Object.values(n).map(o=>o*o*o-o)),i=e+t;return r/12*(i+1-a/(i*(i-1)))}tiesMap(e,t){let n={};for(let r=0;r<e.length;r++)n[e[r]]=n[e[r]]?n[e[r]]+1:1;for(let r=0;r<t.length;r++)n[t[r]]=n[t[r]]?n[t[r]]+1:1;for(let r in n)n[r]===1&&delete n[r];return n}};function MP(e,t,n){switch(t){case"ttest":{if(e.length>2)throw new Error("more than 2 datasets passed");if(n){if(e[0].length!==e[1].length)throw Error("Different size groups in paired test");return Aot(e[0],e[1]).pValue}let r=Mot(e[0],e[1]).pValue;return isNaN(r)?1:r}case"anova":{let r=gje(Ir.flatten(e),Ir.flatten(e.map((a,i)=>a.map(()=>String(i))))).pValue;return isNaN(r)?1:r}case"wilcoxon":{if(e.length>2)throw new Error("more than 2 datasets passed");if(n){if(e[0].length!==e[1].length)throw Error("Different size groups in paired test");return Pft(e[0],e[1]).pValue}let r=new z7t().mannWhitneyUTest(e[0],e[1]);return isNaN(r)?1:r}case"kruskalWallis":{let r=qut(...e).pValue;return isNaN(r)?1:r}default:throw new Error("Unknown test method")}}function U7t(e){return e.slice(0,-1).reduce((t,n,r)=>t.concat(e.slice(r+1).map(a=>[n,a])),[])}function j7t(e,t,n,r,a){return{type:"stats",values:t.reduce((i,o)=>{let s=[];switch(e.statType){case"overall":{let c=n.map(A=>a.getColumnByGrouping([...o,A],r.value)).filter(A=>A.length>0);if(c.length<2)break;let f=MP(c,e.testMethod,e.paired);s=[[["overall"],f]];break}case"referenceGroup":{let c=e.referenceGroup===null?null:String(e.referenceGroup);if(c!==null&&!n.includes(c))throw new Error(`Reference group ${c} for ${e.testMethod} test is not in available groups`);let f=a.getColumnByGrouping([...o,c],r.value);if(f.length===0){s=[];break}let A=n.filter(m=>m!==c).map(m=>[m,a.getColumnByGrouping([...o,m],r.value)]).filter(([,m])=>m.length>0);if(A.length<2&&e.correctionMethod!==null)break;let h=bK(A.map(([,m])=>MP([f,m],e.testMethod,e.paired)),e.correctionMethod);s=A.map(([m],g)=>[[m],h[g]]);break}case"pairwise":{let c=U7t(n).map(([A,h])=>[[A,h],[a.getColumnByGrouping([...o,A],r.value),a.getColumnByGrouping([...o,h],r.value)]]).filter(([,[A,h]])=>A.length&&h.length);if(c.length<1)break;let f=bK(c.map(([,A])=>MP(A,e.testMethod,e.paired)),e.correctionMethod);s=c.map(([A],h)=>[A,f[h]]);break}default:throw new Error("Unknown statType")}return i[o.join("_")]=s,i},{}),meta:{statType:e.statType,testMethod:e.testMethod,format:e.format,ns:e.ns,significanceLevels:e.significanceLevels}}}var C9="#3e9838",h2="21",m2=3,np=class{},xK=class extends np{constructor(t){super();Me(this,"type","box");Me(this,"stat",{upper:.75,medium:.5,lower:.25,k:1.5});Me(this,"aes",{showOutliers:!0,boxWidth:"auto",dotShape:h2,dotFill:Zt,dotSize:m2,lineColor:Zt,fillColor:C9,lineWidth:1,lineShape:"solid",opacity:1});this.stat={...this.stat,...t.stat},this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="box"&&Object.keys(this.stat).every(n=>this.stat[n]===t.stat[n])}},SK=class extends np{constructor(t){super();Me(this,"type","violin");Me(this,"stat",{bandwidth:"auto",stepsCount:40,trim:!0});Me(this,"aes",{width:"auto",lineColor:Zt,fillColor:C9,lineWidth:1,lineShape:"solid",opacity:1,showQuartiles:!0,medianLineStyle:"solid",quartilesLineStyle:"dashed"});this.stat={...this.stat,...t.stat},this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="violin"&&(this.stat.bandwidth!==t.stat.bandwidth||this.stat.trim!==t.stat.trim||this.stat.stepsCount!==t.stat.stepsCount)}},BK=class extends np{constructor(t){super();Me(this,"type","dot");Me(this,"aes",{showOutliers:!0,jitter:.8,lineColor:"none",dotFill:Zt,dotShape:h2,dotSize:m2,opacity:1});this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="dot"&&this.aes.showOutliers===t.aes.showOutliers}},kK=class extends np{constructor(t){super();Me(this,"type","line");Me(this,"pointsValues");Me(this,"aes",{showOutliers:!0,lineWidth:1,lineShape:"solid",fillColor:"none",lineColor:Zt,dotShape:h2,dotSize:m2,opacity:1});this.pointsValues=t.pointsValues,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="line"&&this.pointsValues===t.pointsValues}},TK=class extends np{constructor(t){super();Me(this,"type","errorbar");Me(this,"pointsValues");Me(this,"interval");Me(this,"aes",{showDots:!0,width:"auto",lineWidth:1,fillColor:"none",lineColor:Zt,dotShape:h2,dotSize:m2,opacity:1});this.pointsValues=t.pointsValues,this.interval=t.interval,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="errorbar"&&this.pointsValues===t.pointsValues&&this.interval===t.interval}},_K=class extends np{constructor(t){super();Me(this,"type","bar");Me(this,"height");Me(this,"aes",{width:"auto",lineWidth:1,fillColor:"none",lineColor:Zt,opacity:1});this.height=t.height??"max",this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="bar"&&this.height===t.height}},PK=class extends np{constructor(t){super();Me(this,"type","stackedBar");Me(this,"normalize",!1);Me(this,"aes",{width:"auto",lineWidth:1,fillColor:C9,lineColor:"none",opacity:1});this.normalize=t.normalize??!1,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="stackedBar"&&t.normalize===this.normalize}},MK=class extends np{constructor(t){super();Me(this,"type","logo");Me(this,"normalize",!1);Me(this,"aes",{width:"auto",fillColor:C9,lineColor:"none",opacity:1});this.normalize=t.normalize??!1,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="logo"&&t.normalize===this.normalize}},DK=class extends np{constructor(t){super();Me(this,"type","binnedDots");Me(this,"method");Me(this,"position");Me(this,"keyColumn");Me(this,"aes",{showOutliers:!0,width:"auto",lineWidth:1,fillColor:"none",lineColor:Zt,opacity:1});this.method=t.method??"dotdensity",this.position=t.position??"stack",this.keyColumn=t.keyColumn??null,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){var n,r;return t.type==="binnedDots"&&this.method===t.method&&this.position===t.position&&((n=this.keyColumn)==null?void 0:n.value)===((r=t.keyColumn)==null?void 0:r.value)}},HK=class extends np{constructor(t){super();Me(this,"type","pairedPoints");Me(this,"linkColumn");Me(this,"aes",{showOutliers:!0,lineWidth:1,lineColor:Zt,lineShape:"solid",dotFill:Zt,dotSize:m2,dotShape:h2,opacity:1});this.linkColumn=t.linkColumn,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="pairedPoints"&&this.aes.showOutliers===t.aes.showOutliers&&this.linkColumn.value===t.linkColumn.value}},IK=class extends np{constructor(t){super();Me(this,"type","sina");Me(this,"aes",{showOutliers:!0,width:"auto",dotFill:C9,dotSize:m2,dotShape:h2,opacity:1});this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="sina"&&this.aes.showOutliers===t.aes.showOutliers}},W8=class extends np{constructor(t){var n,r,a;super();Me(this,"type","stat");Me(this,"statType");Me(this,"testMethod");Me(this,"paired");Me(this,"ns");Me(this,"format");Me(this,"referenceGroup",null);Me(this,"correctionMethod",null);Me(this,"significanceLevels");this.statType=t.statType,this.testMethod=t.testMethod,this.paired=t.paired??!1,this.ns=t.ns??!0,this.format=t.format??"pValue",this.statType==="referenceGroup"&&(this.referenceGroup=t.referenceGroup??null),(this.statType==="referenceGroup"||this.statType==="pairwise")&&(this.correctionMethod=t.correctionMethod??null),this.significanceLevels={one:((n=t.significanceLevels)==null?void 0:n.one)??.05,two:((r=t.significanceLevels)==null?void 0:r.two)??.01,three:((a=t.significanceLevels)==null?void 0:a.three)??.001}}isEqualForCalculation(t){return t.type==="stat"&&Object.keys(this).every(n=>this[n]===t[n])}},LK=class{constructor(e){Me(this,"id");Me(this,"type","discrete");Me(this,"y");Me(this,"keyColumn");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"facetSettings");Me(this,"facetBy");Me(this,"chartSettings");Me(this,"layers");var t,n,r,a,i,o,s,c;U3t.parse(e),this.id=Ir.uniqueId("settings"),this.y=e.y,this.keyColumn=e.keyColumn??null,this.primaryGrouping=e.primaryGrouping??null,this.secondaryGrouping=e.secondaryGrouping??null,this.facetSettings={sharedX:!0,sharedY:!0,titlePosition:"left",...e.facetSettings},this.facetBy=e.facetBy??[],this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(this.facetBy.length?400:600),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(this.facetBy.length?250:350)},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},orientation:e.orientation??"vertical",yAxis:{title:((a=e.y)==null?void 0:a.label)??e.y.value??"",scale:"linear",showGrid:!0,showTicks:!0,...e.yAxis},xAxis:{title:((o=(i=e.primaryGrouping)==null?void 0:i.columnName)==null?void 0:o.label)??((s=e.primaryGrouping)==null?void 0:s.columnName.value)??"",showGrid:!0,showTicks:!0,linesBetweenCategories:!0,labelsPosition:"center",...e.xAxis},frame:{type:((c=e.frame)==null?void 0:c.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{box:{show:!0},violin:{show:!0},boxOutliers:{show:!0},line:{show:!0},errorBar:{show:!0},dot:{show:!0},binnedDots:{show:!0},pairedPoints:{show:!0},stackedBar:{show:!0},...e.tooltips}},this.layers=e.layers.map(f=>{if(f.type==="box")return new xK(f);if(f.type==="violin")return new SK(f);if(f.type==="dot")return new BK(f);if(f.type==="line")return new kK(f);if(f.type==="errorbar")return new TK(f);if(f.type==="bar")return new _K(f);if(f.type==="stackedBar")return new PK(f);if(f.type==="stat")return new W8(f);if(f.type==="binnedDots")return new DK(f);if(f.type==="pairedPoints")return new HK(f);if(f.type==="sina")return new IK(f);if(f.type==="logo")return new MK(f);vA(f,"Unknown layer type")}).filter(Boolean)}};function RK(e,t=null,n=null){let r=(t==null?void 0:t.value)??null,a=r===null?["null"]:e.getColumnCategories(r);return Ir.intersection(n??a,a).map(String)}function NK(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}function X8(e,t){if(!t)return{keys:["null"],value:null,label:"",valueLabels:{null:""},inheritedAes:null};let n=t.columnName.value,r=Ir.uniqBy(e.rows,c=>c[n]),a=c=>String(c[n]),i=c=>t.columnName.valueLabels?String(c[t.columnName.valueLabels]):a(c),o=r.map(a),s=(t.order??o).map(String);return{keys:Ir.intersection(s,o),value:n,label:t.columnName.label??n,valueLabels:r.reduce((c,f)=>(c[a(f)]=i(f),c),{}),inheritedAes:t.inheritedAes??null}}var G7t=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new j5t);Me(this,"calculatedData",null);this.settings=new LK(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new LK(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for discrete")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.chartSettings.yAxis.scale!==n.chartSettings.yAxis.scale||(((r=t.primaryGrouping)==null?void 0:r.columnName.value)??"")!==(((a=n.primaryGrouping)==null?void 0:a.columnName.value)??"")||(((i=t.secondaryGrouping)==null?void 0:i.columnName.value)??"")!==(((o=n.secondaryGrouping)==null?void 0:o.columnName.value)??"")||t.facetBy.some((s,c)=>{var f;return s.value!==((f=n.facetBy[c])==null?void 0:f.value)})||t.layers.length!==n.layers.length||t.layers.some((s,c)=>!s.isEqualForCalculation(n.layers[c]))}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{chartSettings:t,y:n,keyColumn:r,facetBy:a,layers:i,facetSettings:o}=this.settings,{yAxis:s}=t,c=this.data.rows.every(x=>{let k=x[n.value];return k===null||!(Number(k)<0)}),f=X8(this.data,this.settings.primaryGrouping),A=X8(this.data,this.settings.secondaryGrouping),h=a.map(x=>x.value)??null,m=a.length?NK(a.map(x=>{var k;return RK(this.data,x,(k=o==null?void 0:o.order)==null?void 0:k[x.value])})):[["null"]];this.data.setGrouping([...h,f.value,A.value]);let g=m.reduce((x,k)=>(x[k.join("_")]=f.keys.filter(_=>this.data.getRowsByGrouping([...k,_]).length>0),x),{}),b=i.filter(x=>!(x instanceof W8)).map(x=>{if(x instanceof xK)return W5t(x,m,f.keys,A.keys,this.data,n,r,s);if(x instanceof SK)return t7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof BK)return c7t(x,m,f.keys,A.keys,this.data,n,s,r);if(x instanceof kK)return d7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof TK)return g7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof _K)return w7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof PK)return C7t(x,m,f.keys,A.keys,this.data,n);if(x instanceof DK)return x7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof HK)return B7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof IK)return u7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof MK)return V2t(x,m,f.keys,A.keys,this.data,n);throw new Error("Unknown layer type")}),C=i.filter(x=>x instanceof W8).map(x=>{if(f.value===null)throw new Error("Cannot calculate p-value without data grouping");return j7t(x,m,f.keys,n,this.data)});this.calculatedData={layersData:b,statsLayersData:C,primaryGrouping:f,secondaryGrouping:A,facetKeyLists:m,nonEmptyGroupsByFacets:g,onlyPositive:c}}_updateAesInData(){if(this.calculatedData===null)return;let{layers:t,facetBy:n,primaryGrouping:r,secondaryGrouping:a,facetSettings:i}=this.settings,o=t.filter(s=>!(s instanceof W8));for(let s=0;s<o.length;s++){let c=o[s];"aes"in c&&(this.calculatedData.layersData[s].aes=c.aes)}this.calculatedData.primaryGrouping=X8(this.data,r),this.calculatedData.secondaryGrouping=X8(this.data,a),this.calculatedData.facetKeyLists=n.length?NK(n.map(s=>{var c;return RK(this.data,s,(c=i==null?void 0:i.order)==null?void 0:c[s.value])})):[["null"]]}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,keyColumn:r,facetSettings:a}=this.settings;this.chartRenderer.render(t,n,this.calculatedData.primaryGrouping,this.calculatedData.secondaryGrouping,a,this.calculatedData.facetKeyLists.map(i=>i.join("_")),this.calculatedData.facetKeyLists,this.calculatedData.layersData,this.calculatedData.statsLayersData,r,this.calculatedData.nonEmptyGroupsByFacets,this.calculatedData.onlyPositive)}};function Y7t(e){let t=cL(e),n=tu(e);return t===void 0||n===void 0||t===0?r=>r:r=>(r-n)/t}function W7t(e){let t=tu(e),[n,r]=$A(e);return t===void 0||n===void 0||r===void 0||r===n?a=>a:a=>(a-t)/(r-n)}function X7t(e,t){return e==="standardScaling"?Y7t(t):e==="meanNormalization"?W7t(t):n=>n}function DP(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}function K7t(e,t,n,r,a,i,o,s,c,f,A,h){let m=a.length?a.map(Y=>e.getColumnCategories(Y.value)):[["null"]],g=i.length?i.map(Y=>e.getColumnCategories(Y.value)):[["null"]],b=o.length?o.map(Y=>e.getColumnCategories(Y.value)):[["null"]],C=DP(m),x=DP(g),k=DP(b),_=C.map(Y=>Y.join("_")),D=x.map(Y=>Y.join("_")),O=k.map(Y=>Y.join("_")),I={meta:{facetKeys:_,xGroupKeys:D,yGroupKeys:O,xKeysByGroups:{},yKeysByGroups:{},xLabels:{},yLabels:{},xGroupLabels:{},yGroupLabels:{},xDataByKeys:{},yDataByKeys:{},facetKeyValues:_.reduce((Y,X,oe)=>(Y[X]=C[oe],Y),{}),xGroupKeyValues:D.reduce((Y,X,oe)=>(Y[X]=x[oe],Y),{}),yGroupKeyValues:O.reduce((Y,X,oe)=>(Y[X]=k[oe],Y),{}),valueExtent:[1/0,-1/0]},facets:{}},$=t.valueLabels??t.value,Q=n.valueLabels??n.value,ee=s.filter(Y=>Y.axis==="x").map(Y=>Y.valueColumn.value),K=s.filter(Y=>Y.axis==="y").map(Y=>Y.valueColumn.value),re=Object.values(c??{}).map(Y=>Y.value),U=Object.values(f??{}).map(Y=>Y.value),G=Ir.uniq([...ee,...re,$]),Z=Ir.uniq([...K,...U,Q]);if(e.rows.forEach(Y=>{let X=a.length?a.map(ze=>Y[ze.value]).join("_"):"null",oe=i.length?i.map(ze=>Y[ze.value]).join("_"):"null",me=o.length?o.map(ze=>Y[ze.value]).join("_"):"null",ae=i.length?i.map(ze=>Y[ze.valueLabels??ze.value]).join(", "):"",ye=o.length?o.map(ze=>Y[ze.valueLabels??ze.value]).join(", "):"";I.meta.xGroupLabels[oe]=ae,I.meta.yGroupLabels[oe]=ye;let Ce=Y[t.value],ce=Y[n.value],ge=Y[r.value]??h;if(!(Ce===null||ce===null||ge===null)){if(I.facets[X]||(I.facets[X]={xKeys:[],yKeys:[],xKeysByGroups:{},yKeysByGroups:{},cells:{}}),I.facets[X].xKeysByGroups[oe]||(I.facets[X].xKeysByGroups[oe]=[]),I.facets[X].yKeysByGroups[me]||(I.facets[X].yKeysByGroups[me]=[]),I.facets[X].xKeys.push(Ce),I.facets[X].yKeys.push(ce),I.facets[X].xKeysByGroups[oe].push(Ce),I.facets[X].yKeysByGroups[me].push(ce),I.facets[X].cells[Ce]||(I.facets[X].cells[Ce]={}),I.meta.valueExtent[0]=Math.min(ge,I.meta.valueExtent[0]),I.meta.valueExtent[1]=Math.max(ge,I.meta.valueExtent[1]),I.facets[X].cells[Ce][ce])throw Error(`More than 1 value for x=${Ce}, y=${ce}`);if(I.meta.xLabels[Ce]&&String(Y[$])!==I.meta.xLabels[Ce])throw Error(`More than 1 x-label value for x=${Ce}`);if(I.meta.yLabels[ce]&&String(Y[Q])!==I.meta.yLabels[ce])throw Error(`More than 1 y-label value for y=${ce}`);I.meta.xLabels[Ce]=String(Y[$]),I.meta.yLabels[ce]=String(Y[Q]),G.forEach(ze=>{let Ne=typeof I.meta.xDataByKeys[ze]<"u",Ge=Ne&&typeof I.meta.xDataByKeys[ze][Ce]<"u";if(Ne||(I.meta.xDataByKeys[ze]={}),Ge&&I.meta.xDataByKeys[ze][Ce]!==Y[ze])throw Error(`More than 1 value for x = ${Ce} and column = ${ze}`);Ge||(I.meta.xDataByKeys[ze][Ce]=Y[ze])}),Z.forEach(ze=>{let Ne=typeof I.meta.yDataByKeys[ze]<"u",Ge=Ne&&typeof I.meta.yDataByKeys[ze][ce]<"u";if(Ne||(I.meta.yDataByKeys[ze]={}),Ge&&I.meta.yDataByKeys[ze][ce]!==Y[ze])throw Error(`More than 1 value for y = ${ce} and column = ${ze}`);Ge||(I.meta.yDataByKeys[ze][ce]=Y[ze])}),I.facets[X].cells[Ce][ce]={id:`${Ce}_${ce}`,x:Ce,y:ce,value:ge,normalizedValue:ge,data:Y}}}),_.forEach(Y=>{let X=I.facets[Y];X.xKeys=Ir.uniq(X.xKeys),X.yKeys=Ir.uniq(X.yKeys),D.forEach(oe=>{I.facets[Y].xKeysByGroups[oe]=Ir.uniq(I.facets[Y].xKeysByGroups[oe])}),O.forEach(oe=>{I.facets[Y].yKeysByGroups[oe]=Ir.uniq(I.facets[Y].yKeysByGroups[oe])})}),A){let Y=[1/0,-1/0];_.forEach(X=>{let{xKeys:oe,yKeys:me,cells:ae}=I.facets[X],ye=A.direction==="row"?oe:me,Ce=A.direction==="row"?me:oe,ce=A.direction==="row"?(ge,ze)=>{var Ne;return(Ne=ae[ge])==null?void 0:Ne[ze]}:(ge,ze)=>{var Ne;return(Ne=ae[ze])==null?void 0:Ne[ge]};Ce.forEach(ge=>{let ze=[];ye.forEach(Ge=>{var Xe;let Oe=(Xe=ce(Ge,ge))==null?void 0:Xe.value;Oe!==void 0&&ze.push(Oe)});let Ne=X7t(A.method,ze);ye.forEach(Ge=>{let Oe=ce(Ge,ge);Oe!==void 0&&(Oe.normalizedValue=Ne(Oe.value),Y[0]=Math.min(Oe.normalizedValue,Y[0]),Y[1]=Math.max(Oe.normalizedValue,Y[1]))})})}),I.meta.valueExtent=Y}return I.meta.xKeysByGroups=D.reduce((Y,X)=>(Y[X]=Ir.uniq(Ir.flatten(_.map(oe=>I.facets[oe].xKeysByGroups[X]))),Y),{}),I.meta.yKeysByGroups=O.reduce((Y,X)=>(Y[X]=Ir.uniq(Ir.flatten(_.map(oe=>I.facets[oe].yKeysByGroups[X]))),Y),{}),I.meta.valueExtent[0]===1/0&&(I.meta.valueExtent[0]=0),I.meta.valueExtent[1]===-1/0&&(I.meta.valueExtent[1]=0),I}function $K(e,t){let n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t[r])*(e[r]-t[r]);return n}function FK(e,t){return Math.sqrt($K(e,t))}var VK=(e,t,n)=>{let r=0;for(let a of e)for(let i of t)r+=n[a][i];return r/e.length/t.length},Z7t=(e,t,n)=>{let r=0;for(let a of e)for(let i of t)r=Math.max(r,n[a][i]);return r},J7t=(e,t,n)=>{let r=1/0;for(let a of e)for(let i of t)r=Math.min(r,n[a][i]);return r};function q7t(e){switch(e){case"average":return VK;case"complete":return Z7t;case"single":return J7t;default:return VK}}function ewt(e){switch(e){case"euclidean":return FK;case"squaredEuclidean":return $K;default:return FK}}function OK(e=[],t,n="euclidean",r="average"){let a=ewt(n),i=q7t(r),o=t.map(c=>t.map(f=>a(c,f))),s=e.map((c,f)=>({height:0,keys:[c],indexes:[f],children:[]}));for(let c=0;c<e.length&&!(c>=e.length-1);c++){let f=1/0,A=0,h=0;for(let g=0;g<s.length;g++)for(let b=g+1;b<s.length;b++){let C=i(s[g].indexes,s[b].indexes,o);C<f&&(f=C,A=g,h=b)}let m={keys:[...s[A].keys,...s[h].keys],indexes:[...s[A].indexes,...s[h].indexes],height:f,children:[s[A],s[h]]};s.splice(Math.max(A,h),1),s.splice(Math.min(A,h),1),s.push(m)}return s[0]}function twt(e,t,n,r){let{facetKeys:a,xGroupKeys:i,yGroupKeys:o}=e.meta,s={};if(t&&r.sharedX)throw Error("Dendrogram on X axis is not available with shared by facets X axis");return a.forEach(c=>{let f={hierarchyX:[],hierarchyY:[]},A=e.facets[c];if(t){let h=[],m=[];i.forEach(g=>{let b=A.xKeysByGroups[g],C=A.yKeys,x=OK(b,b.map(k=>C.map(_=>{var D;return((D=A.cells[k][_])==null?void 0:D.normalizedValue)??t.fillNA})),t.distance,t.linkage);e.facets[c].xKeysByGroups[g]=x.keys,m.push(...x.keys),h.push(x)}),e.facets[c].xKeys=m,f.hierarchyX=h.map(g=>vb(g))}if(n){let h=[],m=[];o.forEach(g=>{let b=A.yKeysByGroups[g],C=A.xKeys,x=OK(b,b.map(k=>C.map(_=>{var D;return((D=A.cells[_][k])==null?void 0:D.normalizedValue)??n.fillNA})),n.distance,n.linkage);e.facets[c].yKeysByGroups[g]=x.keys,m.push(...x.keys),h.push(x)}),e.facets[c].yKeys=m,f.hierarchyY=h.map(g=>vb(g))}s[c]=f}),s}function nwt(e,t,n,r,a,i,o,s,c,f,A,h,m,g){let b=h.length>1&&(!c||o.includes(t.groupingPosition)),C=!c||o.includes(t.position),x=A.length>1&&(!s||o.includes(e.groupingPosition)),k=!s||o.includes(e.position),_=f.length>1,D=r.filter(oe=>o.includes(oe.position)||!s&&["left","right"].includes(oe.position)||!c&&["top","bottom"].includes(oe.position)),O=D.filter(oe=>oe.position==="left").length,I=D.filter(oe=>oe.position==="right").length,$=D.filter(oe=>oe.position==="top").length,Q=D.filter(oe=>oe.position==="bottom").length,ee=e.showTicks?U8:0,K=t.showTicks?U8:0,re=k&&e.showTitle?Vm:0,U=C&&t.showTitle?Vm:0,G=k&&e.showAxisLabels&&m>o2?n.xAxisCaptions+ee+l2:0,Z=C&&t.showAxisLabels&&g>o2?n.yAxisCaptions+K+l2:0,Y=x&&e.showGroupLabels?n.xGroupCaptions:0,X=b&&t.showGroupLabels?n.yGroupCaptions:0;return{left:{dendro:!(i!=null&&i.hidden)&&(i==null?void 0:i.position)==="left"?i.size:0,axisTitle:t.position==="left"?U:0,groups:t.groupingPosition==="left"?X:0,axis:t.position==="left"?Z:0,annotations:O*Qd+(O&&s2)},right:{dendro:!(i!=null&&i.hidden)&&(i==null?void 0:i.position)==="right"?i.size:0,axisTitle:t.position==="right"?U:0,groups:t.groupingPosition==="right"?X:0,axis:t.position==="right"?Z:0,annotations:I*Qd+(I&&s2)},top:{facetTitle:_?U2t:0,dendro:!(a!=null&&a.hidden)&&(a==null?void 0:a.position)==="top"?a.size:0,axisTitle:e.position==="top"?re:0,groups:e.groupingPosition==="top"?Y:0,axis:e.position==="top"?G:0,annotations:$*Qd+($&&s2)},bottom:{dendro:!(a!=null&&a.hidden)&&(a==null?void 0:a.position)==="bottom"?a.size:0,axisTitle:e.position==="bottom"?re:0,groups:e.groupingPosition==="bottom"?Y:0,axis:e.position==="bottom"?G:0,annotations:Q*Qd+(Q&&s2)}}}function rwt(e,t,n){return{left:s1.left.reduce((r,a,i)=>{let o=i>0?s1.left[i-1]:null,s=e.left[a];return r[a]={x:o?r[o].x-s:-s,y:0,width:s,height:n,isVisible:s>0},r},{}),right:s1.right.reduce((r,a,i)=>{let o=i>0?s1.right[i-1]:null,s=e.right[a];return r[a]={x:o?r[o].x+r[o].width:t,y:0,width:s,height:n,isVisible:s>0},r},{}),top:s1.top.reduce((r,a,i)=>{let o=i>0?s1.top[i-1]:null,s=e.top[a];return r[a]={x:0,y:o?r[o].y-s:-s,width:t,height:s,isVisible:s>0},r},{}),bottom:s1.bottom.reduce((r,a,i)=>{let o=i>0?s1.bottom[i-1]:null,s=e.bottom[a];return r[a]={x:0,y:o?r[o].y+r[o].height:n,width:t,height:s,isVisible:s>0},r},{})}}function HP(e,t,n){let r=(t-e)/n,a=Ir.range(e,t-r/2,r);return a.push(t),a}function QK(e,t){let n=HP(0,1,e.length-1),r=Da().domain(n).range(e),a=HP(0,1,t.length-1).map(i=>r(i));return Hl().domain(t).range(a).unknown("#ccc")}function awt(e,t,n,r,a,i){let o=HP(0,1,e.length-1),s=Da().domain(o).range(e),c=[r,...o.filter(C=>C>r&&C<a),a],f=[a,...o.filter(C=>C>a&&C<i),i],A=(n-t)/2,h=c.map(C=>t+A*(C-r)/(a-r)),m=f.map(C=>(t+n)/2+A*(C-a)/(i-a)),g=c.map(C=>s(C)),b=f.map(C=>s(C));return Da().domain(h.concat(m.slice(1))).range(g.concat(b.slice(1)))}function iwt(e,t,n,r){let a=e.filter(A=>A.showTitle&&(t.includes(A.position)||!n&&["left","right"].includes(A.position)||!r&&["top","bottom"].includes(A.position))),i=a.filter(A=>A.titlePosition==="left").map(A=>A.valueColumn.label??A.valueColumn.value),o=a.filter(A=>A.titlePosition==="right").map(A=>A.valueColumn.label??A.valueColumn.value),s=a.filter(A=>A.titlePosition==="top").map(A=>A.valueColumn.label??A.valueColumn.value),c=a.filter(A=>A.titlePosition==="bottom").map(A=>A.valueColumn.label??A.valueColumn.value),f=new Dc("bold 14px Arial");return{left:Math.max(...i.map(A=>f.getTextWidth(A))),right:Math.max(...o.map(A=>f.getTextWidth(A))),top:Math.max(...s.map(A=>f.getTextWidth(A))),bottom:Math.max(...c.map(A=>f.getTextWidth(A)))}}function owt(e,t,n,r,a){let{facetKeys:i,xGroupKeys:o,yGroupKeys:s,xKeysByGroups:c,yKeysByGroups:f,xLabels:A,yLabels:h}=r.meta,m=e.xGroupLabels/180*Math.PI,g=e.yGroupLabels/180*Math.PI,b=e.xAxisLabels/180*Math.PI,C=e.yAxisLabels/180*Math.PI,x=0,k=0,_=e.xGroupLabels===45,D=e.xAxisLabels===45;if(_||D)if(!t.sharedX)i.forEach($=>{let Q=o.find(Z=>r.facets[$].xKeysByGroups[Z].length>0);if(!Q)return;let ee=r.facets[$].xKeysByGroups[Q],K=n.x[$],re=K>o2,U=ee.length*K/2,G=A[ee[0]];x=Math.max(x,(_?a.getTextWidth(Q)*Math.cos(m):0)-U,(D&&re?a.getTextWidth(G)*Math.cos(b):0)-K/2)});else{let $=o[0],Q=i[0];if($){let ee=c[$],K=n.x[Q],re=K>o2,U=ee.length*K/2,G=A[ee[0]];x=Math.max(x,(_?a.getTextWidth($)*Math.cos(m):0)-U,(D&&re?a.getTextWidth(G)*Math.cos(b):0)-K/2)}}let O=e.yGroupLabels===45,I=e.yAxisLabels===45;if(O||I)if(!t.sharedY)i.forEach($=>{let Q=Ir.findLast(s,Z=>r.facets[$].yKeysByGroups[Z].length>0);if(!Q)return;let ee=r.facets[$].yKeysByGroups[Q],K=n.y[$],re=K>o2,U=ee.length*K/2,G=h[ee[ee.length-1]];k=Math.max(k,(O?a.getTextWidth(Q)*Math.cos(g):0)-U,(I&&re?a.getTextWidth(G)*Math.cos(C):0)-K/2)});else{let $=s[s.length-1],Q=i[0];if($){let ee=f[$],K=n.y[Q],re=K>o2,U=ee.length*K/2,G=h[ee[ee.length-1]];k=Math.max(k,(O?a.getTextWidth($)*Math.cos(g):0)-U,(I&&re?a.getTextWidth(G)*Math.cos(C):0)-K/2)}}return{xCaptionTail:x,yCaptionTail:k}}function zK(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function lwt(e,t,n,r,a){if(e){let s=Qd/2,c=n==="top"?-5:a+5;return{x:s,y:c,rotate:t==="left"?-90:90,anchor:t==="left"&&n==="top"?"start":"end"}}let i=n==="right"?r+5:-5,o=Qd/2;return{x:i,y:o,rotate:0,anchor:n==="right"?"start":"end"}}function K8({data:e,scales:t,stepX:n,stepY:r,x:a,y:i,annotation:o,showTitle:s,width:c,height:f,colorScale:A,aes:h,frame:m,xGroupKeys:g,yGroupKeys:b,xKeysByGroups:C,yKeysByGroups:x,setSelectedAnnotation:k}){let{position:_,titlePosition:D,valueColumn:O}=o,I=_==="left"||_==="right",$=(I?t.y:t.x).domain(),Q=lwt(I,_,D,c,f);return le.jsxs("g",{transform:`translate(${a},${i})`,children:[$.map(ee=>{let K=e==null?void 0:e[ee],re=A.type==="continuous"?A.scale(Number(K)):A.scale(String(K)),U=I?0:t.x(ee),G=I?t.y(ee):0,Z=I?Qd:n,Y=I?r:Qd;return le.jsx("rect",{x:U,y:G,width:Z,height:Y,fill:re,stroke:h.cellStrokeColor,onMouseOver:()=>k({x:a+U+Z,y:i+G+Y/2,xKey:I?null:ee,yKey:I?ee:null,value:K,title:O.label??O.value}),onMouseLeave:()=>k(null)},ee)}),m.type==="groups"&&!I&&g.map(ee=>{let K=C[ee].length;if(K===0)return null;let re=K*n,U=t.x(C[ee][0]);return le.jsx("rect",{x:U,width:re,height:Qd,stroke:Zt,fill:"none"},`${U}_${i}`)}),m.type==="groups"&&I&&b.map(ee=>{let K=x[ee].length;if(K===0)return null;let re=K*r,U=t.y(x[ee][0]);return le.jsx("rect",{y:U,width:Qd,height:re,stroke:Zt,fill:"none"},`${a}_${U}`)}),s&&le.jsx("g",{fontWeight:"500",fontSize:"14px",transform:`translate(${Q.x},${Q.y}) rotate(${Q.rotate})`,children:le.jsx("text",{textAnchor:Q.anchor,dominantBaseline:"central",children:O.label??O.value})})]})}function Z8(e,t){return e.showTitle&&t.includes(e.titlePosition)}function swt({sideElementBBoxes:e,annotations:t,annotationColorScales:n,cellsMeta:r,chartEdgeSides:a,sharedX:i,sharedY:o,width:s,height:c,scales:f,stepX:A,stepY:h,aes:m,frame:g,xGroupKeys:b,yGroupKeys:C,xKeysByGroups:x,yKeysByGroups:k,setSelectedAnnotation:_}){let D=t.filter(U=>a.includes(U.position)||!i&&["left","right"].includes(U.position)||!o&&["top","bottom"].includes(U.position)),O=D.filter(U=>U.position==="left"),I=D.filter(U=>U.position==="right"),$=D.filter(U=>U.position==="top"),Q=D.filter(U=>U.position==="bottom"),{xDataByKeys:ee,yDataByKeys:K}=r,re={scales:f,stepX:A,stepY:h,width:s,height:c,aes:m,frame:g,xGroupKeys:b,yGroupKeys:C,xKeysByGroups:x,yKeysByGroups:k,setSelectedAnnotation:_};return le.jsxs("g",{children:[O.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:K[U.valueColumn.value],showTitle:Z8(U,a),x:e.left.annotations.x+G*Qd,y:e.left.annotations.y,...re},U.id)),I.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:K[U.valueColumn.value],showTitle:Z8(U,a),x:e.right.annotations.x+G*Qd+s2,y:e.right.annotations.y,...re},U.id)),$.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:ee[U.valueColumn.value],showTitle:Z8(U,a),x:e.top.annotations.x,y:e.top.annotations.y+G*Qd,...re},U.id)),Q.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:ee[U.valueColumn.value],showTitle:Z8(U,a),x:e.bottom.annotations.x,y:e.bottom.annotations.y+G*Qd+s2,...re},U.id))]})}function uwt({sideElementBBoxes:e,xGroupKeys:t,yGroupKeys:n,xKeysByGroups:r,yKeysByGroups:a,xGroupLabels:i,yGroupLabels:o,scales:s,stepX:c,stepY:f,xAxis:A,yAxis:h,labelAngles:m,debug:g}){let b=e.top.groups.isVisible||e.bottom.groups.isVisible,C=e.top.groups.isVisible?e.top.groups:e.bottom.groups,x=e.left.groups.isVisible||e.right.groups.isVisible,k=e.left.groups.isVisible?e.left.groups:e.right.groups;return le.jsxs("g",{children:[b&&le.jsx("g",{transform:`translate(${C.x},${C.y})`,children:t.map(_=>{let D=r[_].length;if(D===0)return null;let O=m.xGroupLabels!==0,I=A.groupingPosition==="top",$=D*c,Q=s.x(r[_][0])+$/2,ee=O?I?C.height:0:C.height/2,K=-m.xGroupLabels,re=O?I?"start":"end":"middle";return le.jsxs("g",{transform:`translate(${Q},${ee})`,children:[le.jsx("text",{transform:`rotate(${K})`,dominantBaseline:"central",textAnchor:re,children:i[_]}),g&&le.jsx("rect",{x:-$/2,width:$,height:C.height,stroke:"black",fill:"none"})]},_)})}),x&&le.jsx("g",{transform:`translate(${k.x},${k.y})`,children:n.map(_=>{let D=a[_].length;if(D===0)return null;let O=D*f,I=h.groupingPosition==="left",$=I?k.width:0,Q=s.y(a[_][0])+O/2,ee=m.yGroupLabels!==0,K=m.yGroupLabels===45?-45:(I?-1:1)*(90-m.yGroupLabels),re=ee?I?"end":"start":"middle";return le.jsxs("g",{transform:`translate(${$},${Q})`,children:[le.jsx("text",{y:ee?0:-k.width/2,transform:`rotate(${K})`,dominantBaseline:"central",textAnchor:re,children:o[_]}),g&&le.jsx("rect",{x:-k.width/2,y:-O/2,width:k.width,height:O,stroke:"black",fill:"none"})]},_)})})]})}function cwt({sideElementBBoxes:e,debug:t,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,labelAngles:f,xLabels:A,yLabels:h}){let m=i.showTicks?U8:0,g=o.showTicks?U8:0,b=e.top.axis.isVisible||e.bottom.axis.isVisible,C=e.top.axisTitle.isVisible?e.top.axisTitle:e.bottom.axisTitle,x=e.top.axis.isVisible?e.top.axis:e.bottom.axis,k=e.left.axis.isVisible||e.right.axis.isVisible,_=e.left.axisTitle.isVisible?e.left.axisTitle:e.right.axisTitle,D=e.left.axis.isVisible?e.left.axis:e.right.axis;return le.jsxs("g",{children:[le.jsxs("g",{children:[C.isVisible&&le.jsxs("g",{transform:`translate(${C.x},${C.y})`,children:[le.jsx("text",{x:C.width/2,y:C.height/2,textAnchor:"middle",dominantBaseline:"central",children:i.title}),t&&le.jsx("rect",{width:C.width,height:C.height,stroke:Zt,fill:"none"})]}),b&&le.jsxs("g",{fontSize:"14px",transform:`translate(${x.x},${x.y})`,children:[n.map(O=>{let I=f.xAxisLabels!==0,$=i.position==="bottom",Q=$?0:x.height,ee=$?Q+m:Q-m,K=$?ee+l2:ee-l2,re=a.x(O)+s/2,U=-f.xAxisLabels;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:re,y1:Q,y2:ee,stroke:Zt}),le.jsx("text",{x:re,y:K,textAnchor:I?$?"end":"start":"middle",transform:`rotate(${U},${re},${K})`,dominantBaseline:I?"central":$?"hanging":"auto",children:A[O]})]},O)}),t&&le.jsx("rect",{width:x.width,height:x.height,stroke:Zt,fill:"none"})]})]}),le.jsxs("g",{children:[_.isVisible&&le.jsx("g",{transform:`translate(
15186
+ M-${a},${t}L0,${t-2*a}L${a},${t}z`,fill:"none",stroke:n})}case"12":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z M0,-${t}L 0,${t} M -${t},0 L ${t},0`,fill:"none",stroke:n});case"13":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z M-${t},-${t}L ${t},${t} M ${t},-${t} L -${t},${t}`,fill:"none",stroke:n});case"14":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z M-${t},${t}L0,${-t}L${t},${t}`,fill:"none",stroke:n});case"15":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z`,fill:n,stroke:n});case"16":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z`,fill:n,stroke:n});case"17":return le.jsx("path",{d:`M0,-${t}L ${2*t*Math.tan(Math.PI/6)},${t}L ${-2*t*Math.tan(Math.PI/6)},${t}z`,fill:n,stroke:n});case"18":{let a=t*F8;return le.jsx("path",{d:`M0,-${a}L ${a},0 L 0,${a} L -${a},0z`,fill:n,stroke:n})}case"20":{let a=t*2/3;return le.jsx("path",{d:`M -${a},0 a ${a},${a} 0 1,0 ${a*2},0 a ${a},${a} 0 1,0 -${a*2},0z`,fill:n,stroke:n})}case"22":return le.jsx("path",{d:`M -${t},-${t} l ${t*2},0 l 0,${t*2} l -${t*2},0 l 0,-${t*2}z`,fill:n,stroke:r??d9(n)});case"21":return le.jsx("path",{d:`M -${t},0 a ${t},${t} 0 1,0 ${t*2},0 a ${t},${t} 0 1,0 -${t*2},0z`,fill:n,stroke:r??d9(n)});case"24":return le.jsx("path",{d:`M0,-${t}L ${2*t*Math.tan(Math.PI/6)},${t}L ${-2*t*Math.tan(Math.PI/6)},${t}z`,fill:n,stroke:r??d9(n)});case"23":{let a=t*F8;return le.jsx("path",{d:`M0,-${a}L ${a},0 L 0,${a} L -${a},0z`,fill:n,stroke:r??d9(n)})}case"25":return le.jsx("path",{d:`M${-2*t*Math.tan(Math.PI/6)},-${t}L ${2*t*Math.tan(Math.PI/6)},-${t}L0,${t}z`,fill:n,stroke:r??d9(n)});default:vA(e,`Unknown point shape ${e}`)}}var P2t=12;function WX({nodes:e,rootPosition:t,showLeavesLabels:n,showNodesLabels:r,aesGetters:a,selectedNodeId:i,onClick:o,onSelectedUpdate:s}){let c=t==="top",[f,A]=Vn.useState(null);return Vn.useEffect(()=>{A(null)},[i]),le.jsxs(le.Fragment,{children:[le.jsx("g",{children:e.map(h=>{let m=h.data.rawData[0],g=a.nodeSize(m),b=a.nodeColor(m),C=c?h.x:h.y,x=c?h.y:h.x;return le.jsx("g",{transform:`translate(${C},${x})`,style:{cursor:"pointer"},onClick:k=>{k.stopPropagation(),o({x:C+ic.LEFT,y:x+ic.TOP,info:h.data.rawData}),s(h)},children:le.jsx("g",{children:le.jsx("circle",{cx:0,cy:0,r:g+P2t,fill:i===h.id?IX:f===h.id?b:"transparent",opacity:AP,onMouseOver:()=>A(h.id??null),onMouseLeave:()=>A(null)})})},h.id)})}),le.jsx("g",{children:e.map(h=>{let m=h.data.rawData[0],g=a.nodeShape(m),b=a.nodeSize(m),C=a.nodeColor(m),x=c?h.x:h.y,k=c?h.y:h.x;return le.jsx("g",{transform:`translate(${x},${k})`,style:{cursor:"pointer"},onClick:_=>{_.stopPropagation(),o({x:x+ic.LEFT,y:k+ic.TOP,info:h.data.rawData}),s(h)},children:le.jsx("g",{onMouseOver:()=>A(h.id??null),onMouseLeave:()=>A(null),children:Af(g,b,i===h.id?IX:C)})},h.id)})}),le.jsx("g",{children:e.map(h=>{let m=h.data.rawData[0],g=a.nodeSize(m),b=c?h.x:h.y,C=c?h.y:h.x;return le.jsx("g",{transform:`translate(${b},${C})`,style:{pointerEvents:"none"},children:(r&&h.children||n&&!h.children)&&le.jsx("text",{x:g+4,y:"4",paintOrder:"stroke",stroke:"white",strokeWidth:"3",children:h.data.label})},h.id)})})]})}var XX=14,V8=12,A9=12,O8=-12;function M2t({aes:e,label:t}){let n=Af(e.shape,e.size,e.color);return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${A9/2},${A9/2})`,children:n}),le.jsx("text",{x:A9+8,y:A9/2,dominantBaseline:"central",fontWeight:500,children:t})]})}function D2t({legendData:e}){let t=e.items.filter(n=>n.type==="continuous");return le.jsxs("g",{children:[le.jsx("defs",{children:t.map(n=>le.jsx("linearGradient",{id:n.id,gradientTransform:"rotate(90)",children:n.scale.domain().map(r=>{let a=n.scale.domain(),i=a[a.length-1]-a[0],o=i>0?(r-a[0])/i*100:0;return le.jsx("stop",{offset:`${o}%`,stopColor:n.scale(r)},r)})},n.id))}),e.items.map(n=>{if(n.type==="continuous"){let r=Math.min(...n.values),a=Math.max(...n.values);return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:O8,children:n.title}),le.jsx("rect",{x:"0",y:"0",width:XX,height:n.height,stroke:Zt,fill:`url(#${n.id})`}),le.jsx("g",{transform:`translate(${XX},0)`,children:n.values.map(i=>{let o=a-r,s=o>0?n.height*(i-r)/o:0;return le.jsxs("g",{transform:`translate(0,${s})`,children:[le.jsx("line",{x1:"0",x2:-4,stroke:Zt}),le.jsx("text",{x:8,y:4,children:i})]},i)})}),!1]},n.id)}if(n.type==="discrete")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:O8,children:n.title}),n.values.map((r,a)=>le.jsxs("g",{transform:`translate(0, ${a*(V8+4)})`,children:[le.jsx("rect",{x:"0",y:"0",width:V8,height:V8,fill:n.scale(r),rx:"1",ry:"1"}),le.jsx("text",{x:V8+8,y:10,children:r})]},r)),!1]},n.id);if(n.type==="nodes")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:O8,children:n.title}),n.values.map((r,a)=>le.jsx("g",{transform:`translate(0, ${a*(A9+4)})`,children:le.jsx(M2t,{aes:n.scale(r),label:n.labels[r]})},r)),!1]},n.id);if(n.type==="size"){let r=n.height/n.values.length;return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:O8,children:n.title}),n.values.map((a,i)=>{let o=n.scale(a);return le.jsxs("g",{transform:`translate(0, ${i*r})`,children:[le.jsx("circle",{r:o,cx:r/2,cy:r/2,fill:Zt}),le.jsx("text",{x:r+4,y:r/2,alignmentBaseline:"central",children:n.labels[a]})]},a)}),!1]},n.id)}})]})}function KX(e){if(!e)return null;let t=new Set,n=e;for(;n;)t.add(n.id),n=n.parent;return t}function H2t({chartSettings:e,chartSizes:t,nodes:n,links:r,connectionType:a,rootPosition:i,edgeInheritance:o,showNodes:s,showEdges:c,showLeavesLabels:f,showNodesLabels:A,aesGetters:h,labels:m,heatmapData:g,heatmapScales:b,heatmapStep:C,heatmapColor:x,heatmapLabels:k,legendData:_,onClick:D}){let O=Vn.useRef(null),[I,$]=Vn.useState(null),Q=Vn.useRef(null);Vn.useEffect(()=>{Q.current&&$(Q.current);function X(){K(null),U(null)}function oe(me){Object.entries(me.detail).forEach(([ae,ye])=>{if(ae==="selectedNode"){let Ce=n.find(ce=>ce.data.rawData[0].id===ye)??null;K(KX(Ce)),U(Ce)}})}return document.addEventListener("click",X),document.addEventListener(pP,oe),()=>{document.removeEventListener("click",X),document.removeEventListener(pP,oe)}},[]);let[ee,K]=gb.useState(null),[re,U]=gb.useState(null),G=ee!==null,Z={connectionType:a,rootPosition:i,edgeInheritance:o,aesGetters:h},Y={rootPosition:i,showLeavesLabels:f,showNodesLabels:A,aesGetters:h,labels:m,onClick:D,selectedNodeId:re==null?void 0:re.id,onSelectedUpdate:X=>{K(KX(X)),U(X)}};return le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${t.totalWidth} ${t.totalHeight}`,ref:O,width:t.totalWidth,height:t.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${ic.LEFT},${ic.TOP})`,fontFamily:"Manrope",children:[le.jsx("text",{x:"0",y:"-12",fontSize:"20",children:e.title.name}),le.jsxs("g",{opacity:G?AP:1,children:[c&&le.jsx(YX,{links:r.filter(X=>{let{source:oe,target:me}=X;return!ee||!(ee.has(oe.id??"")&&ee.has(me.id??""))}),selected:!1,...Z}),s&&le.jsx(WX,{nodes:n.filter(X=>!X.data.isFake&&!(ee!=null&&ee.has(X.id??""))),...Y})]}),G&&le.jsxs("g",{children:[c&&le.jsx(YX,{links:r.filter(X=>{let{source:oe,target:me}=X;return ee.has(oe.id??"")&&ee.has(me.id??"")}),selected:!0,...Z}),s&&le.jsx(WX,{nodes:n.filter(X=>!X.data.isFake&&(ee==null?void 0:ee.has(X.id??""))),...Y})]}),g!==null&&le.jsx("g",{transform:`translate(${t.treeWidth+30},0)`,children:le.jsx(T2t,{heatmapData:g,scales:b,step:C,colorScale:x,chartSizes:t,labels:k,selectedNode:re,tooltipsContainer:I})}),e.legend.show&&le.jsx("g",{transform:`translate(${t.treeWidth+30+t.heatmapWidth+30},0)`,children:le.jsx(D2t,{legendData:_})})]}),le.jsx("g",{ref:Q})]})}function Fm({message:e}){return le.jsx("div",{style:{width:"500px",height:"400px",color:"#ee1616",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"25px",fontFamily:"Arial",border:"1px solid"},children:e})}function p9(e){if(RX(e))return t=>e.valuesMap[String(t[e.columnName.value])];if($m(e)){let{domain:t,range:n}=e,r=Ny().domain(t).range(n);return a=>{let i=r(Number(a[e.columnName.value]));return Math.max(1,i)}}return t=>e}function I2t(e){return{nodeShape:p9(e.nodeShape),nodeColor:p9(e.nodeColor),nodeSize:p9(e.nodeSize),lineShape:p9(e.lineShape),lineColor:p9(e.lineColor)}}var L2t=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function R2t(e,t=1,n,r){let a=(e<16?40:e<49?32:24)*t;return Math.max(Math.min(a,r??1/0),n??-1/0)}var N2t=class{constructor(){Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"chartSizes",{treeWidth:600,treeHeight:350,heatmapWidth:0,heatmapHeight:0,totalWidth:1200+ic.LEFT+ic.RIGHT,totalHeight:350+ic.TOP+ic.BOTTOM,labelsOffset:0});Me(this,"legend",{width:0,height:0,items:[]});Me(this,"heatmapScales",{x:Hl().domain(["null"]).range([1]),y:Hl().domain(["null"]).range([1])});Me(this,"heatmapStep",{x:0,y:0});Me(this,"heatmapColorScale",{scale:Hl([]),getter:()=>"white"});Me(this,"heatmapLabels",[])}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateHeatmapScales(e,t,n){if(e===null){this.chartSizes.heatmapWidth=0;return}let{xKeysByGroups:r,xGroupKeys:a,xKeys:i,yKeys:o}=e,s=5,c=a.map(x=>r[x].length),f=c.reduce((x,k)=>x+k,0),A=this.chartSizes.treeHeight/o.length,h=Math.min(Math.max((400-(c.filter(x=>x>0).length-1)*s)/f,n.minCellWidth),n.maxCellWidth),m=[],g=0;a.forEach(x=>{let k=r[x];k.forEach(()=>{m.push(g),g+=h}),k.length>0&&(g+=s)}),this.heatmapScales.x=Hl().domain(i).range(m),this.heatmapScales.y=Hl().domain(o).range(o.map((x,k)=>k*A)),this.heatmapStep.x=h,this.heatmapStep.y=A;let{colorsList:b,colorsMap:C}=t.aes;if(t.valueType==="continuous"&&b){let x=Da().domain(L2t(b.length,e.meta.valueExtent)).range(b);this.heatmapColorScale={scale:x,getter:k=>x(k)}}if(t.valueType==="discrete"&&C){let x=Object.keys(C).filter(k=>e.meta.uniqueValues.has(k));this.heatmapColorScale={scale:Hl(x,x.map(k=>C[k])).unknown(s9),getter:k=>k?C[k]??s9:s9}}if(t.valueType==="stringSource"&&b){let x=[...e.meta.uniqueValues],k=Hl(x,x.map((_,D)=>b[D%b.length])).unknown(s9);this.heatmapColorScale={scale:k,getter:_=>_?k(_):s9}}this.chartSizes.heatmapWidth=this.heatmapScales.x(e.xKeys[e.xKeys.length-1])+this.heatmapStep.x}updateLegendSize(e,t,n,r,a,i){if(!e.show){this.legend={width:0,height:0,items:[]};return}let o=new Dc("600 14px Arial"),s=16,c=48,f=20,A=24;function h(O,I){return Math.max(...O.map($=>o.getTextWidth(String($))+f),o.getTextWidth(I))}let m=[];[n.nodeColor,n.nodeShape,n.lineColor].filter(RX).map(O=>O.columnName).forEach(O=>{let I=t[O.value];if(I.usedAes.length===0||!I.aesMap)return;let $=O.label??O.value,Q=I.values,ee={};Q.forEach(K=>{ee[K]||(ee[K]={...mP}),I.usedAes.forEach(re=>{var U,G,Z;(re==="dotFill"||re==="lineColor")&&(ee[K].color=((U=I.aesMap[K])==null?void 0:U[re])??Zt),re==="dotShape"&&(ee[K].shape=((G=I.aesMap[K])==null?void 0:G[re])??"21"),re==="dotSize"&&(ee[K].size=((Z=I.aesMap[K])==null?void 0:Z[re])??3)})}),m.push({columnKey:$,data:ee,values:I.values,labels:I.labels})});let g=[],b=0,C=0,x=0,k=Math.min(this.chartSizes.treeHeight,400);if(r&&a){let O=i.valueType,I=r.label??r.value;if(O==="continuous"){let $=this.heatmapColorScale.scale,Q=a2($,a.meta.valueExtent,4),ee={id:"heatmapValue",type:"continuous",width:UX(Q,I),height:k,left:0,top:0,title:I,scale:$,values:Q,labels:{}};g.push(ee),C=ee.height+c,b=ee.width}else{let $=this.heatmapColorScale.scale,Q=d2t($,I),ee=$.domain(),K=ee.length*s,re={id:"heatmapValue",type:"discrete",width:Q,height:K,left:0,top:0,title:I,scale:$,values:ee,labels:{}};g.push(re),C=re.height+c,b=re.width}}if(m.map(({columnKey:O,labels:I,values:$,data:Q})=>{C>k&&(C=0,x+=b+A);let ee=O,K=h($.map(Y=>I[Y]),ee),re=$.length*s;re>k&&(k=re);let U=Hl().domain($).range($.map(Y=>Q[Y])),G=x,Z=C;g.push({id:O,type:"nodes",width:K,height:re,left:G,top:Z,title:ee,scale:U,values:$,labels:I}),b=K,C+=re+c}),$m(n.nodeSize)){C>k&&(C=0,x+=b+A);let{columnName:O,domain:I,range:$}=n.nodeSize,Q=O.label??O.value,ee=Ny(I,$),K=ee.ticks(3),re=ee.tickFormat(3),U=K.reduce((oe,me)=>(oe[String(me)]=re(me),oe),{}),G=h(K.map(oe=>U[oe]),Q),Z=(ee(Math.max(...K))*2+4)*K.length;Z>k&&(k=Z);let Y=x,X=C;g.push({id:O.value,type:"size",width:G,height:Z,left:Y,top:X,title:Q,scale:ee,values:K,labels:U}),b=G,C+=Z+c}let _=x+b+2*yP,D=k;this.legend={width:_,height:D,items:g}}updateChartSizes(e,t,n){let r=n.leaves().length;this.chartSizes.treeWidth=t?e.width/2:e.width;let a=R2t(r,e.scale,e.minCellHeight,e.maxCellHeight)*r;this.chartSizes.treeHeight=a,this.chartSizes.heatmapHeight=a}updateTotalSizes(e){this.chartSizes.totalWidth=this.chartSizes.treeWidth+this.chartSizes.heatmapWidth+this.legend.width+ic.LEFT+ic.RIGHT,e&&(this.chartSizes.totalWidth+=30),this.legend.width>0&&(this.chartSizes.totalWidth+=30),this.chartSizes.totalHeight=Math.max(this.chartSizes.treeHeight,this.legend.height)+ic.TOP+ic.BOTTOM}prepareTableLabels(e){let t=new Dc("bold 14px Arial"),n="…";if(this.heatmapStep.x<12||!e){this.heatmapLabels=[];return}let r=this.heatmapStep.x-4;this.heatmapLabels=e.xKeys.map(a=>{let i=e.meta.xLabels[a],o=t.getTextWidth(i);if(o<r)return i;let s=i,c=s==null?void 0:s.length;for(;o>r&&c>0;)c--,s=(i==null?void 0:i.substring(0,c))+n,o=t.getTextWidth(s);return c>0?s:""})}addLabelsWidthToTreeArea(e,t){if(!t)return;let n=e.leaves(),r=new Dc("bold 14px Manrope"),a=0;n.forEach(i=>{if(!i.data.label)return;let o=r.getTextWidth(i.data.label),s=i.y+o-this.chartSizes.treeWidth+8;s>a&&(a=s)}),this.chartSizes.treeWidth+=a}render(e,t,n,r,a,i,o,s,c,f,A,h,m,g,b,C,x){var I;this.updateChartSizes(e.size,m,t),this.updateHeatmapScales(m,g,e.size),this.updateLegendSize(e.legend,b,f,h,m,g),this.prepareTableLabels(m);let k=r==="top"?[this.chartSizes.treeWidth,this.chartSizes.treeHeight]:[this.chartSizes.treeHeight,this.chartSizes.treeWidth];xB().size(k).separation(()=>1)(t);let _=t;d3t(_,r==="top"?this.chartSizes.treeHeight:this.chartSizes.treeWidth,C==="alignLeavesToLine"),A3t(_),this.addLabelsWidthToTreeArea(_,s),this.updateTotalSizes(m);let D=I2t(f),O=le.jsx(H2t,{chartSizes:this.chartSizes,chartSettings:e,nodes:_.descendants(),links:_.links(),connectionType:n,rootPosition:r,edgeInheritance:a,showNodes:i,showEdges:o,showLeavesLabels:s,showNodesLabels:c,aesGetters:D,labels:A,heatmapData:m,heatmapScales:this.heatmapScales,heatmapStep:this.heatmapStep,heatmapColor:this.heatmapColorScale.getter,heatmapLabels:this.heatmapLabels,legendData:this.legend,onClick:x});this.component=O,(I=this.reactRoot)==null||I.render(O)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},$2t=N2t,ZX=class{constructor(e){Me(this,"type","dendro");Me(this,"chartSettings");Me(this,"mode");Me(this,"leavesMode");Me(this,"id");Me(this,"parentId");Me(this,"height",null);Me(this,"labels");Me(this,"heatmapAnnotation");Me(this,"heatmapAxis");Me(this,"heatmapGroup");Me(this,"heatmapSettings");Me(this,"connectionType","rectangle");Me(this,"edgeInheritance","up");Me(this,"rootPosition","top");Me(this,"showNodes",!0);Me(this,"showEdges",!0);Me(this,"showLeavesLabels",!0);Me(this,"showNodesLabels",!0);Me(this,"aes",{nodeShape:"21",nodeColor:Zt,nodeSize:3,lineShape:"solid",lineColor:Zt});var t,n,r,a,i,o,s,c,f,A;r2t.parse(e),this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(e.facetSettings?400:560),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(e.facetSettings?250:350),scale:((r=e==null?void 0:e.size)==null?void 0:r.scale)??1,minCellWidth:((a=e==null?void 0:e.size)==null?void 0:a.minCellWidth)??a3t,maxCellWidth:((i=e==null?void 0:e.size)==null?void 0:i.maxCellWidth)??i3t,minCellHeight:(o=e==null?void 0:e.size)==null?void 0:o.minCellHeight,maxCellHeight:(s=e==null?void 0:e.size)==null?void 0:s.maxCellHeight},title:{position:"center",show:!0,...e.title,name:((c=e.title)==null?void 0:c.name)??"Dendrogram"},legend:{show:!0,position:"right",...e.legend}},this.mode=e.mode??"normal",this.leavesMode=e.leavesMode??"normal",this.id=e.id,this.parentId=e.parentId,this.height=e.height??null,this.labels=e.labels??this.id,this.heatmapAnnotation=e.heatmapAnnotation??null,this.heatmapAxis=e.heatmapAxis??null,this.heatmapGroup=e.heatmapGroup??[],this.heatmapSettings={valueType:((f=e.heatmapSettings)==null?void 0:f.valueType)??"continuous",aes:{colorsList:["#FFF680","#53D788","#36739D","#4A005C"],...(A=e.heatmapSettings)==null?void 0:A.aes}},this.connectionType=e.connectionType??this.connectionType,this.edgeInheritance=e.edgeInheritance??this.edgeInheritance,this.showNodes=e.showNodes??this.showNodes,this.showEdges=e.showEdges??this.showEdges,this.showLeavesLabels=e.showLeavesLabels??this.showLeavesLabels,this.showNodesLabels=e.showNodesLabels??this.showNodesLabels,this.rootPosition=e.rootPosition??this.rootPosition,this.aes={...this.aes,...e.aes}}};function Q8(e){return typeof e!="object"?!1:"valuesMap"in e}function JX(e,t){let{nodeColor:n,nodeShape:r,lineColor:a}=t,i=[n,r,a].filter(Q8);return Ir.uniqBy(i,o=>o.columnName.value).reduce((o,s)=>{let{columnName:c}=s,f=Ir.uniqBy(e.rows,b=>b[c.value]),A=b=>String(b[c.value]),h=b=>c.valueLabels?String(b[c.valueLabels]):A(b),m=new Set,g=f.reduce((b,C)=>{let x=A(C);return b[x]||(b[x]={}),b},{});return Q8(n)&&c.value===n.columnName.value&&(m.add("dotFill"),f.forEach(b=>{let C=A(b);g[C].dotFill=n.valuesMap[C]})),Q8(r)&&c.value===r.columnName.value&&(m.add("dotShape"),f.forEach(b=>{let C=A(b);g[C].dotShape=r.valuesMap[C]})),Q8(a)&&c.value===a.columnName.value&&(m.add("lineColor"),f.forEach(b=>{let C=A(b);g[C].lineColor=a.valuesMap[C]})),o[c.value]={values:f.map(A).sort(),usedAes:[...m],aesMap:g,labels:f.reduce((b,C)=>(b[A(C)]=h(C),b),{})},o},{})}var F2t=class extends Sg{constructor(t,n,r){super(t,n);Me(this,"settings");Me(this,"onClick",()=>Kx);Me(this,"chartRenderer",new $2t);Me(this,"calculatedData",null);this.settings=new ZX(n),r&&(this.onClick=r[0])}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new ZX(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){if(document){let r=new CustomEvent(pP,{detail:{[t]:n}});document.dispatchEvent(r)}}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var A,h;let{mode:r,id:a,parentId:i,heatmapAnnotation:o,heatmapAxis:s,heatmapGroup:c}=n;function f(m,g){return m.length!==g.length||m.some((b,C)=>b.value!==g[C].value)}return t.mode!==r||t.id.value!==a.value||t.parentId.value!==i.value||((A=t.heatmapAnnotation)==null?void 0:A.value)!==(o==null?void 0:o.value)||((h=t.heatmapAxis)==null?void 0:h.value)!==(s==null?void 0:s.value)||f(t.heatmapGroup,c)}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{mode:t,id:n,parentId:r,aes:a,heatmapAnnotation:i,heatmapAxis:o,heatmapGroup:s,heatmapSettings:c,height:f,labels:A}=this.settings,h=f3t(n.value,r.value,(f==null?void 0:f.value)??null,A.valueLabels??A.value??null,this.data.rows,t==="useAllNodesAsLeaves"),m=s3t(this.data,c.valueType,i,o,s,n,h),g=JX(this.data,a);this.calculatedData={chartSizes:this.chartRenderer.chartSizes,hierarchy:h,heatmapData:m,legendLabels:g}}_updateAesInData(){this.calculatedData&&(this.calculatedData.legendLabels=JX(this.data,this.settings.aes))}_updateChart(){if(!this.calculatedData)return;let{heatmapAnnotation:t,chartSettings:n,connectionType:r,edgeInheritance:a,rootPosition:i,showNodes:o,showEdges:s,showLeavesLabels:c,showNodesLabels:f,aes:A,labels:h,heatmapSettings:m,leavesMode:g}=this.settings;this.chartRenderer.render(n,this.calculatedData.hierarchy,r,i,a,o,s,c,f,A,h,t,this.calculatedData.heatmapData,m,this.calculatedData.legendLabels,g,this.onClick)}};function V2t(e,t,n,r,a,i){let o=-1/0;return{type:"logo",geoms:t.reduce((s,c)=>{let f=c.join("_");return s[f]=[],n.forEach(A=>{let h=0,m={};r.forEach(b=>{let C=a.getRowsByGrouping([...c,A,b]);if(!C.length)return;let x=Sc(C,k=>Number(k[i.value]));m[b]={height:x,key:b},h+=x});let g=h;e.normalize&&r.forEach(b=>{m[b]&&(m[b].height=m[b].height/g*100)}),o=Math.max(o,h),s[f].push({key:`logo_${A}`,valuesMap:m,primaryGrouping:A,boundsY:{min:0,max:e.normalize?g:100}})}),s},{}),meta:{minY:0,maxY:e.normalize?100:o,normalize:e.normalize},aes:e.aes}}var h9={TOP:30,BOTTOM:30},l1=30,O2t=6,m9=20,CP=15,z8=24,i2=25,Q2t=12,qX={fillColor:"white",lineColor:Zt,lineWidth:1,lineShape:"solid",dotSize:3,dotFill:Zt,dotShape:"21"},bP=20,eK=4,ed=4,tK=25,z2t=15,_g=8,Vm=30,U2t=48,j2t=24,o2=16,l2=4,U8=4,j8=20,G2t=16,Qd=16,s2=8,s1={left:["annotations","axis","groups","axisTitle","dendro"],right:["annotations","axis","groups","axisTitle","dendro"],top:["annotations","axis","groups","axisTitle","dendro","facetTitle"],bottom:["annotations","axis","groups","axisTitle","dendro"]},nK={fillColor:"white",lineColor:Zt,lineWidth:1,lineShape:"solid",dotSize:3,dotFill:Zt,dotShape:"21"};function Y2t(e){return`translate(${e},0)`}function W2t(e){return`translate(0,${e})`}var v9=21;function X2t(e,t){if(e==="45deg"){let n=t==="left"?-v9/2:0,r=t==="bottom"?v9/2:-v9/2;return`translate(${n},${r}) rotate(-45)`}return e==="90deg"&&t==="bottom"?`translate(${-v9/2},${ed+v9/2}) rotate(-90)`:t==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function K2t(e,t){return t==="left"||t==="bottom"&&e==="90deg"?"central":e==="center"?"hanging":"auto"}function Z2t(e,t){return t==="left"||t==="bottom"&&e!=="center"?"end":"middle"}var rK=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",labelsPosition:a="center",labels:i={},offset:o=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function s(x,k){return x.bandwidth&&(k=Math.max(0,x.bandwidth()-k*2)/2),x!=null&&x.round()&&(k=Math.round(k)),_=>{let D=x(_);return D===void 0?0:D+k}}let c=e.domain(),f=x=>i[x]??[x],A=Math.max(t,0)+n,h=s(e.copy(),o),m=r==="bottom"?Y2t:W2t,g=r==="left"?-1:1,b={[(r==="left"?"x":"y")+"2"]:g*t},C={[r==="left"?"x":"y"]:g*A};return le.jsx("g",{children:c.map((x,k)=>le.jsxs("g",{className:"tick",transform:m(h(x)+o),children:[le.jsx("line",{stroke:Zt,...b}),le.jsx("g",{transform:X2t(a,r),children:f(x).map((_,D)=>le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:K2t(a,r),textAnchor:Z2t(a,r),dy:20*D,...C,children:_},`${_}_${D}`))})]},k))})};function aK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function J2t({scales:e,orientation:t,bar:n,aes:r}){let a=t==="vertical",i=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,o=e.xSecondary.bandwidth(),s=r.width==="auto"?o*.8:Math.min(o,r.width),c=Math.abs(e.y(n.value)-e.y(0)),f=aK(e,"lineColor",r.lineColor,n),A=aK(e,"fillColor",r.fillColor,n);return le.jsx("g",{transform:a?`translate(${i},0)`:`translate(0, ${i})`,opacity:r.opacity,stroke:f,strokeWidth:r.lineWidth,children:le.jsx("rect",{width:a?s:c,height:a?c:s,x:a?-s/2:e.y(n.boundsY.min),y:a?e.y(n.boundsY.max):-s/2,fill:A})})}function Ki(e){return isNaN(e)?"?":e===0?"0":Math.abs(e)<.01?j5(".1e")(e):j5(".2f")(e)}function iK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function q2t({scales:e,orientation:t,geom:n,aes:r,min:a,max:i,binsCount:o,hasKeyFromColumn:s,sideDistances:c,showTooltips:f,tooltipsContainer:A}){let[h,m]=Vn.useState(null),g=t==="vertical",b=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,C=iK(e,"lineColor",r.lineColor,n),x=iK(e,"fillColor",r.fillColor,n),k=n.bins,_=r.dotSize?r.dotSize:Math.abs(e.y(i)-e.y(a))/o/2;return le.jsx("g",{transform:g?`translate(${b},0)`:`translate(0, ${b})`,stroke:C,fill:x,strokeWidth:r.lineWidth,children:k.map(({x:D,count:O,dots:I})=>le.jsx("g",{transform:g?`translate(0,${e.y(D)})`:`translate(${e.y(D)},0)`,children:I.map(($,Q)=>{let ee=(Q-O/2)*2*_+_,K=g?ee:0,re=g?0:ee;return le.jsxs("g",{children:[le.jsx("circle",{opacity:r.opacity,cx:K,cy:re,r:_,onMouseOver:()=>m($.key),onMouseLeave:()=>m(null)}),f&&le.jsx(oc,{content:s?[$.key,Ki($.value)]:[Ki($.value)],x:(g?b:e.y(D))+K,y:(g?e.y(D):b)+re,sideDistances:c,horizontal:g,offset:_,active:h===$.key,container:A})]},$.key)})},D))})}function td(e=null){switch(e){case null:return"";case"solid":return"";case"dashed":return"6 6";case"dotted":return"1.5 4";case"dotdash":return"1.4 4 8 4";case"longdash":return"10 4";case"twodash":return"3 3 9 3";default:vA(e,`Unknown line shape ${e}`)}}function G8(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function e5t(e,t){return t?[e.id,`${Ki(e.y)}`]:[`${Ki(e.y)}`]}function t5t({scales:e,orientation:t,box:n,aes:r,hasKeyFromColumn:a,sideDistances:i,showTooltips:o,elementsAmount:s,tooltipsContainer:c}){let[f,A]=Vn.useState(!1),[h,m]=Vn.useState(null),g=t==="vertical",b=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,C=e.xSecondary.bandwidth(),x=r.boxWidth==="auto"?C*.8:Math.min(C,r.boxWidth),k=Math.abs(e.y(n.lower)-e.y(n.upper)),_=G8(e,"lineColor",r.lineColor,n),D=G8(e,"fillColor",r.fillColor,n),O=G8(e,"dotShape",r.dotShape,n),I=G8(e,"dotSize",r.dotSize,n),$=Af(O,I,_),Q=Math.abs(e.y.range()[0]-e.y.range()[1]);return le.jsxs("g",{transform:g?`translate(${b},0)`:`translate(0, ${b})`,opacity:r.opacity,stroke:_,strokeWidth:r.lineWidth,strokeDasharray:td(r.lineShape),children:[le.jsx("line",{x1:g?0:e.y(n.min),x2:g?0:e.y(n.lower),y1:g?e.y(n.min):0,y2:g?e.y(n.lower):0}),le.jsx("line",{x1:g?0:e.y(n.upper),x2:g?0:e.y(n.max),y1:g?e.y(n.upper):0,y2:g?e.y(n.max):0}),le.jsx("rect",{width:g?x:k,height:g?k:x,x:g?-x/2:e.y(n.lower),y:g?e.y(n.upper):-x/2,fill:D}),le.jsx("line",{x1:g?-x/2:e.y(n.middle),x2:g?x/2:e.y(n.middle),y1:g?e.y(n.middle):-x/2,y2:g?e.y(n.middle):x/2}),o&&c&&le.jsx("rect",{onMouseOver:()=>A(!0),onMouseLeave:()=>A(!1),width:g?C:Q,x:g?-C/2:0,y:g?0:-C/2,height:g?Q:C,fill:"transparent",stroke:"none"}),r.showOutliers&&n.outliers.map(ee=>le.jsxs("g",{transform:g?`translate(0,${e.y(ee.y)})`:`translate(${e.y(ee.y)},0)`,strokeDasharray:"0",children:[$,o&&c&&le.jsx("circle",{onMouseOver:()=>m(ee.id),onMouseLeave:()=>m(null),r:"15",fill:"transparent",stroke:"none"}),o&&le.jsx(oc,{content:e5t(ee,a),x:g?b:e.y(ee.y),y:g?e.y(ee.y):b,sideDistances:i,horizontal:!0,active:h===ee.id,container:c})]},ee.id)),o&&le.jsx(oc,{content:[`Max = ${Ki(n.max)}`,`Upper = ${Ki(n.upper)}`,`Median = ${Ki(n.middle)}`,`Lower = ${Ki(n.lower)}`,`Min = ${Ki(n.min)}`],x:g?b:e.y(n.middle),y:g?e.y(n.middle):b,sideDistances:i,horizontal:g,active:f,offset:s>1?C/2:C/4,container:c})]})}function EP(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function n5t(e,t,n){return n?[t,`${Ki(e)}`]:[`${Ki(e)}`]}function r5t({scales:e,orientation:t,geom:n,aes:r,hasKeyFromColumn:a,sideDistances:i,showTooltips:o,tooltipsContainer:s}){let[c,f]=Vn.useState(null),A=t==="vertical",h=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,m=e.xSecondary.bandwidth()*r.jitter,g=_=>(1-_*2)*(m/2),b=EP(e,"lineColor",r.lineColor,n),C=EP(e,"dotFill",r.dotFill,n),x=EP(e,"dotShape",r.dotShape,n),k=Af(x,r.dotSize,C);return le.jsx("g",{transform:A?`translate(${h},0)`:`translate(0, ${h})`,stroke:b,children:n.values.map(({y:_,jitter:D,id:O})=>le.jsxs("g",{opacity:r.opacity,transform:A?`translate(${g(D)},${e.y(_)})`:`translate(${e.y(_)},${g(D)})`,children:[k,o&&s&&le.jsx("circle",{onMouseOver:()=>f(O),onMouseLeave:()=>f(null),r:"4",fill:"transparent",stroke:"none"}),o&&le.jsx(oc,{content:n5t(_,O,a),x:h+g(D),y:e.y(_),active:c===O,sideDistances:i,container:s})]},O))})}function xP(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function a5t({scales:e,orientation:t,errorBar:n,aes:r,sideDistances:a,showTooltips:i,tooltipsContainer:o}){let[s,c]=Vn.useState(!1),f=t==="vertical",A=xP(e,"lineColor",r.lineColor,n),h=xP(e,"fillColor",r.fillColor,n),m=xP(e,"dotShape",r.dotShape,n),g=(e.xPrimary(n.primaryGrouping)??0)+e.xPrimary.bandwidth()/2,b=r.width==="auto"?e.xPrimary.bandwidth()*.2:r.width,C=e.y(n.min),x=e.y(n.max),k=e.y(n.value),_=Af(m,r.dotSize,h);return le.jsxs("g",{opacity:r.opacity,stroke:A,fill:"none",transform:f?`translate(${g},0)`:`translate(0,${g})`,strokeWidth:r.lineWidth,children:[le.jsx("line",{x1:f?0:C,x2:f?0:x,y1:f?C:0,y2:f?x:0}),le.jsx("line",{x1:f?-b/2:C,x2:f?b/2:C,y1:f?C:-b/2,y2:f?C:b/2}),le.jsx("line",{x1:f?-b/2:x,x2:f?b/2:x,y1:f?x:-b/2,y2:f?x:b/2}),r.showDots&&le.jsxs("g",{transform:f?`translate(0,${k})`:`translate(${k},0)`,children:[_,i&&o&&le.jsx("circle",{onMouseOver:()=>c(!0),onMouseLeave:()=>c(!1),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[Ki(n.value)],x:f?g:k,y:f?k:g,sideDistances:a,horizontal:!0,active:s,container:o})]})]})}function Y8(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")throw new Error("Line cannot have aesthetics by primary grouping");if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.key)[t]}return n}function i5t(e,t,n){let r=n.xPrimary.bandwidth()/2;return t.map(a=>[(n.xPrimary(a)??0)+r,n.y(e[a]),a,e[a]])}function o5t({scales:e,orientation:t,line:n,aes:r,sideDistances:a,showTooltips:i,secondaryGrouping:o,tooltipsContainer:s}){let[c,f]=Vn.useState(null),A=t==="vertical",h=Y8(e,"lineColor",r.lineColor,n),m=Y8(e,"dotFill",r.fillColor,n),g=Y8(e,"lineShape",r.lineShape,n),b=Y8(e,"dotShape",r.dotShape,n),C=i5t(n.dots,e.xPrimary.domain(),e),x=Af(b,r.dotSize,m);return le.jsxs("g",{opacity:r.opacity,stroke:h,strokeDasharray:td(g),strokeWidth:r.lineWidth,children:[le.jsx("polyline",{points:C.map(([k,_])=>A?[k,_]:[_,k]).join(" "),stroke:h,fill:"none"},n.key),r.dotShape!==null&&le.jsx("g",{children:C.map(([k,_,D,O])=>le.jsxs("g",{transform:A?`translate(${k},${_})`:`translate(${_},${k})`,strokeDasharray:"none",stroke:"none",children:[x,i&&s&&le.jsx("circle",{onMouseOver:()=>f(D),onMouseLeave:()=>f(null),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[o.valueLabels[n.key],Ki(O)],x:A?k:_,y:A?_:k,sideDistances:a,horizontal:!0,active:c===D,container:s})]},D))})]})}var l5t={A:rr.A,B:rr.B,C:rr.C,D:rr.D,E:rr.E,F:rr.F,G:rr.G,H:rr.H,I:rr.I,J:rr.J,K:rr.K,L:rr.L,M:rr.M,N:rr.N,O:rr.O,P:rr.P,Q:rr.Q,R:rr.R,S:rr.S,T:rr.T,U:rr.U,V:rr.V,W:rr.W,X:rr.X,Y:rr.Y,Z:rr.Z,a:rr.LC_a,b:rr.LC_b,c:rr.LC_c,d:rr.LC_d,e:rr.LC_e,f:rr.LC_f,g:rr.LC_g,h:rr.LC_h,i:rr.LC_i,j:rr.LC_j,k:rr.LC_k,l:rr.LC_l,m:rr.LC_m,n:rr.LC_n,o:rr.LC_o,p:rr.LC_p,q:rr.LC_q,r:rr.LC_r,s:rr.LC_s,t:rr.LC_t,u:rr.LC_u,v:rr.LC_v,w:rr.LC_w,x:rr.LC_x,y:rr.LC_y,z:rr.LC_z,N0:rr.N0,N1:rr.N1,N2:rr.N2,N3:rr.N3,N4:rr.N4,N5:rr.N5,N6:rr.N6,N7:rr.N7,N8:rr.N8,N9:rr.N9};function s5t({scales:e,orientation:t,geom:n,aes:r,sideDistances:a,showTooltips:i,elementsAmount:o,tooltipsContainer:s,normalize:c}){let[f,A]=Vn.useState(null),h=t==="vertical",m=e.xPrimary.bandwidth(),g=(e.xPrimary(n.primaryGrouping)??0)+m/2,b=r.width==="auto"?m*.9:Math.min(m,r.width),C=[...e.xSecondary.domain()].filter(_=>n.valuesMap[_]).sort((_,D)=>{let O=n.valuesMap[_],I=n.valuesMap[D];return O.height-I.height}),x={},k=0;return C.forEach(_=>{if(!n.valuesMap[_])return;let D=n.valuesMap[_].height;x[_]={y1:k,y2:k+D},k+=D}),le.jsx("g",{transform:h?`translate(${g},0)`:`translate(0, ${g})`,opacity:r.opacity,children:C.map(_=>{if(!n.valuesMap[_])return null;let{y1:D,y2:O}=x[_],I=e.y(D),$=e.y(O),Q=Math.abs(I-$),ee=typeof r.fillColor=="string"?r.fillColor:r.fillColor[_],K=h?-b/2:Math.min(I,$),re=h?Math.min(I,$):-b/2,U=l5t[_];if(U)return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${K},${re})`,children:le.jsx("g",{transform:h?`scale(${b/100},${Q/100})`:`scale(${Q/100},${b/100})`,fill:ee,onMouseOver:()=>A(_),onMouseLeave:()=>A(null),children:le.jsx(U,{})})}),i&&le.jsx(oc,{content:[_,Ki(n.valuesMap[_].height)+(c?"%":"")],x:h?g:(I+$)/2,y:h?(I+$)/2:g,sideDistances:a,horizontal:h,offset:o>1?m/2:m/4,active:f===_,container:s})]},_)})})}function u2(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r)[t]}return n}function u5t({scales:e,orientation:t,geom:n,aes:r,sideDistances:a,showTooltips:i,tooltipsContainer:o}){let[s,c]=Vn.useState(null),f=t==="vertical",A=u2(e,"lineColor",r.lineColor,n.id),h=u2(e,"lineShape",r.lineShape,n.id),m=u2(e,"fillColor",r.dotFill,n.key1),g=u2(e,"dotShape",r.dotShape,n.key1),b=u2(e,"fillColor",r.dotFill,n.key2),C=u2(e,"dotShape",r.dotShape,n.key2),x=Af(g,r.dotSize,m),k=Af(C,r.dotSize,b);function _(D){return n.grouping==="primary"?(e.xPrimary(D)??0)+e.xPrimary.bandwidth()/2:(e.xPrimary(n.id)??0)+(e.xSecondary(D)??0)+e.xSecondary.bandwidth()/2}return le.jsx("g",{opacity:r.opacity,children:n.pairs.map(D=>{let O=f?_(n.key1):e.y(D.key1.value),I=f?_(n.key2):e.y(D.key2.value),$=f?e.y(D.key1.value):_(n.key1),Q=f?e.y(D.key2.value):_(n.key2);return le.jsxs("g",{children:[le.jsx("line",{x1:O,y1:$,x2:I,y2:Q,stroke:A,strokeDasharray:td(h),strokeWidth:r.lineWidth,fill:"none"}),le.jsxs("g",{transform:`translate(${O},${$})`,children:[x,i&&o&&le.jsx("circle",{onMouseOver:()=>c(D.key1.id),onMouseLeave:()=>c(null),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[D.id,Ki(D.key1.value)],x:O,y:$,sideDistances:a,horizontal:!0,active:s===D.key1.id,container:o})]}),le.jsxs("g",{transform:`translate(${I},${Q})`,children:[k,i&&o&&le.jsx("circle",{onMouseOver:()=>c(D.key2.id),onMouseLeave:()=>c(null),r:"15",fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[D.id,Ki(D.key2.value)],x:I,y:Q,sideDistances:a,horizontal:!0,active:s===D.key2.id,container:o})]})]},D.id)})})}function oK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function c5t(e,t,n){return n?[t,`${Ki(e)}`]:[`${Ki(e)}`]}function f5t({scales:e,orientation:t,geom:n,aes:r,hasKeyFromColumn:a,sideDistances:i,showTooltips:o,tooltipsContainer:s}){let[c,f]=Vn.useState(null),A=t==="vertical",h=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,m=e.xSecondary.bandwidth(),g=r.width==="auto"?m*.8:Math.min(m,r.width),b=_=>(1-_*2)*(g/2),C=oK(e,"dotFill",r.dotFill,n),x=oK(e,"dotShape",r.dotShape,n),k=Af(x,r.dotSize,C);return le.jsx("g",{transform:A?`translate(${h},0)`:`translate(0, ${h})`,children:n.points.map(({x:_,y:D,jitter:O,id:I})=>{let $=A?D*b(O):e.y(_),Q=A?e.y(_):D*b(O);return le.jsxs("g",{opacity:r.opacity,transform:`translate(${$},${Q})`,children:[k,o&&s&&le.jsx("circle",{onMouseOver:()=>f(I),onMouseLeave:()=>f(null),r:"4",fill:"transparent",stroke:"none"}),o&&le.jsx(oc,{content:c5t(D,I,a),x:h+$,y:Q,active:c===I,sideDistances:i,container:s})]},I)})})}function lK(e,t,n,r,a){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(a)[t]}return n}function d5t({scales:e,orientation:t,geom:n,aes:r,sideDistances:a,showTooltips:i,elementsAmount:o,tooltipsContainer:s,normalize:c,secondaryGrouping:f}){let[A,h]=Vn.useState(null),m=t==="vertical",g=e.xPrimary.bandwidth(),b=(e.xPrimary(n.primaryGrouping)??0)+g/2,C=r.width==="auto"?g*.8:Math.min(g,r.width),x=e.xSecondary.domain().reverse(),k={},_=0;return x.forEach(D=>{if(!n.valuesMap[D])return;let O=n.valuesMap[D].height;k[D]={y1:_,y2:_+O},_+=O}),le.jsx("g",{transform:m?`translate(${b},0)`:`translate(0, ${b})`,opacity:r.opacity,strokeWidth:r.lineWidth,children:x.map(D=>{if(!n.valuesMap[D])return null;let{y1:O,y2:I}=k[D],$=e.y(O),Q=e.y(I),ee=Math.abs($-Q),K=lK(e,"lineColor",r.lineColor,n.primaryGrouping,D),re=lK(e,"fillColor",r.fillColor,n.primaryGrouping,D);return le.jsxs("g",{children:[le.jsx("rect",{width:m?C:ee,height:m?ee:C,x:m?-C/2:Math.min($,Q),y:m?Math.min($,Q):-C/2,fill:re,stroke:K,onMouseOver:()=>h(D),onMouseLeave:()=>h(null)}),i&&le.jsx(oc,{content:[f.valueLabels[D],Ki(n.valuesMap[D].height)+(c?"%":"")],x:m?b:($+Q)/2,y:m?($+Q)/2:b,sideDistances:a,horizontal:m,offset:o>1?g/2:g/4,active:A===D,container:s})]},D)})})}function sK(e,t,n,r){let a=t.reduce((i,o,s)=>(i[o]=s,i),{});return e.filter(([,i])=>r?i<=n.one:!0).sort(([[i,o]],[[s,c]])=>i!==o?a[o]-a[i]:a[c]-a[s])}function A5t(e,t){let n=t.reduce((a,i,o)=>(a[i]=o,a),{}),r=[];return e.map(([[a,i]])=>{let o=n[a],s=n[i];for(let c=0;c<r.length;c++)if(r[c]<o)return r[c]=s,c;return r.push(s),r.length-1})}function uK(e,t,n,r){let a=t.reduce((o,s,c)=>(o[s]=c,o),{}),i=[];return sK(e,t,n,!r).forEach(([[o,s]])=>{let c=a[o],f=a[s];for(let A=0;A<i.length;A++)if(i[A]<c){i[A]=f;return}i.push(f)}),i.length}var p5t={ttest:"TTest",anova:"ANOVA",kruskalWallis:"Kruskal-Wallis",wilcoxon:"Wilcoxon"};function h5t(e,t){return e<=t.three?"***":e<=t.two?"**":e<=t.one?"*":"ns"}function SP(e,t,n,r){return!r&&e>n.one?"":t==="significance"?h5t(e,n):Ki(e)}var c2=18,BP=12;function m5t({orientation:e,scales:t,testMethod:n,values:r,statType:a,format:i,ns:o,significanceLevels:s,yShift:c}){if(!r.length)return null;let f=k=>(t.xPrimary(k)??0)+t.xPrimary.bandwidth()/2,A=e==="vertical",h=Math.abs(t.xPrimary.range()[1]-t.xPrimary.range()[0]),m=Math.abs(t.y.range()[1]-t.y.range()[0]),g=t.xPrimary.domain(),b=a==="pairwise"?sK(r,g,s,!o):r,C=a==="pairwise"?A5t(b,g):[],x=Math.max(...C);return le.jsxs("g",{fontSize:"14px",transform:A?`translate(0,${c})`:`translate(${m-c},0)`,children:[a==="overall"&&le.jsx("text",{x:A?h/2:-c2,y:A?c2:h/2,transform:A?"":`rotate(90,${-c2},${h/2})`,textAnchor:"middle",children:`${p5t[n]}, p = ${SP(r[0][1],"pValue",s,!0)}`}),a==="referenceGroup"&&le.jsx("g",{children:r.map(([[k],_])=>le.jsx("text",{x:A?f(k):-c2,y:A?c2:f(k),transform:A?"":`rotate(90,${-c2},${f(k)})`,textAnchor:"middle",children:SP(_,i,s,o)},k))}),a==="pairwise"&&le.jsx("g",{children:b.map(([[k,_],D],O)=>{let I=f(k),$=f(_),Q=(I+$)/2;return le.jsxs("g",{transform:A?`translate(0,${(x-C[O])*i2})`:`translate(${-(x-C[O])*i2},0)`,children:[le.jsx("text",{x:A?Q:-BP,y:A?BP:Q,transform:A?"":`rotate(90,${-BP},${Q})`,textAnchor:"middle",children:SP(D,i,s,o)}),le.jsx("path",{d:A?`M ${I},21 v-4 h ${$-I} v4`:`M -21,${I} h 4 v ${$-I} h-4`,fill:"none",stroke:Zt})]},`${k}_${_}`)})})]})}function v5t(e){return`translate(${e},0)`}function g5t(e){return`translate(0,${e})`}function y5t(e){return e==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function w5t(e){return e==="bottom"?"hanging":"central"}function C5t(e){return e==="bottom"?"middle":"end"}var cK=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",onlyPositive:a=!1,offset:i=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function o(_){return D=>{let O=_(D);return O===void 0?0:+O}}let s=Math.abs(e.range()[0]-e.range()[1]),c=Math.min(Math.floor(s/tK),10),f=e.ticks(c).filter(_=>a&&_>=0||!a),A=f.some(_=>Math.abs(_)<1e-4&&_!==0||_>1e4)?",e":",f",h=_=>e.tickFormat(c,A)(_),m=Math.max(t,0)+n,g=o(e.copy()),b=r==="bottom"?v5t:g5t,C=r==="left"?-1:1,x={[(r==="left"?"x":"y")+"2"]:C*t},k={[r==="left"?"x":"y"]:C*m};return le.jsx("g",{children:f.map((_,D)=>le.jsxs("g",{className:"tick",transform:b(g(_)+i),children:[le.jsx("line",{stroke:Zt,...x}),le.jsx("g",{transform:y5t(r),children:le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:w5t(r),textAnchor:C5t(r),...k,children:h(_)})})]},D))})};function fK(e,t,n,r){if(n&&typeof n=="object"&&"type"in n){if(n.type==="primaryGrouping")return e.xPrimaryAes(r.primaryGrouping)[t];if(n.type==="secondaryGrouping")return e.xSecondaryAes(r.secondaryGrouping)[t]}return n}function b5t({scales:e,orientation:t,violin:n,aes:r,maxViolinDensity:a,showTooltips:i,sideDistances:o,elementsAmount:s,tooltipsContainer:c}){let[f,A]=Vn.useState(!1),h=t==="vertical",m=(e.xPrimary(n.primaryGrouping)??0)+(e.xSecondary(n.secondaryGrouping)??0)+e.xSecondary.bandwidth()/2,g=e.xSecondary.bandwidth(),b=r.width==="auto"?g*.8:Math.min(g,r.width),C=fK(e,"lineColor",r.lineColor,n),x=fK(e,"fillColor",r.fillColor,n),k=n.getArea(t,e.y,b,a)??"",_=n.getLine(t,e.y,b,a)??"",D=Math.abs(e.y.range()[0]-e.y.range()[1]);return le.jsxs("g",{transform:h?`translate(${m},0)`:`translate(0, ${m})`,opacity:r.opacity,stroke:C,fill:x,strokeWidth:r.lineWidth,strokeDasharray:td(r.lineShape),children:[le.jsx("clipPath",{id:`violin_${n.key}`,children:le.jsx("path",{d:k})}),le.jsx("path",{d:k,stroke:"none"}),r.showQuartiles&&le.jsxs("g",{"clip-path":`url(#violin_${n.key})`,strokeWidth:r.lineWidth,stroke:C,children:[le.jsx("line",{x1:h?-b/2:e.y(n.quartiles.q1),x2:h?b/2:e.y(n.quartiles.q1),y1:h?e.y(n.quartiles.q1):-b/2,y2:h?e.y(n.quartiles.q1):b/2,strokeDasharray:td(r.quartilesLineStyle)}),le.jsx("line",{x1:h?-b/2:e.y(n.quartiles.q2),x2:h?b/2:e.y(n.quartiles.q2),y1:h?e.y(n.quartiles.q2):-b/2,y2:h?e.y(n.quartiles.q2):b/2,strokeDasharray:td(r.medianLineStyle)}),le.jsx("line",{x1:h?-b/2:e.y(n.quartiles.q3),x2:h?b/2:e.y(n.quartiles.q3),y1:h?e.y(n.quartiles.q3):-b/2,y2:h?e.y(n.quartiles.q3):b/2,strokeDasharray:td(r.quartilesLineStyle)})]}),le.jsx("path",{d:_,fill:"none"}),i&&c&&le.jsx("rect",{onMouseOver:()=>A(!0),onMouseLeave:()=>A(!1),width:h?g:D,x:h?-g/2:0,y:h?0:-g/2,height:h?D:g,fill:"transparent",stroke:"none"}),i&&le.jsx(oc,{content:[`Quartile 3 = ${Ki(n.quartiles.q3)}`,`Median = ${Ki(n.quartiles.q2)}`,`Quartile 1 = ${Ki(n.quartiles.q1)}`],x:h?m:e.y(n.quartiles.q2),y:h?e.y(n.quartiles.q2):m,sideDistances:o,horizontal:h,active:f,offset:s>1?b/2:b/4,container:c})]})}var E5t=1;function x5t({scaleX:e,scaleY:t,orientation:n,width:r,height:a,axisX:i,axisY:o,frameType:s}){let[c,f]=Vn.useState(e.domain()),A=Math.abs(t.range()[0]-t.range()[1]),h=Math.min(Math.floor(A/tK),10),[m,g]=Vn.useState(t.ticks(h)),b=e.bandwidth()/2,C=_=>(e(_)??0)+b,x=_=>t(_),k=n==="vertical";return Vn.useEffect(()=>{let _=e.domain(),D=t.ticks(h);f(_),g(D)},[e,t]),le.jsxs("g",{stroke:Jf,children:[i.showGrid&&c.map(_=>{let D=C(_)+(i.linesBetweenCategories?b:0);return le.jsx("line",{x1:k?D:0,x2:k?D:r,y1:k?0:D,y2:k?a:D},`x_${_}`)}),o.showGrid&&m.map(_=>{let D=x(_);return le.jsx("line",{x1:k?0:D,x2:k?r:D,y1:k?D:0,y2:k?D:a},`y_${_}`)}),s!=="empty"&&le.jsxs("g",{strokeWidth:E5t,children:[(i.showGrid||s!=="left")&&le.jsx("line",{stroke:s==="left"?Jf:Zt,x1:"0",x2:r,y1:a,y2:a}),(i.showGrid||s!=="bottom")&&le.jsx("line",{stroke:s==="bottom"?Jf:Zt,x1:"0",x2:"0",y1:"0",y2:a}),(i.showGrid||s==="full")&&le.jsx("line",{stroke:s==="full"?Zt:Jf,x1:r,x2:r,y1:"0",y2:a}),(o.showGrid||s==="full")&&le.jsx("line",{stroke:s==="full"?Zt:Jf,x1:"0",x2:r,y1:"0",y2:"0"})]})]})}function S5t(e,t,n){if(!e.length)return[];let r=[0];for(let a=0;a<e.length-1;a++){let i=e[a];if(i.meta.statType==="pairwise"){let o=uK(i.values[n],t,i.meta.significanceLevels,i.meta.ns);r.push(r[r.length-1]+i2*o)}else r.push(r[r.length-1]+i2)}return r}function dK(e){return typeof e=="string"?e:e.value}function B5t({facetSettings:e,facetTitle:t,dimensions:n,scales:r,orientation:a,layersData:i,statsData:o,facetKey:s,xAxis:c,yAxis:f,frameType:A,tooltips:h,tooltipsContainer:m,keyColumn:g,chartSizes:b,margins:C,xLabels:x,onlyPositive:k,secondaryGrouping:_}){let D=a==="vertical",O=S5t(o,r.xPrimary.domain(),s),I=c.showTicks?eK:0,$=f.showTicks?eK:0,Q=dK(c.title),ee=dK(f.title),K=n.chartEdgeSides.includes("left")||D&&!(e!=null&&e.sharedY)||!D&&!(e!=null&&e.sharedX),re=n.chartEdgeSides.includes("bottom")||D&&!(e!=null&&e.sharedX)||!D&&!(e!=null&&e.sharedY),U=n.chartEdgeSides.includes("left"),G=n.chartEdgeSides.includes("bottom"),{width:Z,height:Y}=n.inner,{left:X,top:oe,padding:me}=n,ae={left:C.left+X+me.left,right:b.totalWidth-(C.left+X+me.left),top:C.top+oe+me.top,bottom:b.totalHeight-(C.top+oe+me.top)},ye=`translate(${X+me.left},${oe+me.top})`,Ce=!1;return le.jsxs("g",{transform:ye,children:[Ce,t.length&&le.jsxs("g",{children:[A==="full"&&le.jsx("rect",{x:"0",y:-me.top,height:me.top,width:Z,fill:"#F7F8FA",stroke:Zt}),t.map((ce,ge)=>{let ze=t.length,Ne=(me.top-m9*ze)/2;return le.jsx("text",{fontSize:"14px",fontWeight:"500",fill:Zt,x:Z/2,dy:Ne+m9/2-me.top,y:ge*m9,textAnchor:"middle",dominantBaseline:"central",children:ce},ge)})]}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[G&&le.jsx("text",{x:Z/2,y:Y+me.bottom-l1/2,children:D?Q:ee}),G&&Ce&&le.jsx("rect",{x:"0",y:Y+me.bottom-l1,width:Z,height:l1,fill:"none",stroke:"black"}),U&&le.jsx("text",{x:-me.left+l1/2,y:Y/2,transform:`rotate(-90,${-me.left+l1/2},${Y/2})`,children:D?ee:Q}),U&&Ce&&le.jsx("rect",{x:-me.left,y:"0",width:l1,height:Y,fill:"none",stroke:"black"})]}),le.jsx(x5t,{orientation:a,width:Z,height:Y,scaleX:r.xPrimary,scaleY:r.y,axisX:c,axisY:f,frameType:A}),re&&le.jsx("g",{transform:`translate(0,${Y})`,children:D?le.jsx(rK,{scale:r.xPrimary,orient:"bottom",labelsPosition:c.labelsPosition,tickSize:I,labels:x}):le.jsx(cK,{scale:r.y,onlyPositive:k,orient:"bottom",tickSize:$})}),K&&le.jsx("g",{children:D?le.jsx(cK,{scale:r.y,onlyPositive:k,orient:"left",tickSize:$}):le.jsx(rK,{scale:r.xPrimary,orient:"left",labelsPosition:c.labelsPosition,tickSize:I,labels:x})}),le.jsxs("g",{children:[i.map(ce=>le.jsxs("g",{children:[ce.type==="box"&&ce.geoms[s].map(ge=>le.jsx(t5t,{box:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,aes:ce.aes,hasKeyFromColumn:g!==null,sideDistances:ae,showTooltips:h.box.show,tooltipsContainer:m},ge.key)),ce.type==="violin"&&ce.geoms[s].map(ge=>le.jsx(b5t,{violin:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,maxViolinDensity:ce.meta.maxDensity,aes:ce.aes,sideDistances:ae,showTooltips:h.violin.show,tooltipsContainer:m},ge.key)),ce.type==="dot"&&ce.geoms[s].map(ge=>le.jsx(r5t,{geom:ge,scales:r,orientation:a,aes:ce.aes,hasKeyFromColumn:g!==null,sideDistances:ae,showTooltips:h.dot.show,tooltipsContainer:m},ge.key)),ce.type==="line"&&ce.geoms[s].map(ge=>le.jsx(o5t,{line:ge,scales:r,orientation:a,sideDistances:ae,aes:ce.aes,showTooltips:h.line.show,secondaryGrouping:_,tooltipsContainer:m},ge.key)),ce.type==="errorbar"&&ce.geoms[s].map(ge=>le.jsx(a5t,{errorBar:ge,scales:r,orientation:a,aes:ce.aes,sideDistances:ae,showTooltips:h.errorBar.show,tooltipsContainer:m},ge.key)),ce.type==="bar"&&ce.geoms[s].map(ge=>le.jsx(J2t,{bar:ge,scales:r,orientation:a,aes:ce.aes},ge.key)),ce.type==="stackedBar"&&ce.geoms[s].map(ge=>le.jsx(d5t,{geom:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,aes:ce.aes,normalize:ce.meta.normalize,sideDistances:ae,showTooltips:h.stackedBar.show,secondaryGrouping:_,tooltipsContainer:m},ge.key)),ce.type==="binnedDots"&&ce.geoms[s].map(ge=>le.jsx(q2t,{geom:ge,scales:r,orientation:a,aes:ce.aes,binsCount:ce.meta.binsCount,min:ce.meta.minY,max:ce.meta.maxY,hasKeyFromColumn:ce.meta.hasKeyFromColumn,sideDistances:ae,showTooltips:h.stackedBar.show,tooltipsContainer:m},ge.key)),ce.type==="pairedPoints"&&ce.geoms[s].map(ge=>le.jsx(u5t,{geom:ge,scales:r,orientation:a,sideDistances:ae,aes:ce.aes,showTooltips:h.pairedPoints.show,tooltipsContainer:m},ge.id)),ce.type==="sina"&&ce.geoms[s].map(ge=>le.jsx(f5t,{geom:ge,scales:r,orientation:a,sideDistances:ae,aes:ce.aes,hasKeyFromColumn:g!==null,showTooltips:!1,tooltipsContainer:m},ge.key)),ce.type==="logo"&&ce.geoms[s].map(ge=>le.jsx(s5t,{geom:ge,elementsAmount:ce.geoms[s].length,scales:r,orientation:a,aes:ce.aes,normalize:ce.meta.normalize,sideDistances:ae,showTooltips:!0,tooltipsContainer:m},ge.key))]},ce.type)),o.map((ce,ge)=>le.jsx(m5t,{yShift:O[ge],scales:r,orientation:a,statType:ce.meta.statType,values:ce.values[s],testMethod:ce.meta.testMethod,format:ce.meta.format,ns:ce.meta.ns,significanceLevels:ce.meta.significanceLevels},`${ce.meta.statType}_${ce.meta.testMethod}`))]})]})}var f2=class extends gb.Component{constructor(e){super(e),this.state={hasError:!1,message:""}}static getDerivedStateFromError(e){return{hasError:!0,message:e.message}}componentDidUpdate(e){e.dataId!==this.props.dataId&&this.setState({hasError:!1,message:"error.message"})}componentDidCatch(e,t){console.log(t)}render(){return this.state.hasError?le.jsx(Fm,{message:this.state.message}):this.props.children}};function k5t(e,t,n,r){return e==="left"?n:e==="right"?t-r:(t-(n+r))/2+n}function T5t(e){return e==="left"?"start":e==="right"?"end":"middle"}function d2({show:e,position:t,title:n,chartsWidth:r,leftPadding:a,rightPadding:i}){return e?le.jsx("g",{children:n.map((o,s)=>le.jsx("text",{x:k5t(t,r,a,i),textAnchor:T5t(t),y:-(n.length-s-1)*24-24-24/2,fontSize:"20px",fontFamily:"Manrope",fontWeight:"500",dominantBaseline:"central",children:o},`${o}_${s}`))}):null}var Hc=12,g9=-12,AK=14;function _5t(e=null){return e==="dashed"?"M1 11.25H6V12.75H1V11.25ZM9.5 11.25H14.5V12.75H9.5V11.25ZM18 11.25H23V12.75H18V11.25Z":e==="dotted"?"M2.75 11.25H1.25V12.75H2.75V11.25Z M11.25 11.25H12.75V12.75H11.25V11.25Z M22.75 11.25H21.25V12.75H22.75V11.25Z M7.75 11.25H6.25V12.75H7.75V11.25Z M16.25 11.25H17.75V12.75H16.25V11.25Z":e==="longdash"?"M1 11.25H10V12.75H1V11.25ZM14 11.25H23V12.75H14V11.25Z":e==="dotdash"?"M1 11.25H2.5V12.75H1V11.25ZM17 12.75H7V11.25H17V12.75ZM21.5 12.75V11.25H23V12.75H21.5Z":e==="twodash"?"M1 11.25H4V12.75H1V11.25ZM17.0261 12.75H7V11.25H17.0261V12.75ZM20 12.75V11.25H23V12.75H20Z":"M1 11.25H23V12.75H1V11.25Z"}var P5t=3,M5t=24;function D5t({aes:e,label:t,usedAes:n}){let r=n.lineShape,a=n.dotShape,i=n.fillColor||n.lineColor&&!n.lineShape||n.dotFill&&!n.dotShape,o=a?Af(e.dotShape??"21",P5t,i?Zt:e.dotFill??Zt):null,s=(a&&r?2*Hc:0)-6,c=r?s+M5t+8:Hc+8;return le.jsxs("g",{children:[i&&le.jsx("rect",{width:Hc,height:Hc,stroke:e.fillColor??e.lineColor,fill:e.fillColor??e.lineColor,rx:"1",ry:"1"}),a&&le.jsx("g",{transform:`translate(${Hc/2},${Hc/2})`,children:o}),r&&le.jsx("path",{transform:`translate(${s},-5)`,fillRule:"evenodd",clipRule:"evenodd",d:_5t(e.lineShape),fill:e.lineColor}),le.jsx("text",{x:c,y:Hc/2,dominantBaseline:"central",fontWeight:500,children:t})]})}function H5t({aes:e,label:t}){let n=Af(e.shape,e.size,e.color);return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${Hc/2},${Hc/2})`,children:n}),le.jsx("text",{x:Hc+8,y:Hc/2,dominantBaseline:"central",fontWeight:500,children:t})]})}function y9({legendData:e}){let t=e.items.filter(n=>n.type==="continuous");return le.jsxs("g",{children:[le.jsx("defs",{children:t.map(n=>le.jsx("linearGradient",{id:n.id,gradientTransform:"rotate(90)",children:n.scale.domain().reverse().map(r=>{let a=n.scale.domain(),i=a[a.length-1]-a[0],o=i>0?100-(r-a[0])/i*100:0;return le.jsx("stop",{offset:`${o}%`,stopColor:n.scale(r)},r)})},n.id))}),e.items.map(n=>{if(n.type==="continuous")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:g9,children:n.title}),le.jsx("rect",{x:"0",y:"0",width:AK,height:n.height,stroke:Zt,fill:`url(#${n.id})`}),le.jsx("g",{transform:`translate(${AK},0)`,children:n.values.map(r=>{let a=n.tickPositionScale(r)??0;return le.jsxs("g",{transform:`translate(0,${a})`,children:[le.jsx("line",{x1:"0",x2:-4,stroke:Zt}),le.jsx("text",{x:8,y:4,children:r})]},r)})}),!1]},n.id);if(n.type==="discreteColor")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,children:[le.jsx("text",{fontWeight:500,fontSize:"14px",y:g9,children:n.title}),n.values.map((r,a)=>le.jsxs("g",{transform:`translate(0, ${a*(Hc+4)})`,children:[le.jsx("rect",{x:"0",y:"0",width:Hc,height:Hc,fill:n.scale(r),rx:"1",ry:"1",stroke:Zt}),le.jsx("text",{x:Hc+8,y:10,children:r})]},r)),!1]},n.id);if(n.type==="discreteMulti")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:600,y:g9,children:n.title}),n.values.map((r,a)=>le.jsx("g",{transform:`translate(0, ${a*(Hc+4)})`,children:le.jsx(D5t,{aes:n.scale(r),label:n.labels[r],usedAes:n.usedAes})},r)),!1]},n.id);if(n.type==="dots")return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:g9,children:n.title}),n.values.map((r,a)=>le.jsx("g",{transform:`translate(0, ${a*(Hc+4)})`,children:le.jsx(H5t,{aes:n.scale(r),label:n.labels[r]})},r)),!1]},n.id);if(n.type==="size"){let r=n.height/n.values.length;return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:"14px",fontWeight:500,children:[le.jsx("text",{fontWeight:500,y:g9,children:n.title}),n.values.map((a,i)=>{let o=n.scale(a);return le.jsxs("g",{transform:`translate(0, ${i*r})`,children:[le.jsx("circle",{r:o,cx:r/2,cy:r/2,fill:Zt}),le.jsx("text",{x:r+4,y:r/2,alignmentBaseline:"central",children:n.labels[a]})]},a)}),!1]},n.id)}})]})}function I5t({settingsId:e,chartSettings:t,chartSizes:n,chartsDimensions:r,facetKeys:a,facetTitles:i,facetSettings:o,scales:s,layersData:c,statsData:f,legendData:A,margins:h,columnsCount:m,keyColumn:g,xLabels:b,chartTitle:C,onlyPositive:x,secondaryGrouping:k}){let[_,D]=Vn.useState(),{orientation:O,xAxis:I,yAxis:$,title:Q,legend:ee,frame:K}=t,re=r[a[0]].padding,U=r[a[m-1]].padding,G=n.chartsWidth+j8,Z=re.top;return le.jsx(f2,{dataId:e,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${n.totalWidth} ${n.totalHeight}`,width:n.totalWidth,height:n.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${h.left},${h.top})`,fontFamily:"Manrope",children:[le.jsx(d2,{title:C,show:Q.show,position:Q.position,leftPadding:re.left,rightPadding:U.right,chartsWidth:n.chartsWidth}),a.map(Y=>le.jsx(B5t,{facetKey:Y,facetTitle:i[Y],facetSettings:o,orientation:O,scales:{...s,xPrimary:s.xPrimary[Y],xSecondary:s.xSecondary[Y],y:s.y[Y]},chartSizes:n,margins:h,dimensions:r[Y],layersData:c,statsData:f,xAxis:I,yAxis:$,frameType:K.type,tooltips:t.tooltips,tooltipsContainer:_,keyColumn:g,xLabels:b[Y],onlyPositive:x,secondaryGrouping:k},Y)),ee.show&&le.jsx("g",{transform:`translate(${G},${Z})`,children:le.jsx(y9,{legendData:A})})]}),le.jsx("g",{ref:Y=>{Y&&!_&&D(Y)}})]})})}function pK(e,t){let n=Object.keys(e.values),r=e.reduce((a,i)=>{if(i.meta.statType==="pairwise"){let o=Object.values(i.values).map(s=>uK(s,t,i.meta.significanceLevels,i.meta.ns));return a+i2*Math.max(...o)}return(i.meta.ns?t.length>0:n.some(o=>i.values[o].some(([,s])=>s<i.meta.significanceLevels.one)))?a+i2:a},Q2t);return Math.max(h9.TOP,r)}function A2(e,t,n=r=>r){let r=A=>t==="log"?Math.log10(A):A,a=A=>t==="log"?Math.pow(10,A):A,i=e.map(n).map(r).sort((A,h)=>A-h),o=Dp(i,.25),s=Dp(i,.75),c=s-o,f=1.5;return[a(o-f*c),a(s+f*c)]}function L5t(e,t,n,r=14){let a=new Dc(`600 ${r}px Manrope`),i=[];e.split(new RegExp("(?=[_-])|(?<=[_-])")).forEach(h=>{a.getTextWidth(h)>n?i.push(...h.split("")):i.push(h)});let o="",s=0,c=0,f="";for(;s<=t;){let h=a.getTextWidth(o+i[c]);h<t&&(o+=i[c],f=o,c++),s=h}o="",s=0;let A=[];for(c;c<i.length;c++){let h=a.getTextWidth(o+i[c]);h<n?(o+=i[c],s=h):(A.push(o),o=i[c],s=a.getTextWidth(i[c]))}return{firstPart:f,lines:A,lastPart:o,lastPartLength:s}}function Om(e,t,n){let r=new Dc(`600 ${n}px Manrope`);if(e.trim()==="")return[];if(r.getTextWidth(e)<=t)return[e];let a=e.split(/\s+/),i=[],o="",s=0;for(let c=0;c<a.length;c++){let f=`${o} ${a[c]}`,A=r.getTextWidth(f);if(A<=t)o=f,s=A;else{let h=r.getTextWidth(a[c]);if(h>t){let{firstPart:m,lines:g,lastPart:b,lastPartLength:C}=L5t(a[c],t-s,t,n);i.push(`${o} ${m}`),i.push(...g),o=b,s=C}else i.push(o),o=a[c],s=h}}return i.push(o),i.filter(c=>c.length>0)}var hK=new Dc("600 14px Manrope"),R5t=16,kP=48,N5t=20,Pg=24;function TP(e,t){return Math.max(...e.map(n=>hK.getTextWidth(String(n))+N5t),hK.getTextWidth(t))}function $5t(e,t,n,r){let a=[[]],i=0,o=t,s=0;return e.forEach(c=>{i+r<=o?(a[s].push(c),i+=r):(a.push([c]),s++,i=r,o=n)}),a}function w9(e,t,n){let r=n??t,a=0,i=0,o=0;e.sort((c,f)=>c.type==="continuous"&&f.type!=="continuous"?-1:f.type==="continuous"&&c.type!=="continuous"?1:c.type==="dots"&&f.type!=="dots"?-1:f.type==="dots"&&c.type!=="dots"?1:0);let s=[];return e.forEach(c=>{let{type:f,values:A,title:h,id:m,scale:g}=c;if(f==="continuous"){let b=UX(A,h),C=r;t-i<C&&(o+=a+Pg,a=0,i=0);let x=o,k=i;b>a&&(a=b),i+=C+kP,i>=t&&(o+=a+Pg,a=0,i=0),s.push({...c,width:b,height:C,left:x,top:k})}else if(f==="size"){let{labels:b}=c,C=g(Math.max(...A))*2+4,x=TP(A.map(O=>b[O]),h),k=A.length*C;t-i<k&&(o+=a+Pg,a=0,i=0);let _=o,D=i;x>a&&(a=x),i+=k+kP,i>=t&&(o+=a+Pg,a=0,i=0),s.push({...c,width:x,height:k,left:_,top:D})}else{let{labels:b}=c,C=R5t,x=t-i;x<C&&(x=t,o+=a+Pg,a=0,i=0);let k=$5t(A,x,t,C),_=TP([],h),D=a===0,O=o+_+Pg;k.forEach((I,$)=>{let Q=$===k.length-1,ee=$>0?"":h,K=$>0?`${m}_${$}`:m,re=TP(I.map(Y=>b[Y]),D?"":ee),U=I.length*C,G=o,Z=i;re>a&&(a=re),Q?i+=U+kP:i=t,i>=t&&(o+=a+Pg,D&&Q&&o<O&&(o=O),a=0,i=0),s.push({...c,id:K,title:ee,width:re,height:U,left:G,top:Z,values:I})})}}),s}function F5t(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function V5t(e,t,n,r,a,i,o,s,c,f){let A=e==="vertical",h=o.includes("left")||A&&!(s!=null&&s.sharedY)||!A&&!(s!=null&&s.sharedX),m=o.includes("left")&&n.title!=="",g=o.includes("bottom")||A&&!(s!=null&&s.sharedX)||!A&&!(s!=null&&s.sharedY),b=o.includes("bottom")&&t.title!=="",C=r.yAxisCaptionsWidth,x=(n.showTicks?t2:0)+ed,k=m?l1:0,_=r.xAxisCaptionsWidthByRows[A?c:f],D=(t.showTicks?t2:0)+ed,O=b?l1:0,I=A?C+x+k:_+D+O,$=A?D+_+O:x+2*l1,Q=Math.max(...a.map(ee=>i[ee].length));return{left:h?I:CP,top:Q===0?0:O2t*2+Q*m9,bottom:g?$:CP,right:CP}}function O5t(e,t,n){let r=new Array(n).fill(null).map(()=>[]);for(let a=0;a<n;a++)for(let i=0;i<t;i++)i*n+a<e.length&&r[a].push(e[i*n+a]);return r}function mK(e,t,n){let r=[];for(let a=0;a<t;a++)r.push(e.slice(a*n,a*n+n));return r}function Q5t(e,t){let n=Math.floor(e/t),r=e-n*t;return[n,r]}function z5t(e){return typeof e=="object"&&"type"in e}var U5t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{xPrimary:{null:F5().range([0,600]).domain(["1"])},xSecondary:{null:F5().range([0,600]).domain(["1"])},y:{null:Da().domain([0,10]).range([350,0]).nice()},xPrimaryAes:Hl().unknown(qX),xSecondaryAes:Hl().unknown(qX)});Me(this,"facetTitles",{});Me(this,"mainTitle",[]);Me(this,"axisLabelsX",{});Me(this,"captionsSizes",{xAxisCaptionsWidthByRows:[],xCaptionsTail:0,yAxisCaptionsWidth:100});Me(this,"legend",{width:0,height:0,items:[]});Me(this,"margins",{left:0,right:0,top:0,bottom:0})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateChartSize(e,t,n,r,a,i){let o=pK(i,r),s=t.length,c=Math.min((n==null?void 0:n.nRows)??s,s),f=Math.min((n==null?void 0:n.nCols)??s,s);this.columnsCount=n!=null&&n.nRows?Math.ceil(s/c):f,this.rowsCount=Math.ceil(s/this.columnsCount);let{width:A,height:h}=e;a==="vertical"&&o>h9.TOP&&(h+=o),a==="horizontal"&&o>h9.TOP&&(A+=o),this.chartSizes.chartWidth=A,this.chartSizes.chartHeight=h}updateChartDimensions(e,t,n,r,a){let{chartWidth:i,chartHeight:o}=this.chartSizes,s=0,c=0;this.chartsDimensions=e.reduce((h,m,g)=>{let[b,C]=Q5t(g,this.columnsCount),x=F5t(g,e.length,this.columnsCount,this.rowsCount),k=V5t(n,r,a,this.captionsSizes,mK(e,this.rowsCount,this.columnsCount)[b],this.facetTitles,x,t,b,C),_=i+k.left+k.right,D=o+k.top+k.bottom;return h[m]={left:s,top:c,chartEdgeSides:x,padding:k,inner:{width:i,height:o},outer:{width:_,height:D}},s+=_,C===this.columnsCount-1&&(s=0,c+=D),h},{});let f=Math.max(...e.map(h=>this.chartsDimensions[h].outer.width+this.chartsDimensions[h].left)),A=Math.max(...e.map(h=>this.chartsDimensions[h].outer.height+this.chartsDimensions[h].top));this.chartSizes.chartsWidth=f,this.chartSizes.chartsHeight=A}updateViewport(e,t,n,r,a,i,o,s,c){let f=e==="vertical",A=pK(s,t),h=a===null||a.sharedX,m=a===null||a.sharedY,{chartHeight:g,chartWidth:b}=this.chartSizes;r.forEach(C=>{let x=i.scale==="log"?Rv():Da(),k=Math.min(...m?o.map(({meta:I})=>I.minY):o.map(({geoms:I})=>Math.min(...I[C].map(({boundsY:$})=>$.min)))),_=Math.max(...m?o.map(({meta:I})=>I.maxY):o.map(({geoms:I})=>Math.max(...I[C].map(({boundsY:$})=>$.max)))),D=x.copy().domain([k,_]).range(f?[g-h9.BOTTOM,A]:[h9.BOTTOM,b-A]);x.domain([D.invert(f?g:0),D.invert(f?0:b)]).range(f?[g,0]:[0,b]),this.scales.y[C]=x;let O=h?t:c[C];this.scales.xPrimary[C]=F5().domain(O).range(f?[0,b]:[g,0]),this.scales.xSecondary[C]=F5().domain(n).range([0,this.scales.xPrimary[C].bandwidth()])})}createFacetTitles(e,t){this.facetTitles=e.reduce((n,r,a)=>(t[a].length===1&&t[a][0]==="null"?n[r]=[]:n[r]=Om(t[a].join(", "),this.chartSizes.chartWidth,14),n),{})}createMainTitle(e,t){let n=this.chartsDimensions[e[0]],r=this.chartsDimensions[e[e.length-1]];this.mainTitle=Om(t.name,this.chartSizes.chartsWidth-n.padding.left-r.padding.right,20)}createAxisLabels(e,t,n,r){let a={center:120,"45deg":256,"90deg":320},i=r==="vertical";function o(s,c){return s==="center"?1/0:Math.floor(s==="45deg"?c*Math.sin(Math.PI/4)/bP:c/bP)}this.axisLabelsX=e.reduce((s,c)=>{let f=this.scales.xPrimary[c],A=f.bandwidth(),h=a[t.labelsPosition],m=t.labelsPosition==="center"?Math.min(h,A):h,g=n.valueLabels;return s[c]=f.domain().reduce((b,C)=>{let x=g[C];if(!i)b[C]=[x];else{let k=o(t.labelsPosition,A),_=Om(x,m,14);b[C]=_.length>k?[x]:_}return b},{}),s},{})}updateAesScales(e,t){if(e.inheritedAes){let{inheritedAes:n,keys:r}=e;this.scales.xPrimaryAes.domain(r).range(r.map(a=>n[a]))}else this.scales.xPrimaryAes.domain([]).range([]);if(t.inheritedAes){let{inheritedAes:n,keys:r}=t;this.scales.xSecondaryAes.domain(r).range(r.map(a=>n[a]))}else this.scales.xSecondaryAes.domain([]).range([])}updateCaptionsSize(e,t,n){let r=new Dc("600 14px Manrope"),a=e==="vertical";function i(g){return g.length?Math.max(...g.map(b=>r.getTextWidth(b))):0}function o(g){return g.length?Math.max(...g.map(i)):0}let s=[],c=0,f=mK(t,this.rowsCount,this.columnsCount),A=O5t(t,this.rowsCount,this.columnsCount);if(!a)s=A.map(g=>Math.max(...g.map(b=>o(this.scales.xPrimary[b].domain().map(C=>this.axisLabelsX[b][C])))));else{if(n.labelsPosition==="center"&&(s=f.map(g=>Math.max(...g.map(b=>Math.max(...this.scales.xPrimary[b].domain().map(C=>C?this.axisLabelsX[b][C].length*bP:0)))))),n.labelsPosition==="45deg"){let g=Math.sin(Math.PI/4);s=f.map(b=>Math.max(...b.map(C=>{let x=this.scales.xPrimary[C].domain().map(_=>this.axisLabelsX[C][_]),k=o(x);return k>0?k*g+14:0}))),c=Math.max(...A[0].map(b=>{let C=this.scales.xPrimary[b].domain(),x=this.axisLabelsX[b][C[0]];return Math.max(i(x)*g-this.scales.xPrimary[b].bandwidth()/2+14,0)}))}n.labelsPosition==="90deg"&&(s=f.map(g=>Math.max(...g.map(b=>o(this.scales.xPrimary[b].domain().map(C=>this.axisLabelsX[b][C]))))))}let h=Ir.flatten(t.map(g=>{let b=this.scales.y[g],C=b.ticks(),x=C.some(_=>Math.abs(_)<1e-4&&_!==0||_>1e4)?",e":",f",k=b.tickFormat(10,x);return C.map(k)})),m=i(h);this.captionsSizes={xCaptionsTail:c,xAxisCaptionsWidthByRows:s,yAxisCaptionsWidth:m}}updateMargins(e,t){let n=this.chartsDimensions[t[0]],r=this.chartsDimensions[t[t.length-1]],a=e==="vertical";this.margins={left:Math.max(z8,a?this.captionsSizes.xCaptionsTail-n.padding.left:0),right:Math.max(this.legend.width,z8),top:Math.max(24*this.mainTitle.length+24*2,z8),bottom:Math.max(z8,a?0:this.captionsSizes.xCaptionsTail-r.padding.bottom)},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight,this.legend.height)+this.margins.bottom}updateLegendSize(e,t,n,r){if(!e.show){this.legend={width:0,height:0,items:[]};return}let a=this.chartSizes.chartHeight,i={width:0,height:0,left:0,top:0},o=[];function s(b,C){return r.some(x=>{let k=x.aes[C];return k&&z5t(k)&&k.type===b})}function c(b){return{dotFill:s(b,"dotFill"),fillColor:s(b,"fillColor"),lineColor:s(b,"lineColor"),dotShape:s(b,"dotShape"),lineShape:s(b,"lineShape")}}let f=c("primaryGrouping"),A=c("secondaryGrouping");if(Object.values(f).some(b=>b)&&t.inheritedAes&&o.push({type:"discreteMulti",id:"primary",title:t.label,scale:this.scales.xPrimaryAes,values:t.keys,labels:t.valueLabels,usedAes:f,...i}),Object.values(A).some(b=>b)&&n.inheritedAes&&o.push({type:"discreteMulti",id:"secondary",title:n.label,scale:this.scales.xSecondaryAes,values:n.keys,labels:n.valueLabels,usedAes:A,...i}),!o.length){this.legend={width:0,height:0,items:[]};return}let h=w9(o,this.chartSizes.chartHeight),m=h[h.length-1],g=m.left+m.width+2*j8;this.legend={width:g,height:a,items:h}}render(e,t,n,r,a,i,o,s,c,f,A,h){var k;let{orientation:m,xAxis:g,yAxis:b,size:C}=t;this.updateChartSize(C,i,a,n.keys,m,c),this.updateViewport(m,n.keys,r.keys,i,a,b,s,c,A),this.createAxisLabels(i,g,n,m),this.createFacetTitles(i,o),this.updateCaptionsSize(m,i,g),this.updateChartDimensions(i,a,m,g,b),this.updateLegendSize(t.legend,n,r,s),this.createMainTitle(i,t.title),this.updateMargins(m,i),this.updateAesScales(n,r);let x=le.jsx(I5t,{settingsId:e,chartSettings:t,facetKeys:i,facetSettings:a,facetTitles:this.facetTitles,chartSizes:this.chartSizes,chartsDimensions:this.chartsDimensions,scales:this.scales,layersData:s,statsData:c,legendData:this.legend,margins:this.margins,columnsCount:this.columnsCount,keyColumn:f,xLabels:this.axisLabelsX,chartTitle:this.mainTitle,onlyPositive:h,secondaryGrouping:r});this.component=x,(k=this.reactRoot)==null||k.render(x)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},j5t=U5t;function G5t(e,t,n,r=!1){let a=e.map(t).sort((i,o)=>i-o);if(r){let i=Ir.find(a,o=>o>0);if(!i)throw Error("Group with all zeros in log scale");return a.map(o=>o===0?i:o).map(n)}return a.map(n)}var Y5t=class{constructor(e,t,n,r,a,i,o,s,c,f,A=!0){Me(this,"lower");Me(this,"middle");Me(this,"upper");Me(this,"min");Me(this,"max");Me(this,"outliers");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"key");Me(this,"boundsY");if(e.length===0)throw Error("Unable to create box on empty data");if(o>s||o>c||s>c)throw Error(`Invalid box bounds values: lower=${o}, middle=${s}, upper=${c}`);if(f<0)throw Error(`Invalid box whiskers coefficient: k=${f}. It should be positive`);let h=I=>Number(I[t]);this.primaryGrouping=a===null?"":String(a),this.secondaryGrouping=i===null?"":String(i),this.key=`box_${this.primaryGrouping}_${this.secondaryGrouping}`;let m=I=>r==="log"?Math.log10(I):I,g=I=>r==="log"?Math.pow(10,I):I,b=G5t(e,h,m,r==="log"),C=Dp(b,o),x=Dp(b,s),k=Dp(b,c),_=k-C;this.upper=g(k),this.middle=g(x),this.lower=g(C),this.min=Math.max(mC(e,h),g(C-f*_)),this.max=Math.min(Ih(e,h),g(k+f*_)),this.outliers=e.filter(I=>h(I)<this.min||h(I)>this.max).map((I,$)=>({y:h(I),data:I,id:String(n?I[n]:$)}));let[D=1/0,O=-1/0]=$A(this.outliers,I=>I.y);this.boundsY={min:A?Math.min(this.min,D):this.min,max:A?Math.max(this.max,O):this.max}}};function W5t(e,t,n,r,a,i,o,s){let c=1/0,f=-1/0;return{type:"box",geoms:t.reduce((A,h)=>{let m=h.join("_");return A[m]=[],n.forEach(g=>{r.forEach(b=>{let C=a.getRowsByGrouping([...h,g,b]);if(!C.length)return;let x=new Y5t(C,i.value,(o==null?void 0:o.value)??null,s.scale,g,b,e.stat.lower,e.stat.medium,e.stat.upper,e.stat.k,e.aes.showOutliers);x.boundsY.min<c&&(c=x.boundsY.min),x.boundsY.max>f&&(f=x.boundsY.max),A[m].push(x)})}),A},{}),meta:{minY:c,maxY:f},aes:e.aes}}var vK=40;function X5t(e,t){return function(n){return t.map(function(r){return[r,tu(n,a=>e(r-a))]})}}function K5t(e){return function(t){return 1/Math.sqrt(2*Math.PI)*Math.pow(Math.E,-.5*Math.pow(t/e,2))}}function Z5t(e){let t=tu(e);return tu(e.map(n=>Math.pow(n-t,2)))}function J5t(e){return Math.sqrt(Z5t(e))}function q5t(e,t,n){let r=(n-t)/1.34,a=J5t(e);return 1.06*Math.min(a,r)*Math.pow(e.length,-1/5)}var e7t=class{constructor(e,t,n,r,a,i){Me(this,"getArea");Me(this,"getLine");Me(this,"maxDensity");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"key");Me(this,"boundsY");Me(this,"quartiles");if(e.length===0)throw Error("Unable to calculate violin on empty data");if(r!=="auto"&&r<1)throw Error(`Unable to calculate violin with ${r} steps`);this.primaryGrouping=a===null?"":String(a),this.secondaryGrouping=i===null?"":String(i),this.key=`violin_${this.primaryGrouping}_${this.secondaryGrouping}`;let o=I=>t==="log"?Math.log10(I):I,s=I=>t==="log"?Math.pow(10,I):I,c=e.filter(I=>t==="log"&&Number(I)===0?(console.warn("Value = 0 on chart with log scale, it was removed from calculation"),!1):!0).map(o).sort((I,$)=>I-$),f=c[0],A=c[c.length-1],h=A-f,m=Dp(c,.25),g=Dp(c,.5),b=Dp(c,.75);this.quartiles={q1:s(m),q2:s(g),q3:s(b)};let C=q5t(c,m,b),x=r!=="auto"?r:C/3>h/vK?vK:h/(C/3),k=n?f:f-3*C,_=n?A:A+3*C,D=Da().domain([k,_]).ticks(x);this.boundsY={min:s(D[0]),max:s(D[D.length-1])};let O=X5t(K5t(C),D)(c).map(([I,$])=>[s(I),$]);this.maxDensity=Ih(O,([,I])=>I),this.getArea=(I,$,Q,ee)=>{let K=I==="vertical",re=ee??this.maxDensity,U=Da().domain([-re,re]).range([-Q/2,Q/2]);return K?VB().curve(A3).x0(G=>U(G[1])).x1(G=>U(-G[1])).y(G=>$(G[0]))(O):VB().curve(A3).y0(G=>U(G[1])).y1(G=>U(-G[1])).x(G=>$(G[0]))(O)},this.getLine=(I,$,Q,ee)=>{let K=I==="vertical",re=ee??this.maxDensity,U=Da().domain([-re,re]).range([-Q/2,Q/2]);return d3().curve(A3).x(K?G=>U(G[1]):G=>$(G[0])).y(K?G=>$(G[0]):G=>U(G[1]))(O)+" "+d3().curve(A3).x(K?G=>U(-G[1]):G=>$(G[0])).y(K?G=>$(G[0]):G=>U(-G[1]))(O)}}};function t7t(e,t,n,r,a,i,o){let s=0,c=1/0,f=-1/0;return{type:"violin",geoms:t.reduce((A,h)=>{let m=h.join("_");return A[m]=[],n.forEach(g=>{r.forEach(b=>{let C=a.getColumnByGrouping([...h,g,b],i.value);if(!C.length)return;let x=new e7t(C,o.scale,e.stat.trim,e.stat.stepsCount,g,b);x.maxDensity>s&&(s=x.maxDensity),x.boundsY.min<c&&(c=x.boundsY.min),x.boundsY.max>f&&(f=x.boundsY.max),A[m].push(x)})}),A},{}),meta:{maxDensity:s,minY:c,maxY:f},aes:e.aes}}var n7t=30;function r7t(e,t){return function(n){return t.map(function(r){return tu(n,a=>e(r-a))})}}function a7t(e){return function(t){return 1/Math.sqrt(2*Math.PI)*Math.pow(Math.E,-.5*Math.pow(t/e,2))}}function i7t(e){let t=tu(e);return tu(e.map(n=>Math.pow(n-t,2)))}function o7t(e){return Math.sqrt(i7t(e))}function l7t(e){let t=Dp(e,.25),n=(Dp(e,.75)-t)/1.34,r=o7t(e);return 1.06*Math.min(r,n)*Math.pow(e.length,-1/5)}var s7t=class{constructor(e,t,n,r,a,i){Me(this,"key");Me(this,"maxDensity");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"points");Me(this,"boundsY");let o=n7t;if(e.length===0)throw Error("Unable to calculate sina on empty data");this.primaryGrouping=r===null?"":String(r),this.secondaryGrouping=a===null?"":String(a),this.key=`sina_${this.primaryGrouping}_${this.secondaryGrouping}`;let s=D=>n==="log"?Math.log10(D):D,c=D=>n==="log"?Math.pow(10,D):D,f=D=>Number(D[t.value]),A=e.filter(D=>n==="log"&&f(D)===0?(console.warn("Value = 0 on chart with log scale, it was removed from calculation"),!1):!0).sort((D,O)=>s(f(D))-s(f(O))),h=A.map(D=>s(f(D))),m=h[0],g=h[A.length-1],b=(g-m)/o,C=l7t(h),x=Ir.range(m+b,g,b);this.boundsY={min:c(m),max:c(g)};let k=r7t(a7t(C),x)(h),_=Da().domain(x).range(k).clamp(!0);this.maxDensity=Ih(k),this.points=A.map((D,O)=>({x:f(D),y:_(s(f(D)))/this.maxDensity,id:String(O),jitter:i(),data:D}))}};function u7t(e,t,n,r,a,i,o){let s=0,c=1/0,f=-1/0,A=nF(1);return{type:"sina",geoms:t.reduce((h,m)=>{let g=m.join("_");return h[g]=[],n.forEach(b=>{r.forEach(C=>{let x=a.getRowsByGrouping([...m,b,C]);if(!x.length)return;let k=x;if(!e.aes.showOutliers){let D=$=>Number($[i.value]),[O,I]=A2(x,o.scale,D);k=x.filter($=>{let Q=D($);return Q>=O&&Q<=I})}let _=new s7t(k,i,o.scale,b,C,A);_.maxDensity>s&&(s=_.maxDensity),_.boundsY.min<c&&(c=_.boundsY.min),_.boundsY.max>f&&(f=_.boundsY.max),h[g].push(_)})}),h},{}),meta:{maxDensity:s,minY:c,maxY:f},aes:e.aes}}function c7t(e,t,n,r,a,i,o,s){let c=1/0,f=-1/0,A=nF(1);return{type:"dot",geoms:t.reduce((h,m)=>{let g=m.join("_");return h[g]=[],n.forEach(b=>{r.forEach(C=>{let x=a.getRowsByGrouping([...m,b,C]);if(!x.length)return;let k=I=>Number(I[i.value]),_=x.map((I,$)=>({y:k(I),jitter:A(),id:String(s?I[s.value]:$),data:I}));if(!e.aes.showOutliers){let[I,$]=A2(x,o.scale,k);_=_.filter(({y:Q})=>Q>=I&&Q<=$)}let[D=1/0,O=-1/0]=$A(_,I=>I.y);D<c&&(c=D),O>f&&(f=O),h[g].push({key:`dots_${b}_${C}`,values:_,primaryGrouping:b,secondaryGrouping:C,boundsY:{min:D,max:O}})})}),h},{}),meta:{minY:c,maxY:f},aes:e.aes}}function f7t(e,t){if(t==="median")return mL(e,.5);if(t==="mean")return tu(e);vA(t,`Unknown line points calculation for dot layer: ${t}`)}function d7t(e,t,n,r,a,i,o){let s=1/0,c=-1/0;return{type:"line",geoms:t.reduce((f,A)=>{let h=A.join("_");f[h]=[];let m=-1/0,g=1/0;return e.aes.showOutliers||([m,g]=A2(a.getColumnByGrouping([...A],i.value),o.scale)),r.forEach(b=>{let C={key:`${b}`,boundsY:{min:1/0,max:-1/0},dots:{}},x=!1,k=D=>o.scale==="log"?Math.log10(D):D,_=D=>o.scale==="log"?Math.pow(10,D):D;n.forEach(D=>{let O=a.getColumnByGrouping([...A,D,b],i.value);if(!O.length){x=!0;return}let I=O;if(e.aes.showOutliers||(I=O.filter(Q=>Q>=m&&Q<=g)),!I.length){x=!0;return}let $=_(f7t(I.map(k),e.pointsValues));C.dots[D]=$,$<s&&(s=$),$>c&&(c=$),$<C.boundsY.min&&(C.boundsY.min=$),$>C.boundsY.max&&(C.boundsY.max=$)}),x||f[h].push(C)}),f},{}),meta:{minY:s,maxY:c},aes:e.aes}}function A7t(e){let t=tu(e);return tu(e.map(n=>Math.pow(n-t,2)))}function _P(e){return Math.sqrt(A7t(e))}function p7t(e){return _P(e)/Math.sqrt(e.length)}function h7t(e){return 1.96*_P(e)}function m7t(e,t){if(t==="median")return mL(e,.5);if(t==="mean")return tu(e);vA(t,"Unknown points calculation")}function v7t(e,t){if(t==="sd")return _P(e);if(t==="se")return p7t(e);if(t==="ci")return h7t(e);vA(t,"Unknown error interval calculation")}function g7t(e,t,n,r,a,i,o){let s=1/0,c=-1/0;return{type:"errorbar",geoms:t.reduce((f,A)=>{let h=A.join("_");f[h]=[];let m=b=>o.scale==="log"?Math.log10(b):b,g=b=>o.scale==="log"?Math.pow(10,b):b;return n.forEach(b=>{r.forEach(C=>{let x=a.getColumnByGrouping([...A,b,C],i.value);if(!x.length)return;let k=x.map(m),_=g(m7t(k,e.pointsValues)),D=g(v7t(k,e.interval)),O=_-D,I=_+D;O<s&&(s=O),I>c&&(c=I),f[h].push({key:`errorbar_${b}_${C}`,primaryGrouping:b,secondaryGrouping:C,value:_,min:O,max:I,boundsY:{min:O,max:I}})})}),f},{}),meta:{minY:s,maxY:c},aes:e.aes}}function y7t(e,t,n,r){if(e.length===0)throw Error("Unable to create bar on empty data");let a=s=>t==="log"?Math.log10(s):s,i=s=>t==="log"?Math.pow(10,s):s,o=s=>{let c=Number(s[n]);if(t==="log"&&c<1)throw Error(`Value < 1 in log scale: ${c}`);return c};switch(r){case"max":return Ih(e,o)??o(e[0]);case"min":return mC(e,o)??o(e[0]);case"median":{let s=e.map(c=>Number(c[n])).map(a).sort((c,f)=>c-f);return i(Dp(s,.5))}case"mean":return tu(e,o)??o(e[0]);default:vA(r,`Unknown bar height function ${r}`)}}function w7t(e,t,n,r,a,i,o){let s=-1/0,c=1/0;return{type:"bar",geoms:t.reduce((f,A)=>{let h=A.join("_");return f[h]=[],n.forEach(m=>{r.forEach(g=>{let b=a.getRowsByGrouping([...A,m,g]);if(!b.length)return;let C=y7t(b,o.scale,i.value,e.height);s=Math.max(s,C,0),c=Math.min(c,C,0),f[h].push({key:`bar_${m}_${g}`,value:C,primaryGrouping:m,secondaryGrouping:g,boundsY:{min:Math.min(0,C),max:Math.max(0,C)}})})}),f},{}),meta:{minY:c,maxY:s},aes:e.aes}}function C7t(e,t,n,r,a,i){let o=-1/0,s=1/0;return{type:"stackedBar",geoms:t.reduce((c,f)=>{let A=f.join("_");return c[A]=[],n.forEach(h=>{let m=0,g={};r.forEach(x=>{let k=a.getRowsByGrouping([...f,h,x]);if(!k.length)return;let _=Sc(k,D=>Number(D[i.value]));g[x]={height:_,key:x},m+=_});let b=m;e.normalize&&r.forEach(x=>{g[x]&&(g[x].height=g[x].height/b*100)}),o=Math.max(o,0,m),s=Math.min(s,0,m);let C=e.normalize?100:b;c[A].push({key:`stackedBar_${h}`,valuesMap:g,primaryGrouping:h,boundsY:{min:Math.min(C,0),max:Math.max(C,0)}})}),c},{}),meta:{minY:e.normalize?0:s,maxY:e.normalize?100:o,normalize:e.normalize},aes:e.aes}}var gK=30;function b7t(e,t,n,r,a,i){let o=e.map(m=>n(a(m))),s=e.length,c=e.map(A),f=[];function A(m,g){return{key:i(m,g),value:a(m)}}let h=0;for(let m=1;m<s;++m){let g=o[h],b=o[m],C=o[m-1];if(b>=g+t){let x=Math.min((g+C)/2,b-t);o.fill(x,h,m),f.push({x:r(x),count:m-h,dots:c.slice(h,m)}),h=m}}return o.fill((o[h]+o[s-1])/2,h,s),f.push({x:r((o[h]+o[s-1])/2),count:s-h,dots:c.slice(h,s)}),f}var E7t=class{constructor(e,t,n,r,a,i,o,s,c,f){Me(this,"bins");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"key");Me(this,"boundsY");this.primaryGrouping=n===null?"":String(n),this.secondaryGrouping=r===null?"":String(r),this.key=`binnedDots_${this.primaryGrouping}_${this.secondaryGrouping}`;let A=e.filter(h=>s(h)===0&&c==="log"?(console.warn(`Item with ${t} = 0 is not shown on chart with log scale`),!1):!0).sort((h,m)=>i(s(h))-i(s(m)));this.bins=b7t(A,a,i,o,s,(h,m)=>String(f?h[f.value]:m)),this.boundsY={min:this.bins[0].x,max:this.bins[this.bins.length-1].x}}};function x7t(e,t,n,r,a,i,o){let s=x=>o.scale==="log"?Math.log10(x):x,c=x=>o.scale==="log"?Math.pow(10,x):x,f=x=>Number(x[i.value]),A=1/0,h=-1/0,m=a.getRowsByGrouping([]),[g=f(m[0]),b=f(m[0])]=$A(m.filter(x=>Number(x[i.value])===0&&o.scale==="log"?(console.warn(`Item with ${i.value} = 0 is not shown on chart with log scale`),!1):!0),x=>Number(x[i.value])),C=Math.abs(s(g)-s(b))/gK;return{type:"binnedDots",geoms:t.reduce((x,k)=>{let _=k.join("_");return x[_]=[],n.forEach(D=>{r.forEach(O=>{let I=a.getRowsByGrouping([...k,D,O]);if(!I.length)return;let $=I;if(!e.aes.showOutliers){let[ee,K]=A2(I,o.scale,f);$=I.filter(re=>{let U=f(re);return U>=ee&&U<=K})}let Q=new E7t($,i.value,D,O,C,s,c,f,o.scale,e.keyColumn);Q.boundsY.min<A&&(A=Q.boundsY.min),Q.boundsY.max>h&&(h=Q.boundsY.max),x[_].push(Q)})}),x},{}),meta:{minY:Math.min(g,b,A),maxY:Math.max(g,b,h),binsCount:gK,hasKeyFromColumn:e.keyColumn!==null},aes:e.aes}}function S7t(e,t){if(t.length===2)return"secondary";if(e.length===2&&t.length<2)return"primary";throw Error("Too many groups for paired points layer")}function yK(e,t,n,r,a,i,o,s,c){let f=Ir.groupBy(n,D=>D[a.value]),A=Ir.groupBy(r,D=>D[a.value]),h=Object.keys(f),m=Object.keys(A);if(Ir.uniq(h).length!==h.length||Ir.uniq(m).length!==m.length)throw Error(`Non unique keys in groups ${e}, ${t} for paired points layer`);if(h.length!==m.length||Ir.intersection(h,m).length!==h.length)throw Error(`Keys in groups ${e}, ${t} not match for paired points layer`);let g=D=>Number(D[i.value]),b=1/0,C=-1/0,x=!1,k=c==="log",_=h.map(D=>{let O=f[D][0],I=A[D][0],$=g(O),Q=g(I);return($===0||Q===0)&&(x=!0),b=Math.min(b,k&&$===0?1/0:$,k&&Q===0?1/0:Q),C=Math.max(C,k&&$===0?-1/0:$,k&&Q===0?-1/0:Q),{id:D,key1:{id:`${D}_${e}`,value:$,data:O},key2:{id:`${D}_${t}`,value:Q,data:I}}});if(!s){b=1/0,C=-1/0;let[D,O]=A2(n,c,g),[I,$]=A2(r,c,g);_=_.filter(({key1:Q,key2:ee})=>Q.value<D||Q.value>O||ee.value<I||ee.value>$?!1:(b=Math.min(b,k&&Q.value===0?1/0:Q.value,k&&ee.value===0?1/0:ee.value),C=Math.max(C,k&&Q.value===0?-1/0:Q.value,k&&ee.value===0?-1/0:ee.value),!0))}return b=x?b/10:b,C=Math.max(C,b),{id:`${e}_${t}`,key1:e,key2:t,pairs:_.map(D=>({...D,key1:{...D.key1,value:D.key1.value===0?b:D.key1.value},key2:{...D.key2,value:D.key2.value===0?b:D.key2.value}})),grouping:o,boundsY:{min:b,max:C}}}function B7t(e,t,n,r,a,i,o){let s=S7t(n,r),c=1/0,f=-1/0;return{type:"pairedPoints",geoms:t.reduce((A,h)=>{let m=h.join("_");if(A[m]=[],s==="primary"){let[g,b]=n,C=a.getRowsByGrouping([...h,g]),x=a.getRowsByGrouping([...h,b]),k=yK(g,b,C,x,e.linkColumn,i,s,e.aes.showOutliers,o.scale);c=Math.min(c,k.boundsY.min),f=Math.max(f,k.boundsY.max),A[m].push(k)}else s==="secondary"&&n.forEach(g=>{let[b,C]=r,x=a.getRowsByGrouping([...h,g,b]),k=a.getRowsByGrouping([...h,g,C]),_=yK(b,C,x,k,e.linkColumn,i,s,e.aes.showOutliers,o.scale);c=Math.min(c,_.boundsY.min),f=Math.max(f,_.boundsY.max),A[m].push(_)});return A},{}),meta:{minY:c,maxY:f},aes:e.aes}}function wK(e,t){let n;if(e==t){n=new Array(t+1);for(let r=0;r<n.length;++r)n[r]=r+1}else if(e<t){n=new Array(t-e+1);for(let r=0;r<n.length;++r)n[r]=e+r}else{n=new Array(e-t+1);for(let r=0;r<n.length;++r)n[r]=e-r}return n}function p2(e,t){return Ir.orderBy(e.map((n,r)=>[n,r]),([n])=>n,[t?"desc":"asc"]).map(([,n])=>n)}function k7t(e){if(e.length<1)throw new Error("cummin requires at least one element");let t=new Array(e.length),n=e[0];for(let r=0;r<e.length;++r)e[r]<n&&(n=e[r]),t[r]=n;return t}function T7t(e){if(e.length<1)throw new Error("cummax requires at least one element");let t=new Array(e.length),n=e[0];for(let r=0;r<e.length;++r)e[r]>n&&(n=e[r]),t[r]=n;return t}function CK(e,t){if(e.length<1)throw new Error("pmin requires at least one element");return e.map(n=>Math.min(n,t))}function _7t(e){if(e.length<1)throw new Error("pAdjust requires at least one element");return Math.min(...e)}function P7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=new Array(t);for(let r=0;r<t;++r){let a=e[r]*t;if(a>=1)n[r]=1;else if(0<=a)n[r]=a;else throw new Error(`${a} is outside [0, 1)`)}return n}function M7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=p2(e,!1),r=n.slice(),a=new Array(t).fill(0);for(let f=0;f<t;++f)a[f]=(t-f)*e[n[f]];let i=p2(r,!1),o=T7t(a),s=CK(o,1),c=new Array(t);for(let f=0;f<t;++f)c[f]=s[i[f]];return c}function D7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=wK(t,t),r=p2(e,!1),a=new Array(t);for(let h=0;h<t;++h)a[h]=e[r[h]];let i=r.slice(),o=p2(i,!1),s=new Array(t),c=new Array(t),f=new Array(t);for(let h=0;h<t;++h)f[h]=a[h]*t/n[h];let A=_7t(f);s.fill(A),c.fill(A);for(let h=t;h>=2;--h){let m=wK(1,t-h+1);for(let x=0;x<t-h+1;++x)m[x]--;let g=h-1,b=new Array(g);for(let x=0;x<g;++x)b[x]=t-h+2+x-1;let C=h*a[b[0]]/2;for(let x=1;x<g;++x){let k=a[b[x]]*h/(2+x);k<C&&(C=k)}for(let x=0;x<t-h+1;++x)s[m[x]]=Math.min(a[m[x]]*h,C);for(let x=0;x<g;++x)s[b[x]]=s[t-h];for(let x=0;x<t;++x)c[x]<s[x]&&(c[x]=s[x])}for(let h=0;h<t;++h)s[h]=c[o[h]];return s}var H7t=class{constructor(e,t,n){this.ni=e,this.o=t,this.ro=n}result(e){let t=k7t(e),n=CK(t,1),r=new Array(e.length);for(let a=0;a<e.length;++a)r[a]=n[this.ro[a]];return r}};function PP(e){let t=e.length,n=new Array(t),r=p2(e,!0);for(let i=0;i<t;++i){if(e[i]<0||e[i]>1)throw new Error("array["+i+"] = "+e[i]+" is outside [0, 1]");n[i]=t/(t-i)}let a=p2(r,!1);return new H7t(n,r,a)}function I7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=PP(e),r=new Array(t);for(let a=0;a<t;++a)r[a]=n.ni[a]*e[n.o[a]];return n.result(r)}function L7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=PP(e),r=new Array(t),a=0;for(let i=1;i<t+1;++i)a+=1/i;for(let i=0;i<t;++i)r[i]=a*n.ni[i]*e[n.o[i]];return n.result(r)}function R7t(e){let t=e.length;if(t<1)throw new Error("pAdjust requires at least one element");let n=PP(e),r=new Array(t);for(let a=0;a<t;++a)r[a]=(a+1)*e[n.o[a]];return n.result(r)}function bK(e,t){switch(t){case"BenjaminiHochberg":return I7t(e);case"BenjaminiYekutieli":return L7t(e);case"Bonferroni":return P7t(e);case"Hochberg":return R7t(e);case"Holm":return M7t(e);case"Hommel":return D7t(e);case null:return e;default:throw new Error(`Unknown p-value correction method: ${t}`)}}function N7t(e){let t=Math.abs(e),n=1/(1+t/2),r=n*Math.exp(-t*t-1.26551223+n*(1.00002368+n*(.37409196+n*(.09678418+n*(-.18628806+n*(.27886807+n*(-1.13520398+n*(1.48851587+n*(-.82215223+n*.17087277)))))))));return e>=0?r:2-r}function $7t(e){return .5*N7t(-e/Math.sqrt(2))}var F7t=class{constructor(e,t){this.value=e,this.position=t}getValue(){return this.value}getPosition(){return this.position}};function V7t(e){let t=new Array(e.length);for(let o=0;o<e.length;o++)t[o]=new F7t(e[o],o);let n=Q7t(t);t.sort((o,s)=>o.getValue()-s.getValue());let r=new Array(t.length),a=1;r[t[0].getPosition()]=a;let i=[];i.push(t[0].getPosition());for(let o=1;o<t.length;o++)t[o].getValue()>t[o-1].getValue()&&(a=o+1,i.length>1&&EK(r,i),i=[]),i.push(t[o].getPosition()),r[t[o].getPosition()]=a;return i.length>1&&EK(r,i),O7t(r,n),r}function EK(e,t){let n=(2*e[t[0]]+t.length-1)/2;t.forEach(r=>{e[r]=n})}function O7t(e,t){t.forEach(n=>{e[n]=NaN})}function Q7t(e){let t=[];for(let n=0;n<e.length;n++)isNaN(e[n].getValue())&&t.push(n);return t}var z7t=class{constructor(){Me(this,"SMALL_SAMPLE_SIZE",50)}mannWhitneyU(e,t){let n=[...e,...t],r=V7t(n),a=0;for(let s=0;s<e.length;s++)a+=r[s];let i=a-e.length*(e.length+1)/2,o=e.length*t.length-i;return Math.min(i,o)}mannWhitneyUTest(e,t,n){if(typeof n>"u")return e.length+t.length<=this.SMALL_SAMPLE_SIZE&&Object.keys(this.tiesMap(e,t)).length===0?this.mannWhitneyUTest(e,t,!0):this.mannWhitneyUTest(e,t,!1);let r=this.tiesMap(e,t),a=this.mannWhitneyU(e,t);if(n){if(Object.keys(r).length!==0)throw new Error;return this.exactP(e.length,t.length,a)}return this.approximateP(a,e.length,t.length,this.varU(e.length,t.length,r))}approximateP(e,t,n,r){let a=t*n/2;if(a==e)return 1;let i=-Math.abs(e-a+.5)/Math.sqrt(r);return 2*$7t(i)}exactP(e,t,n){let r=t*e;if(n>r)return 1;let a=n<r/2?n:r/2-n,i=0,o=0;for(;o<=a;)i+=this.uDensity(e,t,o),o++;return 2*i}uDensity(e,t,n){if(n<0||n>t*e)return 0;let r=this.uFrequencies(e,t);return r[Math.round(n+1)]/Ir.sum(r)}uFrequencies(e,t){let n=Math.max(t,e);if(n>100)throw Error("n or m > 100");let r=Math.min(t,e),a=new Array(e*t+2),i=new Array(e*t+2);for(let s=1;s<a.length;s++)a[s]=s<=n+1?1:0;i[1]=0;let o=n;for(let s=2;s<=r;s++){i[s]=0,o=o+n;let c=o+2,f=1+o/2,A=s;for(let h=1;h<=f;h++){A++,c=c-1;let m=a[h]+i[h];a[h]=m,i[A]=m-a[c],a[c]=m}}return a}varU(e,t,n){let r=e*t;if(Object.keys(n).length===0)return r*(e+t+1)/12;let a=Ir.sum(Object.values(n).map(o=>o*o*o-o)),i=e+t;return r/12*(i+1-a/(i*(i-1)))}tiesMap(e,t){let n={};for(let r=0;r<e.length;r++)n[e[r]]=n[e[r]]?n[e[r]]+1:1;for(let r=0;r<t.length;r++)n[t[r]]=n[t[r]]?n[t[r]]+1:1;for(let r in n)n[r]===1&&delete n[r];return n}};function MP(e,t,n){switch(t){case"ttest":{if(e.length>2)throw new Error("more than 2 datasets passed");if(n){if(e[0].length!==e[1].length)throw Error("Different size groups in paired test");return Aot(e[0],e[1]).pValue}let r=Mot(e[0],e[1]).pValue;return isNaN(r)?1:r}case"anova":{let r=gje(Ir.flatten(e),Ir.flatten(e.map((a,i)=>a.map(()=>String(i))))).pValue;return isNaN(r)?1:r}case"wilcoxon":{if(e.length>2)throw new Error("more than 2 datasets passed");if(n){if(e[0].length!==e[1].length)throw Error("Different size groups in paired test");return Pft(e[0],e[1]).pValue}let r=new z7t().mannWhitneyUTest(e[0],e[1]);return isNaN(r)?1:r}case"kruskalWallis":{let r=qut(...e).pValue;return isNaN(r)?1:r}default:throw new Error("Unknown test method")}}function U7t(e){return e.slice(0,-1).reduce((t,n,r)=>t.concat(e.slice(r+1).map(a=>[n,a])),[])}function j7t(e,t,n,r,a){return{type:"stats",values:t.reduce((i,o)=>{let s=[];switch(e.statType){case"overall":{let c=n.map(A=>a.getColumnByGrouping([...o,A],r.value)).filter(A=>A.length>0);if(c.length<2)break;let f=MP(c,e.testMethod,e.paired);s=[[["overall"],f]];break}case"referenceGroup":{let c=e.referenceGroup===null?null:String(e.referenceGroup);if(c!==null&&!n.includes(c))throw new Error(`Reference group ${c} for ${e.testMethod} test is not in available groups`);let f=a.getColumnByGrouping([...o,c],r.value);if(f.length===0){s=[];break}let A=n.filter(m=>m!==c).map(m=>[m,a.getColumnByGrouping([...o,m],r.value)]).filter(([,m])=>m.length>0);if(A.length<2&&e.correctionMethod!==null)break;let h=bK(A.map(([,m])=>MP([f,m],e.testMethod,e.paired)),e.correctionMethod);s=A.map(([m],g)=>[[m],h[g]]);break}case"pairwise":{let c=U7t(n).map(([A,h])=>[[A,h],[a.getColumnByGrouping([...o,A],r.value),a.getColumnByGrouping([...o,h],r.value)]]).filter(([,[A,h]])=>A.length&&h.length);if(c.length<1)break;let f=bK(c.map(([,A])=>MP(A,e.testMethod,e.paired)),e.correctionMethod);s=c.map(([A],h)=>[A,f[h]]);break}default:throw new Error("Unknown statType")}return i[o.join("_")]=s,i},{}),meta:{statType:e.statType,testMethod:e.testMethod,format:e.format,ns:e.ns,significanceLevels:e.significanceLevels}}}var C9="#3e9838",h2="21",m2=3,np=class{},xK=class extends np{constructor(t){super();Me(this,"type","box");Me(this,"stat",{upper:.75,medium:.5,lower:.25,k:1.5});Me(this,"aes",{showOutliers:!0,boxWidth:"auto",dotShape:h2,dotFill:Zt,dotSize:m2,lineColor:Zt,fillColor:C9,lineWidth:1,lineShape:"solid",opacity:1});this.stat={...this.stat,...t.stat},this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="box"&&Object.keys(this.stat).every(n=>this.stat[n]===t.stat[n])}},SK=class extends np{constructor(t){super();Me(this,"type","violin");Me(this,"stat",{bandwidth:"auto",stepsCount:40,trim:!0});Me(this,"aes",{width:"auto",lineColor:Zt,fillColor:C9,lineWidth:1,lineShape:"solid",opacity:1,showQuartiles:!0,medianLineStyle:"solid",quartilesLineStyle:"dashed"});this.stat={...this.stat,...t.stat},this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="violin"&&(this.stat.bandwidth!==t.stat.bandwidth||this.stat.trim!==t.stat.trim||this.stat.stepsCount!==t.stat.stepsCount)}},BK=class extends np{constructor(t){super();Me(this,"type","dot");Me(this,"aes",{showOutliers:!0,jitter:.8,lineColor:"none",dotFill:Zt,dotShape:h2,dotSize:m2,opacity:1});this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="dot"&&this.aes.showOutliers===t.aes.showOutliers}},kK=class extends np{constructor(t){super();Me(this,"type","line");Me(this,"pointsValues");Me(this,"aes",{showOutliers:!0,lineWidth:1,lineShape:"solid",fillColor:"none",lineColor:Zt,dotShape:h2,dotSize:m2,opacity:1});this.pointsValues=t.pointsValues,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="line"&&this.pointsValues===t.pointsValues}},TK=class extends np{constructor(t){super();Me(this,"type","errorbar");Me(this,"pointsValues");Me(this,"interval");Me(this,"aes",{showDots:!0,width:"auto",lineWidth:1,fillColor:"none",lineColor:Zt,dotShape:h2,dotSize:m2,opacity:1});this.pointsValues=t.pointsValues,this.interval=t.interval,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="errorbar"&&this.pointsValues===t.pointsValues&&this.interval===t.interval}},_K=class extends np{constructor(t){super();Me(this,"type","bar");Me(this,"height");Me(this,"aes",{width:"auto",lineWidth:1,fillColor:"none",lineColor:Zt,opacity:1});this.height=t.height??"max",this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="bar"&&this.height===t.height}},PK=class extends np{constructor(t){super();Me(this,"type","stackedBar");Me(this,"normalize",!1);Me(this,"aes",{width:"auto",lineWidth:1,fillColor:C9,lineColor:"none",opacity:1});this.normalize=t.normalize??!1,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="stackedBar"&&t.normalize===this.normalize}},MK=class extends np{constructor(t){super();Me(this,"type","logo");Me(this,"normalize",!1);Me(this,"aes",{width:"auto",fillColor:C9,lineColor:"none",opacity:1});this.normalize=t.normalize??!1,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="logo"&&t.normalize===this.normalize}},DK=class extends np{constructor(t){super();Me(this,"type","binnedDots");Me(this,"method");Me(this,"position");Me(this,"keyColumn");Me(this,"aes",{showOutliers:!0,width:"auto",lineWidth:1,fillColor:"none",lineColor:Zt,opacity:1});this.method=t.method??"dotdensity",this.position=t.position??"stack",this.keyColumn=t.keyColumn??null,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){var n,r;return t.type==="binnedDots"&&this.method===t.method&&this.position===t.position&&((n=this.keyColumn)==null?void 0:n.value)===((r=t.keyColumn)==null?void 0:r.value)}},HK=class extends np{constructor(t){super();Me(this,"type","pairedPoints");Me(this,"linkColumn");Me(this,"aes",{showOutliers:!0,lineWidth:1,lineColor:Zt,lineShape:"solid",dotFill:Zt,dotSize:m2,dotShape:h2,opacity:1});this.linkColumn=t.linkColumn,this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="pairedPoints"&&this.aes.showOutliers===t.aes.showOutliers&&this.linkColumn.value===t.linkColumn.value}},IK=class extends np{constructor(t){super();Me(this,"type","sina");Me(this,"aes",{showOutliers:!0,width:"auto",dotFill:C9,dotSize:m2,dotShape:h2,opacity:1});this.aes={...this.aes,...t.aes}}isEqualForCalculation(t){return t.type==="sina"&&this.aes.showOutliers===t.aes.showOutliers}},W8=class extends np{constructor(t){var n,r,a;super();Me(this,"type","stat");Me(this,"statType");Me(this,"testMethod");Me(this,"paired");Me(this,"ns");Me(this,"format");Me(this,"referenceGroup",null);Me(this,"correctionMethod",null);Me(this,"significanceLevels");this.statType=t.statType,this.testMethod=t.testMethod,this.paired=t.paired??!1,this.ns=t.ns??!0,this.format=t.format??"pValue",this.statType==="referenceGroup"&&(this.referenceGroup=t.referenceGroup??null),(this.statType==="referenceGroup"||this.statType==="pairwise")&&(this.correctionMethod=t.correctionMethod??null),this.significanceLevels={one:((n=t.significanceLevels)==null?void 0:n.one)??.05,two:((r=t.significanceLevels)==null?void 0:r.two)??.01,three:((a=t.significanceLevels)==null?void 0:a.three)??.001}}isEqualForCalculation(t){return t.type==="stat"&&Object.keys(this).every(n=>this[n]===t[n])}},LK=class{constructor(e){Me(this,"id");Me(this,"type","discrete");Me(this,"y");Me(this,"keyColumn");Me(this,"primaryGrouping");Me(this,"secondaryGrouping");Me(this,"facetSettings");Me(this,"facetBy");Me(this,"chartSettings");Me(this,"layers");var t,n,r,a,i,o,s,c;U3t.parse(e),this.id=Ir.uniqueId("settings"),this.y=e.y,this.keyColumn=e.keyColumn??null,this.primaryGrouping=e.primaryGrouping??null,this.secondaryGrouping=e.secondaryGrouping??null,this.facetSettings={sharedX:!0,sharedY:!0,titlePosition:"left",...e.facetSettings},this.facetBy=e.facetBy??[],this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(this.facetBy.length?400:600),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(this.facetBy.length?250:350)},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},orientation:e.orientation??"vertical",yAxis:{title:((a=e.y)==null?void 0:a.label)??e.y.value??"",scale:"linear",showGrid:!0,showTicks:!0,...e.yAxis},xAxis:{title:((o=(i=e.primaryGrouping)==null?void 0:i.columnName)==null?void 0:o.label)??((s=e.primaryGrouping)==null?void 0:s.columnName.value)??"",showGrid:!0,showTicks:!0,linesBetweenCategories:!0,labelsPosition:"center",...e.xAxis},frame:{type:((c=e.frame)==null?void 0:c.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{box:{show:!0},violin:{show:!0},boxOutliers:{show:!0},line:{show:!0},errorBar:{show:!0},dot:{show:!0},binnedDots:{show:!0},pairedPoints:{show:!0},stackedBar:{show:!0},...e.tooltips}},this.layers=e.layers.map(f=>{if(f.type==="box")return new xK(f);if(f.type==="violin")return new SK(f);if(f.type==="dot")return new BK(f);if(f.type==="line")return new kK(f);if(f.type==="errorbar")return new TK(f);if(f.type==="bar")return new _K(f);if(f.type==="stackedBar")return new PK(f);if(f.type==="stat")return new W8(f);if(f.type==="binnedDots")return new DK(f);if(f.type==="pairedPoints")return new HK(f);if(f.type==="sina")return new IK(f);if(f.type==="logo")return new MK(f);vA(f,"Unknown layer type")}).filter(Boolean)}};function RK(e,t=null,n=null){let r=(t==null?void 0:t.value)??null,a=r===null?["null"]:e.getColumnCategories(r);return Ir.intersection(n??a,a).map(String)}function NK(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}function X8(e,t){if(!t)return{keys:["null"],value:null,label:"",valueLabels:{null:""},inheritedAes:null};let n=t.columnName.value,r=Ir.uniqBy(e.rows,c=>c[n]),a=c=>String(c[n]),i=c=>t.columnName.valueLabels?String(c[t.columnName.valueLabels]):a(c),o=r.map(a),s=(t.order??o).map(String);return{keys:Ir.intersection(s,o),value:n,label:t.columnName.label??n,valueLabels:r.reduce((c,f)=>(c[a(f)]=i(f),c),{}),inheritedAes:t.inheritedAes??null}}var G7t=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new j5t);Me(this,"calculatedData",null);this.settings=new LK(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new LK(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for discrete")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.chartSettings.yAxis.scale!==n.chartSettings.yAxis.scale||(((r=t.primaryGrouping)==null?void 0:r.columnName.value)??"")!==(((a=n.primaryGrouping)==null?void 0:a.columnName.value)??"")||(((i=t.secondaryGrouping)==null?void 0:i.columnName.value)??"")!==(((o=n.secondaryGrouping)==null?void 0:o.columnName.value)??"")||t.facetBy.some((s,c)=>{var f;return s.value!==((f=n.facetBy[c])==null?void 0:f.value)})||t.layers.length!==n.layers.length||t.layers.some((s,c)=>!s.isEqualForCalculation(n.layers[c]))}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{chartSettings:t,y:n,keyColumn:r,facetBy:a,layers:i,facetSettings:o}=this.settings,{yAxis:s}=t,c=this.data.rows.every(x=>{let k=x[n.value];return k===null||!(Number(k)<0)}),f=X8(this.data,this.settings.primaryGrouping),A=X8(this.data,this.settings.secondaryGrouping),h=a.map(x=>x.value)??null,m=a.length?NK(a.map(x=>{var k;return RK(this.data,x,(k=o==null?void 0:o.order)==null?void 0:k[x.value])})):[["null"]];this.data.setGrouping([...h,f.value,A.value]);let g=m.reduce((x,k)=>(x[k.join("_")]=f.keys.filter(_=>this.data.getRowsByGrouping([...k,_]).length>0),x),{}),b=i.filter(x=>!(x instanceof W8)).map(x=>{if(x instanceof xK)return W5t(x,m,f.keys,A.keys,this.data,n,r,s);if(x instanceof SK)return t7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof BK)return c7t(x,m,f.keys,A.keys,this.data,n,s,r);if(x instanceof kK)return d7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof TK)return g7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof _K)return w7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof PK)return C7t(x,m,f.keys,A.keys,this.data,n);if(x instanceof DK)return x7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof HK)return B7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof IK)return u7t(x,m,f.keys,A.keys,this.data,n,s);if(x instanceof MK)return V2t(x,m,f.keys,A.keys,this.data,n);throw new Error("Unknown layer type")}),C=i.filter(x=>x instanceof W8).map(x=>{if(f.value===null)throw new Error("Cannot calculate p-value without data grouping");return j7t(x,m,f.keys,n,this.data)});this.calculatedData={layersData:b,statsLayersData:C,primaryGrouping:f,secondaryGrouping:A,facetKeyLists:m,nonEmptyGroupsByFacets:g,onlyPositive:c}}_updateAesInData(){if(this.calculatedData===null)return;let{layers:t,facetBy:n,primaryGrouping:r,secondaryGrouping:a,facetSettings:i}=this.settings,o=t.filter(s=>!(s instanceof W8));for(let s=0;s<o.length;s++){let c=o[s];"aes"in c&&(this.calculatedData.layersData[s].aes=c.aes)}this.calculatedData.primaryGrouping=X8(this.data,r),this.calculatedData.secondaryGrouping=X8(this.data,a),this.calculatedData.facetKeyLists=n.length?NK(n.map(s=>{var c;return RK(this.data,s,(c=i==null?void 0:i.order)==null?void 0:c[s.value])})):[["null"]]}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,keyColumn:r,facetSettings:a}=this.settings;this.chartRenderer.render(t,n,this.calculatedData.primaryGrouping,this.calculatedData.secondaryGrouping,a,this.calculatedData.facetKeyLists.map(i=>i.join("_")),this.calculatedData.facetKeyLists,this.calculatedData.layersData,this.calculatedData.statsLayersData,r,this.calculatedData.nonEmptyGroupsByFacets,this.calculatedData.onlyPositive)}};function Y7t(e){let t=cL(e),n=tu(e);return t===void 0||n===void 0||t===0?r=>r:r=>(r-n)/t}function W7t(e){let t=tu(e),[n,r]=$A(e);return t===void 0||n===void 0||r===void 0||r===n?a=>a:a=>(a-t)/(r-n)}function X7t(e,t){return e==="standardScaling"?Y7t(t):e==="meanNormalization"?W7t(t):n=>n}function DP(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}function K7t(e,t,n,r,a,i,o,s,c,f,A,h){let m=a.length?a.map(Y=>e.getColumnCategories(Y.value)):[["null"]],g=i.length?i.map(Y=>e.getColumnCategories(Y.value)):[["null"]],b=o.length?o.map(Y=>e.getColumnCategories(Y.value)):[["null"]],C=DP(m),x=DP(g),k=DP(b),_=C.map(Y=>Y.join("_")),D=x.map(Y=>Y.join("_")),O=k.map(Y=>Y.join("_")),I={meta:{facetKeys:_,xGroupKeys:D,yGroupKeys:O,xKeysByGroups:{},yKeysByGroups:{},xLabels:{},yLabels:{},xGroupLabels:{},yGroupLabels:{},xDataByKeys:{},yDataByKeys:{},facetKeyValues:_.reduce((Y,X,oe)=>(Y[X]=C[oe],Y),{}),xGroupKeyValues:D.reduce((Y,X,oe)=>(Y[X]=x[oe],Y),{}),yGroupKeyValues:O.reduce((Y,X,oe)=>(Y[X]=k[oe],Y),{}),valueExtent:[1/0,-1/0]},facets:{}},$=t.valueLabels??t.value,Q=n.valueLabels??n.value,ee=s.filter(Y=>Y.axis==="x").map(Y=>Y.valueColumn.value),K=s.filter(Y=>Y.axis==="y").map(Y=>Y.valueColumn.value),re=Object.values(c??{}).map(Y=>Y.value),U=Object.values(f??{}).map(Y=>Y.value),G=Ir.uniq([...ee,...re,$]),Z=Ir.uniq([...K,...U,Q]);if(e.rows.forEach(Y=>{let X=a.length?a.map(ze=>Y[ze.value]).join("_"):"null",oe=i.length?i.map(ze=>Y[ze.value]).join("_"):"null",me=o.length?o.map(ze=>Y[ze.value]).join("_"):"null",ae=i.length?i.map(ze=>Y[ze.valueLabels??ze.value]).join(", "):"",ye=o.length?o.map(ze=>Y[ze.valueLabels??ze.value]).join(", "):"";I.meta.xGroupLabels[oe]=ae,I.meta.yGroupLabels[oe]=ye;let Ce=Y[t.value],ce=Y[n.value],ge=Y[r.value]??h;if(!(Ce===null||ce===null||ge===null)){if(I.facets[X]||(I.facets[X]={xKeys:[],yKeys:[],xKeysByGroups:{},yKeysByGroups:{},cells:{}}),I.facets[X].xKeysByGroups[oe]||(I.facets[X].xKeysByGroups[oe]=[]),I.facets[X].yKeysByGroups[me]||(I.facets[X].yKeysByGroups[me]=[]),I.facets[X].xKeys.push(Ce),I.facets[X].yKeys.push(ce),I.facets[X].xKeysByGroups[oe].push(Ce),I.facets[X].yKeysByGroups[me].push(ce),I.facets[X].cells[Ce]||(I.facets[X].cells[Ce]={}),I.meta.valueExtent[0]=Math.min(ge,I.meta.valueExtent[0]),I.meta.valueExtent[1]=Math.max(ge,I.meta.valueExtent[1]),I.facets[X].cells[Ce][ce])throw Error(`More than 1 value for x=${Ce}, y=${ce}`);if(I.meta.xLabels[Ce]&&String(Y[$])!==I.meta.xLabels[Ce])throw Error(`More than 1 x-label value for x=${Ce}`);if(I.meta.yLabels[ce]&&String(Y[Q])!==I.meta.yLabels[ce])throw Error(`More than 1 y-label value for y=${ce}`);I.meta.xLabels[Ce]=String(Y[$]),I.meta.yLabels[ce]=String(Y[Q]),G.forEach(ze=>{let Ne=typeof I.meta.xDataByKeys[ze]<"u",Ge=Ne&&typeof I.meta.xDataByKeys[ze][Ce]<"u";if(Ne||(I.meta.xDataByKeys[ze]={}),Ge&&I.meta.xDataByKeys[ze][Ce]!==Y[ze])throw Error(`More than 1 value for x = ${Ce} and column = ${ze}`);Ge||(I.meta.xDataByKeys[ze][Ce]=Y[ze])}),Z.forEach(ze=>{let Ne=typeof I.meta.yDataByKeys[ze]<"u",Ge=Ne&&typeof I.meta.yDataByKeys[ze][ce]<"u";if(Ne||(I.meta.yDataByKeys[ze]={}),Ge&&I.meta.yDataByKeys[ze][ce]!==Y[ze])throw Error(`More than 1 value for y = ${ce} and column = ${ze}`);Ge||(I.meta.yDataByKeys[ze][ce]=Y[ze])}),I.facets[X].cells[Ce][ce]={id:`${Ce}_${ce}`,x:Ce,y:ce,value:ge,normalizedValue:ge,data:Y}}}),I.meta.facetKeys=I.meta.facetKeys.filter(Y=>I.facets[Y]),I.meta.facetKeys.forEach(Y=>{let X=I.facets[Y];X.xKeys=Ir.uniq(X.xKeys),X.yKeys=Ir.uniq(X.yKeys),D.forEach(oe=>{I.facets[Y].xKeysByGroups[oe]=Ir.uniq(I.facets[Y].xKeysByGroups[oe])}),O.forEach(oe=>{I.facets[Y].yKeysByGroups[oe]=Ir.uniq(I.facets[Y].yKeysByGroups[oe])})}),A){let Y=[1/0,-1/0];I.meta.facetKeys.forEach(X=>{let{xKeys:oe,yKeys:me,cells:ae}=I.facets[X],ye=A.direction==="row"?oe:me,Ce=A.direction==="row"?me:oe,ce=A.direction==="row"?(ge,ze)=>{var Ne;return(Ne=ae[ge])==null?void 0:Ne[ze]}:(ge,ze)=>{var Ne;return(Ne=ae[ze])==null?void 0:Ne[ge]};Ce.forEach(ge=>{let ze=[];ye.forEach(Ge=>{var Xe;let Oe=(Xe=ce(Ge,ge))==null?void 0:Xe.value;Oe!==void 0&&ze.push(Oe)});let Ne=X7t(A.method,ze);ye.forEach(Ge=>{let Oe=ce(Ge,ge);Oe!==void 0&&(Oe.normalizedValue=Ne(Oe.value),Y[0]=Math.min(Oe.normalizedValue,Y[0]),Y[1]=Math.max(Oe.normalizedValue,Y[1]))})})}),I.meta.valueExtent=Y}return I.meta.xKeysByGroups=D.reduce((Y,X)=>(Y[X]=Ir.uniq(Ir.flatten(I.meta.facetKeys.map(oe=>I.facets[oe].xKeysByGroups[X]))),Y),{}),I.meta.yKeysByGroups=O.reduce((Y,X)=>(Y[X]=Ir.uniq(Ir.flatten(I.meta.facetKeys.map(oe=>I.facets[oe].yKeysByGroups[X]))),Y),{}),I.meta.valueExtent[0]===1/0&&(I.meta.valueExtent[0]=0),I.meta.valueExtent[1]===-1/0&&(I.meta.valueExtent[1]=0),I}function $K(e,t){let n=0;for(let r=0;r<e.length;r++)n+=(e[r]-t[r])*(e[r]-t[r]);return n}function FK(e,t){return Math.sqrt($K(e,t))}var VK=(e,t,n)=>{let r=0;for(let a of e)for(let i of t)r+=n[a][i];return r/e.length/t.length},Z7t=(e,t,n)=>{let r=0;for(let a of e)for(let i of t)r=Math.max(r,n[a][i]);return r},J7t=(e,t,n)=>{let r=1/0;for(let a of e)for(let i of t)r=Math.min(r,n[a][i]);return r};function q7t(e){switch(e){case"average":return VK;case"complete":return Z7t;case"single":return J7t;default:return VK}}function ewt(e){switch(e){case"euclidean":return FK;case"squaredEuclidean":return $K;default:return FK}}function OK(e=[],t,n="euclidean",r="average"){let a=ewt(n),i=q7t(r),o=t.map(c=>t.map(f=>a(c,f))),s=e.map((c,f)=>({height:0,keys:[c],indexes:[f],children:[]}));for(let c=0;c<e.length&&!(c>=e.length-1);c++){let f=1/0,A=0,h=0;for(let g=0;g<s.length;g++)for(let b=g+1;b<s.length;b++){let C=i(s[g].indexes,s[b].indexes,o);C<f&&(f=C,A=g,h=b)}let m={keys:[...s[A].keys,...s[h].keys],indexes:[...s[A].indexes,...s[h].indexes],height:f,children:[s[A],s[h]]};s.splice(Math.max(A,h),1),s.splice(Math.min(A,h),1),s.push(m)}return s[0]}function twt(e,t,n,r){let{facetKeys:a,xGroupKeys:i,yGroupKeys:o}=e.meta,s={};if(t&&r.sharedX)throw Error("Dendrogram on X axis is not available with shared by facets X axis");return a.forEach(c=>{let f={hierarchyX:[],hierarchyY:[]},A=e.facets[c];if(t){let h=[],m=[];i.forEach(g=>{let b=A.xKeysByGroups[g],C=A.yKeys,x=OK(b,b.map(k=>C.map(_=>{var D;return((D=A.cells[k][_])==null?void 0:D.normalizedValue)??t.fillNA})),t.distance,t.linkage);e.facets[c].xKeysByGroups[g]=x.keys,m.push(...x.keys),h.push(x)}),e.facets[c].xKeys=m,f.hierarchyX=h.map(g=>vb(g))}if(n){let h=[],m=[];o.forEach(g=>{let b=A.yKeysByGroups[g],C=A.xKeys,x=OK(b,b.map(k=>C.map(_=>{var D;return((D=A.cells[_][k])==null?void 0:D.normalizedValue)??n.fillNA})),n.distance,n.linkage);e.facets[c].yKeysByGroups[g]=x.keys,m.push(...x.keys),h.push(x)}),e.facets[c].yKeys=m,f.hierarchyY=h.map(g=>vb(g))}s[c]=f}),s}function nwt(e,t,n,r,a,i,o,s,c,f,A,h,m,g){let b=h.length>1&&(!c||o.includes(t.groupingPosition)),C=!c||o.includes(t.position),x=A.length>1&&(!s||o.includes(e.groupingPosition)),k=!s||o.includes(e.position),_=f.length>1,D=r.filter(oe=>o.includes(oe.position)||!s&&["left","right"].includes(oe.position)||!c&&["top","bottom"].includes(oe.position)),O=D.filter(oe=>oe.position==="left").length,I=D.filter(oe=>oe.position==="right").length,$=D.filter(oe=>oe.position==="top").length,Q=D.filter(oe=>oe.position==="bottom").length,ee=e.showTicks?U8:0,K=t.showTicks?U8:0,re=k&&e.showTitle?Vm:0,U=C&&t.showTitle?Vm:0,G=k&&e.showAxisLabels&&m>o2?n.xAxisCaptions+ee+l2:0,Z=C&&t.showAxisLabels&&g>o2?n.yAxisCaptions+K+l2:0,Y=x&&e.showGroupLabels?n.xGroupCaptions:0,X=b&&t.showGroupLabels?n.yGroupCaptions:0;return{left:{dendro:!(i!=null&&i.hidden)&&(i==null?void 0:i.position)==="left"?i.size:0,axisTitle:t.position==="left"?U:0,groups:t.groupingPosition==="left"?X:0,axis:t.position==="left"?Z:0,annotations:O*Qd+(O&&s2)},right:{dendro:!(i!=null&&i.hidden)&&(i==null?void 0:i.position)==="right"?i.size:0,axisTitle:t.position==="right"?U:0,groups:t.groupingPosition==="right"?X:0,axis:t.position==="right"?Z:0,annotations:I*Qd+(I&&s2)},top:{facetTitle:_?U2t:0,dendro:!(a!=null&&a.hidden)&&(a==null?void 0:a.position)==="top"?a.size:0,axisTitle:e.position==="top"?re:0,groups:e.groupingPosition==="top"?Y:0,axis:e.position==="top"?G:0,annotations:$*Qd+($&&s2)},bottom:{dendro:!(a!=null&&a.hidden)&&(a==null?void 0:a.position)==="bottom"?a.size:0,axisTitle:e.position==="bottom"?re:0,groups:e.groupingPosition==="bottom"?Y:0,axis:e.position==="bottom"?G:0,annotations:Q*Qd+(Q&&s2)}}}function rwt(e,t,n){return{left:s1.left.reduce((r,a,i)=>{let o=i>0?s1.left[i-1]:null,s=e.left[a];return r[a]={x:o?r[o].x-s:-s,y:0,width:s,height:n,isVisible:s>0},r},{}),right:s1.right.reduce((r,a,i)=>{let o=i>0?s1.right[i-1]:null,s=e.right[a];return r[a]={x:o?r[o].x+r[o].width:t,y:0,width:s,height:n,isVisible:s>0},r},{}),top:s1.top.reduce((r,a,i)=>{let o=i>0?s1.top[i-1]:null,s=e.top[a];return r[a]={x:0,y:o?r[o].y-s:-s,width:t,height:s,isVisible:s>0},r},{}),bottom:s1.bottom.reduce((r,a,i)=>{let o=i>0?s1.bottom[i-1]:null,s=e.bottom[a];return r[a]={x:0,y:o?r[o].y+r[o].height:n,width:t,height:s,isVisible:s>0},r},{})}}function HP(e,t,n){let r=(t-e)/n,a=Ir.range(e,t-r/2,r);return a.push(t),a}function QK(e,t){let n=HP(0,1,e.length-1),r=Da().domain(n).range(e),a=HP(0,1,t.length-1).map(i=>r(i));return Hl().domain(t).range(a).unknown("#ccc")}function awt(e,t,n,r,a,i){let o=HP(0,1,e.length-1),s=Da().domain(o).range(e),c=[r,...o.filter(C=>C>r&&C<a),a],f=[a,...o.filter(C=>C>a&&C<i),i],A=(n-t)/2,h=c.map(C=>t+A*(C-r)/(a-r)),m=f.map(C=>(t+n)/2+A*(C-a)/(i-a)),g=c.map(C=>s(C)),b=f.map(C=>s(C));return Da().domain(h.concat(m.slice(1))).range(g.concat(b.slice(1)))}function iwt(e,t,n,r){let a=e.filter(A=>A.showTitle&&(t.includes(A.position)||!n&&["left","right"].includes(A.position)||!r&&["top","bottom"].includes(A.position))),i=a.filter(A=>A.titlePosition==="left").map(A=>A.valueColumn.label??A.valueColumn.value),o=a.filter(A=>A.titlePosition==="right").map(A=>A.valueColumn.label??A.valueColumn.value),s=a.filter(A=>A.titlePosition==="top").map(A=>A.valueColumn.label??A.valueColumn.value),c=a.filter(A=>A.titlePosition==="bottom").map(A=>A.valueColumn.label??A.valueColumn.value),f=new Dc("bold 14px Arial");return{left:Math.max(...i.map(A=>f.getTextWidth(A))),right:Math.max(...o.map(A=>f.getTextWidth(A))),top:Math.max(...s.map(A=>f.getTextWidth(A))),bottom:Math.max(...c.map(A=>f.getTextWidth(A)))}}function owt(e,t,n,r,a){let{facetKeys:i,xGroupKeys:o,yGroupKeys:s,xKeysByGroups:c,yKeysByGroups:f,xLabels:A,yLabels:h}=r.meta,m=e.xGroupLabels/180*Math.PI,g=e.yGroupLabels/180*Math.PI,b=e.xAxisLabels/180*Math.PI,C=e.yAxisLabels/180*Math.PI,x=0,k=0,_=e.xGroupLabels===45,D=e.xAxisLabels===45;if(_||D)if(!t.sharedX)i.forEach($=>{let Q=o.find(Z=>r.facets[$].xKeysByGroups[Z].length>0);if(!Q)return;let ee=r.facets[$].xKeysByGroups[Q],K=n.x[$],re=K>o2,U=ee.length*K/2,G=A[ee[0]];x=Math.max(x,(_?a.getTextWidth(Q)*Math.cos(m):0)-U,(D&&re?a.getTextWidth(G)*Math.cos(b):0)-K/2)});else{let $=o[0],Q=i[0];if($){let ee=c[$],K=n.x[Q],re=K>o2,U=ee.length*K/2,G=A[ee[0]];x=Math.max(x,(_?a.getTextWidth($)*Math.cos(m):0)-U,(D&&re?a.getTextWidth(G)*Math.cos(b):0)-K/2)}}let O=e.yGroupLabels===45,I=e.yAxisLabels===45;if(O||I)if(!t.sharedY)i.forEach($=>{let Q=Ir.findLast(s,Z=>r.facets[$].yKeysByGroups[Z].length>0);if(!Q)return;let ee=r.facets[$].yKeysByGroups[Q],K=n.y[$],re=K>o2,U=ee.length*K/2,G=h[ee[ee.length-1]];k=Math.max(k,(O?a.getTextWidth(Q)*Math.cos(g):0)-U,(I&&re?a.getTextWidth(G)*Math.cos(C):0)-K/2)});else{let $=s[s.length-1],Q=i[0];if($){let ee=f[$],K=n.y[Q],re=K>o2,U=ee.length*K/2,G=h[ee[ee.length-1]];k=Math.max(k,(O?a.getTextWidth($)*Math.cos(g):0)-U,(I&&re?a.getTextWidth(G)*Math.cos(C):0)-K/2)}}return{xCaptionTail:x,yCaptionTail:k}}function zK(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function lwt(e,t,n,r,a){if(e){let s=Qd/2,c=n==="top"?-5:a+5;return{x:s,y:c,rotate:t==="left"?-90:90,anchor:t==="left"&&n==="top"?"start":"end"}}let i=n==="right"?r+5:-5,o=Qd/2;return{x:i,y:o,rotate:0,anchor:n==="right"?"start":"end"}}function K8({data:e,scales:t,stepX:n,stepY:r,x:a,y:i,annotation:o,showTitle:s,width:c,height:f,colorScale:A,aes:h,frame:m,xGroupKeys:g,yGroupKeys:b,xKeysByGroups:C,yKeysByGroups:x,setSelectedAnnotation:k}){let{position:_,titlePosition:D,valueColumn:O}=o,I=_==="left"||_==="right",$=(I?t.y:t.x).domain(),Q=lwt(I,_,D,c,f);return le.jsxs("g",{transform:`translate(${a},${i})`,children:[$.map(ee=>{let K=e==null?void 0:e[ee],re=A.type==="continuous"?A.scale(Number(K)):A.scale(String(K)),U=I?0:t.x(ee),G=I?t.y(ee):0,Z=I?Qd:n,Y=I?r:Qd;return le.jsx("rect",{x:U,y:G,width:Z,height:Y,fill:re,stroke:h.cellStrokeColor,onMouseOver:()=>k({x:a+U+Z,y:i+G+Y/2,xKey:I?null:ee,yKey:I?ee:null,value:K,title:O.label??O.value}),onMouseLeave:()=>k(null)},ee)}),m.type==="groups"&&!I&&g.map(ee=>{let K=C[ee].length;if(K===0)return null;let re=K*n,U=t.x(C[ee][0]);return le.jsx("rect",{x:U,width:re,height:Qd,stroke:Zt,fill:"none"},`${U}_${i}`)}),m.type==="groups"&&I&&b.map(ee=>{let K=x[ee].length;if(K===0)return null;let re=K*r,U=t.y(x[ee][0]);return le.jsx("rect",{y:U,width:Qd,height:re,stroke:Zt,fill:"none"},`${a}_${U}`)}),s&&le.jsx("g",{fontWeight:"500",fontSize:"14px",transform:`translate(${Q.x},${Q.y}) rotate(${Q.rotate})`,children:le.jsx("text",{textAnchor:Q.anchor,dominantBaseline:"central",children:O.label??O.value})})]})}function Z8(e,t){return e.showTitle&&t.includes(e.titlePosition)}function swt({sideElementBBoxes:e,annotations:t,annotationColorScales:n,cellsMeta:r,chartEdgeSides:a,sharedX:i,sharedY:o,width:s,height:c,scales:f,stepX:A,stepY:h,aes:m,frame:g,xGroupKeys:b,yGroupKeys:C,xKeysByGroups:x,yKeysByGroups:k,setSelectedAnnotation:_}){let D=t.filter(U=>a.includes(U.position)||!i&&["left","right"].includes(U.position)||!o&&["top","bottom"].includes(U.position)),O=D.filter(U=>U.position==="left"),I=D.filter(U=>U.position==="right"),$=D.filter(U=>U.position==="top"),Q=D.filter(U=>U.position==="bottom"),{xDataByKeys:ee,yDataByKeys:K}=r,re={scales:f,stepX:A,stepY:h,width:s,height:c,aes:m,frame:g,xGroupKeys:b,yGroupKeys:C,xKeysByGroups:x,yKeysByGroups:k,setSelectedAnnotation:_};return le.jsxs("g",{children:[O.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:K[U.valueColumn.value],showTitle:Z8(U,a),x:e.left.annotations.x+G*Qd,y:e.left.annotations.y,...re},U.id)),I.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:K[U.valueColumn.value],showTitle:Z8(U,a),x:e.right.annotations.x+G*Qd+s2,y:e.right.annotations.y,...re},U.id)),$.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:ee[U.valueColumn.value],showTitle:Z8(U,a),x:e.top.annotations.x,y:e.top.annotations.y+G*Qd,...re},U.id)),Q.map((U,G)=>le.jsx(K8,{annotation:U,colorScale:n[U.id],data:ee[U.valueColumn.value],showTitle:Z8(U,a),x:e.bottom.annotations.x,y:e.bottom.annotations.y+G*Qd+s2,...re},U.id))]})}function uwt({sideElementBBoxes:e,xGroupKeys:t,yGroupKeys:n,xKeysByGroups:r,yKeysByGroups:a,xGroupLabels:i,yGroupLabels:o,scales:s,stepX:c,stepY:f,xAxis:A,yAxis:h,labelAngles:m,debug:g}){let b=e.top.groups.isVisible||e.bottom.groups.isVisible,C=e.top.groups.isVisible?e.top.groups:e.bottom.groups,x=e.left.groups.isVisible||e.right.groups.isVisible,k=e.left.groups.isVisible?e.left.groups:e.right.groups;return le.jsxs("g",{children:[b&&le.jsx("g",{transform:`translate(${C.x},${C.y})`,children:t.map(_=>{let D=r[_].length;if(D===0)return null;let O=m.xGroupLabels!==0,I=A.groupingPosition==="top",$=D*c,Q=s.x(r[_][0])+$/2,ee=O?I?C.height:0:C.height/2,K=-m.xGroupLabels,re=O?I?"start":"end":"middle";return le.jsxs("g",{transform:`translate(${Q},${ee})`,children:[le.jsx("text",{transform:`rotate(${K})`,dominantBaseline:"central",textAnchor:re,children:i[_]}),g&&le.jsx("rect",{x:-$/2,width:$,height:C.height,stroke:"black",fill:"none"})]},_)})}),x&&le.jsx("g",{transform:`translate(${k.x},${k.y})`,children:n.map(_=>{let D=a[_].length;if(D===0)return null;let O=D*f,I=h.groupingPosition==="left",$=I?k.width:0,Q=s.y(a[_][0])+O/2,ee=m.yGroupLabels!==0,K=m.yGroupLabels===45?-45:(I?-1:1)*(90-m.yGroupLabels),re=ee?I?"end":"start":"middle";return le.jsxs("g",{transform:`translate(${$},${Q})`,children:[le.jsx("text",{y:ee?0:-k.width/2,transform:`rotate(${K})`,dominantBaseline:"central",textAnchor:re,children:o[_]}),g&&le.jsx("rect",{x:-k.width/2,y:-O/2,width:k.width,height:O,stroke:"black",fill:"none"})]},_)})})]})}function cwt({sideElementBBoxes:e,debug:t,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,labelAngles:f,xLabels:A,yLabels:h}){let m=i.showTicks?U8:0,g=o.showTicks?U8:0,b=e.top.axis.isVisible||e.bottom.axis.isVisible,C=e.top.axisTitle.isVisible?e.top.axisTitle:e.bottom.axisTitle,x=e.top.axis.isVisible?e.top.axis:e.bottom.axis,k=e.left.axis.isVisible||e.right.axis.isVisible,_=e.left.axisTitle.isVisible?e.left.axisTitle:e.right.axisTitle,D=e.left.axis.isVisible?e.left.axis:e.right.axis;return le.jsxs("g",{children:[le.jsxs("g",{children:[C.isVisible&&le.jsxs("g",{transform:`translate(${C.x},${C.y})`,children:[le.jsx("text",{x:C.width/2,y:C.height/2,textAnchor:"middle",dominantBaseline:"central",children:i.title}),t&&le.jsx("rect",{width:C.width,height:C.height,stroke:Zt,fill:"none"})]}),b&&le.jsxs("g",{fontSize:"14px",transform:`translate(${x.x},${x.y})`,children:[n.map(O=>{let I=f.xAxisLabels!==0,$=i.position==="bottom",Q=$?0:x.height,ee=$?Q+m:Q-m,K=$?ee+l2:ee-l2,re=a.x(O)+s/2,U=-f.xAxisLabels;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:re,y1:Q,y2:ee,stroke:Zt}),le.jsx("text",{x:re,y:K,textAnchor:I?$?"end":"start":"middle",transform:`rotate(${U},${re},${K})`,dominantBaseline:I?"central":$?"hanging":"auto",children:A[O]})]},O)}),t&&le.jsx("rect",{width:x.width,height:x.height,stroke:Zt,fill:"none"})]})]}),le.jsxs("g",{children:[_.isVisible&&le.jsx("g",{transform:`translate(
15187
15187
  ${_.x+_.width/2},
15188
- ${_.y+_.height/2})`,children:le.jsx("text",{transform:`rotate(${o.position==="left"?-90:90})`,dominantBaseline:"central",textAnchor:"middle",children:o.title})}),t&&le.jsx("rect",{x:_.x,y:_.y,width:_.width,height:_.height,stroke:Zt,fill:"none"}),k&&le.jsx("g",{fontSize:"14px",transform:`translate(${D.x},${D.y})`,children:r.map(O=>{let I=f.yAxisLabels!==0,$=o.position==="left",Q=-(90-f.yAxisLabels),ee=f.yAxisLabels===0?"middle":$?"end":"start",K=I?"central":$?"auto":"hanging",re=$?D.width:0,U=$?re-g:re+g,G=$?U-l2:U+l2,Z=a.y(O)+c/2;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:U,y1:Z,y2:Z,stroke:Zt}),le.jsx("text",{x:G,y:Z,textAnchor:ee,transform:`rotate(${Q},${G},${Z})`,dominantBaseline:K,children:h[O]})]},O)})}),t&&le.jsx("rect",{x:D.x,y:D.y,height:D.height,width:D.width,stroke:Zt,fill:"none"})]})]})}function fwt({sideElementBBoxes:e,debug:t,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,xGroupKeys:f,yGroupKeys:A,xKeysByGroups:h,yKeysByGroups:m,labelAngles:g,xLabels:b,yLabels:C,xGroupLabels:x,yGroupLabels:k}){return le.jsxs("g",{fontWeight:"500",children:[le.jsx(cwt,{sideElementBBoxes:e,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,labelAngles:g,xLabels:b,yLabels:C,debug:t}),le.jsx(uwt,{sideElementBBoxes:e,xGroupKeys:f,yGroupKeys:A,xKeysByGroups:h,yKeysByGroups:m,xGroupLabels:x,yGroupLabels:k,scales:a,stepX:s,stepY:c,xAxis:i,yAxis:o,labelAngles:g,debug:t})]})}function UK(e,t="top"){let{source:n,target:r}=e;return t==="top"||t==="bottom"?`M ${n.x},${n.y} L ${r.x},${n.y} L${r.x},${r.y}`:`M ${n.x},${n.y} L ${n.x},${r.y} L${r.x},${r.y}`}function jK(e,t,n,r,a){if(!n)return"";let i=n.aes[e];if(!f9(i))return i;let o=i.value,s=a[o],c=r[o][t.data.keys[0]];return t.data.keys.every(f=>c===r[o][f])?s(String(c))[e]:s.unknown()[e]}var GK={x:0,y:0,width:0,height:0};function dwt({dendrograms:e,sideElementBBoxes:t,xDataByKeys:n,yDataByKeys:r,aesScales:a}){let i=e.x.data,o=e.y.data,s=i?t[i.position].dendro:GK,c=o?t[o.position].dendro:GK;function f(h,m){return jK(h,m,i,n,a)}function A(h,m){return jK(h,m,o,r,a)}return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${s.x},${s.y})`,children:i&&!i.hidden&&e.x.trees.map((h,m)=>{let g=h.links(),b=h.descendants();return le.jsxs("g",{children:[g.map(C=>{let x=i.edgeInheritance==="up"?C.source:C.target;return le.jsx("path",{d:UK(C,i.position),stroke:f("lineColor",x),strokeWidth:f("lineWidth",x),strokeDasharray:td(f("lineShape",x)),fill:"none"},`${C.source.x},${C.source.y},${C.target.x},${C.target.y}`)}),i.showNodes&&b.map(C=>le.jsx("g",{transform:`translate(${C.x},${C.y})`,children:Af(f("dotShape",C),f("dotSize",C),f("dotFill",C))},`${C.x},${C.y}`))]},m)})}),le.jsx("g",{transform:`translate(${c.x},${c.y})`,children:o&&!o.hidden&&e.y.trees.map((h,m)=>{let g=h.links(),b=h.descendants();return le.jsxs("g",{children:[g.map(C=>{let x=o.edgeInheritance==="up"?C.source:C.target;return le.jsx("path",{d:UK(C,o.position),stroke:A("lineColor",x),strokeWidth:A("lineWidth",x),strokeDasharray:td(A("lineShape",x)),fill:"none"},`${C.source.x},${C.source.y},${C.target.x},${C.target.y}`)}),o.showNodes&&b.map(C=>le.jsx("g",{transform:`translate(${C.x},${C.y})`,children:Af(A("dotShape",C),A("dotSize",C),A("dotFill",C))},`${C.x},${C.y}`))]},m)})})]})}function Awt({frame:e,width:t,height:n,xGroupKeys:r,yGroupKeys:a,xKeysByGroups:i,yKeysByGroups:o,scales:s,stepX:c,stepY:f}){return le.jsxs("g",{children:[e.type==="full"&&le.jsx("rect",{fill:"none",stroke:Zt,x:"0",y:"0",width:t,height:n}),e.type==="groups"&&r.map(A=>{let h=i[A].length;if(h===0)return null;let m=h*c,g=s.x(i[A][0]);return a.map(b=>{let C=o[b].length;if(C===0)return null;let x=C*f,k=s.y(o[b][0]);return le.jsx("rect",{x:g,y:k,width:m,height:x,stroke:Zt,fill:"none"},`${g}_${k}`)})})]})}function IP(e){if(e===null)return"null";if(typeof e=="number"){let t=e>0?Math.floor(e):Math.ceil(e),n=e-t;return t+Number(n.toPrecision(2))}return e}function pwt(e,t,n=[]){let r=e.data,a=[`X: ${t.xLabels[e.x]}`,`Y: ${t.yLabels[e.y]}`,`Value: ${IP(e.value)}${e.value!==e.normalizedValue?` (${IP(e.normalizedValue)})`:""}`];for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function hwt(e,t){let n=[];return e.xKey&&n.push(`X: ${t.xLabels[e.xKey]}`),e.yKey&&n.push(`Y: ${t.yLabels[e.yKey]}`),n.push(`${e.title}: ${IP(e.value)}`),n}function mwt({dendrograms:e,facetKey:t,dimensions:n,scales:r,cells:a,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,colorScale:f,chartSettings:A,cellsMeta:h,stepX:m,stepY:g,sharedX:b,sharedY:C,annotations:x,annotationColorScales:k,dendrogramAesScales:_,aes:D,labelAngles:O,chartSizes:I,margins:$,tooltipsContainer:Q}){let[ee,K]=Vn.useState(null),[re,U]=Vn.useState(null),{xAxis:G,yAxis:Z,tooltips:Y}=A,{width:X,height:oe}=n.inner,{padding:me,chartEdgeSides:ae,sideElementBBoxes:ye}=n,{xGroupLabels:Ce,yGroupLabels:ce,xLabels:ge,yLabels:ze}=h,Ne=r.x.domain(),Ge=r.y.domain(),Oe={left:$.left+n.left+me.left,right:I.totalWidth-($.left+n.left+me.left),top:$.top+n.top+me.top,bottom:I.totalHeight-($.top+n.top+me.top)},Xe=!1;return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:G2t,children:[le.jsxs("g",{transform:`translate(${me.left},${me.top})`,children:[le.jsx(swt,{sideElementBBoxes:ye,annotations:x,cellsMeta:h,annotationColorScales:k,sharedX:b,sharedY:C,chartEdgeSides:ae,width:X,height:oe,scales:r,stepX:m,stepY:g,aes:D,frame:A.frame,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,setSelectedAnnotation:U}),le.jsx(dwt,{dendrograms:e,sideElementBBoxes:ye,xDataByKeys:h.xDataByKeys,yDataByKeys:h.yDataByKeys,aesScales:_}),ye.top.facetTitle.isVisible&&le.jsx("text",{x:ye.top.facetTitle.x,y:ye.top.facetTitle.y+ye.top.facetTitle.height-j2t,fontWeight:"500",fontSize:"20px",children:h.facetKeyValues[t].join(", ")}),Xe,Ne.map(dt=>Ge.map(Ye=>{var He;let rt=(He=a==null?void 0:a[dt])==null?void 0:He[Ye];return rt?le.jsx("rect",{x:r.x(dt),y:r.y(Ye),width:m,height:g,stroke:D.cellStrokeColor,fill:rt.value===null?D.emptyCellColor:f(rt.normalizedValue),onMouseOver:()=>K(rt),onMouseLeave:()=>K(null)},rt?rt.id:`${dt}_${Ye}`):null})),le.jsx(Awt,{frame:A.frame,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,scales:r,stepX:m,stepY:g,width:X,height:oe}),le.jsx(fwt,{xAxis:G,yAxis:Z,scales:r,stepX:m,stepY:g,debug:Xe,sideElementBBoxes:ye,xKeys:Ne,yKeys:Ge,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,xGroupLabels:Ce,yGroupLabels:ce,labelAngles:O,xLabels:ge,yLabels:ze})]}),A.tooltips.show&&ee&&le.jsx(oc,{content:pwt(ee,h,Y==null?void 0:Y.content),x:r.x(String(ee.x))+m/2,y:r.y(String(ee.y))+g/2,offset:Ne.length>1?m/2:0,active:!0,sideDistances:Oe,container:Q}),A.tooltips.show&&re&&le.jsx(oc,{content:hwt(re,h),x:re.x,y:re.y,offset:0,active:!0,sideDistances:Oe,container:Q})]})}function vwt({margins:e,captionsSizes:t,settingsId:n,chartSettings:r,chartSizes:a,chartsDimensions:i,facetKeys:o,facetSettings:s,xGroupKeys:c,yGroupKeys:f,scales:A,colorScale:h,groupedCells:m,cellsMeta:g,step:b,annotations:C,annotationColorScales:x,legend:k,aes:_,dendrograms:D,dendrogramAesScales:O,columnsCount:I,labelAngles:$}){let[Q,ee]=Vn.useState(),K=Vn.useRef(null);Vn.useEffect(()=>{K.current&&ee(K.current)},[]);let re=i[o[0]].padding,U=i[o[I-1]].padding,G=e.left+a.chartsWidth+j8,Z=e.top+re.top;return le.jsx(f2,{dataId:n,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${a.totalWidth} ${a.totalHeight}`,width:a.totalWidth,height:a.totalHeight,fontFamily:"Manrope",children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${e.left},${e.top})`,children:[le.jsx(d2,{title:[r.title.name],show:r.title.show,position:r.title.position,leftPadding:re.left,rightPadding:U.right,chartsWidth:a.chartsWidth}),o.map(Y=>{let{cells:X,xKeysByGroups:oe,yKeysByGroups:me}=m[Y];return le.jsx(mwt,{dendrograms:D[Y],captionsSizes:t,facetKey:Y,dimensions:i[Y],xGroupKeys:c,yGroupKeys:f,xKeysByGroups:s.sharedX?g.xKeysByGroups:oe,yKeysByGroups:s.sharedY?g.yKeysByGroups:me,sharedX:s.sharedX,sharedY:s.sharedY,scales:{x:A.x[Y],y:A.y[Y]},cells:X,cellsMeta:g,stepX:b.x[Y],stepY:b.y[Y],colorScale:h,chartSettings:r,aes:_,annotations:C,annotationColorScales:x,dendrogramAesScales:O,labelAngles:$,margins:e,chartSizes:a,tooltipsContainer:Q},Y)})]}),le.jsx("g",{transform:`translate(${G},${Z})`,children:le.jsx(y9,{legendData:k})}),le.jsx("g",{ref:K})]})})}function YK(e,t,n){function r(a){a[n]=t(a.data.height),a.children&&a.children.forEach(r)}r(e)}function WK(e,t,n,r=n){function a(i){i[r]=i[n]+t,i.children&&i.children.forEach(a)}a(e)}var gwt=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function XK(e,t,n){let r=n;return e&&(e.colorRange&&(r=e.colorRange),e.method==="standardScaling"&&(r=[-2,2]),e.method==="meanNormalization"&&(r=[-.75,.75])),gwt(t,r)}var ywt=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"margins",{top:_g,bottom:_g,left:_g,right:_g});Me(this,"captionsSizes",{xAxisCaptions:100,yAxisCaptions:100,xGroupCaptions:Vm,yGroupCaptions:Vm,xCaptionTail:0,yCaptionTail:0});Me(this,"labelAngles",{xAxisLabels:0,yAxisLabels:0,xGroupLabels:0,yGroupLabels:0});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:{null:Hl().domain(["null"]).range([1])},y:{null:Hl().domain(["null"]).range([1])}});Me(this,"step",{x:{},y:{}});Me(this,"colorScale",Da().domain([0,1]).range(["white","black"]));Me(this,"annotationColorScales",{});Me(this,"dendrogramAesScales",{});Me(this,"legend",{width:0,height:0,items:[]});Me(this,"dendrograms",{})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateMargins(e){this.margins={top:e.show?24+24*2:_g,bottom:_g,left:_g,right:this.legend.width},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight+this.margins.bottom,this.legend.height)}updateLegendSize(e,t,n,r,a){if(!t.show){this.legend={width:0,height:0,items:[]};return}let i=this.chartSizes.chartHeight,o=[],s={width:0,height:0,left:0,top:0},c=m=>m.reduce((g,b)=>(g[b]=String(b),g),{});if(e==="continuous"){let m=this.colorScale,g=a2(m,a),b=Da([g[0],g[g.length-1]],[i,0]),C=r.label??r.value;o.push({...s,type:"continuous",id:"heatmapValue",scale:m,values:g,title:C,tickPositionScale:b})}else if(e==="discrete"){let m=this.colorScale,g=r.label??r.value,b=m.domain(),C=c(b);o.push({...s,type:"discreteColor",id:"heatmapValue",title:g,scale:m,values:b,labels:C})}if(n.forEach(m=>{let g=m.valueColumn.label??m.valueColumn.value;if(m.type==="continuous"){let b=this.annotationColorScales[m.id].scale,C=a2(b,a),x=Da([C[0],C[C.length-1]],[i,0]);o.push({...s,type:"continuous",id:m.id,tickPositionScale:x,title:g,scale:b,values:C})}if(m.type==="discrete"){let b=this.annotationColorScales[m.id].scale,C=b.domain(),x=c(C);o.push({...s,type:"discreteColor",id:m.id,title:g,scale:b,values:C,labels:x})}}),!o.length){this.legend={width:0,height:0,items:[]};return}let f=w9(o,this.chartSizes.chartHeight),A=f[f.length-1],h=A.left+A.width+2*j8;this.legend={width:h,height:i,items:f}}updateCaptionsSize(e,t,n,r){let a=new Dc("bold 14px Arial"),{xGroupKeys:i,yGroupKeys:o,xGroupLabels:s,yGroupLabels:c,xKeysByGroups:f,yKeysByGroups:A,xLabels:h,yLabels:m}=e.meta;this.labelAngles={xAxisLabels:t.axisLabelsAngle,yAxisLabels:n.axisLabelsAngle,xGroupLabels:t.groupLabelsAngle,yGroupLabels:n.groupLabelsAngle};let g=Ir.flatten(Object.values(f)),b=Ir.flatten(Object.values(A)),C=g.map(K=>a.getTextWidth(h[K])),x=b.map(K=>a.getTextWidth(m[K])),k=i.map(K=>a.getTextWidth(s[K])),_=o.map(K=>a.getTextWidth(c[K])),{xCaptionTail:D,yCaptionTail:O}=owt(this.labelAngles,r,this.step,e,a),I=this.labelAngles.xGroupLabels/180*Math.PI,$=this.labelAngles.yGroupLabels/180*Math.PI,Q=this.labelAngles.xAxisLabels/180*Math.PI,ee=this.labelAngles.yAxisLabels/180*Math.PI;this.captionsSizes={xCaptionTail:D,yCaptionTail:O,xGroupCaptions:Math.max(...k,0)*Math.sin(I)||Vm,yGroupCaptions:Math.max(..._,0)*Math.sin($)||Vm,xAxisCaptions:Math.max(...C,0)*Math.sin(Q)||Vm,yAxisCaptions:Math.max(...x,0)*Math.sin(ee)||Vm}}updateChartDimensions(e,t,n,r,a,i,o,s,c,f){let A=t.length,h=Math.min(a.nRows??A,A),m=Math.min(a.nCols??A,A);this.columnsCount=a.nRows?Math.ceil(A/h):m,this.rowsCount=Math.ceil(A/this.columnsCount);let{width:g,height:b}=e,{sharedX:C,sharedY:x}=a;this.chartsDimensions={};let k=0,_=0;t.forEach((I,$)=>{let Q=$%this.columnsCount+1,ee=zK($,t.length,this.columnsCount,this.rowsCount),K=this.step.x[I],re=this.step.y[I],U=nwt(i,o,this.captionsSizes,s,c,f,ee,C,x,t,n,r,K,re),G=iwt(s,ee,C,x);function Z(ae){return Math.max(s1[ae].reduce((ye,Ce)=>ye+U[ae][Ce],0),G[ae],z2t)}let Y={left:Z("left"),right:Z("right"),top:Z("top"),bottom:Z("bottom")};Y.left<this.captionsSizes.xCaptionTail&&(Y.left=this.captionsSizes.xCaptionTail),Y.bottom<this.captionsSizes.yCaptionTail&&(Y.bottom=this.captionsSizes.yCaptionTail);let X=rwt(U,g,b),oe=g+Y.left+Y.right,me=b+Y.top+Y.bottom;this.chartsDimensions[I]={left:k,top:_,inner:{width:g,height:b},outer:{width:oe,height:me},padding:Y,sideElementBBoxes:X,chartEdgeSides:ee},k+=oe,Q===this.columnsCount&&(k=0,_+=me)});let D=t.slice(0,this.columnsCount).reduce((I,$)=>I+this.chartsDimensions[$].outer.width,0),O=t.filter((I,$)=>$%this.columnsCount===0).reduce((I,$)=>I+this.chartsDimensions[$].outer.height,0);this.chartSizes.chartsWidth=D,this.chartSizes.chartsHeight=O}updateChartsSizes(e){let{width:t,height:n}=e;this.chartSizes.chartWidth=t,this.chartSizes.chartHeight=n}updateScales(e,t,n,r,a,i,o,s,c){let{width:f,height:A}=a,{meta:h,facets:m}=t,{sharedX:g,sharedY:b}=r,C=(k,_={})=>k.sort((D,O)=>i.sorting==="asc"?(_[D]??D).localeCompare(_[O]??O,"en",{numeric:!0}):(_[O]??O).localeCompare(_[D]??D,"en",{numeric:!0})),x=(k,_={})=>k.sort((D,O)=>o.sorting==="asc"?(_[D]??D).localeCompare(_[O]??O,"en",{numeric:!0}):(_[O]??O).localeCompare(_[D]??D,"en",{numeric:!0}));e.forEach(k=>{let _=m[k],D=C(h.xGroupKeys),O=x(h.yGroupKeys),{xKeysByGroups:I}=g?h:_,{yKeysByGroups:$}=b?h:_,Q=D.map(ye=>I[ye].length),ee=O.map(ye=>$[ye].length),K=Q.reduce((ye,Ce)=>ye+Ce,0),re=ee.reduce((ye,Ce)=>ye+Ce,0),U=(f-(Q.filter(ye=>ye>0).length-1)*n)/K,G=(A-(ee.filter(ye=>ye>0).length-1)*n)/re,Z=[],Y=[],X=0;D.forEach(ye=>{let Ce=s?I[ye]:C(I[ye],h.xLabels);Y.push(...Ce),Ce.forEach(()=>{Z.push(X),X+=U}),Ce.length>0&&(X+=n)});let oe=[],me=[],ae=0;O.forEach(ye=>{let Ce=c?$[ye]:x($[ye],h.yLabels);me.push(...Ce),Ce.forEach(()=>{oe.push(ae),ae+=G}),Ce.length>0&&(ae+=n)}),this.scales.x[k]=Hl().domain(Y).range(Z),this.scales.y[k]=Hl().domain(me).range(oe),this.step.x[k]=U,this.step.y[k]=G})}updateAesScale(e,t,n,r,a,i,o){if(e==="continuous")n.valueColors?this.colorScale=Da().domain(n.valuesByColors??XK(o,n.valueColors.length,t)).range(n.valueColors):n.colorsList&&(this.colorScale=Da().domain(XK(o,n.colorsList.length,t)).range(n.colorsList));else if(n.colorsMap){let f=Object.entries(n.colorsMap);this.colorScale=Hl().domain(f.map(A=>A[0])).range(f.map(A=>A[1])).unknown("#ccc")}else n.colorsList&&(this.colorScale=QK(n.colorsList,i.map(String)));let{xDataByKeys:s,yDataByKeys:c}=a.meta;r.forEach(f=>{let{colors:A,type:h,axis:m,valueColumn:g}=f,b=(m==="x"?s:c)[g.value];if(h==="discrete"){let C=Ir.uniq(Object.values(b).map(String)).sort();this.annotationColorScales[f.id]={type:"discrete",scale:QK(A,C)}}else{let C=Object.values(b).map(Number);if(!C.length)return;let[x=C[0],k=C[0]]=$A(C);this.annotationColorScales[f.id]={type:"continuous",scale:awt(A,x,k,0,.5,1)}}})}updateDendrogram(e,t,n,r,a,i,o){e.forEach(s=>{this.dendrograms[s]={x:{trees:[],data:i},y:{trees:[],data:o}};let{xKeysByGroups:c,yKeysByGroups:f}=r[s],{hierarchyX:A,hierarchyY:h}=a[s],m=Math.max(...A.map(b=>b.data.height)),g=Math.max(...h.map(b=>b.data.height));i&&(this.dendrograms[s].x.trees=A.map((b,C)=>{let x=t[C],k=c[x];xB().separation(()=>1).size([k.length*this.step.x[s],i.size])(b);let _=b,D=Da().domain(i.position==="top"?[0,m]:[m,0]).range([i.size,0]);return YK(_,D,"y"),WK(_,this.scales.x[s](k[0]),"x"),_}),this.dendrograms[s].x.data=i),o&&(this.dendrograms[s].y.trees=h.map((b,C)=>{let x=n[C],k=f[x];xB().separation(()=>1).size([k.length*this.step.y[s],o.size])(b);let _=b,D=Da().domain(o.position==="left"?[0,g]:[g,0]).range([o.size,0]);return WK(_,this.scales.y[s](k[0]),"x","y"),YK(_,D,"x"),_}),this.dendrograms[s].y.data=o)})}updateDendrogramAesScales(e){if(!e)return;let t=Object.keys(e);this.dendrogramAesScales=t.reduce((n,r)=>{let a=e[r],i=Object.keys(a);return n[r]=Hl().domain(i).range(i.map(o=>({...nK,...a[o]}))).unknown(nK),n},{})}render(e,t,n,r,a,i,o,s,c,f,A,h,m){var K;let{meta:g,facets:b}=a,{facetKeys:C,xGroupKeys:x,yGroupKeys:k,valueExtent:_}=g,{xAxis:D,yAxis:O,title:I,size:$,valueType:Q}=t;this.updateChartsSizes($),this.updateAesScale(Q,_,r,i,a,h,m),this.updateScales(C,a,r.groupGap,n,$,t.xAxis,t.yAxis,s,c),this.updateCaptionsSize(a,D,O,n),this.updateChartDimensions($,C,x,k,n,D,O,i,s,c),this.updateLegendSize(Q,t.legend,i,o,_),this.updateMargins(I),this.updateDendrogram(C,x,k,b,f,s,c),this.updateDendrogramAesScales(A);let ee=le.jsx(vwt,{aes:r,annotations:i,annotationColorScales:this.annotationColorScales,captionsSizes:this.captionsSizes,cellsMeta:g,columnsCount:this.columnsCount,chartsDimensions:this.chartsDimensions,chartSettings:t,chartSizes:this.chartSizes,colorScale:this.colorScale,dendrogramAesScales:this.dendrogramAesScales,dendrograms:this.dendrograms,facetKeys:C,facetSettings:n,groupedCells:b,labelAngles:this.labelAngles,legend:this.legend,margins:this.margins,scales:this.scales,settingsId:e,step:this.step,xGroupKeys:x,yGroupKeys:k});this.component=ee,(K=this.reactRoot)==null||K.render(ee)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},wwt=ywt,LP={lineColor:Zt,dotShape:"21",dotFill:Zt,dotSize:3,lineShape:"solid",lineWidth:1},KK={size:150,distance:"euclidean",linkage:"average",fillNA:0,showNodes:!0,hidden:!1,edgeInheritance:"up",aes:LP},ZK=class{constructor(e){Me(this,"id");Me(this,"type","heatmap");Me(this,"facetSettings");Me(this,"xColumn");Me(this,"xGroupBy");Me(this,"yColumn");Me(this,"yGroupBy");Me(this,"valueColumn");Me(this,"facetBy");Me(this,"normalization");Me(this,"chartSettings");Me(this,"aes");Me(this,"annotations");Me(this,"dendrogramX");Me(this,"dendrogramY");Me(this,"inheritedDendrogramAes");Me(this,"NAValueAs");var t,n,r,a,i,o,s,c,f,A,h,m,g;if(t2t.parse(e),this.id=Ir.uniqueId("settings"),this.facetSettings={sharedX:(e.facetBy??[]).length>0,sharedY:(e.facetBy??[]).length>0,...e.facetSettings},this.xColumn=e.xColumn,this.xGroupBy=e.xGroupBy??[],this.yColumn=e.yColumn,this.yGroupBy=e.yGroupBy??[],this.valueColumn=e.valueColumn,this.facetBy=e.facetBy??[],this.chartSettings={title:{position:"left",show:!0,...e.title,name:((t=e.title)==null?void 0:t.name)??"Chart"},size:{width:((n=e==null?void 0:e.size)==null?void 0:n.width)??(this.facetBy.length?400:600),height:((r=e==null?void 0:e.size)==null?void 0:r.height)??(this.facetBy.length?250:350)},frame:{type:((a=e.frame)==null?void 0:a.type)??"none"},valueType:e.valueType??"continuous",yAxis:{title:e.yColumn.label??e.yColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,showGroupLabels:!0,position:"left",groupingPosition:"left",axisLabelsAngle:90,groupLabelsAngle:0,sorting:"asc",...e.yAxis},xAxis:{title:e.xColumn.label??e.xColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,showGroupLabels:!0,position:"bottom",groupingPosition:"bottom",axisLabelsAngle:90,groupLabelsAngle:0,sorting:"asc",...e.xAxis},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.normalization=this.chartSettings.valueType==="continuous"?e.normalization??null:null,this.NAValueAs=e.NAValueAs??null,this.aes={colorsList:((i=e.aes)==null?void 0:i.colorsList)??["black","white","red"],colorsMap:((o=e.aes)==null?void 0:o.colorsMap)??null,valueColors:((s=e.aes)==null?void 0:s.valueColors)??null,valuesByColors:((c=e.aes)==null?void 0:c.valuesByColors)??null,cellStrokeColor:((f=e.aes)==null?void 0:f.cellStrokeColor)??"none",groupGap:((A=e.aes)==null?void 0:A.groupGap)??3,emptyCellColor:((h=e.aes)==null?void 0:h.emptyCellColor)??"white"},this.annotations=(e.annotations??[]).map(b=>b.axis==="x"?{id:Ir.uniqueId("annotation"),axis:"x",valueColumn:b.valueColumn,position:b.position??this.chartSettings.xAxis.position,titlePosition:b.titlePosition??"right",showTitle:b.showTitle??!0,type:b.type,colors:b.colors??["white","black"]}:{id:Ir.uniqueId("annotation"),axis:"y",valueColumn:b.valueColumn,position:b.position??this.chartSettings.yAxis.position,titlePosition:b.titlePosition??"top",showTitle:b.showTitle??!0,type:b.type,colors:b.colors??["white","black"]}),e.valueType==="discrete"&&(e.dendrogramX||e.dendrogramY))throw Error("Dendrogram is not available with discrete cells values");this.dendrogramX=e.dendrogramX?{...KK,position:"top",...e.dendrogramX,aes:{...LP,...(m=e.dendrogramX)==null?void 0:m.aes}}:null,this.dendrogramY=e.dendrogramY?{...KK,position:"left",...e.dendrogramY,aes:{...LP,...(g=e.dendrogramY)==null?void 0:g.aes}}:null,this.inheritedDendrogramAes=e.inheritedDendrogramAes??null}},Cwt=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new wwt);Me(this,"calculatedData",null);this.settings=new ZK(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new ZK(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for heatmap")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var I,$,Q,ee,K,re,U,G,Z,Y,X,oe;let{xColumn:r,yColumn:a,valueColumn:i,xGroupBy:o,yGroupBy:s,facetBy:c,annotations:f,chartSettings:A,facetSettings:h,dendrogramX:m,dendrogramY:g,normalization:b,NAValueAs:C}=n,x=Object.values(((I=t.dendrogramX)==null?void 0:I.aes)||{}).filter(f9),k=Object.values((m==null?void 0:m.aes)||{}).filter(f9),_=Object.values((($=t.dendrogramY)==null?void 0:$.aes)||{}).filter(f9),D=Object.values((g==null?void 0:g.aes)||{}).filter(f9);function O(me,ae){return me.length!==ae.length||me.some((ye,Ce)=>ye.value!==ae[Ce].value)}return t.xColumn.value!==r.value||t.yColumn.value!==a.value||t.valueColumn.value!==i.value||O(t.xGroupBy,o)||O(t.yGroupBy,s)||O(t.facetBy,c)||O(t.annotations.map(me=>me.valueColumn),f.map(me=>me.valueColumn))||O(x,k)||O(_,D)||(n.dendrogramX||t.dendrogramX)&&(((Q=t.dendrogramX)==null?void 0:Q.distance)!==((ee=n.dendrogramX)==null?void 0:ee.distance)||((K=t.dendrogramX)==null?void 0:K.linkage)!==((re=n.dendrogramX)==null?void 0:re.linkage))||(n.dendrogramY||t.dendrogramY)&&(((U=t.dendrogramY)==null?void 0:U.distance)!==((G=n.dendrogramY)==null?void 0:G.distance)||((Z=t.dendrogramY)==null?void 0:Z.linkage)!==((Y=n.dendrogramY)==null?void 0:Y.linkage))||t.chartSettings.valueType!==A.valueType||t.facetSettings.sharedX!==h.sharedX||t.facetSettings.sharedY!==h.sharedY||((X=t.normalization)==null?void 0:X.method)!==(b==null?void 0:b.method)||((oe=t.normalization)==null?void 0:oe.direction)!==(b==null?void 0:b.direction)||t.NAValueAs!==C}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{xColumn:t,yColumn:n,valueColumn:r,xGroupBy:a,yGroupBy:i,facetBy:o,chartSettings:s,facetSettings:c,annotations:f,dendrogramX:A,dendrogramY:h,normalization:m,NAValueAs:g}=this.settings,b=K7t(this.data,t,n,r,o,a,i,f,A,h,m,g),C=twt(b,A,h,c),x=s.valueType==="discrete"?this.data.getColumnCategories(r.value):[];this.calculatedData={groupedCellsData:b,dendrogramsData:C,cellUniqValues:x}}_updateAesInData(){}_updateChart(){if(!this.calculatedData)return;let{id:t,valueColumn:n,chartSettings:r,facetSettings:a,aes:i,annotations:o,dendrogramX:s,dendrogramY:c,inheritedDendrogramAes:f,normalization:A}=this.settings;this.chartRenderer.render(t,r,a,i,this.calculatedData.groupedCellsData,o,n,s,c,this.calculatedData.dendrogramsData,f,this.calculatedData.cellUniqValues,A)}},JK=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r)return[n];if(e<2)return[(n+r)/2];let a=(r-n)/e,i=[];for(let o=1;o<e;o++)i.push(n+a*o);return i};function bwt(e,t,n){let[r=0,a=0]=$A(e,s=>s[t.value]),i=JK(n,[r,a]),o=pL().thresholds(i).value(s=>s[t.value])(e);return{bins:o,minX:o[0].x0??0,maxX:o[o.length-1].x1??0,maxCount:Ih(o,s=>s.length)??0}}function Ewt(e,t,n){let[r=0,a=0]=$A(e,A=>A[t.value]),i=[r,a],o=JK(n,[r,a]),s=q1().domain(i).range(i),c=o.map(A=>s.invert(A)),f=pL().thresholds(c).value(A=>A[t.value])(e);return{bins:f,minX:f[0].x0??0,maxX:f[f.length-1].x1??0,maxCount:Ih(f,A=>A.length)??0}}function xwt(e,t,n,r,a){let i={};return t.forEach(o=>{let s=e.getRowsByGrouping([...o]);i[o.join("_")]=a==="linear"?bwt(s,n,r):Ewt(s,n,r)}),i}var Swt={TOP:30,BOTTOM:0,LEFT:10,RIGHT:10};function b9(e,t,n=!1){let r=Math.abs(e.range()[0]-e.range()[1]),a=n?Math.min(Math.floor(r/45),10):10,i=e.ticks(a).filter(c=>t&&c>=0||!t),o=new Set(i);if(!n&&i.length>1){let c=e(i[0]),f=e(i[0]);for(let A=1;A<i.length;A++)f=e(i[A]),Math.abs(f-c)>=20?c=f:o.delete(i[A])}n&&i.length>2&&Math.abs(e(i[1])-e(i[0]))<45&&(i=i.filter((c,f)=>f%2===0));let s=i.some(c=>Math.abs(c)<1e-4&&c!==0||c>1e4)?",e":",f";return{ticks:i,format:c=>o.has(c)?e.tickFormat(a,s)(c):""}}function Bwt(e){return`translate(${e},0)`}function kwt(e){return`translate(0,${e})`}function Twt(e){return e==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function _wt(e){return e==="bottom"?"hanging":"central"}function Pwt(e){return e==="bottom"?"middle":"end"}var qK=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",onlyPositive:a=!1,offset:i=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function o(C){return x=>{let k=C(x);return k===void 0?0:+k}}let{ticks:s,format:c}=b9(e,a,r==="bottom"),f=Math.max(t,0)+n,A=o(e.copy()),h=r==="bottom"?Bwt:kwt,m=r==="left"?-1:1,g={[(r==="left"?"x":"y")+"2"]:m*t},b={[r==="left"?"x":"y"]:m*f};return le.jsx("g",{children:s.map((C,x)=>le.jsxs("g",{className:"tick",transform:h(A(C)+i),children:[le.jsx("line",{stroke:Zt,...g}),le.jsx("g",{transform:Twt(r),children:le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:_wt(r),textAnchor:Pwt(r),...b,children:c(C)})})]},x))})},Mwt=1;function eZ({scaleX:e,scaleY:t,width:n,height:r,axisX:a,axisY:i,frameType:o,updatingKey:s=""}){let[c,f]=Vn.useState(e.ticks()),[A,h]=Vn.useState(t.ticks()),{significantLines:m=[]}=a,{significantLines:g=[]}=i;return Vn.useEffect(()=>{let b=e.ticks().filter(x=>!m.includes(x)),C=t.ticks().filter(x=>!g.includes(x));f(b),h(C)},[e,t,s]),le.jsxs("g",{stroke:Jf,children:[a.showGrid&&c.map(b=>{let C=e(b);return le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`x_${C}_${r}`)}),i.showGrid&&A.map(b=>{let C=t(b);return le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`y_${C}_${n}`)}),le.jsx("g",{strokeDasharray:td(a.significantLinesStyle),stroke:Zt,children:m.map(b=>{let C=e(b);return C<0||C>n?null:le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`significant_${C}_${r}`)})}),le.jsx("g",{strokeDasharray:td(i.significantLinesStyle),stroke:Zt,children:g.map(b=>{let C=t(b);return C<0||C>r?null:le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`significant_${C}_${n}`)})}),o!=="empty"&&le.jsxs("g",{strokeWidth:Mwt,children:[(a.showGrid||o!=="left")&&le.jsx("line",{stroke:o==="left"?Jf:Zt,x1:"0",x2:n,y1:r,y2:r}),(a.showGrid||o!=="bottom")&&le.jsx("line",{stroke:o==="bottom"?Jf:Zt,x1:"0",x2:"0",y1:"0",y2:r}),(a.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:n,x2:n,y1:"0",y2:r}),(i.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:"0",x2:n,y1:"0",y2:"0"})]})]})}function Dwt({width:e,height:t,dimensions:n,scales:r,xAxis:a,yAxis:i,frameType:o,histogramData:s,facetSettings:c,captionsSizes:f,facetTitle:A,layers:h,aesColorGetter:m}){let{padding:g}=n,b=a.showTicks?4:0,C=i.showTicks?4:0,x=n.chartEdgeSides.includes("left")||!(c!=null&&c.sharedY),k=n.chartEdgeSides.includes("bottom")||!(c!=null&&c.sharedX),_=n.chartEdgeSides.includes("bottom"),D=!1;return le.jsxs("g",{transform:`translate(${n.left+g.left},${n.top+g.top})`,children:[D,A.length&&le.jsxs("g",{children:[o==="full"&&le.jsx("rect",{x:"0",y:-g.top,height:g.top,width:e,fill:"#F7F8FA",stroke:Zt}),A.map((O,I)=>{let $=A.length,Q=(g.top-20*$)/2;return le.jsx("text",{fontSize:"14px",fontWeight:"500",fill:Zt,x:e/2,dy:Q+20/2-g.top,y:I*20,textAnchor:"middle",dominantBaseline:"central",children:O},I)})]}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[_&&le.jsx("text",{x:e/2,y:t+g.bottom-12-20/2,children:a.title}),D]}),le.jsx(eZ,{width:e,height:t,scaleX:r.x,scaleY:r.y,axisX:a,axisY:i,frameType:o}),k&&le.jsxs("g",{transform:`translate(0,${t})`,children:[le.jsx(qK,{scale:r.x,orient:"bottom",onlyPositive:!0,tickSize:b}),D]}),x&&le.jsxs("g",{children:[le.jsx(qK,{scale:r.y,orient:"left",tickSize:C}),D]}),h.map(O=>s.bins.map(I=>le.jsx("rect",{x:r.x(I.x0),y:r.y(I.length),fill:I[0]?m(O.aes.fillColor,I[0]):"",stroke:Zt,width:r.x(I.x1)-r.x(I.x0),height:r.y(0)-r.y(I.length),opacity:O.aes.opacity??1},I.x0)))]})}function Hwt({settingsId:e,chartSettings:t,chartSizes:n,chartsDimensions:r,columnsCount:a,facetKeys:i,facetSettings:o,scales:s,margins:c,mainTitle:f,facetTitles:A,captionsSizes:h,histogramDataByFacets:m,layers:g,aesColorGetter:b}){let{xAxis:C,yAxis:x,title:k,frame:_}=t,D=r[i[0]].padding,O=r[i[a-1]].padding;return le.jsx(f2,{dataId:e,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${n.totalWidth} ${n.totalHeight}`,width:n.totalWidth,height:n.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${c.left},${c.top})`,fontFamily:"Manrope",children:[le.jsx(d2,{title:f,show:k.show,position:k.position,leftPadding:D.left,rightPadding:O.right,chartsWidth:n.chartsWidth}),i.map(I=>le.jsx(Dwt,{scales:{x:s.x[I],y:s.y[I]},width:n.chartWidth,height:n.chartHeight,dimensions:r[I],margins:c,chartSizes:n,facetSettings:o,xAxis:C,yAxis:x,frameType:_.type,facetTitle:A[I],captionsSizes:h,histogramData:m[I],layers:g,aesColorGetter:b},I))]})]})})}function Iwt(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function Lwt(e,t,n,r,a,i,o){let s=i.includes("left")||!(o!=null&&o.sharedY),c=i.includes("bottom")||!(o!=null&&o.sharedX),f=i.includes("bottom")&&e.title!=="",A=n.yAxisCaptionsWidth+2*6,h=(t.showTicks?4:0)+6,m=n.xAxisCaptionsWidth+2*6,g=e.showTicks?4:0,b=f?32:0,C=A+h+8,x=m+g+b+8,k=Math.max(...r.map(_=>a[_].length));return{left:s?C:12,top:k===0?0:6*2+k*20,bottom:c?x+8:12,right:12}}function Rwt(e,t,n){let r=[];for(let a=0;a<t;a++)r.push(e.slice(a*n,a*n+n));return r}function Nwt(e,t){let n=Math.floor(e/t),r=e-n*t;return[n,r]}function $wt(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e&&e.type==="grouping"}function Fwt(e,t){return function(n,r){var a,i;if($wt(n)){let o=n.value;return(i=((a=e[o])==null?void 0:a[String(r[o])])??hP)==null?void 0:i[t]}return n}}var Vwt=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"margins",{top:24,bottom:24,left:24,right:24});Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:{null:Da().domain([0,10]).range([0,600])},y:{null:Da().domain([0,10]).range([350,0])}});Me(this,"captionsSizes",{xAxisCaptionsWidth:30,yAxisCaptionsWidth:100});Me(this,"facetTitles",{});Me(this,"mainTitle",[])}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateChartSizes(e){this.chartSizes.chartWidth=e.width,this.chartSizes.chartHeight=e.height}updateChartDimensions(e,t,n,r){let{chartWidth:a,chartHeight:i}=this.chartSizes,o=0,s=0;this.chartsDimensions=e.reduce((A,h,m)=>{let[g,b]=Nwt(m,this.columnsCount),C=Iwt(m,e.length,this.columnsCount,this.rowsCount),x=Lwt(n,r,this.captionsSizes,Rwt(e,this.rowsCount,this.columnsCount)[g],this.facetTitles,C,t),k=a+x.left+x.right,_=i+x.top+x.bottom;return A[h]={left:o,top:s,chartEdgeSides:C,padding:x,inner:{width:a,height:i},outer:{width:k,height:_}},o+=k,b===this.columnsCount-1&&(o=0,s+=_),A},{});let c=Math.max(...e.map(A=>this.chartsDimensions[A].outer.width+this.chartsDimensions[A].left)),f=Math.max(...e.map(A=>this.chartsDimensions[A].outer.height+this.chartsDimensions[A].top));this.chartSizes.chartsWidth=c,this.chartSizes.chartsHeight=f}updateViewport(e,t,n,r,a){let i=e.length,o=Math.min(t.nRows??i,i),s=Math.min(t.nCols??i,i);this.columnsCount=t.nRows?Math.ceil(i/o):s,this.rowsCount=Math.ceil(i/this.columnsCount);let[c,f]=[1/0,-1/0],A=-1/0,h=e.reduce((m,g)=>{let b=a[g],{minX:C,maxX:x,maxCount:k}=b;return c=Math.min(c,C),f=Math.max(f,x),A=Math.max(A,k),m[g]={minX:C,maxX:x,maxY:k},m},{});e.forEach(m=>{let g=n.scale==="log"?q1():Da(),b=h[m],C=t.sharedX?c:b.minX,x=t.sharedX?f:b.maxX;g.domain([C,x]).range([0,this.chartSizes.chartWidth]),this.scales.x[m]=g}),e.forEach(m=>{let g=r.scale==="log"?q1():Da(),b=h[m],C=0,x=t.sharedY?A:b.maxY,k=[this.chartSizes.chartHeight,0],_=g.copy().domain([C,x]).range([this.chartSizes.chartHeight,Swt.TOP]);g.domain([_.invert(this.chartSizes.chartHeight),_.invert(0)]).range(k),this.scales.y[m]=g})}updateCaptionsSize(){let e=new Dc("600 14px Arial"),t=0;function n(r){return Math.max(...r.map(a=>e.getTextWidth(a)))}Object.values(this.scales.y).forEach(r=>{let{ticks:a,format:i}=b9(r,!1);t=Math.max(t,n(a.map(i)))}),this.captionsSizes={xAxisCaptionsWidth:20,yAxisCaptionsWidth:t}}createMainTitle(e,t){let n=this.chartsDimensions[e[0]],r=this.chartsDimensions[e[e.length-1]];this.mainTitle=Om(t.name,this.chartSizes.chartsWidth-n.padding.left-r.padding.right,20)}createFacetTitles(e,t){this.facetTitles=e.reduce((n,r,a)=>(t[a].length===1&&t[a][0]==="null"?n[r]=[]:n[r]=Om(t[a].join(", "),this.chartSizes.chartWidth,14),n),{})}updateMargins(){let e=24*this.mainTitle.length,t=e>0?e+24*2:0;this.margins={top:Math.max(t,24),bottom:24,left:24,right:24},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+this.chartSizes.chartsHeight+this.margins.bottom}render(e,t,n,r,a,i,o,s){var g;let{xAxis:c,yAxis:f,size:A,title:h}=t;this.updateChartSizes(A),this.updateViewport(r,n,c,f,i),this.updateCaptionsSize(),this.createFacetTitles(r,a),this.updateChartDimensions(r,n,c,f),this.createMainTitle(r,h),this.updateMargins();let m=le.jsx(Hwt,{settingsId:e,chartSettings:t,facetKeys:r,facetSettings:n,chartSizes:this.chartSizes,chartsDimensions:this.chartsDimensions,scales:this.scales,columnsCount:this.columnsCount,margins:this.margins,mainTitle:this.mainTitle,facetTitles:this.facetTitles,captionsSizes:this.captionsSizes,histogramDataByFacets:i,layers:o,aesColorGetter:Fwt(s,"fillColor")});this.component=m,(g=this.reactRoot)==null||g.render(m)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},Owt=Vwt,Qwt=10,zwt=class{constructor(e){Me(this,"type","bins");Me(this,"aes",{fillColor:"white",opacity:1});this.aes={...this.aes,...e.aes}}},Uwt=class{constructor(e){Me(this,"type","binsLine");Me(this,"aes",{opacity:1});this.aes={...this.aes,...e.aes}}},tZ=class{constructor(e){Me(this,"id");Me(this,"type","histogram");Me(this,"valueColumn");Me(this,"binsCount");Me(this,"facetSettings");Me(this,"facetBy");Me(this,"grouping");Me(this,"chartSettings");Me(this,"inheritedAes");Me(this,"layers");var t,n,r,a,i,o,s,c;s2t.parse(e),this.id=Ir.uniqueId("settings"),this.facetSettings={sharedX:!0,sharedY:!0,titlePosition:"left",...e.facetSettings},this.valueColumn=e.valueColumn,this.binsCount=e.binsCount??Qwt,this.facetBy=e.facetBy??[],this.grouping=e.grouping??[],this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(this.facetBy.length?400:600),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(this.facetBy.length?250:350)},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},yAxis:{showGrid:!0,showTicks:!0,scale:((a=e.xAxis)==null?void 0:a.scale)??"linear",...e.yAxis},xAxis:{title:e.valueColumn.label??e.valueColumn.value??"",scale:((i=e.xAxis)==null?void 0:i.scale)??"linear",showGrid:((o=e.xAxis)==null?void 0:o.showGrid)??!0,showTicks:((s=e.xAxis)==null?void 0:s.showTicks)??!0},frame:{type:((c=e.frame)==null?void 0:c.type)??"full"},legend:{show:!0,position:"right",...e.legend}},this.inheritedAes=e.inheritedAes??{},this.layers=e.layers.map(f=>{if(f.type==="bins")return new zwt(f);if(f.type==="binsLine")return new Uwt(f);vA(f,"Unknown layer type")}).filter(Boolean)}};function nZ(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}var jwt=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new Owt);Me(this,"calculatedData",null);this.settings=new tZ(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new tZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for histogram")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){return t.valueColumn.value!==n.valueColumn.value||t.facetBy.some((r,a)=>{var i;return r.value!==((i=n.facetBy[a])==null?void 0:i.value)})||t.grouping.length!==n.grouping.length||t.grouping.some((r,a)=>{var i;return r.value!==((i=n.grouping[a])==null?void 0:i.value)})||t.layers.length!==n.layers.length||t.layers.some((r,a)=>r.type!==n.layers[a].type)||t.binsCount!==n.binsCount||t.chartSettings.xAxis.scale!==n.chartSettings.xAxis.scale}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{valueColumn:t,facetBy:n,binsCount:r,chartSettings:a}=this.settings,i=n.map(f=>this.data.getColumnCategories(f.value)),o=i.length?nZ([...i]):[["null"]],s=n.map(f=>f.value)??null;this.data.setGrouping([...s]);let c=xwt(this.data,o,t,r,a.xAxis.scale);this.calculatedData={facetKeys:o.map(f=>f.join(", ")),facetKeysCombinations:o,histogramDataByFacets:c}}_updateAesInData(){this.calculatedData}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,facetSettings:r,inheritedAes:a,layers:i}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.facetKeys,this.calculatedData.facetKeysCombinations,this.calculatedData.histogramDataByFacets,i,a)}};function Gwt(e,t,n,r,a,i){let o={};return t.forEach(s=>{let c=[],f=1/0,A=1/0,h=-1/0,m=-1/0;i.forEach(g=>{e.getRowsByGrouping([...s,g]).forEach(b=>{let C=b[n.value],x=b[r.value];f=Math.min(f,C),A=Math.min(A,x),h=Math.max(h,C),m=Math.max(m,x),C!==null&&x!==null&&c.push({id:`${Object.values(b)}`,x:C,y:x,label:a?b[a.valueLabels??a.value]:null,data:b})})}),c.sort((g,b)=>g.x-b.x),o[s.join("_")]={minX:f,maxX:h,minY:A,maxY:m,dots:c}}),o}function Ywt(e,t,n,r,a){return t.reduce((i,o)=>{let s=n[o].dots;return i[o]=e.map(c=>{if(c.type==="curve")return{type:"curve",info:c,geoms:r.map(f=>{let A=s.filter(m=>a.every((g,b)=>m.data[g.value]===f[b])),h=a.reduce((m,g,b)=>(m[g.value]=f[b],m),{});return{dots:A,data:h}})};if(c.type==="dots")return{type:"dots",info:c,geoms:s};vA(c,"Unknown scatterplot layer type")}),i},{})}var rZ=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function Wwt(e,t,n){if(n==="linear")return rZ(e,t);if(n==="log"){let r=rZ(e,t),a=q1(t,t),i=r.map(o=>a.invert(o));return i[0]=t[0],i[i.length-1]=t[1],i}return[]}function J8(e,t,n){return(n==="log"?q1():Da()).domain(Wwt(e.length,t,n)).range(e)}function RP(e){let t=e.xPosition!=="middle"&&e.yPosition!=="middle",n=e.padding*(t?.7:1);return e.xPosition==="right"?e.x+n:e.xPosition==="middle"?e.x-e.width/2:e.x-e.width-n}function aZ(e){let t=e.xPosition!=="middle"&&e.yPosition!=="middle",n=e.padding*(t?.7:1);return e.yPosition==="middle"?e.y-e.height/2:e.yPosition==="top"?e.y-n-e.height:e.y+n}function Xwt(e,t){return RP(e)-t}function Kwt(e,t){return aZ(e)-t}function iZ(e){let t=RP(e),n=t+e.width,r=aZ(e),a=r+e.height;return{minX:t,maxX:n,minY:r,maxY:a}}function oZ(e,t,n){let r=Xwt(e,n),a=RP(e)+e.width+n,i=Kwt(e,t),o=i+e.height+2*t;return{minX:r,maxX:a,minY:i,maxY:o}}function Zwt(e,t,n){return e.minX>=0&&e.maxX<=t&&e.minY>=0&&e.maxY<=n}var q8=2;function Jwt(e,t=q8,n=q8){e.forEach(r=>{r.bbox=iZ(r),r.outerBBox=oZ(r,t,n)})}function eE(e,t,n,r=q8,a=q8){let i=[],o=new Dft,s=[["middle","right"],["top","right"],["bottom","right"],["middle","left"],["top","left"],["bottom","left"],["top","middle"],["bottom","middle"]];for(let c of e)for(let[f,A]of s){let h={...c,yPosition:f,xPosition:A};if(h.bbox=iZ(h),h.outerBBox=oZ(h,r,a),Zwt(h.outerBBox,t,n)&&!o.collides(h.outerBBox)){i.push(h),o.insert(h.outerBBox);break}}return i}function qwt(e){return`translate(${e},0)`}function e9t(e){return`translate(0,${e})`}function t9t(e){return e==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function n9t(e){return e==="bottom"?"hanging":"central"}function r9t(e){return e==="bottom"?"middle":"end"}var tE=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",onlyPositive:a=!1,offset:i=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function o(C){return x=>{let k=C(x);return k===void 0?0:+k}}let{ticks:s,format:c}=b9(e,a,r==="bottom"),f=Math.max(t,0)+n,A=o(e.copy()),h=r==="bottom"?qwt:e9t,m=r==="left"?-1:1,g={[(r==="left"?"x":"y")+"2"]:m*t},b={[r==="left"?"x":"y"]:m*f};return le.jsx("g",{children:s.map((C,x)=>le.jsxs("g",{className:"tick",transform:h(A(C)+i),children:[le.jsx("line",{stroke:Zt,...g}),le.jsx("g",{transform:t9t(r),children:le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:n9t(r),textAnchor:r9t(r),...b,children:c(C)})})]},x))})},a9t=1;function i9t({scaleX:e,scaleY:t,width:n,height:r,axisX:a,axisY:i,frameType:o,updatingKey:s=""}){let[c,f]=Vn.useState(e.ticks()),[A,h]=Vn.useState(t.ticks()),{significantLines:m=[]}=a,{significantLines:g=[]}=i;return Vn.useEffect(()=>{let b=e.ticks().filter(x=>!m.includes(x)),C=t.ticks().filter(x=>!g.includes(x));f(b),h(C)},[e,t,s]),le.jsxs("g",{stroke:Jf,children:[a.showGrid&&c.map(b=>{let C=e(b);return le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`x_${C}_${r}`)}),i.showGrid&&A.map(b=>{let C=t(b);return le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`y_${C}_${n}`)}),le.jsx("g",{strokeDasharray:td(a.significantLinesStyle),stroke:Zt,children:m.map(b=>{let C=e(b);return le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`significant_${C}_${r}`)})}),le.jsx("g",{strokeDasharray:td(i.significantLinesStyle),stroke:Zt,children:g.map(b=>{let C=t(b);return le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`significant_${C}_${n}`)})}),o!=="empty"&&le.jsxs("g",{strokeWidth:a9t,children:[(a.showGrid||o!=="left")&&le.jsx("line",{stroke:o==="left"?Jf:Zt,x1:"0",x2:n,y1:r,y2:r}),(a.showGrid||o!=="bottom")&&le.jsx("line",{stroke:o==="bottom"?Jf:Zt,x1:"0",x2:"0",y1:"0",y2:r}),(a.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:n,x2:n,y1:"0",y2:r}),(i.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:"0",x2:n,y1:"0",y2:"0"})]})]})}var o9t=new Dc("16px Manrope");function lZ(e,t){return typeof e=="string"?e:t.length?t[0].data[e.value]:""}function l9t(e,t,n=[]){let r=e.data,a=[`x: ${Ki(e.x)}`,`y: ${Ki(e.y)}`];t.label&&a.unshift(`${t.label}: ${r[t.label]}`);for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function s9t(e){return typeof e.r2>"u"?null:le.jsxs(le.Fragment,{children:[le.jsx("tspan",{children:"R"}),le.jsx("tspan",{fontSize:"10px",dy:"-8",children:"2"}),le.jsx("tspan",{dy:"8",children:` = ${Ki(e.r2)}`})]})}function u9t(e){return typeof e.pValue>"u"?null:le.jsx("tspan",{children:`p-value = ${Ki(e.pValue)}`})}function c9t(e){if(typeof e.coefficients>"u")return null;let{slope:t,slopeError:n,intercept:r,interceptError:a}=e.coefficients;return le.jsx("tspan",{children:le.jsx("tspan",{children:`slope = ${Ki(t)} ± ${Ki(n)}, intercept = ${Ki(r)} ± ${Ki(a)}`})})}function f9t(e){let t=[s9t(e),u9t(e),c9t(e)].filter(n=>n!==null);return le.jsx(le.Fragment,{children:t.map((n,r)=>le.jsxs("tspan",{children:[n,le.jsx("tspan",{children:r<t.length-1&&", "})]},r))})}var NP=3;function sZ(e,t,n,r){if(!r)return[];let a=[];for(let i of e){let o=i.label;if(!o)continue;let s=o9t.getTextMetrics(String(o));a.push({name:String(o),width:s.width,height:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent,x:t.x(i.x),y:t.y(i.y),xPosition:"right",yPosition:"middle",bbox:{minX:0,maxX:0,minY:0,maxY:0},dot:i,padding:n.dotSize(r.info.aes.dotSize,i.data)+NP})}return a}function d9t({width:e,height:t,dimensions:n,scales:r,xAxis:a,yAxis:i,frameType:o,dotsData:s,facetSettings:c,trendsData:f,keyColumn:A,margins:h,chartSizes:m,tooltips:g,tooltipsContainer:b,captionsSizes:C,facetTitle:x,onlyPositive:k,layersData:_,aesGetters:D}){let[O,I]=Vn.useState(null),{padding:$}=n,{dots:Q}=s,ee=a.showTicks?t2:0,K=i.showTicks?t2:0,re=lZ(a.title,Q),U=lZ(i.title,Q),G=n.chartEdgeSides.includes("left")||!(c!=null&&c.sharedY),Z=n.chartEdgeSides.includes("bottom")||!(c!=null&&c.sharedX),Y=n.chartEdgeSides.includes("left"),X=n.chartEdgeSides.includes("bottom"),oe={left:h.left+n.left+$.left,right:m.totalWidth-(h.left+n.left+$.left),top:h.top+n.top+$.top,bottom:m.totalHeight-(h.top+n.top+$.top)},me=!1,[ae,ye]=Vn.useState(()=>sZ(Q,r,D,_.find(Ne=>Ne.type==="dots"))),[Ce,ce]=Vn.useState(()=>eE(ae,e,t,NP,NP)),[ge,ze]=Vn.useState(null);return Vn.useEffect(()=>{ye(sZ(Q,r,D,_.find(Ne=>Ne.type==="dots")))},[Q,r,D,_]),Vn.useEffect(()=>{let Ne=eE(ae,e,t);ce(Ne)},[ae,e,t]),le.jsxs("g",{transform:`translate(${n.left+$.left},${n.top+$.top})`,children:[me,x.length&&le.jsxs("g",{children:[o==="full"&&le.jsx("rect",{x:"0",y:-$.top,height:$.top,width:e,fill:"#F7F8FA",stroke:Zt}),x.map((Ne,Ge)=>{let Oe=x.length,Xe=($.top-vP*Oe)/2;return le.jsx("text",{fontSize:"14px",fontWeight:"500",fill:Zt,x:e/2,dy:Xe+vP/2-$.top,y:Ge*vP,textAnchor:"middle",dominantBaseline:"central",children:Ne},Ge)})]}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[X&&le.jsx("text",{x:e/2,y:t+$.bottom-Rm-u9/2,children:re}),me,Y&&le.jsx("text",{x:-$.left+Rm+u9/2,y:t/2,transform:`rotate(-90,${-$.left+Rm+u9/2},${t/2})`,children:U}),me]}),le.jsx(i9t,{width:e,height:t,scaleX:r.x,scaleY:r.y,axisX:a,axisY:i,frameType:o}),Z&&le.jsxs("g",{transform:`translate(0,${t})`,children:[le.jsx(tE,{scale:r.x,orient:"bottom",onlyPositive:k.x,tickSize:ee}),me]}),G&&le.jsxs("g",{children:[le.jsx(tE,{scale:r.y,orient:"left",onlyPositive:k.y,tickSize:K}),me]}),f&&f.map(({predict:Ne,getArea:Ge,color:Oe,data:Xe,bounded:dt,xBounds:Ye,stats:rt},He)=>{let[$e,ut]=dt?Ye:r.x.domain(),ct=(ut-$e)/15,Bt=Ne($e),dn=Ne(ut);if(isNaN(Bt)||isNaN(dn))return null;let gn=D.dotColor(Oe,Xe);return le.jsxs("g",{children:[le.jsx("text",{y:He*20+20,fill:gn,x:e-8,textAnchor:"end",children:f9t(rt)}),le.jsx("path",{d:Ge(r.x,r.y,Ir.range($e,ut+ct/2,ct)),fill:gn,opacity:.2}),le.jsx("line",{x1:r.x($e),x2:r.x(ut),y1:r.y(Bt),y2:r.y(dn),stroke:gn})]},He)}),_.map((Ne,Ge)=>{if(Ne.type==="dots")return le.jsxs("g",{children:[Q.map(Oe=>le.jsx("g",{transform:`translate(${r.x(Oe.x)},${r.y(Oe.y)})`,onMouseOver:()=>I(Oe),onMouseLeave:()=>I(null),children:Af(D.dotShape(Ne.info.aes.dotShape,Oe.data),D.dotSize(Ne.info.aes.dotSize,Oe.data),D.dotColor(Ne.info.aes.dotFill,Oe.data))},Oe.id)),Ce.map(Oe=>{let{name:Xe,height:dt,bbox:Ye,width:rt}=Oe;return le.jsx("g",{children:le.jsxs("g",{transform:`translate(${Ye.minX},${Ye.minY})`,children:[le.jsx("rect",{x:"0",y:"0",width:rt,height:dt,fill:"transparent",stroke:"none",onMouseOver:()=>ze(Oe.dot),onMouseLeave:()=>ze(null)}),le.jsx("text",{x:0,y:dt/2,stroke:"white",strokeWidth:2,paintOrder:"stroke",style:{pointerEvents:"none"},fontFamily:"Manrope",fontSize:"16px",dominantBaseline:"middle",children:Xe})]})},Oe.dot.id)}),ge&&le.jsxs("g",{transform:`translate(${r.x(ge.x)},${r.y(ge.y)})`,children:[Af(D.dotShape(Ne.info.aes.dotShape,ge.data),D.dotSize(Ne.info.aes.dotSize,ge.data)+1,"white","white"),Af(D.dotShape(Ne.info.aes.dotShape,ge.data),D.dotSize(Ne.info.aes.dotSize,ge.data),D.dotColor(Ne.info.aes.dotFill,ge.data))]},"activeDot")]},Ge);if(Ne.type==="curve"&&!Ne.info.smoothing)return Ne.geoms.map((Oe,Xe)=>le.jsx("g",{children:le.jsx("polyline",{points:Oe.dots.map(dt=>`${r.x(dt.x)},${r.y(dt.y)}`).join(" "),fill:"none",stroke:D.lineColor(Ne.info.aes.lineColor,Oe.data),strokeWidth:Ne.info.aes.lineWidth,strokeDasharray:td(Ne.info.aes.lineShape)})},Xe));if(Ne.type==="curve"&&Ne.info.smoothing)return Ne.geoms.map((Oe,Xe)=>le.jsx("g",{children:le.jsx("path",{d:d3().curve(A3).x(dt=>r.x(dt.x)).y(dt=>r.y(dt.y))(Oe.dots)??"",fill:"none",stroke:D.lineColor(Ne.info.aes.lineColor,Oe.data),strokeWidth:Ne.info.aes.lineWidth,strokeDasharray:td(Ne.info.aes.lineShape)})},Xe))}),g.show&&O&&le.jsx(oc,{content:l9t(O,A,g==null?void 0:g.content),x:r.x(O.x),y:r.y(O.y),active:!0,sideDistances:oe,container:b})]})}function A9t({settingsId:e,chartSettings:t,chartSizes:n,chartsDimensions:r,facetKeys:a,facetSettings:i,scales:o,groupedDots:s,legendData:c,trendsData:f,columnsCount:A,margins:h,keyColumn:m,mainTitle:g,facetTitles:b,captionsSizes:C,onlyPositive:x,layersData:k,aesGetters:_}){let[D,O]=Vn.useState(),I=Vn.useRef(null);Vn.useEffect(()=>{I.current&&O(I.current)},[]);let{xAxis:$,yAxis:Q,title:ee,frame:K,legend:re,tooltips:U}=t,G=r[a[0]].padding,Z=r[a[A-1]].padding,Y=n.chartsWidth+yP,X=G.top;return le.jsx(f2,{dataId:e,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${n.totalWidth} ${n.totalHeight}`,width:n.totalWidth,height:n.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${h.left},${h.top})`,fontFamily:"Manrope",children:[le.jsx(d2,{title:g,show:ee.show,position:ee.position,leftPadding:G.left,rightPadding:Z.right,chartsWidth:n.chartsWidth}),a.map(oe=>le.jsx(d9t,{scales:{x:o.x[oe],y:o.y[oe]},width:n.chartWidth,height:n.chartHeight,dimensions:r[oe],margins:h,chartSizes:n,facetSettings:i,xAxis:$,yAxis:Q,frameType:K.type,dotsData:s[oe],trendsData:f?f[oe]:null,tooltips:U,tooltipsContainer:D,keyColumn:m,facetTitle:b[oe],captionsSizes:C,layersData:k[oe],onlyPositive:x,aesGetters:_},oe)),re.show&&le.jsx("g",{transform:`translate(${Y},${X})`,children:le.jsx(y9,{legendData:c})})]}),le.jsx("g",{ref:I})]})})}function p9t(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function h9t(e,t,n,r,a,i,o){let s=i.includes("left")||!(o!=null&&o.sharedY),c=i.includes("left")&&t.title!=="",f=i.includes("bottom")||!(o!=null&&o.sharedX),A=i.includes("bottom")&&e.title!=="",h=n.yAxisCaptionsWidth+2*gP,m=(t.showTicks?t2:0)+gP,g=c?u9+Rm:0,b=n.xAxisCaptionsWidth+2*gP,C=e.showTicks?t2:0,x=A?u9+Rm:0,k=h+m+g+LX,_=b+C+x+LX,D=Math.max(...r.map(O=>a[O].length));return{left:s?k:Rm,top:D===0?0:p3t*2+D*m9,bottom:f?_+8:Rm,right:Rm}}function m9t(e,t,n){let r=[];for(let a=0;a<t;a++)r.push(e.slice(a*n,a*n+n));return r}function v9t(e,t){let n=Math.floor(e/t),r=e-n*t;return[n,r]}function g9t(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e&&e.type==="grouping"}function v2(e,t){return function(n,r){var a,i;if($m(n)&&t==="dotSize"){let{domain:o,range:s}=n,c=Ny().domain(o).range(s)(Number(r[n.columnName.value]));return Math.max(1,c)}if($m(n)&&(t==="dotFill"||t==="lineColor")){let{domain:o,range:s,type:c="linear"}=n;return J8(s,o,c)(Number(r[n.columnName.value]))}if(g9t(n)){let o=n.value;return(i=((a=e[o])==null?void 0:a[String(r[o])])??hP)==null?void 0:i[t]}return n}}function y9t(e){return{dotShape:v2(e,"dotShape"),dotColor:v2(e,"dotFill"),dotSize:v2(e,"dotSize"),lineShape:v2(e,"lineShape"),lineColor:v2(e,"lineColor"),trendColor:v2(e,"dotFill")}}var w9t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"margins",{top:qf,bottom:qf,left:qf,right:qf});Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:{null:Da().domain([0,10]).range([0,600])},y:{null:Da().domain([0,10]).range([350,0])}});Me(this,"captionsSizes",{xAxisCaptionsWidth:30,yAxisCaptionsWidth:100});Me(this,"facetTitles",{});Me(this,"mainTitle",[]);Me(this,"legend",{width:0,height:0,items:[]})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateChartSizes(e){this.chartSizes.chartWidth=e.width,this.chartSizes.chartHeight=e.height}updateChartDimensions(e,t,n,r){let{chartWidth:a,chartHeight:i}=this.chartSizes,o=0,s=0;this.chartsDimensions=e.reduce((A,h,m)=>{let[g,b]=v9t(m,this.columnsCount),C=p9t(m,e.length,this.columnsCount,this.rowsCount),x=h9t(n,r,this.captionsSizes,m9t(e,this.rowsCount,this.columnsCount)[g],this.facetTitles,C,t),k=a+x.left+x.right,_=i+x.top+x.bottom;return A[h]={left:o,top:s,chartEdgeSides:C,padding:x,inner:{width:a,height:i},outer:{width:k,height:_}},o+=k,b===this.columnsCount-1&&(o=0,s+=_),A},{});let c=Math.max(...e.map(A=>this.chartsDimensions[A].outer.width+this.chartsDimensions[A].left)),f=Math.max(...e.map(A=>this.chartsDimensions[A].outer.height+this.chartsDimensions[A].top));this.chartSizes.chartsWidth=c,this.chartSizes.chartsHeight=f}updateViewport(e,t,n,r,a,i){let o=e.length,s=Math.min(t.nRows??o,o),c=Math.min(t.nCols??o,o);this.columnsCount=t.nRows?Math.ceil(o/s):c,this.rowsCount=Math.ceil(o/this.columnsCount);let[f,A]=[1/0,-1/0],[h,m]=[1/0,-1/0],g=e.reduce((C,x)=>{let k=a[x],{minX:_,minY:D,maxX:O,maxY:I}=k;return f=Math.min(f,_),h=Math.min(h,D),A=Math.max(A,O),m=Math.max(m,I),C[x]={minX:_,maxX:O,minY:D,maxY:I},C},{});e.forEach(C=>{let x=n.scale==="log"?Rv():Da(),k=g[C],_=n.lowerValue?Number(n.lowerValue):t.sharedX?f:k.minX,D=n.upperValue?Number(n.upperValue):t.sharedX?A:k.maxX;if(typeof n.symmetricRange<"u"){let $=n.symmetricRange;if($>=_&&$<=D){let Q=Math.max($-_,D-$);_=$-Q,D=$+Q}}let O=[0,this.chartSizes.chartWidth],I=x.copy().domain([_,D]).range([L8.LEFT,this.chartSizes.chartWidth-L8.RIGHT]);x.domain([I.invert(0),I.invert(this.chartSizes.chartWidth)]).range(O).nice(),this.scales.x[C]=x});let b=e.reduce((C,x)=>{let k=i?i[x]:[];return C[x]=k.reduce((_,D)=>{let O=D.bounded?D.xBounds:this.scales.x[x].domain(),I=D.getInterval(O[0]),$=D.getInterval(O[1]);return _.minY=Math.min(_.minY,isNaN(I.left)?_.minY:I.left,isNaN($.left)?_.minY:$.left),_.maxY=Math.max(_.maxY,isNaN(I.right)?_.maxY:I.right,isNaN($.right)?_.maxY:$.right),_},{minY:1/0,maxY:-1/0}),h=Math.min(h,C[x].minY),m=Math.max(m,C[x].maxY),C},{});e.forEach(C=>{let x=r.scale==="log"?Rv():Da(),k=g[C],_=b[C],D=r.lowerValue?Number(r.lowerValue):t.sharedY?h:Math.min(k.minY,_.minY),O=r.upperValue?Number(r.upperValue):t.sharedY?m:Math.max(k.maxY,_.maxY);if(typeof r.symmetricRange<"u"){let Q=r.symmetricRange;if(Q>=D&&Q<=O){let ee=Math.max(Q-D,O-Q);D=Q-ee,O=Q+ee}}let I=[this.chartSizes.chartHeight,0],$=x.copy().domain([D,O]).range([this.chartSizes.chartHeight-L8.BOTTOM,L8.TOP]);x.domain([$.invert(this.chartSizes.chartHeight),$.invert(0)]).range(I).nice(),this.scales.y[C]=x})}updateCaptionsSize(e){let t=new Dc("600 14px Arial"),n=0;function r(a){return Math.max(...a.map(i=>t.getTextWidth(i)))}Object.values(this.scales.y).forEach(a=>{let{ticks:i,format:o}=b9(a,e);n=Math.max(n,r(i.map(o)))}),this.captionsSizes={xAxisCaptionsWidth:20,yAxisCaptionsWidth:n}}createMainTitle(e,t){let n=this.chartsDimensions[e[0]],r=this.chartsDimensions[e[e.length-1]];this.mainTitle=Om(t.name,this.chartSizes.chartsWidth-n.padding.left-r.padding.right,20)}createFacetTitles(e,t){this.facetTitles=e.reduce((n,r,a)=>(t[a].length===1&&t[a][0]==="null"?n[r]=[]:n[r]=Om(t[a].join(", "),this.chartSizes.chartWidth,14),n),{})}updateMargins(){let e=24*this.mainTitle.length,t=e>0?e+24*2:0;this.margins={top:Math.max(t,qf),bottom:qf,left:qf,right:this.legend.width},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight,this.legend.height)+this.margins.bottom}updateLegendSize(e,t,n,r){if(!e.show){this.legend={width:0,height:0,items:[]};return}let a=[],i={width:0,height:0,left:0,top:0};if(n.forEach(A=>{let h=t[A.value];if(h.usedAes.length===0||!h.aesMap)return;let m={};h.values.forEach(C=>{m[C]||(m[C]={...mP}),h.usedAes.forEach(x=>{var k,_,D;(x==="dotFill"||x==="lineColor")&&(m[C].color=((k=h.aesMap[C])==null?void 0:k[x])??Zt),x==="dotShape"&&(m[C].shape=((_=h.aesMap[C])==null?void 0:_[x])??"21"),x==="dotSize"&&(m[C].size=((D=h.aesMap[C])==null?void 0:D[x])??3)})});let g=A.label??A.value,b=Hl().domain(h.values).range(h.values.map(C=>m[C]));a.push({...i,id:A.value,type:"dots",title:g,scale:b,values:h.values,labels:h.labels})}),r.forEach(A=>{if(A.type==="dots"&&$m(A.aes.dotFill)){let{domain:h,range:m,columnName:g,type:b="linear"}=A.aes.dotFill,C=g.label??g.value,x=J8(m,h,"linear"),k=(b==="log"?q1():Da()).domain(h).range([height,0]),_=a2(k,h);a.push({...i,id:"dotFill",type:"continuous",title:C,scale:x,tickPositionScale:k,values:_})}if(A.type==="dots"&&$m(A.aes.dotSize)){let{columnName:h,domain:m,range:g}=A.aes.dotSize,b=h.label??h.value,C=Ny(m,g),x=C.ticks(3),k=C.tickFormat(3),_=x.reduce((D,O)=>(D[String(O)]=k(O),D),{});a.push({...i,id:h.value,type:"size",title:b,scale:C,values:x,labels:_})}}),!a.length){this.legend={width:0,height:0,items:[]};return}let o=w9(a,this.chartSizes.chartHeight),s=o[o.length-1],c=s.left+s.width+2*yP,f=this.chartSizes.chartHeight;this.legend={width:c,height:f,items:o}}render(e,t,n,r,a,i,o,s,c,f,A,h,m,g){var O;let{xAxis:b,yAxis:C,size:x,title:k,legend:_}=t;this.updateChartSizes(x),this.updateViewport(r,n,b,C,i,o),this.updateCaptionsSize(c.y),this.createFacetTitles(r,a),this.updateChartDimensions(r,n,b,C),this.updateLegendSize(_,f,m,g),this.createMainTitle(r,k),this.updateMargins();let D=le.jsx(A9t,{settingsId:e,chartSettings:t,facetKeys:r,facetSettings:n,chartSizes:this.chartSizes,chartsDimensions:this.chartsDimensions,scales:this.scales,groupedDots:i,trendsData:o,legendData:this.legend,columnsCount:this.columnsCount,margins:this.margins,keyColumn:s,mainTitle:this.mainTitle,facetTitles:this.facetTitles,captionsSizes:this.captionsSizes,onlyPositive:c,layersData:A,aesGetters:y9t(h)});this.component=D,(O=this.reactRoot)==null||O.render(D)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},C9t=w9t,b9t=class{constructor(e){Me(this,"type","dots");Me(this,"aes",{dotFill:Zt,dotShape:"21",dotSize:3,opacity:1});this.aes={...this.aes,...e.aes}}},E9t=class{constructor(e){Me(this,"type","curve");Me(this,"smoothing");Me(this,"aes",{lineColor:Zt,lineWidth:1,lineShape:"solid",opacity:1});this.smoothing=e.smoothing??!1,this.aes={...this.aes,...e.aes}}},uZ=class{constructor(e){Me(this,"id");Me(this,"type","scatterplot");Me(this,"keyColumn");Me(this,"facetSettings");Me(this,"x");Me(this,"y");Me(this,"facetBy");Me(this,"grouping");Me(this,"label");Me(this,"chartSettings");Me(this,"inheritedAes");Me(this,"trend");Me(this,"layers");var t,n,r,a;W3t.parse(e),this.id=Ir.uniqueId("settings"),this.keyColumn=e.keyColumn,this.facetSettings={sharedX:!0,sharedY:!0,titlePosition:"left",...e.facetSettings},this.x=e.x,this.y=e.y,this.facetBy=e.facetBy??[],this.grouping=e.grouping??[],this.label=e.label??null,this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(this.facetBy.length?400:600),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(this.facetBy.length?250:350)},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},yAxis:{title:e.y.label??e.y.value,scale:"linear",showGrid:!0,showTicks:!0,...e.yAxis},xAxis:{title:e.x.label??e.x.value,scale:"linear",showGrid:!0,showTicks:!0,...e.xAxis},frame:{type:((a=e.frame)==null?void 0:a.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.inheritedAes=e.inheritedAes??{},this.trend=e!=null&&e.trend?{bounded:e.trend.bounded??!1,color:e.trend.color??Zt}:null,this.layers=e.layers.map(i=>{if(i.type==="dots")return new b9t(i);if(i.type==="curve")return new E9t(i);vA(i,"Unknown layer type")}).filter(Boolean)}},x9t=oht(r3t()),cZ=.05;function S9t(e){let t=3.3871328727963665,n=133.14166789178438,r=1971.5909503065513,a=13731.69376550946,i=45921.95393154987,o=67265.7709270087,s=33430.57558358813,c=2509.0809287301227,f=42.31333070160091,A=687.1870074920579,h=5394.196021424751,m=21213.794301586597,g=39307.89580009271,b=28729.085735721943,C=5226.495278852854,x=1.4234371107496835,k=4.630337846156546,_=5.769497221460691,D=3.6478483247632045,O=1.2704582524523684,I=.2417807251774506,$=.022723844989269184,Q=.0007745450142783414,ee=2.053191626637759,K=1.6763848301838038,re=.6897673349851,U=.14810397642748008,G=.015198666563616457,Z=.0005475938084995345,Y=10507500716444169e-25,X=6.657904643501103,oe=5.463784911164114,me=1.7848265399172913,ae=.29656057182850487,ye=.026532189526576124,Ce=.0012426609473880784,ce=27115555687434876e-21,ge=20103343992922881e-23,ze=.599832206555888,Ne=.1369298809227358,Ge=.014875361290850615,Oe=.0007868691311456133,Xe=18463183175100548e-21,dt=1421511758316446e-22,Ye=20442631033899397e-31,rt=e-.5,He,$e;return Math.abs(rt)<=.425?(He=.180625-rt*rt,$e=rt*(((((((c*He+s)*He+o)*He+i)*He+a)*He+r)*He+n)*He+t)/(((((((C*He+b)*He+g)*He+m)*He+h)*He+A)*He+f)*He+1),$e):(He=e,He=Math.sqrt(-Math.log(He)),He<=5?(He+=-1.6,$e=(((((((Q*He+$)*He+I)*He+O)*He+D)*He+_)*He+k)*He+x)/(((((((Y*He+Z)*He+G)*He+U)*He+re)*He+K)*He+ee)*He+1)):(He+=-5,$e=(((((((ge*He+ce)*He+Ce)*He+ye)*He+ae)*He+me)*He+oe)*He+X)/(((((((Ye*He+dt)*He+Xe)*He+Oe)*He+Ge)*He+Ne)*He+ze)*He+1)),$e=-$e,$e)}function fZ(e,t){let{sin:n,cos:r,sqrt:a,pow:i,exp:o,PI:s}=Math,c,f;if(t==1)return r(e*s/2)/n(e*s/2);if(t==2)return a(2/(e*(2-e))-2);let A=1/(t-.5),h=48/(A*A),m=((20700*A/h-98)*A-16)*A+96.36,g=((94.5/(h+m)-3)/h+1)*a(A*s*.5)*t;return c=g*e,f=i(c,2/t),f>.05+A?(c=S9t(e/2),f=c*c,t<5&&(m=m+.3*(t-4.5)*(c+.6)),m=(((.05*g*c-5)*c-7)*c-2)*c+h+m,f=(((((.4*f+6.3)*f+36)*f+94.5)/m-f-3)/h+1)*c,f=A*f*f,f>.002?f=o(f)-1:f=.5*f*f+f):f=((1/(((t+6)/(t*f)-.089*g-.822)*(t+2)*3)+.5/(t+4))*f-1)*(t+1)/(t+2)+1/f,a(t*f)}function B9t(e){let t=e.length,n=0,r=0,a=0,i=0;for(let c=0;c<e.length;++c){let f=e[c].x,A=e[c].y;if(!Number.isFinite(f)||!Number.isFinite(A)){--t;continue}n+=f,r+=A,a+=f*A,i+=f*f}let o=(t*a-n*r)/(t*i-n*n),s=(r-o*n)/t;return[o,s]}function k9t(e,t,n){let r=A=>A*t+n,a=e.length,i=Sc(e,A=>A.x)/e.length,o=fZ(cZ,a-2),s=Math.sqrt(Sc(e,A=>(A.y-r(A.x))**2)/(a-2)/Sc(e,A=>(A.x-i)**2)),c=s*o,f=s*Math.sqrt(Sc(e,A=>A.x**2)/a)*o;return{slope:t,intercept:n,slopeError:c,interceptError:f}}function T9t(e,t){let n=Sc(e,s=>s.x)/e.length,r=0,a=0;for(let s=0;s<e.length;++s)r+=Math.pow(e[s].x-n,2),a+=Math.pow(e[s].y-t(e[s].x),2);let i=Math.sqrt(a/(e.length-2)),o=fZ(cZ,e.length-2);return function(s){let c=t(s),f=i*Math.sqrt(1/e.length+Math.pow(s-n,2)/r),A=c-o*f,h=c+o*f;return{x:s,y:c,left:isNaN(A)?c:A,right:isNaN(h)?c:h}}}function _9t(e){let t=e.length;return Math.pow((t*Sc(e,n=>n.x*n.y)-Sc(e,n=>n.x)*Sc(e,n=>n.y))/(Math.sqrt(t*Sc(e,n=>n.x*n.x)-Math.pow(Sc(e,n=>n.x),2))*Math.sqrt(t*Sc(e,n=>n.y*n.y)-Math.pow(Sc(e,n=>n.y),2))),2)}function P9t(e,t){let n=tu(e,t);return tu(e.map(r=>(t(r)-n)**2))}function dZ(e,t){return Math.sqrt(P9t(e,t))}function M9t(e,t,n){let r=tu(e,t),a=tu(e,n),i=e.length;return Sc(e,o=>(o.x-r)*(o.y-a))/i}function D9t(e){let t=M9t(e,a=>a.x,a=>a.y),n=dZ(e,a=>a.x),r=dZ(e,a=>a.y);return t/(n*r)}function H9t(e,t){let n=e.length,r=1,a=1,i=n-r-1,o=tu(e,m=>m.y),s=Sc(e,m=>(t(m.x)-o)**2),c=Sc(e,m=>(t(m.x)-m.y)**2),f=s/a,A=c/i,h=f/A;return 1-(0,x9t.default)(h,a,i)}function I9t(e,t,n,r,a){return a?t.reduce((i,o)=>{let s=e[o].dots;return i[o]=n.map(c=>{let f=s.filter(x=>r.every((k,_)=>String(x.data[k.value])===c[_])),[A=0,h=0]=$A(f,x=>x.x),[m,g]=B9t(f),b=x=>m*x+g,C=T9t(f,b);return{predict:b,getInterval:C,getArea:(x,k,_)=>VB().x(D=>x(D.x)).y0(D=>k(D.left)).y1(D=>k(D.right))(_.map(C))??"",color:a.color,bounded:a.bounded,data:f[0].data,showStats:!0,xBounds:[A,h],stats:{r2:_9t(f),r:D9t(f),pValue:H9t(f,b),coefficients:k9t(f,m,g)}}}),i},{}):null}function AZ(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}function pZ(e){return typeof e=="object"&&"type"in e&&e.type==="grouping"}function L9t(e,t,n,r){return t.reduce((a,i)=>{let o=Ir.uniqBy(e.rows,h=>h[i.value]),s=h=>String(h[i.value]),c=h=>i.valueLabels?String(h[i.valueLabels]):s(h),f=new Set;n.forEach(h=>{h.aes&&Object.entries(h.aes).forEach(([m,g])=>{pZ(g)&&g.value===i.value&&f.add(m)})});let A=o.reduce((h,m)=>(h[s(m)]=c(m),h),{});return a[i.value]={values:o.map(s).filter(h=>h!=="null").sort((h,m)=>A[h].localeCompare(A[m],"en",{numeric:!0})),usedAes:[...f],aesMap:r[i.value],labels:A},a},{})}var R9t=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new C9t);Me(this,"calculatedData",null);this.settings=new uZ(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new uZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for scatterplot")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.facetBy.some((s,c)=>{var f;return s.value!==((f=n.facetBy[c])==null?void 0:f.value)})||t.grouping.length!==n.grouping.length||t.grouping.some((s,c)=>{var f;return s.value!==((f=n.grouping[c])==null?void 0:f.value)})||(((r=t.label)==null?void 0:r.value)||((a=n.label)==null?void 0:a.value))&&((i=t.label)==null?void 0:i.value)!==((o=n.label)==null?void 0:o.value)||t.layers.length!==n.layers.length||t.layers.some((s,c)=>s.type!==n.layers[c].type)||!!t.trend!=!!n.trend}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{x:t,y:n,facetBy:r,grouping:a,keyColumn:i,trend:o,layers:s,inheritedAes:c,label:f}=this.settings,A=this.data.getColumnCategories(i.value),h=r.map($=>this.data.getColumnCategories($.value)),m=a.map($=>this.data.getColumnCategories($.value)),g=h.length?AZ([...h]):[["null"]],b=m.length?AZ([...m]):[["null"]],C=r.map($=>$.value)??null;this.data.setGrouping([...C,i.value]);let x={x:this.data.rows.every($=>{let Q=$[t.value];return Q===null||!(Number(Q)<0)}),y:this.data.rows.every($=>{let Q=$[n.value];return Q===null||!(Number(Q)<0)})},k=Gwt(this.data,g,t,n,f,A),_=Object.keys(k),D=I9t(k,_,b,a,o),O=L9t(this.data,a,s,c),I=Ywt(s,_,k,b,a);this.calculatedData={onlyPositive:x,dotsByFacets:k,facetKeys:_,facetKeysCombinations:g,trendsData:D,legendLabels:O,layersData:I}}_updateAesInData(){let t=this.calculatedData;if(!t)return;let{grouping:n,trend:r,layers:a,inheritedAes:i}=this.settings,{facetKeys:o,trendsData:s}=t;o.forEach(c=>{for(let f=0;f<a.length;f++)t.layersData[c][f].info=a[f]}),n.forEach(c=>{let f=new Set;a.forEach(A=>{A.aes&&Object.entries(A.aes).forEach(([h,m])=>{pZ(m)&&m.value===c.value&&f.add(h)})}),t.legendLabels[c.value].usedAes=[...f],t.legendLabels[c.value].aesMap=i[c.value]}),s&&r&&Object.keys(s).forEach(c=>{s[c].forEach(f=>{f.color=r.color,f.bounded=r.bounded})})}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,facetSettings:r,grouping:a,keyColumn:i,inheritedAes:o,layers:s}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.facetKeys,this.calculatedData.facetKeysCombinations,this.calculatedData.dotsByFacets,this.calculatedData.trendsData,i,this.calculatedData.onlyPositive,this.calculatedData.legendLabels,this.calculatedData.layersData,o,a,s)}},nE={TOP:30,BOTTOM:30,LEFT:30,RIGHT:30},E9=20,hZ=4,$P=24;function N9t(e,t,n=[]){let r=e.data,a=[`x: ${Ki(e.x)}`,`y: ${Ki(e.y)}`];t.label&&a.unshift(`${t.label}: ${r[t.label]}`);for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function mZ(e){return typeof e=="string"?e:e.label??e.value}var vZ=d3().curve(A3);function $9t({scales:e,chartSettings:t,mainTitle:n,keyColumn:r,margins:a,chartSizes:i,onlyPositive:o,container:s,zoomStateKey:c,legendData:f,dotsByGrouping:A,layers:h,aesGetters:m,selectedDot:g=null}){var G;let{title:b,xAxis:C,yAxis:x,frame:k,legend:_}=t,D=C.showTicks?hZ:0,O=x.showTicks?hZ:0,I=C.title,$=x.title,Q={left:0,right:i.chartWidth,top:0,bottom:i.chartHeight};if(!s)return null;let ee=h.find(Z=>Z.type==="curve"),[K,re]=Vn.useState([]);function U(){let Z=Object.entries(A).map(([Y,X])=>({key:Y,d:ee!=null&&ee.smoothing?vZ(X)??"":X.map(oe=>`${e.x(oe.x)},${e.y(oe.y)}`).join(" "),dot:X[0]}));re(Z)}return Vn.useEffect(()=>{ee&&(vZ.x(Z=>e.x(Z.x)).y(Z=>e.y(Z.y)),U())},[c]),Vn.useEffect(()=>{ee&&U()},[ee==null?void 0:ee.smoothing]),le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${i.totalWidth} ${i.totalHeight}`,width:i.totalWidth,height:i.totalHeight,style:{pointerEvents:"none"},children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${a.left},${a.top})`,fontFamily:"Manrope",children:[le.jsx("clipPath",{id:"viewportClipPath",children:le.jsx("rect",{x:"0",y:"0",width:i.chartWidth,height:i.chartHeight})}),le.jsx(d2,{title:n,show:b.show,position:b.position,leftPadding:a.left,rightPadding:a.right,chartsWidth:i.chartWidth}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[I&&le.jsx("text",{x:i.chartWidth/2,y:i.chartHeight+a.bottom-E9/2,children:mZ(I)}),$&&le.jsx("text",{x:-a.left+E9/2,y:i.chartHeight/2,transform:`rotate(-90,${-a.left+E9/2},${i.chartHeight/2})`,children:mZ($)})]}),le.jsx(eZ,{width:i.chartWidth,height:i.chartHeight,scaleX:e.x,scaleY:e.y,axisX:C,axisY:x,updatingKey:c,frameType:k.type}),le.jsx("g",{transform:`translate(0,${i.chartHeight})`,children:le.jsx(tE,{scale:e.x,orient:"bottom",onlyPositive:o.x,tickSize:D})}),le.jsx("g",{children:le.jsx(tE,{scale:e.y,orient:"left",onlyPositive:o.y,tickSize:O})}),ee&&ee.smoothing&&le.jsx("g",{clipPath:"url(#viewportClipPath)",children:K.map(({key:Z,d:Y,dot:X})=>le.jsx("path",{d:Y,fill:"none",stroke:m.dotFill(X.data),strokeWidth:ee.aes.lineWidth,strokeDasharray:m.lineType(X.data)},Z))}),ee&&!ee.smoothing&&le.jsx("g",{clipPath:"url(#viewportClipPath)",children:K.map(({key:Z,d:Y,dot:X})=>le.jsx("polyline",{points:Y,fill:"none",stroke:m.dotFill(X.data),strokeWidth:ee.aes.lineWidth,strokeDasharray:m.lineType(X.data)},Z))}),g&&le.jsx(oc,{content:N9t(g,r,(G=t.tooltips)==null?void 0:G.content),x:e.x(g.x),y:e.y(g.y),active:!0,sideDistances:Q,container:s}),_.show&&le.jsx("g",{transform:`translate(${i.chartWidth+$P},0)`,children:le.jsx(y9,{legendData:f})})]})]})}var F9t=gb.memo($9t),V9t=20;function O9t({scales:e,chartSizes:t,disabled:n,onPolygonUpdate:r}){let[a,i]=Vn.useState([]),[o,s]=Vn.useState(null),[c,f]=Vn.useState(null),A=Vn.useRef(null),h=Vn.useRef(null),m=Vn.useRef(null),g=Vn.useRef(a);function b(){A.current=null,h.current=null,m.current=null,g.current=[],i([]),s(null)}function C(_){n||_.key!=="Escape"||b()}Vn.useEffect(()=>{n&&(A.current=null,h.current=null,m.current=null,s(null))},[n]),Vn.useEffect(()=>(document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)),[]),Vn.useEffect(()=>{if(o&&c)return;if(a.length===0){r([]);return}let _=a.map(D=>D[0]);_.push(a[a.length-1][1]),r(_)},[a]);function x(){if(!A.current||n)return;let _=[...A.current],D=e.x.invert(_[0]),O=e.y.invert(_[1]),I=g.current,$=m.current,Q=h.current&&I.length>1?Math.sqrt((_[0]-h.current[0])**2+(_[1]-h.current[1])**2):1/0;m.current?m.current&&Q>V9t?(I=[...I,[m.current,[D,O]]],$=[D,O]):(I=[...I,[m.current,[D,O]]],I.length>2&&(I=[...I,[I[I.length-1][1],I[0][0]]]),$=null,I.length<=2?r([]):r(I.map(ee=>ee[0])),h.current=null):(h.current=_,I=[],$=[D,O],r([])),i(I),s($),g.current=I,m.current=$}function k(_){let D=[_.nativeEvent.offsetX,_.nativeEvent.offsetY];f(D),A.current=D}return le.jsxs("g",{children:[le.jsx("rect",{fill:"transparent",width:t.chartWidth,height:t.chartHeight,onMouseMove:k,onClick:x}),a.map(([_,D],O)=>le.jsx("line",{x1:e.x(_[0]),y1:e.y(_[1]),x2:e.x(D[0]),y2:e.y(D[1]),stroke:Zt,style:{pointerEvents:"none"}},O)),o&&c&&le.jsx("line",{x1:e.x(o[0]),y1:e.y(o[1]),x2:c[0],y2:c[1],stroke:Zt,style:{pointerEvents:"none"}},"lastLine")]})}function Q9t({scales:e,container:t,labels:n,aesGetters:r,chartSizes:a,onPolygonUpdate:i,lassoMode:o,selectedDot:s=null}){return t?le.jsxs("g",{children:[n.map(c=>{let{name:f,height:A,bbox:h,width:m}=c;return le.jsx("g",{children:le.jsxs("g",{transform:`translate(${h.minX},${h.minY})`,children:[le.jsx("rect",{x:"0",y:"0",width:m,height:A,fill:"transparent",stroke:"none"}),le.jsx("text",{x:0,y:A/2,stroke:"white",strokeWidth:2,paintOrder:"stroke",style:{pointerEvents:"none"},fontFamily:"Manrope",fontSize:"16px",dominantBaseline:"middle",children:f})]})},c.dot.id)}),le.jsx(O9t,{scales:e,chartSizes:a,disabled:!o,onPolygonUpdate:i}),s&&le.jsx("circle",{cx:e.x(s.x),cy:e.y(s.y),r:5,fill:r.dotFill(s.data)})]}):null}var z9t=Q9t;function U9t({settingsId:e,scales:t,chartSettings:n,mainTitle:r,keyColumn:a,margins:i,chartSizes:o,captionsSizes:s,onlyPositive:c,container:f,zoomStateKey:A,aesGetters:h,legendData:m,labels:g,onPolygonUpdate:b,lassoMode:C,dotsByGrouping:x,layers:k,selectedDot:_=null}){return f?le.jsx("div",{children:le.jsxs(f2,{dataId:e,children:[le.jsx(F9t,{aesGetters:h,dotsByGrouping:x,layers:k,scales:t,keyColumn:a,margins:i,mainTitle:r,captionsSizes:s,chartSettings:n,chartSizes:o,onlyPositive:c,container:f,selectedDot:_,zoomStateKey:A,legendData:m}),HB.createPortal(le.jsx(z9t,{scales:t,container:f,aesGetters:h,labels:g,chartSizes:o,selectedDot:_,onPolygonUpdate:b,lassoMode:C}),f)]})}):null}var gZ=e=>e.selection()!==e,yZ=(e,t)=>{e=e||"g";let n=(i,o)=>o,r=null,a=function(i,o){o=o||(g=>g);let s=i.selection(),c=gZ(i)?i:null,f=s.selectChildren(t==null?e:`${e}.${t}`).data(o,n),A=f.enter().append(e).attr("class",t),h=f.exit();f=f.merge(A);let m=c||r;return m&&(f=f.transition(m).style("opacity",1),A.style("opacity",1e-6),h=h.transition(m).style("opacity",1e-6)),h.remove(),f.enter=()=>A,f.exit=()=>h,f};return a.element=(...i)=>i.length?(e=i[0],a):e,a.className=(...i)=>i.length?(t=i[0],a):t,a.key=(...i)=>i.length?(n=i[0],a):n,a.transition=(...i)=>i.length?(r=i[0],a):r,a},wZ=(e,t,n)=>{let r=t[n];if(typeof r!="function")throw new Error(`Attempt to rebind ${n} which isn't a function on the source object`);return(...a)=>{var i=r.apply(t,a);return i===t?e:i}},CZ=(e,t,...n)=>{for(let r of n)e[r]=wZ(e,t,r);return e},j9t=e=>t=>e.reduce((n,r)=>n&&r(n),t),FP=(e,t,...n)=>{let r=j9t(n);for(let a of Object.keys(t)){let i=r(a);i&&(e[i]=wZ(e,t,a))}return e},G9t=e=>e.map(t=>typeof t=="string"?new RegExp(`^${t}$`):t),Y9t=(...e)=>(e=G9t(e),t=>e.every(n=>!n.test(t))&&t),g2=e=>typeof e=="function"?e:()=>e;function W9t(){let e=arguments;return function(t,n){for(let r=0,a=e.length;r<a;r++)if(e[r](t,n)==null)return!1;return!0}}var X9t=(e,t)=>{switch(e){case"left":return t/2;case"right":return-t/2;default:return 0}},bZ=e=>{let t=Object.assign({},e),n=()=>{};return Object.keys(t).forEach(r=>{n[r]=(...a)=>a.length?(t[r]=a[0],n):t[r]}),n},K9t=()=>{let e=()=>0,t=s=>s.x,n=s=>s.y,r="center",a=()=>5,i="vertical",o=bZ({decorate:()=>{},defined:(s,c)=>W9t(e,t,n)(s,c),xScale:J1(),yScale:J1()});return o.values=(s,c)=>{let f=a(s,c),A=X9t(r,f),h=o.xScale(),m=o.yScale();if(i==="vertical"){let g=m(n(s,c),c),b=m(e(s,c),c),C=h(t(s,c),c)+A;return{d:s,x:C,y:g,y0:b,width:f,height:g-b,origin:[C,g],baseOrigin:[C,b],transposedX:C,transposedY:g}}else{let g=h(n(s,c),c),b=h(e(s,c),c),C=m(t(s,c),c)+A;return{d:s,x:C,y:g,y0:b,width:f,height:g-b,origin:[g,C],baseOrigin:[b,C],transposedX:g,transposedY:C}}},o.xValues=()=>i==="vertical"?[t]:[e,n],o.yValues=()=>i!=="vertical"?[t]:[e,n],o.baseValue=(...s)=>s.length?(e=g2(s[0]),o):e,o.crossValue=(...s)=>s.length?(t=g2(s[0]),o):t,o.mainValue=(...s)=>s.length?(n=g2(s[0]),o):n,o.bandwidth=(...s)=>s.length?(a=g2(s[0]),o):a,o.align=(...s)=>s.length?(r=s[0],o):r,o.orient=(...s)=>s.length?(i=s[0],o):i,o},Z9t=()=>{let e=K9t(),t=g2(64),n=X$,r=qw(),a=qw(),i=qw().type(nh.UNSIGNED_SHORT),o=qw().type(nh.UNSIGNED_BYTE),s=L0t().crossValueAttribute(r).mainValueAttribute(a).sizeAttribute(i).definedAttribute(o),c=(b,C)=>!1,f=z0t,A=[],h=null,m=null,g=b=>{let C=f(e.xScale()),x=f(e.yScale()),k=!c(A,b);k&&(A=b,i.value((_,D)=>t(_,D)).data(b),o.value((_,D)=>e.defined()(_,D)).data(b)),(k||C.scale!==h)&&(h=C.scale,e.orient()==="vertical"?r.value((_,D)=>C.scale(e.crossValue()(_,D))).data(b):r.value((_,D)=>C.scale(e.mainValue()(_,D))).data(b)),(k||x.scale!==m)&&(m=x.scale,e.orient()==="vertical"?a.value((_,D)=>x.scale(e.mainValue()(_,D))).data(b):a.value((_,D)=>x.scale(e.crossValue()(_,D))).data(b)),s.xScale(C.webglScale).yScale(x.webglScale).type(K0t(n)).decorate(_=>e.decorate()(_,b,0)),s(b.length)};return g.size=(...b)=>b.length?(t=g2(b[0]),g):t,g.type=(...b)=>b.length?(n=b[0],g):n,g.equals=(...b)=>b.length?(c=b[0],g):c,g.scaleMapper=(...b)=>b.length?(f=b[0],g):f,FP(g,e,Y9t("baseValue","bandwidth","align")),CZ(g,s,"context","pixelRatio"),g},EZ=()=>{let e=[],t=a=>a,n=(a,i)=>i,r=bZ({decorate:()=>{},xScale:J1(),yScale:J1()});return r.xValues=()=>e.map(a=>a.xValues()).reduce((a,i)=>a.concat(i)),r.yValues=()=>e.map(a=>a.yValues()).reduce((a,i)=>a.concat(i)),r.mapping=(...a)=>a.length?(t=a[0],r):t,r.key=(...a)=>a.length?(n=a[0],r):n,r.series=(...a)=>a.length?(e=a[0],r):e,r},J9t=()=>{let e=EZ(),t=yZ("g"),n=yZ("g","multi"),r=a=>{gZ(a)&&(n.transition(a),t.transition(a));let i=e.mapping(),o=e.series(),s=e.xScale(),c=e.yScale();a.each((f,A,h)=>{let m=n(iu(h[A]),o);m.each((g,b,C)=>{g.xScale(s).yScale(c);let x=i(f,b,o);t(iu(C[b]),[x]).call(g)}),m.selection().order(),e.decorate()(m,f,A)})};return FP(r,e),CZ(r,n,"key"),r},q9t=()=>{let e=null,t=1,n=EZ(),r=a=>{let i=n.mapping(),o=n.series(),s=n.xScale(),c=n.yScale();o.forEach((f,A)=>{let h=i(a,A,o);f.context(e).pixelRatio(t).xScale(s).yScale(c);let m;f.decorate?(m=f.decorate(),f.decorate((g,b,C)=>{n.decorate()(g,a,A),m(g,b,C)})):n.decorate()(e,a,A),f(h),m&&f.decorate(m)})};return r.context=(...a)=>a.length?(e=a[0],r):e,r.pixelRatio=(...a)=>a.length?(t=a[0],r):t,FP(r,n),r};function e4t(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e&&e.type==="grouping"}function rE(e={},t,n){return function(r){var a,i;if(e4t(n)){let o=n.value,s=r[o];return(i=((a=e[o])==null?void 0:a[String(s)])??hP)==null?void 0:i[t]}if($m(n)&&t==="dotFill"){let{domain:o,range:s,type:c="linear"}=n;return J8(s,o,c)(Number(r[n.columnName.value]))}return n}}var t4t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"canvasNode",null);Me(this,"svgLayerElement",null);Me(this,"svgLayerComponent",le.jsx(le.Fragment,{}));Me(this,"tools",null);Me(this,"margins",{top:qf,bottom:qf,left:qf,right:qf});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,totalWidth:600,totalHeight:350});Me(this,"scales",{x:Da().domain([0,10]).range([0,600]),y:Da().domain([0,10]).range([350,0]),xOriginal:Da().domain([0,10]).range([0,600]),yOriginal:Da().domain([0,10]).range([350,0])});Me(this,"polygon",[]);Me(this,"onPolygonUpdateOutside",()=>{});Me(this,"zoomStateKey","");Me(this,"selectedDot",null);Me(this,"captionsSizes",{xAxisCaptionsWidth:30,yAxisCaptionsWidth:100});Me(this,"mainTitle",[]);Me(this,"legend",{width:0,height:0,items:[]});Me(this,"notCalculatedProps",{});Me(this,"allPossibleLabels",[]);Me(this,"visibleLabels",[]);Me(this,"lassoMode",!1);Me(this,"onPolygonUpdate",e=>{this.polygon=e,this.updateByLasso(),this.onPolygonUpdateOutside(e)})}clear(){var e,t;this.parentNode&&this.rootNode&&this.canvasNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),(t=this.parentNode)==null||t.removeChild(this.canvasNode),this.parentNode=null,this.rootNode=null,this.canvasNode=null,this.svgLayerElement=null,this.tools=null),setTimeout(()=>{var n;(n=this.reactRoot)==null||n.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.canvasNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.parentNode.appendChild(this.canvasNode),this.reactRoot=zh(this.rootNode))}updateChartSizes(e){this.chartSizes.chartWidth=e.width,this.chartSizes.chartHeight=e.height}updateViewport(e,t,n){let r=e.scale==="log"?Rv():Da(),{minX:a,minY:i,maxX:o,maxY:s}=n;if(e.lowerValue!==void 0&&(a=Math.max(a,e.lowerValue)),e.upperValue!==void 0&&(o=Math.min(o,e.upperValue)),t.lowerValue!==void 0&&(i=Math.max(i,t.lowerValue)),t.upperValue!==void 0&&(s=Math.min(s,t.upperValue)),e.symmetricRange!==void 0){let g=e.symmetricRange;if(g>=a&&g<=o){let b=Math.max(g-a,o-g);a=g-b,o=g+b}}if(typeof t.symmetricRange<"u"){let g=t.symmetricRange;if(g>=i&&g<=s){let b=Math.max(g-i,s-g);i=g-b,s=g+b}}let c=[0,this.chartSizes.chartWidth],f=r.copy().domain([a,o]).range([nE.LEFT,this.chartSizes.chartWidth-nE.RIGHT]);r.domain([f.invert(0),f.invert(this.chartSizes.chartWidth)]).range(c).nice(),this.scales.x=r,this.scales.xOriginal=r.copy();let A=t.scale==="log"?Rv():Da(),h=[this.chartSizes.chartHeight,0],m=A.copy().domain([i,s]).range([this.chartSizes.chartHeight-nE.BOTTOM,nE.TOP]);A.domain([m.invert(this.chartSizes.chartHeight),m.invert(0)]).range(h).nice(),this.scales.y=A,this.scales.yOriginal=A.copy()}updateCaptionsSize(e){let t=new Dc("600 14px Arial");function n(o){return Math.max(...o.map(s=>t.getTextWidth(s)))}let{ticks:r,format:a}=b9(this.scales.y,e),i=n(r.map(a));this.captionsSizes={xAxisCaptionsWidth:20,yAxisCaptionsWidth:i}}createMainTitle(e){this.mainTitle=Om(e.name,this.chartSizes.totalWidth-this.margins.left-this.margins.right,20)}updateMargins(){let e=24*this.mainTitle.length,t=e>0?e+24*2:0;this.margins={top:Math.max(t,qf),bottom:qf+this.captionsSizes.xAxisCaptionsWidth+E9,left:qf+this.captionsSizes.yAxisCaptionsWidth+E9,right:this.legend.width+(this.legend.width>0?$P:0)+qf},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartHeight,this.legend.height)+this.margins.bottom,iu(this.canvasNode).style("width",this.chartSizes.chartWidth+"px").style("height",this.chartSizes.chartHeight+"px").style("top",this.margins.top+"px").style("left",this.margins.left+"px")}updateLegendSize(e,t,n,r){if(!e.show){this.legend={width:0,height:0,items:[]};return}let a=[],i={width:0,height:0,left:0,top:0};if(n.forEach(A=>{let h=t[A.value];if(h.usedAes.length===0||!h.aesMap)return;let m={};h.values.forEach(C=>{m[C]||(m[C]={...mP}),h.usedAes.forEach(x=>{var k,_;x==="dotFill"&&(m[C].color=((k=h.aesMap[C])==null?void 0:k[x])??Zt),x==="dotSize"&&(m[C].size=((_=h.aesMap[C])==null?void 0:_[x])??3)})});let g=A.label??A.value,b=Hl().domain(h.values).range(h.values.map(C=>m[C]));a.push({...i,id:A.value,type:"dots",title:g,scale:b,values:h.values,labels:h.labels})}),r.forEach(A=>{if(A.type==="dots"&&$m(A.aes.dotFill)){let{domain:h,range:m,columnName:g,type:b="linear"}=A.aes.dotFill,C=g.label??g.value,x=J8(m,h,"linear"),k=(b==="log"?q1():Da()).domain(h).range([height,0]),_=a2(k,h);a.push({...i,id:"dotFill",type:"continuous",title:C,scale:x,tickPositionScale:k,values:_})}}),!a.length){this.legend={width:0,height:0,items:[]};return}let o=w9(a,this.chartSizes.chartHeight),s=o[o.length-1],c=s.left+s.width+2*$P,f=this.chartSizes.chartHeight;this.legend={width:c,height:f,items:o}}initSettings(e,t,n,r,a,i,o,s){let{xAxis:c,yAxis:f,size:A,title:h,legend:m}=t;this.updateChartSizes(A),this.updateViewport(c,f,n),this.updateCaptionsSize(r.y),this.updateLegendSize(m,o,s,i),this.createMainTitle(h),this.updateMargins();let g=i.find($=>$.type==="dots"),b=i.find($=>$.type==="curve"),C={dotFill:rE(a,"dotFill",g.aes.dotFill),lineType:rE(a,"lineShape",(b==null?void 0:b.aes.lineShape)??"solid")},x=J0t().data(e).value($=>{let Q=Ly(C.dotFill($.data));return[Q.r/255,Q.g/255,Q.b/255,1]}),k=Z9t().equals(($,Q)=>$===Q).size(50).crossValue($=>$.x).mainValue($=>$.y).decorate($=>x($)),_=t0t().scaleExtent([.1,1e3]).filter(()=>!this.lassoMode).on("start",()=>{this.selectedDot=null}).on("zoom",$=>{let Q=$.transform,ee=Q.rescaleX(this.scales.xOriginal),K=Q.rescaleY(this.scales.yOriginal);this.scales.x.domain(ee.domain()),this.scales.y.domain(K.domain()),this.zoomStateKey=`${Q.x}_${Q.y}_${Q.k}`,this.renderSvgLayer(),this.renderWebglLayer()}).on("end",()=>{this.allPossibleLabels.forEach($=>{$.x=this.scales.x($.dot.x),$.y=this.scales.y($.dot.y)}),this.visibleLabels=eE(this.allPossibleLabels,this.chartSizes.chartWidth,this.chartSizes.chartHeight),this.renderSvgLayer()}),D=N_().x($=>$.x).y($=>$.y).addAll(e),O=q0t().on("point",([$])=>{var U,G;if(!$){this.selectedDot=null,this.renderSvgLayer();return}let Q=this.scales.x.invert($.x),ee=this.scales.y.invert($.y),K=(U=this.tools)==null?void 0:U.qt.find(Q,ee),re=this.selectedDot&&!K||!this.selectedDot&&K||((G=this.selectedDot)==null?void 0:G.id)!==(K==null?void 0:K.id);this.selectedDot=K??null,re&&this.renderSvgLayer()}),I=_0t({xScale:this.scales.x,yScale:this.scales.y}).xAxisHeight(()=>"0").yAxisWidth(()=>"0").svgPlotArea(J9t()).webglPlotArea(q9t().series([k]).mapping($=>$)).decorate($=>{let Q=$.enter();Q&&!this.svgLayerElement&&(Q.style("grid-template-columns","0 auto 1fr auto 0"),Q.style("grid-template-rows","0 auto 1fr auto 0"),this.svgLayerElement=Q.select(".svg-plot-area.plot-area svg").node()),Q.select(".svg-plot-area.plot-area").call(_).call(O)});this.tools={webglChart:I,zoom:_,qt:D,fillColor:x,pointSeries:k,aesGetters:C},iu(this.canvasNode).datum(e).style("position","absolute").style("width",this.chartSizes.chartWidth+"px").style("height",this.chartSizes.chartHeight+"px").style("top",this.margins.top+"px").style("left",this.margins.left+"px")}updateAes(e,t){var i;if(this.tools===null)return;let n=t.find(o=>o.type==="dots"),r=t.find(o=>o.type==="curve"),a={dotFill:rE(e,"dotFill",n.aes.dotFill),lineType:rE(e,"lineShape",(r==null?void 0:r.aes.lineShape)??"solid")};this.tools.aesGetters=a,(i=this.tools)==null||i.fillColor.value(o=>{var A;let s=((A=this.tools)==null?void 0:A.aesGetters.dotFill)??(()=>Zt),c=Ly(s(o.data)),f=this.polygon.length<2||dX(this.polygon,[o.x,o.y])?1:.2;return[c.r/255,c.g/255,c.b/255,f]})}updateByLasso(){var e;this.tools!==null&&((e=this.tools)==null||e.fillColor.value(t=>{var i;let n=((i=this.tools)==null?void 0:i.aesGetters.dotFill)??(()=>Zt),r=Ly(n(t.data)),a=this.polygon.length<2||dX(this.polygon,[t.x,t.y])?1:.4;return[r.r/255,r.g/255,r.b/255,a]}),this.renderWebglLayer())}updateData(e){this.tools!==null&&(iu(this.canvasNode).datum(e),this.tools.fillColor.data(e),this.tools.qt=N_().x(t=>t.x).y(t=>t.y).addAll(e))}render(e,t,n,r,a,i,o,s,c,f,A,h,m,g){if(this.lassoMode=g,this.tools===null)this.initSettings(a,t,i,r,s,c,f,A),this.onPolygonUpdateOutside=m;else{let{title:b,legend:C}=t;this.updateLegendSize(C,f,A,c),this.createMainTitle(b),this.updateMargins(),this.updateAes(s,c)}this.allPossibleLabels=h,this.allPossibleLabels.forEach(b=>{b.x=this.scales.x(b.dot.x),b.y=this.scales.y(b.dot.y)}),this.visibleLabels=eE(this.allPossibleLabels,this.chartSizes.chartWidth,this.chartSizes.chartHeight),this.notCalculatedProps={settingsId:e,chartSettings:t,onlyPositive:r,keyColumn:n,dotsByGrouping:o,layers:c},this.renderWebglLayer(),this.renderSvgLayer()}renderWebglLayer(){var e,t;(e=this.tools)!=null&&e.webglChart&&iu(this.canvasNode).call((t=this.tools)==null?void 0:t.webglChart)}renderSvgLayer(){var t,n;this.visibleLabels.forEach(r=>{r.x=this.scales.x(r.dot.x),r.y=this.scales.y(r.dot.y)}),Jwt(this.visibleLabels);let e={settingsId:this.notCalculatedProps.settingsId,chartSettings:this.notCalculatedProps.chartSettings,onlyPositive:this.notCalculatedProps.onlyPositive,keyColumn:this.notCalculatedProps.keyColumn,dotsByGrouping:this.notCalculatedProps.dotsByGrouping,layers:this.notCalculatedProps.layers,chartSizes:this.chartSizes,scales:this.scales,margins:this.margins,mainTitle:this.mainTitle,captionsSizes:this.captionsSizes,container:this.svgLayerElement,zoomStateKey:this.zoomStateKey,selectedDot:this.selectedDot,aesGetters:(t=this.tools)==null?void 0:t.aesGetters,legendData:this.legend,labels:this.visibleLabels,onPolygonUpdate:this.onPolygonUpdate,lassoMode:this.lassoMode};this.svgLayerComponent=le.jsx(U9t,{...e}),(n=this.reactRoot)==null||n.render(this.svgLayerComponent)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},n4t=t4t,aE=H.object({type:H.literal("grouping"),value:H.string()}),r4t=H.object({type:H.literal("dots"),aes:H.optional(H.object({dotFill:H.optional(H.union([H.string(),aE,rh(H.string())])),dotShape:H.optional(H.union([Od,aE])),dotSize:H.optional(H.union([H.number(),aE]))}))}),a4t=H.object({type:H.literal("curve"),smoothing:H.optional(H.boolean()),aes:H.optional(H.object({lineWidth:H.optional(H.number()),lineShape:H.optional(tp),lineColor:H.optional(H.union([H.string(),aE,rh(H.string())])),opacity:H.optional(H.number())}))}),i4t=H.union([r4t,a4t]),o4t=H.object({type:H.literal("scatterplot-umap"),title:H.object({name:H.string(),show:H.optional(H.boolean()),position:H.optional(Nm)}),size:H.optional(H.object({width:H.optional(H.number()),height:H.optional(H.number())})),legend:H.optional(H.object({show:H.optional(H.boolean()),position:H.optional(Bg)})),tooltips:H.optional(H.object({show:H.optional(H.boolean()),content:H.optional(H.array(Tr))})),frame:H.optional(H.object({type:H.optional(c9)})),keyColumn:Tr,x:Tr,y:Tr,xAxis:H.optional(r2),yAxis:H.optional(r2),grouping:H.optional(H.array(Tr)),label:H.optional(Tr),inheritedAes:H.optional(H.record(H.string(),n2)),layers:H.array(i4t),lassoMode:H.optional(H.boolean())}),l4t=class{constructor(e){Me(this,"type","dots");Me(this,"aes",{dotFill:Zt,dotShape:"21",dotSize:3,opacity:1});this.aes={...this.aes,...e.aes}}},s4t=class{constructor(e){Me(this,"type","curve");Me(this,"smoothing");Me(this,"aes",{lineColor:Zt,lineWidth:1,lineShape:"solid",opacity:1});this.smoothing=e.smoothing??!1,this.aes={...this.aes,...e.aes}}},xZ=class{constructor(e){Me(this,"id");Me(this,"type","scatterplot-umap");Me(this,"keyColumn");Me(this,"x");Me(this,"y");Me(this,"grouping");Me(this,"label");Me(this,"chartSettings");Me(this,"inheritedAes");Me(this,"layers");Me(this,"lassoMode");var t,n,r,a;o4t.parse(e),this.id=Ir.uniqueId("settings"),this.keyColumn=e.keyColumn,this.x=e.x,this.y=e.y,this.grouping=e.grouping??[],this.label=e.label??null,this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??600,height:((n=e==null?void 0:e.size)==null?void 0:n.height)??350},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},yAxis:{title:e.y.label??e.y.value,scale:"linear",showGrid:!0,showTicks:!0,...e.yAxis},xAxis:{title:e.x.label??e.x.value,scale:"linear",showGrid:!0,showTicks:!0,...e.xAxis},frame:{type:((a=e.frame)==null?void 0:a.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.inheritedAes=e.inheritedAes??{},this.layers=e.layers.map(i=>{if(i.type==="dots")return new l4t(i);if(i.type==="curve")return new s4t(i);throw new Error("Unknown layer type")}).filter(Boolean),this.lassoMode=e.lassoMode??!1}};function SZ(e){return typeof e=="object"&&"type"in e&&e.type==="grouping"}function u4t(e,t,n,r){return t.reduce((a,i)=>{let o=Ir.uniqBy(e.rows,h=>h[i.value]),s=h=>String(h[i.value]),c=h=>i.valueLabels?String(h[i.valueLabels]):s(h),f=new Set;n.forEach(h=>{h.aes&&Object.entries(h.aes).forEach(([m,g])=>{SZ(g)&&g.value===i.value&&f.add(m)})});let A=o.reduce((h,m)=>(h[s(m)]=c(m),h),{});return a[i.value]={values:o.map(s).sort((h,m)=>A[h].localeCompare(A[m],"en",{numeric:!0})),usedAes:[...f],aesMap:r[i.value],labels:A},a},{})}var c4t=10;function f4t(e){let t=[],n=new Dc("16px Manrope");for(let r of e){let a=r.label;if(!a)continue;let i=n.getTextMetrics(String(a));t.push({name:String(a),width:i.width,height:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent,x:0,y:0,xPosition:"right",yPosition:"middle",bbox:{minX:0,maxX:0,minY:0,maxY:0},dot:r,padding:c4t})}return t}var d4t=class extends Sg{constructor(t,n,r){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new n4t);Me(this,"onPolygonUpdate",()=>Kx);Me(this,"calculatedData",null);this.settings=new xZ(n),r&&(this.onPolygonUpdate=r[0])}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new xZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){t==="polygon"&&(this.chartRenderer.polygon=n,this._updateChart())}export(){return console.warn("export not implemented"),""}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.grouping.length!==n.grouping.length||t.grouping.some((s,c)=>{var f;return s.value!==((f=n.grouping[c])==null?void 0:f.value)})||(((r=t.label)==null?void 0:r.value)||((a=n.label)==null?void 0:a.value))&&((i=t.label)==null?void 0:i.value)!==((o=n.label)==null?void 0:o.value)}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{x:t,y:n,keyColumn:r,label:a,grouping:i,layers:o,inheritedAes:s}=this.settings,c={x:!0,y:!0},f={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},A=o.some(x=>x.type==="curve"),h=new Set,m={},g=this.data.rows.reduce((x,k)=>{if(k[t.value]===null||k[n.value]===null)return x;let _=Number(k[t.value]),D=Number(k[n.value]);c.x&&_!==null&&_<0&&(c.x=!1),c.y&&D!==null&&D<0&&(c.y=!1),_!==null&&_<f.minX&&(f.minX=_),_!==null&&_>f.maxX&&(f.maxX=_),D!==null&&D<f.minY&&(f.minY=D),D!==null&&D>f.maxY&&(f.maxY=D);let O={x:_,y:D,id:String(k[r.value]),label:a&&k[a.value]?String(k[a.value]):null,data:k};if(A){let I=i.map($=>k[$.value]).join("_");h.add(I),m[I]||(m[I]=[]),m[I].push(O)}return x.push(O),x},[]),b=[...h];A&&b.forEach(x=>{m[x].sort((k,_)=>k.x-_.x)});let C=u4t(this.data,i,o,s);this.calculatedData={onlyPositive:c,dots:g,dotsByGrouping:m,groupingKeys:b,allPossibleLabels:f4t(g),dotsExtents:f,legendLabels:C},this.chartRenderer.updateData(g)}_updateAesInData(){let t=this.calculatedData;if(!t)return;let{layers:n,inheritedAes:r,grouping:a}=this.settings;this.chartRenderer.updateAes(r,n),a.forEach(i=>{let o=new Set;n.forEach(s=>{s.aes&&Object.entries(s.aes).forEach(([c,f])=>{SZ(f)&&f.value===i.value&&o.add(c)})}),t.legendLabels[i.value].usedAes=[...o],t.legendLabels[i.value].aesMap=r[i.value]})}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,keyColumn:r,inheritedAes:a,layers:i,grouping:o,lassoMode:s}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.onlyPositive,this.calculatedData.dots,this.calculatedData.dotsExtents,this.calculatedData.dotsByGrouping,a,i,this.calculatedData.legendLabels,o,this.calculatedData.allPossibleLabels,this.onPolygonUpdate,s)}};function A4t(e){let t=cL(e),n=tu(e);return t===void 0||n===void 0||t===0?r=>r:r=>(r-n)/t}function p4t(e){let t=tu(e),[n,r]=$A(e);return t===void 0||n===void 0||r===void 0?a=>a:a=>(a-t)/(r-n)}function h4t(e,t){return e==="standardScaling"?A4t(t):e==="meanNormalization"?p4t(t):n=>n}function m4t(e,t,n,r,a,i,o,s,c,f){let A={meta:{facetKeys:o,xKeys:[],yKeys:[],xLabels:{},yLabels:{},facetKeyValues:o.reduce((C,x,k)=>(C[x]=s[k],C),{}),valueExtentSize:[1/0,-1/0],valueExtentColor:[1/0,-1/0]},facets:{}},h=new Set,m=new Set,g=t.valueLabels??t.value,b=n.valueLabels??n.value;if(e.rows.forEach(C=>{let x=i.length?i.map(I=>C[I.value]).join("_"):"null",k=C[t.value],_=C[n.value],D=C[r.value]??f,O=C[a.value]??f;if(!(k===null||_===null||D===null||O===null)){if(A.facets[x]||(A.facets[x]={xKeys:[],yKeys:[],cells:{}}),A.facets[x].xKeys.push(k),A.facets[x].yKeys.push(_),h.has(k)||(h.add(k),A.meta.xKeys.push(k)),m.has(_)||(m.add(_),A.meta.yKeys.push(_)),A.facets[x].cells[k]||(A.facets[x].cells[k]={}),A.meta.valueExtentSize[0]=Math.min(D,A.meta.valueExtentSize[0]),A.meta.valueExtentSize[1]=Math.max(D,A.meta.valueExtentSize[1]),A.meta.valueExtentColor[0]=Math.min(O,A.meta.valueExtentColor[0]),A.meta.valueExtentColor[1]=Math.max(O,A.meta.valueExtentColor[1]),A.facets[x].cells[k][_])throw Error(`More than 1 value for x=${k}, y=${_}`);if(A.meta.xLabels[k]&&String(C[g])!==A.meta.xLabels[k])throw Error(`More than 1 x-label value for x=${k}`);if(A.meta.yLabels[_]&&String(C[b])!==A.meta.yLabels[_])throw Error(`More than 1 y-label value for y=${_}`);A.meta.xLabels[k]=String(C[g]),A.meta.yLabels[_]=String(C[b]),A.meta&&(A.facets[x].cells[k][_]={id:`${k}_${_}`,x:k,y:_,sizeValue:D,normalizedSizeValue:D,colorValue:O,normalizedColorValue:O,data:C})}}),o.forEach(C=>{let x=A.facets[C];x.xKeys=Ir.uniq(x.xKeys),x.yKeys=Ir.uniq(x.yKeys)}),c){let C=[1/0,-1/0];o.forEach(x=>{let{xKeys:k,yKeys:_,cells:D}=A.facets[x],O=c.direction==="row"?k:_,I=c.direction==="row"?_:k,$=c.direction==="row"?(Q,ee)=>{var K;return(K=D[Q])==null?void 0:K[ee]}:(Q,ee)=>{var K;return(K=D[ee])==null?void 0:K[Q]};I.forEach(Q=>{let ee=[];O.forEach(re=>{var G;let U=(G=$(re,Q))==null?void 0:G.colorValue;U!==void 0&&ee.push(U)});let K=h4t(c.method,ee);O.forEach(re=>{let U=$(re,Q);U!==void 0&&(U.normalizedColorValue=K(U.colorValue),C[0]=Math.min(U.normalizedColorValue,C[0]),C[1]=Math.max(U.normalizedColorValue,C[1]))})})}),A.meta.valueExtentColor=C}return A.meta.valueExtentSize[0]===1/0&&(A.meta.valueExtentSize[0]=0),A.meta.valueExtentSize[1]===-1/0&&(A.meta.valueExtentSize[1]=0),A.meta.valueExtentColor[0]===1/0&&(A.meta.valueExtentColor[0]=0),A.meta.valueExtentColor[1]===-1/0&&(A.meta.valueExtentColor[1]=0),A}var v4t=15,Mg=8,iE=30,g4t=48,y4t=24,oE=16,y2=4,lE=4,BZ=20,w4t=16,u1={left:["axis","axisTitle"],right:["axis","axisTitle"],top:["axis","axisTitle","facetTitle"],bottom:["axis","axisTitle"]};function C4t(e,t,n,r,a,i,o){let s=r.includes(t.position),c=r.includes(e.position),f=a.length>1,A=e.showTicks?lE:0,h=t.showTicks?lE:0,m=c&&e.showTitle?iE:0,g=s&&t.showTitle?iE:0,b=c&&e.showAxisLabels&&i>oE?n.xAxisCaptions+A+y2:0,C=s&&t.showAxisLabels&&o>oE?n.yAxisCaptions+h+y2:0;return{left:{axisTitle:t.position==="left"?g:0,axis:t.position==="left"?C:0},right:{axisTitle:t.position==="right"?g:0,axis:t.position==="right"?C:0},top:{facetTitle:f?g4t:0,axisTitle:e.position==="top"?m:0,axis:e.position==="top"?b:0},bottom:{axisTitle:e.position==="bottom"?m:0,axis:e.position==="bottom"?b:0}}}function b4t(e,t,n){return{left:u1.left.reduce((r,a,i)=>{let o=i>0?u1.left[i-1]:null,s=e.left[a];return r[a]={x:o?r[o].x-s:-s,y:0,width:s,height:n,isVisible:s>0},r},{}),right:u1.right.reduce((r,a,i)=>{let o=i>0?u1.right[i-1]:null,s=e.right[a];return r[a]={x:o?r[o].x+r[o].width:t,y:0,width:s,height:n,isVisible:s>0},r},{}),top:u1.top.reduce((r,a,i)=>{let o=i>0?u1.top[i-1]:null,s=e.top[a];return r[a]={x:0,y:o?r[o].y-s:-s,width:t,height:s,isVisible:s>0},r},{}),bottom:u1.bottom.reduce((r,a,i)=>{let o=i>0?u1.bottom[i-1]:null,s=e.bottom[a];return r[a]={x:0,y:o?r[o].y+r[o].height:n,width:t,height:s,isVisible:s>0},r},{})}}function E4t(e,t,n,r){let{xLabels:a,yLabels:i}=n.meta,o=e.xAxisLabels/180*Math.PI,s=e.yAxisLabels/180*Math.PI,c=0,f=0,A=e.xAxisLabels===45;if(A){let m=n.meta.xKeys,g=t.x,b=g>oE,C=a[m[0]];c=Math.max(c,(A&&b?r.getTextWidth(C)*Math.cos(o):0)-g/2)}let h=e.yAxisLabels===45;if(h){let m=n.meta.yKeys;if(m.length){let g=t.y,b=g>oE,C=i[m[m.length-1]];f=Math.max(f,(h&&b?r.getTextWidth(C)*Math.cos(s):0)-g/2)}}return{xCaptionTail:c,yCaptionTail:f}}function x4t({sideElementBBoxes:e,debug:t,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,labelAngles:f,xLabels:A,yLabels:h}){let m=i.showTicks?lE:0,g=o.showTicks?lE:0,b=e.top.axis.isVisible||e.bottom.axis.isVisible,C=e.top.axisTitle.isVisible?e.top.axisTitle:e.bottom.axisTitle,x=e.top.axis.isVisible?e.top.axis:e.bottom.axis,k=e.left.axis.isVisible||e.right.axis.isVisible,_=e.left.axisTitle.isVisible?e.left.axisTitle:e.right.axisTitle,D=e.left.axis.isVisible?e.left.axis:e.right.axis;return le.jsxs("g",{children:[le.jsxs("g",{children:[C.isVisible&&le.jsxs("g",{transform:`translate(${C.x},${C.y})`,children:[le.jsx("text",{x:C.width/2,y:C.height/2,textAnchor:"middle",dominantBaseline:"central",children:i.title}),t&&le.jsx("rect",{width:C.width,height:C.height,stroke:Zt,fill:"none"})]}),b&&le.jsxs("g",{fontSize:"14px",transform:`translate(${x.x},${x.y})`,children:[n.map(O=>{let I=f.xAxisLabels!==0,$=i.position==="bottom",Q=$?0:x.height,ee=$?Q+m:Q-m,K=$?ee+y2:ee-y2,re=a.x(O)+s/2,U=-f.xAxisLabels;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:re,y1:Q,y2:ee,stroke:Zt}),le.jsx("text",{x:re,y:K,textAnchor:I?$?"end":"start":"middle",transform:`rotate(${U},${re},${K})`,dominantBaseline:I?"central":$?"hanging":"auto",children:A[O]})]},O)}),t&&le.jsx("rect",{width:x.width,height:x.height,stroke:Zt,fill:"none"})]})]}),le.jsxs("g",{children:[_.isVisible&&le.jsx("g",{transform:`translate(
15188
+ ${_.y+_.height/2})`,children:le.jsx("text",{transform:`rotate(${o.position==="left"?-90:90})`,dominantBaseline:"central",textAnchor:"middle",children:o.title})}),t&&le.jsx("rect",{x:_.x,y:_.y,width:_.width,height:_.height,stroke:Zt,fill:"none"}),k&&le.jsx("g",{fontSize:"14px",transform:`translate(${D.x},${D.y})`,children:r.map(O=>{let I=f.yAxisLabels!==0,$=o.position==="left",Q=-(90-f.yAxisLabels),ee=f.yAxisLabels===0?"middle":$?"end":"start",K=I?"central":$?"auto":"hanging",re=$?D.width:0,U=$?re-g:re+g,G=$?U-l2:U+l2,Z=a.y(O)+c/2;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:U,y1:Z,y2:Z,stroke:Zt}),le.jsx("text",{x:G,y:Z,textAnchor:ee,transform:`rotate(${Q},${G},${Z})`,dominantBaseline:K,children:h[O]})]},O)})}),t&&le.jsx("rect",{x:D.x,y:D.y,height:D.height,width:D.width,stroke:Zt,fill:"none"})]})]})}function fwt({sideElementBBoxes:e,debug:t,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,xGroupKeys:f,yGroupKeys:A,xKeysByGroups:h,yKeysByGroups:m,labelAngles:g,xLabels:b,yLabels:C,xGroupLabels:x,yGroupLabels:k}){return le.jsxs("g",{fontWeight:"500",children:[le.jsx(cwt,{sideElementBBoxes:e,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,labelAngles:g,xLabels:b,yLabels:C,debug:t}),le.jsx(uwt,{sideElementBBoxes:e,xGroupKeys:f,yGroupKeys:A,xKeysByGroups:h,yKeysByGroups:m,xGroupLabels:x,yGroupLabels:k,scales:a,stepX:s,stepY:c,xAxis:i,yAxis:o,labelAngles:g,debug:t})]})}function UK(e,t="top"){let{source:n,target:r}=e;return t==="top"||t==="bottom"?`M ${n.x},${n.y} L ${r.x},${n.y} L${r.x},${r.y}`:`M ${n.x},${n.y} L ${n.x},${r.y} L${r.x},${r.y}`}function jK(e,t,n,r,a){if(!n)return"";let i=n.aes[e];if(!f9(i))return i;let o=i.value,s=a[o],c=r[o][t.data.keys[0]];return t.data.keys.every(f=>c===r[o][f])?s(String(c))[e]:s.unknown()[e]}var GK={x:0,y:0,width:0,height:0};function dwt({dendrograms:e,sideElementBBoxes:t,xDataByKeys:n,yDataByKeys:r,aesScales:a}){let i=e.x.data,o=e.y.data,s=i?t[i.position].dendro:GK,c=o?t[o.position].dendro:GK;function f(h,m){return jK(h,m,i,n,a)}function A(h,m){return jK(h,m,o,r,a)}return le.jsxs("g",{children:[le.jsx("g",{transform:`translate(${s.x},${s.y})`,children:i&&!i.hidden&&e.x.trees.map((h,m)=>{let g=h.links(),b=h.descendants();return le.jsxs("g",{children:[g.map(C=>{let x=i.edgeInheritance==="up"?C.source:C.target;return le.jsx("path",{d:UK(C,i.position),stroke:f("lineColor",x),strokeWidth:f("lineWidth",x),strokeDasharray:td(f("lineShape",x)),fill:"none"},`${C.source.x},${C.source.y},${C.target.x},${C.target.y}`)}),i.showNodes&&b.map(C=>le.jsx("g",{transform:`translate(${C.x},${C.y})`,children:Af(f("dotShape",C),f("dotSize",C),f("dotFill",C))},`${C.x},${C.y}`))]},m)})}),le.jsx("g",{transform:`translate(${c.x},${c.y})`,children:o&&!o.hidden&&e.y.trees.map((h,m)=>{let g=h.links(),b=h.descendants();return le.jsxs("g",{children:[g.map(C=>{let x=o.edgeInheritance==="up"?C.source:C.target;return le.jsx("path",{d:UK(C,o.position),stroke:A("lineColor",x),strokeWidth:A("lineWidth",x),strokeDasharray:td(A("lineShape",x)),fill:"none"},`${C.source.x},${C.source.y},${C.target.x},${C.target.y}`)}),o.showNodes&&b.map(C=>le.jsx("g",{transform:`translate(${C.x},${C.y})`,children:Af(A("dotShape",C),A("dotSize",C),A("dotFill",C))},`${C.x},${C.y}`))]},m)})})]})}function Awt({frame:e,width:t,height:n,xGroupKeys:r,yGroupKeys:a,xKeysByGroups:i,yKeysByGroups:o,scales:s,stepX:c,stepY:f}){return le.jsxs("g",{children:[e.type==="full"&&le.jsx("rect",{fill:"none",stroke:Zt,x:"0",y:"0",width:t,height:n}),e.type==="groups"&&r.map(A=>{let h=i[A].length;if(h===0)return null;let m=h*c,g=s.x(i[A][0]);return a.map(b=>{let C=o[b].length;if(C===0)return null;let x=C*f,k=s.y(o[b][0]);return le.jsx("rect",{x:g,y:k,width:m,height:x,stroke:Zt,fill:"none"},`${g}_${k}`)})})]})}function IP(e){if(e===null)return"null";if(typeof e=="number"){let t=e>0?Math.floor(e):Math.ceil(e),n=e-t;return t+Number(n.toPrecision(2))}return e}function pwt(e,t,n=[]){let r=e.data,a=[`X: ${t.xLabels[e.x]}`,`Y: ${t.yLabels[e.y]}`,`Value: ${IP(e.value)}${e.value!==e.normalizedValue?` (${IP(e.normalizedValue)})`:""}`];for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function hwt(e,t){let n=[];return e.xKey&&n.push(`X: ${t.xLabels[e.xKey]}`),e.yKey&&n.push(`Y: ${t.yLabels[e.yKey]}`),n.push(`${e.title}: ${IP(e.value)}`),n}function mwt({dendrograms:e,facetKey:t,dimensions:n,scales:r,cells:a,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,colorScale:f,chartSettings:A,cellsMeta:h,stepX:m,stepY:g,sharedX:b,sharedY:C,annotations:x,annotationColorScales:k,dendrogramAesScales:_,aes:D,labelAngles:O,chartSizes:I,margins:$,tooltipsContainer:Q}){let[ee,K]=Vn.useState(null),[re,U]=Vn.useState(null),{xAxis:G,yAxis:Z,tooltips:Y}=A,{width:X,height:oe}=n.inner,{padding:me,chartEdgeSides:ae,sideElementBBoxes:ye}=n,{xGroupLabels:Ce,yGroupLabels:ce,xLabels:ge,yLabels:ze}=h,Ne=r.x.domain(),Ge=r.y.domain(),Oe={left:$.left+n.left+me.left,right:I.totalWidth-($.left+n.left+me.left),top:$.top+n.top+me.top,bottom:I.totalHeight-($.top+n.top+me.top)},Xe=!1;return le.jsxs("g",{transform:`translate(${n.left},${n.top})`,fontSize:G2t,children:[le.jsxs("g",{transform:`translate(${me.left},${me.top})`,children:[le.jsx(swt,{sideElementBBoxes:ye,annotations:x,cellsMeta:h,annotationColorScales:k,sharedX:b,sharedY:C,chartEdgeSides:ae,width:X,height:oe,scales:r,stepX:m,stepY:g,aes:D,frame:A.frame,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,setSelectedAnnotation:U}),le.jsx(dwt,{dendrograms:e,sideElementBBoxes:ye,xDataByKeys:h.xDataByKeys,yDataByKeys:h.yDataByKeys,aesScales:_}),ye.top.facetTitle.isVisible&&le.jsx("text",{x:ye.top.facetTitle.x,y:ye.top.facetTitle.y+ye.top.facetTitle.height-j2t,fontWeight:"500",fontSize:"20px",children:h.facetKeyValues[t].join(", ")}),Xe,Ne.map(dt=>Ge.map(Ye=>{var He;let rt=(He=a==null?void 0:a[dt])==null?void 0:He[Ye];return rt?le.jsx("rect",{x:r.x(dt),y:r.y(Ye),width:m,height:g,stroke:D.cellStrokeColor,fill:rt.value===null?D.emptyCellColor:f(rt.normalizedValue),onMouseOver:()=>K(rt),onMouseLeave:()=>K(null)},rt?rt.id:`${dt}_${Ye}`):null})),le.jsx(Awt,{frame:A.frame,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,scales:r,stepX:m,stepY:g,width:X,height:oe}),le.jsx(fwt,{xAxis:G,yAxis:Z,scales:r,stepX:m,stepY:g,debug:Xe,sideElementBBoxes:ye,xKeys:Ne,yKeys:Ge,xGroupKeys:i,yGroupKeys:o,xKeysByGroups:s,yKeysByGroups:c,xGroupLabels:Ce,yGroupLabels:ce,labelAngles:O,xLabels:ge,yLabels:ze})]}),A.tooltips.show&&ee&&le.jsx(oc,{content:pwt(ee,h,Y==null?void 0:Y.content),x:r.x(String(ee.x))+m/2,y:r.y(String(ee.y))+g/2,offset:Ne.length>1?m/2:0,active:!0,sideDistances:Oe,container:Q}),A.tooltips.show&&re&&le.jsx(oc,{content:hwt(re,h),x:re.x,y:re.y,offset:0,active:!0,sideDistances:Oe,container:Q})]})}function vwt({margins:e,captionsSizes:t,settingsId:n,chartSettings:r,chartSizes:a,chartsDimensions:i,facetKeys:o,facetSettings:s,xGroupKeys:c,yGroupKeys:f,scales:A,colorScale:h,groupedCells:m,cellsMeta:g,step:b,annotations:C,annotationColorScales:x,legend:k,aes:_,dendrograms:D,dendrogramAesScales:O,columnsCount:I,labelAngles:$}){let[Q,ee]=Vn.useState(),K=Vn.useRef(null);Vn.useEffect(()=>{K.current&&ee(K.current)},[]);let re=i[o[0]].padding,U=i[o[I-1]].padding,G=e.left+a.chartsWidth+j8,Z=e.top+re.top;return le.jsx(f2,{dataId:n,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${a.totalWidth} ${a.totalHeight}`,width:a.totalWidth,height:a.totalHeight,fontFamily:"Manrope",children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${e.left},${e.top})`,children:[le.jsx(d2,{title:[r.title.name],show:r.title.show,position:r.title.position,leftPadding:re.left,rightPadding:U.right,chartsWidth:a.chartsWidth}),o.map(Y=>{let{cells:X,xKeysByGroups:oe,yKeysByGroups:me}=m[Y];return le.jsx(mwt,{dendrograms:D[Y],captionsSizes:t,facetKey:Y,dimensions:i[Y],xGroupKeys:c,yGroupKeys:f,xKeysByGroups:s.sharedX?g.xKeysByGroups:oe,yKeysByGroups:s.sharedY?g.yKeysByGroups:me,sharedX:s.sharedX,sharedY:s.sharedY,scales:{x:A.x[Y],y:A.y[Y]},cells:X,cellsMeta:g,stepX:b.x[Y],stepY:b.y[Y],colorScale:h,chartSettings:r,aes:_,annotations:C,annotationColorScales:x,dendrogramAesScales:O,labelAngles:$,margins:e,chartSizes:a,tooltipsContainer:Q},Y)})]}),le.jsx("g",{transform:`translate(${G},${Z})`,children:le.jsx(y9,{legendData:k})}),le.jsx("g",{ref:K})]})})}function YK(e,t,n){function r(a){a[n]=t(a.data.height),a.children&&a.children.forEach(r)}r(e)}function WK(e,t,n,r=n){function a(i){i[r]=i[n]+t,i.children&&i.children.forEach(a)}a(e)}var gwt=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function XK(e,t,n){let r=n;return e&&(e.colorRange&&(r=e.colorRange),e.method==="standardScaling"&&(r=[-2,2]),e.method==="meanNormalization"&&(r=[-.75,.75])),gwt(t,r)}var ywt=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"margins",{top:_g,bottom:_g,left:_g,right:_g});Me(this,"captionsSizes",{xAxisCaptions:100,yAxisCaptions:100,xGroupCaptions:Vm,yGroupCaptions:Vm,xCaptionTail:0,yCaptionTail:0});Me(this,"labelAngles",{xAxisLabels:0,yAxisLabels:0,xGroupLabels:0,yGroupLabels:0});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:{null:Hl().domain(["null"]).range([1])},y:{null:Hl().domain(["null"]).range([1])}});Me(this,"step",{x:{},y:{}});Me(this,"colorScale",Da().domain([0,1]).range(["white","black"]));Me(this,"annotationColorScales",{});Me(this,"dendrogramAesScales",{});Me(this,"legend",{width:0,height:0,items:[]});Me(this,"dendrograms",{})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateMargins(e){this.margins={top:e.show?24+24*2:_g,bottom:_g,left:_g,right:this.legend.width},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight+this.margins.bottom,this.legend.height)}updateLegendSize(e,t,n,r,a){if(!t.show){this.legend={width:0,height:0,items:[]};return}let i=this.chartSizes.chartHeight,o=[],s={width:0,height:0,left:0,top:0},c=m=>m.reduce((g,b)=>(g[b]=String(b),g),{});if(e==="continuous"){let m=this.colorScale,g=a2(m,a),b=Da([g[0],g[g.length-1]],[i,0]),C=r.label??r.value;o.push({...s,type:"continuous",id:"heatmapValue",scale:m,values:g,title:C,tickPositionScale:b})}else if(e==="discrete"){let m=this.colorScale,g=r.label??r.value,b=m.domain(),C=c(b);o.push({...s,type:"discreteColor",id:"heatmapValue",title:g,scale:m,values:b,labels:C})}if(n.forEach(m=>{let g=m.valueColumn.label??m.valueColumn.value;if(m.type==="continuous"){let b=this.annotationColorScales[m.id].scale,C=a2(b,a),x=Da([C[0],C[C.length-1]],[i,0]);o.push({...s,type:"continuous",id:m.id,tickPositionScale:x,title:g,scale:b,values:C})}if(m.type==="discrete"){let b=this.annotationColorScales[m.id].scale,C=b.domain(),x=c(C);o.push({...s,type:"discreteColor",id:m.id,title:g,scale:b,values:C,labels:x})}}),!o.length){this.legend={width:0,height:0,items:[]};return}let f=w9(o,this.chartSizes.chartHeight),A=f[f.length-1],h=A.left+A.width+2*j8;this.legend={width:h,height:i,items:f}}updateCaptionsSize(e,t,n,r){let a=new Dc("bold 14px Arial"),{xGroupKeys:i,yGroupKeys:o,xGroupLabels:s,yGroupLabels:c,xKeysByGroups:f,yKeysByGroups:A,xLabels:h,yLabels:m}=e.meta;this.labelAngles={xAxisLabels:t.axisLabelsAngle,yAxisLabels:n.axisLabelsAngle,xGroupLabels:t.groupLabelsAngle,yGroupLabels:n.groupLabelsAngle};let g=Ir.flatten(Object.values(f)),b=Ir.flatten(Object.values(A)),C=g.map(K=>a.getTextWidth(h[K])),x=b.map(K=>a.getTextWidth(m[K])),k=i.map(K=>a.getTextWidth(s[K])),_=o.map(K=>a.getTextWidth(c[K])),{xCaptionTail:D,yCaptionTail:O}=owt(this.labelAngles,r,this.step,e,a),I=this.labelAngles.xGroupLabels/180*Math.PI,$=this.labelAngles.yGroupLabels/180*Math.PI,Q=this.labelAngles.xAxisLabels/180*Math.PI,ee=this.labelAngles.yAxisLabels/180*Math.PI;this.captionsSizes={xCaptionTail:D,yCaptionTail:O,xGroupCaptions:Math.max(...k,0)*Math.sin(I)||Vm,yGroupCaptions:Math.max(..._,0)*Math.sin($)||Vm,xAxisCaptions:Math.max(...C,0)*Math.sin(Q)||Vm,yAxisCaptions:Math.max(...x,0)*Math.sin(ee)||Vm}}updateChartDimensions(e,t,n,r,a,i,o,s,c,f){let A=t.length,h=Math.min(a.nRows??A,A),m=Math.min(a.nCols??A,A);this.columnsCount=a.nRows?Math.ceil(A/h):m,this.rowsCount=Math.ceil(A/this.columnsCount);let{width:g,height:b}=e,{sharedX:C,sharedY:x}=a;this.chartsDimensions={};let k=0,_=0;t.forEach((I,$)=>{let Q=$%this.columnsCount+1,ee=zK($,t.length,this.columnsCount,this.rowsCount),K=this.step.x[I],re=this.step.y[I],U=nwt(i,o,this.captionsSizes,s,c,f,ee,C,x,t,n,r,K,re),G=iwt(s,ee,C,x);function Z(ae){return Math.max(s1[ae].reduce((ye,Ce)=>ye+U[ae][Ce],0),G[ae],z2t)}let Y={left:Z("left"),right:Z("right"),top:Z("top"),bottom:Z("bottom")};Y.left<this.captionsSizes.xCaptionTail&&(Y.left=this.captionsSizes.xCaptionTail),Y.bottom<this.captionsSizes.yCaptionTail&&(Y.bottom=this.captionsSizes.yCaptionTail);let X=rwt(U,g,b),oe=g+Y.left+Y.right,me=b+Y.top+Y.bottom;this.chartsDimensions[I]={left:k,top:_,inner:{width:g,height:b},outer:{width:oe,height:me},padding:Y,sideElementBBoxes:X,chartEdgeSides:ee},k+=oe,Q===this.columnsCount&&(k=0,_+=me)});let D=t.slice(0,this.columnsCount).reduce((I,$)=>I+this.chartsDimensions[$].outer.width,0),O=t.filter((I,$)=>$%this.columnsCount===0).reduce((I,$)=>I+this.chartsDimensions[$].outer.height,0);this.chartSizes.chartsWidth=D,this.chartSizes.chartsHeight=O}updateChartsSizes(e){let{width:t,height:n}=e;this.chartSizes.chartWidth=t,this.chartSizes.chartHeight=n}updateScales(e,t,n,r,a,i,o,s,c){let{width:f,height:A}=a,{meta:h,facets:m}=t,{sharedX:g,sharedY:b}=r,C=(k,_={})=>k.sort((D,O)=>i.sorting==="asc"?(_[D]??D).localeCompare(_[O]??O,"en",{numeric:!0}):(_[O]??O).localeCompare(_[D]??D,"en",{numeric:!0})),x=(k,_={})=>k.sort((D,O)=>o.sorting==="asc"?(_[D]??D).localeCompare(_[O]??O,"en",{numeric:!0}):(_[O]??O).localeCompare(_[D]??D,"en",{numeric:!0}));e.forEach(k=>{let _=m[k],D=C(h.xGroupKeys),O=x(h.yGroupKeys),{xKeysByGroups:I}=g?h:_,{yKeysByGroups:$}=b?h:_,Q=D.map(ye=>I[ye].length),ee=O.map(ye=>$[ye].length),K=Q.reduce((ye,Ce)=>ye+Ce,0),re=ee.reduce((ye,Ce)=>ye+Ce,0),U=(f-(Q.filter(ye=>ye>0).length-1)*n)/K,G=(A-(ee.filter(ye=>ye>0).length-1)*n)/re,Z=[],Y=[],X=0;D.forEach(ye=>{let Ce=s?I[ye]:C(I[ye],h.xLabels);Y.push(...Ce),Ce.forEach(()=>{Z.push(X),X+=U}),Ce.length>0&&(X+=n)});let oe=[],me=[],ae=0;O.forEach(ye=>{let Ce=c?$[ye]:x($[ye],h.yLabels);me.push(...Ce),Ce.forEach(()=>{oe.push(ae),ae+=G}),Ce.length>0&&(ae+=n)}),this.scales.x[k]=Hl().domain(Y).range(Z),this.scales.y[k]=Hl().domain(me).range(oe),this.step.x[k]=U,this.step.y[k]=G})}updateAesScale(e,t,n,r,a,i,o){if(e==="continuous")n.valueColors?this.colorScale=Da().domain(n.valuesByColors??XK(o,n.valueColors.length,t)).range(n.valueColors):n.colorsList&&(this.colorScale=Da().domain(XK(o,n.colorsList.length,t)).range(n.colorsList));else if(n.colorsMap){let f=Object.entries(n.colorsMap);this.colorScale=Hl().domain(f.map(A=>A[0])).range(f.map(A=>A[1])).unknown("#ccc")}else n.colorsList&&(this.colorScale=QK(n.colorsList,i.map(String)));let{xDataByKeys:s,yDataByKeys:c}=a.meta;r.forEach(f=>{let{colors:A,type:h,axis:m,valueColumn:g}=f,b=(m==="x"?s:c)[g.value];if(h==="discrete"){let C=Ir.uniq(Object.values(b).map(String)).sort();this.annotationColorScales[f.id]={type:"discrete",scale:QK(A,C)}}else{let C=Object.values(b).map(Number);if(!C.length)return;let[x=C[0],k=C[0]]=$A(C);this.annotationColorScales[f.id]={type:"continuous",scale:awt(A,x,k,0,.5,1)}}})}updateDendrogram(e,t,n,r,a,i,o){e.forEach(s=>{this.dendrograms[s]={x:{trees:[],data:i},y:{trees:[],data:o}};let{xKeysByGroups:c,yKeysByGroups:f}=r[s],{hierarchyX:A,hierarchyY:h}=a[s],m=Math.max(...A.map(b=>b.data.height)),g=Math.max(...h.map(b=>b.data.height));i&&(this.dendrograms[s].x.trees=A.map((b,C)=>{let x=t[C],k=c[x];xB().separation(()=>1).size([k.length*this.step.x[s],i.size])(b);let _=b,D=Da().domain(i.position==="top"?[0,m]:[m,0]).range([i.size,0]);return YK(_,D,"y"),WK(_,this.scales.x[s](k[0]),"x"),_}),this.dendrograms[s].x.data=i),o&&(this.dendrograms[s].y.trees=h.map((b,C)=>{let x=n[C],k=f[x];xB().separation(()=>1).size([k.length*this.step.y[s],o.size])(b);let _=b,D=Da().domain(o.position==="left"?[0,g]:[g,0]).range([o.size,0]);return WK(_,this.scales.y[s](k[0]),"x","y"),YK(_,D,"x"),_}),this.dendrograms[s].y.data=o)})}updateDendrogramAesScales(e){if(!e)return;let t=Object.keys(e);this.dendrogramAesScales=t.reduce((n,r)=>{let a=e[r],i=Object.keys(a);return n[r]=Hl().domain(i).range(i.map(o=>({...nK,...a[o]}))).unknown(nK),n},{})}render(e,t,n,r,a,i,o,s,c,f,A,h,m){var K;let{meta:g,facets:b}=a,{facetKeys:C,xGroupKeys:x,yGroupKeys:k,valueExtent:_}=g,{xAxis:D,yAxis:O,title:I,size:$,valueType:Q}=t;this.updateChartsSizes($),this.updateAesScale(Q,_,r,i,a,h,m),this.updateScales(C,a,r.groupGap,n,$,t.xAxis,t.yAxis,s,c),this.updateCaptionsSize(a,D,O,n),this.updateChartDimensions($,C,x,k,n,D,O,i,s,c),this.updateLegendSize(Q,t.legend,i,o,_),this.updateMargins(I),this.updateDendrogram(C,x,k,b,f,s,c),this.updateDendrogramAesScales(A);let ee=le.jsx(vwt,{aes:r,annotations:i,annotationColorScales:this.annotationColorScales,captionsSizes:this.captionsSizes,cellsMeta:g,columnsCount:this.columnsCount,chartsDimensions:this.chartsDimensions,chartSettings:t,chartSizes:this.chartSizes,colorScale:this.colorScale,dendrogramAesScales:this.dendrogramAesScales,dendrograms:this.dendrograms,facetKeys:C,facetSettings:n,groupedCells:b,labelAngles:this.labelAngles,legend:this.legend,margins:this.margins,scales:this.scales,settingsId:e,step:this.step,xGroupKeys:x,yGroupKeys:k});this.component=ee,(K=this.reactRoot)==null||K.render(ee)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},wwt=ywt,LP={lineColor:Zt,dotShape:"21",dotFill:Zt,dotSize:3,lineShape:"solid",lineWidth:1},KK={size:150,distance:"euclidean",linkage:"average",fillNA:0,showNodes:!0,hidden:!1,edgeInheritance:"up",aes:LP},ZK=class{constructor(e){Me(this,"id");Me(this,"type","heatmap");Me(this,"facetSettings");Me(this,"xColumn");Me(this,"xGroupBy");Me(this,"yColumn");Me(this,"yGroupBy");Me(this,"valueColumn");Me(this,"facetBy");Me(this,"normalization");Me(this,"chartSettings");Me(this,"aes");Me(this,"annotations");Me(this,"dendrogramX");Me(this,"dendrogramY");Me(this,"inheritedDendrogramAes");Me(this,"NAValueAs");var t,n,r,a,i,o,s,c,f,A,h,m,g;if(t2t.parse(e),this.id=Ir.uniqueId("settings"),this.facetSettings={sharedX:(e.facetBy??[]).length>0,sharedY:(e.facetBy??[]).length>0,...e.facetSettings},this.xColumn=e.xColumn,this.xGroupBy=e.xGroupBy??[],this.yColumn=e.yColumn,this.yGroupBy=e.yGroupBy??[],this.valueColumn=e.valueColumn,this.facetBy=e.facetBy??[],this.chartSettings={title:{position:"left",show:!0,...e.title,name:((t=e.title)==null?void 0:t.name)??"Chart"},size:{width:((n=e==null?void 0:e.size)==null?void 0:n.width)??(this.facetBy.length?400:600),height:((r=e==null?void 0:e.size)==null?void 0:r.height)??(this.facetBy.length?250:350)},frame:{type:((a=e.frame)==null?void 0:a.type)??"none"},valueType:e.valueType??"continuous",yAxis:{title:e.yColumn.label??e.yColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,showGroupLabels:!0,position:"left",groupingPosition:"left",axisLabelsAngle:90,groupLabelsAngle:0,sorting:"asc",...e.yAxis},xAxis:{title:e.xColumn.label??e.xColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,showGroupLabels:!0,position:"bottom",groupingPosition:"bottom",axisLabelsAngle:90,groupLabelsAngle:0,sorting:"asc",...e.xAxis},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.normalization=this.chartSettings.valueType==="continuous"?e.normalization??null:null,this.NAValueAs=e.NAValueAs??null,this.aes={colorsList:((i=e.aes)==null?void 0:i.colorsList)??["black","white","red"],colorsMap:((o=e.aes)==null?void 0:o.colorsMap)??null,valueColors:((s=e.aes)==null?void 0:s.valueColors)??null,valuesByColors:((c=e.aes)==null?void 0:c.valuesByColors)??null,cellStrokeColor:((f=e.aes)==null?void 0:f.cellStrokeColor)??"none",groupGap:((A=e.aes)==null?void 0:A.groupGap)??3,emptyCellColor:((h=e.aes)==null?void 0:h.emptyCellColor)??"white"},this.annotations=(e.annotations??[]).map(b=>b.axis==="x"?{id:Ir.uniqueId("annotation"),axis:"x",valueColumn:b.valueColumn,position:b.position??this.chartSettings.xAxis.position,titlePosition:b.titlePosition??"right",showTitle:b.showTitle??!0,type:b.type,colors:b.colors??["white","black"]}:{id:Ir.uniqueId("annotation"),axis:"y",valueColumn:b.valueColumn,position:b.position??this.chartSettings.yAxis.position,titlePosition:b.titlePosition??"top",showTitle:b.showTitle??!0,type:b.type,colors:b.colors??["white","black"]}),e.valueType==="discrete"&&(e.dendrogramX||e.dendrogramY))throw Error("Dendrogram is not available with discrete cells values");this.dendrogramX=e.dendrogramX?{...KK,position:"top",...e.dendrogramX,aes:{...LP,...(m=e.dendrogramX)==null?void 0:m.aes}}:null,this.dendrogramY=e.dendrogramY?{...KK,position:"left",...e.dendrogramY,aes:{...LP,...(g=e.dendrogramY)==null?void 0:g.aes}}:null,this.inheritedDendrogramAes=e.inheritedDendrogramAes??null}},Cwt=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new wwt);Me(this,"calculatedData",null);this.settings=new ZK(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new ZK(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for heatmap")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var I,$,Q,ee,K,re,U,G,Z,Y,X,oe;let{xColumn:r,yColumn:a,valueColumn:i,xGroupBy:o,yGroupBy:s,facetBy:c,annotations:f,chartSettings:A,facetSettings:h,dendrogramX:m,dendrogramY:g,normalization:b,NAValueAs:C}=n,x=Object.values(((I=t.dendrogramX)==null?void 0:I.aes)||{}).filter(f9),k=Object.values((m==null?void 0:m.aes)||{}).filter(f9),_=Object.values((($=t.dendrogramY)==null?void 0:$.aes)||{}).filter(f9),D=Object.values((g==null?void 0:g.aes)||{}).filter(f9);function O(me,ae){return me.length!==ae.length||me.some((ye,Ce)=>ye.value!==ae[Ce].value)}return t.xColumn.value!==r.value||t.yColumn.value!==a.value||t.valueColumn.value!==i.value||O(t.xGroupBy,o)||O(t.yGroupBy,s)||O(t.facetBy,c)||O(t.annotations.map(me=>me.valueColumn),f.map(me=>me.valueColumn))||O(x,k)||O(_,D)||(n.dendrogramX||t.dendrogramX)&&(((Q=t.dendrogramX)==null?void 0:Q.distance)!==((ee=n.dendrogramX)==null?void 0:ee.distance)||((K=t.dendrogramX)==null?void 0:K.linkage)!==((re=n.dendrogramX)==null?void 0:re.linkage))||(n.dendrogramY||t.dendrogramY)&&(((U=t.dendrogramY)==null?void 0:U.distance)!==((G=n.dendrogramY)==null?void 0:G.distance)||((Z=t.dendrogramY)==null?void 0:Z.linkage)!==((Y=n.dendrogramY)==null?void 0:Y.linkage))||t.chartSettings.valueType!==A.valueType||t.facetSettings.sharedX!==h.sharedX||t.facetSettings.sharedY!==h.sharedY||((X=t.normalization)==null?void 0:X.method)!==(b==null?void 0:b.method)||((oe=t.normalization)==null?void 0:oe.direction)!==(b==null?void 0:b.direction)||t.NAValueAs!==C}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{xColumn:t,yColumn:n,valueColumn:r,xGroupBy:a,yGroupBy:i,facetBy:o,chartSettings:s,facetSettings:c,annotations:f,dendrogramX:A,dendrogramY:h,normalization:m,NAValueAs:g}=this.settings,b=K7t(this.data,t,n,r,o,a,i,f,A,h,m,g),C=twt(b,A,h,c),x=s.valueType==="discrete"?this.data.getColumnCategories(r.value):[];this.calculatedData={groupedCellsData:b,dendrogramsData:C,cellUniqValues:x}}_updateAesInData(){}_updateChart(){if(!this.calculatedData)return;let{id:t,valueColumn:n,chartSettings:r,facetSettings:a,aes:i,annotations:o,dendrogramX:s,dendrogramY:c,inheritedDendrogramAes:f,normalization:A}=this.settings;this.chartRenderer.render(t,r,a,i,this.calculatedData.groupedCellsData,o,n,s,c,this.calculatedData.dendrogramsData,f,this.calculatedData.cellUniqValues,A)}},JK=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r)return[n];if(e<2)return[(n+r)/2];let a=(r-n)/e,i=[];for(let o=1;o<e;o++)i.push(n+a*o);return i};function bwt(e,t,n){let[r=0,a=0]=$A(e,s=>s[t.value]),i=JK(n,[r,a]),o=pL().thresholds(i).value(s=>s[t.value])(e);return{bins:o,minX:o[0].x0??0,maxX:o[o.length-1].x1??0,maxCount:Ih(o,s=>s.length)??0}}function Ewt(e,t,n){let[r=0,a=0]=$A(e,A=>A[t.value]),i=[r,a],o=JK(n,[r,a]),s=q1().domain(i).range(i),c=o.map(A=>s.invert(A)),f=pL().thresholds(c).value(A=>A[t.value])(e);return{bins:f,minX:f[0].x0??0,maxX:f[f.length-1].x1??0,maxCount:Ih(f,A=>A.length)??0}}function xwt(e,t,n,r,a){let i={};return t.forEach(o=>{let s=e.getRowsByGrouping([...o]);i[o.join("_")]=a==="linear"?bwt(s,n,r):Ewt(s,n,r)}),i}var Swt={TOP:30,BOTTOM:0,LEFT:10,RIGHT:10};function b9(e,t,n=!1){let r=Math.abs(e.range()[0]-e.range()[1]),a=n?Math.min(Math.floor(r/45),10):10,i=e.ticks(a).filter(c=>t&&c>=0||!t),o=new Set(i);if(!n&&i.length>1){let c=e(i[0]),f=e(i[0]);for(let A=1;A<i.length;A++)f=e(i[A]),Math.abs(f-c)>=20?c=f:o.delete(i[A])}n&&i.length>2&&Math.abs(e(i[1])-e(i[0]))<45&&(i=i.filter((c,f)=>f%2===0));let s=i.some(c=>Math.abs(c)<1e-4&&c!==0||c>1e4)?",e":",f";return{ticks:i,format:c=>o.has(c)?e.tickFormat(a,s)(c):""}}function Bwt(e){return`translate(${e},0)`}function kwt(e){return`translate(0,${e})`}function Twt(e){return e==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function _wt(e){return e==="bottom"?"hanging":"central"}function Pwt(e){return e==="bottom"?"middle":"end"}var qK=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",onlyPositive:a=!1,offset:i=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function o(C){return x=>{let k=C(x);return k===void 0?0:+k}}let{ticks:s,format:c}=b9(e,a,r==="bottom"),f=Math.max(t,0)+n,A=o(e.copy()),h=r==="bottom"?Bwt:kwt,m=r==="left"?-1:1,g={[(r==="left"?"x":"y")+"2"]:m*t},b={[r==="left"?"x":"y"]:m*f};return le.jsx("g",{children:s.map((C,x)=>le.jsxs("g",{className:"tick",transform:h(A(C)+i),children:[le.jsx("line",{stroke:Zt,...g}),le.jsx("g",{transform:Twt(r),children:le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:_wt(r),textAnchor:Pwt(r),...b,children:c(C)})})]},x))})},Mwt=1;function eZ({scaleX:e,scaleY:t,width:n,height:r,axisX:a,axisY:i,frameType:o,updatingKey:s=""}){let[c,f]=Vn.useState(e.ticks()),[A,h]=Vn.useState(t.ticks()),{significantLines:m=[]}=a,{significantLines:g=[]}=i;return Vn.useEffect(()=>{let b=e.ticks().filter(x=>!m.includes(x)),C=t.ticks().filter(x=>!g.includes(x));f(b),h(C)},[e,t,s]),le.jsxs("g",{stroke:Jf,children:[a.showGrid&&c.map(b=>{let C=e(b);return le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`x_${C}_${r}`)}),i.showGrid&&A.map(b=>{let C=t(b);return le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`y_${C}_${n}`)}),le.jsx("g",{strokeDasharray:td(a.significantLinesStyle),stroke:Zt,children:m.map(b=>{let C=e(b);return C<0||C>n?null:le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`significant_${C}_${r}`)})}),le.jsx("g",{strokeDasharray:td(i.significantLinesStyle),stroke:Zt,children:g.map(b=>{let C=t(b);return C<0||C>r?null:le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`significant_${C}_${n}`)})}),o!=="empty"&&le.jsxs("g",{strokeWidth:Mwt,children:[(a.showGrid||o!=="left")&&le.jsx("line",{stroke:o==="left"?Jf:Zt,x1:"0",x2:n,y1:r,y2:r}),(a.showGrid||o!=="bottom")&&le.jsx("line",{stroke:o==="bottom"?Jf:Zt,x1:"0",x2:"0",y1:"0",y2:r}),(a.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:n,x2:n,y1:"0",y2:r}),(i.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:"0",x2:n,y1:"0",y2:"0"})]})]})}function Dwt({width:e,height:t,dimensions:n,scales:r,xAxis:a,yAxis:i,frameType:o,histogramData:s,facetSettings:c,captionsSizes:f,facetTitle:A,layers:h,aesColorGetter:m}){let{padding:g}=n,b=a.showTicks?4:0,C=i.showTicks?4:0,x=n.chartEdgeSides.includes("left")||!(c!=null&&c.sharedY),k=n.chartEdgeSides.includes("bottom")||!(c!=null&&c.sharedX),_=n.chartEdgeSides.includes("bottom"),D=!1;return le.jsxs("g",{transform:`translate(${n.left+g.left},${n.top+g.top})`,children:[D,A.length&&le.jsxs("g",{children:[o==="full"&&le.jsx("rect",{x:"0",y:-g.top,height:g.top,width:e,fill:"#F7F8FA",stroke:Zt}),A.map((O,I)=>{let $=A.length,Q=(g.top-20*$)/2;return le.jsx("text",{fontSize:"14px",fontWeight:"500",fill:Zt,x:e/2,dy:Q+20/2-g.top,y:I*20,textAnchor:"middle",dominantBaseline:"central",children:O},I)})]}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[_&&le.jsx("text",{x:e/2,y:t+g.bottom-12-20/2,children:a.title}),D]}),le.jsx(eZ,{width:e,height:t,scaleX:r.x,scaleY:r.y,axisX:a,axisY:i,frameType:o}),k&&le.jsxs("g",{transform:`translate(0,${t})`,children:[le.jsx(qK,{scale:r.x,orient:"bottom",onlyPositive:!0,tickSize:b}),D]}),x&&le.jsxs("g",{children:[le.jsx(qK,{scale:r.y,orient:"left",tickSize:C}),D]}),h.map(O=>s.bins.map(I=>le.jsx("rect",{x:r.x(I.x0),y:r.y(I.length),fill:I[0]?m(O.aes.fillColor,I[0]):"",stroke:Zt,width:r.x(I.x1)-r.x(I.x0),height:r.y(0)-r.y(I.length),opacity:O.aes.opacity??1},I.x0)))]})}function Hwt({settingsId:e,chartSettings:t,chartSizes:n,chartsDimensions:r,columnsCount:a,facetKeys:i,facetSettings:o,scales:s,margins:c,mainTitle:f,facetTitles:A,captionsSizes:h,histogramDataByFacets:m,layers:g,aesColorGetter:b}){let{xAxis:C,yAxis:x,title:k,frame:_}=t,D=r[i[0]].padding,O=r[i[a-1]].padding;return le.jsx(f2,{dataId:e,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${n.totalWidth} ${n.totalHeight}`,width:n.totalWidth,height:n.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${c.left},${c.top})`,fontFamily:"Manrope",children:[le.jsx(d2,{title:f,show:k.show,position:k.position,leftPadding:D.left,rightPadding:O.right,chartsWidth:n.chartsWidth}),i.map(I=>le.jsx(Dwt,{scales:{x:s.x[I],y:s.y[I]},width:n.chartWidth,height:n.chartHeight,dimensions:r[I],margins:c,chartSizes:n,facetSettings:o,xAxis:C,yAxis:x,frameType:_.type,facetTitle:A[I],captionsSizes:h,histogramData:m[I],layers:g,aesColorGetter:b},I))]})]})})}function Iwt(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function Lwt(e,t,n,r,a,i,o){let s=i.includes("left")||!(o!=null&&o.sharedY),c=i.includes("bottom")||!(o!=null&&o.sharedX),f=i.includes("bottom")&&e.title!=="",A=n.yAxisCaptionsWidth+2*6,h=(t.showTicks?4:0)+6,m=n.xAxisCaptionsWidth+2*6,g=e.showTicks?4:0,b=f?32:0,C=A+h+8,x=m+g+b+8,k=Math.max(...r.map(_=>a[_].length));return{left:s?C:12,top:k===0?0:6*2+k*20,bottom:c?x+8:12,right:12}}function Rwt(e,t,n){let r=[];for(let a=0;a<t;a++)r.push(e.slice(a*n,a*n+n));return r}function Nwt(e,t){let n=Math.floor(e/t),r=e-n*t;return[n,r]}function $wt(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e&&e.type==="grouping"}function Fwt(e,t){return function(n,r){var a,i;if($wt(n)){let o=n.value;return(i=((a=e[o])==null?void 0:a[String(r[o])])??hP)==null?void 0:i[t]}return n}}var Vwt=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"margins",{top:24,bottom:24,left:24,right:24});Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:{null:Da().domain([0,10]).range([0,600])},y:{null:Da().domain([0,10]).range([350,0])}});Me(this,"captionsSizes",{xAxisCaptionsWidth:30,yAxisCaptionsWidth:100});Me(this,"facetTitles",{});Me(this,"mainTitle",[])}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateChartSizes(e){this.chartSizes.chartWidth=e.width,this.chartSizes.chartHeight=e.height}updateChartDimensions(e,t,n,r){let{chartWidth:a,chartHeight:i}=this.chartSizes,o=0,s=0;this.chartsDimensions=e.reduce((A,h,m)=>{let[g,b]=Nwt(m,this.columnsCount),C=Iwt(m,e.length,this.columnsCount,this.rowsCount),x=Lwt(n,r,this.captionsSizes,Rwt(e,this.rowsCount,this.columnsCount)[g],this.facetTitles,C,t),k=a+x.left+x.right,_=i+x.top+x.bottom;return A[h]={left:o,top:s,chartEdgeSides:C,padding:x,inner:{width:a,height:i},outer:{width:k,height:_}},o+=k,b===this.columnsCount-1&&(o=0,s+=_),A},{});let c=Math.max(...e.map(A=>this.chartsDimensions[A].outer.width+this.chartsDimensions[A].left)),f=Math.max(...e.map(A=>this.chartsDimensions[A].outer.height+this.chartsDimensions[A].top));this.chartSizes.chartsWidth=c,this.chartSizes.chartsHeight=f}updateViewport(e,t,n,r,a){let i=e.length,o=Math.min(t.nRows??i,i),s=Math.min(t.nCols??i,i);this.columnsCount=t.nRows?Math.ceil(i/o):s,this.rowsCount=Math.ceil(i/this.columnsCount);let[c,f]=[1/0,-1/0],A=-1/0,h=e.reduce((m,g)=>{let b=a[g],{minX:C,maxX:x,maxCount:k}=b;return c=Math.min(c,C),f=Math.max(f,x),A=Math.max(A,k),m[g]={minX:C,maxX:x,maxY:k},m},{});e.forEach(m=>{let g=n.scale==="log"?q1():Da(),b=h[m],C=t.sharedX?c:b.minX,x=t.sharedX?f:b.maxX;g.domain([C,x]).range([0,this.chartSizes.chartWidth]),this.scales.x[m]=g}),e.forEach(m=>{let g=r.scale==="log"?q1():Da(),b=h[m],C=0,x=t.sharedY?A:b.maxY,k=[this.chartSizes.chartHeight,0],_=g.copy().domain([C,x]).range([this.chartSizes.chartHeight,Swt.TOP]);g.domain([_.invert(this.chartSizes.chartHeight),_.invert(0)]).range(k),this.scales.y[m]=g})}updateCaptionsSize(){let e=new Dc("600 14px Arial"),t=0;function n(r){return Math.max(...r.map(a=>e.getTextWidth(a)))}Object.values(this.scales.y).forEach(r=>{let{ticks:a,format:i}=b9(r,!1);t=Math.max(t,n(a.map(i)))}),this.captionsSizes={xAxisCaptionsWidth:20,yAxisCaptionsWidth:t}}createMainTitle(e,t){let n=this.chartsDimensions[e[0]],r=this.chartsDimensions[e[e.length-1]];this.mainTitle=Om(t.name,this.chartSizes.chartsWidth-n.padding.left-r.padding.right,20)}createFacetTitles(e,t){this.facetTitles=e.reduce((n,r,a)=>(t[a].length===1&&t[a][0]==="null"?n[r]=[]:n[r]=Om(t[a].join(", "),this.chartSizes.chartWidth,14),n),{})}updateMargins(){let e=24*this.mainTitle.length,t=e>0?e+24*2:0;this.margins={top:Math.max(t,24),bottom:24,left:24,right:24},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+this.chartSizes.chartsHeight+this.margins.bottom}render(e,t,n,r,a,i,o,s){var g;let{xAxis:c,yAxis:f,size:A,title:h}=t;this.updateChartSizes(A),this.updateViewport(r,n,c,f,i),this.updateCaptionsSize(),this.createFacetTitles(r,a),this.updateChartDimensions(r,n,c,f),this.createMainTitle(r,h),this.updateMargins();let m=le.jsx(Hwt,{settingsId:e,chartSettings:t,facetKeys:r,facetSettings:n,chartSizes:this.chartSizes,chartsDimensions:this.chartsDimensions,scales:this.scales,columnsCount:this.columnsCount,margins:this.margins,mainTitle:this.mainTitle,facetTitles:this.facetTitles,captionsSizes:this.captionsSizes,histogramDataByFacets:i,layers:o,aesColorGetter:Fwt(s,"fillColor")});this.component=m,(g=this.reactRoot)==null||g.render(m)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},Owt=Vwt,Qwt=10,zwt=class{constructor(e){Me(this,"type","bins");Me(this,"aes",{fillColor:"white",opacity:1});this.aes={...this.aes,...e.aes}}},Uwt=class{constructor(e){Me(this,"type","binsLine");Me(this,"aes",{opacity:1});this.aes={...this.aes,...e.aes}}},tZ=class{constructor(e){Me(this,"id");Me(this,"type","histogram");Me(this,"valueColumn");Me(this,"binsCount");Me(this,"facetSettings");Me(this,"facetBy");Me(this,"grouping");Me(this,"chartSettings");Me(this,"inheritedAes");Me(this,"layers");var t,n,r,a,i,o,s,c;s2t.parse(e),this.id=Ir.uniqueId("settings"),this.facetSettings={sharedX:!0,sharedY:!0,titlePosition:"left",...e.facetSettings},this.valueColumn=e.valueColumn,this.binsCount=e.binsCount??Qwt,this.facetBy=e.facetBy??[],this.grouping=e.grouping??[],this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(this.facetBy.length?400:600),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(this.facetBy.length?250:350)},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},yAxis:{showGrid:!0,showTicks:!0,scale:((a=e.xAxis)==null?void 0:a.scale)??"linear",...e.yAxis},xAxis:{title:e.valueColumn.label??e.valueColumn.value??"",scale:((i=e.xAxis)==null?void 0:i.scale)??"linear",showGrid:((o=e.xAxis)==null?void 0:o.showGrid)??!0,showTicks:((s=e.xAxis)==null?void 0:s.showTicks)??!0},frame:{type:((c=e.frame)==null?void 0:c.type)??"full"},legend:{show:!0,position:"right",...e.legend}},this.inheritedAes=e.inheritedAes??{},this.layers=e.layers.map(f=>{if(f.type==="bins")return new zwt(f);if(f.type==="binsLine")return new Uwt(f);vA(f,"Unknown layer type")}).filter(Boolean)}};function nZ(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}var jwt=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new Owt);Me(this,"calculatedData",null);this.settings=new tZ(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new tZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for histogram")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){return t.valueColumn.value!==n.valueColumn.value||t.facetBy.some((r,a)=>{var i;return r.value!==((i=n.facetBy[a])==null?void 0:i.value)})||t.grouping.length!==n.grouping.length||t.grouping.some((r,a)=>{var i;return r.value!==((i=n.grouping[a])==null?void 0:i.value)})||t.layers.length!==n.layers.length||t.layers.some((r,a)=>r.type!==n.layers[a].type)||t.binsCount!==n.binsCount||t.chartSettings.xAxis.scale!==n.chartSettings.xAxis.scale}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{valueColumn:t,facetBy:n,binsCount:r,chartSettings:a}=this.settings,i=n.map(f=>this.data.getColumnCategories(f.value)),o=i.length?nZ([...i]):[["null"]],s=n.map(f=>f.value)??null;this.data.setGrouping([...s]);let c=xwt(this.data,o,t,r,a.xAxis.scale);this.calculatedData={facetKeys:o.map(f=>f.join(", ")),facetKeysCombinations:o,histogramDataByFacets:c}}_updateAesInData(){this.calculatedData}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,facetSettings:r,inheritedAes:a,layers:i}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.facetKeys,this.calculatedData.facetKeysCombinations,this.calculatedData.histogramDataByFacets,i,a)}};function Gwt(e,t,n,r,a,i){let o={};return t.forEach(s=>{let c=[],f=1/0,A=1/0,h=-1/0,m=-1/0;i.forEach(g=>{e.getRowsByGrouping([...s,g]).forEach(b=>{let C=b[n.value],x=b[r.value];f=Math.min(f,C),A=Math.min(A,x),h=Math.max(h,C),m=Math.max(m,x),C!==null&&x!==null&&c.push({id:`${Object.values(b)}`,x:C,y:x,label:a?b[a.valueLabels??a.value]:null,data:b})})}),c.sort((g,b)=>g.x-b.x),o[s.join("_")]={minX:f,maxX:h,minY:A,maxY:m,dots:c}}),o}function Ywt(e,t,n,r,a){return t.reduce((i,o)=>{let s=n[o].dots;return i[o]=e.map(c=>{if(c.type==="curve")return{type:"curve",info:c,geoms:r.map(f=>{let A=s.filter(m=>a.every((g,b)=>m.data[g.value]===f[b])),h=a.reduce((m,g,b)=>(m[g.value]=f[b],m),{});return{dots:A,data:h}})};if(c.type==="dots")return{type:"dots",info:c,geoms:s};vA(c,"Unknown scatterplot layer type")}),i},{})}var rZ=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function Wwt(e,t,n){if(n==="linear")return rZ(e,t);if(n==="log"){let r=rZ(e,t),a=q1(t,t),i=r.map(o=>a.invert(o));return i[0]=t[0],i[i.length-1]=t[1],i}return[]}function J8(e,t,n){return(n==="log"?q1():Da()).domain(Wwt(e.length,t,n)).range(e)}function RP(e){let t=e.xPosition!=="middle"&&e.yPosition!=="middle",n=e.padding*(t?.7:1);return e.xPosition==="right"?e.x+n:e.xPosition==="middle"?e.x-e.width/2:e.x-e.width-n}function aZ(e){let t=e.xPosition!=="middle"&&e.yPosition!=="middle",n=e.padding*(t?.7:1);return e.yPosition==="middle"?e.y-e.height/2:e.yPosition==="top"?e.y-n-e.height:e.y+n}function Xwt(e,t){return RP(e)-t}function Kwt(e,t){return aZ(e)-t}function iZ(e){let t=RP(e),n=t+e.width,r=aZ(e),a=r+e.height;return{minX:t,maxX:n,minY:r,maxY:a}}function oZ(e,t,n){let r=Xwt(e,n),a=RP(e)+e.width+n,i=Kwt(e,t),o=i+e.height+2*t;return{minX:r,maxX:a,minY:i,maxY:o}}function Zwt(e,t,n){return e.minX>=0&&e.maxX<=t&&e.minY>=0&&e.maxY<=n}var q8=2;function Jwt(e,t=q8,n=q8){e.forEach(r=>{r.bbox=iZ(r),r.outerBBox=oZ(r,t,n)})}function eE(e,t,n,r=q8,a=q8){let i=[],o=new Dft,s=[["middle","right"],["top","right"],["bottom","right"],["middle","left"],["top","left"],["bottom","left"],["top","middle"],["bottom","middle"]];for(let c of e)for(let[f,A]of s){let h={...c,yPosition:f,xPosition:A};if(h.bbox=iZ(h),h.outerBBox=oZ(h,r,a),Zwt(h.outerBBox,t,n)&&!o.collides(h.outerBBox)){i.push(h),o.insert(h.outerBBox);break}}return i}function qwt(e){return`translate(${e},0)`}function e9t(e){return`translate(0,${e})`}function t9t(e){return e==="bottom"?`translate(0,${ed})`:`translate(${-ed},0)`}function n9t(e){return e==="bottom"?"hanging":"central"}function r9t(e){return e==="bottom"?"middle":"end"}var tE=({scale:e,tickSize:t=6,tickPadding:n=ed,orient:r="bottom",onlyPositive:a=!1,offset:i=typeof window<"u"&&window.devicePixelRatio>1?0:.5})=>{function o(C){return x=>{let k=C(x);return k===void 0?0:+k}}let{ticks:s,format:c}=b9(e,a,r==="bottom"),f=Math.max(t,0)+n,A=o(e.copy()),h=r==="bottom"?qwt:e9t,m=r==="left"?-1:1,g={[(r==="left"?"x":"y")+"2"]:m*t},b={[r==="left"?"x":"y"]:m*f};return le.jsx("g",{children:s.map((C,x)=>le.jsxs("g",{className:"tick",transform:h(A(C)+i),children:[le.jsx("line",{stroke:Zt,...g}),le.jsx("g",{transform:t9t(r),children:le.jsx("text",{fill:Zt,fontSize:"14px",fontWeight:"500",fontFamily:"Manrope",dominantBaseline:n9t(r),textAnchor:r9t(r),...b,children:c(C)})})]},x))})},a9t=1;function i9t({scaleX:e,scaleY:t,width:n,height:r,axisX:a,axisY:i,frameType:o,updatingKey:s=""}){let[c,f]=Vn.useState(e.ticks()),[A,h]=Vn.useState(t.ticks()),{significantLines:m=[]}=a,{significantLines:g=[]}=i;return Vn.useEffect(()=>{let b=e.ticks().filter(x=>!m.includes(x)),C=t.ticks().filter(x=>!g.includes(x));f(b),h(C)},[e,t,s]),le.jsxs("g",{stroke:Jf,children:[a.showGrid&&c.map(b=>{let C=e(b);return le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`x_${C}_${r}`)}),i.showGrid&&A.map(b=>{let C=t(b);return le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`y_${C}_${n}`)}),le.jsx("g",{strokeDasharray:td(a.significantLinesStyle),stroke:Zt,children:m.map(b=>{let C=e(b);return le.jsx("line",{x1:C,x2:C,y1:0,y2:r},`significant_${C}_${r}`)})}),le.jsx("g",{strokeDasharray:td(i.significantLinesStyle),stroke:Zt,children:g.map(b=>{let C=t(b);return le.jsx("line",{x1:0,x2:n,y1:C,y2:C},`significant_${C}_${n}`)})}),o!=="empty"&&le.jsxs("g",{strokeWidth:a9t,children:[(a.showGrid||o!=="left")&&le.jsx("line",{stroke:o==="left"?Jf:Zt,x1:"0",x2:n,y1:r,y2:r}),(a.showGrid||o!=="bottom")&&le.jsx("line",{stroke:o==="bottom"?Jf:Zt,x1:"0",x2:"0",y1:"0",y2:r}),(a.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:n,x2:n,y1:"0",y2:r}),(i.showGrid||o==="full")&&le.jsx("line",{stroke:o==="full"?Zt:Jf,x1:"0",x2:n,y1:"0",y2:"0"})]})]})}var o9t=new Dc("16px Manrope");function lZ(e,t){return typeof e=="string"?e:t.length?t[0].data[e.value]:""}function l9t(e,t,n=[]){let r=e.data,a=[`x: ${Ki(e.x)}`,`y: ${Ki(e.y)}`];t.label&&a.unshift(`${t.label}: ${r[t.label]}`);for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function s9t(e){return typeof e.r2>"u"?null:le.jsxs(le.Fragment,{children:[le.jsx("tspan",{children:"R"}),le.jsx("tspan",{fontSize:"10px",dy:"-8",children:"2"}),le.jsx("tspan",{dy:"8",children:` = ${Ki(e.r2)}`})]})}function u9t(e){return typeof e.pValue>"u"?null:le.jsx("tspan",{children:`p-value = ${Ki(e.pValue)}`})}function c9t(e){if(typeof e.coefficients>"u")return null;let{slope:t,slopeError:n,intercept:r,interceptError:a}=e.coefficients;return le.jsx("tspan",{children:le.jsx("tspan",{children:`slope = ${Ki(t)} ± ${Ki(n)}, intercept = ${Ki(r)} ± ${Ki(a)}`})})}function f9t(e){let t=[s9t(e),u9t(e),c9t(e)].filter(n=>n!==null);return le.jsx(le.Fragment,{children:t.map((n,r)=>le.jsxs("tspan",{children:[n,le.jsx("tspan",{children:r<t.length-1&&", "})]},r))})}var NP=3;function sZ(e,t,n,r){if(!r)return[];let a=[];for(let i of e){let o=i.label;if(!o)continue;let s=o9t.getTextMetrics(String(o));a.push({name:String(o),width:s.width,height:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent,x:t.x(i.x),y:t.y(i.y),xPosition:"right",yPosition:"middle",bbox:{minX:0,maxX:0,minY:0,maxY:0},dot:i,padding:n.dotSize(r.info.aes.dotSize,i.data)+NP})}return a}function d9t({width:e,height:t,dimensions:n,scales:r,xAxis:a,yAxis:i,frameType:o,dotsData:s,facetSettings:c,trendsData:f,keyColumn:A,margins:h,chartSizes:m,tooltips:g,tooltipsContainer:b,captionsSizes:C,facetTitle:x,onlyPositive:k,layersData:_,aesGetters:D}){let[O,I]=Vn.useState(null),{padding:$}=n,{dots:Q}=s,ee=a.showTicks?t2:0,K=i.showTicks?t2:0,re=lZ(a.title,Q),U=lZ(i.title,Q),G=n.chartEdgeSides.includes("left")||!(c!=null&&c.sharedY),Z=n.chartEdgeSides.includes("bottom")||!(c!=null&&c.sharedX),Y=n.chartEdgeSides.includes("left"),X=n.chartEdgeSides.includes("bottom"),oe={left:h.left+n.left+$.left,right:m.totalWidth-(h.left+n.left+$.left),top:h.top+n.top+$.top,bottom:m.totalHeight-(h.top+n.top+$.top)},me=!1,[ae,ye]=Vn.useState(()=>sZ(Q,r,D,_.find(Ne=>Ne.type==="dots"))),[Ce,ce]=Vn.useState(()=>eE(ae,e,t,NP,NP)),[ge,ze]=Vn.useState(null);return Vn.useEffect(()=>{ye(sZ(Q,r,D,_.find(Ne=>Ne.type==="dots")))},[Q,r,D,_]),Vn.useEffect(()=>{let Ne=eE(ae,e,t);ce(Ne)},[ae,e,t]),le.jsxs("g",{transform:`translate(${n.left+$.left},${n.top+$.top})`,children:[me,x.length&&le.jsxs("g",{children:[o==="full"&&le.jsx("rect",{x:"0",y:-$.top,height:$.top,width:e,fill:"#F7F8FA",stroke:Zt}),x.map((Ne,Ge)=>{let Oe=x.length,Xe=($.top-vP*Oe)/2;return le.jsx("text",{fontSize:"14px",fontWeight:"500",fill:Zt,x:e/2,dy:Xe+vP/2-$.top,y:Ge*vP,textAnchor:"middle",dominantBaseline:"central",children:Ne},Ge)})]}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[X&&le.jsx("text",{x:e/2,y:t+$.bottom-Rm-u9/2,children:re}),me,Y&&le.jsx("text",{x:-$.left+Rm+u9/2,y:t/2,transform:`rotate(-90,${-$.left+Rm+u9/2},${t/2})`,children:U}),me]}),le.jsx(i9t,{width:e,height:t,scaleX:r.x,scaleY:r.y,axisX:a,axisY:i,frameType:o}),Z&&le.jsxs("g",{transform:`translate(0,${t})`,children:[le.jsx(tE,{scale:r.x,orient:"bottom",onlyPositive:k.x,tickSize:ee}),me]}),G&&le.jsxs("g",{children:[le.jsx(tE,{scale:r.y,orient:"left",onlyPositive:k.y,tickSize:K}),me]}),f&&f.map(({predict:Ne,getArea:Ge,color:Oe,data:Xe,bounded:dt,xBounds:Ye,stats:rt},He)=>{let[$e,ut]=dt?Ye:r.x.domain(),ct=(ut-$e)/15,Bt=Ne($e),dn=Ne(ut);if(isNaN(Bt)||isNaN(dn))return null;let gn=D.dotColor(Oe,Xe);return le.jsxs("g",{children:[le.jsx("text",{y:He*20+20,fill:gn,x:e-8,textAnchor:"end",children:f9t(rt)}),le.jsx("path",{d:Ge(r.x,r.y,Ir.range($e,ut+ct/2,ct)),fill:gn,opacity:.2}),le.jsx("line",{x1:r.x($e),x2:r.x(ut),y1:r.y(Bt),y2:r.y(dn),stroke:gn})]},He)}),_.map((Ne,Ge)=>{if(Ne.type==="dots")return le.jsxs("g",{children:[Q.map(Oe=>le.jsx("g",{transform:`translate(${r.x(Oe.x)},${r.y(Oe.y)})`,onMouseOver:()=>I(Oe),onMouseLeave:()=>I(null),children:Af(D.dotShape(Ne.info.aes.dotShape,Oe.data),D.dotSize(Ne.info.aes.dotSize,Oe.data),D.dotColor(Ne.info.aes.dotFill,Oe.data))},Oe.id)),Ce.map(Oe=>{let{name:Xe,height:dt,bbox:Ye,width:rt}=Oe;return le.jsx("g",{children:le.jsxs("g",{transform:`translate(${Ye.minX},${Ye.minY})`,children:[le.jsx("rect",{x:"0",y:"0",width:rt,height:dt,fill:"transparent",stroke:"none",onMouseOver:()=>ze(Oe.dot),onMouseLeave:()=>ze(null)}),le.jsx("text",{x:0,y:dt/2,stroke:"white",strokeWidth:2,paintOrder:"stroke",style:{pointerEvents:"none"},fontFamily:"Manrope",fontSize:"16px",dominantBaseline:"middle",children:Xe})]})},Oe.dot.id)}),ge&&le.jsxs("g",{transform:`translate(${r.x(ge.x)},${r.y(ge.y)})`,children:[Af(D.dotShape(Ne.info.aes.dotShape,ge.data),D.dotSize(Ne.info.aes.dotSize,ge.data)+1,"white","white"),Af(D.dotShape(Ne.info.aes.dotShape,ge.data),D.dotSize(Ne.info.aes.dotSize,ge.data),D.dotColor(Ne.info.aes.dotFill,ge.data))]},"activeDot")]},Ge);if(Ne.type==="curve"&&!Ne.info.smoothing)return Ne.geoms.map((Oe,Xe)=>le.jsx("g",{children:le.jsx("polyline",{points:Oe.dots.map(dt=>`${r.x(dt.x)},${r.y(dt.y)}`).join(" "),fill:"none",stroke:D.lineColor(Ne.info.aes.lineColor,Oe.data),strokeWidth:Ne.info.aes.lineWidth,strokeDasharray:td(Ne.info.aes.lineShape)})},Xe));if(Ne.type==="curve"&&Ne.info.smoothing)return Ne.geoms.map((Oe,Xe)=>le.jsx("g",{children:le.jsx("path",{d:d3().curve(A3).x(dt=>r.x(dt.x)).y(dt=>r.y(dt.y))(Oe.dots)??"",fill:"none",stroke:D.lineColor(Ne.info.aes.lineColor,Oe.data),strokeWidth:Ne.info.aes.lineWidth,strokeDasharray:td(Ne.info.aes.lineShape)})},Xe))}),g.show&&O&&le.jsx(oc,{content:l9t(O,A,g==null?void 0:g.content),x:r.x(O.x),y:r.y(O.y),active:!0,sideDistances:oe,container:b})]})}function A9t({settingsId:e,chartSettings:t,chartSizes:n,chartsDimensions:r,facetKeys:a,facetSettings:i,scales:o,groupedDots:s,legendData:c,trendsData:f,columnsCount:A,margins:h,keyColumn:m,mainTitle:g,facetTitles:b,captionsSizes:C,onlyPositive:x,layersData:k,aesGetters:_}){let[D,O]=Vn.useState(),I=Vn.useRef(null);Vn.useEffect(()=>{I.current&&O(I.current)},[]);let{xAxis:$,yAxis:Q,title:ee,frame:K,legend:re,tooltips:U}=t,G=r[a[0]].padding,Z=r[a[A-1]].padding,Y=n.chartsWidth+yP,X=G.top;return le.jsx(f2,{dataId:e,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${n.totalWidth} ${n.totalHeight}`,width:n.totalWidth,height:n.totalHeight,children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${h.left},${h.top})`,fontFamily:"Manrope",children:[le.jsx(d2,{title:g,show:ee.show,position:ee.position,leftPadding:G.left,rightPadding:Z.right,chartsWidth:n.chartsWidth}),a.map(oe=>le.jsx(d9t,{scales:{x:o.x[oe],y:o.y[oe]},width:n.chartWidth,height:n.chartHeight,dimensions:r[oe],margins:h,chartSizes:n,facetSettings:i,xAxis:$,yAxis:Q,frameType:K.type,dotsData:s[oe],trendsData:f?f[oe]:null,tooltips:U,tooltipsContainer:D,keyColumn:m,facetTitle:b[oe],captionsSizes:C,layersData:k[oe],onlyPositive:x,aesGetters:_},oe)),re.show&&le.jsx("g",{transform:`translate(${Y},${X})`,children:le.jsx(y9,{legendData:c})})]}),le.jsx("g",{ref:I})]})})}function p9t(e,t,n,r){let a=[];return e%n===n-1&&a.push("right"),e%n===0&&a.push("left"),e<n&&a.push("top"),(Math.ceil((e+1)/n)===r||Math.ceil((e+1)/n)===r-1&&e%n>(t-1)%n)&&a.push("bottom"),a}function h9t(e,t,n,r,a,i,o){let s=i.includes("left")||!(o!=null&&o.sharedY),c=i.includes("left")&&t.title!=="",f=i.includes("bottom")||!(o!=null&&o.sharedX),A=i.includes("bottom")&&e.title!=="",h=n.yAxisCaptionsWidth+2*gP,m=(t.showTicks?t2:0)+gP,g=c?u9+Rm:0,b=n.xAxisCaptionsWidth+2*gP,C=e.showTicks?t2:0,x=A?u9+Rm:0,k=h+m+g+LX,_=b+C+x+LX,D=Math.max(...r.map(O=>a[O].length));return{left:s?k:Rm,top:D===0?0:p3t*2+D*m9,bottom:f?_+8:Rm,right:Rm}}function m9t(e,t,n){let r=[];for(let a=0;a<t;a++)r.push(e.slice(a*n,a*n+n));return r}function v9t(e,t){let n=Math.floor(e/t),r=e-n*t;return[n,r]}function g9t(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e&&e.type==="grouping"}function v2(e,t){return function(n,r){var a,i;if($m(n)&&t==="dotSize"){let{domain:o,range:s}=n,c=Ny().domain(o).range(s)(Number(r[n.columnName.value]));return Math.max(1,c)}if($m(n)&&(t==="dotFill"||t==="lineColor")){let{domain:o,range:s,type:c="linear"}=n;return J8(s,o,c)(Number(r[n.columnName.value]))}if(g9t(n)){let o=n.value;return(i=((a=e[o])==null?void 0:a[String(r[o])])??hP)==null?void 0:i[t]}return n}}function y9t(e){return{dotShape:v2(e,"dotShape"),dotColor:v2(e,"dotFill"),dotSize:v2(e,"dotSize"),lineShape:v2(e,"lineShape"),lineColor:v2(e,"lineColor"),trendColor:v2(e,"dotFill")}}var w9t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"margins",{top:qf,bottom:qf,left:qf,right:qf});Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:{null:Da().domain([0,10]).range([0,600])},y:{null:Da().domain([0,10]).range([350,0])}});Me(this,"captionsSizes",{xAxisCaptionsWidth:30,yAxisCaptionsWidth:100});Me(this,"facetTitles",{});Me(this,"mainTitle",[]);Me(this,"legend",{width:0,height:0,items:[]})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateChartSizes(e){this.chartSizes.chartWidth=e.width,this.chartSizes.chartHeight=e.height}updateChartDimensions(e,t,n,r){let{chartWidth:a,chartHeight:i}=this.chartSizes,o=0,s=0;this.chartsDimensions=e.reduce((A,h,m)=>{let[g,b]=v9t(m,this.columnsCount),C=p9t(m,e.length,this.columnsCount,this.rowsCount),x=h9t(n,r,this.captionsSizes,m9t(e,this.rowsCount,this.columnsCount)[g],this.facetTitles,C,t),k=a+x.left+x.right,_=i+x.top+x.bottom;return A[h]={left:o,top:s,chartEdgeSides:C,padding:x,inner:{width:a,height:i},outer:{width:k,height:_}},o+=k,b===this.columnsCount-1&&(o=0,s+=_),A},{});let c=Math.max(...e.map(A=>this.chartsDimensions[A].outer.width+this.chartsDimensions[A].left)),f=Math.max(...e.map(A=>this.chartsDimensions[A].outer.height+this.chartsDimensions[A].top));this.chartSizes.chartsWidth=c,this.chartSizes.chartsHeight=f}updateViewport(e,t,n,r,a,i){let o=e.length,s=Math.min(t.nRows??o,o),c=Math.min(t.nCols??o,o);this.columnsCount=t.nRows?Math.ceil(o/s):c,this.rowsCount=Math.ceil(o/this.columnsCount);let[f,A]=[1/0,-1/0],[h,m]=[1/0,-1/0],g=e.reduce((C,x)=>{let k=a[x],{minX:_,minY:D,maxX:O,maxY:I}=k;return f=Math.min(f,_),h=Math.min(h,D),A=Math.max(A,O),m=Math.max(m,I),C[x]={minX:_,maxX:O,minY:D,maxY:I},C},{});e.forEach(C=>{let x=n.scale==="log"?Rv():Da(),k=g[C],_=n.lowerValue?Number(n.lowerValue):t.sharedX?f:k.minX,D=n.upperValue?Number(n.upperValue):t.sharedX?A:k.maxX;if(typeof n.symmetricRange<"u"){let $=n.symmetricRange;if($>=_&&$<=D){let Q=Math.max($-_,D-$);_=$-Q,D=$+Q}}let O=[0,this.chartSizes.chartWidth],I=x.copy().domain([_,D]).range([L8.LEFT,this.chartSizes.chartWidth-L8.RIGHT]);x.domain([I.invert(0),I.invert(this.chartSizes.chartWidth)]).range(O).nice(),this.scales.x[C]=x});let b=e.reduce((C,x)=>{let k=i?i[x]:[];return C[x]=k.reduce((_,D)=>{let O=D.bounded?D.xBounds:this.scales.x[x].domain(),I=D.getInterval(O[0]),$=D.getInterval(O[1]);return _.minY=Math.min(_.minY,isNaN(I.left)?_.minY:I.left,isNaN($.left)?_.minY:$.left),_.maxY=Math.max(_.maxY,isNaN(I.right)?_.maxY:I.right,isNaN($.right)?_.maxY:$.right),_},{minY:1/0,maxY:-1/0}),h=Math.min(h,C[x].minY),m=Math.max(m,C[x].maxY),C},{});e.forEach(C=>{let x=r.scale==="log"?Rv():Da(),k=g[C],_=b[C],D=r.lowerValue?Number(r.lowerValue):t.sharedY?h:Math.min(k.minY,_.minY),O=r.upperValue?Number(r.upperValue):t.sharedY?m:Math.max(k.maxY,_.maxY);if(typeof r.symmetricRange<"u"){let Q=r.symmetricRange;if(Q>=D&&Q<=O){let ee=Math.max(Q-D,O-Q);D=Q-ee,O=Q+ee}}let I=[this.chartSizes.chartHeight,0],$=x.copy().domain([D,O]).range([this.chartSizes.chartHeight-L8.BOTTOM,L8.TOP]);x.domain([$.invert(this.chartSizes.chartHeight),$.invert(0)]).range(I).nice(),this.scales.y[C]=x})}updateCaptionsSize(e){let t=new Dc("600 14px Arial"),n=0;function r(a){return Math.max(...a.map(i=>t.getTextWidth(i)))}Object.values(this.scales.y).forEach(a=>{let{ticks:i,format:o}=b9(a,e);n=Math.max(n,r(i.map(o)))}),this.captionsSizes={xAxisCaptionsWidth:20,yAxisCaptionsWidth:n}}createMainTitle(e,t){let n=this.chartsDimensions[e[0]],r=this.chartsDimensions[e[e.length-1]];this.mainTitle=Om(t.name,this.chartSizes.chartsWidth-n.padding.left-r.padding.right,20)}createFacetTitles(e,t){this.facetTitles=e.reduce((n,r,a)=>(t[a].length===1&&t[a][0]==="null"?n[r]=[]:n[r]=Om(t[a].join(", "),this.chartSizes.chartWidth,14),n),{})}updateMargins(){let e=24*this.mainTitle.length,t=e>0?e+24*2:0;this.margins={top:Math.max(t,qf),bottom:qf,left:qf,right:this.legend.width},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight,this.legend.height)+this.margins.bottom}updateLegendSize(e,t,n,r){if(!e.show){this.legend={width:0,height:0,items:[]};return}let a=[],i={width:0,height:0,left:0,top:0};if(n.forEach(A=>{let h=t[A.value];if(h.usedAes.length===0||!h.aesMap)return;let m={};h.values.forEach(C=>{m[C]||(m[C]={...mP}),h.usedAes.forEach(x=>{var k,_,D;(x==="dotFill"||x==="lineColor")&&(m[C].color=((k=h.aesMap[C])==null?void 0:k[x])??Zt),x==="dotShape"&&(m[C].shape=((_=h.aesMap[C])==null?void 0:_[x])??"21"),x==="dotSize"&&(m[C].size=((D=h.aesMap[C])==null?void 0:D[x])??3)})});let g=A.label??A.value,b=Hl().domain(h.values).range(h.values.map(C=>m[C]));a.push({...i,id:A.value,type:"dots",title:g,scale:b,values:h.values,labels:h.labels})}),r.forEach(A=>{if(A.type==="dots"&&$m(A.aes.dotFill)){let{domain:h,range:m,columnName:g,type:b="linear"}=A.aes.dotFill,C=g.label??g.value,x=J8(m,h,"linear"),k=(b==="log"?q1():Da()).domain(h).range([height,0]),_=a2(k,h);a.push({...i,id:"dotFill",type:"continuous",title:C,scale:x,tickPositionScale:k,values:_})}if(A.type==="dots"&&$m(A.aes.dotSize)){let{columnName:h,domain:m,range:g}=A.aes.dotSize,b=h.label??h.value,C=Ny(m,g),x=C.ticks(3),k=C.tickFormat(3),_=x.reduce((D,O)=>(D[String(O)]=k(O),D),{});a.push({...i,id:h.value,type:"size",title:b,scale:C,values:x,labels:_})}}),!a.length){this.legend={width:0,height:0,items:[]};return}let o=w9(a,this.chartSizes.chartHeight),s=o[o.length-1],c=s.left+s.width+2*yP,f=this.chartSizes.chartHeight;this.legend={width:c,height:f,items:o}}render(e,t,n,r,a,i,o,s,c,f,A,h,m,g){var O;let{xAxis:b,yAxis:C,size:x,title:k,legend:_}=t;this.updateChartSizes(x),this.updateViewport(r,n,b,C,i,o),this.updateCaptionsSize(c.y),this.createFacetTitles(r,a),this.updateChartDimensions(r,n,b,C),this.updateLegendSize(_,f,m,g),this.createMainTitle(r,k),this.updateMargins();let D=le.jsx(A9t,{settingsId:e,chartSettings:t,facetKeys:r,facetSettings:n,chartSizes:this.chartSizes,chartsDimensions:this.chartsDimensions,scales:this.scales,groupedDots:i,trendsData:o,legendData:this.legend,columnsCount:this.columnsCount,margins:this.margins,keyColumn:s,mainTitle:this.mainTitle,facetTitles:this.facetTitles,captionsSizes:this.captionsSizes,onlyPositive:c,layersData:A,aesGetters:y9t(h)});this.component=D,(O=this.reactRoot)==null||O.render(D)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},C9t=w9t,b9t=class{constructor(e){Me(this,"type","dots");Me(this,"aes",{dotFill:Zt,dotShape:"21",dotSize:3,opacity:1});this.aes={...this.aes,...e.aes}}},E9t=class{constructor(e){Me(this,"type","curve");Me(this,"smoothing");Me(this,"aes",{lineColor:Zt,lineWidth:1,lineShape:"solid",opacity:1});this.smoothing=e.smoothing??!1,this.aes={...this.aes,...e.aes}}},uZ=class{constructor(e){Me(this,"id");Me(this,"type","scatterplot");Me(this,"keyColumn");Me(this,"facetSettings");Me(this,"x");Me(this,"y");Me(this,"facetBy");Me(this,"grouping");Me(this,"label");Me(this,"chartSettings");Me(this,"inheritedAes");Me(this,"trend");Me(this,"layers");var t,n,r,a;W3t.parse(e),this.id=Ir.uniqueId("settings"),this.keyColumn=e.keyColumn,this.facetSettings={sharedX:!0,sharedY:!0,titlePosition:"left",...e.facetSettings},this.x=e.x,this.y=e.y,this.facetBy=e.facetBy??[],this.grouping=e.grouping??[],this.label=e.label??null,this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??(this.facetBy.length?400:600),height:((n=e==null?void 0:e.size)==null?void 0:n.height)??(this.facetBy.length?250:350)},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},yAxis:{title:e.y.label??e.y.value,scale:"linear",showGrid:!0,showTicks:!0,...e.yAxis},xAxis:{title:e.x.label??e.x.value,scale:"linear",showGrid:!0,showTicks:!0,...e.xAxis},frame:{type:((a=e.frame)==null?void 0:a.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.inheritedAes=e.inheritedAes??{},this.trend=e!=null&&e.trend?{bounded:e.trend.bounded??!1,color:e.trend.color??Zt}:null,this.layers=e.layers.map(i=>{if(i.type==="dots")return new b9t(i);if(i.type==="curve")return new E9t(i);vA(i,"Unknown layer type")}).filter(Boolean)}},x9t=oht(r3t()),cZ=.05;function S9t(e){let t=3.3871328727963665,n=133.14166789178438,r=1971.5909503065513,a=13731.69376550946,i=45921.95393154987,o=67265.7709270087,s=33430.57558358813,c=2509.0809287301227,f=42.31333070160091,A=687.1870074920579,h=5394.196021424751,m=21213.794301586597,g=39307.89580009271,b=28729.085735721943,C=5226.495278852854,x=1.4234371107496835,k=4.630337846156546,_=5.769497221460691,D=3.6478483247632045,O=1.2704582524523684,I=.2417807251774506,$=.022723844989269184,Q=.0007745450142783414,ee=2.053191626637759,K=1.6763848301838038,re=.6897673349851,U=.14810397642748008,G=.015198666563616457,Z=.0005475938084995345,Y=10507500716444169e-25,X=6.657904643501103,oe=5.463784911164114,me=1.7848265399172913,ae=.29656057182850487,ye=.026532189526576124,Ce=.0012426609473880784,ce=27115555687434876e-21,ge=20103343992922881e-23,ze=.599832206555888,Ne=.1369298809227358,Ge=.014875361290850615,Oe=.0007868691311456133,Xe=18463183175100548e-21,dt=1421511758316446e-22,Ye=20442631033899397e-31,rt=e-.5,He,$e;return Math.abs(rt)<=.425?(He=.180625-rt*rt,$e=rt*(((((((c*He+s)*He+o)*He+i)*He+a)*He+r)*He+n)*He+t)/(((((((C*He+b)*He+g)*He+m)*He+h)*He+A)*He+f)*He+1),$e):(He=e,He=Math.sqrt(-Math.log(He)),He<=5?(He+=-1.6,$e=(((((((Q*He+$)*He+I)*He+O)*He+D)*He+_)*He+k)*He+x)/(((((((Y*He+Z)*He+G)*He+U)*He+re)*He+K)*He+ee)*He+1)):(He+=-5,$e=(((((((ge*He+ce)*He+Ce)*He+ye)*He+ae)*He+me)*He+oe)*He+X)/(((((((Ye*He+dt)*He+Xe)*He+Oe)*He+Ge)*He+Ne)*He+ze)*He+1)),$e=-$e,$e)}function fZ(e,t){let{sin:n,cos:r,sqrt:a,pow:i,exp:o,PI:s}=Math,c,f;if(t==1)return r(e*s/2)/n(e*s/2);if(t==2)return a(2/(e*(2-e))-2);let A=1/(t-.5),h=48/(A*A),m=((20700*A/h-98)*A-16)*A+96.36,g=((94.5/(h+m)-3)/h+1)*a(A*s*.5)*t;return c=g*e,f=i(c,2/t),f>.05+A?(c=S9t(e/2),f=c*c,t<5&&(m=m+.3*(t-4.5)*(c+.6)),m=(((.05*g*c-5)*c-7)*c-2)*c+h+m,f=(((((.4*f+6.3)*f+36)*f+94.5)/m-f-3)/h+1)*c,f=A*f*f,f>.002?f=o(f)-1:f=.5*f*f+f):f=((1/(((t+6)/(t*f)-.089*g-.822)*(t+2)*3)+.5/(t+4))*f-1)*(t+1)/(t+2)+1/f,a(t*f)}function B9t(e){let t=e.length,n=0,r=0,a=0,i=0;for(let c=0;c<e.length;++c){let f=e[c].x,A=e[c].y;if(!Number.isFinite(f)||!Number.isFinite(A)){--t;continue}n+=f,r+=A,a+=f*A,i+=f*f}let o=(t*a-n*r)/(t*i-n*n),s=(r-o*n)/t;return[o,s]}function k9t(e,t,n){let r=A=>A*t+n,a=e.length,i=Sc(e,A=>A.x)/e.length,o=fZ(cZ,a-2),s=Math.sqrt(Sc(e,A=>(A.y-r(A.x))**2)/(a-2)/Sc(e,A=>(A.x-i)**2)),c=s*o,f=s*Math.sqrt(Sc(e,A=>A.x**2)/a)*o;return{slope:t,intercept:n,slopeError:c,interceptError:f}}function T9t(e,t){let n=Sc(e,s=>s.x)/e.length,r=0,a=0;for(let s=0;s<e.length;++s)r+=Math.pow(e[s].x-n,2),a+=Math.pow(e[s].y-t(e[s].x),2);let i=Math.sqrt(a/(e.length-2)),o=fZ(cZ,e.length-2);return function(s){let c=t(s),f=i*Math.sqrt(1/e.length+Math.pow(s-n,2)/r),A=c-o*f,h=c+o*f;return{x:s,y:c,left:isNaN(A)?c:A,right:isNaN(h)?c:h}}}function _9t(e){let t=e.length;return Math.pow((t*Sc(e,n=>n.x*n.y)-Sc(e,n=>n.x)*Sc(e,n=>n.y))/(Math.sqrt(t*Sc(e,n=>n.x*n.x)-Math.pow(Sc(e,n=>n.x),2))*Math.sqrt(t*Sc(e,n=>n.y*n.y)-Math.pow(Sc(e,n=>n.y),2))),2)}function P9t(e,t){let n=tu(e,t);return tu(e.map(r=>(t(r)-n)**2))}function dZ(e,t){return Math.sqrt(P9t(e,t))}function M9t(e,t,n){let r=tu(e,t),a=tu(e,n),i=e.length;return Sc(e,o=>(o.x-r)*(o.y-a))/i}function D9t(e){let t=M9t(e,a=>a.x,a=>a.y),n=dZ(e,a=>a.x),r=dZ(e,a=>a.y);return t/(n*r)}function H9t(e,t){let n=e.length,r=1,a=1,i=n-r-1,o=tu(e,m=>m.y),s=Sc(e,m=>(t(m.x)-o)**2),c=Sc(e,m=>(t(m.x)-m.y)**2),f=s/a,A=c/i,h=f/A;return 1-(0,x9t.default)(h,a,i)}function I9t(e,t,n,r,a){return a?t.reduce((i,o)=>{let s=e[o].dots;return i[o]=n.map(c=>{let f=s.filter(x=>r.every((k,_)=>String(x.data[k.value])===c[_])),[A=0,h=0]=$A(f,x=>x.x),[m,g]=B9t(f),b=x=>m*x+g,C=T9t(f,b);return{predict:b,getInterval:C,getArea:(x,k,_)=>VB().x(D=>x(D.x)).y0(D=>k(D.left)).y1(D=>k(D.right))(_.map(C))??"",color:a.color,bounded:a.bounded,data:f[0].data,showStats:!0,xBounds:[A,h],stats:{r2:_9t(f),r:D9t(f),pValue:H9t(f,b),coefficients:k9t(f,m,g)}}}),i},{}):null}function AZ(e){if(!e.length)return[];let t=[[]];return e.forEach(n=>{let r=[];n.forEach(a=>{r.push(...t.map(i=>[...i,a]))}),t=r}),t}function pZ(e){return typeof e=="object"&&"type"in e&&e.type==="grouping"}function L9t(e,t,n,r){return t.reduce((a,i)=>{let o=Ir.uniqBy(e.rows,h=>h[i.value]),s=h=>String(h[i.value]),c=h=>i.valueLabels?String(h[i.valueLabels]):s(h),f=new Set;n.forEach(h=>{h.aes&&Object.entries(h.aes).forEach(([m,g])=>{pZ(g)&&g.value===i.value&&f.add(m)})});let A=o.reduce((h,m)=>(h[s(m)]=c(m),h),{});return a[i.value]={values:o.map(s).filter(h=>h!=="null").sort((h,m)=>A[h].localeCompare(A[m],"en",{numeric:!0})),usedAes:[...f],aesMap:r[i.value],labels:A},a},{})}var R9t=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new C9t);Me(this,"calculatedData",null);this.settings=new uZ(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new uZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for scatterplot")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.facetBy.some((s,c)=>{var f;return s.value!==((f=n.facetBy[c])==null?void 0:f.value)})||t.grouping.length!==n.grouping.length||t.grouping.some((s,c)=>{var f;return s.value!==((f=n.grouping[c])==null?void 0:f.value)})||(((r=t.label)==null?void 0:r.value)||((a=n.label)==null?void 0:a.value))&&((i=t.label)==null?void 0:i.value)!==((o=n.label)==null?void 0:o.value)||t.layers.length!==n.layers.length||t.layers.some((s,c)=>s.type!==n.layers[c].type)||!!t.trend!=!!n.trend}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{x:t,y:n,facetBy:r,grouping:a,keyColumn:i,trend:o,layers:s,inheritedAes:c,label:f}=this.settings,A=this.data.getColumnCategories(i.value),h=r.map($=>this.data.getColumnCategories($.value)),m=a.map($=>this.data.getColumnCategories($.value)),g=h.length?AZ([...h]):[["null"]],b=m.length?AZ([...m]):[["null"]],C=r.map($=>$.value)??null;this.data.setGrouping([...C,i.value]);let x={x:this.data.rows.every($=>{let Q=$[t.value];return Q===null||!(Number(Q)<0)}),y:this.data.rows.every($=>{let Q=$[n.value];return Q===null||!(Number(Q)<0)})},k=Gwt(this.data,g,t,n,f,A),_=Object.keys(k),D=I9t(k,_,b,a,o),O=L9t(this.data,a,s,c),I=Ywt(s,_,k,b,a);this.calculatedData={onlyPositive:x,dotsByFacets:k,facetKeys:_,facetKeysCombinations:g,trendsData:D,legendLabels:O,layersData:I}}_updateAesInData(){let t=this.calculatedData;if(!t)return;let{grouping:n,trend:r,layers:a,inheritedAes:i}=this.settings,{facetKeys:o,trendsData:s}=t;o.forEach(c=>{for(let f=0;f<a.length;f++)t.layersData[c][f].info=a[f]}),n.forEach(c=>{let f=new Set;a.forEach(A=>{A.aes&&Object.entries(A.aes).forEach(([h,m])=>{pZ(m)&&m.value===c.value&&f.add(h)})}),t.legendLabels[c.value].usedAes=[...f],t.legendLabels[c.value].aesMap=i[c.value]}),s&&r&&Object.keys(s).forEach(c=>{s[c].forEach(f=>{f.color=r.color,f.bounded=r.bounded})})}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,facetSettings:r,grouping:a,keyColumn:i,inheritedAes:o,layers:s}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.facetKeys,this.calculatedData.facetKeysCombinations,this.calculatedData.dotsByFacets,this.calculatedData.trendsData,i,this.calculatedData.onlyPositive,this.calculatedData.legendLabels,this.calculatedData.layersData,o,a,s)}},nE={TOP:30,BOTTOM:30,LEFT:30,RIGHT:30},E9=20,hZ=4,$P=24;function N9t(e,t,n=[]){let r=e.data,a=[`x: ${Ki(e.x)}`,`y: ${Ki(e.y)}`];t.label&&a.unshift(`${t.label}: ${r[t.label]}`);for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function mZ(e){return typeof e=="string"?e:e.label??e.value}var vZ=d3().curve(A3);function $9t({scales:e,chartSettings:t,mainTitle:n,keyColumn:r,margins:a,chartSizes:i,onlyPositive:o,container:s,zoomStateKey:c,legendData:f,dotsByGrouping:A,layers:h,aesGetters:m,selectedDot:g=null}){var G;let{title:b,xAxis:C,yAxis:x,frame:k,legend:_}=t,D=C.showTicks?hZ:0,O=x.showTicks?hZ:0,I=C.title,$=x.title,Q={left:0,right:i.chartWidth,top:0,bottom:i.chartHeight};if(!s)return null;let ee=h.find(Z=>Z.type==="curve"),[K,re]=Vn.useState([]);function U(){let Z=Object.entries(A).map(([Y,X])=>({key:Y,d:ee!=null&&ee.smoothing?vZ(X)??"":X.map(oe=>`${e.x(oe.x)},${e.y(oe.y)}`).join(" "),dot:X[0]}));re(Z)}return Vn.useEffect(()=>{ee&&(vZ.x(Z=>e.x(Z.x)).y(Z=>e.y(Z.y)),U())},[c]),Vn.useEffect(()=>{ee&&U()},[ee==null?void 0:ee.smoothing]),le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${i.totalWidth} ${i.totalHeight}`,width:i.totalWidth,height:i.totalHeight,style:{pointerEvents:"none"},children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${a.left},${a.top})`,fontFamily:"Manrope",children:[le.jsx("clipPath",{id:"viewportClipPath",children:le.jsx("rect",{x:"0",y:"0",width:i.chartWidth,height:i.chartHeight})}),le.jsx(d2,{title:n,show:b.show,position:b.position,leftPadding:a.left,rightPadding:a.right,chartsWidth:i.chartWidth}),le.jsxs("g",{dominantBaseline:"central",textAnchor:"middle",fontWeight:"500",fontSize:"14px",fill:Zt,children:[I&&le.jsx("text",{x:i.chartWidth/2,y:i.chartHeight+a.bottom-E9/2,children:mZ(I)}),$&&le.jsx("text",{x:-a.left+E9/2,y:i.chartHeight/2,transform:`rotate(-90,${-a.left+E9/2},${i.chartHeight/2})`,children:mZ($)})]}),le.jsx(eZ,{width:i.chartWidth,height:i.chartHeight,scaleX:e.x,scaleY:e.y,axisX:C,axisY:x,updatingKey:c,frameType:k.type}),le.jsx("g",{transform:`translate(0,${i.chartHeight})`,children:le.jsx(tE,{scale:e.x,orient:"bottom",onlyPositive:o.x,tickSize:D})}),le.jsx("g",{children:le.jsx(tE,{scale:e.y,orient:"left",onlyPositive:o.y,tickSize:O})}),ee&&ee.smoothing&&le.jsx("g",{clipPath:"url(#viewportClipPath)",children:K.map(({key:Z,d:Y,dot:X})=>le.jsx("path",{d:Y,fill:"none",stroke:m.dotFill(X.data),strokeWidth:ee.aes.lineWidth,strokeDasharray:m.lineType(X.data)},Z))}),ee&&!ee.smoothing&&le.jsx("g",{clipPath:"url(#viewportClipPath)",children:K.map(({key:Z,d:Y,dot:X})=>le.jsx("polyline",{points:Y,fill:"none",stroke:m.dotFill(X.data),strokeWidth:ee.aes.lineWidth,strokeDasharray:m.lineType(X.data)},Z))}),g&&le.jsx(oc,{content:N9t(g,r,(G=t.tooltips)==null?void 0:G.content),x:e.x(g.x),y:e.y(g.y),active:!0,sideDistances:Q,container:s}),_.show&&le.jsx("g",{transform:`translate(${i.chartWidth+$P},0)`,children:le.jsx(y9,{legendData:f})})]})]})}var F9t=gb.memo($9t),V9t=20;function O9t({scales:e,chartSizes:t,disabled:n,onPolygonUpdate:r}){let[a,i]=Vn.useState([]),[o,s]=Vn.useState(null),[c,f]=Vn.useState(null),A=Vn.useRef(null),h=Vn.useRef(null),m=Vn.useRef(null),g=Vn.useRef(a);function b(){A.current=null,h.current=null,m.current=null,g.current=[],i([]),s(null)}function C(_){n||_.key!=="Escape"||b()}Vn.useEffect(()=>{n&&(A.current=null,h.current=null,m.current=null,s(null))},[n]),Vn.useEffect(()=>(document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)),[]),Vn.useEffect(()=>{if(o&&c)return;if(a.length===0){r([]);return}let _=a.map(D=>D[0]);_.push(a[a.length-1][1]),r(_)},[a]);function x(){if(!A.current||n)return;let _=[...A.current],D=e.x.invert(_[0]),O=e.y.invert(_[1]),I=g.current,$=m.current,Q=h.current&&I.length>1?Math.sqrt((_[0]-h.current[0])**2+(_[1]-h.current[1])**2):1/0;m.current?m.current&&Q>V9t?(I=[...I,[m.current,[D,O]]],$=[D,O]):(I=[...I,[m.current,[D,O]]],I.length>2&&(I=[...I,[I[I.length-1][1],I[0][0]]]),$=null,I.length<=2?r([]):r(I.map(ee=>ee[0])),h.current=null):(h.current=_,I=[],$=[D,O],r([])),i(I),s($),g.current=I,m.current=$}function k(_){let D=[_.nativeEvent.offsetX,_.nativeEvent.offsetY];f(D),A.current=D}return le.jsxs("g",{children:[le.jsx("rect",{fill:"transparent",width:t.chartWidth,height:t.chartHeight,onMouseMove:k,onClick:x}),a.map(([_,D],O)=>le.jsx("line",{x1:e.x(_[0]),y1:e.y(_[1]),x2:e.x(D[0]),y2:e.y(D[1]),stroke:Zt,style:{pointerEvents:"none"}},O)),o&&c&&le.jsx("line",{x1:e.x(o[0]),y1:e.y(o[1]),x2:c[0],y2:c[1],stroke:Zt,style:{pointerEvents:"none"}},"lastLine")]})}function Q9t({scales:e,container:t,labels:n,aesGetters:r,chartSizes:a,onPolygonUpdate:i,lassoMode:o,selectedDot:s=null}){return t?le.jsxs("g",{children:[n.map(c=>{let{name:f,height:A,bbox:h,width:m}=c;return le.jsx("g",{children:le.jsxs("g",{transform:`translate(${h.minX},${h.minY})`,children:[le.jsx("rect",{x:"0",y:"0",width:m,height:A,fill:"transparent",stroke:"none"}),le.jsx("text",{x:0,y:A/2,stroke:"white",strokeWidth:2,paintOrder:"stroke",style:{pointerEvents:"none"},fontFamily:"Manrope",fontSize:"16px",dominantBaseline:"middle",children:f})]})},c.dot.id)}),le.jsx(O9t,{scales:e,chartSizes:a,disabled:!o,onPolygonUpdate:i}),s&&le.jsx("circle",{cx:e.x(s.x),cy:e.y(s.y),r:5,fill:r.dotFill(s.data)})]}):null}var z9t=Q9t;function U9t({settingsId:e,scales:t,chartSettings:n,mainTitle:r,keyColumn:a,margins:i,chartSizes:o,captionsSizes:s,onlyPositive:c,container:f,zoomStateKey:A,aesGetters:h,legendData:m,labels:g,onPolygonUpdate:b,lassoMode:C,dotsByGrouping:x,layers:k,selectedDot:_=null}){return f?le.jsx("div",{children:le.jsxs(f2,{dataId:e,children:[le.jsx(F9t,{aesGetters:h,dotsByGrouping:x,layers:k,scales:t,keyColumn:a,margins:i,mainTitle:r,captionsSizes:s,chartSettings:n,chartSizes:o,onlyPositive:c,container:f,selectedDot:_,zoomStateKey:A,legendData:m}),HB.createPortal(le.jsx(z9t,{scales:t,container:f,aesGetters:h,labels:g,chartSizes:o,selectedDot:_,onPolygonUpdate:b,lassoMode:C}),f)]})}):null}var gZ=e=>e.selection()!==e,yZ=(e,t)=>{e=e||"g";let n=(i,o)=>o,r=null,a=function(i,o){o=o||(g=>g);let s=i.selection(),c=gZ(i)?i:null,f=s.selectChildren(t==null?e:`${e}.${t}`).data(o,n),A=f.enter().append(e).attr("class",t),h=f.exit();f=f.merge(A);let m=c||r;return m&&(f=f.transition(m).style("opacity",1),A.style("opacity",1e-6),h=h.transition(m).style("opacity",1e-6)),h.remove(),f.enter=()=>A,f.exit=()=>h,f};return a.element=(...i)=>i.length?(e=i[0],a):e,a.className=(...i)=>i.length?(t=i[0],a):t,a.key=(...i)=>i.length?(n=i[0],a):n,a.transition=(...i)=>i.length?(r=i[0],a):r,a},wZ=(e,t,n)=>{let r=t[n];if(typeof r!="function")throw new Error(`Attempt to rebind ${n} which isn't a function on the source object`);return(...a)=>{var i=r.apply(t,a);return i===t?e:i}},CZ=(e,t,...n)=>{for(let r of n)e[r]=wZ(e,t,r);return e},j9t=e=>t=>e.reduce((n,r)=>n&&r(n),t),FP=(e,t,...n)=>{let r=j9t(n);for(let a of Object.keys(t)){let i=r(a);i&&(e[i]=wZ(e,t,a))}return e},G9t=e=>e.map(t=>typeof t=="string"?new RegExp(`^${t}$`):t),Y9t=(...e)=>(e=G9t(e),t=>e.every(n=>!n.test(t))&&t),g2=e=>typeof e=="function"?e:()=>e;function W9t(){let e=arguments;return function(t,n){for(let r=0,a=e.length;r<a;r++)if(e[r](t,n)==null)return!1;return!0}}var X9t=(e,t)=>{switch(e){case"left":return t/2;case"right":return-t/2;default:return 0}},bZ=e=>{let t=Object.assign({},e),n=()=>{};return Object.keys(t).forEach(r=>{n[r]=(...a)=>a.length?(t[r]=a[0],n):t[r]}),n},K9t=()=>{let e=()=>0,t=s=>s.x,n=s=>s.y,r="center",a=()=>5,i="vertical",o=bZ({decorate:()=>{},defined:(s,c)=>W9t(e,t,n)(s,c),xScale:J1(),yScale:J1()});return o.values=(s,c)=>{let f=a(s,c),A=X9t(r,f),h=o.xScale(),m=o.yScale();if(i==="vertical"){let g=m(n(s,c),c),b=m(e(s,c),c),C=h(t(s,c),c)+A;return{d:s,x:C,y:g,y0:b,width:f,height:g-b,origin:[C,g],baseOrigin:[C,b],transposedX:C,transposedY:g}}else{let g=h(n(s,c),c),b=h(e(s,c),c),C=m(t(s,c),c)+A;return{d:s,x:C,y:g,y0:b,width:f,height:g-b,origin:[g,C],baseOrigin:[b,C],transposedX:g,transposedY:C}}},o.xValues=()=>i==="vertical"?[t]:[e,n],o.yValues=()=>i!=="vertical"?[t]:[e,n],o.baseValue=(...s)=>s.length?(e=g2(s[0]),o):e,o.crossValue=(...s)=>s.length?(t=g2(s[0]),o):t,o.mainValue=(...s)=>s.length?(n=g2(s[0]),o):n,o.bandwidth=(...s)=>s.length?(a=g2(s[0]),o):a,o.align=(...s)=>s.length?(r=s[0],o):r,o.orient=(...s)=>s.length?(i=s[0],o):i,o},Z9t=()=>{let e=K9t(),t=g2(64),n=X$,r=qw(),a=qw(),i=qw().type(nh.UNSIGNED_SHORT),o=qw().type(nh.UNSIGNED_BYTE),s=L0t().crossValueAttribute(r).mainValueAttribute(a).sizeAttribute(i).definedAttribute(o),c=(b,C)=>!1,f=z0t,A=[],h=null,m=null,g=b=>{let C=f(e.xScale()),x=f(e.yScale()),k=!c(A,b);k&&(A=b,i.value((_,D)=>t(_,D)).data(b),o.value((_,D)=>e.defined()(_,D)).data(b)),(k||C.scale!==h)&&(h=C.scale,e.orient()==="vertical"?r.value((_,D)=>C.scale(e.crossValue()(_,D))).data(b):r.value((_,D)=>C.scale(e.mainValue()(_,D))).data(b)),(k||x.scale!==m)&&(m=x.scale,e.orient()==="vertical"?a.value((_,D)=>x.scale(e.mainValue()(_,D))).data(b):a.value((_,D)=>x.scale(e.crossValue()(_,D))).data(b)),s.xScale(C.webglScale).yScale(x.webglScale).type(K0t(n)).decorate(_=>e.decorate()(_,b,0)),s(b.length)};return g.size=(...b)=>b.length?(t=g2(b[0]),g):t,g.type=(...b)=>b.length?(n=b[0],g):n,g.equals=(...b)=>b.length?(c=b[0],g):c,g.scaleMapper=(...b)=>b.length?(f=b[0],g):f,FP(g,e,Y9t("baseValue","bandwidth","align")),CZ(g,s,"context","pixelRatio"),g},EZ=()=>{let e=[],t=a=>a,n=(a,i)=>i,r=bZ({decorate:()=>{},xScale:J1(),yScale:J1()});return r.xValues=()=>e.map(a=>a.xValues()).reduce((a,i)=>a.concat(i)),r.yValues=()=>e.map(a=>a.yValues()).reduce((a,i)=>a.concat(i)),r.mapping=(...a)=>a.length?(t=a[0],r):t,r.key=(...a)=>a.length?(n=a[0],r):n,r.series=(...a)=>a.length?(e=a[0],r):e,r},J9t=()=>{let e=EZ(),t=yZ("g"),n=yZ("g","multi"),r=a=>{gZ(a)&&(n.transition(a),t.transition(a));let i=e.mapping(),o=e.series(),s=e.xScale(),c=e.yScale();a.each((f,A,h)=>{let m=n(iu(h[A]),o);m.each((g,b,C)=>{g.xScale(s).yScale(c);let x=i(f,b,o);t(iu(C[b]),[x]).call(g)}),m.selection().order(),e.decorate()(m,f,A)})};return FP(r,e),CZ(r,n,"key"),r},q9t=()=>{let e=null,t=1,n=EZ(),r=a=>{let i=n.mapping(),o=n.series(),s=n.xScale(),c=n.yScale();o.forEach((f,A)=>{let h=i(a,A,o);f.context(e).pixelRatio(t).xScale(s).yScale(c);let m;f.decorate?(m=f.decorate(),f.decorate((g,b,C)=>{n.decorate()(g,a,A),m(g,b,C)})):n.decorate()(e,a,A),f(h),m&&f.decorate(m)})};return r.context=(...a)=>a.length?(e=a[0],r):e,r.pixelRatio=(...a)=>a.length?(t=a[0],r):t,FP(r,n),r};function e4t(e){return typeof e=="object"&&e!==null&&"type"in e&&"value"in e&&e.type==="grouping"}function rE(e={},t,n){return function(r){var a,i;if(e4t(n)){let o=n.value,s=r[o];return(i=((a=e[o])==null?void 0:a[String(s)])??hP)==null?void 0:i[t]}if($m(n)&&t==="dotFill"){let{domain:o,range:s,type:c="linear"}=n;return J8(s,o,c)(Number(r[n.columnName.value]))}return n}}var t4t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"canvasNode",null);Me(this,"svgLayerElement",null);Me(this,"svgLayerComponent",le.jsx(le.Fragment,{}));Me(this,"tools",null);Me(this,"margins",{top:qf,bottom:qf,left:qf,right:qf});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,totalWidth:600,totalHeight:350});Me(this,"scales",{x:Da().domain([0,10]).range([0,600]),y:Da().domain([0,10]).range([350,0]),xOriginal:Da().domain([0,10]).range([0,600]),yOriginal:Da().domain([0,10]).range([350,0])});Me(this,"polygon",[]);Me(this,"onPolygonUpdateOutside",()=>{});Me(this,"zoomStateKey","");Me(this,"selectedDot",null);Me(this,"captionsSizes",{xAxisCaptionsWidth:30,yAxisCaptionsWidth:100});Me(this,"mainTitle",[]);Me(this,"legend",{width:0,height:0,items:[]});Me(this,"notCalculatedProps",{});Me(this,"allPossibleLabels",[]);Me(this,"visibleLabels",[]);Me(this,"lassoMode",!1);Me(this,"onPolygonUpdate",e=>{this.polygon=e,this.updateByLasso(),this.onPolygonUpdateOutside(e)})}clear(){var e,t;this.parentNode&&this.rootNode&&this.canvasNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),(t=this.parentNode)==null||t.removeChild(this.canvasNode),this.parentNode=null,this.rootNode=null,this.canvasNode=null,this.svgLayerElement=null,this.tools=null),setTimeout(()=>{var n;(n=this.reactRoot)==null||n.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.canvasNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.parentNode.appendChild(this.canvasNode),this.reactRoot=zh(this.rootNode))}updateChartSizes(e){this.chartSizes.chartWidth=e.width,this.chartSizes.chartHeight=e.height}updateViewport(e,t,n){let r=e.scale==="log"?Rv():Da(),{minX:a,minY:i,maxX:o,maxY:s}=n;if(e.lowerValue!==void 0&&(a=Math.max(a,e.lowerValue)),e.upperValue!==void 0&&(o=Math.min(o,e.upperValue)),t.lowerValue!==void 0&&(i=Math.max(i,t.lowerValue)),t.upperValue!==void 0&&(s=Math.min(s,t.upperValue)),e.symmetricRange!==void 0){let g=e.symmetricRange;if(g>=a&&g<=o){let b=Math.max(g-a,o-g);a=g-b,o=g+b}}if(typeof t.symmetricRange<"u"){let g=t.symmetricRange;if(g>=i&&g<=s){let b=Math.max(g-i,s-g);i=g-b,s=g+b}}let c=[0,this.chartSizes.chartWidth],f=r.copy().domain([a,o]).range([nE.LEFT,this.chartSizes.chartWidth-nE.RIGHT]);r.domain([f.invert(0),f.invert(this.chartSizes.chartWidth)]).range(c).nice(),this.scales.x=r,this.scales.xOriginal=r.copy();let A=t.scale==="log"?Rv():Da(),h=[this.chartSizes.chartHeight,0],m=A.copy().domain([i,s]).range([this.chartSizes.chartHeight-nE.BOTTOM,nE.TOP]);A.domain([m.invert(this.chartSizes.chartHeight),m.invert(0)]).range(h).nice(),this.scales.y=A,this.scales.yOriginal=A.copy()}updateCaptionsSize(e){let t=new Dc("600 14px Arial");function n(o){return Math.max(...o.map(s=>t.getTextWidth(s)))}let{ticks:r,format:a}=b9(this.scales.y,e),i=n(r.map(a));this.captionsSizes={xAxisCaptionsWidth:20,yAxisCaptionsWidth:i}}createMainTitle(e){this.mainTitle=Om(e.name,this.chartSizes.totalWidth-this.margins.left-this.margins.right,20)}updateMargins(){let e=24*this.mainTitle.length,t=e>0?e+24*2:0;this.margins={top:Math.max(t,qf),bottom:qf+this.captionsSizes.xAxisCaptionsWidth+E9,left:qf+this.captionsSizes.yAxisCaptionsWidth+E9,right:this.legend.width+(this.legend.width>0?$P:0)+qf},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartHeight,this.legend.height)+this.margins.bottom,iu(this.canvasNode).style("width",this.chartSizes.chartWidth+"px").style("height",this.chartSizes.chartHeight+"px").style("top",this.margins.top+"px").style("left",this.margins.left+"px")}updateLegendSize(e,t,n,r){if(!e.show){this.legend={width:0,height:0,items:[]};return}let a=[],i={width:0,height:0,left:0,top:0};if(n.forEach(A=>{let h=t[A.value];if(h.usedAes.length===0||!h.aesMap)return;let m={};h.values.forEach(C=>{m[C]||(m[C]={...mP}),h.usedAes.forEach(x=>{var k,_;x==="dotFill"&&(m[C].color=((k=h.aesMap[C])==null?void 0:k[x])??Zt),x==="dotSize"&&(m[C].size=((_=h.aesMap[C])==null?void 0:_[x])??3)})});let g=A.label??A.value,b=Hl().domain(h.values).range(h.values.map(C=>m[C]));a.push({...i,id:A.value,type:"dots",title:g,scale:b,values:h.values,labels:h.labels})}),r.forEach(A=>{if(A.type==="dots"&&$m(A.aes.dotFill)){let{domain:h,range:m,columnName:g,type:b="linear"}=A.aes.dotFill,C=g.label??g.value,x=J8(m,h,"linear"),k=(b==="log"?q1():Da()).domain(h).range([height,0]),_=a2(k,h);a.push({...i,id:"dotFill",type:"continuous",title:C,scale:x,tickPositionScale:k,values:_})}}),!a.length){this.legend={width:0,height:0,items:[]};return}let o=w9(a,this.chartSizes.chartHeight),s=o[o.length-1],c=s.left+s.width+2*$P,f=this.chartSizes.chartHeight;this.legend={width:c,height:f,items:o}}initSettings(e,t,n,r,a,i,o,s){let{xAxis:c,yAxis:f,size:A,title:h,legend:m}=t;this.updateChartSizes(A),this.updateViewport(c,f,n),this.updateCaptionsSize(r.y),this.updateLegendSize(m,o,s,i),this.createMainTitle(h),this.updateMargins();let g=i.find($=>$.type==="dots"),b=i.find($=>$.type==="curve"),C={dotFill:rE(a,"dotFill",g.aes.dotFill),lineType:rE(a,"lineShape",(b==null?void 0:b.aes.lineShape)??"solid")},x=J0t().data(e).value($=>{let Q=Ly(C.dotFill($.data));return[Q.r/255,Q.g/255,Q.b/255,1]}),k=Z9t().equals(($,Q)=>$===Q).size(50).crossValue($=>$.x).mainValue($=>$.y).decorate($=>x($)),_=t0t().scaleExtent([.1,1e3]).filter(()=>!this.lassoMode).on("start",()=>{this.selectedDot=null}).on("zoom",$=>{let Q=$.transform,ee=Q.rescaleX(this.scales.xOriginal),K=Q.rescaleY(this.scales.yOriginal);this.scales.x.domain(ee.domain()),this.scales.y.domain(K.domain()),this.zoomStateKey=`${Q.x}_${Q.y}_${Q.k}`,this.renderSvgLayer(),this.renderWebglLayer()}).on("end",()=>{this.allPossibleLabels.forEach($=>{$.x=this.scales.x($.dot.x),$.y=this.scales.y($.dot.y)}),this.visibleLabels=eE(this.allPossibleLabels,this.chartSizes.chartWidth,this.chartSizes.chartHeight),this.renderSvgLayer()}),D=N_().x($=>$.x).y($=>$.y).addAll(e),O=q0t().on("point",([$])=>{var U,G;if(!$){this.selectedDot=null,this.renderSvgLayer();return}let Q=this.scales.x.invert($.x),ee=this.scales.y.invert($.y),K=(U=this.tools)==null?void 0:U.qt.find(Q,ee),re=this.selectedDot&&!K||!this.selectedDot&&K||((G=this.selectedDot)==null?void 0:G.id)!==(K==null?void 0:K.id);this.selectedDot=K??null,re&&this.renderSvgLayer()}),I=_0t({xScale:this.scales.x,yScale:this.scales.y}).xAxisHeight(()=>"0").yAxisWidth(()=>"0").svgPlotArea(J9t()).webglPlotArea(q9t().series([k]).mapping($=>$)).decorate($=>{let Q=$.enter();Q&&!this.svgLayerElement&&(Q.style("grid-template-columns","0 auto 1fr auto 0"),Q.style("grid-template-rows","0 auto 1fr auto 0"),this.svgLayerElement=Q.select(".svg-plot-area.plot-area svg").node()),Q.select(".svg-plot-area.plot-area").call(_).call(O)});this.tools={webglChart:I,zoom:_,qt:D,fillColor:x,pointSeries:k,aesGetters:C},iu(this.canvasNode).datum(e).style("position","absolute").style("width",this.chartSizes.chartWidth+"px").style("height",this.chartSizes.chartHeight+"px").style("top",this.margins.top+"px").style("left",this.margins.left+"px")}updateAes(e,t){var i;if(this.tools===null)return;let n=t.find(o=>o.type==="dots"),r=t.find(o=>o.type==="curve"),a={dotFill:rE(e,"dotFill",n.aes.dotFill),lineType:rE(e,"lineShape",(r==null?void 0:r.aes.lineShape)??"solid")};this.tools.aesGetters=a,(i=this.tools)==null||i.fillColor.value(o=>{var A;let s=((A=this.tools)==null?void 0:A.aesGetters.dotFill)??(()=>Zt),c=Ly(s(o.data)),f=this.polygon.length<2||dX(this.polygon,[o.x,o.y])?1:.2;return[c.r/255,c.g/255,c.b/255,f]})}updateByLasso(){var e;this.tools!==null&&((e=this.tools)==null||e.fillColor.value(t=>{var i;let n=((i=this.tools)==null?void 0:i.aesGetters.dotFill)??(()=>Zt),r=Ly(n(t.data)),a=this.polygon.length<2||dX(this.polygon,[t.x,t.y])?1:.4;return[r.r/255,r.g/255,r.b/255,a]}),this.renderWebglLayer())}updateData(e){this.tools!==null&&(iu(this.canvasNode).datum(e),this.tools.fillColor.data(e),this.tools.qt=N_().x(t=>t.x).y(t=>t.y).addAll(e))}render(e,t,n,r,a,i,o,s,c,f,A,h,m,g){if(this.lassoMode=g,this.tools===null)this.initSettings(a,t,i,r,s,c,f,A),this.onPolygonUpdateOutside=m;else{let{title:b,legend:C}=t;this.updateLegendSize(C,f,A,c),this.createMainTitle(b),this.updateMargins(),this.updateAes(s,c)}this.allPossibleLabels=h,this.allPossibleLabels.forEach(b=>{b.x=this.scales.x(b.dot.x),b.y=this.scales.y(b.dot.y)}),this.visibleLabels=eE(this.allPossibleLabels,this.chartSizes.chartWidth,this.chartSizes.chartHeight),this.notCalculatedProps={settingsId:e,chartSettings:t,onlyPositive:r,keyColumn:n,dotsByGrouping:o,layers:c},this.renderWebglLayer(),this.renderSvgLayer()}renderWebglLayer(){var e,t;(e=this.tools)!=null&&e.webglChart&&iu(this.canvasNode).call((t=this.tools)==null?void 0:t.webglChart)}renderSvgLayer(){var t,n;this.visibleLabels.forEach(r=>{r.x=this.scales.x(r.dot.x),r.y=this.scales.y(r.dot.y)}),Jwt(this.visibleLabels);let e={settingsId:this.notCalculatedProps.settingsId,chartSettings:this.notCalculatedProps.chartSettings,onlyPositive:this.notCalculatedProps.onlyPositive,keyColumn:this.notCalculatedProps.keyColumn,dotsByGrouping:this.notCalculatedProps.dotsByGrouping,layers:this.notCalculatedProps.layers,chartSizes:this.chartSizes,scales:this.scales,margins:this.margins,mainTitle:this.mainTitle,captionsSizes:this.captionsSizes,container:this.svgLayerElement,zoomStateKey:this.zoomStateKey,selectedDot:this.selectedDot,aesGetters:(t=this.tools)==null?void 0:t.aesGetters,legendData:this.legend,labels:this.visibleLabels,onPolygonUpdate:this.onPolygonUpdate,lassoMode:this.lassoMode};this.svgLayerComponent=le.jsx(U9t,{...e}),(n=this.reactRoot)==null||n.render(this.svgLayerComponent)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},n4t=t4t,aE=H.object({type:H.literal("grouping"),value:H.string()}),r4t=H.object({type:H.literal("dots"),aes:H.optional(H.object({dotFill:H.optional(H.union([H.string(),aE,rh(H.string())])),dotShape:H.optional(H.union([Od,aE])),dotSize:H.optional(H.union([H.number(),aE]))}))}),a4t=H.object({type:H.literal("curve"),smoothing:H.optional(H.boolean()),aes:H.optional(H.object({lineWidth:H.optional(H.number()),lineShape:H.optional(tp),lineColor:H.optional(H.union([H.string(),aE,rh(H.string())])),opacity:H.optional(H.number())}))}),i4t=H.union([r4t,a4t]),o4t=H.object({type:H.literal("scatterplot-umap"),title:H.object({name:H.string(),show:H.optional(H.boolean()),position:H.optional(Nm)}),size:H.optional(H.object({width:H.optional(H.number()),height:H.optional(H.number())})),legend:H.optional(H.object({show:H.optional(H.boolean()),position:H.optional(Bg)})),tooltips:H.optional(H.object({show:H.optional(H.boolean()),content:H.optional(H.array(Tr))})),frame:H.optional(H.object({type:H.optional(c9)})),keyColumn:Tr,x:Tr,y:Tr,xAxis:H.optional(r2),yAxis:H.optional(r2),grouping:H.optional(H.array(Tr)),label:H.optional(Tr),inheritedAes:H.optional(H.record(H.string(),n2)),layers:H.array(i4t),lassoMode:H.optional(H.boolean())}),l4t=class{constructor(e){Me(this,"type","dots");Me(this,"aes",{dotFill:Zt,dotShape:"21",dotSize:3,opacity:1});this.aes={...this.aes,...e.aes}}},s4t=class{constructor(e){Me(this,"type","curve");Me(this,"smoothing");Me(this,"aes",{lineColor:Zt,lineWidth:1,lineShape:"solid",opacity:1});this.smoothing=e.smoothing??!1,this.aes={...this.aes,...e.aes}}},xZ=class{constructor(e){Me(this,"id");Me(this,"type","scatterplot-umap");Me(this,"keyColumn");Me(this,"x");Me(this,"y");Me(this,"grouping");Me(this,"label");Me(this,"chartSettings");Me(this,"inheritedAes");Me(this,"layers");Me(this,"lassoMode");var t,n,r,a;o4t.parse(e),this.id=Ir.uniqueId("settings"),this.keyColumn=e.keyColumn,this.x=e.x,this.y=e.y,this.grouping=e.grouping??[],this.label=e.label??null,this.chartSettings={size:{width:((t=e==null?void 0:e.size)==null?void 0:t.width)??600,height:((n=e==null?void 0:e.size)==null?void 0:n.height)??350},title:{position:"center",show:!0,...e.title,name:((r=e.title)==null?void 0:r.name)??"Chart"},yAxis:{title:e.y.label??e.y.value,scale:"linear",showGrid:!0,showTicks:!0,...e.yAxis},xAxis:{title:e.x.label??e.x.value,scale:"linear",showGrid:!0,showTicks:!0,...e.xAxis},frame:{type:((a=e.frame)==null?void 0:a.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.inheritedAes=e.inheritedAes??{},this.layers=e.layers.map(i=>{if(i.type==="dots")return new l4t(i);if(i.type==="curve")return new s4t(i);throw new Error("Unknown layer type")}).filter(Boolean),this.lassoMode=e.lassoMode??!1}};function SZ(e){return typeof e=="object"&&"type"in e&&e.type==="grouping"}function u4t(e,t,n,r){return t.reduce((a,i)=>{let o=Ir.uniqBy(e.rows,h=>h[i.value]),s=h=>String(h[i.value]),c=h=>i.valueLabels?String(h[i.valueLabels]):s(h),f=new Set;n.forEach(h=>{h.aes&&Object.entries(h.aes).forEach(([m,g])=>{SZ(g)&&g.value===i.value&&f.add(m)})});let A=o.reduce((h,m)=>(h[s(m)]=c(m),h),{});return a[i.value]={values:o.map(s).sort((h,m)=>A[h].localeCompare(A[m],"en",{numeric:!0})),usedAes:[...f],aesMap:r[i.value],labels:A},a},{})}var c4t=10;function f4t(e){let t=[],n=new Dc("16px Manrope");for(let r of e){let a=r.label;if(!a)continue;let i=n.getTextMetrics(String(a));t.push({name:String(a),width:i.width,height:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent,x:0,y:0,xPosition:"right",yPosition:"middle",bbox:{minX:0,maxX:0,minY:0,maxY:0},dot:r,padding:c4t})}return t}var d4t=class extends Sg{constructor(t,n,r){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new n4t);Me(this,"onPolygonUpdate",()=>Kx);Me(this,"calculatedData",null);this.settings=new xZ(n),r&&(this.onPolygonUpdate=r[0])}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new xZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){t==="polygon"&&(this.chartRenderer.polygon=n,this._updateChart())}export(){return console.warn("export not implemented"),""}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.grouping.length!==n.grouping.length||t.grouping.some((s,c)=>{var f;return s.value!==((f=n.grouping[c])==null?void 0:f.value)})||(((r=t.label)==null?void 0:r.value)||((a=n.label)==null?void 0:a.value))&&((i=t.label)==null?void 0:i.value)!==((o=n.label)==null?void 0:o.value)}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{x:t,y:n,keyColumn:r,label:a,grouping:i,layers:o,inheritedAes:s}=this.settings,c={x:!0,y:!0},f={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},A=o.some(x=>x.type==="curve"),h=new Set,m={},g=this.data.rows.reduce((x,k)=>{if(k[t.value]===null||k[n.value]===null)return x;let _=Number(k[t.value]),D=Number(k[n.value]);c.x&&_!==null&&_<0&&(c.x=!1),c.y&&D!==null&&D<0&&(c.y=!1),_!==null&&_<f.minX&&(f.minX=_),_!==null&&_>f.maxX&&(f.maxX=_),D!==null&&D<f.minY&&(f.minY=D),D!==null&&D>f.maxY&&(f.maxY=D);let O={x:_,y:D,id:String(k[r.value]),label:a&&k[a.value]?String(k[a.value]):null,data:k};if(A){let I=i.map($=>k[$.value]).join("_");h.add(I),m[I]||(m[I]=[]),m[I].push(O)}return x.push(O),x},[]),b=[...h];A&&b.forEach(x=>{m[x].sort((k,_)=>k.x-_.x)});let C=u4t(this.data,i,o,s);this.calculatedData={onlyPositive:c,dots:g,dotsByGrouping:m,groupingKeys:b,allPossibleLabels:f4t(g),dotsExtents:f,legendLabels:C},this.chartRenderer.updateData(g)}_updateAesInData(){let t=this.calculatedData;if(!t)return;let{layers:n,inheritedAes:r,grouping:a}=this.settings;this.chartRenderer.updateAes(r,n),a.forEach(i=>{let o=new Set;n.forEach(s=>{s.aes&&Object.entries(s.aes).forEach(([c,f])=>{SZ(f)&&f.value===i.value&&o.add(c)})}),t.legendLabels[i.value].usedAes=[...o],t.legendLabels[i.value].aesMap=r[i.value]})}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,keyColumn:r,inheritedAes:a,layers:i,grouping:o,lassoMode:s}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.onlyPositive,this.calculatedData.dots,this.calculatedData.dotsExtents,this.calculatedData.dotsByGrouping,a,i,this.calculatedData.legendLabels,o,this.calculatedData.allPossibleLabels,this.onPolygonUpdate,s)}};function A4t(e){let t=cL(e),n=tu(e);return t===void 0||n===void 0||t===0?r=>r:r=>(r-n)/t}function p4t(e){let t=tu(e),[n,r]=$A(e);return t===void 0||n===void 0||r===void 0?a=>a:a=>(a-t)/(r-n)}function h4t(e,t){return e==="standardScaling"?A4t(t):e==="meanNormalization"?p4t(t):n=>n}function m4t(e,t,n,r,a,i,o,s,c){let f=o.map(C=>C.join("_")),A={meta:{facetKeys:f,xKeys:[],yKeys:[],xLabels:{},yLabels:{},facetKeyValues:f.reduce((C,x,k)=>(C[x]=o[k],C),{}),valueExtentSize:[1/0,-1/0],valueExtentColor:[1/0,-1/0]},facets:{}},h=new Set,m=new Set,g=t.valueLabels??t.value,b=n.valueLabels??n.value;if(e.rows.forEach(C=>{let x=i.length?i.map(I=>C[I.value]).join("_"):"null",k=C[t.value],_=C[n.value],D=C[r.value]??c,O=C[a.value]??c;if(!(k===null||_===null||D===null||O===null)){if(A.facets[x]||(A.facets[x]={xKeys:[],yKeys:[],cells:{}}),A.facets[x].xKeys.push(k),A.facets[x].yKeys.push(_),h.has(k)||(h.add(k),A.meta.xKeys.push(k)),m.has(_)||(m.add(_),A.meta.yKeys.push(_)),A.facets[x].cells[k]||(A.facets[x].cells[k]={}),A.meta.valueExtentSize[0]=Math.min(D,A.meta.valueExtentSize[0]),A.meta.valueExtentSize[1]=Math.max(D,A.meta.valueExtentSize[1]),A.meta.valueExtentColor[0]=Math.min(O,A.meta.valueExtentColor[0]),A.meta.valueExtentColor[1]=Math.max(O,A.meta.valueExtentColor[1]),A.facets[x].cells[k][_])throw Error(`More than 1 value for x=${k}, y=${_}`);if(A.meta.xLabels[k]&&String(C[g])!==A.meta.xLabels[k])throw Error(`More than 1 x-label value for x=${k}`);if(A.meta.yLabels[_]&&String(C[b])!==A.meta.yLabels[_])throw Error(`More than 1 y-label value for y=${_}`);A.meta.xLabels[k]=String(C[g]),A.meta.yLabels[_]=String(C[b]),A.meta&&(A.facets[x].cells[k][_]={id:`${k}_${_}`,x:k,y:_,sizeValue:D,normalizedSizeValue:D,colorValue:O,normalizedColorValue:O,data:C})}}),A.meta.facetKeys=A.meta.facetKeys.filter(C=>A.facets[C]),A.meta.facetKeys.forEach(C=>{let x=A.facets[C];x.xKeys=Ir.uniq(x.xKeys),x.yKeys=Ir.uniq(x.yKeys)}),s){let C=[1/0,-1/0];A.meta.facetKeys.forEach(x=>{if(!A.facets[x])return;let{xKeys:k,yKeys:_,cells:D}=A.facets[x],O=s.direction==="row"?k:_,I=s.direction==="row"?_:k,$=s.direction==="row"?(Q,ee)=>{var K;return(K=D[Q])==null?void 0:K[ee]}:(Q,ee)=>{var K;return(K=D[ee])==null?void 0:K[Q]};I.forEach(Q=>{let ee=[];O.forEach(re=>{var G;let U=(G=$(re,Q))==null?void 0:G.colorValue;U!==void 0&&ee.push(U)});let K=h4t(s.method,ee);O.forEach(re=>{let U=$(re,Q);U!==void 0&&(U.normalizedColorValue=K(U.colorValue),C[0]=Math.min(U.normalizedColorValue,C[0]),C[1]=Math.max(U.normalizedColorValue,C[1]))})})}),A.meta.valueExtentColor=C}return A.meta.valueExtentSize[0]===1/0&&(A.meta.valueExtentSize[0]=0),A.meta.valueExtentSize[1]===-1/0&&(A.meta.valueExtentSize[1]=0),A.meta.valueExtentColor[0]===1/0&&(A.meta.valueExtentColor[0]=0),A.meta.valueExtentColor[1]===-1/0&&(A.meta.valueExtentColor[1]=0),A}var v4t=15,Mg=8,iE=30,g4t=48,y4t=24,oE=16,y2=4,lE=4,BZ=20,w4t=16,u1={left:["axis","axisTitle"],right:["axis","axisTitle"],top:["axis","axisTitle","facetTitle"],bottom:["axis","axisTitle"]};function C4t(e,t,n,r,a,i,o){let s=r.includes(t.position),c=r.includes(e.position),f=a.length>1,A=e.showTicks?lE:0,h=t.showTicks?lE:0,m=c&&e.showTitle?iE:0,g=s&&t.showTitle?iE:0,b=c&&e.showAxisLabels&&i>oE?n.xAxisCaptions+A+y2:0,C=s&&t.showAxisLabels&&o>oE?n.yAxisCaptions+h+y2:0;return{left:{axisTitle:t.position==="left"?g:0,axis:t.position==="left"?C:0},right:{axisTitle:t.position==="right"?g:0,axis:t.position==="right"?C:0},top:{facetTitle:f?g4t:0,axisTitle:e.position==="top"?m:0,axis:e.position==="top"?b:0},bottom:{axisTitle:e.position==="bottom"?m:0,axis:e.position==="bottom"?b:0}}}function b4t(e,t,n){return{left:u1.left.reduce((r,a,i)=>{let o=i>0?u1.left[i-1]:null,s=e.left[a];return r[a]={x:o?r[o].x-s:-s,y:0,width:s,height:n,isVisible:s>0},r},{}),right:u1.right.reduce((r,a,i)=>{let o=i>0?u1.right[i-1]:null,s=e.right[a];return r[a]={x:o?r[o].x+r[o].width:t,y:0,width:s,height:n,isVisible:s>0},r},{}),top:u1.top.reduce((r,a,i)=>{let o=i>0?u1.top[i-1]:null,s=e.top[a];return r[a]={x:0,y:o?r[o].y-s:-s,width:t,height:s,isVisible:s>0},r},{}),bottom:u1.bottom.reduce((r,a,i)=>{let o=i>0?u1.bottom[i-1]:null,s=e.bottom[a];return r[a]={x:0,y:o?r[o].y+r[o].height:n,width:t,height:s,isVisible:s>0},r},{})}}function E4t(e,t,n,r){let{xLabels:a,yLabels:i}=n.meta,o=e.xAxisLabels/180*Math.PI,s=e.yAxisLabels/180*Math.PI,c=0,f=0,A=e.xAxisLabels===45;if(A){let m=n.meta.xKeys,g=t.x,b=g>oE,C=a[m[0]];c=Math.max(c,(A&&b?r.getTextWidth(C)*Math.cos(o):0)-g/2)}let h=e.yAxisLabels===45;if(h){let m=n.meta.yKeys;if(m.length){let g=t.y,b=g>oE,C=i[m[m.length-1]];f=Math.max(f,(h&&b?r.getTextWidth(C)*Math.cos(s):0)-g/2)}}return{xCaptionTail:c,yCaptionTail:f}}function x4t({sideElementBBoxes:e,debug:t,xKeys:n,yKeys:r,scales:a,xAxis:i,yAxis:o,stepX:s,stepY:c,labelAngles:f,xLabels:A,yLabels:h}){let m=i.showTicks?lE:0,g=o.showTicks?lE:0,b=e.top.axis.isVisible||e.bottom.axis.isVisible,C=e.top.axisTitle.isVisible?e.top.axisTitle:e.bottom.axisTitle,x=e.top.axis.isVisible?e.top.axis:e.bottom.axis,k=e.left.axis.isVisible||e.right.axis.isVisible,_=e.left.axisTitle.isVisible?e.left.axisTitle:e.right.axisTitle,D=e.left.axis.isVisible?e.left.axis:e.right.axis;return le.jsxs("g",{children:[le.jsxs("g",{children:[C.isVisible&&le.jsxs("g",{transform:`translate(${C.x},${C.y})`,children:[le.jsx("text",{x:C.width/2,y:C.height/2,textAnchor:"middle",dominantBaseline:"central",children:i.title}),t&&le.jsx("rect",{width:C.width,height:C.height,stroke:Zt,fill:"none"})]}),b&&le.jsxs("g",{fontSize:"14px",transform:`translate(${x.x},${x.y})`,children:[n.map(O=>{let I=f.xAxisLabels!==0,$=i.position==="bottom",Q=$?0:x.height,ee=$?Q+m:Q-m,K=$?ee+y2:ee-y2,re=a.x(O)+s/2,U=-f.xAxisLabels;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:re,y1:Q,y2:ee,stroke:Zt}),le.jsx("text",{x:re,y:K,textAnchor:I?$?"end":"start":"middle",transform:`rotate(${U},${re},${K})`,dominantBaseline:I?"central":$?"hanging":"auto",children:A[O]})]},O)}),t&&le.jsx("rect",{width:x.width,height:x.height,stroke:Zt,fill:"none"})]})]}),le.jsxs("g",{children:[_.isVisible&&le.jsx("g",{transform:`translate(
15189
15189
  ${_.x+_.width/2},
15190
- ${_.y+_.height/2})`,children:le.jsx("text",{transform:`rotate(${o.position==="left"?-90:90})`,dominantBaseline:"central",textAnchor:"middle",children:o.title})}),t&&le.jsx("rect",{x:_.x,y:_.y,width:_.width,height:_.height,stroke:Zt,fill:"none"}),k&&le.jsx("g",{fontSize:"14px",transform:`translate(${D.x},${D.y})`,children:r.map(O=>{let I=f.yAxisLabels!==0,$=o.position==="left",Q=-(90-f.yAxisLabels),ee=f.yAxisLabels===0?"middle":$?"end":"start",K=I?"central":$?"auto":"hanging",re=$?D.width:0,U=$?re-g:re+g,G=$?U-y2:U+y2,Z=a.y(O)+c/2;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:U,y1:Z,y2:Z,stroke:Zt}),le.jsx("text",{x:G,y:Z,textAnchor:ee,transform:`rotate(${Q},${G},${Z})`,dominantBaseline:K,children:h[O]})]},O)})}),t&&le.jsx("rect",{x:D.x,y:D.y,height:D.height,width:D.width,stroke:Zt,fill:"none"})]})]})}function sE(e){if(e===null)return"null";if(typeof e=="number"){let t=e>0?Math.floor(e):Math.ceil(e),n=e-t;return t+Number(n.toPrecision(2))}return e}function S4t(e,t,n=[]){let r=e.data,a=[`X: ${t.xLabels[e.x]}`,`Y: ${t.yLabels[e.y]}`,`Value (color): ${sE(e.colorValue)}${e.colorValue!==e.normalizedColorValue?` (${sE(e.normalizedColorValue)})`:""}`,`Value (size): ${sE(e.sizeValue)}${e.sizeValue!==e.normalizedSizeValue?` (${sE(e.normalizedSizeValue)})`:""}`];for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function B4t({facetKey:e,dimensions:t,scales:n,cells:r,colorScale:a,sizeScale:i,chartSettings:o,cellsMeta:s,stepX:c,stepY:f,aes:A,labelAngles:h,chartSizes:m,margins:g,tooltipsContainer:b}){let[C,x]=Vn.useState(null),{xAxis:k,yAxis:_,tooltips:D}=o,{width:O,height:I}=t.inner,{padding:$,sideElementBBoxes:Q}=t,{xLabels:ee,yLabels:K}=s,re=n.x.domain(),U=n.y.domain(),G={left:g.left+t.left+$.left,right:m.totalWidth-(g.left+t.left+$.left),top:g.top+t.top+$.top,bottom:m.totalHeight-(g.top+t.top+$.top)},Z=!1;return le.jsxs("g",{transform:`translate(${t.left},${t.top})`,fontSize:w4t,children:[le.jsxs("g",{transform:`translate(${$.left},${$.top})`,children:[Q.top.facetTitle.isVisible&&le.jsx("text",{x:Q.top.facetTitle.x,y:Q.top.facetTitle.y+Q.top.facetTitle.height-y4t,fontWeight:"500",fontSize:"20px",children:s.facetKeyValues[e].join(", ")}),Z,re.map(Y=>U.map(X=>{var me;let oe=(me=r==null?void 0:r[Y])==null?void 0:me[X];return oe?le.jsx("circle",{cx:n.x(Y)+c/2,cy:n.y(X)+f/2,r:i(oe.normalizedSizeValue),stroke:A.cellStrokeColor,fill:oe.colorValue===null?A.emptyCellColor:a(oe.normalizedColorValue),onMouseOver:()=>x(oe),onMouseLeave:()=>x(null)},oe?oe.id:`${Y}_${X}`):null})),le.jsx("g",{children:o.frame.type==="full"&&le.jsx("rect",{fill:"none",stroke:Zt,x:"0",y:"0",width:O,height:I})}),le.jsx("g",{fontWeight:"500",children:le.jsx(x4t,{sideElementBBoxes:Q,xKeys:re,yKeys:U,scales:n,xAxis:k,yAxis:_,stepX:c,stepY:f,labelAngles:h,xLabels:ee,yLabels:K,debug:Z})})]}),o.tooltips.show&&C&&le.jsx(oc,{content:S4t(C,s,D==null?void 0:D.content),x:n.x(String(C.x))+c/2,y:n.y(String(C.y))+f/2,offset:re.length>1?c/2:0,active:!0,sideDistances:G,container:b})]})}function k4t({margins:e,captionsSizes:t,settingsId:n,chartSettings:r,chartSizes:a,chartsDimensions:i,facetKeys:o,scales:s,colorScale:c,sizeScale:f,groupedCells:A,cellsMeta:h,step:m,legend:g,aes:b,columnsCount:C,labelAngles:x}){let[k,_]=Vn.useState(),D=Vn.useRef(null);Vn.useEffect(()=>{D.current&&_(D.current)},[]);let O=i[o[0]].padding,I=i[o[C-1]].padding,$=e.left+a.chartsWidth+BZ,Q=e.top+O.top;return le.jsx(f2,{dataId:n,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${a.totalWidth} ${a.totalHeight}`,width:a.totalWidth,height:a.totalHeight,fontFamily:"Manrope",children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${e.left},${e.top})`,children:[le.jsx(d2,{title:[r.title.name],show:r.title.show,position:r.title.position,leftPadding:O.left,rightPadding:I.right,chartsWidth:a.chartsWidth}),o.map(ee=>{let{cells:K}=A[ee];return le.jsx(B4t,{captionsSizes:t,facetKey:ee,dimensions:i[ee],scales:s,cells:K,cellsMeta:h,stepX:m.x,stepY:m.y,colorScale:c,sizeScale:f,chartSettings:r,aes:b,labelAngles:x,margins:e,chartSizes:a,tooltipsContainer:k},ee)})]}),le.jsx("g",{transform:`translate(${$},${Q})`,children:le.jsx(y9,{legendData:g})}),le.jsx("g",{ref:D})]})})}var T4t=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function _4t(e,t,n){let r=n;return e&&(e.colorRange&&(r=e.colorRange),e.method==="standardScaling"&&(r=[-2,2]),e.method==="meanNormalization"&&(r=[-.75,.75])),T4t(t,r)}var P4t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"margins",{top:Mg,bottom:Mg,left:Mg,right:Mg});Me(this,"captionsSizes",{xAxisCaptions:100,yAxisCaptions:100,xCaptionTail:0,yCaptionTail:0});Me(this,"labelAngles",{xAxisLabels:0,yAxisLabels:0});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:Hl().domain(["null"]).range([1]),y:Hl().domain(["null"]).range([1])});Me(this,"step",{x:10,y:10});Me(this,"colorScale",Da().domain([0,1]).range(["white","black"]));Me(this,"sizeScale",Ny().domain([0,1]).range([3,20]));Me(this,"legend",{width:0,height:0,items:[]})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateMargins(e){this.margins={top:e.show?24+24*2:Mg,bottom:Mg,left:Mg,right:this.legend.width},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight+this.margins.bottom,this.legend.height)}updateLegendSize(e,t,n){if(!e.show){this.legend={width:0,height:0,items:[]};return}let r=[],a=this.chartSizes.chartHeight,i=Math.min(this.chartSizes.chartHeight,350),o={width:0,height:0,left:0,top:0},s=this.colorScale.domain(),c=a2(this.colorScale,[s[0],s[s.length-1]]),f=t.label??t.value,A=Da([c[0],c[c.length-1]],[i,0]);r.push({id:"colorValue",type:"continuous",scale:this.colorScale,tickPositionScale:A,values:c,title:f,...o});let h=n.label??n.value,m=this.sizeScale.ticks(3),g=this.sizeScale.tickFormat(3),b=m.reduce((_,D)=>(_[String(D)]=g(D),_),{});if(r.push({id:"sizeValue",type:"size",title:h,scale:this.sizeScale,values:m,labels:b,...o}),!r.length){this.legend={width:0,height:0,items:[]};return}let C=w9(r,a,i),x=C[C.length-1],k=x.left+x.width+2*BZ;this.legend={width:k,height:a,items:C}}updateCaptionsSize(e,t,n){let r=new Dc("bold 14px Arial"),{xKeys:a,yKeys:i,xLabels:o,yLabels:s}=e.meta;this.labelAngles={xAxisLabels:t.axisLabelsAngle,yAxisLabels:n.axisLabelsAngle};let c=a.map(b=>r.getTextWidth(o[b])),f=i.map(b=>r.getTextWidth(s[b])),{xCaptionTail:A,yCaptionTail:h}=E4t(this.labelAngles,this.step,e,r),m=this.labelAngles.xAxisLabels/180*Math.PI,g=this.labelAngles.yAxisLabels/180*Math.PI;this.captionsSizes={xCaptionTail:A,yCaptionTail:h,xAxisCaptions:Math.max(...c,0)*Math.sin(m)||iE,yAxisCaptions:Math.max(...f,0)*Math.sin(g)||iE}}updateChartDimensions(e,t,n,r){let a=e.length,i=Math.min(t.nRows??a,a),o=Math.min(t.nCols??a,a);this.columnsCount=t.nRows?Math.ceil(a/i):o,this.rowsCount=Math.ceil(a/this.columnsCount),this.chartsDimensions={};let s=0,c=0;e.forEach((h,m)=>{let g=m%this.columnsCount+1,b=zK(m,e.length,this.columnsCount,this.rowsCount),C=this.chartSizes.chartWidth,x=this.chartSizes.chartHeight,k=C4t(n,r,this.captionsSizes,b,e,this.step.x,this.step.y);function _(Q){return Math.max(u1[Q].reduce((ee,K)=>ee+k[Q][K],0),v4t)}let D={left:_("left"),right:_("right"),top:_("top"),bottom:_("bottom")};D.left<this.captionsSizes.xCaptionTail&&(D.left=this.captionsSizes.xCaptionTail),D.bottom<this.captionsSizes.yCaptionTail&&(D.bottom=this.captionsSizes.yCaptionTail);let O=b4t(k,C,x),I=C+D.left+D.right,$=x+D.top+D.bottom;this.chartsDimensions[h]={left:s,top:c,inner:{width:C,height:x},outer:{width:I,height:$},padding:D,sideElementBBoxes:O,chartEdgeSides:b},s+=I,g===this.columnsCount&&(s=0,c+=$)});let f=e.slice(0,this.columnsCount).reduce((h,m)=>h+this.chartsDimensions[m].outer.width,0),A=e.filter((h,m)=>m%this.columnsCount===0).reduce((h,m)=>h+this.chartsDimensions[m].outer.height,0);this.chartSizes.chartsWidth=f,this.chartSizes.chartsHeight=A}updateChartsSizes(e,t){let{width:n,height:r,cellSize:a}=t;a&&(this.chartSizes.chartWidth=e.meta.xKeys.length*a,this.chartSizes.chartHeight=e.meta.yKeys.length*a),n&&r&&(this.chartSizes.chartWidth=n,this.chartSizes.chartHeight=r)}updateScales(e,t,n,r){let{width:a,height:i,cellSize:o}=t,{meta:s}=e,c=(b,C={})=>[...b].sort((x,k)=>n.sorting==="asc"?(C[x]??x).localeCompare(C[k]??k,"en",{numeric:!0}):(C[k]??k).localeCompare(C[x]??x,"en",{numeric:!0})),f=(b,C={})=>[...b].sort((x,k)=>r.sorting==="asc"?(C[x]??x).localeCompare(C[k]??k,"en",{numeric:!0}):(C[k]??k).localeCompare(C[x]??x,"en",{numeric:!0})),A=c(s.xKeys,s.xLabels),h=f(s.yKeys,s.yLabels);o?(this.step.x=o,this.step.y=o):a&&i&&(this.step.x=a/A.length,this.step.y=i/h.length);let m=new Array(A.length).fill(null).map((b,C)=>C*this.step.x),g=new Array(h.length).fill(null).map((b,C)=>C*this.step.y);this.scales.x=Hl().domain(A).range(m),this.scales.y=Hl().domain(h).range(g)}updateAesScale(e,t,n,r){this.colorScale=Da().domain(_4t(r,e.colorsList.length,n)).range(e.colorsList),this.sizeScale=Ny(t,[e.minRadius,e.maxRadius])}render(e,t,n,r,a,i,o,s,c){var _;let{meta:f,facets:A}=a,{valueExtentSize:h,valueExtentColor:m}=f,{xAxis:g,yAxis:b,title:C,size:x}=t;this.updateChartsSizes(a,x),this.updateAesScale(c,h,m,s),this.updateScales(a,x,t.xAxis,t.yAxis),this.updateCaptionsSize(a,g,b),this.updateChartDimensions(r,n,g,b),this.updateLegendSize(t.legend,i,o),this.updateMargins(C);let k=le.jsx(k4t,{aes:c,captionsSizes:this.captionsSizes,cellsMeta:f,columnsCount:this.columnsCount,chartsDimensions:this.chartsDimensions,chartSettings:t,chartSizes:this.chartSizes,sizeScale:this.sizeScale,colorScale:this.colorScale,facetKeys:r,facetSettings:n,groupedCells:A,labelAngles:this.labelAngles,legend:this.legend,margins:this.margins,scales:this.scales,settingsId:e,step:this.step});this.component=k,(_=this.reactRoot)==null||_.render(k)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},M4t=P4t,kZ=class{constructor(e){Me(this,"id");Me(this,"type","bubble");Me(this,"facetSettings");Me(this,"valueColumnSize");Me(this,"valueColumnColor");Me(this,"xColumn");Me(this,"yColumn");Me(this,"facetBy");Me(this,"normalization");Me(this,"NAValueAs");Me(this,"chartSettings");Me(this,"aes");var a,i,o,s,c,f,A,h,m,g;u2t.parse(e),this.id=Ir.uniqueId("settings"),this.facetSettings={titlePosition:"left",...e.facetSettings},this.facetBy=e.facetBy??[],this.valueColumnSize=e.valueSize,this.valueColumnColor=e.valueColor,this.xColumn=e.xColumn,this.yColumn=e.yColumn,this.NAValueAs=e.NAValueAs??null,this.normalization=e.normalization??null;let t=((a=e.size)==null?void 0:a.cellSize)??null,n=t?null:((i=e==null?void 0:e.size)==null?void 0:i.width)??(this.facetBy.length?400:600),r=t?null:((o=e==null?void 0:e.size)==null?void 0:o.height)??(this.facetBy.length?250:350);this.chartSettings={size:{width:n,height:r,cellSize:t},title:{position:"center",show:!0,...e.title,name:((s=e.title)==null?void 0:s.name)??"Chart"},yAxis:{title:e.yColumn.label??e.yColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,position:"left",axisLabelsAngle:90,sorting:"asc",...e.yAxis},xAxis:{title:e.xColumn.label??e.xColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,position:"bottom",axisLabelsAngle:90,sorting:"asc",...e.xAxis},frame:{type:((c=e.frame)==null?void 0:c.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.aes={minRadius:((f=e.aes)==null?void 0:f.minRadius)??3,maxRadius:((A=e.aes)==null?void 0:A.maxRadius)??20,colorsList:((h=e.aes)==null?void 0:h.colorsList)??["black","white","red"],cellStrokeColor:((m=e.aes)==null?void 0:m.cellStrokeColor)??Zt,emptyCellColor:((g=e.aes)==null?void 0:g.emptyCellColor)??"white"}}},D4t=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new M4t);Me(this,"calculatedData",null);this.settings=new kZ(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new kZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for bubble chart")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.facetBy.some((s,c)=>{var f;return s.value!==((f=n.facetBy[c])==null?void 0:f.value)})||((r=t.normalization)==null?void 0:r.method)!==((a=n.normalization)==null?void 0:a.method)||((i=t.normalization)==null?void 0:i.direction)!==((o=n.normalization)==null?void 0:o.direction)||t.xColumn.value!==n.xColumn.value||t.yColumn.value!==n.yColumn.value||t.valueColumnColor.value!==n.valueColumnColor.value||t.valueColumnSize.value!==n.valueColumnSize.value||t.NAValueAs!==n.NAValueAs}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{facetBy:t,xColumn:n,yColumn:r,valueColumnSize:a,valueColumnColor:i,normalization:o,NAValueAs:s}=this.settings,c=t.map(h=>this.data.getColumnCategories(h.value)),f=(c.length?nZ([...c]):[["null"]]).map(h=>h.join(", ")),A=t.map(h=>h.value)??null;this.data.setGrouping([...A]),this.calculatedData={facetKeys:f,groupedCellsData:m4t(this.data,n,r,a,i,t,f,c,o,s)}}_updateAesInData(){this.calculatedData}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,facetSettings:r,valueColumnColor:a,valueColumnSize:i,normalization:o,aes:s}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.facetKeys,this.calculatedData.groupedCellsData,a,i,o,s)}};function H4t(e){return"type"in e&&e.type==="columns"}var TZ=class DI{constructor(t,n){Me(this,"id");Me(this,"data");Me(this,"rowsCount");Me(this,"columnNames");Me(this,"rowsGrouped");this.id=t,this.data=n,this.columnNames=Object.keys(n),this.rowsCount=this.columnNames.length?n[this.columnNames[0]].length:0}static from(t){if(t instanceof DI)return t;if(H4t(t))return new DI(t.id,t.values);vA(t,"Unknown input data format")}get rows(){let t=this.columnNames,n=[];for(let r=0;r<this.rowsCount;r++)n.push(t.reduce((a,i)=>(a[i]=this.data[i][r],a),{}));return n}getColumn(t){return this.data[t]}getColumnCategories(t){if(!this.columnNames.includes(t))throw new Error(`Column ${t} does not exist`);return Ir.uniq(this.getColumn(t)).map(String)}setGrouping(t){let n={grouped:{},rows:this.rows},r=[n];t.forEach(a=>{let i=a===null?["null"]:this.getColumnCategories(a),o=[];r.forEach(s=>{if(a===null)s.grouped={null:{rows:s.rows,grouped:{}}},o.push(s.grouped.null);else{let c=Ir.groupBy(s.rows,f=>String(f[a]));s.grouped=i.reduce((f,A)=>(f[A]={rows:c[A]??[],grouped:{}},o.push(f[A]),f),{})}}),r=o}),this.rowsGrouped=n.grouped}getColumnByGrouping(t,n){if(!this.rowsGrouped)return[];if(!t.length)return this.rows.map(a=>Number(a[n]));let r={grouped:this.rowsGrouped,rows:this.rows};return t.forEach(a=>{let i=r.grouped[a??"null"];if(!i)return[];r=i}),r.rows.map(a=>Number(a[n]))}getRowsByGrouping(t){if(!this.rowsGrouped)return[];if(!t.length)return this.rows;let n={grouped:this.rowsGrouped,rows:this.rows};return t.forEach(r=>{let a=n.grouped[r??"null"];if(!a)return[];n=a}),n==null?void 0:n.rows}},I4t=class HI{constructor(t){Me(this,"node");Me(this,"chart");this.chart=t}static createChart(t,n,r){let{type:a}=n;if(a==="discrete")return new G7t(t,n);if(a==="dendro")return new F2t(t,n,r);if(a==="scatterplot")return new R9t(t,n);if(a==="scatterplot-umap")return new d4t(t,n,r);if(a==="heatmap")return new Cwt(t,n);if(a==="histogram")return new jwt(t,n);if(a==="bubble")return new D4t(t,n);vA(a,`Unknown chart type: ${a}`)}static newPlot(t,n,r){let a=TZ.from(t);return new this(HI.createChart(a,n,r))}get calculatedData(){return this.chart.calculatedData}mount(t){this.node=t,this.chart.mount(t)}unmount(){delete this.node,this.chart.unmount()}updateSettingsAndData(t,n){if(n.type!==this.chart.settings.type){let r=HI.createChart(this.chart.data,n);this.node?(this.chart.unmount(),this.chart=r,this.chart.mount(this.node)):this.chart=r}else this.chart.updateSettingsAndData(TZ.from(t),n)}updateChartState(t,n){this.chart.updateChartState(t,n)}export(){return this.chart.export()}};/*! Bundled license information:
15190
+ ${_.y+_.height/2})`,children:le.jsx("text",{transform:`rotate(${o.position==="left"?-90:90})`,dominantBaseline:"central",textAnchor:"middle",children:o.title})}),t&&le.jsx("rect",{x:_.x,y:_.y,width:_.width,height:_.height,stroke:Zt,fill:"none"}),k&&le.jsx("g",{fontSize:"14px",transform:`translate(${D.x},${D.y})`,children:r.map(O=>{let I=f.yAxisLabels!==0,$=o.position==="left",Q=-(90-f.yAxisLabels),ee=f.yAxisLabels===0?"middle":$?"end":"start",K=I?"central":$?"auto":"hanging",re=$?D.width:0,U=$?re-g:re+g,G=$?U-y2:U+y2,Z=a.y(O)+c/2;return le.jsxs("g",{children:[le.jsx("line",{x1:re,x2:U,y1:Z,y2:Z,stroke:Zt}),le.jsx("text",{x:G,y:Z,textAnchor:ee,transform:`rotate(${Q},${G},${Z})`,dominantBaseline:K,children:h[O]})]},O)})}),t&&le.jsx("rect",{x:D.x,y:D.y,height:D.height,width:D.width,stroke:Zt,fill:"none"})]})]})}function sE(e){if(e===null)return"null";if(typeof e=="number"){let t=e>0?Math.floor(e):Math.ceil(e),n=e-t;return t+Number(n.toPrecision(2))}return e}function S4t(e,t,n=[]){let r=e.data,a=[`X: ${t.xLabels[e.x]}`,`Y: ${t.yLabels[e.y]}`,`Value (color): ${sE(e.colorValue)}${e.colorValue!==e.normalizedColorValue?` (${sE(e.normalizedColorValue)})`:""}`,`Value (size): ${sE(e.sizeValue)}${e.sizeValue!==e.normalizedSizeValue?` (${sE(e.normalizedSizeValue)})`:""}`];for(let i of n)a.push(`${i.label}: ${r[i.valueLabels??i.value]}`);return a}function B4t({facetKey:e,dimensions:t,scales:n,cells:r,colorScale:a,sizeScale:i,chartSettings:o,cellsMeta:s,stepX:c,stepY:f,aes:A,labelAngles:h,chartSizes:m,margins:g,tooltipsContainer:b}){let[C,x]=Vn.useState(null),{xAxis:k,yAxis:_,tooltips:D}=o,{width:O,height:I}=t.inner,{padding:$,sideElementBBoxes:Q}=t,{xLabels:ee,yLabels:K}=s,re=n.x.domain(),U=n.y.domain(),G={left:g.left+t.left+$.left,right:m.totalWidth-(g.left+t.left+$.left),top:g.top+t.top+$.top,bottom:m.totalHeight-(g.top+t.top+$.top)},Z=!1;return le.jsxs("g",{transform:`translate(${t.left},${t.top})`,fontSize:w4t,children:[le.jsxs("g",{transform:`translate(${$.left},${$.top})`,children:[Q.top.facetTitle.isVisible&&le.jsx("text",{x:Q.top.facetTitle.x,y:Q.top.facetTitle.y+Q.top.facetTitle.height-y4t,fontWeight:"500",fontSize:"20px",children:s.facetKeyValues[e].join(", ")}),Z,re.map(Y=>U.map(X=>{var me;let oe=(me=r==null?void 0:r[Y])==null?void 0:me[X];return oe?le.jsx("circle",{cx:n.x(Y)+c/2,cy:n.y(X)+f/2,r:i(oe.normalizedSizeValue),stroke:A.cellStrokeColor,fill:oe.colorValue===null?A.emptyCellColor:a(oe.normalizedColorValue),onMouseOver:()=>x(oe),onMouseLeave:()=>x(null)},oe?oe.id:`${Y}_${X}`):null})),le.jsx("g",{children:o.frame.type==="full"&&le.jsx("rect",{fill:"none",stroke:Zt,x:"0",y:"0",width:O,height:I})}),le.jsx("g",{fontWeight:"500",children:le.jsx(x4t,{sideElementBBoxes:Q,xKeys:re,yKeys:U,scales:n,xAxis:k,yAxis:_,stepX:c,stepY:f,labelAngles:h,xLabels:ee,yLabels:K,debug:Z})})]}),o.tooltips.show&&C&&le.jsx(oc,{content:S4t(C,s,D==null?void 0:D.content),x:n.x(String(C.x))+c/2,y:n.y(String(C.y))+f/2,offset:re.length>1?c/2:0,active:!0,sideDistances:G,container:b})]})}function k4t({margins:e,captionsSizes:t,settingsId:n,chartSettings:r,chartSizes:a,chartsDimensions:i,facetKeys:o,scales:s,colorScale:c,sizeScale:f,groupedCells:A,cellsMeta:h,step:m,legend:g,aes:b,columnsCount:C,labelAngles:x}){let[k,_]=Vn.useState(),D=Vn.useRef(null);Vn.useEffect(()=>{D.current&&_(D.current)},[]);let O=i[o[0]].padding,I=i[o[C-1]].padding,$=e.left+a.chartsWidth+BZ,Q=e.top+O.top;return le.jsx(f2,{dataId:n,children:le.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${a.totalWidth} ${a.totalHeight}`,width:a.totalWidth,height:a.totalHeight,fontFamily:"Manrope",children:[le.jsx("defs",{children:Tg}),le.jsxs("g",{transform:`translate(${e.left},${e.top})`,children:[le.jsx(d2,{title:[r.title.name],show:r.title.show,position:r.title.position,leftPadding:O.left,rightPadding:I.right,chartsWidth:a.chartsWidth}),o.map(ee=>{let{cells:K}=A[ee];return le.jsx(B4t,{captionsSizes:t,facetKey:ee,dimensions:i[ee],scales:s,cells:K,cellsMeta:h,stepX:m.x,stepY:m.y,colorScale:c,sizeScale:f,chartSettings:r,aes:b,labelAngles:x,margins:e,chartSizes:a,tooltipsContainer:k},ee)})]}),le.jsx("g",{transform:`translate(${$},${Q})`,children:le.jsx(y9,{legendData:g})}),le.jsx("g",{ref:D})]})})}var T4t=(e,t)=>{let n=Math.min(...t),r=Math.max(...t);if(n===r){let o=e%2===0?[]:[n];for(let s=1;s<e/2+1;s++)o.push(n+s),o.unshift(n-s);return o}if(e<2)return[n,r];let a=(r-n)/(e-1),i=[];for(let o=0;o<e-1;o++)i.push(n+a*o);return i.push(r),i};function _4t(e,t,n){let r=n;return e&&(e.colorRange&&(r=e.colorRange),e.method==="standardScaling"&&(r=[-2,2]),e.method==="meanNormalization"&&(r=[-.75,.75])),T4t(t,r)}var P4t=class{constructor(){Me(this,"reactRoot",null);Me(this,"parentNode",null);Me(this,"rootNode",null);Me(this,"component",le.jsx(le.Fragment,{}));Me(this,"chartsDimensions",{});Me(this,"chartSizes",{chartWidth:600,chartHeight:350,chartsWidth:600,chartsHeight:350,totalWidth:600,totalHeight:350});Me(this,"margins",{top:Mg,bottom:Mg,left:Mg,right:Mg});Me(this,"captionsSizes",{xAxisCaptions:100,yAxisCaptions:100,xCaptionTail:0,yCaptionTail:0});Me(this,"labelAngles",{xAxisLabels:0,yAxisLabels:0});Me(this,"columnsCount",1);Me(this,"rowsCount",1);Me(this,"scales",{x:Hl().domain(["null"]).range([1]),y:Hl().domain(["null"]).range([1])});Me(this,"step",{x:10,y:10});Me(this,"colorScale",Da().domain([0,1]).range(["white","black"]));Me(this,"sizeScale",Ny().domain([0,1]).range([3,20]));Me(this,"legend",{width:0,height:0,items:[]})}clear(){var e;this.parentNode&&this.rootNode&&((e=this.parentNode)==null||e.removeChild(this.rootNode),this.parentNode=null,this.rootNode=null),setTimeout(()=>{var t;(t=this.reactRoot)==null||t.unmount(),this.reactRoot=null})}init(e){this.parentNode===null&&(this.parentNode=e,this.rootNode=document.createElement("div"),this.parentNode.appendChild(this.rootNode),this.reactRoot=zh(this.rootNode))}updateMargins(e){this.margins={top:e.show?24+24*2:Mg,bottom:Mg,left:Mg,right:this.legend.width},this.chartSizes.totalWidth=this.margins.left+this.chartSizes.chartsWidth+this.margins.right,this.chartSizes.totalHeight=this.margins.top+Math.max(this.chartSizes.chartsHeight+this.margins.bottom,this.legend.height)}updateLegendSize(e,t,n){if(!e.show){this.legend={width:0,height:0,items:[]};return}let r=[],a=this.chartSizes.chartHeight,i=Math.min(this.chartSizes.chartHeight,350),o={width:0,height:0,left:0,top:0},s=this.colorScale.domain(),c=a2(this.colorScale,[s[0],s[s.length-1]]),f=t.label??t.value,A=Da([c[0],c[c.length-1]],[i,0]);r.push({id:"colorValue",type:"continuous",scale:this.colorScale,tickPositionScale:A,values:c,title:f,...o});let h=n.label??n.value,m=this.sizeScale.ticks(3),g=this.sizeScale.tickFormat(3),b=m.reduce((_,D)=>(_[String(D)]=g(D),_),{});if(r.push({id:"sizeValue",type:"size",title:h,scale:this.sizeScale,values:m,labels:b,...o}),!r.length){this.legend={width:0,height:0,items:[]};return}let C=w9(r,a,i),x=C[C.length-1],k=x.left+x.width+2*BZ;this.legend={width:k,height:a,items:C}}updateCaptionsSize(e,t,n){let r=new Dc("bold 14px Arial"),{xKeys:a,yKeys:i,xLabels:o,yLabels:s}=e.meta;this.labelAngles={xAxisLabels:t.axisLabelsAngle,yAxisLabels:n.axisLabelsAngle};let c=a.map(b=>r.getTextWidth(o[b])),f=i.map(b=>r.getTextWidth(s[b])),{xCaptionTail:A,yCaptionTail:h}=E4t(this.labelAngles,this.step,e,r),m=this.labelAngles.xAxisLabels/180*Math.PI,g=this.labelAngles.yAxisLabels/180*Math.PI;this.captionsSizes={xCaptionTail:A,yCaptionTail:h,xAxisCaptions:Math.max(...c,0)*Math.sin(m)||iE,yAxisCaptions:Math.max(...f,0)*Math.sin(g)||iE}}updateChartDimensions(e,t,n,r){let a=e.length,i=Math.min(t.nRows??a,a),o=Math.min(t.nCols??a,a);this.columnsCount=t.nRows?Math.ceil(a/i):o,this.rowsCount=Math.ceil(a/this.columnsCount),this.chartsDimensions={};let s=0,c=0;e.forEach((h,m)=>{let g=m%this.columnsCount+1,b=zK(m,e.length,this.columnsCount,this.rowsCount),C=this.chartSizes.chartWidth,x=this.chartSizes.chartHeight,k=C4t(n,r,this.captionsSizes,b,e,this.step.x,this.step.y);function _(Q){return Math.max(u1[Q].reduce((ee,K)=>ee+k[Q][K],0),v4t)}let D={left:_("left"),right:_("right"),top:_("top"),bottom:_("bottom")};D.left<this.captionsSizes.xCaptionTail&&(D.left=this.captionsSizes.xCaptionTail),D.bottom<this.captionsSizes.yCaptionTail&&(D.bottom=this.captionsSizes.yCaptionTail);let O=b4t(k,C,x),I=C+D.left+D.right,$=x+D.top+D.bottom;this.chartsDimensions[h]={left:s,top:c,inner:{width:C,height:x},outer:{width:I,height:$},padding:D,sideElementBBoxes:O,chartEdgeSides:b},s+=I,g===this.columnsCount&&(s=0,c+=$)});let f=e.slice(0,this.columnsCount).reduce((h,m)=>h+this.chartsDimensions[m].outer.width,0),A=e.filter((h,m)=>m%this.columnsCount===0).reduce((h,m)=>h+this.chartsDimensions[m].outer.height,0);this.chartSizes.chartsWidth=f,this.chartSizes.chartsHeight=A}updateChartsSizes(e,t){let{width:n,height:r,cellSize:a}=t;a&&(this.chartSizes.chartWidth=e.meta.xKeys.length*a,this.chartSizes.chartHeight=e.meta.yKeys.length*a),n&&r&&(this.chartSizes.chartWidth=n,this.chartSizes.chartHeight=r)}updateScales(e,t,n,r){let{width:a,height:i,cellSize:o}=t,{meta:s}=e,c=(b,C={})=>[...b].sort((x,k)=>n.sorting==="asc"?(C[x]??x).localeCompare(C[k]??k,"en",{numeric:!0}):(C[k]??k).localeCompare(C[x]??x,"en",{numeric:!0})),f=(b,C={})=>[...b].sort((x,k)=>r.sorting==="asc"?(C[x]??x).localeCompare(C[k]??k,"en",{numeric:!0}):(C[k]??k).localeCompare(C[x]??x,"en",{numeric:!0})),A=c(s.xKeys,s.xLabels),h=f(s.yKeys,s.yLabels);o?(this.step.x=o,this.step.y=o):a&&i&&(this.step.x=a/A.length,this.step.y=i/h.length);let m=new Array(A.length).fill(null).map((b,C)=>C*this.step.x),g=new Array(h.length).fill(null).map((b,C)=>C*this.step.y);this.scales.x=Hl().domain(A).range(m),this.scales.y=Hl().domain(h).range(g)}updateAesScale(e,t,n,r){this.colorScale=Da().domain(_4t(r,e.colorsList.length,n)).range(e.colorsList),this.sizeScale=Ny(t,[e.minRadius,e.maxRadius])}render(e,t,n,r,a,i,o,s,c){var _;let{meta:f,facets:A}=a,{valueExtentSize:h,valueExtentColor:m}=f,{xAxis:g,yAxis:b,title:C,size:x}=t;this.updateChartsSizes(a,x),this.updateAesScale(c,h,m,s),this.updateScales(a,x,t.xAxis,t.yAxis),this.updateCaptionsSize(a,g,b),this.updateChartDimensions(r,n,g,b),this.updateLegendSize(t.legend,i,o),this.updateMargins(C);let k=le.jsx(k4t,{aes:c,captionsSizes:this.captionsSizes,cellsMeta:f,columnsCount:this.columnsCount,chartsDimensions:this.chartsDimensions,chartSettings:t,chartSizes:this.chartSizes,sizeScale:this.sizeScale,colorScale:this.colorScale,facetKeys:r,facetSettings:n,groupedCells:A,labelAngles:this.labelAngles,legend:this.legend,margins:this.margins,scales:this.scales,settingsId:e,step:this.step});this.component=k,(_=this.reactRoot)==null||_.render(k)}renderError(e){var t;(t=this.reactRoot)==null||t.render(le.jsx(Fm,{message:e}))}},M4t=P4t,kZ=class{constructor(e){Me(this,"id");Me(this,"type","bubble");Me(this,"facetSettings");Me(this,"valueColumnSize");Me(this,"valueColumnColor");Me(this,"xColumn");Me(this,"yColumn");Me(this,"facetBy");Me(this,"normalization");Me(this,"NAValueAs");Me(this,"chartSettings");Me(this,"aes");var a,i,o,s,c,f,A,h,m,g;u2t.parse(e),this.id=Ir.uniqueId("settings"),this.facetSettings={titlePosition:"left",...e.facetSettings},this.facetBy=e.facetBy??[],this.valueColumnSize=e.valueSize,this.valueColumnColor=e.valueColor,this.xColumn=e.xColumn,this.yColumn=e.yColumn,this.NAValueAs=e.NAValueAs??null,this.normalization=e.normalization??null;let t=((a=e.size)==null?void 0:a.cellSize)??null,n=t?null:((i=e==null?void 0:e.size)==null?void 0:i.width)??(this.facetBy.length?400:600),r=t?null:((o=e==null?void 0:e.size)==null?void 0:o.height)??(this.facetBy.length?250:350);this.chartSettings={size:{width:n,height:r,cellSize:t},title:{position:"center",show:!0,...e.title,name:((s=e.title)==null?void 0:s.name)??"Chart"},yAxis:{title:e.yColumn.label??e.yColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,position:"left",axisLabelsAngle:90,sorting:"asc",...e.yAxis},xAxis:{title:e.xColumn.label??e.xColumn.value,showTicks:!0,showTitle:!0,showAxisLabels:!0,position:"bottom",axisLabelsAngle:90,sorting:"asc",...e.xAxis},frame:{type:((c=e.frame)==null?void 0:c.type)??"full"},legend:{show:!0,position:"right",...e.legend},tooltips:{show:!0,...e.tooltips}},this.aes={minRadius:((f=e.aes)==null?void 0:f.minRadius)??3,maxRadius:((A=e.aes)==null?void 0:A.maxRadius)??20,colorsList:((h=e.aes)==null?void 0:h.colorsList)??["black","white","red"],cellStrokeColor:((m=e.aes)==null?void 0:m.cellStrokeColor)??Zt,emptyCellColor:((g=e.aes)==null?void 0:g.emptyCellColor)??"white"}}},D4t=class extends Sg{constructor(t,n){super(t,n);Me(this,"settings");Me(this,"chartRenderer",new M4t);Me(this,"calculatedData",null);this.settings=new kZ(n)}mount(t){try{this.chartRenderer.init(t),this._updateData(),this._updateChart()}catch(n){n instanceof Error&&this.chartRenderer.renderError(n.message)}}unmount(){this.chartRenderer.clear()}updateSettingsAndData(t,n){try{let r=this.settings,a=this.data;this.settings=new kZ(n),this.data=t,this._needUpdateCalculatedDataBySettings(r,this.settings)||this._needUpdateCalculatedDataByData(a,this.data)?this._updateData():this._updateAesInData(),this._updateChart()}catch(r){r instanceof Error&&this.chartRenderer.renderError(r.message)}}updateChartState(t,n){console.warn("no chart state for bubble chart")}export(){return this._updateChart(),f3(this.chartRenderer.component)}_needUpdateCalculatedDataBySettings(t,n){var r,a,i,o;return t.facetBy.some((s,c)=>{var f;return s.value!==((f=n.facetBy[c])==null?void 0:f.value)})||((r=t.normalization)==null?void 0:r.method)!==((a=n.normalization)==null?void 0:a.method)||((i=t.normalization)==null?void 0:i.direction)!==((o=n.normalization)==null?void 0:o.direction)||t.xColumn.value!==n.xColumn.value||t.yColumn.value!==n.yColumn.value||t.valueColumnColor.value!==n.valueColumnColor.value||t.valueColumnSize.value!==n.valueColumnSize.value||t.NAValueAs!==n.NAValueAs}_needUpdateCalculatedDataByData(t,n){let r=Object.keys(t.data),a=Object.keys(n.data);return t.id!==n.id||r.length!==a.length||r.some(i=>{var o;return t.data[i].length!==((o=n.data[i])==null?void 0:o.length)})}_updateData(){let{facetBy:t,xColumn:n,yColumn:r,valueColumnSize:a,valueColumnColor:i,normalization:o,NAValueAs:s}=this.settings,c=t.map(m=>this.data.getColumnCategories(m.value)),f=c.length?nZ([...c]):[["null"]],A=t.map(m=>m.value)??null;this.data.setGrouping([...A]);let h=m4t(this.data,n,r,a,i,t,f,o,s);this.calculatedData={facetKeys:h.meta.facetKeys,groupedCellsData:h}}_updateAesInData(){this.calculatedData}_updateChart(){if(!this.calculatedData)return;let{id:t,chartSettings:n,facetSettings:r,valueColumnColor:a,valueColumnSize:i,normalization:o,aes:s}=this.settings;this.chartRenderer.render(t,n,r,this.calculatedData.facetKeys,this.calculatedData.groupedCellsData,a,i,o,s)}};function H4t(e){return"type"in e&&e.type==="columns"}var TZ=class DI{constructor(t,n){Me(this,"id");Me(this,"data");Me(this,"rowsCount");Me(this,"columnNames");Me(this,"rowsGrouped");this.id=t,this.data=n,this.columnNames=Object.keys(n),this.rowsCount=this.columnNames.length?n[this.columnNames[0]].length:0}static from(t){if(t instanceof DI)return t;if(H4t(t))return new DI(t.id,t.values);vA(t,"Unknown input data format")}get rows(){let t=this.columnNames,n=[];for(let r=0;r<this.rowsCount;r++)n.push(t.reduce((a,i)=>(a[i]=this.data[i][r],a),{}));return n}getColumn(t){return this.data[t]}getColumnCategories(t){if(!this.columnNames.includes(t))throw new Error(`Column ${t} does not exist`);return Ir.uniq(this.getColumn(t)).map(String)}setGrouping(t){let n={grouped:{},rows:this.rows},r=[n];t.forEach(a=>{let i=a===null?["null"]:this.getColumnCategories(a),o=[];r.forEach(s=>{if(a===null)s.grouped={null:{rows:s.rows,grouped:{}}},o.push(s.grouped.null);else{let c=Ir.groupBy(s.rows,f=>String(f[a]));s.grouped=i.reduce((f,A)=>(f[A]={rows:c[A]??[],grouped:{}},o.push(f[A]),f),{})}}),r=o}),this.rowsGrouped=n.grouped}getColumnByGrouping(t,n){if(!this.rowsGrouped)return[];if(!t.length)return this.rows.map(a=>Number(a[n]));let r={grouped:this.rowsGrouped,rows:this.rows};return t.forEach(a=>{let i=r.grouped[a??"null"];if(!i)return[];r=i}),r.rows.map(a=>Number(a[n]))}getRowsByGrouping(t){if(!this.rowsGrouped)return[];if(!t.length)return this.rows;let n={grouped:this.rowsGrouped,rows:this.rows};return t.forEach(r=>{let a=n.grouped[r??"null"];if(!a)return[];n=a}),n==null?void 0:n.rows}},I4t=class HI{constructor(t){Me(this,"node");Me(this,"chart");this.chart=t}static createChart(t,n,r){let{type:a}=n;if(a==="discrete")return new G7t(t,n);if(a==="dendro")return new F2t(t,n,r);if(a==="scatterplot")return new R9t(t,n);if(a==="scatterplot-umap")return new d4t(t,n,r);if(a==="heatmap")return new Cwt(t,n);if(a==="histogram")return new jwt(t,n);if(a==="bubble")return new D4t(t,n);vA(a,`Unknown chart type: ${a}`)}static newPlot(t,n,r){let a=TZ.from(t);return new this(HI.createChart(a,n,r))}get calculatedData(){return this.chart.calculatedData}mount(t){this.node=t,this.chart.mount(t)}unmount(){delete this.node,this.chart.unmount()}updateSettingsAndData(t,n){if(n.type!==this.chart.settings.type){let r=HI.createChart(this.chart.data,n);this.node?(this.chart.unmount(),this.chart=r,this.chart.mount(this.node)):this.chart=r}else this.chart.updateSettingsAndData(TZ.from(t),n)}updateChartState(t,n){this.chart.updateChartState(t,n)}export(){return this.chart.export()}};/*! Bundled license information:
15191
15191
 
15192
15192
  @stdlib/utils-define-property/lib/define_property.js:
15193
15193
  (**