"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[906],{14472:(e,t,i)=>{i.r(t),i.d(t,{LineDataSourceDefinitionsViewModel:()=>x,LineDataSourceTabTypes:()=>r,pointPriceBarTitle:()=>P});var r,n=i(50151),o=i(11542),s=i(95804),l=(i(40167),i(95338)),a=i(60567),c=i(22613),d=i(73863),h=i(97578),p=i(81634),u=i(36313);!function(e){e.Visibility="visibility",e.Coordinates="coordinates",e.Style="style",e.Text="text",e.Inputs="inputs"}(r||(r={}));const _=o.t(null,void 0,i(40091)),g=o.t(null,void 0,i(78930)),f=o.t(null,void 0,i(92516)),y=o.t(null,void 0,i(70320)),v=o.t(null,void 0,i(21429)),P=o.t(null,{context:"linetool point"},i(80166));class x{constructor(e,t){this._yCoordinateStepWV=null,this._propertyPages=[],this._source=t,this._undoModel=e,this._ownerSource=(0,n.ensureNotNull)(this._source.ownerSource()),this._propertyApplier=new p.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,l.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 r=this._createCoordinatesPropertyPage();null!==r&&(r.visible=this._source.hasEditableCoordinates(),this._propertyPages.push(r));const n=this._createVisibilitiesPropertyPage();this._propertyPages.push(n)}_createVisibilitiesPropertyPage(){const e=this._source.properties().childs().intervalsVisibilities.childs();return(0,a.createPropertyPage)((0,d.getIntervalsVisibilitiesPropertiesDefinitions)(this._propertyApplier,e,new s.TranslatedString(this._source.name(),this._source.title(u.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,a.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,n.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=[],r=this._getYCoordinateStepWV();return e.forEach(((e,n)=>{const o=t[n].childs();o&&i.push((0,h.getCoordinatesPropertiesDefinitions)(this._propertyApplier,o,e,r,P.format({count:(n+1).toString()}),this._source.name()))})),{definitions:i}}_createStylePropertyPage(){const e=this._stylePropertyDefinitions();return null!==e?(0,a.createPropertyPage)(e,"style",f):null}_stylePropertyDefinitions(){return null}_createTextPropertyPage(){const e=this._textPropertyDefinitions();return null!==e?(0,a.createPropertyPage)(e,"text",y):null}_textPropertyDefinitions(){return null}_createInputsPropertyPage(){const e=this._inputsPropertyDefinitions();return null!==e?(0,a.createPropertyPage)(e,"inputs",v):null}_inputsPropertyDefinitions(){return null}_updateYCoordinateStep(){const e=this._ownerSource.priceStep();this._getYCoordinateStepWV().setValue(e||1)}_updateCoordinatesPropertyDefinitons(){const e=this._coordinatesPropertyDefinitions();if(null!==e){(0,n.ensureDefined)(this._propertyPages.find((e=>"coordinates"===e.id))).definitions.setValue(e.definitions),this._source.points().length===this._source.pointsCount()&&this._source.pointAdded().unsubscribeAll(this)}}}},40226:(e,t,i)=>{i.d(t,{LevelsProperty:()=>g});var r=i(90054),n=i(16738),o=i(87465),s=i(78176),l=i(60973);const a={prefixes:[""],range:[0,0],names:["coeff","color","visible","linestyle","linewidth"],typecheck:{pack:()=>Object(),unpack:()=>[]}};function c(e,t,i,r){return r.push(i[t]),r}function d(e,t,i,r){return r[t]=i[e],r}function h(){return[]}function p(){return{}}function u(e,t,i){return i.prefixes.forEach((r=>{const n=r+"level";for(let r=i.range[0];r<=i.range[1];r++)if(e[n+r]&&(0,o.isSameType)(e[n+r],t.typecheck())){let o=t.tpl();i.names.forEach(((i,s)=>{o=t.fill(""+s,i,e[n+r],o)})),e[n+r]=o}})),e}function _(e,t,i){return i(e,{tpl:p,fill:d,typecheck:t.typecheck.unpack},t)}class g extends s.DefaultProperty{constructor(e){const{levelsIterator:t=u,map:i={},...r}=e,n={...a,...i};r.state&&(r.state=_(r.state,n,t)),super(r),this._map=n,this._levelsIterator=t}state(e,t,i){const r=super.state(e,t);return i?r:(n=r,o=this._map,(0,this._levelsIterator)(n,{tpl:h,fill:c,typecheck:o.typecheck.pack},o));var n,o}preferences(){return(0,s.extractState)(this.state(this._excludedDefaultsKeys,void 0,!0),this._allDefaultsKeys)}applyTemplate(e,t){this.mergeAndFire((0,s.extractState)((0,n.default)((0,r.default)(t),_(e,this._map,this._levelsIterator)),this._allStateKeys,this._excludedTemplateKeys))}saveDefaults(){this._useUserPreferences&&(0,l.saveDefaults)(this._defaultName,this.preferences())}clone(){return new g(this._options())}merge(e,t){return super.merge(this._map?_(e,this._map,this._levelsIterator):e,t)}_options(){return{...super._options(),map:{...this._map},levelsIterator:this._levelsIterator}}}},44005:(e,t,i)=>{i.d(t,{CollectibleColorPropertyDirectWrapper:()=>l,CollectibleColorPropertyUndoWrapper:()=>s});var r=i(50151),n=i(43337);class o extends n.Property{constructor(e){super(),this._listenersMappers=[],
this._isProcess=!1,this._baseProperty=e}destroy(){this._baseProperty.destroy(),super.destroy()}value(){const e=this._baseProperty.value();return"mixed"===e?"":e}visible(){return this._baseProperty.visible()}setValue(e){this._isProcess=!0,this._baseProperty.setValue(""===e?"mixed":e,void 0,{applyValue:this._applyValue.bind(this)}),this._isProcess=!1,this._listenersMappers.forEach((e=>{e.method.call(e.obj,this,"")}))}subscribe(e,t){const i=i=>{this._isProcess||t.call(e,this,"")},r={obj:e,method:t,callback:i};this._listenersMappers.push(r),this._baseProperty.subscribe(e,i)}unsubscribe(e,t){const i=(0,r.ensureDefined)(this._listenersMappers.find((i=>i.obj===e&&i.method===t))?.callback);this._baseProperty.unsubscribe(e,i)}unsubscribeAll(e){this._baseProperty.unsubscribeAll(e)}}class s extends o{constructor(e,t,i){super(e),this._propertyApplier=t,this._undoText=i}_applyValue(e,t){this._propertyApplier.setProperty(e,t,this._undoText)}}class l extends o{_applyValue(e,t){e.setValue(t)}}},5352:(e,t,i)=>{i.r(t),i.d(t,{LineToolFibSpeedResistanceFan:()=>ee});var r=i(50151),n=i(11542),o=i(95804),s=i(41414),l=i(40226),a=i(65045),c=i(13896),d=i(95338),h=i(14472),p=i(91682),u=i(44005);const _=new o.TranslatedString("change {title} level {index} line visibility",n.t(null,void 0,i(51403))),g=new o.TranslatedString("change {title} level {index} line color",n.t(null,void 0,i(664))),f=new o.TranslatedString("change {title} level {index} line coeff",n.t(null,void 0,i(27154))),y=new o.TranslatedString("change {title} all lines color",n.t(null,void 0,i(59577))),v=new o.TranslatedString("change {title} background visibility",n.t(null,void 0,i(30839))),P=new o.TranslatedString("change {title} background transparency",n.t(null,void 0,i(13783))),x=new o.TranslatedString("change {title} left labels visibility",n.t(null,void 0,i(63021))),b=new o.TranslatedString("change {title} right labels visibility",n.t(null,void 0,i(8390))),T=new o.TranslatedString("change {title} top labels visibility",n.t(null,void 0,i(81301))),S=new o.TranslatedString("change {title} bottom labels visibility",n.t(null,void 0,i(62130))),m=new o.TranslatedString("change {title} reverse",n.t(null,void 0,i(50762))),w=new o.TranslatedString("change {title} grid visibility",n.t(null,void 0,i(20664))),A=new o.TranslatedString("change {title} grid line color",n.t(null,void 0,i(36467))),C=new o.TranslatedString("change {title} grid line width",n.t(null,void 0,i(30127))),L=new o.TranslatedString("change {title} grid line style",n.t(null,void 0,i(54244))),D=n.t(null,void 0,i(28683)),R=n.t(null,void 0,i(79468)),k=n.t(null,void 0,i(58557)),I=n.t(null,void 0,i(58476)),M=n.t(null,void 0,i(65e3)),V=n.t(null,void 0,i(28971)),E=n.t(null,void 0,i(74939)),N=n.t(null,void 0,i(17129)),H=n.t(null,void 0,i(81356)),W=n.t(null,void 0,i(64489));class B extends h.LineDataSourceDefinitionsViewModel{_stylePropertyDefinitions(){const e=[],t=this._source.properties().childs(),i=this._source.name(),n=(0,
p.removeSpaces)(i),s=new o.TranslatedString(i,this._source.translatedType()),l=[],a=this._source.hLevelsCount();for(let e=1;e<=a;e++){const i=t[`hlevel${e}`].childs(),r=(0,d.createLeveledLinePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,i.visible,_.format({title:s,index:e})),color:(0,d.getColorDefinitionProperty)(this._propertyApplier,i.color,null,g.format({title:s,index:e})),level:(0,d.convertToDefinitionProperty)(this._propertyApplier,i.coeff,f.format({title:s,index:e}))},{id:`${n}HLineLevel${e}`});l.push(r)}const c=(0,d.createPropertyDefinitionsLeveledLinesGroup)(l,`${n}HLeveledLinesGroup`),h=(0,d.createCheckablePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,t.showLeftLabels,x.format({title:s}))},{id:`${n}LeftLabels`,title:M}),B=(0,d.createCheckablePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,t.showRightLabels,b.format({title:s}))},{id:`${n}RightLabels`,title:V}),$=(0,d.createPropertyDefinitionsGeneralGroup)([c,h,B],`${n}HLevelGroup`,k);e.push($);const z=[],F=this._source.vLevelsCount();for(let e=1;e<=F;e++){const i=t[`vlevel${e}`].childs(),r=(0,d.createLeveledLinePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,i.visible,_.format({title:s,index:e})),color:(0,d.getColorDefinitionProperty)(this._propertyApplier,i.color,null,g.format({title:s,index:e})),level:(0,d.convertToDefinitionProperty)(this._propertyApplier,i.coeff,f.format({title:s,index:e}))},{id:`${n}VLineLevel${e}`});z.push(r)}const O=(0,d.createPropertyDefinitionsLeveledLinesGroup)(z,`${n}VLeveledLinesGroup`),Y=(0,d.createCheckablePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,t.showTopLabels,T.format({title:s}))},{id:`${n}TopLabels`,title:E}),G=(0,d.createCheckablePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,t.showBottomLabels,S.format({title:s}))},{id:`${n}BottomLabels`,title:N}),q=(0,d.createPropertyDefinitionsGeneralGroup)([O,Y,G],`${n}VLevelGroup`,I);e.push(q);const K=(0,d.createColorPropertyDefinition)({color:(0,d.getColorDefinitionProperty)(this._propertyApplier,new u.CollectibleColorPropertyUndoWrapper((0,r.ensureNotNull)(this._source.lineColorsProperty()),this._propertyApplier,null),null,y.format({title:s}),!0)},{id:`${n}AllLineColor`,title:D});e.push(K);const j=(0,d.createTransparencyPropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,t.fillBackground,v.format({title:s})),transparency:(0,d.convertToDefinitionProperty)(this._propertyApplier,t.transparency,P.format({title:s}))},{id:`${n}Background`,title:R});e.push(j);const X=t.grid.childs(),U=(0,d.createLinePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,X.visible,w.format({title:s})),color:(0,d.getColorDefinitionProperty)(this._propertyApplier,X.color,null,A.format({title:s})),width:(0,d.convertToDefinitionProperty)(this._propertyApplier,X.linewidth,C.format({title:s})),style:(0,
d.convertToDefinitionProperty)(this._propertyApplier,X.linestyle,L.format({title:s}))},{id:`${n}GridLine`,title:H});e.push(U);const J=(0,d.createCheckablePropertyDefinition)({checked:(0,d.convertToDefinitionProperty)(this._propertyApplier,t.reverse,m.format({title:s}))},{id:`${n}Reverse`,title:W});return e.push(J),{definitions:e}}}var $=i(10555),z=i(50605),F=i(84617),O=i(56265),Y=i(2383),G=i(39723),q=i(94602),K=i(25672),j=i(4753),X=i(80819),U=i(54707);class J extends U.LineSourcePaneView{constructor(e,t){super(e,t),this._leftTextRenderers=[],this._rightTextRenderers=[],this._topTextRenderers=[],this._bottomTextRenderers=[],this._renderer=null;for(let e=0;e<this._source.hLevelsCount();e++)this._leftTextRenderers.push(new j.TextRenderer),this._rightTextRenderers.push(new j.TextRenderer);for(let e=0;e<this._source.vLevelsCount();e++)this._topTextRenderers.push(new j.TextRenderer),this._bottomTextRenderers.push(new j.TextRenderer)}renderer(e){return this._invalidated&&this._updateImpl(e),this._renderer}_updateImpl(e){if(super._updateImpl(e),this._renderer=null,this._source.points().length<2)return;const t=this._source.priceScale(),i=(0,r.ensureNotNull)(this._source.ownerSource()).firstValue();if(null===i||!t||t.isEmpty()||this._model.timeScale().isEmpty())return;if(this._points.length<2)return;const n=this._source.points()[0],o=this._source.points()[1],s=this._source.properties().childs(),l=s.reverse.value(),a=[],c=l?o.price-n.price:n.price-o.price,d=l?n.price:o.price;for(let e=1;e<=this._source.hLevelsCount();e++){const n="hlevel"+e,o=(0,r.ensureDefined)(this._source.properties().child(n)).childs();if(!o.visible.value())continue;const s=o.coeff.value(),l=o.color.value(),h=d+s*c,p=t.priceToCoordinate(h,i);a.push({coeff:s,color:l,y:p,index:e})}const h=[],p=l?o.index-n.index:n.index-o.index,u=l?n.index:o.index;for(let e=1;e<=this._source.vLevelsCount();e++){const t="vlevel"+e,i=(0,r.ensureDefined)(this._source.properties().child(t)).childs();if(!i.visible.value())continue;const n=i.coeff.value(),o=i.color.value(),s=Math.round(u+n*p),l=this._model.timeScale().indexToCoordinate(s);h.push({coeff:n,color:o,x:l,index:e})}const _=new q.CompositeRenderer,g=this._points[0],f=this._points[1],y=Math.min(g.x,f.x),v=Math.min(g.y,f.y),P=Math.max(g.x,f.x),x=Math.max(g.y,f.y),b=s.grid.childs().color.value(),T=s.grid.childs().linewidth.value(),S=s.grid.childs().linestyle.value(),m=(0,O.getNumericFormatter)();for(let e=0;e<a.length;e++){const t=new $.Point(y,a[e].y),i=new $.Point(P,a[e].y);if(s.grid.childs().visible.value()){const e={points:[t,i],color:b,linewidth:T,linestyle:S,extendleft:!1,extendright:!1,leftend:K.LineEnd.Normal,rightend:K.LineEnd.Normal},r=new X.TrendLineRenderer;r.setData(e),_.append(r)}if(s.showLeftLabels.value()){const i={points:[t],text:m.format(a[e].coeff),color:a[e].color,vertAlign:z.VerticalAlign.Middle,horzAlign:z.HorizontalAlign.Right,font:F.CHART_FONT_FAMILY,offsetX:5,offsetY:0,fontsize:12,forceTextAlign:!0};this._leftTextRenderers[e].setData(i),_.append(this._leftTextRenderers[e])}
if(s.showRightLabels.value()){const t={points:[i],text:m.format(a[e].coeff),color:a[e].color,vertAlign:z.VerticalAlign.Middle,horzAlign:z.HorizontalAlign.Left,font:F.CHART_FONT_FAMILY,offsetX:5,offsetY:0,fontsize:12,forceTextAlign:!0};this._rightTextRenderers[e].setData(t),_.append(this._rightTextRenderers[e])}}for(let e=0;e<h.length;e++){const t=new $.Point(h[e].x,v),i=new $.Point(h[e].x,x);if(s.grid.childs().visible.value()){const e={points:[t,i],color:b,linewidth:T,linestyle:S,extendleft:!1,extendright:!1,leftend:K.LineEnd.Normal,rightend:K.LineEnd.Normal},r=new X.TrendLineRenderer;r.setData(e),_.append(r)}if(s.showTopLabels.value()){const i={points:[t],text:m.format(h[e].coeff),color:h[e].color,vertAlign:z.VerticalAlign.Bottom,horzAlign:z.HorizontalAlign.Center,font:F.CHART_FONT_FAMILY,offsetX:0,offsetY:5,fontsize:12};this._topTextRenderers[e].setData(i),_.append(this._topTextRenderers[e])}if(s.showBottomLabels.value()){const t={points:[i],text:m.format(h[e].coeff),color:h[e].color,vertAlign:z.VerticalAlign.Top,horzAlign:z.HorizontalAlign.Center,font:F.CHART_FONT_FAMILY,offsetX:0,offsetY:5,fontsize:12};this._bottomTextRenderers[e].setData(t),_.append(this._bottomTextRenderers[e])}}const w=s.fillBackground.value(),A=s.transparency.value();for(let e=0;e<a.length;e++){const t=new $.Point(f.x,a[e].y);if(e>0&&w){const i={p1:g,p2:t,p3:g,p4:new $.Point(f.x,a[e-1].y),color:a[e].color,transparency:A,hittestOnBackground:!0,extendLeft:!1},r=new G.ChannelRenderer;r.setData(i),_.append(r)}{const i={points:[g,t],color:a[e].color,linewidth:s.linewidth.value(),linestyle:s.linestyle.value(),extendleft:!1,extendright:!0,leftend:K.LineEnd.Normal,rightend:K.LineEnd.Normal},r=new X.TrendLineRenderer;r.setData(i),r.setHitTest(new Y.HitTestResult(Y.HitTarget.MovePoint,void 0,{type:"h",index:a[e].index})),_.append(r)}}for(let e=0;e<h.length;e++){const t=new $.Point(h[e].x,f.y);if(e>0&&w){const i={p1:g,p2:t,p3:g,p4:new $.Point(h[e-1].x,f.y),color:h[e].color,transparency:A,hittestOnBackground:!0,extendLeft:!1},r=new G.ChannelRenderer;r.setData(i),_.append(r)}{const i={points:[g,t],color:h[e].color,linewidth:s.linewidth.value(),linestyle:s.linestyle.value(),extendleft:!1,extendright:!0,leftend:K.LineEnd.Normal,rightend:K.LineEnd.Normal},r=new X.TrendLineRenderer;r.setData(i);const n={type:"v",index:h[e].index};r.setHitTest(new Y.HitTestResult(Y.HitTarget.MovePoint,void 0,n)),_.append(r)}}this.addAnchors(_),this._renderer=_}}const Q=new o.TranslatedString("erase level line",n.t(null,void 0,i(77114)));var Z;!function(e){e[e.HLevelsCount=7]="HLevelsCount",e[e.VLevelsCount=7]="VLevelsCount"}(Z||(Z={}));class ee extends s.LineDataSource{constructor(e,t,i,r){super(e,t??ee.createProperties(e.backgroundTheme().spawnOwnership()),i,r),this._setPaneViews([new J(this,this._model)])}hLevelsCount(){return 7}vLevelsCount(){return 7}pointsCount(){return 2}name(){return"Fib Speed Resistance Fan"}processErase(e,t){const i=`${t.type}level${t.index}`,n=(0,r.ensureDefined)(this.properties().child(i)).childs().visible
;e.setProperty(n,!1,Q,c.lineToolsDoNotAffectChartInvalidation)}snapTo45DegreesAvailable(){return!0}static createProperties(e,t){t&&void 0===t.reverse&&(t.reverse=!0);const i=new l.LevelsProperty({defaultName:"linetoolfibspeedresistancefan",state:t,map:{range:[1,7],prefixes:["h","v"],names:["coeff","color","visible"]},theme:e});return this._configureProperties(i),i}async _getPropertyDefinitionsViewModelClass(){return B}static _configureProperties(e){super._configureProperties(e);const t=[e.childs().grid.childs().color];for(let i=1;i<=7;i++)t.push((0,r.ensureDefined)(e.child(`hlevel${i}`)?.child("color")));for(let i=1;i<=7;i++)t.push((0,r.ensureDefined)(e.child(`vlevel${i}`)?.child("color")));e.addChild("linesColors",new a.LineToolColorsProperty(t)),e.addExcludedKey("linesColors",3)}}},54707:(e,t,i)=>{i.d(t,{LineSourcePaneView:()=>f,anchorResizeCursorType:()=>_,createLineSourcePaneViewPoint:()=>g});var r=i(58978),n=i(50151),o=i(39612),s=i(2383),l=i(45801),a=i(73914),c=i(43838),d=i(4753);const h=r.colorsPalette["color-tv-blue-600"];var p,u;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 o=Math.atan2(r,i);return o<0&&(o+=2*Math.PI),o>=u.deg337_5||o<u.deg22_5||o>=u.deg157_5&&o<u.deg202_5?c.PaneCursorType.HorizontalResize:o>=u.deg22_5&&o<u.deg67_5||o>=u.deg202_5&&o<u.deg247_5?c.PaneCursorType.DiagonalNwSeResize:o>=u.deg67_5&&o<u.deg112_5||o>=u.deg247_5&&o<u.deg292_5?c.PaneCursorType.VerticalResize:o>=u.deg112_5&&o<u.deg157_5||o>=u.deg292_5&&o<u.deg337_5?c.PaneCursorType.DiagonalNeSwResize:void(0,n.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"}(p||(p={})),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"}(u||(u={}));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 r=null!==t?t.firstValue():null;return null===r?null:i.priceToCoordinate(e,r)}anchorColor(){return h}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 r=this._source.points(),n=i.map(((e,t)=>{const i=r[t],n=(0,a.lineSourcePaneViewPointToLineAnchorPoint)(e);return i&&(n.snappingPrice=i.price,n.snappingIndex=i.index),n}));e.append(this.createLineAnchor({...t,points:n},0))}createLineAnchor(e,t){const i=e.points.map((e=>e.point)),r=this._getOwnerSource();if(this.isLocked()){const n=this._getSelectionRenderer(t);return n.setData({bgColors:this._lineAnchorColors(i),points:e.points,visible:this.areAnchorsVisible(),hittestResult:s.HitTarget.Regular,ownerSourceId:r?.id(),barSpacing:this._model.timeScale().barSpacing()}),n}const n=(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:n?p.TouchStrokeWidth:p.RegularStrokeWidth,selected:this.isSelectedSource(),selectedStrokeWidth:n?p.TouchSelectedStrokeWidth:p.RegularSelectedStrokeWidth,visible:this.areAnchorsVisible(),clickHandler:e.clickHandler,ownerSourceId:r?.id()}),l}_getOwnerSource(){return this._ownerSource??this._source.ownerSource()}_anchorRadius(){return(0,o.lastMouseOrTouchEventInfo)().isTouch?p.TouchAnchorRadius:p.RegularAnchorRadius}_lineAnchorColors(e){const t=(0,n.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,t=this._source.properties().linecolor.value(),i){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]}}},39723:(e,t,i)=>{i.d(t,{ChannelRenderer:()=>h});var r=i(50151),n=i(10555),o=i(6453),s=i(2624),l=i(2383),a=i(58221),c=i(52859),d=i(20820);class h extends d.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e,t){if(null===this._data||!this._data.hittestOnBackground)return null;const i=this._visiblePolygon(t.mediaSize);return null!==i&&(0,o.pointInPolygon)(e,i)?new l.HitTestResult(l.HitTarget.MovePointBackground):null}_drawImpl(e){if(null===this._data)return;const t=e.context,i=this._visiblePolygon(e.mediaSize);if(null!==i){t.beginPath(),t.moveTo(i[0].x,i[0].y);for(let e=1;e<i.length;e++)t.lineTo(i[e].x,i[e].y);t.fillStyle=(0,c.generateColor)(this._data.color,this._data.transparency,!0),t.fill()}}_visiblePolygon(e){const t=(0,r.ensureNotNull)(this._data),i=t.p1,o=t.p2,l=t.p3,c=t.p4;if((0,n.equalPoints)(i,o)||(0,n.equalPoints)(l,c)||(0,s.distanceToLine)(i,o,l).distance<1e-6&&(0,s.distanceToLine)(i,o,c).distance<1e-6)return null;if(e.width<=0||e.height<=0)return null;let d=[new n.Point(0,0),new n.Point(e.width,0),new n.Point(e.width,e.height),new n.Point(0,e.height)];return d=(0,a.clipPolygonByEdge)(d,i,o,[c,l]),d=(0,a.clipPolygonByEdge)(d,c,l,[i,o]),(0,n.equalPoints)(l,i)||t.extendLeft||(d=(0,a.clipPolygonByEdge)(d,l,i,[o,c])),d}}},73914:(e,t,i)=>{i.d(t,{LineAnchorRenderer:()=>y,lineSourcePaneViewPointToLineAnchorPoint:()=>v,lineSourcePaneViewPointToLineAnchorPoint2:()=>P,mapLineSourcePaneViewPointToLineAnchorPoint:()=>x});var r=i(10555),n=i(6453),o=i(50151),s=i(58221),l=i(87465),a=i(2383),c=i(43838),d=i(4539),h=i(10307);function p(e,t,i,r){const{point:n}=t,o=i+r/2;(0,s.drawRoundRect)(e,n.x-o,n.y-o,2*o,2*o,(i+r)/2),e.closePath(),e.lineWidth=r}function u(e,t,i,r){e.globalAlpha=.2,p(e,t,i,r),e.stroke(),e.globalAlpha=1}function _(e,t,i,r){p(e,t,i-r,r),e.fill(),e.stroke()}function g(e,t,i,r){const{point:n}=t;e.globalAlpha=.2,e.beginPath(),e.arc(n.x,n.y,i+r/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=r,e.stroke(),e.globalAlpha=1}function f(e,t,i,r){const{point:n}=t;e.beginPath(),e.arc(n.x,n.y,i-r/2,0,2*Math.PI,!0),e.closePath(),e.lineWidth=r,e.fill(),e.stroke()}class y 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,n.pointInBox)(t.point,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const t=[],i=[],r=[],n=[];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)):(r.push(o),n.push(s))}t.length&&this._drawPoints(e,t,i,_,u),r.length&&this._drawPoints(e,r,n,f,g)}_drawPoints(e,t,i,n,s){const{context:a,horizontalPixelRatio:c,verticalPixelRatio:d}=e,h=(0,o.ensureNotNull)(this._data),p=h.radius;let u=Math.max(1,Math.floor((h.strokeWidth||2)*c));h.selected&&(u+=Math.max(1,Math.floor(c/2)));const _=Math.max(1,Math.floor(c));let g=Math.round(p*c*2);g%2!=_%2&&(g+=1);const f=_%2/2;a.strokeStyle=h.color;for(let e=0;e<t.length;++e){const o=t[e];if(!((0,l.isInteger)(o.pointIndex)&&h.linePointBeingEdited===o.pointIndex)){a.fillStyle=i[e];if(n(a,{...o,point:new r.Point(Math.round(o.point.x*c)+f,Math.round(o.point.y*d)+f)},g/2,u),!h.disableInteractions){if(null!==h.hoveredPointIndex&&o.pointIndex===h.hoveredPointIndex){const e=Math.max(1,Math.floor(h.selectedStrokeWidth*c));let t=Math.round(p*c*2);t%2!=_%2&&(t+=1);s(a,{...o,point:new r.Point(Math.round(o.point.x*c)+f,Math.round(o.point.y*d)+f)},t/2,e)}}}}}}function v(e,t=e.pointIndex,i,r,n,o,s,l,a,c){return{point:e,pointIndex:t,cursorType:i,square:r,hitTarget:n,snappingPrice:o,snappingIndex:s,nonDiscreteIndex:l,activeItem:a,possibleMovingDirections:c}}function P(e){return v(e.point,e.pointIndex,e.cursorType,e.square,e.hitTarget,e.snappingPrice,e.snappingIndex,e.nonDiscreteIndex,e.activeItem,e.possibleMovingDirections)}function x(e){return v(e)}}}]);