import{b9 as M,u as R,b3 as S,b as p,aS as _,b1 as A,r as f,b8 as g,c as v,at as O,dq as U,fw as Y,aY as q,aZ as z,j as a,cf as H,a$ as F,al as J,dJ as Z}from"./index-ea7817a2.js";import{P as B}from"./Panel-041c5d61.js";import{N as K}from"./NoData-8733f606.js";import{C as Q}from"./Correlation-3329dfda.js";import{u as W}from"./useUserPermissions-d2903885.js";import{u as X}from"./useFeatureGroupView-80b143cb.js";import{u as tt}from"./useFeatureGroupVersions-ee161b97.js";import"./Deprecated-9bfe2e44.js";import"./CardActionButton-6aa39bc1.js";import"./setPrototypeOf-c2b1cc7a.js";import"./objectWithoutPropertiesLoose-4f48578a.js";import"./utils-297973b8.js";import"./useCurrentProject-0132f110.js";import"./useProject-77619fff.js";import"./FileUploaderButton-495e1c87.js";import"./useDownload-09eaf3eb.js";import"./props-31bc4ea7.js";import"./zipObj-08c84ab1.js";import"./index-8f672200.js";import"./file-utils-a5f053e8.js";import"./project-c611a3ec.js";const xt=()=>{const{DATE_TIME_FULL:m}=M.DATE_TIME,{id:s,fsId:r,fgId:o,commitTime:c}=R(),l=S(t=>{var u;return(u=t.featureGroupStatistics)==null?void 0:u.entities.statistics}),j=S(t=>t.loading.effects.featureGroupStatistics.fetch),i=S(t=>t.featureGroupStatisticsCommits),{isLoading:x,data:e}=X(+s,+o,+r),{currentData:L=[e],isFetching:V,handleVersionChange:N}=tt(e==null?void 0:e.name,p.featureGroup.correlation),h=_(),n=A(),{canEdit:P,isLoading:k,isDataScientist:T}=W();f.useEffect(()=>{n.featureGroupStatisticsCommits.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o}),n.featureGroupStatistics.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o,timeCommit:c})},[s,o,n,r,c]);const w=f.useCallback(()=>{n.featureGroupStatisticsCommits.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o}),n.featureGroupStatistics.fetch({projectId:+s,featureStoreId:+r,featureGroupId:+o,timeCommit:c})},[n.featureGroupStatisticsCommits,n.featureGroupStatistics,s,r,o,c]),d=f.useMemo(()=>{let t=c;return i.length>0&&(!t||t===i[0]?t=`${g(+i[0],m)} (latest)`:Number.isInteger(+t)&&(t=g(+t,m))),t},[c,i,m]),b=f.useCallback((t,u=o)=>{let E=t;t.includes("(latest)")&&(E=t.slice(0,t.indexOf(" (latest)")));const I=i.find(G=>g(+G,m)===E),$=i.find(G=>{const D=g(+G,m);return D===d||`${D} (latest)`===d});I&&$!==I&&h(v(p.featureGroup.correlationViewCommit,p.project.value,{id:s,fsId:r,fgId:u,commitTime:I}))},[s,r,i,h,o,d,m]),y=f.useCallback(t=>{const[u]=t;b(u)},[b]),C=f.useMemo(()=>l&&O(U(Y,"correlations"),l),[l]);return q(`${z.correlation} ${e!=null&&e.name?e.name:"Feature group"}`),!x&&!e?a.jsx(H,{}):x?a.jsx(F,{}):a.jsxs(a.Fragment,{children:[a.jsx(B,{title:e.name,data:e,idColor:(e==null?void 0:e.type)==="onDemandFeaturegroupDTO"?"labels.blue":"labels.orange",isEditDisabled:!P||T||k,onClickEdit:()=>h(v(p.featureGroup.edit,p.project.value,{id:s,fsId:r,fgId:o})),onClickRefresh:w,version:e==null?void 0:e.version,versions:L||[],isVersionsLoading:V,onVersionChange:N,hasCommits:!0,commits:i||[],commit:d,handleCommitChange:y,pathnamePostFix:"/correlation",editRightText:T?"Your role is not allowed to perform this action":void 0}),j&&a.jsx(F,{}),!j&&(!C||J(C)?a.jsx(K,{mainText:"No feature correlation",secondaryText:""}):a.jsx(Q,{item:e,correlation:C,type:Z.fg}))]})};export{xt as default};
