import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import{useRef as n,useState as o}from"react";import a from"moment";import r from"classnames";import{makeStyles as i,Grid as s,Typography as c}from"@material-ui/core";import{getUnitDisplay as l}from"../../../../utils/index.js";import m from"../../../Modal/Modal.js";import p from"../../../PostInput/PostInput.js";import d from"../../../IconButton/index.js";import{Regular14 as u}from"../../../Typography.js";import f from"../../../Icons/SendIcon.js";import{isSuggestionsListOpened as h}from"../../../UserMention/utils/index.js";import{MENTION_STYLE as g}from"../../../../constants/feed.js";import{jsxs as y,jsx as b}from"react/jsx-runtime";function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function x(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?v(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}var N=i((function(t){return{postInput:{paddingBottom:8},filePreviewWrapper:{width:"100%",marginLeft:0,maxHeight:251},modal:{maxWidth:450,width:"100vw"},actionsAdornment:{flex:1},info:{marginTop:16},text:{color:t.palette.primary.text6},value:{color:t.palette.primary.text1},inputMain:{marginBottom:0,fontSize:"11px",color:t.palette.primary.text8},inputHelper:{display:"flex",paddingRight:5},cancelText:{cursor:"pointer"},highlightedLabel:{color:t.palette.primary.main},modalActions:{paddingTop:16},actions:{height:36},sendRow:{display:"flex"},sendIcon:{"&.Mui-disabled":{cursor:"not-allowed!important"}}}}));function j(t){var i=t.feedItem.context,v=i.id,j=i.lessons_learned,w=j.attachment,O=j.timestamp,C=j.data,P=j.data,I=P.description,M=P.cause,B=P.section,D=P.activity,E=P.md_start,S=P.tvd_start,T=t.onClose,H=t.onSave,F=t.userCompanyId,_=N(),k=n(),A=o({body:I,attachment:w}),L=e(A,2),W=L[0],R=L[1],K=function(){H({context:{id:v,lessons_learned:{attachment:W.attachment,data:x(x({},C),{},{description:W.body})}}})};return y(m,{open:!0,onClose:T,title:"Edit Comment",contentClassName:_.modal,actionsClassName:_.modalActions,onClick:function(t){t.stopPropagation()},actions:y(s,{container:!0,direction:"row",justify:"space-between",alignItems:"center",className:_.actions,children:[b(s,{item:!0,children:b(c,{variant:"caption",className:r(_.inputMain,_.cancelText,_.highlightedLabel),"data-testid":"".concat("EditComment","_cancel"),component:"div",gutterBottom:!0,onClick:T,children:"Cancel"})}),y(s,{item:!0,direction:"row",alignItems:"center",className:_.sendRow,children:[y(c,{variant:"caption",className:r(_.inputMain,_.inputHelper),component:"div",gutterBottom:!0,children:["Press ",b(c,{variant:"caption",color:"primary",className:r(_.inputMain,_.highlightedLabel),children:"Enter"})," to send"]}),b(d,{onClick:K,className:_.sendIcon,"data-testid":"".concat("EditComment","_send"),disabled:!W||!W.body&&!W.attachment,children:b(f,{})})]})]}),ref:k,children:[b(p,{initialValue:{body:I,attachment:w},userCompanyId:F,onChange:R,filePreviewWrapperClass:_.filePreviewWrapper,className:_.postInput,onKeyDown:function(t){"Enter"!==t.key||t.shiftKey||h()||(t.preventDefault(),K())},mentionStyle:g,suggestionsPortalHost:k.current,allowSuggestionsAboveCursor:!0}),y("div",{className:_.info,children:[O&&y(u,{className:_.text,gutterBottom:!0,children:["Time:"," ",b("span",{className:_.value,children:a(O).format("MM/DD/YY, HH:mm")})," "]}),M&&y(u,{className:_.text,gutterBottom:!0,children:["Event Cause: ",b("span",{className:_.value,children:M})]}),(Number.isFinite(E)||Number.isFinite(S))&&y(u,{className:_.text,gutterBottom:!0,children:["MD/TVD:"," ",y("span",{className:_.value,children:[Number.isFinite(E)?"".concat(E.fixFloat(2),"  ").concat(l("length")):"-","/",Number.isFinite(S)?"".concat(S.fixFloat(2),"  ").concat(l("length")):"-"]})]}),B&&y(u,{className:_.text,gutterBottom:!0,children:["Hole Section: ",b("span",{className:_.value,children:B})]}),D&&y(u,{className:_.text,gutterBottom:!0,children:["Operation: ",b("span",{className:_.value,children:D})]})]})]})}export{j as default};
