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