import{i as e,n as t,t as n}from"./jsx-runtime-CXrijb2r.js";var r=e(t(),1),i=n();function a(e,t,n,r){if(typeof window>`u`)return t;let i=window.localStorage.getItem(e),a=i?Number.parseInt(i,10):NaN;return Number.isFinite(a)?Math.max(n,Math.min(r,a)):t}function o({className:e,storageKey:t,navigation:n,detail:o,navigationClassName:s,detailClassName:c,minWidth:l=220,maxWidth:u=420,defaultWidth:d=248}){let[f,p]=(0,r.useState)(()=>a(t,d,l,u)),m=(0,r.useRef)(null);(0,r.useEffect)(()=>{window.localStorage.setItem(t,String(f))},[f,t]),(0,r.useEffect)(()=>{function e(e){let n=m.current;if(!n||n.pointerId!==e.pointerId)return;let r=Math.max(l,Math.min(u,Math.round(n.startWidth+(e.clientX-n.startX))));p(r),window.localStorage.setItem(t,String(r))}function n(e){m.current?.pointerId===e&&(m.current=null)}function r(e){n(e.pointerId)}function i(e){n(e.pointerId)}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,i),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,i)}},[u,l,t]);let h=(0,r.useMemo)(()=>({"--secondary-nav-width":`${f}px`}),[f]);return(0,i.jsxs)(`section`,{className:`${e} resizable-sidebar-layout`,style:h,children:[(0,i.jsx)(`aside`,{className:s,children:n}),(0,i.jsx)(`div`,{className:`secondary-nav-resize-handle`,"data-role":`secondary-nav-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize navigation`,onDoubleClick:()=>p(d),onPointerDown:e=>{m.current={pointerId:e.pointerId,startX:e.clientX,startWidth:f},e.currentTarget.setPointerCapture(e.pointerId)},children:(0,i.jsx)(`span`,{className:`secondary-nav-resize-handle__bar`,"aria-hidden":`true`})}),(0,i.jsx)(`section`,{className:c,children:o})]})}export{o as t};