import{_ as I}from"./BFKchtYk.js";import{d as O,a0 as R,a as N,w as T,o,m as u,F as f,n as k,aa as v,f as r,h as p,p as y,G as b,i as m,j as V,k as S,t as A,v as C,X as E,a6 as L,_ as z}from"./CAAfHP_R.js";import{_ as G}from"./Bufsui5p.js";const K={p4:"",flex:"~ col gap-4"},M={key:1,ml2:"",flex:""},X=["value"],q={key:0,flex:"","gap-4":""},H=S("div",{"flex-auto":""},null,-1),Y=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 a={};for(const e of $.value)a[e]=g.default[e]||"";return a}),j=["string","number","boolean","file","date","time","datetime-local"];function D(a,e){const t=e.target;if(t.files&&t.files[0]){const i=t.files[0],c=new FileReader;c.readAsDataURL(i),c.onload=()=>{d.value[a].value=c.result}}}return T(()=>d,a=>{a.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"}),(a,e)=>{const t=I,i=E,c=G,F=L,h=z;return o(),u("div",K,[(o(!0),u(f,null,k(r(d),(l,_)=>(o(),u("div",{key:_,flex:"~ gap-2","justify-around":""},[v(a.$slots,"input",{item:l}),(o(!0),u(f,null,k(r($),n=>(o(),u(f,{key:n},[l.type!==null&&n==="active"?(o(),p(t,{key:0,modelValue:l[n],"onUpdate:modelValue":s=>l[n]=s,n:"sm primary",disabled:a.disabled},null,8,["modelValue","onUpdate:modelValue","disabled"])):y("",!0),l.type!==null&&n==="key"?(o(),p(i,{key:1,modelValue:l[n],"onUpdate:modelValue":s=>l[n]=s,placeholder:n,"flex-1":"","font-mono":"",n:"sm primary",disabled:a.disabled,class:b(a.disabled?"op50":"")},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])):n==="value"?(o(),u(f,{key:2},[l.type==="file"?(o(),p(i,{key:0,type:"file",disabled:a.disabled,class:b(a.disabled?"op75":""),onChange:s=>D(_,s)},null,8,["disabled","class","onChange"])):l.type==="boolean"?(o(),u("div",M,[m(t,{modelValue:l.value,"onUpdate:modelValue":s=>l.value=s,placeholder:"Value",n:"green lg",disabled:a.disabled},null,8,["modelValue","onUpdate:modelValue","disabled"])])):(o(),p(i,{key:2,modelValue:l.value,"onUpdate:modelValue":s=>l.value=s,type:l.type,placeholder:"Value","flex-1":"","font-mono":"",n:"sm primary",disabled:a.disabled,class:b(a.disabled?"op75":"")},null,8,["modelValue","onUpdate:modelValue","type","disabled","class"]))],64)):n==="type"?(o(),p(c,{key:3,modelValue:l.type,"onUpdate:modelValue":s=>l.type=s,n:"sm green",class:b(a.disabled?"op75":""),disabled:a.disabled},{default:V(()=>[(o(),u(f,null,k(j,s=>S("option",{key:s,value:s},A(s),9,X)),64))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled"])):y("",!0)],64))),128)),v(a.$slots,"input-actions",{},()=>[m(h,{n:"red",disabled:a.disabled,class:b(a.disabled?"op0!":""),onClick:n=>r(d).splice(_,1)},{default:V(()=>[m(F,{icon:"carbon:trash-can"})]),_:2},1032,["disabled","class","onClick"])])]))),128)),a.disabled?y("",!0):(o(),u("div",q,[v(a.$slots,"actions",{params:r(d)},()=>[m(h,{icon:"carbon-add",n:"sm primary",my1:"","px-3":"",onClick:e[0]||(e[0]=l=>r(d).push({...r(B)}))},{default:V(()=>[C(" Add ")]),_:1}),H,r(d).length?(o(),p(h,{key:0,icon:"carbon-trash-can",n:"sm red",my1:"","px-3":"",onClick:e[1]||(e[1]=l=>r(d).splice(0,r(d).length))},{default:V(()=>[C(" Remove All ")]),_:1})):y("",!0)])])),v(a.$slots,"default")])}}});export{Y as _};
