"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5384],{35384:(e,n,t)=>{t.r(n),t.d(n,{default:()=>E});var a=t(95155),r=t(94271),s=t(92749),l=t(32532),i=t(12115),o=t(7373);t(72246);let u=(0,i.forwardRef)(function(e,n){let{equation:t,setEquation:r,inline:s}=e,l=e=>{r(e.target.value)};return s&&n instanceof HTMLInputElement?(0,a.jsxs)("span",{className:"EquationEditor_inputBackground",children:[(0,a.jsx)("span",{className:"EquationEditor_dollarSign",children:"$"}),(0,a.jsx)("input",{className:"EquationEditor_inlineEditor",value:t,onChange:l,autoFocus:!0,ref:n}),(0,a.jsx)("span",{className:"EquationEditor_dollarSign",children:"$"})]}):(0,a.jsxs)("div",{className:"EquationEditor_inputBackground",children:[(0,a.jsx)("span",{className:"EquationEditor_dollarSign",children:"$$\n"}),(0,a.jsx)("textarea",{className:"EquationEditor_blockEditor",value:t,onChange:l,ref:n}),(0,a.jsx)("span",{className:"EquationEditor_dollarSign",children:"\n$$"})]})});var c=t(17735),d=t(52034);function E(e){let{equation:n,inline:t,nodeKey:E}=e,[f]=(0,r.DF)(),[m,g]=(0,i.useState)(n),[h,p]=(0,i.useState)(!1),x=(0,i.useRef)(null),_=(0,i.useCallback)(e=>{p(!1),f.update(()=>{let n=(0,l.nsf)(E);(0,d.R_)(n)&&(n.setEquation(m),e&&n.selectNext(0,0))})},[f,m,E]);return(0,i.useEffect)(()=>{h||m===n||g(n)},[h,n,m]),(0,i.useEffect)(()=>h?(0,s.Sd)(f.registerCommand(l.MvL,e=>{let n=document.activeElement;return x.current!==n&&_(),!1},l.WgU),f.registerCommand(l.Q$N,e=>{let n=document.activeElement;return x.current===n&&(_(!0),!0)},l.WgU)):f.registerUpdateListener(e=>{let{editorState:n}=e;n.read(()=>{let e=(0,l.vJq)();return(0,l.RTZ)(e)&&e.has(E)&&1===e.getNodes().length})&&p(!0)}),[f,E,_,h]),(0,a.jsx)(a.Fragment,{children:h?(0,a.jsx)(u,{equation:m,setEquation:g,inline:t,ref:x}):(0,a.jsx)(o.ErrorBoundary,{onError:e=>f._onError(e),fallback:null,children:(0,a.jsx)(c.A,{equation:m,inline:t,onDoubleClick:()=>p(!0)})})})}}}]);