import r from"@babel/runtime/helpers/slicedToArray";import{useMemo as e,useState as t,useRef as n,useEffect as o}from"react";import{makeStyles as a}from"@material-ui/core";import{convertStringToEditorValue as i,getUpdatedHtmlValue as u,setCaret as p,getCaret as c,convertEditorValueToString as s}from"./utils.js";import{jsx as l}from"react/jsx-runtime";var m=a((function(){return{customTextarea:{display:"flex",flexWrap:"wrap",alignItems:"center",width:"442px",maxWidth:"442px",minHeight:"90px",overflowWrap:"anywhere",whiteSpace:"normal",margin:"-8px 0",padding:function(r){return r.isEmptyValue?"31px 24px 24px 16px":"16px 24px 16px 16px"},fontSize:"16px",lineHeight:"24px",borderRadius:"8px",outline:"0px",border:function(r){var e=r.color;return"1px solid ".concat(e)}}}})),x=function(a){var x=a.initFormula,f=a.cursorPos,d=a.color,g=a.suggestions,h=a.isValueUpdated,y=a.setIsValueUpdated,v=a.onChange,T=e((function(){return i(x,g)}),[x,g]),b=t(T),w=r(b,2),H=w[0],I=w[1],V=e((function(){return u(H)}),[H]),E=r(V,2),L=E[0],M=E[1],S=n(),W=n(!1),j=m({color:d,isEmptyValue:M});return o((function(){h&&(W.current=!0,I(T),y(!1))}),[T,h]),o((function(){p(S.current,f),W.current&&S.current.focus()}),[L]),l("span",{ref:S,contentEditable:!0,onInput:function(r){var e=c(S.current);I(r.target.innerHTML),v(s(r.target.innerHTML,g),e)},onKeyPress:function(r){13===r.charCode&&r.preventDefault()},className:j.customTextarea,dangerouslySetInnerHTML:{__html:L}})};export{x as default,m as useStyles};
//# sourceMappingURL=FormulaTextEditor.js.map
