"use strict";var it=Object.create;var w=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var mt=(e,i)=>{for(var a in i)w(e,a,{get:i[a],enumerable:!0})},B=(e,i,a,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let u of st(i))!at.call(e,u)&&u!==a&&w(e,u,{get:()=>i[u],enumerable:!(l=nt(i,u))||l.enumerable});return e};var $=(e,i,a)=>(a=e!=null?it(rt(e)):{},B(i||!e||!e.__esModule?w(a,"default",{value:e,enumerable:!0}):a,e)),lt=e=>B(w({},"__esModule",{value:!0}),e);var ut={};mt(ut,{GeomHLine:()=>W});module.exports=lt(ut);var o=$(require("react"),1),S=require("@graphique/graphique"),U=require("react-move"),X=require("jotai"),P=require("d3-ease"),Z=require("d3-interpolate");var c=$(require("react"),1),Y=require("jotai"),T=require("@graphique/graphique");var y=$(require("react"),1),H=require("jotai"),v=require("@graphique/graphique"),N=({data:e})=>{let[{y:i}]=(0,H.useAtom)(v.labelsState),[{tooltip:a}]=(0,H.useAtom)(v.themeState);return e?y.default.createElement(v.TooltipContainer,null,e.map(l=>y.default.createElement("div",{key:`group-tooltip-${l.label??""}`},y.default.createElement("div",{style:{marginTop:4,marginBottom:4}},l.label&&y.default.createElement(y.default.Fragment,null,l.mark,y.default.createElement("div",{style:{display:"flex",alignItems:"flex-end",fontWeight:500}},y.default.createElement("div",{style:{marginBottom:4}},y.default.createElement("span",{style:{fontSize:a?.groupLabel?.fontSize||a?.font?.size}},l.formattedMeasure)))),y.default.createElement("div",{style:{display:"flex",marginBottom:2,alignItems:"flex-end"}},l.label?y.default.createElement("div",{style:{fontSize:a?.groupLabel?.fontSize||a?.font?.size,marginRight:2}},`${l.label}:`):i&&y.default.createElement("div",{style:{fontSize:a?.groupLabel?.fontSize||a?.font?.size,marginRight:2}},`${i}:`),y.default.createElement("div",{style:{marginLeft:1,fontWeight:500,fontSize:a?.yLabel?.fontSize||(a?.font?.size||12)+1}},l.formattedY)))))):null};var M=({aes:e,group:i})=>{let{ggState:a}=(0,T.useGG)()||{},{id:l,scales:u,width:A,height:C,margin:O}=a||{width:0,height:0},[{datum:d,xFormat:D,yFormat:g,measureFormat:L,content:z}]=(0,Y.useAtom)(T.tooltipState),n=(0,c.useMemo)(()=>d&&d[0],[d]),m=(0,c.useMemo)(()=>{let x={given:n&&e?.label&&e.label(n),keyed:n&&e?.key&&e.key(n)};return x?.given??x?.keyed},[e,n]),k=u?.xScale,h=u?.yScale,p=(0,c.useMemo)(()=>u?.yScale.bandwidth?u?.yScale.bandwidth()/2:0,[u]),G=(0,c.useMemo)(()=>n&&i&&i(n),[n,i]),s=[{x:n&&e?.x&&k&&k(e.x(n)),y:n&&e?.y&&h&&h(e.y(n)),formattedX:n&&e?.x&&(D?D(e.x(n)):e.x(n)),formattedY:n&&e?.y&&(g?g(e.y(n)):e.y(n)),group:G,label:m,formattedMeasure:L?L(m??G):void 0,datum:d,containerWidth:A}],V=z?d&&c.default.createElement("div",null,z(s)):d&&c.default.createElement(N,{data:s});return d&&s[0].y!==void 0?c.default.createElement("div",null,c.default.createElement(T.YTooltip,{id:l,left:A-(O?.right||0),top:(s[0].y||0)-C+p,value:V})):null};var K=6,W=({data:e,aes:i,focusedStyle:a,unfocusedStyle:l,onDatumFocus:u,onDatumSelection:A,onExit:C,showTooltip:O=!0,strokeWidth:d=1.5,strokeOpacity:D=1,...g})=>{let{ggState:L}=(0,S.useGG)()||{},{data:z,aes:n,scales:m,copiedScales:k,width:h,margin:p}=L||{},G=e||z,s=(0,o.useMemo)(()=>i?{...n,...i}:n,[n,i]),[V,E]=(0,X.useAtom)(S.themeState),{stroke:x,strokeDasharray:q}={...g},{defaultStroke:j,animationDuration:F}=V,J=(0,S.usePageVisibility)(),[Q,R]=(0,o.useState)(!0);(0,o.useEffect)(()=>{let t=setTimeout(()=>R(!1),0);return()=>clearTimeout(t)},[]),(0,o.useEffect)(()=>{E(t=>({...t,geoms:{...t.geoms,vline:{strokeWidth:g.style?.strokeWidth||d,strokeOpacity:g.style?.strokeOpacity||D,strokeDasharray:q,stroke:x}}}))},[E,x,D,d,g.style]);let I=(0,o.useMemo)(()=>t=>x||(s?.stroke&&k?.strokeScale?k.strokeScale(s.stroke(t)):j),[s,k,x,j]),f=(0,o.useMemo)(()=>t=>(m?.yScale&&s?.y&&m.yScale(s.y(t)))??0,[m,s]),b=(0,o.useMemo)(()=>m?.yScale?.bandwidth?m.yScale.bandwidth()/2*m.yScale.paddingInner():0,[m]),_=(0,o.useMemo)(()=>t=>{let r=m?.yScale&&m.yScale.domain();return m.yScale?.bandwidth?.()&&s.y&&r.includes(String(s.y(t)))?!1:r&&(f(t)>m.yScale(r[0])||f(t)(t,r)=>s?.key?s.key(t):`${s?.y&&s.y(t)}-${m?.groupAccessor&&m.groupAccessor(t)}-${r}`,[s,m]),et=(0,o.useRef)(null);return o.default.createElement(o.default.Fragment,null,o.default.createElement("g",{ref:et},!Q&&h&&J&&o.default.createElement(U.NodeGroup,{data:[...G],keyAccessor:tt,start:t=>({x1:p?.left||0,x2:p?.left||0,y1:f(t)-b,y2:f(t)-b,stroke:I(t),strokeOpacity:0}),enter:t=>{let r=_(t);return{x1:[(p?.left||0)-K],x2:[h-(p?.right||0)],y1:[f(t)-b],y2:[f(t)-b],stroke:[I(t)],strokeOpacity:[r?0:D],timing:{duration:F,ease:P.easeCubic}}},update:t=>{let r=_(t);return{x1:[(p?.left||0)-K],x2:[h-(p?.right||0)],y1:[f(t)-b],y2:[f(t)-b],stroke:[I(t)],strokeOpacity:[r?0:D],timing:{duration:F,ease:P.easeCubic}}},leave:()=>({stroke:["transparent"],x1:[p?.left||0],x2:[p?.left||0],timing:{duration:F,ease:P.easeCubic}}),interpolation:(t,r)=>(0,Z.interpolate)(t,r)},t=>o.default.createElement(o.default.Fragment,null,t.map(({state:r,key:ot})=>o.default.createElement("line",{key:ot,...g,x1:r.x1,x2:r.x2,y1:r.y1,y2:r.y2,stroke:r.stroke,strokeWidth:d,strokeOpacity:r.strokeOpacity,style:{pointerEvents:"none"},"data-testid":"__gg_geom_hline"}))))),O&&o.default.createElement(o.default.Fragment,null,o.default.createElement(S.EventArea,{data:G?.filter(t=>!_(t)),aes:s,x:()=>0,y:f,group:"y",onDatumFocus:u,onClick:A?({d:t,i:r})=>{A(t,r)}:void 0,onMouseLeave:()=>{C&&C()}}),o.default.createElement(M,{aes:s})))};W.displayName="GeomHLine";0&&(module.exports={GeomHLine}); //# sourceMappingURL=index.cjs.map