import{bx as G,by as U,u as y,g0 as F,r as l,aK as W,g2 as Y,p as $,j as e,D as v,a as s,g5 as q,aH as Q,bd as C,L as S,ao as V,cD as X,f as E,aJ as m,ap as Z,d as x,ek as ee,jS as te,s as se,t as I,bT as ae,c5 as re}from"./index-_eM6l4Nf.js";import{u as ie}from"./useUserPermissions-Dd9YjnbM.js";import{s as oe}from"./searchText-DQ-LeNvB.js";import"./sort-BOLIcXtz.js";import{u as ne}from"./useMultiStoreSelect-B3ie-TCg.js";import{F as le}from"./FeatureViewsListContent-B61jOIDG.js";import"./FilterResult-DzQsF93v.js";import"./LoadMore-CH7MFfoq.js";import"./TableCells-C5ojOgAx.js";import"./Deprecated-Cn0z8EIY.js";import"./FeatureGroupTypeBadge-CTMzMdrC.js";import"./TagsSection-B2HTMG_L.js";import"./SchematisedTagTable-BUnYakOD.js";import"./SchematisedTagsEdit-D034QUDk.js";import"./index-BXwHI1zk.js";import"./SchematisedTagsForm-D8cUEyzq.js";import"./useUpdateTdOrFvInfoService-Byz_Aakv.js";import"./schematised-tags.selectors-WK3AUml0.js";import"./randomArrayString---X8tfjV.js";const L=[{value:"CREATION:DESC",label:"last created"},{value:"CREATION:ASC",label:"first created"},{value:"VERSION:DESC",label:"version"},{value:"NAME:ASC",label:"name ascending"},{value:"NAME:DESC",label:"name descending"}],ye=()=>{G(U.featureViews);const{id:t,fsId:a}=y(),{selectFSValue:r,selectFSOptions:c,handleFSSelectionChange:T,isLoading:i,hasSharedFS:g,isSharedLoading:A}=ne(),[d,D]=F("fvListSort_v2",L[0].value),[o,f]=l.useState(""),u=W(o,300),M=l.useMemo(()=>({pId:+t,fsId:+a,params:{filter_by:["latest_version",...u?[`NAME_LIKE:${u}`]:[]],sort_by:d}}),[u,a,t,d]),{data:n,hasMore:_,loadMore:R,isFetchingMore:k,isFetching:H,isLoading:P,refetch:O}=Y({api:te,apiEndpointName:"getFeatureViews",apiArgs:M}),[j,z]=F("fgAsTable",!1),{canEdit:b,isLoading:w}=ie(),B=()=>{f("")},J=h=>{f(h.target.value)},K=()=>z(h=>!h),p=l.useMemo(()=>$(oe(o))(n),[n,o]);return A||P?e.jsx(v,{}):e.jsxs(s,{flexDirection:"column",mt:"-20px",children:[e.jsxs(s,{sx:q.stickyHeader,pt:"20px",children:[e.jsxs(s,{gap:"10px",alignItems:"center",children:[e.jsx(Q,{labelProps:{flexGrow:1},variant:"white",value:o,placeholder:"Find a Feature View...",onChange:J,autoFocus:!0}),g&&e.jsx(C,{width:"auto",variant:"white",label:"feature store",labelPosition:"inline",value:r,options:c,onChange:T}),e.jsx(S,{children:e.jsx(V,{mainText:"You have no edit right on the feature store",disabled:b&&!w,children:e.jsx(N,{disabled:!b||w})})})]}),e.jsx(X,{mt:"10px",mb:"10px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(s,{mb:"10px",justifyContent:"space-between",alignItems:"center",children:[e.jsx(s,{children:!i&&e.jsxs(e.Fragment,{children:[e.jsx(E,{primary:!0,mr:"5px",children:p.length}),e.jsx(E,{children:"feature views"})]})}),e.jsxs(s,{gap:"10px",alignItems:"center",children:[e.jsx(V,{mainText:"Change View",children:e.jsx(m,{p:"4px",intent:"secondary",onClick:K,children:e.jsx(Z,{icon:j?x.card:x.lines,size:"lg"})})}),e.jsx(C,{labelPosition:"inline",variant:"white",value:d,isDisabled:i,options:L,label:"sort by",onChange:D}),e.jsx(ee,{onClick:O,icon:x.refresh,tooltipText:"Refresh"})]})]})]}),(i||H)&&e.jsx(v,{}),e.jsxs(S,{mt:"20px",children:[e.jsx(le,{data:p,isFiltered:n.length!==p.length,asTable:j,onResetFilters:B,hasMore:_,loadMore:R,isFetchingMore:k}),!i&&!n.length&&e.jsx(ce,{hasSharedFS:g})]})]})},ce=({hasSharedFS:t})=>e.jsxs(ae,{mainText:t?"No Feature Views for the selected feature store":"No Feature Views",secondaryText:t?"Create one from feature groups or select another feature store":"Create one from feature groups",sx:{gap:"14px"},children:[e.jsx(N,{}),e.jsx(m,{intent:"secondary",href:re("/user_guides/fs/feature_view/overview/"),external:!0,target:"_blank",children:"Feature View Documentation"})]}),N=({disabled:t})=>{const{id:a,fsId:r}=y(),c=l.useMemo(()=>se(I.project.featureView.create,I.project.value,{id:a,fsId:r}),[r,a]);return e.jsx(m,{href:c,intent:"primary",disabled:t,children:"New Feature View"})};export{ye as default,L as sortOptions};
