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