Files
ai/charting_library/bundles/line-tool-brush.96d9ad2234a604886367.js

8 lines
21 KiB
JavaScript

"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[7479],{68786:(e,t,i)=>{i.d(t,{BrushBasePaneView:()=>d});var n=i(57415),s=i(5915),r=i(71367),o=i(99680),a=i(8165),l=i(83077),h=i(41928);class d extends h.LineSourcePaneView{constructor(){super(...arguments),this._polygonRenderer=new s.PolygonRenderer,this._renderer=new o.CompositeRenderer}renderer(e){return this._invalidated&&this._updateImpl(e),this._renderer}_updateImpl(e){super._updateImpl(e);const t=Math.max(1,this._source.smooth()),i=this._points;if(0===i.length)return void this._renderer.clear();const n=[i[0]];for(let e=1;e<i.length;e++){const s=i[e].subtract(i[e-1]),r=s.length(),o=Math.min(5,Math.floor(r/t)),a=s.normalized().scaled(r/o);for(let t=0;t<o-1;t++)n.push(i[e-1].add(a.scaled(t)));n.push(i[e])}this._points=this._smoothArray(n,t);const s=this._createPolygonRendererData();if(this._polygonRenderer.setData(s),this._renderer=new o.CompositeRenderer,this._renderer.append(this._polygonRenderer),this._source.finished()&&this._addAnchors()){const e=s.points.length;if(e>0){const t=1!==e?[s.points[0],s.points[e-1]]:[s.points[0]],i=new r.SelectionRenderer({points:t.map(a.mapLineSourcePaneViewPointToLineAnchorPoint),bgColors:this._lineAnchorColors(t),visible:this.areAnchorsVisible(),hittestResult:l.HitTarget.Regular,barSpacing:this._getModel().timeScale().barSpacing()});this._renderer.append(i)}}}_addAnchors(){return!0}_smoothArray(e,t){if(1===e.length)return e;const i=new Array(e.length);for(let s=0;s<e.length;s++){let r=new n.Point(0,0);for(let i=0;i<t;i++){const t=Math.max(s-i,0),n=Math.min(s+i,e.length-1);r=r.add(e[t]),r=r.add(e[n])}i[s]=r.scaled(.5/t)}return i.push(e[e.length-1]),i}}},23163:(e,t,i)=>{i.d(t,{LineToolBrushBase:()=>a,lineToolBrushBaseNonThemedFactoryDefaults:()=>o});var n=i(85842),s=i(82014),r=i(89659);const o={smooth:5};class a extends s.LineDataSource{constructor(){super(...arguments),this._hasEditableCoordinates=new r.WatchedValue(!1),this._finished=!1}pointsCount(){return-1}finished(){return this._finished}finish(){this._finished=!0,this._lastPoint=null,this._normalizePoints(),this.createServerPoints()}hasOnlyOnePoint(){return 1===this._points.length}addPoint(e,t,i){if(this._finished)return!0;if(this._lastPoint=null,this._points.length>0){const t=this._points[this._points.length-1],i=(0,n.ensureNotNull)(this.pointToScreenPoint(t));if((0,n.ensureNotNull)(this.pointToScreenPoint(e)).subtract(i).length()<2)return this._finished}return super.addPoint(e),this._finished}restorePoints(e,t,i){super.restorePoints(e,t,i),this._finished=!0}}},37984:(e,t,i)=>{i.r(t),i.d(t,{LineToolBrush:()=>D});var n=i(23163),s=i(80140),r=i(68786);class o extends r.BrushBasePaneView{_createPolygonRendererData(){const e=this._source.properties().childs(),t={points:this._points,color:e.linecolor.value(),linewidth:e.linewidth.value(),linestyle:s.LINESTYLE_SOLID,skipClosePath:!0,leftend:e.leftEnd.value(),rightend:e.rightEnd.value(),filled:!1,fillBackground:!1,backcolor:e.backgroundColor.value()}
;return e.fillBackground.value()&&this._model.lineBeingCreated()!==this._source&&(t.filled=!0,t.fillBackground=!0,t.transparency=e.transparency.value()),t}}var a=i(85842),l=i(68459),h=i(47097),d=i(86684),c=i(88483),u=i(93445),p=i(17567),_=i(25432),g=i(5829),f=i(86371),m=i(33993);const P={intervalsVisibilities:{...c.intervalsVisibilitiesDefaults},...n.lineToolBrushBaseNonThemedFactoryDefaults,fillBackground:!1,linewidth:g.DEFAULT_LINE_TOOL_LINE_WIDTH,leftEnd:l.LineEnd.Normal,rightEnd:l.LineEnd.Normal},S={linecolor:d.colors.colorSkyBlue500,backgroundColor:d.colors.colorSkyBlue500Alpha20,transparency:80},T=new Map([[h.StdTheme.Light,S],[h.StdTheme.Dark,S]]),y=(0,u.extractThemedColors)((0,a.ensureDefined)(T.get(h.StdTheme.Light)),(0,a.ensureDefined)(T.get(h.StdTheme.Dark))),w=(0,u.extractAllPropertiesKeys)((0,a.ensureDefined)(T.get(h.StdTheme.Light))),v=(0,u.extractAllPropertiesKeys)(P),b=[...w,...v],I=[...new Set([...b,..._.commonLineToolPropertiesStateKeys]),"smooth"];class k extends f.LineDataSourceProperty{constructor(e){super(e),this.addChild("backgroundsColors",new m.LineToolColorsProperty([this.childs().backgroundColor],this.childs().fillBackground)),this.hasChild("linestyle")&&this.removeProperty("linestyle"),this.hasChild("linesStyles")&&this.removeProperty("linesStyles")}static create(e,t){return new this({defaultName:"linetoolbrush",factoryDefaultsSupplier:()=>(0,p.factoryDefaultsForCurrentTheme)(P,T),nonThemedDefaultsKeys:v,themedDefaultsKeys:w,allStateKeys:I,themedColors:y,templateKeys:b,replaceThemedColorsOnThemeChange:!0,state:t,theme:e})}}class D extends n.LineToolBrushBase{constructor(e,t,i,n){super(e,t??D.createProperties(e.backgroundTheme().spawnOwnership()),i,n),this._setPaneViews([new o(this,e)])}smooth(){return this.properties().childs().smooth.value()}name(){return"Brush"}static createProperties(e,t){const i=k.create(e,t);return this._configureProperties(i),i}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(1982),i.e(7686),i.e(2428),i.e(3920),i.e(9328)]).then(i.bind(i,31544)).then((e=>e.BrushDefinitionsViewModel))}}},80995:(e,t,i)=>{i.r(t),i.d(t,{LineToolDemonstrationHighlighter:()=>h});var n=i(47166),s=i(93445),r=i(23163),o=i(80140),a=i(68786);class l extends a.BrushBasePaneView{_createPolygonRendererData(){return{points:this._points,color:this._source.color(),linewidth:this._source.width(),backcolor:"rgba(0, 0, 0, 0)",fillBackground:!1,linestyle:o.LINESTYLE_SOLID,filled:!1,globalAlpha:1-this._source.animationProgress(),disableInteractions:!0}}_addAnchors(){return!1}}class h extends r.LineToolBrushBase{constructor(e,t,i,s){super(e,h.createProperties(e.backgroundTheme().spawnOwnership()),!1,(0,n.randomHash)()),this.toolname="LineToolDemonstrationHighlighter",this._creationTime=null,this._color=t,this._width=i,this._visibilityTime=s,this._setPaneViews([new l(this,e)])}smooth(){return 5}color(){return this._color}width(){return this._width}name(){return"Presentation highlighter"}canBeHidden(){return!1}finish(){super.finish(),this._creationTime=performance.now()}animationProgress(){
if(null===this._creationTime)return 0;const e=(performance.now()-this._creationTime)/this._visibilityTime;return Math.min(1,e)}static createProperties(e){const t=new s.DefaultProperty({defaultName:"",useUserPreferences:!1,state:void 0,theme:e});return this._configureProperties(t),t}_ignoreSourceEvent(e){return"data-source-change"===e.type&&e.sourceId!==this.model().crosshairSource().id()}}},86366:(e,t,i)=>{i.r(t),i.d(t,{LineToolHighlighter:()=>I});var n=i(23163),s=i(80140),r=i(68786);class o extends r.BrushBasePaneView{_createPolygonRendererData(){const e=this._source.properties().childs();return{points:this._points,color:e.linecolor.value(),linewidth:e.width.value(),backcolor:"rgba(0, 0, 0, 0)",fillBackground:!1,linestyle:s.LINESTYLE_SOLID,filled:!1,transparency:e.transparency.value()}}}var a=i(85842),l=i(47097),h=i(86684),d=i(88483),c=i(93445),u=i(17567),p=i(25432),_=i(86371),g=i(33993);const f={intervalsVisibilities:{...d.intervalsVisibilitiesDefaults},...n.lineToolBrushBaseNonThemedFactoryDefaults,width:20},m={linecolor:h.colors.colorRipeRed500Alpha20,transparency:80},P=new Map([[l.StdTheme.Light,m],[l.StdTheme.Dark,m]]),S=(0,c.extractThemedColors)((0,a.ensureDefined)(P.get(l.StdTheme.Light)),(0,a.ensureDefined)(P.get(l.StdTheme.Dark))),T=(0,c.extractAllPropertiesKeys)((0,a.ensureDefined)(P.get(l.StdTheme.Light))),y=(0,c.extractAllPropertiesKeys)(f),w=[...T,...y],v=[...new Set([...w,...p.commonLineToolPropertiesStateKeys]),"smooth"];class b extends _.LineDataSourceProperty{constructor(e){super(e),this.addChild("widths",new g.LineToolWidthsProperty([this.childs().width]))}static create(e,t){return new this({defaultName:"linetoolhighlighter",factoryDefaultsSupplier:()=>(0,u.factoryDefaultsForCurrentTheme)(f,P),nonThemedDefaultsKeys:y,themedDefaultsKeys:T,allStateKeys:v,themedColors:S,templateKeys:w,replaceThemedColorsOnThemeChange:!0,state:t,theme:e})}}class I extends n.LineToolBrushBase{constructor(e,t,i,n){super(e,t??I.createProperties(e.backgroundTheme().spawnOwnership()),i,n),this._setPaneViews([new o(this,e)])}smooth(){return this.properties().childs().smooth.value()}name(){return"Highlighter"}static createProperties(e,t){const i=b.create(e,t);return this._configureProperties(i),i}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(1982),i.e(7686),i.e(2428),i.e(3920),i.e(9328)]).then(i.bind(i,86349)).then((e=>e.HighlighterDefinitionsViewModel))}}},25432:(e,t,i)=>{i.d(t,{commonLineToolPropertiesStateKeys:()=>n})
;const n=["symbolStateVersion","zOrderVersion","frozen","title","interval","symbol","currencyId","unitId","metricId","visible","adjustedToSplitTime","intervalsVisibilities.ticks","intervalsVisibilities.seconds","intervalsVisibilities.secondsFrom","intervalsVisibilities.secondsTo","intervalsVisibilities.minutes","intervalsVisibilities.minutesFrom","intervalsVisibilities.minutesTo","intervalsVisibilities.hours","intervalsVisibilities.hoursFrom","intervalsVisibilities.hoursTo","intervalsVisibilities.days","intervalsVisibilities.daysFrom","intervalsVisibilities.daysTo","intervalsVisibilities.weeks","intervalsVisibilities.weeksFrom","intervalsVisibilities.weeksTo","intervalsVisibilities.months","intervalsVisibilities.monthsFrom","intervalsVisibilities.monthsTo","intervalsVisibilities.ranges"];var s,r,o;!function(e){e[e.NotShared=0]="NotShared",e[e.SharedInLayout=1]="SharedInLayout",e[e.GloballyShared=2]="GloballyShared"}(s||(s={})),function(e){e.BeforeAllAction="BeforeAll",e.CustomAction="CustomAction"}(r||(r={})),function(e){e.FloatingToolbarButton="FloatingToolbarButton",e.Default="Default"}(o||(o={}))},41928:(e,t,i)=>{i.d(t,{LineSourcePaneView:()=>f,anchorResizeCursorType:()=>_,createLineSourcePaneViewPoint:()=>g});var n=i(11284),s=i(85842),r=i(29968),o=i(83077),a=i(71367),l=i(8165),h=i(28031),d=i(61208);const c=n.colorsPalette["color-tv-blue-600"];var u,p;function _(e,t){const i=e.x-t.x,n=e.y-t.y;if(!Number.isFinite(i)||!Number.isFinite(n)||0===i&&0===n)return h.PaneCursorType.Default;let r=Math.atan2(n,i);return r<0&&(r+=2*Math.PI),r>=p.deg337_5||r<p.deg22_5||r>=p.deg157_5&&r<p.deg202_5?h.PaneCursorType.HorizontalResize:r>=p.deg22_5&&r<p.deg67_5||r>=p.deg202_5&&r<p.deg247_5?h.PaneCursorType.DiagonalNwSeResize:r>=p.deg67_5&&r<p.deg112_5||r>=p.deg247_5&&r<p.deg292_5?h.PaneCursorType.VerticalResize:r>=p.deg112_5&&r<p.deg157_5||r>=p.deg292_5&&r<p.deg337_5?h.PaneCursorType.DiagonalNeSwResize:void(0,s.assert)(!1,"unexpected angle")}function g(e,t){return e.pointIndex=t,e}!function(e){e[e.RegularAnchorRadius=6]="RegularAnchorRadius",e[e.TouchAnchorRadius=13]="TouchAnchorRadius",e[e.RegularStrokeWidth=1]="RegularStrokeWidth",e[e.TouchStrokeWidth=3]="TouchStrokeWidth",e[e.RegularSelectedStrokeWidth=3]="RegularSelectedStrokeWidth",e[e.TouchSelectedStrokeWidth=0]="TouchSelectedStrokeWidth"}(u||(u={})),function(e){e[e.deg22_5=Math.PI/8]="deg22_5",e[e.deg67_5=3*Math.PI/8]="deg67_5",e[e.deg112_5=5*Math.PI/8]="deg112_5",e[e.deg157_5=7*Math.PI/8]="deg157_5",e[e.deg202_5=9*Math.PI/8]="deg202_5",e[e.deg247_5=11*Math.PI/8]="deg247_5",e[e.deg292_5=13*Math.PI/8]="deg292_5",e[e.deg337_5=15*Math.PI/8]="deg337_5"}(p||(p={}));class f{constructor(e,t,i){this._invalidated=!0,this._points=[],this._middlePoint=null,this._selectionRenderers=[],this._lineAnchorRenderers=[],this._source=e,this._model=t,this._ownerSource=i??null}priceToCoordinate(e){const t=this._getOwnerSource(),i=t?.priceScale();if(null==i)return null;const n=null!==t?t.firstValue():null;return null===n?null:i.priceToCoordinate(e,n)}anchorColor(){return c}isHoveredSource(){
return this._source===this._model.hoveredSource()}isSelectedSource(){return this._model.selection().isSelected(this._source)}isBeingEdited(){return this._model.lineBeingEdited()===this._source}isEditMode(){return!this._model.isSnapshot()}areAnchorsVisible(){return(this.isHoveredSource()&&!this.isLocked()||this.isSelectedSource())&&this.isEditMode()}update(){this._invalidated=!0}isLocked(){return Boolean(this._source.isLocked&&this._source.isLocked())}addAnchors(e,t={}){let i=this._getPoints();this._model.lineBeingCreated()===this._source&&(i=i.slice(0,-1));const n=this._source.points(),s=i.map(((e,t)=>{const i=n[t],s=(0,l.lineSourcePaneViewPointToLineAnchorPoint)(e);return i&&(s.snappingPrice=i.price,s.snappingIndex=i.index),s}));e.append(this.createLineAnchor({...t,points:s},0))}createLineAnchor(e,t){const i=e.points.map((e=>e.point)),n=this._getOwnerSource();if(this.isLocked()){const s=this._getSelectionRenderer(t);return s.setData({bgColors:this._lineAnchorColors(i),points:e.points,visible:this.areAnchorsVisible(),hittestResult:o.HitTarget.Regular,ownerSourceId:n?.id(),barSpacing:this._model.timeScale().barSpacing()}),s}const s=(0,r.lastMouseOrTouchEventInfo)().isTouch,a=this._getLineAnchorRenderer(t),l=this.isHoveredSource()?this._model.lastHittestData()?.pointIndex??null:null;return a.setData({...e,color:this.anchorColor(),backgroundColors:this._lineAnchorColors(i),hoveredPointIndex:l,linePointBeingEdited:this.isBeingEdited()?this._model.linePointBeingEdited():null,radius:this._anchorRadius(),strokeWidth:s?u.TouchStrokeWidth:u.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:s?u.TouchSelectedStrokeWidth:u.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible(),clickHandler:e.clickHandler,ownerSourceId:n?.id()}),a}_getOwnerSource(){return this._ownerSource??this._source.ownerSource()}_anchorRadius(){return(0,r.lastMouseOrTouchEventInfo)().isTouch?u.TouchAnchorRadius:u.RegularAnchorRadius}_lineAnchorColors(e){const t=(0,s.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 a.SelectionRenderer);return this._selectionRenderers[e]}_getLineAnchorRenderer(e){for(;this._lineAnchorRenderers.length<=e;)this._lineAnchorRenderers.push(new l.LineAnchorRenderer);return this._lineAnchorRenderers[e]}}},86371:(e,t,i)=>{i.d(t,{LineDataSourceProperty:()=>l});var n=i(57600),s=i(35558),r=i(85842),o=i(93445),a=i(47895);class l extends o.DefaultProperty{constructor({templateKeys:e,factoryDefaultsSupplier:t,...i}){let n=t;t&&(n=()=>{const e=t();return(0,a.applyDefaultsOverrides)(e,void 0,void 0,i.defaultName),e}),super({saveNonDefaultUserPreferencesOnly:!0,factoryDefaultsSupplier:n,...i}),this._templateKeys=(0,r.ensureDefined)(e||this._allDefaultsKeys)}template(){return(0,o.extractState)(this.state(),this._templateKeys,[])}applyTemplate(e){this.mergeAndFire((0,o.extractState)((0,s.default)((0,n.default)(this._factoryDefaultsSupplier()),e),this._templateKeys))}}},8165:(e,t,i)=>{i.d(t,{LineAnchorRenderer:()=>m,lineSourcePaneViewPointToLineAnchorPoint:()=>P,lineSourcePaneViewPointToLineAnchorPoint2:()=>S,mapLineSourcePaneViewPointToLineAnchorPoint:()=>T});var n=i(57415),s=i(91069),r=i(85842),o=i(51946),a=i(7321),l=i(83077),h=i(28031),d=i(72244),c=i(57507);function u(e,t,i,n){const{point:s}=t,r=i+n/2;(0,o.drawRoundRect)(e,s.x-r,s.y-r,2*r,2*r,(i+n)/2),e.closePath(),e.lineWidth=n}function p(e,t,i,n){e.globalAlpha=.2,u(e,t,i,n),e.stroke(),e.globalAlpha=1}function _(e,t,i,n){u(e,t,i-n,n),e.fill(),e.stroke()}function g(e,t,i,n){const{point:s}=t;e.globalAlpha=.2,e.beginPath(),e.arc(s.x,s.y,i+n/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=n,e.stroke(),e.globalAlpha=1}function f(e,t,i,n){const{point:s}=t;e.beginPath(),e.arc(s.x,s.y,i-n/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=n,e.fill(),e.stroke()}class m extends c.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,n=t+(0,d.interactionTolerance)().anchor;for(const t of i){if(t.point.subtract(e).length()<=n)return new l.HitTestResult(t.hitTarget??l.HitTarget.ChangePoint,{areaName:l.AreaName.AnchorPoint,pointIndex:t.pointIndex,cursorType:t.cursorType??h.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,s.pointInBox)(t.point,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const t=[],i=[],n=[],s=[];for(let e=0;e<this._data.points.length;++e){const r=this._data.points[e],o=this._data.backgroundColors[e];r.square?(t.push(r),i.push(o)):(n.push(r),s.push(o))}t.length&&this._drawPoints(e,t,i,_,p),n.length&&this._drawPoints(e,n,s,f,g)}_drawPoints(e,t,i,s,o){
const{context:l,horizontalPixelRatio:h,verticalPixelRatio:d}=e,c=(0,r.ensureNotNull)(this._data),u=c.radius;let p=Math.max(1,Math.floor((c.strokeWidth||2)*h));c.selected&&(p+=Math.max(1,Math.floor(h/2)));const _=Math.max(1,Math.floor(h));let g=Math.round(u*h*2);g%2!=_%2&&(g+=1);const f=_%2/2;l.strokeStyle=c.color;for(let e=0;e<t.length;++e){const r=t[e];if(!((0,a.isInteger)(r.pointIndex)&&c.linePointBeingEdited===r.pointIndex)){l.fillStyle=i[e];if(s(l,{...r,point:new n.Point(Math.round(r.point.x*h)+f,Math.round(r.point.y*d)+f)},g/2,p),!c.disableInteractions){if(null!==c.hoveredPointIndex&&r.pointIndex===c.hoveredPointIndex){const e=Math.max(1,Math.floor(c.selectedStrokeWidth*h));let t=Math.round(u*h*2);t%2!=_%2&&(t+=1);o(l,{...r,point:new n.Point(Math.round(r.point.x*h)+f,Math.round(r.point.y*d)+f)},t/2,e)}}}}}}function P(e,t=e.pointIndex,i,n,s,r,o,a,l,h){return{point:e,pointIndex:t,cursorType:i,square:n,hitTarget:s,snappingPrice:r,snappingIndex:o,nonDiscreteIndex:a,activeItem:l,possibleMovingDirections:h}}function S(e){return P(e.point,e.pointIndex,e.cursorType,e.square,e.hitTarget,e.snappingPrice,e.snappingIndex,e.nonDiscreteIndex,e.activeItem,e.possibleMovingDirections)}function T(e){return P(e)}},5915:(e,t,i)=>{i.d(t,{PolygonRenderer:()=>_});var n=i(91069),s=i(17086),r=i(6353),o=i(68459),a=i(83077),l=i(82347),h=i(56568),d=i(72244),c=i(51946),u=i(80140),p=i(40450);class _ extends h.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._backHittest=new a.HitTestResult(a.HitTarget.MovePointBackground),this._points=[],this._hittest=e??new a.HitTestResult(a.HitTarget.MovePoint)}setData(e){this._data=e,this._points=e.points}hitTest(e){if(null===this._data||this._data.disableInteractions)return null;const t=Math.max((0,d.interactionTolerance)().line,Math.ceil(this._data.linewidth/2)),i=this._points.length;if(1===i){return(0,n.pointInCircle)(e,this._points[0],t)?this._hittest:null}for(let n=1;n<i;n++){const i=this._points[n-1],r=this._points[n];if((0,s.distanceToSegment)(i,r,e).distance<=t)return this._hittest}if(this._data.filled&&this._data.fillBackground&&i>0){const n=this._points[0],r=this._points[i-1];if((0,s.distanceToSegment)(n,r,e).distance<=t)return this._hittest}return this._data.filled&&this._data.fillBackground&&(0,n.pointInPolygon)(e,this._data.points)?this._backHittest:null}_drawImpl(e){const t=e.context,i=this._points.length;if(null===this._data||0===i)return;const n=t.globalAlpha;try{if(void 0!==this._data.globalAlpha&&(t.globalAlpha=this._data.globalAlpha),1===i)return void this._drawPoint(t,this._points[0],this._data.linewidth/2,this._data.color);t.beginPath();const e=this._data.linestyle===u.LINESTYLE_SOLID?"round":"butt",n=this._data.linecap??e;t.lineCap=n,t.strokeStyle=this._data.color,t.lineWidth=this._data.linewidth,t.lineJoin=this._data.linejoin??"round",(0,c.setLineStyle)(t,this._data.linestyle);const s=this._points[0];t.moveTo(s.x,s.y);for(const e of this._points)t.lineTo(e.x,e.y);if(this._data.filled&&this._data.fillBackground&&(t.fillStyle=(0,
l.generateColor)(this._data.backcolor,this._data.transparency),t.fill()),this._data.filled&&!this._data.skipClosePath&&t.closePath(),i>1){if(this._data.leftend===o.LineEnd.Arrow){const e=this._correctArrowPoints(this._points[1],this._points[0],t.lineWidth,n);(0,r.drawArrow)(e[0],e[1],t,t.lineWidth,p.dpr1PixelRatioInfo)}if(this._data.rightend===o.LineEnd.Arrow){const e=this._correctArrowPoints(this._points[i-2],this._points[i-1],t.lineWidth,n);(0,r.drawArrow)(e[0],e[1],t,t.lineWidth,p.dpr1PixelRatioInfo)}}this._data.linewidth>0&&t.stroke()}finally{t.globalAlpha=n}}_drawPoint(e,t,i,n){0!==i&&(e.beginPath(),e.fillStyle=n,e.arc(t.x,t.y,i,0,2*Math.PI,!0),e.fill(),e.closePath())}_correctArrowPoints(e,t,i,n){const s=t.subtract(e),r=s.length();if("butt"===n||r<1)return[e,t];const o=r+i/2;return[e,s.scaled(o/r).add(e)]}}},17567:(e,t,i)=>{i.d(t,{factoryDefaultsForCurrentTheme:()=>l});var n=i(35558),s=i(57600),r=i(85842),o=i(49841),a=i(47097);function l(e,t){const i=o.watchedTheme.value()??a.StdTheme.Light,l=(0,s.default)(e);return(0,n.default)(l,(0,r.ensureDefined)(t.get(i))),l}}}]);