import{r as T,u as Z,dp as tt,bf as et,b4 as it,w as at,eK as rt,d_ as ot,dm as st,v as L,x as nt,as as pt,fp as $,fq as v,fr as ut,g as C,du as N,fs as U,O,o as ct,q as P,bh as mt,bb as dt,bc as lt,j as n,L as gt,bW as ft,be as xt}from"./index-CK33qGU_.js";import{u as Ft,a as St}from"./index-Z2NVN_R3.js";import{F as ht}from"./FeatureGroupForm-Bnc8TAZ_.js";import{u as vt}from"./useDeleteFG-y1PZHctX.js";import"./Anchor-HBBcGDu5.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./schematised-tags.selectors-xn4c-iOu.js";import"./storage-connector-BuEuJyVA.js";import"./AlertForm-BWXdFIuw.js";import"./alertManagerConfig.selectors-BX2JGYEL.js";import"./Project-j3KdDsvH.js";import"./ButtonWithRole-NHXEosto.js";import"./__-BIxbRvwe.js";import"./useDownload-hrjXceJg.js";import"./useProject-BzBQtp4J.js";import"./length-fOfC3W0h.js";import"./complement-M2aUPqXA.js";import"./FileUploaderButton-Bppadu35.js";import"./dumbPluralize-CcxDsNiu.js";import"./PrimaryIconButton-DQUEhx3G.js";import"./zipObj-DQ8OxaYj.js";import"./git-C8OLuEaG.js";import"./NoData-CuLyR2Bg.js";import"./useCopyToClipboard-_4vnCVip.js";import"./ServiceAlertList-BdM6y14f.js";import"./index-CKCOe8Wi.js";import"./utils-37_jnP5r.js";import"./index-CIxm3shV.js";import"./transformations.selectors-DnzHXZ16.js";import"./LabelsForm-CXM09GXF.js";import"./randomString-D3iDJlGT.js";import"./project-C-jJLTjn.js";import"./where-Mo9A6TUc.js";import"./flip-BOjSlIdl.js";import"./symmetricDifference-BM7wpjYU.js";import"./isAfter-DXq4FRTQ.js";import"./useUpdateTdOrFvInfoService-iD5D3Lyd.js";import"./SingleSelect-CV8k2k_j.js";import"./SchematisedTagsForm-BQySjcvw.js";import"./randomArrayString---X8tfjV.js";import"./sort-BOLIcXtz.js";import"./index-B4h3z62J.js";import"./StatisticsConfigurationForm-CIhaZTg5.js";import"./index-DnFHOcek.js";import"./NewTransformationPopup-sCZyxBfG.js";import"./ViewTransformation-B_KH3iXm.js";import"./index-DPxTMw0E.js";import"./zoom-CRTJnDeN.js";import"./transform-C0Urpblx.js";import"./string-CFFdVFMV.js";import"./pathSatisfies-CSrP04yE.js";const Tt=()=>{const{id:e,fsId:i,fgId:a}=Z(),{data:A}=tt(),s=et(),b=it(),[_,u]=at(),{currentData:q,isFetching:B}=rt(),[E,{isLoading:M}]=Ft(),[y,{isLoading:Q}]=St(),{deleteFg:H,isDeleting:D}=vt(),K=()=>{u(),H()},{currentData:l,isLoading:R}=ot({pId:+e,fsId:+i,fgId:+a},{skip:!A});T.useEffect(()=>{s.schematisedTags.fetch()},[s,e,q,i,a]);const{currentData:r,isFetching:W}=st({pId:+e,fsId:+i,fgId:+a},{selectFromResult:L({currentData:nt(L({transformationFunctions:pt(({version:t,hopsworksUdf:{name:I,transformationFeatures:g}})=>({features:g,transformation:{name:`${I} v${t}`}}))}))})}),z=T.useCallback(async(t,I,g)=>{let j=a;try{if(g){const{features:o,enabled:f,histograms:x,correlations:F,exactUniqueness:S,expectationSuite:h,type:c,spine:m,...p}=t,d=await s.featureGroups.create({projectId:+e,featureStoreId:+i,data:{...p,type:c,features:$(o),timeTravelFormat:p.timeTravelFormat.toUpperCase(),descStatsEnabled:!!v(o).length,validationType:p.validationType[0].toUpperCase(),eventTime:ut(o),jobs:[],statisticsConfig:{columns:v(o),correlations:F,enabled:f,histograms:x,exactUniqueness:S},...!C(h.expectations??[])&&(c!==N.ON_DEMAND||!m&&t.onlineEnabled)?{expectationSuite:t.expectationSuite}:{}}});d&&(j=String(d))}else{const{features:o,transformationFunctions:f,description:x,enabled:F,histograms:S,correlations:h,exactUniqueness:c,onlineEnabled:m,tags:p,keywords:d,validationType:J,type:w,expectationSuite:k,notificationTopicName:V,spine:X}=t;t.expectationSuite&&Object.keys(t.expectationSuite).length>1&&(t.expectationSuite.id?await y({id:e,fgId:a,fsId:i,data:t.expectationSuite}).unwrap():await E({id:e,fgId:a,fsId:i,data:t.expectationSuite}).unwrap()),await s.featureGroups.edit({projectId:+e,featureStoreId:+i,featureGroupId:+a,data:{description:x,keywords:d,features:$(o),transformationFunctions:f,onlineEnabled:m,tags:p,type:w,validationType:J[0],prevTags:l.map(({name:Y})=>Y),statisticsConfig:{columns:v(o),correlations:h,enabled:F,histograms:S,exactUniqueness:c},...!C(k.expectations??[])&&(w!==N.ON_DEMAND||!X&&m)?{expectationSuite:k}:{},notificationTopicName:V}})}s(U.invalidateTags([O.ProjectTags.FeatureGroup])),s(U.invalidateTags([{type:O.ProjectTags.FeatureGroupKeyword,id:a}])),b(ct(P.featureGroup.overview,P.project.value,{id:e,fsId:i,fgId:j}))}catch{}},[a,s,b,e,i,l,y,E]),G=mt(t=>t.loading.effects.featureGroups.edit);return dt(`${lt.editFg} - ${r==null?void 0:r.name}`),W||R?n.jsx(gt,{}):r?n.jsxs(n.Fragment,{children:[n.jsx(ht,{isEdit:!0,isLoading:G||D||B||M||Q,isDisabled:G,submitHandler:z,onDelete:u,initialData:{...r,tags:l}}),n.jsx(xt,{title:`Delete ${r.name} v${r.version}`,secondaryText:"Once you delete a feature group, there is no going back. Please be certain.",isOpen:_,onClose:u,mainButtonProps:{children:`Delete ${r.name} v${r.version}`,onClick:K,isLoading:D,"data-test":"delete-feature-group"},secondaryButtonProps:{children:"Back",onClick:u}})]}):n.jsx(ft,{})},he=T.memo(Tt);export{he as default};
