import{u as L,b9 as T,y as P,r as s,q as k,p as E,iX as v,bt as w,iY as B,jd as F,bw as M,bx as N,j as a,D as O,cp as $,bz as z}from"./index-46ma1THH.js";import{d as G,e as q,f as Q}from"./index-CEcdCfcT.js";import{D as R}from"./DataSourceCreate-Da5yIYyi.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./index-CcWUz40c.js";import"./flip-szqi4alz.js";import"./FeaturesForm-CufhwCoR.js";import"./sum-DF_JiBHo.js";import"./countBy-mtn2Iagr.js";const _=()=>{const{connectorName:o,id:n,fsId:t}=L(),l=T(),[f,i]=P(),[p,{error:h,isLoading:g}]=G(),[u,{isLoading:m}]=q(),{currentData:e,isUninitialized:j,isFetching:C}=Q({pId:+n,fsId:+t,id:o}),D=s.useCallback(()=>{l(k.project.storageConnector.list,{fsId:t})},[t,l]),x=s.useCallback(async(c,d)=>{const{storageConnectorType:b}=c,I=E(w("type",B(b)),v(b))(c);await p({pId:+n,fsId:+t,id:o,data:I}).unwrap().then(U=>{d==null||d(c)})},[p,n,t,o]),y=s.useCallback(()=>u({pId:+n,fsId:+t,id:o}).unwrap().then(D),[u,n,t,o,D]),r=e==null?void 0:e.storageConnectorType,S=s.useMemo(()=>F(r)(e),[e,r]);return M(`${N.editStorageConnector} - ${e==null?void 0:e.name}`),C&&!e||j?a.jsx(O,{}):!e&&!C?a.jsx($,{}):a.jsxs(a.Fragment,{children:[a.jsx(R,{error:h,isSaving:g||m,isDisabled:g,onSubmit:x,initialProtocol:r,initialData:S,onDelete:i,isEdit:!0}),a.jsx(z,{title:`Delete ${e==null?void 0:e.name}`,secondaryText:"Once you delete a storage connector, there is no going back. Please be certain.",isOpen:f,onClose:i,mainButtonProps:{children:"Delete",onClick:y,isLoading:m,"data-test":"delete-ds"},secondaryButtonProps:{children:"Back",onClick:i}})]})};export{_ as default};
