"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),n=require("prop-types"),r=require("react"),l=require("@material-ui/core"),a=require("classnames"),s=require("lodash"),o=require("./PostInput.css.js"),i=require("../FilePreview/index.js"),u=require("../FailedFileUploading.js"),d=require("../UserMention/index.js"),p=require("../FileUploadIconButton.js"),c=require("../EmojiIconButton.js"),f=require("react/jsx-runtime");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=m(e),h=m(t),j=m(n),v=m(a),w=function(e){var t=e.className,n=e.userCompanyId,a=e.onChange,s=e.onKeyDown,m=e.initialValue,j=e.filePreviewWrapperClass,w=e.smallerView,y=e.suggestionsPortalHost,b=e.allowSuggestionsAboveCursor,x=r.useState(m.body),P=h.default(x,2),q=P[0],C=P[1],F=r.useState(m.attachment),I=h.default(F,2),S=I[0],A=I[1],T=r.useState(null),N=h.default(T,2),D=N[0],U=N[1],V=r.useRef(null);return r.useEffect((function(){V.current&&(V.current.selectionStart=V.current.value.length)}),[]),r.useEffect((function(){a({body:q,attachment:S})}),[q,S]),f.jsxs("div",{className:v.default(o.input,t),children:[f.jsx(l.TextField,{"data-testid":"".concat("PostInput","_input"),className:v.default(o.inputTextField,g.default({},o.inputTextFieldSmaller,w)),placeholder:"Add Comment...",FormHelperTextProps:{component:"div",margin:"dense"},inputRef:V,InputProps:{inputComponent:d,inputProps:{onChange:C,value:q,withLightTheme:!1,companyId:n,autoFocus:!0,className:o.inputInput,placeholder:"Type here...",suggestionsPortalHost:y,allowSuggestionsAboveCursor:b},endAdornment:f.jsxs(l.InputAdornment,{position:"end",className:v.default(o.inputAdornment,g.default({},o.inputAdornmentSmaller,w)),children:[!S&&f.jsx("div",{children:f.jsx(p.default,{openPreviewDialogOnUpload:!1,onFinish:function(e,t,n){A({url:e,file_name:t,size:n})},onError:U})}),f.jsx("div",{children:f.jsx(c,{"data-testid":"".concat("PostInput","_emoji"),handleSelectEmoji:function(e){return C((function(t){return"".concat(t).concat(e.native)}))}})})]}),disableUnderline:!0,classes:{}},onKeyDown:s}),S&&f.jsx(i,{fileName:S.file_name||S.name,fileUrl:S.signed_url||S.url,handleFileDelete:function(){return A(null)},classes:{wrapper:j}}),D&&f.jsx(u,{errorMessage:D})]})};w.propTypes={userCompanyId:j.default.oneOfType([j.default.string,j.default.number]).isRequired,className:j.default.string,onKeyDown:j.default.func,onChange:j.default.func,initialValue:j.default.shape({body:j.default.string,attachment:j.default.shape({})}),filePreviewWrapperClass:j.default.string,suggestionsPortalHost:j.default.node,allowSuggestionsAboveCursor:j.default.bool,smallerView:j.default.bool},w.defaultProps={className:null,initialValue:{body:"",attachment:null},filePreviewWrapperClass:null,onKeyDown:s.noop,onChange:s.noop,smallerView:!1,suggestionsPortalHost:void 0,allowSuggestionsAboveCursor:!1},module.exports=w;
//# sourceMappingURL=PostInput.js.map
