"use strict";var e=require("@babel/runtime/helpers/defineProperty"),o=require("@babel/runtime/helpers/slicedToArray"),n=require("react"),t=require("classnames"),r=require("prop-types"),i=require("lodash"),l=require("../BHACasingEmptyView/BHACasingEmptyView.js"),s=require("./components/Header.js"),u=require("./components/Component.js"),a=require("./components/SortableComponents.js"),d=require("./BhaComponentsTable.css.js"),c=require("react/jsx-runtime");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=f(e),m=f(o),C=f(t),v=f(r);function q(e){var o=e.isActualBha,t=e.viewColumnsPerRow,r=e.editColumnsPerRow,f=e.components,v=e.draftComponent,q=e.validate,A=e.onSort,R=e.onAdd,b=e.onDelete,w=e.onSave,j=e.onCancel,x=e.isMobile,h=e.onAutocompleteApplied,y=n.useState(-1),S=m.default(y,2),P=S[0],B=S[1],M=n.useState(!1),g=m.default(M,2),D=g[0],E=g[1],H=n.useRef(null),T=n.useMemo((function(){return!(f&&!i.isEmpty(f)||v)}),[f,v]);return c.jsxs("div",{className:d.container,children:[T?c.jsx(l,{type:"BHA",onAdd:R}):c.jsxs("div",{className:C.default(d.drilistringContent,p.default({},d.contentMobile,x)),ref:H,onScroll:function(){H.current&&E(!!H.current.scrollTop)},children:[!x&&c.jsx(s,{}),c.jsxs("div",{children:[v&&c.jsx(u,{isMobile:x,isActualBha:o,viewColumnsPerRow:t,editColumnsPerRow:r,component:v,isDraft:!0,validate:q,onCancel:j,onSave:w,onAutocompleteApplied:h}),c.jsx(a,{useDragHandle:!0,lockAxis:"y",lockToContainerEdges:!0,isActualBha:o,components:f,sortableIndex:P,validate:q,onSaveComponent:w,onDeleteComponent:b,onSortEnd:function(e,o){B(-1),A(e,o)},onSortStart:function(e){B(e.index)},isMobile:x,viewColumnsPerRow:t,editColumnsPerRow:r,onAutocompleteApplied:h})]})]}),c.jsx("div",{className:C.default(d.topGradient,p.default({},d.visible,D)),style:{top:x?0:50}}),c.jsx("div",{className:d.bottomGradient})]})}q.propTypes={isActualBha:v.default.bool.isRequired,viewColumnsPerRow:v.default.oneOf([1,2,3,4,6]),editColumnsPerRow:v.default.oneOf([1,2,3,4,6]),components:v.default.arrayOf(v.default.shape({})),draftComponent:v.default.arrayOf(v.default.shape({})),validate:v.default.func.isRequired,onSort:v.default.func.isRequired,onAdd:v.default.func.isRequired,onDelete:v.default.func.isRequired,onSave:v.default.func.isRequired,onCancel:v.default.func.isRequired,isMobile:v.default.bool.isRequired,onAutocompleteApplied:v.default.func.isRequired},q.defaultProps={viewColumnsPerRow:3,editColumnsPerRow:3,components:null,draftComponent:null},module.exports=q;
//# sourceMappingURL=BHAComponentsTable.js.map
