"use strict";var ae=Object.create;var bt=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var fe=(o,n)=>{for(var m in n)bt(o,m,{get:n[m],enumerable:!0})},Kt=(o,n,m,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ue(n))!ce.call(o,r)&&r!==m&&bt(o,r,{get:()=>n[r],enumerable:!(l=le(n,r))||l.enumerable});return o};var ot=(o,n,m)=>(m=o!=null?ae(me(o)):{},Kt(n||!o||!o.__esModule?bt(m,"default",{value:o,enumerable:!0}):m,o)),de=o=>Kt(bt({},"__esModule",{value:!0}),o);var pe={};fe(pe,{GeomPoint:()=>Et,Legend:()=>_t,SizeLegend:()=>Nt});module.exports=de(pe);var a=ot(require("react"),1),Yt=require("react-move"),vt=require("d3-ease"),Ht=require("d3-scale"),Xt=require("d3-array"),Zt=require("d3-interpolate"),st=require("jotai"),p=require("@graphique/graphique");var j=ot(require("react"),1),It=require("jotai"),J=require("@graphique/graphique");var _=ot(require("react"),1),Ft=require("jotai"),U=require("@graphique/graphique"),qt=({data:o})=>{let[{x:n,y:m}]=(0,Ft.useAtom)(U.labelsState),[{tooltip:l}]=(0,Ft.useAtom)(U.themeState);return o?_.default.createElement(U.TooltipContainer,null,o.map(r=>{let w=(0,U.formatMissing)(r.group);return _.default.createElement("div",{key:`group-tooltip-${r.label||w}`},_.default.createElement("div",{style:{marginTop:4,marginBottom:4}},(r.label||r.group!=="__group")&&_.default.createElement(_.default.Fragment,null,r.mark,_.default.createElement("div",{style:{display:"flex",alignItems:"flex-end",fontWeight:500}},_.default.createElement("div",{style:{marginBottom:4}},_.default.createElement("span",{style:{fontSize:l?.groupLabel?.fontSize||l?.font?.size}},r.formattedMeasure||w)))),_.default.createElement("div",{style:{display:"flex",marginBottom:2}},n&&_.default.createElement("div",{style:{fontSize:l?.xLabel?.fontSize||l?.font?.size}},`${n}:`),_.default.createElement("div",{style:{marginLeft:1,fontWeight:500,fontSize:l?.xLabel?.fontSize||(l?.font?.size||12)+1}},r.formattedX)),_.default.createElement("div",{style:{display:"flex"}},m&&_.default.createElement("div",{style:{fontSize:l?.yLabel?.fontSize||l?.font?.size}},`${m}:`),_.default.createElement("div",{style:{marginLeft:1,fontWeight:500,fontSize:l?.yLabel?.fontSize||(l?.font?.size||12)+1}},r.formattedY))))})):null};var Ot=({aes:o,group:n})=>{let{ggState:m}=(0,J.useGG)()||{},{id:l,scales:r,height:w,width:T}=m||{width:0,height:0},[{datum:D,position:b,xFormat:A,yFormat:V,measureFormat:v,content:G}]=(0,It.useAtom)(J.tooltipState),[{x:E,y:h}]=(0,It.useAtom)(J.labelsState),i=(0,j.useMemo)(()=>D&&D[0],[D]),s=(0,j.useMemo)(()=>{let C={given:i&&o?.label&&o.label(i),keyed:i&&o?.key&&o.key(i)};return C?.given||C?.keyed},[o,i]),F=r?.xScale,u=r?.yScale,c=(0,j.useMemo)(()=>r?.xScale.bandwidth?r?.xScale.bandwidth()/2:0,[r]),f=(0,j.useMemo)(()=>r?.yScale?.bandwidth?r.yScale.bandwidth()/2:0,[r]),k=(0,j.useMemo)(()=>i&&n&&n(i),[i,n]),x=[{x:i&&o?.x&&F&&F(o.x(i)),y:i&&o?.y&&u&&u(o.y(i)),xLab:E?.toString(),yLab:h?.toString(),formattedX:i&&o?.x&&(A?A(o.x(i)):o.x(i)),formattedY:i&&o?.y&&(V?V(o.y(i)):o.y(i)),group:k,label:s,formattedMeasure:v&&(s||String(k))&&v(s||k),datum:D,containerWidth:T}],L=G?i&&j.default.createElement("div",null,G(x)):i&&j.default.createElement(qt,{data:x});return i&&x[0].x!==void 0&&x[0].y!==void 0?j.default.createElement("div",null,j.default.createElement(J.YTooltip,{id:l,left:(x[0].x||0)+c,top:b==="data"?-(w-(x[0].y||0)-f):-w,value:L})):null};var Et=({data:o,aes:n,focusedStyle:m,unfocusedStyle:l,focusedKeys:r=[],onDatumFocus:w,onDatumSelection:T,entrance:D="midpoint",onExit:b,showTooltip:A=!0,brushAction:V,fillOpacity:v=1,strokeOpacity:G=1,isClipped:E=!0,r:h=3.5,...i})=>{let{ggState:s}=(0,p.useGG)()||{},{id:F,data:u,aes:c,scales:f,copiedScales:k,height:x,margin:L}=s||{},[y,C]=(0,st.useAtom)(p.themeState),[B]=(0,st.useAtom)(p.radiusScaleState),[{xDomain:Z,yDomain:d}]=(0,st.useAtom)(p.zoomState),[{isFixed:g}]=(0,st.useAtom)(p.xScaleState),[{isFixed:S}]=(0,st.useAtom)(p.yScaleState),W=(0,p.usePageVisibility)(),{domain:Q,range:ut}=B||{},{fill:nt,stroke:R,strokeWidth:mt}={...i},{defaultFill:rt,animationDuration:P}=y,$=(0,a.useMemo)(()=>o||u,[u,o]),e=(0,a.useMemo)(()=>n?{...c,...n}:c,[c,n]),H=(0,a.useMemo)(()=>e&&(0,p.defineGroupAccessor)(e),[e,p.defineGroupAccessor]),K=(0,a.useCallback)(t=>`${e?.x&&e.x(t)}-${e?.y&&e.y(t)}-${H&&H(t)}`,[e,H]),tt=(0,a.useCallback)(t=>e?.key?e.key(t):K(t),[e,H,K]),Gt=(0,a.useMemo)(()=>$?$.filter(t=>e?.x&&(e.x(t)===null||typeof e.x(t)>"u"||(0,p.isDate)(e.x(t))&&Number.isNaN(e.x(t)?.valueOf()))):[],[$,e]),Lt=(0,a.useMemo)(()=>$?$.filter(t=>e?.y&&(e.y(t)===null||typeof e.y(t)>"u")):[],[$]),et=(0,a.useMemo)(()=>r.filter(t=>t),[r]),X=(0,a.useMemo)(()=>{let t=$?.filter(M=>e?.x&&e?.x(M)!==null&&!(typeof e?.x(M)>"u")&&((0,p.isDate)(e?.x(M))?!Number.isNaN(e?.x(M)?.valueOf()):!0)&&e.y&&e.y(M)!==null&&!(typeof e.y(M)>"u"));return Array.from(new Set(t?.map(M=>tt(M)))).flatMap(M=>{let q=t?.filter(Vt=>tt(Vt)===M);return q&&q.length>1?q.map((Vt,se)=>({...Vt,gg_gen_index:se})):q?.flat()})},[$,tt]),ne=(0,a.useMemo)(()=>X.map(K).join(""),[X,K]),[it,re]=(0,a.useState)(!0);(0,a.useEffect)(()=>{let t=setTimeout(()=>re(!1),0);return()=>clearTimeout(t)},[]),(0,a.useEffect)(()=>{it&&Gt.length>0&&console.warn(`Ignoring ${Gt.length} points with missing x values.`),it&&Lt.length>0&&console.warn(`Ignoring ${Lt.length} points with missing y values.`)},[it,Gt,Lt]);let Bt=(0,a.useMemo)(()=>x&&L?x-L.bottom:void 0,[x,L]);(0,a.useEffect)(()=>{C(t=>({...t,geoms:{...t.geoms,point:{fillOpacity:i.style?.fillOpacity||v,stroke:R,strokeWidth:i.style?.strokeWidth||mt,strokeOpacity:i.style?.strokeOpacity||G,size:e?.size}}}))},[v,C,R,G,mt,i.style]);let Pt={transition:"fill-opacity 200ms",fillOpacity:v,strokeOpacity:G,...i.style},Tt={...Pt,fillOpacity:v,strokeOpacity:G,...m},wt={...Pt,fillOpacity:.2,strokeOpacity:.2,...l},pt=(0,a.useMemo)(()=>t=>nt||(e?.fill&&k?.fillScale?k.fillScale(e.fill(t)):rt),[e,k,nt,rt]),yt=(0,a.useMemo)(()=>t=>R||(e?.stroke&&k?.strokeScale?k.strokeScale(e.stroke(t)):"none"),[e,k,R]),gt=(0,a.useMemo)(()=>{if(X&&e?.size&&ut&&Q){let t=Q[0]&&Q[1]?Q:(0,Xt.extent)(X,e.size);return(0,Ht.scaleSqrt)().domain(t).range(ut).unknown([h])}return()=>h},[h,e,X,ut,Q]),St=(0,a.useMemo)(()=>f?.xScale.bandwidth?t=>(f?.xScale(e?.x&&e.x(t))||0)+f?.xScale.bandwidth()/2+.9:t=>f?.xScale&&e?.x&&(f.xScale(e.x(t))||0),[f,e]),xt=(0,a.useMemo)(()=>f?.yScale.bandwidth?t=>(f?.yScale(e?.y&&e.y(t))||0)+f?.yScale.bandwidth()/2:t=>f?.yScale&&e?.y&&(f.yScale(e.y(t))||0),[f,e]),jt=(0,a.useRef)(null),ct=jt.current?.getElementsByTagName("circle"),[ie,Wt]=(0,a.useState)(E||g||S);return(0,a.useEffect)(()=>{if(Z?.current||d?.current)Wt(!0);else{let t=setTimeout(()=>Wt(E),P);return()=>clearTimeout(t)}},[g,S,Z?.current,d?.current,P]),a.default.createElement(a.default.Fragment,null,a.default.createElement("g",{ref:jt,clipPath:ie?`url(#__gg_canvas_${F})`:void 0},!it&&W&&a.default.createElement(Yt.NodeGroup,{data:[...X],keyAccessor:t=>e?.key?tt(t):`${tt(t)}-${t.gg_gen_index}`,start:t=>({cx:St(t),cy:D==="data"?xt(t):Bt,fill:pt(t),stroke:yt(t),r:0,fillOpacity:0,strokeOpacity:0}),enter:t=>({cx:[St(t)],cy:[xt(t)],r:[e?.size?gt(e.size(t)):gt(t)],fill:[pt(t)],stroke:[yt(t)],fillOpacity:[v],strokeOpacity:[G],timing:{duration:P,ease:vt.easeCubic}}),update:t=>({cx:[St(t)],cy:[xt(t)],fill:it?pt(t):[pt(t)],stroke:it?yt(t):[yt(t)],r:[e?.size?gt(e.size(t)):gt(t)],fillOpacity:[v],strokeOpacity:[G],timing:{duration:P,ease:vt.easeCubic}}),leave:()=>({fill:["transparent"],stroke:["transparent"],cy:[Bt],timing:{duration:P,ease:vt.easeCubic}}),interpolation:(t,I)=>(0,Zt.interpolate)(t,I)},t=>a.default.createElement(a.default.Fragment,null,t.map(({state:I,key:M})=>{let q={};return et.includes(M)&&(q=Tt),et?.length>0&&!et.includes(M)&&(q=wt),a.default.createElement("circle",{key:M,...i,r:I.r>=0?I.r:h,fill:I.fill,stroke:I.stroke,cx:I.cx,cy:I.cy,fillOpacity:I.fillOpacity,strokeOpacity:I.strokeOpacity,style:{pointerEvents:"none",...q},"data-testid":"__gg_geom_point"})})))),(A||V)&&e&&a.default.createElement(a.default.Fragment,null,a.default.createElement(p.EventArea,{data:X,showTooltip:A,brushAction:V,aes:e,x:St,y:xt,onDatumFocus:w,onMouseOver:({i:t})=>{let I=X.flatMap((M,q)=>et.includes(tt(M))?q:[]);ct&&(0,p.focusNodes)({nodes:ct,focusedIndex:[...I,...[t].flat()],focusedStyles:Tt,unfocusedStyles:wt})},onClick:T?({d:t,i:I})=>{T(t,I)}:void 0,onMouseLeave:()=>{ct&&((0,p.unfocusNodes)({nodes:ct,baseStyles:Pt}),et&&et.length&&(0,p.focusNodes)({nodes:ct,focusedIndex:X.flatMap((t,I)=>et.includes(tt(t))?I:[]),focusedStyles:Tt,unfocusedStyles:wt})),b&&b()},positionKeys:ne}),A&&a.default.createElement(Ot,{aes:e,group:H})))};Et.displayName="GeomPoint";var Ct=ot(require("react"),1),zt=require("@graphique/graphique"),te=require("jotai");var N=ot(require("react"),1),Y=require("@graphique/graphique"),ht=require("jotai"),Ut=({legendData:o,legendScales:n,orientation:m="vertical",labelFormat:l,fontSize:r=12,onSelection:w})=>{let[T,D]=(0,N.useState)(n.groups||[]),[{geoms:b}]=(0,ht.useAtom)(Y.themeState),[{domain:A}]=(0,ht.useAtom)(Y.fillScaleState),[{domain:V}]=(0,ht.useAtom)(Y.strokeScaleState),v=A||V||n.groups,{ggState:G,updateData:E}=(0,Y.useGG)()||{},{scales:h,data:i}=G||{};(0,N.useEffect)(()=>{D(h?.groups||[])},[h,i]);let s=n.groupAccessor?n.groupAccessor:()=>n.groups&&n.groups[0],F=m==="horizontal",u=c=>{let f=T,k;f.includes(c)?f.length===1?k=n.groups:k=f.filter(L=>L!==c):k=[...f,c],D(k);let x=Array.from(new Set(i?.map(L=>s(L))));if(w&&w(c),i&&E){let L;x.includes(c)?x.length===1?L=o:L=i.filter(y=>s(y)!==c):L=o.filter(y=>x.includes(s(y))||s(y)===c),E(L)}};return N.default.createElement("div",{style:{marginTop:8,display:"flex",flexDirection:F?"row":"column",flexWrap:"wrap",alignItems:F?"center":void 0}},b?.point?.fillOpacity&&v?.map((c,f,k)=>N.default.createElement("div",{key:c,style:{display:"flex",alignItems:"center",marginBottom:F?6:2}},N.default.createElement("div",{tabIndex:0,role:"button",style:{cursor:"pointer",marginRight:f{["Enter"," "].includes(x.key)&&u(c)},onClick:()=>u(c)},N.default.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center"}},N.default.createElement("svg",{width:12,height:12},N.default.createElement("circle",{r:4,cx:6,cy:6,fill:b?.point?.fill||(n.fillScale?n.fillScale(c):"none"),stroke:b?.point?.stroke||(n.strokeScale?n.strokeScale(c):"none"),strokeWidth:1.8,fillOpacity:T.includes(c)?b?.point?.fillOpacity:.5,strokeOpacity:T.includes(c)?b?.point?.strokeOpacity:.5,style:{transition:"fill-opacity 200ms"}}))),N.default.createElement("div",{style:{marginLeft:4,fontSize:r}},l?l(c,f):(0,Y.formatMissing)(c))))))};var z=ot(require("react"),1),kt=require("jotai"),at=require("@graphique/graphique"),Jt=require("d3-interpolate"),ft=require("d3-selection"),Mt=require("d3-axis"),Dt=require("d3-array"),Qt=require("d3-transition"),Rt=({scales:o,tickFormat:n,width:m=320,tickSize:l=6,height:r=30+l,margin:w,numTicks:T=m/64,fontSize:D=10})=>{let b=(0,z.useRef)(null),A=(0,z.useRef)(null),V=(0,z.useRef)(null),v=(0,z.useRef)(null),G=(0,z.useRef)(null),E=o?.fillScale||o?.strokeScale,[{geoms:h,font:i,legend:s,animationDuration:F}]=(0,kt.useAtom)(at.themeState),[{reverse:u}]=(0,kt.useAtom)(at.fillScaleState),[{reverse:c}]=(0,kt.useAtom)(at.strokeScaleState),[f,k]=(0,z.useState)(!0);(0,z.useEffect)(()=>{let B=setTimeout(()=>k(!1),0);return()=>clearTimeout(B)},[]);let x=u||c,L=256,y={top:4,right:0,bottom:16+l,left:0,...w},C=(0,z.useCallback)((B,Z)=>{if(b.current&&A.current&&V.current&&v.current&&G.current){let d=(P,$,e)=>{let H=P.getContext("2d");for(let K=0;KP.selectAll(".tick line").attr("y1",y.top+y.bottom-r),ut=(0,ft.select)(A.current),nt=(0,ft.select)(V.current),R=(0,ft.select)(v.current),mt=(0,ft.select)(G.current),rt=(0,Qt.transition)().duration(g);if(!B?.interpolate){if(B?.interpolator){if(S=Object.assign(B.copy().interpolator((0,Jt.interpolateRound)(y.left,m-y.right)),{range(){return[y.left,m-y.right]}}),mt.attr("x",y.left).attr("y",y.top).attr("width",m-y.left-y.right).attr("height",r-y.top-y.bottom).attr("preserveAspectRatio","none").attr("xlink:href",d(A.current,B.interpolator(),L).toDataURL()),f&&mt.style("opacity",0).transition(rt).style("opacity",o?.fillScale&&h?.point?.fillOpacity||o?.strokeScale&&h?.point?.strokeOpacity||void 0),!S.ticks&&W===void 0){let P=Math.round(T+1);W=(0,Dt.range)(P).map($=>(0,Dt.quantile)(B.domain(),$/(P-1)))}ut.remove()}}x&&S.domain(S.domain().reverse()),nt.attr("transform",`translate(0,${r-y.bottom})`).transition(rt).call((0,Mt.axisBottom)(S).ticks(T,typeof n=="string"?n:void 0).tickFormat(typeof n=="function"?n:void 0).tickSize(l).tickValues(W)),nt.call(P=>P.select(".domain").remove()).selectAll("line").attr("stroke",s?.tickColor||"currentColor").style("opacity",s?.tickColor?1:.85),nt.selectAll(".tick").select("text").style("font-family",Z||"sans-serif").style("font-size",D).attr("fill",s?.labelColor||"currentColor").style("opacity",s?.labelColor?1:.85),R.attr("transform",`translate(0,${r-y.bottom})`).transition(rt).call((0,Mt.axisBottom)(S).ticks(T,typeof n=="string"?n:void 0).tickSize(1).tickFormat(()=>"")).selectAll("line").attr("stroke","#111"),R.call(P=>P.select(".domain").remove()).call(P=>P.selectAll(".tick").select("text").remove()).call(Q)}},[m,r,T,n,l,y,s,h,o,D,f,x,F]);return(0,z.useEffect)(()=>{C(E,i?.family)},[i,E,C]),z.default.createElement("div",null,i?.family&&z.default.createElement("svg",{ref:b,width:m,height:r,viewBox:`0 0 ${m} ${r}`,style:{overflow:"visible",display:"block"}},z.default.createElement("image",{ref:G}),z.default.createElement("g",{ref:V}),z.default.createElement("g",{ref:v})),z.default.createElement("canvas",{ref:A,width:L,height:1}))};var _t=({title:o,style:n,orientation:m="vertical",format:l,numTicks:r,width:w,onSelection:T})=>{let{ggState:D}=(0,zt.useGG)()||{},{copiedScales:b,copiedData:A,aes:V}=D||{},[{font:v}]=(0,te.useAtom)(zt.themeState),{groups:G}=b||{},E=V?.fill||V?.stroke,{fontSize:h}={...n};return E?Ct.default.createElement("div",{style:{fontFamily:v?.family,...n}},o,A&&b&&G?Ct.default.createElement(Ut,{legendData:A,orientation:m,legendScales:b,labelFormat:l,fontSize:h,onSelection:T}):Ct.default.createElement(Rt,{scales:b,tickFormat:l,numTicks:r,fontSize:h,width:w})):null};var O=ot(require("react"),1),$t=require("jotai"),At=require("d3-selection"),dt=require("d3-array"),lt=require("@graphique/graphique"),ee=require("d3-scale"),oe=require("d3-transition"),Nt=({labelDirection:o="right",radiiVals:n,width:m=120,numCircles:l=3,format:r,style:w,title:T})=>{let[{domain:D,range:b}]=(0,$t.useAtom)(lt.radiusScaleState)||{},[{font:A,animationDuration:V,geoms:v}]=(0,$t.useAtom)(lt.themeState)||{},{ggState:G}=(0,lt.useGG)()||{},{data:E}=G||{},h=(0,O.useRef)(null),i=(0,O.useMemo)(()=>D&&D[0]&&D[1]?D:E&&v?.point?.size?(0,dt.extent)(E,v.point.size):[],[E,v,D]),s=(0,O.useMemo)(()=>(0,ee.scaleSqrt)().domain(i).range(b),[i,b]),F=(0,O.useMemo)(()=>{let C=s.ticks();return n||l===3?[C[0],C[3],C[C.length-1]]:(0,dt.extent)(C)},[n,l,s]),u=(0,O.useMemo)(()=>(0,dt.max)(F)||0,[F]),{fontSize:c,color:f}={...w},[k,x]=(0,O.useState)(!0);(0,O.useEffect)(()=>{let C=setTimeout(()=>x(!1),0);return()=>clearTimeout(C)},[]),(0,O.useEffect)(()=>{let C=F.map(d=>({value:d,r:s(d)})),B=V??1e3,Z=(0,oe.transition)().duration(B);(0,At.select)(h.current).selectAll("circle").attr("fill","transparent").attr("stroke","currentColor").style("opacity",.6).attr("stroke-width",1.5).attr("stroke-dasharray","0.05 4").attr("stroke-linecap","round").attr("cx",0).data(C,(d,g)=>g).join(d=>d.append("circle").attr("r",0).attr("cy",s(u)),d=>d.call(g=>g.transition(Z).attr("r",S=>S.r).attr("cy",S=>S.value===u?0:s(u)-S.r))),(0,At.select)(h.current).selectAll("line").attr("stroke","currentColor").attr("x1",(d,g)=>o==="right"?d.r/2+(g+15)*.5-(g+1)*2:-(d.r/2+(g+15)*.5-(g+1)*2)).attr("x2",o==="right"?s(u)+15:-s(u)-12).data(C,(d,g)=>g).join(d=>d.append("line").attr("y1",s(u)).attr("y2",s(u)).style("opacity",0),d=>d.call(g=>g.transition(Z).attr("x1",(S,W)=>o==="right"?S.r/2+(W+15)*.5-(W+1)*2:-(S.r/2+(W+15)*.5-(W+1)*2)).attr("y1",S=>s(u)-2*S.r+3).attr("y2",S=>s(u)-2*S.r+3).style("opacity",.25))),(0,At.select)(h.current).selectAll("text").data(C,(d,g)=>g).attr("x",o==="right"?s(u)+18:-s(u)-15).style("font-size",c||10).attr("dominant-baseline","central").attr("text-anchor",o==="right"?"start":"end").attr("fill",f||"currentColor").text((d,g)=>r?r(d.value,g):d.value.toLocaleString()).join(d=>d.append("text").attr("y",s(u)).style("opacity",0),d=>d.call(g=>g.transition(Z).attr("x",o==="right"?s(u)+18:-s(u)-15).attr("y",S=>s(u)-2*S.r+3).style("opacity",.85)))},[k,s,F,A,r,o,u,c,f,V]);let L=o==="right"?s(u)+2:m-s(u)-2,y=s(u)+2;return s.domain()[0]&&s.domain()[1]?O.default.createElement("div",{style:{fontFamily:A?.family,...w}},T,O.default.createElement("div",{style:{marginTop:8}},O.default.createElement("svg",{height:s(u)*2+4,width:m},O.default.createElement("g",{style:{transform:`translate(${L}px, ${y}px)`},ref:h})))):null};0&&(module.exports={GeomPoint,Legend,SizeLegend}); //# sourceMappingURL=index.cjs.map