Liferay.Loader.define("data-engine-js-components-web@1.0.89/js/utils/fieldSets",["module","exports","require","./FormSupport.es","./constants","./fieldSupport","./settingsContext","./visitors.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.createFieldSet=function createFieldSet(e,t,r,n=[{columns:[{fields:[],size:12}]}]){const{defaultLanguageId:s,editingLanguageId:d,fieldNameGenerator:a,fieldTypes:l,portletNamespace:p}=e,{skipFieldNameGeneration:c,useFieldName:u}=t,f=(0,i.createField)({defaultLanguageId:s,editingLanguageId:d,fieldNameGenerator:a,fieldType:l.find((({name:e})=>e===o.FIELD_TYPE_FIELDSET)),portletNamespace:p,skipFieldNameGeneration:c,useFieldName:u});return addNestedFields({field:_objectSpread(_objectSpread({},f),{},{rows:n,style:{}}),indexes:{columnIndex:0,pageIndex:0,rowIndex:0},nestedFields:r,props:e})};var n=r("./FormSupport.es"),o=r("./constants"),i=r("./fieldSupport"),s=r("./settingsContext"),d=r("./visitors.es");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}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 addNestedFields=({field:e,indexes:t,nestedFields:r,props:o})=>{let a=[{rows:e.rows}];new d.PagesVisitor(a).mapFields(((e,t,o,i,s)=>{r.some((t=>t.fieldName===e.fieldName))||(a=(0,n.removeFields)(a,s,i,o))})),[...r].reverse().forEach((e=>{e.instanceId||(e.instanceId=(0,i.generateInstanceId)()),a=(0,n.addFieldToColumn)(a,t.pageIndex,t.rowIndex,t.columnIndex,e.fieldName)})),e=(0,s.updateField)(o,e,"nestedFields",r);const{rows:l}=a[t.pageIndex];return _objectSpread(_objectSpread({},(0,s.updateField)(o,e,"rows",l)),{},{nestedFields:r,rows:l})}}}));
//# sourceMappingURL=fieldSets.js.map