import{router as I}from"./vendor/inertia-CR4tWtMT.js";import{n as K,g as L,d as B}from"./registry-DyIszw9-.js";import{b as x,c as C,_ as O,a as S}from"./CardContent.vue_vue_type_script_setup_true_lang-DPd7KJ8I.js";import{_ as T}from"./CardDescription.vue_vue_type_script_setup_true_lang-Ds2CuvUf.js";import{_ as j}from"./CardFooter.vue_vue_type_script_setup_true_lang-N61eYvGN.js";import{_ as F}from"./DynamicField.vue_vue_type_script_setup_true_lang-DYH52Q2k.js";import{_ as M,a as P,b as Q,c as W}from"./TabsContent.vue_vue_type_script_setup_true_lang-Dy9mVg3Z.js";import{d as q,r as $,aT as l,W as m,Q as r,bK as a,a3 as u,a2 as n,bh as o,u as y,F as v,b2 as p,U as N,O as z}from"./vendor-reka-Edfq1EPl.js";import"./Input.vue_vue_type_script_setup_true_lang-D6nVx0lb.js";const A={class:"space-y-4"},le=q({__name:"Index",props:{sections:{}},setup(i){var E;const{t:f}=K(),D=L(),_=i,c=$(Object.fromEntries(_.sections.map(t=>[t.key,{...t.values}]))),d=$(Object.fromEntries(_.sections.map(t=>[t.key,!1]))),b=$(Object.fromEntries(_.sections.map(t=>[t.key,{}])));function h(t){d.value[t.key]=!0,I.put(`/${D}/settings`,{section:t.key,...c.value[t.key]},{onFinish:()=>{d.value[t.key]=!1},onError:g=>{b.value[t.key]=g},onSuccess:()=>{b.value[t.key]={}}})}const U=$(((E=_.sections[0])==null?void 0:E.key)??""),w=z(()=>_.sections.length>1);return(t,g)=>(l(),m("div",A,[i.sections.length===0?(l(),r(C,{key:0},{default:a(()=>[u(x,{class:"py-12 text-center text-muted-foreground"},{default:a(()=>[n(o(y(f)("builder.settings.no_settings")),1)]),_:1})]),_:1})):w.value?(l(),r(W,{key:2,modelValue:U.value,"onUpdate:modelValue":g[0]||(g[0]=e=>U.value=e)},{default:a(()=>[u(M,null,{default:a(()=>[(l(!0),m(v,null,p(i.sections,e=>(l(),r(P,{key:e.key,value:e.key},{default:a(()=>[n(o(e.label),1)]),_:2},1032,["value"]))),128))]),_:1}),(l(!0),m(v,null,p(i.sections,e=>(l(),r(Q,{key:e.key,value:e.key},{default:a(()=>[u(C,null,{default:a(()=>[u(O,null,{default:a(()=>[u(S,null,{default:a(()=>[n(o(e.label),1)]),_:2},1024),e.description?(l(),r(T,{key:0},{default:a(()=>[n(o(e.description),1)]),_:2},1024)):N("",!0)]),_:2},1024),u(x,{class:"space-y-4"},{default:a(()=>[(l(!0),m(v,null,p(e.fields,s=>{var k;return l(),r(F,{key:s.name,field:s,"model-value":c.value[e.key][s.name],error:(k=b.value[e.key])==null?void 0:k[s.name],"onUpdate:modelValue":V=>c.value[e.key][s.name]=V},null,8,["field","model-value","error","onUpdate:modelValue"])}),128))]),_:2},1024),u(j,null,{default:a(()=>[u(B,{disabled:d.value[e.key],onClick:s=>h(e)},{default:a(()=>[n(o(d.value[e.key]?y(f)("builder.settings.saving"):y(f)("builder.settings.save")),1)]),_:2},1032,["disabled","onClick"])]),_:2},1024)]),_:2},1024)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])):(l(!0),m(v,{key:1},p(i.sections,e=>(l(),r(C,{key:e.key},{default:a(()=>[u(O,null,{default:a(()=>[u(S,null,{default:a(()=>[n(o(e.label),1)]),_:2},1024),e.description?(l(),r(T,{key:0},{default:a(()=>[n(o(e.description),1)]),_:2},1024)):N("",!0)]),_:2},1024),u(x,{class:"space-y-4"},{default:a(()=>[(l(!0),m(v,null,p(e.fields,s=>{var k;return l(),r(F,{key:s.name,field:s,"model-value":c.value[e.key][s.name],error:(k=b.value[e.key])==null?void 0:k[s.name],"onUpdate:modelValue":V=>c.value[e.key][s.name]=V},null,8,["field","model-value","error","onUpdate:modelValue"])}),128))]),_:2},1024),u(j,null,{default:a(()=>[u(B,{disabled:d.value[e.key],onClick:s=>h(e)},{default:a(()=>[n(o(d.value[e.key]?y(f)("builder.settings.saving"):y(f)("builder.settings.save")),1)]),_:2},1032,["disabled","onClick"])]),_:2},1024)]),_:2},1024))),128))]))}});export{le as default};
