"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[5529],{14472:(e,t,i)=>{i.r(t),i.d(t,{LineDataSourceDefinitionsViewModel:()=>v,LineDataSourceTabTypes:()=>n,pointPriceBarTitle:()=>f});var n,r=i(50151),o=i(11542),s=i(95804),a=(i(40167),i(95338)),l=i(60567),c=i(22613),h=i(73863),u=i(97578),d=i(81634),p=i(36313);!function(e){e.Visibility="visibility",e.Coordinates="coordinates",e.Style="style",e.Text="text",e.Inputs="inputs"}(n||(n={}));const _=o.t(null,void 0,i(40091)),g=o.t(null,void 0,i(78930)),P=o.t(null,void 0,i(92516)),S=o.t(null,void 0,i(70320)),y=o.t(null,void 0,i(21429)),f=o.t(null,{context:"linetool point"},i(80166));class v{constructor(e,t){this._yCoordinateStepWV=null,this._propertyPages=[],this._source=t,this._undoModel=e,this._ownerSource=(0,r.ensureNotNull)(this._source.ownerSource()),this._propertyApplier=new d.PropertyApplierWithoutSavingChart((()=>e)),this._createPropertyRages()}destroy(){null!==this._yCoordinateStepWV&&(this._source.ownerSourceChanged().unsubscribeAll(this),this._ownerSource.priceStepChanged().unsubscribeAll(this)),this._source.pointAdded().unsubscribeAll(this),this._propertyPages.forEach((e=>{(0,a.destroyDefinitions)(e.definitions.value())}))}propertyPages(){return Promise.resolve(this._propertyPages)}_createPropertyRages(){this._propertyPages=[];const e=this._createInputsPropertyPage();null!==e&&this._propertyPages.push(e);const t=this._createStylePropertyPage();null!==t&&this._propertyPages.push(t);const i=this._createTextPropertyPage();null!==i&&this._propertyPages.push(i);const n=this._createCoordinatesPropertyPage();null!==n&&(n.visible=this._source.hasEditableCoordinates(),this._propertyPages.push(n));const r=this._createVisibilitiesPropertyPage();this._propertyPages.push(r)}_createVisibilitiesPropertyPage(){const e=this._source.properties().childs().intervalsVisibilities.childs();return(0,l.createPropertyPage)((0,h.getIntervalsVisibilitiesPropertiesDefinitions)(this._propertyApplier,e,new s.TranslatedString(this._source.name(),this._source.title(p.TitleDisplayTarget.StatusLine,!0))),"visibility",_)}_createCoordinatesPropertyPage(){const e=this._coordinatesPropertyDefinitions();return null!==e?(e.definitions.length<this._source.pointsCount()&&this._source.pointAdded().subscribe(this,this._updateCoordinatesPropertyDefinitons),(0,l.createPropertyPage)(e,"coordinates",g)):null}_getYCoordinateStepWV(){return null===this._yCoordinateStepWV&&(this._yCoordinateStepWV=new c.WatchedValue(function(e){if(null!==e){const t=e.priceStep();if(null!==t)return t}return 1}(this._source.ownerSource())),this._ownerSource.priceStepChanged().subscribe(this,(()=>this._updateYCoordinateStep())),this._source.ownerSourceChanged().subscribe(this,(()=>{this._ownerSource.priceStepChanged().unsubscribeAll(this),this._ownerSource=(0,r.ensureNotNull)(this._source.ownerSource()),this._ownerSource.priceStepChanged().subscribe(this,(()=>this._updateYCoordinateStep()))}))),this._yCoordinateStepWV}_coordinatesPropertyDefinitions(){
const e=this._source.points(),t=this._source.pointsProperty().childs().points,i=[],n=this._getYCoordinateStepWV();return e.forEach(((e,r)=>{const o=t[r].childs();o&&i.push((0,u.getCoordinatesPropertiesDefinitions)(this._propertyApplier,o,e,n,f.format({count:(r+1).toString()}),this._source.name()))})),{definitions:i}}_createStylePropertyPage(){const e=this._stylePropertyDefinitions();return null!==e?(0,l.createPropertyPage)(e,"style",P):null}_stylePropertyDefinitions(){return null}_createTextPropertyPage(){const e=this._textPropertyDefinitions();return null!==e?(0,l.createPropertyPage)(e,"text",S):null}_textPropertyDefinitions(){return null}_createInputsPropertyPage(){const e=this._inputsPropertyDefinitions();return null!==e?(0,l.createPropertyPage)(e,"inputs",y):null}_inputsPropertyDefinitions(){return null}_updateYCoordinateStep(){const e=this._ownerSource.priceStep();this._getYCoordinateStepWV().setValue(e||1)}_updateCoordinatesPropertyDefinitons(){const e=this._coordinatesPropertyDefinitions();if(null!==e){(0,r.ensureDefined)(this._propertyPages.find((e=>"coordinates"===e.id))).definitions.setValue(e.definitions),this._source.points().length===this._source.pointsCount()&&this._source.pointAdded().unsubscribeAll(this)}}}},97879:(e,t,i)=>{i.r(t),i.d(t,{LineToolEmoji:()=>b});var n=i(3415),r=i(9343),o=i(32925),s=i(78861),a=i(87347),l=i(70099),c=i(90054),h=i(16738),u=i(88636),d=i(37293),p=i(78176),_=i(31558);const g={intervalsVisibilities:{...d.intervalsVisibilitiesDefaults},size:72},P={emoji:"😀",angle:.5*Math.PI},S=(0,p.extractAllPropertiesKeys)(g),y=(0,p.extractAllPropertiesKeys)(P),f=[...new Set([...y,...S,..._.commonLineToolPropertiesStateKeys])];class v extends u.LineDataSourceProperty{constructor(e){super(e)}static create(e,t,i){return new this({defaultName:"linetoolemoji",factoryDefaultsSupplier:()=>(0,c.default)(g),nonThemedDefaultsKeys:S,themedDefaultsKeys:[],state:(0,h.default)({},P,{emoji:i},t??{}),allStateKeys:f,theme:e})}}var C=i(14472),w=i(34271);class m extends w.SvgIconPaneView{_iconColor(){return null}}const x=(0,r.getLogger)("Chart.LineToolEmoji");var I;!function(e){e[e.Version=1]="Version"}(I||(I={}));class b extends l.LineToolSvgIconBase{constructor(e,t,i,n){super(e,t??b.createProperties(e.backgroundTheme().spawnOwnership()),i,n),this.version=1,this._loadViews()}name(){return"Emoji"}template(){return this.properties().template()}static createProperties(e,t){const i=v.create(e,t,s.emojiTool.value());return b._configureProperties(i),i}async _getPropertyDefinitionsViewModelClass(){return C.LineDataSourceDefinitionsViewModel}async _loadViews(){const e=this._properties.childs().emoji.value(),t=(0,n.getTwemojiUrl)(e,"svg");this._iconUrl=t;try{const i=await(0,o.fetch)(t).then((e=>e.text()));if(!this._isDestroyed){this._svgContent=i,this._onIconChanged.fire();const t=(0,a.svgRenderer)(i);null===t&&x.logWarn(`Couldn't create svg renderer for emoji ${e}`),this._setPaneViews([new m(this,this._model,t)])}}catch(t){x.logWarn(`An error ocurred while loading emoji content ${e}: ${t}`)}}}},54707:(e,t,i)=>{i.d(t,{
LineSourcePaneView:()=>P,anchorResizeCursorType:()=>_,createLineSourcePaneViewPoint:()=>g});var n=i(58978),r=i(50151),o=i(39612),s=i(2383),a=i(45801),l=i(73914),c=i(43838),h=i(4753);const u=n.colorsPalette["color-tv-blue-600"];var d,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 c.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?c.PaneCursorType.HorizontalResize:o>=p.deg22_5&&o<p.deg67_5||o>=p.deg202_5&&o<p.deg247_5?c.PaneCursorType.DiagonalNwSeResize:o>=p.deg67_5&&o<p.deg112_5||o>=p.deg247_5&&o<p.deg292_5?c.PaneCursorType.VerticalResize:o>=p.deg112_5&&o<p.deg157_5||o>=p.deg292_5&&o<p.deg337_5?c.PaneCursorType.DiagonalNeSwResize:void(0,r.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"}(d||(d={})),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 P{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 u}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(),r=i.map(((e,t)=>{const i=n[t],r=(0,l.lineSourcePaneViewPointToLineAnchorPoint)(e);return i&&(r.snappingPrice=i.price,r.snappingIndex=i.index),r}));e.append(this.createLineAnchor({...t,points:r},0))}createLineAnchor(e,t){const i=e.points.map((e=>e.point)),n=this._getOwnerSource();if(this.isLocked()){const r=this._getSelectionRenderer(t);return r.setData({bgColors:this._lineAnchorColors(i),points:e.points,visible:this.areAnchorsVisible(),hittestResult:s.HitTarget.Regular,ownerSourceId:n?.id(),barSpacing:this._model.timeScale().barSpacing()}),r}
const r=(0,o.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:r?d.TouchStrokeWidth:d.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:r?d.TouchSelectedStrokeWidth:d.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible(),clickHandler:e.clickHandler,ownerSourceId:n?.id()}),a}_getOwnerSource(){return this._ownerSource??this._source.ownerSource()}_anchorRadius(){return(0,o.lastMouseOrTouchEventInfo)().isTouch?d.TouchAnchorRadius:d.RegularAnchorRadius}_lineAnchorColors(e){const t=(0,r.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,t=this._source.properties().linecolor.value(),i){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]}}},70099:(e,t,i)=>{i.d(t,{LineToolSvgIconBase:()=>u});var n,r=i(50151),o=i(10555),s=i(22613),a=i(39612),l=i(48096),c=i(41414);function h(e,t,i){return i>=4&&(i-=4),Math.atan2(e.y-t.y,e.x-t.x)+Math.PI/4+Math.PI/2*i+Math.PI/2}!function(e){e[e.AdditionalPaddingFor72PxSize=4]="AdditionalPaddingFor72PxSize",e[e.MinSizeWithoutPadding=20]="MinSizeWithoutPadding"}(n||(n={}));class u extends c.LineDataSource{constructor(e,t,i,n){super(e,t,i,n),this._onIconChanged=new l.Delegate,this._svgContent=null,this._iconUrl=null,this._hasEditableCoordinates=new s.WatchedValue(!1),this._changePointData=null,this._loadViews()}pointsCount(){return 1}getAdditionalPadding(){return 4*Math.max(1,this.properties().childs().size.value()/72)}getChangePointForSync(e){return null}startChanging(e,t){
const i=(0,r.ensureNotNull)(this.pointToScreenPoint(this._points[0])),n=this.properties().childs(),s=n.size.value();let l;if(t)l=(0,r.ensureNotNull)(this.pointToScreenPoint(t));else{const e=s/2+this.getAdditionalPadding();l=(0,o.point)(i.y+e,i.y+e),t=(0,r.ensureNotNull)(this.screenPointToPoint(l,!0))}const c=i.subtract(l).length();this._changePointData={centerPoint:i,initialLength:c,initialSize:s,originalAngle:n.angle.value(),startChangeAngle:h(l,i,e??0),alwaysChangeAngle:(0,a.lastMouseOrTouchEventInfo)().isTouch,startPoint:t},super.startChanging(e,t)}setPoint(e,t,i){const{centerPoint:n,initialLength:o,initialSize:s,startChangeAngle:a,originalAngle:l,alwaysChangeAngle:c,startPoint:u}=(0,r.ensureNotNull)(this._changePointData),d=(0,r.ensureNotNull)(this.pointToScreenPoint(t)),p=this.properties().childs();if(e>=4||c){const t=h(d,n,e);p.angle.setValue(l+(t-a))}if(e<4){const e=n.subtract(d).length(),i=Math.max(20,s*(e/o));if(p.size.setValue(i),!c){const{index:e,price:i}=this._points[0],{index:n,price:r}=u,{index:o,price:s}=t;r<=i!=s<=i||n<=e!=o<=e?p.angle.setValue(l+Math.PI):p.angle.setValue(l)}}}getSourceIcon(){if(this._iconUrl)return{type:"url",href:this._iconUrl};const e=this.svgContent();return null===e?null:{type:"svgContent",content:e}}onSourceIconChanged(){return this._onIconChanged}svgContent(){return this._svgContent}static _configureProperties(e){super._configureProperties(e),e.addExcludedKey("angle",1)}}},73914:(e,t,i)=>{i.d(t,{LineAnchorRenderer:()=>S,lineSourcePaneViewPointToLineAnchorPoint:()=>y,lineSourcePaneViewPointToLineAnchorPoint2:()=>f,mapLineSourcePaneViewPointToLineAnchorPoint:()=>v});var n=i(10555),r=i(6453),o=i(50151),s=i(58221),a=i(87465),l=i(2383),c=i(43838),h=i(4539),u=i(10307);function d(e,t,i,n){const{point:r}=t,o=i+n/2;(0,s.drawRoundRect)(e,r.x-o,r.y-o,2*o,2*o,(i+n)/2),e.closePath(),e.lineWidth=n}function p(e,t,i,n){e.globalAlpha=.2,d(e,t,i,n),e.stroke(),e.globalAlpha=1}function _(e,t,i,n){d(e,t,i-n,n),e.fill(),e.stroke()}function g(e,t,i,n){const{point:r}=t;e.globalAlpha=.2,e.beginPath(),e.arc(r.x,r.y,i+n/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=n,e.stroke(),e.globalAlpha=1}function P(e,t,i,n){const{point:r}=t;e.beginPath(),e.arc(r.x,r.y,i-n/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=n,e.fill(),e.stroke()}class S extends u.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 l.HitTestResult(t.hitTarget??l.HitTarget.ChangePoint,{areaName:l.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,r.pointInBox)(t.point,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const t=[],i=[],n=[],r=[];for(let e=0;e<this._data.points.length;++e){const o=this._data.points[e],s=this._data.backgroundColors[e];o.square?(t.push(o),i.push(s)):(n.push(o),r.push(s))}t.length&&this._drawPoints(e,t,i,_,p),n.length&&this._drawPoints(e,n,r,P,g)}_drawPoints(e,t,i,r,s){const{context:l,horizontalPixelRatio:c,verticalPixelRatio:h}=e,u=(0,o.ensureNotNull)(this._data),d=u.radius;let p=Math.max(1,Math.floor((u.strokeWidth||2)*c));u.selected&&(p+=Math.max(1,Math.floor(c/2)));const _=Math.max(1,Math.floor(c));let g=Math.round(d*c*2);g%2!=_%2&&(g+=1);const P=_%2/2;l.strokeStyle=u.color;for(let e=0;e<t.length;++e){const o=t[e];if(!((0,a.isInteger)(o.pointIndex)&&u.linePointBeingEdited===o.pointIndex)){l.fillStyle=i[e];if(r(l,{...o,point:new n.Point(Math.round(o.point.x*c)+P,Math.round(o.point.y*h)+P)},g/2,p),!u.disableInteractions){if(null!==u.hoveredPointIndex&&o.pointIndex===u.hoveredPointIndex){const e=Math.max(1,Math.floor(u.selectedStrokeWidth*c));let t=Math.round(d*c*2);t%2!=_%2&&(t+=1);s(l,{...o,point:new n.Point(Math.round(o.point.x*c)+P,Math.round(o.point.y*h)+P)},t/2,e)}}}}}}function y(e,t=e.pointIndex,i,n,r,o,s,a,l,c){return{point:e,pointIndex:t,cursorType:i,square:n,hitTarget:r,snappingPrice:o,snappingIndex:s,nonDiscreteIndex:a,activeItem:l,possibleMovingDirections:c}}function f(e){return y(e.point,e.pointIndex,e.cursorType,e.square,e.hitTarget,e.snappingPrice,e.snappingIndex,e.nonDiscreteIndex,e.activeItem,e.possibleMovingDirections)}function v(e){return y(e)}}}]);