Liferay.Loader.define("data-engine-js-components-web@1.0.79/js/core/utils/sectionAddedHandler",["module","exports","require","../../utils/FormSupport.es","../../utils/constants","../../utils/fieldSets","../../utils/fieldSupport","../../utils/settingsContext","../../utils/visitors.es","./fieldDeletedHandler"],(function(e,t,i){var d;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i("../../utils/FormSupport.es"),r=i("../../utils/constants"),l=i("../../utils/fieldSets"),s=i("../../utils/fieldSupport"),a=i("../../utils/settingsContext"),o=i("../../utils/visitors.es"),u=(d=i("./fieldDeletedHandler"))&&d.__esModule?d:{default:d};function p(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(e);t&&(d=d.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,d)}return i}function f(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?p(Object(i),!0).forEach((function(t){c(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):p(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function c(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const e=({field:e,indexes:t,nestedField:i,props:d})=>{const r=(0,n.addFieldToColumn)([{rows:e.rows}],t.pageIndex,t.rowIndex,t.columnIndex,i.fieldName),l=[...e.nestedFields,i];e=(0,a.updateField)(d,e,"nestedFields",l);const{rows:s}=r[t.pageIndex];return f(f({},e=(0,a.updateField)(d,e,"rows",s)),{},{nestedFields:l,rows:s})};var m=(t,i,d)=>{var a;const{data:p,indexes:c}=d,{fieldName:m,parentFieldName:g}=p,{pages:F}=i,{defaultLanguageId:w,editingLanguageId:b,fieldNameGenerator:y,portletNamespace:O}=t,{fieldType:N,skipFieldNameGeneration:j,useFieldName:v}=d,x=null!==(a=d.newField)&&void 0!==a?a:(0,s.createField)({defaultLanguageId:w,editingLanguageId:b,fieldNameGenerator:y,fieldType:N,portletNamespace:O,skipFieldNameGeneration:j,useFieldName:v}),I=(0,n.findFieldByFieldName)(F,m),P=(0,l.createFieldSet)(t,d,[I,x]),S=new o.PagesVisitor(F);let D;return D=I.type===r.FIELD_TYPE_FIELDSET?(0,s.addFieldToPage)(f(f({},t),{},{indexes:{columnIndex:0,pageIndex:0,rowIndex:I.rows.length},newField:x,pages:F,parentFieldName:I.fieldName})):g?S.mapFields((d=>{if(d.fieldName===g){const d=(0,n.findFieldByFieldName)((0,u.default)(t,i,{fieldName:m,removeEmptyRows:!1}).pages,g);return e({field:d,indexes:f(f({},c),{},{pageIndex:0}),nestedField:P,props:t})}return d}),!1,!0):S.mapFields((e=>e.fieldName===m?P:e)),{focusedField:x,pages:D}};t.default=m}}));
//# sourceMappingURL=sectionAddedHandler.js.map