import{r as n,gX as k}from"./index-ea7817a2.js";import{f as l}from"./utils-aedc41ca.js";var v=(e=>(e[e.primary=0]="primary",e[e.partition=1]="partition",e[e.label=2]="label",e[e.type=3]="type",e[e.onlineType=4]="onlineType",e[e.eventTime=5]="eventTime",e[e.null=6]="null",e))(v||{});const M=(e,b="",w=!1,h="")=>{const[i,c]=n.useState([]),[u,T]=n.useState([]),[o,f]=n.useState(6),[p,a]=k({search:b}),y=n.useCallback(({target:t})=>{const r=t.value;a(r?{search:r}:{})},[a]),C=n.useCallback(t=>()=>{f(r=>r===t?6:t)},[f]),S=n.useCallback(()=>{a({}),c([]),T([]),f(6)},[a]),m=n.useMemo(()=>{const t=Array.from(new Set(e.map(({type:s})=>s)));let r=[];return w&&(r=Array.from(new Set(e.map(({onlineType:s})=>s)))),{offlineTypes:t,onlineTypes:r}},[e]),g=n.useMemo(()=>{let t=e;return o===1&&(t=l(t,!0,"partition")),o===0&&(t=l(t,!0,"primary")),o===2&&(t=l(t,!0,"label")),t=l(t,i,"type"),t=l(t,u,"onlineType"),o===5&&(t=t.filter(({name:r})=>r.toLowerCase()===h)),t.filter(({name:r})=>{const s=(p.get("search")||"").toLowerCase();return r.toLowerCase().includes(s)})},[e,p,o,i,u,h]);return n.useMemo(()=>({dataFiltered:g,types:m.offlineTypes,onlineTypes:m.onlineTypes,search:p.get("search")||"",typeFilters:i,onlineTypeFilters:u,keyFilter:o,onTypeFiltersChange:c,onOnlineTypeFiltersChange:T,onSearchChange:y,onToggleKey:C,onReset:S}),[g,m,p,i,o,c,y,C,S])};export{v as K,M as u};
