import{memo as e}from"react";import{shape as t,bool as n,string as l,arrayOf as i,func as a}from"prop-types";import{makeStyles as c,useTheme as o,Tooltip as r,Checkbox as s}from"@material-ui/core";import{ExpandMore as d}from"@material-ui/icons";import m from"./NumberCircle.js";import{jsxs as p,jsx as h}from"react/jsx-runtime";var u=c({sectionContainer:{display:"flex",width:"100%",justifyContent:"space-between",marginRight:"4px",alignItems:"center"},itemLabel:{display:"flex",alignItems:"center","&:hover":{color:"#DADADA",cursor:"pointer"}},disabledItemLabel:{display:"flex",alignItems:"center","&:hover":{cursor:"pointer"}},itemLabelToggle:{},sectionName:{marginLeft:"6px",marginRight:"10px"},checkbox:{width:"11px",height:"11px"},sectionTitle:{display:"flex",alignItems:"center"},expandIcon:{fontSize:"14px",marginRight:"8px"}});function f(e){return(e.wells.filter((function(e){return e.checked}))||[]).length}function x(e){var t=f(e);return t===e.wells.length?"".concat(t):"".concat(t," of ").concat(e.wells.length," Selected")}function g(e){return e.wells.filter((function(e){return e.checked})).length>0}function b(e){return e.wells.filter((function(e){return e.checked})).length!==e.wells.length}function C(e){var t=e.section,n=e.disabled,l=e.onExpandCollapse,i=e.onSelectAll,a=e.onClearAll,c=u(),C=o(),k=function(e){e.stopPropagation(),!b(t)&&a&&a(t),b(t)&&i&&i(t)};return p("div",{"data-testid":"".concat("SectionItem","_section_").concat(t.name),className:c.sectionContainer,children:[p("div",{className:n?c.disabledItemLabel:c.itemLabel,onClick:function(){return l&&l(t)},children:[h(r,{title:"No Wells",placement:"right",children:p("div",{className:c.sectionTitle,children:[n&&h(d,{className:c.expandIcon}),p("span",{className:c.sectionName,children:[" ",t.name]})]})}),f(t)>0&&h(m,{"data-testid":"".concat("SectionItem","_wellsNumber"),bgColor:C.palette.primary.text9,textColor:"#fff",width:20+6*(x(t).length-2),children:x(t)})]}),g(t)?h(s,{"data-testid":"".concat("SectionItem","_checkbox"),className:c.checkbox,size:"small",checked:!0,indeterminate:b(t),color:"primary",onClick:k,disabled:n}):h(s,{"data-testid":"".concat("SectionItem","_checkbox"),className:c.checkbox,checked:!1,size:"small",color:"primary",onClick:k,indeterminate:!1,disabled:n})]})}C.propTypes={section:t({expanded:n,name:l,wells:i(t({}))}).isRequired,disabled:n,onExpandCollapse:a,onSelectAll:a,onClearAll:a},C.defaultProps={disabled:!1,onSelectAll:null,onExpandCollapse:null,onClearAll:null};var k=e(C);export{k as default};
