import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/toConsumableArray";import{memo as t,Fragment as o}from"react";import i from"classnames";import n from"prop-types";import{IconButton as a,Grid as s}from"@material-ui/core";import l from"@material-ui/icons/Add";import c from"@material-ui/icons/Delete";import"../shared/CancelButton.js";import"../shared/ExpandCollapseButton.js";import"../shared/FormatedNumber.js";import{InputText as u}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{getUnitPreference as f,getUnitDisplay as h}from"../../../../../utils/index.js";import{jsxs as b,jsx as g}from"react/jsx-runtime";function j(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 y(r){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?j(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):j(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function z(t){var n,j=t.data,z=t.errors,O=t.isEditing,v=t.onChange,N=p({isMobile:d}),C=z||[],P="in"===f("shortLength")?"".concat(h("shortLength"),"/32"):"".concat(h("shortLength")),x=function(e){return function(){v([].concat(r(j.slice(0,e)),r(j.slice(e+1))))}},S=function(r){return function(t,o){var i=j.map((function(i,n){return n===r?y(y({},i),{},e({},t,o)):i}));v(i)}};return 0!==j.length||O?b("div",{className:N.subGroup,children:[b("div",{className:i(N.subTitle,e({},N.subTitleEditing,O)),children:["Nozzle Sizes",O&&g(a,{"data-not-migrated-muiiconbutton":!0,className:N.addButton,onClick:function(){v([].concat(r(j),[{size:null,count:null}]))},children:g(l,{className:N.addIcon,color:"primary"})})]}),g(s,{container:!0,spacing:2,className:i(N.detailedView,(n={},e(n,N.detailedViewMobile,d),e(n,N.eidtorNozzleView,O),n)),children:j.map((function(r,t){return b(o,{children:[O?g(u,{type:"count",label:"# of this size",value:r.count,error:C[t]&&C[t].count,xs:d?5:4,onChangeField:S(t)}):g(m,{label:"# of this size",value:r.count,xs:6}),O?g(u,{type:"size",label:"Nozzle Size (".concat(P,")"),value:r.size,error:C[t]&&C[t].size,xs:d?5:4,onChangeField:S(t)}):g(m,{label:"Nozzle Size",unit:"shortLength",value:r.size,xs:6}),O&&g(s,{item:!0,xs:d?2:4,className:e({},N.cellInnerMobile,d),children:g(a,{"data-not-migrated-muiiconbutton":!0,className:N.addButton,onClick:x(t),children:g(c,{className:N.addIcon})})})]},t)}))})]}):null}z.propTypes={isEditing:n.bool.isRequired,data:n.arrayOf(n.shape({count:n.number,size:n.number})),errors:n.arrayOf(n.shape({count:n.string,size:n.string})),onChange:n.func},z.defaultProps={data:[],errors:[],onChange:null};var O=t(z);export{O as default};
