import{d as x,ar as j,r as B,bn as d,bo as g,aa as I,by as K,bq as p,bu as D,bz as O,a9 as E,h as N,bC as P,br as U,A as y}from"./preload-helper.BAt0wiQU.js";import{a as $,l as z,_ as A}from"../apps/settings/index.DetZ7Cvo.js";import{_ as L}from"./LeadCaptureRecommended.vue_vue_type_style_index_0_lang.qe6Nvn6K.js";const G=x({__name:"DynamicComponents",props:{sectionParent:{type:String,required:!0},sectionChild:{type:String,required:!0},sectionKey:{type:String,required:!0}},emits:["fieldData"],setup(C,{emit:k}){const S=C,{sectionParent:i,sectionChild:s,sectionKey:F}=j(S),f=$.settings;let _=null;typeof f.controls[i.value][s.value]<"u"&&f.controls[i.value][s.value]!==null&&(_=f.controls[i.value][s.value][F.value]);const u=y(_),r=B({controls:u.value}),e=y([]),c=k,h=y([]);typeof u.value<"u"&&u.value!==null&&(r.controls=u.value.filter(t=>typeof t.hide<"u"&&t.hide?!1:(typeof e.value[t.id]<"u"&&(t.default=e.value[t.id]),!0)));const V=t=>{Object.entries(t).forEach(([a,n])=>{e.value[a]=n}),c("fieldData",e.value)},q=(t,a)=>{const n=t;a.type==="checkbox"&&(n.target.value=n.target.checked),e.value[a.id]=n.target.value,c("fieldData",e.value)},b=t=>{let a="",n="";for(const[l,o]of Object.entries(t)){let v=o;a=l,n=v}r.controls=u.value.filter(l=>{if(typeof l.condition<"u"){const o=l.condition.find(v=>v.key===a);return o.value==="yes"&&n==="yes"||o.value==="no"&&n==="no"?(typeof e.value[l.id]<"u"&&(l.default=e.value[l.id]),!0):!1}else return typeof e.value[l.id]<"u"&&(l.default=e.value[l.id]),!0}),h.value[a]=n,e.value[a]=n,c("fieldData",e.value)},w=t=>{r.controls=u.value.filter(a=>typeof a.hide<"u"&&a.hide!==null&&a.hide?!1:(typeof e.value[a.id]<"u"&&e.value[a.id]!==null&&(a.default=e.value[a.id]),!0))};return(t,a)=>(d(!0),g(I,null,K(r.controls,(n,l)=>(d(),g("div",{key:l},[(d(),p(P,null,{fallback:D(()=>[N(A)]),default:D(()=>[(d(),p(O(E(z)(n.type)),{params:n,"conditional-values":h.value,onInput:o=>q(o,n),onFieldData:V,onConditionalData:b,onSelectedCondition:b,onFieldUpdatedData:w},null,40,["params","conditional-values","onInput"]))]),_:2},1024)),n.show_lead_upgrade!=null&&n.show_lead_upgrade?(d(),p(L,{key:0})):U("",!0)]))),128))}});export{G as _};
