import{r as n,j as o}from"./vendor-react-wBh_31cN.js";import{e as E,a as S,r as C}from"./index-dNe6i2rS.js";import{u as T,c as w,d as N}from"./index-ZWn4qLiW.js";import{u as G,M as Q,a as $,b as z}from"./useMonitoringConfigsFilter-Dihz27_R.js";import{D as H}from"./relativeCheckTime-U3FQvqU-.js";import{t as h}from"./toast-wiGcevcF.js";import{d as q}from"./dumbPluralize-CcxDsNiu.js";import{F as A}from"./FVPanel-ZBxofnxK.js";import{c as J}from"./vendor-router-D1GqFWiT.js";import"./vendor-redux-CJZrIb6x.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";import"./sortBy-COer1Ia5.js";import"./mergeRight-D1nsCm60.js";import"./time-utils-CQYZ5msB.js";import"./addDays-Cdit4yPz.js";import"./always-oSAuSdys.js";import"./init-Dq_gEBi9.js";import"./concat-CTXo1gGM.js";import"./formatDistance-B6o-SXVU.js";import"./badge-UCnweWGd.js";import"./data-table-Mt0DWBPO.js";import"./checkbox-BlA4MwH9.js";import"./skeleton-C7BaXix8.js";import"./BlinkingDots-CJK9OJE3.js";import"./LoadMore-Bg-Y-iGB.js";import"./table-a0YeQrHM.js";import"./tooltip-DFFgUYh6.js";import"./icon-button-BZeFL7T7.js";import"./dropdown-menu-DCcmtBGI.js";import"./index-CcynNqTL.js";import"./index-dHd2aGu6.js";import"./join-oazOKFfj.js";import"./includes-ucXR_9jq.js";import"./add-SI0q72Q7.js";import"./EnableConfigButton-dv9GX3tn.js";import"./monitoring-config-utils-Di6JXNMn.js";import"./theme-colors-BFneJNsI.js";import"./countBy-B-JkTAeT.js";import"./complement-BEggNnIO.js";import"./not-C0YaysLC.js";import"./whereEq-qRDwP6XF.js";import"./where-5NF5DPVb.js";import"./any-BVxDk2A0.js";import"./input-DFI7JniT.js";import"./label-gPWmc6ow.js";import"./editable-select-DItn4ZHW.js";import"./confirmation-dialog-C7dws5K4.js";import"./useCopyToClipboard-DfzwgDFE.js";import"./useNotifier-BGMn6HaH.js";import"./notifications-5miqOdlG.js";import"./NoData-BtM2pAIA.js";import"./Panel-D_anPZvo.js";import"./MissingMandatoryTagsWarning-BHZy5VlV.js";import"./combobox-QqI9aNup.js";import"./input-group-gxy3DSmS.js";import"./textarea-BJVuSob1.js";import"./vendor-recharts-DmJlpLaF.js";import"./list-page-header-Fc18Qd7m.js";import"./animated-progress-DY4TkPAt.js";import"./separator-CxqNNMXg.js";import"./value-7N0Keti9.js";import"./metadata-field-Uf1PM1Ss.js";import"./CardActionButton-9dnJFRFw.js";import"./Deprecated-DEh1iT37.js";import"./uniqBy-6oWnYXMs.js";import"./sort-qlseijG5.js";import"./ascend-DedmOJV5.js";import"./useUserPermissions-Bu9Wyk8A.js";import"./selectors-DK1_X0Cd.js";import"./index-DLI8oDiK.js";import"./useCurrentProject-CTMLbmkf.js";import"./useProject-BbrP3CX5.js";import"./index-DURBtSjL.js";import"./project-eQY1xQe-.js";import"./ResourceNotFound-Cgzu0F33.js";import"./index-DnLCKZiK.js";import"./uniq--Ej6WwWR.js";import"./useProjectNavigate-BM67yKhl.js";import"./useProjectRole-DpUIGfh9.js";const xo=()=>{const{id:m,fsId:s,fvName:r,fvVersion:e}=J(),{data:p=[],isLoading:l,refetch:F}=T({pId:m,fsId:s,fvName:r,fvVersion:e},{selectFromResult:E({data:S([],"items")})}),a=p.map(i=>i.id),{data:c={},isLoading:g,refetch:M}=w({pId:m,fsId:s,fvName:r,fvVersion:e,configIds:a},{skip:a.length===0}),j=n.useMemo(()=>{const i={};return Object.entries(c).forEach(([V,B])=>{i[+V]=B.shiftedFeatureCount}),i},[c]),{filteredConfigs:v,filterState:x,updateField:D}=G(p),[b,f]=n.useState(!1),[t,y]=n.useState(void 0),[u,{isLoading:I}]=N(),L=n.useCallback(i=>{y(i),f(!0)},[]),k=n.useCallback(()=>{t&&u({pId:m,fsId:s,fvName:r,fvVersion:e,configId:t.id}).unwrap().then(()=>{f(!1),h.success(`Monitoring config '${t.name}' deleted successfully`)}).catch(()=>{h.error(`Failed to delete monitoring config '${t.name}'`)})},[t,u,s,r,e,m]),d=l||g,O=o.jsx(z,{filterState:x,updateField:D}),P={value:p.length,label:q("monitoring configuration",p.length)},R=o.jsx($,{isFetching:d,onRefresh:()=>{F(),a.length>0&&M()}});return o.jsxs(o.Fragment,{children:[o.jsx(H,{isOpen:b,onClose:()=>f(!1),configName:(t==null?void 0:t.name)??"",onConfirm:k,isDeleting:I}),o.jsx(A,{path:C.project.featureView.featureMonitoringList,filterToolbar:O,count:P,tools:R,isFetchingContent:d,children:()=>o.jsx(Q,{monitoringConfigs:v,shiftCountByConfigId:j,isResultsLoading:g,configHrefProps:{to:C.project.featureView.featureMonitoring,params:{fvName:r,fvVersion:e}},isLoading:l,onClickDelete:L})})]})};export{xo as default};
