import{C as e,E as t,Mt as n,Qt as r,W as i,X as a,Y as o,_ as s,c,ct as l,dt as u,g as d,h as f,m as p,tn as m,v as h,w as g}from"./vendor/json-editor-vue-eojr4v24.js";import{P as _}from"./client-nwyjxodt.js";import{t as v}from"./nicon-m1crov2l.js";import{t as y}from"./nbutton-gygn07c2.js";import{t as b}from"./ntext-input-e8iut2en.js";import{t as x}from"./nselect-gyaplrph.js";import{t as S}from"./ncheckbox-ep01n5y1.js";var C={p4:``,flex:`~ col gap-4`},w={key:1,ml2:``,flex:``},T=[`value`],E={key:0,flex:``,"gap-4":``},D=t({__name:`ServerRouteInputs`,props:{modelValue:{},keys:{default:()=>[]},default:{default:()=>({})},disabled:{type:Boolean,default:!1}},setup(t,{emit:D}){let O=t,k=D,A=/^\d{4}-\d{2}-\d{2}$/,j=/^\d{2}:\d{2}$/,M=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/,N=_(O,`modelValue`,k,{passive:!0}),P=p(()=>[...O.keys,`active`,`key`,`value`,`type`]),F=p(()=>{let e={};for(let t of P.value)e[t]=O.default[t]||``;return e}),I=[`string`,`number`,`boolean`,`file`,`date`,`time`,`datetime-local`];function L(e,t){let n=t.target;if(n.files&&n.files[0]){let t=n.files[0],r=new FileReader;r.readAsDataURL(t),r.onload=()=>{N.value[e].value=r.result}}}return l(()=>N,e=>{e.value.forEach(e=>{if(e.type===`number`&&typeof e.value!=`number`){let 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`&&!A.test(e.value)?e.value=new Date().toISOString().slice(0,10):e.type===`time`&&typeof e.value==`string`&&!j.test(e.value)?e.value=new Date().toISOString().slice(11,16):e.type===`datetime-local`&&typeof e.value==`string`&&!M.test(e.value)?e.value=new Date().toISOString().slice(0,16):e.type===`string`&&(e.value=e.value.toString())})},{deep:!0,immediate:!0,flush:`sync`}),(l,p)=>{let _=S,D=b,O=x,k=v,A=y;return i(),h(`div`,C,[(i(!0),h(c,null,o(n(N),(e,p)=>(i(),h(`div`,{key:p,flex:`~ gap-2`,"justify-around":``},[a(l.$slots,`input`,{item:e}),(i(!0),h(c,null,o(P.value,n=>(i(),h(c,{key:n},[e.type!==null&&n===`active`?(i(),d(_,{key:0,modelValue:e[n],"onUpdate:modelValue":t=>e[n]=t,n:`sm primary`,disabled:t.disabled},null,8,[`modelValue`,`onUpdate:modelValue`,`disabled`])):s(``,!0),e.type!==null&&n===`key`?(i(),d(D,{key:1,modelValue:e[n],"onUpdate:modelValue":t=>e[n]=t,placeholder:n,"flex-1":``,"font-mono":``,n:`sm primary`,disabled:t.disabled,class:r(t.disabled?`op50`:``)},null,8,[`modelValue`,`onUpdate:modelValue`,`placeholder`,`disabled`,`class`])):n===`value`?(i(),h(c,{key:2},[e.type===`file`?(i(),d(D,{key:0,type:`file`,disabled:t.disabled,class:r(t.disabled?`op75`:``),onChange:e=>L(p,e)},null,8,[`disabled`,`class`,`onChange`])):e.type===`boolean`?(i(),h(`div`,w,[g(_,{modelValue:e.value,"onUpdate:modelValue":t=>e.value=t,placeholder:`Value`,n:`green lg`,disabled:t.disabled},null,8,[`modelValue`,`onUpdate:modelValue`,`disabled`])])):(i(),d(D,{key:2,modelValue:e.value,"onUpdate:modelValue":t=>e.value=t,type:e.type,placeholder:`Value`,"flex-1":``,"font-mono":``,n:`sm primary`,disabled:t.disabled,class:r(t.disabled?`op75`:``)},null,8,[`modelValue`,`onUpdate:modelValue`,`type`,`disabled`,`class`]))],64)):n===`type`?(i(),d(O,{key:3,modelValue:e.type,"onUpdate:modelValue":t=>e.type=t,n:`sm green`,class:r(t.disabled?`op75`:``),disabled:t.disabled},{default:u(()=>[(i(),h(c,null,o(I,e=>f(`option`,{key:e,value:e},m(e),9,T)),64))]),_:1},8,[`modelValue`,`onUpdate:modelValue`,`class`,`disabled`])):s(``,!0)],64))),128)),a(l.$slots,`input-actions`,{},()=>[g(A,{n:`red`,disabled:t.disabled,class:r(t.disabled?`op0!`:``),onClick:e=>n(N).splice(p,1)},{default:u(()=>[g(k,{icon:`carbon:trash-can`})]),_:1},8,[`disabled`,`class`,`onClick`])])]))),128)),t.disabled?s(``,!0):(i(),h(`div`,E,[a(l.$slots,`actions`,{params:n(N)},()=>[g(A,{icon:`carbon-add`,n:`sm primary`,my1:``,"px-3":``,onClick:p[0]||=e=>n(N).push({...F.value})},{default:u(()=>[...p[2]||=[e(` Add `,-1)]]),_:1}),p[4]||=f(`div`,{"flex-auto":``},null,-1),n(N).length?(i(),d(A,{key:0,icon:`carbon-trash-can`,n:`sm red`,my1:``,"px-3":``,onClick:p[1]||=e=>n(N).splice(0,n(N).length)},{default:u(()=>[...p[3]||=[e(` Remove All `,-1)]]),_:1})):s(``,!0)])])),a(l.$slots,`default`)])}}}),O=Object.assign(D,{__name:`ServerRouteInputs`});export{O as t};