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