import{aY as z,u as I,gl as C,r as d,W as Q,g6 as W,w as B,j as e,a$ as V,cf as G,Q as i,gr as U,aH as Y,bq as $,o as y,af as S,cu as q,g as v,aU as x,ag as J,z as m,bg as Z,cj as D,c as K,b as L,aZ as X}from"./index-ea7817a2.js";import{N as ee}from"./NoData-8733f606.js";import{u as se}from"./useUserPermissions-d2903885.js";import{d as te}from"./index-6ffd126a.js";import{u as re}from"./useMultiStoreSelect-64ee55e0.js";import{C as ae}from"./CardActionButton-6aa39bc1.js";import{F as ie}from"./FeatureViewsListContent-cfc4da58.js";import{d as oe}from"./FileUploaderButton-495e1c87.js";import"./index-8f672200.js";import"./file-utils-a5f053e8.js";import"./useCurrentProject-0132f110.js";import"./useProject-77619fff.js";import"./FilterResult-9d9dd7e5.js";import"./TableCells-0706f7f1.js";import"./Deprecated-9bfe2e44.js";import"./FeatureGroupTypeBadge-0e65ce60.js";import"./TagsSection-6ccbe40a.js";import"./SchematisedTags-a748e3d3.js";import"./useDownload-09eaf3eb.js";const ne=s=>t=>s?t.filter(({name:a,id:o})=>JSON.stringify({name:a,id:o}).toLowerCase().includes(s.toLowerCase())):t,k=[{key:"created",label:"last created"},{key:"name",label:"name"},{key:"version",label:"version"}],ke=()=>{z(X.featureViews);const{id:s,fsId:t}=I(),{selectFSValue:a,selectFSOptions:o,handleFSSelectionChange:N,isLoading:c,hasSharedFS:f,isSharedLoading:M}=re(),{currentData:r,isFetching:g,isLoading:H,refetch:P}=te({pId:+s,fsId:+t,params:{filter_by:"latest_version"}},{refetchOnFocus:!0}),[u,R]=C("fvListSort",k[0].key),[p,j]=d.useState(""),[w,_]=C("fgAsTable",!1),n=d.useMemo(()=>(r==null?void 0:r.items)??[],[r==null?void 0:r.items]),{canEdit:F,isLoading:b}=se(),A=()=>{j("")},E=l=>{j(l.target.value)},O=()=>_(l=>!l),h=d.useMemo(()=>Q(W(oe(B(u))),ne(p))(n),[n,p,u]);return M||H?e.jsx(V,{}):!g&&!r?e.jsx(G,{}):e.jsxs(i,{flexDirection:"column",mt:"-20px",children:[e.jsxs(i,{sx:U.stickyHeader,pt:"20px",children:[e.jsxs(i,{gap:"20px",alignItems:"center",children:[e.jsx(Y,{labelProps:{flexGrow:1},variant:"white",value:p,disabled:!n.length,placeholder:"Find a Feature View...",onChange:E,autoFocus:!0}),f&&e.jsx($,{width:"auto",variant:"white",listWidth:"max-content",placeholder:"feature store",value:a,options:o,onChange:N}),e.jsx(y,{children:e.jsx(S,{mainText:"You have no edit right on the feature store",disabled:F&&!b,children:e.jsx(T,{disabled:!F||b})})})]}),e.jsx(q,{mt:"10px",mb:"10px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(i,{mb:"10px",justifyContent:"space-between",alignItems:"center",children:[e.jsx(i,{children:!c&&e.jsxs(e.Fragment,{children:[e.jsx(v,{primary:!0,mr:"5px",children:h.length}),e.jsx(v,{children:"feature views"})]})}),e.jsxs(i,{gap:"10px",alignItems:"center",children:[e.jsx(S,{mainText:"Change View",children:e.jsx(x,{p:"4px",intent:"secondary",onClick:O,children:e.jsx(J,{icon:w?m.card:m.lines,size:"lg"})})}),e.jsx(Z,{labelMode:"inline",width:"150px",color:"white",listWidth:"100%",value:u,disabled:c,options:k,placeholder:"sort by",onChange:l=>R(l.key),isMulti:!1}),e.jsx(ae,{onClick:P,icon:m.refresh,tooltipText:"Refresh"})]})]})]}),(c||g)&&e.jsx(V,{}),e.jsxs(y,{mt:"20px",children:[e.jsx(ie,{data:h,isFiltered:n.length!==h.length,asTable:w,onResetFilters:A}),!c&&!n.length&&e.jsx(le,{hasSharedFS:f})]})]})},le=({hasSharedFS:s})=>e.jsxs(ee,{mainText:s?"No Feature Views for the selected feature store":"No Feature Views",secondaryText:s?"Create one from feature groups or select another feature store":"Create one from feature groups",sx:{gap:"14px"},children:[e.jsx(T,{}),e.jsx(x,{intent:"secondary",href:"https://docs.hopsworks.ai/".concat(D.docsVersion,"/user_guides/fs/feature_view/overview/"),external:!0,target:"_blank",children:"Feature View Documentation"})]}),T=({disabled:s})=>{const{id:t,fsId:a}=I(),o=d.useMemo(()=>K(L.featureView.create,L.project.value,{id:t,fsId:a}),[a,t]);return e.jsx(x,{href:o,intent:"primary",disabled:s,children:"New Feature View"})};export{ke as default,k as sortOptions};
