import o from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import{useState as i,memo as r}from"react";import t from"prop-types";import n from"classnames";import{sortableHandle as a,SortableElement as s}from"react-sortable-hoc";import{makeStyles as l,Tooltip as p,IconButton as d}from"@material-ui/core";import m from"@material-ui/icons/DragIndicator";import u from"./Component.js";import{BHA_FAMILY as c}from"../../../../constants/bha.js";import{jsx as b,jsxs as f}from"react/jsx-runtime";var g=l((function(o){return{sortableComponent:{position:"relative","&:hover":{"& $dragIndicatorButton":{visibility:"visible"}},zIndex:"99999999 !important",background:function(e){return e.isSortable&&o.palette.background.b5},boxShadow:function(o){return o.isSortable&&"0px 0px 6px rgba(0, 0, 0, 0.5)"}},topComponent:{marginTop:"16px"},bottomComponent:{marginBottom:"8px"},dragInidicationHidden:{"&:hover":{"& $dragIndicatorButton":{visibility:"hidden"}}},dragIndicatorWrapper:{position:"absolute",left:function(o){return o.isMobile?"8px":0},top:function(o){return o.isMobile?"20px":"8px"}},dragIndicatorButton:{visibility:function(o){return o.isMobile?"visible":"hidden"},padding:"8px",background:function(e){return e.isMobile?"none":o.palette.background.b9},"&:hover":{background:o.palette.background.b7,"& $dragIndicatorIcon":{color:o.palette.primary.text1}}},dragIndicatorIcon:{cursor:"pointer",color:o.palette.primary.text6,fontSize:"16px"}}})),v=a((function(o){var e=o.isMobile,i=g({isMobile:e});return b("div",{className:i.dragIndicatorWrapper,children:b(p,{title:e?"":"Click & Drag to reorder",children:b(d,{className:i.dragIndicatorButton,children:b(m,{className:i.dragIndicatorIcon})})})})})),C=s((function(r){var t,a=r.isActualBha,s=r.component,l=r.isTopComponent,p=r.isLastCompnent,d=r.isSortable,m=r.sortableIndex,C=r.validate,h=r.onDelete,R=r.onSave,x=r.isMobile,I=r.viewColumnsPerRow,q=r.editColumnsPerRow,M=r.onAutocompleteApplied,w=g({isMobile:x,isSortable:d}),y=i(!1),A=e(y,2),S=A[0],B=A[1];return f("div",{className:n(w.sortableComponent,(t={},o(t,w.topComponent,!x&&l),o(t,w.bottomComponent,!x&&p),o(t,w.dragInidicationHidden,!d&&-1!==m),t)),children:[s.family!==c.bit&&!S&&b(v,{isMobile:x}),b(u,{isMobile:x,isActualBha:a,viewColumnsPerRow:I,editColumnsPerRow:q,component:s,validate:C,onSave:R,onDelete:h,onChangeEditing:B,onAutocompleteApplied:M,isDragComponent:-1!==m})]})}));C.propTypes={isActualBha:t.bool.isRequired,isMobile:t.bool.isRequired,component:t.shape({}).isRequired,isTopComponent:t.bool.isRequired,isLastCompnent:t.bool.isRequired,isSortable:t.bool.isRequired,sortableIndex:t.number.isRequired,validate:t.func.isRequired,onDelete:t.func.isRequired,onSave:t.func.isRequired,viewColumnsPerRow:t.number.isRequired,editColumnsPerRow:t.number.isRequired,onAutocompleteApplied:t.func.isRequired};var h=r(C);export{h as default};
//# sourceMappingURL=SortableComponent.js.map
