(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[5592],{43982:(e,t,n)=>{"use strict";n.d(t,{useProperty:()=>a});var o=n(50959);const a=e=>{const[t,n]=(0,o.useState)(e.value());return(0,o.useEffect)((()=>{const t=e=>{n(e.value())};t(e);const o={};return e.subscribe(o,t),()=>e.unsubscribe(o,t)}),[e]),t}},77975:(e,t,n)=>{"use strict";n.d(t,{useWatchedValueReadonly:()=>a});var o=n(50959);const a=(e,t=!1,n=[])=>{const a="watchedValue"in e?e.watchedValue:void 0,u="defaultValue"in e?e.defaultValue:e.watchedValue.value(),[r,i]=(0,o.useState)(a?a.value():u);return(t?o.useLayoutEffect:o.useEffect)((()=>{if(a){i(a.value());const e=e=>i(e);return a.subscribe(e),()=>a.unsubscribe(e)}return()=>{}}),[a,...n]),r}},29185:(e,t,n)=>{"use strict";n.d(t,{useWatchedValue:()=>a});var o=n(50959);const a=(e,t=[])=>{const[n,a]=(0,o.useState)(e.value());return(0,o.useEffect)((()=>{const t=e=>a(e);return e.subscribe(t),()=>e.unsubscribe(t)}),[e,...t]),[n,t=>e.setValue(t)]}},49023:e=>{e.exports={padding:"2",textArea:"textArea-pBDekXDd"}},44847:(e,t,n)=>{"use strict";n.r(t),n.d(t,{closeChartEditorText:()=>_,updateChartEditorText:()=>g});var o=n(50959),a=n(32227),u=n(50151),r=n(26867),i=n(77975),c=n(29185),s=n(43982),l=n(68335),d=n(43337),f=n(49023);const v=parseInt(f.padding);var h;!function(e){e[e.Hotkey=0]="Hotkey",e[e.Blur=1]="Blur"}(h||(h={}));const b=new Map([["10b_2",.15],["10bi_2",.15],["12_3",.8],["12b_2",.5],["12bi_2",.45],["14b_2",.65],["14bi_2",.65],["16_2.5",.8],["16b_2",.8],["16bi_2",.75],["16b_2.5",.8],["16bi_2.5",.75],["16bi_3",.65],["20_2",1],["20b_2",.8],["20bi_2",.75],["20bi_3",.55],["20_2.5",.25],["20_3",.8],["24_2.5",.95],["24_3",.95],["28_2",1.4],["28_2.5",1.38],["28_3",1.38],["32_2",1.6],["32_2.5",1.6],["32_3",1.6]]),p=new d.Property(!1);function x(e){const{text:t,wordWrap:n=p,textInfo:a,placeholder:d,forbidLineBreaks:h,maxLength:x,onClose:_,onSelectionChange:g,onContextMenu:m}=e,[E,w]=(0,c.useWatchedValue)(t),S=(0,s.useProperty)(n),y=(0,i.useWatchedValueReadonly)({watchedValue:a}),{font:C,fontSize:V,textLeft:M,textTop:R,textBottom:k,textRight:L,textAlign:P,centerRotation:A,lineSpacing:B}=(0,u.ensureNotNull)((0,u.ensureDefined)(y)),D=Math.ceil(L-M)+1,W=Math.ceil(k-R);let N,F,H=0;void 0===A||0===A.angle?(N=Math.round(R),F=Math.round(M)):(F=A.x-D/2,N=A.y-W/2,H=A.angle);const T=C.includes("bold")?"b":"",I=C.includes("italic")?"i":"",$=devicePixelRatio<=2||devicePixelRatio>=3?devicePixelRatio:devicePixelRatio<2.5?2:2.5,q=b.get(V+T+I+"_"+$),z=(0,o.useRef)(null),[K,U]=(0,o.useState)(!0),X=(0,o.useMemo)((()=>performance.now()),[]);return(0,o.useEffect)((()=>{const e=()=>{const e=z.current;e&&g({start:e.selectionStart,end:e.selectionEnd})};return document.addEventListener("mousemove",e),document.addEventListener("touchmove",e),e(),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("touchmove",e)}}),[]),o.createElement("textarea",{ref:z,placeholder:d,style:{width:D+2*v,height:W+2*v,top:N-v,left:F-v,font:C,lineHeight:`${V+B}px`,textAlign:P,letterSpacing:S?q+"px":"normal",
rotate:H?`${H}rad`:void 0},maxLength:x,className:f.textArea,"data-name":"text-editor","data-qa-id":"inplace-text-editor",value:E,onClick:e=>j(e),onMouseDown:e=>function(e){U(!1),j(e)}(e),onMouseUp:e=>function(e){if(K)return void U(!1);j(e)}(e),onChange:function(e){w(e.target.value),g({start:e.target.selectionStart,end:e.target.selectionEnd})},onFocus:e=>function(e){const t=E.length;e.setSelectionRange(t,t)}(e.target),onBlur:()=>_(1),onKeyDown:function(e){const t=(0,l.hashFromEvent)(e);(27===t||h&&13===t)&&_(0)},onSelect:function(e){const t=e.target;g({start:t.selectionStart,end:t.selectionEnd})},onContextMenu:async function(e){if(!m)return;(0,r.preventDefault)(e),m(e)},autoFocus:!0});function j(e){performance.now()-X>500&&e.stopPropagation()}}function _(e){a.unmountComponentAtNode(e)}function g(e,t){a.render(o.createElement(x,{...t}),e)}}}]);