import{j as e,r as x}from"./vendor-react-wBh_31cN.js";import{j as C,u as F}from"./vendor-redux-CJZrIb6x.js";import{D as d}from"./drawer-D7Vwn5J8.js";import{cf as M,e as U,u as H,aD as O,g as G,r as m,aq as Q,cg as _,R as z}from"./index-dNe6i2rS.js";import{V as v}from"./value-7N0Keti9.js";import{a as A}from"./useProjectId-DeuaOE3U.js";import{S as J,a as K}from"./StatisticsCharts-QIp3194E.js";import{u as W}from"./vendor-router-D1GqFWiT.js";const T=({data:a,className:i})=>e.jsx("ul",{className:`m-0 flex list-none flex-col p-0 ${i??""}`,children:a.filter(({value:t})=>t!==void 0).map(({title:t,value:s})=>e.jsxs("li",{className:"my-[5px] flex flex-grow justify-between",children:[e.jsx(v,{children:t}),e.jsx(v,{primary:!0,className:"ml-auto",children:Number.isNaN(s||"-")?"-":Number(Number(s).toFixed(6))})]},t))}),P=(a,i)=>{const t=i.reduce((s,[p,f])=>[...s,{title:f,value:a[p]}],[]);return t.every(({value:s})=>!s)?null:t},X=({data:a})=>{const i=x.useMemo(()=>P(a||{},[["min","min"],["max","max"],["mean","mean"],["sum","sum"],["stddev","std dev"]]),[a]),t=x.useMemo(()=>P(a||{},[["approxNumDistinctValues","approximate distinct count"],["exactNumDistinctValues","exact distinct count"],["completeness","completeness"],["uniqueness","uniqueness"],["distinctness","distinctness"],["entropy","entropy"]]),[a]);return e.jsxs("div",{className:"flex w-full flex-col",children:[i&&e.jsx(T,{data:i}),t&&e.jsx(T,{data:t})]})},ce=({isOpen:a,handleToggle:i,projectId:t,featurestoreId:s,parentProjectId:p,featuregroup:f,fgName:h,version:R,name:n,feature:k,fgId:L})=>{var w,y,D;const j=W(),N=C(),{pId:V,skip:q}=A(p),{data:E}=M({pId:V,fsId:s,fgName:h,version:R},{skip:!h||q,selectFromResult:U({data:H(O)})}),c=f??E,I=k??(c==null?void 0:c.features.find(l=>l.name===n)),o=L??(c==null?void 0:c.id)??0,$=G(m.project.featureGroup.overview,m.project.value,{id:t,fsId:s,fgId:o}),B=`${G(m.project.featureGroup.preview,m.project.value,{id:t,fsId:s,fgId:o})}?search=${n}`;x.useEffect(()=>{o&&N.featureGroupStatistics.fetch({projectId:t,featureStoreId:s,featureGroupId:o})},[I,N,o,t,s]);const S=F(l=>{var b;return(b=l.featureGroupStatistics)==null?void 0:b.entities.statistics}),u=F(l=>l.loading.effects.featureGroupStatistics.fetch),r=n&&S?S[n]:void 0,g=!!r;return e.jsxs(d,{headerLine:u?" ":n,isOpen:a,bottomButton:["Open in Feature Groups Page",()=>j($)],onClose:i,children:[u&&e.jsx(Q,{}),!u&&!g&&e.jsx(v,{className:"mt-[30px] text-center",children:"No Feature Statistics"}),!u&&g&&e.jsxs(e.Fragment,{children:[e.jsx(d.Section,{title:"Data overview",children:e.jsxs("div",{className:"flex w-full",children:[((w=r.extendedStatistics)==null?void 0:w.histogram)&&r.featureType&&e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(J,{dataType:_.fg,data:(y=r.extendedStatistics)==null?void 0:y.histogram,type:r.featureType})}),(!((D=r.extendedStatistics)!=null&&D.histogram)||!r.featureType)&&e.jsx(z,{bold:!0,gray:!0,className:"text-center",children:"No data overview"})]})}),e.jsx(d.Section,{title:"Data preview",action:["view data preview table",()=>j(B)],children:o&&e.jsx(K,{projectId:t,featureStoreId:s,fgId:o,featureName:n,featureGroup:c})}),e.jsx(d.Section,{title:"Statistics",children:e.jsx(X,{data:r})})]})]})};export{ce as F};
