(window.webpackJsonp=window.webpackJsonp||[]).push([[41],{1568:function(e,n,t){"use strict";t.r(n),t.d(n,"default",(function(){return F}));var o=t(130),r=t.n(o),c=t(132),a=t.n(c),i=t(120),s=t.n(i),l=t(124),u=t(128),d=t(138),f=t(237),b=t(642),m=t(336),p=t(312),O=t(402);var g=t(918),v=t(126),j=t.n(v);var C=t(911);var h=t(167),T=t(205);function y(e,n,t){const o=Object(i.useRef)(null),[r,c]=Object(i.useState)(e),a=Object(i.useCallback)((()=>{o.current&&(o.current.innerHTML=""),null==t||t()}),[o,t]),s=Object(i.useCallback)((e=>{c(e),null==n||n(e)}),[n]),l=!Object(h.b)("MessageComposerInput.ctrlEnterToSend"),u=Object(i.useCallback)((e=>{if(e.target instanceof HTMLDivElement){const n=l?e.target.innerHTML:e.target.innerHTML.replace(/<div><br><\/div>/g,"\n").replace(/<div>/g,"\n").replace(/<\/div>/g,"");s(n)}}),[s,l]),d=Object(i.useCallback)((e=>{if(e.key===T.b.ENTER){const n=T.a?e.metaKey:e.ctrlKey;l&&!e.shiftKey&&(e.preventDefault(),e.stopPropagation(),a()),!l&&n&&(e.preventDefault(),e.stopPropagation(),a())}}),[l,a]);return{ref:o,onInput:u,onPaste:u,onKeyDown:d,content:r,setContent:s}}var R=t(910),E=t(927);function k(e){let{className:n,disabled:t=!1,onSend:o,onChange:r,children:c,placeholder:a,initialContent:l,leftComponent:u,rightComponent:d}=e;const{ref:f,onInput:b,onPaste:m,onKeyDown:p,content:g,setContent:v}=y(l,r,o),h=function(e,n){return Object(i.useMemo)((()=>({clear:()=>{e.current&&(e.current.innerHTML="")},insertText:t=>{const o=document.getSelection();if(e.current&&o){const r=e.current.innerHTML,{anchorOffset:c,focusOffset:a}=o;e.current.innerHTML=`${r.slice(0,c)}${t}${r.slice(a)}`,Object(O.d)({anchorNode:e.current.firstChild,anchorOffset:c+t.length,focusNode:e.current.firstChild,focusOffset:a+t.length,isForward:!0}),n(e.current.innerHTML)}}})),[e,n])}(f,v);!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1?arguments[1]:void 0;Object(i.useEffect)((()=>{n.current&&(n.current.innerText=e)}),[n,e])}(l,f),Object(R.a)(t,f);const{isFocused:T,onFocus:k}=Object(C.a)(),w=!g&&a||void 0;return s.a.createElement("div",{"data-testid":"PlainTextComposer",className:j()(n,{[`${n}-focused`]:T}),onFocus:k,onBlur:k,onInput:b,onPaste:m,onKeyDown:p},s.a.createElement(E.a,{ref:f,disabled:t,leftComponent:u,rightComponent:d,placeholder:w}),null==c?void 0:c(f,h))}var w=t(266),M=t(898);function P(e){let{menuPosition:n}=e;const t=Object(d.c)();return s.a.createElement(M.a,{menuPosition:n,addEmoji:e=>(l.a.dispatch({action:u.a.ComposerInsert,text:e,timelineRenderingType:t.timelineRenderingType}),!0)})}const x=["isRichTextEnabled","e2eStatus","menuPosition","eventRelation"],S=Object(i.forwardRef)((function(e,n){let{disabled:t=!1,composerFunctions:o}=e;return function(e,n,t){const o=Object(d.c)(),r=Object(p.c)(),c=Object(i.useRef)(null),a=Object(i.useCallback)((a=>{var i;if(e||null==n||!n.current)return;const s=null!==(i=a.context)&&void 0!==i?i:d.a.Room;switch(a.action){case"reply_to_event":case u.a.FocusSendMessageComposer:Object(b.a)(n,s,o,c);break;case u.a.ClearAndFocusSendMessageComposer:if(a.timelineRenderingType!==o.timelineRenderingType)break;t.clear(),Object(b.a)(n,s,o,c);break;case u.a.ComposerInsert:if(a.timelineRenderingType!==o.timelineRenderingType)break;if(a.composerType!==m.a.Send)break;a.userId||a.event||a.text&&Object(O.d)(r.selection).then((()=>t.insertText(a.text)))}}),[e,n,o,t,r]);Object(f.a)(l.a,a)}(t,n,o),null}));function F(e){let{isRichTextEnabled:n,e2eStatus:t,menuPosition:o,eventRelation:c}=e,l=a()(e,x);const u=n?g.a:k,d=Object(i.useRef)(Object(p.b)({eventRelation:c}));return s.a.createElement(p.a.Provider,{value:d.current},s.a.createElement(u,r()({className:"mx_SendWysiwygComposer",leftComponent:t&&s.a.createElement(w.b,{status:t}),rightComponent:s.a.createElement(P,{menuPosition:o})},l),((e,n)=>s.a.createElement(S,{disabled:l.disabled,ref:e,composerFunctions:n}))))}}}]);
//# sourceMappingURL=41.js.map