import{d as b,m as q,f as v,q as y,F as z,bm as S,j as h,S as O}from"./index-3c1b2661.js";import{c as N}from"./instanceConfigInheritance-8da60590.js";import{g as R,C as $}from"./ConfigurationTable-5663621c.js";import{t as w}from"./ConfigFieldDescription-f8ae8325.js";const d={restricted_cluster_groups:"restricted.cluster.groups",restricted_cluster_target:"restricted.cluster.target",restricted_devices_disk:"restricted.devices.disk",restricted_devices_disk_paths:"restricted.devices.disk.paths",restricted_devices_gpu:"restricted.devices.gpu",restricted_devices_infiniband:"restricted.devices.infiniband",restricted_devices_nic:"restricted.devices.nic",restricted_devices_pci:"restricted.devices.pci",restricted_devices_unix_block:"restricted.devices.unix-block",restricted_devices_unix_char:"restricted.devices.unix-char",restricted_devices_unix_hotplug:"restricted.devices.unix-hotplug",restricted_devices_usb:"restricted.devices.usb",restricted_virtual_machines_low_level:"restricted.virtual-machines.lowlevel",restricted_containers_low_level:"restricted.containers.lowlevel",restricted_containers_nesting:"restricted.containers.nesting",restricted_containers_privilege:"restricted.containers.privilege",restricted_container_interception:"restricted.containers.interception",restrict_snapshots:"restricted.snapshots",restricted_idmap_uid:"restricted.idmap.uid",restricted_idmap_gid:"restricted.idmap.gid",restricted_network_access:"restricted.networks.access",restricted_network_subnets:"restricted.networks.subnets",restricted_network_uplinks:"restricted.networks.uplinks",restricted_network_zones:"restricted.networks.zones",restricted:"restricted",features_images:"features.images",features_profiles:"features.profiles",features_networks:"features.networks",features_networks_zones:"features.networks.zones",features_storage_buckets:"features.storage.buckets",features_storage_volumes:"features.storage.volumes",limits_instances:"limits.instances",limits_containers:"limits.containers",limits_virtual_machines:"limits.virtual-machines",limits_disk:"limits.disk",limits_networks:"limits.networks",limits_cpu:"limits.cpu",limits_memory:"limits.memory",limits_processes:"limits.processes"},H=e=>{if(!(e in d))throw new Error(`Could not find ${e} in projectConfigFormFieldsToPayload`);return d[e]},E=()=>new Set(Object.values(d)),l={rootStorage:"",limits_cpu:"limits.cpu",limits_memory:"limits.memory",limits_memory_swap:"limits.memory.swap",limits_disk_priority:"limits.disk.priority",limits_processes:"limits.processes",security_privileged:"security.privileged",security_protection_delete:"security.protection.delete",security_protection_shift:"security.protection.shift",security_idmap_base:"security.idmap.base",security_idmap_size:"security.idmap.size",security_idmap_isolated:"security.idmap.isolated",security_devlxd:"security.devlxd",security_devlxd_images:"security.devlxd.images",security_secureboot:"security.secureboot",snapshots_pattern:"snapshots.pattern",snapshots_expiry:"snapshots.expiry",snapshots_schedule:"snapshots.schedule",snapshots_schedule_stopped:"snapshots.schedule.stopped",cloud_init_network_config:"cloud-init.network-config",cloud_init_user_data:"cloud-init.user-data",cloud_init_vendor_data:"cloud-init.vendor-data"},Q=e=>{if(!(e in l))throw new Error(`Could not find ${e} in instanceConfigFormFieldsToPayload`);return l[e]},k=()=>new Set(Object.values(l)),G=k,J=k,M=({formik:e,name:t,label:s,children:o,defaultValue:x,disabled:C=!1,readOnlyRenderer:n})=>{const j=b.useNotify(),{project:u}=q();let _=[];if(u){const{data:c=[],error:g}=v({queryKey:[y.profiles],queryFn:()=>z(u)});_=c,g&&j.failure("Loading profiles failed",g)}const{data:r}=v({queryKey:[y.configOptions],queryFn:S}),K=e.values.type==="project"?w((r==null?void 0:r.configs.project)??{}):w((r==null?void 0:r.configs.instance)??{}),p=e.values,a=p[t],F=a!==void 0,m=p.type==="project"?H(t):Q(t),i=K.find(c=>c.key===m),[f,P]=N(e.values,m,_,i==null?void 0:i.default),I=e.values.readOnly,V=()=>n?n(f):f,T=()=>{const c=a===""?"-":a;return n?n(c):c};return R({formik:e,name:t,label:s,children:o,defaultValue:x,disabled:C,help:i==null?void 0:i.shortdesc,inputHelp:i==null?void 0:i.longdesc,isOverridden:F,inheritedValue:V(),inheritSource:P,isReadOnly:I,value:a,overrideValue:T()})},W=({rows:e,configurationExtra:t,emptyStateMsg:s})=>{const o=b.useNotify();return h.jsx(O,{dependencies:[o.notification],belowId:"form-footer",children:h.jsx($,{rows:e,configurationExtra:t,emptyStateMsg:s})})},X=(e,t)=>Object.fromEntries(Object.entries(e).filter(([s])=>!t.has(s))),Y=(e,t)=>{const s=t==null?void 0:t.find(o=>o.value===e);return s!=null&&s.label&&e!==""?s.label:""};export{W as I,X as a,G as b,M as c,Q as d,E as e,H as f,J as g,Y as o};
