import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/toConsumableArray";import{memo as t,Fragment as o}from"react";import s from"classnames";import i from"prop-types";import{IconButton as a,Grid as n}from"@material-ui/core";import l from"@material-ui/icons/Add";import u from"@material-ui/icons/Delete";import"../shared/CancelButton.js";import"../shared/ExpandCollapseButton.js";import"../shared/FormatedNumber.js";import{InputText as c}from"../shared/InputText.js";import"../shared/MoreButton.js";import"../shared/SaveButton.js";import"../shared/SelectField.js";import{StaticField as m}from"../shared/StaticField.js";import"../shared/SharedEditorElements.js";import"../shared/ConfirmationPopup.js";import{useStyles as p}from"../sharedStyles.js";import{isMobileDetected as d}from"../../../../../utils/mobileDetect.js";import{jsxs as f,jsx as b}from"react/jsx-runtime";function h(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function j(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?h(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):h(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function g(t){var i,h=t.data,g=t.title,y=t.errors,w=t.isEditing,O=t.onChange,v=p({isMobile:d,isEditing:w}),P=y||[],_=function(e){return function(){O([].concat(r(h.slice(0,e)),r(h.slice(e+1))))}},C=function(r){return function(t,o){var s=h.map((function(s,i){return i===r?j(j({},s),{},e({},t,o)):s}));O(s)}};return 0!==h.length||w?f("div",{className:v.subGroup,children:[f("div",{className:s(v.subTitle,e({},v.subTitleEditing,w)),children:[g,w&&b(a,{"data-not-migrated-muiiconbutton":!0,className:v.addButton,onClick:function(){O([].concat(r(h),[{flow_rate:null,pressure_loss:null}]))},children:b(l,{className:v.addIcon,color:"primary"})})]}),b(n,{container:!0,spacing:2,className:s(v.detailedView,(i={},e(i,v.detailedViewMobile,d),e(i,v.eidtorNozzleView,w),i)),children:h.map((function(r,t){return f(o,{children:[w?b(c,{type:"flow_rate",label:"Flow Rate",unit:"volumeFlowRate",value:r.flow_rate,error:P[t]&&P[t].flow_rate,xs:d?5:4,onChangeField:C(t)}):b(m,{label:"Flow Rate",unit:"volumeFlowRate",value:r.flow_rate,xs:6}),w?b(c,{type:"pressure_loss",label:"Pressure Loss",unit:"pressure",value:r.pressure_loss,error:P[t]&&P[t].pressure_loss,xs:d?5:4,onChangeField:C(t)}):b(m,{label:"Pressure Loss",unit:"pressure",value:r.pressure_loss,xs:6}),w&&b(n,{item:!0,xs:d?2:4,className:e({},v.cellInnerMobile,d),children:b(a,{"data-not-migrated-muiiconbutton":!0,className:v.addButton,onClick:_(t),children:b(u,{className:v.addIcon})})})]},t)}))})]}):null}g.propTypes={isEditing:i.bool.isRequired,title:i.string,data:i.arrayOf(i.shape({flow_rate:i.number,pressure_loss:i.number})),errors:i.arrayOf(i.shape({flow_rate:i.string,pressure_loss:i.string})),onChange:i.func},g.defaultProps={title:"Pressure Loss",data:[],errors:[],onChange:null};var y=t(g);export{y as default};
