import e from"@babel/runtime/helpers/toConsumableArray";import t from"@babel/runtime/helpers/defineProperty";import{memo as n}from"react";import{string as r,arrayOf as o,shape as i,func as a}from"prop-types";import c from"classnames";import{makeStyles as l,Typography as s,Accordion as d,AccordionSummary as m,AccordionDetails as p,List as u}from"@material-ui/core";import{ExpandMore as f}from"@material-ui/icons";import h from"./AssetSearch.js";import w from"./SectionItem.js";import y from"./WellListItem.js";import"../../../../utils/index.js";import{jsxs as x,jsx as b}from"react/jsx-runtime";import{showSuccessNotification as g}from"../../../../utils/notificationToasts.js";function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?v(Object(r),!0).forEach((function(n){t(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var j=l((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 O(t){var n=t.company,r=t.wellSections,o=t.getWellName,i=t.onChangeWellSections,a=t.onExploreMode,l=j(),v=function(e,t){var n=r.find((function(t){return t.name===e.name})).wells.map((function(e){return e.id})),o=r.map((function(e){var r=e.wells.map((function(e){return n.includes(e.id)?S(S({},e),{},{checked:t}):S({},e)}));return S(S({},e),{},{wells:r})}));i(o)},O=function(e){var t=r.map((function(t){return t.name===e.name?S(S({},t),{},{expanded:!t.expanded}):t}));i(t)},C=function(e){var t=r.map((function(t){var n=t.wells.map((function(t){return t.id===e.id?S(S({},t),{},{checked:!t.checked}):t}));return S(S({},t),{},{wells:n})}));i(t)},N=function(e){v(e,!0)},I=function(e){v(e,!1)};return x("div",{className:l.content,children:[x("div",{className:l.searchContainer,children:[b(h,{company:+n,onClickAsset:function(t,n){var o=r.map((function(r){if("Search Results"===r.name){var o=e(r.wells);return r.wells.find((function(e){return e.id===t}))||o.push({id:t,checked:!0,name:n,kind:"manual"}),S(S({},r),{},{wells:o})}return S(S({},r),{},{wells:r.wells.map((function(e){return e.id===t?S(S({},e),{},{checked:!0}):e}))})}));i(o),g("Offset well successfully added!")},onExploreMode:a}),b(s,{"data-testid":"".concat("WellSection","_advancedSearch"),className:l.advancedSearch,onClick:function(){a()},children:"Advanced Search"})]}),(r||[]).map((function(e){return 0===e.wells.length?b("div",{className:c(l.sectionItem,l.disabledSectionItem),children:b(w,{section:e,disabled:!0})},"empty-".concat(e.name)):b("div",{className:l.sectionItem,children:x(d,{expanded:e.expanded,onChange:function(){return O(e)},children:[b(m,{expandIcon:b(f,{}),style:{width:"100%"},children:b(w,{section:e,onExpandCollapse:O,onSelectAll:N,onClearAll:I})}),b(p,{children:b(u,{dense:!0,className:l.wellList,children:e.wells.map((function(t){return b(y,{well:t,wellName:o(e.wells,t.id),rigName:t.rigName,onToggleWell:C},"well-".concat(e.name,"-").concat(t.id))}))})})]})},"section-".concat(e.name))}))]})}O.propTypes={company:r.isRequired,wellSections:o(i({})),getWellName:a.isRequired,onChangeWellSections:a.isRequired,onExploreMode:a.isRequired},O.defaultProps={wellSections:[]};var C=n(O);export{C as default};
//# sourceMappingURL=index.js.map
