6 lines
17 KiB
JavaScript
6 lines
17 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[5734],{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,o,r;!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"}(o||(o={})),function(e){e.FloatingToolbarButton="FloatingToolbarButton",e.Default="Default"}(r||(r={}))},41928:(e,t,i)=>{i.d(t,{LineSourcePaneView:()=>f,anchorResizeCursorType:()=>_,createLineSourcePaneViewPoint:()=>g});var n=i(11284),s=i(85842),o=i(29968),r=i(83077),l=i(71367),a=i(8165),d=i(28031),h=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 d.PaneCursorType.Default;let o=Math.atan2(n,i);return o<0&&(o+=2*Math.PI),o>=p.deg337_5||o<p.deg22_5||o>=p.deg157_5&&o<p.deg202_5?d.PaneCursorType.HorizontalResize:o>=p.deg22_5&&o<p.deg67_5||o>=p.deg202_5&&o<p.deg247_5?d.PaneCursorType.DiagonalNwSeResize:o>=p.deg67_5&&o<p.deg112_5||o>=p.deg247_5&&o<p.deg292_5?d.PaneCursorType.VerticalResize:o>=p.deg112_5&&o<p.deg157_5||o>=p.deg292_5&&o<p.deg337_5?d.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,a.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:r.HitTarget.Regular,ownerSourceId:n?.id(),barSpacing:this._model.timeScale().barSpacing()}),s}const s=(0,o.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:s?u.TouchStrokeWidth:u.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:s?u.TouchSelectedStrokeWidth:u.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible(),clickHandler:e.clickHandler,ownerSourceId:n?.id()}),l}_getOwnerSource(){return this._ownerSource??this._source.ownerSource()}_anchorRadius(){return(0,o.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,h.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]}}},86371:(e,t,i)=>{i.d(t,{LineDataSourceProperty:()=>a});var n=i(57600),s=i(35558),o=i(85842),r=i(93445),l=i(47895);class a extends r.DefaultProperty{constructor({templateKeys:e,factoryDefaultsSupplier:t,...i}){let n=t;t&&(n=()=>{const e=t();return(0,l.applyDefaultsOverrides)(e,void 0,void 0,i.defaultName),e}),super({saveNonDefaultUserPreferencesOnly:!0,factoryDefaultsSupplier:n,...i}),this._templateKeys=(0,o.ensureDefined)(e||this._allDefaultsKeys)}template(){return(0,r.extractState)(this.state(),this._templateKeys,[])}applyTemplate(e){this.mergeAndFire((0,r.extractState)((0,s.default)((0,n.default)(this._factoryDefaultsSupplier()),e),this._templateKeys))}}},3855:(e,t,i)=>{i.r(t),i.d(t,{LineToolPolyline:()=>C});var n=i(85842),s=i(57415),o=i(72244),r=i(82014),l=i(89659),a=i(5915),d=i(99680),h=i(41928);class c extends h.LineSourcePaneView{constructor(e,t){super(e,t),this._polygonRenderer=new a.PolygonRenderer,this._renderer=new d.CompositeRenderer}renderer(e){return this._invalidated&&this._updateImpl(e),this._renderer}_updateImpl(e){super._updateImpl(e),this._renderer.clear();const t=this._source.properties().childs(),i={points:this._points,color:t.linecolor.value(),linewidth:t.linewidth.value(),linestyle:t.linestyle.value(),filled:t.filled.value(),backcolor:t.backgroundColor.value(),fillBackground:t.fillBackground.value(),transparency:t.transparency.value()};this._polygonRenderer.setData(i),this._renderer.append(this._polygonRenderer),this.addAnchors(this._renderer)}}var u=i(47097),p=i(86684),_=i(17567),g=i(93445),f=i(80140),P=i(88483),S=i(5829),m=i(25432),T=i(86371);const y={intervalsVisibilities:{...P.intervalsVisibilitiesDefaults},linewidth:S.DEFAULT_LINE_TOOL_LINE_WIDTH,linestyle:f.LINESTYLE_SOLID,fillBackground:!0},v={linecolor:p.colors.colorSkyBlue500,backgroundColor:p.colors.colorSkyBlue500Alpha20,transparency:80},w=new Map([[u.StdTheme.Light,v],[u.StdTheme.Dark,v]]),b=(0,g.extractThemedColors)((0,n.ensureDefined)(w.get(u.StdTheme.Light)),(0,n.ensureDefined)(w.get(u.StdTheme.Dark))),I=(0,g.extractAllPropertiesKeys)((0,n.ensureDefined)(w.get(u.StdTheme.Light))),x=(0,g.extractAllPropertiesKeys)(y),k=[...I,...x],A=[...new Set([...k,...m.commonLineToolPropertiesStateKeys,"filled"])];class R extends T.LineDataSourceProperty{constructor(e){super(e),this.hasChild("filled")||this.addProperty("filled",!1)}static create(e,t){return new this({defaultName:"linetoolpolyline",factoryDefaultsSupplier:()=>(0,_.factoryDefaultsForCurrentTheme)(y,w),nonThemedDefaultsKeys:x,themedDefaultsKeys:I,allStateKeys:A,themedColors:b,
|
|
templateKeys:k,replaceThemedColorsOnThemeChange:!0,state:t,theme:e})}}class C extends r.LineDataSource{constructor(e,t,i,n){super(e,t??C.createProperties(e.backgroundTheme().spawnOwnership()),i,n),this._hasEditableCoordinates=new l.WatchedValue(!1),this._finished=!1,this._setPaneViews([new c(this,e)])}pointsCount(){return-1}name(){return"Polyline"}finish(){this._finished=!0,this._lastPoint=null,this._normalizePoints(),this.createServerPoints()}addPoint(e,t,i,r){if(this._finished)return!0;const l=(0,n.ensureNotNull)(this.priceScale()),a=this._model.timeScale().indexToCoordinate(e.index),d=e.price,h=(0,n.ensure)(this.ownerSource()?.firstValue()),c=l.priceToCoordinate(d,h),u=(0,o.interactionTolerance)().minDistanceBetweenPoints;if(this._points.length>0){const e=this._points[this._points.length-1],i=this._model.timeScale().indexToCoordinate(e.index),n=e.price,o=l.priceToCoordinate(n,h),d=new s.Point(a,c).subtract(new s.Point(i,o)).length();if(!t?.isApiEvent()&&d<u&&!r)return this._lastPoint=null,this._normalizePoints(),this.createServerPoints(),!0;const p=this._points[0],_=this._model.timeScale().indexToCoordinate(p.index),g=l.priceToCoordinate(p.price,h),f=new s.Point(a,c).subtract(new s.Point(_,g)).length();if(!t?.isApiEvent()&&f<u&&!r)return this.properties().childs().filled.setValue(!0),this._lastPoint=null,this._normalizePoints(),this.createServerPoints(),!0}return super.addPoint(e,t,i)}setPoint(e,t,i){super.setPoint(e,t,i);const r=this.priceScale();if(!(this._model.timeScale().isEmpty()||null===r||r.isEmpty()||e!==this._points.length-1&&0!==e)){const i=(0,n.ensure)(this.ownerSource()?.firstValue()),l=this._model.timeScale().indexToCoordinate(t.index),a=r.priceToCoordinate(t.price,i),d=e===this._points.length-1?this._points[0]:this._points[this._points.length-1],h=this._model.timeScale().indexToCoordinate(d.index),c=r.priceToCoordinate(d.price,i);new s.Point(l,a).subtract(new s.Point(h,c)).length()<(0,o.interactionTolerance)().minDistanceBetweenPoints&&this.properties().childs().filled.setValue(!0)}}static createProperties(e,t){const i=R.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,55539)).then((e=>e.PolylinesDefinitionsViewModel))}}},8165:(e,t,i)=>{i.d(t,{LineAnchorRenderer:()=>P,lineSourcePaneViewPointToLineAnchorPoint:()=>S,lineSourcePaneViewPointToLineAnchorPoint2:()=>m,mapLineSourcePaneViewPointToLineAnchorPoint:()=>T});var n=i(57415),s=i(91069),o=i(85842),r=i(51946),l=i(7321),a=i(83077),d=i(28031),h=i(72244),c=i(57507);function u(e,t,i,n){const{point:s}=t,o=i+n/2;(0,r.drawRoundRect)(e,s.x-o,s.y-o,2*o,2*o,(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 P 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,h.interactionTolerance)().anchor;for(const t of i){if(t.point.subtract(e).length()<=n)return new a.HitTestResult(t.hitTarget??a.HitTarget.ChangePoint,{areaName:a.AreaName.AnchorPoint,pointIndex:t.pointIndex,cursorType:t.cursorType??d.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 o=this._data.points[e],r=this._data.backgroundColors[e];o.square?(t.push(o),i.push(r)):(n.push(o),s.push(r))}t.length&&this._drawPoints(e,t,i,_,p),n.length&&this._drawPoints(e,n,s,f,g)}_drawPoints(e,t,i,s,r){const{context:a,horizontalPixelRatio:d,verticalPixelRatio:h}=e,c=(0,o.ensureNotNull)(this._data),u=c.radius;let p=Math.max(1,Math.floor((c.strokeWidth||2)*d));c.selected&&(p+=Math.max(1,Math.floor(d/2)));const _=Math.max(1,Math.floor(d));let g=Math.round(u*d*2);g%2!=_%2&&(g+=1);const f=_%2/2;a.strokeStyle=c.color;for(let e=0;e<t.length;++e){const o=t[e];if(!((0,l.isInteger)(o.pointIndex)&&c.linePointBeingEdited===o.pointIndex)){a.fillStyle=i[e];if(s(a,{...o,point:new n.Point(Math.round(o.point.x*d)+f,Math.round(o.point.y*h)+f)},g/2,p),!c.disableInteractions){if(null!==c.hoveredPointIndex&&o.pointIndex===c.hoveredPointIndex){const e=Math.max(1,Math.floor(c.selectedStrokeWidth*d));let t=Math.round(u*d*2);t%2!=_%2&&(t+=1);r(a,{...o,point:new n.Point(Math.round(o.point.x*d)+f,Math.round(o.point.y*h)+f)},t/2,e)}}}}}}function S(e,t=e.pointIndex,i,n,s,o,r,l,a,d){return{point:e,pointIndex:t,cursorType:i,square:n,hitTarget:s,snappingPrice:o,snappingIndex:r,nonDiscreteIndex:l,activeItem:a,possibleMovingDirections:d}}function m(e){return S(e.point,e.pointIndex,e.cursorType,e.square,e.hitTarget,e.snappingPrice,e.snappingIndex,e.nonDiscreteIndex,e.activeItem,e.possibleMovingDirections)}function T(e){return S(e)}},5915:(e,t,i)=>{i.d(t,{PolygonRenderer:()=>_});var n=i(91069),s=i(17086),o=i(6353),r=i(68459),l=i(83077),a=i(82347),d=i(56568),h=i(72244),c=i(51946),u=i(80140),p=i(40450);class _ extends d.MediaCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._backHittest=new l.HitTestResult(l.HitTarget.MovePointBackground),this._points=[],this._hittest=e??new l.HitTestResult(l.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,h.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],o=this._points[n];if((0,s.distanceToSegment)(i,o,e).distance<=t)return this._hittest}if(this._data.filled&&this._data.fillBackground&&i>0){const n=this._points[0],o=this._points[i-1];if((0,s.distanceToSegment)(n,o,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,a.generateColor)(this._data.backcolor,this._data.transparency),t.fill()),this._data.filled&&!this._data.skipClosePath&&t.closePath(),i>1){if(this._data.leftend===r.LineEnd.Arrow){const e=this._correctArrowPoints(this._points[1],this._points[0],t.lineWidth,n);(0,o.drawArrow)(e[0],e[1],t,t.lineWidth,p.dpr1PixelRatioInfo)}if(this._data.rightend===r.LineEnd.Arrow){const e=this._correctArrowPoints(this._points[i-2],this._points[i-1],t.lineWidth,n);(0,o.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),o=s.length();if("butt"===n||o<1)return[e,t];const r=o+i/2;return[e,s.scaled(r/o).add(e)]}}},17567:(e,t,i)=>{i.d(t,{factoryDefaultsForCurrentTheme:()=>a});var n=i(35558),s=i(57600),o=i(85842),r=i(49841),l=i(47097);function a(e,t){const i=r.watchedTheme.value()??l.StdTheme.Light,a=(0,s.default)(e);return(0,n.default)(a,(0,o.ensureDefined)(t.get(i))),a}}}]); |