"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[9843],{2171:(e,t,i)=>{i.d(t,{createTextStyleDefinition:()=>S});var o=i(91599),r=i(72769),s=i(73405),n=i(42897);const l=new r.TranslatedString("change {toolName} text visibility",o.t(null,void 0,i(67684))),a=new r.TranslatedString("change {toolName} text color",o.t(null,void 0,i(65304))),c=new r.TranslatedString("change {toolName} text font size",o.t(null,void 0,i(70052))),h=new r.TranslatedString("change {toolName} text font bold",o.t(null,void 0,i(75446))),d=new r.TranslatedString("change {toolName} text font italic",o.t(null,void 0,i(63944))),u=new r.TranslatedString("change {toolName} text",o.t(null,void 0,i(40382))),p=new r.TranslatedString("change {toolName} labels alignment vertical",o.t(null,void 0,i(28579))),g=new r.TranslatedString("change {toolName} labels alignment horizontal",o.t(null,void 0,i(81746))),_=new r.TranslatedString("change {toolName} labels direction",o.t(null,void 0,i(10377))),m=new r.TranslatedString("change {toolName} text background visibility",o.t(null,void 0,i(31397))),f=new r.TranslatedString("change {toolName} text background color",o.t(null,void 0,i(28838))),x=new r.TranslatedString("change {toolName} text border visibility",o.t(null,void 0,i(12379))),b=new r.TranslatedString("change {toolName} text border width",o.t(null,void 0,i(81802))),T=new r.TranslatedString("change {toolName} text border color",o.t(null,void 0,i(22174))),C=new r.TranslatedString("change {toolName} text wrap",o.t(null,void 0,i(55044))),y=o.t(null,void 0,i(36926)),v=o.t(null,void 0,i(69407)),P=o.t(null,void 0,i(41697)),w=o.t(null,void 0,i(3443));function S(e,t,i,o){const r={},S={id:`${(0,n.removeSpaces)(i.originalText())}Text`,title:o.customTitles&&o.customTitles.text||"",placeholder:o.placeholder??w};if(void 0===t.showText||o.hideTextCheckbox||(r.checked=(0,s.convertToDefinitionProperty)(e,t.showText,l.format({toolName:i}))),void 0!==t.textColor&&(r.color=(0,s.getColorDefinitionProperty)(e,t.textColor,t.transparency||null,a.format({toolName:i}))),void 0!==t.fontSize&&(r.size=(0,s.convertToDefinitionProperty)(e,t.fontSize,c.format({toolName:i}))),void 0!==t.bold&&(r.bold=(0,s.convertToDefinitionProperty)(e,t.bold,h.format({toolName:i}))),void 0!==t.italic&&(r.italic=(0,s.convertToDefinitionProperty)(e,t.italic,d.format({toolName:i}))),void 0!==t.text){const n=u.format({toolName:i});r.text=(0,s.convertToDefinitionProperty)(e,t.text,n,void 0),S.isEditable=Boolean(o.isEditable),S.isMultiLine=Boolean(o.isMultiLine)}if(void 0!==t.vertLabelsAlign&&(r.alignmentVertical=(0,s.convertToDefinitionProperty)(e,t.vertLabelsAlign,p.format({toolName:i})),S.alignmentVerticalItems=o.alignmentVerticalItems),void 0!==t.horzLabelsAlign&&(r.alignmentHorizontal=(0,s.convertToDefinitionProperty)(e,t.horzLabelsAlign,g.format({toolName:i})),S.alignmentHorizontalItems=o.alignmentHorizontalItems),void 0!==t.textOrientation&&(r.orientation=(0,s.convertToDefinitionProperty)(e,t.textOrientation,_.format({toolName:i}))), void 0!==t.backgroundVisible&&(r.backgroundVisible=(0,s.convertToDefinitionProperty)(e,t.backgroundVisible,m.format({toolName:i}))),void 0!==t.backgroundColor){let o=null;void 0!==t.backgroundTransparency&&(o=t.backgroundTransparency),r.backgroundColor=(0,s.getColorDefinitionProperty)(e,t.backgroundColor,o,f.format({toolName:i}))}return void 0===t.backgroundVisible&&void 0===t.backgroundColor||(S.backgroundTitle=o.customTitles&&o.customTitles.backgroundTitle||y),void 0!==t.borderVisible&&(r.borderVisible=(0,s.convertToDefinitionProperty)(e,t.borderVisible,x.format({toolName:i}))),void 0!==t.borderWidth&&(r.borderWidth=(0,s.convertToDefinitionProperty)(e,t.borderWidth,b.format({toolName:i}))),void 0!==t.borderColor&&(r.borderColor=(0,s.getColorDefinitionProperty)(e,t.borderColor,null,T.format({toolName:i}))),void 0===t.borderVisible&&void 0===t.borderColor&&void 0===t.borderWidth||(S.borderTitle=o.customTitles&&o.customTitles.borderTitle||v),void 0!==t.wrap&&(r.wrap=(0,s.convertToDefinitionProperty)(e,t.wrap,C.format({toolName:i})),S.wrapTitle=o.customTitles&&o.customTitles.wrapTitle||P),(0,s.createTextPropertyDefinition)(r,S)}},23157:(e,t,i)=>{i.r(t),i.d(t,{FibTimezoneDefinitionsViewModel:()=>V,availableAlignmentHorizontalItems:()=>S,availableAlignmentVerticalItems:()=>w});var o=i(85842),r=i(91599),s=i(72769),n=i(73405),l=i(44907),a=i(95385),c=i(89659),h=i(42897),d=i(75840);const u=new s.TranslatedString("change {title} level {index} line visibility",r.t(null,void 0,i(78521))),p=new s.TranslatedString("change {title} level {index} line color",r.t(null,void 0,i(15226))),g=new s.TranslatedString("change {title} level {index} line width",r.t(null,void 0,i(53825))),_=new s.TranslatedString("change {title} level {index} line style",r.t(null,void 0,i(26260))),m=new s.TranslatedString("change {title} level {index} line coeff",r.t(null,void 0,i(44475))),f=new s.TranslatedString("change {title} all lines color",r.t(null,void 0,i(80264))),x=new s.TranslatedString("change {title} background visibility",r.t(null,void 0,i(19514))),b=new s.TranslatedString("change {title} background transparency",r.t(null,void 0,i(44263))),T=new s.TranslatedString("change {title} labels visibility",r.t(null,void 0,i(11080))),C=new s.TranslatedString("change {title} labels alignment",r.t(null,void 0,i(17417))),y=r.t(null,void 0,i(64846)),v=r.t(null,void 0,i(36926)),P=r.t(null,void 0,i(27150)),w=[{id:a.VerticalAlign.Bottom,value:a.VerticalAlign.Top,title:r.t(null,void 0,i(65388))},{id:a.VerticalAlign.Middle,value:a.VerticalAlign.Middle,title:r.t(null,void 0,i(55636))},{id:a.VerticalAlign.Top,value:a.VerticalAlign.Bottom,title:r.t(null,void 0,i(65244))}],S=[{id:a.HorizontalAlign.Left,value:a.HorizontalAlign.Left,title:r.t(null,void 0,i(48816))},{id:a.HorizontalAlign.Center,value:a.HorizontalAlign.Center,title:r.t(null,void 0,i(93283))},{id:a.HorizontalAlign.Right,value:a.HorizontalAlign.Right,title:r.t(null,void 0,i(98415))}];class V extends l.LineDataSourceDefinitionsViewModel{_stylePropertyDefinitions(){ const e=[],t=this._source.properties().childs(),i=this._source.name(),r=(0,h.removeSpaces)(i),l=new s.TranslatedString(i,this._source.translatedType()),a=this._source.levelsCount();for(let i=1;i<=a;i++){const o=t[`level${i}`].childs(),s=(0,n.createLeveledLinePropertyDefinition)({checked:(0,n.convertToDefinitionProperty)(this._propertyApplier,o.visible,u.format({title:l,index:i})),color:(0,n.getColorDefinitionProperty)(this._propertyApplier,o.color,null,p.format({title:l,index:i})),width:(0,n.convertToDefinitionProperty)(this._propertyApplier,o.linewidth,g.format({title:l,index:i})),style:(0,n.convertToDefinitionProperty)(this._propertyApplier,o.linestyle,_.format({title:l,index:i})),level:(0,n.convertToDefinitionProperty)(this._propertyApplier,o.coeff,m.format({title:l,index:i}))},{id:`${r}LineLevel${i}`});e.push(s)}const V=(0,n.createColorPropertyDefinition)({color:(0,n.getColorDefinitionProperty)(this._propertyApplier,new d.CollectibleColorPropertyUndoWrapper((0,o.ensureNotNull)(this._source.lineColorsProperty()),this._propertyApplier,null),null,f.format({title:l}),!0)},{id:`${r}AllLineColor`,title:y});e.push(V);const D=(0,n.createTransparencyPropertyDefinition)({checked:(0,n.convertToDefinitionProperty)(this._propertyApplier,t.fillBackground,x.format({title:l})),transparency:(0,n.convertToDefinitionProperty)(this._propertyApplier,t.transparency,b.format({title:l}))},{id:`${r}Background`,title:v});e.push(D);const A=(0,n.createTwoOptionsPropertyDefinition)({checked:(0,n.convertToDefinitionProperty)(this._propertyApplier,t.showLabels,T.format({title:l})),option1:(0,n.convertToDefinitionProperty)(this._propertyApplier,t.horzLabelsAlign,C.format({title:l})),option2:(0,n.convertToDefinitionProperty)(this._propertyApplier,t.vertLabelsAlign,C.format({title:l}))},{id:`${r}Labels`,title:P,optionsItems1:new c.WatchedValue(S),optionsItems2:new c.WatchedValue(w)});return e.push(A),{definitions:e}}}},44907:(e,t,i)=>{i.r(t),i.d(t,{LineDataSourceDefinitionsViewModel:()=>T,LineDataSourceTabTypes:()=>o,pointPriceBarTitle:()=>b});var o,r=i(85842),s=i(91599),n=i(72769),l=(i(53225),i(73405)),a=i(18632),c=i(89659),h=i(5258),d=i(14405),u=i(78379),p=i(65366);!function(e){e.Visibility="visibility",e.Coordinates="coordinates",e.Style="style",e.Text="text",e.Inputs="inputs"}(o||(o={}));const g=s.t(null,void 0,i(87733)),_=s.t(null,void 0,i(18817)),m=s.t(null,void 0,i(31992)),f=s.t(null,void 0,i(79115)),x=s.t(null,void 0,i(2931)),b=s.t(null,{context:"linetool point"},i(59712));class T{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 u.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 o=this._createCoordinatesPropertyPage();null!==o&&(o.visible=this._source.hasEditableCoordinates(),this._propertyPages.push(o));const r=this._createVisibilitiesPropertyPage();this._propertyPages.push(r)}_createVisibilitiesPropertyPage(){const e=this._source.properties().childs().intervalsVisibilities.childs();return(0,a.createPropertyPage)((0,h.getIntervalsVisibilitiesPropertiesDefinitions)(this._propertyApplier,e,new n.TranslatedString(this._source.name(),this._source.title(p.TitleDisplayTarget.StatusLine,!0))),"visibility",g)}_createCoordinatesPropertyPage(){const e=this._coordinatesPropertyDefinitions();return null!==e?(e.definitions.lengththis._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=[],o=this._getYCoordinateStepWV();return e.forEach(((e,r)=>{const s=t[r].childs();s&&i.push((0,d.getCoordinatesPropertiesDefinitions)(this._propertyApplier,s,e,o,b.format({count:(r+1).toString()}),this._source.name()))})),{definitions:i}}_createStylePropertyPage(){const e=this._stylePropertyDefinitions();return null!==e?(0,a.createPropertyPage)(e,"style",m):null}_stylePropertyDefinitions(){return null}_createTextPropertyPage(){const e=this._textPropertyDefinitions();return null!==e?(0,a.createPropertyPage)(e,"text",f):null}_textPropertyDefinitions(){return null}_createInputsPropertyPage(){const e=this._inputsPropertyDefinitions();return null!==e?(0,a.createPropertyPage)(e,"inputs",x):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)}}}},75840:(e,t,i)=>{i.d(t,{ CollectibleColorPropertyDirectWrapper:()=>l,CollectibleColorPropertyUndoWrapper:()=>n});var o=i(85842),r=i(22384);class s extends r.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,"")},o={obj:e,method:t,callback:i};this._listenersMappers.push(o),this._baseProperty.subscribe(e,i)}unsubscribe(e,t){const i=(0,o.ensureDefined)(this._listenersMappers.find((i=>i.obj===e&&i.method===t))?.callback);this._baseProperty.unsubscribe(e,i)}unsubscribeAll(e){this._baseProperty.unsubscribeAll(e)}}class n extends s{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 s{_applyValue(e,t){e.setValue(t)}}},25432:(e,t,i)=>{i.d(t,{commonLineToolPropertiesStateKeys:()=>o});const o=["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 r,s,n;!function(e){e[e.NotShared=0]="NotShared",e[e.SharedInLayout=1]="SharedInLayout",e[e.GloballyShared=2]="GloballyShared"}(r||(r={})),function(e){e.BeforeAllAction="BeforeAll",e.CustomAction="CustomAction"}(s||(s={})),function(e){e.FloatingToolbarButton="FloatingToolbarButton",e.Default="Default"}(n||(n={}))},86371:(e,t,i)=>{i.d(t,{LineDataSourceProperty:()=>a});var o=i(57600),r=i(35558),s=i(85842),n=i(93445),l=i(47895);class a extends n.DefaultProperty{constructor({templateKeys:e,factoryDefaultsSupplier:t,...i}){let o=t;t&&(o=()=>{const e=t();return(0,l.applyDefaultsOverrides)(e,void 0,void 0,i.defaultName),e}),super({saveNonDefaultUserPreferencesOnly:!0,factoryDefaultsSupplier:o,...i}),this._templateKeys=(0,s.ensureDefined)(e||this._allDefaultsKeys)}template(){return(0,n.extractState)(this.state(),this._templateKeys,[])}applyTemplate(e){this.mergeAndFire((0,n.extractState)((0,r.default)((0,o.default)(this._factoryDefaultsSupplier()),e),this._templateKeys))}}},29445:(e,t,i)=>{i.r(t),i.d(t,{ LineToolTable:()=>Ke});var o=i(85842),r=i(57415),s=i(60135),n=i(11624),l=i(82014),a=i(63212),c=i(86684),h=i(47097),d=i(93445),u=i(17567),p=i(95385),g=i(88483),_=i(86371),m=i(25432),f=i(22384),x=i(33993),b=i(91903),T=i(57268),C=i(31048),y=i(14491);class v{constructor(e){this._textWidthCache=new T.TextWidthCache(1e3),this.setFont(e)}setFont(e){this._fontSize=e,this._font=(0,C.makeFont)(e,y.CHART_FONT_FAMILY)}font(){return this._font}textWidthCache(){return this._textWidthCache}getSymbolWidth(){return(0,b.measureText)("0",this._font,this._textWidthCache).width}getSymbolHeight(){return this._fontSize}}var P=i(34634);function w(e,t){return Math.max(e-16-2,t.getSymbolWidth())}function S(e,t,i){const o=(0,P.wordWrap)(e,i.font(),i.textWidthCache(),!0,t).length,r=i.getSymbolHeight();return o*r+(o-1)*(r*(1.3-1))+16+2}function V(e){return e.getSymbolHeight()+16+1}function D(e){return e.getSymbolWidth()+16+2}function A(e,t,i,o){let r=0;for(let e=0;ei[t].value()))}rowHeightValues(){const{rowsCount:e,rowHeights:t}=this.childs(),i=t.childs();return Array.from({length:e.value()},((e,t)=>i[t].value()))}setColumnWidthValues(e){const t=this.childs(),i=t.colsCount.value(),o=D(this._tableTextCache);for(let r=0;rArray.from({length:t.value()},((e,t)=>o[i].childs()[t].value()))))}static create(e,t){return new this({defaultName:"linetooltable",factoryDefaultsSupplier:()=>(0,u.factoryDefaultsForCurrentTheme)(E,L),nonThemedDefaultsKeys:M,themedDefaultsKeys:N,allStateKeys:B,themedColors:z,replaceThemedColorsOnThemeChange:!0,state:t,theme:e,templateKeys:k})}}var O,K=i(29968),U=i(83077),$=i(99680),Y=i(7919),j=i(7955),G=i(82347),X=i(28031),q=i(72445),J=i(16965);!function(e){e[e.TopLeft=0]="TopLeft",e[e.BottomLeft=1]="BottomLeft",e[e.TopRight=2]="TopRight",e[e.BottomRight=3]="BottomRight",e[e.ResizeVirtualAnchorBase=1024]="ResizeVirtualAnchorBase"}(O||(O={}));var Q,Z=i(91069),ee=i(72244),te=i(57507),ie=i(51946),oe=i(83443);function re(e){if(e{r.fillRect(e,t,i,o)})),r.fillStyle=t.borderColor}}}(e,i),function(e,t,i){if(null===t.activeEdge.row&&null===t.activeEdge.column)return;const o=Math.max(1,Math.round(7*i.horizontalPixelRatio));if(e.strokeStyle=ne,e.lineWidth=o,null!==t.activeEdge.column){const i=t.cells.cells[0][t.activeEdge.column];(0,ie.drawVerticalLine)(e,i.right,t.cells.topLeft.y,t.cells.bottomRight.y)}if(null!==t.activeEdge.row){const i=t.cells.cells[t.activeEdge.row][0];(0,ie.drawHorizontalLine)(e,i.bottom,t.cells.topLeft.x,t.cells.bottomRight.x)}}(t,i,e)}}class ce extends Y.InplaceTextLineSourcePaneView{constructor(e,t,i,o,s){super(e,t,o,s),this._renderer=new $.CompositeRenderer,this._cellsTextRenderers=[],this._lastRenderingInfo=null,this._tryActivateEditMode=(e,t)=>{this.closeTextEditor(),this._source.setInplaceEditableCellIndexes(e),super._tryActivateEditMode(e,t)},this._anchorClickHandler=()=>{this._source.setInplaceEditableCellIndexes([-1,-1])},this._tableTextCache=i,this._anchorPoints=Array.from({length:4},((e,t)=>({point:(0,r.point)(NaN,NaN),pointIndex:t,cursorType:t===O.TopLeft||t===O.BottomRight?X.PaneCursorType.DiagonalNwSeResize:X.PaneCursorType.DiagonalNeSwResize,hitTarget:U.HitTarget.ChangePoint,nonDiscreteIndex:t===O.TopRight||t===O.BottomRight}))),this._tableRenderer=new ae,this._source.setAdditionalCursorData((()=>{const e=this._getTextEditableRenderer();return e?{ color:this._source.editableTextStyle().cursorColor,...e.getTextInfo()}:{color:this._source.editableTextStyle().cursorColor,lineSpacing:0,lineHeight:0}}),(e=>{const t=this._getTextEditableRenderer();return t?t.positionToCoordinate(e):{x:0,y:0,lineNumber:0}}))}renderer(e){return this._lastRenderingInfo=e,this._invalidated&&this._updateImpl(e),this._renderer}lastRenderingInfo(){return this._lastRenderingInfo}_updateImpl(e){super._updateImpl(e),this._renderer.clear();const t=this._source.priceScale();if(!t||t.isEmpty())return;if(!this._points||this._source.isFixed()&&void 0===this._source.fixedPoint())return;const i=this._source.isFixed()?[(0,o.ensureDefined)(this._source.fixedPoint())]:this._points;if(i.length<1)return;const[s]=i,n=this._source.properties(),l=n.childs(),a=(0,K.lastMouseOrTouchEventInfo)().isTouch;let c={column:null,row:null};if((a?this._source.model().selection().dataSources()[0]:this._source.model().hoveredSource())===this._source){const e=q.mobiletouch?this._source.model().lastSelectedHittestData():this._source.model().lastHittestData(),t=e?.activeItem;(function(e){return(0,oe.isObject)(e)&&"row"in e&&"column"in e})(t)&&(c=t)}const h={columnWidths:this._source.columnWidths(),rowHeights:this._source.rowHeights(),texts:n.cellsValues(),leftTop:s,borderColor:l.borderColor.value(),backgroundColor:l.backgroundColor.value(),textColor:l.textColor.value(),fontSize:l.fontSize.value(),horzAlign:l.horzAlign.value()};this._updateTextRenderers(e,h);const d=this._rawPrecalculatedData(h,e);this._tableRenderer.setData({...h,editableCell:this._getTextEditableCellIndexes(),selectableCell:this._getSelectableCellIndexes(),cells:d,activeEdge:c,changeSize:this._model.selection().isSelected(this._source),changeOnlyActiveEdge:a}),this._setTextRendererPositions(d,e),this._renderer.append(this._tableRenderer),this._cellsTextRenderers.forEach((e=>e.forEach((e=>this._renderer.append(e)))));const{x:u,y:p}=d.topLeft,{x:g,y:_}=d.bottomRight,{horizontalPixelRatio:m,verticalPixelRatio:f}=e,x=u/m,b=p/f,T=g/m,C=_/f,y=this._source.isFixed();this._anchorPoints[O.TopLeft].point=(0,r.point)(x,b),this._anchorPoints[O.TopLeft].nonDiscreteIndex=y,this._anchorPoints[O.BottomLeft].point=(0,r.point)(x,C),this._anchorPoints[O.BottomLeft].nonDiscreteIndex=y,this._anchorPoints[O.TopRight].point=(0,r.point)(T,b),this._anchorPoints[O.BottomRight].point=(0,r.point)(T,C),this._renderer.append(this.createLineAnchor({points:this._anchorPoints,clickHandler:this._anchorClickHandler},0)),this._model.selection().isSelected(this._source)||(this.closeTextEditor(),this._source.setInplaceEditableCellIndexes([-1,-1]))}_activateEditMode(e){super._activateEditMode(e);const t=this._getTextEditableRenderer();null!==t&&(t.setCursorType(this._textCursorType()),this._updateInplaceText(t.getTextInfo()))}_textColorForCell([e,t]){const i=this._source.properties().childs().textColor.value();let o;return o=this._isEditableCell([e,t])?this._text():this._source.cellText(e,t),o?i:(0,G.generateColor)(i,50,!0)}_isEditableCell([e,t]){const i=this._getTextEditableCellIndexes() ;return i[0]===e&&i[1]===t}_updateTextRenderers(e,t){if(t)if(this._cellsTextRenderers.length!==t.texts.length||this._cellsTextRenderers[0].length!==t.texts[0].length){const e=[],i=[];for(let o=0;o{e.forEach(((e,l)=>{const a=this._cellsTextRenderers[n][l];let c={...(0,o.ensureNotNull)(a.data()),text:e,selectionHighlight:void 0,fontSize:t.fontSize,color:this._textColorForCell([n,l]),horzTextAlign:t.horzAlign,horzAlign:t.horzAlign,wordWrapWidth:w(t.columnWidths[l],this._tableTextCache),boxPadding:8};s===a&&(c={...c,...this._inplaceTextHighlight(),text:this._text()},a.isOutOfScreen(r,i)?this.closeTextEditor():this._updateInplaceText(a.getTextInfo())),a.setData(c),a.setCursorType(this._textCursorType())}))}))}}_setTextRendererPositions(e,t){const i=this._source.properties().childs().horzAlign.value(),{horizontalPixelRatio:o,verticalPixelRatio:s}=t;this._cellsTextRenderers.forEach(((t,n)=>{t.forEach(((t,l)=>{const{left:a,right:c,top:h,bottom:d}=e.cells[n][l];t.setPoint((0,r.point)((a+("right"===i?c-a:"center"===i?(c-a)/2:0))/o,h/s));const u=t.data();null!==u&&t.setData({...u,boxWidth:(c-a)/o-1,boxHeight:Math.max((d-h)/s,t.measure().height)})}))}))}_rawPrecalculatedData(e,t){const i=this._cellsTextRenderers.map(((t,i)=>Math.max(...t.map((e=>e.measure().height)),e.rowHeights[i]))),o=e.columnWidths.map(((i,o)=>A(e.leftTop.x,e.columnWidths,o,t.horizontalPixelRatio))),s=i.map(((o,r)=>A(e.leftTop.y,i,r,t.verticalPixelRatio))),n=i.map(((t,i)=>e.columnWidths.map(((t,r)=>{const[n,l]=o[r],[a,c]=s[i];return{left:n,right:l,top:a,bottom:c,columnIndex:r,rowIndex:i,text:e.texts[i][r]}}))));return{topLeft:(0,r.point)(o[0][0],s[0][0]),bottomRight:(0,r.point)(o[o.length-1][1],s[s.length-1][1]),cells:n}}_getTextEditableCellIndexes(){return this._isTextEditMode()?this._getSelectableCellIndexes():[-1,-1]}_getSelectableCellIndexes(){return this._source.inplaceEditableCellIndexes()}_getTextEditableRenderer(){const[e,t]=this._getTextEditableCellIndexes();return-1===e&&-1===t?null:this._cellsTextRenderers[e]?.[t]}}var he=i(91599),de=i(72769),ue=i(2171),pe=i(44907),ge=i(73405),_e=i(42897),me=i(89659),fe=i(23157) ;const xe=new de.TranslatedString("change {title} background color",he.t(null,void 0,i(77582))),be=new de.TranslatedString("change {title} border color",he.t(null,void 0,i(5970))),Te=new de.TranslatedString("change {title} texts alignment",he.t(null,void 0,i(88967))),Ce=he.t(null,void 0,i(36926)),ye=he.t(null,void 0,i(69407)),ve=he.t(null,void 0,i(79115)),Pe=he.t(null,void 0,i(74953));class we extends pe.LineDataSourceDefinitionsViewModel{_stylePropertyDefinitions(){const e=this._source.properties().childs(),t=this._source.name(),i=(0,_e.removeSpaces)(t),o=new de.TranslatedString(t,this._source.translatedType());return{definitions:[(0,ge.createColorPropertyDefinition)({color:(0,ge.getColorDefinitionProperty)(this._propertyApplier,e.backgroundColor,null,xe.format({title:o}))},{id:`${i}BackgroundColor`,title:Ce}),(0,ge.createColorPropertyDefinition)({color:(0,ge.getColorDefinitionProperty)(this._propertyApplier,e.borderColor,null,be.format({title:o}))},{id:`${i}BorderColor`,title:ye}),(0,ue.createTextStyleDefinition)(this._propertyApplier,{textColor:e.textColor,fontSize:e.fontSize},o,{isEditable:!0,isMultiLine:!0,customTitles:{text:ve}}),(0,ge.createOptionsPropertyDefinition)({option:(0,ge.convertToDefinitionProperty)(this._propertyApplier,e.horzAlign,Te.format({title:o}))},{id:`${i}TextAlignment`,title:Pe,options:new me.WatchedValue(fe.availableAlignmentHorizontalItems)})]}}}var Se=i(21515),Ve=i(9840),De=i(40450);class Ae extends a.InplaceTextUndoCommand{constructor(e,t,i,o,r){super(e,t,i,o),this._cellIndexes=[-1,-1],this._cellIndexes=r}_textProperty(e){const[t,i]=this._cellIndexes;return(0,o.assert)(-1!==t,"rowIndex shouldn't be -1"),(0,o.assert)(-1!==i,"columnIndex shouldn't be -1"),e.properties().childs().cells.childs()[t].childs()[i]}}var Ie=i(1479),Re=i(34773);const We=new de.TranslatedString("add column to right",s.t(null,void 0,i(86447))),He=new de.TranslatedString("add row below",s.t(null,void 0,i(18821))),Ee=new de.TranslatedString("remove column",s.t(null,void 0,i(56621))),Le=new de.TranslatedString("remove row",s.t(null,void 0,i(51008)));class ze extends Ie.UndoCommand{constructor(e,t,i,o){super(o,!0,!Re.lineToolsDoNotAffectChartInvalidation),this._sourceId=t.id(),this._model=e,this._operationType=i;const{rowsCount:r,colsCount:s}=t.properties().state();this._rowsCountPropsState=r,this._colsCountPropsState=s,this._columnWidthsPropsState=t.properties().columnWidthValues(),this._rowHeightsPropsState=t.properties().rowHeightValues(),this._cellsPropsState=t.properties().cellsValues(),this._inplaceEditCellIndexes=t.inplaceEditableCellIndexes()}undo(){const e=this._source();e.properties().recreateCellsPropsByState({cells:this._cellsPropsState,colsCount:this._colsCountPropsState,rowsCount:this._rowsCountPropsState,columnWidths:this._columnWidthsPropsState,rowHeights:this._rowHeightsPropsState}),e.setInplaceEditableCellIndexes(this._inplaceEditCellIndexes,!0)}_source(){return(0,o.ensureNotNull)(this._model.dataSourceForId(this._sourceId))}}class Ne extends ze{constructor(e,t,i){super(e,t,i,1===i?We:He)}redo(){ this._source().insertCells(this._operationType,this._inplaceEditCellIndexes)}}class Me extends ze{constructor(e,t,i){super(e,t,i,1===i?Ee:Le)}redo(){this._source().removeCells(this._operationType,this._inplaceEditCellIndexes)}}function ke(e,t,i){let o=(0,Se.sum)(e);const r=(0,Se.sum)(t);let s=Math.max(i,r);if(o===s)return[...e];if(sMath.max(t[i],e*n)));return(0,Se.sum)(l)>s+.01?ke(l,t,i):l}const Be=new de.TranslatedString("change the column width",s.t(null,void 0,i(58828))),Fe=new de.TranslatedString("change the row height",s.t(null,void 0,i(17162))),Oe=new de.TranslatedString("resize the cell",s.t(null,void 0,i(90851)));class Ke extends a.InplaceTextLineDataSource{constructor(e,t,i,o){const r=t??Ke.createProperties(e.backgroundTheme().spawnOwnership());super(e,r,i,o),this._hasEditableCoordinates=new me.WatchedValue(!1),this._widthsSnapshot=null,this._inplaceEditCellIndexes=[-1,-1],this._tablePaneView=null,this._contextMenu=null,this._tableTextCache=new v(this._properties.childs().fontSize.value()),this._properties.childs().fontSize.subscribe(this,(e=>{this._tableTextCache.setFont(e.value()),this._properties.setColumnWidthValues(this._properties.columnWidthValues()),this.updateAllViews((0,Ve.sourceChangeEvent)(this.id())),this._model.updateSource(this)})),this._properties.setTableTextCache(this._tableTextCache),this._tablePaneView=new ce(this,e,this._tableTextCache,this._openTextEditor.bind(this),this._closeTextEditor.bind(this)),this._setPaneViews([this._tablePaneView]),this.setInplaceEditableCellIndexes([-1,-1],!0),r.childs().anchored.subscribe(this,this._onAnchoredChange.bind(this))}destroy(){this._properties.childs().fontSize.unsubscribeAll(this),this._contextMenu?.then((e=>e.hide())),super.destroy()}pointsCount(){return 1}name(){return"Table"}isFixed(){return this._properties.childs().anchored.value()}anchorable(){return!0}properties(){return this._properties}template(){return this._properties.template()}snapTo45DegreesAvailable(){return!1}getPoint(e){const t=this._topLeftPoint();if(e===O.TopLeft)return t;const i=this.pointToScreenPoint(t);let o=null;if(i){const e=this.columnWidths(),t=this.rowHeights(),s=i.add((0,r.point)((0,Se.sum)(e),(0,Se.sum)(t)));o=this.screenPointToPoint(s)}if(!o)return null;switch(e){case O.TopRight:return{...t,index:o.index};case O.BottomRight:return{...o};case O.BottomLeft:return{...t,price:o.price}}return null}inplaceEditableCellIndexes(){return this._inplaceEditCellIndexes}setInplaceEditableCellIndexes(e,t=!1){const[i,o]=this._inplaceEditCellIndexes,[r,s]=e;if(!t&&i===r&&o===s)return;this._destroyEditableTextSubscriptions?.();const n=this.properties().childs().editableText,l={};if(-1!==r&&-1!==s){const e=this.properties().childs().cells.childs()[r].childs()[s];n.setValue(e.value()),n.subscribe(l,(()=>e.setValue(n.value()))),e.subscribe(l,(()=>n.setValue(e.value()))),this._destroyEditableTextSubscriptions=()=>{n.unsubscribeAll(l),e.unsubscribeAll(l)}}this._inplaceEditCellIndexes=[r,s], this._editableText.setValue(n.value()),this.updateAllViews((0,Ve.sourceChangeEvent)(this.id())),this._model.updateSource(this)}switchActiveCell(e=!1){let[t,i]=this._inplaceEditCellIndexes;if(-1===t&&-1===i)return!1;const{colsCount:o,rowsCount:r}=this.properties().state(),s=o*r,n=(t*o+i+(e?s-1:1))%s;return t=Math.floor(n/o)%r,i=n%o,this._saveEditedText(),this.setInplaceEditableCellIndexes([t,i],!0),!0}insertCells(e,t){const i=this.properties().state();let{rowsCount:o,colsCount:r}=i;const s=this.properties().cellsValues(),n=this.properties().columnWidthValues(),l=this.properties().rowHeightValues();let[a,c]=t??this._inplaceEditCellIndexes,h=!1;switch(-1===a&&-1===c&&(h=!0,a=o-1,c=r-1),e){case 0:const e=a+1,t=new Array(r).fill("");e>=o?s.push(t):s.splice(e,0,t),l.splice(e,0,0),o++;break;case 1:const i=c+1;for(const e of s)e.splice(i,0,"");n.splice(i,0,120),r++}this._properties.recreateCellsPropsByState({rowsCount:o,colsCount:r,columnWidths:n,rowHeights:l,cells:s}),this.setInplaceEditableCellIndexes(h?[-1,-1]:[a,c],!0)}isRemoveCellsAvailable(e){const t=this._properties.cellsValues();return(0!==e||1!==t.length)&&(1!==e||1!==t[0].length)}removeCells(e,t){const[i,o]=t??this._inplaceEditCellIndexes;if(-1===i&&-1===o)return;let{rowsCount:r,colsCount:s}=this.properties().state();const n=this.properties().cellsValues(),l=this.properties().columnWidthValues(),a=this.properties().rowHeightValues();switch(e){case 0:n.splice(i,1),a.splice(i,1),r--;break;case 1:for(const e of n)e.splice(o,1);l.splice(o,1),s--}this._properties.recreateCellsPropsByState({rowsCount:r,colsCount:s,columnWidths:l,rowHeights:a,cells:n});const c=Math.min(i,r-1),h=Math.min(o,s-1);this.setInplaceEditableCellIndexes([c,h],!0)}async additionalActions(e,t="Default"){let o=[];return"Default"===t&&(o=(await Promise.all([i.e(5150),i.e(6882)]).then(i.bind(i,31511))).tableActions(this,e)),{actions:o,placement:"BeforeAll"}}editableTextProperties(){return{text:this.properties().childs().editableText,textColor:this.properties().childs().textColor}}cellText(e,t){return this.properties().childs().cells.childs()[e].childs()[t].value()}changePointUndoText(e){const{row:t,column:i}=re(e);return null===t&&null===i?l.changePointUndoText:null===t?Be:null===i?Fe:Oe}startChanging(e,t){this.isFixed()&&this.restoreFixedPoint();const[i,r]=this.columnWidths(!0),[s,n]=this.rowHeights(!0),l=(0,Se.sum)(i),a=(0,Se.sum)(s),c=(0,Se.sum)(n);e??=O.TopLeft;const h=this._topLeftPoint(),d=(0,o.ensureNotNull)(this.priceScale()),u=(0,o.ensure)(this.ownerSource()?.firstValue()),p=d.priceToCoordinate(h.price,u),g=d.coordinateToPrice(p+a,u),_=this._model.timeScale().indexToCoordinate(h.index),m=this._model.timeScale().coordinateToFloatIndex(_+l);switch(e){case O.BottomLeft:t={index:h.index,price:g};break;case O.TopRight:t={index:m,price:h.price};break;case O.BottomRight:t={index:m,price:g};break;default:t={...h}}this._widthsSnapshot={columnWidths:i,columnMinWidths:r,rowHeights:s,rowMinHeights:n,minTotalHeight:c,totalWidth:l,totalHeight:a,startPoint:{...t},topLeftPoint:h},super.startChanging(e,t)} setPoint(e,t,i,s){const n=this._model.timeScale(),l=(0,o.ensureNotNull)(this.priceScale()),a=(0,o.ensure)(this.ownerSource()?.firstValue()),c=this._model.mainSeries().interval(),h=(0,o.ensureNotNull)(this._widthsSnapshot),d=(0,o.ensureNotNull)(this.pointToScreenPoint(h.startPoint));let u=(0,o.ensureNotNull)(this.pointToScreenPoint(t));const{totalWidth:p,totalHeight:g,columnWidths:_,columnMinWidths:m,rowHeights:f,rowMinHeights:x}=h,b=this._topLeftPoint(),T=(0,o.ensureNotNull)(this.pointToScreenPoint(b)),C=e===O.TopLeft||e===O.BottomLeft,y=e===O.TopLeft||e===O.TopRight,v=d.add((0,r.point)(C?p:-p,y?g:-g)),P=D(this._tableTextCache);let{x:A,y:I}=u;if(!s){const e=P*h.columnWidths.length,t=h.minTotalHeight;A=C?Math.min(u.x,v.x-e):Math.max(u.x,v.x+e),I=y?Math.min(u.y,v.y-t):Math.max(u.y,v.y+t),u=(0,r.point)(A,I)}const R=this.isFixed(),W=C&&!R?Math.floor(n.coordinateToFloatIndex(A)):n.coordinateToFloatIndex(A);A=n.indexToCoordinate(W);const H=l.coordinateToPrice(I,a),E=d.x-A,L=d.y-I;switch(e){case O.TopLeft:R?this.addFixedPoint(u):this._setPoint(0,{...t,price:H,index:W,interval:c}),s||(this._properties.setColumnWidthValues(this._correctColumnWidths(ke(_,m,p+E),h)),this._properties.setRowHeightValues(ke(f,x,g+L)));break;case O.BottomLeft:R?this.addFixedPoint((0,r.point)(u.x,T.y)):this._setPoint(0,{...t,index:W,price:b.price,interval:c}),s||(this._properties.setColumnWidthValues(this._correctColumnWidths(ke(_,m,p+E),h)),this._properties.setRowHeightValues(ke(f,x,g-L)));break;case O.TopRight:R?this.addFixedPoint((0,r.point)(T.x,u.y)):this._setPoint(0,{...t,price:H,index:b.index,interval:c}),s||(this._properties.setColumnWidthValues(ke(_,m,p-E)),this._properties.setRowHeightValues(ke(f,x,g+L)));break;case O.BottomRight:s||(this._properties.setColumnWidthValues(ke(_,m,p-E)),this._properties.setRowHeightValues(ke(f,x,g-L)))}if(e>=O.ResizeVirtualAnchorBase){const{column:t,row:i}=re(e);if(null!==t){const e=(0,Se.sum)(_.slice(0,t))+T.x,i=Math.max(P,u.x-e),o=_.map(((e,o)=>o===t?i:e));this._properties.setColumnWidthValues(o)}if(null!==i){const e=(0,Se.sum)(f.slice(0,i))+T.y;let t=V(this._tableTextCache);for(let e=0;e<_.length;e++)t=Math.max(t,S(this.cellText(i,e),w(_[e],this._tableTextCache),this._tableTextCache));const o=Math.max(t,u.y-e),r=f.map(((e,t)=>t===i?o:e));this._properties.setRowHeightValues(r)}}else;}columnWidths(e){const t=this._properties.columnWidthValues();if(!e)return t;const i=D(this._tableTextCache),o=t.map((e=>i));return[t,o]}rowHeights(e){const t=this.properties().rowHeightValues(),i=this.columnWidths(),o=[],r=t.map(((t,r)=>{let s=V(this._tableTextCache),n=Math.max(t,s);for(let e=0;et.showTableContextMenu(this,(()=>{this._contextMenu=null}),e))))}insertCellsUndoCommand(e){return new Ne(this.model(),this,e)}removeCellsUndoCommand(e){return this.isRemoveCellsAvailable(e)?new Me(this.model(),this,e):null}static createProperties(e,t){const i=F.create(e,t);return this._configureProperties(i),i}_closeTextEditor(e){super._closeTextEditor(),0===e&&(this._inplaceEditCellIndexes=[-1,-1])}_changeEditableTextUndoCommand(e,t){return new Ae(this._model,this,e,t,(0,o.ensureNotNull)(this._inplaceEditCellIndexes))}async _getPropertyDefinitionsViewModelClass(){return we}_createDataSourceBackgroundColorWV(){return(0,n.convertPropertyToWatchedValue)(this.properties().childs().backgroundColor).ownership()}static _addCollectedProperties(e){}_topLeftPoint(){return this.isFixed()?(0,o.ensureNotNull)(this.screenPointToPoint((0,o.ensureDefined)(this._fixedPoint),!0)):this._points[0]}_correctColumnWidths(e,t){const i=(this._tablePaneView?.lastRenderingInfo()??De.dpr1PixelRatioInfo).horizontalPixelRatio,r=(0,o.ensureNotNull)(this.pointToScreenPoint(t.topLeftPoint)).x,[,s]=A(r,t.columnWidths,t.columnMinWidths.length-1,i),n=(0,o.ensureNotNull)(this.pointToScreenPoint(this._topLeftPoint())).x,l=(0,Se.sum)(e),a=s/i-n;return e[e.length-1]+=a-l,e}}},16965:(e,t,i)=>{i.d(t,{LineToolTextRenderer:()=>r});var o=i(61208);class r extends o.TextRenderer{getTextInfo(){const e=this._getInternalData(),t=this.fontStyle(),i=this._getFontInfo();return{...e,lineHeight:this.lineHeight(),lineSpacing:this.lineSpacing(),font:t,fontSize:i.fontSize,centerRotation:this.centerTextRotation()??void 0}}setCursorType(e){this._hitTest.data()?.cursorType!==e&&this._hitTest.mergeData({cursorType:e})}}},17567:(e,t,i)=>{i.d(t,{factoryDefaultsForCurrentTheme:()=>a});var o=i(35558),r=i(57600),s=i(85842),n=i(49841),l=i(47097);function a(e,t){const i=n.watchedTheme.value()??l.StdTheme.Light,a=(0,r.default)(e);return(0,o.default)(a,(0,s.ensureDefined)(t.get(i))),a}}}]);