"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[56303],{846778:(e,t,i)=>{i.d(t,{showPasteLineToolHint:()=>c});var s=i(444372),r=i(62802),n=i(638456),o=i(470316),l=i(244842);const a=s.t(null,void 0,i(13262));function c(e,t){l.enabled("popup_hints")&&!n.CheckMobile.any()&&Promise.all([i.e(66458),i.e(51439),i.e(90385),i.e(26166)]).then(i.bind(i,410837)).then((i=>{const s=new i.ChartEventHintRenderer(e),n=a.format({shortcut:(0,o.humanReadableHash)(o.Modifiers.Mod+86)});let l=null;s.show(n,(()=>{null!==l&&(clearTimeout(l),l=null,r.setValue(t,!0,{forceFlush:!0}))})),l=setTimeout((()=>{l=null,s.hide()}),5e3)}))}},1500:(e,t,i)=>{i.d(t,{solutionIds:()=>s}) ;const s=JSON.parse('{"EXTENDED_HOURS":43000502023,"PRE_MARKET":43000502023,"POST_MARKET":43000502023,"SPREAD_CHARTS":43000502298,"ALERTS":43000520149,"ALERT_ON_STRATEGY":43000481368,"ALERT_WEBHOOK":43000529348,"ALERT_DESCRIPTION_PLACEHOLDER":43000531021,"ALERT_RECEIVE_NOTIFICATIONS_OH_PHONE":43000474389,"ALERT_USE_ALTERNATIVE_EMAIL":43000474394,"ALERT_WEBHOOK_CREDENTIALS":43000722015,"VOLUME_PROFILE":43000502040,"VOLUME_PROFILE_INDICATOR":43000557450,"RENKO":43000502284,"KAGI":43000502272,"LINE_BREAK":43000502273,"PNF":43000502276,"FINANCIAL_DATA":43000543506,"BROKER_RATING":43000542490,"CRYPTO_MARKET_CAP":43000540941,"CRYPTO_PAYMENT":43000485536,"ALERT_ON_SPREAD":43000478406,"ALERT_ON_LOG_SCALE":43000690942,"ALERT_ON_CUSTOM_SCRIPT":43000478415,"ALERT_FUNCTION":43000597494,"SMS_VERIFICATION":43000553429,"MAGNET_MODE":43000537270,"PRIVACY_SETTINGS":43000548335,"PUBLICATION_TYPE":43000609497,"SCRIPT_ACCESS":43000482573,"FREE_USER_FAQS":43000590947,"STRATEGY_UNREALISTIC_RESULTS":43000481029,"STRATEGY_FUTURE_DATA":43000614705,"STREAM_RULES":43000591348,"HOW_TO_USE_PAPER":43000516466,"HOW_TO_USE_CQG":43000516372,"HOW_TO_USE_OANDA":43000516375,"HOW_TO_USE_FOREXCOM":43000516374,"FAVORITE_IDEA":43000555216,"YOUTUBE_ERROR":43000612153,"AUTHORS_INSTRUCTIONS_PUBCLICATION":43000549951,"AUTHORS_INSTRUCTIONS_EDIT":43000614618,"SCRIPT_INSTRUCTIONS":43000482573,"BAR_REPLAY_UNAVAILABILITY":43000475470,"WHAT_IS_CBOE_BZX_EXCHANGE":43000473924,"GOPRO_UPGRADE_DESCRIPTION":43000473324,"GOPRO_DOWNGRADE_DESCRIPTION":43000485437,"GOPRO_RENEW_ANNUAL_MONTHLY_DESCRIPTION":43000644491,"FINANCIALS_OWNERSHIP":43000699479,"FINANCIALS_VALUATION_SUMMARY":43000699484,"FINANCIALS_VALUATION_RATIOS":43000699495,"FINANCIALS_GROWTH_AND_PROFITABILITY":43000699485,"FINANCIALS_REVENUE_TO_PROFIT_CONVERSION":43000699496,"FINANCIALS_REVENUE_BREAKDOWN_BY_SOURCE":43000699487,"FINANCIALS_REVENUE_BREAKDOWN_BY_COUNTRY":43000699497,"FINANCIALS_REVENUE_ESTIMATES":43000699489,"FINANCIALS_EARNINGS_ESTIMATES":43000699498,"FINANCIALS_DIVIDEND_SUMMARY":43000699500,"FINANCIALS_DIVIDEND_HISTORY":43000699501,"FINANCIALS_DEBT_LEVEL":43000699502,"FINANCIALS_POSITION":43000699503,"BROKERAGE_REVIEWS":43000591351,"CHANGE_SUBSCRIPTION":43000635806,"PINE_LIBRARY_INFO":43000638371,"HOW_TO_CREATE_A_STREAM":43000646171,"HOW_DO_I_UPDATE_DESKTOP_APP":43000647779,"TECHNICAL_RATINGS":43000614331,"BACKTESTING_WIDGET":43000562362,"BACKTESTING_NO_DATA":43000478450,"BACKEND_CONNECTIONS":43000694474,"DEEP_BACKTESTING_WIDGET":43000670566,"DEEP_BACKTESTING":43000666199,"DEEP_BACKTESTING_AVAILABLE_DATA":43000668210,"BETA_BROKERS":43000673434,"VIDEO_UPLOAD_FAILED":43000666607,"VIDEO_DEVICE_ACCESS":43000677209,"PUBLIC_INVITE_ONLY_SCRIPTS":43000614617,"HOW_DOES_BRACKETS_MANAGEMENT_WORK":43000631987,"HOW_TO_SEE_THE_DEEPEST_HIST_DATA":43000687053,"I_CANT_SEE_ALL_HIST_DATA_ON_RES_LOWER_THAN_DAY":43000480679,"IDEAS_ON_CHART":43000694285,"GET_A_REFUND":43000485430,"USE_SETTLEMENT_AS_CLOSE_ON_DAILY_INTREVAL":43000685268,"ADJUST_FOR_CONTRACT_CHANGES":43000685266,"SWITCHING_CONTINUOUS_FUTURES_CONTRACTS":43000689313,"ADJUST_DATA_FOR_DIVIDENDS":43000590597,"WHY_IS_MY_ACCOUNT_BANNED":43000674726,"HOW_TO_PUBLISH_A_VIDEO_IDEA":43000476752,"WHAT_ARE_TRADINGVIEW_LIVE_STREAMS_BEST_PRACTICES":43000685377,"TELL_ME_MORE_ABOUT_THE_COMMUNITY_SCRIPTS":43000558522,"HOW_TO_POST_AWESOME_IDEAS_AND_GET_LOTS_OF_LIKES":43000603748,"ABOUT_EXPERT_PLAN":43000677382,"CONNECTIONS_LIMIT_EXCEEDED":43000693877,"ACCOUNT_RECOVERY":43000619597,"HOW_TO_SYNC_CHARTS_ON_LAYOUT":43000629992,"HOW_TO_SEE_BUILTIN_INDICATOR_SOURCE":43000481659,"HOW_CAN_I_GET_ACCESS_TO_STREAMS":43000685376,"MULTI_CHART_MODE":43000629990,"QUICK_SEARCH":43000659671,"WHATS_AN_INDICATOR":43000543626,"CHART_TYPES":43000703407,"DRAWING_TOOLS":43000703396,"CUSTOM_INTERVALS":43000543883,"CUSTOM_RANGE_BARS":43000474007,"CANDLESTICK_PATTERNS":43000584462,"MULTI_TIMEFRAME_CHARTS":43000502591,"BAR_REPLAY":43000712747,"PINE_SCRIPT":43000561836,"SCREENER_OVERVIEW":43000635796,"STREAMS_OBS_SETUP":43000639464,"AUTO_CHART_PATTERNS":43000690464,"HOW_TO_PROTECT_YOUR_ACCOUNT":43000582277,"PLUS_BUTTON":43000645256,"PLAN_UPGRADED_BUT_DATA_STILL_DELAYED":43000471705,"WHY_TAX_HAS_BEEN_ADDED_TO_MY_BILL":43000684741,"COMPARE_SYMBOLS_TOOL":43000543053,"SAVED_CHART":43000692404,"CUSTOM_INDICATOR":43000543048,"BIST_MIXED_SUBSCRIPTION":43000609137,"WHY_RENKO_NOT_WORK":43000711502,"ALERTS_SEPARATION_BY_TYPE":43000696403,"HOW_TO_SET_UP_ALERTS":43000595315,"PINE_SCRIPT_STRATEGIES":43000562362,"ECONOMIC_CALENDAR":43000707391,"DIFFERENCE_BETWEEN_PRO_AND_NONPRO_PLANS":43000677382,"HOW_TO_USE_MINDS":43000690226,"HOW_TO_USE_TRADINGVIEW_CHAT":43000604448,"PAPER_COMPETITION":43000593579,"PAPER_COMPETITION_ACCOUNT":43000721315,"PAPER_COMPETITION_PRIZE":43000721317,"PAPER_COMPETITION_FREE_ACCOUNT":43000721310,"PUBLISHING_AND_UPDATING_IDEAS":43000591338,"USING_MINDS":43000696301,"PUBLISH_VIDEO_IDEA":43000476752,"STREAM_GUIDE":43000646171,"TAROT_DECK":43000724020,"VAT_NUMBER_GUIDE":43000721910,"AVAILABLE_COMPETITION_INSTRUMENTS":43000721311,"PINE_PERFORMANCE_PROFILER":43000725216,"PINE_LOGS_INFO":43000710876,"INDICATORS":43000474048,"CHART_DATA_EXPORT":43000537255,"TIME_PRICE_OPPORTUNITIES":43000713306,"TICK_INTERVALS":43000709225}') },626333:(e,t,i)=>{function s(e,t=window){const i="theme-"+e,s=t.document.documentElement.classList;for(const e of Array.from(s))e.startsWith("theme-")&&e!==i&&s.remove(e);s.add(i)}i.d(t,{applyTheme:()=>s})},983898:(e,t,i)=>{function s(e,t,i){const s=e.get(t);return void 0!==s?s:(e.set(t,i),i)}function r(e,t,i){const s=e.get(t);if(void 0!==s)return s;const r=i();return e.set(t,r),r}function n(e,t,i,r){const n=s(e,t,new Map);return s(n,i,r)}function o(e,t,i,n){return r(s(e,t,new Map),i,n)}function l(e,t,i,r,n){const o=s(e,t,new Map),l=s(o,i,new Map);return s(l,r,n)}i.d(t,{AbstractMapContainer:()=>a,getDefault2:()=>n,getDefault2Lazy:()=>o,getDefault3:()=>l});class a{constructor(){this._map=new Map,this._size=0}size(){return this._size}clear(){this._map.clear(),this._size=0}}},407478:(e,t,i)=>{i.d(t,{CircularCacheBuffer:()=>n});var s=i(650151);function r(e){const{prevItem:t,nextItem:i}=e;null!==t&&(t.nextItem=i),null!==i&&(i.prevItem=t)}class n{constructor(e=0,t=1.3){this._cache=new Map,this._lastItem=null,this._firstItem=null,this._size=e,this._sizeLimited=e>0,this._capacityFactor=t}set(e,t){const i={key:e,value:t,prevItem:this._lastItem,nextItem:null};null!==this._lastItem&&(this._lastItem.nextItem=i);const s=this._cache.get(e);return void 0!==s&&(r(s),s===this._firstItem&&(this._firstItem=s.nextItem)),this._cache.set(e,i),this._lastItem=i,null===this._firstItem&&(this._firstItem=i),this._sizeLimited&&this._cache.size>this._size*this._capacityFactor&&this._removeExtraItems(),this}has(e){return this._cache.has(e)}get(e){var t;const i=this._cache.get(e);if(void 0===i)return i;if(i===this._firstItem&&(this._firstItem=null!==(t=i.nextItem)&&void 0!==t?t:i),i!==this._lastItem){r(i);const e=(0,s.ensureNotNull)(this._lastItem);e.nextItem=i,i.prevItem=e,i.nextItem=null,this._lastItem=i}return i.value}clear(){this._cache.clear(),this._firstItem=null,this._lastItem=null}delete(e){const t=this._cache.get(e);return void 0!==t&&(r(t),t===this._lastItem&&(this._lastItem=t.prevItem),t===this._firstItem&&(this._firstItem=t.nextItem)),this._cache.delete(e)}_removeExtraItems(){const e=this._cache.size-this._size;let t=(0,s.ensureNotNull)(this._firstItem);for(let i=0;i{i.d(t,{TranslatedString:()=>s});class s{constructor(e,t){this._originalText=e,this._translatedText=t}originalText(){return this._originalText}translatedText(){return this._translatedText}format(e){const t={},i={};for(const r of Object.keys(e)){const n=e[r];n instanceof s?(t[r]=n.originalText(),i[r]=n.translatedText()):(t[r]=n.toString(),i[r]=n.toString())}const r=this._originalText.format(t),n=this._translatedText.format(i);return new s(r,n)}}},938550:(e,t,i)=>{i.d(t,{WatchedObject:()=>o});var s=i(401580),r=i(389137);function n(e,t){return(0,r.deepEquals)(e,t)[0]}class o extends s.WatchedValue{constructor(e,t=n){super(e),this._comparator=t}setValue(e,t){!1===this._comparator(this.value(),e)&&super.setValue(e,t)}}},199471:(e,t,i)=>{i.d(t,{ addExclusionArea:()=>C,addExclusionAreaByScope:()=>x,calcTextHorizontalShift:()=>S,clearRect:()=>_,createBoundCanvas:()=>P,createDisconnectedCanvas:()=>m,createDisconnectedCanvasByRenderingInfo:()=>v,disableSelection:()=>b,drawScaled:()=>f,drawWithExclusionAreaByScope:()=>w,fillRect:()=>p,getBindingRenderingInfo:()=>u,getContext2D:()=>h,getPrescaledContext2D:()=>d,measureText:()=>I,tryApplySuggestedCanvasBitmapSize:()=>y});var s=i(743068),r=i(650151),n=i(109154),o=i(294162),l=i(31341),a=i(638456);function c(e){return{horizontalPixelRatio:Math.max(1,e.bitmapSize.width/e.canvasElementClientSize.width),verticalPixelRatio:Math.max(1,e.bitmapSize.height/e.canvasElementClientSize.height)}}function u(e){return{...c(e),bitmapSize:e.bitmapSize,mediaSize:e.canvasElementClientSize}}function h(e){const t=(0,r.ensureNotNull)(e.getContext("2d"));return t.setTransform(1,0,0,1,0,0),t}function d(e){const t=(0,r.ensureNotNull)(e.getContext("2d")),i=(0,n.getCanvasDevicePixelRatio)(e);return t.setTransform(i,0,0,i,0,0),t}function p(e,t,i,s,r,n){e.save(),e.fillStyle=n,e.fillRect(t,i,s,r),e.restore()}function _(e,t,i,s,r,n){e.save(),e.globalCompositeOperation="copy",e.fillStyle=n,e.fillRect(t,i,s,r),e.restore()}function f(e,t,i,s){e.save(),e.scale(t,i),s(),e.restore()}function m(e,t,i){const s=g(e);return void 0===i&&(i=(0,n.getCanvasDevicePixelRatio)(s)),s.width=t.width*i,s.height=t.height*i,s}function v(e,t){const{bitmapSize:i,mediaSize:s}=t,r=g(e);return r.style.width=`${s.width}px`,r.style.height=`${s.height}px`,r.width=i.width,r.height=i.height,r}function g(e){const t=e.createElement("canvas");return b(t),t}function P(e,t){const i=g((0,r.ensureNotNull)(e.ownerDocument));e.appendChild(i);const n=(0,s.bindCanvasElementBitmapSizeTo)(i,{type:"device-pixel-content-box",transform:(e,t)=>0===e.width||0===e.height?e:{width:Math.max(e.width,t.width),height:Math.max(e.height,t.height)}});return n.resizeCanvasElement(t),n}function y(e){const t=e.suggestedBitmapSize;return null!==t&&t.width>0&&t.height>0&&(e.applySuggestedBitmapSize(),!0)}function S(e,t){return"center"===e.textAlign?0:(0,l.isRtl)()?"start"===e.textAlign||"right"===e.textAlign?t:0:"start"===e.textAlign||"left"===e.textAlign?0:t}function b(e){e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.msUserSelect="none",e.style.MozUserSelect="none",e.style.webkitTapHighlightColor="transparent"}function x(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r,bitmapSize:n}=e;i.beginPath(),i.rect(0,0,n.width,n.height);for(let e=0;e{i.r(t),i.d(t,{CHART_FONT_FAMILY:()=>l,CHART_MONOSPACE_FONT_FAMILY:()=>a,setChartFontFamily:()=>o});var s=i(314802);const r="'Trebuchet MS', Roboto, Ubuntu, sans-serif",n=`-apple-system, BlinkMacSystemFont, ${r}`;function o(e){l=e}let l=((0,s.isOnMobileAppPage)("old"),r);const a="monospace";{const e=["U+2E80-2FD5","U+3040-309F","U+1B100-1B12F","U+1AFF0-1AFFF","U+1B000-1B0FF","U+1B130-1B16F","U+3190-319F","U+30A0-30FF","U+31F0-31FF","U+3400-4DBF","U+4E00-9FFF","U+0E00-0E7F"],t=l;(async()=>{if(!/iPhone OS 15_\d+?/.test(navigator.userAgent))return n;{if(["kr","zh_CN","zh_TW"].includes(window.locale))return l;const t=new FontFace("ChartIosFont","local(Helvetica), local(Arial)",{unicodeRange:e.join(", ")});try{return document.fonts.add(await t.load()),`ChartIosFont, ${n}`}catch(e){return l}}})().then((e=>{t===l&&o(e)}))}},543373:(e,t,i)=>{i.d(t,{showCustomUrlEventDialog:()=>l});var s=i(444372),r=i(779923);const n=s.t(null,void 0,i(468988)),o=s.t(null,void 0,i(620036));async function l(e){const{onConfirm:t,onClose:i,title:s,placeholderText:l}=e;return(0,r.showRename)({title:s,text:"",placeholder:l,mainButtonText:n,cancelButtonText:o,onRename:({newValue:e,dialogClose:i})=>{t(e),i()},onClose:i})}},109154:(e,t,i)=>{function s(e){var t,i;return Math.max(1,(null===(i=null===(t=e.ownerDocument)||void 0===t?void 0:t.defaultView)||void 0===i?void 0:i.devicePixelRatio)||1)}i.d(t,{getCanvasDevicePixelRatio:()=>s})},270294:(e,t,i)=>{i.d(t,{CHART_WIDGET_COLLECTION_SERVICE:()=>r,CollectionViewMode:()=>o,chartWidgetCollectionService:()=>n});var s=i(564894);const r={id:"ChartWidgetCollectionService"};function n(){return(0,s.hasService)(r)?(0,s.service)(r):null}var o;!function(e){e.Multichart="multichart",e.ForceFullscreen="force-fullscreen"}(o||(o={}))},86121:(e,t,i)=>{i.d(t,{lastMouseOrTouchEventInfo:()=>r,setLastMouseOrTouchEventInfo:()=>n});let s=(0,i(638456).supportTouch)()?{isTouch:!0,stylus:!1}:{isTouch:!1};function r(){return s}function n(e){s=e.isTouch?{isTouch:!0,stylus:e.stylus}:{isTouch:!1}}},318041:(e,t,i)=>{i.d(t,{TextImageCachesContainer:()=>l});var s=i(650151),r=i(983898),n=i(511131),o=i(600642);class l extends r.AbstractMapContainer{constructor(e){super(),this._maxSize=e,this._keysQueue=[]}get(e){const{fontSize:t,text:i,align:s,font:l,lineSpacing:a=0}=e;if(!i||!t||!s)return null;const c=(0,n.makeFont)(t,l),u=(0,r.getDefault3)(this._map,a,s,c,new Map);let h=u.get(i);return void 0!==h||(this._size>=this._maxSize?this._deleteFirstKey():++this._size,this._keysQueue.push([c,s,a,i]),h=new o.TextImageCache(i,e.bold,e.italic,l,t,s,a),u.set(i,h)),h}_deleteFirstKey(){const e=this._keysQueue.shift(),[t,i,r,n]=e,o=(0,s.ensureDefined)(this._map.get(r)),l=(0,s.ensureDefined)(o.get(i)),a=(0,s.ensureDefined)(l.get(t));a.delete(n),0===a.size&&l.delete(t),0===l.size&&o.delete(i),0===o.size&&this._map.delete(r)}}},600642:(e,t,i)=>{i.d(t,{HorizontalAlign:()=>s,TextImageCache:()=>u,VerticalAlign:()=>r});var s,r,n=i(743068),o=i(650151),l=i(511131),a=i(199471);!function(e){e.Left="left", e.Right="right",e.Center="center"}(s||(s={})),function(e){e.Top="top",e.Bottom="bottom",e.Middle="middle"}(r||(r={}));const c=(0,a.createDisconnectedCanvas)(document,(0,n.size)({width:0,height:0}),1);class u{constructor(e,t,i,s,r,n="center",a=0){this._lines=e.split(/[^\S\r\n]*(?:\r\n|\r|\n)/),this._font=function(e,t,i,s){return(0,l.makeFont)(s,i,`${e?"bold ":""}${t?"italic ":""}`)}(t,i,s,r),this._fontSize=r,this._verticalPadding=~~(r/6),this._textAlign=n,this._lineSpacing=a;const u=(0,o.ensureNotNull)(c.getContext("2d"));u.font=this._font,u.textBaseline="top";let h=0;for(let e=0;e{for(const e of this._lines)o.strokeStyle&&i.strokeText(e,l,c),i.fillText(e,l,c),c+=this._fontSize,c+=this._lineSpacing})),i.restore()}}},938471:(e,t,i)=>{i.d(t,{AbstractBarColorer:()=>s});class s{constructor(){this._backColorers=[]}barStyle(e,t,i){const s={};for(const r of this._backColorers)r.applyBarStyle(e,t,s,i);return this.applyBarStyle(e,t,s,i),s}pushBackBarColorer(e){this._backColorers.unshift(e)}firstColoredBar(e){return null}}},811630:(e,t,i)=>{i.d(t,{alertsAvailable:()=>s});const s=i(244842).enabled("alerts")},593804:(e,t,i)=>{i.d(t,{alignToStep:()=>n});var s=i(960521),r=i.n(s);function n(e,t){return r()(e).div(t).round(0,r().roundHalfUp).mul(t).toNumber()}},995310:(e,t,i)=>{i.d(t,{BarBuilderBase:()=>l,SessionInfo:()=>o});var s=i(988124),r=i(987571),n=i(44031);class o{constructor(e,t,i,s){this.init(e,t,i,s),this._state={timezone:e,spec:t,holidays:i,corrections:s}}init(e,t,i,r){this.timezone=s.get_timezone(e),this.spec=new n.SessionSpec(e,t,i,r)}state(){return this._state}static fromState(e){return new o(e.timezone,e.spec,e.holidays,e.corrections)}}class l{alignTime(e){if(isNaN(e))return NaN;let t=this.indexOfBar(e);return t===r.SessionStage.POST_SESSION&&(this.moveTo(e),t=this.indexOfBar(e)),t<0?NaN:this.startOfBar(t)}}},586784:(e,t,i)=>{var s=i(511131).makeFont,r=i(511131).parseFont,n=i(201089).getLogger;const{drawPoly:o}=i(787123) ;var l=n("Model.ChartTradingUtils"),a={_fontHeightCache:{},_parsedColorCache:{},_parseColor:function(e){if(this._parsedColorCache[e])return this._parsedColorCache[e];var t=document.createElement("div");t.style.color=e;var i=t.style.color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i)||t.style.color.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*\.?\d+)\s*\)$/i),s={r:i[1],g:i[2],b:i[3],a:i[4]||"1"};return this._parsedColorCache[e]=s,s},getColorFromProperties:function(e,t){var i=1-t.value()/100,s=this._parseColor(e.value());return"rgba("+s.r+","+s.g+","+s.b+","+i+")"},setColorToProperties:function(e,t,i){var s=this._parseColor(e);t.setValue("rgb("+s.r+","+s.g+","+s.b+")");var r=100*(1-s.a);i.setValue(Math.max(0,Math.min(r,100)))},getFontFromProperties:function(e,t,i,r){return s(t.value(),e.value(),r.value()?"italic":"",i.value()?"bold":"")},setFontToProperties:function(e,t,i,s,n){var o=r(e);null!==o?(o.family.length>0&&t.setValue(o.family),i.setValue(o.size),s.setValue(o.bold),n.setValue(o.italic)):l.logError("Invalid font: "+e)},fontHeight:function(e){if(!this._fontHeightCache[e]){var t=document.createElement("span");t.appendChild(document.createTextNode("height")),document.body.appendChild(t),t.style.cssText="font: "+e+"; white-space: nowrap; display: inline;";var i=t.offsetHeight;document.body.removeChild(t),this._fontHeightCache[e]=Math.ceil(i)}return this._fontHeightCache[e]},drawPolyHoverOrPress:function(e,t,i,s){s?(e.save(),e.fillStyle="rgba(0, 0, 0, 0.15)",o(e,t,!0),e.restore()):i&&(e.save(),e.fillStyle="rgba(0, 0, 0, 0.1)",o(e,t,!0),e.restore())},repaint:function(e){e.lightUpdate()},roundToMinTick:function(e,t){var i=1/e.mainSource().base();return i*Math.round(t/i)}};e.exports=a},261066:(e,t,i)=>{i.d(t,{currencyUnitVisibilityOptions:()=>l,currencyUnitVisibilityProperty:()=>o,migrateShowCurrencyAndShowUnitProperties:()=>u,restoreCurrencyUnitVisibilitySettingsValue:()=>a});var s=i(87053),r=i(62802),n=i.n(r);const{property:o,availableValues:l,restoreDefaultValue:a}=(0,s.createVisibilityController)("PriceAxisCurrencyAndUnit.visibility");let c=!1;function u(e,t){c||(c=!0,void 0===n().getValue("PriceAxisCurrencyAndUnit.visibility")&&o().setValue(e||t?"alwaysOn":"alwaysOff"))}},996986:(e,t,i)=>{i.d(t,{DataSource:()=>c,getTranslatedStringForSource:()=>a});var s=i(809796),r=i(541558),n=i(707957),o=i(811630),l=i(401580);function a(e,t){return new s.TranslatedString(t.name(),t.title(e))}class c{constructor(e){this._isDestroyed=!1,this._hasAlert=new l.WatchedValue(!1),this._alertStatus=new l.WatchedValue(0),this._alertCreationAvailable=new l.WatchedValue(o.alertsAvailable),this._zorder=0,this._priceScale=null,this._ownerSource=null,this._userEditEnabled=!0,this._priceScaleChanged=new n.Delegate,this._isSelectionEnabled=!0,this._instanceId=(0,r.randomHashN)(6),this._ownerSourceChanged=new n.Delegate,this._zOrderChanged=new n.Delegate,this._id=null!=e?e:(0,r.randomHashN)(6),o.alertsAvailable&&Promise.resolve().then((()=>{ this._isDestroyed||this._hasAlert.subscribe(this._updateAlertCreationAvailable.bind(this),{callWithLast:!0})}))}destroy(){this._isDestroyed=!0}id(){return this._id}instanceId(){return this._instanceId}preferNoScale(){return!1}setId(e){this._id=e}zorder(){return this._zorder}setZorder(e){"number"==typeof e&&this._zorder!==e&&(this._zorder=e,this._zOrderChanged.fire(e))}preferredZOrder(){return null}isSpeciallyZOrderedSource(){return!1}title(e){return this.name()}priceScale(){return this._priceScale}setPriceScale(e){this._priceScale=e,this._priceScaleChanged.fire(e)}priceScaleChanged(){return this._priceScaleChanged}ownerSource(){return this._ownerSource}setOwnerSource(e){const t=this._ownerSource;this._ownerSource=e,this._ownerSourceChanged.fire(t,e)}ownerSourceChanged(){return this._ownerSourceChanged}zOrderChanged(){return this._zOrderChanged}isSavedInChart(e){return!0}isSavedInStudyTemplates(){return!0}isRemovedByStudyTemplates(){return!0}hasContextMenu(){return!0}showInObjectTree(){return!0}setUserEditEnabled(e){this._userEditEnabled=e}userEditEnabled(){return this._userEditEnabled}canBeHidden(){return this.userEditEnabled()}isUserDeletable(){return this.userEditEnabled()}properties(){return null}isVisible(){return this.properties().visible.value()}dataWindowView(){return null}priceAxisViews(e,t){return null}timeAxisViews(){return null}updateAllViews(e){}paneViews(e){return null}labelPaneViews(e){return null}isFailed(){return!1}isLoading(){return!1}isPhantom(){return!1}isChildStudy(){return!1}hasChildren(){return!1}canHaveChildren(){return!1}onClickOutside(e,t){}getSourceIcon(){return null}state(e){return null}doesMovingAffectsUndo(){return!0}isMultiPaneAvailable(){return!1}isMultiPaneEnabled(){return!1}copiable(){return!1}cloneable(){return!1}movable(){return!1}isIncludedInAutoScale(){return!1}isHoveredEnabled(){return this.isSelectionEnabled()}showOnTopOnHovering(){return!0}isSelectionEnabled(){return this._isSelectionEnabled}setSelectionEnabled(e){this._isSelectionEnabled=e}firstValue(){return null}priceRange(e,t,i){return null}autoScaleInfo(e,t,i){return{range:this.priceRange(e,t,i)}}stateForAlert(){return null}canHasAlert(){return!1}canHasAlertOnLineTools(){return!1}hasAlert(){return this._hasAlert.readonly()}alertCreationAvailable(){return this._alertCreationAvailable.readonly()}hasStateForAlert(){return o.alertsAvailable}idForAlert(){return this._id}alertStatus(){return this._alertStatus.readonly()}_getAlertCreationAvailable(){return o.alertsAvailable&&this.hasStateForAlert()}_updateAlertCreationAvailable(){o.alertsAvailable&&this._alertCreationAvailable.setValue(this._getAlertCreationAvailable())}}},782086:(e,t,i)=>{i.d(t,{DataWindowItem:()=>s,DataWindowView:()=>r});class s{constructor(e,t,i,s=!1){this._visible=!0,this._id=e,this._title=t,this._value=i,this._unimportant=s}id(){return this._id}title(){return this._title}setTitle(e){this._title=e}text(){return this._value}value(){return this._value}setValue(e){this._value=e}visible(){return this._visible}setVisible(e){this._visible=e}color(){ return this._color}setColor(e){this._color=e}unimportant(){return this._unimportant}}class r{constructor(){this._items=[],this._header="",this._title=""}header(){return this._header}title(){return this._title}items(){return this._items}update(){}}},853965:(e,t,i)=>{i.d(t,{DefaultProperty:()=>D,allowSavingDefaults:()=>x,createDefaultsState:()=>S,extractAllPropertiesKeys:()=>C,extractState:()=>T});var s=i(822914),r=i(852290),n=i(702040),o=i(438004),l=i(267199),a=i(571059),c=i(316230),u=i(138651),h=i(598279),d=i(86746),p=i(331633),_=i(42292),f=i(707957),m=i(194582),v=i(354950),g=i(650151);const P=(0,m.getLogger)("ThemedDefaults");function y(e,t,i){for(const s of t)if((0,n.default)(e,s),i){const t=s.split(".");for(t.pop();t.length;){const i=(0,o.default)(e,t);if(!(0,h.default)(i)||0!==Object.keys(i).length)break;(0,n.default)(e,t),t.pop()}}}function S(e,t,i,n){const o=e?_.defaults:_.factoryDefaults,l=t.startsWith("study_")?(0,s.default)(o("study")):{};let a=(0,s.default)(o(t,n));return t.startsWith("study_")&&a.inputs&&delete a.inputs.symbol,"linetoolicon"===t&&e&&(a.icon=(0,_.defaults)(t).icon),"linetooemoji"===t&&e&&(a.emoji=(0,_.defaults)(t).emoji),"linetoolsticker"===t&&e&&(a.sticker=(0,_.defaults)(t).sticker),a=(0,s.default)(a),y(a,i),(0,r.default)(l,a),l}let b=!1;function x(e){b=e}function C(e){const t=Object.keys(e),i=[];return t.forEach((t=>{const s=e[t];if((0,h.default)(s)){C(s).forEach((e=>i.push(`${t}.${e}`)))}else i.push(t)})),i}function w(e,t,i=""){const s={};for(const r of t){const n=r.split("."),o=n[0],l=e[o],a=""===i?o:`${i}.${o}`;if(e.hasOwnProperty(o))if(n.length>1){if(!(0,h.default)(l)){P.logError(`path ${a} must be an object, but it is a primitive`);continue}{const e=t.filter((e=>e.startsWith(`${o}.`))).map((e=>e.split(".").slice(1).join(".")));s[o]=w(l,e,a)}}else{if((0,h.default)(l)){P.logError(`path ${a} must be a primitive, but it is an object`);continue}s[o]=l}}return s}function T(e,t,i){if(!e)return{};let s=e;return t&&(s=w(e,t)),i&&y(s,i,!0),s}function I(e,t){e.includes(t)||e.push(t)}function V(e,t){const i=e.indexOf(t);-1!==i&&e.splice(i,1)}function M(e,t){const i=(0,a.default)(e,((e,i,s)=>{if(void 0===t[s])return e;if(!(0,c.default)(i,t[s]))if((0,h.default)(i)&&(0,h.default)(t[s])){const r=M(i,t[s]);void 0!==r&&(e[s]=r)}else e[s]=i;return e}),{});return(0,u.default)(i)?void 0:i}function A(e){return e===d.StdTheme.Dark?1:0}class D extends v.Property{constructor(e){const{defaultName:t,nonThemedDefaultsKeys:i,themedDefaultsKeys:s,excludedDefaultsKeys:n=[],themedColors:o,allStateKeys:l,excludedStateKeys:a=[],state:c,useUserPreferences:u=!0,saveNonDefaultUserPreferencesOnly:h=!1,ignoreAllowSavingDefaults:d=!1,saveDefaultsConsumer:p=_.saveDefaults,factoryDefaultsSupplier:m=(()=>S(!1,t,[],null))}=e;super(),this._themedColors=[],this._restoreFactoryDefaultsEvent=new f.Delegate,this._defaultName=t,this._useUserPreferences=u,this._saveNonDefaultUserPreferencesOnly=h,this._ignoreAllowSavingDefaults=d,this._saveDefaultsConsumer=p,this._factoryDefaultsSupplier=m,this._allStateKeys=l, this._excludedStateKeys=a,this._nonThemedDefaultsKeys=i,this._themedDefaultsKeys=s,this._allDefaultsKeys=i||s?[...null!=i?i:[],...null!=s?s:[]]:void 0,this._themedColors=o,this._excludedDefaultsKeys=n,(0,g.assert)(void 0===this._allDefaultsKeys||0===this._excludedDefaultsKeys.length,"Defaults keys and excluded defaults keys cannot be used at the same time"),(0,g.assert)(void 0===this._allStateKeys||0===this._excludedStateKeys.length,"State keys and excluded state keys cannot be used at the same time"),this.merge((0,r.default)(this._factoryDefaultsSupplier(),this._userSettings(),T(c,l,a))),this._restoreFactoryDefaultsEvent=new f.Delegate}destroy(){var e;null===(e=this._unsubscribeWatchedTheme)||void 0===e||e.call(this),super.destroy()}applyTemplate(e,t){this.mergePreferences((0,r.default)((0,s.default)(t),e))}preferences(){return T(super.state(this._excludedDefaultsKeys),this._allDefaultsKeys)}mergePreferences(e){this.mergeAndFire(T(e,this._allDefaultsKeys,this._excludedDefaultsKeys))}addExcludedKey(e,t){1&t&&I(this._excludedDefaultsKeys,e),2&t&&I(this._excludedStateKeys,e)}removeExcludedKey(e,t){1&t&&V(this._excludedDefaultsKeys,e),2&t&&V(this._excludedStateKeys,e)}restoreFactoryDefaults(){const e=this._factoryDefaultsSupplier();if(y(e,this._excludedDefaultsKeys),this._themedColors){const t=A(p.watchedTheme.value());for(const i of this._themedColors)(0,l.default)(e,i.path,i.colors[t])}this.mergeAndFire(e),this._defaultName.startsWith("study_")&&!this._defaultName.startsWith("study_VbPFixed")||this.saveDefaults(),this._restoreFactoryDefaultsEvent.fire()}onRestoreFactoryDefaults(){return this._restoreFactoryDefaultsEvent}childChanged(e,t){var i;super.childChanged(e,t),!this._ignoreAllowSavingDefaults&&!b||this._defaultName.startsWith("study_")&&!this._defaultName.startsWith("study_VbPFixed")||!(this._allDefaultsKeys&&this._allDefaultsKeys.includes(t)||!this._allDefaultsKeys&&!(null===(i=this._excludedDefaultsKeys)||void 0===i?void 0:i.includes(t)))||this.saveDefaults()}saveDefaults(){if(!this._useUserPreferences)return;let e;if(this._saveNonDefaultUserPreferencesOnly){const t=super.state(this._excludedDefaultsKeys),i=this._factoryDefaultsSupplier();e=M(T(t,this._nonThemedDefaultsKeys),T(i,this._nonThemedDefaultsKeys,this._excludedDefaultsKeys));const s=T(i,this._themedDefaultsKeys,this._excludedDefaultsKeys),n=T(t,this._themedDefaultsKeys),o=M(n,s);(0,u.default)(o)||(e=null!=e?e:{},(0,r.default)(e,n))}else e=this.preferences();this._saveDefaultsConsumer(this._defaultName,e)}clone(e){return new D(this._options())}setThemedColors(e){if(this._themedColors=e,void 0===this._unsubscribeWatchedTheme){const e=()=>this.updateThemedColors();p.watchedTheme.subscribe(e),this._unsubscribeWatchedTheme=()=>p.watchedTheme.unsubscribe(e)}this.updateThemedColors()}updateThemedColors(e){if(!this._themedColors)return;const t=p.watchedTheme.value(),i=t===d.StdTheme.Light?d.StdTheme.Dark:d.StdTheme.Light;for(const s of this._themedColors){const r=(0,g.ensureDefined)(this.childByPath(s.path)),n=s.colors[A(i)] ;!e&&r.value()!==n&&r.value()||r.setValue(s.colors[A(t)])}}state(e){return T(super.state([...this._excludedStateKeys,...null!=e?e:[]]),this._allStateKeys)}_userSettings(){if(!this._useUserPreferences)return;const e=S(!0,this._defaultName,[],null);return e?T((0,s.default)(e),this._allDefaultsKeys,this._excludedDefaultsKeys):void 0}_options(){return{defaultName:this._defaultName,factoryDefaultsSupplier:this._factoryDefaultsSupplier,state:this.state(),nonThemedDefaultsKeys:this._nonThemedDefaultsKeys,themedDefaultsKeys:this._themedDefaultsKeys,excludedDefaultsKeys:this._excludedDefaultsKeys,themedColors:this._themedColors,allStateKeys:this._allStateKeys,excludedStateKeys:this._excludedDefaultsKeys,useUserPreferences:this._useUserPreferences,saveNonDefaultUserPreferencesOnly:this._saveNonDefaultUserPreferencesOnly,ignoreAllowSavingDefaults:this._ignoreAllowSavingDefaults,saveDefaultsConsumer:this._saveDefaultsConsumer}}}},885482:(e,t,i)=>{i.r(t),i.d(t,{SelectPointMode:()=>s,activePointSelectionMode:()=>j,barTimesUnderCursor:()=>$,beenSetLineToolLastPoint:()=>B,cancelLineTool:()=>J,cancelledLineTool:()=>L,changeLineStyle:()=>ce,changeLineTool:()=>ne,changedLineStyle:()=>H,changedLineTool:()=>O,continueLineTool:()=>Z,continuedLineTool:()=>D,copiedLineTool:()=>U,copyLineTool:()=>ue,createLineTool:()=>X,createdLineTool:()=>A,crosshairLock:()=>y,cursorTool:()=>w,drawOnAllCharts:()=>be,drawOnAllChartsMode:()=>xe,emojiTool:()=>x,finishChangingLineTool:()=>oe,finishLineTool:()=>ae,finishMovingLineTool:()=>se,finishedChangingLineTool:()=>F,finishedLineTool:()=>z,finishedMovingLineTool:()=>E,hideAllDrawings:()=>ge,hideAllIndicators:()=>Pe,hideMarksOnBars:()=>Se,iconTool:()=>b,init:()=>fe,isDirectionalMovementActive:()=>M,isStudyEditingNow:()=>q,isToolCreatingNow:()=>T,isToolEditingNow:()=>I,isToolMovingNow:()=>V,lockDrawings:()=>ye,moveLineTool:()=>ie,movedLineTool:()=>N,properties:()=>ve,removeLineTool:()=>le,removedLineTool:()=>W,resetToCursor:()=>_,restoreLineTool:()=>he,restoreLineToolState:()=>de,restoredLineTool:()=>K,restoredLineToolState:()=>G,runOnDrawingStateReady:()=>me,setLineToolLastPoint:()=>ee,startChangingLineTool:()=>re,startMovingLineTool:()=>te,startedChangingLineTool:()=>k,startedMovingLineTool:()=>R,stickerTool:()=>C,tool:()=>S,toolIsCursor:()=>d,toolIsMeasure:()=>p});var s,r=i(650151),n=i(152633),o=i(853965),l=i(401580),a=i(938550),c=i(707957),u=i(62802),h=i(251954);function d(e){return"cursor"===e||"arrow"===e||"dot"===e||"performance"===e}function p(e){return"measure"===e}function _(e=!1){if(!e&&f){if(f.childs().stayInDrawingMode.value())return}S.setValue(w.value())}!function(e){e[e.None=0]="None",e[e.Replay=1]="Replay",e[e.Study=2]="Study"}(s||(s={}));let f=null,m=null,v=null,g=null,P=null ;const y=new a.WatchedObject(null),S=new l.WatchedValue,b=new l.WatchedValue,x=new l.WatchedValue,C=new l.WatchedValue,w=new l.WatchedValue,T=new l.WatchedValue(!1),I=new l.WatchedValue(!1),V=new l.WatchedValue(!1),M=new l.WatchedValue(!1),A=new c.Delegate,D=new c.Delegate,L=new c.Delegate,B=new c.Delegate,R=new c.Delegate,N=new c.Delegate,E=new c.Delegate,k=new c.Delegate,O=new c.Delegate,F=new c.Delegate,W=new c.Delegate,z=new c.Delegate,H=new c.Delegate,U=new c.Delegate,K=new c.Delegate,G=new c.Delegate,j=new l.WatchedValue(s.None),q=new l.WatchedValue(!1),$=new Map;function Y(e,t){const i=t||{value:!1};return t=>{i.value||(i.value=!0,e.fire(t),i.value=!1)}}const Q={value:!1},X=Y(A,Q),Z=Y(D,Q),J=Y(L,Q),ee=Y(B,Q),te=Y(R),ie=Y(N),se=Y(E),re=Y(k),ne=Y(O),oe=Y(F),le=Y(W),ae=Y(z),ce=Y(H,Q),ue=Y(U,Q),he=Y(K),de=Y(G);let pe=!1,_e=[];function fe(){pe||(S.setValue(u.getValue("chart.cursorPreference","cursor")),S.subscribe((e=>d(e)&&w.setValue(e)),{callWithLast:!0}),w.subscribe((e=>{e&&"performance"!==e&&u.setValue("chart.cursorPreference",e)})),f=new o.DefaultProperty({defaultName:"drawings"}),m=(0,n.createPrimitiveProperty)(),v=(0,n.createPrimitiveProperty)(),g=(0,n.createPrimitiveProperty)(),P=(0,n.createPrimitiveProperty)(),m.setValue(!1),v.setValue(!1),g.setValue(!1),P.setValue(!u.getBool("BarsMarksContainer.visibile",!0)),S.subscribe((e=>{(0,h.emit)("onSelectedLineToolChanged")})),pe=!0,_e.forEach((e=>e())),_e=[])}function me(e){pe?e():_e.push(e)}function ve(){return(0,r.ensureNotNull)(f)}function ge(){return(0,r.ensureNotNull)(m)}function Pe(){return(0,r.ensureNotNull)(v)}function ye(){return(0,r.ensureNotNull)(g)}function Se(){return(0,r.ensureNotNull)(P)}function be(){return ve().childs().drawOnAllCharts}function xe(){return ve().childs().drawOnAllChartsMode}},327453:(e,t,i)=>{i.d(t,{LimitedPrecisionNumericFormatter:()=>n});var s=i(389137),r=i(182436);class n{constructor(e,t){this._precision=null!=e?e:1,this._numericFormatter=new r.NumericFormatter(this._precision,t)}format(e,t){(0,s.isNumber)(e)||(e=parseFloat(e));const i=e.toFixed(this._precision),r=Math.pow(10,-this._precision);return this._numericFormatter.format(Math.max(parseFloat(i),r),null==t?void 0:t.ignoreLocaleNumberFormat)}parse(e,t){const i=this._numericFormatter.parse(e,null==t?void 0:t.ignoreLocaleNumberFormat);return isNaN(i)?{res:!1}:{res:!0,value:i,suggest:this.format(i)}}}},570226:(e,t,i)=>{i.d(t,{getPriceValueFormatterForSource:()=>a,getPriceValueFormatterForStudy:()=>c,shouldBeFormattedAsIndexedTo100:()=>o,shouldBeFormattedAsPercent:()=>n});var s=i(444331),r=i(981107);function n(e){const t=e.priceScale();return!(null===t||!t.isPercentage())&&(!(0,r.isActingAsSymbolSource)(e)||(0,s.isPriceSourceStyle)(e.style()))}function o(e){const t=e.priceScale();return!(null===t||!t.isIndexedTo100())&&(!(0,r.isActingAsSymbolSource)(e)||(0,s.isPriceSourceStyle)(e.style()))}function l(e){const t=e.priceScale();return o(e)&&null!==t?(i,s)=>{var r;return t.formatPriceIndexedTo100(i,null!==(r=e.firstValue())&&void 0!==r?r:100,s)}:n(e)&&null!==t?(i,s)=>{var r ;return t.formatPricePercentage(i,null!==(r=e.firstValue())&&void 0!==r?r:100,s)}:null}function a(e){const t=l(e);if(t)return t;const i=e.formatter();return i.format.bind(i)}function c(e,t){const i=l(e);if(i)return i;const s=e.plotFormatter(t);return s.format.bind(s)}},315801:(e,t,i)=>{i.d(t,{AreaName:()=>s,HitTarget:()=>r,HitTestResult:()=>c,hitTestResultDataAreEqual:()=>a,shouldDefaultActionBeExecuted:()=>l,tryCallHandler:()=>o});var s,r,n=i(650151);function o(e,t,i,s){if(e.isTouch){if(void 0!==s)return s(e,t),!0}else if(void 0!==i)return i(e,t),!0;return!1}function l(e,t,i,s){return void 0!==t.executeDefaultAction&&(e.isTouch?Boolean(t.executeDefaultAction[s]):Boolean(t.executeDefaultAction[i]))}function a(e,t){return e&&t&&e.equals&&t.equals?e.equals(t):e===t}!function(e){e.Style="Style",e.Text="Text",e.Line="Line",e.Tooltip="Tooltip",e.Button="Button",e.SourceItemMove="SourceItemMove",e.AnchorPoint="AnchorPoint"}(s||(s={})),function(e){e[e.MovePointBackground=1]="MovePointBackground",e[e.Regular=2]="Regular",e[e.MovePoint=3]="MovePoint",e[e.ChangePoint=4]="ChangePoint",e[e.Custom=5]="Custom"}(r||(r={}));class c{constructor(e,t,i){this._target=e,this._data=t||null,this._eraseMarker=i}target(){return this._target}data(){return this._data}mergeData(e){this._data={...(0,n.ensureNotNull)(this._data),...e}}hasPressedMoveHandler(e){return null!==this._data&&function(e,t,i){if(e.isTouch){if(void 0!==i)return!0}else if(void 0!==t)return!0;return!1}(e,this._data.pressedMouseMoveHandler,this._data.touchMoveHandler)}tryCallMouseDownOrTouchStartHandler(e,t){return null!==this._data&&o(e,t,this._data.mouseDownHandler,this._data.touchStartHandler)}tryCallMouseUpOrTouchEndHandler(e,t){return null!==this._data&&o(e,t,this._data.mouseUpHandler,this._data.touchEndHandler)}tryCallMouseEnterHandler(e,t){return null!==this._data&&o(e,t,this._data.mouseEnterHandler)}tryCallMouseLeaveHandler(e,t){return null!==this._data&&o(e,t,this._data.mouseLeaveHandler)}tryCallMouseMoveHandler(e,t){return null!==this._data&&o(e,t,this._data.mouseMoveHandler)}tryCallClickOrTapHandler(e,t){return null!==this._data&&o(e,t,this._data.clickHandler,this._data.tapHandler)}tryCallDblClickOrDblTapHandler(e,t){return null!==this._data&&o(e,t,this._data.doubleClickHandler,this._data.doubleTapHandler)}tryCallContextMenuHandler(e,t){return null!==this._data&&o(e,t,this._data.contextMenuHandler,this._data.touchContextMenuHandler)}eraseMarker(){return this._eraseMarker}}},955831:(e,t,i)=>{i.d(t,{HorizontalLinePaneView:()=>n});var s=i(9524),r=i(458963);class n{constructor(){this._lineRendererData={y:0,color:"rgba(0, 0, 0, 0)",linewidth:1,linestyle:r.LINESTYLE_SOLID,visible:!1},this._lineRenderer=new s.HorizontalLineRenderer,this._invalidated=!0,this._lineRenderer.setData(this._lineRendererData)}update(e){this._invalidated=!0}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._lineRenderer}}},808068:(e,t,i)=>{i.d(t,{intervalsVisibilitiesDefaults:()=>s});const s={ticks:!0,seconds:!0,secondsFrom:1,secondsTo:59,minutes:!0, minutesFrom:1,minutesTo:59,hours:!0,hoursFrom:1,hoursTo:24,days:!0,daysFrom:1,daysTo:366,weeks:!0,weeksFrom:1,weeksTo:52,months:!0,monthsFrom:1,monthsTo:12,ranges:!0}},312449:(e,t,i)=>{i.d(t,{IntervalsVisibilitiesProperty:()=>n});var s=i(354950),r=i(395098);class n extends s.Property{state(e){var t;return null!==(t=(0,r.nonDefaultIntervalsVisibilities)(super.state(e)))&&void 0!==t?t:void 0}storeStateIfUndefined(){return!1}}},534741:(e,t,i)=>{var s;i.d(t,{PlotRowSearchMode:()=>s}),function(e){e[e.NearestLeft=-1]="NearestLeft",e[e.Exact=0]="Exact",e[e.NearestRight=1]="NearestRight"}(s||(s={}))},826989:(e,t,i)=>{var s;i.d(t,{SymbolErrorPermissionDeniedReason:()=>s,invalidSymbol:()=>n,permissionDenied:()=>r}),function(e){e.Symbol="symbol",e.GroupPermission="group"}(s||(s={}));const r="permission denied",n="invalid symbol"},981107:(e,t,i)=>{function s(e){const t=(null==e?void 0:e.symbolSource)&&e.symbolSource()===e,i=void 0!==(null==e?void 0:e.isActingAsSymbolSource);return t||i}function r(e){return s(e)&&"quotesProvider"in e}function n(e){return s(e)&&e.isActingAsSymbolSource().value()}i.d(t,{isActingAsSymbolSource:()=>n,isSymbolSource:()=>s,isSymbolSourceWithQuotesProvider:()=>r})},517336:(e,t,i)=>{i.d(t,{LevelsProperty:()=>f});var s=i(822914),r=i(852290),n=i(389137),o=i(853965),l=i(42292);const a={prefixes:[""],range:[0,0],names:["coeff","color","visible","linestyle","linewidth"],typecheck:{pack:()=>Object(),unpack:()=>[]}};function c(e,t,i,s){return s.push(i[t]),s}function u(e,t,i,s){return s[t]=i[e],s}function h(){return[]}function d(){return{}}function p(e,t,i){return i.prefixes.forEach((s=>{const r=s+"level";for(let s=i.range[0];s<=i.range[1];s++)if(e[r+s]&&(0,n.isSameType)(e[r+s],t.typecheck())){let n=t.tpl();i.names.forEach(((i,o)=>{n=t.fill(""+o,i,e[r+s],n)})),e[r+s]=n}})),e}function _(e,t,i){return i(e,{tpl:d,fill:u,typecheck:t.typecheck.unpack},t)}class f extends o.DefaultProperty{constructor(e){const{levelsIterator:t=p,map:i={},...s}=e,r={...a,...i};s.state&&(s.state=_(s.state,r,t)),super(s),this._map=r,this._levelsIterator=t}state(e,t){const i=super.state(e);return t?i:(s=i,r=this._map,(0,this._levelsIterator)(s,{tpl:h,fill:c,typecheck:r.typecheck.pack},r));var s,r}applyTemplate(e,t){this.mergePreferences((0,r.default)((0,s.default)(t),_(e,this._map,this._levelsIterator)))}saveDefaults(){this._useUserPreferences&&(0,l.saveDefaults)(this._defaultName,this.preferences())}clone(){return new f(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}}}},440941:(e,t,i)=>{i.d(t,{lineToolsDoNotAffectChartInvalidation:()=>s});const s=!0},147985:(e,t,i)=>{i.d(t,{LineTool5PointsPattern:()=>l});var s=i(650151),r=i(853965),n=i(821979),o=i(31712);class l extends n.LineDataSource{constructor(e,t,i,s){super(e,t||l.createProperties(),i,s),this._loadPaneViews(e)}pointsCount(){return 5}name(){return"XABCD Pattern"}static createProperties(e){const t=new r.DefaultProperty({ defaultName:"linetool5pointspattern",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,63124)).then((e=>e.PatternWithBackgroundDefinitionViewModel))}_loadPaneViews(e){Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,382242)).then((t=>{this._setPaneViews([new t.Pattern5pointsPaneView(this,e)])}))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new o.LineToolColorsProperty([(0,s.ensureDefined)(e.child("color"))])),e.addChild("textsColors",new o.LineToolColorsProperty([(0,s.ensureDefined)(e.child("textcolor"))]))}}},78:(e,t,i)=>{i.d(t,{LineToolABCD:()=>l});var s=i(650151),r=i(853965),n=i(821979),o=i(31712);class l extends n.LineDataSource{constructor(e,t,s,r){const n=t||l.createProperties();super(e,n,s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,662657)).then((t=>{this._setPaneViews([new t.ABCDPaneView(this,e)])}))}pointsCount(){return 4}name(){return"ABCD Pattern"}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolabcd",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,669403)).then((e=>e.PatternWithoutBackgroundDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new o.LineToolColorsProperty([(0,s.ensureDefined)(e.child("color"))])),e.addChild("textsColors",new o.LineToolColorsProperty([(0,s.ensureDefined)(e.child("textcolor"))]))}}},907416:(e,t,i)=>{i.d(t,{LineToolArc:()=>u});var s=i(650151),r=i(204652),n=i(86441),o=i(625422),l=i(853965),a=i(821979),c=i(31712);class u extends a.LineDataSource{constructor(e,t,s,r){const n=t||u.createProperties();super(e,n,s,r),this.version=2,this._dist=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,953940)).then((({ArcPaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}startChanging(e,t){if(super.startChanging(e,t),0===e||1===e){const e=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),t=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[2]));this._dist=(0,r.distanceToLine)(e,t,i).distance;const o=t.subtract(e),l=new n.Point(-o.y,o.x),a=e.add(t).scaled(.5);i.subtract(a).dotProduct(l)<0&&(this._dist=-this._dist)}}endChanging(e,t){return this._dist=null,super.endChanging(e,t)}pointsCount(){return 3}name(){return"Arc"}hasEditableCoordinates(){return!1}setPoint(e,t){const i={...t},l=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),a=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1]));switch(e){case 0:{const e=(0,s.ensureNotNull)(this._dist),t=(0,s.ensureNotNull)(this.pointToScreenPoint(i)),r=a.subtract(t),o=t.add(a).scaled(.5);let l=new n.Point(-r.y,r.x) ;l=l.normalized();const c=o.add(l.scaled(e));this._points[0]=i,this._points[2]=(0,s.ensureNotNull)(this.screenPointToPoint(c));break}case 1:{const e=(0,s.ensureNotNull)(this._dist),t=(0,s.ensureNotNull)(this.pointToScreenPoint(i)),r=t.subtract(l),o=l.add(t).scaled(.5),a=new n.Point(-r.y,r.x).normalized(),c=o.add(a.scaled(e));this._points[1]=i,this._points[2]=(0,s.ensureNotNull)(this.screenPointToPoint(c));break}case 2:{let e=(0,s.ensureNotNull)(this.pointToScreenPoint(i));const t=(0,r.distanceToLine)(l,a,e).distance,c=a.subtract(l),u=l.add(a).scaled(.5),h=new n.Point(-c.y,c.x).normalized(),d=u.add(h.scaled(t)),p=u.add(h.scaled(-t)),_=c.length(),f=c.x/_,m=c.y/_;let v=Math.acos(f);m<0&&(v=-v);let g=(0,o.translationMatrix)(-u.x,-u.y);e=(0,o.transformPoint)(g,e);let P=(0,o.transformPoint)(g,d);g=(0,o.rotationMatrix)(-v),e=(0,o.transformPoint)(g,e),P=(0,o.transformPoint)(g,P),g=(0,o.scalingMatrix)(1,_/(2*t)),e=(0,o.transformPoint)(g,e),P=(0,o.transformPoint)(g,P);const y=e.y*P.y>=0?new n.Point(d.x,d.y):new n.Point(p.x,p.y);this._points[2]=(0,s.ensureNotNull)(this.screenPointToPoint(y));break}}this._normalizePoints()}migrateVersion(e,t,i){if(1===e&&2===this._points.length){const e=(2*this._points[0].price+3*this._points[1].price)/5;this._points.push({price:e,index:this._points[1].index})}if(1===e&&2===this._timePoint.length){const e={price:(2*this._timePoint[0].price+3*this._timePoint[1].price)/5,offset:this._timePoint[1].offset,time_t:this._timePoint[1].time_t};this._timePoint.push(e)}}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolarc",state:e});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,967382))).GeneralFiguresDefinitionsViewModelBase}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new c.LineToolColorsProperty([e.childs().color]))}}},41394:(e,t,i)=>{i.d(t,{LineToolArrowMark:()=>l,LineToolArrowMarkDown:()=>h,LineToolArrowMarkLeft:()=>a,LineToolArrowMarkRight:()=>u,LineToolArrowMarkUp:()=>c});var s=i(853965),r=i(821979),n=i(354950),o=i(31712);class l extends r.LineDataSource{constructor(e,t,s,r,n){const o=t||l.createProperties(null,s);super(e,o,r,n),this._textPaneView=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,129022)).then((({ArrowMarkPaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}paneViews(e){const t=super.paneViews();return null!==t&&this._textPaneView&&t.push(this._textPaneView),t}pointsCount(){return 1}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}static createProperties(e,t){const i=new s.DefaultProperty({defaultName:t,state:e});return this._configureProperties(i),i}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,952842)).then((e=>e.ArrowMarkDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e), this.properties().childs().text.setValue(e.text)}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new o.LineToolColorsProperty([e.childs().arrowColor])),e.addChild("textsColors",new o.LineToolColorsProperty([e.childs().color])),e.hasChild("text")||e.addChild("text",new n.Property("")),e.addExcludedKey("text",1)}}l.version=2;class a extends l{constructor(e,t,i,s){super(e,t,"linetoolarrowmarkleft",i,s)}direction(){return"left"}name(){return"Arrow Mark Left"}textAlignParams(){return{horzAlign:"left",vertAlign:"middle",offsetX:22,offsetY:3}}static createProperties(e){return super.createProperties(e,"linetoolarrowmarkleft")}}class c extends l{constructor(e,t,i,s){super(e,t,"linetoolarrowmarkup",i,s)}direction(){return"up"}name(){return"Arrow Mark Up"}textAlignParams(){return{horzAlign:"center",vertAlign:"top",offsetX:0,offsetY:20}}static createProperties(e){return super.createProperties(e,"linetoolarrowmarkup")}}class u extends l{constructor(e,t,i,s){super(e,t,"linetoolarrowmarkright",i,s)}direction(){return"right"}name(){return"Arrow Mark Right"}textAlignParams(){return{horzAlign:"right",vertAlign:"middle",offsetX:22,offsetY:3,forceTextAlign:!0}}static createProperties(e){return super.createProperties(e,"linetoolarrowmarkright")}}class h extends l{constructor(e,t,i,s){super(e,t,"linetoolarrowmarkdown",i,s)}direction(){return"down"}name(){return"Arrow Mark Down"}textAlignParams(){return{horzAlign:"center",vertAlign:"bottom",offsetX:0,offsetY:20}}static createProperties(e){return super.createProperties(e,"linetoolarrowmarkdown")}}},683396:(e,t,i)=>{i.d(t,{LineToolArrowMarker:()=>o});var s=i(821979),r=i(853965),n=i(354950);class o extends s.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:o.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,922514)).then((({ArrowMarkerPaneView:e})=>{this._setPaneViews([new e(this,this.model())])}))}pointsCount(){return 2}name(){return"Trend Line"}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolarrowmarker",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,470719)).then((e=>e.ArrowMarkerDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new n.Property("")),e.addExcludedKey("text",1)}}},548160:(e,t,i)=>{i.d(t,{LineToolArrow:()=>r});var s=i(956268);class r extends s.LineToolTrendLine{constructor(e,t,i,s){super(e,null!=t?t:r.createProperties(),i,s)}name(){return"Arrow"}static createProperties(e){const t=s.LineToolTrendLine._createPropertiesImpl("linetoolarrow",e);return r._configureProperties(t),t}}},179180:(e,t,i)=>{i.d(t,{LineToolBalloon:()=>c});var s=i(444372),r=i(853965),n=i(821979),o=i(354950),l=i(31712);const a=s.t(null,void 0,i(119372));class c extends n.LineDataSource{constructor(e,t,i,s){super(e,t||c.createProperties(),i,s),this._createPaneView()} pointsCount(){return 1}name(){return"Balloon"}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}shouldBeRemovedOnDeselect(){return""===this._properties.childs().text.value().trim()}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolballoon",state:e});return this._configureProperties(t),t}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,417540)).then((e=>e.BalloonDefinitionsViewModel))}_createPaneView(){Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,35986)).then((e=>{this._setPaneViews([new e.BalloonPaneView(this,this._model)])}))}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new o.Property(a)),e.addExcludedKey("text",1),e.addChild("linesColors",new l.LineToolColorsProperty([e.childs().borderColor])),e.addChild("textsColors",new l.LineToolColorsProperty([e.childs().color]))}}},180148:(e,t,i)=>{i.d(t,{LineToolBarsPattern:()=>y});var s=i(650151),r=i(444372),n=i(809796),o=i(389137),l=i(373571),a=i(853965),c=i(534741),u=i(821979),h=i(540598),d=i(964824),p=i(440941);const _=new n.TranslatedString("mirror bars pattern",r.t(null,void 0,i(881870))),f=new n.TranslatedString("flip bars pattern",r.t(null,void 0,i(559942))),m=r.t(null,void 0,i(363158)),v=r.t(null,void 0,i(892754)),g={0:2,1:4,2:1,3:1,4:2,5:3,6:-1},P={0:3,1:4,2:4,3:1,4:2,5:3,6:-1};class y extends u.LineDataSource{constructor(e,t=y.createProperties(),s,r){super(e,t,s,r),this._pattern=[],this._scale=1,this._pointsCoordinatePricesDiff=null;const n=t.childs().mode.value();(0,o.isString)(n)&&t.childs().mode.setValue(parseInt(n)),t.childs().mirrored.listeners().subscribe(this,this._mirror),t.childs().flipped.listeners().subscribe(this,this._flip),t.childs().mode.subscribe(this,this._updateLastPoint),this.version=2,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,416645)).then((t=>{this._setPaneViews([new t.BarsPatternPaneView(this,e)])}))}pattern(){return this._pattern}isSynchronizable(){return!1}additionalActions(e){return[new l.Action({actionId:"Chart.LineTool.BarsPattern.ToggleMirrored",options:{checked:this.properties().childs().mirrored.value(),checkable:!0,label:m,onExecute:()=>{e.setProperty(this.properties().childs().mirrored,!this.properties().childs().mirrored.value(),_,p.lineToolsDoNotAffectChartInvalidation),this.updateAllViews((0,d.sourceChangeEvent)(this.id())),this._model.updateSource(this)}}}),new l.Action({actionId:"Chart.LineTool.BarsPattern.ToggleFlipped",options:{checked:this.properties().childs().flipped.value(),checkable:!0,label:v,onExecute:()=>{e.setProperty(this.properties().childs().flipped,!this.properties().childs().flipped.value(),f,p.lineToolsDoNotAffectChartInvalidation),this.updateAllViews((0,d.sourceChangeEvent)(this.id())), this._model.updateSource(this)}}})]}pointsCount(){return 2}state(e){return{...super.state(e),pattern:this._pattern,scale:this._scale,diff:this._pointsCoordinatePricesDiff}}restoreData(e){const{pattern:t=this._pattern,scale:i=this._scale,diff:s=this._pointsCoordinatePricesDiff}=e;this._pattern=t,this._scale=i,this._pointsCoordinatePricesDiff=s}name(){return"Bars Pattern"}hasEditableCoordinates(){return!1}cloneData(e){this._pattern=(0,o.clone)(e._pattern),this._scale=e._scale,this._pointsCoordinatePricesDiff=e._pointsCoordinatePricesDiff}firstPatternPrice(){const{mode:e,flipped:t}=this.properties().childs(),i=this._pattern[0];return e.value()===h.LineToolBarsPatternMode.LineHL2?(i[2]+i[3])/2:t.value()?i[P[e.value()]]:i[g[e.value()]]}lastPatternPrice(){const{mode:e,flipped:t}=this.properties().childs(),i=this._pattern[this._pattern.length-1];return e.value()===h.LineToolBarsPatternMode.LineHL2?(i[2]+i[3])/2:t.value()?i[g[e.value()]]:i[P[e.value()]]}addPoint(e,t,i){const r=super.addPoint(e,t,!0);if(r){const e=this._model.mainSeries(),[{index:t},{index:i}]=this.points(),r=(0,s.ensureDefined)(e.nearestIndex(Math.min(t,i),c.PlotRowSearchMode.NearestRight)),n=(0,s.ensureDefined)(e.nearestIndex(Math.max(t,i),c.PlotRowSearchMode.NearestLeft));this._pattern=this._createPattern(r,n),this._pattern.length>0&&(t>i&&this._points.reverse(),this._points[1].price=this._points[0].price+this._patternPriceDiff(),this._points[1].index=this._points[0].index+(n-r),this._normalizePoints(),this.createServerPoints()),this._updatePointsCoordinatePricesDiff()}return r}setPoint(e,t,i,s){1===e&&t.index<=this._points[0].index&&(t.index=this._points[0].index+1),0===e&&t.index>=this._points[1].index&&(t.index=this._points[1].index-1),super.setPoint(e,t,i),this._updatePointsCoordinatePricesDiff()}move(e,t,i,s){super.move(e,t,i,s),this._updatePointsCoordinatePricesDiff()}migrateVersion(e,t,i){if(1===e&&this._pattern.length>0){const e=this._patternPriceDiff();2===this._timePoint.length&&(this._timePoint[1].price=this._timePoint[0].price+e),2===this._points.length&&(this._points[1].price=this._points[0].price+e)}}getScale(){return this._scale=this._calculateScale()}static createProperties(e){const t=new a.DefaultProperty({defaultName:"linetoolbarspattern",state:e});return this._configureProperties(t),t}_preparePoint(e,t){var i;const r=this._alignPointToRangeOfActualData(e),n=this._model.mainSeries(),o=(0,s.ensureNotNull)(n.bars().valueAt(r.index));this.properties().childs().mode.value()===h.LineToolBarsPatternMode.Bars?r.price=(0,s.ensure)(o[2]):r.price=(0,s.ensure)(o[4]);const l=(0,s.ensureNotNull)(this.priceScale()),a=(0,s.ensure)(null===(i=this.ownerSource())||void 0===i?void 0:i.firstValue()),c=.05*l.height(),u=l.priceToCoordinate(r.price,a)-c;return r.price=l.coordinateToPrice(u,a),super._preparePoint(r,t)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,154403))).BarsPatternDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e), e.addExcludedKey("mirrored",1),e.addExcludedKey("flipped",1)}_calculatePatternCoordinatePricesDiff(){var e;return this._pattern.length>0&&null!==(e=this._priceCoordinateDiff([this.firstPatternPrice(),this.lastPatternPrice()]))&&void 0!==e?e:null}_updatePointsCoordinatePricesDiff(){this._pointsCoordinatePricesDiff=this._calculatePointsCoordinatePricesDiff()}_calculatePointsCoordinatePricesDiff(){var e;if(2===this._points.length){const[{price:t},{price:i}]=this.points();return null!==(e=this._priceCoordinateDiff([t,i]))&&void 0!==e?e:null}return null}_createPattern(e,t){const i=this._model.mainSeries().data(),r=[];for(let n=e;n<=t;n++)r.push((0,o.clone)((0,s.ensureNotNull)(i.valueAt(n))));return r}_switchPointsPrice(){const e=this._points[0].price;this._timePoint[0].price=this._points[0].price=this._points[1].price,this._timePoint[1].price=this._points[1].price=e}_mirror(){const e=this._pattern;let t=Math.min(e[0][3],e[0][2]),i=Math.max(e[0][3],e[0][2]);for(let s=1;ss-(e-s);for(let t=0;ts.priceToCoordinate(e,r)))}_priceCoordinateDiff(e){const t=this._pricesToCoordinates(e);if(t)return t[1]-t[0]}_calculateScale(){let e=1;if(2===this._points.length){const t=this._calculatePatternCoordinatePricesDiff();if(!t)return e;const i=this._calculatePointsCoordinatePricesDiff();if(t&&null!==i&&(e=+(i/t).toFixed(8)),this._pointsCoordinatePricesDiff!==i){if(this._scale!==e)return this._updateLastPoint(),this._scale;this._updatePointsCoordinatePricesDiff()}}return e}_updateLastPoint(){var e,t;if(this._points.length<2)return;const i=this.priceScale(),s=null!==(t=null===(e=this.ownerSource())||void 0===e?void 0:e.firstValue())&&void 0!==t?t:null;if(null===s||null===i||i.isEmpty())return;const r=this._calculatePatternCoordinatePricesDiff(),n=this._pricesToCoordinates([this.points()[0].price]);null!==r&&n&&(this._timePoint[1].price=this._points[1].price=i.coordinateToPrice(+(this._scale*r).toFixed(8)+n[0],s),this._updatePointsCoordinatePricesDiff())}}},511628:(e,t,i)=>{i.d(t,{LineToolBezierCubic:()=>o});var s=i(650151),r=i(853965),n=i(821979);class o extends n.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),this._controlPoints=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,98321)).then((t=>{ this._setPaneViews([new t.BezierCubicPaneView(this,e)])}))}pointsCount(){return 2}name(){return"Double Curve"}setLastPoint(e,t){const i=super.setLastPoint(e,t);return this._controlPoints=this._calculateControlPoints(),i}addPoint(e,t,i){const s=super.addPoint(e,t,i);if(s){const e=this._calculateControlPoints();this._controlPoints=null,this._points.push(e[0]),this._points.push(e[1]),i||(this._normalizePoints(),this.createServerPoints()),this._createPointProperty(2),this._createPointProperty(3)}return s}restorePoints(e,t,i){super.restorePoints(e,t,i),this._createPointProperty(2),this._createPointProperty(3)}controlPoints(){return this._controlPoints}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolbeziercubic",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,383716)).then((e=>e.GeneralBezierDefinitionsViewModel))}_calculateControlPoints(){const e=(0,s.ensureNotNull)(this.pointToScreenPoint(this.points()[0])),t=(0,s.ensureNotNull)(this.pointToScreenPoint(this.points()[1])),i=t.subtract(e).scaled(.5).transposed().scaled(.3),r=e.add(t).scaled(.33),n=e.add(t).scaled(.67),o=r.add(i),l=n.subtract(i);return[(0,s.ensureNotNull)(this.screenPointToPoint(o)),(0,s.ensureNotNull)(this.screenPointToPoint(l))]}}},516487:(e,t,i)=>{i.d(t,{LineToolBezierQuadro:()=>o});var s=i(650151),r=i(853965),n=i(821979);class o extends n.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),this._controlPoint=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,545357)).then((t=>{this._setPaneViews([new t.BezierQuadroPaneView(this,e)])}))}pointsCount(){return 2}name(){return"Curve"}setLastPoint(e,t){const i=super.setLastPoint(e,t);return this._controlPoint=this._calculateControlPoint(),i}addPoint(e,t,i){const s=super.addPoint(e,t,i);if(s){const e=this._calculateControlPoint();this._points.push(e),this._controlPoint=null,i||(this._normalizePoints(),this.createServerPoints()),this._createPointProperty(2)}return s}restorePoints(e,t,i){super.restorePoints(e,t,i),this._createPointProperty(2)}controlPoint(){return this._controlPoint}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolbezierquadro",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,383716)).then((e=>e.GeneralBezierDefinitionsViewModel))}_calculateControlPoint(){const e=(0,s.ensureNotNull)(this.pointToScreenPoint(this.points()[0])),t=(0,s.ensureNotNull)(this.pointToScreenPoint(this.points()[1])),i=t.subtract(e).scaled(.5).transposed().scaled(.3),r=e.add(t).scaled(.5).add(i);return(0,s.ensureNotNull)(this.screenPointToPoint(r))}}},168504:(e,t,i)=>{i.d(t,{LineToolBrushBase:()=>n});var s=i(650151),r=i(821979);class n extends r.LineDataSource{constructor(){super(...arguments),this._finished=!1}pointsCount(){ return-1}finished(){return this._finished}finish(){this._finished=!0,this._lastPoint=null,this._normalizePoints(),this.createServerPoints()}hasEditableCoordinates(){return!1}addPoint(e,t,i){if(this._finished)return!0;if(this._lastPoint=null,this._points.length>0){const t=this._points[this._points.length-1],i=(0,s.ensureNotNull)(this.pointToScreenPoint(t));if((0,s.ensureNotNull)(this.pointToScreenPoint(e)).subtract(i).length()<2)return this._finished}return super.addPoint(e),this._finished}restorePoints(e,t,i){super.restorePoints(e,t,i),this._finished=!0}}},271133:(e,t,i)=>{i.d(t,{LineToolBrush:()=>o});var s=i(853965),r=i(168504),n=i(31712);class o extends r.LineToolBrushBase{constructor(e,t,i,s){super(e,t||o.createProperties(),i,s),this._loadPaneViews(e)}smooth(){return this.properties().childs().smooth.value()}name(){return"Brush"}hasEditableCoordinates(){return!1}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolbrush",state:e});return this._configureProperties(t),t}_loadPaneViews(e){Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,411733)).then((t=>{this._setPaneViews([new t.BrushPaneView(this,e)])}))}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,351109)).then((e=>e.BrushDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("backgroundsColors",new n.LineToolColorsProperty([e.childs().backgroundColor],e.childs().fillBackground))}}},844295:(e,t,i)=>{i.d(t,{LineToolCallout:()=>l});var s=i(354950),r=i(853965),n=i(31712),o=i(126222);class l extends o.InplaceTextLineDataSource{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),this._barOffset=0,this._dragStartLeftEdgeIndex=NaN,this._timeScale=e.timeScale(),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,279537)).then((e=>{this._paneView=new e.CalloutPaneView(this,this._model,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this)),this._setPaneViews([this._paneView])}))}pointsCount(){return 2}name(){return"Callout"}getBarOffset(){return this._barOffset}editableTextProperties(){const e=this.properties().childs();return{text:e.text,textColor:e.color,wordWrap:e.wordWrap}}shouldBeRemovedOnDeselect(){const e=this._properties.childs().text.value().trim();return this._points.length===this.pointsCount()&&""===e}addPoint(e){const t=super.addPoint(e);return t&&this._calculateBarOffset(),t}setLastPoint(e){const t=super.setLastPoint(e);return 2===this.points().length&&this._calculateBarOffset(),t}setPoint(e,t){switch(e){case 0:super.setPoint(e,t),this._calculateBarOffset();break;case 1:const i=this.properties().childs();if(!i.wordWrapWidth)return;const s=this._points,r=this._dragStartLeftEdgeIndex,n=Math.round((t.index-r)/2);if(isFinite(r)&&isFinite(n)){s[1]={index:r+n,price:s[1].price},this._calculateBarOffset(),this._normalizePoints() ;const e=this._timeScale.indexToCoordinate(r+2*n)-this._timeScale.indexToCoordinate(r)-8-2;if(!isFinite(e))return;i.wordWrapWidth.setValue(Math.max(100,e));break}s[1]=t,this._calculateBarOffset(),this._normalizePoints()}}setPoints(e){super.setPoints(e);const t=this.properties().childs();if(!t.wordWrapWidth)return;const i=this._dragStartLeftEdgeIndex,s=Math.round((e[1].index-i)/2);if(this._calculateBarOffset(),this._normalizePoints(),isFinite(i)&&isFinite(s)){const e=this._timeScale.indexToCoordinate(i+2*s)-this._timeScale.indexToCoordinate(i)-8-2;if(!isFinite(e))return;t.wordWrapWidth.setValue(Math.max(100,e))}}move(e,t,i){super.move(e,t,i),this._calculateBarOffset()}state(e){const t=super.state(e);return t.barOffset=this._barOffset,t}restoreData(e){e.barOffset?this._barOffset=e.barOffset:this._calculateBarOffset(),this.calculatePoint2()}setPriceScale(e){super.setPriceScale(e),e&&e.priceRange()&&this.calculatePoint2()}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}calculatePoint2(){if(this._model.lineBeingEdited()===this||this._model.sourcesBeingMoved().includes(this))return;if(this._points.length<2)return;const[e,t]=this.points();this._points[1]={price:t.price,index:e.index+this._barOffset}}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolcallout",state:e});return this._configureProperties(t),t}_applyTemplateImpl(e){this.properties().childs().text.setValue(e.text),super._applyTemplateImpl(e)}_correctPoints(e,t){if(e.length1&&(this._barOffset=this.points()[1].index-this.points()[0].index)}}},638202:(e,t,i)=>{i.d(t,{LineToolCircle:()=>l});var s=i(354950),r=i(853965),n=i(821979),o=i(31712);class l extends n.LineDataSource{constructor(e,t,s,r){const n=t||l.createProperties();super(e,n,s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,434475)).then((({CirclePaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}pointsCount(){return 2}name(){return"Circle"}template(){const e=super.template() ;return e.text=this.properties().childs().text.value(),e}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolcircle",state:e});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,70418))).EllipseCircleDefinitionsViewModel}_snapTo45DegreesAvailable(){return!0}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new s.Property("")),e.addChild("linesColors",new o.LineToolColorsProperty([e.childs().color])),e.addChild("linesWidths",new o.LineToolWidthsProperty([e.childs().linewidth])),e.addChild("backgroundsColors",new o.LineToolColorsProperty([e.childs().backgroundColor])),e.addChild("textsColors",new o.LineToolColorsProperty([e.childs().textColor],e.childs().showLabel)),e.addExcludedKey("linesColors",3),e.addExcludedKey("linesWidths",3),e.addExcludedKey("backgroundsColors",3),e.addExcludedKey("textsColors",3),e.addExcludedKey("text",1)}}},768574:(e,t,i)=>{i.d(t,{LineToolComment:()=>n});var s=i(853965),r=i(179180);class n extends r.LineToolBalloon{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Comment"}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolcomment",state:e});return n._configureProperties(t),t}_createPaneView(){Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,229548)).then((e=>{this._setPaneViews([new e.CommentPaneView(this,this._model)])}))}}},73217:(e,t,i)=>{i.d(t,{LineToolCrossLine:()=>l});var s=i(853965),r=i(682912),n=i(421644),o=i(821979);class l extends o.LineDataSource{constructor(e,t,s,o){super(e,t||l.createProperties(),s,o),this._priceAxisView=new r.LineToolHorzLinePriceAxisView(this),this._timeAxisView=new n.LineToolVertLineTimeAxisView(this),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,533661)).then((({CrossLinePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 1}name(){return"Cross Line"}priceAxisViews(e,t){return this.isSourceHidden()?null:t===this.priceScale()&&this.properties().childs().showPrice.value()&&this._model.paneForSource(this)===e?[this._priceAxisView]:null}timeAxisViews(){return this.isSourceHidden()?null:this.properties().childs().showTime.value()?[this._timeAxisView]:null}updateAllViews(e){super.updateAllViews(e),this._priceAxisView.update(e),this._timeAxisView.update()}canHasAlert(){return!1}lineColor(){return this.properties().childs().linecolor.value()}lineWidth(){return this.properties().childs().linewidth.value()}lineStyle(){return this.properties().childs().linestyle.value()}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolcrossline",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){ return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,184062)).then((e=>e.CrossLineDefinitionsViewModel))}}},70726:(e,t,i)=>{i.d(t,{CustomEventItem:()=>n,LineToolCustomUrlEvent:()=>o});var s=i(650151),r=i(776954);class n{constructor(e){this._source=e}position(){return this._props().childs().position.value()}_props(){return this._source.properties()}}class o extends r.LineToolWithRelativePriceCoordinate{constructor(){super(...arguments),this._item=null,this._eventTimePointIndex=null}pointsCount(){return 1}cloneable(){return!1}eventTimePointIndex(){return this._eventTimePointIndex}customEvent(){return this._item}restorePoints(e,t,i){i&&t.length>0&&(this._eventTimePointIndex=t[0].index),super.restorePoints(e,t,i)}priceAxisPoints(){return[]}_baseSeriesIndexForPoint(e){var t;return null!==(t=this._eventTimePointIndex)&&void 0!==t?t:e.index}_alignPointHorizontallyOrVertically(e){var t,i;if(null===this._eventTimePointIndex)return e;const r=this._points[0].index-this._eventTimePointIndex,n=(0,s.ensure)(null===(i=null===(t=this._startMovingPoint)||void 0===t?void 0:t.logical)||void 0===i?void 0:i.index)-r;return{price:e.price,index:n}}_snapPoint45Degree(e,t,i){this._eventTimePointIndex&&(e.index=this._eventTimePointIndex)}_snapTo45DegreesAvailable(){return!0}_allowChangeAnchorHorizontally(){return!0}_pointsForPointset(){return[[(0,s.ensureNotNull)(this._item).time(),0],...super._pointsForPointset()]}_onPointsetUpdated(e){if(0===e.length)return;const t=e.findIndex((e=>0===e.index));-1!==t&&(this._eventTimePointIndex=e[t].value[0]);const i=e.slice(1).map((e=>({value:e.value,index:e.index-1})));super._onPointsetUpdated(i)}_readyToCreatePointset(){return super._readyToCreatePointset()&&null!==this._item}}},224777:(e,t,i)=>{i.d(t,{LineToolCypherPattern:()=>n});var s=i(147985),r=i(853965);class n extends s.LineTool5PointsPattern{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Cypher Pattern"}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolcypherpattern",state:e});return this._configureProperties(t),t}_loadPaneViews(e){Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,100417)).then((t=>{this._setPaneViews([new t.CypherPaneView(this,e)])}))}}},941883:(e,t,i)=>{i.d(t,{DateAndPriceBaseProperties:()=>p,allPropertiesStateKeysBase:()=>d,nonThemedFactoryDefaultsBase:()=>u,themedFactoryDefaultsBase:()=>h});var s=i(195294),r=i(61499),n=i(246733),o=i(808068),l=i(354950),a=i(33249);const c=(0,s.getHexColorByName)("color-tv-blue-500"),u={linewidth:2,fontsize:12,fillLabelBackground:!0,fillBackground:!0,backgroundTransparency:60,intervalsVisibilities:{...o.intervalsVisibilitiesDefaults},customText:{visible:!1,fontsize:12,bold:!1,italic:!1}},h=new Map([[r.StdTheme.Light,{textcolor:(0,s.getHexColorByName)("color-black"),labelBackgroundColor:(0,s.getHexColorByName)("color-white"),linecolor:c,backgroundColor:(0,n.generateColor)(c,85),shadow:"rgba(0, 0, 0, 0.2)",customText:{color:c}}],[r.StdTheme.Dark,{textcolor:(0, s.getHexColorByName)("color-white"),labelBackgroundColor:(0,s.getHexColorByName)("color-cold-gray-800"),linecolor:c,backgroundColor:(0,n.generateColor)(c,85),shadow:"rgba(0, 0, 0, 0.4)",customText:{color:c}}]]),d=["customText.text"];class p extends a.LineDataSourceProperty{constructor({nonThemedDefaultsKeys:e,themedDefaultsKeys:t,...i}){var s,r,n;super({nonThemedDefaultsKeys:e,themedDefaultsKeys:t,templateKeys:[...null!=e?e:[],...null!=t?t:[],...d],...i});const o=null===(s=i.state)||void 0===s?void 0:s.customText;this._textProperty=new l.Property(null!==(r=null==o?void 0:o.text)&&void 0!==r?r:""),null===(n=this.childs().customText)||void 0===n||n.addChild("text",this._textProperty)}template(){const e=super.template();return e.customText.text=this._textProperty.value(),e}}},836843:(e,t,i)=>{i.d(t,{LineToolDateAndPriceRange:()=>P});var s=i(650151),r=i(821979),n=i(3140),o=i(61499),l=i(195294),a=i(853965),c=i(738232),u=i(923237),h=i(941883);const d=(0,l.getHexColorByName)("color-tv-blue-500"),p={...h.nonThemedFactoryDefaultsBase,drawBorder:!1,borderWidth:1},_=new Map([[o.StdTheme.Light,{...h.themedFactoryDefaultsBase.get(o.StdTheme.Light),borderColor:d}],[o.StdTheme.Dark,{...h.themedFactoryDefaultsBase.get(o.StdTheme.Dark),borderColor:d}]]),f=(0,a.extractAllPropertiesKeys)((0,s.ensureDefined)(_.get(o.StdTheme.Light))),m=(0,a.extractAllPropertiesKeys)(p),v=[...f,...m,...u.commonLineToolPropertiesStateKeys,...h.allPropertiesStateKeysBase];class g extends h.DateAndPriceBaseProperties{static create(e){return new this({defaultName:"linetooldateandpricerange",factoryDefaultsSupplier:()=>(0,c.factoryDefaultsForCurrentTheme)(p,_),nonThemedDefaultsKeys:m,themedDefaultsKeys:f,allStateKeys:v,state:e})}}class P extends r.LineDataSource{constructor(e,t,s,r){super(e,t||P.createProperties(),s,r),this._volumeCalculator=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,745062)).then((e=>{this._setPaneViews([new e.DateAndPriceRangePaneView(this,this._model)])}))}destroy(){super.destroy(),null!==this._volumeCalculator&&this._volumeCalculator.destroy()}pointsCount(){return 2}name(){return"Date and Price Range"}template(){return this._properties.template()}volume(){if(null===this._volumeCalculator)return NaN;const e=this.points();return this._volumeCalculator.volume(e[0].index,e[1].index)}setOwnerSource(e){e===this._model.mainSeries()&&((0,s.assert)(null===this._volumeCalculator),this._volumeCalculator=new n.SeriesTimeRangeVolumeCalculator(this._model.mainSeries())),super.setOwnerSource(e)}static createProperties(e){const t=g.create(e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,133954))).GeneralDatePriceRangeDefinitionsViewModel}}},727264:(e,t,i)=>{i.d(t,{LineToolDateRange:()=>v});var s=i(650151),r=i(821979),n=i(3140),o=i(61499),l=i(853965),a=i(738232),c=i(941883),u=i(923237);const h={...c.nonThemedFactoryDefaultsBase,extendTop:!1,extendBottom:!1 },d=c.themedFactoryDefaultsBase,p=(0,l.extractAllPropertiesKeys)((0,s.ensureDefined)(d.get(o.StdTheme.Light))),_=(0,l.extractAllPropertiesKeys)(h),f=[...p,..._,...u.commonLineToolPropertiesStateKeys,...c.allPropertiesStateKeysBase];class m extends c.DateAndPriceBaseProperties{static create(e){return new this({defaultName:"linetooldaterange",factoryDefaultsSupplier:()=>(0,a.factoryDefaultsForCurrentTheme)(h,d),nonThemedDefaultsKeys:_,themedDefaultsKeys:p,allStateKeys:f,state:e})}}class v extends r.LineDataSource{constructor(e,t,s,r){super(e,t||v.createProperties(),s,r),this._volumeCalculator=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,691448)).then((e=>{this._setPaneViews([new e.DateRangePaneView(this,this._model)])}))}destroy(){super.destroy(),null!==this._volumeCalculator&&this._volumeCalculator.destroy()}pointsCount(){return 2}name(){return"Date Range"}template(){return this._properties.template()}volume(){if(null===this._volumeCalculator)return NaN;const e=this.points();return this._volumeCalculator.volume(e[0].index,e[1].index)}setOwnerSource(e){e===this._model.mainSeries()&&((0,s.assert)(null===this._volumeCalculator),this._volumeCalculator=new n.SeriesTimeRangeVolumeCalculator(this._model.mainSeries())),super.setOwnerSource(e)}static createProperties(e){const t=m.create(e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,133954))).GeneralDatePriceRangeDefinitionsViewModel}}},709638:(e,t,i)=>{i.d(t,{LineToolDisjointChannel:()=>l});var s=i(821979),r=i(853965),n=i(389137),o=i(354950);class l extends s.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:l.createProperties(),s,r),this.version=1,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,318467)).then((e=>{this._setPaneViews([new e.DisjointChannelPaneView(this,this._model)])}))}pointsCount(){return 3}name(){return"Disjoint Channel"}hasEditableCoordinates(){return!1}addPoint(e,t,i){return t&&t.shift()&&2===this.points().length&&this._snapPoint45Degree(e,this.points()[this.points().length-2]),super.addPoint(e)}setLastPoint(e,t){return t&&t.shift()&&2===this.points().length&&this._snapPoint45Degree(e,this.points()[this.points().length-2]),super.setLastPoint(e)}setPoint(e,t,i,s){const r=.5*(this._points[1].price+this._points[2].price);if(i&&i.shift()&&1===e){const e=0;this._snapPoint45Degree(t,this.points()[e])}if(e<3&&super.setPoint(e,t),0!==e&&2!==e){if(1===e){const e=this._points[1].price-r;this._points[2].price=this._points[1].price-2*e}else if(3===e){const e=t.price-this._points[2].price;this._points[0].price=this._points[1].price-e,this._points[0].index=t.index}this._normalizePoints()}}getPoint(e){if(e<3)return super.getPoint(e);const t=this._points[0].price-this._points[2].price;return{index:this._points[0].index,price:this._points[1].price-t}}canHasAlert(){return!0}template(){const e=super.template() ;return e.labelText=this.properties().childs().labelText.value(),e}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetooldisjointangle",state:e});return this._configureProperties(t),t}_applyTemplateImpl(e){var t;super._applyTemplateImpl(e),this.properties().childs().labelText.setValue(null!==(t=e.labelText)&&void 0!==t?t:"")}_getAlertPlots(){const e=this._points[0],t=this._points[1],i=[];e.index<=t.index?(i.push(e),i.push(t)):(i.push(t),i.push(e));const s=this._points[2];s.time=t.time,s.index=t.index;const r={price:s.price+(t.price-e.price),time:e.time,index:e.index},o=[];let l,a,c,u;s.index<=r.index?(o.push(s),o.push(r)):(o.push(r),o.push(s)),i[0].price>o[0].price?(l=i,a=o):o[0].price>i[0].price||o[1].price>i[1].price?(l=o,a=i):(l=i,a=o);const h=this.properties().childs().extendLeft.value(),d=this.properties().childs().extendRight.value();return e.index<=t.index?(c=h,u=d):(c=d,u=h),[this._linePointsToAlertPlot(l,"Upper",c,u),this._linePointsToAlertPlot(a,"Lower",c,u)].filter(n.notNull)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,872077))).GeneralTrendFiguresDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.hasChild("labelText")||e.addChild("labelText",new o.Property("")),e.addExcludedKey("labelText",1)}}},960690:(e,t,i)=>{i.d(t,{LineToolElliott:()=>p,LineToolElliottCorrection:()=>x,LineToolElliottDoubleCombo:()=>w,LineToolElliottImpulse:()=>m,LineToolElliottTriangle:()=>g,LineToolElliottTripleCombo:()=>y});var s=i(444372),r=i(809796),n=i(821979),o=i(373571),l=i(853965),a=i(31712),c=i(440941);const u=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],h=new r.TranslatedString("change Elliott degree",s.t(null,void 0,i(876020))),d=[{value:0,title:s.t(null,void 0,i(433820))},{value:1,title:s.t(null,void 0,i(558397))},{value:2,title:s.t(null,void 0,i(609753))},{value:3,title:s.t(null,void 0,i(718367))},{value:4,title:s.t(null,void 0,i(591889))},{value:5,title:s.t(null,void 0,i(495176))},{value:6,title:s.t(null,void 0,i(348404))},{value:7,title:s.t(null,void 0,i(671778))},{value:8,title:s.t(null,{context:"wave"},i(266051))},{value:9,title:s.t(null,{context:"wave"},i(486054))},{value:10,title:s.t(null,void 0,i(185884))},{value:11,title:s.t(null,void 0,i(471722))},{value:12,title:s.t(null,void 0,i(210931))},{value:13,title:s.t(null,void 0,i(729662))},{value:14,title:s.t(null,void 0,i(609632))}];class p extends n.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:p.createProperties(),s,r),this.version=4,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,762994)).then((e=>{this._setPaneViews([new e.ElliottLabelsPaneView(this,this._model)])}))}migrateVersion(e,t,i){if(i.properties.hasChild("background")&&i.properties.removeProperty("background"),i.properties.hasChild("backgroundColor")&&i.properties.removeProperty("backgroundColor"),i.properties.hasChild("showBackground")&&i.properties.removeProperty("showBackground"),1===e){ const e=Object.assign({},this._timePoint[0]);if(this._timePoint.unshift(e),this._points.length>0){const e=Object.assign({},this._points[0]);this._points.unshift(e)}}}applyTemplate(e){const t=e;delete t.background,delete t.backgroundColor,delete t.showBackground,super.applyTemplate(e)}name(){return"Elliott Labels"}additionalActions(e){return[new o.Action({actionId:"Chart.LineTool.Elliot.ChangeDegreeProperty",options:{label:s.t(null,void 0,i(69479)),subItems:u.map((t=>{const i=d.filter((e=>e.value===t))[0];return new o.Action({actionId:"Chart.LineTool.Elliot.ChangeDegreeProperty",options:{label:i.title,checkable:!0,checked:this.properties().childs().degree.value()===t,onExecute:()=>{e.setProperty(this.properties().childs().degree,t,h,c.lineToolsDoNotAffectChartInvalidation)}}})}))}})]}label(e){const t=u.length-this.properties().childs().degree.value()-1,i=Math.floor(t/3);return{group:i,bold:!!(i%2),decoration:["","brackets","circle"][t%3],label:this.labelsGroup()[i][e]}}availableDegreesValues(){return d}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolelliott",state:e});return this._configureProperties(t),t}static migrateState(e){const t={0:11,1:10,2:9,3:8,4:7,5:6,6:5,7:4,8:3},i={0:11,1:8};"LineToolElliottSubminuette"===e.type&&(e.type="LineToolElliottImpulse",e.state.degree=t[e.state.wavesize]),"LineToolElliottMinor"===e.type&&(e.type="LineToolElliottImpulse",e.state.degree=t[e.state.wavesize]),"LineToolElliottCircle"===e.type&&(e.type="LineToolElliottImpulse",e.state.degree=t[e.state.wavesize]),"LineToolElliottMinorRetr"===e.type&&(e.type="LineToolElliottCorrection",e.state.degree=i[e.state.wavesize]),"LineToolElliottMajorRetr"===e.type&&(e.type="LineToolElliottCorrection",e.state.degree=i[e.state.wavesize])}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,46971))).ElliottPatternDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new a.LineToolColorsProperty([e.childs().color])),e.addExcludedKey("linesColors",3)}}class _ extends p{pointsCount(){return 6}}const f=[["0","1","2","3","4","5"],["0","i","ii","iii","iv","v"],["0","1","2","3","4","5"],["0","I","II","III","IV","V"],["0","1","2","3","4","5"]];class m extends _{constructor(e,t,i,s){super(e,t||m.createProperties(),i,s)}name(){return"Elliott Impulse Wave (12345)"}labelsGroup(){return f}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolelliottimpulse",state:e});return this._configureProperties(t),t}}const v=[["0","A","B","C","D","E"],["0","a","b","c","d","e"],["0","A","B","C","D","E"],["0","a","b","c","d","e"],["0","A","B","C","D","E"]];class g extends _{constructor(e,t,i,s){super(e,t||g.createProperties(),i,s)}name(){return"Elliott Triangle Wave (ABCDE)"}labelsGroup(){return v}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolelliotttriangle",state:e});return this._configureProperties(t),t}} const P=[["0","W","X","Y","X","Z"],["0","w","x","y","x","z"],["0","W","X","Y","X","Z"],["0","w","x","y","x","z"],["0","W","X","Y","X","Z"]];class y extends _{constructor(e,t,i,s){super(e,null!=t?t:y.createProperties(),i,s)}name(){return"Elliott Triple Combo Wave (WXYXZ)"}labelsGroup(){return P}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolelliotttriplecombo",state:e});return this._configureProperties(t),t}}class S extends p{pointsCount(){return 4}}const b=[["0","A","B","C"],["0","a","b","c"],["0","A","B","C"],["0","a","b","c"],["0","A","B","C"]];class x extends S{constructor(e,t,i,s){super(e,null!=t?t:x.createProperties(),i,s)}name(){return"Elliott Correction Wave (ABC)"}labelsGroup(){return b}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolelliottcorrection",state:e});return this._configureProperties(t),t}}const C=[["0","W","X","Y"],["0","w","x","y"],["0","W","X","Y"],["0","w","x","y"],["0","W","X","Y"]];class w extends S{constructor(e,t,i,s){super(e,null!=t?t:w.createProperties(),i,s)}name(){return"Elliott Double Combo Wave (WXY)"}labelsGroup(){return C}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolelliottdoublecombo",state:e});return this._configureProperties(t),t}}},43853:(e,t,i)=>{i.d(t,{LineToolEllipse:()=>u});var s=i(650151),r=i(204652),n=i(86441),o=i(354950),l=i(853965),a=i(821979),c=i(31712);class u extends a.LineDataSource{constructor(e,t,s,r){super(e,t||u.createProperties(),s,r),this.version=2,this._dist=null,this._fakePointAdded=!1,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,555422)).then((({EllipsePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}startChanging(e,t){if(super.startChanging(e,t),0===e||1===e){const e=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),t=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[2]));this._dist=(0,r.distanceToLine)(e,t,i).distance||0}}addPoint(e,t,i){const s=super.addPoint(e,t,i);return s&&(this._fakePointAdded=!1),s}setPoint(e,t,i,o){const l={...t};let a=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),c=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),u=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[2]));switch(e){case 0:{if(i&&i.shift()){this._snapPoint45Degree(l,this._points[1]),this._points[0]=l,this._points[2]=this._preparePointInternal(this._points[2],i,!0),this._points[0].index===this._points[1].index&&this._fixVerticalDiameterPoints(this._points[0],this._points[1],this._points[2]);break}a=(0,s.ensureNotNull)(this.pointToScreenPoint(l));const e=c.subtract(a),t=a.add(c).scaled(.5),r=new n.Point(-e.y,e.x).normalized();u=t.add(r.scaled((0,s.ensureNotNull)(this._dist))),this._points[0]=l,this._points[2]=(0,s.ensureNotNull)(this.screenPointToPoint(u));break}case 1:{if(i&&i.shift()){this._snapPoint45Degree(l,this._points[0]),this._points[1]=l, this._points[2]=this._preparePointInternal(this._points[2],i,!0),this._points[0].index===this._points[1].index&&this._fixVerticalDiameterPoints(this._points[1],this._points[0],this._points[2]);break}c=(0,s.ensureNotNull)(this.pointToScreenPoint(l));const e=c.subtract(a),t=a.add(c).scaled(.5),r=new n.Point(-e.y,e.x).normalized();u=t.add(r.scaled((0,s.ensureNotNull)(this._dist))),this._points[1]=l,this._points[2]=(0,s.ensureNotNull)(this.screenPointToPoint(u));break}case 2:{const e=(0,s.ensureNotNull)(this.pointToScreenPoint(l)),t=(0,r.distanceToLine)(a,c,e).distance,i=c.subtract(a),o=a.add(c).scaled(.5),h=new n.Point(-i.y,i.x).normalized();u=o.add(h.scaled(t)),this._points[2]=(0,s.ensureNotNull)(this.screenPointToPoint(u));break}case 3:{const e=(0,s.ensureNotNull)(this.pointToScreenPoint(l)),t=(0,r.distanceToLine)(a,c,e).distance,i=c.subtract(a),o=a.add(c).scaled(.5),h=new n.Point(-i.y,i.x).normalized();u=o.add(h.scaled(t)),this._points[2]=(0,s.ensureNotNull)(this.screenPointToPoint(u));break}}this._normalizePoints()}pointsCount(){return 3}name(){return"Ellipse"}hasEditableCoordinates(){return!1}migrateVersion(e,t,i){if(1===e&&2===this._points.length){const e=this._points[0].price,t=.5*(this._points[0].price+this._points[1].price);this._points[0]={price:t,index:this._points[0].index},this._points[1]={price:t,index:this._points[1].index},this._points.push({price:e,index:this._points[0].index})}if(1===e&&2===this._timePoint.length){const e=this._timePoint[0].price,t=.5*(this._timePoint[0].price+this._timePoint[1].price);this._timePoint[0].price=t,this._timePoint[1].price=t;const i={price:e,offset:this._timePoint[0].offset,time_t:this._timePoint[0].time_t};this._timePoint.push(i)}}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}static createProperties(e){const t=new l.DefaultProperty({defaultName:"linetoolellipse",state:e});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,70418))).EllipseCircleDefinitionsViewModel}_preparePoint(e,t){const i=this._preparePointInternal(e,t,!1);return t&&t.shift()&&this._points[0].index===this._points[1].index&&this._fixVerticalDiameterPoints(this._points[1],this._points[0],i),i}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new o.Property("")),e.addChild("linesColors",new c.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new c.LineToolColorsProperty([e.childs().textColor],e.childs().showLabel)),e.addExcludedKey("text",1)}_preparePointInternal(e,t,i){let r={...e};if(t&&t.shift()){const t=this.points().length;if(!this._fakePointAdded&&3===t&&!i)return r;if(this._fakePointAdded||2===t||i){this._snapPoint45Degree(e,this._points[0]),this._fakePointAdded?this._points[1]=e:i||(this._fakePointAdded=!0,super._addPointIntenal(e));const t=(0, s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),l=o.x-t.x,a=o.y-t.y,c=Math.sqrt(l*l+a*a)/2,u=o.subtract(t),h=t.add(o).scaled(.5),d=new n.Point(-u.y,u.x).normalized(),p=h.add(d.scaled(c));r=(0,s.ensureNotNull)(this.screenPointToPoint(p)),(isNaN(r.price)||isNaN(r.index))&&(r=(0,s.ensureNotNull)(this.screenPointToPoint(h)))}}else this._fakePointAdded&&(this._points.splice(1,1),this._fakePointAdded=!1);return r}_fixVerticalDiameterPoints(e,t,i){const r=(0,s.ensureNotNull)(this.pointToScreenPoint(e)),o=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),l=this._model.timeScale(),a=l.indexToCoordinate(e.index),c=l.indexToCoordinate(i.index);let u=2*Math.abs(a-c);u*=t.price>e.price?1:-1,e.price=(0,s.ensureNotNull)(this.screenPointToPoint(new n.Point(r.x,o.y+u))).price}}},167843:(e,t,i)=>{i.d(t,{LineToolEmoji:()=>b});var s=i(328530),r=i(201089),n=i(120780),o=i(885482),l=i(500477),a=i(760184),c=i(822914),u=i(852290),h=i(33249),d=i(808068),p=i(853965),_=i(923237);const f={intervalsVisibilities:{...d.intervalsVisibilitiesDefaults},size:40},m={emoji:"😀",angle:.5*Math.PI},v=(0,p.extractAllPropertiesKeys)(f),g=(0,p.extractAllPropertiesKeys)(m),P=[...v,...g,..._.commonLineToolPropertiesStateKeys];class y extends h.LineDataSourceProperty{constructor(e){super(e)}static create(e,t){return new this({defaultName:"linetoolemoji",factoryDefaultsSupplier:()=>(0,c.default)(f),nonThemedDefaultsKeys:v,themedDefaultsKeys:[],state:(0,u.default)({},m,{emoji:t},null!=e?e:{}),allStateKeys:P})}}const S=(0,r.getLogger)("Chart.LineToolEmoji");class b extends a.LineToolSvgIconBase{constructor(e,t,i,s){super(e,t||b.createProperties(),i,s),this.version=1,this._loadViews()}name(){return"Emoji"}template(){return this.properties().template()}static createProperties(e){const t=y.create(e,o.emojiTool.value());return b._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,282375))).LineDataSourceDefinitionsViewModel}async _loadViews(){const e=this._properties.childs().emoji.value(),t=(0,s.getTwemojiUrl)(e,"svg");try{const[s,{EmojiPaneView:r}]=await Promise.all([(0,n.fetch)(t).then((e=>e.text())),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,496259))]);if(!this._isDestroyed){this._svgContent=s,this._onIconChanged.fire();const t=(0,l.svgRenderer)(s);null===t&&S.logWarn(`Couldn't create svg renderer for emoji ${e}`),this._setPaneViews([new r(this,this._model,t)])}}catch(t){S.logWarn(`An error ocurred while loading emoji content ${e}: ${t}`)}}}},252598:(e,t,i)=>{i.d(t,{LineToolExtended:()=>r});var s=i(956268);class r extends s.LineToolTrendLine{constructor(e,t,i,s){super(e,null!=t?t:r.createProperties(),i,s)}name(){return"Extended Line"}static createProperties(e){const t=s.LineToolTrendLine._createPropertiesImpl("linetoolextended",e);return r._configureProperties(t),t}}},101443:(e,t,i)=>{i.d(t,{LineToolFibWithInplaceTextBase:()=>c, getLevelProps:()=>l});var s=i(650151),r=i(354950),n=i(126222);const o=new r.Property(!1);function l(e,t){return(0,s.ensureDefined)(e.child(`level${t}`))}class a extends n.InplaceTextUndoCommand{constructor(e,t,i,s,r){super(e,t,i,s),this._levelIndex=r}_textProperty(e){return l(e.properties(),this._levelIndex).childs().text}}class c extends n.InplaceTextLineDataSource{constructor(){super(...arguments),this._inplaceEditLevelIndex=1}editableTextStyle(){return{...super.editableTextStyle(),forbidLineBreaks:!0,maxLength:50}}editableTextProperties(){const e=this.properties().childs();return{text:e.editableText,textColor:e.editableTextColor,wordWrap:o}}removeIfEditableTextIsEmpty(){return!1}activateEditingOnCreation(){return!1}setInplaceEditLevelIndex(e){var t;null===(t=this._destroyEditableTextSubscriptions)||void 0===t||t.call(this);const i=this.properties(),r=i.childs().editableText,n=i.childs().editableTextColor,o=l(i,e),a=(0,s.ensureDefined)(o).childs().text,c=(0,s.ensureDefined)(o).childs().color,u={};r.setValue(a.value()),n.setValue(c.value()),r.subscribe(u,(()=>a.setValue(r.value()))),a.subscribe(u,(()=>r.setValue(a.value()))),n.subscribe(u,(()=>c.setValue(n.value()))),c.subscribe(u,(()=>n.setValue(c.value()))),this._destroyEditableTextSubscriptions=()=>{r.unsubscribeAll(u),a.unsubscribeAll(u),n.unsubscribeAll(u),c.unsubscribeAll(u)},this._inplaceEditLevelIndex=e,this._editableText.setValue(r.value())}_changeEditableTextUndoCommand(e,t){return new a(this._model,this,e,t,this._inplaceEditLevelIndex)}static _configureProperties(e){super._configureProperties(e),e.addChild("editableText",new r.Property("")),e.addChild("editableTextColor",new r.Property("")),e.addExcludedKey("editableText",3),e.addExcludedKey("editableTextColor",3)}}},965989:(e,t,i)=>{i.d(t,{LineToolFibChannel:()=>h});var s=i(650151),r=i(444372),n=i(809796),o=i(440941),l=i(517336),a=i(31712),c=i(126222);const u=new n.TranslatedString("erase level line",r.t(null,void 0,i(812962)));class h extends c.InplaceTextLineDataSource{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),this.version=2,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,361501)).then((({FibChannelPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 24}migrateVersion(e,t,i){i.properties.removeProperty("reverse")}pointsCount(){return 3}name(){return"Fib Channel"}processErase(e,t){const i="level"+t,s=this.properties().child(i).childs().visible;e.setProperty(s,!1,u,o.lineToolsDoNotAffectChartInvalidation)}editableTextProperties(){(0,s.assert)(!1,"unexpected method call")}removeIfEditableTextIsEmpty(){return!1}static createProperties(e){const t=new l.LevelsProperty({defaultName:"linetoolfibchannel",state:e,map:{range:[1,24],names:["coeff","color","visible"]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,866406))).FibDrawingsWith24LevelsDefinitionsViewModel} static _configureProperties(e){super._configureProperties(e);const t=[];for(let i=1;i<=24;i++){const r=(0,s.ensureDefined)(e.child("level"+i));t.push((0,s.ensureDefined)(r.child("color")))}e.addChild("linesColors",new a.LineToolColorsProperty(t))}}},953718:(e,t,i)=>{i.d(t,{LineToolFibCircles:()=>h});var s=i(650151),r=i(444372),n=i(809796),o=i(517336),l=i(31712),a=i(440941),c=i(126222);const u=new n.TranslatedString("erase level line",r.t(null,void 0,i(812962)));class h extends c.InplaceTextLineDataSource{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,889131)).then((e=>{this._setPaneViews([new e.FibCirclesPaneView(this,this._model)])}))}levelsCount(){return 11}pointsCount(){return 2}name(){return"Fib Circles"}processErase(e,t){const i=(0,s.ensureDefined)(this.properties().child(`level${t}`));e.setProperty(i,!1,u,a.lineToolsDoNotAffectChartInvalidation)}editableTextProperties(){(0,s.assert)(!1,"unexpected method call")}removeIfEditableTextIsEmpty(){return!1}static createProperties(e){const t=new o.LevelsProperty({defaultName:"linetoolfibcircles",state:e,map:{range:[1,11]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,151611))).FibCirclesDefinitionsViewModel}_snapTo45DegreesAvailable(){return!0}static _configureProperties(e){var t,i;super._configureProperties(e);const r=e.childs(),n=[r.trendline.childs().linewidth],o=[r.trendline.childs().color];for(let r=1;r<=11;r++)n.push((0,s.ensureDefined)(null===(t=e.child("level"+r))||void 0===t?void 0:t.child("linewidth"))),o.push((0,s.ensureDefined)(null===(i=e.child("level"+r))||void 0===i?void 0:i.child("color")));e.addChild("linesColors",new l.LineToolColorsProperty(o)),e.addChild("linesWidths",new l.LineToolWidthsProperty(n))}}},498995:(e,t,i)=>{i.d(t,{LineToolFibRetracement:()=>u});var s=i(444372),r=i(809796),n=i(517336),o=i(440941),l=i(31712),a=i(101443);const c=new r.TranslatedString("erase level line",s.t(null,void 0,i(812962)));class u extends a.LineToolFibWithInplaceTextBase{constructor(e,t,s,r){super(e,t||u.createProperties(),s,r),this.version=2,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,832307)).then((e=>{this._paneView=new e.FibRetracementPaneView(this,this._model,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this)),this._setPaneViews([this._paneView])}))}levelsCount(){return 24}pointsCount(){return 2}name(){return"Fib Retracement"}migrateVersion(e){1===e&&this.properties().childs().extendLines.setValue(!0)}processErase(e,t){const i="level"+t,{visible:s}=this.properties().childs()[i].childs();e.setProperty(s,!1,c,o.lineToolsDoNotAffectChartInvalidation)}fibLevelsBasedOnLogScale(){var e;return this.properties().childs().fibLevelsBasedOnLogScale.value()&&!!(null===(e=this.priceScale())||void 0===e?void 0:e.isLog())}template(){ const e=super.template();for(let t=1;t<=24;t++){const i=(0,a.getLevelProps)(this._properties,t);e[`level${t}`][3]=i.childs().text.value()}return e}static createProperties(e){const t=new n.LevelsProperty({defaultName:"linetoolfibretracement",state:e,map:{range:[1,24],names:["coeff","color","visible","text"]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,866406))).FibDrawingsWith24LevelsDefinitionsViewModel}_applyTemplateImpl(e){var t;for(let i=1;i<=24;i++){const s=(0,a.getLevelProps)(this._properties,i),r=e[`level${i}`];s.childs().text.setValue(null!==(t=r[3])&&void 0!==t?t:"")}super._applyTemplateImpl(e)}static _configureProperties(e){super._configureProperties(e);const t=[e.childs().trendline.childs().linewidth,e.childs().levelsStyle.childs().linewidth],i=[e.childs().trendline.childs().color];for(let t=1;t<=24;t++){const s=(0,a.getLevelProps)(e,t);i.push(s.childs().color),e.addExcludedKey(`level${t}.text`,1)}e.addChild("linesColors",new l.LineToolColorsProperty(i)),e.addChild("linesWidths",new l.LineToolWidthsProperty(t))}}},974472:(e,t,i)=>{i.d(t,{LineToolFibSpeedResistanceArcs:()=>h});var s=i(650151),r=i(444372),n=i(809796),o=i(517336),l=i(31712),a=i(440941),c=i(126222);const u=new n.TranslatedString("erase level line",r.t(null,void 0,i(812962)));class h extends c.InplaceTextLineDataSource{constructor(e,t,s,r){super(e,null!=t?t:h.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,303842)).then((e=>{this._setPaneViews([new e.FibSpeedResistanceArcsPaneView(this,this._model)])}))}levelsCount(){return 11}pointsCount(){return 2}name(){return"Fib Speed Resistance Arcs"}processErase(e,t){const i=(0,s.ensureDefined)(this.properties().child(`level${t}`)).childs().visible;e.setProperty(i,!1,u,a.lineToolsDoNotAffectChartInvalidation)}editableTextProperties(){(0,s.assert)(!1,"unexpected method call")}removeIfEditableTextIsEmpty(){return!1}static createProperties(e){const t=new o.LevelsProperty({defaultName:"linetoolfibspeedresistancearcs",state:e,map:{range:[1,11]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,149820))).FibSpeedResistanceArcsDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=e.childs().trendline.childs(),i=[t.linewidth],r=[t.color];for(let t=1;t<=11;t++){const n=(0,s.ensureDefined)(e.child(`level${t}`)).childs();i.push(n.linewidth),r.push(n.color)}e.addChild("linesColors",new l.LineToolColorsProperty(r)),e.addChild("linesWidths",new l.LineToolWidthsProperty(i))}}},63491:(e,t,i)=>{i.d(t,{LineToolFibSpeedResistanceFan:()=>h});var s=i(650151),r=i(444372),n=i(809796),o=i(821979),l=i(517336),a=i(31712),c=i(440941);const u=new n.TranslatedString("erase level line",r.t(null,void 0,i(812962)));class h extends o.LineDataSource{ constructor(e,t,s,r){super(e,null!=t?t:h.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,446261)).then((e=>{this._setPaneViews([new e.FibSpeedResistanceFanPaneView(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}`,r=(0,s.ensureDefined)(this.properties().child(i)).childs().visible;e.setProperty(r,!1,u,c.lineToolsDoNotAffectChartInvalidation)}static createProperties(e){e&&void 0===e.reverse&&(e.reverse=!0);const t=new l.LevelsProperty({defaultName:"linetoolfibspeedresistancefan",state:e,map:{range:[1,7],prefixes:["h","v"],names:["coeff","color","visible"]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,233169))).FibSpeedResistanceFanDefinitionsViewModel}_snapTo45DegreesAvailable(){return!0}static _configureProperties(e){var t,i;super._configureProperties(e);const r=[e.childs().grid.childs().color];for(let i=1;i<=7;i++)r.push((0,s.ensureDefined)(null===(t=e.child(`hlevel${i}`))||void 0===t?void 0:t.child("color")));for(let t=1;t<=7;t++)r.push((0,s.ensureDefined)(null===(i=e.child(`vlevel${t}`))||void 0===i?void 0:i.child("color")));e.addChild("linesColors",new a.LineToolColorsProperty(r)),e.addExcludedKey("linesColors",3)}}},958849:(e,t,i)=>{i.d(t,{LineToolFibTimeZone:()=>u});var s=i(444372),r=i(809796),n=i(31712),o=i(517336),l=i(440941),a=i(821979);const c=new r.TranslatedString("erase level line",s.t(null,void 0,i(812962)));class u extends a.LineDataSource{constructor(e,t,s,r){super(e,t||u.createProperties(),s,r),this.version=2,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,122613)).then((({FibTimeZonePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 11}migrateVersion(e,t,i){if(1===e){const e=i.properties.childs(),t=i.properties,s=t.baselinecolor.value(),r=t.linecolor.value(),n=t.linewidth.value(),o=t.linestyle.value();e.level1.childs().color.setValue(s);for(let t=2;t<=11;t++)e["level"+t].childs().color.setValue(r);for(let t=1;t<=11;t++)e["level"+t].childs().linewidth.setValue(n),e["level"+t].childs().linestyle.setValue(o)}}pointsCount(){return 2}name(){return"Fib Time Zone"}processErase(e,t){const i="level"+t,s=this.properties().childs()[i].childs().visible;e.setProperty(s,!1,c,l.lineToolsDoNotAffectChartInvalidation)}static createProperties(e){const t=new o.LevelsProperty({defaultName:"linetoolfibtimezone",state:e,map:{range:[1,11]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,542375))).FibTimezoneDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=[],i=[],s=[];for(let r=1;r<=11;r++){const n=e.childs()["level"+r].childs() ;t.push(n.linewidth),i.push(n.color),s.push(n.linestyle)}e.addChild("linesColors",new n.LineToolColorsProperty(i)),e.addChild("linesWidths",new n.LineToolWidthsProperty(t)),e.addChild("linesStyles",new n.LineToolCollectedProperty(s)),e.hasChild("baselinecolor")&&e.removeProperty("baselinecolor"),e.hasChild("linecolor")&&e.removeProperty("linecolor"),e.hasChild("linewidth")&&e.removeProperty("linewidth"),e.hasChild("linestyle")&&e.removeProperty("linestyle")}}},672688:(e,t,i)=>{i.d(t,{LineToolFibWedgeBase:()=>o});var s=i(650151),r=i(86441),n=i(126222);class o extends n.InplaceTextLineDataSource{pointsCount(){return 3}hasEditableCoordinates(){return!1}setPoint(e,t){if(super.setPoint(e,t),!this._recursiveGuard)try{if(this._recursiveGuard=!0,2===e){const e=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0]));let t=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1]));const i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[2])).subtract(e).length();let n=t.subtract(e);n.length()<=0&&(n=new r.Point(1,0)),t=e.add(n.normalized().scaled(i));const o=(0,s.ensureNotNull)(this.screenPointToPoint(t)),l=this._pointsProperty.childs().points[1];l.childs().price.setValue(o.price),l.childs().bar.setValue(o.index)}else{const e=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),t=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1]));let i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[2]));const n=t.subtract(e).length();let o=i.subtract(e);o.length()<=0&&(o=new r.Point(1,0)),i=e.add(o.normalized().scaled(n));const l=(0,s.ensureNotNull)(this.screenPointToPoint(i)),a=this._pointsProperty.childs().points[2];a.childs().price.setValue(l.price),a.childs().bar.setValue(l.index)}}finally{this._recursiveGuard=!1}}addPoint(e){if(2===this._points.length){const t=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1]));let r=(0,s.ensureNotNull)(this.pointToScreenPoint(e));const n=i.subtract(t).length(),o=r.subtract(t).normalized();r=t.add(o.scaled(n));const l=(0,s.ensureNotNull)(this.ownerSource()),a=(0,s.ensureNotNull)(l.firstValue()),c=(0,s.ensureNotNull)(this.priceScale()).coordinateToPrice(r.y,a);e={index:Math.round(this._model.timeScale().coordinateToIndex(r.x)),price:c}}return super.addPoint(e)}editableTextProperties(){(0,s.assert)(!1,"unexpected method call")}removeIfEditableTextIsEmpty(){return!1}}},781811:(e,t,i)=>{i.d(t,{LineToolFibWedge:()=>h});var s=i(650151),r=i(444372),n=i(809796),o=i(672688),l=i(517336),a=i(31712),c=i(440941);const u=new n.TranslatedString("erase level line",r.t(null,void 0,i(812962)));class h extends o.LineToolFibWedgeBase{constructor(e,t,s,r){super(e,null!=t?t:h.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,257760)).then((e=>{this._setPaneViews([new e.FibWedgePaneView(this,this._model)])}))}levelsCount(){return 11}isSynchronizable(){return!1}name(){return"Fib Wedge"}processErase(e,t){const i=(0, s.ensureDefined)(this.properties().child(`level${t}`));e.setProperty(i.childs().visible,!1,u,c.lineToolsDoNotAffectChartInvalidation)}static createProperties(e){const t=new l.LevelsProperty({defaultName:"linetoolfibwedge",state:e,map:{range:[1,11]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,444191))).FibWedgeDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=[e.childs().trendline.childs().linewidth],i=[e.childs().trendline.childs().color];for(let r=1;r<=11;r++){const n=(0,s.ensureDefined)(e.child(`level${r}`));t.push(n.childs().linewidth),i.push(n.childs().color)}e.addChild("linesColors",new a.LineToolColorsProperty(i)),e.addChild("linesWidths",new a.LineToolWidthsProperty(t))}}},218032:(e,t,i)=>{i.d(t,{LineToolFlagMark:()=>l});var s=i(86441),r=i(821979),n=i(853965),o=i(31712);class l extends r.LineDataSource{constructor(e,t,r,n){super(e,t||l.createProperties(),r,n),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,812318)).then((({FlagMarkPaneView:e})=>{const t=new e(this,this.model());t.setAnchors(new s.Point(0,0)),this._setPaneViews([t])}))}pointsCount(){return 1}name(){return"Flag Mark"}static createProperties(e){e&&void 0===e.flagColor&&(e.flagColor="#318757");const t=new n.DefaultProperty({defaultName:"linetoolflagmark",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,268987)).then((e=>e.FlagMarkDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("backgroundsColors",new o.LineToolColorsProperty([e.childs().flagColor])),e.addExcludedKey("backgroundsColors",3)}}l.version=2},634659:(e,t,i)=>{i.d(t,{LineToolFlatBottom:()=>l});var s=i(821979),r=i(853965),n=i(389137),o=i(354950);class l extends s.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:l.createProperties(),s,r),this.version=1,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,767345)).then((e=>{this._setPaneViews([new e.FlatBottomPaneView(this,this._model)])}))}pointsCount(){return 3}name(){return"Flat Bottom"}hasEditableCoordinates(){return!1}addPoint(e,t,i){return t&&t.shift()&&2===this.points().length&&this._snapPoint45Degree(e,this.points()[this.points().length-2]),super.addPoint(e)}setLastPoint(e,t){return t&&t.shift()&&2===this.points().length&&this._snapPoint45Degree(e,this.points()[this.points().length-2]),super.setLastPoint(e)}setPoint(e,t,i,s){if(i&&i.shift()&&1===e){const e=0;this._snapPoint45Degree(t,this.points()[e])}if(2===e)this._points[1].index=t.index;else if(3===e)return this._points[0].index=t.index,this._points[2].price=t.price,void this._normalizePoints();super.setPoint(e,t)}getPoint(e){return e<3?super.getPoint(e):3===e?{index:this._points[0].index,price:this._points[2].price}:null}canHasAlert(){ return!0}template(){const e=super.template();return e.labelText=this.properties().childs().labelText.value(),e}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolflatbottom",state:e});return this._configureProperties(t),t}_applyTemplateImpl(e){var t;super._applyTemplateImpl(e),this.properties().childs().labelText.setValue(null!==(t=e.labelText)&&void 0!==t?t:"")}_getAlertPlots(){const e=this._points[0],t=this._points[1],i=[];e.index<=t.index?(i.push(e),i.push(t)):(i.push(t),i.push(e));const s=this._points[2];s.time=t.time,s.index=t.index;const r={price:s.price,time:e.time,index:e.index},o=[];let l,a,c,u;s.index<=r.index?(o.push(s),o.push(r)):(o.push(r),o.push(s)),i[0].price>o[0].price?(l=i,a=o):o[0].price>i[0].price||o[1].price>i[1].price?(l=o,a=i):(l=i,a=o);const h=this.properties().childs().extendLeft.value(),d=this.properties().childs().extendRight.value();return e.index<=t.index?(c=h,u=d):(c=d,u=h),[this._linePointsToAlertPlot(l,"Upper",c,u),this._linePointsToAlertPlot(a,"Lower",h,u)].filter(n.notNull)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,872077))).GeneralTrendFiguresDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.hasChild("labelText")||e.addChild("labelText",new o.Property("")),e.addExcludedKey("labelText",1)}}},406182:(e,t,i)=>{i.d(t,{createPropertiesObject:()=>l});var s=i(389137),r=i(517336);function n(e,t,i){var r;for(const n of Object.keys(null!==(r=e.levels)&&void 0!==r?r:{}))if(e.levels[n]&&(0,s.isSameType)(e.levels[n],t.typecheck())){let s=t.tpl();i.names.forEach(((i,r)=>{s=t.fill(""+r,i,e.levels[n],s)})),e.levels[n]=s}return e}class o extends r.LevelsProperty{constructor(e,t){super({defaultName:e,state:t,map:{names:["width","color","visible"]},levelsIterator:n})}}function l(e,t){return new o(e,t)}},833762:(e,t,i)=>{i.d(t,{LineToolGannComplex:()=>h});var s=i(86441),r=i(650151),n=i(327453),o=i(821979),l=i(915179),a=i(406182),c=i(31712),u=i(422333);class h extends o.LineDataSource{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),this.version=2,this._scaleRatioFormatter=new n.LimitedPrecisionNumericFormatter(7),this.version=2,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,726868)).then((({GannComplexPaneView:e})=>{this._setPaneViews([new e(this,this.model())])}));const o=this.properties();this._adjustScaleRatio(o),o.subscribe(this,this._adjustScaleRatio),o.childs().scaleRatio.subscribe(this,this._correctFirstPoint),this._syncStateExclusions=["scaleRatio"],o.onRestoreFactoryDefaults().subscribe(this,this._handleRestoringFactoryDefaults),this._onTemplateApplying.subscribe(this,this._handleTemplateApplying),this._onTemplateApplied.subscribe(this,this._correctFirstPoint)}migrateVersion(e,t,i){1===e&&(this._points.length>=this.pointsCount()?setTimeout((()=>this._migratePoint())):this._timePoint.length>=this.pointsCount()&&this._pointAdded.subscribe(this,this._migratePoint))}destroy(){ const e=this.properties();e.unsubscribe(this,this._adjustScaleRatio),e.childs().scaleRatio.unsubscribe(this,this._correctFirstPoint),e.onRestoreFactoryDefaults().unsubscribe(this,this._handleRestoringFactoryDefaults),this._onTemplateApplying.unsubscribe(this,this._handleTemplateApplying),this._onTemplateApplied.unsubscribe(this,this._correctFirstPoint),super.destroy()}pointsCount(){return 2}name(){return"Gann Square"}addPoint(e,t,i){this._points.length>1&&this._points.pop();const s=super.addPoint(e,t,i),n=this.priceScale();return!(0,r.ensureNotNull)(n).isLog()&&s&&this._correctFirstPoint(),s}setPoint(e,t,i){super.setPoint(e,t,i),void 0!==i&&i.shift()?this._correctPoint(e):this._correctScaleRatio()}setLastPoint(e,t){const i=this.priceScale();return(0,r.ensureNotNull)(i).isLog()||(this._points[1]=e,this._correctPoint(1)),super.setLastPoint(e,t)}isReversed(){return this.properties().childs().reverse.value()}levelsCount(){return this.properties().childs().levels.childCount()}levels(){const e=[],t=this.properties().childs(),i=t.levels.childCount();for(let s=0;se.GannComplexAndFixedDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addExcludedKey("scaleRatio",1);const t=[],i=[],s=e.childs();{const e=s.levels.childCount();for(let r=0;r0,o=s.index-r.index>0;let l=n&&!o||!n&&o?-1:1;0===e&&(l=-l),s.price=r.price+l*t*i,this._pointChanged.fire(e)}this._normalizePoints()}_correctFirstPoint(){this._correctPoint(this.isReversed()?0:1)}_handleRestoringFactoryDefaults(){this.properties().childs().scaleRatio.setValue(this._getAdjustedScaleRatio())}_handleTemplateApplying(e){""===e.scaleRatio&&(e.scaleRatio=this._getAdjustedScaleRatio())}_migratePoint(){if(this.points().length0){s=s.normalized();let e=Math.acos(s.x);return s.y>0&&(e=-e),e}return null}}},643442:(e,t,i)=>{var s=i(809796).TranslatedString,r=i(440941).lineToolsDoNotAffectChartInvalidation,n=i(821979).LineDataSource,o=i(517336).LevelsProperty,l=i(31712),a=l.LineToolWidthsProperty,c=l.LineToolColorsProperty,u=new s("erase level line",i.tf(null,void 0,i(812962)));class h extends n{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r), Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,33877)).then((({GannFanPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return h.LevelsCount}pointsCount(){return 2}name(){return"Gann Fan"}processErase(e,t){var i="level"+t,s=this.properties()[i].visible;e.setProperty(s,!1,u,r)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,903951))).GannFanDefinitionsViewModel}static createProperties(e){var t=new o({defaultName:"linetoolgannfan",state:e,map:{range:[1,9]}});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e);for(var t=[],i=[],s=1;s<=this.LevelsCount;s++)t.push(e.child("level"+s).child("linewidth")),i.push(e.child("level"+s).child("color"));e.addChild("linesColors",new c(i)),e.addChild("linesWidths",new a(t))}}h.LevelsCount=9,t.LineToolGannFan=h},839386:(e,t,i)=>{i.d(t,{LineToolGannFixed:()=>a});var s=i(86441),r=i(650151),n=i(821979),o=i(31712),l=i(406182);class a extends n.LineDataSource{constructor(e,t,s,r){super(e,t||a.createProperties(),s,r),this._constructor="LineToolGannFixed",Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,14986)).then((({GannFixedPaneView:e})=>{this._setPaneViews([new e(this,this.model())])})),this.properties().childs().reverse.subscribe(this,this._reversePoints)}pointsCount(){return 2}name(){return"Gann Square Fixed"}axisPoints(){const e=this.points(),t=this.getScreenPoints();return e.length<2||t.length<2?[]:[e[0],(0,r.ensureNotNull)(this.screenPointToPoint(t[1]))]}getScreenPoints(){const e=this.points();if(e.length<2)return[];const t=this._calcAngle();if(null===t)return[];const[i,n]=e,o=(0,r.ensureNotNull)(this.pointToScreenPoint(i)),l=(0,r.ensureNotNull)(this.pointToScreenPoint(n)),a=Math.sqrt(Math.pow(o.x-l.x,2)+Math.pow(o.y-l.y,2)),c=new s.Point(Math.cos(t),-Math.sin(t)),u=c.normalized(),h=u.x<0?-1:1,d=u.y<0?-1:1;return[o.addScaled(c,a),o.add(new s.Point(5*a*h,5*a*d))]}levelsCount(){return this.properties().childs().levels.childCount()}levels(){const e=[],t=this.properties().childs(),i=t.levels.childCount();for(let s=0;se.GannComplexAndFixedDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e);const t=[],i=[],s=e.childs();{const e=s.levels.childCount();for(let r=0;r0&&(o=-o),o}_reversePoints(){const[e,t]=this._points;this._points[0]=t,this._points[1]=e,this._normalizePoints(),this.restart()}}},168853:(e,t,i)=>{var s=i(821979).LineDataSource,r=i(517336).LevelsProperty,n=i(31712).LineToolColorsProperty,o=[4.5,9,11.25,18,22.5,36,45],l=function(){for(var e=[],t=o.length-1,i=1,s=0,r=0;r<1e10;)r=o[s]*i,e.push(Math.round(r)),e.push(Math.ceil(-r)),s===t-1&&(i*=10),s=(s+1)%t;return e.sort((function(e,t){return et?1:0})),e}();class a extends s{constructor(e,t,s,r){super(e,t||a.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.t.bind(i,257794,19)).then((({GannSquarePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}hLevelsCount(){return a.HLevelsCount}vLevelsCount(){return a.VLevelsCount}pointsCount(){return 2}name(){return"Gann Box"}_alignPriceOnPattern(e,t){var i=Math.round(1e6*(e.price-t.price))/1e6;if(0===i)return t.price;for(var s=o[0],r=o[o.length-1],n=1,l=Math.abs(i);l=0&&!(o[c]*n=0?a:-a),e}_alignTimeOnPattern(e,t){var i=e.index-t.index;if(0===i)return 0;for(var s=l.length-2;s>=0&&!(l[s]0?1:0,e.index=t.index+l[s],e}_alignPointsFixedIncrement(e,t){return this._alignTimeOnPattern(e,t),this._alignPriceOnPattern(e,t),e}_preparePoint(e,t){return t&&t.shift()&&0!==this._points.length&&this._alignPointsFixedIncrement(e,this._points[0]),super._preparePoint(e,t)}getPoint(e){if(e<2)return super.getPoint(e);var t=null;switch(e){case 2:case 3:var i=this.points();if(i.length===this.pointsCount()){var s=i[0].index,r=i[1].price;3===e&&(s=i[1].index,r=i[0].price),t={ index:s,price:r}}}return t}setPoint(e,t,i){if(i&&i.shift()){var s=e%2==0?this._points[1]:this._points[0];this._alignPointsFixedIncrement(t,s)}switch(e){case 2:this._points[0].index=t.index,this._points[1].price=t.price;break;case 3:this._points[1].index=t.index,this._points[0].price=t.price;break;default:super.setPoint(e,t,i)}}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,114388))).GannSquareDefinitionsViewModel}static createProperties(e){var t=new r({defaultName:"linetoolgannsquare",state:e,map:{range:[1,7],prefixes:["h","v"],names:["coeff","color","visible"]}});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e);for(var t=[e.child("color"),e.child("fans").child("color")],i=1;i<=this.HLevelsCount;i++)t.push(e.child("hlevel"+i).child("color"));for(i=1;i<=this.VLevelsCount;i++)t.push(e.child("vlevel"+i).child("color"));e.addChild("linesColors",new n(t)),e.addExcludedKey("linesColors",3)}}a.HLevelsCount=7,a.VLevelsCount=7,t.LineToolGannSquare=a},711755:(e,t,i)=>{i.d(t,{LineToolGhostFeed:()=>c});var s=i(853965),r=i(821979),n=i(650151),o=i(389137);class l{constructor(e,t,i){this._source=e,this._segmentIndex=t,this._bars=null!=i?i:[]}setBars(e){this._bars=e}clone(e){return new l(e,this._segmentIndex,(0,o.clone)(this._bars))}generate(){this._bars=[];const e=this._source.points(),t=e[this._segmentIndex],i=e[this._segmentIndex+1];if(!t||!i||t.index===i.index)return;const s=this._segmentIndex?t.index+1:t.index,r=Math.sign(i.index-t.index);for(let e=s;e!==i.index;e+=r)this._bars.push(this._createBar())}bars(){return this._bars}setSize(e){if(e{this._setPaneViews([new t.GhostFeedPaneView(this,e)])}))}isSynchronizable(){return!1}destroy(){ this.properties().onRestoreFactoryDefaults().unsubscribe(this,this._handleRestoringFactoryDefaults),super.destroy()}propertiesChanged(){super.propertiesChanged(),this._currentAverageHL===this.properties().childs().averageHL.value()&&this._currentVariance===this.properties().childs().variance.value()||this._regenerate()}pointsCount(){return-1}name(){return"Ghost Feed"}segmentBars(e){return this._segments[e].bars()}segments(){return this._segments}generateBars(e){this._segments.length<=e&&this._segments.push(new l(this,e)),this._segments[e].generate()}addPoint(e,t,i){if(this._finished)return!0;if(this._points.length>0){const i=this._points[this._points.length-1];if(!(null==t?void 0:t.isApiEvent())&&i.index===e.index){this._lastPoint=null,this._normalizePoints(),this.createServerPoints();for(let e=0;e1&&this.generateBars(this._points.length-2),s}finish(){this._finished=!0,this._lastPoint=null,this._normalizePoints(),this.createServerPoints()}setPoint(e,t,i,s){if(super.setPoint(e,t,i),e>0){const i=this.points()[e-1],s=t.index-i.index;this._segments[e-1].setSize(Math.abs(s))}if(e({bars:[...e.bars()]}))),t}restoreData(e){e.segments&&(this._segments=e.segments.map(((e,t)=>new l(this,t,e.bars)))),this._currentAverageHL=this.properties().childs().averageHL.value(),this._currentVariance=this.properties().childs().variance.value()}onData(e){super.onData(e);if(!this.pointsProperty().childs().points.child("0"))for(let e=0;ee.clone(this)))}startMoving(e,t,i,s){super.startMoving(e,t,i,s),this._preparePixelSegments()}move(e,t,i,s){super.move(e,t,i,s),this._restoreSegmentsFromPixels()}endMoving(e,t){return this._segmentsPixelsWhileMoving=null,super.endMoving(e,t)}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolghostfeed",state:e});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,743836))).GhostFeedDefinitionsViewModel}_handleRestoringFactoryDefaults(){const e=Math.round(this._calculateATR());this.properties().childs().averageHL.setValue(e)}_regenerate(){this._currentAverageHL=this.properties().childs().averageHL.value(),this._currentVariance=this.properties().childs().variance.value(),this._segments.forEach((e=>e.generate())),this.updateAllViews((0,a.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_calculateATR(){const e=this._model.mainSeries(),t=[];e.bars().each(((e,i)=>{const s=i[2],r=i[3] ;return null!=s&&null!=r&&t.push(s-r),!1}));let i=0===t.length?0:t.reduce(((e,t)=>e+t),0)/t.length;return i*=e.base(),i}_preparePixelSegments(){var e,t;const i=this.priceScale(),s=null!==(t=null===(e=this.ownerSource())||void 0===e?void 0:e.firstValue())&&void 0!==t?t:null;if(null===i||null===s||i.isEmpty()||!i.isLog())return;const r=this.points();this._segmentsPixelsWhileMoving=this._segments.map(((e,t)=>{const n=r[t].price,o=r[t+1].price,l=i.priceToCoordinate(n,s),a=(i.priceToCoordinate(o,s)-l)/(e.bars().length-1);return{bars:e.bars().map(((e,t)=>{const r=l+t*a,n=i.coordinateToPrice(r,s);return{open:i.priceToCoordinate(n+e.o,s)-r,high:i.priceToCoordinate(n+e.h,s)-r,low:i.priceToCoordinate(n+e.l,s)-r,close:i.priceToCoordinate(n+e.c,s)-r}}))}}))}_restoreSegmentsFromPixels(){var e,t;const i=this.priceScale(),s=null!==(t=null===(e=this.ownerSource())||void 0===e?void 0:e.firstValue())&&void 0!==t?t:null;if(null===i||null===s||null===this._segmentsPixelsWhileMoving)return;const r=this.points();this._segmentsPixelsWhileMoving.forEach(((e,t)=>{const n=this._segments[t],o=r[t].price,l=r[t+1].price,a=i.priceToCoordinate(o,s),c=(i.priceToCoordinate(l,s)-a)/(e.bars.length-1),u=n.bars().map(((t,r)=>{const n=e.bars[r],o=a+r*c,l=i.coordinateToPrice(o,s);return{...t,o:i.coordinateToPrice(n.open+o,s)-l,h:i.coordinateToPrice(n.high+o,s)-l,l:i.coordinateToPrice(n.low+o,s)-l,c:i.coordinateToPrice(n.close+o,s)-l}}));n.setBars(u)}))}}},336471:(e,t,i)=>{i.d(t,{LineToolHeadAndShoulders:()=>o});var s=i(853965),r=i(821979),n=i(31712);class o extends r.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,726360)).then((t=>{this._setPaneViews([new t.LineToolHeadAndShouldersPaneView(this,e)])}))}pointsCount(){return 7}name(){return"Head and Shoulders"}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolheadandshoulders",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,63124)).then((e=>e.PatternWithBackgroundDefinitionViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new n.LineToolColorsProperty([e.childs().textcolor]))}}},680330:(e,t,i)=>{i.d(t,{LineToolHighlighter:()=>n});var s=i(853965),r=i(168504);class n extends r.LineToolBrushBase{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s),this._loadPaneViews(e)}smooth(){return this.properties().childs().smooth.value()}name(){return"Highlighter"}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolhighlighter",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,48462)).then((e=>e.HighlighterDefinitionsViewModel))}_loadPaneViews(e){ Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,898471)).then((t=>{this._setPaneViews([new t.HighlighterPaneView(this,e)])}))}}},682912:(e,t,i)=>{i.d(t,{LineToolHorzLinePriceAxisView:()=>n});var s=i(229765),r=i(246733);class n extends s.PriceAxisView{constructor(e){super(),this._source=e}_updateRendererData(e,t,i){e.visible=!1;const s=this._source.points(),n=this._source.priceScale();if(0===s.length||null===n||n.isEmpty())return;const o=s[0];if(!isFinite(o.price))return;const l=this._source.ownerSource(),a=null!==l?l.firstValue():null;if(null===a)return;const c=(0,r.resetTransparency)(this._source.properties().linecolor.value());i.background=c,i.textColor=this.generateTextColor(c),i.coordinate=n.priceToCoordinate(o.price,a),e.text=n.formatPrice(o.price,a),e.visible=!0}}},994761:(e,t,i)=>{i.d(t,{LineToolHorzLine:()=>l});var s=i(354950),r=i(853965),n=i(126222),o=i(682912);class l extends n.InplaceTextLineDataSource{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),this._priceAxisView=new o.LineToolHorzLinePriceAxisView(this),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,254896)).then((({HorzLinePaneView:e})=>{this._setPaneViews([new e(this,this._model,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this))])}))}state(e){const t=super.state(e);return t.points&&0!==t.points.length&&(t.points[0].offset=0),t}pointsCount(){return 1}name(){return"Horizontal Line"}priceAxisViews(e,t){return this.isSourceHidden()||t!==this.priceScale()||!this._model.selection().isSelected(this)&&!this.properties().childs().showPrice.value()||e!==this._model.paneForSource(this)?null:[this._priceAxisView]}timeAxisViews(){return null}timeAxisPoints(){return[]}updateAllViews(e){super.updateAllViews(e),this._priceAxisView.update(e)}canHasAlert(){return!0}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}denormalizeTimePoints(){this._points=[],this._timePoint.length>0&&this._points.push({price:this._timePoint[0].price,index:0})}clearData(){const e=this._points;super.clearData(),this._points=e}editableTextProperties(){const e=this.properties().childs();return{text:e.text,textColor:e.textcolor,textVisible:e.showLabel}}removeIfEditableTextIsEmpty(){return!1}activateEditingOnCreation(){return!1}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolhorzline",state:e});return this._configureProperties(t),t}_getAlertPlots(){return[this.points()[0].price]}_pointsForPointset(){return[]}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,51646)).then((e=>e.HorizontalLineDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new s.Property("")),e.addExcludedKey("text",1)}}},867716:(e,t,i)=>{i.d(t,{ LineToolHorzRay:()=>l});var s=i(853965),r=i(354950),n=i(682912),o=i(821979);class l extends o.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:l.createProperties(),s,r),this._priceAxisView=new n.LineToolHorzLinePriceAxisView(this),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,658622)).then((({HorzRayPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 1}name(){return"Horizontal Ray"}priceAxisViews(e,t){return this.isSourceHidden()||t!==this.priceScale()||!this._model.selection().isSelected(this)&&!this.properties().childs().showPrice.value()||e!==this._model.paneForSource(this)?null:[this._priceAxisView]}updateAllViews(e){super.updateAllViews(e),this._priceAxisView.update(e)}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}canHasAlert(){return!0}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolhorzray",state:e});return this._configureProperties(t),t}_getAlertPlots(){const e=this._points[0],t={index:e.index+1,price:e.price},i=this._linePointsToAlertPlot([e,t],null,!1,!0);return null!==i?[i]:[]}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,852440))).HorizontalRayDefinitionsViewModel}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new r.Property("")),e.addExcludedKey("text",1)}}},618117:(e,t,i)=>{i.d(t,{LineToolIcon:()=>x});var s=i(885482),r=i(500477),n=i(760184),o=i(201089),l=i(822914),a=i(852290),c=i(195294),u=i(33249),h=i(808068),d=i(853965),p=i(923237),_=i(31712);const f=(0,c.getHexColorByName)("color-tv-blue-500"),m={intervalsVisibilities:{...h.intervalsVisibilitiesDefaults},color:f,size:40},v={icon:61720,angle:.5*Math.PI},g=(0,d.extractAllPropertiesKeys)(m),P=(0,d.extractAllPropertiesKeys)(v),y=[...g,...P,...p.commonLineToolPropertiesStateKeys];class S extends u.LineDataSourceProperty{constructor(e){super(e),this.addChild("backgroundsColors",new _.LineToolColorsProperty([this.childs().color]))}static create(e,t){return new this({defaultName:"linetoolicon",factoryDefaultsSupplier:()=>(0,l.default)(m),nonThemedDefaultsKeys:g,themedDefaultsKeys:[],state:(0,a.default)({},v,{icon:t},null!=e?e:{}),allStateKeys:y})}}const b=(0,o.getLogger)("Chart.LineToolIcon");class x extends n.LineToolSvgIconBase{constructor(e,t,i,s){super(e,t||x.createProperties(),i,s),this.version=1,this._loadViews()}name(){return"Icon"}template(){return this._properties.template()}static createProperties(e){const t=S.create(e,s.iconTool.value());return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,681791)).then((e=>e.IconsDefinitionsViewModel))}async _loadViews(){ const[{getSvgContentForCharCode:e,getSvgRenderer:t},{IconPaneView:s}]=await Promise.all([i.e(27987).then(i.bind(i,728996)),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,23728))]);if(!this._isDestroyed){const i=this._properties.childs().icon.value();this._svgContent=e(i),this._onIconChanged.fire();const n=t(r.svgRenderer,i);null===n&&b.logWarn(`Couldn't create svg renderer for icon ${i}`),this._setPaneViews([new s(this,this._model,n)])}}}},953639:(e,t,i)=>{i.d(t,{createIdeaLineToolByUrl:()=>p,isIdeaAuthorProfileImageUrl:()=>h,isIdeaUrl:()=>u});var s=i(650151),r=i(62802),n=i(66974),o=i(541558),l=i(461794),a=i(900569);const c=/^\/chart\/.+?\/([0-9a-zA-Z]{8})(-[-\w]+)?\/?$/;function u(e){try{const t=new URL(e);return((e=>"https:"===e.protocol&&e.hostname.endsWith(".tradingview.com"))(t)||(e=>!(0,n.isProd)()&&e.hostname.endsWith(window.location.hostname))(t))&&c.test(t.pathname)}catch(e){return!1}}function h(e){if(e.startsWith("data:image/svg+xml,"))return!0;try{const t=new URL(e),i=new URL(window.AWS_S3_CDN);return t.protocol===i.protocol&&t.hostname===i.hostname&&t.pathname.includes("/userpics/")}catch(e){return!1}}async function d(e){const t=new URL(`/api/v1/ideas/${i=e,(0,s.ensureNotNull)(c.exec(new URL(i).pathname))[1]}/`,location.href);var i;return fetch(t.toString()).then((e=>{if(!e.ok)throw new Error(`Error processing idea: ${e.statusText}`);return e.json()}))}function p(e,t,i=!1){return d(e).then((e=>{const n=function(e,t){var i;const r=(0,s.ensureDefined)(e.user);let n;r.avatars&&h(r.avatars.small)&&(n=r.avatars.small.startsWith("data:image/svg+xml,")?r.avatars.small:`${r.avatars.small.replace(window.AWS_S3_CDN,"")}?resetCache=true`);const o={avatarUrl:n,badges:null===(i=r.badges)||void 0===i?void 0:i.map((e=>e.name)),username:r.username};return{createdAt:e.created_timestamp,direction:e.direction,name:(0,l.clean)(e.name,!0),author:o,uuid:e.uuid}}(e),c={price:0,time_t:n.createdAt,offset:0},u=t.mainSeries(),d=(0,s.ensureNotNull)(t.model().paneForSource(u)),p=d.newLineToolZOrder(!0),_={type:"drawing",source:{id:(0,o.randomHashN)(6),zorder:p,type:"LineToolIdea",position:50,state:{interval:"1",...a.LineToolIdea.createProperties().state()},ideaData:n,symbol:u.symbol(),ownerSource:u.id(),points:[c]},geometry:[],modelId:t.model().id()},f=t.pasteLineTool(d,_,!0,!0);return i&&r.setValue("hint.pasteIdea",!0,{forceFlush:!0}),f.pointAdded().subscribe(null,(()=>t.scrollToLineTool(f)),!0),f}))}},900569:(e,t,i)=>{i.d(t,{LineToolIdea:()=>C});var s=i(853965),r=i(821979),n=i(444372),o=i(62802),l=i(345848),a=i(201089),c=i(167222),u=i(846778),h=i(270294),d=i(885482),p=i(543373),_=i(953639);const f=(0,a.getLogger)("Chart.IdeaDialog"),m=n.t(null,void 0,i(241246)),v=n.t(null,void 0,i(467466));let g=null;function P(e){"LineToolIdea"===e?(window.is_authenticated||(0,d.resetToCursor)(!0),(0,c.runOrSigninWithFeature)((()=>{d.tool.setValue("LineToolIdea"),g=(0,p.showCustomUrlEventDialog)({onConfirm:y,onClose:()=>{g=null,"LineToolIdea"===d.tool.value()&&(0,d.resetToCursor)(!0)},title:m, placeholderText:v}),(0,l.trackEvent)("Idea","Open idea dialog")}),{feature:"drawings",source:"Change drawing tool state"})):null!==g&&g.then((e=>e()))}function y(e){const t=(0,h.chartWidgetCollectionService)();if(null===t)return;if(!(0,_.isIdeaUrl)(e))return void f.logWarn(`Invalid idea url: ${e}`);const i=!Boolean(o.getBool("hint.pasteIdea")),s=t.activeChartWidget.value();(0,_.createIdeaLineToolByUrl)(e,s.model()).then((()=>{i&&(0,u.showPasteLineToolHint)(t.getContainer(),"hint.pasteIdea")}))}var S=i(354950),b=i(70726);class x extends b.CustomEventItem{constructor(e,t){super(t),this._data=e}ideaData(){return this._data}index(){return this._source.eventTimePointIndex()}time(){return this._data.createdAt}avatar(){var e;return null===(e=this._data.author)||void 0===e?void 0:e.avatarUrl}}class C extends b.LineToolCustomUrlEvent{constructor(e,t,s,r){super(e,t||C.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,320593)).then((t=>{this._setPaneViews([new t.IdeaPaneView(this,e)])}))}name(){return"Idea"}state(e){const t=super.state(e);return this._item&&(t.ideaData=this._item.ideaData()),e&&(t.eventTimePointIndex=this._eventTimePointIndex),t}restoreData(e){e.ideaData&&(this._item=new x(e.ideaData,this)),void 0!==e.eventTimePointIndex&&(this._eventTimePointIndex=e.eventTimePointIndex)}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolIdea",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,325232)).then((e=>e.IdeaDefinitionsViewModel))}static _configureProperties(e){r.LineDataSource._configureProperties(e),e.hasChild("position")||e.addChild("position",new S.Property(50)),e.addExcludedKey("position",1)}}(0,d.runOnDrawingStateReady)((()=>{d.tool.subscribe(P)}))},923237:(e,t,i)=>{i.d(t,{commonLineToolPropertiesStateKeys:()=>s});const s=["symbolStateVersion","zOrderVersion","frozen","title","symbolInfo","interval","symbol","currencyId","unitId","visible","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"]},17329:(e,t,i)=>{i.d(t,{LineToolImage:()=>C,buildAbsoluteUserImageUrl:()=>x});var s=i(650151),r=i(86441),n=i(201089),o=i(853965),l=i(354950),a=i(821979),c=i(964824),u=i(62802),h=i(345848),d=i(167222),p=i(846778),_=i(270294),f=i(885482);async function m(e,t){return async function(e){ return(await Promise.all([i.e(32662),i.e(5987),i.e(98996),i.e(43387),i.e(66458),i.e(4343),i.e(70621),i.e(62033),i.e(13633),i.e(69749),i.e(66233),i.e(21975),i.e(30408),i.e(97405),i.e(90385),i.e(28019),i.e(62526),i.e(77038)]).then(i.bind(i,595470))).renderImageDialog(e)}({onConfirm:e,onClose:t})}let v=null;function g(e){if("LineToolImage"!==e)return null==v||v.then((e=>e())),void(v=null);window.is_authenticated||(0,f.resetToCursor)(!0),(0,d.runOrSigninWithFeature)((()=>{f.tool.setValue("LineToolImage"),v=m(P,(()=>{null==v||v.then((e=>e())),v=null,"LineToolImage"===f.tool.value()&&(0,f.resetToCursor)(!0)})),(0,h.trackEvent)("Image","Open image dialog")}),{feature:"drawings",source:"Change drawing tool state"})}function P(e){const t=(0,_.chartWidgetCollectionService)();if(null===t)return;const i=!Boolean(u.getBool("hint.pasteImage")),r=t.activeChartWidget.value();r.model().pasteImageAsLineTool(e.url,e.blobUrl,(0,s.ensureNotNull)(r.model().model().paneForSource(r.model().mainSeries())),e.transparency),i&&(0,p.showPasteLineToolHint)(t.getContainer(),"hint.pasteImage")}const y=(0,n.getLogger)("Chart.LineToolImage");function S(e){return e.toLowerCase().startsWith("blob:")}const b=window.AWS_BBS3_DOMAIN;function x(e){if(S(e))return e;const t=new URL(e,b),i=new URL(t.pathname,b);if("/"===i.pathname)return null;const s=i.toString();return t.toString()!==s?null:s}class C extends a.LineDataSource{constructor(e,t,s,r){var n;super(e,t||C.createProperties(),s,r),this._image=null,this._originPoint=4;const o=this.properties().childs().url;this._absoluteUserImageUrl=new l.Property(null!==(n=x(this.properties().childs().url.value()))&&void 0!==n?n:""),this._absoluteUserImageUrl.subscribe(this,(e=>{const t=e.value();if(S(t))return;const i=x(t);null!==i&&o.setValue(new URL(i).pathname)})),o.subscribe(this,(()=>{const e=x(o.value());null!==e&&this._absoluteUserImageUrl.setValue(e)})),this._loadImage(),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,102380)).then((({ImagePaneView:t})=>{this._setPaneViews([new t(this,e)])})),this.properties().childs().url.subscribe(this,(()=>{this._loadImage()}))}absoluteUserImageUrl(){return this._absoluteUserImageUrl}cssWidth(){return this.properties().childs().cssWidth.value()}cssHeight(){return this.properties().childs().cssHeight.value()}angle(){return this.properties().childs().angle.value()}originPoint(){return this._originPoint}dOffsetX(){return this._dOffsetX||0}pointsCount(){return 1}name(){return"Image"}image(){return this._image}setBlobImageUrl(e){this._image||(this._createImage(e),this._blobUrl=e)}getChangePointForSync(e){return null}hasEditableCoordinates(){return!1}pointToScreenPoint({index:e,price:t},i=0){const n=this._model.timeScale(),o=(0,s.ensureNotNull)(this.priceScale()),l=(0,s.ensureNotNull)((0,s.ensureNotNull)(this.ownerSource()).firstValue()),a=n.indexToCoordinate(e)+i,c=o.priceToCoordinate(t,l);return new r.Point(a,c)}setPoint(e,t,i){if(null===this._image)return;const{width:r,height:n}=this._image,o=(0, s.ensureNotNull)(this.pointToScreenPoint(t)),l=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0],this.dOffsetX())),a=Math.max(Math.abs(l.x-o.x)/r,Math.abs(l.y-o.y)/n),c=Math.round(r*a),u=Math.round(n*a),h=this.properties().childs();h.cssWidth.setValue(c),h.cssHeight.setValue(u),this.propertiesChanged()}startChanging(e,t){super.startChanging(e,t),this._changeOriginPoint(C._oppositePoints[e])}endChanging(e,t){return this._changeOriginPoint(4),super.endChanging(e,t)}getPoint(){return null}syncLineStyleState(){const e=super.syncLineStyleState();return!e.url&&this._blobUrl&&(e.blobUrl=this._blobUrl),e}restoreExternalState(e){const{blobUrl:t,...i}=e;t&&this.setBlobImageUrl(t),super.restoreExternalState(i)}isSavedInChart(){return super.isSavedInChart()&&""!==this.absoluteUserImageUrl().value()}static createProperties(e){const t=new o.DefaultProperty({defaultName:"linetoolimage",state:e});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,69487))).ImageDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.hasChild("url")||e.addChild("url",new l.Property("")),e.addExcludedKey("url",1),e.addExcludedKey("cssWidth",1),e.addExcludedKey("cssHeight",1),e.addExcludedKey("angle",1)}_loadImage(){const e=this.properties(),t=(0,s.ensureDefined)(e.child("url")).value();t&&this._createImage(t)}_changeOriginPoint(e){const t=this.originPoint(),i=4===t?C._correctOriginDirections[e]:C._correctOriginDirections[C._oppositePoints[t]],n=this.properties().childs().cssWidth.value()/2,o=this.properties().childs().cssHeight.value()/2,[l]=this._points,a=(0,s.ensureNotNull)(this.pointToScreenPoint(l)),c=new r.Point(a.x+n*i[0],a.y+o*i[1]),u=(0,s.ensureNotNull)(this.screenPointToPoint(c));this._dOffsetX=4===t?c.x-(0,s.ensureNotNull)(this.pointToScreenPoint(u)).x:void 0,l.index=u.index,l.price=u.price,this._originPoint=e}_createImage(e){var t;const i=S(e),r=x(e);if(null===r)return void y.logWarn(`Invalid image URL: ${e}`);if(r===(null===(t=this._image)||void 0===t?void 0:t.src))return;const n=document.createElement("img");n.crossOrigin="anonymous",n.src=r,n.addEventListener("load",(()=>{this._image=n;const e=this._model,t=this.properties().childs();if(!i){const e=new URL(r).pathname;t.url.setValue(e),this._blobUrl=void 0}if(t.cssWidth.value()&&t.cssHeight.value())return void this._model.updateSource(this);const o=e.timeScale().width()/4,l=(0,s.ensureNotNull)(this.priceScale()).height()/4,a=n.naturalWidth,u=n.naturalHeight,h=Math.min(1,o/a),d=Math.min(1,l/u),p=Math.min(h,d),_=Math.round(p*a),f=Math.round(p*u);t.cssWidth.setValue(_),t.cssHeight.setValue(f),this.updateAllViews((0,c.sourceChangeEvent)(this.id())),this._model.updateSource(this)})),n.addEventListener("error",(()=>{this.model().removeSource(this)}))}}C._correctOriginDirections=[[-1,-1],[1,-1],[-1,1],[1,1],[0,0]],C._oppositePoints=[3,2,1,0,4],(0,f.runOnDrawingStateReady)((()=>{f.tool.subscribe(g)}))},933513:(e,t,i)=>{i.d(t,{ LineToolInfoLine:()=>r});var s=i(956268);class r extends s.LineToolTrendLine{constructor(e,t,i,s){super(e,t||r.createProperties(),i,s)}pointsCount(){return 2}name(){return"Info Line"}static createProperties(e){const t=s.LineToolTrendLine._createPropertiesImpl("linetoolinfoline",e);return r._configureProperties(t),t}}},126222:(e,t,i)=>{i.d(t,{InplaceTextLineDataSource:()=>m,InplaceTextUndoCommand:()=>f});var s=i(316230),r=i(650151),n=i(86441),o=i(195294),l=i(444372),a=i(809796),c=i(401580),u=i(142257),h=i(821979),d=i(964824);const p={selectionColor:(0,o.getHexColorByName)("color-tv-blue-500"),cursorColor:(0,o.getHexColorByName)("color-black")},_={selectionColor:(0,o.getHexColorByName)("color-white"),cursorColor:(0,o.getHexColorByName)("color-white")};class f extends u.UndoCommand{constructor(e,t,s,r){var n;super(new a.TranslatedString("change {title} text",l.t(null,void 0,i(968005))).format({title:new a.TranslatedString(t.name(),t.translatedType())})),this._sourceId=t.id(),this._model=e,this._oldValue=s,this._newValue=r,this._changeVisibility=!1===(null===(n=t.editableTextProperties().textVisible)||void 0===n?void 0:n.value())}redo(){var e;const t=this._source();this._textProperty(t).setValue(this._newValue),this._changeVisibility&&(null===(e=this._textVisibilityProperty(t))||void 0===e||e.setValue(!0))}undo(){var e;const t=this._source();this._textProperty(t).setValue(this._oldValue),this._changeVisibility&&(null===(e=this._textVisibilityProperty(t))||void 0===e||e.setValue(!1))}_textProperty(e){return e.editableTextProperties().text}_textVisibilityProperty(e){return e.editableTextProperties().textVisible}_source(){return(0,r.ensureNotNull)(this._model.dataSourceForId(this._sourceId))}}class m extends h.LineDataSource{constructor(e,t,s,r){super(e,t,s,r),this._container=null,this._editableText=new c.WatchedValue(""),this._activateTextEditingEl=null,this._paneView=null,this._selectionData={},this._editingOnCreation=!1,this._editableText.subscribe((()=>{this.updateAllViewsAndRedraw((0,d.sourceChangeEvent)(this.id()))})),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,721683)).then((t=>{this._cursorPaneView=new t.InplaceTextCursorPaneView(this,e),this._additionalCursorDataGetters&&this._cursorPaneView.setAdditionalCursorData(...this._additionalCursorDataGetters)}))}destroy(){this._editableText.unsubscribe(),this._closeTextEditor(),super.destroy()}editableTextStyle(){return{...this._model.dark().value()?_:p}}removeIfEditableTextIsEmpty(){return!0}activateEditingOnCreation(){return!0}topPaneViews(e){return e.hasDataSource(this)&&!window.TradingView.printing&&this._cursorPaneView?(this._cursorPaneView.update((0,d.sourceChangeEvent)(this.id())),[this._cursorPaneView]):null}editableText(){return this._editableText}textEditingEl(){return this._activateTextEditingEl}activateTextEditingOn(e,t){this._activateTextEditingEl=e,this._editingOnCreation=!!t,this.updateAllViewsAndRedraw((0,d.sourceChangeEvent)(this.id()))}onSelectionChange(e){const t={} ;void 0!==e&&(e.start===e.end?t.cursorPosition=e.start:t.selectionRange=[Math.min(e.start,e.end),Math.max(e.start,e.end)]),(0,s.default)(t,this._selectionData)||(this._selectionData=t,this._paneViews.forEach((e=>{e.forEach((e=>{"setSelectionRange"in e&&e.setSelectionRange(t.selectionRange)}))})),this._cursorPaneView.setCursorPosition(t.cursorPosition),this.updateAllViewsAndRedraw((0,d.sourceChangeEvent)(this.id())))}setAdditionalCursorData(e,t){this._cursorPaneView?this._cursorPaneView.setAdditionalCursorData(e,t):this._additionalCursorDataGetters=[e,t]}async _openTextEditor(e,t,s,o,l){if(null!==this._container)return;this._activateTextEditingEl=null;const a=this.isFixed()?(0,r.ensureDefined)(this.fixedPoint()):(0,r.ensureNotNull)(this.pointToScreenPoint(this._points[0])),c=new n.Point(a.x,a.y);this._container=document.createElement("div"),this._container.style.position="absolute",this._container.style.top="0",this._container.style.bottom="0",this._container.style.left="0",this._container.style.right="0",this._container.style.overflow="hidden",this._container.style.pointerEvents="none",e.appendChild(this._container);const{updateChartEditorText:u,closeChartEditorText:h}=await Promise.all([i.e(66661),i.e(90385),i.e(15592)]).then(i.bind(i,353028));if(null===this._container||this._isDestroyed)return;this._closeChartEditorText=h;const p=this.editableTextProperties(),_=this.editableTextStyle();this._editableText.setValue(p.text.value());const f={position:c,textInfo:t,placeholder:s,text:this._editableText,textColor:p.textColor,wordWrap:p.wordWrap,forbidLineBreaks:_.forbidLineBreaks,maxLength:_.maxLength,onClose:o,onSelectionChange:l};u(this._container,f),this.updateAllViewsAndRedraw((0,d.sourceChangeEvent)(this.id()))}_closeTextEditor(){var e;if(null===this._container||this._isDestroyed)return;const t=this.editableTextProperties().text.value(),i=this._editableText.value();t!==i&&(this._editingOnCreation?this.editableTextProperties().text.setValue(i):this._model.undoModel().undoHistory().pushUndoCommand(this._changeEditableTextUndoCommand(t,i))),this._editingOnCreation=!1,this.onSelectionChange(),null===(e=this._closeChartEditorText)||void 0===e||e.call(this,this._container),this._closeChartEditorText=void 0,this._container.remove(),this._container=null,this.updateAllViewsAndRedraw((0,d.sourceChangeEvent)(this.id()))}_changeEditableTextUndoCommand(e,t){return new f(this._model,this,e,t)}}},478760:(e,t,i)=>{var s=i(517336).LevelsProperty,r=i(9093).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Inside Pitchfork"}static createProperties(e){var t=new s({defaultName:"linetoolinsidepitchfork",state:e,map:{range:[0,8]}});return this._configureProperties(t),t}}t.LineToolInsidePitchfork=n},616117:(e,t,i)=>{var s;i.d(t,{isImageToolName:()=>d,isLineDrawnWithPressedButton:()=>c,isLineToolDrawWithoutPoints:()=>h,isLineToolFinishRequiredWhenCreatedByApi:()=>u,isLineToolName:()=>a,isMtpPredictorToolName:()=>o,isStudyLineToolName:()=>l,isTextToolName:()=>p});var r=i(968361) ;const n=new Set(["LineStudyMtpAnalysis","LineStudyMtpDecisionPoint","LineStudyMtpRiskReward","LineStudyMtpElliotWaveMain","LineStudyMtpElliotWaveMajor","LineStudyMtpElliotWaveMinor","LineStudyMtpDownWave1OrA","LineStudyMtpDownWave2OrB","LineStudyMtpDownWave3","LineStudyMtpDownWave4","LineStudyMtpDownWave5","LineStudyMtpDownWaveC","LineStudyMtpUpWave1OrA","LineStudyMtpUpWave2OrB","LineStudyMtpUpWave3","LineStudyMtpUpWave4","LineStudyMtpUpWave5","LineStudyMtpUpWaveC"]);function o(e){return n.has(e)}function l(e){return"LineToolRegressionTrend"===e||"LineToolVbPFixed"===e||"LineToolFixedRangeVolumeProfile"===e||"LineToolAnchoredVolumeProfile"===e||"LineToolAnchoredVWAP"===e}function a(e){return e in(s||(s=i.t(r,2)))||l(e)}function c(e){return"LineToolBrush"===e||"LineToolHighlighter"===e}function u(e){return c(e)||"LineToolPath"===e||"LineToolPolyline"===e||"LineToolGhostFeed"===e}function h(e){return"LineToolTweet"===e||"LineToolIdea"===e||"LineToolImage"===e}function d(e){return"LineToolImage"===e}function p(e){switch(e){case"LineToolBalloon":case"LineToolComment":case"LineToolText":case"LineToolTextAbsolute":case"LineToolCallout":case"LineToolNote":case"LineToolNoteAbsolute":case"LineToolSignpost":return!0}return!1}},68626:(e,t,i)=>{i.d(t,{LineDataSourcePointIndexProperty:()=>r});var s=i(354950);class r extends s.Property{constructor(e,t){super(),this._waitingPointsetUpdate=!1,this._lineSource=e,this._pointIndex=t,this._cachedIndex=this.value()}value(){const e=this._lineSource.points();return 0===e.length?this._cachedIndex:e[this._pointIndex].index}setValue(e){this._cachedIndex=e;const t=this._lineSource.points(),i=e=>{const t=this._lineSource.points()[this._pointIndex];if(t.index===e)return;t.index=e,this._lineSource.startChanging(this._pointIndex,t),this._setPointImpl(t),this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this,"");const i=this._lineSource.endChanging(!0,!1);this._lineSource.syncMultichartState(i)};if(0===t.length){const e=()=>{i(this._cachedIndex),this._waitingPointsetUpdate=!1};if(this._waitingPointsetUpdate)return;this._lineSource.pointsetUpdated().subscribe(this,e,!0),this._waitingPointsetUpdate=!0}else i(e)}_setPointImpl(e){this._lineSource.setPoint(this._pointIndex,e)}}},517067:(e,t,i)=>{i.d(t,{LineDataSourcePointPriceProperty:()=>n});var s=i(650151),r=i(354950);class n extends r.Property{constructor(e,t){super(),this._lineSource=e,this._pointIndex=t,e.pointAdded().subscribe(this,(e=>{this._pointIndex===e&&this._listeners.fire(this,`${e}`)})),e.pointChanged().subscribe(this,(e=>{this._pointIndex===e&&this._listeners.fire(this,`${e}`)}))}value(){const e=this._lineSource.points()[this._pointIndex].price,t=(0,s.ensureNotNull)(this._lineSource.ownerSource()).formatter();if(t.parse){const i=t.format(e),s=t.parse(i);return s.res?s.value:e}return e}setValue(e){const t=this._lineSource.points()[this._pointIndex];t.price=parseFloat(""+e),this._lineSource.startChanging(this._pointIndex,t),this._lineSource.setPoint(this._pointIndex,t), this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this,"");const i=this._lineSource.endChanging(!0,!1);this._lineSource.syncMultichartState(i)}}},837202:(e,t,i)=>{i.d(t,{LineToolPriceAxisView:()=>o});var s=i(650151),r=i(229765),n=i(246733);class o extends r.PriceAxisView{constructor(e,t){super(),this._source=e,this._data=t,this._properties=e.model().properties().childs().scalesProperties}_updateRendererData(e,t,i){e.visible=!1;const s=this._source.model();if(!s.timeScale()||s.timeScale().isEmpty())return;const r=this._source.priceScale();if(null===r||r.isEmpty())return;if(!s.selection().isSelected(this._source)&&!this._source.isForcedDrawPriceAxisLabel())return;if(null===s.timeScale().visibleBarsStrictRange())return;const o=this._source.priceAxisPoints(),l=this._data.pointIndex;if(o.length<=l)return;const a=o[l];if(!isFinite(a.price))return;const c=this._source.ownerSource(),u=null!==c?c.firstValue():null;if(null===u)return;let h=this._data.backgroundPropertyGetter?this._data.backgroundPropertyGetter():null;null===h&&(h=this._getBgColor()),i.background=(0,n.resetTransparency)(h),i.borderColor="#2E84A6",i.textColor=this.generateTextColor(i.background),i.coordinate=r.priceToCoordinate(a.price,u),e.text=this._formatPrice(a.price,u),e.visible=!0}_getBgColor(){return this._active?this._properties.childs().axisLineToolLabelBackgroundColorActive.value():this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}_formatPrice(e,t){return(0,s.ensureNotNull)(this._source.priceScale()).formatPrice(e,t)}}},33249:(e,t,i)=>{i.d(t,{LineDataSourceProperty:()=>l});var s=i(822914),r=i(852290),n=i(650151),o=i(853965);class l extends o.DefaultProperty{constructor({templateKeys:e,...t}){super({ignoreAllowSavingDefaults:!0,saveNonDefaultUserPreferencesOnly:!0,...t}),this._templateKeys=(0,n.ensureDefined)(e||this._allDefaultsKeys)}template(){return(0,o.extractState)(this.state(),this._templateKeys,[])}applyTemplate(e){this.mergeAndFire((0,o.extractState)((0,r.default)((0,s.default)(this._factoryDefaultsSupplier()),e),this._templateKeys))}}},902214:(e,t,i)=>{i.d(t,{LineDataSourceTimeAxisView:()=>r});var s=i(161164);class r extends s.TimeAxisView{constructor(e,t){super(e.model()),this._active=!1,this._source=e,this._pointIndex=t,this._properties=e.model().properties().childs().scalesProperties}setActive(e){this._active=e}_getBgColor(){return this._active?this._properties.childs().axisLineToolLabelBackgroundColorActive.value():this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}_getIndex(){if(!this._model.selection().isSelected(this._source))return null;const e=this._source.timeAxisPoints();return e.length<=this._pointIndex?null:e[this._pointIndex].index}_isVisible(){return!0}}},613053:(e,t,i)=>{i.d(t,{LineToolTradingPriceAxisView:()=>r});var s=i(837202);class r extends s.LineToolPriceAxisView{_formatPrice(e,t){return this._source.formatter().format(e)}}},776954:(e,t,i)=>{i.d(t,{LineToolWithRelativePriceCoordinate:()=>f,getNoDataPosition:()=>p,getSeriesPosition:()=>_, positionToCoordinate:()=>u});var s=i(650151),r=i(534741),n=i(126222),o=i(885482);function l(e,t,i){const s=e.barFunction();switch(e.style()){case 3:case 10:case 2:case 14:case 15:return s(t.value);default:return t.value[-1===i?3:2]}}function a(e){return e>=0?1:-1}function c(e,t){return-1===a(e)!==t?-1:1}function u(e,t,i,s){const r=Math.min(t,Math.max(0,1===s?i:t-i));return i-s*Math.abs(r*e/100)}function h(e,t,i){const s=e.index();return null===s?null:{index:s,price:t.coordinateToPrice(t.height()/2,i)}}function d(e,t){const i=e.data().bars(),s=i.first(),n=i.last();if(null===s||null===n)return null;let o;const c=t.index();if(null===c){if(void 0===t.time)return null;const e=t.time(),l=s.value[0],a=n.value[0];if(ea)return null;o=i.searchByTime(e,r.PlotRowSearchMode.NearestRight,4)}else o=i.search(c);return null===o?null:{index:o.index,price:l(e,o,a(t.position()))}}function p(e,t,i,s){const r=h(e,t,s);if(null===r)return null;const n=c(e.position(),t.isInverted());return{index:r.index,price:r.price,poleStartY:t.height(),visualDirection:1,positionPointDirection:n,startsOnSeriesData:!1,priceCoordinate:t.priceToCoordinate(r.price,s),indexCoordinate:i.indexToCoordinate(r.index)}}function _(e,t,i=!0){const r=d(e,t),n=e.priceScale(),o=e.model().timeScale(),l=(0,s.ensureNotNull)(e.firstValue());if(null===r)return p(t,n,o,l);let a=0;const u=e.properties().childs(),h=n.priceToCoordinate(r.price,l),_=c(t.position(),n.isInverted());if(i)switch(e.style()){case 16:a=1===_?u.hlcAreaStyle.childs().highLineWidth.value()/2:u.hlcAreaStyle.childs().lowLineWidth.value()/2;break;case 3:a=u.areaStyle.childs().linewidth.value()/2;break;case 2:a=u.lineStyle.childs().linewidth.value()/2;break;case 14:a=u.lineWithMarkersStyle.childs().linewidth.value()/2;break;case 15:a=u.steplineStyle.childs().linewidth.value()/2;break;case 10:const e=Math.abs(100-u.baselineStyle.childs().baseLevelPercentage.value());a=n.height()*e/100>h?u.baselineStyle.childs().topLineWidth.value()/2:u.baselineStyle.childs().bottomLineWidth.value()/2;break;case 1:case 9:case 8:case 12:case 4:case 7:a=3;break;case 0:a=u.barStyle.childs().thinBars.value()?3:Math.max(3,.25*o.barSpacing());break;case 11:a=u.rangeStyle.childs().thinBars.value()?3:Math.max(3,.25*o.barSpacing());break;case 5:a=Math.max(4,.25*o.barSpacing());break;case 6:a=Math.max(5,.25*o.barSpacing())}const f=h-_*a;return{index:r.index,price:r.price,poleStartY:f,visualDirection:_,positionPointDirection:_,startsOnSeriesData:!0,priceCoordinate:h,indexCoordinate:o.indexToCoordinate(r.index)}}class f extends n.InplaceTextLineDataSource{constructor(){super(...arguments),this._startMovingAnchorY=NaN}priceSource(){return this.ownerSource()}editableTextProperties(){(0,s.assert)(!1,"unexpected method call")}addPoint(e,t,i){return super.addPoint(this._updatePositionAndCorrectPoint(e),t,i)}setPoint(e,t,i){super.setPoint(e,this._updatePositionAndCorrectPoint(t,!this.isPhantom()&&!this._allowChangeAnchorHorizontally()),i),this._syncPosition()}setPointAndChangeIndex(e,t,i){ super.setPoint(e,this._updatePositionAndCorrectPoint(t,!1),i),this._syncPosition()}startMoving(e,t,i,r){r||(this._startMovingAnchorY=(0,s.ensureNotNull)(this._anchorYCoordinate())),super.startMoving(e,t,i)}move(e,t,i,r){var n;const o=(0,s.ensureDefined)((0,s.ensureNotNull)(this.startMovingPoint()).logical),l=(0,s.ensureDefined)(e.logical);if(!r&&0===t){const e=this._points[0],t=l.index-o.index,i=(0,s.ensureNotNull)(this.priceScale()),r=(0,s.ensure)(null===(n=this.ownerSource())||void 0===n?void 0:n.firstValue()),a=i.priceToCoordinate(l.price,r)-i.priceToCoordinate(o.price,r),c=this._startMovingAnchorY+a,u=i.coordinateToPrice(c,r);this._updatePositionAndCorrectPoint({index:e.index+t,price:u})}super.move(e,t,i),r||this._syncPosition()}_allowChangeAnchorHorizontally(){return!1}_updatePositionAndCorrectPoint(e,t){t&&(e.index=this._points[0].index);const i=this.priceSource();if(null===i)return e;const s=i.priceScale(),r=i.firstValue();if(null===s||s.isEmpty()||null===r)return e;const n=s.height();let o=n/2,a=e.price>=s.coordinateToPrice(o,r)?1:-1;const c=this._model.mainSeries();if(i===c){const t=c.data().search(this._baseSeriesIndexForPoint(e));if(null!==t){const i=l(c,t,-1),n=l(c,t,1);a=e.price>=i?1:-1,o=s.priceToCoordinate(1===a?n:i,r),e.price=1===a?Math.max(n,e.price):e.price}}const u=1===(-1===a!==s.isInverted()?-1:1)?o:n-o,h=s.priceToCoordinate(e.price,r),d=Math.min(n,Math.abs(h-o)),p=Math.max(0,Math.min(100,100*d/u))*a;return this.properties().childs().position.setValue(p),e}_baseSeriesIndexForPoint(e){return e.index}_syncPosition(){const e=this.linkKey().value();if(null!==e){const t={position:this.properties().childs().position.value()};(0,o.changeLineStyle)({linkKey:e,state:t,model:this._model})}}_anchorYCoordinate(){const e=this.priceSource();if(null===e)return null;const t=e.priceScale(),i=e.firstValue();if(null===t||t.isEmpty()||null===i)return null;const s=this._model.mainSeries(),r=this.customEvent();if(null===r)return null;let n=null;if(e===s&&(n=d(s,r)),null===n&&(n=h(r,t,i)),null===n)return null;const o=r.position(),l=t.priceToCoordinate(n.price,i);return u(o,t.height(),l,c(o,t.isInverted()))}}},778737:(e,t,i)=>{var s=i(477227).LineToolTrading,r=i(613053).LineToolTradingPriceAxisView,n=i(586784),o=i(821979).LineDataSource,l=i(853965).DefaultProperty;const a=i(244842);var c=i(888929).sortSourcesPreOrdered.LineToolOrder;function u(e){return null==e?e="":e+="",e}class h{constructor(e){this._line=e,this._data={bodyText:"order",quantityText:"0"},this._editable=!0,this._cancellable=!0,this._mode="",this._direction="buy",this._active=!0}setMode(e){return this._mode=e,this._line.updateAllViewsAndRedraw(),this}setDirection(e){return this._direction=e,this._line.updateAllViewsAndRedraw(),this}setActive(e){return this._active=e,this._line.updateAllViewsAndRedraw(),this}setEditable(e){return this._editable=e,this._line.updateAllViewsAndRedraw(),this}getEditable(){return this._editable}setCancellable(e){return this._cancellable=e,this._line.updateAllViewsAndRedraw(),this}getCancellable(){return this._cancellable} hasMoveCallback(){return this.isFunction(this._onMoveCallback)}hasModifyCallback(){return this.isFunction(this._onModifyCallback)}getPrice(){return this._line.points().length>0?this._line.points()[0].price:this._line._timePoint.length>0?this._line._timePoint[0].price:void 0}setPrice(e){if(this._line.points().length>0){var t=this._line.points()[0];t.price=e,this._line.setPoint(0,t),this._line.updateAllViewsAndRedraw()}return this._line._timePoint.length>0&&(this._line._timePoint[0].price=e),this}getText(){return this._data.bodyText}setText(e){return this._data.bodyText=e||"",this._line.updateAllViewsAndRedraw(),this}setTooltip(e){return this._line.properties().tooltip.setValue(u(e)),this}getTooltip(){return this._line.properties().tooltip.value()}setModifyTooltip(e){return this._line.properties().modifyTooltip.setValue(u(e)),this}getModifyTooltip(){return this._line.properties().modifyTooltip.value()}setCancelTooltip(e){return this._line.properties().cancelTooltip.setValue(u(e)),this}getCancelTooltip(){return this._line.properties().cancelTooltip.value()}getQuantity(){return this._data.quantityText}setQuantity(e){return this._data.quantityText=e||"",this._line.updateAllViewsAndRedraw(),this}getExtendLeft(){var e=this._line.properties().extendLeft.value();return"inherit"===e?this._line._model.properties().tradingProperties.extendLeft.value():e}setExtendLeft(e){return this._line.properties().extendLeft.setValue(e),this}getLineLength(){var e=this._line.properties().lineLength.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineLength.value():e}setLineLength(e,t="percentage"){const i=t&&"pixel"===t?e:Math.max(0,Math.min(e,100));return this._line.properties().lineLength.setValue(i),this._line.properties().lineLengthUnit.setValue(t),this}getLineLengthUnit(){return this._line.properties().lineLengthUnit.value()}getLineColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.lineActiveBuyColor.value():e.lineInactiveBuyColor.value():this._active?e.lineActiveSellColor.value():e.lineInactiveSellColor.value()}setLineColor(e){return"buy"===this._direction?this._active?this.setLineActiveBuyColor(e):this.setLineInactiveBuyColor(e):this._active?this.setLineActiveSellColor(e):this.setLineInactiveSellColor(e),this}setLineActiveBuyColor(e){return this._line.properties().lineActiveBuyColor.setValue(e),this}setLineInactiveBuyColor(e){return this._line.properties().lineInactiveBuyColor.setValue(e),this}setLineActiveSellColor(e){return this._line.properties().lineActiveSellColor.setValue(e),this}setLineInactiveSellColor(e){return this._line.properties().lineInactiveSellColor.setValue(e),this}getLineStyle(){var e=this._line.properties().lineStyle.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineStyle.value():e}setLineStyle(e){return this._line.properties().lineStyle.setValue(e),this}getLineWidth(){var e=this._line.properties().lineWidth.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineWidth.value():e}setLineWidth(e){ return this._line.properties().lineWidth.setValue(e),this}getBodyBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.bodyBorderActiveBuyColor.value():e.bodyBorderInactiveBuyColor.value():this._active?e.bodyBorderActiveSellColor.value():e.bodyBorderInactiveSellColor.value()}setBodyBorderColor(e){return"buy"===this._direction?this._active?this.setBodyBorderActiveBuyColor(e):this.setBodyBorderInactiveBuyColor(e):this._active?this.setBodyBorderActiveSellColor(e):this.setBodyBorderInactiveSellColor(e),this}setBodyBorderActiveBuyColor(e){return this._line.properties().bodyBorderActiveBuyColor.setValue(e),this}setBodyBorderInactiveBuyColor(e){return this._line.properties().bodyBorderInactiveBuyColor.setValue(e),this}setBodyBorderActiveSellColor(e){return this._line.properties().bodyBorderActiveSellColor.setValue(e),this}setBodyBorderInactiveSellColor(e){return this._line.properties().bodyBorderInactiveSellColor.setValue(e),this}getBodyBackgroundColor(){return n.getColorFromProperties(this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency)}setBodyBackgroundColor(e){return n.setColorToProperties(e,this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency),this}getBodyTextColor(){var e=this._line.properties();return"limit"===this._mode?this._active?e.bodyTextActiveLimitColor.value():e.bodyTextInactiveLimitColor.value():"stop"===this._mode?this._active?e.bodyTextActiveStopColor.value():e.bodyTextInactiveStopColor.value():"buy"===this._direction?this._active?e.bodyTextActiveBuyColor.value():e.bodyTextInactiveBuyColor.value():this._active?e.bodyTextActiveSellColor.value():e.bodyTextInactiveSellColor.value()}setBodyTextColor(e){return"limit"===this._mode?this._active?this.setBodyTextActiveLimitColor(e):this.setBodyTextInactiveLimitColor(e):"stop"===this._mode?this._active?this.setBodyTextActiveStopColor(e):this.setBodyTextInactiveStopColor(e):"buy"===this._direction?this._active?this.setBodyTextActiveBuyColor(e):this.setBodyTextInactiveBuyColor(e):this._active?this.setBodyTextActiveSellColor(e):this.setBodyTextInactiveSellColor(e),this}setBodyTextInactiveLimitColor(e){return this._line.properties().bodyTextInactiveLimitColor.setValue(e),this}setBodyTextActiveLimitColor(e){return this._line.properties().bodyTextActiveLimitColor.setValue(e),this}setBodyTextInactiveStopColor(e){return this._line.properties().bodyTextInactiveStopColor.setValue(e),this}setBodyTextActiveStopColor(e){return this._line.properties().bodyTextActiveStopColor.setValue(e),this}setBodyTextInactiveBuyColor(e){return this._line.properties().bodyTextInactiveBuyColor.setValue(e),this}setBodyTextActiveBuyColor(e){return this._line.properties().bodyTextActiveBuyColor.setValue(e),this}setBodyTextInactiveSellColor(e){return this._line.properties().bodyTextInactiveSellColor.setValue(e),this}setBodyTextActiveSellColor(e){return this._line.properties().bodyTextActiveSellColor.setValue(e),this}getBodyFont(){ return n.getFontFromProperties(this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic)}setBodyFont(e){return n.setFontToProperties(e,this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic),this}getQuantityBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.quantityBorderActiveBuyColor.value():e.quantityBorderInactiveBuyColor.value():this._active?e.quantityBorderActiveSellColor.value():e.quantityBorderInactiveSellColor.value()}setQuantityBorderColor(e){return"buy"===this._direction?this._active?this.setQuantityBorderActiveBuyColor(e):this.setQuantityBorderInactiveBuyColor(e):this._active?this.setQuantityBorderActiveSellColor(e):this.setQuantityBorderInactiveSellColor(e),this}setQuantityBorderActiveBuyColor(e){return this._line.properties().quantityBorderActiveBuyColor.setValue(e),this}setQuantityBorderInactiveBuyColor(e){return this._line.properties().quantityBorderInactiveBuyColor.setValue(e),this}setQuantityBorderActiveSellColor(e){return this._line.properties().quantityBorderActiveSellColor.setValue(e),this}setQuantityBorderInactiveSellColor(e){return this._line.properties().quantityBorderInactiveSellColor.setValue(e),this}getQuantityBackgroundColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.quantityBackgroundActiveBuyColor.value():e.quantityBackgroundInactiveBuyColor.value():this._active?e.quantityBackgroundActiveSellColor.value():e.quantityBackgroundInactiveSellColor.value()}setQuantityBackgroundColor(e){return"buy"===this._direction?this._active?this.setQuantityBackgroundActiveBuyColor(e):this.setQuantityBackgroundInactiveBuyColor(e):this._active?this.setQuantityBackgroundActiveSellColor(e):this.setQuantityBackgroundInactiveSellColor(e),this}setQuantityBackgroundActiveBuyColor(e){return this._line.properties().quantityBackgroundActiveBuyColor.setValue(e),this}setQuantityBackgroundInactiveBuyColor(e){return this._line.properties().quantityBackgroundInactiveBuyColor.setValue(e),this}setQuantityBackgroundActiveSellColor(e){return this._line.properties().quantityBackgroundActiveSellColor.setValue(e),this}setQuantityBackgroundInactiveSellColor(e){return this._line.properties().quantityBackgroundInactiveSellColor.setValue(e),this}getQuantityTextColor(){return n.getColorFromProperties(this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency)}setQuantityTextColor(e){return n.setColorToProperties(e,this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency),this}getQuantityFont(){return n.getFontFromProperties(this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic)}setQuantityFont(e){ return n.setFontToProperties(e,this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic),this}getCancelButtonBorderColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.cancelButtonBorderActiveBuyColor.value():e.cancelButtonBorderInactiveBuyColor.value():this._active?e.cancelButtonBorderActiveSellColor.value():e.cancelButtonBorderInactiveSellColor.value()}setCancelButtonBorderColor(e){return"buy"===this._direction?this._active?this.setCancelButtonBorderActiveBuyColor(e):this.setCancelButtonBorderInactiveBuyColor(e):this._active?this.setCancelButtonBorderActiveSellColor(e):this.setCancelButtonBorderInactiveSellColor(e),this}setCancelButtonBorderActiveBuyColor(e){return this._line.properties().cancelButtonBorderActiveBuyColor.setValue(e),this}setCancelButtonBorderInactiveBuyColor(e){return this._line.properties().cancelButtonBorderInactiveBuyColor.setValue(e),this}setCancelButtonBorderActiveSellColor(e){return this._line.properties().cancelButtonBorderActiveSellColor.setValue(e),this}setCancelButtonBorderInactiveSellColor(e){return this._line.properties().cancelButtonBorderInactiveSellColor.setValue(e),this}getCancelButtonBackgroundColor(){return n.getColorFromProperties(this._line.properties().cancelButtonBackgroundColor,this._line.properties().cancelButtonBackgroundTransparency)}setCancelButtonBackgroundColor(e){return n.setColorToProperties(e,this._line.properties().cancelButtonBackgroundColor,this._line.properties().cancelButtonBackgroundTransparency),this}getCancelButtonIconColor(){var e=this._line.properties();return"buy"===this._direction?this._active?e.cancelButtonIconActiveBuyColor.value():e.cancelButtonIconInactiveBuyColor.value():this._active?e.cancelButtonIconActiveSellColor.value():e.cancelButtonIconInactiveSellColor.value()}setCancelButtonIconColor(e){return"buy"===this._direction?this._active?this.setCancelButtonIconActiveBuyColor(e):this.setCancelButtonIconInactiveBuyColor(e):this._active?this.setCancelButtonIconActiveSellColor(e):this.setCancelButtonIconInactiveSellColor(e),this}setCancelButtonIconActiveBuyColor(e){return this._line.properties().cancelButtonIconActiveBuyColor.setValue(e),this}setCancelButtonIconInactiveBuyColor(e){return this._line.properties().cancelButtonIconInactiveBuyColor.setValue(e),this}setCancelButtonIconActiveSellColor(e){return this._line.properties().cancelButtonIconActiveSellColor.setValue(e),this}setCancelButtonIconInactiveSellColor(e){return this._line.properties().cancelButtonIconInactiveSellColor.setValue(e),this}block(){this._blocked=!0,this._line.updateAllViewsAndRedraw()}unblock(){this._blocked=!1,this._line.updateAllViewsAndRedraw()}getBlocked(){return this._blocked}isFunction(e){return"function"==typeof e}onCancel(e,t){return t?this.isFunction(t)&&(this._onCancelData=e,this._onCancelCallback=t):this.isFunction(e)&&(this._onCancelCallback=e),this}callOnCancel(){ this.isFunction(this._onCancelCallback)&&this._onCancelCallback.call(this,this._onCancelData)}isOnCancelCallbackPresent(){return this.isFunction(this._onCancelCallback)}onModify(e,t){return t?this.isFunction(t)&&(this._onModifyData=e,this._onModifyCallback=t):this.isFunction(e)&&(this._onModifyCallback=e),this}callOnModify(){this.isFunction(this._onModifyCallback)&&this._onModifyCallback.call(this,this._onModifyData)}onMove(e,t){return t?this.isFunction(t)&&(this._onMoveData=e,this._onMoveCallback=t):this.isFunction(e)&&(this._onMoveCallback=e),this}callOnMove(){this.isFunction(this._onMoveCallback)&&this._onMoveCallback.call(this,this._onMoveData)}onMoving(e,t){return t?this.isFunction(t)&&(this._onMovingData=e,this._onMovingCallback=t):this.isFunction(e)&&(this._onMovingCallback=e),this}callOnMoving(){this.isFunction(this._onMovingCallback)&&this._onMovingCallback.call(this,this._onMovingData)}onContextMenu(e,t){return t?this.isFunction(t)&&(this._onContextMenuData=e,this._onContextMenuCallback=t):this.isFunction(e)&&(this._onContextMenuCallback=e),this}shouldShowContextMenu(){return this.isFunction(this._onContextMenuCallback)}callOnContextMenu(){if(this.isFunction(this._onContextMenuCallback))return this._onContextMenuCallback.call(this,this._onContextMenuData)}remove(){this._line._model.removeSource(this._line),delete this._line}}class d extends s{constructor(e,t){super(e,t||d.createProperties()),this._adapter=new h(this),this.setSelectionEnabled(!0),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,198918)).then((({OrderPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}zorder(){return c}isSpeciallyZOrderedSource(){return!0}setPoint(e,t){this._points[e]=t,this._normalizePoints()}addPoint(e,t){return this._points.push(e),this._lastPoint=null,this._normalizePoints(),this.createServerPoints(),!0}name(){return"Order"}move(e,t,i,s){var r=this._startMovingPoint&&this._currentMovingPoint&&this._startMovingPoint.logical.price!==this._currentMovingPoint.logical.price;super.move(e,t,i,s),r&&this._adapter.callOnMoving()}endMoving(e){var t=this._startMovingPoint&&this._currentMovingPoint&&this._startMovingPoint.logical.price!==this._currentMovingPoint.logical.price;super.endMoving(),!e&&t&&this._adapter.callOnMove()}createPriceAxisView(e){var t={pointIndex:e,backgroundPropertyGetter:()=>this._adapter.getLineColor()};return this._priceAxisView=new r(this,t),this._priceAxisView}paneViews(){return TradingView.printing&&!a.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showOrders.value()?o.prototype.paneViews.call(this):null}priceAxisViews(e,t){return TradingView.printing&&!a.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showOrders.value()?o.prototype.priceAxisViews.call(this,e,t):null}adapter(){return this._adapter}hasContextMenu(){return this._adapter.shouldShowContextMenu()}contextMenuItems(){return this._adapter.callOnContextMenu()}movable(){return Boolean(this._adapter._onMoveCallback)} formatter(){return this._formatter}static createProperties(e){var t=new l({defaultName:"linetoolorder",state:e,useUserPreferences:!1});return this._configureProperties(t),t}}t.LineToolOrder=d},247035:(e,t,i)=>{i.d(t,{LineToolParallelChannel:()=>h});var s=i(650151),r=i(86441),n=i(811630),o=i(853965),l=i(885482),a=i(821979),c=i(389137),u=i(354950);class h extends a.LineDataSource{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),this._priceAxisViews.push(this.createPriceAxisView(3)),this._coordOffsetWhileMovingOrChanging=null,this._pendingPriceOffset=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,570404)).then((({ParallelChannelPaneView:e})=>{this._setPaneViews([new e(this,this._model)])})),n.alertsAvailable&&this._normalizedPointsChanged.subscribe(this,this._updateAlertCreationAvailable)}paneViews(e){return null!==this._pendingPriceOffset&&this._applyPendingPriceOffset(),super.paneViews(e)}setLastPoint(e,t){t&&t.shift()&&2===this.points().length&&this._snapPoint45Degree(e,this.points()[0]);const i=(0,c.clone)(e);return super.setLastPoint(e),i}startMoving(e,t,i,s){super.startMoving(e,t,i,s),this._coordOffsetWhileMovingOrChanging=this._findPixelsHeight()}endMoving(e,t,i){return this._coordOffsetWhileMovingOrChanging=null,super.endMoving(e,t,i)}startChanging(e,t){super.startChanging(e,t),this._coordOffsetWhileMovingOrChanging=this._findPixelsHeight()}endChanging(e,t,i){return this._coordOffsetWhileMovingOrChanging=null,super.endChanging(e,t,i)}restoreExternalPoints(e,t,i){const s=i?e.points:this._timePoint.map(((t,i)=>({price:t.price,offset:e.points[i].offset,time_t:e.points[i].time_t})));if(super.restoreExternalPoints({...e,points:s},t),t.pricesChanged&&this._points.length===s.length)for(let e=0;e=4)return;this._snapPointBeforeChange(e,t,i);const o=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),a=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),c=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),u=(0,s.ensureNotNull)(this._coordOffsetWhileMovingOrChanging),h=(0,s.ensureNotNull)(this.priceScale()),d=(0,s.ensure)(null===(n=this.ownerSource())||void 0===n?void 0:n.firstValue());switch(e){case 0:super.setPoint(e,t,i),this._points[2].price=h.coordinateToPrice(c.y+u,d);break;case 1:super.setPoint(e,t,i);break;case 2:super.setPoint(e,t,i),this._points[0].price=h.coordinateToPrice(c.y-u,d),this._points[0].index=t.index;break;case 3:this._points[1].price=h.coordinateToPrice(c.y-u,d),this._points[1].index=t.index;break;case 4:{const e=a.subtract(o),t=(c.x-o.x)/e.x,i=o.addScaled(e,t),s=c.y-i.y;this._points[2].price=h.coordinateToPrice(o.y+s,d);break}case 5:{const e=a.subtract(o),t=(c.x-o.x)/e.x,i=o.addScaled(e,t),s=c.y-i.y;this._points[0].price=h.coordinateToPrice(o.y+s,d), this._points[1].price=h.coordinateToPrice(a.y+s,d);break}}const p=this.linkKey().value();if(p&&!r&&e<4){const e=this._points.map((e=>e.price));(0,l.changeLineStyle)({model:this._model,linkKey:p,state:{prices:e}})}}state(e){const t=super.state(e);return this._pendingPriceOffset&&(t.priceOffset=this._pendingPriceOffset),t}restoreExternalState(e){const{prices:t,...i}=e;if(t&&this.isActualSymbol())for(let e=0;ee.index<=t.index?[e,t]:[t,e],s=i(t[0],t[1]),r=i(t[2],t[3]);let n,o,l,a;t[2].pricenull!==e))}_correctLastPoint(e){if(this._points.length<2||this._points[1].index===this._points[0].index)return e;const t=(0,s.ensureNotNull)(this.pointToScreenPoint(e)),i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),n=(0, s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=i.subtract(n),l=(t.x-n.x)/o.x,a=n.addScaled(o,l),c=t.y-a.y,u=n.add(new r.Point(0,c));return(0,s.ensureNotNull)(this.screenPointToPoint(u))}static _configureProperties(e){super._configureProperties(e),e.hasChild("labelText")||e.addChild("labelText",new u.Property("")),e.addExcludedKey("labelText",1)}_isTimePointsValid(){return this._timePoint.every((e=>Number.isFinite(e.price)))}_axisPoints(){const e=this.points(),t=this._points[0]?this.pointToScreenPoint(this._points[0]):null,i=this._points[1]?this.pointToScreenPoint(this._points[1]):null,n=this._points[2]?this.pointToScreenPoint(this._points[2]):null;if(t&&i&&n){const o=i.y-t.y,l=n.add(new r.Point(0,o));e.push((0,s.ensureNotNull)(this.screenPointToPoint(l)))}return e}_convertLastPointTo3rdPoint(e){const t=(0,s.ensureNotNull)(this.pointToScreenPoint(e)),i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1])),n=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=i.subtract(n),l=(t.x-n.x)/o.x,a=n.addScaled(o,l),c=t.y-a.y,u=n.add(new r.Point(0,c));return(0,s.ensureNotNull)(this.screenPointToPoint(u))}_findPixelsHeight(){const e=this.pointToScreenPoint(this._points[2]),t=this.pointToScreenPoint(this._points[0]);return e&&t?e.y-t.y:null}_applyPendingPriceOffset(){const e=this._pendingPriceOffset;if(null===e||this._points.length<3)return;const t=this.priceScale(),i=(0,s.ensureNotNull)(this.ownerSource()).firstValue();if(!t||t.isEmpty()||null===i)return;const r=e+this._points[0].price,n=e+this._points[1].price,o=.5*(r+n)-e,l=.5*(r+n),a=t.priceToCoordinate(o,i),c=t.priceToCoordinate(l,i)-a,u=t.priceToCoordinate(this._points[0].price,i)+c,h=t.coordinateToPrice(u,i);this._points[2].price=h,this._timePoint[2].price=h,this._points[2].index=this._points[0].index,this._timePoint[2].time_t=this._timePoint[0].time_t,this._timePoint[2].offset=this._timePoint[0].offset,this._pendingPriceOffset=null}_snapPointBeforeChange(e,t,i){if(i&&i.shift())switch(e){case 0:case 1:this._snapPoint45Degree(t,this._points[1-e]);break;case 2:case 3:const i=(0,s.ensureNotNull)(this.getPoint(5-e));this._snapPoint45Degree(t,i)}}}},999432:(e,t,i)=>{i.d(t,{LineToolPath:()=>c});var s=i(650151),r=i(86441),n=i(853965),o=i(9640),l=i(821979),a=i(31712);class c extends l.LineDataSource{constructor(e,t,s,r){const n=t||c.createProperties();super(e,n,s,r),this._finished=!1,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,310981)).then((t=>{this._setPaneViews([new t.PathPaneView(this,e)])}))}pointsCount(){return-1}name(){return"Path"}hasEditableCoordinates(){return!1}finish(){this._finished=!0,this._lastPoint=null,this._normalizePoints(),this.createServerPoints()}addPoint(e,t,i,n){var l;if(this._finished)return!0;const a=(0,s.ensureNotNull)(this.priceScale()),c=this._model.timeScale().indexToCoordinate(e.index),u=e.price,h=(0,s.ensure)(null===(l=this.ownerSource())||void 0===l?void 0:l.firstValue()),d=a.priceToCoordinate(u,h);if(this._points.length>0){ const e=this._points[this._points.length-1],i=this._model.timeScale().indexToCoordinate(e.index),s=e.price,l=a.priceToCoordinate(s,h),u=new r.Point(c,d).subtract(new r.Point(i,l)).length();if(!(null==t?void 0:t.isApiEvent())&&u<(0,o.interactionTolerance)().minDistanceBetweenPoints&&!n)return this._lastPoint=null,this._normalizePoints(),this.createServerPoints(),!0}return super.addPoint(e,t,i)}static createProperties(e){const t=new n.DefaultProperty({defaultName:"linetoolpath",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,317115)).then((e=>e.PathDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesWidths",new a.LineToolWidthsProperty([(0,s.ensureDefined)(e.child("lineWidth"))])),e.addChild("linesColors",new a.LineToolColorsProperty([e.childs().lineColor]))}}},932732:(e,t,i)=>{var s=i(809796).TranslatedString,r=i(440941).lineToolsDoNotAffectChartInvalidation,n=i(821979).LineDataSource,o=i(517336).LevelsProperty,l=i(31712),a=l.LineToolWidthsProperty,c=l.LineToolColorsProperty,u=new s("erase level line",i.tf(null,void 0,i(812962)));class h extends n{constructor(e,t,s,r){super(e,t||h.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,443454)).then((({PitchfanLinePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return h.LevelsCount}pointsCount(){return 3}name(){return"Pitchfan"}processErase(e,t){var i="level"+t,s=this.properties()[i].visible;e.setProperty(s,!1,u,r)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,315340))).PitchBaseDefinitionsViewModel}static createProperties(e){var t=new o({defaultName:"linetoolpitchfan",state:e,map:{range:[0,8]}});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e);for(var t=[e.child("median").child("linewidth")],i=[e.child("median").child("color")],s=0;s<=this.LevelsCount;s++)t.push(e.child("level"+s).child("linewidth")),i.push(e.child("level"+s).child("color"));e.addChild("linesColors",new c(i)),e.addChild("linesWidths",new a(t))}}h.LevelsCount=8,t.LineToolPitchfan=h},9093:(e,t,i)=>{var s=i(809796).TranslatedString,r=i(440941).lineToolsDoNotAffectChartInvalidation,n=i(821979).LineDataSource,o=i(517336).LevelsProperty,l=i(373571).Action,a=i(607509).ACTION_ID,c=i(642346).LineToolPitchforkStyle,u=null,h=i(31712),d=h.LineToolWidthsProperty,p=h.LineToolColorsProperty,_=new s("erase level line",i.tf(null,void 0,i(812962))),f=new s("change {title} style",i.tf(null,void 0,i(474428)));class m extends n{constructor(e,t,i,s){super(e,t||m.createProperties(),i,s),this._properties.style.listeners().subscribe(this,this._recreatePaneView),this._recreatePaneView()}levelsCount(){return m.LevelsCount}additionalActions(e){for(var t=[],n=[{title:i.tf(null,void 0,i(825595)), actionId:a.ChartLineToolPitchforkChangeTypeToOriginal},{title:i.tf(null,void 0,i(966276)),actionId:a.ChartLineToolPitchforkChangeTypeToModifiedSchiff},{title:i.tf(null,void 0,i(809114)),actionId:a.ChartLineToolPitchforkChangeTypeToInside},{title:i.tf(null,void 0,i(151464)),actionId:a.ChartLineToolPitchforkChangeTypeToSchiff}],o=0;o<4;o++){var c=new l({actionId:n[o].actionId,options:{checked:this.properties().style.value()===o,checkable:!0,label:n[o].title,payload:{target:this,value:o},onExecute:function(t){var i=t.getPayload(),n=i.target;e.setProperty(n.properties().style,i.value,f.format({title:new s(n.name(),n.title())}),r),n.updateAllViews(),n._model.updateSource(n)}}});t.push(c)}return[t[0],t[3],t[1],t[2]]}_recreatePaneView(){if(null!==u){var e=[];this._properties.style.value()===c.Original?e=[new u.PitchforkLinePaneView(this,this._model)]:this._properties.style.value()===c.Schiff?e=[new u.SchiffPitchforkLinePaneView(this,this._model)]:this._properties.style.value()===c.Schiff2?e=[new u.SchiffPitchfork2LinePaneView(this,this._model)]:this._properties.style.value()===c.Inside&&(e=[new u.InsidePitchforkLinePaneView(this,this._model)]),this._setPaneViews(e)}else Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,183415)).then((e=>{null===u&&(u=e),this._recreatePaneView()}))}pointsCount(){return 3}name(){return"Pitchfork"}processErase(e,t){var i="level"+t,s=this.properties()[i].visible;e.setProperty(s,!1,_,r)}static createProperties(e){var t=new o({defaultName:"linetoolpitchfork",state:e,map:{range:[0,8]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,61107))).PitchForkDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);for(var t=[e.child("median").child("linewidth")],i=[e.child("median").child("color")],s=0;s<=this.LevelsCount;s++)t.push(e.child("level"+s).child("linewidth")),i.push(e.child("level"+s).child("color"));e.addChild("linesColors",new p(i)),e.addChild("linesWidths",new d(t))}}m.LevelsCount=8,t.LineToolPitchfork=m},527342:(e,t,i)=>{i.d(t,{LineToolPolyline:()=>a});var s=i(650151),r=i(86441),n=i(853965),o=i(9640),l=i(821979);class a extends l.LineDataSource{constructor(e,t,s,r){const n=t||a.createProperties();super(e,n,s,r),this._finished=!1,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,623652)).then((t=>{this._setPaneViews([new t.PolylinePaneView(this,e)])}))}pointsCount(){return-1}name(){return"Polyline"}hasEditableCoordinates(){return!1}finish(){this._finished=!0,this._lastPoint=null,this._normalizePoints(),this.createServerPoints()}addPoint(e,t,i,n){var l;if(this._finished)return!0;const a=(0,s.ensureNotNull)(this.priceScale()),c=this._model.timeScale().indexToCoordinate(e.index),u=e.price,h=(0,s.ensure)(null===(l=this.ownerSource())||void 0===l?void 0:l.firstValue()),d=a.priceToCoordinate(u,h),p=(0,o.interactionTolerance)().minDistanceBetweenPoints ;if(this._points.length>0){const e=this._points[this._points.length-1],i=this._model.timeScale().indexToCoordinate(e.index),s=e.price,o=a.priceToCoordinate(s,h),l=new r.Point(c,d).subtract(new r.Point(i,o)).length();if(!(null==t?void 0:t.isApiEvent())&&le.PolylinesDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addExcludedKey("filled",1)}}},674053:(e,t,i)=>{var s=i(477227).LineToolTrading,r=i(821979).LineDataSource,n=i(613053).LineToolTradingPriceAxisView,o=i(586784),l=i(853965).DefaultProperty;const a=i(244842);var c=i(888929).sortSourcesPreOrdered.LineToolPosition;function u(e){return null==e?e="":e+="",e}class h{constructor(e){this._line=e,this._data={bodyText:"position",quantityText:"0"},this._closeEnabled=!0,this._direction="buy",this._profitState="neutral"}setDirection(e){return this._direction=e,this._line.updateAllViewsAndRedraw(),this}setProfitState(e){return this._profitState=e,this._line.updateAllViewsAndRedraw(),this}getPrice(){return this._line.points().length>0?this._line.points()[0].price:this._line._timePoint.length>0?this._line._timePoint[0].price:void 0}setPrice(e){if(this._line.points().length>0){var t=this._line.points()[0];t.price=e,this._line.setPoint(0,t),this._line.updateAllViewsAndRedraw()}return this._line._timePoint.length>0&&(this._line._timePoint[0].price=e),this}getText(){return this._data.bodyText}setText(e){return this._data.bodyText=e||"",this._line.updateAllViewsAndRedraw(),this}setTooltip(e){return this._line.properties().tooltip.setValue(u(e)),this}getTooltip(){return this._line.properties().tooltip.value()}setProtectTooltip(e){ return this._line.properties().protectTooltip.setValue(u(e)),this}getProtectTooltip(){return this._line.properties().protectTooltip.value()}setCloseTooltip(e){return this._line.properties().closeTooltip.setValue(u(e)),this}getCloseTooltip(){return this._line.properties().closeTooltip.value()}setReverseTooltip(e){return this._line.properties().reverseTooltip.setValue(u(e)),this}getReverseTooltip(){return this._line.properties().reverseTooltip.value()}getQuantity(){return this._data.quantityText}setQuantity(e){return this._data.quantityText=e||"",this._line.updateAllViewsAndRedraw(),this}getExtendLeft(){var e=this._line.properties().extendLeft.value();return"inherit"===e?this._line._model.properties().tradingProperties.extendLeft.value():e}setExtendLeft(e){return this._line.properties().extendLeft.setValue(e),this}getLineLength(){var e=this._line.properties().lineLength.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineLength.value():e}getLineLengthUnit(){return this._line.properties().lineLengthUnit.value()}setLineLength(e,t="percentage"){const i=t&&"pixel"===t?e:Math.max(0,Math.min(e,100));return this._line.properties().lineLength.setValue(i),this._line.properties().lineLengthUnit.setValue(t),this}getLineColor(){var e=this._line.properties();return("buy"===this._direction?e.lineBuyColor:e.lineSellColor).value()}setLineColor(e){return"buy"===this._direction?this.setLineBuyColor(e):this.setLineSellColor(e),this}setLineBuyColor(e){return this._line.properties().lineBuyColor.setValue(e),this}setLineSellColor(e){return this._line.properties().lineSellColor.setValue(e),this}getLineStyle(){var e=this._line.properties().lineStyle.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineStyle.value():e}setLineStyle(e){return this._line.properties().lineStyle.setValue(e),this}getLineWidth(){var e=this._line.properties().lineWidth.value();return"inherit"===e?this._line._model.properties().tradingProperties.lineWidth.value():e}setLineWidth(e){return this._line.properties().lineWidth.setValue(e),this}getBodyBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.bodyBorderBuyColor:e.bodyBorderSellColor).value()}setBodyBorderColor(e){return"buy"===this._direction?this.setBodyBorderBuyColor(e):this.setBodyBorderSellColor(e),this}setBodyBorderBuyColor(e){return this._line.properties().bodyBorderBuyColor.setValue(e),this}setBodyBorderSellColor(e){return this._line.properties().bodyBorderSellColor.setValue(e),this}getBodyBackgroundColor(){return o.getColorFromProperties(this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency)}setBodyBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().bodyBackgroundColor,this._line.properties().bodyBackgroundTransparency),this}getBodyTextColor(){var e=this._line.properties();return("positive"===this._profitState?e.bodyTextPositiveColor:"negative"===this._profitState?e.bodyTextNegativeColor:e.bodyTextNeutralColor).value()}setBodyTextColor(e){ return"positive"===this._profitState?this.setBodyTextPositiveColor(e):"negative"===this._profitState?this.setBodyTextNegativeColor(e):this.setBodyTextNeutralColor(e),this}setBodyTextPositiveColor(e){return this._line.properties().bodyTextPositiveColor.setValue(e),this}setBodyTextNegativeColor(e){return this._line.properties().bodyTextNegativeColor.setValue(e),this}setBodyTextNeutralColor(e){return this._line.properties().bodyTextNeutralColor.setValue(e),this}getBodyFont(){return o.getFontFromProperties(this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic)}setBodyFont(e){return o.setFontToProperties(e,this._line.properties().bodyFontFamily,this._line.properties().bodyFontSize,this._line.properties().bodyFontBold,this._line.properties().bodyFontItalic),this}getQuantityBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.quantityBorderBuyColor:e.quantityBorderSellColor).value()}setQuantityBorderColor(e){return"buy"===this._direction?this.setQuantityBorderBuyColor(e):this.setQuantityBorderSellColor(e),this}setQuantityBorderBuyColor(e){return this._line.properties().quantityBorderBuyColor.setValue(e),this}setQuantityBorderSellColor(e){return this._line.properties().quantityBorderSellColor.setValue(e),this}getQuantityBackgroundColor(){var e=this._line.properties();return("buy"===this._direction?e.quantityBackgroundBuyColor:e.quantityBackgroundSellColor).value()}setQuantityBackgroundColor(e){return"buy"===this._direction?this.setQuantityBackgroundBuyColor(e):this.setQuantityBackgroundSellColor(e),this}setQuantityBackgroundBuyColor(e){return this._line.properties().quantityBackgroundBuyColor.setValue(e),this}setQuantityBackgroundSellColor(e){return this._line.properties().quantityBackgroundSellColor.setValue(e),this}getQuantityTextColor(){return o.getColorFromProperties(this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency)}setQuantityTextColor(e){return o.setColorToProperties(e,this._line.properties().quantityTextColor,this._line.properties().quantityTextTransparency),this}getQuantityFont(){return o.getFontFromProperties(this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic)}setQuantityFont(e){return o.setFontToProperties(e,this._line.properties().quantityFontFamily,this._line.properties().quantityFontSize,this._line.properties().quantityFontBold,this._line.properties().quantityFontItalic),this}getReverseButtonBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.reverseButtonBorderBuyColor:e.reverseButtonBorderSellColor).value()}setReverseButtonBorderColor(e){return"buy"===this._direction?this.setReverseButtonBorderBuyColor(e):this.setReverseButtonBorderSellColor(e),this}setReverseButtonBorderBuyColor(e){return this._line.properties().reverseButtonBorderBuyColor.setValue(e),this}setReverseButtonBorderSellColor(e){ return this._line.properties().reverseButtonBorderSellColor.setValue(e),this}getReverseButtonBackgroundColor(){return o.getColorFromProperties(this._line.properties().reverseButtonBackgroundColor,this._line.properties().reverseButtonBackgroundTransparency)}setReverseButtonBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().reverseButtonBackgroundColor,this._line.properties().reverseButtonBackgroundTransparency),this}getReverseButtonIconColor(){var e=this._line.properties();return("buy"===this._direction?e.reverseButtonIconBuyColor:e.reverseButtonIconSellColor).value()}setReverseButtonIconColor(e){return"buy"===this._direction?this.setReverseButtonIconBuyColor(e):this.setReverseButtonIconSellColor(e),this}setReverseButtonIconBuyColor(e){return this._line.properties().reverseButtonIconBuyColor.setValue(e),this}setReverseButtonIconSellColor(e){return this._line.properties().reverseButtonIconSellColor.setValue(e),this}getCloseButtonBorderColor(){var e=this._line.properties();return("buy"===this._direction?e.closeButtonBorderBuyColor:e.closeButtonBorderSellColor).value()}setCloseButtonBorderColor(e){return"buy"===this._direction?this.setCloseButtonBorderBuyColor(e):this.setCloseButtonBorderSellColor(e),this}setCloseButtonBorderBuyColor(e){return this._line.properties().closeButtonBorderBuyColor.setValue(e),this}setCloseButtonBorderSellColor(e){return this._line.properties().closeButtonBorderSellColor.setValue(e),this}getCloseButtonBackgroundColor(){return o.getColorFromProperties(this._line.properties().closeButtonBackgroundColor,this._line.properties().closeButtonBackgroundTransparency)}setCloseButtonBackgroundColor(e){return o.setColorToProperties(e,this._line.properties().closeButtonBackgroundColor,this._line.properties().closeButtonBackgroundTransparency),this}getCloseButtonIconColor(){var e=this._line.properties();return("buy"===this._direction?e.closeButtonIconBuyColor:e.closeButtonIconSellColor).value()}setCloseButtonIconColor(e){return"buy"===this._direction?this.setCloseButtonIconBuyColor(e):this.setCloseButtonIconSellColor(e),this}setCloseButtonIconBuyColor(e){return this._line.properties().closeButtonIconBuyColor.setValue(e),this}setCloseButtonIconSellColor(e){return this._line.properties().closeButtonIconSellColor.setValue(e),this}block(){this._blocked=!0,this._line.updateAllViewsAndRedraw()}unblock(){this._blocked=!1,this._line.updateAllViewsAndRedraw()}isFunction(e){return"function"==typeof e}onReverse(e,t){return t?this.isFunction(t)&&(this._onReverseData=e,this._onReverseCallback=t):this.isFunction(e)&&(this._onReverseCallback=e),this}callOnReverse(){this.isFunction(this._onReverseCallback)&&this._onReverseCallback.call(this,this._onReverseData)}isOnReverseCallbackPresent(){return this.isFunction(this._onReverseCallback)}onClose(e,t){return t?this.isFunction(t)&&(this._onCloseData=e,this._onCloseCallback=t):this.isFunction(e)&&(this._onCloseCallback=e),this}setCloseEnabled(e){return this._closeEnabled===e||(this._closeEnabled=e, this._onCloseCallback&&this._line.updateAllViewsAndRedraw()),this}isCloseEnabled(){return this._closeEnabled}callOnClose(){this.isFunction(this._onCloseCallback)&&this._closeEnabled&&this._onCloseCallback.call(this,this._onCloseData)}isOnCloseCallbackPresent(){return this._closeEnabled&&this.isFunction(this._onCloseCallback)}onModify(e,t){return t?this.isFunction(t)&&(this._onModifyData=e,this._onModifyCallback=t):this.isFunction(e)&&(this._onModifyCallback=e),this}callOnModify(){this.isFunction(this._onModifyCallback)&&this._onModifyCallback.call(this,this._onModifyData)}onContextMenu(e,t){return t?this.isFunction(t)&&(this._onContextMenuData=e,this._onContextMenuCallback=t):this.isFunction(e)&&(this._onContextMenuCallback=e),this}shouldShowContextMenu(){return this.isFunction(this._onContextMenuCallback)}callOnContextMenu(){if(this.isFunction(this._onContextMenuCallback))return this._onContextMenuCallback.call(this,this._onContextMenuData)}remove(){this._line._model.removeSource(this._line),delete this._line}}class d extends s{constructor(e,t){super(e,t||d.createProperties()),this._adapter=new h(this),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.t.bind(i,221759,19)).then((({PositionPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}adapter(){return this._adapter}zorder(){return c}isSpeciallyZOrderedSource(){return!0}setPoint(e,t){this._points[e]=t,this._normalizePoints()}addPoint(e,t){return this._points.push(e),this._lastPoint=null,this._normalizePoints(),this.createServerPoints(),!0}name(){return"Position"}createPriceAxisView(e){return this._priceAxisView=new n(this,{pointIndex:e,backgroundPropertyGetter:()=>this._adapter.getLineColor()}),this._priceAxisView}paneViews(){return TradingView.printing&&!a.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showPositions.value()?r.prototype.paneViews.call(this):null}priceAxisViews(e,t){return TradingView.printing&&!a.enabled("snapshot_trading_drawings")?null:this._model.properties().tradingProperties.showPositions.value()?r.prototype.priceAxisViews.call(this,e,t):null}hasContextMenu(){return this._adapter.shouldShowContextMenu()}contextMenuItems(){return this._adapter.callOnContextMenu()}formatter(){return this._formatter}static createProperties(e){var t=new l({defaultName:"linetoolposition",state:e,useUserPreferences:!1});return this._configureProperties(t),t}}t.LineToolPosition=d},917004:(e,t,i)=>{var s,r;i.d(t,{AlertStatus:()=>s,Direction:()=>r}),function(e){e[e.Waiting=0]="Waiting",e[e.Success=1]="Success",e[e.Failure=2]="Failure"}(s||(s={})),function(e){e[e.Up=1]="Up",e[e.Down=2]="Down"}(r||(r={}))},240569:(e,t,i)=>{i.d(t,{LineToolPrediction:()=>a});var s=i(650151),r=i(853965),n=i(354950),o=i(821979),l=i(917004);class a extends o.LineDataSource{constructor(e,t,s,r){const n=t||a.createProperties();super(e,n,s,r),this._predictionPaneView=null;const o=this._model.mainSeries();o.properties().childs().interval.subscribe(this,(()=>{this.setStatus(l.AlertStatus.Waiting)})), o.dataEvents().dataUpdated().subscribe(this,this.recalculateStateByData),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,964858)).then((t=>{this._predictionPaneView=new t.PredictionPaneView(this,e),this._setPaneViews([this._predictionPaneView])}))}destroy(){const e=this._model.mainSeries();e.properties().childs().interval.unsubscribeAll(this),e.dataEvents().dataUpdated().unsubscribeAll(this),super.destroy()}dataAndViewsReady(){return super.dataAndViewsReady()&&Boolean(this._predictionPaneView&&this._predictionPaneView.iconsReady())}cloneable(){return!1}isSynchronizable(){return!1}status(){return this._properties.childs().status.value()}setStatus(e){return this._properties.childs().status.setValue(e)}pointsCount(){return 2}name(){return"Forecast"}restorePoints(e,t,i){super.restorePoints(e,t,i),this.recalculateStateByData()}recalculateStateByData(){if(this.isSourceHidden())return;if(this._points.length<2)return;if(this._model.mainSeries().bars().isEmpty())return;const e=this._points[1];if(this.status())return void(e.index>this._model.timeScale().baseIndex()&&this.setStatus(l.AlertStatus.Waiting));const t=this._model.mainSeries().bars().valueAt(e.index);if(null===t)return;const i=this.direction();if(i===l.Direction.Up&&(0,s.ensure)(t[2])>=e.price)this.setStatus(l.AlertStatus.Success);else if(i===l.Direction.Down&&(0,s.ensure)(t[3])<=e.price)this.setStatus(l.AlertStatus.Success);else{const t=(0,s.ensureNotNull)(this._model.mainSeries().bars().lastIndex());e.index!==t&&this.setStatus(l.AlertStatus.Failure)}}addPoint(e,t,i){const s=super.addPoint(e,t,i);return s&&this.recalculateStateByData(),s}endChanging(e,t){const i=super.endChanging(e,t);return this.setStatus(l.AlertStatus.Waiting),this.recalculateStateByData(),i}onData(e){super.onData(e),this.recalculateStateByData()}endMoving(e,t,i){const s=super.endMoving(e,t,i);return this.setStatus(l.AlertStatus.Waiting),this.recalculateStateByData(),s}direction(){if(this._points.length<2)return l.Direction.Up;const e=this._points[0];return this._points[1].price>e.price?l.Direction.Up:l.Direction.Down}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolprediction",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,87069)).then((e=>e.PredictionDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.hasChild("status")||e.addChild("status",new n.Property(l.AlertStatus.Waiting))}}},729443:(e,t,i)=>{var s=i(821979).LineDataSource,r=i(853965).DefaultProperty,n=i(31712).LineToolColorsProperty;class o extends s{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.t.bind(i,473612,19)).then((({PriceLabelPaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 1}name(){return"Price Label"}async _getPropertyDefinitionsViewModelClass(){ return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,732887))).PriceLabelDefinitionsViewModel}static createProperties(e){var t=new r({defaultName:"linetoolpricelabel",state:e});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.childs().borderColor])),e.addChild("textsColors",new n([e.childs().color]))}}t.LineToolPriceLabel=o},830695:(e,t,i)=>{i.d(t,{LineToolPriceRange:()=>m});var s=i(821979),r=i(650151),n=i(61499),o=i(853965),l=i(738232),a=i(941883),c=i(923237);const u={...a.nonThemedFactoryDefaultsBase,extendLeft:!1,extendRight:!1},h=a.themedFactoryDefaultsBase,d=(0,o.extractAllPropertiesKeys)((0,r.ensureDefined)(h.get(n.StdTheme.Light))),p=(0,o.extractAllPropertiesKeys)(u),_=[...d,...p,...c.commonLineToolPropertiesStateKeys,...a.allPropertiesStateKeysBase];class f extends a.DateAndPriceBaseProperties{static create(e){return new this({defaultName:"linetoolpricerange",factoryDefaultsSupplier:()=>(0,l.factoryDefaultsForCurrentTheme)(u,h),nonThemedDefaultsKeys:p,themedDefaultsKeys:d,allStateKeys:_,state:e})}}class m extends s.LineDataSource{constructor(e,t,s,r){super(e,t||m.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,425784)).then((e=>{this._setPaneViews([new e.PriceRangePaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Price Range"}template(){return this._properties.template()}static createProperties(e){const t=f.create(e);return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,133954))).GeneralDatePriceRangeDefinitionsViewModel}}},506416:(e,t,i)=>{i.d(t,{LineToolProjection:()=>o});var s=i(672688),r=i(517336),n=i(31712);class o extends s.LineToolFibWedgeBase{constructor(e,t,s,r){super(e,null!=t?t:o.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,678175)).then((e=>{this._setPaneViews([new e.ProjectionLinePaneView(this,this._model)])}))}levelsCount(){return 1}name(){return"Projection"}static createProperties(e){const t=new r.LevelsProperty({defaultName:"linetoolprojection",state:e,map:{range:[1,1]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,758221))).ProjectionDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().trendline.childs().color]))}}},352747:(e,t,i)=>{i.d(t,{LineToolRay:()=>r});var s=i(956268);class r extends s.LineToolTrendLine{constructor(e,t,i,s){super(e,null!=t?t:r.createProperties(),i,s)}name(){return"Ray"}static createProperties(e){const t=s.LineToolTrendLine._createPropertiesImpl("linetoolray",e);return r._configureProperties(t),t}}},442724:(e,t,i)=>{i.d(t,{ LineToolRectangle:()=>c});var s=i(650151),r=i(86441),n=i(853965),o=i(354950),l=i(821979),a=i(31712);class c extends l.LineDataSource{constructor(e,t,s,r){const n=t||c.createProperties();super(e,n,s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,239631)).then((({RectanglePaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}pointsCount(){return 2}textColorsProperty(){return this.properties().childs().showLabel.value()?super.textColorsProperty():null}name(){return"Rectangle"}setPoint(e,t,i){if(e<2&&super.setPoint(e,t,i),i&&i.shift()){const i=this._getAnchorPointForIndex(e);if(e>=4)return this._correctMiddlePoints(e,t,i),void this._normalizePoints();this._snapPoint45Degree(t,i)}switch(e){case 2:this._points[1].price=t.price,this._points[0].index=t.index;break;case 3:this._points[0].price=t.price,this._points[1].index=t.index;break;case 4:this._points[0].index=t.index;break;case 5:this._points[1].index=t.index;break;case 6:this._points[0].price=t.price;break;case 7:this._points[1].price=t.price}this._normalizePoints()}getPoint(e){return e<2?super.getPoint(e):this._getAnchorPointForIndex(e)}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}static createProperties(e,t){const i=new n.DefaultProperty({defaultName:"linetoolrectangle",state:e,useUserPreferences:t});return this._configureProperties(i),i}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,261145)).then((e=>e.RectangleDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_snapPoint45Degree(e,t,i){const r=this._priceScale,n=this.ownerSource();if(null===r||null===n)return;const o=n.firstValue();if(null===o)return;const l=this._model.timeScale(),a=(0,s.ensureNotNull)(this.pointToScreenPoint(e)),c=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),u=a.x-c.x,h=a.y-c.y,d=u<0?-1:1,p=h<0?-1:1,_=Math.max(Math.abs(u),Math.abs(h)),f=Math.round(l.coordinateToIndex(c.x+_*d)),m=Math.abs(l.indexToCoordinate(f)-c.x),v=r.coordinateToPrice(c.y+m*p,o);e.index=f,e.price=v}_correctMiddlePoints(e,t,i){e<6?this._correctRightLeftMiddlePoint(e,t,i):this._correctTopBottomMiddlePoint(e,t,i)}_correctRightLeftMiddlePoint(e,t,i){const n=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),o=(0,s.ensureNotNull)(this.pointToScreenPoint(i)),l=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),a=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[1]));let c=n.x-o.x;if(0===c)return;const u=l.x{var s;i.d(t,{RiskDisplayMode:()=>s}),function(e){e.Percentage="percents",e.Money="money"}(s||(s={}))},514524:(e,t,i)=>{var s;i.d(t,{RiskRewardPointIndex:()=>s}),function(e){e[e.Entry=0]="Entry",e[e.Close=1]="Close",e[e.ActualEntry=2]="ActualEntry",e[e.ActualClose=3]="ActualClose"}(s||(s={}))},864555:(e,t,i)=>{i.d(t,{LineToolRiskRewardLong:()=>w,LineToolRiskRewardShort:()=>C});var s=i(650151),r=i(534741),n=i(291784),o=i(821979),l=i(264663),a=i(514524),c=i(229765),u=i(246733);class h extends c.PriceAxisView{constructor(e,t){super(),this._source=e,this._data=t}_updateRendererData(e,t,i){if(e.visible=!1,!this._showAxisLabel())return;const s=this._source.priceScale();if(0===this._source.points().length||null===s||s.isEmpty())return ;const r=this._source.ownerSource(),n=null!==r?r.firstValue():null;if(null===n)return;const o=this._data.priceProperty.value(),l=(0,u.resetTransparency)(this._data.colorProperty.value());i.background=l,i.textColor=this.generateTextColor(l),i.coordinate=s.priceToCoordinate(o,n),e.text=s.formatPrice(o,n),e.visible=!0}_showAxisLabel(){return this._source.properties().childs().showPriceLabels.value()||this._source.model().selection().isSelected(this._source)}}var d=i(354950);class p extends d.Property{constructor(e,t){super(),this._lineSource=e,this._pointIndex=t}value(){const e=this._lineSource.points()[this._pointIndex].price;return this._formatAndParsePrice(e)}state(){return this.value()}merge(e,t){return this.setValue(e),t?[]:null}_formatAndParsePrice(e){var t;const i=(0,s.ensureNotNull)(this._lineSource.ownerSource()),r=(null===(t=i.defaultFormatter)||void 0===t?void 0:t.call(i))||i.formatter();if(r.parse){const t=r.format(e),i=r.parse(t);return i.res?i.value:e}return e}}class _ extends p{constructor(e){super(e,0)}setValue(e){const t=this._lineSource.points()[this._pointIndex];this._lineSource.startChanging(this._pointIndex,t),t.price=parseFloat(""+e),this._lineSource.setPoint(this._pointIndex,t),this._lineSource.recalculate(),this._lineSource.model().updateSource(this._lineSource),this._listeners.fire(this,""),this._lineSource.endChanging(!1,!1),this._lineSource.syncPriceLevels()}}class f extends p{constructor(e){super(e,1)}value(){const e=this._lineSource.stopPrice();return this._formatAndParsePrice(e)}setValue(e){const t=Math.round(Math.abs(e-this._lineSource.entryPrice())*this._lineSource.ownerSourceBase());this._lineSource.properties().childs().stopLevel.setValue(t),this._lineSource.syncPriceLevels()}}class m extends p{constructor(e){super(e,2)}value(){const e=this._lineSource.profitPrice();return this._formatAndParsePrice(e)}setValue(e){const t=Math.round(Math.abs(e-this._lineSource.entryPrice())*this._lineSource.ownerSourceBase());this._lineSource.properties().childs().profitLevel.setValue(t),this._lineSource.syncPriceLevels()}}var v=i(389137),g=i(885482),P=i(964824),y=i(948767);function S(e){return parseFloat(e.toFixed(2))}class b extends o.LineDataSource{constructor(e,t,r,o){super(e,t,r,o),this._syncStateExclusions=["points","entryPrice","stopPrice","targetPrice","stopLevel","profitLevel","riskSize","qty","amountTarget","amountStop"],this._riskInChange=!1,this.version=2,t.hasChild("stopLevel")||t.hasChild("profitLevel")||(t.addProperty("stopLevel",0),t.addProperty("profitLevel",0),this.ownerSourceChanged().subscribe(this,(()=>{const i=(0,s.ensureNotNull)(e.timeScale().visibleBarsStrictRange()),r=i.firstBar(),o=i.lastBar(),l=(0,s.ensureNotNull)(this.ownerSource()),a=l.priceScale();if(a){let e=(0,s.ensureNotNull)(l.priceRange(r,o,{targetPriceScale:a,scaleSeriesOnly:null==a?void 0:a.isScaleSeriesOnly()}));if(a.isLog()){const t=a.logicalToPrice(e.minValue()),i=a.logicalToPrice(e.maxValue());e=new n.PriceRange(t,i)}if(e&&!e.isEmpty()){const i=Math.round(.2*e.length()*this.ownerSourceBase());t.merge({stopLevel:i, profitLevel:i})}}}),!0));const c=t.childs();c.stopLevel.listeners().subscribe(this,this.recalculate),c.stopLevel.listeners().subscribe(null,(()=>{this.properties().childs().stopPrice.childChanged(null,"")})),c.profitLevel.listeners().subscribe(this,this.recalculate),c.profitLevel.listeners().subscribe(null,(()=>{this.properties().childs().targetPrice.childChanged(null,"")})),t.addChild("entryPrice",new _(this)),t.addChild("stopPrice",new f(this)),t.addChild("targetPrice",new m(this)),t.hasChild("riskSize")||t.addProperty("riskSize",0),t.hasChild("qty")||t.addProperty("qty",0),t.hasChild("amountTarget")||t.addProperty("amountTarget",c.accountSize.value()),t.hasChild("amountStop")||t.addProperty("amountStop",c.accountSize.value()),t.addExcludedKey("riskSize",1),t.addExcludedKey("qty",1),t.addExcludedKey("amountTarget",1),t.addExcludedKey("amountStop",1),c.risk.subscribe(this,this._recalculateRiskSize),c.accountSize.subscribe(this,this._recalculateRiskSize),c.riskDisplayMode.subscribe(this,this._recalculateRisk),c.riskDisplayMode.subscribe(this,this._recalculateRiskSize),c.entryPrice.subscribe(this,this._recalculateRiskSize),c.stopPrice.subscribe(this,this._recalculateRiskSize),c.profitLevel.subscribe(this,this._recalculateRiskSize),c.profitLevel.subscribe(this,this.syncPriceLevels.bind(this)),c.stopLevel.subscribe(this,this._recalculateRiskSize),c.stopLevel.subscribe(this,this.syncPriceLevels.bind(this)),c.qty.subscribe(this,this._recalculateRiskSize),this.ownerSourceChanged().subscribe(null,((e,t)=>{e&&e.barsProvider().dataUpdated().unsubscribeAll(this),t&&t.barsProvider().dataUpdated().subscribe(this,this._onSeriesUpdated)})),this.pointAdded().subscribe(this,(e=>{switch(e){case a.RiskRewardPointIndex.Entry:case a.RiskRewardPointIndex.Close:this._recalculateRiskSize(),this._recalculateQty()}})),this.pointChanged().subscribe(this,(e=>{switch(e){case a.RiskRewardPointIndex.Entry:case a.RiskRewardPointIndex.Close:this._recalculateRiskSize(),this._recalculateQty()}})),c.riskDisplayMode.value()===l.RiskDisplayMode.Percentage&&c.risk.value()>100&&c.riskDisplayMode.setValueSilently(l.RiskDisplayMode.Money),c.entryPrice.subscribe(this,this._recalculateQty),c.stopPrice.subscribe(this,this._recalculateQty),c.riskSize.subscribe(this,this._recalculateQty),c.entryPrice.subscribe(this,this._recalculateAmount),c.profitLevel.subscribe(this,this._recalculateAmount),c.stopLevel.subscribe(this,this._recalculateAmount),c.accountSize.subscribe(this,this._recalculateAmount),c.riskSize.subscribe(this,this._recalculateAmount),c.qty.subscribe(this,this._recalculateAmount),this._entryPriceAxisView=new h(this,{colorProperty:c.linecolor,priceProperty:c.entryPrice}),this._stopPriceAxisView=new h(this,{colorProperty:c.stopBackground,priceProperty:c.stopPrice}),this._profitPriceAxisView=new h(this,{colorProperty:c.profitBackground,priceProperty:c.targetPrice}),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,7293)).then((({RiskRewardPaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))} destroy(){var e;null===(e=this.ownerSource())||void 0===e||e.barsProvider().dataUpdated().unsubscribeAll(this),this.ownerSourceChanged().unsubscribeAll(this),super.destroy()}hasEditableCoordinates(){return!1}setOwnerSource(e){super.setOwnerSource(e);const t=this.ownerSource();t&&t.symbolSource().symbolInfo()&&(this._recalculateAmount(),this._recalculateRiskSize(),this._recalculateQty())}pointsCount(){return 2}priceAxisPoints(){const e=this._points[0],t=this._properties.childs();return[{...e,price:t.stopPrice.value()},{...e,price:t.entryPrice.value()},{...e,price:t.targetPrice.value()}]}priceAxisViews(e,t){return this.isSourceHidden()||t!==this.priceScale()||this._model.paneForSource(this)!==e?null:[this._entryPriceAxisView,this._stopPriceAxisView,this._profitPriceAxisView]}updateAllViews(e){this.isActualSymbol()&&this.properties().childs().visible.value()&&((0,g.hideAllDrawings)().value()&&this.userEditEnabled()||(super.updateAllViews(e),this._entryPriceAxisView.update(e),this._stopPriceAxisView.update(e),this._profitPriceAxisView.update(e)))}migrateVersion(e,t,i){if(1===e&&this._points.length>=1){const e=[];e.push(this._points[0]);let t=this._points[0];if(t={price:t.price,index:this._getClosePointIndex(t.index)},e.push(t),this._points[1]&&e.push(this._points[1]),this._points[2]&&e.push(this._points[2]),this._points=e,this._timePoint.length>=1){const t=[],i=this._timePoint[0];t.push(i);const s={price:i.price,time_t:i.time_t,offset:this._getClosePointIndex(i.offset)};t.push(s),this._timePoint[1]&&e.push(this._points[1]),this._timePoint[2]&&e.push(this._points[2]),this._timePoint=t}}}restoreExternalState(e){if((0,v.isNumber)(e.entryPrice)){if(e=Object.assign({},e),!this.isActualSymbol()){this._timePoint[0].price=e.entryPrice,delete e.entryPrice}this.properties().merge(e)}else super.restoreExternalState(e)}addPoint(e,t,i){e.price=this._roundPrice(e.price),super.addPoint(e,void 0,!0);const s={price:e.price,index:this._getClosePointIndex(e.index)};super._addPointIntenal(s,void 0,!0);const r=this._calculateActualEntry(e,s);if(r){super._addPointIntenal(r,void 0,!0);const e=this._findClosePoint(r,s);e&&super._addPointIntenal(e,void 0,!0)}return this._lastPoint=null,this._normalizePoints(),this.createServerPoints(),!0}setPoint(e,t,i,s){if(!this.isActualSymbol())return;const r=this.properties().childs();switch(this._muteSyncLineStyle(),e){case 0:this._changeEntryPoint(t);break;case 2:r.stopPrice.setValue(this.prepareStopPrice(t.price));break;case 3:r.targetPrice.setValue(this.prepareProfitPrice(t.price));break;case 1:t.price=this._points[0].price,super.setPoint(1,t),this.recalculate()}this._unmuteSyncLineStyleWithoutApplyingChanges(),this.syncPriceLevels()}getPoint(e){switch(e){case 0:return this._points[0];case 1:return{index:this._points[1].index,price:this._points[0].price};case 2:return{index:this._points[0].index,price:this.stopPrice()};case 3:return{index:this._points[0].index,price:this.profitPrice()}}return null}setPoints(e){this._muteSyncLineStyle(),super.setPoints(e),this.recalculate(), this._unmuteSyncLineStyleWithoutApplyingChanges(),this.syncPriceLevels()}start(){super.start(),this.recalculate()}startMoving(e,t,i,r){const n=(0,s.ensureDefined)(e.logical);n.price=this._roundPrice(n.price),super.startMoving(e,t,i)}move(e,t,i,r){const n=(0,s.ensureDefined)(e.logical);n.price=this._roundPrice(n.price),super.move(e,t,i),this.recalculate(),this._entryPriceAxisView.update((0,P.sourceChangeEvent)(this.id()))}axisPoints(){if(!this._points[a.RiskRewardPointIndex.ActualEntry])return[];const e=this._points[a.RiskRewardPointIndex.ActualEntry];let t=null;if(4===this._points.length)t=this._points[a.RiskRewardPointIndex.ActualClose];else{const e=this.lastBarData();if(!e)return[];t={index:e.index,price:e.closePrice}}return[e,t]}recalculateStateByData(){this.recalculate()}recalculate(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.targetPrice.value(),i=e.stopPrice.value(),s=[this._points[0],this._points[1]],r=this._calculateActualEntry(this.points()[0],this.points()[1]);if(r){s.push(r);const e=this._findClosePoint(r,this.points()[1]);e&&s.push(e)}this._points=s,t!==e.targetPrice.value()&&e.targetPrice.listeners().fire(e.targetPrice,""),i!==e.stopPrice.value()&&e.stopPrice.listeners().fire(e.stopPrice,"")}syncPriceLevels(){const e=this.linkKey().value();if(e){const t=this.properties().childs(),i={entryPrice:t.entryPrice.value(),stopLevel:t.stopLevel.value(),profitLevel:t.profitLevel.value()};(0,g.changeLineStyle)({linkKey:e,state:i,model:this._model})}}entryPrice(){return this.points()[0].price}lastBarData(){var e;const t=null===(e=this.ownerSource())||void 0===e?void 0:e.barsProvider();if(!t)return null;const i=t.bars().firstIndex(),n=t.bars().lastIndex();if(null===i||null===n||isNaN(i)||isNaN(n))return null;const o=this.points();if(4===o.length){const e=o[a.RiskRewardPointIndex.ActualClose];return e.indexs?(e.risk.setValue(s),e.riskSize.setValue(s)):e.riskSize.setValue(t)}_roundPrice(e){const t=this.ownerSourceBase();return Math.round(e*t)/t}_ownerSourcePointValue(){var e,t,i;return null!==(i=null===(t=null===(e=this.ownerSource())||void 0===e?void 0:e.symbolSource().symbolInfo())||void 0===t?void 0:t.pointvalue)&&void 0!==i?i:1}static _configureProperties(e){o.LineDataSource._configureProperties(e),e.addExcludedKey("stopLevel",1),e.addExcludedKey("profitLevel",1),e.addExcludedKey("stopPrice",1),e.addExcludedKey("targetPrice",1),e.addExcludedKey("entryPrice",1)}_onSeriesUpdated(e,t,i){this.isSourceHidden()||this._points.length<2||null!==i&&i.index>Math.max(this._points[0].index,this._points[1].index)||this.recalculateStateByData()}_recalculateRisk(){const e=this.properties().childs(),t=e.riskDisplayMode.value(),i=e.riskSize.value(),s=e.accountSize.value();let r=e.risk.value();r=t===l.RiskDisplayMode.Percentage?S(i/s*100):S(s/100*r),this._riskInChange=!0,e.risk.setValue(parseFloat(this._riskFormatter(t).format(r,!0))),this._riskInChange=!1}_recalculateAmount(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.accountSize.value(),i=e.entryPrice.value(),s=e.qty.value(),r=e.stopPrice.value(),n=e.targetPrice.value(),o=this._ownerSourcePointValue();e.amountTarget.setValue(this._amountTarget(t,n,i,s,o)),e.amountStop.setValue(this._amountStop(t,r,i,s,o))}_recalculateQty(){if(0===this.points().length)return;const e=this.properties().childs(),t=e.entryPrice.value(),i=e.stopPrice.value(),s=e.riskSize.value()/(Math.abs(t-i)*this._ownerSourcePointValue());e.qty.setValue(s)}_calculateActualEntry(e,t){const i=this.ownerSource();if(!i)return null;const r=i.barsProvider().bars();if(r.isEmpty())return null;const n=(0,s.ensureNotNull)(r.firstIndex()),o=Math.max(e.index,n),l=e.price,a=(0,s.ensureNotNull)(r.lastIndex()),c=Math.min(a,t.index);for(const e of r.rangeIterator(o,c+1)){const t=e.value;if(null!==t&&(0,s.ensure)(t[2])>=l&&(0,s.ensure)(t[3])<=l)return{index:e.index,price:l}}return null}_riskFormatter(e){return e===l.RiskDisplayMode.Percentage?(0,y.getNumericFormatter)(2):(0,y.getNumericFormatter)()}_getClosePointIndex(e){const t=this._model.timeScale(),i=Math.round(t.width()/t.barSpacing());return e+Math.max(3,Math.round(.15*i))}_findClosePoint(e,t){const i=this.ownerSource();if(!i)return null ;const r=i.barsProvider().bars(),n=(0,s.ensureNotNull)(r.firstIndex()),o=Math.max(e.index,n),l=(0,s.ensureNotNull)(r.lastIndex()),a=Math.min(l,t.index);for(const e of r.rangeIterator(o,a+1)){const t=e.value;if(null===t)continue;const i=this._checkStopPrice(t);if(null!=i)return{index:e.index,price:i}}return null}_changeEntryPoint(e){const t=this.properties().childs(),i=t.stopPrice.value(),s=t.targetPrice.value(),r=1/this.ownerSourceBase(),n=Math.min(i,s)+r,o=Math.max(i,s)-r;e.price=Math.max(n,Math.min(o,this._roundPrice(e.price))),this.setPoints([e,{...this._points[1],price:e.price}]),t.stopPrice.setValue(i),t.targetPrice.setValue(s)}}var x=i(853965);class C extends b{constructor(e,t,i,s){super(e,null!=t?t:C.createProperties(),i,s)}name(){return"Risk/Reward short"}stopPrice(){return this.entryPrice()+this.properties().childs().stopLevel.value()/this.ownerSourceBase()}calculatePL(e){return this.entryPrice()-e}profitPrice(){return this.entryPrice()-this.properties().childs().profitLevel.value()/this.ownerSourceBase()}prepareStopPrice(e){e=this._roundPrice(e);const t=this.entryPrice()+1/this.ownerSourceBase();return Math.max(e,t)}prepareProfitPrice(e){e=this._roundPrice(e);const t=this.entryPrice()-1/this.ownerSourceBase();return Math.min(e,t)}static createProperties(e){const t=new x.DefaultProperty({defaultName:"linetoolriskrewardshort",state:e});return this._configureProperties(t),t}_amountTarget(e,t,i,s,r){return S(e+(i-t)*s*r)}_amountStop(e,t,i,s,r){return S(e-(t-i)*s*r)}_checkStopPrice(e){const t=this.stopPrice(),i=this.profitPrice();return(0,s.ensure)(e[2])>=t?this.stopPrice():(0,s.ensure)(e[3])<=i?this.profitPrice():null}_orderSide(){return-1}}class w extends b{constructor(e,t,i,s){super(e,null!=t?t:w.createProperties(),i,s)}name(){return"Risk/Reward long"}stopPrice(){return this.entryPrice()-this.properties().childs().stopLevel.value()/this.ownerSourceBase()}profitPrice(){return this.entryPrice()+this.properties().childs().profitLevel.value()/this.ownerSourceBase()}calculatePL(e){return e-this.entryPrice()}prepareStopPrice(e){e=this._roundPrice(e);const t=this.entryPrice()-1/this.ownerSourceBase();return Math.min(e,t)}prepareProfitPrice(e){e=this._roundPrice(e);const t=this.entryPrice()+1/this.ownerSourceBase();return Math.max(e,t)}static createProperties(e){const t=new x.DefaultProperty({defaultName:"linetoolriskrewardlong",state:e});return this._configureProperties(t),t}_amountTarget(e,t,i,s,r){return S(e+(t-i)*s*r)}_amountStop(e,t,i,s,r){return S(e-(i-t)*s*r)}_checkStopPrice(e){const t=this.stopPrice(),i=this.profitPrice();return(0,s.ensure)(e[3])<=t?this.stopPrice():(0,s.ensure)(e[2])>=i?this.profitPrice():null}_orderSide(){return 1}}},605703:(e,t,i)=>{var s=i(86441).Point,r=i(204652).distanceToLine,n=i(821979).LineDataSource,o=i(853965).DefaultProperty,l=i(31712).LineToolColorsProperty;class a extends n{constructor(e,t,s,r){super(e,t||a.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.t.bind(i,642366,19)).then((({RotatedRectanglePaneView:e})=>{ this._setPaneViews([new e(this,this._model)])}))}startChanging(e,t){if(super.startChanging(e,t),0===e||1===e){var i=this._getPaneViews()[0],s=i._points[0],n=i._points[1],o=i._points[2];this._distance=r(s,n,o).distance}}setPoint(e,t,i){if(super.setPoint(e,t,i),0===e||1===e){var r=this._getPaneViews()[0];r.update();var n=r._points[0],o=r._points[1].subtract(n),l=new s(o.y,-o.x).normalized().scaled(this._distance),a=n.add(l),c=this.screenPointToPoint(a);this._points[2]=c}}endChanging(e,t){delete this._distance,super.endChanging(e,t)}pointsCount(){return 3}name(){return"Rotated Rectangle"}hasEditableCoordinates(){return!1}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,967382))).GeneralFiguresDefinitionsViewModel}_snapTo45DegreesAvailable(){return!0}static createProperties(e){var t=new o({defaultName:"linetoolrotatedrectangle",state:e});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new l([e.color]))}}t.LineToolRotatedRectangle=a},115137:(e,t,i)=>{var s=i(517336).LevelsProperty,r=i(9093).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Modified Schiff Pitchfork"}static createProperties(e){var t=new s({defaultName:"linetoolschiffpitchfork",state:e,map:{range:[0,8]}});return this._configureProperties(t),t}}t.LineToolSchiffPitchfork=n},126144:(e,t,i)=>{var s=i(517336).LevelsProperty,r=i(9093).LineToolPitchfork;class n extends r{constructor(e,t,i,s){super(e,t||n.createProperties(),i,s)}name(){return"Schiff Pitchfork"}static createProperties(e){var t=new s({defaultName:"linetoolschiffpitchfork2",state:e,map:{range:[0,8]}});return this._configureProperties(t),t}}t.LineToolSchiffPitchfork2=n},812788:(e,t,i)=>{i.d(t,{LineToolSignpost:()=>d});var s=i(195294),r=i(853965),n=i(354950),o=i(821979),l=i(31712),a=i(776954);class c extends n.Property{constructor(e){super(),this._source=e,e.pointAdded().subscribe(this,(()=>this.listeners().fire(this,""))),e.pointChanged().subscribe(this,(()=>this.listeners().fire(this,"")))}value(){const e=this._source.properties().childs().position.value();return parseFloat(e.toFixed(2))}setValue(e){this._source.properties().childs().position.setValue(e),this._source.model().updateSource(this._source),this.listeners().fire(this,""),this._source.syncMultichartState({pricesChanged:!1,indexesChanged:!1})}}var u=i(68626);class h extends u.LineDataSourcePointIndexProperty{constructor(e,t){super(e,t),this._source=e}_setPointImpl(e){this._source.setPointAndChangeIndex(this._pointIndex,e)}}class d extends a.LineToolWithRelativePriceCoordinate{constructor(e,t,r,o){super(e,null!=t?t:d.createProperties(),r,o),this._textColorProperty=new n.Property("transparent"),this._setTextColorByTheme=e=>{this._textColorProperty.setValue(e?(0,s.getHexColorByName)("color-cold-gray-200"):(0,s.getHexColorByName)("color-cold-gray-900"))},e.dark().subscribe(this._setTextColorByTheme,{callWithLast:!0}), Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,944581)).then((t=>{this._setPaneViews([new t.SignpostPaneView(this,e,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this))])}))}destroy(){this._model.dark().unsubscribe(this._setTextColorByTheme),super.destroy()}pointsCount(){return 1}name(){return"Signpost"}customEvent(){return{index:()=>{var e,t;return null!==(t=null===(e=this.points()[0])||void 0===e?void 0:e.index)&&void 0!==t?t:null},position:()=>this.properties().childs().position.value()}}showInObjectTree(){return!this.isPhantom()&&super.showInObjectTree()}isPhantom(){return this._model.isPhantomLine(this)}clonePositionOffset(){return{barOffset:1,xCoordOffset:0,yCoordOffset:0}}template(){const e=super.template(),t=this.properties().childs();return e.text=t.text.value(),e.position=t.position.value(),e}shouldBeRemovedOnDeselect(){const e=this._properties.childs();if(e.showImage.value())return!1;return""===e.text.value().trim()}editableTextProperties(){return{text:this.properties().childs().text,textColor:this._textColorProperty}}removeIfEditableTextIsEmpty(){return!1}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetoolsignpost",state:e});return this._configureProperties(t),t}_createPointProperty(e){super._createPointProperty(e);const t=this._pointsProperty.childs().points[e];t.removeProperty("price"),t.removeProperty("bar"),t.addChild("price",new c(this)),t.addChild("bar",new h(this,0))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text),this.properties().childs().position.setValue(e.position)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,611989)).then((e=>e.SignpostDefinitionsViewModel))}static _configureProperties(e){o.LineDataSource._configureProperties(e),e.hasChild("text")||e.addChild("text",new n.Property("")),e.hasChild("position")||e.addChild("position",new n.Property(50)),e.addExcludedKey("text",1),e.addExcludedKey("position",1),e.addChild("backgroundsColors",new l.LineToolColorsProperty([e.childs().plateColor]))}}d.supportPhantomMode=!0},305480:(e,t,i)=>{i.d(t,{LineToolSineLine:()=>n});var s=i(853965),r=i(821979);class n extends r.LineDataSource{constructor(e,t,s,r){super(e,t||n.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,435977)).then((e=>{this._setPaneViews([new e.SineLinePaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Sine Line"}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolsineline",state:e});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,925293))).CyclicAndSineLinesPatternDefinitionsViewModel}}},882626:(e,t,i)=>{i.d(t,{LineToolSticker:()=>y}) ;var s=i(885482),r=i(500477),n=i(760184),o=i(201089),l=i(822914),a=i(852290),c=i(33249),u=i(808068),h=i(853965),d=i(923237);const p={intervalsVisibilities:{...u.intervalsVisibilitiesDefaults},size:110},_={sticker:"bitcoin",angle:.5*Math.PI},f=(0,h.extractAllPropertiesKeys)(p),m=(0,h.extractAllPropertiesKeys)(_),v=[...f,...m,...d.commonLineToolPropertiesStateKeys];class g extends c.LineDataSourceProperty{constructor(e){super(e)}static create(e,t){return new this({defaultName:"linetoolsticker",factoryDefaultsSupplier:()=>(0,l.default)(p),nonThemedDefaultsKeys:f,themedDefaultsKeys:[],allStateKeys:v,state:(0,a.default)({},_,{sticker:t},null!=e?e:{})})}}const P=(0,o.getLogger)("Chart.LineToolSticker");class y extends n.LineToolSvgIconBase{constructor(e,t,i,s){super(e,t||y.createProperties(),i,s),this.version=1,this._loadViews()}name(){return"Sticker"}static createProperties(e){const t=g.create(e,s.stickerTool.value());return y._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,282375))).LineDataSourceDefinitionsViewModel}async _loadViews(){const[{getSvgContentForSticker:e,getSvgRenderer:t},{StickerPaneView:s}]=await Promise.all([i.e(25598).then(i.bind(i,40038)),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,434576))]);if(!this._isDestroyed){const i=this._properties.childs().sticker.value();this._svgContent=e(i),this._onIconChanged.fire();const n=t(r.svgRenderer,i);null===n&&P.logWarn(`Couldn't create svg renderer for sticker ${i}`),this._setPaneViews([new s(this,this._model,n)])}}}},760184:(e,t,i)=>{i.d(t,{LineToolSvgIconBase:()=>a});var s=i(650151),r=i(86441),n=i(625422),o=i(707957),l=i(821979);class a extends l.LineDataSource{constructor(e,t,i,s){super(e,t,i,s),this._onIconChanged=new o.Delegate,this._svgContent=null,this._changePointData=null,this._loadViews()}pointsCount(){return 1}hasEditableCoordinates(){return!1}getAnchorLimit(){return 80}getChangePointForSync(e){return null}startChanging(e,t){const i=(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),o=this.properties().childs(),l=o.size.value();let a;if(t)a=(0,s.ensureNotNull)(this.pointToScreenPoint(t));else{let e=new r.Point(0,Math.max(80,l)/2);const t=(0,n.rotationMatrix)(o.angle.value());e=(0,n.transformPoint)(t,e),a=i.add(e)}const c=i.subtract(a).length();this._changePointData={centerPoint:i,initialLength:c,initialSize:l},super.startChanging(e,t)}setPoint(e,t,i){const{centerPoint:r,initialLength:n,initialSize:o}=(0,s.ensureNotNull)(this._changePointData),l=(0,s.ensureNotNull)(this.pointToScreenPoint(t)),a=this.properties().childs();if(0===e||1===e){const t=l.subtract(r).normalized();let i=Math.acos(-t.x);Math.asin(t.y)>0&&(i=2*Math.PI-i),0===e&&(i+=Math.PI),a.angle.setValue(i)}else{const e=o*(r.subtract(l).length()/n);a.size.setValue(e)}}getSourceIcon(){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)}}},520259:(e,t,i)=>{i.d(t,{LineToolText:()=>u,LineToolTextAbsolute:()=>h});var s=i(650151),r=i(86441),n=i(354950),o=i(853965),l=i(31712),a=i(964824),c=i(126222);class u extends c.InplaceTextLineDataSource{constructor(e,t,s,r){const n=t||u.createProperties();super(e,n,s,r),this._barSpacing=e.timeScale().barSpacing(),this._recalculatePointsOnCenter=!1,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,630468)).then((({TextPaneView:t})=>{const i=this._recalculatePointsOnCenter?(e,t)=>{this._recalculatePointsOnCenter&&this._recalculateCenterPosition(e,t)}:void 0;this._paneView=new t(this,e,void 0,void 0,void 0,void 0,void 0,i,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this)),this._setPaneViews([this._paneView])}))}centerPosition(){this._recalculatePointsOnCenter=!0}setPoint(e,t,i){const r=this.properties().childs();let n;if(1===e&&r.wordWrapWidth.value()){const e=this.model().timeScale();n=this.isFixed()?(0,s.ensureDefined)(this.fixedPoint()).x:e.indexToCoordinate(this.points()[0].index);const i=e.indexToCoordinate(t.index)-n-~~(r.fontsize.value()/6);if(!isFinite(i))return;r.wordWrapWidth.setValue(Math.max(100,i))}}pointsCount(){return 1}name(){return"Text"}editableTextProperties(){const e=this.properties().childs();return{text:e.text,textColor:e.color,wordWrap:e.wordWrap}}setPriceScale(e){super.setPriceScale(e),e&&e.priceRange()&&(this._priceDencity=e.height()/(0,s.ensureNotNull)(e.priceRange()).length(),this._isPriceDencityLog=e.isLog())}restoreSize(){const e=(0,s.ensureNotNull)(this.priceScale());this._barSpacing=this.model().timeScale().barSpacing(),this._priceDencity=e.height()/(0,s.ensureNotNull)(e.priceRange()).length(),this.updateAllViewsAndRedraw((0,a.sourceChangeEvent)(this.id()))}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}state(e){const t=super.state(e);return e&&(t.state.fixedSize=!1),t}barSpacing(){return this._barSpacing}priceDencity(){return this._priceDencity}isPriceDencityLog(){return this._isPriceDencityLog}hasEditableCoordinates(){return!1}shouldBeRemovedOnDeselect(){return""===this._properties.childs().text.value().trim()}static createProperties(e){const t=new o.DefaultProperty({defaultName:"linetooltext",state:e});return this._configureProperties(t),t}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,941117)).then((e=>e.TextDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new n.Property("")),e.addChild("linesColors",new l.LineToolColorsProperty([e.childs().borderColor])),e.addChild("textsColors",new l.LineToolColorsProperty([e.childs().color])),e.addExcludedKey("text",1), e.addExcludedKey("linesColors",3),e.addExcludedKey("textsColors",3)}_recalculateCenterPosition(e,t){const i=this.isFixed()?(0,s.ensureDefined)(this.fixedPoint()):(0,s.ensureNotNull)(this.pointToScreenPoint(this._points[0])),n=new r.Point(i.x-e/2,i.y-t/2),o=(0,s.ensureNotNull)(this.screenPointToPoint(n));this.setPoints([o]),this._normalizePoints(),this.createServerPoints(),this.updateAllViewsAndRedraw((0,a.sourceChangeEvent)(this.id()))}}class h extends u{constructor(e,t){super(e,t||h.createProperties())}name(){return"Anchored Text"}hasEditableCoordinates(){return!1}isFixed(){return!0}static createProperties(e){const t=new o.DefaultProperty({defaultName:"linetooltextabsolute",state:e});return this._configureProperties(t),t}}},521600:(e,t,i)=>{i.d(t,{LineToolThreeDrivers:()=>o});var s=i(853965),r=i(821979),n=i(31712);class o extends r.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,927913)).then((t=>{this._setPaneViews([new t.LineToolThreeDrivesPaneView(this,e)])}))}pointsCount(){return 7}name(){return"Three Drives Pattern"}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolthreedrivers",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,669403)).then((e=>e.PatternWithoutBackgroundDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new n.LineToolColorsProperty([e.childs().textcolor])),e.addChild("linesWidths",new n.LineToolWidthsProperty([e.childs().linewidth])),e.hasChild("backgroundsColors")&&e.removeProperty("backgroundsColors")}}},36459:(e,t,i)=>{i.d(t,{LineToolTimeCycles:()=>o});var s=i(822914),r=i(853965),n=i(821979);class o extends n.LineDataSource{constructor(e,t,s,r){super(e,null!=t?t:o.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,764389)).then((e=>{this._setPaneViews([new e.TimeCyclesPaneView(this,this._model)])}))}pointsCount(){return 2}name(){return"Time Cycles"}setPoint(e,t){const i=(0,s.default)(t),r=this._points[0],n=this._points[1];r.price=i.price,n.price=i.price,this._points[e]=i,this._normalizePoints()}addPoint(e,t,i){const s=super.addPoint(e,t,!0);if(s){const e=this._points[0];this._points[1].price=e.price,i||(this._normalizePoints(),this.createServerPoints())}return s}static createProperties(e){const t=new r.DefaultProperty({defaultName:"linetooltimecycles",state:e});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,73900))).TimeCyclesPatternDefinitionsViewModel}}},167723:(e,t,i)=>{i.d(t,{LineToolTrendAngle:()=>u});var s=i(86441),r=i(650151),n=i(853965),o=i(126222),l=i(354950),a=i(964824) ;class c extends l.Property{constructor(e){super(),this._lineSource=e}value(){return Math.round(180*this._lineSource.angle()/Math.PI)}setValue(e){const t=e*Math.PI/180,i=(0,r.ensureNotNull)(this._lineSource.pointToScreenPoint(this._lineSource.points()[0])),n=Math.cos(t),o=-Math.sin(t),l=new s.Point(n,o),c=i.addScaled(l,this._lineSource.distance()),u=(0,r.ensureNotNull)(this._lineSource.screenPointToPoint(c));this._lineSource.setPoint(1,u);const h=this._lineSource.model();h.updateSource(this._lineSource),this._lineSource.updateAllViews((0,a.sourceChangeEvent)(this._lineSource.id())),h.updateSource(this._lineSource)}notifyChanged(){this._listeners.fire(this,"")}}class u extends o.InplaceTextLineDataSource{constructor(e,t,s,r){const n=t||u.createProperties();super(e,n,s,r),this._angle=0,this._distance=0,n.addChild("angle",new c(this)),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,528123)).then((({TrendAnglePaneView:t})=>{const i=[new t(this,e)];this._setPaneViews(i)}))}isSynchronizable(){return!1}pointsCount(){return 2}name(){return"Trend Angle"}angle(){return this._angle}distance(){return this._distance}addPoint(e,t){const i=super.addPoint(e,t);return i&&this._calculateAngle(),i}setLastPoint(e,t){const i=super.setLastPoint(e,t);return this.points().length>1&&this._calculateAngle(),i}axisPoints(){if(this.points().length<2)return[];const e=[this.points()[0]],t=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[0])),i=Math.cos(this._angle)*this._distance,n=-Math.sin(this._angle)*this._distance,o=t.add(new s.Point(i,n)),l=(0,r.ensureNotNull)(this.screenPointToPoint(o));return e.push(l),e}timeAxisPoints(){return this.axisPoints()}priceAxisPoints(){return this.axisPoints()}setPoint(e,t,i){super.setPoint(e,t,i),this.points().length>1&&1===e&&this._calculateAngle()}restoreData(e){var t,i;this._angle=null!==(t=e.angle)&&void 0!==t?t:0,this._distance=null!==(i=e.distance)&&void 0!==i?i:0}state(e){const t=super.state(e);return t.angle=this._angle,t.distance=this._distance,t}cloneData(e){this._angle=e.angle(),this._distance=e.distance()}canHasAlert(){return!0}editableTextProperties(){(0,r.assert)(!1,"unexpected method call")}removeIfEditableTextIsEmpty(){return!1}static createProperties(e){e&&void 0===e.showPercentPriceRange&&(e.showPercentPriceRange=e.showPriceRange,e.showPipsPriceRange=e.showPriceRange);const t=new n.DefaultProperty({defaultName:"linetooltrendangle",state:e});return this._configureProperties(t),t}_snapTo45DegreesAvailable(){return!0}_getAlertPlots(){const e=this._linePointsToAlertPlot(this._points,null,this._properties.childs().extendLeft.value(),this._properties.childs().extendRight.value());return null===e?[]:[e]}_calculateAngle(){const e=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[0]));let t=(0,r.ensureNotNull)(this.pointToScreenPoint(this.points()[1])).subtract(e);const i=t.length();i>0?(t=t.normalized(),this._angle=Math.acos(t.x),t.y>0&&(this._angle=-this._angle),this._distance=i):this._angle=0 ;this.properties().childs().angle.notifyChanged()}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,476535)).then((e=>e.TrendAngleDefinitionsViewModel))}}},882980:(e,t,i)=>{i.d(t,{LineToolTrendBasedFibExtension:()=>u});var s=i(444372),r=i(809796),n=i(517336),o=i(31712),l=i(440941),a=i(101443);const c=new r.TranslatedString("erase level line",s.t(null,void 0,i(812962)));class u extends a.LineToolFibWithInplaceTextBase{constructor(e,t,s,r){super(e,t||u.createProperties(),s,r),this.version=2,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,242128)).then((({TrendBasedFibExtensionPaneView:e})=>{this._setPaneViews([new e(this,this._model,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this))])}))}levelsCount(){return 24}pointsCount(){return 3}name(){return"Trend-Based Fib Extension"}migrateVersion(e,t){1===e&&this.properties().childs().extendLines.setValue(!0)}processErase(e,t){const i="level"+t,s=this.properties().childs()[i].childs().visible;e.setProperty(s,!1,c,l.lineToolsDoNotAffectChartInvalidation)}fibLevelsBasedOnLogScale(){var e;return this.properties().childs().fibLevelsBasedOnLogScale.value()&&Boolean(null===(e=this.priceScale())||void 0===e?void 0:e.isLog())}template(){const e=super.template();for(let t=1;t<=24;t++){const i=(0,a.getLevelProps)(this._properties,t);e[`level${t}`][3]=i.childs().text.value()}return e}static createProperties(e){const t=new n.LevelsProperty({defaultName:"linetooltrendbasedfibextension",state:e,map:{names:["coeff","color","visible","linestyle","linewidth","text"],range:[0,24]}});return this._configureProperties(t),t}_applyTemplateImpl(e){var t;for(let i=1;i<=24;i++){const s=(0,a.getLevelProps)(this._properties,i),r=e[`level${i}`];s.childs().text.setValue(null!==(t=r[3])&&void 0!==t?t:"")}super._applyTemplateImpl(e)}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,866406))).FibDrawingsWith24LevelsDefinitionsViewModel}static _configureProperties(e){const t=e.childs();super._configureProperties(e);const i=[t.trendline.childs().color];for(let t=1;t<=24;t++){const s=(0,a.getLevelProps)(e,t);i.push(s.childs().color),e.addExcludedKey(`level${t}.text`,1)}e.addChild("linesColors",new o.LineToolColorsProperty(i));const s=[t.trendline.childs().linewidth,t.levelsStyle.childs().linewidth];e.addChild("linesWidths",new o.LineToolWidthsProperty(s))}}},418219:(e,t,i)=>{i.d(t,{LineToolTrendBasedFibTime:()=>u});var s=i(444372),r=i(809796),n=i(821979),o=i(517336),l=i(31712),a=i(440941);const c=new r.TranslatedString("erase level line",s.t(null,void 0,i(812962)));class u extends n.LineDataSource{constructor(e,t,s,r){super(e,t||u.createProperties(),s,r),this.version=1,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,61304)).then((({TrendBasedFibTimePaneView:e})=>{ this._setPaneViews([new e(this,this._model)])}))}levelsCount(){return 11}pointsCount(){return 3}name(){return"Trend-Based Fib Time"}processErase(e,t){const i="level"+t,s=this.properties().childs()[i].childs().visible;e.setProperty(s,!1,c,a.lineToolsDoNotAffectChartInvalidation)}static createProperties(e){const t=new o.LevelsProperty({defaultName:"linetooltrendbasedfibtime",state:e,map:{range:[1,11]}});return this._configureProperties(t),t}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,663394))).TrendBasedFibTimeDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=e.childs(),i=[t.trendline.childs().linewidth],s=[t.trendline.childs().color];for(let e=1;e<=11;e++)i.push(t["level"+e].childs().linewidth),s.push(t["level"+e].childs().color);e.addChild("linesColors",new l.LineToolColorsProperty(s)),e.addChild("linesWidths",new l.LineToolWidthsProperty(i))}}},956268:(e,t,i)=>{i.d(t,{LineToolTrendLine:()=>l});var s=i(853965),r=i(354950),n=i(126222),o=i(837202);class l extends n.InplaceTextLineDataSource{constructor(e,t,s,r){super(e,t||l.createProperties(),s,r),this._trendLinePaneView=null,Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,982446)).then((({TrendLinePaneView:e})=>{this._trendLinePaneView=new e(this,this._model,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this)),this._setPaneViews([this._trendLinePaneView])}))}dataAndViewsReady(){return super.dataAndViewsReady()&&null!==this._trendLinePaneView&&this._trendLinePaneView.iconsReady()}pointsCount(){return 2}name(){return"Trend Line"}canHasAlert(){return!0}showPriceLabels(){return this._properties.childs().showPriceLabels.value()}createPriceAxisView(e){return new o.LineToolPriceAxisView(this,{pointIndex:e,backgroundPropertyGetter:()=>this.showPriceLabels()?this._properties.childs().linecolor.value():null})}isForcedDrawPriceAxisLabel(){return this.showPriceLabels()}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}editableTextProperties(){const e=this.properties().childs();return{text:e.text,textColor:e.textcolor,textVisible:e.showLabel}}removeIfEditableTextIsEmpty(){return!1}activateEditingOnCreation(){return!1}static createProperties(e,t){return l._createPropertiesImpl("linetooltrendline",e,t)}_getAlertPlots(){const e=this._linePointsToAlertPlot(this._points,null,this._properties.childs().extendLeft.value(),this._properties.childs().extendRight.value());return null===e?[]:[e]}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,167738))).TrendLineDefinitionsViewModel}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}_snapTo45DegreesAvailable(){return!0}static _createPropertiesImpl(e,t,i){ t&&void 0===t.showPercentPriceRange&&(t.showPercentPriceRange=t.showPriceRange,t.showPipsPriceRange=t.showPriceRange);const r=new s.DefaultProperty({defaultName:e,state:t,useUserPreferences:i});return this._configureProperties(r),r}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new r.Property("")),e.addExcludedKey("text",1)}}},948653:(e,t,i)=>{i.d(t,{LineToolTrianglePattern:()=>o});var s=i(853965),r=i(821979),n=i(31712);class o extends r.LineDataSource{constructor(e,t,s,r){const n=t||o.createProperties();super(e,n,s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,658539)).then((t=>{this._setPaneViews([new t.LineToolTrianglePatternPaneView(this,e)])}))}pointsCount(){return 4}name(){return"Triangle Pattern"}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetooltrianglepattern",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,63124)).then((e=>e.PatternWithBackgroundDefinitionViewModel))}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n.LineToolColorsProperty([e.childs().color])),e.addChild("textsColors",new n.LineToolColorsProperty([e.childs().textcolor])),e.addChild("backgroundsColors",new n.LineToolColorsProperty([e.childs().backgroundColor]))}}},287743:(e,t,i)=>{var s=i(821979).LineDataSource,r=i(853965).DefaultProperty,n=i(31712).LineToolColorsProperty;class o extends s{constructor(e,t,s,r){super(e,t||o.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.t.bind(i,560001,19)).then((({TrianglePaneView:e})=>{this._setPaneViews([new e(this,this._model)])}))}pointsCount(){return 3}name(){return"Triangle"}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,967382))).GeneralFiguresDefinitionsViewModel}static createProperties(e){var t=new r({defaultName:"linetooltriangle",state:e});return this._configureProperties(t),t}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new n([e.childs().color]))}}t.LineToolTriangle=o},972375:(e,t,i)=>{i.d(t,{createTweetLineToolByUrl:()=>h,isTwitterProfileImageUrl:()=>u,isTwitterUrl:()=>c});var s=i(650151),r=i(62802),n=i(541558),o=i(461794),l=i(623336);const a=(0,i(125226).isFeatureEnabled)("mock_tweet_data_for_tests");function c(e){try{const t=new URL(e);return("twitter.com"===t.hostname||t.hostname.endsWith(".twitter.com")||"x.com"===t.hostname||t.hostname.endsWith(".x.com"))&&"https:"===t.protocol}catch(e){return!1}}function u(e){try{const t=new URL(e);return"pbs.twimg.com"===t.hostname&&"https:"===t.protocol&&t.pathname.startsWith("/profile_images/")}catch(e){return!1}}function h(e,t,i=!1){return async function(e){if(a)return{id:0x853cb08cfe8b,created_at:1638107940, text:"𝓭𝓪𝓲𝓵𝔂 𝓻𝓮𝓶𝓲𝓷𝓭𝓮𝓻\r\rAlways do your own research.",username:"tradingview",user:"TradingView",profile_image_url:"https://pbs.twimg.com/profile_images/1598328471729704963/D7slFVZN_400x400.jpg",tweet_url:"https://twitter.com/tradingview/status/1464957065621872641?s=20"};const t=new URL("/api/v1/get-tweet-data/",location.href);return t.searchParams.append("tweet_url",e),fetch(t.toString()).then((e=>{if(!e.ok)throw new Error(`Error processing tweet: ${e.statusText}`);return e.json()}))}(e).then((a=>{const c=function(e,t){var i;return{id:e.id,createdAt:e.created_at,text:(0,o.clean)(e.text,!0),username:`@${e.username}`,user:e.user,profileImageUrl:e.profile_image_url,tweetUrl:null!==(i=e.tweet_url)&&void 0!==i?i:t}}(a,e),u={price:0,time_t:c.createdAt,offset:0},h=t.mainSeries(),d=(0,s.ensureNotNull)(t.model().paneForSource(h)),p=d.newLineToolZOrder(!0),_={type:"drawing",source:{id:(0,n.randomHashN)(6),zorder:p,type:"LineToolTweet",position:50,state:{interval:"1",...l.LineToolTweet.createProperties().state()},tweetData:c,symbol:h.symbol(),ownerSource:h.id(),points:[u]},geometry:[],modelId:t.model().id()},f=t.pasteLineTool(d,_,!0,!0);return i&&r.setValue("hint.pasteTweet",!0,{forceFlush:!0}),f.pointAdded().subscribe(null,(()=>t.scrollToLineTool(f)),!0),f}))}},623336:(e,t,i)=>{i.d(t,{LineToolTweet:()=>x});var s=i(853965),r=i(444372),n=i(62802),o=i(345848),l=i(201089),a=i(167222),c=i(846778),u=i(270294),h=i(885482),d=i(543373),p=i(972375);const _=(0,l.getLogger)("Chart.TweetDialog"),f=r.t(null,void 0,i(100970)),m=r.t(null,void 0,i(735415));let v=null;function g(e){"LineToolTweet"===e?(window.is_authenticated||(0,h.resetToCursor)(!0),(0,a.runOrSigninWithFeature)((()=>{h.tool.setValue("LineToolTweet"),v=(0,d.showCustomUrlEventDialog)({onConfirm:P,onClose:()=>{v=null,"LineToolTweet"===h.tool.value()&&(0,h.resetToCursor)(!0)},title:f,placeholderText:m}),(0,o.trackEvent)("Tweet","Open tweet dialog")}),{feature:"drawings",source:"Change drawing tool state"})):null!==v&&v.then((e=>e()))}function P(e){const t=(0,u.chartWidgetCollectionService)();if(null===t)return;if(!(0,p.isTwitterUrl)(e))return void _.logWarn(`Invalid tweet url: ${e}`);const i=!Boolean(n.getBool("hint.pasteTweet")),s=t.activeChartWidget.value();(0,p.createTweetLineToolByUrl)(e,s.model()).then((()=>{i&&(0,c.showPasteLineToolHint)(t.getContainer(),"hint.pasteTweet")}))}var y=i(354950),S=i(70726);class b extends S.CustomEventItem{constructor(e,t){super(t),this._data=e}tweetData(){return this._data}index(){return this._source.eventTimePointIndex()}time(){return this._data.createdAt}avatar(){return this._data.profileImageUrl}}class x extends S.LineToolCustomUrlEvent{constructor(e,t,s,r){super(e,t||x.createProperties(),s,r),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,123896)).then((t=>{this._setPaneViews([new t.TweetPaneView(this,e)])}))}name(){return"Tweet"}state(e){const t=super.state(e);return this._item&&(t.tweetData=this._item.tweetData()),e&&(t.eventTimePointIndex=this._eventTimePointIndex),t} restoreData(e){if(e.tweetData){if(!(0,p.isTwitterUrl)(e.tweetData.tweetUrl))throw new Error(`Invalid url for tweet line tool: ${e.tweetData.tweetUrl}`);this._item=new b(e.tweetData,this)}void 0!==e.eventTimePointIndex&&(this._eventTimePointIndex=e.eventTimePointIndex)}static createProperties(e){const t=new s.DefaultProperty({defaultName:"linetoolTweet",state:e});return this._configureProperties(t),t}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,427491)).then((e=>e.TweetDefinitionsViewModel))}static _configureProperties(e){super._configureProperties(e),e.hasChild("position")||e.addChild("position",new y.Property(50)),e.addExcludedKey("position",1)}}(0,h.runOnDrawingStateReady)((()=>{h.tool.subscribe(g)}))},421644:(e,t,i)=>{i.d(t,{LineToolVertLineTimeAxisView:()=>r});var s=i(902214);class r extends s.LineDataSourceTimeAxisView{constructor(e){super(e,0)}_getBgColor(){return this._source.properties().linecolor.value()}_getAlwaysInViewPort(){return!1}_getIndex(){const e=this._source.points();return 0===e.length?null:e[0].index}}},43653:(e,t,i)=>{i.d(t,{LineToolVertLine:()=>c});var s=i(650151),r=i(86441),n=i(853965),o=i(354950),l=i(126222),a=i(421644);class c extends l.InplaceTextLineDataSource{constructor(e,t,s,r){const n=t||c.createProperties();super(e,n,s,r),this._verticalLinePaneViews=new WeakMap,this._timeAxisView=new a.LineToolVertLineTimeAxisView(this),this._paneViewFactory=null,this.properties().childs().extendLine.subscribe(this,(()=>e.lightUpdate())),Promise.all([i.e(36827),i.e(7879),i.e(35367),i.e(35698),i.e(13207),i.e(51583)]).then(i.bind(i,590810)).then((t=>{this._paneViewFactory=i=>new t.VertLinePaneView(this,e,i,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this)),this._model.lightUpdate()})),this.setAdditionalCursorData(this._additionalCursorData.bind(this),this._positionToCoordinate.bind(this))}destroy(){this.properties().childs().extendLine.unsubscribeAll(this),super.destroy()}pointsCount(){return 1}name(){return"Vertical Line"}timeAxisViews(){return this.isSourceHidden()?null:this.properties().childs().showTime.value()?[this._timeAxisView]:null}updateAllViews(e){super.updateAllViews(e),this._timeAxisView.update(e)}canHasAlert(){return!0}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}isMultiPaneAvailable(){return!0}isMultiPaneEnabled(){return this.properties().childs().extendLine.value()}paneViews(e){if(e=(0,s.ensureDefined)(e),!this.isMultiPaneEnabled()&&this._model.paneForSource(this)!==e)return null;if(null===this._getPaneViews(e)&&null!==this._paneViewFactory){const t=this._paneViewFactory(e);this._verticalLinePaneViews.set(e,t),this._setPaneViews([t],e,!0)}return super.paneViews(e)}priceAxisViews(){return null}priceAxisPoints(){return[]}pointToScreenPoint(e){const t=this._model.timeScale();if(t.isEmpty())return null;const i=t.indexToCoordinate(e.index);return new r.Point(i,0)}convertYCoordinateToPriceForMoving(e){return 0} editableTextProperties(){const e=this.properties().childs();return{text:e.text,textColor:e.textcolor,textVisible:e.showLabel}}removeIfEditableTextIsEmpty(){return!1}activateEditingOnCreation(){return!1}static createProperties(e){null!=e&&(void 0===e.textOrientation&&(e.textOrientation="horizontal"),void 0===e.extendLine&&(e.extendLine=!1));const t=new n.DefaultProperty({defaultName:"linetoolvertline",state:e});return this._configureProperties(t),t}_normalizePoint(e){var t;const i=null!==(t=this._model.timeScale().indexToTimePoint(e.index))&&void 0!==t?t:this._utcTimeInCurrentResolution(e);return null!==i?{price:e.price,time_t:i,offset:0}:super._normalizePoint(e)}_getAlertPlots(){const e=this._points[0],t={index:e.index,price:e.price+1},i=this._linePointsToAlertPlot([e,t],null,!0,!0);return null===i?[]:[i]}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(36914),i.e(47495),i.e(30154),i.e(82375),i.e(18537)]).then(i.bind(i,480262)).then((e=>e.VerticalLineDefinitionsViewModel))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}static _configureProperties(e){super._configureProperties(e),e.hasChild("text")||e.addChild("text",new o.Property("")),e.addExcludedKey("text",1)}_additionalCursorData(){return(0,s.ensureDefined)(this._verticalLinePaneViews.get((0,s.ensureNotNull)(this._model.paneForSource(this)))).additionalCursorData()}_positionToCoordinate(e){return(0,s.ensureDefined)(this._verticalLinePaneViews.get((0,s.ensureNotNull)(this._model.paneForSource(this)))).positionToCoordinate(e)}}},917180:(e,t,i)=>{i.d(t,{unpackNonSeriesData:()=>l});var s=i(130551),r=i(650151);function n(e){if(!(0,s.isObject)(e))throw new Error("Graphics commands should be wrapped in an object");if((0,s.hasProperty)(e,"create"),(0,s.hasProperty)(e,"erase")){const t=e.erase;(0,r.assert)(Array.isArray(t),"Collection of erase commands should be array");for(const e of t){if(!(0,s.isObject)(e)||!(0,s.hasProperty)(e,"action"))throw new Error("Command should be an object with 'action' property");(0,r.assert)("all"===e.action||"one"===e.action,"Erase command action should be 'all' or 'one'")}}return e}async function o(e){{const[{inflateZlib:t,inflateRaw:s},{unpackImpl:r}]=await Promise.all(["function"==typeof DecompressionStream?i.e(95465).then(i.bind(i,854718)):Promise.all([i.e(84069),i.e(82170)]).then(i.bind(i,840940)),i.e(95465).then(i.bind(i,851925))]);return r(t,s,e)}}async function l(e){if(""===e)return null;const t=JSON.parse(e);if(!(0,s.isObject)(t)||"function"==typeof t)throw new Error("Non-object content in the non-series envelope");if((0,s.hasProperty)(t,"indexes_replace"))return{indexes_replace:!0};const i={indexes_replace:!1};if((0,s.hasProperty)(t,"offsets")&&(i.offsets=t.offsets),(0,s.hasProperty)(t,"isUpdate")){if("boolean"!=typeof t.isUpdate)throw new Error('Invalid type of "isUpdate" field');i.isUpdate=t.isUpdate}return(0,s.hasProperty)(t,"data")&&(i.data=t.data),(0,s.hasProperty)(t,"graphicsCmds")&&(i.graphicsCmds=n(t.graphicsCmds)),(0, s.hasProperty)(t,"dataCompressed")&&(i.data=await o(t.dataCompressed)),(0,s.hasProperty)(t,"graphicsCmdsCompressed")&&(i.graphicsCmds=n(await o(t.graphicsCmdsCompressed))),i}},60897:(e,t,i)=>{i.d(t,{notAvailable:()=>s});i(444372),i(244842);const s="∅"},948767:(e,t,i)=>{i.d(t,{getNumericFormatter:()=>u,getPercentageFormatter:()=>h,getPipFormatter:()=>_,getVolumeFormatter:()=>d});var s=i(182436),r=i(541346),n=i(181728),o=i(624444);class l extends o.PriceFormatter{constructor(e){const{priceScale:t,minMove:i=1,type:s,typespecs:r,minMove2:o,ignoreLocaleNumberFormat:l}=e;("forex"===s||(0,n.isCFDSymbol)(s,r))&&o?(super({priceScale:o,ignoreLocaleNumberFormat:l}),this._isForex=!0):(super({priceScale:1,ignoreLocaleNumberFormat:l}),this._isForex=!1),this._pipPriceScale=t,this._pipMinMove=i,this._pipMinMove2=o}format(e,t={}){const{signPositive:i,tailSize:s,ignoreLocaleNumberFormat:r}=t;let n=this._isForex?this._pipMinMove2:this._pipMinMove;return void 0===n&&(n=NaN),super.format(e*this._pipPriceScale/n,{signPositive:i,tailSize:s,ignoreLocaleNumberFormat:r})}}var a=i(943994);function c(e){const t=new Map;return i=>{const s=null!=i?i:-1;let r=t.get(s);return r||(r=e(i),t.set(s,r)),r}}const u=c((e=>new s.NumericFormatter(e))),h=c((e=>new r.PercentageFormatter({priceScale:Math.pow(10,null!=e?e:2),minMove:1}))),d=c((e=>new a.VolumeFormatter({precision:e}))),p=new WeakMap;function _(e){let t=p.get(e);return t||(t=new l({priceScale:e.pricescale,minMove:e.minmov,minMove2:e.minmove2,type:e.type,typespecs:e.typespecs}),p.set(e,t)),t}},742391:(e,t,i)=>{i.d(t,{PanePriceAxisView:()=>n});var s=i(294162);class r{constructor(e){this._priceAxisViewRenderer=null,this._rendererOptions=null,this._align="right",this._textWidthCache=e}setParams(e,t,i,s,r){this._priceAxisViewRenderer=e,this._rendererOptions=t,this._align=r}draw(e,t){null!==this._rendererOptions&&null!==this._priceAxisViewRenderer&&this._priceAxisViewRenderer.draw(e,t,this._rendererOptions,this._textWidthCache,this._align)}hitTest(e,t){var i,s;return void 0===(null===(i=this._priceAxisViewRenderer)||void 0===i?void 0:i.hitTest)?null:null===(s=this._priceAxisViewRenderer)||void 0===s?void 0:s.hitTest(e,t,this._align)}}class n{constructor(e,t,i){this._renderer=null,this._invalidated=!0,this._priceAxisView=e,this._textWidthCache=new s.TextWidthCache(100),this._dataSource=t,this._chartModel=i,this._fontSize=-1,this._panePriceAxisViewRenderer=new r(this._textWidthCache)}update(e){this._invalidated=!0}renderer(e){return this._invalidated&&this._updateImpl(e),this._renderer}_position(){const e=this._chartModel.crossHairSource(),t=this._dataSource===e?e.pane:this._chartModel.paneForSource(this._dataSource);if(null===t)return null;const i=this._priceScale();if(null===i)return null;let s=t.priceScalePosition(i);return"overlay"===s&&(s=t.priceScalePosition(t.defaultPriceScale())),"overlay"===s?null:s}_updateImpl(e){this._renderer=null;const t=this._position();if(null===t)return;const i=this._chartModel.priceAxisRendererOptions();i.fontSize!==this._fontSize&&(this._fontSize=i.fontSize, this._textWidthCache.reset()),this._panePriceAxisViewRenderer.setParams(this._priceAxisView.paneRenderer(),i,e.mediaSize.width,e.mediaSize.height,t),this._renderer=this._panePriceAxisViewRenderer,this._invalidated=!1}_priceScale(){return this._dataSource.priceScale()}}},57372:(e,t,i)=>{i.d(t,{AreaBackgroundItem:()=>a,AreaBackgroundItemsGroup:()=>o,AreaBackgroundRenderer:()=>c,CachedMap:()=>l});var s=i(650151),r=i(43192),n=i(632739);class o extends n.CachedContainer{constructor(e){super(),this.color=e}}class l{constructor(){this._map=new Map,this._usedKeys=new Set,this._invalidations=0}invalidateCache(){this._invalidations+=1,50===this._invalidations&&(this._deleteUnused(),this._invalidations=0),this._usedKeys.clear(),this._map.forEach(((e,t)=>e.invalidateCache()))}get(e){const t=this._map.get(e);return void 0!==t&&this._usedKeys.add(e),t}set(e,t){this._usedKeys.add(e),this._map.set(e,t)}[Symbol.iterator](){const e=Array.from(this._usedKeys)[Symbol.iterator]();return{[Symbol.iterator](){return this},next:()=>{const t=e.next();return t.value?{value:[t.value,(0,s.ensureDefined)(this._map.get(t.value))],done:!1}:{value:void 0,done:!0}}}}forEach(e){this._map.forEach(((t,i)=>{this._usedKeys.has(i)&&e(t,i)}))}delete(e){const t=this._map.get(e);void 0!==t&&t.invalidateCache(),this._usedKeys.delete(e)}_deleteUnused(){const e=[];this._map.forEach(((t,i)=>{this._usedKeys.has(i)||e.push(i)}));for(const t of e)this._map.delete(t)}}class a extends n.CachedContainer{constructor(){super(),this.points1=new n.CachedContainer,this.points2=new n.CachedContainer,this.push(this.points1),this.push(this.points2)}addPoints1Point(e,t){let i=this.points1.newItem();null!==i?(i.x=e,i.y=t):i={x:e,y:t},this.points1.push(i)}addPoints2Point(e,t){let i=this.points2.newItem();null!==i?(i.x=e,i.y=t):i={x:e,y:t},this.points2.push(i)}invalidateCache(){this.points1.invalidateCache(),this.points2.invalidateCache()}}class c extends r.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._data=null!=e?e:null}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){var t,i;if(null===this._data)return;const{context:s,horizontalPixelRatio:r,verticalPixelRatio:n}=e,o=.25*this._data.barSpacing;for(const[,e]of this._data.colorAreas){s.beginPath();for(let t=0;t{i.d(t,{PaneRendererArea:()=>o});var s=i(879617),r=i(9640),n=i(787123);class o extends s.PaneRendererLine{constructor(e){e.forceLineColor=!1,super(e)}_drawImpl(e){var t,i,o,l,a;const c=this._data;if(0===c.items.length)return;let u=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,h=(null!==(l=null===(o=this._data.visibleItemsRange)||void 0===o?void 0:o.endItemIndex)&&void 0!==l?l:this._data.items.length)-1;for(;u=0&&!(0,r.coordinateIsValid)(c.items[h].y);)h--;if(u>h)return;const{context:d,horizontalPixelRatio:p,verticalPixelRatio:_}=e;d.save(),d.scale(p,_),d.lineCap="round",d.strokeStyle=c.lineColor,d.lineWidth=c.lineWidth,(0,n.setLineStyle)(d,c.lineStyle),d.lineWidth=1;const f={},m=new s.PaneRendererLineItemsIterator(this._data.items,u,h+1,this._data.skipHoles);for(;m.next();){const e=m.currentValue();let t;t=(0,s.isValidPoint)(e)&&e.style?e.style.color:c.lineColor;const i=m.nextValue();if((0,s.isValidPoint)(i)&&(null==i?void 0:i.style)){const s=i.style.color;if(t!==s){const t=f[s]||[];t.push(e),f[s]=t}}const r=f[t]||[];r.push(e),f[t]=r}for(const e of Object.keys(f)){const t=f[e];d.beginPath();let i=0;for(let r=0;r{i.d(t,{BitmapCoordinatesPaneRenderer:()=>r});var s=i(743068);class r{draw(e,t){new s.CanvasRenderingTarget2D(e,t.mediaSize,t.bitmapSize).useBitmapCoordinateSpace((e=>this._drawImpl(e)))}drawBackground(e,t){new s.CanvasRenderingTarget2D(e,t.mediaSize,t.bitmapSize).useBitmapCoordinateSpace((e=>this._drawBackgroundImpl(e)))}_drawBackgroundImpl(e){}}},142119:(e,t,i)=>{i.d(t,{CompositeRenderer:()=>s});class s{constructor(){this._renderers=[],this._globalAlpha=1}setGlobalAlpha(e){this._globalAlpha=e}append(e){this._renderers.push(e)}insert(e,t){this._renderers.splice(t,0,e)}clear(){this._renderers.length=0}isEmpty(){return 0===this._renderers.length}draw(e,t){for(let i=0;i=0;s--){const r=this._renderers[s].hitTest(e,t);null!==r&&(null===i||r.target()>i.target())&&(i=r)}return i} doesIntersectWithBox(e,t){return this._renderers.some((i=>!!i.doesIntersectWithBox&&i.doesIntersectWithBox(e,t)))}}},787123:(e,t,i)=>{i.r(t),i.d(t,{addHorizontalLineToPath:()=>h,addLineToPath:()=>w,addPixelPerfectLineToPath:()=>I,addVerticalLineToPath:()=>p,clearRectWithGradient:()=>c,clipPolygonByEdge:()=>M,computeDashPattern:()=>C,createCircle:()=>S,drawHorizontalLine:()=>d,drawLine:()=>T,drawPixelPerfectLine:()=>V,drawPoly:()=>b,drawRoundRect:()=>v,drawRoundRectWithInnerBorder:()=>g,drawVerticalLine:()=>_,fillRectInnerBorder:()=>u,fillRectWithBorder:()=>y,scaleDrawRoundRectRadii:()=>f,scaledDashPattern:()=>P,setLineStyle:()=>x});var s=i(86441),r=i(5531),n=i(458963),o=i(379048),l=i(199471),a=i(510147);function c(e,t,i,s,r,n,o){e.save(),e.globalCompositeOperation="copy";const l=e.createLinearGradient(0,0,0,r);l.addColorStop(0,n),l.addColorStop(1,o),e.fillStyle=l,e.fillRect(t,i,s,r),e.restore()}function u(e,t,i,s,r,n){e.fillRect(t+n,i,s-2*n,n),e.fillRect(t+n,i+r-n,s-2*n,n),e.fillRect(t,i,n,r),e.fillRect(t+s-n,i,n,r)}function h(e,t,i,s){const r=e.lineWidth%2?.5:0;e.moveTo(i,t+r),e.lineTo(s,t+r)}function d(e,t,i,s){e.beginPath(),h(e,t,i,s),e.stroke()}function p(e,t,i,s){const r=e.lineWidth%2?.5:0;e.moveTo(t+r,i),e.lineTo(t+r,s)}function _(e,t,i,s){e.beginPath(),p(e,t,i,s),e.stroke()}function f(e,t){return Array.isArray(e)?e.map((e=>Math.round(e*t))):Math.round(e*t)}function m(e,t){return Array.isArray(e)?e.map((e=>0===e?e:e+t)):e+t}function v(e,t,i,s,r,n,o){let l,a,c,u;if(Array.isArray(n))if(2===n.length){const e=Math.max(0,n[0]),t=Math.max(0,n[1]);l=e,a=e,c=t,u=t}else{if(4!==n.length)throw new Error("Wrong border radius - it should be like css border radius");l=Math.max(0,n[0]),a=Math.max(0,n[1]),c=Math.max(0,n[2]),u=Math.max(0,n[3])}else{const e=Math.max(0,n);l=e,a=e,c=e,u=e}o||e.beginPath(),e.moveTo(t+l,i),e.lineTo(t+s-a,i),0!==a&&e.arcTo(t+s,i,t+s,i+a,a),e.lineTo(t+s,i+r-c),0!==c&&e.arcTo(t+s,i+r,t+s-c,i+r,c),e.lineTo(t+u,i+r),0!==u&&e.arcTo(t,i+r,t,i+r-u,u),e.lineTo(t,i+l),0!==l&&e.arcTo(t,i,t+l,i,l)}function g(e,t,i,s,r,n,l=0,a=0,c="",u=o.LineStyle.Solid){if(e.save(),!a||!c||c===n)return v(e,t,i,s,r,l),e.fillStyle=n,e.fill(),void e.restore();const h=a/2;if("transparent"!==n){const h="transparent"!==c&&u!==o.LineStyle.Solid;v(e,h?t:t+a,h?i:i+a,h?s:s-2*a,h?r:r-2*a,h?l:m(l,-a)),e.fillStyle=n,e.fill()}if("transparent"!==c){v(e,t+h,i+h,s-a,r-a,m(l,-h)),e.lineWidth=a,e.strokeStyle=c,x(e,u),e.closePath(),e.stroke()}e.restore()}function P(e,t){return t=Math.max(1,t),e.map((e=>e*t))}function y(e,t,i,s,r,o,a,c,u){const{context:h}=e,p=o%2/2,_=t+p,f=s+p;let m,v;if(c){const{borderMode:e,borderWidth:l,color:a,dashPattern:u,lineStyle:d}=c;switch(e){case"outer":{const e=-o/2-l/2,t=-l/2;v={left:_+e,right:f-e,top:i+t,bottom:r-t};break}case"center":{const e=l%2/2;v={left:t+e,right:s+e,top:i+e,bottom:r+e};break}case"inner":{const e=-o/2+l/2,t=l/2;v={left:_+e,right:f-e,top:i+t,bottom:r-t}}}h.strokeStyle=a,h.lineWidth=l;let p=-1;u?h.setLineDash(P(u,l)):void 0!==d&&(x(h,d),d===n.LINESTYLE_SOLID&&(p=1)),m={left:v.left+p*l/2, top:v.top+p*l/2,right:v.right-p*l/2,bottom:v.bottom-p*l/2}}if(a&&(h.fillStyle=a.color,m||(m={left:_-o/2,right:f+o/2,top:i,bottom:r}),h.fillRect(m.left,m.top,m.right-m.left,m.bottom-m.top)),u){const{lineWidth:n,lineColor:o,lineStyle:a,excludeBoundaries:c}=u;h.save(),h.lineCap="butt",h.lineWidth=n,h.strokeStyle=o,x(h,a);const p=()=>d(h,Math.floor((i+r)/2),t,s);c?(0,l.drawWithExclusionAreaByScope)(e,c,p):p(),h.restore()}v&&h.strokeRect(v.left,v.top,v.right-v.left,v.bottom-v.top)}function S(e,t,i,s){e.beginPath(),e.arc(t,i,s,0,2*Math.PI,!1),e.closePath()}function b(e,t,i){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(const i of t)e.lineTo(i.x,i.y);e.closePath(),e.stroke(),i&&e.fill()}function x(e,t){let i=[];t!==n.LINESTYLE_SOLID&&(i=C(e.lineWidth,t)),e.setLineDash(i)}function C(e,t){return[[e,2*e],[5*e,6*e],[6*e,6*e],[e,4*e],[2*e,e]][t-1]}function w(e,t,i,s,r){e.moveTo(t,i),e.lineTo(s,r)}function T(e,t,i,s,r){isFinite(t)&&isFinite(s)&&isFinite(i)&&isFinite(r)&&(e.beginPath(),w(e,t,i,s,r),e.stroke())}function I(e,t,i,s,r,n){const{horizontalPixelRatio:o,verticalPixelRatio:l}=n;t===s?p(e,Math.round(t*o),i*l,r*l):i===r?h(e,Math.round(i*l),t*o,s*o):w(e,t*o,i*l,s*o,r*l)}function V(e,t,i,s,r,n=a.dpr1PixelRatioInfo){e.beginPath(),I(e,t,i,s,r,n),e.stroke()}function M(e,t,i,n){const o=(0,s.equalPoints)(i,n[0])?(0,s.equalPoints)(i,n[1])?null:n[1]:n[0];return null!==e&&null!==o?(0,r.intersectPolygonAndHalfplane)(e,(0,s.halfplaneThroughPoint)((0,s.lineThroughPoints)(t,i),o)):null}},9640:(e,t,i)=>{i.d(t,{coordinateIsValid:()=>m,extendAndClipLineSegment:()=>u,fillScaledRadius:()=>g,getArrowPoints:()=>h,interactionTolerance:()=>f,optimalBarWidth:()=>d,optimalCandlestickWidth:()=>p,optimalHiLoWidth:()=>_,setValidLineStyle:()=>v,strokeScaledRadius:()=>P});var s=i(86441),r=i(5531),n=i(86121),o=i(389137),l=i(787123);const a={common:13,line:13,minDistanceBetweenPoints:10,series:14,curve:10,anchor:13,esd:4},c={common:3,line:3,minDistanceBetweenPoints:5,series:2,curve:3,anchor:2,esd:0};function u(e,t,i,n,o,l){if((0,s.equalPoints)(e,t))return null;const a=new s.Point(0,0),c=new s.Point(i,n);if(o){if(l){const i=(0,r.intersectLineAndBox)((0,s.lineThroughPoints)(e,t),(0,s.box)(a,c));return Array.isArray(i)?i:null}{const i=(0,r.intersectRayAndBox)(t,e,(0,s.box)(a,c));return null===i||(0,s.equalPoints)(t,i)?null:(0,s.lineSegment)(t,i)}}if(l){const i=(0,r.intersectRayAndBox)(e,t,(0,s.box)(a,c));return null===i||(0,s.equalPoints)(e,i)?null:(0,s.lineSegment)(e,i)}{const i=(0,r.intersectLineSegmentAndBox)((0,s.lineSegment)(e,t),(0,s.box)(a,c));return Array.isArray(i)?i:null}}function h(e,t,i,s,r){const n=.5*i,o=Math.sqrt(2),l=t.subtract(e),a=l.normalized();let c=5*i;s&&(c=Math.min(c,.35*l.length()));const u=1*n;if(c*o*.2<=u)return[];const h=a.scaled(c),d=t.subtract(h),p=a.transposed(),_=1*c,f=p.scaled(_),m=d.add(f),v=d.subtract(f),g=m.subtract(t).normalized().scaled(u),P=v.subtract(t).normalized().scaled(u),y=r?t:t.add(g),S=r?t:t.add(P),b=n*(o-1),x=p.scaled(b),C=Math.min(c-1*n/o,n*o*1),w=a.scaled(C),T=t.subtract(x),I=t.add(x),V=t.subtract(w) ;return[[m,y],[S,v],[T,V.subtract(x)],[I,V.add(x)]]}function d(e,t){return t=t||1,Math.floor(.3*e*t)}function p(e,t){if(e>=2.5&&e<=4)return Math.floor(3*t);const i=1-.2*Math.atan(Math.max(4,e)-4)/(.5*Math.PI),s=Math.floor(e*i*t),r=Math.floor(e*t),n=Math.min(s,r);return Math.max(Math.floor(t),n)}function _(e){return.4*e}function f(){return(0,n.lastMouseOrTouchEventInfo)().isTouch?a:c}function m(e){return null!=e&&!(0,o.isNaN)(e)}function v(e,t){void 0!==t&&(0,l.setLineStyle)(e,t)}function g(e,t){const i=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+i}function P(e,t,i){const s=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+(s!==i%2?.5:0)}},9524:(e,t,i)=>{i.d(t,{HorizontalLineRenderer:()=>a});var s=i(315801),r=i(787123),n=i(9640),o=i(43192),l=i(199471);class a extends o.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._hitTest=new s.HitTestResult(s.HitTarget.Regular)}setData(e){this._data=e}setHitTest(e){this._hitTest=e}hitTest(e){if(null===this._data||!1===this._data.visible||null===this._hitTest)return null;const t=(0,n.interactionTolerance)().line,i=Math.abs(e.y-this._data.y)<=t+this._data.linewidth/2,s=void 0===this._data.left||this._data.left-e.x<=t,r=void 0===this._data.right||e.x-this._data.right<=t;return i&&s&&r?this._hitTest:null}_drawImpl(e){if(null===this._data||!1===this._data.visible)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,mediaSize:n}=e;if(this._data.y<-this._data.linewidth/2||this._data.y>n.height+this._data.linewidth/2)return;t.lineCap="butt",t.strokeStyle=this._data.color,t.lineWidth=Math.max(1,Math.floor(this._data.linewidth*i)),void 0!==this._data.linestyle&&(0,r.setLineStyle)(t,this._data.linestyle);const o=void 0!==this._data.left?Math.max(this._data.left,0):0,a=void 0!==this._data.right?Math.min(this._data.right,n.width):n.width,c=Math.round(this._data.y*s),u=Math.round(o*i),h=Math.round(a*i),d=this._data.excludeBoundaries;void 0!==d&&(0,l.addExclusionAreaByScope)(e,d),(0,r.drawHorizontalLine)(t,c,u,h)}}},879617:(e,t,i)=>{i.d(t,{PaneRendererLine:()=>p,PaneRendererLineItemsIterator:()=>d,isValidPoint:()=>h});var s=i(650151),r=i(86441),n=i(204652),o=i(315801),l=i(9640),a=i(787123),c=i(43192);const u={y:NaN};function h(e){return null!==e&&!isNaN(e.y)}class d{constructor(e,t,i,r){this._calculatedPrev={index:null,currentBreakProcessed:!1,value:null},this._calculatedCurrent={index:null,currentBreakProcessed:!1,value:null},this._calculatedNext={index:null,currentBreakProcessed:!1,value:null},this._preallocatedVariable={index:null,currentBreakProcessed:!1,value:null},e.length&&((0,s.assert)(t<=i,"First index must be less or equal to last index"),(0,s.assert)(t2;){const t=Math.round((h+u)/2);this._data.items[t].center<=e.x?u=t:h=t}u=Math.max(1,u-1),h=Math.min(this._data.items.length-1,h+1) ;for(let t=u;t<=h;++t){const i=this._data.items[t-1],s=this._data.items[t],l=i.center,a=s.center;if((0,n.distanceToSegment)(new r.Point(l,i.y),new r.Point(a,s.y),new r.Point(e.x,e.y)).distance<=c)return this._data.hittest?this._data.hittest:new o.HitTestResult(o.HitTarget.Regular)}return null}_drawImpl(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;t.scale(i,s),t.lineCap="round",t.lineJoin="round",t.strokeStyle=this._data.lineColor,t.fillStyle=this._data.lineColor,t.lineWidth=this._data.lineWidth,(0,a.setLineStyle)(t,this._data.lineStyle),(0,l.setValidLineStyle)(t,this._data.lineStyle),this._data.simpleMode?this._drawSimpleMode(t,i,s):this._drawLines(t)}_drawSimpleMode(e,t,i){var s,r,n,o;e.beginPath(),this._walkLine(e,this._data.items,!1,NaN),e.stroke();const l=this._data.lineWidth+2;if(this._data.withMarkers&&2*l=h;){const r=this._data.items[s];if(r){const s=Math.round(r.center*t)+a,n=r.y*i;e.moveTo(s,n),e.arc(s,n,c,0,u)}}e.fill()}}_walkLine(e,t,i,s,r){var n,o,l,a;if(!t)return;const c=.25*this._data.barSpacing;let u,p,_=null;const f=r?0:null!==(o=null===(n=this._data.visibleItemsRange)||void 0===n?void 0:n.startItemIndex)&&void 0!==o?o:0,m=r?t.length:Math.min(null!==(a=null===(l=this._data.visibleItemsRange)||void 0===l?void 0:l.endItemIndex)&&void 0!==a?a:t.length,t.length);if(f>m||f>=t.length)return;const v=new d(t,f,m,this._data.skipHoles);for(;v.next();){if(u=v.currentValue(),p=v.nextValue(),h(u)){const t=Math.round(u.center);_&&h(_)?(e.lineTo(t,u.y),i&&!h(p)&&e.lineTo(t,s)):p&&h(p)?i?(v.atStart()||e.lineTo(t,s),e.lineTo(t,u.y)):e.moveTo(t,u.y):i?(v.atStart()||e.lineTo(t-c,s),e.lineTo(t-c,u.y),e.lineTo(t+c,u.y),e.lineTo(t+c,s)):(e.moveTo(t-c,u.y),e.lineTo(t+c,u.y))}_=u}}_drawLines(e){var t,i,s,r;if(!this._data.items.length)return;let n,o,a=null;const c=.25*this._data.barSpacing;e.beginPath();const u=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,p=null!==(r=null===(s=this._data.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:this._data.items.length;if(u>p||u>=this._data.items.length)return;const _=this._data.items[u];_&&e.moveTo(_.center,_.y);let f,m=e.strokeStyle,v=e.lineWidth;const g=new d(this._data.items,u,p,this._data.skipHoles);for(;g.next();){let t,i,s;a=g.prevValue(),n=g.currentValue(),o=g.nextValue();let r=!1;if(h(n)&&(n.style&&!this._data.forceLineColor?(t=n.style.color,i=n.style.width,s=n.style.style):(t=this._data.lineColor,i=this._data.lineWidth,s=this._data.lineStyle),this._data.ignorePaletteLineWidth&&(i=this._data.lineWidth),r=t!==m||i!==v||s!==f),r)if(m=t,v=i,f=s,e.stroke(),e.beginPath(),e.strokeStyle=t,e.lineWidth=i,(0, l.setValidLineStyle)(e,s),h(a))e.moveTo(a.center,a.y);else{const t=n;e.moveTo(t.center,t.y)}P=a,S=o,h(y=n)&&(h(P)?e.lineTo(y.center,y.y):S&&h(S)?e.moveTo(y.center,y.y):(e.moveTo(y.center-c,y.y),e.lineTo(y.center+c,y.y)))}var P,y,S;e.stroke()}}},710455:(e,t,i)=>{i.d(t,{MediaCoordinatesPaneRenderer:()=>r});var s=i(743068);class r{draw(e,t){new s.CanvasRenderingTarget2D(e,t.mediaSize,t.bitmapSize).useMediaCoordinateSpace((e=>this._drawImpl(e)))}drawBackground(e,t){new s.CanvasRenderingTarget2D(e,t.mediaSize,t.bitmapSize).useMediaCoordinateSpace((e=>this._drawBackgroundImpl(e)))}_drawBackgroundImpl(e){}}},632739:(e,t,i)=>{i.d(t,{CachedContainer:()=>r,ObjectValuesCache:()=>n});class s{constructor(e,t,i,s){this._items=e,this._actualLength=t,this._step=s?-1:1,this._currentIndex=i-this._step}[Symbol.iterator](){return this}next(){return this._currentIndex+=this._step,this._currentIndex>=this._actualLength||this._currentIndex<0?{value:void 0,done:!0}:{done:!1,value:this._items[this._currentIndex]}}}class r{constructor(){this._items=[],this._actualLength=0,this._invalidations=0}push(e){this._items.length===this._actualLength?this._items.push(e):this._items[this._actualLength]!==e&&(this._items[this._actualLength]=e),this._actualLength+=1}newItem(){const e=this._items.length>this._actualLength?this._items[this._actualLength]:null;return null!==e&&Boolean(e.invalidateCache)&&e.invalidateCache(),e}invalidateCache(){this._invalidations+=1,3e3===this._invalidations&&(this._items.splice(this._actualLength),this._invalidations=0),this._actualLength=0}at(e){return this._items[e]}data(){return this._items}length(){return this._actualLength}isEmpty(){return 0===this._actualLength}iterator(e,t){return new s(this._items,this._actualLength,e,t)}}class n extends r{constructor(){super(...arguments),this._startIndex=0}setStartIndex(e){this._startIndex=e}isValidIndex(e){return e>=this._startIndex}at(e){const t=e-this._startIndex;for(;t>=this._actualLength;)this._items.length<=t?this._items.push(this._newObject()):this._clearObject(this._items[this._actualLength]),this._actualLength+=1;return this._items[t]}}},500477:(e,t,i)=>{i.d(t,{svgRenderer:()=>T});var s=i(650151),r=i(201089);const n=(0,r.getLogger)("Chart.SvgParser");function o(e,t){const i=e.split(/[,\s]/).map((e=>parseFloat(e.trim())));let s=0;for(const e of i){if(!Number.isFinite(e)&&s(0,s.ensureDefined)(t.getStyle(e,i)):e=>n}const o=e.getAttribute("stroke");if(null!==o){const e=d(o);r.getStrokeStyle=null!==e?i=>(0,s.ensureDefined)(t.getStyle(e,i)):e=>o}const l=u(e,"stroke-width");Number.isFinite(l)&&(r.strokeWidth=l);const c=u(e,"opacity");Number.isFinite(c)&&(r.fillOpacity=c,r.strokeOpacity=c);const h=u(e,"stroke-opacity");Number.isFinite(h)&&(r.strokeOpacity=h);const p=u(e,"fill-opacity");if(Number.isFinite(p)&&(r.fillOpacity=p),i){const t=a(e);null!==t&&(r.transform=t)}return r}class _{constructor(e){this._transformOperations=e}apply(e,t){null!==this._transformOperations?(e.save(),c(e,this._transformOperations)):e.restore()}}class f{constructor(e,t,i){this._styleData={...i,...p(e,t,!0)}}apply(e,t){if(!this._isValid())return;const{getFillStyle:i,getStrokeStyle:s,strokeWidth:r,transform:n,strokeOpacity:o,fillOpacity:l}=this._styleData,a=void 0!==n||void 0!==o||void 0!==l;a&&(e.save(),void 0!==n&&c(e,n)),this._render(e);const u=null==i?void 0:i(e);"none"!==u&&(t.doNotApplyColors||(void 0!==l&&(e.globalAlpha=l),e.fillStyle=null!=u?u:"black"),this._fill(e));const h=null==s?void 0:s(e);void 0!==h&&"none"!==h&&(void 0!==r&&(e.lineWidth=r),t.doNotApplyColors||(void 0!==l&&(e.globalAlpha=l),e.strokeStyle=h),this._stroke(e)),a&&e.restore()}_fill(e){e.fill()}_stroke(e){e.stroke()}}class m extends f{constructor(e,t,i){var s;super(e,t,i);const r=e.getAttribute("d");this._path=null!==r?new Path2D(r):null,this._fillRule=null!==(s=e.getAttribute("fill-rule"))&&void 0!==s?s:void 0}_fill(e){e.fill((0,s.ensureNotNull)(this._path),this._fillRule)}_stroke(e){e.stroke((0,s.ensureNotNull)(this._path))}_render(e){}_isValid(){return null!==this._path}}class v extends f{constructor(e,t,i){super(e,t,i),this._cx=u(e,"cx"),this._cy=u(e,"cy"),this._r=u(e,"r")}_render(e){e.beginPath(),e.arc(this._cx,this._cy,this._r,0,2*Math.PI)}_isValid(){return Number.isFinite(this._cx)&&Number.isFinite(this._cy)&&Number.isFinite(this._r)}}class g extends f{constructor(e,t,i){super(e,t,i),this._cx=u(e,"cx"),this._cy=u(e,"cy"),this._rx=u(e,"rx"),this._ry=u(e,"ry")}_render(e){e.beginPath(),e.ellipse(this._cx,this._cy,this._rx,this._ry,0,0,2*Math.PI)}_isValid(){return Number.isFinite(this._cx)&&Number.isFinite(this._cy)&&Number.isFinite(this._rx)&&Number.isFinite(this._ry)}}class P{constructor(e){this._originalViewBox=e }apply(e,t){const i=t.targetViewBox;e.translate(i.x,i.y),e.scale(i.width/this._originalViewBox.width,i.height/this._originalViewBox.height),e.beginPath(),e.rect(0,0,this._originalViewBox.width,this._originalViewBox.height),e.clip(),e.translate(-this._originalViewBox.x,-this._originalViewBox.y)}}const y=(0,r.getLogger)("Chart.SvgParser");function S(e){const t=e.getAttribute("gradientUnits");if("objectBoundingBox"===t)return void y.logWarn(`Unsupported linearGradient gradientUnits: ${t}`);const i=[],s=e.getElementsByTagName("stop");for(let e=0;e{const t=e.createLinearGradient(r,n,o,l);for(const e of i)t.addColorStop(e[0],e[1]);return t}}const b=(0,r.getLogger)("Chart.SvgParser");const x=new DOMParser,C=(0,r.getLogger)("Chart.SvgParser");function w(e,t,i,s){var r;const n=e.children;let o,l=s;"g"!==e.tagName&&"svg"!==e.tagName||(l={...l,...p(e,i,!1)},o=null!==(r=a(e))&&void 0!==r?r:void 0),void 0!==o&&t.push(new _(o));for(let e=0;e{}};const a=r.getElementsByTagName("defs");return a.length>0&&(l=function(e){const t={},i=e.children;for(let e=0;e{const r=t[e];if(!r)return;let n=s.get(i);void 0===n&&(n=new Map,s.set(i,n));const o=n.get(e);if(void 0!==o)return o;const l=r(i);return n.set(e,l),l}}}(a[0])),w(r,i,l),{viewBox:()=>o,render:(e,t)=>{e.save();for(const s of i)s.apply(e,t);e.restore()}}}},627172:(e,t,i)=>{i.d(t,{PaneRendererStepLine:()=>m,StepLineDecoration:()=>s});var s,r=i(204652),n=i(86441),o=i(246733),l=i(315801),a=i(9640),c=i(787123),u=i(43192),h=i(879617);!function(e){e[e.None=0]="None",e[e.Diamonds=1]="Diamonds"}(s||(s={}));class d{constructor(e){this._forceExtendFirstBar=!!e}initialize(e,t,i){var s,r,n,o;const{context:l,horizontalPixelRatio:a,verticalPixelRatio:u}=t,h=e.lineStyle;l.lineCap="butt",l.lineJoin="round";const d=Math.max(Math.floor(null!==(r=null===(s=i.style)||void 0===s?void 0:s.width)&&void 0!==r?r:e.lineWidth*a));void 0!==h&&(0,c.setLineStyle)(l,h);const p=d%2?.5:0;l.moveTo(Math.round(i.center*a)+p,Math.round(i.y*u)+p),l.strokeStyle=null!==(o=null===(n=i.style)||void 0===n?void 0:n.color)&&void 0!==o?o:e.lineColor,l.lineWidth=d}startFragment(e,t,i,s){e.beginPath() ;const r=i.firstItem&&i.extendToBarsEndings?t.center:t.left;e.moveTo(isNaN(r)?-50:r,t.y)}finishFragment(e,t,i){t&&i&&e.lineTo(t.left,i.y),e.stroke()}hitTest(e,t,i,s){var o,l;if(!(0,h.isValidPoint)(t))return!1;const c=null!==(l=null===(o=t.style)||void 0===o?void 0:o.width)&&void 0!==l?l:e.lineWidth,u=(0,a.interactionTolerance)().series+c/2,{left:d,y:p}=t,_=isNaN(d)?-50:d;let f,m;return i&&(0,h.isValidPoint)(i)?(f=i.left,m=i.y):(f=t.right,m=t.y),!(_s.x+u&&f>s.x+u)&&((0,r.distanceToSegment)((0,n.point)(_,p),(0,n.point)(f,p),s).distancethis._drawDecorationItem(e,t)))}_drawDecorationItem(e,t){var i,s,r,n,o,l,a,c,u,d;if(null===this._data||0===this._data.items.length)return;const{lineWidth:p,lineColor:_,items:f,visibleItemsRange:m,skipHoles:v,extendToBarsEndings:g}=this._data,{context:P,horizontalPixelRatio:y,verticalPixelRatio:S}=e;let b=Math.max(Math.floor((null!==(s=null===(i=f[0].style)||void 0===i?void 0:i.width)&&void 0!==s?s:p)*y)),x=b%2?.5:0;t.initialize(this._data,e,f[0]);const C=null!==(r=null==m?void 0:m.startItemIndex)&&void 0!==r?r:0,w=null!==(n=null==m?void 0:m.endItemIndex)&&void 0!==n?n:f.length;if(w<=C)return;let T,I,V;P.beginPath(),t.applyColor(P,null!==(l=null===(o=f[C].style)||void 0===o?void 0:o.color)&&void 0!==l?l:_),t.applyLineWidth(P,b);let M=!1;const A=new h.PaneRendererLineItemsIterator(f,C,w,v);for(;A.next();){const i=A.currentValue();if(!(0,h.isValidPoint)(i)){T=void 0,M=!0;continue}const s=null!==(c=null===(a=i.style)||void 0===a?void 0:a.color)&&void 0!==c?c:_,r=null!==(d=null===(u=i.style)||void 0===u?void 0:u.width)&&void 0!==d?d:p,n=s!==I,o=r!==V,l={firstItem:A.currentValueIsFirst(),lastItem:A.currentValueIsLast(),extendToBarsEndings:g,valIsNotSameAsPrev:i.valIsNotSameAsPrev},f={y:Math.round(i.y*S)+x,left:Math.round(i.left*y)+x,center:Math.round(i.center*y)+x,right:Math.round(i.right*y)+x};(n||o||M)&&(I&&V&&t.finishFragment(P,f,T),n&&t.applyColor(P,s),o&&(b=Math.max(1,Math.floor(r*y)),x=b%2?.5:0,t.applyLineWidth(P,b)),t.startFragment(P,f,l,T),M=!1,I=s,V=r),t.drawItem(e,f,l,T),T=f}t.finishFragment(P)}}},888929:(e,t,i)=>{i.d(t,{sortSources:()=>r,sortSourcesPreOrdered:()=>s});const s={LatestUpdates:10000001,BarMarks:10000002,TimeScaleMarks:10000003,ChartEventsSource:10000004,Dividends:10000005,Splits:10000006,Earnings:10000007,RollDates:10000008,FutureContractExpiration:10000009,LineToolOrder:10000010,LineToolPosition:10000011,LineToolExecution:10000012,AlertLabelInactive:10000013,AlertLabel:10000014};function r(e,t){if(0===e.length)return[];if(!t)return[...e].sort(((e,t)=>e.zorder()-t.zorder()));if(!(t.model().mainPane()===t))return[...e].sort(((e,t)=>e.zorder()-t.zorder()));const i=t.model().panes(),s=i.indexOf(t),r=e=>i.findIndex((t=>t.hasDataSource(e)));return e.map((e=>{const i=!t.hasDataSource(e);return{source:e,isMultipane:i,aboveSeries:e.zorder()>t.model().mainSeries().zorder(),paneIndex:i?r(e):s}})).sort(((e,t)=>e.isMultipane||t.isMultipane?e.isMultipane&&!t.isMultipane?t.aboveSeries?-1:1:!e.isMultipane&&t.isMultipane?e.aboveSeries?1:-1:e.paneIndex-t.paneIndex:e.source.zorder()-t.source.zorder())).map((e=>e.source))}},601183:(e,t,i)=>{i.d(t,{PriceAxisViewRenderer:()=>d,hittestByData:()=>h});var s=i(86441),r=i(934026),n=i(86121),o=i(31341),l=i(199471),a=i(315801),c=i(787123) ;const u=new Path2D("M4.09.93c.4.16.75.4 1.02.73a5.47 5.47 0 0 0-3.78 3.27A2.5 2.5 0 0 1 3.2.77c.31 0 .61.06.89.16Zm8.24 3.35a2.5 2.5 0 0 0-3.27-3.23c-.38.16-.7.4-.97.7a5.47 5.47 0 0 1 3.56 3.5c.3-.26.53-.6.68-.97Zm-3.15-.84a4.5 4.5 0 1 0-5.5 7.12 4.5 4.5 0 0 0 5.5-7.12ZM6 4h1v4H4V7h2V4Z");function h(e,t){var i;const o=(0,n.lastMouseOrTouchEventInfo)().isTouch?10:0,l=e.hitTestData;if(void 0===l||!e.visible)return null;const{itemBox:c,clickHandler:u,tooltip:h}=l;if(c){const n=(0,s.box)(new s.Point(c.min.x-o,c.min.y-o),new s.Point(c.max.x+o,c.max.y+o));if((0,r.pointInBox)(t,n))return new a.HitTestResult(null!==(i=e.hitTarget)&&void 0!==i?i:a.HitTarget.Custom,{clickHandler:null==u?void 0:u.bind(null,t),tapHandler:null==u?void 0:u.bind(null,t),hoverModelFromAxis:l.hoverModelFromAxis,activeItem:l.activeItem,tooltip:h})}return null}class d{constructor(e,t){this._bodyBox=null,this.setData(e,t)}setData(e,t){this._data=e,this._commonData=t}lastDrawnBodyBox(){return this._bodyBox}draw(e,t,i,r,n){var a,u,h,d;const p=this._data,{mediaSize:_,bitmapSize:f,horizontalPixelRatio:m,verticalPixelRatio:v}=t;if(!p.visible||this._isOutOfScreen(i,_.height))return;const g=this._commonData,P=void 0!==p.labelIcon,y=i.borderSize,S=i.paddingTop+g.additionalPaddingTop,b=i.paddingBottom+g.additionalPaddingBottom,x=i.paddingInner,C=p.ignoreAdditionalPaddingInner?0:i.additionalPaddingInner,w=i.paddingOuter,T=i.fontSize;let I=p.text,V=p.textColor||g.textColor,M=p.secondLine||"",A=g.secondLineTextColor||V,D=p.thirdLine||"";const L=g.thirdLineTextColor||V;0===M.length&&(M=D,A=L,D=""),0===I.length&&(I=M,V=A,M=D,A=L,D=""),e.save(),void 0!==g.globalAlpha&&(e.globalAlpha*=g.globalAlpha),e.font=i.font;const B=r.yMidCorrection(e,I)*v,R=Math.ceil(r.measureText(e,I)),N=T+S+b,E=(null!==(a=p.labelIconMinWidth)&&void 0!==a?a:0)*m,k=Boolean(M),O=Boolean(D),F=k?Math.ceil(r.measureText(e,M)):0,W=O?Math.ceil(r.measureText(e,D)):0,z=y+x+w+R+C,H=F>0?y+x+w+F+C:0,U=W>0?y+x+w+W+C:0,K=Math.max(z,H,U),G=Math.max(1,Math.floor(v));let j=Math.round(N*v);j%2!=G%2&&(j+=1);const q=Math.round((T+i.lineSpacing)*v),$=Math.round(2*(T+i.lineSpacing)*v),Y=Math.max(1,Math.floor(y*m)),Q=p.separatorVisible?Y:0,X=p.borderVisible?Y:0,Z=P?Math.max(j,E):Math.round(K*m),J=Math.round(C*m),ee=f.width,te=Math.ceil(x*m),ie=Math.round((null!==(u=g.fixedCoordinate)&&void 0!==u?u:g.coordinate)*v)-Math.floor(.5*v),se=Math.floor(ie+G/2-j/2),re=se+j,ne="right"===n,oe=void 0!==p.xCoord?Math.round(p.xCoord*m)+(ne?1:-1)*Math.round(Z/2):ne?ee-Q:Q,le=ee;let ae,ce=oe;const ue=null!==(h=p.backgroung)&&void 0!==h?h:g.background;e.fillStyle=ue;const he=2*v;if(e.textAlign=ne?"right":"left",e.textBaseline="middle",ne?(ce=oe-Z,ae=oe-J-te-1):(ce=oe+Z,ae=oe+J+te),this._bodyBox=null,I||P){const r=O?j+$:k?j+q:j,n=null!==(d=g.borderColor)&&void 0!==d?d:ue,o=void 0!==p.xCoord?he:0;if(((t,i,n)=>{if(ne){(0,c.drawRoundRectWithInnerBorder)(e,ce,se,Z,r,t,p.overridenRadius?(0,c.scaleDrawRoundRectRadii)(p.overridenRadius,v):[he,o,o,he],X,i,n);const l=(0,s.point)(ce/m,se/v),a=l.add((0,s.point)(Z/m,r/v));this._bodyBox=(0, s.box)(l,a)}else{(0,c.drawRoundRectWithInnerBorder)(e,oe,se,Z,r,t,p.overridenRadius?(0,c.scaleDrawRoundRectRadii)(p.overridenRadius,v):[o,he,he,o],X,i,n);const l=(0,s.point)(oe/m,se/v),a=l.add((0,s.point)(Z/m,r/v));this._bodyBox=(0,s.box)(l,a)}})(ue,n,g.borderStyle),p.separatorVisible&&(e.fillStyle=i.paneBackgroundColor,e.fillRect(ne?le-Q:0,se,Q,re-se)),P){switch(p.labelIcon){case 0:this._drawPlusIcon(e,oe,ce,se,ie,re,G);break;case 1:this._drawClockExistingAlertIcon(e,oe,ce,t,se,r)}return void e.restore()}e.save(),e.translate(ae,(se+re)/2+B),(0,l.drawScaled)(e,m,v,(()=>{e.fillStyle=V,e.fillText(I,0,0)})),e.restore()}k&&(e.fillStyle=A,e.save(),e.translate(ae,(se+re)/2+B+q),(0,l.drawScaled)(e,m,v,(()=>{e.fillText((0,o.startWithLTR)(M),0,0)})),e.restore()),O&&(e.fillStyle=L,e.save(),e.translate(ae,(se+re)/2+B+$),(0,l.drawScaled)(e,m,v,(()=>{e.fillText((0,o.startWithLTR)(D),0,0)})),e.restore()),e.restore()}topBottomTotalHeight(e){const t=this._lines();if(!this._data.visible||0===t)return{top:0,bottom:0,total:0};const i=e.fontSize/2+e.paddingTop+this._commonData.additionalPaddingTop,s=(t-.5)*e.fontSize+(t-1)*e.lineSpacing+e.paddingBottom+this._commonData.additionalPaddingBottom;return{top:i,bottom:s,total:i+s}}hitTest(e){return h(this._data,e)}_drawPlusIcon(e,t,i,s,r,n,o){e.fillStyle=this._commonData.textColor,e.strokeStyle=this._commonData.textColor,e.lineWidth=o;const l=Math.abs(t-i);let a=Math.round(.35*l);a%2!=o%2&&(a+=1);let c=Math.round(.65*l);c%2!=o%2&&(c+=1);const u=Math.floor((l-a)/2),h=Math.min(t,i),d=h+Math.floor(l/2-o/2);e.fillRect(h+u,r,a,o),e.fillRect(d,s+u,o,a),e.beginPath(),e.arc(d+o/2,r+o/2,c/2,0,2*Math.PI,!1),e.stroke()}_drawClockExistingAlertIcon(e,t,i,s,r,n){e.fillStyle=this._commonData.textColor;const o=Math.abs(t-i),l=Math.min(t,i),{horizontalPixelRatio:a,verticalPixelRatio:c}=s,h=o/(23*a),d=o/(23*c),p=12*a*h,_=10.73*c*d,f=Math.floor((o-p)/2),m=Math.floor((n-_)/2)-1;e.save(),e.translate(l+f,r+m),e.scale(a*h,c*d),e.fill(u),e.restore()}_lines(){const e=this._data;return(e.text?1:0)+(e.secondLine?1:0)+(e.thirdLine?1:0)}_isOutOfScreen(e,t){var i;const s=this._commonData,r=null!==(i=s.fixedCoordinate)&&void 0!==i?i:s.coordinate,{total:n}=this.topBottomTotalHeight(e),o=n/this._lines();return r-o/2-3>t||r+(n-o/2)+3<0}}},974655:(e,t,i)=>{i.d(t,{PriceDataSource:()=>l,isPriceDataSource:()=>o});var s=i(996986),r=i(707957),n=i(981107);function o(e){return e instanceof l}class l extends s.DataSource{constructor(e,t){super(t),this._formatterChanged=new r.Delegate,this._priceStepChanged=new r.Delegate,this._currencyChanged=new r.Delegate,this._unitChanged=new r.Delegate,this._priceRangeReadyChanged=new r.Delegate,this._priceStep=null,this._priceRangeReady=!0,this._model=e}base(){return 0}model(){return this._model}currencyChanged(){return this._currencyChanged}isCurrencySource(){return!0}isDisplayedInLegend(){return!0}unitChanged(){return this._unitChanged}isUnitSource(){return!0}priceRange(e,t,i){return null}isDraggable(){return!0}priceLineColor(e){return e}formatterChanged(){return this._formatterChanged} priceStep(e){return this._priceStep}priceStepChanged(){return this._priceStepChanged}isIncludedInAutoScale(){return!0}correctScaleMargins(e){return e}priceRangeReady(){return this._priceRangeReady}priceRangeReadyChanged(){return this._priceRangeReadyChanged}disablePriceRangeReady(){const e=this.priceScale();null===e||e.isAutoScale()||e.mainSource()!==this||(this._priceRangeReady=!1,e.recalculatePriceRangeOnce()),this._priceRangeReadyChanged.fire(!1)}statusView(){return null}legendView(){return null}marketStatusModel(){return null}dataUpdatedModeModel(){return null}dataProblemModel(){return null}canHasAlertOnLineTools(){return!0}_enablePriceRangeReady(){this._priceRangeReady=!0,this._priceRangeReadyChanged.fire(!0)}_onSourceCurrencyChanged(){(0,n.isActingAsSymbolSource)(this)||this._currencyChanged.fire()}_onSourceUnitChanged(){(0,n.isActingAsSymbolSource)(this)||this._unitChanged.fire()}_onSourcePriceRangeReadyChanged(e){(0,n.isActingAsSymbolSource)(this)||e||this.disablePriceRangeReady()}}},506387:(e,t,i)=>{i.d(t,{PriceLineAxisView:()=>a,SeriesPriceLineAxisView:()=>c,StudyPriceLineAxisView:()=>u});var s=i(229765),r=i(650151),n=i(458963),o=i(787123);class l{constructor(e,t){this.setData(e,t)}setData(e,t){this._data=e,this._commonData=t}draw(e,t,i,s,l){var a;if(!this._data.visible)return;const{bitmapSize:c,verticalPixelRatio:u}=t,h=null!==(a=this._commonData.fixedCoordinate)&&void 0!==a?a:this._commonData.coordinate;e.lineWidth=Math.max(1,Math.floor((0,r.ensureDefined)(this._data.linewidth)*u)),e.lineCap="butt",(0,o.setLineStyle)(e,void 0===this._data.linestyle?n.LINESTYLE_DOTTED:this._data.linestyle),e.strokeStyle=this._commonData.textColor,(0,o.drawHorizontalLine)(e,Math.round(h*u),0,c.width)}topBottomTotalHeight(e){return{top:0,bottom:0,total:0}}}class a extends s.PriceAxisView{constructor(e){super(e||l)}ignoreAlignment(){return!0}_updateRendererData(e,t,i){if(t.visible=!1,e.visible=!1,!this._isVisible())return;const s=this._value();s.noData||(i.background="",i.textColor=this._priceLineColor(s.color),i.coordinate=s.coordinate,i.floatCoordinate=s.floatCoordinate,e.linewidth=this._lineWidth(),e.linestyle=this._lineStyle(),e.backgroundAreaVisible=this._backgroundAreaVisible(),e.backgroundAreaColor=this._backgroundAreaColor(),e.backgroundAreaHeight=this._backgroundAreaHeight(),e.visible=!0)}_lineStyle(){return n.LINESTYLE_DOTTED}_backgroundAreaVisible(){return!1}_backgroundAreaColor(){return""}_backgroundAreaHeight(){return 0}}class c extends a{constructor(e){super(),this._series=e}_value(){return this._series.lastValueData(void 0,!0)}_priceLineColor(e){return this._series.priceLineColor(e)}_lineWidth(){return this._series.properties().childs().priceLineWidth.value()}_isVisible(){const e=this._series.model().properties().childs().scalesProperties.childs().showSeriesLastValue.value();return this._series.properties().childs().showPriceLine.value()&&e}}class u extends a{constructor(e,t){super(),this._study=e,this._plotname=t}_value(){return this._study.lastValueData(this._plotname,!0)}_lineWidth(){ return this._study.properties().childs().styles.childs()[this._plotname].childs().linewidth.value()}_lineStyle(){return n.LINESTYLE_DOTTED}_priceLineColor(e){return e}_isVisible(){const e=this._study.model().properties().childs().scalesProperties.childs().showStudyLastValue.value(),t=this._study.isPlotVisibleAt(this._plotname,1);return this._study.properties().childs().styles.childs()[this._plotname].childs().trackPrice.value()&&e&&t}}},291784:(e,t,i)=>{i.d(t,{PriceRange:()=>n,mergePriceRanges:()=>o});var s=i(389137);const r=(0,i(201089).getLogger)("Chart.PriceRange");class n{constructor(e,t){if(null!==e&&"object"==typeof e){const t=e;this._minValue=t.m_minValue,this._maxValue=t.m_maxValue}else{const i=e;this._minValue=i,void 0!==t&&(this._maxValue=t)}}equals(e){return this._minValue===e._minValue&&this._maxValue===e._maxValue}clone(){return new n(this._minValue,this._maxValue)}minValue(){return this._minValue}setMinValue(e){this._minValue=e}maxValue(){return this._maxValue}setMaxValue(e){this._maxValue=e}length(){return this._maxValue-this._minValue}isEmpty(){return this._maxValue===this._minValue||this._maxValue!=this._maxValue||this._minValue!=this._minValue}serialize(){return{m_maxValue:this._maxValue,m_minValue:this._minValue}}state(){return{max:this._maxValue,min:this._minValue}}merge(e){return new n(Math.min(this.minValue(),e.minValue()),Math.max(this.maxValue(),e.maxValue()))}apply(e,t){this._minValue=Math.min(this._minValue,e),this._maxValue=Math.max(this._maxValue,t)}set(e,t){this._minValue=e,this._maxValue=t}scaleAroundCenter(e){if(!(0,s.isNumber)(e))return void r.logDebug("PriceRange.scaleAroundCenter: invalid coeff");if(0===this._maxValue-this._minValue)return;const t=.5*(this._maxValue+this._minValue);let i=this._maxValue-t,n=this._minValue-t;i*=e,n*=e,this._maxValue=t+i,this._minValue=t+n}shift(e){(0,s.isNumber)(e)?(this._maxValue+=e,this._minValue+=e):r.logDebug("PriceRange.shift: invalid coeff")}containsStrictly(e){return e.minValue()>this._minValue&&e.maxValue()e?t?e.merge(t):e:t),null)}},738232:(e,t,i)=>{i.d(t,{factoryDefaultsForCurrentTheme:()=>a});var s=i(852290),r=i(822914),n=i(650151),o=i(331633),l=i(86746);function a(e,t){var i;const a=null!==(i=o.watchedTheme.value())&&void 0!==i?i:l.StdTheme.Light,c=(0,r.default)(e);return(0,s.default)(c,(0,n.ensureDefined)(t.get(a))),c}},915179:(e,t,i)=>{i.d(t,{barSpacingByScaleRatio:()=>o,priceRangeByScaleRatio:()=>n,scaleRatio:()=>r});var s=i(291784);function r(e,t){if(t.isLog()||e.isEmpty()||t.isEmpty())return null;const i=function(e){if(e.isEmpty())return null;const t=e.priceRange();if(null===t)return null;const i=t.length();return e.internalHeight()/i}(t);if(null===i)return null;return e.getValidBarSpacing()/Math.max(1e-10,i)}function n(e,t,i){if(e.isLog()||null===i||e.isEmpty())return null;const r=e.priceRange();if(null===r||r.isEmpty())return null;const n=e.internalHeight()/(t/i),o=r.length();if(n===o)return r;const l=(n-o)/2 ;return new s.PriceRange(r.minValue()-l,r.maxValue()+l)}function o(e,t){if(e.isLog()||null===t||e.isEmpty())return null;const i=e.priceRange();if(null===i)return null;const s=i.length();return e.internalHeight()/s*t}},63316:(e,t,i)=>{i.d(t,{SelectionIndexes:()=>r});var s=i(650151);class r{constructor(e){this._baseIndex=null,this._offsetInBar=null,this._offsetInTime=null,this._barsBetweenPoints=null,this._timescale=e}indexes(){const e=this._timescale.visibleBarsStrictRange();if(null===e)return[];const t=e.firstBar(),i=e.lastBar();if(null===this._offsetInTime||null===this._barsBetweenPoints){const e=this._timescale.barSpacing();this._barsBetweenPoints=Math.floor(120/e),this._offsetInBar=i%this._barsBetweenPoints,this._offsetInTime=this._timescale.indexToTimePoint(this._offsetInBar),this._baseIndex=this._timescale.baseIndex()}const r=this._timescale.baseIndex();this._baseIndex!==r&&(this._baseIndex=r,this._offsetInBar=(0,s.ensureNotNull)(this._timescale.timePointToIndex(this._offsetInTime)));const n=(0,s.ensureNotNull)(this._offsetInBar),o=[];let l=Math.floor((t-n)/this._barsBetweenPoints);const a=Math.floor((i-n)/this._barsBetweenPoints);for(;l<=a;l++)o.push(n+l*this._barsBetweenPoints);return o}clear(){this._offsetInBar=null,this._offsetInTime=null,this._baseIndex=null,this._barsBetweenPoints=null}}},230058:(e,t,i)=>{i.d(t,{SelectionRenderer:()=>c});var s=i(934026),r=i(195294),n=i(315801),o=i(147354),l=i(43192);const a=r.colorsPalette["color-tv-blue-600"];class c extends l.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e||null}setData(e){this._data=e}hitTest(e){if(!this._data||!this._data.visible)return null;for(let t=0;t(0,s.pointInBox)(t,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const{context:t,horizontalPixelRatio:i}=e;t.strokeStyle=void 0!==this._data.color?this._data.color:a,t.lineCap="butt";const s=Math.max(1,Math.floor(i));t.lineWidth=s;const r=this._data.vertOffset||0;for(let i=0;i{i.d(t,{SeriesData:()=>p,barFunction:()=>u,seriesPlotFunctionMap:()=>c});var s,r=i(650151),n=i(195447),o=i(674981);!function(e){ e[e.FromLeft=-1]="FromLeft",e[e.FromRight=1]="FromRight"}(s||(s={}));const l={open:e=>e[1],high:e=>e[2],low:e=>e[3],close:e=>e[4],hl2:e=>(e[2]+e[3])/2,hlc3:e=>(e[2]+e[3]+e[4])/3,ohlc4:e=>(e[1]+e[2]+e[3]+e[4])/4},a=["open","high","low","close","hl2","hlc3","ohlc4"];function c(){const e=new Map;return a.forEach(((t,i)=>{e.set(t,u(t))})),e}function u(e,t,i){const s=l[null!=t?t:e],r=l[e],n=l[null!=i?i:e];return(e,t)=>{switch(t){case 0:return s(e);case 2:return n(e);default:return r(e)}}}function h(e,t){return null==e[t]}const d=[{barsToMerge:10,forBarspacingLargerThen:.03},{barsToMerge:30,forBarspacingLargerThen:.01},{barsToMerge:100,forBarspacingLargerThen:.003},{barsToMerge:500,forBarspacingLargerThen:0}];class p{constructor(){this._pressedChunks={chunks:new Map,priceSource:"uninitialized"},this.m_bars=new n.PlotList(c(),h),this.m_nsBars=new n.PlotList(c(),h),this._clearPressedChunks()}bars(){return this.m_bars}nsBars(){return this.m_nsBars}pressedChunks(e,t){if(t!==this._pressedChunks.priceSource){this._pressedChunks.priceSource=t;const e=this.m_bars.first();e&&(this._clearPressedChunks(),this._rebuildPressedChunks(e))}const i=(0,r.ensureDefined)(d.find((t=>t.forBarspacingLargerThen<=e)));return(0,r.ensureDefined)(this._pressedChunks.chunks.get(i.barsToMerge))}mergeRegularBars(e){const t=this.m_bars.size(),i=this.m_bars.merge(e);return i&&"uninitialized"!==this._pressedChunks.priceSource&&(t===this.m_bars.size()&&i.index===this.m_bars.lastIndex()?this._updateLatestChunks():this._rebuildPressedChunks(i)),i}size(){return this.m_bars.size()+this.m_nsBars.size()}each(e){this.m_bars.each(e),this.m_nsBars.each(e)}clear(){this.m_bars.clear(),this.m_nsBars.clear(),this.lastProjectionPrice=void 0,this._clearPressedChunks()}clone(){const e=new p;return e.lastProjectionPrice=this.lastProjectionPrice,e.boxSize=this.boxSize,e.reversalAmount=this.reversalAmount,e.m_bars=this.m_bars.clone(),e.m_nsBars=this.m_bars.clone(),e}isEmpty(){return this.m_bars.isEmpty()&&this.m_nsBars.isEmpty()}first(){return this.m_bars.isEmpty()?this.m_nsBars.first():this.m_bars.first()}last(){return this.m_nsBars.isEmpty()?this.m_bars.last():this.m_nsBars.last()}search(e,t,i){return this.nsBars().isEmpty()?this.bars().search(e,t,i):this.bars().isEmpty()||(0,r.ensureNotNull)(this.nsBars().firstIndex())<=e?this.nsBars().search(e,t,i):this.bars().search(e,t,i)}valueAt(e){const t=this.search(e);return null!==t?t.value:null}plotValueToTimePointIndex(e,t,i){if(i===s.FromRight){const i=(i,s)=>{const r=s[t];return null!=r&&e>=r},s=this.m_bars.findLast(i);if(null!==s)return s.index;const r=this.m_nsBars.findLast(i);return null!==r?r.index:this.m_bars.firstIndex()}if(i===s.FromLeft){const i=(i,s)=>{const r=s[t];return null!=r&&e<=r},s=this.m_bars.findFirst(i);if(null!==s)return s.index;const r=this.m_nsBars.findFirst(i);return null!==r?r.index:this.m_bars.lastIndex()}throw new Error("plotValueToTimePointIndex: unsupported search mode")}moveData(e){this.m_bars.move(e),this.m_nsBars.move(e),this.m_bars.size()>0&&this._rebuildPressedChunks((0, r.ensureNotNull)(this.m_bars.first()))}_rebuildPressedChunks(e){const t=this._pressedChunks.priceSource;if("uninitialized"===t)return;const i=e.index,s=l[t],n=(e,t,i)=>{let r=null;for(const n of e){const e=s(n.value);r&&n.index-r.startTime>=i.barsToMerge&&(t.push(r),r=null),r?(r.endTime=n.index,r.high=Math.max(r.high,e),r.low=Math.min(r.low,e),r.close=e):r={startTime:n.index,endTime:n.index,open:e,high:e,low:e,close:e}}r&&t.push(r)};d.forEach((e=>{const t=(0,r.ensureDefined)(this._pressedChunks.chunks.get(e.barsToMerge)),s=(0,o.lowerbound)(t,i,((e,t)=>e.endTime0){const i=t[0].startTime-1,s=(0,r.ensureNotNull)(this.m_bars.firstIndex()),o=this.m_bars.rangeIterator(s,i),l=[];n(o,l,e);const a=l.concat(t);this._pressedChunks.chunks.set(e.barsToMerge,a)}else{const i=(0,r.ensureNotNull)(this.m_bars.lastIndex());t.splice(s);let o=(0,r.ensureNotNull)(this.m_bars.firstIndex());t.length&&(o=t[t.length-1].endTime+1);const l=this.m_bars.rangeIterator(o,i);n(l,t,e)}}))}_updateLatestChunks(){const e=(0,r.ensureNotNull)(this.m_bars.last());d.forEach((t=>{const i=(0,r.ensureDefined)(this._pressedChunks.chunks.get(t.barsToMerge)),s=e.value[4],n=i[i.length-1];n.high=Math.max(n.high,s),n.low=Math.min(n.low,s),n.close=s,n.endTime=e.index}))}_clearPressedChunks(){d.forEach((e=>this._pressedChunks.chunks.set(e.barsToMerge,[])))}}},3140:(e,t,i)=>{i.d(t,{SeriesTimeRangeVolumeCalculator:()=>s});class s{constructor(e){this._value=null,this._series=e,this._series.dataEvents().dataUpdated().subscribe(this,this._onSeriesUpdated)}destroy(){this._series.dataEvents().dataUpdated().unsubscribeAll(this)}volume(e,t){if(null!==this._value&&this._value.from===e&&this._value.to===t)return this._value.value;let i=0;const s=this._series.data().bars(),r=s.firstIndex(),n=s.lastIndex();if(null!==r&&en&&t>n)i=NaN;else{const s=this._series.data().bars().rangeIterator(Math.min(e,t),Math.max(e,t));for(const e of s){const t=e.value[5];if(void 0===t){i=NaN;break}i+=t}}return this._value={from:e,to:t,value:i},i}_onSeriesUpdated(e,t){if(null===this._value)return;if(t)return void(this._value=null);const i=this._series.data().bars().lastIndex();(null===i||i<=this._value.to)&&(this._value=null)}}},969419:(e,t,i)=>{i.d(t,{PaneRendererBars:()=>n});var s=i(9640),r=i(756930);class n extends r.PaneRendererSeriesBase{constructor(e){super(),this._bars=e.bars,this._dontDrawOpen=e.dontDrawOpen,this._thinBars=e.thinBars}_drawImpl(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;t.save();let r=null;for(const e of this._bars){let n=this._calcRealBarWidth(e.right-e.left,i);if(n>=2){Math.max(1,Math.floor(i))%2!=n%2&&n--}const o=this._thinBars?Math.min(n,Math.floor(i)):n,l=o<=n&&e.right-e.left>=Math.floor(1.5*i);r!==e.color&&(t.fillStyle=e.color,r=e.color);const a=Math.floor(.5*o),c=Math.round(e.center*i),u=c-a,h=o,d=u+h-1,p=Math.min(e.high,e.low),_=Math.max(e.high,e.low),f=Math.round(p*s)-a,m=Math.round(_*s)+a,v=Math.max(m-f,o);t.fillRect(u,f,h,v);const g=Math.ceil(1.5*n);if(l){const i=c-g,r=c+g,n=Math.min(u-i,r-d) ;if(!this._dontDrawOpen){let r=Math.max(f,Math.round(e.open*s)-a),o=r+h-1;o>f+v-1&&(o=f+v-1,r=o-h+1),t.fillRect(i,r,n,o-r+1)}let o=Math.max(f,Math.round(e.close*s)-a),l=o+h-1;l>f+v-1&&(l=f+v-1,o=l-h+1),t.fillRect(d+1,o,n,l-o+1)}}t.restore()}_getTolerance(){return(0,s.interactionTolerance)().series}_calcRealBarWidth(e,t){const i=Math.floor(t);return Math.max(i,Math.floor((0,s.optimalBarWidth)(e,t)))}}},756930:(e,t,i)=>{i.d(t,{PaneRendererSeriesBase:()=>n});var s=i(315801),r=i(43192);class n extends r.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._bars=[]}hitTest(e){const t=this._bars;if(0===t.length)return null;const i=this._getTolerance(),s=t[0],r=t[t.length-1];if(e.xr.right+i)return null;let n=0,o=t.length-1,l=-1;for(;n<=o;){const i=Math.floor((n+o)/2),s=t[i];if(e.x>=s.left&&e.x<=s.right){l=i;break}e.x>s.right?n=i+1:o=i-1}if(-1===l)return null;if(this._isPointAtBar(t[l],e.y,i))return this._getHitTest();let a=l;for(;a>=1&&e.x-t[a-1].right{i.d(t,{PaneRendererCandles:()=>c});var s=i(650151),r=i(315801),n=i(787123),o=i(9640),l=i(756930);function a(e,t,i,s){const r=Math.floor(t);return e.map((e=>{let n=(0,o.optimalCandlestickWidth)((e.right-e.left)*s,t);n>=2&&r%2!=n%2&&n--;const l=Math.floor(.5*n),a=function(e,t){let i=Math.floor(1*t);e<=2*i&&(i=Math.floor(.5*(e-1)));const s=Math.max(Math.floor(t),i);if(e<=2*s)return Math.max(Math.floor(t),Math.floor(1*t));return s}(n,t),c=Math.round(e.center*t),u=c-l,h=u+n-1,d=Math.abs(Math.max(e.open,e.close)-Math.min(e.open,e.close))*i,p=Math.round(Math.min(e.open,e.close)*i),_=Math.round(Math.max(e.open,e.close)*i);let f=Math.min(Math.floor(t),Math.floor(n*t));f=Math.max(Math.floor(t),Math.min(f,n));const m=Math.floor(.5*f);return{rawBodyHeight:d,top:p,bottom:_,center:c,left:u,right:h,candleWidth:n,high:Math.round(e.high*i),low:Math.round(e.low*i),wickWidth:f,wickOffset:m,borderWidth:a}}))}class c extends l.PaneRendererSeriesBase{constructor(e){super(),this._scaleCoeff=1,this._borderVisible=!1,this._wickVisible=!1,this._bodyVisible=!0,this._borderColor=void 0,this._wickColor=void 0,this._hittest=void 0,this._isPriceScaleInverted=!1,e&&this.setData(e)}setData(e){var t;this._bars=e.bars,this._scaleCoeff=null!==(t=e.scaleCoeff)&&void 0!==t?t:1,this._borderVisible=e.borderVisible,this._bodyVisible=e.bodyVisible,this._wickVisible=e.wickVisible,this._borderColor=e.borderColor,this._wickColor=e.wickColor,this._hittest=e.hittest,this._isPriceScaleInverted=e.isPriceScaleInverted}hitTest(e){return this._wickVisible||this._borderVisible||this._bodyVisible?super.hitTest(e):null}_drawImpl(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e ;if(0===this._bars.length)return;const r=a(this._bars,i,s,this._scaleCoeff);this._wickVisible&&this._drawWicks(t,r),this._borderVisible&&this._drawBorder(t,r),this._bodyVisible&&this._drawCandles(t,r)}_getTolerance(){return(0,o.interactionTolerance)().series}_getHitTest(){return this._hittest||new r.HitTestResult(r.HitTarget.Regular)}_isPointAtBar(e,t,i){const s=this._bodyVisible||this._borderVisible,r=this._wickVisible;if(!s&&!r)return!1;if(s){const s=r?Math.min(e.high,e.low):Math.min(e.open,e.close),n=r?Math.max(e.high,e.low):Math.max(e.open,e.close);return s-i<=t&&t<=n+i}{const s=Math.min(e.open,e.close),r=Math.max(e.open,e.close);return e.high-i<=t&&t<=s+i||r-i<=t&&t<=e.low+i}}_drawWicks(e,t){let i="",r=null;this._bars.forEach(((n,o)=>{const l=n.wickColor?n.wickColor:(0,s.ensureDefined)(this._wickColor);l!==i&&(e.fillStyle=l,i=l);let{top:a,bottom:c}=t[o];const{rawBodyHeight:u,borderWidth:h,center:d,high:p,low:_,wickWidth:f,wickOffset:m}=t[o];this._isPriceScaleInverted&&([c,a]=[a,c]);let v=d-m;const g=v+f-1;null!==r&&(v=Math.max(r+1,v),v=Math.min(v,g));const P=g-v+1;u<=h&&(a!==p&&(a=Math.round(a-.5*h)),c=c!==_?Math.round(a-.5*h)+h-1:_-1),a!==p&&e.fillRect(v,p,P,a-p),_-c-1&&e.fillRect(v,c+1,P,_-c-1),r=g}))}_drawBorder(e,t){let i="",r=null;this._bars.forEach(((o,l)=>{if(o.borderColor!==i&&(e.fillStyle=o.borderColor?o.borderColor:(0,s.ensureDefined)(this._borderColor),i=o.borderColor),this._bodyVisible&&o.hollow)return;let{left:a}=t[l];const{rawBodyHeight:c,top:u,bottom:h,right:d,borderWidth:p}=t[l];null!==r&&(a=Math.max(r+1,a),a=Math.min(a,d));const _=d-a+1;c<=p?e.fillRect(a,Math.round(u-.5*p),_,p):_>2*p?(0,n.fillRectInnerBorder)(e,a,u,d-a+1,h-u+1,p):e.fillRect(a,u,_,h-u+1),r=d}))}_drawCandles(e,t){let i="";this._bars.forEach(((s,r)=>{let{top:o,bottom:l,left:a,right:c}=t[r];const{rawBodyHeight:u,borderWidth:h,candleWidth:d}=t[r];if(!(this._borderVisible&&d<=2*h)||s.hollow){if(s.color!==i){const t=s.color;e.fillStyle=t,i=t}if(s.hollow)e.fillStyle=s.color,u<=h?e.fillRect(a,Math.round(o-.5*h),d,h):(0,n.fillRectInnerBorder)(e,a,o,c-a+1,l-o+1,h);else{if(!this._borderVisible&&u<=h)return void e.fillRect(a,Math.round(o-.5*h),d,h);if(this._borderVisible&&(a+=h,o+=h,c-=h,l-=h),o>l)return;e.fillRect(a,o,c-a+1,l-o+1)}}}))}}},985715:(e,t,i)=>{i.d(t,{StatusProviderBase:()=>s});class s{size(){return"13px"}bold(){return!1}}},833642:(e,t,i)=>{i.d(t,{StatusView:()=>s});class s{constructor(e){this._text="",this._color="",this._size="13px",this._bold=!1,this._statusProvider=e}text(){return this._text}getSplitTitle(){return[this._text]}bold(){return this._bold}size(){return this._size}}},434294:(e,t,i)=>{i.d(t,{AbstractFilledAreaPaneView:()=>_});var s=i(650151),r=(i(86441),i(5531),i(674981)),n=i(448874),o=i(246733),l=i(407478);var a=i(57372),c=i(272933);function u(e,t){return Array.from({length:e},((e,i)=>({timePointIndex:i+t})))}function h(e,t,i){let s,r;const n=e.length;for(let o=t;o>=0&&o`${e}_${t}_${i}`));return n.default.Cache=t,i}(),this._source=e,this._model=t,this._fillGaps=!!(null==i?void 0:i.fillgaps),this._fillToIntersection=!!(null==i?void 0:i.fillToIntersection)}update(e){if("global-change"===e.type)return this._dataInvalidated=(0,c.mergeDataInvalidation)(this._dataInvalidated,{}),void(this._viewportInvalidated=!0);if("data-source-change"!==e.type)this._viewportInvalidated=!0;else{e.sourceId===this._source.id()&&(this._dataInvalidated=(0,c.mergeDataInvalidation)(this._dataInvalidated,{firstIndex:e.firstUpdatedTimePointIndex,clearData:e.clearData}))}}renderer(){return this._dataInvalidated?this._updateImplFull(this._dataInvalidated)&&(this._dataInvalidated=null,this._viewportInvalidated=!1):this._viewportInvalidated&&(this._updateImplLight(),this._viewportInvalidated=!1),this._areaRenderer}_minFirstBarIndex(){return-1/0}_priceScale(){return this._source.priceScale()}_firstValue(){return this._source.firstValue()}_plotNames(){return this._source.metaInfo().plots.map((e=>e.id))}_plotIndex1(){return null===this._plIndex1&&(this._plIndex1=this._plotNames().indexOf(this._plotAId())+1),this._plIndex1}_plotIndex2(){return null===this._plIndex2&&(this._plIndex2=this._plotNames().indexOf(this._plotBId())+1),this._plIndex2}_updateImplFull(e){var t,i,n,o;if(this._areaRenderer.setData(null),(null===(t=this._dataInvalidated)||void 0===t?void 0:t.clearData)&&(this._items=[]),!this._visible())return!1;if(null===this._priceScale())return!1;if(null===this._firstValue())return!1;const l=this._source.plots().plottableRange(),a=l.size();if(0===a)return!1;const c=this._source.offset(this._plotAId()),h=this._source.offset(this._plotBId()),d=Math.min(c,h),p=Math.max(c,h);let _=e.firstIndex;const f=a+(p-d)+1,m=this._plotIndex1(),v=this._plotIndex2();f!==this._items.length&&(void 0===_||0===this._items.length||_e.timePointIndex=0&&te.timePointIndex=this._items.length)return;const y=Math.min(this._items.length-1,(0,r.lowerbound)(this._items,_.lastBar(),((e,t)=>e.timePointIndex1&&(w=null),void 0!==c?(r=c.level1,o=c.level2):(r=t.plot1Coordinate=void 0===t.plot1Value?void 0:f(t.plot1Value),o=t.plot2Coordinate=void 0===t.plot2Value?void 0:f(t.plot2Value));const l=t.xCoordinate=u.indexToCoordinate(t.timePointIndex);if(t.color&&1===t.color.type&&(t.color.coordinate1=f(t.color.value1),t.color.coordinate2=f(t.color.value2)),this._fillGaps?void 0!==r||void 0!==o:void 0!==r&&void 0!==o){const s=null!==this._colorPlotIndex?t.color||p:V;if(D=s,!(null===(A=I)||null===D?A===D:0===A.type&&0===D.type?A.color===D.color:1===A.type&&1===D.type&&A.color1===D.color1&&A.color2===D.color2&&A.coordinate1===D.coordinate1&&A.coordinate2===D.coordinate2)||null===w){if(null!==w&&(void 0!==r&&w.addPoints1Point(l,r),void 0!==o&&w.addPoints2Point(l,o)),e===b)continue;I=s ;const t=d(s),c=null!==(i=x.get(t))&&void 0!==i?i:new a.AreaBackgroundItemsGroup(s);T=w,w=null!==(n=c.newItem())&&void 0!==n?n:new a.AreaBackgroundItem,c.push(w),x.set(t,c)}void 0!==r&&w.addPoints1Point(l,r),void 0!==o&&w.addPoints2Point(l,o)}else this._fillGaps||(I=null,w=null,T=null);M=s,C=t}var A,D;x.delete(d(p));const L={barSpacing:this._model.timeScale().barSpacing(),colorAreas:x};this._areaRenderer.setData(L)}}},1584:(e,t,i)=>{i.d(t,{AreaBackgroundPaneView:()=>n});var s=i(650151),r=i(434294);class n extends r.AbstractFilledAreaPaneView{constructor(e,t){super(e,t)}_plotAId(){return(0,s.ensureDefined)(this._source.metaInfo().area)[0].name}_plotBId(){return(0,s.ensureDefined)(this._source.metaInfo().area)[1].name}_commonColor(){return{type:0,color:this._source.properties().areaBackground.backgroundColor.value()}}_transparency(){return this._source.properties().areaBackground.transparency.value()}_visible(){return this._source.properties().areaBackground.fillBackground.value()}_getColorByPlotValue(e){return this._commonColor()}}},539163:(e,t,i)=>{i.d(t,{DwgLabelPaneViewConstants:()=>s,calculateDwgLabelsMargins:()=>l,calculateLabelHeight:()=>o});var s,r=i(368135),n=i(294024);function o(e,t,i){let s=i;switch(t){case r.PlotSymbolSize.Tiny:s=.6*e;break;case r.PlotSymbolSize.Small:s=.8*e;break;case r.PlotSymbolSize.Normal:s=e;break;case r.PlotSymbolSize.Large:s=1.5*e;break;case r.PlotSymbolSize.Huge:s=2*e}return s}function l(e,t,i){const r=e.model().timeScale().barSpacing(),l=Math.round(r*s.AUTO_SIZE_MULT),a=o(s.NORMAL_SIZE,t.size,l)*s.SHAPE_HEIGHT_MULT,c=Math.round(a/2);switch(t.style){case n.DwgLabelStyle.LabelUp:case n.DwgLabelStyle.LabelLeftUp:case n.DwgLabelStyle.LabelRightUp:return{bottomPixelMargin:c,topPixelMargin:0};case n.DwgLabelStyle.LabelDown:case n.DwgLabelStyle.LabelLeftDown:case n.DwgLabelStyle.LabelRightDown:return{bottomPixelMargin:0,topPixelMargin:c};case n.DwgLabelStyle.LabelLeft:case n.DwgLabelStyle.LabelRight:case n.DwgLabelStyle.LabelCenter:return{bottomPixelMargin:c,topPixelMargin:c}}return{bottomPixelMargin:0,topPixelMargin:0}}!function(e){e.NORMAL_SIZE=50,e.AUTO_SIZE_MULT=1,e.SHAPE_HEIGHT_MULT=.5,e.SHAPE_WIDTH_MULT=.6,e.FONT_SIZE_MULT=.24}(s||(s={}))},934393:(e,t,i)=>{i.d(t,{containsDwgLineFillTimePointIndexes:()=>s,dematerializeDwgLineFill:()=>n,materializeDwgLineFill:()=>r});const s=!1;function r(e){return{id:e.id,line1:e.line1,line2:e.line2,colorIndex:e.ci}}function n(e,t){return{id:t,line1:e.line1,line2:e.line2,ci:e.colorIndex}}},651788:(e,t,i)=>{i.d(t,{containsLogTimePointIndexes:()=>n,materializeLog:()=>o});var s=i(650151),r=i(130551);const n=!1;function o(e){const t=JSON.parse(e.pp);var i;return(0,s.assert)("s"in(i=t)&&(0,r.isObject)(i.s)&&"l"in i.s&&"c"in i.s&&"e"in i&&(0,r.isObject)(i.e)&&"l"in i.e&&"c"in i.e,"unexpected log source"),{barTime:e.t,time:e.tms,level:e.ll,source:{start:{line:t.s.l,column:t.s.c},end:{line:t.e.l,column:t.e.c}},message:e.m}}},229169:(e,t,i)=>{function s(e){return{lines:e.l,time:e.t,invocations:e.c}}i.d(t,{containsPerformanceTimePointIndexes:()=>r, materializePerformance:()=>n});const r=!1;function n(e){return{total:e.total,profile:e.profile.map(s)}}},878475:(e,t,i)=>{i.d(t,{containsPolygonTimePointIndexes:()=>n,dematerializePolygon:()=>l,isPolygonInBarsRange:()=>a,materializePolygon:()=>o});var s=i(732149),r=i(387963);const n=!0;function o(e,t){for(const i of e.points){if(i.index>=t.length)return null;if(t[i.index]===s.INVALID_TIME_POINT_INDEX)return null}return{points:e.points.map((e=>({index:t[e.index],offset:e.offset,level:e.level})))}}function l(e,t,i){return{id:t,points:e.points.map((e=>({...e,index:(0,r.ensureTimePointIndexIndex)(i.indexOf(e.index))})))}}function a(e,t){var i;if(e.points.some((e=>{var i;return t.contains(e.index+(null!==(i=e.offset)&&void 0!==i?i:0))})))return!0;let s=!1,r=!1;const n=t.firstBar();for(const t of e.points)t.index+(null!==(i=t.offset)&&void 0!==i?i:0){i.d(t,{containsVertLineTimePointIndexes:()=>n,dematerializeVertLine:()=>l,isVertLineInBarsRange:()=>a,materializeVertLine:()=>o});var s=i(732149),r=i(387963);const n=!0;function o(e,t){if(e.index>=t.length)return null;const i=t[e.index];return i===s.INVALID_TIME_POINT_INDEX?null:{startPrice:e.startPrice,endPrice:e.endPrice,index:i,extendTop:e.extendTop,extendBottom:e.extendBottom}}function l(e,t,i){const s=(0,r.ensureTimePointIndexIndex)(i.indexOf(e.index));return{id:t,...e,index:s}}function a(e,t){return t.contains(e.index)}},214798:(e,t,i)=>{i.d(t,{containsFootprintPriceLevelTimePointIndexes:()=>n,dematerializeVolumeFootprintPriceLevel:()=>l,isVolumeFootprintPriceLevelInBarsRange:()=>a,materializeVolumeFootprintPriceLevel:()=>o});var s=i(732149),r=i(387963);const n=!0;function o(e,t){if(e.startIndex>=t.length)return null;const i=t[e.startIndex],r=null===e.extendTo?null:t[e.extendTo];return i===s.INVALID_TIME_POINT_INDEX||r===s.INVALID_TIME_POINT_INDEX?null:{id:e.id,price:e.price,type:e.type,startIndex:i,extendTo:r}}function l(e,t,i){var n,o;const l=(0,r.ensureTimePointIndexIndex)(i.indexOf(null!==(n=e.startIndex)&&void 0!==n?n:s.INVALID_TIME_POINT_INDEX)),a=null===e.extendTo?null:(0,r.ensureTimePointIndexIndex)(i.indexOf(null!==(o=e.extendTo)&&void 0!==o?o:s.INVALID_TIME_POINT_INDEX));return{id:t,price:e.price,type:e.type,startIndex:l,extendTo:a}}function a(e,t){var i;const s=e.startIndex;return!((null!==(i=e.extendTo)&&void 0!==i?i:1/0)t.lastBar())}},567467:(e,t,i)=>{i.d(t,{HHistBasedValuesProvider:()=>f});var s=i(150335),r=i(650151),n=i(638456),o=i(534741),l=i(885482),a=i(948767),c=i(396372),u=i(616117),h=i(60897);function d(e,t="",i=""){return{id:t,index:e,title:i,value:"",visible:!1}}const p=n.CheckMobile.any(),_=(0,a.getVolumeFormatter)();class f{constructor(e,t,i=!1){this._emptyValues=[],this._study=e,this._model=t,this._emptyTitles=i,void 0!==this._study.metaInfo().graphics.hhists&&this._emptyValues.push(d(0),d(1),d(2))}getItems(){return this._emptyValues}getValues(e){var t,i;const n=this._emptyValues.map((e=>({...e})));n.forEach((e=>{e.visible=this._study.isVisible(),e.value=h.notAvailable})) ;const l=this._study.properties().childs().inputs.childs().volume.value();switch(l){case c.HHistVolumeMode.UpDown:this._emptyTitles||(n[0].title="Up",n[1].title="Down",n[2].title="Total");break;case c.HHistVolumeMode.Total:this._emptyTitles||(n[0].title="Total"),n[1].visible=!1,n[2].visible=!1;break;case c.HHistVolumeMode.Delta:this._emptyTitles||(n[0].title="Delta",n[1].title="Max(Up, Down)",n[2].title="Total")}const a=this._study.priceScale(),u=this._model.timeScale();if(null===a||a.isEmpty()||u.isEmpty()||this._hideValues())return n;if(null===e||!isFinite(e)){const t=this._study.data().last();if(null===t)return n;e=t.index}const d=this._model.crossHairSource(),p=d.price;if(!isFinite(d.y)&&(e=function(e,t){var i;const s=null===(i=e.visibleBarsStrictRange())||void 0===i?void 0:i.lastBar();if(!s)return null;const r=t.data().search(s,o.PlotRowSearchMode.NearestLeft);return r?r.index:null}(this._model.timeScale(),this._model.mainSeries()),null===e))return n;const f=function(e,t,i,s){if(0===e.size)return null;if(!i){const e=(0,r.ensureNotNull)(s.data().valueAt(t));i=s.barFunction()(e)}const n=function(e,t){let i=null;return e.forEach(((e,s)=>{s<=t&&(null===i||s>i)&&(i=s)})),i}(e,t);if(null===n)return null;const o=e.get(n);if(!o||0===o.size)return null;return function(e,t){let i=null;return e.forEach((e=>{e.priceLow<=t&&t{e.value="0"})),n;const m=this._study.metaInfo().graphics.hhists;if(void 0===m)return n;if(void 0===m[f.styleId])return n;const v=null===(i=null===(t=this._study.properties().childs().graphics.childs().hhists)||void 0===t?void 0:t.childs()[f.styleId])||void 0===i?void 0:i.childs(),g=e=>(0,s.isNumber)(e)?_.format(e):"";if(l!==c.HHistVolumeMode.Delta){if(f.rate.forEach(((e,t)=>{n[t].value=g(e),n[t].color=(0,r.ensureDefined)(v).colors[t].value()})),l===c.HHistVolumeMode.UpDown){const e=f.rate[0]+f.rate[1];n[2].value=g(e),n[2].color=(0,r.ensureDefined)(v).valuesColor.value()}}else{const e=f.rate[0]>f.rate[1]?0:1,t=(0,r.ensureDefined)(v).colors[e].value(),i=f.rate[0]+f.rate[1];[2*f.rate[e]-i,f.rate[e],i].forEach(((e,i)=>{n[i].value=g(e),n[i].color=t}))}return n}_hideValues(){return p&&(null===this._model.crossHairSource().pane||(0,u.isLineToolName)(l.tool.value())||null!==this._model.lineBeingEdited())}}},173220:(e,t,i)=>{i.d(t,{makeNextStudyId:()=>o,makeNextSymbolId:()=>r});let s=0;function r(){return s++,"ss_"+s}let n=0;function o(){return n++,"st"+n}},272933:(e,t,i)=>{function s(e,t){if(null===e)return t;const i=e.firstIndex,s=t.firstIndex,r=e.clearData||t.clearData;return{firstIndex:r||void 0===i||void 0===s?void 0:Math.min(i,s),clearData:r}}i.d(t,{mergeDataInvalidation:()=>s})},574809:(e,t,i)=>{function s(e){e.lineWidth=void 0,e.lineStyle=void 0;for(let t=0;ts,createEmptyStyle:()=>r })},793907:(e,t,i)=>{i.d(t,{PaneRendererColumns:()=>n});var s=i(43192),r=i(315801);class n extends s.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._precalculatedCache=[],this.setData(e)}setData(e){this._data=e,this._precalculatedCache=[]}hitTest(e){var t,i,s,n;if(null===this._data)return null;const o=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,l=(null!==(n=null===(s=this._data.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==n?n:this._data.items.length)-1;for(let t=o;t<=l;t++){const i=this._data.items[t];if(e.x>=i.left&&e.x<=i.right){const t=i.y;if(e.y>=Math.min(t,this._data.histogramBase)&&e.y<=Math.max(t,this._data.histogramBase))return new r.HitTestResult(r.HitTarget.Regular)}}return null}_drawImpl(e){var t,i,s,r;if(null===this._data||0===this._data.items.length)return;const{context:n,horizontalPixelRatio:o,verticalPixelRatio:l}=e;this._precalculatedCache.length||this._fillPrecalculatedCache(o);const a=Math.max(1,Math.floor(o)),c=Math.max(1,Math.floor(l)),u=Math.round(this._data.histogramBase*l)-Math.floor(a/2),h=u+a,d=this._data.lineColor,p=null!==(i=null===(t=this._data.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,_=(null!==(r=null===(s=this._data.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:this._data.items.length)-1;for(let e=p;e<=_;e++){const t=this._data.items[e],i=this._precalculatedCache[e-p],s=Math.round(t.y*l);let r,o;n.fillStyle=t.style?t.style.color:d,s<=u?(r=s,o=h):(r=u,o=s-Math.floor(c/2)+c),n.fillRect(i.left,r,i.right-i.left+1,o-r)}}_fillPrecalculatedCache(e){var t,i;if(null===this._data||0===this._data.items.length)return void(this._precalculatedCache=[]);const{barSpacing:s,visibleItemsRange:r,items:n}=this._data,o=Math.ceil(s*e)<=1?0:Math.max(1,Math.floor(e)),l=null!==(t=null==r?void 0:r.startItemIndex)&&void 0!==t?t:0,a=(null!==(i=null==r?void 0:r.endItemIndex)&&void 0!==i?i:n.length)-1,c=a-l+1;if(c<=0)return void(this._precalculatedCache=[]);this._precalculatedCache=new Array(c);for(let t=l;t<=a;t++){const i=n[t],s=Math.round(i.center*e);let r,a;const c=Math.round((i.right-i.left)*e)-o;if(c%2){const e=(c-1)/2;r=s-e,a=s+e}else{const e=c/2;r=s-e,a=s+e-1}this._precalculatedCache[t-l]={left:r,right:a,roundedCenter:s,center:i.center*e,time:i.timePointIndex}}for(let e=l+1;e<=a;e++){const t=this._precalculatedCache[e-l],i=this._precalculatedCache[e-l-1];t.time===i.time+1&&(t.left-i.right!==o+1&&(i.roundedCenter>i.center?i.right=t.left-o-1:t.left=i.right+o+1))}let u=Math.ceil(s*e);for(let e=l+1;e<=a;e++){const t=this._precalculatedCache[e-l];t.right0&&u<4)for(let e=l+1;e<=a;e++){const t=this._precalculatedCache[e-l];t.right-t.left+1>u&&(t.roundedCenter>t.center?t.right-=1:t.left+=1)}}}},268008:(e,t,i)=>{i.d(t,{StudyPlotPaneView:()=>N}) ;var s=i(650151),r=i(724377),n=i(244842),o=i(678515),l=i(389137),a=i(246733),c=i(103221),u=i(755785),h=i(413225),d=i(142119),p=i(879617),_=i(627172),f=i(230058),m=i(574809),v=i(470130),g=i(86441),P=i(9640),y=i(315801),S=i(43192),b=i(638456);class x extends S.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){var t,i,s,r;const n=this._data,o=n.lineWidth,l=n.vertOffset||0,a=(0,P.interactionTolerance)().series+o,c=null!==(i=null===(t=n.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,u=null!==(r=null===(s=n.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:n.items.length;for(let t=c;t{const t=(0,r.rgbToHsl)((0,r.parseRgb)(e)),i=t[0]+.05;return t[0]=i-Math.floor(i),(0,r.rgbToHexString)((0,r.hslToRgb)(t))},B=(0,u.memoize)(L),R=new Set([V.LineStudyPlotStyle.Line,V.LineStudyPlotStyle.Area,V.LineStudyPlotStyle.Circles,V.LineStudyPlotStyle.Cross,V.LineStudyPlotStyle.StepLine,V.LineStudyPlotStyle.StepLineWithDiamonds]);class N extends D.StudyPaneViewInplaceUpdatable{constructor(e,t,i,s,r=!1){super(t,i,s),this._histogramBase=null,this._lineColor="",this._lineWidth=1,this._color1="",this._color2="",this._renderer=new d.CompositeRenderer,this._isMarkersEnabled=n.enabled("source_selection_markers"),this._study=e,this._plotIndex=e.metaInfo().plots.findIndex((e=>e.id===s)),this._colorProvider=(0,M.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s),this._extendStepLineToBarsEndings=r,this._isFundamental=(0,v.isFundamentalStudyMetaInfo)(e.metaInfo());const o=this._study.properties().styles[this._plotName].plottype.value();this._isStepLinePlot=o===V.LineStudyPlotStyle.StepLine||o===V.LineStudyPlotStyle.StepLineWithBreaks||o===V.LineStudyPlotStyle.StepLineWithDiamonds}items(){return this._items}renderer(){return this._makeSureRendererIsValid(),this._renderer}_getTranspValue(){const e=this._study.properties(),t=e.styles[this._plotName];let i=0;const s=this._study.metaInfo();return"Volume@tv-basicstudies"===s.id&&s.version<=46&&"transparency"in e?(i=e.transparency.value(),i=(0,l.isNumber)(i)?i:0,i):(t.transparency&&(i=t.transparency.value(),i=(0,l.isNumber)(i)?i:0),i)}_updateImplFull(e){var t,i,r;if(this._renderer.clear(), (null===(t=this._dataInvalidated)||void 0===t?void 0:t.clearData)&&(this._items=[]),!this._study.isPlotVisibleAt(this._plotName,1))return!1;if(!this._study.priceScale())return!1;if(null===this._study.firstValue(void 0,this.isForceOverlay()))return!1;if(null===this._study.priceScale())return!1;this._histogramBase=null;const n=this._study.properties().styles[this._plotName],l=n.plottype.value(),u=this._isFundamental&&this._isStepLinePlot,h=this._study.plots().plottableRange(u);if(0===h.size())return!1;const d=this._study.offset(this._plotName),p=R.has(l),_=this._preallocateItems(h,((e,t)=>({y:NaN,left:NaN,center:NaN,right:NaN,origPrices:{price:null!=t?t:NaN,timePointIndex:e+d},timePointIndex:e+d})));let f=NaN,v=NaN;const g=new Map,P=(e,t)=>{let i=g.get(e);void 0===i&&(i=new Map,g.set(e,i));let s=i.get(t);if(void 0===s){const r=!this._plotName||"vol"!==this._plotName;s=(0,a.generateColor)(e,t,r),i.set(t,s)}return s},y=(0,m.createEmptyStyle)(),S=(0,o.clamp)(this._getTranspValue(),0,100),b=this._model.timeScale().visibleBarsStrictRange();if(null===b)return!1;const{startBar:x,endBar:C}=this._calculateStartEnd(b);if(null===x||null===C||0===this._items.length)return!1;const w=null!=_?_:(0,s.ensureNotNull)(h.firstIndex()),T=(0,s.ensureNotNull)(h.lastIndex())+1,I=h.rangeIterator(w,T);let V,M=(0,A.lowerbound)(this._items,w+d,((e,t)=>e.timePointIndex0&&(this._items[M].breakBefore=!0),v=o,f=t,M++,V=c}if(V&&this._isFundamental&&this._isStepLinePlot){const e=this._model.mainSeries().data().bars().lastIndex(),t=V;if(null!==e&&e>t.timePointIndex){const i=(0,c.deepCopy)(t);i.timePointIndex=e,i.valIsNotSameAsPrev=!1,this._items.length>M?this._items[M]=i:this._items.push(i)}}return this._updateImplLight(),!0}_correctVisibleItemIndexes(e,t){const i=super._correctVisibleItemIndexes(e,t);return this._isFundamental&&this._isStepLinePlot&&i.endItemIndex===this._items.length-1&&(i.endItemIndex+=1),i}_updateRenderer(e,t){var i,r;this._renderer.clear();const n=this._study.properties().styles.childs()[this._plotName].childs(),u=null===(i=this._study.metaInfo().styles)||void 0===i?void 0:i[this._plotName],d=(0,o.clamp)(this._getTranspValue(),0,100);this._lineColor=(0,a.generateColor)(n.color.value(),d),this._lineWidth=n.linewidth.value();let m=n.color.value();const v=this._colorProvider.getDefaultPlotPointStyle();v&&(m=v.colors[0]||m,this._lineWidth=null!==(r=v.lineWidth)&&void 0!==r?r:this._lineWidth, this._lineColor=m?(0,a.generateColor)(m,d):this._lineColor),this._color2=(0,a.generateColor)(m,d);const g=this._study.metaInfo().isRGB?L(m):B(m);this._color1=(0,a.generateColor)(g,d);const P=this._histogramBase?this._histogramBase:(0,s.ensureNotNull)(this._study.priceScale()).height(),y=n.plottype.value(),S={barSpacing:this._model.timeScale().barSpacing(),items:this._items,histogramBase:P,lineIndex:0,lineStyle:n.linestyle.value(),lineColor:this._lineColor,lineWidth:(0,l.isNumber)(this._lineWidth)?this._lineWidth:1,color1:this._color1,color2:this._color2,bottom:P,visibleItemsRange:{startItemIndex:e,endItemIndex:t},simpleMode:this._colorProvider.singleColor(),skipHoles:[V.LineStudyPlotStyle.Line,V.LineStudyPlotStyle.Area,V.LineStudyPlotStyle.Cross,V.LineStudyPlotStyle.Circles,V.LineStudyPlotStyle.StepLine,V.LineStudyPlotStyle.StepLineWithDiamonds].includes(y)},b=this._renderer,w=Boolean(null==u?void 0:u.joinPoints);switch(y){case V.LineStudyPlotStyle.Line:case V.LineStudyPlotStyle.LineWithBreaks:b.append(new p.PaneRendererLine(S));break;case V.LineStudyPlotStyle.Area:case V.LineStudyPlotStyle.AreaWithBreaks:b.append(new h.PaneRendererArea(S));break;case V.LineStudyPlotStyle.Histogram:b.append(new I(S));break;case V.LineStudyPlotStyle.Columns:b.append(new C.PaneRendererColumns(S));break;case V.LineStudyPlotStyle.Cross:b.append(new T(S)),w&&b.append(new p.PaneRendererLine({...(0,c.deepCopy)(S),lineWidth:1,forceLineWidth:!0}));break;case V.LineStudyPlotStyle.Circles:b.append(new x(S)),w&&b.append(new p.PaneRendererLine({...(0,c.deepCopy)(S),lineWidth:1,ignorePaletteLineWidth:!0}));break;case V.LineStudyPlotStyle.StepLine:case V.LineStudyPlotStyle.StepLineWithBreaks:case V.LineStudyPlotStyle.StepLineWithDiamonds:{const e=new _.PaneRendererStepLine;e.setData({...S,decoration:n.plottype.value()===V.LineStudyPlotStyle.StepLineWithDiamonds?_.StepLineDecoration.Diamonds:_.StepLineDecoration.None,extendToBarsEndings:this._extendStepLineToBarsEndings}),b.append(e);break}default:b.append(new p.PaneRendererLine(S))}this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&this._selectionData&&b.append(new f.SelectionRenderer(this._selectionData))}_updateAdditionalPrices(e,t){var i;const s=null===(i=this._study.metaInfo().styles)||void 0===i?void 0:i[this._plotName];void 0!==(null==s?void 0:s.histogramBase)&&(this._histogramBase=e.priceToCoordinate(s.histogramBase,t))}}},821885:(e,t,i)=>{i.d(t,{PaneRendererAbstractFillStrokeShape:()=>m,PaneRendererAbstractShape:()=>_,PaneRendererAbstractStrokeShape:()=>f});var s=i(650151),r=i(86441),n=i(934026),o=i(150335),l=i(315801),a=i(318041),c=i(600642),u=i(422333),h=i(43192),d=i(199471),p=i(638456);class _ extends h.BitmapCoordinatesPaneRenderer{constructor(e,t={skipRenderingOptimizations:!1}){super(),this._items=[],this._barSpacing=0,this._vertOffset=0,this._textCache=t.textCache||new a.TextImageCachesContainer(5e3),this._drawOperation=t.skipRenderingOptimizations?this._drawWithoutOptimizations.bind(this):this._drawWithOptimizations.bind(this),null!==e&&this.setData(e)} hitTest(e){const t=l.HitTarget.Regular;let i=null;for(const s of this._items){if(!s)continue;const r=this._calcBoundingBox(s);if(r&&(0,n.pointInBox)(e,r)){const e={tooltip:this._getTooltip(s,r)};i=new l.HitTestResult(t,e)}}return i}setData(e){var t,i,s,r;if(this._height=void 0!==e.height?e.height:e.width,this._width=void 0!==e.width?e.width:e.height,this._color=e.color,this._borderColor=e.borderColor,this._vertOffset=e.vertOffset||0,e.text&&(this._text=e.text,this._fontSize=e.fontSize,this._lineSpacing=e.lineSpacing,this._textColor=e.textColor,this._textAlign=e.textAlign||"center"),void 0!==e.items&&void 0!==e.barSpacing){const n=null!==(i=null===(t=e.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,o=null!==(r=null===(s=e.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:e.items.length;this.setItems(o>n?e.items.slice(n,o):[],e.barSpacing)}}setItems(e,t){this._setBaseData(e,t)}_drawImpl(e){this._preDrawInit(),this._drawOperation(e)}_calcBoundingBox(e){const t=e.vertOffset,i=this._getTextCache(e);if(!i)return;const s=i.textImageWidth,n=i.textImageHeight,o=s/2,l=e.y+t+e.textVertOffset,a=t>0?0:-n,c=t>0?n:0,u=new r.Point(e.center-o,l+a),h=new r.Point(e.center+o,l+c);return(0,r.box)(u,h)}_unionBox(e,t){const i=Math.min(e.min.x,t.min.x),s=Math.max(e.max.x,t.max.x),n=Math.min(e.min.y,t.min.y),o=Math.max(e.max.y,t.max.y),l=new r.Point(i,n),a=new r.Point(s,o);return(0,r.box)(l,a)}_getTooltip(e,t){if(e.tooltip)return{content:{type:"text",data:e.tooltip},tooltipDelay:200,extendMargin:!0,rect:{x:t.min.x,y:t.min.y,w:Math.abs(t.max.x-t.min.x),h:Math.abs(t.max.y-t.min.y)}}}_setBaseData(e,t){this._items.length=0,this._barSpacing=t;for(const t of e){if((0,o.isNaN)(t.y))continue;const e=void 0===t.width?(0,s.ensureDefined)(this._width):t.width,i=void 0===t.height?(0,s.ensureDefined)(this._height):t.height,r=void 0===t.vertOffset?this._vertOffset:t.vertOffset,n=r>0?i:-i;this._items.push({width:e,height:i,vertOffset:r,textVertOffset:n,shapeWidth:0,shapeHeight:0,stepX:0,stepY:0,...t})}}_drawItemText(e,t){const i=this._getTextCache(t);if(null===i)return;const s=t.center,r=t.vertOffset,n=t.y+r+t.textVertOffset;let o;o=t.style&&void 0!==t.style.textColor?t.style.textColor:this._textColor;const l={style:{fillStyle:o},location:{x:s,y:n,horzAlign:c.HorizontalAlign.Center,vertAlign:r>0?c.VerticalAlign.Top:c.VerticalAlign.Bottom}};i.paintTo(e,l)}_drawWithOptimizations(e){let t,i,s=null,r=!1;for(const n of this._items)(0,o.isNaN)(n.y)||(n.style&&void 0!==n.style.color?(t=n.style.color||"rgba(0, 0, 0, 0)",i=n.style.borderColor||"rgba(0, 0, 0, 0)"):(t=this._color,i=this._borderColor),(s!==t||p.isSafari)&&(s=t,r&&this._endPath(e),this._startPath(e,t,i)),this._drawItemShape(e,n),r=!0);r&&this._endPath(e);for(const t of this._items)(0,o.isNaN)(t.y)||this._drawItemText(e,t)}_drawWithoutOptimizations(e){let t,i;for(const r of this._items){if((0,o.isNaN)(r.y))continue;const n=(0,s.ensureDefined)(r.style);t=n.color||"rgba(0, 0, 0, 0)",i=n.borderColor||"rgba(0, 0, 0, 0)",this._startPath(e,t,i), this._drawItemShape(e,r),this._endPath(e),this._drawItemText(e,r)}}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r}=e;(0,d.drawScaled)(i,s,r,(()=>this._drawItemShapeUsingCSSPixels(i,t)))}_drawItemShapeUsingCSSPixels(e,t){}_preDrawInit(){}_startPath(e,t,i){}_endPath(e){}_getTextCache(e){var t,i;const s=e.text||this._text,r=e.fontSize||this._fontSize,n=null!==(t=e.lineSpacing)&&void 0!==t?t:this._lineSpacing,o=e.textAlign||this._textAlign,l=null!==(i=e.font)&&void 0!==i?i:u.CHART_FONT_FAMILY;return this._textCache.get({text:s,bold:!1,italic:!1,font:l,fontSize:r,lineSpacing:n,align:o})}}class f extends _{_startPath(e,t,i){const s=e.context;s.beginPath(),s.lineWidth=this._lineWidth(e),s.lineCap="butt",s.strokeStyle=t}_endPath(e){e.context.stroke()}_lineWidth(e){return Math.max(1,Math.floor(2*e.horizontalPixelRatio))}}class m extends _{_startPath(e,t,i){const s=e.context;s.beginPath(),s.lineWidth=this._lineWidth(e),s.lineCap="butt",s.fillStyle=t,s.strokeStyle=i}_endPath(e){const t=e.context;t.fill(),t.stroke()}_lineWidth(e){return Math.max(1,Math.floor(e.horizontalPixelRatio))}}},111595:(e,t,i)=>{i.d(t,{PaneRendererArrowDown:()=>a,PaneRendererArrowUp:()=>l});var s=i(86441),r=i(821885),n=i(678515);class o extends r.PaneRendererAbstractFillStrokeShape{constructor(){super(...arguments),this._sign=0,this._thinArrow=!1,this._thinArrowLineWidth=0,this._headHeight=0,this._arrowWidth=0}setItems(e,t){this._setBaseData(e,t)}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r}=e,o=this._lineWidth(e)%2?.5:0,l=this._sign,a=this._arrowWidth,c=this._headHeight,u=Math.abs(t.height),h=Math.round(t.center*s)+o,d=t.vertOffset,p=Math.round((t.y+d+l*u/2)*r)+o,_=(0,n.ceiledEven)(a*s),f=_/2,m=Math.round(u*r),v=Math.round(c*r);i.translate(h,p),this._thinArrow?(i.moveTo(0,0),i.lineTo(-f,-f*l),i.moveTo(0,0),i.lineTo(f,-f*l),i.moveTo(0,0),i.lineTo(0,-m*l),i.moveTo(-f,-m*l),i.lineTo(f,-m*l)):(i.moveTo(0,0),m{i.d(t,{PaneRendererCircleShape:()=>o});var s=i(86441),r=i(821885);const n=2*Math.PI ;class o extends r.PaneRendererAbstractFillStrokeShape{_drawItemShapeUsingCSSPixels(e,t){const i=Math.max(t.width,t.height)/2,s=t.center,r=t.vertOffset,o=t.y+r;e.moveTo(s+i,o),e.arc(s,o,i,0,n,!1)}_calcBoundingBox(e){const t=Math.max(e.width,e.height)/2,i=e.center,r=e.vertOffset,n=e.y+r,o=i-t,l=i+t,a=n-t,c=n+t,u=new s.Point(o,a),h=new s.Point(l,c);let d=(0,s.box)(u,h);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}}},506366:(e,t,i)=>{i.d(t,{PaneRendererCrossShape:()=>n});var s=i(86441),r=i(821885);class n extends r.PaneRendererAbstractStrokeShape{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r}=e,n=t.width,o=t.height,l=t.center-n/2,a=t.vertOffset,c=t.y-o/2+a,u=this._lineWidth(e),h=u%2?.5:0,d=Math.round(l*s);let p=Math.round((l+n)*s);(p-d)%2!=u%2&&(p+=1);const _=Math.floor((d+p)/2)+h,f=Math.round(c*r);let m=Math.round((c+o)*r);(m-f)%2!=u%2&&(m+=1);const v=Math.floor((f+m)/2)+h;i.moveTo(_,f),i.lineTo(_,m),i.moveTo(d,v),i.lineTo(p,v)}_calcBoundingBox(e){const t=e.width,i=e.height,r=e.center-t/2,n=e.vertOffset,o=e.y-i/2+n,l=r,a=r+t,c=o,u=o+i,h=new s.Point(l,c),d=new s.Point(a,u);let p=(0,s.box)(h,d);const _=super._calcBoundingBox(e);return _&&(p=this._unionBox(p,_)),p}}},992885:(e,t,i)=>{i.d(t,{PaneRendererDiamond:()=>n});var s=i(86441),r=i(821885);class n extends r.PaneRendererAbstractFillStrokeShape{_drawItemShapeUsingCSSPixels(e,t){const i=Math.round(t.height/2),s=t.center,r=t.vertOffset,n=t.y+r;e.moveTo(s,n-i),e.lineTo(s+i,n),e.lineTo(s,n+i),e.lineTo(s-i,n),e.lineTo(s,n-i)}_calcBoundingBox(e){const t=Math.round(e.height/2),i=e.center,r=e.vertOffset,n=e.y+r,o=i-t,l=i+t,a=n-t,c=n+t,u=new s.Point(o,a),h=new s.Point(l,c);let d=(0,s.box)(u,h);const p=super._calcBoundingBox(e);return p&&(d=this._unionBox(d,p)),d}}},618241:(e,t,i)=>{i.d(t,{PaneRendererFlagShape:()=>n});var s=i(86441),r=i(821885);class n extends r.PaneRendererAbstractFillStrokeShape{_drawItemShapeUsingCSSPixels(e,t){const i=t.width,s=t.height,r=s/2,n=(i-3)/3,o=t.center-i/2,l=t.vertOffset,a=t.y-r+l;e.moveTo(o,a),e.lineTo(o+3,a),e.bezierCurveTo(o+n,a-n,o+2*n,a+n,o+i,a),e.lineTo(o+i,a+r),e.bezierCurveTo(o+i-n,a+r+n,o+i-2*n,a+r-n,o+3,a+r),e.lineTo(o+3,a+s),e.lineTo(o,a+s),e.lineTo(o,a)}_calcBoundingBox(e){const t=e.width,i=e.height,r=i/2,n=e.center-t/2,o=e.vertOffset,l=e.y-r+o,a=n,c=n+t,u=l,h=l+i,d=new s.Point(a,u),p=new s.Point(c,h);let _=(0,s.box)(d,p);const f=super._calcBoundingBox(e);return f&&(_=this._unionBox(_,f)),_}}},379730:(e,t,i)=>{i.d(t,{CornerVectorsClockwise:()=>s,PaneRendererLabelBase:()=>l});var s,r=i(650151),n=i(821885),o=i(600642);class l extends n.PaneRendererAbstractFillStrokeShape{setItems(e,t){this._setBaseData(e,t);for(const e of this._items){if(e.fontSize){const t=e.fontSize;e.stepX=Math.round(t/1.5),e.stepY=Math.round(t/2)-1}else{const t=e.height;e.stepX=Math.round(t/2*.65)+.5,e.stepY=e.stepX}e.vertOffset=this._calcVertOffset(e);const t=this._getTextCache(e);if(null===t){e.shapeWidth=2*e.stepX,e.shapeHeight=2.5*e.stepY;continue}const i=t.textImageWidth,s=t.textImageHeight ;e.shapeWidth=i+2*e.stepX,e.shapeHeight=s+2*e.stepY,e.vertOffset=this._calcVertOffset(e),e.textHorizOffset=this._getHorizontalTextOffset(e),e.textVertOffset=this._getVerticalTextOffset(e)}}_calcVertOffset(e){return e.vertOffset}_drawCorner(e,t,i,s){const{context:r,horizontalPixelRatio:n}=e,o=Math.max(1,Math.floor(2*n));r.lineTo(t-o*s.prevPointSignX,i-o*s.prevPointSignY),r.arcTo(t,i,t+o*s.nextPointSignX,i+o*s.nextPointSignY,o)}_getArrowSize(e){return e.stepX}_getHorizontalTextOffset(e){return 0}_getVerticalTextOffset(e){return 0}_hasText(e){return Boolean(e.text)||Boolean(this._text)}_drawItemText(e,t){var i;const s=this._getTextCache(t);if(null===s)return;const n=t.textHorizOffset||0,l=t.center+n,a=t.vertOffset,c=t.y+a+t.textVertOffset,u=(null===(i=t.style)||void 0===i?void 0:i.textColor)||this._textColor,h={style:{fillStyle:(0,r.ensureDefined)(u)},location:{x:l,y:Math.floor(c),horzAlign:o.HorizontalAlign.Center,vertAlign:o.VerticalAlign.Middle}};s.paintTo(e,h)}}class a{constructor(e,t,i,s){this.prevPointSignX=e,this.prevPointSignY=t,this.nextPointSignX=i,this.nextPointSignY=s}}!function(e){e.rightUp=new a(1,0,0,1),e.rightDown=new a(0,1,-1,0),e.leftDown=new a(-1,0,0,-1),e.leftUp=new a(0,-1,1,0)}(s||(s={}))},778190:(e,t,i)=>{i.d(t,{PaneRendererLabelCenter:()=>c,PaneRendererLabelDown:()=>o,PaneRendererLabelLeft:()=>l,PaneRendererLabelRight:()=>a,PaneRendererLabelUp:()=>n});var s=i(86441),r=i(379730);class n extends r.PaneRendererLabelBase{_calcBoundingBox(e){const t=e.center-e.shapeWidth/2,i=e.center+e.shapeWidth/2,r=e.y+e.vertOffset,n=e.y+e.shapeHeight+e.vertOffset,o=new s.Point(t,r),l=new s.Point(i,n);return(0,s.box)(o,l)}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:n}=e,o=this._lineWidth(e)%2?.5:0,l=Math.max(1,Math.floor(s))%2?.5:0,a=this._getArrowSize(t);let c=Math.round(a*s);(l+c)%1!=o%1&&(c+=.5);let u=Math.round(t.shapeWidth/2*s);(l+u)%1!=o%1&&(u+=.5);const h=Math.round(t.center*s)+l,d=Math.round((t.y+t.vertOffset)*n)+o,p=h-c,_=Math.round((t.y+t.vertOffset+a)*n)+o,f=h+c,m=h+u,v=Math.round((t.y+t.vertOffset+a+t.shapeHeight)*n)+o,g=h-u;i.moveTo(p,_),i.lineTo(h,d),i.lineTo(f,_),t.shapeWidth<=2*a?(i.lineTo(m,_),this._drawCorner(e,m,v,r.CornerVectorsClockwise.rightDown),this._drawCorner(e,g,v,r.CornerVectorsClockwise.leftDown),i.lineTo(g,_)):(this._drawCorner(e,m,_,r.CornerVectorsClockwise.rightUp),this._drawCorner(e,m,v,r.CornerVectorsClockwise.rightDown),this._drawCorner(e,g,v,r.CornerVectorsClockwise.leftDown),this._drawCorner(e,g,_,r.CornerVectorsClockwise.leftUp)),i.lineTo(p,_)}_getVerticalTextOffset(e){return e.shapeHeight/2+this._getArrowSize(e)}_calcVertOffset(e){return Math.sign(e.vertOffset)>=0?e.vertOffset:e.vertOffset-e.shapeHeight}}class o extends r.PaneRendererLabelBase{_calcBoundingBox(e){const t=e.center-e.shapeWidth/2,i=e.center+e.shapeWidth/2,r=e.y-e.shapeHeight+e.vertOffset,n=e.y+e.vertOffset,o=new s.Point(t,r),l=new s.Point(i,n);return(0,s.box)(o,l)}_drawItemShape(e,t){ const{context:i,horizontalPixelRatio:s,verticalPixelRatio:n}=e,o=this._lineWidth(e)%2?.5:0,l=Math.max(1,Math.floor(s))%2?.5:0,a=this._getArrowSize(t);let c=Math.round(a*s);(l+c)%1!=o%1&&(c+=.5);let u=Math.round(t.shapeWidth/2*s);(l+u)%1!=o%1&&(u+=.5);const h=Math.round(t.center*s)+l,d=Math.round((t.y+t.vertOffset)*n)+o,p=h+c,_=Math.round((t.y+t.vertOffset-a)*n)+o,f=h-c,m=h+u,v=Math.round((t.y+t.vertOffset-t.shapeHeight-a)*n)+o,g=h-u;i.moveTo(p,_),i.lineTo(h,d),i.lineTo(f,_),t.shapeWidth<=2*a?(i.lineTo(g,_),this._drawCorner(e,g,v,r.CornerVectorsClockwise.leftUp),this._drawCorner(e,m,v,r.CornerVectorsClockwise.rightUp),i.lineTo(m,_)):(this._drawCorner(e,g,_,r.CornerVectorsClockwise.leftDown),this._drawCorner(e,g,v,r.CornerVectorsClockwise.leftUp),this._drawCorner(e,m,v,r.CornerVectorsClockwise.rightUp),this._drawCorner(e,m,_,r.CornerVectorsClockwise.rightDown)),i.lineTo(p,_)}_getVerticalTextOffset(e){return-e.shapeHeight/2-this._getArrowSize(e)}_calcVertOffset(e){return Math.sign(e.vertOffset)<=0?e.vertOffset:e.vertOffset+e.shapeHeight}}class l extends r.PaneRendererLabelBase{_calcBoundingBox(e){const t=e.center,i=e.center+e.shapeWidth,r=e.y-e.shapeHeight/2+e.vertOffset,n=e.y+e.shapeHeight/2+e.vertOffset,o=new s.Point(t,r),l=new s.Point(i,n);return(0,s.box)(o,l)}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:n}=e,o=this._lineWidth(e)%2?.5:0,l=this._getArrowSize(t),a=this._hasText(t),c=a?t.shapeHeight/2:l,u=Math.round(t.center*s)+o,h=Math.round((t.y+t.vertOffset)*n)+o,d=Math.round((t.center+l)*s)+o,p=Math.round((t.y+t.vertOffset+l)*n)+o,_=Math.round((t.y+t.vertOffset-l)*n)+o,f=Math.round((t.y+t.vertOffset-c)*n)+o,m=Math.round((t.center+t.shapeWidth+l)*s)+o,v=Math.round((t.y+t.vertOffset+c)*n)+o;i.moveTo(d,p),i.lineTo(u,h),i.lineTo(d,_),a?this._drawCorner(e,d,f,r.CornerVectorsClockwise.leftUp):i.lineTo(d,f),this._drawCorner(e,m,f,r.CornerVectorsClockwise.rightUp),this._drawCorner(e,m,v,r.CornerVectorsClockwise.rightDown),a?this._drawCorner(e,d,v,r.CornerVectorsClockwise.leftDown):i.lineTo(d,v),i.lineTo(d,p)}_getHorizontalTextOffset(e){return e.shapeWidth/2+this._getArrowSize(e)}}class a extends r.PaneRendererLabelBase{_calcBoundingBox(e){const t=e.center-e.shapeWidth,i=e.center,r=e.y-e.shapeHeight/2+e.vertOffset,n=e.y+e.shapeHeight/2+e.vertOffset,o=new s.Point(t,r),l=new s.Point(i,n);return(0,s.box)(o,l)}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:n}=e,o=this._lineWidth(e)%2?.5:0,l=this._getArrowSize(t),a=this._hasText(t),c=a?t.shapeHeight/2:l,u=Math.round(t.center*s)+o,h=Math.round((t.y+t.vertOffset)*n)+o,d=Math.round((t.center-l)*s)+o,p=Math.round((t.y+t.vertOffset-l)*n)+o,_=Math.round((t.y+t.vertOffset+l)*n)+o,f=Math.round((t.y+t.vertOffset-c)*n)+o,m=Math.round((t.center-t.shapeWidth-l)*s)+o,v=Math.round((t.y+t.vertOffset+c)*n)+o;i.moveTo(d,p),i.lineTo(u,h),i.lineTo(d,_),a?this._drawCorner(e,d,v,r.CornerVectorsClockwise.rightDown):i.lineTo(d,v),this._drawCorner(e,m,v,r.CornerVectorsClockwise.leftDown), this._drawCorner(e,m,f,r.CornerVectorsClockwise.leftUp),a?this._drawCorner(e,d,f,r.CornerVectorsClockwise.rightUp):i.lineTo(d,f),i.lineTo(d,p)}_getHorizontalTextOffset(e){return-e.shapeWidth/2-this._getArrowSize(e)}}class c extends r.PaneRendererLabelBase{_calcBoundingBox(e){const t=e.center-e.shapeWidth/2,i=e.center+e.shapeWidth/2,r=e.y-e.shapeHeight/2+e.vertOffset,n=e.y+e.shapeHeight/2+e.vertOffset,o=new s.Point(t,r),l=new s.Point(i,n);return(0,s.box)(o,l)}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:n}=e,o=this._lineWidth(e)%2?.5:0,l=t.shapeHeight/2,a=t.shapeWidth/2,c=Math.round(t.center*s)+o,u=Math.round((t.center-a)*s)+o,h=Math.round((t.center+a)*s)+o,d=Math.round((t.y+t.vertOffset-l)*n)+o,p=Math.round((t.y+t.vertOffset+l)*n)+o;i.moveTo(c,d),this._drawCorner(e,h,d,r.CornerVectorsClockwise.rightUp),this._drawCorner(e,h,p,r.CornerVectorsClockwise.rightDown),this._drawCorner(e,u,p,r.CornerVectorsClockwise.leftDown),this._drawCorner(e,u,d,r.CornerVectorsClockwise.leftUp),i.lineTo(c,d)}}},29164:(e,t,i)=>{i.d(t,{PaneRendererSquare:()=>n});var s=i(86441),r=i(821885);class n extends r.PaneRendererAbstractFillStrokeShape{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r}=e,n=Math.max(1,Math.floor(s))%2?.5:0,o=this._lineWidth(e)%2?.5:0;let l=Math.round(t.height/2*r);(n+l)%1!=o%1&&(l+=.5);const a=Math.round(t.center*s)+n,c=Math.round((t.y+t.vertOffset)*r)+n,u=a-l,h=c-l,d=a+l,p=c+l;i.rect(u,h,d-u,p-h)}_calcBoundingBox(e){const t=e.height,i=Math.round(t/2),r=e.center-i,n=e.vertOffset,o=e.y+n-i,l=r,a=r+t,c=o,u=o+t,h=new s.Point(l,c),d=new s.Point(a,u);let p=(0,s.box)(h,d);const _=super._calcBoundingBox(e);return _&&(p=this._unionBox(p,_)),p}}},119914:(e,t,i)=>{i.d(t,{PaneRendererTriangleApexDown:()=>l,PaneRendererTriangleApexUp:()=>o});var s=i(86441),r=i(821885);class n extends r.PaneRendererAbstractFillStrokeShape{_calcBoundingBox(e){const t=e.width,i=e.height,r=t/2,n=Math.round(i/3),o=e.center,l=e.vertOffset-2*n,a=e.y+l,c=o-r,u=o+r,h=a,d=a+i,p=new s.Point(c,h),_=new s.Point(u,d);let f=(0,s.box)(p,_);const m=super._calcBoundingBox(e);return m&&(f=this._unionBox(f,m)),f}}class o extends n{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r}=e,n=t.width,o=t.height,l=Math.round(o/3),a=t.vertOffset-2*l,c=this._lineWidth(e)%2?.5:0,u=Math.max(1,Math.floor(s)),h=u%2?.5:0;let d=Math.round(n*s);d%2!=u%2&&(d+=1);const p=Math.round(t.center*s)+h,_=Math.round((t.y+a)*r),f=p+d/2,m=Math.round((t.y+a+o)*r)+c,v=p-d/2;i.moveTo(p,_),i.lineTo(f,m),i.lineTo(v,m),i.lineTo(p,_)}}class l extends n{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:r}=e,n=t.width,o=t.height,l=Math.round(o/3),a=t.vertOffset-l,c=this._lineWidth(e)%2?.5:0,u=Math.max(1,Math.floor(s)),h=u%2?.5:0;let d=Math.round(n*s);d%2!=u%2&&(d+=1);const p=Math.round(t.center*s)+h,_=Math.round((t.y+a)*r)+c,f=p+d/2,m=Math.round((t.y+a+o)*r),v=p-d/2;i.moveTo(v,_),i.lineTo(f,_),i.lineTo(p,m),i.lineTo(v,_)}}},815555:(e,t,i)=>{i.d(t,{PaneRendererXCross:()=>n}) ;var s=i(86441),r=i(821885);class n extends r.PaneRendererAbstractStrokeShape{_drawItemShapeUsingCSSPixels(e,t){const i=t.width,s=t.height,r=t.center-i/2,n=t.vertOffset,o=t.y-s/2+n;e.moveTo(r,o),e.lineTo(r+i,o+s),e.moveTo(r,o+s),e.lineTo(r+i,o)}_calcBoundingBox(e){const t=e.width,i=e.height,r=e.center-t/2,n=e.vertOffset,o=e.y-i/2+n,l=r,a=r+t,c=o,u=o+i,h=new s.Point(l,c),d=new s.Point(a,u);let p=(0,s.box)(h,d);const _=super._calcBoundingBox(e);return _&&(p=this._unionBox(p,_)),p}}},106492:(e,t,i)=>{i.d(t,{StudyForceOverlayPlotView:()=>s});class s{constructor(e,t,i){this._series=e,this._model=t,this._plotName=i}isForceOverlay(){return!!this._study.metaInfo().isPlotForceOverlay(this._plotName)}_priceScale(){return this.isForceOverlay()?this._model.mainSeries().priceScale():this._study.priceScale()}}},928483:(e,t,i)=>{i.d(t,{StudyPaneViewInplaceUpdatable:()=>h});var s=i(650151),r=i(86441),n=i(272933),o=i(534741),l=i(674981),a=i(63316),c=i(315801),u=i(106492);class h extends u.StudyForceOverlayPlotView{constructor(e,t,i){super(e,t,i),this._selectionData=null,this._dataInvalidated=null,this._viewportInvalidated=!1,this._items=[],this._selectionIndexer=new a.SelectionIndexes(t.timeScale())}update(e){if("global-change"===e.type)return this._dataInvalidated=(0,n.mergeDataInvalidation)(this._dataInvalidated,{}),void(this._viewportInvalidated=!0);if("data-source-change"!==e.type)this._viewportInvalidated=!0;else{if((e.sourceId===this._study.id()||this._dependsOnSeriesData()&&e.sourceId===this._model.mainSeries().id())&&!e.nonSeriesOnly){const t=(0,n.mergeDataInvalidation)(this._dataInvalidated,{firstIndex:e.firstUpdatedTimePointIndex,clearData:e.clearData});this._dataInvalidated=t}}}_dependsOnSeriesData(){return!1}_makeSureRendererIsValid(){this._dataInvalidated?this._updateImplFull(this._viewportInvalidated)&&(this._dataInvalidated=null):this._viewportInvalidated&&this._updateImplLight(),this._viewportInvalidated=!1}_preallocateItems(e,t){var i,r;const n=e.size(),o=null===(i=this._dataInvalidated)||void 0===i?void 0:i.firstIndex;if(0===n)return o;const a=this._study.offset(this._plotName);if(n!==this._items.length){const i=void 0!==o?o+a:void 0;if(void 0===i||0===this._items.length||i<(0,s.ensureDefined)(this._items[0].timePointIndex))return this._items=[],e.each(((e,i)=>{const s=i[this._plotIndex+1];return this._items.push(t(e,s)),!1})),this._items.length?(0,s.ensureDefined)(this._items[0].timePointIndex)-a:void 0;{const i=(0,s.ensureDefined)(o),n=a>=0?0:a,c=a>=0?a:0;let u=(0,l.lowerbound)(this._items,i+n,((e,t)=>e.timePointIndex=0?0:a,i=a>=0?a:0;let r=(0,l.lowerbound)(this._items,o+t,((e,t)=>e.timePointIndexr+1)return{startBar:null,endBar:null};let l=this._study.plots();l=l.range(n,(0,s.ensureNotNull)(l.lastIndex())),i=Math.max(i,n),r=Math.max(r,n);const a=l.search(i,o.PlotRowSearchMode.NearestLeft,this._plotIndex+1),c=l.search(r,o.PlotRowSearchMode.NearestRight,this._plotIndex+1);return null!==a&&(i=a.index),null!==c&&(r=c.index),i=Math.max(n,i),{startBar:i,endBar:r}}_updateImplLight(){const e=this._study.firstValue(void 0,this.isForceOverlay());if(null===e)return this._selectionData=null,void this._updateRenderer(0,-1);const t=this._priceScale();if(null===t)return this._selectionData=null,void this._updateRenderer(0,-1);const i=this._model.timeScale().visibleBarsStrictRange();if(null===i)return this._selectionData=null,void this._updateRenderer(0,-1);const{startBar:s,endBar:r}=this._calculateStartEnd(i);if(null===s||null===r||0===this._items.length)return this._selectionData=null,void this._updateRenderer(0,-1);const{startItemIndex:n,endItemIndex:o}=this._correctVisibleItemIndexes(Math.max(0,(0,l.lowerbound)(this._items,s,((e,t)=>e.timePointIndexe=o)return this._selectionData=null,void this._updateRenderer(0,-1);this._convertItemsToCoordinates(t,e,n,o),this._createSelection(e),this._updateRenderer(n,o)}_correctVisibleItemIndexes(e,t){return{startItemIndex:e,endItemIndex:t}}_convertItemsToCoordinates(e,t,i,s){this._convertItemsToCoordinatesImpl(e,t,i,s)}_convertItemsToCoordinatesImpl(e,t,i,s){for(let e=i;e{i.d(t,{createStudyPlotColorProvider:()=>p}) ;var s=i(368135),r=i(650151),n=i(574809);const o=new Map([[0,"color"],[2,"textColor"],[3,"borderColor"],[4,"wickColor"],[5,"colorup"],[6,"colordown"]]);class l{constructor(e){this._plotStyle=e}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return o.forEach(((e,t)=>{this._plotStyle[e]&&(i.colors[t]=this._plotStyle[e].value())})),i.lineWidth=this._plotStyle.linewidth?this._plotStyle.linewidth.value():void 0,i.lineStyle=this._plotStyle.linestyle?this._plotStyle.linestyle.value():void 0,i}isColorDefined(){return!0}singleColor(){return!0}getDefaultPlotPointStyle(){return null}}const a=[0,1,2,3,4,5,6];class c{constructor(e,t,i,s){this._palettesColors=new Map,this._defaultPlotColors=new Map,this._indexes=s;const n=t.styles[i];if(n)for(const[e,t]of o)this._defaultPlotColors.set(e,n[t]);const l=(0,r.ensureDefined)(e.palettes),a=e.plots;s.forEach(((e,i)=>{const s=a[e];if(s&&"palette"in s){const e=l[s.palette],r=t.palettes[s.palette];if(e&&r){const{valToIndex:t}=e,{colors:s}=r,n={...s};t&&Object.keys(t).forEach((e=>{const i=t[e];void 0!==i&&(n[e]=s[i])})),this._palettesColors.set(i,n)}}}))}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return a.forEach((t=>{var s,n;if(this._palettesColors.has(t)){const n=e[(0,r.ensureDefined)(this._indexes.get(t))+1];if("number"==typeof n){const e=null===(s=this._palettesColors.get(t))||void 0===s?void 0:s[n];0===t&&e&&(i.lineWidth=e.width.value(),i.lineStyle=e.style.value()),i.colors[t]=null==e?void 0:e.color.value()}else i.colors[t]="transparent"}else i.colors[t]=null===(n=this._defaultPlotColors.get(t))||void 0===n?void 0:n.value()})),i}getDefaultPlotPointStyle(){var e;const t=null===(e=this._palettesColors.get(0))||void 0===e?void 0:e[0];if(void 0!==t){return{colors:[t.color.value(),void 0,void 0,void 0,void 0,void 0,void 0],lineStyle:void 0,lineWidth:t.width.value()}}return null}isColorDefined(){return!!this._palettesColors.size}singleColor(){return!1}}var u=i(151149);class h{constructor(e){this._rgbaFromInteger=(0,u.rgbaFromIntegerCached)(),this._indexes=e}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return this._indexes.forEach(((t,s)=>{const r=e[t+1];if(null!=r){const e=this._rgbaFromInteger(r);i.colors[s]=e}else i.colors[s]="transparent"})),i}isColorDefined(){return!0}singleColor(){return!1}getDefaultPlotPointStyle(){return null}}const d=new Map([[0,function(e,t){const i=(0,s.isColorerPlot)(t)||(0,s.isOhlcColorerPlot)(t);return"target"in t&&t.target===e&&i}],[2,function(e,t){const i=(0,s.isTextColorerPlot)(t);return"target"in t&&t.target===e&&i}],[1,function(e,t){return(0,s.isBgColorerPlot)(t)&&t.id===e}],[3,function(e,t){const i=(0,s.isCandleBorderColorerPlot)(t);return"target"in t&&t.target===e&&i}],[4,function(e,t){const i=(0,s.isCandleWickColorerPlot)(t);return"target"in t&&t.target===e&&i}],[5,function(e,t){const i=(0,s.isUpColorerPlot)(t);return"target"in t&&t.target===e&&i}],[6,function(e,t){const i=(0,s.isDownColorerPlot)(t);return"target"in t&&t.target===e&&i}]]);function p(e,t,i){ const{colorers:s}=function(e,t){const i=e.plots,s=i.findIndex((e=>e.id===t)),r=new Map;return i.forEach(((e,i)=>{d.forEach(((s,n)=>{s(t,e)&&r.set(n,i)}))})),{plotIndex:-1===s?null:s,colorers:r}}(e,i);if(s.size)return e.isRGB?new h(s):new c(e,t,i,s);{const e=t.ohlcPlots;if(e&&e[i])return new l(e[i]);const s=t.styles[i];return new l(s)}}},537919:(e,t,i)=>{function s(e,t="shift",i){return{studyConstructor:e,colorRotationMode:t,colorRotationComparator:i}}i.d(t,{addStudyInfoToMap:()=>n,createStudyInfo:()=>s,getStudyClassName:()=>l,getStudyInfoByName:()=>o});const r=new Map;function n(e,t){r.set(e,t)}function o(e){return r.get(e)}function l(e){for(const[t,i]of r.entries())if(i.studyConstructor===e)return t;return null}},260414:(e,t,i)=>{i.d(t,{StudyBaseWindowView:()=>n});var s=i(782086),r=i(982217);class n extends s.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._study=e,this._model=t,this._valueProvider=this._createValuesProvider(e,t),this._items=this._valueProvider.getItems().map((e=>new s.DataWindowItem(e.id,e.title,""))),this.update()}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}study(){return this._study}_updateImpl(){this._header=this._study.title(r.TitleDisplayTarget.DataWindow,!0),this._title=this._study.title(r.TitleDisplayTarget.DataWindow);const e=this._valueProvider.getValues(this._currentIndex());for(let t=0;t{i.d(t,{StudyDataWindowView:()=>n});var s=i(260414),r=i(241981);class n extends s.StudyBaseWindowView{_createValuesProvider(e,t){return new r.StudyDataWindowValuesProvider(e,t)}}},989709:(e,t,i)=>{function s(e){const t=new Map;return e.plots.forEach(((e,i)=>{t.set(e.id,(e=>e[i+1]))})),t}function r(e,t){return null==e[t]}i.d(t,{studyEmptyPlotValuePredicate:()=>r,studyPlotFunctionMap:()=>s})},241981:(e,t,i)=>{i.d(t,{StudyDataWindowValuesProvider:()=>n});var s=i(103055),r=i(567467);class n{constructor(e,t){this._study=e,this._model=t,this._hhistBasedStudy=void 0!==e.metaInfo().graphics.hhists,this._valuesProvider=this._createValuesProvider(e,t)}getItems(){return this._valuesProvider.getItems()}getValues(e){const t=this._valuesProvider.getValues(e),i=e=>!!this._hhistBasedStudy||this._study.isPlotVisibleAt(e,2);for(const e of t)e.visible=e.visible&&i(e.id);return t}_createValuesProvider(e,t){return this._hhistBasedStudy?new r.HHistBasedValuesProvider(e,t):new s.StudyValuesProvider(e,t)}}},634005:(e,t,i)=>{i.d(t,{StudyLegendValuesProvider:()=>n});var s=i(103055),r=i(567467);class n{constructor(e,t,i){this._study=e,this._model=t,this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._hhistBasedStudy=void 0!==e.metaInfo().graphics.hhists,this._valuesProvider=this._createValuesProvider(e,t,i)}getItems(){ return this._valuesProvider.getItems()}getValues(e){const t=this._valuesProvider.getValues(e),i=this._study.properties(),s=this._showStudyValues.value()&&i.childs().showLegendValues.value(),r=e=>!!this._hhistBasedStudy||this._study.isPlotVisibleAt(e,8);for(const e of t)e.visible=e.visible&&s&&r(e.id);return t}_createValuesProvider(e,t,i){return this._hhistBasedStudy?new r.HHistBasedValuesProvider(e,t,i):new s.StudyValuesProvider(e,t,i)}}},347710:(e,t,i)=>{i.d(t,{emptyPineId:()=>_,isStudyDescriptor:()=>f,studyMetaInfoRepository:()=>P});var s=i(895171),r=i(444372),n=i(650151),o=i(526075),l=i(819021),a=i(854798),c=i(107973),u=i(520533),h=i(201089),d=i(268222);const p=(0,h.getLogger)("Chart.Studies.StudyMetaInfoRepository",{color:"#606"}),_="";function f(e){return"object"==typeof e&&null!==e&&"type"in e&&("java"===e.type&&"studyId"in e||"pine"===e.type&&"pineId"in e)}class m{constructor(e){this._isReady=!1,this._studyVersioning=null,this._rawStudiesMetaInfo=[],this._rawStudiesMetaInfoDeferredPromise=null,this._javaStudiesMetaInfo=[],this._pineMetaInfoCache=[],this._studiesMigrations=[],this._chartApi=e}async requestMetaInfo(){if(null===this._rawStudiesMetaInfoDeferredPromise){this._rawStudiesMetaInfoDeferredPromise=(0,d.createDeferredPromise)();const e=await this._chartApi.requestMetadata(),t=e.params[1].metainfo.slice();{const i=e.params[1].migrations.slice();this._processSiteMetaInfo(t,i)}this._studyVersioning=new c.StudyVersioning(this._javaStudiesMetaInfo,this._studiesMigrations),this._requestFinished(),this._rawStudiesMetaInfoDeferredPromise.resolve(this._rawStudiesMetaInfo)}return this._rawStudiesMetaInfoDeferredPromise.promise}async findById(e){this._isReady||await this.requestMetaInfo();const t=this._findStudyMetaInfo(e);return null!==t?Promise.resolve(t):"pine"===e.type?this._compilePine(e):Promise.reject(`unexpected study id=${e.studyId} with type=${e.type}`)}findByIdSync(e){return this._findStudyMetaInfo(e)}isReady(){return this._isReady}async findAllJavaStudies(){return this._isReady||await this.requestMetaInfo(),this._javaStudiesMetaInfo}studyVersioning(){return(0,n.ensureNotNull)(this._studyVersioning)}getInternalMetaInfoArray(){return this._javaStudiesMetaInfo}addPineMetaInfo(e){return g(this._pineMetaInfoCache,e)}async getLatestMetaInfoForPineStudy(e,t){const i=await(0,u.requestUserScripts)();let s;if(i){const r=i.find((t=>t.scriptIdPart===e));if(r){const e=a.Version.parse(t),i=a.Version.parse(r.version);e.isLess(i)&&(s=r.version)}}if(void 0!==s){const t={type:"pine",pineId:e,pineVersion:s};return this.findById(t)}return null}_processMigrations(e){this._studiesMigrations=[];for(let t=0;e&&tt.id===e.studyId))||null):this._pineMetaInfoCache.find((t=>t.scriptIdPart===e.pineId&&(void 0===e.pineVersion||(0,n.ensureDefined)(t.pine).version===e.pineVersion)))||null}_compilePine(e){p.logNormal(`Compiling ${e.pineId} script`);const t=(0,u.translateScriptAsync2)(e.pineId,e.pineVersion||"last").then((({metaInfo:t})=>(p.logNormal(`Compiling ${e.pineId} is successful`),this.addPineMetaInfo((0,n.ensureDefined)(t)))));return t.catch((()=>{p.logNormal(`Compiling ${e.pineId} is failed`)})),t}}function v(e){e.description_localized=r.t(e.description,{context:"study"},i(168716))}function g(e,t){const i=new o.StudyMetaInfo(t).state();(0,l.migrateMetaInfoAndPropState)(i);const s=new o.StudyMetaInfo(i);let r=!0;const n=e.findIndex((e=>e.id===s.id));if(-1===n)e.push(s);else{const t=e[n],i=void 0!==t.pine?a.Version.parse(t.pine.version):null,o=void 0!==s.pine?a.Version.parse(s.pine.version):null;null===o||null===i||o.isGreaterOrEqual(i)?(t.removeDefaults(),e[n]=s):r=!1}return r&&s.createDefaults(),s}const P=(0,s.default)((()=>new m(window.ChartApiInstance)))},470130:(e,t,i)=>{i.d(t,{fundamentalsPrefix:()=>s,isFundamentalStudyMetaInfo:()=>r,studyNameByMetaInfo:()=>n});const s="study_Internal$STD;Fund_";function r(e){return n(e)===s}function n(e){const t="study_"+(e.classId||e.shortId);return t.startsWith(s)?s:t}},414585:(e,t,i)=>{i.d(t,{StudyStatusProviderBase:()=>a});var s=i(985715),r=i(7288),n=i(982217);const o={NONE:"Default"},l=!0;class a extends s.StatusProviderBase{constructor(e){super(),this._source=e}getSplitTitle(){return this._source.titleInParts(n.TitleDisplayTarget.StatusLine,!0,o,void 0,l)}text(){return this._source.isActualInterval()?this._source.isFailed()?`${this._source.title(n.TitleDisplayTarget.StatusLine,!0,o,void 0,l)}: ${this.sourceStatusText()}`:`${this._source.title(n.TitleDisplayTarget.StatusLine,!0,o,void 0,l)} ${this.sourceStatusText()}`:this._source.title(n.TitleDisplayTarget.StatusLine,!0,o,void 0,l)}sourceStatusText(){return(0,r.convertStudyStatusToString)(this._source.status(),!0)}errorStatus(){if(!this._source.isActualInterval()||this._source.isSymbolInvalid())return null;const e=this._source.status();return e.type===r.StudyStatusType.Error?{error:this.sourceStatusText(),solutionId:(0,r.studyStatusSolutionId)(e),title:(0,r.studyStatusTitle)(e),studyFeature:(0,r.studyStatusFeature)(e),stackTrace:(0,r.studyErrorStatusStackTrace)(e.errorDescription.stack_trace),editorError:e.errorDescription.editorError}:null}}},509550:(e,t,i)=>{i.d(t,{StudyStatusProvider:()=>a});var s=i(444372),r=i(7288),n=i(971417),o=i(414585);const l=s.t(null,void 0,i(947542));class a extends o.StudyStatusProviderBase{sourceStatusText(){const e=this._source;if(e.status().type===r.StudyStatusType.Error){const t=e.metaInfo(),i=(0,n.extractPineId)(t.fullId);if(t.scriptIdPart&&(0,n.isEdgrPineId)(t.scriptIdPart)||i&&(0,n.isEdgrPineId)(i))return l}return super.sourceStatusText()}}}, 555502:(e,t,i)=>{i.d(t,{StudyStatusView:()=>r});var s=i(833642);class r extends s.StatusView{constructor(e){super(e.statusProvider())}getSplitTitle(){return this._statusProvider.getSplitTitle()}update(){this._text=this._statusProvider.text()}}},103055:(e,t,i)=>{i.d(t,{StudyValuesProvider:()=>y});var s=i(150335),r=i(638456),n=i(246733),o=i(244842),l=i(534741),a=i(616117),c=i(885482),u=i(368135),h=i(441212),d=i(470130),p=i(570226),_=i(650151),f=i(60897),m=i(982217);const v=r.CheckMobile.any(),g=o.enabled("hide_last_na_study_output"),P=o.enabled("always_show_legend_values_on_mobile");class y{constructor(e,t,i){this._emptyValues=[],this._colorProviders=new Map,this._study=e,this._model=t,this._studyMetaInfo=this._study.metaInfo(),this._studyProperties=this._study.properties().childs(),this._isFundamental=(0,d.isFundamentalStudyMetaInfo)(this._studyMetaInfo);const s=this._studyMetaInfo.plots;s&&s.forEach(((e,t)=>{if((0,u.isPlotWithTechnicalValues)(e))return;const s=e.id;this._emptyValues.push(function(e,t="",i=""){return{id:t,index:e,title:i,value:"",visible:!1}}(t,s,i?"":this._study.guiPlotName(m.TitleDisplayTarget.StatusLine,s)));const r=(0,u.isOhlcPlot)(e)?e.target:s;this._colorProviders.set(r,(0,h.createStudyPlotColorProvider)(this._studyMetaInfo,this._study.properties(),r))}))}getItems(){return this._emptyValues}getPlotColor(e,t){var i;const r=t[e+1];if(!(0,s.isNumber)(r))return"";const n=r>0;let o;const l=this._studyMetaInfo.plots[e];let a=l.id;const c=this._studyProperties;if((0,u.isOhlcPlot)(l))a=l.target||a,o=(0,_.ensureDefined)(c.ohlcPlots.childs()[a].childs().color).value();else if((0,u.isArrowsPlot)(l)){const e=(0,_.ensureDefined)(c.styles.childs()[a]);o=n?e.childs().colorup.value():e.childs().colordown.value()}else o=(0,_.ensureDefined)(null===(i=c.styles.childs()[a])||void 0===i?void 0:i.child("color")).value();let h=o;const d=this._colorProviders.get(a),p=d&&d.getPlotPointStyle(t);return p&&((0,u.isArrowsPlot)(l)?(n&&void 0!==p.colors[5]&&(h=p.colors[5]),n||void 0===p.colors[6]||(h=p.colors[6])):void 0!==p.colors[0]&&(h=p.colors[0])),"transparent"===h&&(h=o),h}getValues(e){var t,i;const r=this._emptyValues.map((e=>({...e})));let o=null;const a=this._study.data().lastIndex(),c=this._studyProperties;if(null!==a)for(const e of r){if(0===(null===(t=c.styles.childs()[e.id])||void 0===t?void 0:t.childs().display.value()))continue;const i=this._study.nearestIndex(a,l.PlotRowSearchMode.NearestLeft,e.index+1);if(void 0===i)continue;const s=i+this._study.offset(e.id);o=null!==o?Math.max(s,o):s}(null===e||null!==o&&e>o)&&(e=o);const h=this._hideValues(),d=this._study.isVisible()&&!h?f.notAvailable:"";for(const e of r)e.value=d;if(h)return r;g&&r.length&&(r[r.length-1].value="");const m=this._study.priceScale();if(!this._study.isVisible()||null===e||null===m||m.isEmpty()||this._model.timeScale().isEmpty())return r;const v={};for(const t of r){const r=t.id,o=(0,p.getPriceValueFormatterForStudy)(this._study,r),h=(0,_.ensureDefined)(c.styles.childs()[r]),d=h.childs().display.value();if(t.visible=0!==d,!t.visible)continue ;const f=h.hasChild("plottype")?null===(i=h.child("plottype"))||void 0===i?void 0:i.value():null,m=this._isFundamental&&(f===u.LineStudyPlotStyle.StepLine||f===u.LineStudyPlotStyle.StepLineWithDiamonds),g=t.index,P=e-this._study.offset(r),y=m||null!==a&&P>a?l.PlotRowSearchMode.NearestLeft:l.PlotRowSearchMode.Exact,S=this._study.nearestIndex(P,y);if(void 0===S)continue;let b=v[r];if(void 0===b&&(b=this._study.getMinFirstBarIndexForPlot(r),Number.isFinite(b)&&(v[r]=b)),b>S)continue;const x=this._study.data().last(),C=this._study.data().valueAt(S)||(null!==x?x.value:null);if(null===C)continue;const w=C[g+1];(0,s.isNumber)(w)&&(t.value=o(w),t.color=(0,n.resetTransparency)(this.getPlotColor(g,C)))}return r}_hideValues(){return P?(0,a.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited():v&&(null===this._model.crossHairSource().pane||(0,a.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited())}}},223284:(e,t,i)=>{i.d(t,{EXCLUDED_FOR_ALERT_ID_INPUTS:()=>_,collectDepsForAlert:()=>v,plotsForAlert:()=>m});var s=i(484156),r=i(650151),n=i(62745),o=i(201089),l=i(827523),a=i(526075),c=i(95452),u=i(368135);const h=(0,o.getLogger)("Chart.Study");function d(e,t,i){void 0!==i&&i.forEach((i=>{const s=e[i];"string"==typeof s?e[i]=p(s,t):(0,n.isExtendedInput)(s)&&(0,n.isExtendedInputSource)(s)?s.v=p((0,n.getInputValue)(s),t):h.logError(`Cannot patch source input, its type is not source: ${JSON.stringify(s)}`)}))}function p(e,t){const[i,s]=e.split("$"),r=t.get(i);return r?r+(void 0===s?"":"$"+s):e}const _=["text","pineFeatures"];function f(e){return(0,s.default)(e,_)}function m(e,t){const i=[u.isLinePlot,u.isShapesPlot,u.isCharsPlot,u.isArrowsPlot,u.isOhlcPlot,u.isAlertConditionPlot];return e.plots.map(((e,t)=>({...e,pinePlotIndex:t}))).filter((e=>i.some((t=>t(e))))).map((i=>{const s={id:i.id,type:i.type,pinePlotIndex:i.pinePlotIndex,offset:t(i.id)};if(e.styles&&void 0!==e.styles[i.id]){const t=(0,r.ensureDefined)((0,r.ensureDefined)(e.styles)[i.id]);s.title=t.title||"",s.text=t.text||""}return(0,u.isOhlcPlot)(i)&&i.target&&e.ohlcPlots&&e.ohlcPlots[i.target]&&(s.ohlcTitle=(0,r.ensureDefined)((0,r.ensureDefined)(e.ohlcPlots)[i.target]).title),s}))}function v(e,t){const i=[],s=new Map;let n;for(let r=e.length-1;r>=0;r--){const o=e[r],u=(0,l.extractStudyId)(o.metaInfo().id),h=a.StudyMetaInfo.getStudyIdWithLatestVersion(o.metaInfo());n=o.inputsForAlertState();d(n,s,o.metaInfo().inputs.filter((e=>"source"===e.type)).map((e=>e.id)));const p=o.metaInfo().isTVScript?f(n):n,_=(0,c.getStudyIdForAlert)(u,p,t);i.push({id:_,study:h,inputs:n}),s.set(o.id(),_)}const o=i.reverse();return{idForAlert:(0,r.ensureDefined)(o[0].id),inputsForAlert:(0,r.ensureDefined)(n),studyDependencies:o}}},932167:(e,t,i)=>{i.d(t,{StudyPriceAxisView:()=>o});var s=i(650151),r=i(229765),n=i(246733);class o extends r.PriceAxisView{constructor(e,t){super(),this._model=e.model(),this._source=e,this._data=t,this._isForceOverlay=!!this._source.metaInfo().isPlotForceOverlay(this._data.plotIndex)}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1 ;const r=this._source.model(),o=this._isForceOverlay?r.mainSeries().priceScale():this._source.priceScale();if(null===o)return;if(!r.isPriceScaleVisible(o))return;const l=this._source.lastValueData(this._data.plotIndex,!1);if(l.noData)return;const a=r.timeScale().visibleBarsStrictRange(),c=r.mainSeries().bars().lastIndex();if(null!==a&&null!==c){if(c<=a.lastBar()){i.background=(0,n.resetTransparency)(l.color);let s=l.color;"transparent"===s&&(s=this._model.properties().childs().scalesProperties.childs().backgroundColor.value()),i.textColor=this.generateTextColor(s),i.borderColor=void 0,e.borderVisible=!1,t.borderVisible=!1}else{const o=r.backgroundColorAtYPercentFromTop(l.coordinate/(0,s.ensureNotNull)(r.paneForSource(this._source)).height());i.background=o,i.textColor=(0,n.resetTransparency)(l.color),i.borderColor=(0,n.resetTransparency)(i.textColor),e.borderVisible=!0,t.borderVisible=!0}i.coordinate=l.coordinate,i.floatCoordinate=l.floatCoordinate,this._showAxisLabel()&&(e.text=l.text,e.visible=!0),this._updatePaneRendererData(t)}}_showPaneLabel(){const e=this._model.properties().childs().scalesProperties.childs();return(e.showStudyPlotLabels.value()||e.showFundamentalNameLabel.value())&&this._source.properties().childs().showLabelsOnPriceScale.value()&&this._source.isPlotVisibleAt(this._data.plotIndex,4)}_showAxisLabel(){const e=this._model.properties().childs().scalesProperties.childs();return(e.showStudyLastValue.value()||e.showFundamentalLastValue.value())&&this._source.properties().childs().showLabelsOnPriceScale.value()&&this._source.isPlotVisibleAt(this._data.plotIndex,4)}_updatePaneRendererData(e){e.text="",this._showPaneLabel()&&(e.text=this._source.priceLabelText(this._data.plotIndex),e.visible=!0)}}},470452:(e,t,i)=>{i.d(t,{Study:()=>Ci,createStudyError:()=>yi,prepareStudyProperties:()=>pi,prepareStudyPropertiesForLoadChart:()=>vi});var s=i(316230),r=i(822914),n=i(852290),o=i(650151),l=i(130551),a=i(444372),c=i(201089),u=i(537919),h=i(461794),d=i(168682),p=i(855611),_=i(782856),f=i(62745),m=i(298113);function v(e){const t=new Set;("historyCalculationMayChange"in e?e.historyCalculationMayChange():e.metaInfo().historyCalculationMayChange)&&t.add(_.DataSourceDangerReason.PineRepainting);for(const i of Object.values(e.inputs()))if((0,f.isExtendedInput)(i)&&"symbol"===i.t){const s=e.resolvedSymbolInfoBySymbol(i.v);"spread"===(null==s?void 0:s.type)&&t.add(_.DataSourceDangerReason.Spread),"CRYPTOCAP"===(null==s?void 0:s.exchange)&&t.add(_.DataSourceDangerReason.CryptoCap)}for(const i of e.parentSources())(0,m.addToSet)(t,v(i));const i=e.ownerSource();return e.isChildStudy()&&i&&(0,m.addToSet)(t,v(i)),t}function g(e){const[t]=v(e);return null!=t?t:null}var P=i(223284),y=i(662080),S=i(960337),b=i(371927),x=i(397150),C=i(623551),w=i(707957),T=i(246733),I=i(590713),V=i(917180),M=i(974655),A=i(291784),D=i(195447),L=i(526075),B=i(484812),R=i(534741),N=i(379048),E=i(260414),k=i(634005),O=i(368135);class F extends E.StudyBaseWindowView{constructor(e,t){super(e,t), this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._showStudyValues.subscribe(this,this.update);const i=this._study.properties();i.childs().showLegendValues.subscribe(this,this.update);const s=this._study.metaInfo().plots,r=new Set;s.forEach((e=>{var t;if((0,O.isOhlcPlot)(e)){const t=e.target;if(r.has(t))return;r.add(t),i.childs().ohlcPlots.childs()[t].childs().display.subscribe(this,this.update)}else(0,O.isPlotSupportDisplay)(e)&&(null===(t=i.childs().styles.childs()[e.id])||void 0===t||t.childs().display.subscribe(this,this.update))}))}areValuesVisible(){return this._showStudyValues.value()}additional(){return null}destroy(){this._showStudyValues.unsubscribeAll(this);const e=this._study.properties();e.childs().showLegendValues.unsubscribeAll(this);const t=this._study.metaInfo().plots,i=new Set;t.forEach((t=>{var s;if((0,O.isOhlcPlot)(t)){const s=t.target;if(i.has(s))return;i.add(s),e.childs().ohlcPlots.childs()[s].childs().display.unsubscribe(this,this.update)}else(0,O.isPlotSupportDisplay)(t)&&(null===(s=e.childs().styles.childs()[t.id])||void 0===s||s.childs().display.unsubscribe(this,this.update))}))}_createValuesProvider(e,t){return new k.StudyLegendValuesProvider(e,t)}}var W=i(885482),z=i(555502),H=i(919892),U=i(173220),K=i(826989),G=i(509550),j=i(389137),q=i(982217),$=i(674981),Y=i(539163);class Q{constructor(e,t,i=!1){this.price=t,this.index=e,this.useMainSeriesForPriceRange=i}}var X=i(92245);function Z(e,t,i,s){if(e.y1===e.y2)return function(e,t,i){return(0,o.assert)(e.y1===e.y2),(0,X.doesItemAffectVisibleRange)(e.x1,e.x2,e.extend,t,i)?[new Q(t,e.y1,!1),new Q(i,e.y2,!1)]:[]}(e,i,s);const r=[];return null!==e.x1&&r.push(new Q(e.x1,e.y1,!1)),null!==e.x2&&r.push(new Q(e.x2,e.y2,!1)),r}function J(e,t,i,s){return e.points.filter((e=>e.x>=i&&e.x<=s)).map((e=>new Q(e.x,e.y,!1)))}function ee(e,t,i,s){return(0,X.doesItemAffectVisibleRange)(e.left,e.right,e.extend,i,s)?[new Q(i,e.top,!1),new Q(s,e.bottom,!1)]:[]}var te=i(294024);function ie(e,t,i,s){let r;const n=e.yloc!==te.DwgLabelYloc.Price&&e.yloc!==te.DwgLabelYloc.Auto;if(n){const i=e.yloc===te.DwgLabelYloc.AboveBar?2:3,s=t.valueAt(e.x);null!==s&&(r=s[i])}else r=e.y;return null==r?null:[new Q(e.x,r,n)]}function se(e,t,i,s,r,n){if(!(0,X.doesItemAffectVisibleRange)(e.firstBarTime,e.lastBarTime,X.DwgExtend.None,i,s))return[];let o=1/0,l=-1/0;for(const[t,i]of r.tpoBlockSets())if(n===t)for(const[,t]of i)for(const i of t)i.tpoId===e.id&&(o=Math.min(o,i.rowIndex*e.priceRange),l=Math.max(l,(i.rowIndex+1)*e.priceRange));return Number.isFinite(o)?[new Q(i,l,!1),new Q(s,o,!1)]:[]}class re{constructor(e,t,i,s,r){this._mapGetter=e,this._study=t,this._bars=t.series().bars(),this._visibilityGetter=i,this._getPoints=s,this._getMargins=r}groupPriceRange(e,t,i){let s=null;const r=this._study.graphics();for(const[n,o]of this._mapGetter(i))if(this._visibilityGetter(n))for(const i of o){const o=this._getPoints(i,this._bars,e,t,r,n);if(null===o)continue;let l=1/0,a=-1/0,c=!1,u=!1,h=!1;for(const i of o){ const s=i.index<=t,r=i.index>=e;c=c||s,u=u||r,h=h||s&&r;let n=i.price,o=i.price;if(i.useMainSeriesForPriceRange){const e=this._bars.valueAt(i.index);if(null===e)continue;const t=e[2];if(null==t)continue;const s=e[3];if(null==s)continue;n=s,o=t}na&&(a=o)}if(!(h||c&&u))continue;const d=new A.PriceRange(l,a);s=null===s?d:s.merge(d)}return s}firstValue(e,t){let i=1/0,s=1/0,r=-1/0,n=1/0,o=1/0,l=1/0;const a=this._study.graphics();for(const[c,u]of this._mapGetter(!1))if(this._visibilityGetter(c))for(const h of u){const u=this._getPoints(h,this._bars,e,t,a,c);if(null!==u)for(const a of u){const c=a.index;c>=e&&c<=t&&cr?(r=c,n=a.price):c>t&&c{const s=i.index;return s>=e&&s<=t})).length)continue;const l=this._getMargins(i,this._bars);s.bottomPixelMargin=Math.max(s.bottomPixelMargin,l.bottomPixelMargin),s.topPixelMargin=Math.max(s.topPixelMargin,l.topPixelMargin)}return s}}const ne=()=>({bottomPixelMargin:0,topPixelMargin:0});function oe(e){const t=(0,o.ensureDefined)(e.properties().childs().graphics).childs();return[new re((()=>(0,$.mapEntriesGenerator)(e.graphics().tpos())),e,(e=>{const i=(0,o.ensureDefined)(t.tpoBlockSets).childs()[e].childs();return i.showLetters.value()||i.showBlocks.value()||(0,o.ensureDefined)(t.tpoVolumeRows).childs()[e].childs().visible.value()}),se,ne),new re((t=>(0,$.nestedMapGenerator)(e.graphics().dwglabels(),t)),e,(e=>(0,o.ensureDefined)(t.dwglabels).childs()[e].childs().visible.value()),ie,Y.calculateDwgLabelsMargins.bind(null,e)),new re((t=>(0,$.nestedMapGenerator)(e.graphics().dwglines(),t)),e,(e=>(0,o.ensureDefined)(t.dwglines).childs()[e].childs().visible.value()),Z,ne),new re((t=>(0,$.nestedMapGenerator)(e.graphics().dwgpolylines(),t)),e,(e=>(0,o.ensureDefined)(t.dwgpolylines).childs()[e].childs().visible.value()),J,ne),new re((t=>(0,$.nestedMapGenerator)(e.graphics().dwgboxes(),t)),e,(e=>(0,o.ensureDefined)(t.dwgboxes).childs()[e].childs().visible.value()),ee,ne),new re((t=>function*(e,t){const i=e.dwglines(),s=e.dwglinefills(),r=new Map;i.forEach((e=>{if(void 0===t)e.forEach((e=>{null==e||e.forEach((e=>{r.set(e.id,e)}))}));else{const i=e.get(t);null==i||i.forEach((e=>{r.set(e.id,e)}))}}));for(const[e,t]of s){const i=Array.from(t).filter((e=>r.has(e.line1)));i.length&&(yield[e,new Set(i)])}}(e.graphics(),t)),e,(e=>(0,o.ensureDefined)(t.dwglinefills).childs()[e].childs().visible.value()),((t,i,s,r)=>{const n=new Map;for(const[,t]of e.graphics().dwglines())for(const[,e]of t)for(const t of e)n.set(t.id,t);return function(e,t,i,s,r){ const n=e.get(t.line1),o=e.get(t.line2);return void 0!==n&&void 0!==o&&((0,X.doesItemAffectVisibleRange)(n.x1,n.x2,n.extend,s,r)||(0,X.doesItemAffectVisibleRange)(o.x1,o.x2,o.extend,s,r))?[new Q(s,n.y1,!1),new Q(r,n.y2,!1),new Q(s,o.y1,!1),new Q(r,o.y2,!1)]:[]}(n,t,0,s,r)}),ne)]}function le(e,t,i){return null===t?e:null===e?t:e.index{t.has(e.studyId)||(t.add(e.studyId),i.push(e))})),i}function me(e){const t=e.model().mainSeries();return{studyId:(0,o.ensureNotNull)(e.sourceId()),turnaround:e.turnaround(),sourceStudies:e.parentSources().filter((e=>e!==t)).map((e=>me(e)))}}var ve=i(244842),ge=i(142119),Pe=i(43192);class ye extends Pe.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return null}_drawImpl(e){}_drawBackgroundImpl(e){const{context:t,horizontalPixelRatio:i,bitmapSize:s}=e,r=this._data;for(let e=0;e0?(i-=r,s+=r):(i+=r,s-=r);const n=this._study.getMinFirstBarIndexForPlot(this._plotName);if(n>s)return;i=Math.max(n,i);const l=this._study.data();for(const e of l.rangeIterator(i,s)){let i=e.index;const s=e.value;i+=r;const n={timePointIndex:Math.floor(i),left:NaN,center:NaN,right:NaN};let l=(0,j.isNumber)(t)?t:50;l=Math.min(l,100),l=Math.max(l,0);const a=this._colorProvider.getPlotPointStyle(s);void 0!==a.colors[1]&&(n.color=(0,T.generateColor)((0,o.ensureDefined)(a.colors[1]),l)),this._items.push(n)}this._model.timeScale().fillBarBorders(this._items)}}var Ce=i(230058),we=i(466144),Te=i(678515),Ie=i(63316),Ve=i(544421),Me=i(574809),Ae=i(111595),De=i(594931),Le=i(506366),Be=i(992885),Re=i(618241),Ne=i(778190),Ee=i(29164),ke=i(119914),Oe=i(815555),Fe=i(928483);const We=new Map;We.set("PaneRendererArrowUp",Ae.PaneRendererArrowUp),We.set("PaneRendererArrowDown",Ae.PaneRendererArrowDown),We.set("PaneRendererCircleShape",De.PaneRendererCircleShape),We.set("PaneRendererCrossShape",Le.PaneRendererCrossShape),We.set("PaneRendererDiamond",Be.PaneRendererDiamond),We.set("PaneRendererFlagShape",Re.PaneRendererFlagShape),We.set("PaneRendererLabelUp",Ne.PaneRendererLabelUp),We.set("PaneRendererLabelDown",Ne.PaneRendererLabelDown),We.set("PaneRendererSquare",Ee.PaneRendererSquare),We.set("PaneRendererTriangleApexUp",ke.PaneRendererTriangleApexUp),We.set("PaneRendererTriangleApexDown",ke.PaneRendererTriangleApexDown),We.set("PaneRendererXCross",Oe.PaneRendererXCross);class ze extends Fe.StudyPaneViewInplaceUpdatable{constructor(e,t,i,s){var r;super(t,i,s),this._renderer=null,this._shapesRenderer=null,this._selectionRenderer=null,this._isMarkersEnabled=ve.enabled("source_selection_markers"),this._study=e;const n=e.metaInfo().plots;for(let e=0;ethis._createItem(e,null!=t?t:null,c,u,l)));let d=this._series.nearestIndex(r.firstBar(),R.PlotRowSearchMode.NearestRight),p=this._series.nearestIndex(r.lastBar(),R.PlotRowSearchMode.NearestLeft);if(void 0===d||void 0===p)return!1;l>0?(d-=l,p+=l):(d+=l,p-=l);const _=this._study.getMinFirstBarIndexForPlot(this._plotName);if(_>p)return!0;d=Math.max(_,d);const f=this._getTranspValue(),m=this._study.properties().childs().styles.childs()[this._plotName].childs(),v=m.color.value(),g=m.textColor?m.textColor.value():void 0,P=v,y=v,S=void 0===g?void 0:g,b=(0,o.ensureNotNull)(this._plotIndex),x=(0,Me.createEmptyStyle)(),C=null!=h?h:(0,o.ensureNotNull)(n.firstIndex()),w=n.rangeIterator(C,(0,o.ensureNotNull)(n.lastIndex())+1);let T=(0,$.lowerbound)(this._items,C+l,((e,t)=>e.timePointIndex9?i-10:0;s.borderColor=(0,T.generateColor)(s.color,e)}void 0!==t.colors[2]&&(s.textColor=(0,T.generateColor)((0,o.ensureDefined)(t.colors[2]),i))}_updateRenderer(e,t){this._makeSureRendererIsValid();const i=this._model.timeScale(),s={},r=this._getTranspValue(),n=i.barSpacing(),o=this._calculateShapeHeight(n),l=this._study.properties().childs().styles.childs()[this._plotName].childs(),a=l.location.value(),c=this._calculateVerticalOffset(a,o+o/2);s.barSpacing=n,s.items=this._items,s.color=(0,T.generateColor)(l.color.value(),r),s.height=o,s.vertOffset=c,s.visibleItemsRange={startItemIndex:e,endItemIndex:t};const u=l.plottype.value(),h=we.plotShapesData[u],d=new ge.CompositeRenderer;h&&(this._shapesRenderer?this._shapesRenderer.setData(s):(this._shapesRenderer=this._createRenderer(h.paneRendererClass,s),d.append(this._shapesRenderer))),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=c,d.append(new Ce.SelectionRenderer(this._selectionData))),this._renderer=d}_createRenderer(e,t){const i=We.get(e);return new((0,o.ensureDefined)(i))(t)}_getSeriesVal(e,t){const i=(0,Ve.barFunction)(e),s=this._series.data().valueAt(t);return null===s?null:i(s)}_getTranspValue(){let e=0;const t=this._study.properties().childs();t.transparency&&(e=t.transparency.value(),e=(0,j.isNumber)(e)?e:50);const i=t.styles.childs()[this._plotName].childs();return i.transparency&&(e=i.transparency.value(),e=(0,j.isNumber)(e)?e:50),(0,Te.clamp)(e,0,100)}_createItem(e,t,i,s,r){ const n=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value(),l={origPrices:{price:NaN},timePointIndex:e+r};if((null===t||0===t)&&n!==N.MarkLocation.Absolute)return l;if(null==t)return l;let a=NaN;switch(n){case N.MarkLocation.AboveBar:{const t=this._getLocationPrice(e,i,r);if(null===t)return l;a=t;break}case N.MarkLocation.BelowBar:{const t=this._getLocationPrice(e,s,r);if(null===t)return l;a=t;break}case N.MarkLocation.Absolute:a=(0,o.ensureNotNull)(t);break;case N.MarkLocation.Top:case N.MarkLocation.Bottom:a=0;break;default:throw new Error("Bad value: "+n)}return{y:NaN,origPrices:{price:a},timePointIndex:e+r}}_dependsOnSeriesData(){const e=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value();return e===N.MarkLocation.AboveBar||e===N.MarkLocation.BelowBar}_getValueForUpdating(e){const t=e.value[this._plotIndex+1];if(null==t)return null;const i=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value();if(0===t&&i!==N.MarkLocation.Absolute)return null;const s=this._study.offset(this._plotName),{hiPlot:r,loPlot:n}=this._hiLoPlots();switch(i){case N.MarkLocation.AboveBar:return this._getLocationPrice(e.index,r,s);case N.MarkLocation.BelowBar:return this._getLocationPrice(e.index,n,s)}return super._getValueForUpdating(e)}_convertItemsToCoordinates(e,t,i,s){for(let e=i;e{for(let t=i;t19?o-10:0,p=this._calculateVerticalOffset(c,Math.round(1.5*a));n.barSpacing=l,n.items=this.items(),n.color=u,n.borderColor=(0,T.generateColor)(s.color.value(),d),n.height=a,n.vertOffset=p,n.visibleItemsRange={startItemIndex:e,endItemIndex:t};const _=s.plottype.value(),f=we.plotShapesData[_],m=this._plotStyleInfo.text;if(void 0!==m&&""!==m.trim()){let e=m.trim().replace(/\\n/gm,"\n");e=(0,h.cleanButAmpersand)(e,!0),n.text=e,n.fontSize=12;const t=s.textColor?s.textColor.value():void 0;n.textColor=t?(0,T.generateColor)(t,o):u}if(this._renderer&&this._shapesRenderer&&this._selectionRenderer)this._shapesRenderer.setData(n),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData?(this._selectionData.vertOffset=p,this._selectionRenderer.setData(this._selectionData)):this._selectionRenderer.setData(null);else{const e=new ge.CompositeRenderer;this._shapesRenderer=super._createRenderer(f.paneRendererClass,n),e.append(this._shapesRenderer),this._selectionRenderer=new Ce.SelectionRenderer(null!==(i=this._selectionData)&&void 0!==i?i:void 0),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData?this._selectionData.vertOffset=p:this._selectionRenderer.setData(null),e.append(this._selectionRenderer),this._renderer=e}}}var Ue=i(687795),Ke=i.n(Ue),Ge=i(86441),je=i(821885),qe=i(315801),$e=i(9640),Ye=i(422333),Qe=i(600642);class Xe extends je.PaneRendererAbstractShape{constructor(e,t){super(null,t),this._fontSizeEnsured=0,this._ch="",this._fontFamily=Ye.CHART_FONT_FAMILY,this._charCache=null,null!==e&&this.setData(e)}setData(e){super.setData(e),this._fontSizeEnsured=(0,o.ensureDefined)(this._height);const t=e.char.slice(0,40);this._ch=Ke()(t)[0]||" ",this._fontFamily=e.fontFamily||Ye.CHART_FONT_FAMILY}hitTest(e){const t=(0,$e.interactionTolerance)().series+this._fontSizeEnsured/2;for(const i of this._items){if(new Ge.Point(i.center,i.y+i.vertOffset).subtract(e).length()<=t)return new qe.HitTestResult(qe.HitTarget.Regular)}return null}_drawItemShape(e,t){const i=t.center,s=t.vertOffset>0?1:-1,r=t.y+t.vertOffset-s*Math.round(this._fontSizeEnsured/2);let n;n=t.style&&void 0!==t.style.color?t.style.color:this._color;const o=this._textImageCache(),{context:l,horizontalPixelRatio:a,verticalPixelRatio:c}=e;if(this._fontSizeEnsured<=4/a){l.save();const e=Math.max(1,Math.floor(a));let s=Math.max(1,Math.floor(o.textImageWidth*a));s%2!=e%2&&(s+=s>1?-1:1);const u=Math.round(r*c)+(t.vertOffset>=0?0:-s);return l.fillStyle=n,l.fillRect(Math.round(i*a)+(a%2?.5:0)-s/2,u,s,s),void l.restore()}const u={style:{fillStyle:n},location:{x:i,y:r,horzAlign:Qe.HorizontalAlign.Center, vertAlign:t.vertOffset>0?Qe.VerticalAlign.Top:Qe.VerticalAlign.Bottom}};o.paintTo(e,u)}_startPath(e,t,i){}_endPath(e){}_textImageCache(){return null!==this._charCache&&this._charCache.fontFamily===this._fontFamily&&this._charCache.fontSize===this._fontSizeEnsured||(this._charCache={fontSize:this._fontSizeEnsured,fontFamily:this._fontFamily,cache:new Qe.TextImageCache(this._ch,!1,!1,this._fontFamily,this._fontSizeEnsured,"center",0)}),this._charCache.cache}}class Ze extends ze{constructor(){super(...arguments),this._charRenderer=new Xe(null)}_updateRenderer(e,t){var i,s;const r=this._getTranspValue(),n=this._model.timeScale().barSpacing();let l;const a=this._study.properties().childs().styles.childs()[this._plotName].childs();l=this._plotStyleInfo.size?this._calculateShapeHeight(50,this._plotStyleInfo.size):Math.round(n);const c=a.location.value(),u=(0,T.generateColor)(a.color.value(),r),d=this._calculateVerticalOffset(c,l),p={items:this.items(),barSpacing:n,char:(0,o.ensureDefined)(null!==(s=null===(i=a.char)||void 0===i?void 0:i.value())&&void 0!==s?s:this._plotStyleInfo.char),height:l,vertOffset:d,color:u,visibleItemsRange:{startItemIndex:e,endItemIndex:t}},_=this._plotStyleInfo.text;if(void 0!==_&&""!==_.trim()){let e=_.trim().replace(/\\n/gm,"\n");e=(0,h.cleanButAmpersand)(e,!0),p.text=e,p.fontSize=12;const t=a.textColor?a.textColor.value():void 0;p.textColor=t?(0,T.generateColor)(t,r):u}this._charRenderer.setData(p);const f=new ge.CompositeRenderer;f.append(this._charRenderer),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=d,f.append(new Ce.SelectionRenderer(this._selectionData))),this._renderer=f}}var Je=i(724377);class et{constructor(e,t,i,s,r){this.left=NaN,this.right=NaN,this.height=NaN,this.center=e,this.y=t,this.origHeight=i,this.isUp=s,this.origPrices=r,this.timePointIndex=e,this.style={}}}function tt(e){return Math.round(e/4)}function it(e){return Math.round(e/2)}class st extends Pe.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){var t,i,s,r;const n=this._data,o=it(n.barSpacing),l=Math.round(o/2),a=Math.round(o),c=tt(n.barSpacing),u=null!==(i=null===(t=n.visibleItemsRange)||void 0===t?void 0:t.startItemIndex)&&void 0!==i?i:0,h=null!==(r=null===(s=n.visibleItemsRange)||void 0===s?void 0:s.endItemIndex)&&void 0!==r?r:n.items.length;if(u>=h)return null;for(const t of n.items.slice(u,h)){if(!t)continue;if(!Number.isFinite(t.center)||!Number.isFinite(t.y))continue;const i=Math.abs(t.height),s=t.isUp?-1:1,r=i+a,n=t.y-s*c,o=n-s*r,u=t.center-l,h=t.center+l;if(u=P))for(const e of c.items.slice(g,P)){if(!Number.isFinite(e.center)||!Number.isFinite(e.y))continue;const t=e.isUp?-1:1,i=Math.round(Math.abs(e.height)*l),s=Math.round(e.center*o)+v,r=Math.round((e.y-t*h)*l)+v;a.beginPath(),a.translate(s,r);const u=null!==(n=e.style&&e.style.color)&&void 0!==n?n:e.isUp?c.colorup:c.colordown;d?(a.moveTo(0,0),a.lineTo(-f,-f*t),a.moveTo(0,0),a.lineTo(f,-f*t),a.moveTo(0,0),a.lineTo(0,-i*t),a.moveTo(-f,-i*t),a.lineTo(f,-i*t),a.lineWidth=p,a.strokeStyle=u,a.stroke()):(a.moveTo(0,0),i0,{hiPlot:r,loPlot:n}=this._hiLoPlots(),l=this._study.offset(this._plotName),a=Math.min(i+l,(0,o.ensureNotNull)(this._series.data().last()).index);if(s){const e=this._getSeriesVal(n,a) ;if(null!==e)return e}else{const e=this._getSeriesVal(r,a);if(null!==e)return e}return null}_updateItem(e,t){const i=this._getValueForUpdating(e),s=e.value[this._plotIndex+1]>0;return this._items[t].origPrices.price=null!=i?i:NaN,this._items[t].isUp=s,t+1}_createItem(e,t,i,s,r){const n={center:NaN,y:NaN,origPrices:{price:NaN,timePointIndex:NaN},origHeight:NaN};if(n.timePointIndex=e+r,!t)return n;const l=Math.min(e+r,(0,o.ensureNotNull)(this._series.data().last()).index),a=t>0;let c;if(a){const e=this._getSeriesVal(s,l);if(null===e)return n;c=e}else{const e=this._getSeriesVal(i,l);if(null===e)return n;c=e}return new et(e+r,c,t,a,{price:c,timePointIndex:e+r})}_dependsOnSeriesData(){return!0}_convertItemsToCoordinates(e,t,i,s){this._convertItemsToCoordinatesImpl(e,t,i,s)}_updateItemsHeights(e){var t,i,s,r,n,l,a,c;const u=this._study.properties().childs().styles.childs();let h=Math.abs((0,o.ensureDefined)(null!==(i=null===(t=u[this._plotName].childs().minHeight)||void 0===t?void 0:t.value())&&void 0!==i?i:this._plotStyleInfo.minHeight)),d=Math.abs((0,o.ensureDefined)(null!==(r=null===(s=u[this._plotName].childs().maxHeight)||void 0===s?void 0:s.value())&&void 0!==r?r:this._plotStyleInfo.maxHeight));if(h>d){const e=h;h=d,d=e}const p=this._items,_=null!==(l=null===(n=e.visibleItemsRange)||void 0===n?void 0:n.startItemIndex)&&void 0!==l?l:0,f=(null!==(c=null===(a=e.visibleItemsRange)||void 0===a?void 0:a.endItemIndex)&&void 0!==c?c:p.length)-1;let m=0;for(let e=_;e<=f;e++){const t=p[e],i=Math.abs(t.origHeight);i>m&&(m=i)}const v=(d-h)/m;for(let e=_;e<=f;e++){const t=p[e],i=Math.abs(t.origHeight);t.height=i*v+h}}}var ot=i(969419);class lt extends be.StudyForceOverlayPlotView{constructor(e,t,i,s){super(t,i,s),this._bars=[],this._invalidated=!1,this._isMarkersEnabled=ve.enabled("source_selection_markers"),this._selectionData=null,this._ohlcPlotIndexes=new Map,this._study=e,this._isMarkersEnabled=ve.enabled("source_selection_markers"),this._colorProvider=(0,Se.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s),this._selectionIndexer=new Ie.SelectionIndexes(i.timeScale());const r=this._study.metaInfo().plots;for(let e=0;es)return;i=Math.max(r,i) ;const n=this._study.data(),l=this._study.firstValue(void 0,this.isForceOverlay());if(null===l)return;const a=n.rangeIterator(i,s),c=(0,o.ensureDefined)(this._study.properties().childs().ohlcPlots).childs()[this._plotName].childs(),u=new Map,h=(e,t)=>{const i=e+"@"+t;if(!u.has(i)){const s=(0,T.generateColor)(e,t);return u.set(i,s),s}return u.get(i)},d=(0,Me.createEmptyStyle)();for(const e of a){let t=e.index;const i=e.value;t=Math.floor(t);let s=!0;const r=new Map;for(let e=1;e<=4;++e){const t=this._ohlcPlotIndexes.get(e);if(void 0===t){s=!1;break}const n=i[t+1];if(null==n){s=!1;break}r.set(e,n)}if(!s)continue;const n=(0,o.ensureDefined)(r.get(1)),l=(0,o.ensureDefined)(r.get(4)),a=(0,o.ensureDefined)(r.get(2)),u=(0,o.ensureDefined)(r.get(3)),p=Math.max(n,a,u,l),_=Math.min(n,a,u,l);let f=(0,o.ensureDefined)(h(c.color.value(),0));const m=this._colorProvider.getPlotPointStyle(i,d);void 0!==m.colors[0]&&(f=(0,o.ensureDefined)(m.colors[0]));const v={open:n,high:p,low:_,close:l,color:f,wickColor:m.colors[4],borderColor:m.colors[3],hollow:null,center:NaN,left:NaN,right:NaN,timePointIndex:Math.round(t)};this._bars.push(v)}if(e.barPricesToCoordinates(this._bars,l),this._model.timeScale().fillBarBorders(this._bars),this._model.selection().isSelected(this._study)){const t=this._selectionIndexer.indexes();this._selectionData={points:[],hittestResult:qe.HitTarget.Regular,bgColors:[],visible:!0,barSpacing:this._model.timeScale().barSpacing()};const i=(0,o.ensureNotNull)(this._model.paneForSource(this._study)).height(),s=(0,o.ensureDefined)(this._ohlcPlotIndexes.get(4));for(let r=0;r{var e;return this._colorPlotIndex=null!==(e=this._colorPlotIndex)&&void 0!==e?e:{type:1}};for(let t=0;t{null===this._bandAKey&&i.id===e&&(this._bandAKey=s),null===this._bandBKey&&i.id===t&&(this._bandBKey=s)}))}}var Vt=i(7288),Mt=i(395098),At=i(572230),Dt=i(964824),Lt=i(401580),Bt=i(444331),Rt=i(261066),Nt=i(932167),Et=i(506387),kt=i(938471);class Ot extends kt.AbstractBarColorer{constructor(e,t){super(),this._rgbaFromInteger=(0,vt.rgbaFromIntegerCached)(),this._study=e,this._plotIndex=t}applyBarStyle(e,t,i,s){var r;if(t)return i;const n=this._study.properties().childs();if(!n.visible.value())return i;const l=this._study.metaInfo(),a=this._study.data();if(!a||0===a.size())return i;const c=l.plots[this._plotIndex],u=this._getOffset();if(this._study.getMinFirstBarIndexForPlot(c.id)>e+u)return i;if(0===n.styles.childs()[c.id].childs().display.value())return i;const h=a.valueAt(e-u);if(null===h)return i;let d=h[this._plotIndex+1];if(null==d)return i;if(d=Math.round(d),l.isRGB)i.barColor=this._rgbaFromInteger(d),i.upColor=i.barColor,i.downColor=i.barColor;else{const e=l.plots[this._plotIndex];if("palette"in e){const t=e.palette,s=n.palettes.childs()[t],a=(0,o.ensureDefined)(null===(r=l.palettes)||void 0===r?void 0:r[t]),c=a.valToIndex?(0,o.ensureDefined)(a.valToIndex[d]):d,u=s.childs().colors.childs()[c].childs().color.value();i.barColor=u,i.upColor=u,i.downColor=u}}return i}firstColoredBar(e){var t;let i=e;for(const s of this._backColorers)i=Math.min(i,null!==(t=s.firstColoredBar(e))&&void 0!==t?t:1/0);const s=this._getOffset();i=Math.min(i,e+s);const r=this._getBars().firstIndex();return Math.max(i,null!=r?r:-1/0)}_getBars(){return this._study.series().bars()}_getOffset(){const e=this._study.metaInfo().plots[this._plotIndex] ;return this._study.offset(e.id)}}var Ft=i(251954),Wt=i(42292),zt=i(808068),Ht=i(853965),Ut=i(312449),Kt=i(107973),Gt=i(103055),jt=i(624444),qt=i(989709);class $t extends ht.PanePriceAxisView{constructor(e,t,i,s){super(e,t,i),this._dataSource=t,this._isForceOverlay=t.metaInfo().isPlotForceOverlay(s)}_position(){const e=this._isForceOverlay?this._chartModel.mainPane():this._chartModel.paneForSource(this._dataSource);if(null===e)return null;const t=this._isForceOverlay?this._chartModel.mainSeries().priceScale():this._dataSource.priceScale();if(null===t)return null;let i=e.priceScalePosition(t);return"overlay"===i&&(i=e.priceScalePosition(e.defaultPriceScale())),"overlay"===i?null:i}}var Yt=i(948767);const Qt=(0,c.getLogger)("Chart.Study"),Xt=a.t(null,void 0,i(814177));const Zt={symbolsForDisplay:!1,symbolsForChartApi:!0,skipHiddenInputs:!1,skipFakeInputs:!1,skipBooleanInputs:!1,asObject:!0,skippedGroups:[],skippedInputs:[],noExchanges:!1,noResolution:!1,keepOptionalSymbolsEmpty:!1,skipColorInputs:!1,skipTimeInputs:!1,skipOptionalEmptySymbolInputs:!1,skipTextareaInputs:!1,priceInputsForDisplay:!1},Jt={symbolsForDisplay:!1,symbolsForChartApi:!0,skipHiddenInputs:!0,skipFakeInputs:!1,skipBooleanInputs:!1,skippedGroups:[],skippedInputs:[],noExchanges:!1,noResolution:!1,keepOptionalSymbolsEmpty:!1,skipColorInputs:!1,skipTimeInputs:!1,skipOptionalEmptySymbolInputs:!1,skipTextareaInputs:!1,priceInputsForDisplay:!1,fakeInputsForDisplay:!1,doNotSkipHiddenWithMigrate:!1,onlyAtomValues:!0,patchSosInputs:!1},ei=ve.enabled("study_symbol_ticker_description"),ti=ve.enabled("hide_main_series_symbol_from_indicator_legend"),ii=ve.enabled("datasource_copypaste"),si=ve.enabled("hide_unresolved_symbols_in_legend");function ri(e,t){const i=e.plots[t];if(!i||!(0,O.isOhlcPlot)(i))return!1;const s=i.target,r=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],o=e.ohlcPlots&&e.ohlcPlots[s];return r&&(0,O.isOhlcPlotStyleBars)(r)||n&&(0,O.isOhlcPlotStyleBars)(n)||!!o&&(0,O.isOhlcPlotStyleBars)(o)}function ni(e,t){const i=e.plots[t];if(!i||!(0,O.isOhlcPlot)(i))return!1;const s=i.target,r=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],o=e.ohlcPlots&&e.ohlcPlots[s];return r&&(0,O.isOhlcPlotStyleCandles)(r)||n&&(0,O.isOhlcPlotStyleCandles)(n)||!!o&&(0,O.isOhlcPlotStyleCandles)(o)}function oi(e,t){(0,o.assert)(void 0!==e,"zOrder must be defined"),(0,o.assert)(!t.has(e),"zOrder must be unique")}function li(e,t){return e.plots.some((e=>((0,O.isColorerPlot)(e)||(0,O.isDataPlot)(e))&&e.target===t))}function ai(e){const t={};if(e.plots)for(let i=0;i= 1");const o=L.StudyMetaInfo.getStudyPropertyRootName(e),a=(0,j.clone)(e.defaults),c=ci();if((0,n.default)(c,ai(e)),(0,n.default)(c,a),(0,n.default)(c,(0,Wt.factoryDefaults)(o)),(0,n.default)(c,ui(e,s,o)),(0,n.default)(c,t),(0,n.default)(c,hi(a,c)),null!==i){const t=i.model().studiesColorRotatorFactory().getColorRotator(e);null!==t&&("Overlay@tv-basicstudies"===e.id?c.lineStyle.color=t.getColor(c.lineStyle.color):(0,n.default)(c,function(e,t){for(const i of Object.keys(e.styles)){const s=e.styles[i];if((0,l.isObject)(s)&&"color"in s){const e=s.color;s.color=t.getColor(e)}}return e}(c,t)))}return s.updateStudyInputsIfNeeded(c,null!==(r=c.version)&&void 0!==r?r:e.version,e),c}function pi(e,t,i,s,r){return function(e,t,i,s,r,n){const o=di(e,t,i,s);return L.StudyMetaInfo.getSourceInputIds(e).forEach(((e,t)=>{const i=o.inputs[e];t=1&&(0,n.default)(h,hi(a,h)),h}(e,t,i,s,o);return fi(t||e,r,l)}function vi(e,t,i,s,r){return mi(e,t,i,s,L.StudyMetaInfo.getStudyPropertyRootName(e),r)}function gi(e,t,i){let s=0,r=0;return e.inputs.filter((e=>"source"===e.type)).forEach((e=>{(0,f.getInputValue)(i[e.id]).includes("$")&&s++,(0,f.getInputValue)(t[e.id]).includes("$")&&r++})),Math.sign(r)-Math.sign(s)}function Pi(e){const t=new Set;for(const i of e.parentSources())for(const e of Pi(i))t.add(e);return t.add(e),Array.from(t)}function yi(e,t){return"BISTMIXED"===t&&(0,Vt.isVolumeDataError)(e.error)&&(e.error="VOLUME_BIST_MIXED",e.solution_id=ce.solutionIds.BIST_MIXED_SUBSCRIPTION,e.title=Vt.noVolumeErrorTooltip),{type:Vt.StudyStatusType.Error,errorDescription:e}}function Si(e){return"inherit"===e.type&&(e.type="price"),e}function bi(e,t,i,s){if(null!==t)switch(e.type){case"inherit":case"price":return new jt.PriceFormatter({priceScale:t});case"volume":return(0,Yt.getVolumeFormatter)(Math.log10(t));case"percent":return(0,Yt.getPercentageFormatter)(Math.log10(t))}if("inherit"===e.type)return null;const r=(0,j.isNumber)(e.precision)?Math.pow(10,e.precision):void 0;switch(e.type){case"price":return new jt.PriceFormatter({priceScale:r});case"volume":{let t=e.precision;return void 0===t&&(t=i&&(0,j.isNumber)(i.volume_precision)?i.volume_precision:0),(0,Yt.getVolumeFormatter)(t)}case"percent":return(0,Yt.getPercentageFormatter)(void 0===r?void 0:Math.log10(r));default:return Qt.logWarn(`Unsupported format type: ${e.type}`),null}}const xi=new Set(["first_visible_bar_time","last_visible_bar_time","subscribeRealtime"]);class Ci extends M.PriceDataSource{constructor(e,t,i,s){var r,n,l;super(e),this._onStart=new w.Delegate,this._restarting=!1,this._paneViews=[],this._forceOverlaysPaneViews=[],this._legendView=null,this._priceAxisViews=[],this._forceOverlayPriceAxisViews=[],this._priceAxisViewsBase=[],this._resolvedSymbols={},this._resolvedSymbolsByInput={},this._priceLinesAxisViews=[],this._labelPaneViews=[],this._forceOverlayLabelPaneViews=[],this._ownFirstValue=null,this._formatter=null,this._defaultFormatter=null,this._dataUpdated=new w.Delegate,this._currencySourceSymbolInputProperty=null,this._onHibernationStateChange=new w.Delegate, this._symbolsResolved=new w.Delegate,this._statusChanged=new w.Delegate,this._inputsAnchorsPaneView=null,this._inputsLinesPaneView=null,this._inputsTimeAxisPaneViews=[],this._inputsPriceAxisPaneViews=[],this._sources=[],this._status={type:Vt.StudyStatusType.Undefined},this._recompilationStatus=null,this._wasCompletedBefore=!1,this._studyId=null,this._isSubscribedToSessionId=!1,this._titleStrCache={},this._titleInPartsCache={},this._children=[],this._graphicsPriceAxisViews=[],this._plotOffsets={},this._ongoingDataUpdate=Promise.resolve(),this._studyModified=!1,this._tagsChanged=new w.Delegate,this._studyName="",this._turnaround="st0",this._pendingResolveSymbols=new Map,this._onIsActualIntervalChange=new w.Delegate,this._childStudyByRebind=new w.Delegate,this._lastNonEmptyPlotRowCache={},this._startMovingPoint=null,this._processHibernateBound=this.processHibernate.bind(this,1),this._maxOffset=new Lt.WatchedValue(0),this._currencySourceSymbolInfo=null,this._graphicsPriceRangeGroups=null,this._graphicsViewsReady=!1,this._visibleTimeRangeInputs=null,this._turnaroundCounter=0,this._deferredPinePatchProps=!1,this._propertiesPatched=Promise.resolve(),this._aboutToBeDestroyed=new w.Delegate,this._definitionsViewModel=null,this._plotFormatters=new Map,this._pineSourceCodeModel=null,this._onParentSourcesChanges=new w.Delegate,this._statusChangesSubscriber={},this._chartApi=e.chartApi(),this._properties=t,this._metaInfo=s,this._hideMatches=s.inputs.filter((e=>e.hideWhenPlotsHidden)).map((e=>({id:e.id,plotIds:e.hideWhenPlotsHidden||[]}))),this._series=this._model.mainSeries(),this._series.onIntervalChanged().subscribe(this,this._calcIsActualInterval),this._series.alertCreationAvailable().subscribe(this._updateAlertCreationAvailable.bind(this)),this._showStudyArgumentsProperty=e.properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments,e.collapsed().subscribe(this._processHibernateBound),this._sources=i,L.StudyMetaInfo.setChildStudyMetaInfoPropertiesSourceId(s,null===(r=this._sources[0])||void 0===r?void 0:r.id(),t),i.forEach((e=>{e.setChild(this)})),[this._series,...i].forEach((e=>{e.currencyChanged().subscribe(this,this._onSourceCurrencyChanged),e.unitChanged().subscribe(this,this._onSourceUnitChanged),e.priceRangeReadyChanged().subscribe(this,this._onSourcePriceRangeReadyChanged),e.formatterChanged().subscribe(this,this._onSourceFormatterChanged),e.priceStepChanged().subscribe(this,this._onSourcePriceStepChanged)})),ei&&this._model.mainSeries().properties().childs().statusViewStyle.childs().symbolTextSource.listeners().subscribe(this,(()=>{this.invalidateTitleCache(!0)}));const a=this._properties.childs();for(const e of L.StudyMetaInfo.getSourceInputIds(s))null===(n=a.inputs.childs()[e])||void 0===n||n.subscribe(this,this._onSourceInputChanged);this._properties.subscribe(this,this._onPropertiesChanged),a.visible.subscribe(this,this._visibleChanged),a.visible.subscribe(this,(()=>this.processHibernate())),a.intervalsVisibilities.subscribe(this,this._calcIsActualInterval), a.inputs.listeners().subscribe(this,this._updateMaxOffsetValue),void 0!==a.offsets&&a.offsets.listeners().subscribe(this,this._updateMaxOffsetValue),void 0!==a.offset&&a.offset.listeners().subscribe(this,this._updateMaxOffsetValue),W.hideAllIndicators().subscribe(this,this._visibleChanged);for(let e=0;e{this.processHibernate(),this.invalidateTitleCache()}))}for(const e of Object.keys(this._metaInfo.graphics))for(const t of Object.keys(this._metaInfo.graphics[e])){const i=null===(l=a.graphics.childs()[e])||void 0===l?void 0:l.childs()[t];i&&i.childs().visible&&(0,o.ensureDefined)(i.childs().visible).subscribe(this,(()=>this.processHibernate()))}this._isActualInterval=(0,Mt.isActualInterval)(this._series.intervalObj(),a.intervalsVisibilities),this._initializeStudyInputsPaneViews(),this._handler=e=>this._onData(e),this._valuesProvider=new Gt.StudyValuesProvider(this,e),this._graphicsPriceRangeGroups=oe(this),this._graphics=new B.LiveStudyGraphics(s.graphics),this._signlePerformanceValue=(0,pe.createWVFromGetterAndSubscriptions)((()=>{var e;return null!==(e=Array.from((0,o.ensureDefined)(this._graphics.performance().get("performance")))[0])&&void 0!==e?e:null}),[(0,o.ensureDefined)(this._graphics.observablePerformance().get("performance")).changed(),(0,o.ensureDefined)(this._graphics.observablePerformance().get("performance")).cleared()]),this._chartApi=e.chartApi(),this._invalidateLastNonEmptyPlotRowCache(),this._data=new D.PlotList((0,qt.studyPlotFunctionMap)(this._metaInfo),qt.studyEmptyPlotValuePredicate),this._createViews(),this._recreatePriceFormattingDependencies(this._series.symbolInfo()),a.precision.subscribe(this,this._onFormatterPropsChanged),this._showStudyArgumentsProperty.subscribe(this,(()=>this.invalidateTitleCache(!0))),a.inputs.listeners().subscribe(this,(()=>this.invalidateTitleCache(!0))),ve.enabled("update_study_formatter_on_symbol_resolve")&&e.mainSeries().dataEvents().symbolResolved().subscribe(this,this._recreatePriceFormattingDependencies),e.mainSeries().dataEvents().symbolResolved().subscribe(this,(()=>this.invalidateTitleCache(!0)));const c=new Set;if(this._simplePlotsCount=s.plots.filter(((e,t)=>{if((0,O.isLinePlot)(e))return!0;if((0,O.isOhlcPlot)(e)){const t=e.target;return!c.has(t)&&(c.add(t),!0)}return!1})).length,this.hasBarColorer()&&a.visible.listeners().subscribe(this,(()=>e.mainSeries().invalidateBarStylesCache)),this._definitionsViewModel=null,this._updateMaxOffsetValue(),s.inputs.some((e=>xi.has(e.id)))){this._visibleTimeRangeInputs=e.visibleRangeStudiesInputs().spawn();const t=this._visibleTimeRangeInputs.value();let i=null!==t;this._visibleTimeRangeInputs.subscribe((e=>{const t=()=>{this._onVisibleTimeRangeInputsChanged(e),i!==(null!==e)&&(i=null!==e,!i||this._restarting||this.isStarted()||this.start(!0))};this._statusChanged.unsubscribeAll(this._statusChangesSubscriber), this._status.type===Vt.StudyStatusType.Loading?this._statusChanged.subscribe(this._statusChangesSubscriber,t,!0):t()})),t&&this._updateVisibleTimeRangeInputs(t,!1)}}destroy(){var e,t,i,s,r,n;null===(e=this._signlePerformanceValue)||void 0===e||e.destroy(),this._aboutToBeDestroyed.fire(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),this._showStudyArgumentsProperty.unsubscribeAll(this),this._model.mainSeries().dataEvents().symbolResolved().unsubscribeAll(this);this.parentSources().forEach((e=>{e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this),e.priceRangeReadyChanged().unsubscribeAll(this),e.formatterChanged().unsubscribeAll(this),e.priceStepChanged().unsubscribeAll(this)})),this._series.properties().childs().statusViewStyle.childs().symbolTextSource.unsubscribeAll(this),this._series.onIntervalChanged().unsubscribeAll(this),this._series.alertCreationAvailable().unsubscribe(this._updateAlertCreationAvailable),this.formatterChanged().unsubscribe(this,this.invalidateTitleCache),W.hideAllIndicators().unsubscribe(this,this._visibleChanged),this._model.collapsed().unsubscribe(this._processHibernateBound),null!==this._currencySourceSymbolInputProperty&&this._currencySourceSymbolInputProperty.unsubscribeAll(this),null===(t=this._legendView)||void 0===t||t.destroy(),null===(s=null===(i=this._pineSourceCodeModel)||void 0===i?void 0:i.get())||void 0===s||s.destroy(),null===(r=this._pineSourceCodeModel)||void 0===r||r.destroy(),null===(n=this._visibleTimeRangeInputs)||void 0===n||n.destroy(),super.destroy()}properties(){return this._properties}propertiesPatched(){return this._propertiesPatched}isDraggable(){return!this._metaInfo.linkedToSeries}logs(){return this._metaInfo.graphics.logs&&this._graphics instanceof B.LiveStudyGraphics?(0,o.ensureDefined)(this._graphics.observableLogs().get("logs")):null}logLevelMask(){const e=this._properties.childs().inputs.childs().__log_level.value();if(!(0,j.isNumber)(e)||e<0||e>7)throw new Error(`Value of log level is unexpected, current value is ${e}, but expected values from 0 to 7`);return{error:Boolean(1&e),warning:Boolean(2&e),info:Boolean(4&e)}}setLogLevelMask(e){const t=(Number(e.error)&&1)|(Number(e.warning)&&2)|(Number(e.info)&&4);this._properties.childs().inputs.childs().__log_level.setValue(t)}performance(){return this._graphics instanceof B.LiveStudyGraphics?this._signlePerformanceValue:new Lt.WatchedValue(null)}profilingEnabled(){var e;return!!(null===(e=this._properties.childs().inputs.childs().__profile)||void 0===e?void 0:e.value())}enableProfiling(e){var t;null===(t=this._properties.childs().inputs.childs().__profile)||void 0===t||t.setValue(e)}onAboutToBeDestroyed(){return this._aboutToBeDestroyed}priceScale(e){return e?this._model.mainSeries().priceScale():super.priceScale()}lastValueData(e,t,i){const s={noData:!0},r=this.metaInfo().isPlotForceOverlay(e),n=r?this._model.mainSeries().priceScale():this.priceScale() ;if(this._model.timeScale().isEmpty()||null===n||n.isEmpty()||this.data().isEmpty())return s;const o=this._model.timeScale().visibleBarsStrictRange(),l=this.firstValue(!0,r);if(null===o||null===l)return s;if(!this._properties.childs().visible.value())return s;const a=this._properties.childs().styles,c=this._properties.childs().ohlcPlots;let u,h;if(a&&a.childs()[e]&&(u=a.childs()[e]),c&&c.childs()[e]&&(u=c.childs()[e]),!u||0===u.childs().display.value())return s;const d=this.metaInfo().plots;for(h=0;he.id()));if(a.length&&(l.parentSources=a),e){let e=this.data();const t=this._model.timeScale(),i=this._seriesDataRangeToSave(e);null!==i&&(e=e.range(i.firstBar(),i.lastBar())),l.data=e.state(),l.data.symbols=this._resolvedSymbols,l.data.graphics=(0,B.saveStudyGraphics)(this.graphics(),t.visibleBarsStrictRange()),l.data.plotOffsets=this._plotOffsets}this.ownerSource()&&(l.ownerSource=null===(i=this.ownerSource())||void 0===i?void 0:i.id());for(let e=0;e=0?e:0}}if(null===(s=l.state)||void 0===s?void 0:s.inputs){const e=l.metaInfo.inputs.find((e=>"ILScript"===e.name));e&&delete l.state.inputs[e.id],delete l.state.inputs.__log_level,delete l.state.inputs.__profile}const c=this.stateCustomFields();var h;return c&&(l.customFields=c),t&&(h=l).metaInfo&&h.metaInfo.scriptIdPart&&h.metaInfo.scriptIdPart.startsWith("USER;")&&(function(e){if(!e.metaInfo)return;const t=e.metaInfo.scriptIdPart;if(!t)return;const i=t.split(";")[0],s=e.metaInfo;s.id=(s.id||"").replace(t,i),s.fullId=(s.fullId||"").replace(t,i),s.name=(s.name||"").replace(t,i),s.shortId=(s.shortId||"").replace(t,i),s.scriptIdPart=(s.scriptIdPart||"").replace(t,i), e.state&&(e.state.id=(e.state.id||"").replace(t,i),e.state.name=(e.state.name||"").replace(t,i),e.state.scriptIdPart=(e.state.scriptIdPart||"").replace(t,i))}(h),function(e){const t=(e.metaInfo&&e.metaInfo.inputs||[]).find((e=>"ILScript"===e.name));t&&(t.defval="",e.state&&e.state.inputs&&(e.state.inputs[t.id]=""),e.metaInfo.defaults.inputs&&(e.metaInfo.defaults.inputs[t.id]=""))}(h)),l}stateCustomFields(){}restoreStateCustomFields(e){}restoreData(e){var t,i;this._invalidateLastNonEmptyPlotRowCache(),this.data().restoreState(e),this._resolvedSymbols=null!==(t=e.symbols)&&void 0!==t?t:{},this._graphics=e.graphics?(0,B.loadStudyGraphics)(e.graphics):(0,B.emptyStudyGraphics)(),this._postProcessGraphics(),this._plotOffsets=null!==(i=e.plotOffsets)&&void 0!==i?i:{},this._setStatus({type:Vt.StudyStatusType.Completed},!0)}hasStateForAlert(){return de.alertsAvailable&&!this.isFailed()&&!this._metaInfo.isTVLibrary&&this._series.alertCreationAvailable().value()&&(this._hasAlertConditions()||this._hasAvailableAlertPlots()||this._hasAlertFunction())}stateForAlert(){const e=(0,o.ensureNotNull)(this._alertMetaInfo()),t=this._plotsForAlert(),i=this._collectDepsForAlert(),s=i.idForAlert,r=i.studyDependencies,n=i.inputsForAlert,l=(this.priceScale()||this.model().mainSeries().priceScale()).formatter(),a=l?p.FormattersSerializer.serialize(l):null,c={id:s,uniqueId:s,type:(0,o.ensureNotNull)((0,u.getStudyClassName)(this.constructor)),title:(0,h.clean)(this._title(q.TitleDisplayTarget.StatusLine,!1,{},!1,!1,!0),!0),shortTitle:(0,h.clean)(this._title(q.TitleDisplayTarget.StatusLine,!0,{},!1,!1,!0),!0),shortDescription:(0,h.clean)(e.shortDescription||"Study",!0),fullId:e.fullId,isTVScript:Boolean(e.isTVScript),isTVScriptStrategy:Boolean(e.isTVScriptStrategy),isTVLibrary:Boolean(e.isTVLibrary),hasAlertFunction:Boolean(e.hasAlertFunction),plots:t,inputs:n,alerts:e.alerts,scriptIdPart:e.scriptIdPart,scriptVersion:e.pine?e.pine.version:"-1",studyDependencies:r,formatter:a},d=g(this);d&&(c.dangerReason=d);const _=e.defaultStrategyAlertMessage;return _&&(c.defaultStrategyAlertMessage=(0,h.clean)(_,!0)),c}idForAlert(){return this._collectDepsForAlert().idForAlert}hasBarColorer(){return(0,o.ensureNotNull)(this._metaInfo).plots.some(O.isBarColorerPlot)}barColorer(){const e=this._metaInfo.plots;let t=null;for(let i=0;i"bar_time"!==e.type))}restart(e){this._restarting=!0,this.clearData(),(e||ve.enabled("stop_study_on_restart"))&&this.stop(),setTimeout(this.start.bind(this),0)}stop(e,t){if(!0===e&&this._children)for(const e of this._children)e.stop(!0);this._stopStudyOnServer(),this.clearData(),this._unsubscribeToSessionId(),this.recalculate()}disconnect(){this._studyId=null,this._model.isSnapshot()||(this._resolvedSymbols={},this._resolvedSymbolsByInput={})}sourceId(){return this._studyId}parentSources(){return this._sources}symbolSource(){ return this._firstSourceOrSeries().symbolSource()}valueAt(e,t){return this.symbolSource().valueAt(e,t)}barsProvider(){return this._firstSourceOrSeries().barsProvider()}ownerSource(){return this.isChildStudy()?this._sources[0]:super.ownerSource()}isChildStudy(){return this._sources.length>0}hasChildren(){return this._children.length>0}isStarted(){return Boolean(this._studyId)}isRestarting(){return this._restarting}isActualInterval(){return this._isActualInterval}onIsActualIntervalChange(){return this._onIsActualIntervalChange}isVisible(){var e,t,i;const s=this._properties.childs();if(this._model.collapsed().value()||!s.visible.value()||!this.isActualInterval())return!1;const r=this.metaInfo();if(r.plots.length>0)for(let e=0;ee.isHibernated())).map((e=>e.start())));const r=!(this.isHibernationAllowed()&&!this.isVisible())||!0===t;if(this._chartApi&&this._chartApi.isConnected().value()&&r)try{await this._allSymbolsAreResolved(),await this._startAfterSymbolsResolved(e,t)}catch(e){const t=`ERROR: ${this._debugId()} start failed, ${e}`;Qt.logError(t),this._restarting=!1,"TooManyStudies"===(null==e?void 0:e.cause)&&(0,x.showTooManyStudiesNotice)(this._chartApi.getStudyCounter())}}replaceData(e,t,i){this._invalidateLastNonEmptyPlotRowCache(),this.data().remove(e+1),this.data().addTail(i,t)}inputs(e){const t=(0,n.default)((0,j.clone)(Zt),e||{});t.skipOptionalEmptySymbolInputs&&(t.keepOptionalSymbolsEmpty=!0);const i=(0,r.default)(this._buildInputs(t));return t.patchSosInputs&&L.StudyMetaInfo.patchSoSInputs(i,(e=>{var t,i;return null!==(i=null===(t=this._sources.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),i}data(){return this._data}moveData(e){this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>{this._invalidateLastNonEmptyPlotRowCache(),this.data().move(e)}))}plots(){return this.data()}metaInfo(){return this._metaInfo}status(){var e;return null!==(e=this._recompilationStatus)&&void 0!==e?e:this._status}name(e){return e?this.metaInfo().shortDescription||"Study":this.metaInfo().description||"Study"}title(e,t,i,s,r,n){s=void 0===s?!this._showStudyArgumentsProperty.value():s;const o=JSON.stringify([e,t,i,s,r,n]);if(this._titleStrCache[o])return this._titleStrCache[o] ;if(this._titleInPartsCache[o])return this._joinTitlesParts(this._titleInPartsCache[o]);const l=this._title(e,t,i,s,r,n);return this._titleStrCache[o]=l,l}titleInParts(e,t,i,s,r){s=void 0===s?!this._showStudyArgumentsProperty.value():s;const n=JSON.stringify([e,t,i,s,r]);if(this._titleInPartsCache[n])return this._titleInPartsCache[n];const o=this._titleInParts(e,t,i,s,r);return this._titleInPartsCache[n]=o,o}invalidateTitleCache(e){if(this._titleStrCache={},this._titleInPartsCache={},!0===e&&this._children)for(let t=0;t!this._metaInfo.isPlotForceOverlay(e.id)));if(null===n){const t=new Set,a=this._metaInfo.filledAreas||[];for(let e=0;et.update(e))),this._forceOverlaysPaneViews.forEach((t=>t.update(e))),this._labelPaneViews.forEach((t=>t.update(e))), this._forceOverlayLabelPaneViews.forEach((t=>t.update(e))),null===(t=this._dataWindowView)||void 0===t||t.update(),null===(i=this._legendView)||void 0===i||i.update(),null===(s=this._statusView)||void 0===s||s.update(),this._priceAxisViews.forEach((t=>t.update(e))),this._forceOverlayPriceAxisViews.forEach((t=>t.update(e))),this._priceLinesAxisViews.forEach((t=>t.update(e))),null===(r=this._inputsLinesPaneView)||void 0===r||r.update(e),null===(n=this._inputsAnchorsPaneView)||void 0===n||n.update(e),this._inputsTimeAxisPaneViews.forEach((t=>t.update(e))),this._inputsPriceAxisPaneViews.forEach((t=>t.update(e))),"data-source-change"===e.type&&e.sourceId===this.id()&&e.clearData&&this._children.forEach((e=>e.updateAllViews({type:"data-source-change",sourceId:e.id(),clearData:!0})))}removeByRemoveAllStudies(){return!0}getStudyName(){return this._studyName}nearestIndex(e,t,i){var s;return null===(s=this.data().search(e,t,i))||void 0===s?void 0:s.index}getMinFirstBarIndexForPlot(e){var t,i,s,r,n,o,l,a,c,u,h,d,p,_,f;const m=this._properties.childs(),v=this._metaInfo,g=null!==(f=null!==(d=null!==(c=null!==(o=null!==(s=null===(i=null===(t=m.styles.childs()[e])||void 0===t?void 0:t.child("showLast"))||void 0===i?void 0:i.value())&&void 0!==s?s:null===(n=null===(r=m.filledAreasStyle.childs()[e])||void 0===r?void 0:r.child("showLast"))||void 0===n?void 0:n.value())&&void 0!==o?o:null===(a=null===(l=v.styles)||void 0===l?void 0:l[e])||void 0===a?void 0:a.showLast)&&void 0!==c?c:null===(h=null===(u=m.ohlcPlots.childs()[e])||void 0===u?void 0:u.child("showLast"))||void 0===h?void 0:h.value())&&void 0!==d?d:null===(_=null===(p=v.ohlcPlots)||void 0===p?void 0:p[e])||void 0===_?void 0:_.showLast)&&void 0!==f?f:null;if(null===g)return-1/0;const P=this.data().lastIndex();return null===P?-1/0:P-g+1}guiPlotName(e,t){var i,s,r;return null!==(r=null===(s=null===(i=this._metaInfo.styles)||void 0===i?void 0:i[t])||void 0===s?void 0:s.title)&&void 0!==r?r:this.title(e)}childStudyByRebind(){return this._childStudyByRebind}isPine(){return void 0!==this._metaInfo.pine}isStandardPine(){return this.isPine()&&L.StudyMetaInfo.isStandardPine(this._metaInfo.id)}isLinkedToSeries(){return!0===this._metaInfo.linkedToSeries}defaultPlotIdForAlert(){return this._metaInfo.plots.length?this._metaInfo.plots[0].id:null}resolvedSymbolInfoBySymbol(e){return this._resolvedSymbols&&e&&this._resolvedSymbols[this._getSymbolForResolve(e)]||null}hasPendingUnresolvedSymbols(){return this._pendingResolveSymbols.size>0}hasSymbolInputs(){return this._metaInfo.inputs.some((e=>"symbol"===e.type))}currency(){const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().currency():null}currencySourceSymbolInfo(){var e,t,i;return null!==(e=this._currencySourceSymbolInfo)&&void 0!==e?e:null!==(i=null===(t=this.symbolSource())||void 0===t?void 0:t.symbolInfo())&&void 0!==i?i:null}unit(){const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().unit():null}canOverrideMinTick(){return!1}dataWindowView(){ return this._dataWindowView}statusView(){return this._statusView}legendView(){return this._legendView}pineSourceCodeModel(){return this.metaInfo().pine?(this._pineSourceCodeModel||(this._pineSourceCodeModel=new C.AsyncResourceWrapper(i.e(89199).then(i.bind(i,356146)).then((e=>this._isDestroyed?null:new e.PineSourceCodeModel(this))))),this._pineSourceCodeModel.promise()):Promise.resolve(null)}inputsForAlertState(){return this.inputs()}sessionId(){return this._firstSourceOrSeries().sessionId()}sessionIdChanged(){return this._firstSourceOrSeries().sessionIdChanged()}getSymbolString(e){return""===e?"":(0,H.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(e))}onStatusChanged(){return this._statusChanged}symbolsResolved(){return this._symbolsResolved}onHibernationStateChange(){return this._onHibernationStateChange}legendValuesProvider(){return new k.StudyLegendValuesProvider(this,this.model())}statusProvider(e){return new G.StudyStatusProvider(this)}correctScaleMargins(e){if("Volume"===this.metaInfo().shortId){const t=this.model().paneForSource(this);return null!==t&&t.isOverlay(this)&&t.containsMainSeries()?{top:.75,bottom:0}:{top:e.top,bottom:0}}return e}canBeHiddenByGlobalFlag(){return!0}isSourceHidden(){return!this.isVisible()||this.canBeHiddenByGlobalFlag()&&W.hideAllIndicators().value()}wasCompletedBefore(){return this._wasCompletedBefore}paneViews(e){const t=this._model.mainPane();if(this.isSourceHidden())return null;if(!e.hasPriceDataSource(this))return e!==t?null:this._forceOverlaysPaneViews;const i=[];return!this._startMovingPoint&&this._wasCompletedBefore&&i.push(...this._paneViews.filter((e=>{var t;return!(null===(t=e.isForceOverlay)||void 0===t?void 0:t.call(e))}))),this._inputsLinesPaneView&&(this._startMovingPoint||this._model.selection().isSelected(this))&&i.push(this._inputsLinesPaneView),this._inputsAnchorsPaneView&&i.push(this._inputsAnchorsPaneView),e===t&&i.push(...this._forceOverlaysPaneViews),i}labelPaneViews(e){const t=this._model.mainPane();if(this.isSourceHidden()||!e.hasPriceDataSource(this))return this._metaInfo.hasForceOverlayPlots()?e!==t?null:this._forceOverlayLabelPaneViews:null;const i=[...this._labelPaneViews];return e===t&&i.push(...this._forceOverlayLabelPaneViews),i}timeAxisViews(){return this._model.selection().isSelected(this)?this._inputsTimeAxisPaneViews:null}priceAxisViews(e,t){if(t!==this.priceScale()&&t===this._model.mainSeries().priceScale()&&!e.hasDataSource(this))return this._forceOverlayPriceAxisViews;const i=this._properties.childs().oldShowLastValue;if(i&&!i.value())return null;let s=this._priceAxisViews.slice();return this._model.selection().isSelected(this)&&(s=s.concat(this._inputsPriceAxisPaneViews)),t===this._model.mainSeries().priceScale()&&(s=s.concat(this._forceOverlayPriceAxisViews)),e.findTargetPriceAxisViews(this,t,s,this._priceLinesAxisViews)}movable(){return null!==this._inputsAnchorsPaneView}startMoving(e,t,i,s){this._startMovingPoint=e}move(e,t,i,s){if(void 0!==e.logical&&null!==this._startMovingPoint){if(Array.isArray(t)){const i=t ;this._updateInputValue(e.logical,i[0]),this._updateInputValue(e.logical,i[1])}else this._updateInputValue(e.logical,t);this.updateAllViews((0,Dt.sourceChangeEvent)(this.id()))}}endMoving(e,t){return this._startMovingPoint=null,{indexesChanged:!1,pricesChanged:!1}}clearData(){var e;this._invalidateLastNonEmptyPlotRowCache(),this.data().clear(),this._graphics instanceof B.LiveStudyGraphics&&(null===(e=this._graphics)||void 0===e||e.clear()),this._plotOffsets={},this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this.updateAllViews((0,Dt.sourceChangeEvent)({sourceId:this.id(),clearData:!0}))}convertYCoordinateToPriceForMoving(e,t){const i=this.priceScale();if(!t||!i||i.isEmpty())return null;const s=t.firstValue();return null===s?null:i.coordinateToPrice(e,s)}processHibernate(e){const t=this.isVisible();if(!this.isStarted()&&t&&(this._sources.forEach((e=>{e.processHibernate()})),this.start(void 0,void 0,e),this._onHibernationStateChange.fire(!1)),this.isHibernationAllowed()&&this.isStarted()&&!t){for(const e of this._children)e.processHibernate();this.stop(void 0,e),this._onHibernationStateChange.fire(!0)}}isHibernationAllowed(){return!this.metaInfo().historyCalculationMayChange&&(!this.hasChildren()||!!this._model.collapsed().value()&&this._children.every((e=>e.isHibernationAllowed())))}isPlotVisibleAt(e,t){let i;const s=this.metaInfo().plots.find((t=>t.id===e));if(i=void 0!==s?(0,O.isOhlcPlot)(s)?this._properties.childs().ohlcPlots.childs()[s.target]:this._properties.childs().styles.childs()[e]:this._properties.childs().ohlcPlots.childs()[e],void 0===i)throw new Error(`Study does not contain ${e} plot`);const r=i.childs().display.value();return null!==r&&(r&t)===t}recalculate(){const e=this._model.paneForSource(this);this._model.recalculatePane(e,(0,Dt.sourceChangeEvent)(this.id())),this._model.updateSource(this)}maxOffset(){return this._maxOffset}onStart(){return this._onStart}onParentSourcesChanges(){return this._onParentSourcesChanges}isHibernated(){return!this.isVisible()&&!this.isStarted()}graphicsViewsReady(){return this._graphicsViewsReady}setRecompilationActive(e){var t;e!==Boolean(this._recompilationStatus)&&(this._recompilationStatus=e?{type:Vt.StudyStatusType.Loading,startTime:Date.now()}:null,null===(t=this._statusView)||void 0===t||t.update(),this._model.updateSource(this),this._statusChanged.fire(this.status()))}turnaround(e){if(!e)return this._turnaround;return function(e,t){let i=t.turnaround,s=[t];for(;s.length>0;){let e=[];const t=[];s.forEach((i=>{const s=fe(i.sourceStudies).sort(_e);if(s.length>0){e=e.concat(s);const i=s.map((e=>e.turnaround)).join("_");t.push(i)}})),t.length&&(i=t.join("_")+"_"+i),s=e}return e+"_"+i}(this._series.seriesSource().turnaround(),me(this))}canHaveChildren(){var e;return this._canHaveChildren=null!==(e=this._canHaveChildren)&&void 0!==e?e:L.StudyMetaInfo.canHaveChildren(this._metaInfo),this._canHaveChildren}setChild(e){-1===this._children.indexOf(e)&&this._children.push(e)}unsetChild(e){const t=this._children.indexOf(e) ;~t&&this._children.splice(t,1)}getAllChildren(){const e=this._children.slice();for(let t=0;te.id()===i)))&&void 0!==t?t:null}return this._series}priceStep(){return this._priceStep||this._firstSourceOrSeries().priceStep(!1)}recreatePriceFormatter(){this._recreatePriceFormattingDependencies()}setOwnerSource(e){super.setOwnerSource(e),this._recreatePriceFormattingDependencies()}onTagsChanged(){return this._tagsChanged}getPropertyDefinitionsViewModel(){return null===this._definitionsViewModel?this._getPropertyDefinitionsViewModelClass().then((e=>null===e||this._isDestroyed?null:(null===this._definitionsViewModel&&(this._definitionsViewModel=new e(this._model.undoModel(),this)),this._definitionsViewModel))):Promise.resolve(this._definitionsViewModel)}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_alertMetaInfo(){return this.metaInfo()}_createStudyOnServer(){if(this._isDestroyed)return!1;const e=this._getStudyIdWithLatestVersion();this._studyId=(0,U.makeNextStudyId)(),this._incrementTurnaround(),this._studyName=e;const t=(0,j.clone)((0,o.ensureDefined)(this._inputs));let i;if(L.StudyMetaInfo.patchSoSInputs(t,(e=>{var t,i;return null!==(i=null===(t=this._sources.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),i=this._chartApi.createStudy(this._studyId,this._turnaround,(0,o.ensureNotNull)(this._series.seriesSource().instanceId()),this._studyName,t,this._handler,this._studySpec()),!i)return this._studyId=null,i;if(void 0===this._oldStudyInputs){if(this._metaInfo.TVScriptMetaInfoExprs){this._previousPatchMap={};const e=this._metaInfo.TVScriptMetaInfoExprs.patchMap;(0,y.iterateAndPatchObjectsByMap)([this._properties,this._metaInfo.defaults,this._metaInfo],e,((e,t,i)=>{const s=e[0],r=e[1],n=e[2];r.hasOwnProperty(t)?(0,o.ensureDefined)(this._previousPatchMap)[i]=s[t].value():(0,o.ensureDefined)(this._previousPatchMap)[i]=n[t]}))}const e=this._prepareInputs(Jt);Object.keys(e).some((e=>(0,f.isStudyInputDependsOnChart)({id:e})))||(this._oldStudyInputs=e)}return this._deferredPinePatchProps&&!this._restarting&&this._pinePatchProps(),!0}_stopStudyOnServer(){this._chartApi&&this._chartApi.isConnected().value()&&this.isStarted()&&(this._chartApi.removeStudy((0,o.ensureNotNull)(this._studyId)),this._setStatus({type:Vt.StudyStatusType.Undefined})),this._studyId=null}_modifyStudyOnServer(e,t){const i=(0,j.clone)((0,o.ensureDefined)(e));L.StudyMetaInfo.patchSoSInputs(i,(e=>{var t,i;return null!==(i=null===(t=this._sources.find((t=>t.id()===e)))||void 0===t?void 0:t.sourceId())&&void 0!==i?i:null})),this._chartApi.modifyStudy((0,o.ensureNotNull)(this._studyId),this._turnaround,i,this._handler,t)}_sendNotifyCommand(e,t){this._chartApi.notifyStudy((0,o.ensureNotNull)(this._studyId),e,t)}_transformData(e){}_invalidateLastNonEmptyPlotRowCache(){ this._lastNonEmptyPlotRowCache={}}_collectDepsForAlert(){const e=[this,...this._getAllOwnerSources().filter((e=>e instanceof Ci))];return(0,P.collectDepsForAlert)(e)}_allInputsAreValid(){var e;if(null===(null===(e=this._visibleTimeRangeInputs)||void 0===e?void 0:e.value()))return!1;for(const e of this._metaInfo.inputs)if("bar_time"===e.type){const t=e.id;if(null==this._properties.childs().inputs.childs()[t].value())return!1}return!0}async _startAfterSymbolsResolved(e,t){await Promise.all(this._sources.map((e=>!e.isStarted()||e.isRestarting()?new Promise((t=>{e.onStart().subscribe(this,t,!0)})):Promise.resolve()))),this.isStarted()&&!this._restarting||(this._restarting=!1,this._allInputsAreValid()&&!this.metaInfo().isTVScriptStub&&(this._inputs=this._apiInputs(),this._createStudyOnServer()&&(this._subscribeToSessionId(),this._onStart.fire(),!0===e&&this._children&&await this._children.map((e=>e.start(!0,t))))))}async _changeInputsImpl(e,t){const s=this._calcSources(),r=gi(this._metaInfo,e,t),n=()=>{for(const i of this._metaInfo.inputs){if("source"!==i.type)continue;const s=e[i.id].v,r=t[i.id].v;if(s!==r){(0,o.ensureDefined)(this._properties.childs().inputs.child(i.id)).setValue(r)}}};if(this.isStarted()&&this._chartApi.isConnected().value()&&r>0&&!this._chartApi.canCreateStudy(this._studySpec(!0),!0).success){const e=window.user.pro_plan;return(0,S.createGoProDialog)({feature:"studyOnStudy",actions:e&&"pro_premium_expert"===e?[{text:a.t(null,void 0,i(875139)),action:b.PredefinedAction.Close}]:void 0}),void n()}this._inputs=e;let l=!1;const c=Object.values(f.RangeDependentStudyInputNames);for(const i of Object.keys(e))if(JSON.stringify(e[i])!==JSON.stringify(t[i])&&!c.includes(i)){l=!0;break}this._incrementTurnaround(),l&&this.disablePriceRangeReady();try{await this._updateParentSources(s,r,!0),this._modifyStudyOnServer(e,r),this._studyModified=!0}catch(e){Qt.logError(`Error applying parent sources: ${e}`),n()}this.invalidateTitleCache()}_createPriceAxisView(e){return new Nt.StudyPriceAxisView(this,{plotIndex:e})}_createPriceLineAxisView(e){return new Et.StudyPriceLineAxisView(this,e)}_createStudyPlotPaneView(e){return new dt.StudyPlotPaneView(this,this._series,this._model,e)}_createViews(){var e,t,i,s;this._priceAxisViewsBase=[],this._forceOverlayPriceAxisViews=[],this._priceLinesAxisViews=[],this._paneViews=[],this._forceOverlaysPaneViews=[],this._labelPaneViews=[],this._forceOverlayLabelPaneViews=[];const r=new Set,n=this.metaInfo(),l=Boolean(n.usePlotsZOrder),a=new Map,c=this._properties.childs();if(c.filledAreasStyle&&n.filledAreas)for(let e=0;e{const i=c.bands.childs()[t];if(i&&i.childs().visible.value()){const t=new xt(i,this),s=l?(0,o.ensureDefined)(e.zorder):a.size;oi(s,a),a.set(s,{paneViews:[t]})}})),c.bandsBackground&&((0,o.assert)(!l,"'usePlotsZOrder' flag does not supported"),a.set(a.size,{paneViews:[new Tt(this)]}));const u=this._paneViews,h=this._forceOverlaysPaneViews;this._createGraphicsPaneViews().then((e=>{for(let t=0;te-t));for(let e=0;e0){const t=(0,o.ensureNotNull)(this.barColorer()).firstColoredBar(e[0].index);null!==t&&this._model.mainSeries().invalidateBarStylesCache(t)}null!==t&&this._postProcessGraphics();const r=this._model.paneForSource(this);this._model.recalculatePane(r,(0,Dt.sourceChangeEvent)({sourceId:this.id(),firstUpdatedTimePointIndex:null!=s?s:void 0,nonSeriesOnly:0===e.length})),this._updateSources()}_titleInputs(e,t,i){return this.inputs(this._titleInputsOptions(e,t,i))}_titleInputsOptions(e,t,i){return{symbolsForDisplay:!0,skipHiddenInputs:!0,skipFakeInputs:!1,fakeInputsForDisplay:!0,asObject:!0,skippedGroups:[],skippedInputs:this._skippedTitleInputs(),noExchanges:t,noResolution:i,priceInputsForDisplay:!0,skipOptionalEmptySymbolInputs:ti,displayMask:e}}_postProcessGraphics(){this._graphicsPriceAxisViews=this._createGraphicsPriceAxisViews(),this._concatPriceAxisViews()}async _createGraphicsPaneViews(){return(0,B.createGraphicsPaneViews)(this,this.model())}_createGraphicsPriceAxisViews(){return(0,B.createGraphicsPriceAxisViews)(this)}_subscribeToSessionId(){!this._isSubscribedToSessionId&&this.hasSymbolInputs()&&(this.sessionIdChanged().subscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!0)}_recreateFormatter(e){this._recreatePlotsFormatters(e),this._formatter=this._tryCreateFormatter(e),this._defaultFormatter=this._tryCreateDefaultFormatter(e),this._formatterChanged.fire();const t=this.priceScale();null!==t&&t.updateFormatter(),this.getAllChildren().forEach((e=>{e.recreatePriceFormatter()})),this._model.fullUpdate()}_recreatePriceFormattingDependencies(e){this._recreateFormatter(e),this._recreatePriceStep()}_title(e,t,i,s,r,n){const o=this._titleInParts(e,t,i,s,r,n);return this._joinTitlesParts(o)}_postProcessPriceRange(e,t){if(e&&e.minValue()===e.maxValue()&&!this.metaInfo().is_price_study){const t=.005*e.minValue();e=new A.PriceRange(e.minValue()-t,e.maxValue()+t)}const i=t.targetPriceScale;return i&&i.isLog()&&e?new A.PriceRange(i.priceToLogical(e.minValue()),i.priceToLogical(e.maxValue())):e}_titleInParts(e,t,s,r,n,l){var c;const u=this.name(t);s=s||{};const h=[a.t(u,{context:"study"},i(168716))];let d=[];if(!r){const i=this._getMTFResolutionInputTitle();null!==i&&i.length>0&&h.push(i);const r=this.metaInfo(),a=this._titleInputs(e,n,!0),u=r.inputs.filter((e=>a.hasOwnProperty(e.id))).map((e=>({meta:e,value:a[e.id]})));if(u.length>0){const i={};if(this.isChildStudy())for(let s=0;s=0){const s=this.parentSourceForInput(h);if(s instanceof Ci){const r=s.metaInfo(),o=s.title(e,t,{},!0,n,l);if(1===r.plots.length)i[h]=o;else{const e=h.split("$")[1],t=null===(c=r.plots[parseInt(e)])||void 0===c?void 0:c.id,s=r.styles&&r.styles[t],n=s&&s.title||t;i[h]=o+": "+n}}}}d=u.map((({meta:e,value:t})=>{if("time"===e.type)return new Date(t).toISOString();let r=(0,j.isNumber)(t)?(0,Yt.getNumericFormatter)().format(t):i&&i[t.toString()]||t.toString();return s&&s[r.toString()]&&(r=s[r.toString()]),r}))}}return[h.join(" · "),d]}_seriesDataRangeToSave(e){return this._model.timeScale().visibleExtendedDataRange(e,0)}_getSymbolForResolve(e){return this.getSymbolString(this._getSymbolForApi(e))}_getSymbolForApi(e){return e}_getSymbolObject(e){const t={symbol:e},i=this.currency();return null!==this._currencySourceSymbolInputProperty&&null!==this._currencySourceSymbolInfo&&this._getSymbolForApi(this._currencySourceSymbolInputProperty.value())===e&&(t["currency-id"]=i),t.session=this.sessionId(),t}_onSymbolResolved(e,t,i){{const e=(0,o.ensureNotNull)(this._model.alertsWatcher());e.syncSourceAlertLabels(this);const t=this.getAllChildren();for(const i of t)e.syncSourceAlertLabels(i)}this._onCurrencyMayChange()}_onSymbolResolvingStart(e,t){}_onSymbolError(){}_setStatus(e,t){var i;const s=this.isFailed();this._status=e,e.type===Vt.StudyStatusType.Completed?this._wasCompletedBefore=!0:e.type!==Vt.StudyStatusType.Error&&e.type!==Vt.StudyStatusType.Undefined||(this._wasCompletedBefore=!1),t||(null===(i=this._statusView)||void 0===i||i.update(),this._model.updateSource(this),this._statusChanged.fire(this.status())),s!==this.isFailed()&&this._updateAlertCreationAvailable()}_onPropertiesChanged(){this._restarting||(this._inputs?this._tryChangeInputs():this._chartApi&&this._chartApi.isConnected().value()&&this.restart()),this._metaInfo.isTVScript&&this._metaInfo.TVScriptMetaInfoExprs&&(this._restarting?this._deferredPinePatchProps=!0:this._pinePatchProps()),this._recreatePaneViews(),(0,Ft.emit)("study_properties_changed",this._id)}_lastNonEmptyPlotRow(e){var t;if(!(0,j.isInteger)(e))return Qt.logDebug("_lastNonEmptyPlotRow: incorrect plotIndex"),null;let i=null!==(t=this._lastNonEmptyPlotRowCache[e])&&void 0!==t?t:null;if(null!==i)return i;return i=this.data().findLast(((t,i)=>void 0!==i[e]),1e3),null===i?null:(this._lastNonEmptyPlotRowCache[e]=i,i)}_onCurrencyChanged(){"alwaysOff"!==(0,Rt.currencyUnitVisibilityProperty)().value()&&this._model.fullUpdate(),this.isStarted()&&this._tryChangeInputs(),this._currencyChanged.fire()}_apiInputs(){return this.inputs({keepOptionalSymbolsEmpty:!0})}async _tryChangeInputs(){const e=this.isStarted()&&this._chartApi.isConnected().value(),t=this._allInputsAreValid(),i=(0,o.ensureDefined)((0,j.clone)(this._inputs)),s=this._apiInputs(),r=JSON.stringify(s),n=r!==JSON.stringify(this._inputs);if(e&&t)try{ if(await this._allSymbolsAreResolved(),r!==JSON.stringify(this._apiInputs()))return this._tryChangeInputs();if(this._isStopped())return void(n&&this.disablePriceRangeReady());n&&(await this._changeInputsImpl(s,(0,o.ensureDefined)((0,j.clone)(this._inputs))),(0,o.ensureNotNull)(this.model().alertsWatcher()).syncSourceAlertLabels(this))}catch(e){Qt.logError(`ERROR: ${this._debugId()} _tryChangeInputs: cannot modify study, ${e}`)}else if(e&&!t&&this.stop(!0),!e&&t&&this.start(!0),n){const e=this._calcSources(),t=gi(this._metaInfo,s,i);this._updateParentSources(e,t,!0),this._inputs=s}this._tagsChanged.fire()}_onCurrencyMayChange(){if(null!==this._currencySourceSymbolInputProperty){const e=this.currency();this._updateCurrencySourceSymbolInfo(),e!==this.currency()&&this._onCurrencyChanged()}}_fillPrecalculatedAutoscaleInfo(e,t,i){const s=this._metaInfo,r=this.properties().childs(),n=new Set,o=this._metaInfo.filledAreas||[];for(let e=0;e!(0,O.isPlotWithTechnicalValues)(e))).filter((e=>this._metaInfo.isPlotForceOverlay(e.id)?i.targetPriceScale===this._model.mainSeries().priceScale():i.targetPriceScale===this.priceScale()&&!i.forceOverlayOnly)).filter((e=>n.has(e.id)||this.isPlotVisibleAt(e.id,1))).reduce(((i,s)=>this._applyPlotToPrecalculatedAutoscaleInfo(e,t,i,s)),{fields:[],useMainSeriesRange:!1,baseValueMinMax:null})}_firstSourceOrSeries(){var e;return null!==(e=this._sources[0])&&void 0!==e?e:this._series}_skipHistogramBaseOnAutoScale(){return!1}_tryCreateFormatter(e){const t=void 0===e?this.symbolSource().symbolInfo():e;return bi(this._metaInfo.format,this._priceScaleByProperties(),t,this.properties().childs().precision.value())}_tryCreateDefaultFormatter(e){return this._tryCreateFormatter(e)}_mergeData(e){return this._invalidateLastNonEmptyPlotRowCache(),this.data().merge(e)}_skippedTitleInputs(){return this._hideMatches.filter((e=>e.plotIds.every((e=>0===this._getPlotDisplayValue(e))))).map((e=>e.id))}_getPlotDisplayValue(e){var t,i,s,r,n,o,l;return null===(l=null===(o=null===(n=null===(r=null===(s=null===(i=null===(t=this.properties())||void 0===t?void 0:t.childs())||void 0===i?void 0:i.styles)||void 0===s?void 0:s.childs())||void 0===r?void 0:r[e])||void 0===n?void 0:n.childs())||void 0===o?void 0:o.display)||void 0===l?void 0:l.value()}_onStudyError(e){this._handleStudyError(this._createStudyError(e)),this._enablePriceRangeReady()}_onStudyCompleted(e){var t;this._studyModified&&(this.clearData(),this._studyModified=!1),this._sendTelemetryCounter(this._getTelemetryObjectName()+"_loaded"),this._setStatus({type:Vt.StudyStatusType.Completed}),null===(t=this._statusView)||void 0===t||t.update();const i=this._model.paneForSource(this);this._model.recalculatePane(i,(0,Dt.sourceChangeEvent)(this.id())),this._updateSources();const s=At.InvalidationMask.full();null!==this._model.appliedTimeFrame().value()&&s.lockVisibleTimeRangeOnResize(),this._model.invalidate(s)} _incrementTurnaround(){this._turnaround="st"+ ++this._turnaroundCounter}_checkTurnaround(e){return e===this._turnaround||e===this._model.mainSeries().seriesSource().turnaround()||e===this.turnaround(!0)}_updateMaxOffsetValue(){let e=-1/0;for(const t of this._metaInfo.plots)e=Math.max(this.offset(t.id),e);this._maxOffset.setValue(e)}_rightOffsetToUnixTime(e){if(this._series.bars().size()>=e){const t=(0,o.ensureNotNull)(this._series.bars().lastIndex())-e;return(0,o.ensureNotNull)(this._series.bars().valueAt(t))[0]}return null}_concatPriceAxisViews(){this._priceAxisViews=[...this._priceAxisViewsBase,...this._graphicsPriceAxisViews]}_onStudyLoading(){var e;this._setStatus({type:Vt.StudyStatusType.Loading,startTime:Date.now()}),null===(e=this._statusView)||void 0===e||e.update(),this._model.updateSource(this)}_handleStudyError(e){var t,i,s;this.clearData(),this._setStatus(e);{const s=(0,Vt.convertStudyStatusToString)(e),r=this._getTelemetryAdditionalData(),n=s.indexOf("Command info");r.reason=n>=0?s.slice(0,n).trim():s;if(!/study in error state|the data vendor doesn\'t provide volume data for this symbol.|error in series|unsupported resolution/gi.test(null!==(i=null===(t=r.reason)||void 0===t?void 0:t.toLowerCase())&&void 0!==i?i:"")){const e=this._getTelemetryObjectName();this._sendTelemetryCounter(e+"_error",r)}}null===(s=this._statusView)||void 0===s||s.update(),this._model.updateSource(this)}_createStudyError(e){var t,i;let s;return s=(0,j.isString)(e)?{error:this._getStudyErrorText(e),title:e.includes("study_not_auth")?"Access error":"Runtime error"}:{...e,title:null!==(t=e.title)&&void 0!==t?t:"Runtime error"},yi(s,null===(i=this.symbolSource().symbolInfo())||void 0===i?void 0:i.exchange)}_updateSources(){this._model.updateSource(this),this.hasBarColorer()&&this._model.updateSource(this._model.mainSeries())}_unsubscribeToSessionId(){this._isSubscribedToSessionId&&(this.sessionIdChanged().unsubscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!1)}_onSessionIdChanged(){this.restart(!0)}_recreatePriceStep(){var e;let t=null;const i=null!==(e=this._priceScaleByProperties())&&void 0!==e?e:this._priceScaleByMetaInfo();null!==i&&(t=1/i),this._priceStep!==t&&(this._priceStep=t,this._priceStepChanged.fire())}_recreatePlotsFormatters(e){var t,i;this._plotFormatters.clear();const s=this._metaInfo.format,r=this._priceScaleByProperties(),n=void 0===e?this.symbolSource().symbolInfo():e;for(const[e,i]of Object.entries(null!==(t=this._metaInfo.ohlcPlots)&&void 0!==t?t:{}))if(null==i?void 0:i.format){const t=bi(Si({...s,...null==i?void 0:i.format}),r,n,this.properties().childs().precision.value());t&&this._plotFormatters.set(e,t)}for(const[e,t]of Object.entries(null!==(i=this._metaInfo.styles)&&void 0!==i?i:{}))if(null==t?void 0:t.format){const i=bi(Si({...s,...null==t?void 0:t.format}),r,n,this.properties().childs().precision.value());i&&this._plotFormatters.set(e,i)}for(const e of this._metaInfo.plots)if((0,O.isOhlcPlot)(e)){const t=this._plotFormatters.get(e.target);t&&this._plotFormatters.set(e.id,t)}} _joinTitlesParts(e){const t=e[1]?e[1].join(", "):"";return e[0]+(t.length>0?" ("+t+")":"")}_getMTFResolutionInputTitle(){const e=this.metaInfo();for(let t=0;ts),(()=>s)).then(this._onDataUnpacked.bind(this,e,t.indexes,i)),this._ongoingDataUpdate}_allSymbolsAreResolved(){const e=this._inputSymbols(),t=[];let i=!1;for(const s of e){const e=this._getSymbolForResolve(s);if(""!==e)if(this._resolvedSymbols[e])i=!0;else{const i=this._resolveSymbol(e,s);t.push(i)}}if(0===t.length){const e=Promise.resolve();return i?e.then((()=>this._symbolsResolved.fire())):e}return Promise.all(t).catch((e=>(this._inputSymbols().includes(e)&&this.stop(!0),this._setStatus({type:Vt.StudyStatusType.Error,errorDescription:{error:Xt}}),this._model.updateSource(this),Promise.reject("Invalid symbol, "+e)))).then((()=>{this._symbolsResolved.fire(),this._recheckLineToolsActuality()}))}_resolveSymbol(e,t){if(""===e)return Promise.resolve();let i=this._pendingResolveSymbols.get(e);return void 0!==i||(i=new Promise(((i,s)=>{this._onSymbolResolvingStart(e,t),this._chartApi.resolveSymbol((0,U.makeNextSymbolId)(),e,(r=>{switch(this._pendingResolveSymbols.delete(e),r.method){case"symbol_resolved":{this._setStatus({type:Vt.StudyStatusType.Undefined});const s=r.params[1];this._resolvedSymbols[e]=s,this._resolvedSymbolsByInput[t]=s,this._onSymbolResolved(e,t,s),this.invalidateTitleCache(!0),i();break}case"symbol_error":if(this._setStatus({type:Vt.StudyStatusType.Error,errorDescription:{error:r.params[1]}}),this._onSymbolError(),r.params[1]===K.permissionDenied&&r.params[2]){if(r.params[2]!==K.SymbolErrorPermissionDeniedReason.Symbol)return void this._resolveSymbol(r.params[2],t).then(i);if(r.params[3])return void this._resolveSymbol(r.params[3],t).then(i)}this._sendTelemetryCounter("symbol_error",Object.assign(this._getTelemetryAdditionalData(),{symbol:e,reason:r.params[1]})),s(t)}}))})),this._pendingResolveSymbols.set(e,i)),i}_recheckLineToolsActuality(){const e=this._model.paneForSource(this);null!==e&&e.sourcesByGroup().lineSourcesForAllSymbols().forEach((e=>{e.ownerSource()===this&&e.calcIsActualSymbol()}))}_sendTelemetryCounter(e,t){void 0===t&&(t=this._getTelemetryAdditionalData());const i={count:1,additional:t};ue.telemetry.sendChartReport(e,i)}_getTelemetryAdditionalData(){let e="";return this._metaInfo.pine&&this._metaInfo.pine.version&&this._metaInfo.shortId.indexOf("USER")>=0&&(e="_v"+this._metaInfo.pine.version),{symbol:this.series().actualSymbol(),resolution:this.series().interval(),study:this._metaInfo.shortId+e}}_onSourceFormatterChanged(){null===this._formatter&&(null!==this._priceScale&&this._priceScale.updateFormatter(),this._formatterChanged.fire())}_onSourcePriceStepChanged(){ null===this._priceStep&&this._priceStepChanged.fire()}_bandsFirstValue(e){const t=this._metaInfo;if(!t.bands)return null;for(let i=0;i=0?t:e}return e}if(this._metaInfo.isTVScript||this._metaInfo.pine){if("text"===o)return null!==(n=null===(r=this._metaInfo.defaults.inputs)||void 0===r?void 0:r.text)&&void 0!==n?n:"";if("pineId"===o)return this._metaInfo.scriptIdPart;if("pineVersion"===o)return this._metaInfo.pine?this._metaInfo.pine.version:"-1";if("color"===e.type&&this._metaInfo.isRGB){const e=l.inputs.childs()[o].value();return(0,T.colorToInteger)(e)}if("price"===e.type){const e=l.inputs.childs()[o].value();return t.priceInputsForDisplay?this.formatter().format(e):e}}return l.inputs.childs()[o].value()}_getAllOwnerSources(){return Pi(this).reverse().slice(1)}_getStudyIdWithLatestVersion(){return L.StudyMetaInfo.getStudyIdWithLatestVersion(this.metaInfo())}_debugId(){const e=[] ;return this._studyId&&e.push(this._studyId),e.push(this._metaInfo.fullId),e.push(this._metaInfo.description),JSON.stringify({study:e})}_hasAvailableAlertPlots(){if(null===this._alertMetaInfo())return!1;const e=this.stateForAlert(),t=d.alertBandFactory.create(e).getPlots();return null!=t&&t.length>0}_hasAlertConditions(){const e=this._alertMetaInfo();if(null===e)return!1;if(e.plots.some(O.isAlertConditionPlot))return!0;const t=this.stateForAlert();return Boolean(t.alerts&&t.alerts.conditions)}_hasAlertFunction(){const e=this._alertMetaInfo();return Boolean(null!==e&&e.hasAlertFunction)}async _updateParentSources(e,t,i){if(this._sources.forEach((e=>e.unsetChild(this))),i&&await Promise.all(e.map((e=>e.isStarted()?Promise.resolve():e.start(!1,!0)))),e.forEach((e=>e.setChild(this))),this._setSources(e),this._recreatePriceFormattingDependencies(),0!==t&&this._sources.length<=1){const e=this._firstSourceOrSeries(),t=this._priceScale,i=(0,o.ensureNotNull)(e.priceScale());if(t!==i){const t=this._model.paneForSource(this),s=(0,o.ensureNotNull)(this._model.paneForSource(e));t===s&&s.move(this,i,!0)}}}_calcSources(){const e=this._properties.childs().inputs.state();return L.StudyMetaInfo.getSourceIdsByInputs(this._metaInfo.inputs,e).map((e=>{if("high"===e||"open"===e||"low"===e||"close"===e||"hl2"===e||"ohl3"===e||"ohlc4"===e)return null;{const t=this._model.allStudies().find((t=>t.canHaveChildren()&&t.id()===e));return null!=t?t:null}})).filter(j.notNull)}_isStopped(){return!this.isStarted()}_onDataUnpacked(e,t,i,s){if(this._isDestroyed)return;"nochange"!==t&&this._processPlotOffsets(s),this._transformData(e);const r=this._mergeData(e);null!==s&&(s.indexes_replace?((0,o.assert)("nochange"!==t),this._graphics.replaceIndexesTo(t)):("nochange"!==t&&this._graphics.replaceIndexesTo(t),void 0!==s.graphicsCmds&&this._graphics.processCommands(s.graphicsCmds))),this._onDataUpdated(e,s,t,r&&r.index),this.priceRangeReady()||this._enablePriceRangeReady(),this._dataUpdated.fire(i,!1,r)}_processPlotOffsets(e){if(e&&e.indexes_replace)return;const t=this._plotOffsets;this._plotOffsets=e&&e.offsets||{},(0,s.default)(t,this._plotOffsets)||this.updateAllViews((0,Dt.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._updateMaxOffsetValue()}_applyPlotToPrecalculatedAutoscaleInfo(e,t,i,s){var r,n,l;const a=s.id,c=this._properties.childs().styles.childs()[a],u=(0,O.isShapesPlot)(s)||(0,O.isCharsPlot)(s);i.useMainSeriesRange=i.useMainSeriesRange||(0,O.isArrowsPlot)(s);let h=(0,O.isLinePlot)(s)||(0,O.isOhlcPlot)(s);if(u){const e=(0,o.ensureDefined)(c).childs().location.value(),t=[N.MarkLocation.Absolute,N.MarkLocation.Top,N.MarkLocation.Bottom].indexOf(e)<0;i.useMainSeriesRange=i.useMainSeriesRange||u&&t,h=h||e===N.MarkLocation.Absolute}if(!h)return i;const d={name:a,offset:this.offset(a)},p=c.childs().plottype.value();if(!this._skipHistogramBaseOnAutoScale()&&[O.LineStudyPlotStyle.Histogram,O.LineStudyPlotStyle.Columns,O.LineStudyPlotStyle.Area].indexOf(p)>=0){ const s=null===(l=null===(n=null!==(r=this._metaInfo.styles)&&void 0!==r?r:{})||void 0===n?void 0:n[a])||void 0===l?void 0:l.histogramBase;if(void 0===s)return i;const o=this.data().minMaxOnRangeCached(e,t,[d]);return(0,j.isNumber)(s)&&null!==o&&(i.baseValueMinMax=(0,D.mergeMinMax)(i.baseValueMinMax,{min:s,max:s}),i.baseValueMinMax=(0,D.mergeMinMax)(i.baseValueMinMax,o)),i}return i.fields.push(d),i}async _onSourceInputChanged(){if(!this.isStarted()){const e=this._calcSources();{const t=1===e.length&&e[0]!==this._sources[0]?1:0;this._updateParentSources(e,t,!1)}}}_buildInputs(e){(0,o.assert)(!!e,"options not set");let t={};try{t=this._prepareInputs(e)}catch(e){Qt.logWarn("Failed to prepare study inputs: "+e)}if(e.asObject){const e={};return Object.keys(t).forEach((i=>{null!=t[i]&&(e[i]=t[i])})),e}{const e=[];return Object.keys(t).forEach((i=>{null!=t[i]&&e.push(t[i])})),e}}_prepareInput(e,t){const i=this._prepareInputValue(e,t);return!e.isFake||t.fakeInputsForDisplay||t.onlyAtomValues?i:{v:i,f:!0,t:e.type}}_plotsForAlert(){return(0,P.plotsForAlert)(this.metaInfo(),this.offset.bind(this))}_calcIsActualInterval(){const e=this._isActualInterval;this._isActualInterval=(0,Mt.isActualInterval)(this._series.intervalObj(),this._properties.childs().intervalsVisibilities),e!==this._isActualInterval&&(this._onIsActualIntervalChange.fire(),this._visibleChanged(),this.processHibernate())}_visibleChanged(){this._series.invalidateBarColorerCache()}_getNonPriceParent(){const e=this._sources;for(const t of e)if(t instanceof Ci){const e=t.metaInfo();return e.is_price_study&&"Compare@tv-basicstudies"!==e.id?t._getNonPriceParent():t}return null}_updateInputValue(e,t){const i=this._properties.childs().inputs.childs();if(i[t.id])if("price"===t.type)i[t.id].setValue(e.price);else if("time"===t.type){const s=this._model.timeScale().indexToTimePoint(e.index);null!==s&&i[t.id].setValue(1e3*s)}}_initializeStudyInputsPaneViews(){const e=(0,f.editableStudyInputs)(this._metaInfo.inputs);if(0===e.length)return;const t={convertPriceToCoordinate:e=>{const t=this.priceScale();if(null!==t&&!t.isEmpty()){const i=this.firstValue();if(null!==i)return t.priceToCoordinate(e,i)}return null},formatPrice:e=>{const t=this.priceScale();if(null!==t&&!t.isEmpty()){const i=this.firstValue();if(null!==i)return t.formatPrice(e,i)}return""},getInputValue:e=>{var t,i;return null!==(i=null===(t=this._properties.childs().inputs.child(e))||void 0===t?void 0:t.value())&&void 0!==i?i:null},isSelected:()=>this._model.selection().isSelected(this),isHovered:()=>this===this._model.hoveredSource()};Promise.all([i.e(62183).then(i.bind(i,781929)),i.e(62183).then(i.bind(i,141361)),i.e(62183).then(i.bind(i,286125)),i.e(62183).then(i.bind(i,180861))]).then((i=>{const[s,r,n,o]=i;this._inputsAnchorsPaneView=new s.StudyInputsAnchorsPaneView(e,this._model,t);const l=e.filter((e=>!Array.isArray(e)));this._inputsLinesPaneView=new r.StudyInputsLinesPaneView(l,this._model,t);let a=!1;e.forEach((e=>{if(Array.isArray(e)){const i="time"===e[0].type?e[0]:e[1],s="price"===e[0].type?e[0]:e[1] ;this._inputsTimeAxisPaneViews.push(new n.StudyInputTimeAxisPaneView(i,this._model,t.getInputValue)),this._inputsPriceAxisPaneViews.push(new o.StudyInputPriceAxisPaneView(s,t)),a=!0}else"time"===e.type?this._inputsTimeAxisPaneViews.push(new n.StudyInputTimeAxisPaneView(e,this._model,t.getInputValue)):(this._inputsPriceAxisPaneViews.push(new o.StudyInputPriceAxisPaneView(e,t)),a=!0)})),a&&this.formatterChanged().subscribe(this,this.invalidateTitleCache)}))}_updateCurrencySourceSymbolInfo(){}_initializeCurrencySource(){var e,t;const i=this.metaInfo(),s="symbolInputSymbolSource"===(null===(e=i.symbolSource)||void 0===e?void 0:e.type)&&(null===(t=i.symbolSource)||void 0===t?void 0:t.inputId),r=i.inputs.find((e=>e.id===s)),n="symbol"===(null==r?void 0:r.type);if("string"==typeof s&&n&&i.is_price_study){const e=this._properties.childs().inputs.childs()[s];void 0!==e&&(e.subscribe(this,this._onCurrencyMayChange),this._currencySourceSymbolInputProperty=e)}}_recreatePaneViews(){this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this._createViews(),this.recalculate(),this.updateAllViews((0,Dt.sourceChangeEvent)(this.id()))}_pinePatchProps(){this._deferredPinePatchProps=!1;const e=this._prepareInputs(Jt);if(!this._areStudyInputsModified(e))return;this._oldStudyInputs=e;const t=(0,y.patchPropertiesAsync)(this._properties,this._metaInfo,e,this._previousPatchMap),i=this._allSymbolsAreResolved(),s=this._propertiesPatched=new Promise((e=>{const r=()=>{s===this._propertiesPatched?e():this._propertiesPatched.then(e)};Promise.all([t,i]).then((()=>{r(),this._isDestroyed||(this._createViews(),this.recalculate(),this.updateAllViews((0,Dt.sourceChangeEvent)(this.id())),this.invalidateTitleCache())})).catch((e=>{r(),Qt.logError(`ERROR: ${this._debugId()} pine inputs patching failed, reason: ${e}`)}))}))}_areStudyInputsModified(e){if(0===Object.keys(e).length)return!1;if(void 0===this._oldStudyInputs)return!0;const t=Object.keys(this._oldStudyInputs);(0,o.assert)(t.length===Object.keys(e).length,"keys quantity should be equal");for(const i of t)if((0,o.assert)(e.hasOwnProperty(i),`key '${i}' should exist in study inputs`),(0,o.ensureDefined)(this._oldStudyInputs)[i]!==e[i])return!0;return!1}_onVisibleTimeRangeInputsChanged(e){null!==e?this._updateVisibleTimeRangeInputs(e):this.isStarted()&&this._chartApi.isConnected().value()&&this.stop(!0)}_updateVisibleTimeRangeInputs(e,t=!0){const i={first_visible_bar_time:e.firstVisibleBarTime,last_visible_bar_time:e.lastVisibleBarTime,subscribeRealtime:e.subscribeRealtime},s=this.metaInfo().inputs,r=[];for(const e of s)i.hasOwnProperty(e.id)&&r.push(e.id);const n=this.properties().childs().inputs;for(const e of r)n.childs()[e].setValueSilently(i[e]);t&&r.length>0&&n.listeners().fire(n,"")}_getStudyErrorText(e){var t;switch(null===(t=e.match(/^study_not_auth:(.*)?@.*/))||void 0===t?void 0:t[1]){case"Script":case"StrategyScript":return"This script is invite-only. To request access, please contact its author.";case"VbPSessions":case"VbPPeriodic":case"VbPVisible": return"Volume Profile indicator available only on our upgraded plans."}return e.split(":",2)[0]}_priceScaleByProperties(){if("default"===this.properties().childs().precision.value())return null;const e=parseInt(this.properties().childs().precision.value());return isFinite(e)?Math.pow(10,e):null}_priceScaleByMetaInfo(){const e=this.metaInfo().format,t="inherit"!==e.type?e.precision:void 0,i=(0,j.isNumber)(t)?Math.pow(10,t):void 0;if("price"===e.type||"percent"===e.type)return i||100;if("volume"===e.type){if(void 0===e.precision){const e=this.series().symbolInfo();if(null!==e&&(0,j.isNumber)(e.volume_precision))return Math.pow(10,e.volume_precision)}return 1}return"inherit"===e.type||Qt.logWarn("Unsupported format type: "+e.type),null}_inputSymbols(){return this.metaInfo().inputs.filter((e=>"symbol"===e.type)).map((e=>(0,o.ensureDefined)(this._properties.childs().inputs.child(e.id)).value()))}_studySpec(e){return{id:this._metaInfo.id,child:null!=e?e:this.isChildStudy(),fundamental:(0,he.isFundamentalStudyMetaInfo)(this._metaInfo)}}_onFormatterPropsChanged(){this._recreatePriceFormattingDependencies()}_setSources(e){this.invalidateTitleCache(),this._sources=e,this._onParentSourcesChanges.fire()}}(0,u.addStudyInfoToMap)("Study",(0,u.createStudyInfo)(Ci))},466144:(e,t,i)=>{i.d(t,{plotShapesData:()=>r});var s=i(444372);const r={shape_arrow_down:{guiName:s.t(null,void 0,i(348732)),id:"shape_arrow_down",paneRendererClass:"PaneRendererArrowDown",pineName:"shape.arrowdown",icon:"arrow_down"},shape_arrow_up:{guiName:s.t(null,void 0,i(610650)),id:"shape_arrow_up",paneRendererClass:"PaneRendererArrowUp",pineName:"shape.arrowup",icon:"arrow_up"},shape_circle:{guiName:s.t(null,void 0,i(490068)),id:"shape_circle",paneRendererClass:"PaneRendererCircleShape",pineName:"shape.circle",icon:"circle"},shape_cross:{guiName:s.t(null,void 0,i(429908)),id:"shape_cross",paneRendererClass:"PaneRendererCrossShape",pineName:"shape.cross",icon:"cross"},shape_diamond:{guiName:s.t(null,void 0,i(773720)),id:"shape_diamond",paneRendererClass:"PaneRendererDiamond",pineName:"shape.diamond",icon:"diamond"},shape_flag:{guiName:s.t(null,void 0,i(121524)),id:"shape_flag",paneRendererClass:"PaneRendererFlagShape",pineName:"shape.flag",icon:"flag"},shape_label_down:{guiName:s.t(null,void 0,i(318528)),id:"shape_label_down",paneRendererClass:"PaneRendererLabelDown",pineName:"shape.labeldown",icon:"label_down"},shape_label_up:{guiName:s.t(null,void 0,i(513046)),id:"shape_label_up",paneRendererClass:"PaneRendererLabelUp",pineName:"shape.labelup",icon:"label_up"},shape_square:{guiName:s.t(null,void 0,i(944904)),id:"shape_square",paneRendererClass:"PaneRendererSquare",pineName:"shape.square",icon:"square"},shape_triangle_down:{guiName:s.t(null,void 0,i(483356)),id:"shape_triangle_down",paneRendererClass:"PaneRendererTriangleApexDown",pineName:"shape.triangledown",icon:"triangle_down"},shape_triangle_up:{guiName:s.t(null,void 0,i(928340)),id:"shape_triangle_up",paneRendererClass:"PaneRendererTriangleApexUp",pineName:"shape.triangleup",icon:"triangle_up"}, shape_xcross:{guiName:s.t(null,void 0,i(707050)),id:"shape_xcross",paneRendererClass:"PaneRendererXCross",pineName:"shape.xcross",icon:"x_cross"}}},502141:(e,t,i)=>{i.d(t,{areEqualSymbols:()=>n,compareSymbolParams:()=>c,symbolParams:()=>a,symbolSameAsCurrent:()=>l});i(244842);var s=i(444331),r=i(223699);function n(e,t){return void 0===e?void 0===t:void 0!==t&&e.toUpperCase()===t.toUpperCase()}function o(e,t){return e.some((e=>n(t,e)))}function l(e,t){if(null===t)return!1;if(t){if(n(t.full_name,e)||n(t.pro_name,e))return!0;if(n(t.ticker,e))return!0;if(t.aliases&&o(t.aliases,e))return!0;if(t.alternatives&&o(t.alternatives,e))return!0;if(0===e.indexOf("FRA:")&&n(t.pro_name,e.replace("FRA:","FWB:")))return!0}return!1}function a(e){return{symbol:e.symbol(),currency:e.currency(),unit:e.unit(),interval:e.interval(),style:e.style()}}function c(e,t,i){const{symbol:n,currency:o,unit:l,style:a,interval:c}=t,u=void 0!==n&&!e.symbolSameAsResolved(n);let h,d;const p=e.symbolInfo();null!==p?(h=void 0!==o&&!function(e,t){return null===e&&!(0,s.isConvertedToOtherCurrency)(t)||e===(0,s.symbolCurrency)(t)}(o,p),d=void 0!==l&&!function(e,t,i){return null===e&&!(0,s.isConvertedToOtherUnit)(t,i)||e===(0,s.symbolUnit)(t,i)}(l,p,i)):(h=void 0!==o&&o!==e.currency(),d=void 0!==l&&l!==e.unit());return{symbolChanged:u,intervalChanged:void 0!==c&&!r.Interval.isEqual(e.interval(),c),currencyChanged:h,unitChanged:d,styleChanged:void 0!==a&&a!==e.style(),styleChangeRequiresRestart:void 0!==a&&(0,s.styleChangeRequiresRestart)(a,e.style())}}},294162:(e,t,i)=>{function s(e){return{width:e.width,actualBoundingBoxAscent:e.actualBoundingBoxAscent,actualBoundingBoxDescent:e.actualBoundingBoxDescent,fontBoundingBoxAscent:e.fontBoundingBoxAscent,fontBoundingBoxDescent:e.fontBoundingBoxDescent}}i.d(t,{TextWidthCache:()=>r,getMinTextMetrics:()=>s});class r{constructor(e=150){this._actualSize=0,this._usageTick=1,this._oldestTick=1,this._tick2Labels=new Map,this._cache=new Map,this._fontStyle="",this._maxSize=e}reset(){this._actualSize=0,this._cache.clear(),this._usageTick=1,this._oldestTick=1,this._tick2Labels.clear()}measureText(e,t){return this.getMetrics(e,t).width}yMidCorrection(e,t){const i=this.getMetrics(e,t);return void 0!==i.actualBoundingBoxAscent&&void 0!==i.actualBoundingBoxDescent?(i.actualBoundingBoxAscent-i.actualBoundingBoxDescent)/2:0}getMetrics(e,t){e.font!==this._fontStyle&&(this.reset(),this._fontStyle=e.font);const i=this._cache.get(t);if(void 0!==i)return i.metrics;if(this._actualSize===this._maxSize){const e=this._tick2Labels.get(this._oldestTick);this._tick2Labels.delete(this._oldestTick),this._cache.delete(e),this._oldestTick++,this._actualSize--}const r=e.textBaseline;e.textBaseline="middle";const n=s(e.measureText(t));return e.textBaseline=r,0===n.width&&t.length||(this._cache.set(t,{metrics:n,tick:this._usageTick}),this._tick2Labels.set(this._usageTick,t),this._actualSize++,this._usageTick++),n}}},161164:(e,t,i)=>{i.d(t,{TimeAxisView:()=>o});var s=i(246733),r=i(199471);class n{constructor(){this._data=null}setData(e){this._data=e} draw(e,t,i){if(null===this._data||!this._data.visible||0===this._data.text.length)return;const s=this._data;e.font=i.font;const n=Math.round(i.widthCache.measureText(e,s.text));if(n<=0)return;e.save();const o=i.paddingHorizontal,l=n+2*o,a=l/2;let c=s.coordinate,u=Math.floor(c-a)+.5;if(s.alwaysInViewPort){const e=s.width;u<0?(c+=Math.abs(0-u),u=Math.floor(c-a)+.5):u+l>e&&(c-=Math.abs(e-(u+l)),u=Math.floor(c-a)+.5)}const h=u+l,d=Math.ceil(0+i.borderSize+i.offsetSize+i.paddingTop+i.fontSize+i.paddingBottom),{horizontalPixelRatio:p,verticalPixelRatio:_}=t;e.fillStyle=s.background;const f=Math.round(u*p),m=Math.round(0*_),v=Math.round(h*p),g=Math.round(d*_),P=Math.round(2*p);e.beginPath(),e.moveTo(f,m),e.lineTo(f,g-P),e.arcTo(f,g,f+P,g,P),e.lineTo(v-P,g),e.arcTo(v,g,v,g-P,P),e.lineTo(v,m),e.fill();const y=0+i.borderSize+i.offsetSize+i.paddingTop+i.fontSize/2;e.textAlign="left",e.textBaseline="middle",e.fillStyle=s.color;const S=i.widthCache.yMidCorrection(e,"Apr0");e.translate((u+o)*p,(y+S)*_),(0,r.drawScaled)(e,p,_,(()=>e.fillText(s.text,0,0))),e.restore()}}class o{constructor(e){this._renderer=new n,this._rendererData={background:"",color:"",coordinate:0,text:"",visible:!1,width:0,alwaysInViewPort:!0},this._invalidated=!0,this._model=e,this._renderer.setData(this._rendererData)}update(){this._invalidated=!0}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._renderer}coordinate(){return this._rendererData.coordinate}_getAlwaysInViewPort(){return!0}_getText(e){const t=this._model.timeScale().indexToUserTime(e);return null!==t?this._model.dateTimeFormatter().format(t):""}_updateImpl(){const e=this._rendererData;if(e.visible=!1,this._model.timeScale().isEmpty()||!this._isVisible())return;const t=this._getIndex();null!==t&&Number.isFinite(t)&&(e.visible=!0,e.width=this._model.timeScale().width(),e.background=this._getBgColor(),e.color=(0,s.colorFromBackground)(e.background),e.coordinate=this._model.timeScale().indexToCoordinate(t),e.alwaysInViewPort=this._getAlwaysInViewPort(),e.text=this._getText(t),this._invalidated=!1)}}},142257:(e,t,i)=>{i.d(t,{UndoCommand:()=>r});var s=i(809796);class r{constructor(e,t=!0,i=!0){this._text=e||new s.TranslatedString("",""),this._executeOnPush=t,this._affectsState=i}text(){return this._text}executeOnPush(){return this._executeOnPush}affectsState(){return this._affectsState}canMerge(e){return!1}merge(e){throw new Error("Should be re-implemented in child classes")}}},87053:(e,t,i)=>{i.d(t,{createVisibilityController:()=>c});var s=i(444372),r=i(778785),n=i(152633),o=i(62802);const l="visibleOnMouseOver";function a(e){return"alwaysOn"===e||"alwaysOff"===e?e:l}function c(e,t){let c,u;function h(){if(!c){c=(0,n.createPrimitiveProperty)();let i=o.getValue(e);void 0===i&&void 0!==t&&(i=o.getValue(t)),c.setValue(a(i)),c.subscribe(c,(t=>{o.setValue(e,a(t.value()))}))}return c}return{property:h,availableValues:function(){return[{id:"visibleOnMouseOver",value:"visibleOnMouseOver",title:s.t(null,void 0,i(689960))},{id:"alwaysOn",value:"alwaysOn", title:s.t(null,void 0,i(471997))},{id:"alwaysOff",value:"alwaysOff",title:s.t(null,void 0,i(109408))}]},actualBehavior:function(){if(!u){u=(0,n.createPrimitiveProperty)();const e=h(),t=()=>{let t=e.value();"alwaysOn"!==t&&"alwaysOff"!==t&&(t=r.mobiletouch?"alwaysOn":"visibleOnMouseOver"),u&&u.setValue(t)};e.subscribe(u,t),t()}return u},restoreDefaultValue:function(){h().setValue(l),o.remove(e)}}}},558793:(e,t,i)=>{i.d(t,{getChartAlertsFacade:()=>l,getChartAlertsFacadeIfCreatedBefore:()=>a});var s=i(922100),r=i(307500);let n,o;async function l(){return n||(n=async function(){const[e,{getAlertsCollection:t},n,o]=await Promise.all([Promise.all([i.e(61285),i.e(94949),i.e(28035),i.e(29589),i.e(36679)]).then(i.bind(i,31884)),Promise.all([i.e(68239),i.e(94949),i.e(28035),i.e(47149),i.e(14141)]).then(i.bind(i,228035)),(0,r.getChartSourceIdsGetter)(),(0,s.getAlertsFiresFocusHandler)()]);return new e.ChartAlertsFacade(t(),o,n)}()),o||(o=await n),o}function a(){return null!=o?o:null}},307500:(e,t,i)=>{i.d(t,{getChartSourceIdsGetter:()=>s});const s=(0,i(895171).default)((async()=>{const{ChartSourceIdsGetter:e}=await Promise.all([i.e(94949),i.e(28035),i.e(79979)]).then(i.bind(i,845483));return new e}))},623551:(e,t,i)=>{i.d(t,{AsyncResourceWrapper:()=>s});class s{constructor(e){this._destroyed=!1,this._callbacks=[],this._resource={pendingResource:e},e.then((e=>{for(const t of this._callbacks)t(e);this._resource.resource=e})).finally((()=>{this._callbacks=[]}))}destroy(){this._resource={pendingResource:Promise.reject("Resource is destroyed").catch((()=>{}))},this._callbacks=[],this._destroyed=!0}callFunction(e){this._destroyed||(this._resource.resource?e(this._resource.resource):this._callbacks.push(e))}get(){return this._destroyed||!this._resource.resource?null:this._resource.resource}promise(){return this._resource.pendingResource}}},511131:(e,t,i)=>{function s(e,t,i,s){return`${s?s+" ":""}${i?i+" ":""}${e}px ${t}`}i.d(t,{makeFont:()=>s,parseFont:()=>n});const r=/(bold )?(italic )?(\d+)(px|pt) (.*)$/;function n(e){const t=r.exec(e);return null===t?null:{family:t[5],size:parseInt(t[3])*("pt"===t[4]?.75:1),bold:Boolean(t[1]),italic:Boolean(t[2])}}},151149:(e,t,i)=>{i.d(t,{rgbaFromIntegerCached:()=>o});var s=i(448874),r=i(246733),n=i(407478);function o(e=1e3){const t=s.default.Cache;s.default.Cache=n.CircularCacheBuffer.bind(n.CircularCacheBuffer,e);const i=(0,s.default)(r.rgbaFromInteger);return s.default.Cache=t,i}},298113:(e,t,i)=>{function s(e,t){for(const i of t.keys())e.add(i)}i.d(t,{addToSet:()=>s})},847754:(e,t,i)=>{async function s(e){(await Promise.all([i.e(66681),i.e(6123),i.e(40246),i.e(32662),i.e(43387),i.e(14),i.e(36827),i.e(37657),i.e(34422),i.e(63244),i.e(95069),i.e(92469),i.e(36748),i.e(85317),i.e(49542),i.e(97485),i.e(10890),i.e(55980),i.e(18612),i.e(70490),i.e(90385),i.e(59255),i.e(84450),i.e(8658),i.e(8145),i.e(49515),i.e(37161),i.e(94913)]).then(i.bind(i,960345))).renderRunOrSigninWithFeatureDialog(e)}i.d(t,{createRunOrSigniWithFeatureDialog:()=>s})},735337:(e,t,i)=>{i.d(t,{showGoProAlertsOnSecondsDialog:()=>r });var s=i(960337);function r(){(0,s.createGoProDialog)({feature:"alertsOnSeconds"})}}}]);