import{j as s,e as m,aQ as d,g as h,q as x,aj as j}from"./index-Cziemgsu.js";const o=({profile:a,project:e})=>{const t=`/ui/project/${e}/instances?profile=${a}`;return s.jsx(m,{className:"u-no-margin u-no-padding",to:t,children:"Go to instances"})},f=({profile:a,affectedProjects:e,headingClassName:t})=>s.jsx(s.Fragment,{children:e==null?void 0:e.map(n=>s.jsxs("tr",{className:"instances-by-project list-wrapper",children:[s.jsx("th",{className:t,children:s.jsxs("div",{className:"flexible-container",children:[s.jsx("div",{className:"u-truncate",title:`Project ${n.name}`,children:n.name}),s.jsxs("div",{className:"u-float-right",children:["(",n.instances.length,")"]})]})}),s.jsxs("td",{children:[n.instances.length===0&&s.jsx("i",{className:"u-text--muted no-instances",children:"No instances"}),n.instances.length>0&&s.jsx(o,{profile:a,project:n.name})]})]},n.name))}),g=({profile:a,project:e,usedByInstances:t})=>s.jsx(s.Fragment,{children:t.length>0&&s.jsx("tr",{children:s.jsx("td",{children:s.jsx(o,{profile:a,project:e})})})}),N=({profile:a,project:e,headingClassName:t})=>{const n=e==="default",l=d(e,n,a.used_by),r=n?[{name:e,instances:l.filter(c=>c.project===e)}]:void 0;if(n){const{data:c=[]}=h({queryKey:[x.projects],queryFn:j});c.filter(i=>i.config["features.profiles"]==="false").map(i=>i.name).forEach(i=>r==null?void 0:r.push({name:i,instances:l.filter(u=>u.project===i)}))}return n?s.jsx(f,{profile:a.name,affectedProjects:r,headingClassName:t}):s.jsx(g,{profile:a.name,project:e,usedByInstances:l})};export{N as P};
