1import{a as e}from"./chunk-Cyuzqnbw.js";import{n as t}from"./chunk-B8qZ34QF.js";import{o as n}from"./chunk-1ojowaFp.js";import{t as r}from"./chunk-D3oBH38_.js";var i=e(t(),1),a=n();function o({options:e,value:t,onChange:n,className:o,ariaLabel:s,ariaLabelledBy:c}){let l=(0,i.useRef)(null),[u,d]=(0,i.useState)(null),f=(0,i.useCallback)((e,r)=>{r||e!==t&&n(e)},[t,n]),p=(0,i.useCallback)(()=>{let n=l.current;if(!n)return;let r=e.findIndex(e=>e.value===t);if(r===-1)return;let i=n.querySelectorAll(`.segment__option`)[r];i&&d({left:i.offsetLeft,width:i.offsetWidth})},[t,e]);(0,i.useEffect)(()=>{p();let e=l.current;if(!e)return;let t=()=>p();window.addEventListener(`resize`,t);let n=typeof ResizeObserver>`u`?null:new ResizeObserver(t);return n?.observe(e),document.fonts?.ready.then(p),()=>{n?.disconnect(),window.removeEventListener(`resize`,t)}},[p]);let m=e.map((e,t)=>e.disabled?-1:t).filter(e=>e!==-1),h=e.findIndex(e=>e.value===t&&!e.disabled),g=h===-1?m[0]??-1:h,_=(0,i.useCallback)(r=>{let i=e[r];!i||i.disabled||(i.value!==t&&n(i.value),(l.current?.querySelectorAll(`.segment__option`))?.[r]?.focus())},[n,e,t]),v=(0,i.useCallback)((e,t)=>{if(!m.length)return;let n;if(e.key===`Home`&&(n=m[0]),e.key===`End`&&(n=m.at(-1)),e.key===`ArrowRight`||e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowUp`){let r=e.key===`ArrowRight`||e.key===`ArrowDown`?1:-1,i=m.indexOf(t);n=m[((i===-1?0:i)+r+m.length)%m.length]}n!==void 0&&(e.preventDefault(),_(n))},[m,_]);return(0,a.jsxs)(`div`,{className:r(`segment`,o),role:`radiogroup`,"aria-label":s,"aria-labelledby":c,"aria-orientation":`horizontal`,ref:l,children:[u&&(0,a.jsx)(`div`,{className:`segment__indicator`,style:{left:`${u.left}px`,width:`${u.width}px`}}),e.map((e,n)=>(0,a.jsx)(`button`,{type:`button`,className:r(`segment__option`,e.value===t&&`segment__option--active`,e.disabled&&`segment__option--disabled`),role:`radio`,"aria-checked":e.value===t,"aria-disabled":e.disabled||void 0,disabled:e.disabled,tabIndex:n===g?0:-1,onClick:()=>f(e.value,e.disabled),onKeyDown:e=>v(e,n),children:e.label},e.value))]})}export{o as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.