"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 a=require("../RealTimeSidebarContext.js"),u=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(a),p=q.onAppSettingChange,g=q.appSettings,I=q.assetKey,h=q.realTimeTypes,C=q.setting,_=q.handleChangeParamToEdit,x=u(),v=function(s){var o;p("rtValuesSetting",e.__assign(e.__assign({},g.rtValuesSetting),((o={})[I]=s,o)))},f=o.useState(d),k=f[0],S=f[1];return o.useEffect((function(){S(d)}),[d]),s.jsx(t,e.__assign({open:m,onClose:j,title:"Add/Edit Real-Time Parameter",size:r.isMobileDetected?"extraLarge":"medium",actions:s.jsxs(s.Fragment,{children:[s.jsx(c,e.__assign({color:"primary",classes:{root:x.cancelButton},onClick:j},{children:"Cancel"})),d&&s.jsx(c,e.__assign({color:"primary",onClick:function(){var e=C.filter((function(e){return e!==d}));v(e),_(""),j()}},{children:"Delete"})),s.jsx(c,e.__assign({classes:{root:x.saveButton},variation:"primary",onClick:function(){var s;if(d)s=C.map((function(e){return e===d?k:e}));else{if(C.find((function(e){return e===k})))return void j();s=e.__spreadArray([k],C,!0)}s=n.uniq(s),v(s),_(""),j()},disabled:!k},{children:"Save"}))]})},{children:s.jsxs(i.FormControl,e.__assign({classes:{root:x.selectFormControl},"data-testid":"addEditRealTimeParameterDropdown"},{children:[s.jsx(i.InputLabel,e.__assign({htmlFor:"parameter"},{children:"Parameter"})),s.jsx(i.Select,e.__assign({value:k||"",inputProps:{name:"parameter",id:"parameter"},onChange:function(e){S(String(e.target.value))}},{children:h.map((function(o){return s.jsx(i.MenuItem,e.__assign({"data-testid":"".concat(o.key,"_menuItem"),value:o.key,disabled:C.includes(o.key)},{children:o.name}),o.key)}))}))]}))}))}));module.exports=l;
