Liferay.Loader.define("data-engine-js-components-web@1.0.87/js/core/reducers/dragAndDropReducer.es",["module","exports","require","../../utils/FormSupport.es","../../utils/constants","../../utils/fieldSupport","../../utils/settingsContext","../../utils/visitors.es","../actions/eventTypes.es","../utils/columnResizedHandler","../utils/sectionAddedHandler","./fieldEditableReducer.es"],(function(e,a,d){window;Object.defineProperty(a,"__esModule",{value:!0}),a.default=function dragAndDropReducer(e,a,d){switch(a.type){case s.EVENT_TYPES.DND.MOVE:{const{sourceFieldName:s,sourceFieldPage:r,targetFieldName:f,targetIndexes:m,targetParentFieldName:F}=a.payload,{activePage:p,availableLanguageIds:L,defaultLanguageId:N,editingLanguageId:c,pages:I,rules:E}=e,{fieldTypes:b,generateFieldNameUsingFieldLabel:y,getFieldNameGenerator:P}=d,v=P(I,y);let{sourceParentField:w}=a.payload;const R=(0,i.findFieldByFieldName)(I,s);if(w&&f&&w.fieldName===f)return e;let T=(0,o.deleteField)({defaultLanguageId:N,editingLanguageId:c,fieldName:s,fieldNameGenerator:v,fieldPage:r,generateFieldNameUsingFieldLabel:y,pages:I});if(w&&w.type===l.FIELD_TYPE_FIELDSET&&1===w.nestedFields.length){let e=w?w.fieldName:"";do{w&&(e=w.fieldName),w=(0,t.getParentField)(I,w.fieldName)}while(w&&w.type===l.FIELD_TYPE_FIELDSET&&w.fieldName!==F&&1===w.nestedFields.length);e&&e!==F&&(T=(0,o.deleteField)({defaultLanguageId:N,editingLanguageId:c,fieldName:e,fieldNameGenerator:v,fieldPage:r,generateFieldNameUsingFieldLabel:y,pages:I}))}if(f)return T=(0,o.deleteField)({clean:!0,defaultLanguageId:N,editingLanguageId:c,fieldName:s,fieldNameGenerator:v,fieldPage:r,generateFieldNameUsingFieldLabel:y,pages:I}),(0,u.default)({availableLanguageIds:L,defaultLanguageId:N,editingLanguageId:c,fieldNameGenerator:v,fieldTypes:b,generateFieldNameUsingFieldLabel:y},{activePage:p,pages:T,rules:E},{data:{fieldName:f,parentFieldName:F},indexes:m,newField:R});T=(0,t.addFieldToPage)({defaultLanguageId:N,editingLanguageId:c,fieldNameGenerator:v,generateFieldNameUsingFieldLabel:y,indexes:m,newField:R,pages:T,parentFieldName:F});const D=new g.PagesVisitor(T);return T=D.mapFields((e=>"grid"!==e.type&&e.rows?(0,n.updateField)({availableLanguageIds:L,defaultLanguageId:N,fieldNameGenerator:v,generateFieldNameUsingFieldLabel:y},e,"rows",(0,i.removeEmptyRows)([e],0)):e)),T[r].rows=(0,i.removeEmptyRows)(T,r),{pages:T}}case s.EVENT_TYPES.DND.RESIZE:{const{column:i,direction:l,loc:t}=a.payload,{defaultLanguageId:n,editingLanguageId:g,pages:s}=e,{generateFieldNameUsingFieldLabel:u,getFieldNameGenerator:o}=d,f=o(s,u);let m=[...s];return(0,r.getColumn)(s,t)&&(m="left"===l?(0,r.handleResizeLeft)({defaultLanguageId:n,editingLanguageId:g,fieldNameGenerator:f,generateFieldNameUsingFieldLabel:u},{pages:s},t,i):(0,r.handleResizeRight)({defaultLanguageId:n,editingLanguageId:g,fieldNameGenerator:f,generateFieldNameUsingFieldLabel:u},{pages:s},t,i+1)),{pages:m}}default:return e}};var i=d("../../utils/FormSupport.es"),l=d("../../utils/constants"),t=d("../../utils/fieldSupport"),n=d("../../utils/settingsContext"),g=d("../../utils/visitors.es"),s=d("../actions/eventTypes.es"),r=d("../utils/columnResizedHandler"),u=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(d("../utils/sectionAddedHandler")),o=d("./fieldEditableReducer.es")}));
//# sourceMappingURL=dragAndDropReducer.es.js.map