function c(n,i){for(const{db:a,id:o}of i){const d=n.db?.modelDefined?.[o],p=n.db?.isMapped?.[o],l=n.db?.[a];d===void 0&&l===void 0||n.setComponent(o,s=>{d!==void 0&&(s.modelDefined=d),p!==void 0&&n.util.isSelectComponent(s)&&(s.isMapped=p),l!==void 0&&(s.value=l)})}}const v=n=>({$:i,e:a})=>{i.setThisComponent(o=>{o.value=a}),i.setDb(o=>{o[n]=a})},b=({$:n,componentId:i,dbKey:a,fields:o,mapFieldKey:d,mapFieldValue:p})=>{const l=n.db?.[a]||[],s=new Map(l.map(e=>[e[0].value,e])),u=[],m=[];o?.forEach(e=>{const t=s.get(e.value);if(t&&s.delete(e.value),!e.required){t&&(t[0].disabled=!1,m.push(t));return}if(t){t[0].disabled=!0,u.push(t);return}u.push([{disabled:!0,name:d,value:e.value},{name:p,required:!0,value:[]}])});const r=[...u,...m];if(s.size)for(const e of s.values())e[0].disabled=!1,r.push(e);const f=u.length?Array.from({length:u.length},(e,t)=>t):[];return n.setComponent(i,e=>{n.util.isRepeaterFieldComponent(e)&&(e.value=r,e.nonRemovableRows=f)}),n.setDb(e=>{e[a]=r,e.nonRemovableRows=f}),{repeaterValue:r,requiredFieldIndexes:f}};export{b as a,v as h,c as s};
