import{_ as I}from"./C3Ii60cx.js";import{d as O,Y as R,a as N,w as T,o,m as u,F as c,n as _,a8 as v,f as r,h as p,p as y,D as b,i as m,j as V,k as C,t as A,v as S,V as E,a4 as L,_ as z}from"./zEcrVex8.js";import{_ as K}from"./Bve0Ey2P.js";const M={p4:"",flex:"~ col gap-4"},Y={key:1,ml2:"",flex:""},q=["value"],G={key:0,flex:"","gap-4":""},W=O({__name:"ServerRouteInputs",props:{modelValue:{},keys:{default:()=>[]},default:{default:()=>({})},disabled:{type:Boolean,default:!1}},setup(U,{emit:w}){const g=U,d=R(g,"modelValue",w,{passive:!0}),$=N(()=>[...g.keys,"active","key","value","type"]),B=N(()=>{const l={};for(const e of $.value)l[e]=g.default[e]||"";return l}),D=["string","number","boolean","file","date","time","datetime-local"];function j(l,e){const t=e.target;if(t.files&&t.files[0]){const i=t.files[0],f=new FileReader;f.readAsDataURL(i),f.onload=()=>{d.value[l].value=f.result}}}return T(()=>d,l=>{l.value.forEach(e=>{if(e.type==="number"&&typeof e.value!="number"){const t=Number.parseFloat(e.value);e.value=Number.isNaN(t)?0:t}else e.type==="boolean"&&typeof e.value!="boolean"?e.value=!0:e.type==="file"&&typeof e.value!="object"?e.value="":e.type==="date"&&typeof e.value=="string"&&!e.value.match(/^\d{4}-\d{2}-\d{2}$/)?e.value=new Date().toISOString().slice(0,10):e.type==="time"&&typeof e.value=="string"&&!e.value.match(/^\d{2}:\d{2}$/)?e.value=new Date().toISOString().slice(11,16):e.type==="datetime-local"&&typeof e.value=="string"&&!e.value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/)?e.value=new Date().toISOString().slice(0,16):e.type==="string"&&(e.value=e.value.toString())})},{deep:!0,immediate:!0,flush:"sync"}),(l,e)=>{const t=I,i=E,f=K,F=L,k=z;return o(),u("div",M,[(o(!0),u(c,null,_(r(d),(a,h)=>(o(),u("div",{key:h,flex:"~ gap-2","justify-around":""},[v(l.$slots,"input",{item:a}),(o(!0),u(c,null,_(r($),n=>(o(),u(c,{key:n},[a.type!==null&&n==="active"?(o(),p(t,{key:0,modelValue:a[n],"onUpdate:modelValue":s=>a[n]=s,n:"sm primary",disabled:l.disabled},null,8,["modelValue","onUpdate:modelValue","disabled"])):y("",!0),a.type!==null&&n==="key"?(o(),p(i,{key:1,modelValue:a[n],"onUpdate:modelValue":s=>a[n]=s,placeholder:n,"flex-1":"","font-mono":"",n:"sm primary",disabled:l.disabled,class:b(l.disabled?"op50":"")},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])):n==="value"?(o(),u(c,{key:2},[a.type==="file"?(o(),p(i,{key:0,type:"file",disabled:l.disabled,class:b(l.disabled?"op75":""),onChange:s=>j(h,s)},null,8,["disabled","class","onChange"])):a.type==="boolean"?(o(),u("div",Y,[m(t,{modelValue:a.value,"onUpdate:modelValue":s=>a.value=s,placeholder:"Value",n:"green lg",disabled:l.disabled},null,8,["modelValue","onUpdate:modelValue","disabled"])])):(o(),p(i,{key:2,modelValue:a.value,"onUpdate:modelValue":s=>a.value=s,type:a.type,placeholder:"Value","flex-1":"","font-mono":"",n:"sm primary",disabled:l.disabled,class:b(l.disabled?"op75":"")},null,8,["modelValue","onUpdate:modelValue","type","disabled","class"]))],64)):n==="type"?(o(),p(f,{key:3,modelValue:a.type,"onUpdate:modelValue":s=>a.type=s,n:"sm green",class:b(l.disabled?"op75":""),disabled:l.disabled},{default:V(()=>[(o(),u(c,null,_(D,s=>C("option",{key:s,value:s},A(s),9,q)),64))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled"])):y("",!0)],64))),128)),v(l.$slots,"input-actions",{},()=>[m(k,{n:"red",disabled:l.disabled,class:b(l.disabled?"op0!":""),onClick:n=>r(d).splice(h,1)},{default:V(()=>[m(F,{icon:"carbon:trash-can"})]),_:2},1032,["disabled","class","onClick"])])]))),128)),l.disabled?y("",!0):(o(),u("div",G,[v(l.$slots,"actions",{params:r(d)},()=>[m(k,{icon:"carbon-add",n:"sm primary",my1:"","px-3":"",onClick:e[0]||(e[0]=a=>r(d).push({...r(B)}))},{default:V(()=>e[2]||(e[2]=[S(" Add ")])),_:1}),e[4]||(e[4]=C("div",{"flex-auto":""},null,-1)),r(d).length?(o(),p(k,{key:0,icon:"carbon-trash-can",n:"sm red",my1:"","px-3":"",onClick:e[1]||(e[1]=a=>r(d).splice(0,r(d).length))},{default:V(()=>e[3]||(e[3]=[S(" Remove All ")])),_:1})):y("",!0)])])),v(l.$slots,"default")])}}});export{W as _};
