import{gR as g,gT as b,j as e,a as r,aG as J,Z as N,bp as k,O as d,g7 as Q,r as c,gm as U,dF as j,f as y,dH as V,dI as Y,b3 as P,bo as R}from"./index-d6499a22.js";import{F as _}from"./FilterResult-550b3b9f.js";import{u as ee}from"./Deprecated-ec8916ed.js";import{K as E,u as te}from"./useFeatureFilters-659d6dec.js";import{F as se}from"./FeatureFilters-d7ede7cc.js";const ae=(t,h,n=0)=>{const s=t.length,i=n&&n<s?n:s,a=i*h;return{data:t.slice(a-i,a>s?s:a),totalPages:s?Math.ceil(s/i):1}},ne={"name (A -> Z)":["name",g.string,b.asc],"name (Z -> A)":["name",g.string,b.desc]},re=({search:t,onSearchChange:h,typeFilters:n,onTypeFiltersChange:s,types:i,onToggleKey:a,keyFilter:F,sortKey:o,setSortKey:p})=>e.jsx(r,{width:"100%",flexDirection:"column",alignItems:"center",children:e.jsxs(r,{width:"100%",children:[e.jsx(J,{variant:"white",value:t,icon:N.glass,placeholder:"Find feature",onChange:h}),e.jsx(k,{maxWidth:"180px",width:"max-content",ml:"15px",variant:"white",isMulti:!0,value:n,options:i,placeholder:"type",onChange:s,noDataMessage:"type all"}),e.jsx(d,{sx:{label:{div:{backgroundColor:"white"},"div:hover":{div:{backgroundColor:"grayShade3",borderColor:"transparent"}}}},children:e.jsx(Q,{ml:"15px",height:"35px",checked:F===E.label,onChange:a(E.label),children:"Target features only"})}),e.jsx(k,{width:"max-content",variant:"white",value:[o],ml:"auto",options:Object.keys(ne),placeholder:"sort by",onChange:p})]})}),S={"20 features":20,"50 features":50,"100 features":100,"200 features":200,"all features":void 0},ie={"name (A -> Z)":["name",g.string,b.asc],"name (Z -> A)":["name",g.string,b.desc]},de=({data:t,renderChild:h,extraActions:n,type:s=j.fg,...i})=>{const[[a],F]=c.useState(["20 features"]),[[o],p]=c.useState(["name (A -> Z)"]),O=S[a]||1,[u,v]=c.useState(1),{isActiveFeatures:B,handleBasket:H,isSwitch:$}=ee(),{dataFiltered:m,types:C,search:T,typeFilters:D,keyFilter:L,onTypeFiltersChange:K,onSearchChange:Z,onToggleKey:A,onReset:G}=te(t.features,"",t.onlineEnabled,"eventTime"in t?t.eventTime:""),{data:w,totalPages:f}=c.useMemo(()=>ae(m,u,S[a]),[m,u,a]),l=c.useMemo(()=>{const x=ie[o];if(x){const[X,q,z]=x;return g(X,q,z)(w)}return w},[w,o]),I=t==null?void 0:t.features.length,M=m.length,W=I!==M;return c.useEffect(()=>{v(1)},[O]),e.jsxs(r,{width:"100%",flexDirection:"column",alignItems:"center",children:[e.jsxs(r,{sx:{...U.stickyHeader},pt:"20px",children:[s===j.fg&&e.jsx(se,{search:T,typeFilters:D,types:C,keyFilter:L,enableStorageConnectorFilter:!1,sortKey:o,setSortKey:p,onToggleKey:A,onSearchChange:Z,onTypeFiltersChange:K}),s===j.td&&e.jsx(re,{search:T,typeFilters:D,types:C,keyFilter:L,sortKey:o,setSortKey:p,onToggleKey:A,onSearchChange:Z,onTypeFiltersChange:K}),e.jsxs(r,{width:"100%",mt:"10px",alignItems:"center",pb:"10px",children:[e.jsxs(r,{children:[e.jsx(y,{primary:!0,px:"5px",children:M}),e.jsx(y,{children:"features displayed out of"}),e.jsx(y,{primary:!0,px:"5px",children:I}),e.jsx(y,{children:"features"})]}),n&&e.jsx(r,{ml:"10px",children:n}),$&&s===j.fg&&e.jsx(d,{ml:"10px",children:e.jsx(V,{mode:Y.bulk,possible:l.length>0,tooltipMainText:"Add all features to basket",tooltipSecondaryText:`${l.length} features`,handleClick:H(l,t),inBasket:B(l,t)})}),e.jsx(d,{ml:"auto",sx:{span:{marginTop:"4px"}},children:e.jsx(k,{width:"max-content",variant:"white",value:[a],label:"show",align:"left",options:Object.keys(S),placeholder:"",onChange:F})}),e.jsx(d,{sx:{span:{marginTop:"4px"}},children:e.jsx(P,{ml:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(R,{variant:"white",disabled:f===1,totalPages:f,currentPage:u,onChange:v})})})]})]}),e.jsxs(r,{sx:{gap:"20px",mt:"10px",flexDirection:"column",width:"100%"},...i,children:[l.map(x=>e.jsx(d,{children:h({type:s,parent:t,data:x})},x.name)),l.length>10&&e.jsx(P,{mt:"35px",as:"span",text:"go to page",align:"left",children:e.jsx(R,{variant:"white",disabled:f===1,totalPages:f,currentPage:u,onChange:v})}),W&&e.jsx(_,{subject:"features",result:m.length,onReset:G})]})]})};export{de as F};
