import{j as e,B as r,aM as X,Z as B,c0 as Y,e as h,bm as O,r as l,p as ee,z as te,fW as se,e0 as y,Q as w,e7 as ae,e8 as ne,bK as E,b$ as R}from"./index-dP1W1_bd.js";import{F as re}from"./FilterResult-VfTAUiIy.js";import{s as g,S as v}from"./sort-BOLIcXtz.js";import{u as ie}from"./Deprecated-ClfPkp7s.js";import{F as oe,K as $,u as le}from"./useFeatureFilters-H7_GmsAw.js";import{F as ce}from"./FeatureFilters-D-g3xjlf.js";import{m as xe}from"./min-DNV8UA03.js";const pe=(t,c,a=0)=>{const s=t.length,i=a&&a<s?a:s,n=i*c;return{data:t.slice(n-i,n>s?s:n),totalPages:s?Math.ceil(s/i):1}},me={"name (A -> Z)":["name",g.string,v.asc],"name (Z -> A)":["name",g.string,v.desc]},ue=({search:t,onSearchChange:c,typeFilters:a,onTypeFiltersChange:s,types:i,onToggleKey:n,keyFilter:k,sortKey:o,setSortKey:d})=>e.jsx(r,{width:"100%",flexDirection:"column",alignItems:"center",children:e.jsxs(r,{width:"100%",children:[e.jsx(X,{variant:"white",value:t,icon:B.glass,placeholder:"Find feature",onChange:c}),e.jsx(Y,{maxWidth:"180px",width:"max-content",ml:"15px",variant:"white",isMulti:!0,value:a,options:i,placeholder:"type",onChange:s,noDataMessage:"type all"}),e.jsx(h,{ml:"10px",sx:{label:{div:{bg:"white"}}},children:e.jsx(oe,{icon:B.target,checked:k===$.label,onChange:n($.label),children:"Label (target) features only"})}),e.jsx(O,{label:"sort by",labelPosition:"inline",width:"max-content",variant:"white",value:o,ml:"auto",options:Object.keys(me),onChange:d})]})}),H={"10 features":10,"20 features":20,"50 features":50,"100 features":100,"200 features":200,"all features":void 0},he={"name (A -> Z)":["name",g.string,v.asc],"name (Z -> A)":["name",g.string,v.desc]},ve=({data:t,renderChild:c,extraActions:a,type:s=y.fg,...i})=>{var A;const[n,k]=l.useState("20 features"),[o,d]=l.useState("name (A -> Z)"),x=H[n]||1,[f,S]=l.useState(1),{isActiveFeatures:Q,handleBasket:W,isSwitch:q}=ie(),{dataFiltered:j,types:D,search:K,typeFilters:L,keyFilter:I,onTypeFiltersChange:P,onSearchChange:M,onToggleKey:Z,onReset:z}=le(t.features??[],"",t.onlineEnabled,"eventTime"in t?t.eventTime:""),{data:C,totalPages:p}=l.useMemo(()=>pe(j,f,x),[j,x,f]),m=l.useMemo(()=>{const u=he[o];if(u){const[N,V,_]=u;return ee(g(N,V,_),F=>{const T=F.findIndex(te("name","Feature Group"));return T>0?[F[T],...F.filter((ge,U)=>T!==U)]:F})(C)}return C},[C,o]),b=((A=t==null?void 0:t.features)==null?void 0:A.length)??0,G=j.length,J=b!==G;return l.useEffect(()=>{S(1)},[x]),e.jsxs(r,{width:"100%",flexDirection:"column",alignItems:"center",children:[e.jsxs(r,{sx:{...se.stickyHeader},pt:"20px",mt:"-20px",children:[s===y.fg&&e.jsx(ce,{search:K,typeFilters:L,types:D,keyFilter:I,enableStorageConnectorFilter:!1,sortKey:o,setSortKey:d,onToggleKey:Z,onSearchChange:M,onTypeFiltersChange:P}),s===y.td&&e.jsx(ue,{search:K,typeFilters:L,types:D,keyFilter:I,sortKey:o,setSortKey:d,onToggleKey:Z,onSearchChange:M,onTypeFiltersChange:P}),e.jsxs(r,{width:"100%",mt:"10px",alignItems:"center",children:[e.jsxs(r,{children:[e.jsx(w,{primary:!0,px:"5px",children:xe(x,b)}),e.jsx(w,{children:"features displayed out of"}),e.jsx(w,{primary:!0,px:"5px",children:b}),e.jsx(w,{children:"features"})]}),a&&e.jsx(r,{ml:"10px",children:a}),q&&s===y.fg&&e.jsx(h,{ml:"10px",children:e.jsx(ae,{mode:ne.bulk,possible:m.length>0,tooltipMainText:"Add all features to basket",tooltipSecondaryText:`${m.length} features`,handleClick:W(m,t),inBasket:Q(m,t)})}),e.jsx(h,{ml:"auto",sx:{span:{mt:"4px"}},children:e.jsx(O,{variant:"white",value:n,label:"show",labelPosition:"side",options:Object.keys(H),onChange:k})}),p>1&&e.jsx(h,{sx:{span:{marginTop:"4px"}},children:e.jsx(E,{ml:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(R,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:S})})})]})]}),e.jsxs(r,{sx:{gap:"20px",mt:"10px",mb:"20px",flexDirection:"column",width:"100%"},...i,children:[m.map(u=>e.jsx(h,{children:c({type:s,parent:t,data:u})},u.name)),b>x&&e.jsx(E,{mt:"10px",mb:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(R,{variant:"white",disabled:p===1,totalPages:p,currentPage:f,onChange:S})}),J&&e.jsx(re,{subject:"features",result:j.length,onReset:z})]})]})};export{ve as F};
