import{Or as e,Tr as t,fn as n,fr as r,wt as i}from"./jsx-runtime-NwRKtVrk.js";var a=e(t()),o=()=>a.useReducer(e=>e+1,0),s=[`xxxl`,`xxl`,`xl`,`lg`,`md`,`sm`,`xs`],c=[].concat(s).reverse(),l=e=>({xs:`(max-width: ${e.screenXSMax}px)`,sm:`(min-width: ${e.screenSM}px)`,md:`(min-width: ${e.screenMD}px)`,lg:`(min-width: ${e.screenLG}px)`,xl:`(min-width: ${e.screenXL}px)`,xxl:`(min-width: ${e.screenXXL}px)`,xxxl:`(min-width: ${e.screenXXXL}px)`}),u=e=>{let t=e,n=[].concat(s).reverse();return n.forEach((e,r)=>{let i=e.toUpperCase(),a=`screen${i}Min`,o=`screen${i}`;if(!(t[a]<=t[o]))throw Error(`${a}<=${o} fails : !(${t[a]}<=${t[o]})`);if(r<n.length-1){let e=`screen${i}Max`;if(!(t[o]<=t[e]))throw Error(`${o}<=${e} fails : !(${t[o]}<=${t[e]})`);let a=`screen${n[r+1].toUpperCase()}Min`;if(!(t[e]<=t[a]))throw Error(`${e}<=${a} fails : !(${t[e]}<=${t[a]})`)}}),e},d=(e,t)=>{if(t){for(let n of s)if(e[n]&&t?.[n]!==void 0)return t[n]}},f=()=>{let[,e]=i(),t=l(u(e));return a.useMemo(()=>{let e=new Map,r=-1,i={};return{responsiveMap:t,matchHandlers:{},dispatch(t){return i=t,e.forEach(e=>{e(i)}),e.size>=1},subscribe(t){return e.size||this.register(),r+=1,e.set(r,t),t(i),r},unsubscribe(t){e.delete(t),e.size||this.unregister()},register(){Object.entries(t).forEach(([e,t])=>{let r=({matches:t})=>{this.dispatch({...i,[e]:t})},a=window.matchMedia(t);n(a.addEventListener)&&a.addEventListener(`change`,r),this.matchHandlers[t]={mql:a,listener:r},r(a)})},unregister(){Object.values(t).forEach(e=>{let t=this.matchHandlers[e];n(t?.mql.removeEventListener)&&t.mql.removeEventListener(`change`,t?.listener)}),e.clear()}}},[t])};function p(e=!0,t={}){let n=(0,a.useRef)(t),[,i]=o(),s=f();return r(()=>{let t=s.subscribe(t=>{n.current=t,e&&i()});return()=>s.unsubscribe(t)},[]),n.current}export{o as a,c as i,d as n,s as r,p as t};