import{r as n,aX as C,u as P,cH as k,b0 as U,aR as H,e3 as N,m as f,z as c,bj as R,aw as q,dB as B,W as m,gx as L,cT as z,dl as K,gs as M,gt as l,gu as Q,gv as W,x as X,g as Y,e as g,b2 as $,j as J,gw as V,aY as Z}from"./index-d6499a22.js";import{u as _}from"./useFeatureGroups-9d8b1765.js";var v=(e=>(e.job="job",e.start="start",e.fgStats="fgStats",e.newProject="newProject",e.experiments="experiments",e.featuregroup="featuregroup",e))(v||{});const O=()=>{C(Z.createFeatureGroup);const{id:e,fsId:a}=P(),{data:{id:i}={}}=k(),t=U(),d=H(),{currentData:F,isFetching:G}=N(),{currentData:T=[],isFetching:j}=_();n.useEffect(()=>{t.schematisedTags.fetch()},[t,e,F,a]);const h=f(c("name"),T),b=n.useCallback(async(p,r)=>{const{features:s,enabled:x,histograms:S,correlations:y,exactUniqueness:w,timeTravelFormat:E,validationType:A,expectationSuite:ee,...D}=p,o=await t.featureGroups.create({projectId:+e,featureStoreId:+a,data:R(q("type",B.STREAM),m(L("timeTravelFormat"),u=>z("primaryKeys",m(K(c("primary")),f(c("name")))(u.features),u)),{...D,features:M(s),timeTravelFormat:E[0].toUpperCase(),descStatsEnabled:!!l(s).length,validationType:A[0].toUpperCase(),eventTime:Q(s),jobs:[],statisticsConfig:{columns:l(s),correlations:y,enabled:x,histograms:S,exactUniqueness:w}})});if(o){if(r&&r.length>1){const u={items:r};await t.validationAlert.createBulk({projectId:+e,featureStoreId:+a,featureGroupId:o,validationAlert:u})}else r&&r.length===1&&await t.validationAlert.create({projectId:+e,featureStoreId:+a,featureGroupId:o,validationAlert:r[0]});t(W.invalidateTags([X.ProjectTags.FeatureGroup])),t.onboarding.checkSection({userId:i,id:v.featuregroup}),t.onboarding.setOpenOnboarding({userId:i,open:!0}),d(Y(g.featureGroup.overview,g.project.value,{fgId:o,fsId:a,id:e}))}},[t,a,d,e,i]),I=$(p=>p.loading.effects.featureGroups.create);return J.jsx(V,{featureGroupsNames:h,isLoading:G||j,isDisabled:I,submitHandler:b})},re=n.memo(O);export{re as default};
