"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[4013],{41928:(e,t,i)=>{i.d(t,{LineSourcePaneView:()=>S,anchorResizeCursorType:()=>_,createLineSourcePaneViewPoint:()=>g});var r=i(11284),o=i(85842),n=i(29968),s=i(83077),l=i(71367),a=i(8165),c=i(28031),d=i(61208);const h=r.colorsPalette["color-tv-blue-600"];var u,p;function _(e,t){const i=e.x-t.x,r=e.y-t.y;if(!Number.isFinite(i)||!Number.isFinite(r)||0===i&&0===r)return c.PaneCursorType.Default;let n=Math.atan2(r,i);return n<0&&(n+=2*Math.PI),n>=p.deg337_5||n=p.deg157_5&&n=p.deg22_5&&n=p.deg202_5&&n=p.deg67_5&&n=p.deg247_5&&n=p.deg112_5&&n=p.deg292_5&&n{const i=r[t],o=(0,a.lineSourcePaneViewPointToLineAnchorPoint)(e);return i&&(o.snappingPrice=i.price,o.snappingIndex=i.index),o}));e.append(this.createLineAnchor({...t,points:o},0))}createLineAnchor(e,t){const i=e.points.map((e=>e.point)),r=this._getOwnerSource();if(this.isLocked()){const o=this._getSelectionRenderer(t);return o.setData({bgColors:this._lineAnchorColors(i),points:e.points,visible:this.areAnchorsVisible(), hittestResult:s.HitTarget.Regular,ownerSourceId:r?.id(),barSpacing:this._model.timeScale().barSpacing()}),o}const o=(0,n.lastMouseOrTouchEventInfo)().isTouch,l=this._getLineAnchorRenderer(t),a=this.isHoveredSource()?this._model.lastHittestData()?.pointIndex??null:null;return l.setData({...e,color:this.anchorColor(),backgroundColors:this._lineAnchorColors(i),hoveredPointIndex:a,linePointBeingEdited:this.isBeingEdited()?this._model.linePointBeingEdited():null,radius:this._anchorRadius(),strokeWidth:o?u.TouchStrokeWidth:u.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:o?u.TouchSelectedStrokeWidth:u.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible(),clickHandler:e.clickHandler,ownerSourceId:r?.id()}),l}_getOwnerSource(){return this._ownerSource??this._source.ownerSource()}_anchorRadius(){return(0,n.lastMouseOrTouchEventInfo)().isTouch?u.TouchAnchorRadius:u.RegularAnchorRadius}_lineAnchorColors(e){const t=(0,o.ensureNotNull)(this._model.paneForSource(this._source)).height();return e.map((e=>this._model.backgroundColorAtYPercentFromTop(e.y/t)))}_updateImpl(e){this._points=[];this._model.timeScale().isEmpty()||this._validatePriceScale()&&(this._source.points().forEach(((e,t)=>{const i=this._source.pointToScreenPoint(e,this._ownerSource??void 0);i&&this._points.push(g(i,t))})),2===this._points.length&&(this._middlePoint=this._source.calcMiddlePoint(this._points[0],this._points[1])),this._invalidated=!1)}_validatePriceScale(){const e=this._getOwnerSource()?.priceScale();return null!=e&&!e.isEmpty()}_getSource(){return this._source}_getPoints(){return this._points}_getModel(){return this._model}_height(){const e=this._getOwnerSource()?.priceScale();return null!=e?e.height():0}_width(){return this._model.timeScale().width()}_needLabelExclusionPath(e,t){const i=this._source.properties().childs();return"middle"===(t??i.vertLabelsAlign.value())&&(0,d.needTextExclusionPath)(e)}_addAlertRenderer(e,t,i=this._source.properties().linecolor.value()){}_getAlertRenderer(e){return null}_getSelectionRenderer(e){for(;this._selectionRenderers.length<=e;)this._selectionRenderers.push(new l.SelectionRenderer);return this._selectionRenderers[e]}_getLineAnchorRenderer(e){for(;this._lineAnchorRenderers.length<=e;)this._lineAnchorRenderers.push(new a.LineAnchorRenderer);return this._lineAnchorRenderers[e]}}},19029:(e,t,i)=>{i.r(t),i.d(t,{LineToolPriceNote:()=>te});var r=i(85842),o=i(82014),n=i(11284),s=i(47097),l=i(95385),a=i(25432),c=i(33993),d=i(88483),h=i(93445),u=i(17567),p=i(86371);const _={intervalsVisibilities:{...d.intervalsVisibilitiesDefaults},horzLabelsAlign:l.HorizontalAlign.Center,vertLabelsAlign:l.VerticalAlign.Bottom,fontSize:14,bold:!1,italic:!1,priceLabelFontSize:12,priceLabelBold:!1,priceLabelItalic:!1},g=(0,n.getHexColorByName)("color-tv-blue-500"),S={lineColor:g,textColor:g,priceLabelBackgroundColor:g,priceLabelBorderColor:g,priceLabelTextColor:(0,n.getHexColorByName)("color-white")},P=new Map([[s.StdTheme.Light,S],[s.StdTheme.Dark,S]]),f=(0,h.extractThemedColors)((0, r.ensureDefined)(P.get(s.StdTheme.Light)),(0,r.ensureDefined)(P.get(s.StdTheme.Dark))),b=(0,h.extractAllPropertiesKeys)((0,r.ensureDefined)(P.get(s.StdTheme.Light))),x=(0,h.extractAllPropertiesKeys)(_),m=[...new Set([...b,...x,...a.commonLineToolPropertiesStateKeys,"text"])],T=[...new Set([...b,...x,"text"])];class v extends p.LineDataSourceProperty{constructor(e){super(e),this.hasChild("text")||this.addProperty("text",""),this.addChild("linesColors",new c.LineToolColorsProperty([(0,r.ensureDefined)(this.child("lineColor"))])),this.addChild("backgroundsColors",new c.LineToolColorsProperty([(0,r.ensureDefined)(this.child("priceLabelBackgroundColor"))])),this.addChild("textsColors",new c.LineToolColorsProperty([(0,r.ensureDefined)(this.child("priceLabelTextColor"))]))}static create(e,t){return new this({defaultName:"linetoolpricenote",factoryDefaultsSupplier:()=>(0,u.factoryDefaultsForCurrentTheme)(_,P),nonThemedDefaultsKeys:x,themedDefaultsKeys:b,allStateKeys:m,themedColors:f,templateKeys:T,replaceThemedColorsOnThemeChange:!0,state:t,theme:e})}}var C,L,R=i(9840),w=i(57415),y=i(99680),M=i(61208),A=i(41928),I=i(8165),k=i(17086),D=i(80140),z=i(91903),B=i(14491),H=i(29968),W=i(83077),N=i(51946),V=i(72244),E=i(52612);!function(e){e[e.Label=1]="Label"}(C||(C={})),function(e){e[e.Tolerance=3]="Tolerance",e[e.TouchTolerance=20]="TouchTolerance",e[e.LineWidth=1]="LineWidth",e[e.CircleRadius=2]="CircleRadius",e[e.CircleStrokeWidth=1]="CircleStrokeWidth",e[e.BackgroundRoundRect=4]="BackgroundRoundRect",e[e.PriceLabelFontSize=12]="PriceLabelFontSize",e[e.LabelVertPadding=6]="LabelVertPadding",e[e.LabelHorzPadding=8]="LabelHorzPadding"}(L||(L={}));class F{constructor(){this._data=null,this._priceLabelRenderer=new M.TextRenderer(void 0,new W.HitTestResult(W.HitTarget.MovePoint,{areaName:W.AreaName.Style,activeItem:1})),this._hittest=new W.HitTestResult(W.HitTarget.MovePoint,{areaName:W.AreaName.Style})}setData(e){this._data=e;const t=e.points[0],i=e.points[1],r=Math.round(180*Math.atan2(i.y-t.y,i.x-t.x)/Math.PI);this._priceLabelRenderer.setData({...(0,E.alignByAngle)(r),points:[i],text:e.text,color:e.textColor,font:B.CHART_FONT_FAMILY,fontSize:e.fontSize,bold:e.bold,italic:e.italic,offsetX:0,offsetY:0,borderColor:e.borderColor,borderWidth:1,backgroundColor:e.backgroundColor,backgroundRoundRect:4,boxPaddingVert:6,boxPaddingHorz:8})}setHitTest(e){this._hittest=e}draw(e,t){const i=this._data;if(null===i||i.points.length<2)return;e.save();const{horizontalPixelRatio:r,verticalPixelRatio:o}=t,n=Math.round(i.points[0].x*r),s=Math.round(i.points[0].y*o),l=Math.round(i.points[1].x*r),a=Math.round(i.points[1].y*o);e.lineCap="round",(0,N.setLineStyle)(e,D.LINESTYLE_SOLID),e.strokeStyle=i.lineColor,e.fillStyle=i.lineColor,e.lineWidth=Math.round(1*r);const c=(0,V.fillScaledRadius)(2,r);(0,N.createCircle)(e,n,s,c),e.fill(),void 0!==i.excludeBoundaries&&(e.save(),(0,z.addExclusionArea)(e,t,i.excludeBoundaries)),(0,N.drawLine)(e,n,s,l,a),void 0!==i.excludeBoundaries&&e.restore(),this._priceLabelRenderer.draw(e,t);const d=1*r ;e.strokeStyle=i.circleBorderColor,e.lineWidth=d;const h=c+d/2;(0,N.createCircle)(e,n,s,h),e.stroke(),e.restore()}hitTest(e){const t=this._data;if(null===t)return null;const i=(0,H.lastMouseOrTouchEventInfo)().isTouch?20:3;return(0,k.distanceToSegment)(t.points[0],t.points[1],e).distance<=i?this._hittest:this._priceLabelRenderer.hitTest(e)}}class O extends A.LineSourcePaneView{constructor(){super(...arguments),this._renderer=new y.CompositeRenderer,this._priceNoteRenderer=new F,this._customLabelRenderer=new M.TextRenderer}renderer(e){return this._invalidated&&this._updateImpl(e),this._renderer}_updateImpl(e){super._updateImpl(e),this._renderer.clear();const t=this._source.priceScale();if(!t||t.isEmpty())return;const i=this._points;if(i.length<2)return;const o=(0,r.ensureNotNull)(this._source.ownerSource()).firstValue();if(null===o)return;const s=this._source.properties().childs(),a=this._model.dark().value()?n.colorsPalette["color-cold-gray-900"]:n.colorsPalette["color-white"],c=this._source.points()[0].price,d={text:t.formatPrice(c,o),points:i,lineColor:s.lineColor.value(),circleBorderColor:a,backgroundColor:s.priceLabelBackgroundColor.value(),borderColor:s.priceLabelBorderColor.value(),textColor:s.priceLabelTextColor.value(),fontSize:s.priceLabelFontSize.value(),bold:s.priceLabelBold.value(),italic:s.priceLabelItalic.value()};{const t=i[0],r=i[1],o=t.x{i.d(t,{LineAnchorRenderer:()=>P,lineSourcePaneViewPointToLineAnchorPoint:()=>f,lineSourcePaneViewPointToLineAnchorPoint2:()=>b,mapLineSourcePaneViewPointToLineAnchorPoint:()=>x});var r=i(57415),o=i(91069),n=i(85842),s=i(51946),l=i(7321),a=i(83077),c=i(28031),d=i(72244),h=i(57507);function u(e,t,i,r){const{point:o}=t,n=i+r/2;(0,s.drawRoundRect)(e,o.x-n,o.y-n,2*n,2*n,(i+r)/2),e.closePath(),e.lineWidth=r}function p(e,t,i,r){e.globalAlpha=.2,u(e,t,i,r),e.stroke(),e.globalAlpha=1}function _(e,t,i,r){u(e,t,i-r,r),e.fill(),e.stroke()}function g(e,t,i,r){const{point:o}=t;e.globalAlpha=.2,e.beginPath(),e.arc(o.x,o.y,i+r/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=r,e.stroke(),e.globalAlpha=1}function S(e,t,i,r){const{point:o}=t;e.beginPath(),e.arc(o.x,o.y,i-r/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=r,e.fill(),e.stroke()}class P extends h.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e??null}setData(e){this._data=e}hitTest(e){if(null===this._data||this._data.disableInteractions)return null;const{radius:t,points:i}=this._data,r=t+(0,d.interactionTolerance)().anchor;for(const t of i){if(t.point.subtract(e).length()<=r)return new a.HitTestResult(t.hitTarget??a.HitTarget.ChangePoint,{areaName:a.AreaName.AnchorPoint, pointIndex:t.pointIndex,cursorType:t.cursorType??c.PaneCursorType.Default,activeItem:t.activeItem,snappingPrice:t.snappingPrice,snappingIndex:t.snappingIndex,nonDiscreteIndex:t.nonDiscreteIndex,possibleMovingDirections:t.possibleMovingDirections,clickHandler:this._data.clickHandler,tapHandler:this._data.clickHandler,ownerSourceId:this._data.ownerSourceId})}return null}doesIntersectWithBox(e){return null!==this._data&&this._data.points.some((t=>(0,o.pointInBox)(t.point,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const t=[],i=[],r=[],o=[];for(let e=0;e