import{R as o,bE as c,d7 as p,a as l,aP as i,q as m,j as n,d as r}from"./index-C88DWJny.js";const u=["can_delete","can_edit"],P=async(e,a)=>{const t=new URLSearchParams;return t.set("recursion","1"),t.set("project",e),p(t,a,u),fetch(`${o}/1.0/placement-groups?${t.toString()}`).then(c).then(s=>s.metadata)},h=async(e,a,t)=>{const s=new URLSearchParams;return s.set("project",a),p(s,t,u),fetch(`${o}/1.0/placement-groups/${encodeURIComponent(e)}?${s.toString()}`).then(c).then(d=>d.metadata)},G=async(e,a)=>{const t=new URLSearchParams;t.set("project",a),await fetch(`${o}/1.0/placement-groups?${t.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:e}).then(c)},g=async(e,a)=>{const t=new URLSearchParams;t.set("project",a),await fetch(`${o}/1.0/placement-groups/${encodeURIComponent(e.name)}?${t.toString()}`,{method:"PUT",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}}).then(c)},C=async(e,a)=>{const t=new URLSearchParams;t.set("project",a),await fetch(`${o}/1.0/placement-groups/${encodeURIComponent(e)}?${t.toString()}`,{method:"DELETE"}).then(c)},_=e=>{const{isFineGrained:a}=l();return i({queryKey:[m.placementGroups,e],queryFn:async()=>P(e,a)})},T=(e,a)=>{const{isFineGrained:t}=l();return i({queryKey:[m.placementGroups,a,e],queryFn:async()=>h(e,a,t)})},y="compact",R="spread",S="strict",b="permissive",j=({formik:e,isEdit:a=!1})=>{const t=s=>e.touched[s]?e.errors[s]:void 0;return n.jsxs(r.Form,{onSubmit:e.handleSubmit,children:[n.jsx(r.Input,{type:"submit",hidden:!0,value:"Hidden input"}),n.jsx(r.Input,{...e.getFieldProps("name"),type:"text",label:"Name",required:!0,autoFocus:!a,error:t("name"),placeholder:"Enter name",disabled:a,title:a?"Placement groups can't be renamed":void 0}),n.jsx(r.Input,{...e.getFieldProps("description"),type:"text",autoFocus:a,label:"Description",placeholder:"Enter description",error:t("description")}),n.jsx(r.Select,{...e.getFieldProps("policy"),label:"Policy",options:[{value:y,label:"Compact"},{value:R,label:"Spread"}],help:"Compact packs instances on as few members as possible. Spread distributes instances across members."}),n.jsx(r.Select,{...e.getFieldProps("rigor"),label:"Rigor",options:[{value:S,label:"Strict"},{value:b,label:"Permissive"}],help:"Strict fails instance creation if no matching member is available. Permissive allows creation to other members."})]})};export{y as P,S as a,j as b,G as c,T as d,g as e,C as f,_ as u};
