import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as r,jsxs as i,Fragment as t}from"react/jsx-runtime";import{forwardRef as o,useCallback as s}from"react";import{isArrowUpEvent as n,isArrowRightEvent as a,isArrowDownEvent as l,isArrowLeftEvent as m,isPageUpEvent as d,isPageDownEvent as f,isHomeEvent as u,isEndEvent as p}from"../../../utils/dom-event-utils.js";import{useSliderUi as c,useSliderSelection as v,useSliderActions as j}from"../SliderContext.js";import{calcDimensions as b,moveToPx as h,getNearest as S,bem as g,calculatePageStep as T}from"../SliderHelpers.js";import{useSliderRail as x}from"../SliderHooks.js";import D from"./SliderRail.js";import k from"./SliderTrack.js";import y from"./SliderFilledTrack.js";import C from"./SliderThumb.js";import"./SliderBase.scss.js";var H=o((function(o,H){var V,B=o.className,K=c(),M=K.color,N=K.disabled,O=K.size,P=K.shapeTestId,R=v(),X=R.min,_=R.max,w=R.ranged,z=R.step,F=R.value,I=j(),q=I.changeThumbValue,A=I.drugThumb,E=I.decreaseValue,G=I.increaseValue,J=x(),L=J.railCoords,Q=J.railRef,U=b(_,X,w,F),W=U.dimension,Y=U.offset,Z=U.positions,$=U.thumbKeys,ee=s((function(e){var r=h(Math.round(e.clientX-L.left),X,_,L,z);A(r)}),[A,X,_,L,z]),re=s((function(e){var r=h(e.clientX-L.left,X,_,L,z),i=S(r,w,F);q(r,i)}),[q,X,_,L,w,z,F]);return r("div",Object.assign({className:g("base",(V={},e(V,O,O),e(V,M,M),e(V,"disabled",N),V),B),"data-testid":P("base"),onKeyDown:function(e){return n(e)||a(e)?G():l(e)||m(e)?E():d(e)?(e.preventDefault(),G(T(_,X,z))):f(e)?(e.preventDefault(),E(T(_,X,z))):u(e)?(e.preventDefault(),q(X)):p(e)?(e.preventDefault(),q(_)):void 0}},{children:i(D,Object.assign({onClick:re,ref:Q},{children:[r(k,{}),Q.current&&i(t,{children:[r(y,{dimension:W,offset:Y}),Z.map((function(e,i){return r(C,{index:i,onMove:ee,position:e},$[i])}))]})]}))}))}));export{H as default};
