"use strict";var e=require("@babel/runtime/helpers/toConsumableArray"),n=require("@babel/runtime/helpers/defineProperty"),t=require("react"),r=require("prop-types"),i=require("classnames"),a=require("@material-ui/core"),c=require("@material-ui/icons"),o=require("./AssetSearch.js"),l=require("./SectionItem.js"),s=require("./WellListItem.js");require("../../../../utils/index.js");var u=require("react/jsx-runtime"),d=require("../../../../utils/notificationToasts.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=p(e),f=p(n),h=p(i);function x(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function w(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?x(Object(t),!0).forEach((function(n){f.default(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):x(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var y=a.makeStyles((function(e){return{content:{width:"472px",marginTop:"24px"},sectionItem:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:"8px",fontSize:"12px",fontWeight:"normal",color:e.palette.primary.text6,borderTop:"1px solid ".concat(e.palette.primary.text8),"&:last-child":{borderBottom:"1px solid ".concat(e.palette.primary.text8)}},disabledSectionItem:{color:e.palette.primary.text8},wellList:{width:"100%",margin:0,padding:0},searchContainer:{display:"flex",justifyContent:"space-between",marginBottom:"24px",alignItems:"center"},advancedSearch:{fontSize:"14px",fontWeight:500,color:"#03BCD4",cursor:"pointer","&:hover":{textDecoration:"underline"}}}}));function j(e){var n=e.company,t=e.wellSections,r=e.getWellName,i=e.onChangeWellSections,p=e.onExploreMode,f=y(),x=function(e,n){var r=t.find((function(n){return n.name===e.name})).wells.map((function(e){return e.id})),a=t.map((function(e){var t=e.wells.map((function(e){return r.includes(e.id)?w(w({},e),{},{checked:n}):w({},e)}));return w(w({},e),{},{wells:t})}));i(a)},j=function(e){var n=t.map((function(n){return n.name===e.name?w(w({},n),{},{expanded:!n.expanded}):n}));i(n)},g=function(e){var n=t.map((function(n){var t=n.wells.map((function(n){return n.id===e.id?w(w({},n),{},{checked:!n.checked}):n}));return w(w({},n),{},{wells:t})}));i(n)},b=function(e){x(e,!0)},v=function(e){x(e,!1)};return u.jsxs("div",{className:f.content,children:[u.jsxs("div",{className:f.searchContainer,children:[u.jsx(o,{company:+n,onClickAsset:function(e,n){var r=t.map((function(t){if("Search Results"===t.name){var r=m.default(t.wells);return t.wells.find((function(n){return n.id===e}))||r.push({id:e,checked:!0,name:n,kind:"manual"}),w(w({},t),{},{wells:r})}return w(w({},t),{},{wells:t.wells.map((function(n){return n.id===e?w(w({},n),{},{checked:!0}):n}))})}));i(r),d.showSuccessNotification("Offset well successfully added!")},onExploreMode:p}),u.jsx(a.Typography,{"data-testid":"".concat("WellSection","_advancedSearch"),className:f.advancedSearch,onClick:function(){p()},children:"Advanced Search"})]}),(t||[]).map((function(e){return 0===e.wells.length?u.jsx("div",{className:h.default(f.sectionItem,f.disabledSectionItem),children:u.jsx(l,{section:e,disabled:!0})},"empty-".concat(e.name)):u.jsx("div",{className:f.sectionItem,children:u.jsxs(a.Accordion,{expanded:e.expanded,onChange:function(){return j(e)},children:[u.jsx(a.AccordionSummary,{expandIcon:u.jsx(c.ExpandMore,{}),style:{width:"100%"},children:u.jsx(l,{section:e,onExpandCollapse:j,onSelectAll:b,onClearAll:v})}),u.jsx(a.AccordionDetails,{children:u.jsx(a.List,{dense:!0,className:f.wellList,children:e.wells.map((function(n){return u.jsx(s,{well:n,wellName:r(e.wells,n.id),rigName:n.rigName,onToggleWell:g},"well-".concat(e.name,"-").concat(n.id))}))})})]})},"section-".concat(e.name))}))]})}j.propTypes={company:r.string.isRequired,wellSections:r.arrayOf(r.shape({})),getWellName:r.func.isRequired,onChangeWellSections:r.func.isRequired,onExploreMode:r.func.isRequired},j.defaultProps={wellSections:[]};var g=t.memo(j);module.exports=g;
//# sourceMappingURL=index.js.map
