import{r as n}from"./main-D6SjkSWq.js";function B(s,e,a,g){var y=this,c=n.useRef(null),i=n.useRef(0),f=n.useRef(0),t=n.useRef(null),o=n.useRef([]),l=n.useRef(),d=n.useRef(),T=n.useRef(s),m=n.useRef(!0);T.current=s;var R=typeof window<"u",v=!e&&e!==0&&R;if(typeof s!="function")throw new TypeError("Expected a function");e=+e||0;var w=!!(a=a||{}).leading,A=!("trailing"in a)||!!a.trailing,p="maxWait"in a,E="debounceOnServer"in a&&!!a.debounceOnServer,x=p?Math.max(+a.maxWait||0,e):null;n.useEffect(function(){return m.current=!0,function(){m.current=!1}},[]);var q=n.useMemo(function(){var P=function(r){var u=o.current,S=l.current;return o.current=l.current=null,i.current=r,f.current=f.current||r,d.current=T.current.apply(S,u)},D=function(r,u){v&&cancelAnimationFrame(t.current),t.current=v?requestAnimationFrame(r):setTimeout(r,u)},F=function(r){if(!m.current)return!1;var u=r-c.current;return!c.current||u>=e||u<0||p&&r-i.current>=x},b=function(r){return t.current=null,A&&o.current?P(r):(o.current=l.current=null,d.current)},Q=function r(){var u=Date.now();if(w&&f.current===i.current&&M(),F(u))return b(u);if(m.current){var S=e-(u-c.current),W=p?Math.min(S,x-(u-i.current)):S;D(r,W)}},M=function(){},h=function(){if(R||E){var r=Date.now(),u=F(r);if(o.current=[].slice.call(arguments),l.current=y,c.current=r,u){if(!t.current&&m.current)return i.current=c.current,D(Q,e),w?P(c.current):d.current;if(p)return D(Q,e),P(c.current)}return t.current||D(Q,e),d.current}};return h.cancel=function(){var r=t.current;r&&(v?cancelAnimationFrame(t.current):clearTimeout(t.current)),i.current=0,o.current=c.current=l.current=t.current=null},h.isPending=function(){return!!t.current},h.flush=function(){return t.current?b(Date.now()):d.current},h},[w,p,e,x,A,v,R,E,g]);return q}function V(s){const[e,a]=n.useState(""),g=B(a,300),y=n.useDeferredValue(e),[c,i]=n.useState(s),f=n.useDeferredValue(c),t=e!==y||c!==f,o={query:y||"",orderBy:f.orderBy,orderDir:f.orderDir,paginate:"simple"};return{searchQuery:e,setSearchQuery:g,sortDescriptor:c,setSortDescriptor:i,isDefferedLoading:t,queryParams:o}}export{V as u};
