import{r as i,c as t,h as n,H as o}from"./p-a0569a5f.js";let e=class{constructor(n){i(this,n),this.change=t(this,"change",7),this.getParentValue=()=>this.value||new Array(this.field.minCount).fill(void 0)}componentWillLoad(){1!==this.field.maxCount&&(this.subFormKeys=this.getParentValue().map((()=>`${Math.random()}`)))}render(){const{field:i,errors:t,subFormKeys:e,value:r}=this,s=t&&t.length>0?t[0]:void 0;if(1===i.maxCount){const t=i.fields.map((i=>Object.assign(Object.assign({},i),{value:(r||{})[i.id]})));return n(o,null,n("div",{class:{"form-container":!0,separated:i.separated}},n("doldurma-form",{fields:t,layout:i.layout,onChange:i=>{i.stopImmediatePropagation(),this.change.emit(i.detail)}})),n("div",null,s))}const a=this.getParentValue();return n(o,null,a.map(((t,o)=>{const r=t?i.fields.map((i=>Object.assign(Object.assign({},i),{value:t[i.id]}))):i.fields;return n("div",{key:e[o],class:{"form-container":!0,separated:i.separated}},n("doldurma-form",{fields:r,layout:i.layout,onChange:i=>{i.stopImmediatePropagation();const t=[...a];t[o]=i.detail,this.change.emit(t)}}),a.length>i.minCount&&n("dvn-button",{class:"remove-input-button",shape:"circle",scale:"x-small",tint:"danger",leaned:!0,onClick:i=>{i.stopImmediatePropagation(),this.subFormKeys=e.filter(((i,t)=>t!==o)),this.change.emit(a.filter(((i,t)=>t!==o)))}},n("i",{class:"uil uil-minus"})))})),a.length<i.maxCount&&n("dvn-button",{class:"add-input-button",shape:"circle",view:"flat",scale:"small",leaned:!0,onClick:i=>{i.stopImmediatePropagation(),this.subFormKeys=[...e,`${Math.random()}`],this.change.emit([...a,void 0])}},n("i",{class:"uil uil-plus"})),n("div",null,s))}};e.style="dvn-field-input-sub-form{display:block}dvn-field-input-sub-form .form-container{margin-top:calc(4 * var(--spacing-unit));position:relative}dvn-field-input-sub-form .form-container.separated{border:1px solid var(--color-border);padding:calc(4 * var(--spacing-unit));border-radius:var(--corner-radius)}dvn-field-input-sub-form .form-container .remove-input-button i,dvn-field-input-sub-form .form-container .add-input-button i{line-height:1rem}dvn-field-input-sub-form .form-container .remove-input-button{position:absolute;top:6px;left:-8px}dvn-field-input-sub-form doldurma-form{--form-min-height:0px}";export{e as dvn_field_input_sub_form}