import{gT as p,gV as y,j as e,Q as r,aH as G,z as Z,bq as k,o as g,r as c,gr as N,dJ as j,g as F,dL as U,dM as X,b4 as E,bp as B}from"./index-ea7817a2.js";import{F as Y}from"./FilterResult-9d9dd7e5.js";import{u as _}from"./Deprecated-9bfe2e44.js";import{K as H,u as ee}from"./useFeatureFilters-c103b717.js";import{F as te}from"./utils-aedc41ca.js";import{F as se}from"./FeatureFilters-9d528cd7.js";const ae=(t,x,n=0)=>{const s=t.length,i=n&&n<s?n:s,a=i*x;return{data:t.slice(a-i,a>s?s:a),totalPages:s?Math.ceil(s/i):1}},ne={"name (A -> Z)":["name",p.string,y.asc],"name (Z -> A)":["name",p.string,y.desc]},re=({search:t,onSearchChange:x,typeFilters:n,onTypeFiltersChange:s,types:i,onToggleKey:a,keyFilter:b,sortKey:l,setSortKey:u})=>e.jsx(r,{width:"100%",flexDirection:"column",alignItems:"center",children:e.jsxs(r,{width:"100%",children:[e.jsx(G,{variant:"white",value:t,icon:Z.glass,placeholder:"Find feature",onChange:x}),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(g,{ml:"10px",sx:{label:{div:{bg:"white"}}},children:e.jsx(te,{icon:Z.target,checked:b===H.label,onChange:a(H.label),children:"Label (target) features only"})}),e.jsx(k,{width:"max-content",variant:"white",value:[l],ml:"auto",options:Object.keys(ne),placeholder:"sort by",onChange:u})]})}),S={"20 features":20,"50 features":50,"100 features":100,"200 features":200,"all features":void 0},ie={"name (A -> Z)":["name",p.string,y.asc],"name (Z -> A)":["name",p.string,y.desc]},pe=({data:t,renderChild:x,extraActions:n,type:s=j.fg,...i})=>{const[[a],b]=c.useState(["20 features"]),[[l],u]=c.useState(["name (A -> Z)"]),Q=S[a]||1,[d,w]=c.useState(1),{isActiveFeatures:R,handleBasket:z,isSwitch:O}=_(),{dataFiltered:m,types:T,search:C,typeFilters:L,keyFilter:D,onTypeFiltersChange:A,onSearchChange:K,onToggleKey:M,onReset:V}=ee(t.features,"",t.onlineEnabled,"eventTime"in t?t.eventTime:""),{data:v,totalPages:f}=c.useMemo(()=>ae(m,d,S[a]),[m,d,a]),o=c.useMemo(()=>{const h=ie[l];if(h){const[q,J,W]=h;return p(q,J,W)(v)}return v},[v,l]),P=t==null?void 0:t.features.length,I=m.length,$=P!==I;return c.useEffect(()=>{w(1)},[Q]),e.jsxs(r,{width:"100%",flexDirection:"column",alignItems:"center",children:[e.jsxs(r,{sx:{...N.stickyHeader},pt:"20px",children:[s===j.fg&&e.jsx(se,{search:C,typeFilters:L,types:T,keyFilter:D,enableStorageConnectorFilter:!1,sortKey:l,setSortKey:u,onToggleKey:M,onSearchChange:K,onTypeFiltersChange:A}),s===j.td&&e.jsx(re,{search:C,typeFilters:L,types:T,keyFilter:D,sortKey:l,setSortKey:u,onToggleKey:M,onSearchChange:K,onTypeFiltersChange:A}),e.jsxs(r,{width:"100%",mt:"10px",alignItems:"center",pb:"10px",children:[e.jsxs(r,{children:[e.jsx(F,{primary:!0,px:"5px",children:I}),e.jsx(F,{children:"features displayed out of"}),e.jsx(F,{primary:!0,px:"5px",children:P}),e.jsx(F,{children:"features"})]}),n&&e.jsx(r,{ml:"10px",children:n}),O&&s===j.fg&&e.jsx(g,{ml:"10px",children:e.jsx(U,{mode:X.bulk,possible:o.length>0,tooltipMainText:"Add all features to basket",tooltipSecondaryText:`${o.length} features`,handleClick:z(o,t),inBasket:R(o,t)})}),e.jsx(g,{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:b})}),e.jsx(g,{sx:{span:{marginTop:"4px"}},children:e.jsx(E,{ml:"10px",as:"span",text:"go to page",align:"left",children:e.jsx(B,{variant:"white",disabled:f===1,totalPages:f,currentPage:d,onChange:w})})})]})]}),e.jsxs(r,{sx:{gap:"20px",mt:"10px",flexDirection:"column",width:"100%"},...i,children:[o.map(h=>e.jsx(g,{children:x({type:s,parent:t,data:h})},h.name)),o.length>10&&e.jsx(E,{mt:"35px",as:"span",text:"go to page",align:"left",children:e.jsx(B,{variant:"white",disabled:f===1,totalPages:f,currentPage:d,onChange:w})}),$&&e.jsx(Y,{subject:"features",result:m.length,onReset:V})]})]})};export{pe as F};
