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