import{a8 as ce,a9 as de,r as c,aa as ue,j as d,ab as _,ac as C,ad as fe,ae as A,af as me,ag as Se,ah as Y,a as pe}from"./index-DMhQuCwd.js";var $=["PageUp","PageDown"],X=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],G={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},M="Slider",[z,he,ge]=ce(M),[W,Te]=de(M,[ge]),[ve,V]=W(M),q=c.forwardRef((e,t)=>{const{name:n,min:o=0,max:s=100,step:l=1,orientation:r="horizontal",disabled:a=!1,minStepsBetweenThumbs:f=0,defaultValue:b=[o],value:h,onValueChange:i=()=>{},onValueCommit:u=()=>{},inverted:v=!1,form:y,...g}=e,S=c.useRef(new Set),m=c.useRef(0),w=r==="horizontal"?be:we,[p=[],j]=ue({prop:h,defaultProp:b,onChange:x=>{[...S.current][m.current]?.focus(),i(x)}}),B=c.useRef(p);function T(x){const R=De(p,x);K(x,R)}function ae(x){K(x,m.current)}function le(){const x=B.current[m.current];p[m.current]!==x&&u(p)}function K(x,R,{commit:N}={commit:!1}){const U=Me(l),k=je(Math.round((x-o)/l)*l+o,U),I=Y(k,[o,s]);j((E=[])=>{const P=Re(E,I,R);if(Ce(P,f*l)){m.current=P.indexOf(I);const F=String(P)!==String(E);return F&&N&&u(P),F?P:E}else return E})}return d.jsx(ve,{scope:e.__scopeSlider,name:n,disabled:a,min:o,max:s,valueIndexToChangeRef:m,thumbs:S.current,values:p,orientation:r,form:y,children:d.jsx(z.Provider,{scope:e.__scopeSlider,children:d.jsx(z.Slot,{scope:e.__scopeSlider,children:d.jsx(w,{"aria-disabled":a,"data-disabled":a?"":void 0,...g,ref:t,onPointerDown:_(g.onPointerDown,()=>{a||(B.current=p)}),min:o,max:s,inverted:v,onSlideStart:a?void 0:T,onSlideMove:a?void 0:ae,onSlideEnd:a?void 0:le,onHomeKeyDown:()=>!a&&K(o,0,{commit:!0}),onEndKeyDown:()=>!a&&K(s,p.length-1,{commit:!0}),onStepKeyDown:({event:x,direction:R})=>{if(!a){const k=$.includes(x.key)||x.shiftKey&&X.includes(x.key)?10:1,I=m.current,E=p[I],P=l*k*R;K(E+P,I,{commit:!0})}}})})})})});q.displayName=M;var[J,Q]=W(M,{startEdge:"left",endEdge:"right",size:"width",direction:1}),be=c.forwardRef((e,t)=>{const{min:n,max:o,dir:s,inverted:l,onSlideStart:r,onSlideMove:a,onSlideEnd:f,onStepKeyDown:b,...h}=e,[i,u]=c.useState(null),v=C(t,w=>u(w)),y=c.useRef(void 0),g=fe(s),S=g==="ltr",m=S&&!l||!S&&l;function D(w){const p=y.current||i.getBoundingClientRect(),j=[0,p.width],T=O(j,m?[n,o]:[o,n]);return y.current=p,T(w-p.left)}return d.jsx(J,{scope:e.__scopeSlider,startEdge:m?"left":"right",endEdge:m?"right":"left",direction:m?1:-1,size:"width",children:d.jsx(Z,{dir:g,"data-orientation":"horizontal",...h,ref:v,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const p=D(w.clientX);r?.(p)},onSlideMove:w=>{const p=D(w.clientX);a?.(p)},onSlideEnd:()=>{y.current=void 0,f?.()},onStepKeyDown:w=>{const j=G[m?"from-left":"from-right"].includes(w.key);b?.({event:w,direction:j?-1:1})}})})}),we=c.forwardRef((e,t)=>{const{min:n,max:o,inverted:s,onSlideStart:l,onSlideMove:r,onSlideEnd:a,onStepKeyDown:f,...b}=e,h=c.useRef(null),i=C(t,h),u=c.useRef(void 0),v=!s;function y(g){const S=u.current||h.current.getBoundingClientRect(),m=[0,S.height],w=O(m,v?[o,n]:[n,o]);return u.current=S,w(g-S.top)}return d.jsx(J,{scope:e.__scopeSlider,startEdge:v?"bottom":"top",endEdge:v?"top":"bottom",size:"height",direction:v?1:-1,children:d.jsx(Z,{"data-orientation":"vertical",...b,ref:i,style:{...b.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:g=>{const S=y(g.clientY);l?.(S)},onSlideMove:g=>{const S=y(g.clientY);r?.(S)},onSlideEnd:()=>{u.current=void 0,a?.()},onStepKeyDown:g=>{const m=G[v?"from-bottom":"from-top"].includes(g.key);f?.({event:g,direction:m?-1:1})}})})}),Z=c.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:s,onSlideEnd:l,onHomeKeyDown:r,onEndKeyDown:a,onStepKeyDown:f,...b}=e,h=V(M,n);return d.jsx(A.span,{...b,ref:t,onKeyDown:_(e.onKeyDown,i=>{i.key==="Home"?(r(i),i.preventDefault()):i.key==="End"?(a(i),i.preventDefault()):$.concat(X).includes(i.key)&&(f(i),i.preventDefault())}),onPointerDown:_(e.onPointerDown,i=>{const u=i.target;u.setPointerCapture(i.pointerId),i.preventDefault(),h.thumbs.has(u)?u.focus():o(i)}),onPointerMove:_(e.onPointerMove,i=>{i.target.hasPointerCapture(i.pointerId)&&s(i)}),onPointerUp:_(e.onPointerUp,i=>{const u=i.target;u.hasPointerCapture(i.pointerId)&&(u.releasePointerCapture(i.pointerId),l(i))})})}),ee="SliderTrack",te=c.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,s=V(ee,n);return d.jsx(A.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...o,ref:t})});te.displayName=ee;var H="SliderRange",ne=c.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,s=V(H,n),l=Q(H,n),r=c.useRef(null),a=C(t,r),f=s.values.length,b=s.values.map(u=>ie(u,s.min,s.max)),h=f>1?Math.min(...b):0,i=100-Math.max(...b);return d.jsx(A.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...o,ref:a,style:{...e.style,[l.startEdge]:h+"%",[l.endEdge]:i+"%"}})});ne.displayName=H;var L="SliderThumb",oe=c.forwardRef((e,t)=>{const n=he(e.__scopeSlider),[o,s]=c.useState(null),l=C(t,a=>s(a)),r=c.useMemo(()=>o?n().findIndex(a=>a.ref.current===o):-1,[n,o]);return d.jsx(xe,{...e,ref:l,index:r})}),xe=c.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:s,...l}=e,r=V(L,n),a=Q(L,n),[f,b]=c.useState(null),h=C(t,D=>b(D)),i=f?r.form||!!f.closest("form"):!0,u=me(f),v=r.values[o],y=v===void 0?0:ie(v,r.min,r.max),g=Pe(o,r.values.length),S=u?.[a.size],m=S?Ee(S,y,a.direction):0;return c.useEffect(()=>{if(f)return r.thumbs.add(f),()=>{r.thumbs.delete(f)}},[f,r.thumbs]),d.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${y}% + ${m}px)`},children:[d.jsx(z.ItemSlot,{scope:e.__scopeSlider,children:d.jsx(A.span,{role:"slider","aria-label":e["aria-label"]||g,"aria-valuemin":r.min,"aria-valuenow":v,"aria-valuemax":r.max,"aria-orientation":r.orientation,"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,tabIndex:r.disabled?void 0:0,...l,ref:h,style:v===void 0?{display:"none"}:e.style,onFocus:_(e.onFocus,()=>{r.valueIndexToChangeRef.current=o})})}),i&&d.jsx(re,{name:s??(r.name?r.name+(r.values.length>1?"[]":""):void 0),form:r.form,value:v},o)]})});oe.displayName=L;var ye="RadioBubbleInput",re=c.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const s=c.useRef(null),l=C(s,o),r=Se(t);return c.useEffect(()=>{const a=s.current;if(!a)return;const f=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(f,"value").set;if(r!==t&&h){const i=new Event("input",{bubbles:!0});h.call(a,t),a.dispatchEvent(i)}},[r,t]),d.jsx(A.input,{style:{display:"none"},...n,ref:l,defaultValue:t})});re.displayName=ye;function Re(e=[],t,n){const o=[...e];return o[n]=t,o.sort((s,l)=>s-l)}function ie(e,t,n){const l=100/(n-t)*(e-t);return Y(l,[0,100])}function Pe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function De(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),o=Math.min(...n);return n.indexOf(o)}function Ee(e,t,n){const o=e/2,l=O([0,50],[0,o]);return(o-l(t)*n)*n}function _e(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Ce(e,t){if(t>0){const n=_e(e);return Math.min(...n)>=t}return!0}function O(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function Me(e){return(String(e).split(".")[1]||"").length}function je(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var se=q,Ke=te,Ie=ne,Ae=oe;const Ve=c.forwardRef(({className:e,...t},n)=>d.jsxs(se,{ref:n,className:pe("relative flex w-full touch-none select-none items-center",e),...t,children:[d.jsx(Ke,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:d.jsx(Ie,{className:"absolute h-full bg-primary"})}),d.jsx(Ae,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Ve.displayName=se.displayName;export{Ve as S};