import{j as b,q as j,et as k,ao as A,v as P,i3 as D,r as s,db as E}from"./index-C6OVXshM.js";const v={label:{"> div":{py:0,pl:"4px",pr:"8px",alignItems:"center"},"> div:hover":{div:{backgroundColor:"grayShade3",borderColor:"transparent"}}}},M={label:{div:{backgroundColor:"white"}}},I=({children:e,icon:a,white:p=!1,size:i="md",...u})=>b.jsx(j,{sx:p?D(M,v):v,alignItems:"center",children:b.jsxs(k,{...u,children:[b.jsx(A,{p:"4px !important",size:i,icon:a||P.cross,sx:!a&&{visibility:"hidden",width:"0px",mr:"-15px"}}),e]})}),l=(e,a,p)=>e.filter(({[p]:i})=>Array.isArray(a)?a.length?a.includes(i):e:a===i);var q=(e=>(e[e.primary=0]="primary",e[e.partition=1]="partition",e[e.foreign=2]="foreign",e[e.label=3]="label",e[e.type=4]="type",e[e.onlineType=5]="onlineType",e[e.eventTime=6]="eventTime",e[e.onDemand=7]="onDemand",e[e.feature=8]="feature",e[e.null=9]="null",e))(q||{});const O=(e,a="",p=!1,i="")=>{const[u,m]=s.useState([]),[h,x]=s.useState([]),[n,d]=s.useState(9),[f,c]=E({search:a}),y=s.useCallback(({target:r})=>{const t=r.value;c(t?{search:t}:{})},[c]),C=s.useCallback(r=>()=>{d(t=>t===r?9:r)},[d]),T=s.useCallback(()=>{c({}),m([]),x([]),d(9)},[c]),g=s.useMemo(()=>{const r=Array.from(new Set(e.filter(({name:o})=>o!=="Feature Group").map(({type:o})=>o)));let t=[];return p&&(t=Array.from(new Set(e.map(({onlineType:o})=>o)))),{offlineTypes:r,onlineTypes:t}},[e]),S=s.useMemo(()=>{let r=e;return n===1&&(r=l(r,!0,"partition")),n===7&&(r=l(r,!0,"onDemand")),n===0&&(r=l(r,!0,"primary")),n===2&&(r=l(r,!0,"foreign")),n===3&&(r=l(r,!0,"label")),n===8&&(r=r.filter(t=>{const o=t.primary===!0,w=t.partition===!0,L=t.name.toLowerCase()===i.toLowerCase();return!o&&!w&&!L})),r=l(r,u,"type"),r=l(r,h,"onlineType"),n===6&&(r=r.filter(({name:t})=>t.toLowerCase()===i)),r.filter(({name:t})=>{const o=(f.get("search")||"").toLowerCase();return t.toLowerCase().includes(o)||t.includes("Feature Group")})},[e,f,n,u,h,i]);return s.useMemo(()=>({dataFiltered:S,types:g.offlineTypes,onlineTypes:g.onlineTypes,search:f.get("search")||"",typeFilters:u,onlineTypeFilters:h,keyFilter:n,onTypeFiltersChange:m,onOnlineTypeFiltersChange:x,onSearchChange:y,onToggleKey:C,onReset:T}),[S,g,f,u,n,m,y,C,T])};export{I as F,q as K,l as f,O as u};
