import{j as x,r as s}from"./vendor-react-wBh_31cN.js";import{G as q,a0 as v,d as A}from"./index-BKr2rJhV.js";import{d as L}from"./vendor-router-D1GqFWiT.js";const D=({children:e,icon:a,checked:p,onChange:i})=>x.jsxs(q,{type:"button",variant:"outline",onClick:i,className:A(p&&"border-quartz-primary bg-quartz-primary/10 text-quartz-primary hover:bg-quartz-primary/20 hover:text-quartz-primary"),children:[a&&x.jsx(v,{icon:a,size:"sm"}),e]}),u=(e,a,p)=>e.filter(({[p]:i})=>Array.isArray(a)?a.length?a.includes(i):e:a===i);var P=(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))(P||{});const E=(e,a="",p=!1,i="")=>{const[l,f]=s.useState([]),[h,T]=s.useState([]),[n,y]=s.useState(9),[m,c]=L({search:a}),C=s.useCallback(({target:r})=>{const t=r.value;c(t?{search:t}:{})},[c]),b=s.useCallback(r=>()=>{y(t=>t===r?9:r)},[y]),S=s.useCallback(()=>{c({}),f([]),T([]),y(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]),d=s.useMemo(()=>{let r=e;return n===1&&(r=u(r,!0,"partition")),n===7&&(r=u(r,!0,"onDemand")),n===0&&(r=u(r,!0,"primary")),n===2&&(r=u(r,!0,"foreign")),n===3&&(r=u(r,!0,"label")),n===8&&(r=r.filter(t=>{const o=t.primary===!0,w=t.partition===!0,z=t.name.toLowerCase()===i.toLowerCase();return!o&&!w&&!z})),r=u(r,l,"type"),r=u(r,h,"onlineType"),n===6&&(r=r.filter(({name:t})=>t.toLowerCase()===i)),r.filter(({name:t})=>{const o=(m.get("search")||"").toLowerCase();return t.toLowerCase().includes(o)||t.includes("Feature Group")})},[e,m,n,l,h,i]);return s.useMemo(()=>({dataFiltered:d,types:g.offlineTypes,onlineTypes:g.onlineTypes,search:m.get("search")||"",typeFilters:l,onlineTypeFilters:h,keyFilter:n,onTypeFiltersChange:f,onOnlineTypeFiltersChange:T,onSearchChange:C,onToggleKey:b,onReset:S}),[d,g,m,l,n,f,C,b,S])};export{D as F,P as K,u as f,E as u};
