import{_ as I}from"./ncheckbox.vue-ny9mboxw.js";import{C as O,z as R,H as T,_ as A}from"./ebt3cj6n.js";import{_ as z}from"./nselect.vue-o0k1l9g8.js";import{p as E,q as C,j as L,U as s,W as u,F as c,ae as _,Y as b,P as p,Z as m,a0 as v,a3 as y,a2 as V,X as N,a8 as q,u as r,a9 as U}from"./vendor/json-editor-vue-kcahofzr.js";const H={p4:"",flex:"~ col gap-4"},K={key:1,ml2:"",flex:""},M=["value"],P={key:0,flex:"","gap-4":""},J=E({__name:"ServerRouteInputs",props:{modelValue:{},keys:{default:()=>[]},default:{default:()=>({})},disabled:{type:Boolean,default:!1}},setup(S,{emit:w}){const g=S,d=O(g,"modelValue",w,{passive:!0}),$=C(()=>[...g.keys,"active","key","value","type"]),B=C(()=>{const l={};for(const e of $.value)l[e]=g.default[e]||"";return l}),j=["string","number","boolean","file","date","time","datetime-local"];function D(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 L(()=>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=R,f=z,F=T,k=A;return s(),u("div",H,[(s(!0),u(c,null,_(r(d),(a,h)=>(s(),u("div",{key:h,flex:"~ gap-2","justify-around":""},[b(l.$slots,"input",{item:a}),(s(!0),u(c,null,_($.value,n=>(s(),u(c,{key:n},[a.type!==null&&n==="active"?(s(),p(t,{key:0,modelValue:a[n],"onUpdate:modelValue":o=>a[n]=o,n:"sm primary",disabled:l.disabled},null,8,["modelValue","onUpdate:modelValue","disabled"])):m("",!0),a.type!==null&&n==="key"?(s(),p(i,{key:1,modelValue:a[n],"onUpdate:modelValue":o=>a[n]=o,placeholder:n,"flex-1":"","font-mono":"",n:"sm primary",disabled:l.disabled,class:v(l.disabled?"op50":"")},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled","class"])):n==="value"?(s(),u(c,{key:2},[a.type==="file"?(s(),p(i,{key:0,type:"file",disabled:l.disabled,class:v(l.disabled?"op75":""),onChange:o=>D(h,o)},null,8,["disabled","class","onChange"])):a.type==="boolean"?(s(),u("div",K,[y(t,{modelValue:a.value,"onUpdate:modelValue":o=>a.value=o,placeholder:"Value",n:"green lg",disabled:l.disabled},null,8,["modelValue","onUpdate:modelValue","disabled"])])):(s(),p(i,{key:2,modelValue:a.value,"onUpdate:modelValue":o=>a.value=o,type:a.type,placeholder:"Value","flex-1":"","font-mono":"",n:"sm primary",disabled:l.disabled,class:v(l.disabled?"op75":"")},null,8,["modelValue","onUpdate:modelValue","type","disabled","class"]))],64)):n==="type"?(s(),p(f,{key:3,modelValue:a.type,"onUpdate:modelValue":o=>a.type=o,n:"sm green",class:v(l.disabled?"op75":""),disabled:l.disabled},{default:V(()=>[(s(),u(c,null,_(j,o=>N("option",{key:o,value:o},q(o),9,M)),64))]),_:2},1032,["modelValue","onUpdate:modelValue","class","disabled"])):m("",!0)],64))),128)),b(l.$slots,"input-actions",{},()=>[y(k,{n:"red",disabled:l.disabled,class:v(l.disabled?"op0!":""),onClick:n=>r(d).splice(h,1)},{default:V(()=>[y(F,{icon:"carbon:trash-can"})]),_:2},1032,["disabled","class","onClick"])])]))),128)),l.disabled?m("",!0):(s(),u("div",P,[b(l.$slots,"actions",{params:r(d)},()=>[y(k,{icon:"carbon-add",n:"sm primary",my1:"","px-3":"",onClick:e[0]||(e[0]=a=>r(d).push({...B.value}))},{default:V(()=>e[2]||(e[2]=[U(" Add ")])),_:1}),e[4]||(e[4]=N("div",{"flex-auto":""},null,-1)),r(d).length?(s(),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]=[U(" Remove All ")])),_:1})):m("",!0)])])),b(l.$slots,"default")])}}});export{J as _};
