import{useState as w}from"react";import{useEffect as h,useLayoutEffect as l}from"react";var a=typeof window>"u"?h:l;var c={sm:576,md:852,lg:968,xl:1080,"2lg":1200},r=(()=>{let e=0;return Object.keys(c).reduce((o,s,t)=>{if(t===Object.keys(c).length-1)return{...o,[s]:`(min-width: ${e}px)`};let n=e,i=c[s];return e=i+1,{...o,[s]:`(min-width: ${n}px) and (max-width: ${i}px)`}},{})})(),f=e=>`is${e.charAt(0).toUpperCase()}${e.slice(1)}`,d=()=>Object.keys(r).reduce((o,s)=>{let t=f(s);if(typeof window>"u")return{...o,[t]:!1};let n=typeof window?.matchMedia=="function"?window.matchMedia(r[s]):null;return{...o,[t]:n?.matches??!1}},{}),y=()=>{let[e,o]=w(()=>d());return a(()=>{let s=Object.keys(r).map(t=>{let n,i;return typeof window?.matchMedia=="function"&&(n=window.matchMedia(r[t]),i=m=>{let p=f(t);o(u=>({...u,[p]:m.matches}))},n.addEventListener&&n.addEventListener("change",i)),()=>{n?.removeEventListener&&n.removeEventListener("change",i)}});return o(d()),()=>{s.forEach(t=>{t()})}},[]),{...e,isMobile:e.isSm,isTablet:e.isMd||e.isLg,isDesktop:e.isXlg||e.is2xl}},M=y;export{c as breakpointMap,M as default};
