"use strict";var e=require('./../../../ext-esm/tslib/tslib.es6.js'),s=require("react/jsx-runtime"),o=require("react"),n=require("lodash"),i=require("@material-ui/core"),r=require("../../../utils/mobileDetect.js"),t=require("../../Modal/Modal.js"),c=require("../../Button/components/Button/index.js");require("moment-timezone"),require("classnames"),require("../../../icons/WithCustomSize.js"),require("../../../icons/IconParkProvider.js"),require("../../../icons/customIcons/icons/AddMessage.js"),require("../../../icons/customIcons/icons/Attention.js"),require("../../../icons/customIcons/icons/Collapse.js"),require("../../../icons/customIcons/icons/Dashboard.js"),require("../../../icons/customIcons/icons/Expand.js"),require("../../../icons/customIcons/icons/FolderClosed.js"),require("../../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../../icons/customIcons/icons/FolderOpened.js"),require("../../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../../icons/customIcons/icons/LessOrEqual.js"),require("../../../icons/customIcons/icons/Search.js"),require("../../../icons/customIcons/icons/Wellhub.js"),require("../../../icons/customIcons/icons/MultiRuler.js"),require("../../../icons/customIcons/icons/Checkbox.js"),require("../../../icons/customIcons/icons/CheckboxChecked.js"),require("../../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../../icons/customIcons/icons/Radio.js"),require("../../../icons/customIcons/icons/RadioChecked.js"),require("../../../icons/customIcons/icons/SimulFrac.js"),require("../../../icons/customIcons/icons/ZipperFrac.js"),require("../../../icons/customIcons/icons/CautionFilled.js"),require("../../../icons/customIcons/icons/MoreApp.js"),require("../../Button/components/LiveButton/components/LiveButtonStateIndicator/index.js"),require("../../Button/components/LiveButton/styles.js");var u=require("../RealTimeSidebarContext.js"),a=i.makeStyles({selectFormControl:{width:"80%",marginRight:"1rem"},cancelButton:{margin:"0 16px 0 auto"},saveButton:{marginLeft:16}});var l=o.memo((function(l){var m=l.isDialogOpen,d=l.paramToEdit,j=l.handleCloseRealTimeDialog,q=o.useContext(u),p=q.onAppSettingChange,I=q.appSettings,h=q.assetKey,C=q.realTimeTypes,g=q.setting,x=q.handleChangeParamToEdit,v=a(),f=function(s){var o;p("rtValuesSetting",e.__assign(e.__assign({},I.rtValuesSetting),((o={})[h]=s,o)))},k=o.useState(d),S=k[0],b=k[1];return o.useEffect((function(){b(d)}),[d]),s.jsx(t,{open:m,onClose:j,title:"Add/Edit Real-Time Parameter",size:r.isMobileDetected?"extraLarge":"medium",actions:s.jsxs(s.Fragment,{children:[s.jsx(c,{color:"primary",classes:{root:v.cancelButton},onClick:j,children:"Cancel"}),d&&s.jsx(c,{color:"primary",onClick:function(){var e=g.filter((function(e){return e!==d}));f(e),x(""),j()},children:"Delete"}),s.jsx(c,{classes:{root:v.saveButton},variation:"primary",onClick:function(){var s;if(d)s=g.map((function(e){return e===d?S:e}));else{if(g.find((function(e){return e===S})))return void j();s=e.__spreadArray([S],g,!0)}s=n.uniq(s),f(s),x(""),j()},disabled:!S,children:"Save"})]}),children:s.jsxs(i.FormControl,{classes:{root:v.selectFormControl},"data-testid":"addEditRealTimeParameterDropdown",children:[s.jsx(i.InputLabel,{htmlFor:"parameter",children:"Parameter"}),s.jsx(i.Select,{value:S||"",inputProps:{name:"parameter",id:"parameter"},onChange:function(e){b(String(e.target.value))},children:C.map((function(e){return s.jsx(i.MenuItem,{"data-testid":"".concat(e.key,"_menuItem"),value:e.key,disabled:g.includes(e.key),children:e.name},e.key)}))})]})})}));module.exports=l;
