(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[1297],{18092:e=>{e.exports={}},32517:e=>{e.exports={}},5992:e=>{e.exports={}},87457:e=>{e.exports={}},40987:e=>{e.exports={"tv-spinner__container-rotate":"tv-spinner__container-rotate-aLqboHuu"}},72877:e=>{e.exports={container:"container-B8mkOfAH",inner:"inner-B8mkOfAH","border-left":"border-left-B8mkOfAH","border-right":"border-right-B8mkOfAH","border-top":"border-top-B8mkOfAH","border-bottom":"border-bottom-B8mkOfAH","top-right-radius":"top-right-radius-B8mkOfAH","top-left-radius":"top-left-radius-B8mkOfAH","bottom-right-radius":"bottom-right-radius-B8mkOfAH","bottom-left-radius":"bottom-left-radius-B8mkOfAH"}},11044:e=>{e.exports={screen:"screen-otjoFNF2",fade:"fade-otjoFNF2",screenfade:"screenfade-otjoFNF2"}},76003:e=>{e.exports={}},93688:e=>{e.exports={css_value_currency_label_radius:"4",css_wrapper_margin:"4",css_row_left_right_padding:"3",css_fade_height:"10","price-axis-currency-label-wrapper":"price-axis-currency-label-wrapper-y5H41VPj",hidden:"hidden-y5H41VPj","price-axis-currency-label":"price-axis-currency-label-y5H41VPj",row:"row-y5H41VPj",expanded:"expanded-y5H41VPj","price-axis-currency-label-arrow-down":"price-axis-currency-label-arrow-down-y5H41VPj","price-axis-currency-label-text":"price-axis-currency-label-text-y5H41VPj"}},65810:e=>{e.exports={}},20715:e=>{e.exports={}},26352:e=>{e.exports={"css-value-chart-controls-bar-height-with-border":"39px","css-value-chart-controls-bar-border":"1px"}},3980:e=>{e.exports={}},34907:e=>{e.exports={}},59449:e=>{e.exports={}},46021:e=>{e.exports={"common-tooltip":"common-tooltip-EJBD96zX","common-tooltip--hidden":"common-tooltip--hidden-EJBD96zX","common-tooltip--horizontal":"common-tooltip--horizontal-EJBD96zX","common-tooltip--farther":"common-tooltip--farther-EJBD96zX","common-tooltip--vertical":"common-tooltip--vertical-EJBD96zX","common-tooltip-farther":"common-tooltip-farther-EJBD96zX","common-tooltip--direction_normal":"common-tooltip--direction_normal-EJBD96zX","common-tooltip__body":"common-tooltip__body-EJBD96zX","common-tooltip__button-container":"common-tooltip__button-container-EJBD96zX","common-tooltip__body--no-buttons":"common-tooltip__body--no-buttons-EJBD96zX","common-tooltip__button":"common-tooltip__button-EJBD96zX","common-tooltip--direction_reversed":"common-tooltip--direction_reversed-EJBD96zX","common-tooltip__ear-holder":"common-tooltip__ear-holder-EJBD96zX","common-tooltip__ear-holder--below":"common-tooltip__ear-holder--below-EJBD96zX","common-tooltip__ear-holder--above":"common-tooltip__ear-holder--above-EJBD96zX","common-tooltip__ear-holder--before":"common-tooltip__ear-holder--before-EJBD96zX","common-tooltip__ear-holder--after":"common-tooltip__ear-holder--after-EJBD96zX","common-tooltip__body--with-hotkey":"common-tooltip__body--with-hotkey-EJBD96zX","common-tooltip__body--width_wide":"common-tooltip__body--width_wide-EJBD96zX","common-tooltip__body--width_narrow":"common-tooltip__body--width_narrow-EJBD96zX",
"common-tooltip__body--no-padding":"common-tooltip__body--no-padding-EJBD96zX","common-tooltip__hotkey-block":"common-tooltip__hotkey-block-EJBD96zX","common-tooltip__hotkey-block--divider":"common-tooltip__hotkey-block--divider-EJBD96zX","common-tooltip__hotkey-text":"common-tooltip__hotkey-text-EJBD96zX","common-tooltip__hotkey-button":"common-tooltip__hotkey-button-EJBD96zX","common-tooltip__plus-sign":"common-tooltip__plus-sign-EJBD96zX"}},47312:(e,t,i)=>{"use strict";i.d(t,{BarBuilderBase:()=>a,SessionInfo:()=>r});var s=i(37236),o=i(51829),n=i(16329);class r{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,o){this.timezone=(0,s.get_timezone)(e),this.spec=new n.SessionsSpec(e,t,i,o)}state(){return this._state}static fromState(e){return new r(e.timezone,e.spec,e.holidays,e.corrections)}static wrap(e){const t=new r("Etc/UTC","24x7");return t.spec=e,t}static create(e,t,i,s){return new r(e,t,i,s)}}class a{alignTime(e){if(isNaN(e))return NaN;let t=this.indexOfBar(e);return t===o.SessionStage.POST_SESSION&&(this.moveTo(e),t=this.indexOfBar(e)),t<0?NaN:this.startOfBar(t)}}},51101:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SessionInfo:()=>r.SessionInfo,alignExchangeTimeToSessionStartAndReturnUTC:()=>E,alignPeriodsBackForDataRequest:()=>I,alignPeriodsBackForVisibleRange:()=>A,getPeriodsBetweenDates:()=>k,isTradingNow:()=>D,newBarBuilder:()=>M});var s=i(37236),o=i(10892),n=i(77914),r=i(47312),a=i(51829);class l extends r.BarBuilderBase{constructor(e,t){super(),this._sessionStartMs=-Number.MAX_VALUE,this._sessionEndMs=-Number.MAX_VALUE,this._periodSec=e,this._session=t}alignTimeIfPossible(e){const t=this.alignTime(e);return isNaN(t)?e:t}indexOfBar(e){return e<this._sessionStartMs?a.SessionStage.PRE_SESSION:e>=this._sessionEndMs?a.SessionStage.POST_SESSION:(0,n.toInt)((0,s.time_seconds_diff)(e,this._sessionStartMs)/this._periodSec)}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=(0,s.get_cal_from_unix_timestamp_ms)(this._session.timezone,this._sessionStartMs-1),t=this._session.spec.alignToNearestSessionEnd(e,-1);return(0,s.cal_to_utc)(this._session.timezone,t)}if(e===a.SessionStage.POST_SESSION)return this._sessionEndMs;if(e<0)throw new Error("Negative offset is not supported");return this._sessionStartMs+(0,s.time_seconds)(this._periodSec*e)}endOfBar(e){if(e<0)throw new Error("Index cannot be negative");const t=this.startOfBar(e)+1e3*this._periodSec;return t>this._sessionEndMs?this._sessionEndMs:t}isLastBar(e,t){return t>=this._sessionStartMs+(0,s.time_seconds)(this._periodSec*(e+1)-1)}moveTo(e){const t=this._session.timezone,i=(0,s.utc_to_cal)(t,e),o=this._session.spec.alignToSessionStart(i);this._sessionStartMs=(0,s.cal_to_utc)(t,i),(0,s.add_minutes)(i,o),this._sessionEndMs=(0,s.cal_to_utc)(t,i)}indexOfLastBarInSession(){return(0,n.toInt)((this._sessionEndMs-1-this._sessionStartMs)/1e3/this._periodSec)}moveNext(){this.moveTo(this._sessionEndMs)}static minutes(e,t){return new l(60*e,t)}static seconds(e,t){return new l(e,t)}}var c=i(50151),h=i(71149);const d=(0,
s.get_timezone)("Etc/UTC");function u(e,t,i){const o=(0,s.clone)(t),n=e.businessDaysToCalendarDays(o,1);n>1&&(0,s.add_date)(o,n-1);const r=e.leftBorderOfDailyBar(o);if(null===r)throw new Error("Cannot calculate left border of daily bar");return(0,s.cal_to_utc)(i,r,!0)}class _{constructor(e,t){this.from=e,this.to=t}toString(){return`${this.from.toString()} - ${this.to.toString()}`}}class p extends r.BarBuilderBase{constructor(e,t,i,s,o=!1){super(),this._periodStart=-Number.MAX_VALUE,this._periodEnd=-Number.MAX_VALUE,this._periodLastBarStart=-Number.MAX_VALUE,this._periodStartDay=new h.BusinessDay(0,0,0),this._periodEndDay=new h.BusinessDay(0,0,0),this._period=i,this._sessionTgt=e,this._builder=s,this._useBusinessDays=o,o?((0,c.assert)(null===t,"useBusinessDays and sessionSrc are mutually exclusive arguments"),this._sessionSrc=new r.SessionInfo("Etc/UTC","24x7")):this._sessionSrc=t||e}builder(){return this._builder}alignTimeIfPossible(e){return this.tradingDayToSessionStart(e)}tradingDayToSessionStart(e){return this.moveTo(e),this.startOfBar(0)}indexOfBar(e){if(this._useBusinessDays){const t=h.BusinessDay.fromCalendar((0,s.get_cal_from_unix_timestamp_ms)(this._sessionSrc.timezone,e));return t.before(this._periodStartDay)?a.SessionStage.PRE_SESSION:this._periodEndDay.before(t)?a.SessionStage.POST_SESSION:0}return e<this._periodStart?a.SessionStage.PRE_SESSION:e>=this._periodEnd?a.SessionStage.POST_SESSION:0}startOfBar(e){if(e===a.SessionStage.PRE_SESSION){const e=(0,s.get_cal_from_unix_timestamp_ms)(this._sessionTgt.timezone,this._periodStart-1),t=this._sessionTgt.spec.alignToNearestSessionEnd(e,-1);return(0,s.cal_to_utc)(this._sessionTgt.timezone,t)-1}return e===a.SessionStage.POST_SESSION||e>0?this._periodEnd:e===a.SessionStage.LASTBAR_SESSION?this._periodLastBarStart:this._periodStart}moveTo(e){let t=(0,s.get_cal_from_unix_timestamp_ms)(this._sessionSrc.timezone,e);t=this._sessionSrc.spec.correctTradingDay(t);const i=(0,s.get_year)(t),o=this._indexOfPeriodInYear(t),n=o+this._period,r=this._sessionTgt.spec,a=this._sessionTgt.timezone,l=this._builder.startOfPeriod(o,i);this._periodStart=u(r,l,a);const c=r.businessDaysToCalendarDays(l,1);c>1&&(0,s.add_date)(l,c-1),this._periodStartDay=h.BusinessDay.fromCalendar(l);let d=this._builder.startOfPeriod(n,i);this._periodEnd=u(r,d,a);const _=(0,s.clone)(d);for((0,s.add_date)(_,-1);r.isCalWeekEnd(_);)(0,s.add_date)(_,-1);this._periodEndDay=h.BusinessDay.fromCalendar(_),(0,s.add_date)(d,-1),d=function(e,t){const i=(0,s.clone)(t);for(;e.isCalWeekEnd(i);)(0,s.add_date)(i,-1);return i}(this._sessionTgt.spec,d),this._periodLastBarStart=u(r,d,a),(this._periodLastBarStart<this._periodStart||this._periodLastBarStart===this._periodEnd)&&(this._periodLastBarStart=this._periodStart)}endOfBar(e){return e===a.SessionStage.LAST_SESSION_END?this._getZonedDateTimeOfBorder(a.SessionStage.LAST_SESSION_END).getTime()+1e3:((0,c.assert)(0===e),this._periodEnd)}isLastBar(e,t){if(0!==e)throw new Error("index should be 0");return t>=this._periodLastBarStart}moveBarsForward(e,t){(0,c.assert)(t>0)
;const i=(0,s.get_cal_from_unix_timestamp_ms)(this._sessionTgt.timezone,e);let o=this._sessionTgt.spec.correctTradingDay(i);for(let e=0;e<t;e++){const e=this._period+this._builder.indexOfPeriod(o);o=this._builder.startOfPeriod(e,(0,s.get_year)(o)),o=this._sessionTgt.spec.correctTradingDay(o)}return this.moveTo((0,s.cal_to_utc)(this._sessionTgt.timezone,o)),this.startOfBar(0)}currentRange(){return new _(this._periodStartDay,this._periodEndDay)}indexOfBarInYear(e){const t=(0,s.get_cal_from_unix_timestamp_ms)(this._sessionSrc.timezone,e),i=(0,s.get_year)(t),o=this._builder.indexOfPeriod(t),r=this._sessionTgt.timezone;let a=this._builder.startOfPeriod(o,i),l=u(this._sessionTgt.spec,a,r);return a=(0,s.get_cal_from_unix_timestamp_ms)(d,l),i<(0,s.get_year)(a)?(a=this._builder.startOfPeriod(o-1,i),l=u(this._sessionTgt.spec,a,r),{index:(o-1)/this._period,time:l}):{index:(0,n.toInt)(o/this._period),time:l}}sessionSrc(){return this._sessionSrc}sessionTgt(){return this._sessionTgt}static days(e,t,i){return new p(t,i,e,new S(t),!1)}static weeks(e,t,i){return new p(t,i,e,new C(t),!1)}static months(e,t,i){return new p(t,i,e,new T(t),!1)}static daysFromBusinessDays(e,t){return new p(t,null,e,new S(t),!0)}static weeksFromBusinessDays(e,t){return new p(t,null,e,new C(t),!0)}static monthsFromBusinessDays(e,t){return new p(t,null,e,new T(t),!0)}_getZonedDateTimeOfBorder(e){(0,c.assert)(e===a.SessionStage.FIRST_SESSION_START||e===a.SessionStage.LAST_SESSION_END);const t=this._sessionTgt.spec.timezoneObj();if(e===a.SessionStage.FIRST_SESSION_START){const e=this.currentRange().from.toCalendar(t);return(0,c.ensureNotNull)(this._sessionTgt.spec.bordersOfDailyBar(e)).from}{const e=this.currentRange().to.toCalendar(t);return(0,c.ensureNotNull)(this._sessionTgt.spec.bordersOfDailyBar(e)).to}}_indexOfPeriodInYear(e){const t=this._builder.indexOfPeriod(e);let i=(0,n.toInt)(t/this._period)*this._period;return-1===t&&(i=-this._period),i}}function m(e,t){const i=e.getWeekIndex(t),o=(0,s.get_day_of_week)(t)-e.getEntriesForWeek(i).firstDayOfWeek();return o<0?o+7:o}function g(e,t){const i=(0,s.get_day_of_year)(t)-1;let o=m(e,t)-i%7;return 0===o?(0,n.toInt)(i/7):(o>=0&&(o-=7),(0,n.toInt)((o+i)/7))}class f{indexOfPeriod(e){return(0,s.get_day_of_year)(e)-1}startOfPeriod(e,t){const i=(0,s.days_per_year)(t);return(0,s.get_cal)(d,t,s.JANUARY,1+Math.min(e,i))}}class y extends f{constructor(e){super(),this._sessionsSpec=e}indexOfPeriod(e){return super.indexOfPeriod(e)-function(e,t){const i=g(e,t),o=(0,s.get_cal)(d,(0,s.get_year)(t),s.JANUARY,1);(0,s.add_date)(o,7*i);const n=i*e.weekEndsCountForSingleSession()+e.holidaysFromYearStart(o),r=(0,s.get_day_of_year)(t)-(0,s.get_day_of_year)(o);return n+r-e.calendarDaysToBusinessDays(o,r)}(this._sessionsSpec,e)}startOfPeriod(e,t){const i=7-this._sessionsSpec.weekEndsCountForSingleSession(),o=Math.max(0,Math.trunc(e/i)-1),n=(0,s.get_cal)(d,t,s.JANUARY,1),r=(0,s.days_per_year)(t);if((0,s.add_date)(n,7*o),(e-=i*o-this._sessionsSpec.holidaysFromYearStart(n))>0){const t=this._sessionsSpec.businessDaysToCalendarDays(n,e)
;(0,s.add_date)(n,t)}let a=(0,s.get_day_of_year)(n)-1;return t<(0,s.get_year)(n)&&(a+=r),super.startOfPeriod(a,t)}}class v extends f{constructor(e){super(),this._sessionsSpec=e}indexOfPeriod(e){return super.indexOfPeriod(e)-this._sessionsSpec.daysOffFromYearStart(e)}startOfPeriod(e,t){const i=(0,s.get_cal)(d,t,s.JANUARY,1);(0,s.add_date)(i,e);const o=this._sessionsSpec.daysOffFromYearStart(i);(0,s.add_date)(i,o);const n=this._sessionsSpec.daysOffFromYearStart(i)-o;if(n>0){const e=this._sessionsSpec.businessDaysToCalendarDays(i,n);(0,s.add_date)(i,e)}let r=(0,s.get_day_of_year)(i)-1;if(t<(0,s.get_year)(i)){r+=(0,s.days_per_year)(t)}return super.startOfPeriod(r,t)}}class S{constructor(e){this._builder=null,this._initialized=!1,this._session=e}indexOfPeriod(e){return this._getBuilder().indexOfPeriod(e)}startOfPeriod(e,t){return this._getBuilder().startOfPeriod(e,t)}_getBuilder(){return null!==this._builder&&this._initialized||(this._session.spec.hasWeekEnds()?this._builder=this._session.spec.hasHistoryCorrections()?new v(this._session.spec):new y(this._session.spec):this._builder=this._session.spec.hasHistoryCorrections()?new v(this._session.spec):new f,this._initialized=!0),this._builder}}class b{constructor(e){this._spec=e}indexOfPeriod(e){let t=g(this._spec,e);return 0===t&&e.getTime()<this.startOfPeriod(0,(0,s.get_year)(e)).getTime()&&(t=-1),t}startOfPeriod(e,t){if(e<0){t--;const i=(0,s.get_cal)(d,t,s.DECEMBER,31,23,59,59),o=this.indexOfPeriod(i),n=-1*e,r=Math.trunc(o/n)*n;return this.startOfPeriod(r,t)}const i=(0,s.get_cal)(d,t,s.JANUARY,1),o=m(this._spec,i),n=0===o?7*e:7*(e+1)-o;return n>(0,s.days_per_year)((0,s.get_year)(i))?this.startOfPeriod(0,t+1):((0,s.add_date)(i,n),i)}}class w{constructor(e){this._yearStartDataHash=new Map,this._spec=e}startOfPeriod(e,t){if(e<0){t--;const i=(0,s.get_cal)(d,t,s.DECEMBER,31,23,59,59),o=this.indexOfPeriod(i),n=-1*e,r=Math.trunc(o/n)*n;return this.startOfPeriod(r,t)}const i=this._spec.getWeekIndicesWithAdditionalWeekBars(t),o=this._getStartOfYearData(t,i),n=this._moveToWeekIndexAccountingAdditional(o.firstWeekIndex,i,e),r=7*(n-o.firstWeekIndex);let a=(0,s.clone)((0,c.ensureNotNull)(o.startOfFirstBarInYear));if((0,s.add_date)(a,r),(0,s.get_year)(a)>t){const e=t+1,i=this._spec.getWeekIndicesWithAdditionalWeekBars(e),s=this._getStartOfYearData(e,i);if(a.getTime()>=(0,c.ensureNotNull)(s.startOfFirstBarInYear).getTime())return this.startOfPeriod(0,e)}return a=this._calculateBarWeekStart(a,i,n,e),a}indexOfPeriod(e){const t=this._spec.getWeekIndex(e),i=this._spec.getWeekIndicesWithAdditionalWeekBars((0,s.get_year)(e)),o=this._getStartOfYearData((0,s.get_year)(e),i);if(e.getTime()<(0,c.ensureNotNull)(o.startOfFirstBarInYear).getTime())return-1;if(0===t&&w.isOnFirstCalendarWeekOfYear(e)||0!==t&&t===o.firstWeekIndex)return this._calculateLastWeek(e,t,i,o.firstWeekbarsCount)-1;let n=this._numberOfCalendarWeeks(e);return n+=o.firstWeekbarsCount-o.fullWeeksAdjustment,n+=this._calculateWeeksWithExtraBar(t,i,o.firstWeekIndex),
n+=this._calculateLastWeek(e,t,i,w.fullWeekOfAdditionalBarsCount)-1,n}static isOnFirstCalendarWeekOfYear(e){if((0,s.get_day_of_year)(e)>s.LAST_DAY_OF_WEEK)return!1;const t=(0,s.get_cal)(d,(0,s.get_year)(e),s.JANUARY,1,0,0),i=(0,s.clone)(t);return(0,s.add_date)(i,s.LAST_DAY_OF_WEEK-(0,s.get_day_of_week)(t)),e.getTime()<i.getTime()}_moveToWeekIndexAccountingAdditional(e,t,i){let s=e+i;for(const i of t)if(!(i.weekIndex<e)){if(i.weekIndex>=s)break;s--}return s}_calculateBarWeekStart(e,t,i,o){const n=this._getIndexOfWeekWithExtraBarIfExists(t,i);if(null===n){const t=this._spec.getEntriesForWeek(i).firstDayOfWeek()-(0,s.get_day_of_week)(e),o=(0,s.clone)(e);return(0,s.add_date)(o,t),o}const r=this._spec.getHistoryByIndex(n.entryIndex);if(this.indexOfPeriod((0,c.ensureNotNull)(r.getStartDay()))===o)return(0,s.clone)((0,c.ensureNotNull)(r.getStartDay()));const a=this._spec.getHistoryByIndex(n.entryIndex-1).getEntries().firstDayOfWeek()-(0,s.get_day_of_week)(e),l=(0,s.clone)(e);return(0,s.add_date)(l,a),l}_numberOfCalendarWeeks(e){const t=(0,s.get_day_of_year)(e),i=(0,s.get_day_of_week)(e);return Math.trunc((t-i)/7)}_getStartOfYearData(e,t){let i=this._yearStartDataHash.get(e);if(void 0!==i)return i;let o=(0,s.get_cal)(d,e,s.JANUARY,1,0,0),n=this._spec.getWeekIndex(o),r=0;for((0,s.get_day_of_week)(o)===s.FIRST_DAY_OF_WEEK&&(r=1),i=this._getYearStartDataFromWeek(t,n,o);null===i.startOfFirstBarInYear;)n++,r++,o=this._moveToNextCalendarWeekStart(o),i=this._getYearStartDataFromWeek(t,n,o);return i.fullWeeksAdjustment=r,this._yearStartDataHash.set(e,i),i}_moveToNextCalendarWeekStart(e){const t=(0,s.get_day_of_week)(e),i=(0,s.clone)(e);return(0,s.add_date)(i,s.LAST_DAY_OF_WEEK-t+1),i}_getYearStartDataFromWeek(e,t,i){const o=(0,s.get_day_of_week)(i);let n=null,r=0;const a=this._getIndexOfWeekWithExtraBarIfExists(e,t);if(null!==a){let e=this._spec.getHistoryByIndex(a.entryIndex-1).getEntries().firstDayOfWeek()-o;if(e>=0)n=(0,s.clone)(i),(0,s.add_date)(n,e),r=2;else{const t=this._spec.getHistoryByIndex(a.entryIndex);e=t.getEntries().firstDayOfWeek()-o,e>=0&&(n=t.getStartDay(),n&&(n=(0,s.clone)(n)),r=1)}}else{const e=this._spec.getEntriesForWeek(t),a=e.firstDayOfWeek()-o;a>=0&&(this._hasWorkingDays(e)||this._hasWorkingDaysNextWeek(t+1))&&(n=(0,s.clone)(i),(0,s.add_date)(n,a),r=1)}return{startOfFirstBarInYear:n,firstWeekIndex:t,firstWeekbarsCount:r,fullWeeksAdjustment:0}}_hasWorkingDays(e){if(0===e.entriesByDay().size)return!1;for(let t=e.firstDayOfWeek();t<=s.LAST_DAY_OF_WEEK;t++)if(void 0!==e.entriesByDay().get(t))return!0;return!1}_hasWorkingDaysNextWeek(e){const t=this._spec.getEntriesForWeek(e);for(let e=1;e<t.firstDayOfWeek();e++)if(void 0!==t.entriesByDay().get(e))return!0;return!1}_calculateWeeksWithExtraBar(e,t,i){let s=0;for(const o of t){if(o.weekIndex>=e)break;o.weekIndex>i&&s++}return s}_calculateLastWeek(e,t,i,o){const n=(0,s.get_day_of_week)(e),r=this._getIndexOfWeekWithExtraBarIfExists(i,t);if(null===r){return n-this._spec.getEntriesForWeek(t).firstDayOfWeek()>=0?1:0}const a=this._positionInsideWeekWithSeveralBars(r,n)
;return a===w.IsInNewSession?o:a===w.IsInMidSession?o-1:0}_getIndexOfWeekWithExtraBarIfExists(e,t){for(const i of e){if(i.weekIndex===t)return i;if(i.weekIndex>t)break}return null}_positionInsideWeekWithSeveralBars(e,t){let i=this._spec.getHistoryByIndex(e.entryIndex).getEntries().firstDayOfWeek()-t;if(i<=0)return w.IsInNewSession;return i=this._spec.getHistoryByIndex(e.entryIndex-1).getEntries().firstDayOfWeek()-t,i<=0?w.IsInMidSession:w.IsBeforeAnySession}}w.IsBeforeAnySession=-1,w.IsInMidSession=0,w.IsInNewSession=1,w.fullWeekOfAdditionalBarsCount=2;class C{constructor(e){this._builder=null,this._session=e}indexOfPeriod(e){return this._getBuilder().indexOfPeriod(e)}startOfPeriod(e,t){return this._getBuilder().startOfPeriod(e,t)}_getBuilder(){return null==this._builder&&(this._builder=this._session.spec.hasHistoryCorrections()?new w(this._session.spec):new b(this._session.spec)),this._builder}}class T{constructor(e){this._session=e}indexOfPeriod(e){return(0,s.get_month)(e)}startOfPeriod(e,t){if(e<0){const i=(0,n.toInt)((11-e)/12);t-=i,e+=12*i}else e>s.DECEMBER&&(t++,e=s.JANUARY);return(0,s.get_cal)(d,t,e,1)}}var P,x;function M(e,t,i,s=!1){const n=o.Interval.parse(e),r=n.multiplier();return n.isMinutes()?l.minutes(r,t):n.isSeconds()?l.seconds(r,t):n.isTicks()?new l(1,t):n.isRange()?new l(60*r,t):new p(t,i??null,r,function(e,t){switch(e){case o.ResolutionKind.Days:return new S(t);case o.ResolutionKind.Weeks:return new C(t);case o.ResolutionKind.Months:return new T(t)}throw new Error(`Unknown dwm resolution: ${e}`)}(n.kind(),t),s)}function I(e,t,i,s,o,n,r){return L(e,t,i,s,o,n,r,0)}function A(e,t,i,s,o,n,r){return L(e,t,i,s,o,n,r,1)}function L(e,t,i,n,a,l,c,h){const d=o.Interval.parse(a+n);if(d.isMonths()){const e=new Date(c);return 0===h&&e.setUTCDate(1),function(e,t){B(e,Math.floor(t/12));let i=e.getUTCMonth()-t%12;i<0&&(B(e,1),i+=12);e.setUTCMonth(i);for(;e.getUTCMonth()!==i;)V(e,1)}(e,l*d.multiplier()),e.getTime()}const u=new r.SessionInfo("Etc/UTC",e,t,i),_=d.inMilliseconds(),p=d.isDWM();let m;if(p)m=864e5;else{const e=u.spec.getWeekIndex((0,s.get_cal_from_unix_timestamp_ms)(u.timezone,c));m=60*u.spec.getEntriesForWeek(e).maxTradingDayLength()*1e3}let g=0;if(d.isWeeks())g=7;else{const e=u.spec.getWeekIndex((0,s.get_cal_from_unix_timestamp_ms)(u.timezone,c));g=7-u.spec.getEntriesForWeek(e).weekEndsCount()}const f=m/_,y=g*f;let v;if(l<y)v=l/f;else{v=7*(l/y)}return p&&(v=Math.floor(v)),c-864e5*v}function k(e,t,i,n,a,l,c){const h=o.Interval.parse(a+n);if(h.isMonths()){const e=new Date(l),t=new Date(c);let i=12*(t.getUTCFullYear()-e.getUTCFullYear());return i+=t.getUTCMonth()-e.getUTCMonth(),Math.ceil(i/h.multiplier())}const d=new r.SessionInfo("Etc/UTC",e,t,i),u=h.inMilliseconds();let _;if(h.isDWM())_=864e5;else{const e=d.spec.getWeekIndex((0,s.get_cal_from_unix_timestamp_ms)(d.timezone,c));_=60*d.spec.getEntriesForWeek(e).maxTradingDayLength()*1e3}let p=0;if(h.isWeeks())p=7;else{const e=d.spec.getWeekIndex((0,s.get_cal_from_unix_timestamp_ms)(d.timezone,c));p=7-d.spec.getEntriesForWeek(e).weekEndsCount()}
const m=c-l,g=_/u,f=p*g;let y=m/864e5*g;y>=f&&(y=m/6048e5*f);return y%1<=Number.EPSILON*Math.ceil(y)?Math.round(y):Math.ceil(y)}function E(e,t){const i=(0,s.clone)(t);return e.alignToSessionStart(i),(0,s.cal_to_utc)((0,s.get_timezone)(e.timezone()),i)}function D(e,t){const i=(0,s.utc_to_cal)(t.timezone,+e);let o=(0,s.get_day_of_week)(i),n=(0,s.get_minutes_from_midnight)(i);const r=t.spec.findSession(t.spec.getWeekIndex(i),o,n).getEntry();return r.isOvernight()&&n>r.startOffset()+r.length()&&o===r.dayOfWeek()-1&&(o++,n-=1440),o===r.dayOfWeek()&&n>=r.startOffset()&&n<r.startOffset()+r.length()}function B(e,t){const i=e.getUTCMonth();e.setUTCFullYear(e.getUTCFullYear()-t),e.getUTCMonth()!==i&&V(e,1)}function V(e,t){e.setTime(e.getTime()-864e5*t)}!function(e){e[e.AlignToFirstDay=0]="AlignToFirstDay",e[e.AlignToClosestDay=1]="AlignToClosestDay"}(P||(P={})),function(e){e[e.D=864e5]="D",e[e.W=6048e5]="W"}(x||(x={}))},71149:(e,t,i)=>{"use strict";i.d(t,{BusinessDay:()=>n});var s=i(37236),o=i(97725);class n{constructor(e,t,i){this.year=e,this.month=t,this.day=i}toString(){return`${(0,o.addLeadingZeros)(this.year,4)}-${(0,o.addLeadingZero)(this.month)}-${(0,o.addLeadingZero)(this.day)}`}toyyyymmdd(){return`${(0,o.addLeadingZeros)(this.year,4)}${(0,o.addLeadingZero)(this.month)}${(0,o.addLeadingZero)(this.day)}`}compareTo(e){return this.year>e.year||this.year===e.year&&this.month>e.month||this.year===e.year&&this.month===e.month&&this.day>e.day?1:this.year===e.year&&this.month===e.month&&this.day===e.day?0:-1}before(e){return-1===this.compareTo(e)}toCalendar(e){return(0,s.get_cal)(e??(0,s.get_timezone)("Etc/UTC"),this.year,this.month-1,this.day)}addDays(e){const t=this.toCalendar((0,s.get_timezone)("Etc/UTC"));return(0,s.add_date)(t,e),n.fromCalendar(t)}firstDayOfYear(){return new n(this.year,1,1)}getDayOfWeek(){const e=this.toCalendar();return(0,s.get_day_of_week)(e)}static fromCalendar(e){return new n((0,s.get_year)(e),(0,s.get_month)(e)+1,(0,s.get_day_of_month)(e))}}},51829:(e,t,i)=>{"use strict";var s;i.d(t,{SessionStage:()=>s}),function(e){e[e.PRE_SESSION=-1]="PRE_SESSION",e[e.POST_SESSION=-2]="POST_SESSION",e[e.LASTBAR_SESSION=-3]="LASTBAR_SESSION",e[e.LAST_SESSION_END=-4]="LAST_SESSION_END",e[e.FIRST_SESSION_START=-5]="FIRST_SESSION_START"}(s||(s={}))},99955:(e,t,i)=>{"use strict";i.d(t,{extrapolateBarsFrontByCount:()=>n,extrapolateBarsFrontToTime:()=>o});var s=i(51829);function o(e,t,i,s,n=!1){if(t>i){const r=o(e,i,t,s,n);return r.count=-r.count,r}return r(e,t,1,((e,t)=>t>i||0!==s&&e>s),n)}function n(e,t,i,s=!1){const o=i<0?-1:1;return r(e,t,o,((e,t)=>e>=i*o),s)}function r(e,t,i,o,n){let r=0,a=t;e.moveTo(a);let l=0,c=Number.MAX_VALUE,h=!1,d=t;const u=[];for(;!o(r,a);){if(l>15)throw new Error("Internal error 0x10 while extrapolating.");const o=e.indexOfBar(a);if(o===s.SessionStage.PRE_SESSION&&1===i)a=e.startOfBar(0),e.moveTo(a);else if(o===s.SessionStage.PRE_SESSION&&-1===i)a=e.startOfBar(s.SessionStage.PRE_SESSION),e.moveTo(a);else if(o===s.SessionStage.POST_SESSION&&1===i)a=e.startOfBar(s.SessionStage.POST_SESSION),
e.moveTo(a);else{if(o===s.SessionStage.POST_SESSION&&-1===i)throw new Error("Internal error 0x12 while extrapolating.");{const _=e.startOfBar(o);if(_>t&&i>0||t>_&&i<0){if(h&&c===_)throw new Error("Internal error 0x11 while extrapolating.");h=!0,c=_,l=0,r++,d=_,n&&u.push(d)}if(0===o&&-1===i)a=_-1;else{a=e.startOfBar(o+i);const t=e.startOfBar(s.SessionStage.POST_SESSION);a>t&&(e.moveTo(t),a=e.startOfBar(0))}}}l++}return{time:d,times:u,count:r}}},16329:(e,t,i)=>{"use strict";i.d(t,{SessionsSpec:()=>T});var s,o=i(50151),n=i(37236),r=i(16879),a=i(71149);function l(e,t){return e.compareTo(t)}!function(e){e[e.LeftFirst=-1]="LeftFirst",e[e.Unchanged=0]="Unchanged",e[e.RightFirst=1]="RightFirst"}(s||(s={}));class c{constructor(e,t,i){(0,o.assert)(Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(i),"Invalid arguments"),this._dayOfWeek=e,this._start=t,this._length=i}start(){return this._start+n.minutesPerDay*this.sessionStartDaysOffset()}startOffset(){return this._start}sessionStartDaysOffset(){return this._start>=0?0:this._start%n.minutesPerDay==0?-Math.ceil(this._start/n.minutesPerDay):-Math.floor(this._start/n.minutesPerDay)}isOvernight(){return this._start<0}dayOfWeek(){return this._dayOfWeek}sessionStartDayOfWeek(){let e=this._dayOfWeek-this.sessionStartDaysOffset();return e<n.SUNDAY&&(e+=7),e}length(){return this._length}compareTo(e){const t=this._weight(),i=t+this._length,s=e._weight(),o=s+e._length;return t<=s&&s<i||s<=t&&t<o?0:t>s?1:-1}contains(e){return this._contains((0,n.get_minutes_with_hours)(e),(0,n.get_day_of_week)(e))}_weight(){return this._dayOfWeek*n.minutesPerDay+this._start}_contains(e,t){let i=t-this._dayOfWeek;i>0&&(i-=7);const s=i*n.minutesPerDay+e;return s>=this._start&&s<this._start+this._length}}class h{constructor(e,t,i){this.weekIndex=e,this.entryIndex=t,this.entries=i}getEntry(){return this.entries[this.entryIndex]}}class d{constructor(e,t,i,s){this._maxTradingDayLength=null,this._list=e,this._entriesByDay=t,this._firstDayOfWeek=i,this._weekEndsCount=s}firstDayOfWeek(){return this._firstDayOfWeek}entriesByDay(){return this._entriesByDay}list(){return this._list}isWeekEnd(e){return!this._entriesByDay.has(e)}weekEndsCount(){return this._weekEndsCount}longestSessionLength(){return 0===this._list.length?0:Math.max(...this._list.map((e=>e.length())))}maxTradingDayLength(){if(null==this._maxTradingDayLength){const e=new Map;for(const t of this._list){const i=t.dayOfWeek();e.set(i,t.length()+(e.get(i)??0))}let t=0;e.forEach((e=>{t=Math.max(t,e)})),this._maxTradingDayLength=t}return this._maxTradingDayLength}}class u{constructor(e,t,i){this._startDay=e,this._entries=i,this._specEndDay=t}getEntries(){return this._entries}getStartDay(){return this._startDay}getSpecEndDay(){return this._specEndDay}isOpenEnded(){return null==this._specEndDay}}const _=[n.MONDAY,n.TUESDAY,n.WEDNESDAY,n.THURSDAY,n.FRIDAY],p=[n.SUNDAY,n.MONDAY,n.TUESDAY,n.WEDNESDAY,n.THURSDAY,n.FRIDAY,n.SATURDAY];function m(e){return e>=48&&e<=57}const g=[0,31,28,31,30,31,30,31,31,30,31,30,31];class f extends Map{constructor(){
super(...arguments),this._keyStringsToKey=new Map}get(e){const t=this._keyStringsToKey.get(e.toString());return t&&super.get(t)}set(e,t){const i=e.toString(),s=this._keyStringsToKey.get(i);return void 0!==s&&super.delete(s),this._keyStringsToKey.set(i,e),super.set(e,t)}has(e){return this._keyStringsToKey.has(e.toString())}}function y(e){return e.length>0}class v{constructor(){this.historyEntries=[],this.timezone="",this.adjustSessionsIndexes=null}parseSessions(e,t){this._parseHistoryEntries(e,t,!1)}parseSessionsAndValidateDateTime(e,t){this._parseHistoryEntries(e,t,!0)}static parseHolidaysAndCorrections(e,t,i,s){return this._parseHolidaysAndCorrectionsImpl(e,t,i,s)}static parseHolidaysAndCorrectionsAndValidateDateTime(e,t,i){return this._parseHolidaysAndCorrectionsImpl(e,t,i,!0)}_clearAll(){this.timezone="",this.historyEntries=[],this.adjustSessionsIndexes=[]}_parseHistoryEntries(e,t,i){this._clearAll();const s=t.split("/");let o=null,n=null;this.hasHistoryCorrections=s.length>1;for(let t=0;t<s.length;t++){const r=s[t].split("#");let a=null;if(t!==s.length-1){if(2!==r.length)throw new Error(`bad session history entry definition: ${s[t]}`);a=v._parseDay(r[1],"session history entry end",i).toCalendar()}else{if(1!==r.length)throw new Error(`bad session history entry definition: ${s[t]}`);a=null}if(null!==n&&null!==a&&a.getTime()<n.getTime())throw new Error(`history sessions are not listed in ascending order (${n} -> ${a}`);const l=this._parseSessionsImpl(e,r[0],i);o=this._adjustStartToPreviousSession(l.firstDayOfWeek());const c=new u(o,a,l);this.historyEntries.push(c),n=a}}_parseSessionsImpl(e,t,i){this.timezone=e,t=this._parseFirstDayOfWeek(t);const s=new Map,o=[];if("24x7"===t.toLowerCase())for(const e of p){const t=v._createSessionEntry(e,0,0,0,0);o.push(t);const i=[];i.push(t),s.set(e,i)}else{let e=!1;const n=new Map;for(const i of t.split("|")){const t=i.split(":").filter(y);if(1!==t.length&&2!==t.length)throw new Error(`bad session section: ${i}`);const s=1===t.length;if(s){if(e)throw new Error(`duplicated default section: ${i}`);e=!0}const o=s?_:v._parseWorkingDays(t[1]);for(const e of o)s&&n.has(e)||n.set(e,t[0])}for(const e of p){const t=n.get(e);if(void 0!==t)for(const n of t.split(",").filter(y)){const t=v._parseSessionEntry(e,n,i);let r=s.get(e);void 0===r&&(r=[]),r.push(t),o.push(t),s.set(e,r)}}}o.sort(l);const n=new Set;for(const e of o)n.add(e.dayOfWeek());const r=7-n.size;return new d(o,s,this._firstDayOfWeek,r)}_parseFirstDayOfWeek(e){const t=e.split(";");if(this._firstDayOfWeek=n.MONDAY,t.length>2)throw new Error(`bad sessions spec: ${e}`);if(1===t.length)return e;let i=1;let s=t[0].indexOf("-")>=0?NaN:parseInt(t[0]);if(isNaN(s)&&(i=0,s=parseInt(t[1])),s<n.SUNDAY||s>n.SATURDAY)throw new Error(`bad sessions spec: ${e}`);return this._firstDayOfWeek=s,t[i]}_adjustStartToPreviousSession(e){if(0===this.historyEntries.length)return null;const t=(0,o.ensureNotNull)(this.historyEntries[this.historyEntries.length-1].getSpecEndDay()),i=e-(0,n.get_day_of_week)(t);if(0===i)return t;const s=(0,n.clone)(t);return(0,
n.add_date)(s,i),t.getTime()<s.getTime()||(0,n.add_date)(s,7),s}static _parseSessionEntry(e,t,i){const s=t.split("-");if(2!==s.length)throw new Error(`bad session entry: ${t}`);let o=0,n=s[0];if(n.includes("F")){const e=n.split("F");n=e[0],o=""!==e[1]?parseInt(e[1]):1}let r=0,a=s[1];if(a.includes("F")){const e=a.split("F");a=e[0],r=""!==e[1]?parseInt(e[1]):1}const l=this._minutesFromHHMM(n,t,i),c=this._minutesFromHHMM(a,t,i);return this._createSessionEntry(e,l,c,o,r)}static _minutesFromHHMM(e,t,i){if(4===e.length&&m(e.charCodeAt(0))&&m(e.charCodeAt(1))&&m(e.charCodeAt(2))&&m(e.charCodeAt(3))){const t=parseInt(e),s=Math.trunc(t/100),o=t%100;if(!i||s<24&&o<60)return o+60*s}throw new Error(`incorrect entry syntax: ${t}`)}static _parseDay(e,t,i){if(8===e.length&&m(e.charCodeAt(0))&&m(e.charCodeAt(1))&&m(e.charCodeAt(2))&&m(e.charCodeAt(3))&&m(e.charCodeAt(4))&&m(e.charCodeAt(5))&&m(e.charCodeAt(6))&&m(e.charCodeAt(7))){const t=parseInt(e.substring(0,4)),s=parseInt(e.substring(4,6)),o=parseInt(e.substring(6,8));if(!i||this._isValidDayOfMonth(o,s,t))return new a.BusinessDay(t,s,o)}throw new Error(`bad ${t} date: ${e}`)}static _isValidDayOfMonth(e,t,i){return!(t<1||t>12)&&(!(e<1||e>g[t])||!(2!==t||29!==e||!(0,n.is_leap_year)(i)))}static _parseWorkingDays(e){const t=[];for(let i=0;i<e.length;i++){const s=e.charCodeAt(i)-48;if(s<1||s>7)throw new Error(`Invalid days specification: ${e}`);t.includes(s)||t.push(s)}return t}static _createSessionEntry(e,t,i,s,r){(0,o.assert)(s>=0&&s<7),(0,o.assert)(r>=0&&r<7),0===i&&(i=n.minutesPerDay),s===r&&i<=t&&(s+=1),(0,o.assert)(s>=r),s>0&&(t-=s*n.minutesPerDay),r>0&&(i-=r*n.minutesPerDay);const a=i-t;return(0,o.assert)(e>=n.SUNDAY&&e<=n.SATURDAY),(0,o.assert)(t<n.minutesPerDay),(0,o.assert)(a>0),new c(e,t,a)}static _parseHolidaysAndCorrectionsImpl(e,t,i,s){const o=new f;if(""!==t){const e=[];for(const i of t.split(",")){const t=this._parseDay(i,"holiday",s);o.set(t,e)}}if(""===i)return o;for(const e of i.split(";")){const t=e.split(":");if(2!==t.length)throw new Error(`bad correction section: ${e}`);const i=[];if("dayoff"!==t[0])for(const e of t[0].split(","))i.push(this._parseSessionEntry(1,e,s));for(const e of t[1].split(",")){const t=this._parseDay(e,"correction",s),r=(0,n.get_day_of_week)(t.toCalendar()),a=[];for(let e=0;e<i.length;e++){const t=i[e];a.push(new c(r,t.startOffset(),t.length()))}o.set(t,a)}}return o}}function S(e,t){return e.compareTo(t)<0}const b=(0,n.get_timezone)("Etc/UTC");var w;!function(e){e[e.Closest=0]="Closest",e[e.FirstInDay=-1]="FirstInDay",e[e.LastInDay=1]="LastInDay"}(w||(w={}));class C{constructor(e){this._value=e}get(){return this._value}set(e){this._value=e}}class T{constructor(e="Etc/UTC",t="0000-0000",i="",s="",o=!1){const r=new v;o?r.parseSessionsAndValidateDateTime(e,t):r.parseSessions(e,t),this._entries=r.historyEntries,this._hasHistoryCorrections=r.hasHistoryCorrections,this._presentHistoryEntry=r.historyEntries[r.historyEntries.length-1],this._timezone=r.timezone,this._timezoneObj=(0,n.get_timezone)(r.timezone),
this._holidayAndCorrectionMap=o?v.parseHolidaysAndCorrectionsAndValidateDateTime(e,i,s):v.parseHolidaysAndCorrections(e,i,s,o);const a=this._holidayAndCorrectionMap.keys();this._entriesHash=new Map;const l=this._prepareSessionsBorderParams();this._borderWeeksIndicesHash=l.borderWeeksIndicesHash,this._yearToWeeksIndicesHash=l.yearToWeeksIndicesHash,this._weekIndicesOfLastHistoryWeek=l.weekIndicesOfLastHistoryWeek,this._presentStartWeekIndex=l.startPresentSessionWeekIndex,this._yearToCalculatedAddedWeekIndicesHash=new Map,""===i&&""===s&&null===this._weekIndicesOfLastHistoryWeek?this._isThereCorrections=!1:this._isThereCorrections=!0;for(const e of a){const t=this.getWeekIndex(e.toCalendar());this._entriesHash.set(t,new C(null))}}hasHistoryCorrections(){return this._hasHistoryCorrections}firstDayOfWeek(){return this._presentHistoryEntry.getEntries().firstDayOfWeek()}includesDay(e){return this._getEntriesForDay(e).length>0}getEntriesForWeek(e){if(!this._isThereCorrections)return this._presentHistoryEntry.getEntries();(0,o.assert)(e>=0);const t=e,i=this._entriesHash.get(t);if(void 0===i){return this._getHistoryAndIndexForWeek(t).getEntries()}let s=i.get();if(null!==s)return s;let r=null;const c=this._borderWeeksIndicesHash.get(t);r=void 0===c?this._getHistoryAndIndexForWeek(t).getEntries():this._prepareBorderWeekHistory(c);const h=new Map(r.entriesByDay());let u=[...r.list()];const _=this._weekIndexToLocalDateTime(e),m=this._weekIndexToLocalDateTime(e+1),g=a.BusinessDay.fromCalendar(_),f=a.BusinessDay.fromCalendar(m);for(const[e,t]of this._selectHolidays(g,f)){const i=(0,n.get_day_of_week)(e.toCalendar());u=u.filter((e=>e.dayOfWeek()!==i)),u.push(...t),0===t.length?h.delete(i):h.set(i,t)}u.sort(l);const y=p.length-h.size;return s=new d(u,h,r.firstDayOfWeek(),y),i.set(s),s}getHistoryByIndex(e){return this._entries[e]}timezone(){return this._timezone}timezoneObj(){return this._timezoneObj}longestSessionLength(){let e=this._presentHistoryEntry.getEntries().longestSessionLength();for(let t=0;t<this._entries.length-1;t++){const i=this._entries[t].getEntries().longestSessionLength();e=Math.max(e,i)}let t=-1/0;for(const e of this._holidayAndCorrectionMap.values())t=Math.max(t,...e.map((e=>e.length())));return Math.max(t,e)}isWeekEnd(e){const t=this.getWeekIndex(e);let i;return i=void 0===this._borderWeeksIndicesHash.get(t)?this._getHistoryAndIndexForWeek(t).getEntries():this.getEntriesForWeek(t),i.isWeekEnd((0,n.get_day_of_week)(e))}isCalWeekEnd(e){const t=(0,n.get_day_of_week)(e);if(!this._isThereCorrections)return this._presentHistoryEntry.getEntries().isWeekEnd(t);const i=this.getWeekIndex(e),s=this.getEntriesForWeek(i),o=a.BusinessDay.fromCalendar(e),r=this._holidayAndCorrectionMap.get(o);return void 0===r?s.isWeekEnd(t):0===r.length}holidaysFromYearStart(e){const t=e instanceof a.BusinessDay?e:a.BusinessDay.fromCalendar(e);return this._holidaysFromYearStart(t)}daysOffFromYearStart(e){const t=(0,n.get_cal)(b,(0,n.get_year)(e),n.JANUARY,1),i=this.getWeekIndex(t),s=(0,n.get_day_of_week)(t),o=(0,n.get_day_of_week)(e)-1;if((0,
n.get_day_of_year)(e)+s<=n.LAST_DAY_OF_WEEK+n.FIRST_DAY_OF_WEEK)return this._getDaysOffForWeekInBorders(i,s,o);const r=this.getWeekIndex(e);let a=this._getDaysOffForWeekInBorders(i,s,n.LAST_DAY_OF_WEEK);for(let e=i+1;e<r;e++){a+=this.getEntriesForWeek(e).weekEndsCount()}return a+=this._getDaysOffForWeekInBorders(r,n.FIRST_DAY_OF_WEEK,o),a}weekEndsCountForSingleSession(){return(0,o.assert)(!this.hasHistoryCorrections()),this._presentHistoryEntry.getEntries().weekEndsCount()}intradayCanBeBuiltFrom24x7(e){for(const t of this._entries)if(!t.getEntries().list().every((t=>t.start()%e==0&&t.length()%e==0)))return!1;return!0}intradayCanBeBuiltFrom24x7Seconds(e){for(const t of this._entries)if(!t.getEntries().list().every((t=>60*t.start()%e==0&&60*t.length()%e==0)))return!1;return!0}indexOfSession(e,t,i){(0,o.assert)(t>=n.SUNDAY&&t<=n.SATURDAY),(0,o.assert)(i>=0&&i<n.minutesPerDay);const s=this.getEntriesForWeek(e),a=s.list();let l=(0,r.lowerbound)(a,new c(t,i,0),S);if(l<a.length)return new h(e,l,[...a]);let d=e+1,u=this.getEntriesForWeek(d);if(0!==u.list().length){const e=7-t+u.firstDayOfWeek()-1;if(i=-(n.minutesPerDay-i+e*n.minutesPerDay),l=(0,r.lowerbound)(u.list(),new c(u.firstDayOfWeek(),i,0),S),l<u.list().length)return new h(d,l,[...u.list()])}for(;;)if(d++,i-=n.minutesPerWeek,u=this.getEntriesForWeek(d),0!==u.list().length&&(l=(0,r.lowerbound)(u.list(),new c(s.firstDayOfWeek(),i,0),S),!(l>=u.list().length)))return new h(d,l,[...u.list()])}findSession(e,t,i,s=0){const o=this.indexOfSession(e,t,i),n=o.entries;let r=o.entryIndex;if(0!==s){const e=n[r].dayOfWeek(),t=s>0?1:-1;for(;;){const i=r+t;if(i<0||i>=n.length||n[i].dayOfWeek()!==e)break;r=i}}return new h(o.weekIndex,r,n)}getWeekIndex(e){return this._isThereCorrections?T._getWeekIndexImpl(e):0}correctTradingDay(e){const t=this._correctTradingDay(this.getWeekIndex(e),(0,n.get_day_of_week)(e),(0,n.get_minutes_with_hours)(e)),i=(0,n.clone)(e);return(0,n.add_date)(i,t),i}alignToSessionStart(e,t=0){const i=(0,n.get_day_of_week)(e),s=(0,n.get_minutes_from_midnight)(e),o=this.getWeekIndex(e),r=this.findSession(o,i,s,t),a=r.getEntry(),l=a.dayOfWeek()-i+7*Math.trunc(r.weekIndex-o);0!==l&&(0,n.add_date)(e,l);const c=a.startOffset();return(0,n.set_hms)(e,Math.trunc(c/60),c%60,0,0),a.length()}businessDaysToCalendarDays(e,t){return this._businessDaysToCalendarDays(this.getWeekIndex(e),(0,n.get_day_of_week)(e),t)}calendarDaysToBusinessDays(e,t){return this._calendarDaysToBusinessDays(this.getWeekIndex(e),(0,n.get_day_of_week)(e),t)}alignToNearestSessionStart(e,t){return this._alignToNearestSessionValue(e,t,this._entrySessionStart.bind(this))}alignToNearestSessionEnd(e,t){return this._alignToNearestSessionValue(e,t,this._entrySessionEnd.bind(this))}bordersOfDailyBar(e){const t=this._getEntriesForDay(e);if(0===t.length)return null;const i=t.slice();i.sort(l);const s=this._getLeftEntryBorder(e,i[0]),o=i[i.length-1],r=60*(o.startOffset()+o.length())-1,a=(0,n.clone)(e);return(0,n.set_seconds)(a,r),{from:s,to:a}}leftBorderOfDailyBar(e){const t=this._getEntriesForDay(e)
;if(0===t.length)return null;const i=t.slice();return i.sort(l),this._getLeftEntryBorder(e,i[0])}checkSession(){return this._checkEachHistorySession()&&this._checkSpecialEntries()&&this._checkTooManyCorrectionsOnWeek()}inSession(e){e=new Date(1e3*Math.floor(e.getTime()/1e3));const t=this.alignToNearestSessionStart(e,-1),i=this.alignToNearestSessionEnd(t,1);return!(e.getTime()>i.getTime())}hasWeekEnds(){for(const e of this._entries)if(0!==e.getEntries().weekEndsCount())return!0;return!1}getWeekIndicesWithAdditionalWeekBars(e){let t=this._yearToCalculatedAddedWeekIndicesHash.get(e);return void 0===t&&(t=this._calculateAddedIndices(e),this._yearToCalculatedAddedWeekIndicesHash.set(e,t)),t}_prepareSessionsBorderParams(){const e=new Map,t=new Map;let i=null;this._entries.length>1&&(i=Array.from({length:this._entries.length-1},(()=>0)));let s=0;for(let n=0;n<this._entries.length-1;n++){const r=this._entries[n+1],a=(0,o.ensureNotNull)(r.getStartDay());s=T._getWeekIndexImpl(a),e.set(s,n+1),this._addToYearHash(t,a,s),this._entriesHash.set(s,new C(null)),(0,o.ensureNotNull)(i)[n]=s}return{borderWeeksIndicesHash:e,yearToWeeksIndicesHash:t,startPresentSessionWeekIndex:s,weekIndicesOfLastHistoryWeek:i}}_addToYearHash(e,t,i){const s=(0,n.get_year)(t);let o=e.get(s);void 0===o&&(o=[],e.set(s,o)),o.push(i)}_getHistoryAndIndexForWeek(e){if(this._presentStartWeekIndex<=e)return this._presentHistoryEntry;const t=this._getIndexOfHistoryEntry(e);return this._entries[t]}_getIndexOfHistoryEntry(e){let t=0,i=this._entries.length-1,s=Math.floor((t+i)/2);for((0,o.assert)(null!==this._weekIndicesOfLastHistoryWeek);;){if(this._weekIndicesOfLastHistoryWeek[s]>=e){if(i=s-1,i<t)return s}else if(t=s+1,i<t)return s+1;s=Math.floor((t+i)/2)}}_selectHolidays(e,t){const i=new Set;for(const[s,o]of this._holidayAndCorrectionMap)s.compareTo(e)>=0&&s.compareTo(t)<0&&i.add([s,o]);return i}_prepareBorderWeekHistory(e){const t=this._entries[e-1],i=this._entries[e],s=new Map,r=[],a=(0,n.get_day_of_week)((0,o.ensureNotNull)(i.getStartDay()));for(let e=0;e<p.length;e++){const o=p[e];if(o<a){const e=t.getEntries().entriesByDay().get(o);void 0!==e&&(r.push(...e),s.set(o,e))}else{const e=i.getEntries().entriesByDay().get(o);void 0!==e&&(r.push(...e),s.set(o,e))}}return new d(r,s,i.getEntries().firstDayOfWeek(),0)}_holidaysFromYearStart(e){if(!this._isThereCorrections)return 0;(0,o.assert)(!this.hasHistoryCorrections());const t=e.firstDayOfYear();let i=0;for(const[s,o]of this._selectHolidays(t,e)){const e=s.getDayOfWeek(),t=0===o.length;this._presentHistoryEntry.getEntries().isWeekEnd(e)?i+=t?0:-1:i+=t?1:0}return i}_getDaysOffForWeekInBorders(e,t,i){let s=0;const o=this.getEntriesForWeek(e);for(let e=t;e<=i;e++)o.entriesByDay().has(e)||s++;return s}_weekIndexToLocalDateTime(e){const t=Math.floor(86400*e*7+86400-62167219200),i=(0,n.get_cal_from_unix_timestamp_ms)(b,1e3*t);return(0,n.set_hms)(i,0,0,0,0),i}_correctTradingDay(e,t,i){const s=this.findSession(e,t,i,0);return s.getEntry().dayOfWeek()-t+7*Math.trunc(s.weekIndex-e)}_entrySessionValue(e,t,i,s){t=(0,n.clone)(t)
;let o=(0,n.get_day_of_week)(t);const r=e.getEntry();let a=r.dayOfWeek()-r.sessionStartDaysOffset();const l=this.getWeekIndex(t);let c=Math.trunc(e.weekIndex-l),h=!1;if(a<n.SUNDAY&&(c<=0?h=!0:c--,a+=7),(c>0&&i>=0||c<0&&i<0)&&(0,n.add_date)(t,7*c),!r.contains(t)){let e=a-o;h&&i<0&&(e=-(7-a+o)),(0,n.add_date)(t,e),o=(0,n.get_day_of_week)(t)}if(r.isOvernight()){const e=r.sessionStartDaysOffset(),i=(o-(r.dayOfWeek()-e)+7)%7;0!==i&&(0,n.add_date)(t,-i)}const d=s(r);return(0,n.set_seconds)(t,d),t}_businessDaysToCalendarDays(e,t,i){let s=0,o=0;for(;o<i;){const r=this.getEntriesForWeek(e);for(let e=t;e<=n.SATURDAY;e++)if(s++,void 0!==r.entriesByDay().get(e)&&o++,o>=i)return s;e++,t=n.SUNDAY}return s}_calendarDaysToBusinessDays(e,t,i){let s=0,o=0;for(;s<i;){const r=this.getEntriesForWeek(e);for(let e=t;e<=n.SATURDAY;e++)if(s++,void 0!==r.entriesByDay().get(e)&&o++,s>=i)return o;e++,t=n.SUNDAY}return o}_entrySessionStart(e,t,i){return this._entrySessionValue(e,t,i,(e=>60*e.start()))}_entrySessionEnd(e,t,i){return this._entrySessionValue(e,t,i,(e=>60*(e.start()+e.length())-1))}_alignToNearestSessionValue(e,t,i){const s=(0,n.get_day_of_week)(e),o=(0,n.get_minutes_with_hours)(e),r=this.getWeekIndex(e);let a=this.findSession(r,s,o);if(1===t)return i(a,e,t);const l=a.getEntry(),c=l.contains(e),d=r===a.weekIndex,u=l.sessionStartDaysOffset()-l.dayOfWeek()>=0;if(c&&(d||u))return i(a,e,t);let _=a.entryIndex-1;if(_<0){let e=a.weekIndex,t=a.entries;if(0===e)e--,_+=t.length;else for(;_<0;)e--,t=this.getEntriesForWeek(e).list(),_+=t.length;a=new h(e,_,t)}else a=new h(a.weekIndex,_,a.entries);return i(a,e,t)}_getEntriesForDay(e){const t=(0,n.get_day_of_week)(e),i=this.getEntriesForWeek(this.getWeekIndex(e)).entriesByDay().get(t);return void 0!==i?i:[]}_getLeftEntryBorder(e,t){let i=t.startOffset();const s=-Math.trunc((i-1439)/1440);i+=1440*s;const o=(0,n.get_cal)(b,(0,n.get_year)(e),(0,n.get_month)(e),(0,n.get_day_of_month)(e),Math.trunc(i/60),i%60,0);return(0,n.add_date)(o,-s),o}_checkEachHistorySession(){for(const e of this._entries){const t=e.getEntries().list();if(!this._checkEntriesForIntersections(t,t,t))return!1}return!0}_checkEntriesForIntersections(e,t,i){const s=this._buildTestEntries(e,t,i);for(let e=0;e<s.length-1;e++)for(let t=e+1;t<s.length;t++)if(0===s[e].compareTo(s[t]))return!1;return!0}_buildTestEntries(e,t,i){const s=[];for(let t=0;t<e.length;t++){const i=e[t],o=new c(i.dayOfWeek(),i.startOffset(),i.length());s.push(o)}for(let e=0;e<t.length;e++){const i=t[e],o=new c(i.dayOfWeek()+7,i.startOffset(),i.length());s.push(o)}for(let e=0;e<i.length;e++){const t=i[e],o=new c(t.dayOfWeek()+14,t.startOffset(),t.length());s.push(o)}return s}_checkSpecialEntries(){for(const[e]of this._entriesHash){const t=this.getEntriesForWeek(e).list(),i=this.getEntriesForWeek(e-1).list(),s=this.getEntriesForWeek(e+1).list();if(!this._checkEntriesForIntersections(i,t,s))return!1}return!0}_checkTooManyCorrectionsOnWeek(){if(this._entries.length<2)return!0;for(let e=0;e<this._entries.length-2;e++){const t=this._entries[e],i=this._entries[e+1]
;if(this.getWeekIndex((0,o.ensureNotNull)(t.getSpecEndDay()))===this.getWeekIndex((0,o.ensureNotNull)(i.getSpecEndDay())))return!1}return!0}_calculateAddedIndices(e){const t=[],i=this._yearToWeeksIndicesHash.get(e);if(void 0===i)return t;for(const e of i){const i=(0,o.ensureDefined)(this._borderWeeksIndicesHash.get(e)),s=this._entries[i],r=this._entries[i-1];let a=s.getEntries().firstDayOfWeek()-r.getEntries().firstDayOfWeek();for(;a>0;){const r=(0,n.clone)((0,o.ensureNotNull)(s.getStartDay()));if((0,n.add_date)(r,-a),!this.isCalWeekEnd(r)){const s={entryIndex:i,weekIndex:e};t.push(s);break}a--}}return t}static _getWeekIndexImpl(e){const t=(0,n.get_cal_utc)((0,n.get_year)(e),(0,n.get_month)(e),1);(0,n.add_date)(t,(0,n.get_day_of_month)(e)-(0,n.get_day_of_week)(e));const i=t.getTime()/1e3;return(0,o.assert)((i+62167219200)%86400==0),Math.trunc((i+62167219200)/86400/7)}}},37236:(e,t,i)=>{"use strict";i.d(t,{DAY_OF_MONTH:()=>P,DAY_OF_WEEK:()=>M,DECEMBER:()=>b,FIRST_DAY_OF_WEEK:()=>_,FRIDAY:()=>d,HOUR_OF_DAY:()=>I,JANUARY:()=>m,JULY:()=>y,LAST_DAY_OF_WEEK:()=>p,MARCH:()=>g,MAY:()=>f,MINUTE:()=>A,MONDAY:()=>a,MONTH:()=>C,NOVEMBER:()=>S,SATURDAY:()=>u,SECOND:()=>L,SEPTEMBER:()=>v,SUNDAY:()=>r,THURSDAY:()=>h,TUESDAY:()=>l,WEDNESDAY:()=>c,WEEK_OF_YEAR:()=>T,YEAR:()=>w,add_date:()=>q,add_days_considering_dst:()=>j,add_minutes:()=>$,add_years_considering_dst:()=>G,cal_to_utc:()=>ae,clone:()=>Y,days_per_year:()=>X,get_cal:()=>oe,get_cal_from_unix_timestamp_ms:()=>ne,get_cal_utc:()=>re,get_day_of_month:()=>O,get_day_of_week:()=>F,get_day_of_year:()=>W,get_hours:()=>R,get_minutes:()=>N,get_minutes_from_midnight:()=>H,get_minutes_with_hours:()=>z,get_month:()=>V,get_part:()=>Q,get_timezone:()=>le,get_year:()=>B,is_leap_year:()=>J,minutesPerDay:()=>k,minutesPerWeek:()=>E,setCustomTimezones:()=>he,set_hms:()=>U,set_seconds:()=>K,time_seconds:()=>ee,time_seconds_diff:()=>te,utc_to_cal:()=>ie,utc_to_cal_ts:()=>se});var s=i(87453);const o={0:0,1:31,2:59,3:90,4:120,5:151,6:181,7:212,8:243,9:273,10:304,11:334};class n{constructor(e){this._invalid=!1,this._name=e;let t=s.tzData[e];!t&&ce&&(t=ce.instance().getTimezoneData(e)),t||(t={time:[],offset:[]},this._invalid=!0),t.time.length!==t.offset.length&&(t={time:[],offset:[]},this._invalid=!0);const i=t;if(!i.time_utc){const e=t.time,s=t.offset,o=e.length,n=new Array(o);for(let t=0;t<o;t++)e[t]*=1e3,s[t]*=1e3,n[t]=e[t]-s[t];i.time_utc=n}this.tz=i}offset_utc(e){return n.offset(this.tz.time_utc,this.tz.offset,e)}offset_loc(e){return n.offset(this.tz.time,this.tz.offset,e)}name(){return this._name}is_valid(){return!this._invalid}correction_loc(e){const t=this.tz.time,i=this.tz.offset,s=de(t,e);if(s<1)return 0;const o=i[s]-i[s-1];if(o>0){if(e-t[s-1]<=o)return o}return 0}static offset(e,t,i){const s=de(e,i);return-1===s?0:t[s]}}const r=1,a=2,l=3,c=4,h=5,d=6,u=7,_=r,p=u,m=0,g=2,f=4,y=6,v=8,S=10,b=11,w=1,C=2,T=3,P=5,x=6,M=7,I=11,A=12,L=13,k=1440,E=10080,D=864e5;function B(e){return e.getUTCFullYear()}function V(e){return e.getUTCMonth()}function R(e){return e.getUTCHours()}function N(e){
return e.getUTCMinutes()}function O(e){return e.getUTCDate()}function F(e){return e.getUTCDay()+1}function W(e){const t=e.getUTCMonth();let i=o[t];return t>m+1&&J(e.getUTCFullYear())&&(i+=1),i+e.getUTCDate()}function H(e){return 60*R(e)+N(e)}function z(e){return H(e)}function U(e,t,i,s,o,n){e.setUTCHours(t),e.setUTCMinutes(i),e.setUTCSeconds(s),e.setUTCMilliseconds(o),void 0!==n&&function(e,t){const i=e.getTime(),s=t.correction_loc(i);e.setTime(i+s)}(e,n)}function j(e,t,i){const s=e.offset_utc(t.getTime()),o=Y(t);q(o,i);const n=e.offset_utc(o.getTime());return o.setTime(o.getTime()+s-n),o}function G(e,t,i){let s=t;for(let t=Math.abs(i);t>0;t--)s=j(e,s,Z(s)*Math.sign(i));return s}function q(e,t){e.setTime(e.getTime()+t*D)}function $(e,t){e.setTime(e.getTime()+60*t*1e3)}function K(e,t){const i=86400,s=t%i<0?-1:0,o=Math.trunc(t/i)+s,n=t-o*i,r=Math.trunc(n/3600),a=Math.trunc(n%3600/60);U(e,r,a,n-3600*r-60*a,0),q(e,o)}function Y(e){return new Date(e.getTime())}function Z(e){return X(e.getUTCFullYear())}function X(e){return J(e)?366:365}function J(e){return e%4==0&&(e%100!=0||e%400==0)}function Q(e,t){switch(t){case w:return B(e);case C:return V(e);case P:return O(e);case T:return function(e){const t=new Date(Date.UTC(e.getUTCFullYear(),0,1)).getUTCDay(),i=0===t?1:8-t,s=W(e)-i;return Math.ceil(s/7)+1}(e);case M:return F(e);case I:return R(e);case A:return N(e);case x:return W(e);case L:return function(e){return e.getUTCSeconds()}(e);default:return e.getTime()}}function ee(e){return 1e3*e}function te(e,t){return _e(e)-_e(t)}function ie(e,t){return new Date(se(e,t))}function se(e,t){return t+e.offset_utc(t)}function oe(e,t,i,s,o,n,r){const a=new Date(Date.UTC(t,i,s,o||0,n||0,r||0)),l=e.offset_utc(+a);return new Date(a.valueOf()-l)}function ne(e,t){return new Date(t+e.offset_utc(t))}function re(e,t,i,s=0,o=0,n=0){return new Date(Date.UTC(e,t,i,s,o,n))}function ae(e,t,i){let s=t.getTime();i&&(s+=e.correction_loc(s));return s-e.offset_loc(s)}function le(e){return new n(e)}let ce;function he(e){ce=e}function de(e,t){const i=e.length;if(0===i)return-1;if(isNaN(t))throw Error("Key is NaN");let s=0,o=i-1,n=ue((s+o)/2);for(;;){if(e[n]>t){if(o=n-1,o<s)return n}else if(s=n+1,o<s)return n<i-1?n+1:-1;n=ue((s+o)/2)}}function ue(e){return Math.trunc(e)}function _e(e){return e<0?ue(e/1e3)-(e%1e3!=0?1:0):ue(e/1e3)}},87453:e=>{e.exports.tzData={"America/New_York":{
time:[-2717668562,-1633298400,-1615154400,-1601848800,-1583704800,-1570399200,-1551650400,-1536530400,-1523224800,-1504476e3,-1491775200,-1473026400,-1459720800,-1441576800,-1428271200,-1410127200,-1396821600,-1378677600,-1365372e3,-1347228e3,-1333922400,-1315173600,-1301868e3,-1283724e3,-1270418400,-1252274400,-1238968800,-1220824800,-1207519200,-1189375200,-1176069600,-1157320800,-114462e4,-1125871200,-1112565600,-1094421600,-1081116e3,-1062972e3,-1049666400,-1031522400,-1018216800,-1000072800,-986767200,-968018400,-955317600,-936568800,-923263200,-905119200,-891813600,-880236e3,-76941e4,-765410400,-747266400,-733960800,-715816800,-702511200,-684367200,-671061600,-652917600,-639612e3,-620863200,-608162400,-589413600,-576108e3,-557964e3,-544658400,-526514400,-513208800,-495064800,-481759200,-463615200,-447285600,-431560800,-415836e3,-400111200,-384386400,-368661600,-352936800,-337212e3,-321487200,-305762400,-289432800,-273708e3,-257983200,-242258400,-226533600,-210808800,-195084e3,-179359200,-163634400,-147909600,-13158e4,-11646e4,-100130400,-84405600,-68680800,-52956e3,-37231200,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,126669600,152071200,162352800,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],
offset:[-17762,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3]},"America/Los_Angeles":{
time:[-2717668378,-1633298400,-1615154400,-1601848800,-1583704800,-880236e3,-769420800,-765410400,-687995940,-662680800,-620866800,-608162400,-589417200,-576108e3,-557967600,-544658400,-526518e3,-513208800,-495068400,-481759200,-463618800,-450309600,-431564400,-418255200,-400114800,-386805600,-368665200,-355356e3,-337215600,-323906400,-305766e3,-292456800,-273711600,-261007200,-242262e3,-226533600,-210812400,-195084e3,-179362800,-163634400,-147913200,-13158e4,-116463600,-100130400,-84405600,-68680800,-52956e3,-37231200,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,126669600,152071200,162352800,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],offset:[-28378,-28800,-25200,-28800,-25200,-28800,-25200,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800]},"America/Chicago":{
time:[-2717668236,-1633298400,-1615154400,-1601848800,-1583704800,-1563746400,-1551650400,-1538949600,-1520200800,-1504476e3,-1491775200,-1473026400,-1459720800,-1441576800,-1428271200,-1410127200,-1396821600,-1378677600,-1365372e3,-1347228e3,-1333922400,-1315173600,-1301868e3,-1283724e3,-1270418400,-1252274400,-1238968800,-1220824800,-1207519200,-1189375200,-1176069600,-1157320800,-114462e4,-1125871200,-1112565600,-1094421600,-1081116e3,-1067810400,-1045432800,-1031522400,-1018216800,-1000072800,-986767200,-968018400,-955317600,-936568800,-923263200,-905119200,-891813600,-880236e3,-769413600,-765410400,-747266400,-733960800,-715816800,-702511200,-684367200,-671061600,-652917600,-639612e3,-620863200,-608162400,-589413600,-576108e3,-557964e3,-544658400,-526514400,-513208800,-495064800,-481759200,-463615200,-447285600,-431560800,-415836e3,-400111200,-384386400,-368661600,-352936800,-337212e3,-321487200,-305762400,-289432800,-273708e3,-257983200,-242258400,-226533600,-210808800,-195084e3,-179359200,-163634400,-147909600,-13158e4,-11646e4,-100130400,-84405600,-68680800,-52956e3,-37231200,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,126669600,152071200,162352800,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],
offset:[-21036,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600]},"America/Phoenix":{time:[-2717670498,-1633298400,-1615154400,-1601848800,-1583704800,-880236e3,-820540740,-812678340,-796867140,-84405600,-68680800,1924966800],offset:[-26898,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200]},"America/Toronto":{
time:[-2366755200,-1632088800,-1615154400,-1601771400,-1583712e3,-1567375200,-1554681600,-1534716e3,-1524088800,-1503266400,-149238e4,-1471816800,-1460930400,-1440972e3,-1428876e3,-1409522400,-1397426400,-1378072800,-1365976800,-1346623200,-1333922400,-1315173600,-1301868e3,-1283724e3,-1270418400,-1252274400,-1238968800,-1220824800,-1207519200,-1188770400,-1176069600,-1157320800,-1144015200,-1125871200,-1112565600,-1094421600,-1081116e3,-1062972e3,-1049666400,-1031522400,-1018216800,-1000072800,-986767200,-968018400,-955317600,-936568800,-880232400,-76941e4,-765410400,-747266400,-733960800,-715816800,-702511200,-684367200,-671061600,-652917600,-634168800,-620863200,-602719200,-589413600,-576108e3,-557964e3,-544658400,-526514400,-513208800,-495064800,-481759200,-463615200,-450309600,-431560800,-418255200,-400111200,-384386400,-368661600,-352936800,-337212e3,-321487200,-305762400,-289432800,-273708e3,-257983200,-242258400,-226533600,-210808800,-195084e3,-179359200,-163634400,-147909600,-13158e4,-11646e4,-100130400,-84405600,-68680800,-52956e3,-37231200,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,136346400,152071200,167796e3,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],
offset:[-19052,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-14400,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3]},"America/Vancouver":{
time:[-2713910400,-1632088800,-1615154400,-880236e3,-769420800,-765410400,-747266400,-733960800,-715816800,-702511200,-684367200,-671061600,-652917600,-639612e3,-620863200,-608162400,-589413600,-576108e3,-557964e3,-544658400,-526514400,-513208800,-495064800,-481759200,-463615200,-450309600,-431560800,-418255200,-400111200,-386805600,-368661600,-355356e3,-337212e3,-323906400,-305762400,-292456800,-273708e3,-261007200,-242258400,-226533600,-210808800,-195084e3,-179359200,-163634400,-147909600,-13158e4,-11646e4,-100130400,-84405600,-68680800,-52956e3,-37231200,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,136346400,152071200,167796e3,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],
offset:[-29548,-28800,-25200,-28800,-25200,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800]},"America/Argentina/Buenos_Aires":{time:[-2372112e3,-1567468800,-1233446400,-1222992e3,-1205971200,-1194048e3,-117288e4,-1162512e3,-1141344e3,-1130976e3,-1109808e3,-109944e4,-1078272e3,-1067817600,-1046649600,-1036281600,-1015113600,-1004745600,-983577600,-973209600,-952041600,-941587200,-931046400,-900892800,-890352e3,-83376e4,-82728e4,-752284800,-733795200,-197337600,-190857600,-184204800,-164505600,-152668800,-132969600,-121132800,-101433600,-86832e3,-71107200,-54777600,-39052800,-23328e3,-7603200,128131200,136598400,596937600,605059200,624412800,636508800,656467200,667958400,687916800,699408e3,719366400,731462400,938908800,952041600,1198972800,1205625600,1224374400,1237075200,1924981200],offset:[-14028,-15408,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-10800,-10800,-7200,-10800,-7200,-10800]},"America/El_Salvador":{time:[-1546300800,546998400,559699200,578448e3,591148800,1924970400],offset:[-21408,-21600,-18e3,-21600,-18e3,-21600]},"America/Sao_Paulo":{
time:[-1767225600,-1206968400,-1191369600,-1175385600,-1159833600,-633830400,-622076400,-602294400,-59184e4,-570758400,-560217600,-539136e3,-53136e4,-195436800,-189388800,-184204800,-155174400,-150076800,-128908800,-121132800,-99964800,-89596800,-68428800,-57974400,499737600,511228800,530582400,540259200,562118400,571190400,592963200,602035200,624412800,634694400,656467200,666748800,687916800,697593600,719971200,728438400,750816e3,761702400,782265600,793152e3,813715200,823996800,84456e4,856051200,876096e3,888710400,908064e3,919555200,938908800,951609600,970963200,982454400,1003017600,1013904e3,1036281600,1045353600,1066521600,1076803200,1099353600,1108857600,1129420800,1140307200,1162684800,1172361600,119232e4,1203206400,1224374400,1234656e3,1255824e3,1266710400,1287273600,129816e4,1318723200,1330214400,1350777600,1361059200,1382227200,1392508800,1413676800,1424563200,1445126400,1456012800,1476576e3,1487462400,1508025600,1518912e3,1541289600,1550361600,1924981200],offset:[-11188,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800]},"America/Bogota":{time:[-2707689600,-1739059200,704851200,729043200,1924974e3],offset:[-17776,-17776,-18e3,-14400,-18e3]},"America/Caracas":{time:[-2524521600,-1826755200,-157766400,1197169200,1462069800,1924977600],offset:[-16064,-16060,-16200,-14400,-16200,-14400]},"America/Anchorage":{
time:[-3225173303,-2188987200,-880236e3,-769428e3,-765410400,-86918400,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,126669600,152071200,162352800,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,438998400,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],offset:[50424,-35976,-36e3,-32400,-32400,-36e3,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-36e3,-32400,-32400,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400]},"Europe/Moscow":{
time:[-2840140800,-1688256e3,-165681e4,-1641340800,-1627956e3,-1618700400,-1596416400,-1593804521,-1589846400,-1542416400,-1539478800,-1525305600,-1522713600,-1491177600,-1247529600,354931200,370742400,386467200,402278400,418003200,433814400,449625600,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,695786400,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1414288800,1925002800],offset:[9017,9017,9079,12679,9079,16279,12679,16279,14400,10800,14400,18e3,14400,10800,7200,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,10800,7200,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800]},"Europe/Athens":{time:[-2344636800,-1686095940,-1182988800,-1178150400,-906854400,-904867200,-85725e4,-844473600,-828230400,-812419200,-552355200,-541641600,166492800,186195600,198036e3,213764400,228880800,244090800,260330400,275457600,291805200,307418400,323395200,338947200,354682800,370411200,386132400,401860800,417582e3,433310400,449031600,465364800,481086e3,496814400,512535600,528264e3,543985200,559713600,575434800,591163200,606884400,622612800,638334e3,654667200,670388400,686116800,701838e3,717566400,733287600,749016e3,764737200,780465600,796186800,811915200,828241200,846388800,859690800,877838400,891140400,909288e3,92259e4,941342400,954039600,972792e3,985489200,1004241600,1017543600,1035691200,1048993200,1067140800,1080442800,1099195200,1111892400,1130644800,1143342e3,1162094400,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301194800,1319947200,1332644400,1351396800,1364698800,1382846400,1396148400,1414296e3,1427598e3,1445745600,1459047600,14778e5,1490497200,1509249600,1521946800,1540699200,1554001200,1572148800,1585450800,1603598400,1616900400,1635652800,164835e4,1667102400,1679799600,1698552e3,1711854e3,1730001600,1743303600,1761451200,1774753200,1792900800,1806202800,1824955200,1837652400,1856404800,1869102e3,1887854400,1901156400,1919304e3,1932606e3],
offset:[5692,5692,7200,10800,7200,10800,7200,3600,7200,3600,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Europe/Belgrade":{time:[-2713910400,-905821200,-85725e4,-844552800,-828219600,-812498400,-79677e4,-777938400,-766616400,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[4920,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Berlin":{
time:[-2422051200,-1693702800,-1680476400,-1663452e3,-1650142800,-1632002400,-1618693200,-938901600,-85725e4,-844552800,-828219600,-812498400,-79677e4,-781048800,-776556e3,-765925200,-761173200,-748476e3,-733266e3,-717627600,-714603600,-71037e4,-701902800,-684972e3,-670453200,-654127200,-639003600,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[3208,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,10800,7200,3600,7200,3600,7200,10800,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Bratislava":{
time:[-3786825600,-2469398400,-1693702800,-1680476400,-1663452e3,-1650142800,-1632002400,-1618693200,-938901600,-85725e4,-844552800,-828219600,-812498400,-79677e4,-781048800,-765320400,-746575200,-733352400,-728514e3,-72126e4,-716421600,-701902800,-684972e3,-670453200,-654213600,-639003600,29178e4,307508400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[3464,3464,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,0,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Bucharest":{
time:[-2469398400,-1213142400,-1187049600,-1175468400,-1159747200,-1144018800,-1127692800,-1111964400,-1096243200,-1080514800,-1064793600,-1049065200,-1033344e3,-1017615600,-1001894400,-986166e3,-970444800,-954716400,296611200,307497600,323823600,338950800,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670377600,686106e3,701827200,717555600,733276800,749005200,764726400,780451200,796176e3,811900800,828230400,846374400,859690800,877838400,891140400,909288e3,92259e4,941342400,954039600,972792e3,985489200,1004241600,1017543600,1035691200,1048993200,1067140800,1080442800,1099195200,1111892400,1130644800,1143342e3,1162094400,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301194800,1319947200,1332644400,1351396800,1364698800,1382846400,1396148400,1414296e3,1427598e3,1445745600,1459047600,14778e5,1490497200,1509249600,1521946800,1540699200,1554001200,1572148800,1585450800,1603598400,1616900400,1635652800,164835e4,1667102400,1679799600,1698552e3,1711854e3,1730001600,1743303600,1761451200,1774753200,1792900800,1806202800,1824955200,1837652400,1856404800,1869102e3,1887854400,1901156400,1919304e3,1932606e3],offset:[6264,6264,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Europe/Budapest":{
time:[-2498256e3,-1693702800,-1680476400,-1663452e3,-1650142800,-1632002400,-1618693200,-1600466400,-1587243600,-1569708e3,-1555189200,-906771600,-85725e4,-844552800,-828219600,-812498400,-79677e4,-778467600,-762649200,-749685600,-733269600,-717631200,-701902800,-686181600,-670453200,-654127200,-639003600,-492652800,-481161600,-461196e3,-449701200,-428536800,-418251600,-397087200,-386802e3,323827200,338950800,354672e3,370400400,386121600,40185e4,417571200,433299600,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[4580,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/London":{
time:[-3852662400,-1691964e3,-1680469200,-1664143200,-1650142800,-1633903200,-1617483600,-1601848800,-1586034e3,-1570399200,-1552165200,-1538344800,-152253e4,-15075e5,-1490562e3,-1473631200,-1460926800,-1442786400,-1428872400,-1410732e3,-1396213200,-1379282400,-1364763600,-1348437600,-1333314e3,-1315778400,-1301259600,-1284328800,-126981e4,-1253484e3,-1238360400,-1221429600,-1206910800,-118998e4,-1175461200,-1159135200,-1143406800,-1126476e3,-1111957200,-1095631200,-1080507600,-1063576800,-1049058e3,-1032127200,-1017608400,-1001282400,-986158800,-969228e3,-950475600,-942012e3,-904514400,-896043600,-875484e3,-864594e3,-844034400,-832539600,-812584800,-798066e3,-781048800,-772059600,-764802e3,-748476e3,-733352400,-719445600,-717026400,-706741200,-699483600,-687996e3,-668034e3,-654732e3,-636584400,-622072800,-605739600,-590623200,-57429e4,-558568800,-542235600,-527119200,-512600400,-496274400,-481150800,-46422e4,-449701200,-432165600,-417646800,-401320800,-386197200,-369266400,-354747600,-337816800,-323298e3,-306972e3,-291848400,-276732e3,-257979600,-245282400,-22653e4,-213228e3,-195080400,-182383200,-163630800,-150933600,-132181200,-119484e3,-100731600,-88034400,-68677200,-59004e3,-37238400,57726e3,69818400,89175600,101268e3,120625200,132717600,152074800,164167200,183524400,196221600,214974e3,227671200,246423600,259120800,278478e3,290570400,309927600,32202e4,341377200,354675600,372823200,386125200,404272800,417574800,435722400,449024400,467776800,481078800,499226400,512528400,530676e3,543978e3,562125600,575427600,593575200,606877200,625629600,638326800,657079200,670381200,688528800,701830800,719978400,733280400,751428e3,76473e4,782877600,796179600,814327200,828234e3,846381600,859683600,877831200,891133200,909280800,922582800,941335200,954032400,972784800,985482e3,1004234400,1017536400,1035684e3,1048986e3,1067133600,1080435600,1099188e3,1111885200,1130637600,1143334800,1162087200,1174784400,1193536800,1206838800,1224986400,1238288400,1256436e3,1269738e3,1288490400,1301187600,131994e4,1332637200,1351389600,1364691600,1382839200,1396141200,1414288800,1427590800,1445738400,1459040400,1477792800,149049e4,1509242400,1521939600,1540692e3,1553994e3,1572141600,1585443600,1603591200,1616893200,1635645600,1648342800,1667095200,1679792400,1698544800,1711846800,1729994400,1743296400,1761444e3,1774746e3,1792893600,1806195600,1824948e3,1837645200,1856397600,1869094800,1887847200,1901149200,1919296800,1932598800],
offset:[-75,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,0,3600,0,3600,7200,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0]},"Europe/Luxembourg":{time:[-2069712e3,-1692493200,-1680476400,-1662339600,-165015e4,-1632002400,-1618693200,-1612656e3,-1604278800,-1585515600,-1574038800,-1552255200,-1539997200,-1520546400,-1507510800,-1490569200,-1473642e3,-1459116e3,-1444006800,-142767e4,-1411866e3,-1396220400,-1379293200,-1364770800,-1348448400,-1333321200,-1316394e3,-1301266800,-1284339600,-126981e4,-1253484e3,-1238360400,-1221429600,-1206910800,-1191189600,-1175461200,-1160344800,-1143406800,-1127685600,-1111957200,-1096840800,-1080507600,-1063576800,-1049058e3,-1033336800,-1017608400,-1002492e3,-986158800,-969228e3,-950475600,-942012e3,-935182800,-85725e4,-844552800,-828219600,-812498400,-797979600,-781048800,-766616400,-745452e3,-733266e3,228880800,244004400,260330400,276058800,29178e4,307508400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],
offset:[1476,3600,7200,3600,7200,3600,7200,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Madrid":{time:[-2177453684,-1631926800,-1616886e3,-1601168400,-158535e4,-1442451600,-142767e4,-1379293200,-1364770800,-1348448400,-1333321200,-1316390400,-1301266800,-1284339600,-1269817200,-1026954e3,-1017615600,-1001898e3,-999478800,-986083200,-954111600,-940208400,-873075600,-862614e3,-842835600,-828313200,-811386e3,-796863600,-779936400,-765414e3,-748486800,-733964400,-652323600,-639010800,135126e3,150253200,166575600,181702800,196815600,212547600,22887e4,243997200,260330400,276058800,29178e4,307508400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],
offset:[-884,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,7200,3600,0,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Paris":{time:[-2486592e3,-1855958400,-1689814800,-1680393600,-1665363600,-1648339200,-1635123600,-1616889600,-1604278800,-158544e4,-1574038800,-1552262400,-1539997200,-1520553600,-1507510800,-1490572800,-1470618e3,-1459123200,-1444006800,-1427673600,-1411952400,-1396224e3,-1379293200,-1364774400,-1348448400,-1333324800,-1316394e3,-1301270400,-1284339600,-1269820800,-1253494800,-1238371200,-1221440400,-1206921600,-1191200400,-1175472e3,-1160355600,-1143417600,-1127696400,-1111968e3,-1096851600,-1080518400,-1063587600,-1049068800,-1033347600,-1017619200,-1002502800,-986169600,-969238800,-950486400,-942012e3,-932432400,-85725e4,-844552800,-828219600,-812498400,-800064e3,-796258800,-781048800,-766616400,196822800,212547600,228880800,244004400,260330400,276058800,29178e4,307508400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],
offset:[561,561,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,7200,3600,7200,3600,7200,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Prague":{time:[-3786825600,-2469398400,-1693702800,-1680476400,-1663452e3,-1650142800,-1632002400,-1618693200,-938901600,-85725e4,-844552800,-828219600,-812498400,-79677e4,-781048800,-765320400,-746575200,-733352400,-728514e3,-72126e4,-716421600,-701902800,-684972e3,-670453200,-654213600,-639003600,29178e4,307508400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[3464,3464,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,0,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Rome":{
time:[-3252096e3,-2403562204,-1690761600,-168048e4,-1664755200,-1648944e3,-163512e4,-1616889600,-1604275200,-1585526400,-1571011200,-1555286400,-932428800,-85725e4,-844552800,-828219600,-812498400,-798066e3,-781048800,-76671e4,-750895200,-733352400,-719452800,-70191e4,-689205600,-670453200,-114048e3,-103161600,-81993600,-71708400,-50544e3,-40258800,-18489600,-8204400,1296e4,23245200,43804800,54694800,75859200,86749200,107913600,118198800,138758400,149648400,170812800,181098e3,202262400,212547600,233107200,243997200,265161600,276051600,296611200,307501200,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[2996,2996,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Vienna":{
time:[-2422051200,-1693702800,-1680476400,-1663452e3,-1650142800,-1632002400,-1618693200,-1569708e3,-1555794e3,-938901600,-85725e4,-844552800,-828219600,-812498400,-79677e4,-781048800,-780181200,-748476e3,-733266e3,-717631200,-701902800,-684972e3,-670453200,323827200,338947200,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[3921,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Warsaw":{
time:[-2840140800,-1717027200,-1693702800,-1680476400,-1663452e3,-1650142800,-1632002400,-1618693200,-1600466400,-1587157200,-1501718400,-931730400,-85725e4,-844552800,-828219600,-812498400,-796600800,-778723200,-762652800,-748483200,-733266e3,-715212e3,-701902800,-684972e3,-670453200,-654127200,-639003600,-397090800,-386805600,-371084400,-355356e3,-334191600,-323301600,-307580400,-291852e3,-271292400,-260402400,-239842800,-228952800,-208393200,-197503200,-176338800,-166053600,228877200,244000800,260326800,276055200,291776400,307504800,323830800,338954400,354675600,370404e3,386125200,401853600,417574800,433303200,449024400,465357600,481078800,496807200,512528400,528256800,543978e3,559706400,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[5040,5040,3600,7200,3600,7200,3600,7200,7200,10800,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Istanbul":{
time:[-2840140800,-1869868800,-1693699200,-168048e4,-1570406400,-1552176e3,-1538352e3,-1522540800,-1507507200,-1490572800,-1440201600,-1428019200,-1409702400,-1396483200,-931046400,-922665600,-917827200,-892425600,-875836800,-764726400,-744336e3,-733795200,-716428800,-701913600,-684979200,-670464e3,-654134400,-639014400,-62208e4,-60696e4,-590025600,-575510400,-235612800,-194832e3,-177724800,-165715200,107917200,121226400,133927200,152676e3,164685600,184125600,196221600,215575200,228880800,245815200,260330400,267926400,428464800,433908e3,468122400,482806800,496720800,512528400,528256800,543978e3,559706400,575427600,591156e3,606877200,622605600,638326800,65466e4,670381200,686109600,701830800,717559200,733280400,749008800,764125200,780458400,796179600,811908e3,828234e3,846381600,859683600,877831200,891133200,909280800,922582800,941335200,954032400,972784800,985482e3,1004234400,1017536400,1035684e3,1048986e3,1067133600,1080435600,1099188e3,1111885200,1130637600,1143334800,1162087200,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301281200,1319947200,1332644400,1351396800,1364698800,1382846400,1396234800,1414296e3,1427598e3,1446955200,1459047600,1473206400,1925002800],offset:[6952,7016,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,10800,14400,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,10800]},"Europe/Zurich":{time:[-3675196800,-2385244800,-904431600,-891122400,-872982e3,-859672800,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],
offset:[2048,1786,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Australia/Sydney":{time:[-2364076800,-1672524e3,-1665349200,-883605600,-876085200,-860364e3,-844635600,-828309600,-813186e3,57722400,68007600,89172e3,100062e3,120621600,131511600,152071200,162961200,183520800,195015600,215575200,226465200,247024800,257914800,278474400,289364400,309924e3,320814e3,341373600,352263600,372823200,386737200,404877600,415767600,436327200,447217200,467776800,478666800,499226400,511326e3,530071200,542775600,562125600,57483e4,59418e4,606279600,625629600,636519600,657079200,667969200,688528800,699418800,719978400,731473200,752032800,762922800,783482400,794372400,814932e3,828241200,846381600,859690800,877831200,891140400,909280800,92259e4,941335200,954039600,967341600,985489200,1004234400,1017543600,1035684e3,1048993200,1067133600,1080442800,1099188e3,1111892400,1130637600,1143946800,1162087200,1174791600,1193536800,1207450800,1223172e3,1238900400,1254621600,127035e4,1286071200,1301799600,1317520800,1333249200,1349575200,1365303600,1381024800,1396753200,1412474400,1428202800,1443924e3,1459652400,1475373600,1491102e3,1506823200,1522551600,1538877600,1554606e3,1570327200,1586055600,1601776800,1617505200,1633226400,1648954800,1664676e3,1680404400,1696125600,1712458800,172818e4,1743908400,1759629600,1775358e3,1791079200,1806807600,1822528800,1838257200,1853978400,1869706800,1886032800,1901761200,1917482400,1933210800],offset:[36292,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600]},"Australia/Brisbane":{time:[-2366755200,-1672524e3,-1665349200,-883605600,-876085200,-860364e3,-844635600,-828309600,-813186e3,57722400,68007600,625629600,636519600,657079200,667969200,688528800,699418800,1925028e3],offset:[36728,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3]},"Australia/Adelaide":{
time:[-2364076800,-2230156800,-1672524e3,-1665349200,-883605600,-876085200,-860364e3,-844635600,-828309600,-813186e3,57722400,68007600,89172e3,100062e3,120621600,131511600,152071200,162961200,183520800,195015600,215575200,226465200,247024800,257914800,278474400,289364400,309924e3,320814e3,341373600,352263600,372823200,384318e3,404877600,415767600,436327200,447217200,467776800,478666800,499226400,511326e3,530071200,542775600,562125600,57483e4,59418e4,606279600,625629600,637729200,657079200,667969200,688528800,701233200,719978400,731473200,752032800,764132400,783482400,796186800,814932e3,828241200,846381600,859690800,877831200,891140400,909280800,92259e4,941335200,954039600,972784800,985489200,1004234400,1017543600,1035684e3,1048993200,1067133600,1080442800,1099188e3,1111892400,1130637600,1143946800,1162087200,1174791600,1193536800,1207450800,1223172e3,1238900400,1254621600,127035e4,1286071200,1301799600,1317520800,1333249200,1349575200,1365303600,1381024800,1396753200,1412474400,1428202800,1443924e3,1459652400,1475373600,1491102e3,1506823200,1522551600,1538877600,1554606e3,1570327200,1586055600,1601776800,1617505200,1633226400,1648954800,1664676e3,1680404400,1696125600,1712458800,172818e4,1743908400,1759629600,1775358e3,1791079200,1806807600,1822528800,1838257200,1853978400,1869706800,1886032800,1901761200,1917482400,1933210800],offset:[33260,32400,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800,34200,37800]},"Australia/ACT":{
time:[-2364076800,-1672524e3,-1665349200,-883605600,-876085200,-860364e3,-844635600,-828309600,-813186e3,57722400,68007600,89172e3,100062e3,120621600,131511600,152071200,162961200,183520800,195015600,215575200,226465200,247024800,257914800,278474400,289364400,309924e3,320814e3,341373600,352263600,372823200,386737200,404877600,415767600,436327200,447217200,467776800,478666800,499226400,511326e3,530071200,542775600,562125600,57483e4,59418e4,606279600,625629600,636519600,657079200,667969200,688528800,699418800,719978400,731473200,752032800,762922800,783482400,794372400,814932e3,828241200,846381600,859690800,877831200,891140400,909280800,92259e4,941335200,954039600,967341600,985489200,1004234400,1017543600,1035684e3,1048993200,1067133600,1080442800,1099188e3,1111892400,1130637600,1143946800,1162087200,1174791600,1193536800,1207450800,1223172e3,1238900400,1254621600,127035e4,1286071200,1301799600,1317520800,1333249200,1349575200,1365303600,1381024800,1396753200,1412474400,1428202800,1443924e3,1459652400,1475373600,1491102e3,1506823200,1522551600,1538877600,1554606e3,1570327200,1586055600,1601776800,1617505200,1633226400,1648954800,1664676e3,1680404400,1696125600,1712458800,172818e4,1743908400,1759629600,1775358e3,1791079200,1806807600,1822528800,1838257200,1853978400,1869706800,1886032800,1901761200,1917482400,1933210800],offset:[36292,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600,36e3,39600]},"Asia/Almaty":{time:[-1441152e3,-1247529600,354931200,370742400,386467200,402278400,418003200,433814400,449625600,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,695786400,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1709251200,192501e4],offset:[18468,18e3,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,21600,18e3,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,25200,21600,18e3]},"Asia/Ashkhabad":{
time:[-1441152e3,-1247529600,354931200,370742400,386467200,402278400,418003200,433814400,449625600,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,695786400,192501e4],offset:[14012,14400,18e3,21600,18e3,21600,18e3,21600,18e3,21600,18e3,21600,18e3,21600,18e3,21600,18e3,21600,18e3,21600,18e3,21600,18e3,18e3,14400,18e3]},"Asia/Colombo":{time:[-2840140800,-2019686400,-883267200,-862617600,-764028e3,832982400,846289800,1145061e3,1925011800],offset:[19164,19172,19800,21600,23400,19800,23400,21600,19800]},"Asia/Dhaka":{time:[-2524521600,-891561600,-872035200,-862617600,-576115200,1230768e3,1245452400,1262303999,1925013600],offset:[21700,21200,23400,19800,23400,21600,21600,25200,21600]},"Asia/Tokyo":{time:[-2587678861,-683769600,-672274800,-654739200,-640825200,-620265600,-609375600,-588816e3,-577926e3,1925024400],offset:[33539,32400,36e3,32400,36e3,32400,36e3,32400,36e3,32400]},"Asia/Taipei":{time:[-2335219200,-1017792e3,-766191600,-745804800,-733795200,-716860800,-699580800,-683856e3,-670636800,-65232e4,-639100800,-620784e3,-607564800,-589248e3,-576028800,-562896e3,-541728e3,-528681600,-510192e3,-497145600,-478656e3,-465609600,-449798400,-433987200,-418176e3,-402451200,-38664e4,-370915200,-355104e3,-339379200,-323568e3,-302486400,-291945600,-270950400,-260409600,134006400,149817600,165542400,181353600,299635200,307584e3,1925020800],offset:[29160,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800]},"Asia/Singapore":{time:[-2177452800,-2038176e3,-1167609600,-1073001600,-894153600,-879638400,-766972800,378689400,1925020800],offset:[24925,24925,25200,26400,26400,27e3,32400,27e3,28800]},"Asia/Karachi":{time:[-1988150400,-862617600,-764121600,-576115200,38793600,1018137600,1033862400,1212278400,1225497600,1239753600,1257033600,192501e4],offset:[16092,19800,23400,19800,18e3,18e3,21600,18e3,21600,18e3,21600,18e3]},"Asia/Manila":{time:[-3944678400,-2219054168,-1046649600,-1040083200,-884995200,-879984e3,-783561600,-760060800,-496195200,-491529600,228355200,243734400,643248e3,649209600,1925020800],offset:[-57368,29032,28800,32400,28800,32400,32400,32400,28800,32400,28800,32400,28800,32400,28800]},"Asia/Shanghai":{time:[-2177452800,-1600646400,-1585872e3,-933638400,-922060800,-908841600,-888796800,-881020800,-767836800,-745804800,-733795200,-716860800,-699580800,-683856e3,-670636800,-65232e4,-649987200,515556e3,527047200,545191200,558496800,577245600,589946400,608695200,622000800,640144800,653450400,671594400,6849e5,1925020800],offset:[29143,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800]},"Asia/Seoul":{
time:[-1948752e3,-1830384e3,-767318400,-681177600,-672192e3,-654739200,-640828800,-623376e3,-609379200,-588816e3,-577929600,-498096e3,-462672e3,-451699200,-429753600,-418262400,-399513600,-387417600,-368064e3,-355968e3,-336614400,-324518400,-305164800,-293068800,-264902400,547610400,560919600,57906e4,592369200,1925024400],offset:[30472,30600,32400,32400,36e3,32400,36e3,32400,36e3,32400,36e3,32400,30600,34200,30600,34200,30600,34200,30600,34200,30600,34200,30600,34200,30600,32400,36e3,32400,36e3,32400]},"Asia/Tehran":{time:[-1704153600,-1090454400,227833200,24624e4,259632e3,271126800,283996800,296611200,306547200,322444800,338515200,673228800,685497600,701222400,71712e4,732758400,748656e3,764294400,780192e3,795830400,811728e3,827366400,843264e3,858988800,874886400,890524800,906422400,922060800,937958400,953596800,969494400,985219200,1001116800,1016755200,1032652800,1048291200,1064188800,1079827200,1095724800,1111449600,1127347200,1206057600,1221955200,123768e4,1253577600,1269216e3,1285113600,1300752e3,1316649600,1332288e3,1348185600,1363910400,1379808e3,1395446400,1411344e3,1426982400,144288e4,1458518400,1474416e3,1490140800,1506038400,1521676800,1537574400,1553212800,1569110400,1584748800,1600646400,1616371200,1632268800,1647907200,1663804800,1925004600],offset:[12344,12344,12600,16200,14400,18e3,14400,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600,16200,12600]},"Asia/Dubai":{time:[-1577923200,1925006400],offset:[13272,14400]},"Asia/Kolkata":{time:[-3645216e3,-3155673600,-2019686400,-891561600,-872035200,-862617600,-764121600,1925011800],offset:[21208,21200,19270,19800,23400,19800,23400,19800]},"Asia/Hong_Kong":{time:[-2056663398,-900882e3,-891547200,-884217600,-761176800,-747878400,-728508600,-717021e3,-697059e3,-683757e3,-668028600,-654726600,-636579e3,-623277e3,-605129400,-591827400,-573679800,-559773e3,-541625400,-528323400,-510179400,-498083400,-478729800,-466633800,-446675400,-435184200,-415225800,-403129800,-383776200,-371680200,-352326600,-340230600,-320877e3,-308781e3,-288822600,-277331400,-257373e3,-245881800,-225923400,-213827400,-194473800,-182377800,-163024200,-148509e3,-132784200,-117059400,-101334600,-85609800,-69280200,-53555400,-37830600,-22105800,-6381e3,9343800,25068600,40793400,56518200,72243e3,88572600,104297400,120022200,126070200,151471800,167196600,182921400,198646200,214371e3,295414200,309324600,1925020800],
offset:[27402,28800,32400,30600,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800]},"Asia/Bangkok":{time:[-2840140800,-1570060800,1925017200],offset:[24124,24124,25200]},"Asia/Chongqing":{time:[-2177452800,-1600646400,-1585872e3,-933638400,-922060800,-908841600,-888796800,-881020800,-767836800,-745804800,-733795200,-716860800,-699580800,-683856e3,-670636800,-65232e4,-649987200,515556e3,527047200,545191200,558496800,577245600,589946400,608695200,622000800,640144800,653450400,671594400,6849e5,1925020800],offset:[29143,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800]},"Asia/Jerusalem":{time:[-2840140800,-1640995200,-933631200,-923086800,-919029600,-857336400,-844293600,-825800400,-812671200,-794178e3,-779839200,-762642e3,-748303200,-731106e3,-681948e3,-673214400,-667947600,-652312800,-636411600,-622072800,-608936400,-591832800,-572475600,-558568800,-542840400,-527724e3,-514414800,-490831200,-482965200,-459381600,-451515600,-428536800,-418251600,-400111200,-387406800,142387200,150854400,167184e3,178675200,334108800,337741200,452649600,46233e4,482284800,494380800,516758400,526435200,545443200,558489600,576633600,589334400,609897600,620784e3,638323200,651628800,669772800,683683200,701827200,715737600,733708800,747187200,765158400,778032e3,796608e3,810086400,826848e3,842832e3,858902400,874195200,890352e3,90504e4,923018400,936324e3,955677600,970794e3,986778e3,1001293200,1017363600,1033952400,1048813200,1065142800,1081299600,1095814800,1112320800,1128823200,1143770400,1159668e3,117522e4,1189908e3,1206669600,1223172e3,1238119200,1254016800,1269568800,1284256800,1301623200,1317520800,1333072800,1348365600,1364522400,1382839200,1395972e3,1414288800,1427421600,1445738400,1458871200,1477792800,1490320800,1509242400,1521770400,1540692e3,1553824800,1572141600,1585274400,1603591200,1616724e3,1635645600,1648173600,1667095200,1679623200,1698544800,1711677600,1729994400,1743127200,1761444e3,1774576800,1792893600,1806026400,1824948e3,1837476e3,1856397600,1868925600,1887847200,190098e4,1919296800,1932429600],
offset:[8454,8440,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,14400,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Asia/Kuala_Lumpur":{time:[-2177452800,-2038176e3,-1167609600,-1073001600,-894153600,-879638400,-766972800,378689400,1925020800],offset:[24406,24925,25200,26400,26400,27e3,32400,27e3,28800]},"Asia/Kuwait":{time:[-631152e3,1925002800],offset:[11516,10800]},"Asia/Muscat":{time:[-1577923200,1925006400],offset:[14064,14400]},"Asia/Nicosia":{time:[-1518912e3,166579200,182304e3,200966400,21384e4,228873600,243993600,260323200,276134400,291772800,307497600,323827200,338947200,354672e3,370396800,386121600,401846400,417571200,433296e3,449020800,465350400,481075200,4968e5,512524800,528249600,543974400,559699200,575424e3,591148800,606873600,622598400,638323200,654652800,670377600,686102400,701827200,717552e3,733276800,749001600,764726400,780451200,796176e3,811900800,828230400,843955200,85968e4,875404800,891129600,909288e3,92259e4,941342400,954039600,972792e3,985489200,1004241600,1017543600,1035691200,1048993200,1067140800,1080442800,1099195200,1111892400,1130644800,1143342e3,1162094400,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301194800,1319947200,1332644400,1351396800,1364698800,1382846400,1396148400,1414296e3,1427598e3,1445745600,1459047600,14778e5,1490497200,1509249600,1521946800,1540699200,1554001200,1572148800,1585450800,1603598400,1616900400,1635652800,164835e4,1667102400,1679799600,1698552e3,1711854e3,1730001600,1743303600,1761451200,1774753200,1792900800,1806202800,1824955200,1837652400,1856404800,1869102e3,1887854400,1901156400,1919304e3,1932606e3],offset:[8008,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Asia/Qatar":{time:[-1577923200,76204800,1925002800],offset:[12368,14400,10800]},"Asia/Riyadh":{time:[-719625600,1925002800],offset:[11212,10800]},"Asia/Yangon":{
time:[-2840140800,-1577923200,-873244800,-778377600,1925015400],offset:[23087,23087,23400,32400,23400]},"Pacific/Auckland":{time:[-3192393600,-1330293600,-1320012e3,-1300658400,-1287352800,-1269208800,-1255903200,-1237759200,-1224453600,-1206309600,-1192399200,-117486e4,-1160949600,-1143410400,-1125871200,-1112565600,-1094421600,-1081116e3,-1062972e3,-1049666400,-1031522400,-1018216800,-1000072800,-986767200,-968018400,-955317600,-936568800,-923263200,-757382400,152676e3,162356400,183520800,195015600,215575200,226465200,247024800,257914800,278474400,289364400,309924e3,320814e3,341373600,352263600,372823200,384318e3,404877600,415767600,436327200,447217200,467776800,478666800,499226400,510116400,530676e3,541566e3,562125600,573620400,59418e4,60507e4,623815200,637729200,655264800,669178800,686714400,700628400,718164e3,732682800,749613600,764132400,781063200,795582e3,812512800,827031600,844567200,858481200,876016800,889930800,907466400,921985200,938916e3,953434800,970365600,984884400,100242e4,1016334e3,1033869600,1047783600,1065319200,1079838e3,1096768800,1111287600,1128218400,1142737200,1159668e3,1174186800,1191117600,1207450800,1222567200,1238900400,1254016800,127035e4,1285466400,1301799600,1316916e3,1333249200,1348970400,1365303600,138042e4,1396753200,1411869600,1428202800,1443319200,1459652400,1474768800,1491102e3,1506218400,1522551600,1538272800,1554606e3,1569722400,1586055600,1601172e3,1617505200,1632621600,1648954800,1664071200,1680404400,1695520800,1712458800,1727575200,1743908400,1759024800,1775358e3,1790474400,1806807600,1821924e3,1838257200,1853373600,1869706800,1885428e3,1901761200,1916877600,1933210800],offset:[41944,41400,45e3,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,41400,43200,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800,43200,46800]},"Pacific/Chatham":{
time:[-3192393600,-757382400,152678700,162359100,183523500,195018300,215577900,226467900,247027500,257917500,278477100,289367100,309926700,320816700,341376300,352266300,372825900,384320700,404880300,415770300,436329900,447219900,467779500,478669500,499229100,510119100,530678700,541568700,562128300,573623100,594182700,605072700,623817900,637731900,655267500,669181500,686717100,700631100,718166700,732685500,749616300,764135100,781065900,795584700,812515500,827034300,844569900,858483900,876019500,889933500,907469100,921987900,938918700,953437500,970368300,984887100,1002422700,1016336700,1033872300,1047786300,1065321900,1079840700,1096771500,1111290300,1128221100,1142739900,1159670700,1174189500,1191120300,1207453500,1222569900,1238903100,1254019500,1270352700,1285469100,1301802300,1316918700,1333251900,1348973100,1365306300,1380422700,1396755900,1411872300,1428205500,1443321900,1459655100,1474771500,1491104700,1506221100,1522554300,1538275500,1554608700,1569725100,1586058300,1601174700,1617507900,1632624300,1648957500,1664073900,1680407100,1695523500,1712461500,1727577900,1743911100,1759027500,1775360700,1790477100,1806810300,1821926700,1838259900,1853376300,1869709500,1885430700,1901763900,1916880300,1933213500],offset:[44028,44100,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500,45900,49500]},"Pacific/Fakaofo":{time:[-2177452800,1325203200,1925038800],offset:[-41096,-39600,46800]},"Pacific/Honolulu":{time:[-2334139200,-1157320800,-1155470400,-880236e3,-769429800,-765410400,-712188e3,1924956e3],offset:[-37886,-37800,-34200,-37800,-34200,-34200,-37800,-36e3]},"America/Mexico_City":{time:[-1514763396,-1343174400,-1234828800,-1220486400,-1207180800,-1191369600,-975283200,-963187200,-917136e3,-907372800,-821923200,-810086400,-627523200,-613008e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,989114400,1001815200,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1175392800,1193536800,1207447200,1224986400,1238896800,1256436e3,1270346400,1288490400,1301796e3,131994e4,1333245600,1351389600,13653e5,1382839200,1396749600,1414288800,1428199200,1445738400,1459648800,1477792800,1491098400,1509242400,1522548e3,1540692e3,1554602400,1572141600,1586052e3,1603591200,1617501600,1635645600,1648951200,1667095200,1924970400],
offset:[-23796,-25200,-21600,-25200,-21600,-25200,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600,-18e3,-21600]},"Africa/Cairo":{time:[-2185401600,-929836800,-923097600,-906163200,-892857600,-875836800,-857779200,-844300800,-825811200,-812678400,-794188800,-779846400,-762652800,-399081600,-38664e4,-368323200,-355104e3,-336783600,-323643600,-305161200,-292021200,-273625200,-260485200,-242089200,-228949200,-210553200,-197413200,-178930800,-165790800,-147394800,-134254800,-115858800,-102632400,-84322800,-71096400,-52700400,-39474e3,-21164400,-7938e3,10371600,23598e3,41907600,55134e3,7353e4,86756400,105066e3,118292400,136602e3,149828400,168138e3,181364400,199760400,212986800,231296400,244522800,262832400,276058800,294368400,307594800,325990800,339217200,357526800,370753200,396406800,402289200,426819600,433825200,452221200,465447600,483757200,496983600,515293200,528519600,546829200,560055600,578451600,591678e3,610419600,623214e3,641523600,65475e4,673059600,686286e3,704682e3,717908400,736218e3,749444400,767754e3,780980400,799027200,812332800,830476800,843782400,861926400,875232e3,893376e3,906681600,925430400,938736e3,95688e4,970185600,988329600,1001635200,1019779200,1033084800,1051228800,1064534400,1083283200,1096588800,1114732800,1128038400,1146182400,1158883200,1177632e3,1189123200,1209081600,1219968e3,1240531200,1250812800,1272585600,1281484800,1284076800,1285891200,1400198400,1403827200,1406851200,1411689600,168264e4,1698364800,1714089600,1730419200,1745539200,1761868800,1776988800,1793318400,1809043200,1824768e3,1840492800,1856217600,1871942400,1887667200,1903392e3,1919721600,1934841600],offset:[7509,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Africa/Casablanca":{
time:[-1773014400,-956361600,-950486400,-942019200,-761184e3,-617241600,-605145600,-81432e3,-71107200,141264e3,147225600,199756800,207705600,231292800,244252800,265507200,271036800,448243200,504921600,1212278400,1220227200,1243814400,1250812800,1272758400,1281225600,1301788800,1312070400,1335664800,1342753200,1345428e3,1348974e3,1367114400,1373166e3,13761e5,1382842800,1396144800,1403924400,1406944800,1414292400,1427594400,1434250800,1437271200,1445742e3,1459044e3,1465095600,1468116e3,1477796400,1490493600,1495335600,1498960800,1509246e3,1521943200,1526180400,1529200800,1540695600,1557025200,1560045600,1587265200,1590890400,161811e4,1621130400,164835e4,1651975200,1679194800,1682215200,1710039600,171306e4,1740279600,1743904800,1771124400,1774144800,1801969200,1804989600,1832209200,1835834400,1863054e3,1866074400,1893294e3,1896919200,1924138800,1927159200],offset:[-1820,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0]},"Africa/Johannesburg":{time:[-2458166400,-2109283200,-860968800,-845244e3,-829519200,-813794400,1924999200],offset:[6720,5400,7200,10800,7200,10800,7200]},"Africa/Nairobi":{time:[-194616e4,-1309737600,-1261958400,-1041379200,-865296e3,1925002800],offset:[8836,9e3,10800,9e3,9900,10800]},"Africa/Tunis":{time:[-27972e5,-1855958400,-969238800,-950486400,-941936400,-891129600,-877824e3,-85725e4,-844552800,-842911200,-84222e4,-828223200,-812498400,-796262400,-781048800,-766627200,231206400,243910800,262828800,276051600,581126400,591152400,606873600,622602e3,64152e4,654656400,1114905600,1128045600,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1924995600],offset:[2444,561,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Asia/Kathmandu":{time:[-1577923200,504921600,1925012700],offset:[20476,19800,20700]},"US/Mountain":{
time:[-2717668796,-1633298400,-1615154400,-1601848800,-1583704800,-1570399200,-1551650400,-1538949600,-1534111200,-880236e3,-769417200,-765410400,-147909600,-13158e4,-11646e4,-100130400,-84405600,-68680800,-52956e3,-37231200,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,126669600,152071200,162352800,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],offset:[-25196,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200,-21600,-25200]},"Europe/Helsinki":{
time:[-2890252800,-1535932800,-875664e3,-859762800,354679200,370407600,386128800,401857200,417582e3,433310400,449031600,465364800,481086e3,496814400,512535600,528264e3,543985200,559713600,575434800,591163200,606884400,622612800,638334e3,654667200,670388400,686116800,701838e3,717566400,733287600,749016e3,764737200,780465600,796186800,811915200,828241200,846388800,859690800,877838400,891140400,909288e3,92259e4,941342400,954039600,972792e3,985489200,1004241600,1017543600,1035691200,1048993200,1067140800,1080442800,1099195200,1111892400,1130644800,1143342e3,1162094400,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301194800,1319947200,1332644400,1351396800,1364698800,1382846400,1396148400,1414296e3,1427598e3,1445745600,1459047600,14778e5,1490497200,1509249600,1521946800,1540699200,1554001200,1572148800,1585450800,1603598400,1616900400,1635652800,164835e4,1667102400,1679799600,1698552e3,1711854e3,1730001600,1743303600,1761451200,1774753200,1792900800,1806202800,1824955200,1837652400,1856404800,1869102e3,1887854400,1901156400,1919304e3,1932606e3],offset:[5989,5989,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Europe/Stockholm":{time:[-2871676800,-2208988800,-1692493200,-1680476400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],
offset:[4332,3614,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Copenhagen":{time:[-2524521600,-2398291200,-1692493200,-1680483600,-935107200,-85725e4,-844552800,-828219600,-812498400,-79677e4,-781048800,-769381200,-747007200,-736376400,-715212e3,-706741200,-683157600,-675291600,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[3020,3020,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Atlantic/Reykjavik":{
time:[-1956614400,-1668214800,-1647212400,-1636678800,-161343e4,-1605142800,-1581894e3,-1539565200,-153135e4,-968029200,-952293600,-942012e3,-920239200,-909961200,-888789600,-877906800,-857944800,-846457200,-826495200,-815007600,-795045600,-783558e3,-762991200,-752108400,-731541600,-717634800,-700092e3,-686185200,-668642400,-654735600,-636588e3,-623286e3,-605743200,-591836400,-573688800,-559782e3,-542239200,-528332400,-510789600,-496882800,-47934e4,-465433200,-447890400,-433983600,-415836e3,-401929200,-384386400,-370479600,-352936800,-33903e4,-321487200,-307580400,-290037600,-276130800,-258588e3,-244681200,-226533600,-212626800,-195084e3,-181177200,-163634400,-149727600,-132184800,-118278e3,-100735200,-86828400,-68680800,-54774e3,1924992e3],offset:[-5280,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0]},"Europe/Tallinn":{time:[-2840140800,-1638316800,-1632002400,-1618693200,-1593820800,-1535932800,-927936e3,-892944e3,-85725e4,-844552800,-828219600,-812498400,-797644800,354931200,370742400,386467200,402278400,418003200,433814400,449625600,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909288e3,92259e4,941342400,1017543600,1035691200,1048993200,1067140800,1080442800,1099195200,1111892400,1130644800,1143342e3,1162094400,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301194800,1319947200,1332644400,1351396800,1364698800,1382846400,1396148400,1414296e3,1427598e3,1445745600,1459047600,14778e5,1490497200,1509249600,1521946800,1540699200,1554001200,1572148800,1585450800,1603598400,1616900400,1635652800,164835e4,1667102400,1679799600,1698552e3,1711854e3,1730001600,1743303600,1761451200,1774753200,1792900800,1806202800,1824955200,1837652400,1856404800,1869102e3,1887854400,1901156400,1919304e3,1932606e3],offset:[5940,5940,3600,7200,3600,5940,7200,10800,7200,3600,7200,3600,7200,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Europe/Riga":{
time:[-2840140800,-1632002400,-1618693200,-1601676e3,-1597266e3,-1377302400,-928022400,-899510400,-85725e4,-844552800,-828219600,-812498400,-79677e4,-795830400,354931200,370742400,386467200,402278400,418003200,433814400,449625600,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,843966e3,859690800,877838400,891140400,909288e3,92259e4,941342400,985489200,1004241600,1017543600,1035691200,1048993200,1067140800,1080442800,1099195200,1111892400,1130644800,1143342e3,1162094400,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301194800,1319947200,1332644400,1351396800,1364698800,1382846400,1396148400,1414296e3,1427598e3,1445745600,1459047600,14778e5,1490497200,1509249600,1521946800,1540699200,1554001200,1572148800,1585450800,1603598400,1616900400,1635652800,164835e4,1667102400,1679799600,1698552e3,1711854e3,1730001600,1743303600,1761451200,1774753200,1792900800,1806202800,1824955200,1837652400,1856404800,1869102e3,1887854400,1901156400,1919304e3,1932606e3],offset:[5794,5794,9394,5794,9394,5794,7200,10800,7200,3600,7200,3600,7200,3600,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"Europe/Vilnius":{time:[-2840140800,-1672531200,-1585094400,-1561248e3,-1553558400,-928195200,-900115200,-85725e4,-844552800,-828219600,-812498400,-802137600,354931200,370742400,386467200,402278400,418003200,433814400,449625600,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891140400,909284400,922586400,941338800,1048993200,1067140800,1080442800,1099195200,1111892400,1130644800,1143342e3,1162094400,1174791600,1193544e3,1206846e3,1224993600,1238295600,1256443200,1269745200,1288497600,1301194800,1319947200,1332644400,1351396800,1364698800,1382846400,1396148400,1414296e3,1427598e3,1445745600,1459047600,14778e5,1490497200,1509249600,1521946800,1540699200,1554001200,1572148800,1585450800,1603598400,1616900400,1635652800,164835e4,1667102400,1679799600,1698552e3,1711854e3,1730001600,1743303600,1761451200,1774753200,1792900800,1806202800,1824955200,1837652400,1856404800,1869102e3,1887854400,1901156400,1919304e3,1932606e3],
offset:[6076,5040,5736,3600,7200,3600,10800,7200,3600,7200,3600,7200,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,14400,10800,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,7200,3600,7200,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200,10800,7200]},"America/Lima":{time:[-2524521600,-1938556800,-1009843200,-1002067200,-986774400,-971049600,-955324800,-9396e5,504921600,512697600,536457600,544233600,631152e3,638928e3,757382400,765158400,1924974e3],offset:[-18492,-18516,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3]},"America/Santiago":{time:[-2524521600,-1892678400,-1688428800,-1619222400,-1593820800,-1336003200,-13176e5,-1304380800,-1286064e3,-1272844800,-1254528e3,-1241308800,-1222992e3,-1209772800,-1191369600,-1178150400,-870566400,-865296e3,-740534400,-736646400,-718070400,-713667600,-36633600,-23932800,-3369600,7516800,24451200,37756800,55900800,69206400,87955200,100656e3,118195200,132105600,150854400,163555200,182304e3,195609600,213753600,227059200,245203200,258508800,277257600,289958400,308707200,321408e3,340156800,353462400,371606400,384912e3,403056e3,416361600,434505600,447811200,46656e4,479260800,498009600,510710400,529459200,545184e3,560908800,574214400,592358400,605664e3,624412800,637113600,653443200,668563200,687312e3,700617600,718761600,732067200,750211200,763516800,781660800,794966400,813715200,826416e3,845164800,85968e4,876614400,88992e4,906854400,923184e3,939513600,952819200,971568e3,984268800,1003017600,1015718400,1034467200,1047168e3,1065916800,1079222400,1097366400,1110672e3,1128816e3,1142121600,1160870400,1173571200,119232e4,1206835200,1223769600,1237075200,1255219200,1270339200,1286668800,1304812800,1313884800,1335657600,1346544e3,1367107200,1378598400,1398556800,1410048e3,1463270400,1471132800,149472e4,1502582400,1526169600,1534032e3,1554595200,1567900800,1586044800,1599350400,1617494400,16308e5,1648944e3,1662854400,1680393600,1693699200,1712448e3,1725753600,1743897600,1757203200,1775347200,1788652800,1806796800,1820102400,1838246400,1851552e3,1870300800,1883001600,1901750400,1915056e3,19332e5],
offset:[-16965,-16965,-18e3,-16965,-14400,-16965,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-18e3,-14400,-10800,-14400,-18e3,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800,-14400,-10800]},"Asia/Bahrain":{time:[-897868800,-820540800,76204800,1925002800],offset:[12140,12600,14400,10800]},"Asia/Jakarta":{time:[-3231273600,-1451693568,-117288e4,-876614400,-766022400,-683856e3,-620784e3,-189388800,1925017200],offset:[25632,25632,26400,27e3,32400,27e3,28800,27e3,25200]},"Africa/Lagos":{time:[-2035584e3,-1940889600,-1767225600,-1588464e3,1924995600],offset:[815,0,815,1800,3600]},"Pacific/Norfolk":{time:[-2177452800,-599616e3,152071200,162961200,1443924e3,1561939200,1570327200,1586055600,1601776800,1617505200,1633226400,1648954800,1664676e3,1680404400,1696125600,1712458800,172818e4,1743908400,1759629600,1775358e3,1791079200,1806807600,1822528800,1838257200,1853978400,1869706800,1886032800,1901761200,1917482400,1933210800],offset:[40312,40320,41400,45e3,41400,39600,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200,39600,43200]},"America/Juneau":{
time:[-3225169588,-2188987200,-880236e3,-769420800,-765410400,-21506400,-5781600,9943200,25668e3,41392800,57722400,73447200,89172e3,104896800,120621600,126669600,152071200,162352800,183520800,199245600,215575200,230695200,247024800,262749600,278474400,294199200,309924e3,325648800,341373600,357098400,372823200,388548e3,404877600,419997600,436327200,438998400,452052e3,467776800,483501600,499226400,514951200,530676e3,544586400,562125600,576036e3,59418e4,607485600,625629600,638935200,657079200,670989600,688528800,702439200,719978400,733888800,752032800,765338400,783482400,796788e3,814932e3,828842400,846381600,860292e3,877831200,891741600,909280800,923191200,941335200,954640800,972784800,986090400,1004234400,1018144800,1035684e3,1049594400,1067133600,1081044e3,1099188e3,1112493600,1130637600,1143943200,1162087200,1173578400,1194141600,1205028e3,1225591200,1236477600,1257040800,1268532e3,1289095200,1299981600,1320544800,1331431200,1351994400,1362880800,1383444e3,1394330400,1414893600,142578e4,1446343200,1457834400,1478397600,1489284e3,1509847200,1520733600,1541296800,1552183200,1572746400,1583632800,1604196e3,1615687200,1636250400,1647136800,16677e5,1678586400,1699149600,1710036e3,1730599200,1741485600,1762048800,1772935200,1793498400,1804989600,1825552800,1836439200,1857002400,1867888800,1888452e3,1899338400,1919901600,1930788e3],offset:[54139,-32261,-28800,-25200,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-25200,-28800,-28800,-28800,-25200,-28800,-25200,-28800,-25200,-32400,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400,-28800,-32400]},"Asia/Ho_Chi_Minh":{time:[-2004048e3,-1851552e3,-852080400,-782614800,-767836800,-718070400,-457743600,-315622800,171849600,1925017200],offset:[25590,25590,25200,28800,32400,25200,28800,25200,28800,25200]},"Australia/Perth":{time:[-2337897600,-1672524e3,-1665349200,-883605600,-876085200,-860364e3,-844635600,152071200,162961200,436327200,447217200,690343200,699418800,1165111200,1174791600,1193536800,1206846e3,1224986400,1238295600,1925020800],offset:[27804,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800,32400,28800]},"Europe/Malta":{
time:[-2403475200,-1690761600,-168048e4,-1664755200,-1648944e3,-163512e4,-1616889600,-1604275200,-1585526400,-1571011200,-1555286400,-932428800,-85725e4,-844552800,-828219600,-812584800,-798066e3,-781048800,-76671e4,-750895200,-733352400,-719452800,-70191e4,-689205600,-670453200,-114048e3,-103161600,-81993600,-71708400,-50544e3,-40258800,-18489600,-8204400,1296e4,23245200,43804800,54694800,75859200,86749200,102384e3,118112400,135734400,148525200,167191200,180496800,198640800,211946400,230090400,243396e3,26154e4,274845600,292989600,306295200,323316e3,338349600,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[3484,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Amsterdam":{
time:[-4260211200,-1693699200,-168048e4,-1663452e3,-1650142800,-1633212e3,-1617483600,-1601157600,-1586034e3,-1569708e3,-1554584400,-1538258400,-1523134800,-15075e5,-1490562e3,-1470175200,-1459112400,-1443996e3,-1427662800,-1406671200,-1396213200,-1376949600,-1364763600,-1345413600,-1333314e3,-1313791200,-1301259600,-1282255200,-126981e4,-1250719200,-1238360400,-1219183200,-1206910800,-1186956e3,-1175461200,-1156024800,-1143406800,-1124488800,-1111957200,-1092952800,-1080507600,-1061330400,-1049058e3,-1029189600,-1025740800,-1017608400,-998258400,-986158800,-966722400,-954104400,-935020800,-85725e4,-844552800,-828219600,-812498400,-79677e4,-781048800,-766616400,228880800,244004400,260330400,276058800,29178e4,307508400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[1172,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,1172,4772,4800,1200,4800,1200,4800,1200,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Brussels":{
time:[-2840140800,-2450994150,-1740355200,-1693699200,-1680476400,-1663452e3,-1650142800,-1632002400,-1618693200,-1613822400,-1604278800,-1585526400,-1574038800,-1552262400,-1539997200,-1520553600,-1507510800,-1490572800,-1473642e3,-1459123200,-1444006800,-1427673600,-1411952400,-1396224e3,-1379293200,-1364774400,-1348448400,-1333324800,-1316394e3,-1301259600,-1284328800,-126981e4,-1253484e3,-1238360400,-1221429600,-1206910800,-1191189600,-1175461200,-1160344800,-1143406800,-1127685600,-1111957200,-1096840800,-1080507600,-1063576800,-1049058e3,-1033336800,-1017608400,-1002492e3,-986158800,-969228e3,-950475600,-942012e3,-934664400,-85725e4,-844552800,-828219600,-812498400,-798066e3,-781048800,-766616400,-745452e3,-733266e3,228880800,244004400,260330400,276058800,29178e4,307508400,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[1050,1050,0,3600,7200,3600,7200,3600,7200,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Europe/Lisbon":{
time:[-1830386205,-1689555600,-1677798e3,-1667433600,-1647734400,-1635897600,-1616198400,-1604361600,-1584662400,-1572739200,-155304e4,-1541203200,-1521504e3,-1442451600,-1427673600,-1379293200,-1364774400,-1348448400,-1333324800,-1316394e3,-1301270400,-1284339600,-1269820800,-1221440400,-1206921600,-1191200400,-1175472e3,-1127696400,-1111968e3,-1096851600,-1080518400,-1063587600,-1049068800,-1033347600,-1017619200,-1002502800,-986169600,-969238800,-950486400,-942022800,-922492800,-906944400,-891129600,-877309200,-873680400,-864e6,-857952e3,-845859600,-842835600,-831340800,-825897600,-81441e4,-810781200,-799891200,-794448e3,-782960400,-779331600,-768441600,-762998400,-749091600,-733363200,-717631200,-701902800,-686181600,-670453200,-654732e3,-639003600,-623282400,-607554e3,-591832800,-575499600,-559778400,-54405e4,-528328800,-512600400,-496879200,-481150800,-465429600,-449701200,-43398e4,-417646800,-401925600,-386197200,-370476e3,-354747600,-339026400,-323298e3,-307576800,-291848400,-276127200,-260398800,-244677600,-228344400,-212623200,-196894800,-181173600,-165445200,-149724e3,-133995600,-118274400,-102546e3,212547600,228268800,243997200,260326800,276055200,291776400,307504800,323830800,338954400,354672e3,370400400,386121600,40185e4,417571200,433299600,449020800,465354e3,481075200,496803600,512528400,528256800,543978e3,559706400,575427600,591156e3,606877200,622605600,638326800,65466e4,670381200,686109600,701830800,717559200,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846381600,859683600,877831200,891133200,909280800,922582800,941335200,954032400,972784800,985482e3,1004234400,1017536400,1035684e3,1048986e3,1067133600,1080435600,1099188e3,1111885200,1130637600,1143334800,1162087200,1174784400,1193536800,1206838800,1224986400,1238288400,1256436e3,1269738e3,1288490400,1301187600,131994e4,1332637200,1351389600,1364691600,1382839200,1396141200,1414288800,1427590800,1445738400,1459040400,1477792800,149049e4,1509242400,1521939600,1540692e3,1553994e3,1572141600,1585443600,1603591200,1616893200,1635645600,1648342800,1667095200,1679792400,1698544800,1711846800,1729994400,1743296400,1761444e3,1774746e3,1792893600,1806195600,1824948e3,1837645200,1856397600,1869094800,1887847200,1901149200,1919296800,1932598800],offset:[-2205,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,7200,3600,0,3600,7200,3600,0,3600,7200,3600,0,3600,7200,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,3600,7200,3600,7200,3600,7200,3600,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0]},"Europe/Dublin":{
time:[-2821651200,-1691964e3,-1680469200,-1664143200,-1650142800,-1633903200,-1617483600,-1601848800,-1586034e3,-1570399200,-1552165200,-1538344800,-152253e4,-15075e5,-1490562e3,-1473631200,-1460926800,-1442786400,-1428872400,-1410732e3,-1396213200,-1379282400,-1364763600,-1348437600,-1333314e3,-1315778400,-1301259600,-1284328800,-126981e4,-1253484e3,-1238360400,-1221429600,-1206910800,-118998e4,-1175461200,-1159135200,-1143406800,-1126476e3,-1111957200,-1095631200,-1080507600,-1063576800,-1049058e3,-1032127200,-1017608400,-1001282400,-986158800,-969228e3,-950475600,-942012e3,-733352400,-719445600,-699483600,-684972e3,-668034e3,-654732e3,-636584400,-622072800,-605739600,-590623200,-57429e4,-558568800,-542235600,-527119200,-512600400,-496274400,-481150800,-46422e4,-449701200,-432165600,-417646800,-401320800,-386197200,-369266400,-354747600,-337816800,-323298e3,-306972e3,-291848400,-276732e3,-257979600,-245282400,-22653e4,-213228e3,-195080400,-182383200,-163630800,-150933600,-132181200,-119484e3,-100731600,-88034400,-68677200,-59004e3,57726e3,69818400,89175600,101268e3,120625200,132717600,152074800,164167200,183524400,196221600,214974e3,227671200,246423600,259120800,278478e3,290570400,309927600,32202e4,341377200,354675600,372823200,386125200,404272800,417574800,435722400,449024400,467776800,481078800,499226400,512528400,530676e3,543978e3,562125600,575427600,593575200,606877200,625629600,638326800,657079200,670381200,688528800,701830800,719978400,733280400,751428e3,76473e4,782877600,796179600,814327200,828234e3,846381600,859683600,877831200,891133200,909280800,922582800,941335200,954032400,972784800,985482e3,1004234400,1017536400,1035684e3,1048986e3,1067133600,1080435600,1099188e3,1111885200,1130637600,1143334800,1162087200,1174784400,1193536800,1206838800,1224986400,1238288400,1256436e3,1269738e3,1288490400,1301187600,131994e4,1332637200,1351389600,1364691600,1382839200,1396141200,1414288800,1427590800,1445738400,1459040400,1477792800,149049e4,1509242400,1521939600,1540692e3,1553994e3,1572141600,1585443600,1603591200,1616893200,1635645600,1648342800,1667095200,1679792400,1698544800,1711846800,1729994400,1743296400,1761444e3,1774746e3,1792893600,1806195600,1824948e3,1837645200,1856397600,1869094800,1887847200,1901149200,1919296800,1932598800],offset:[-1521,-1521,2079,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0,3600,0]},"Europe/Oslo":{
time:[-2366755200,-1691881200,-1680566400,-927507600,-85725e4,-844552800,-828219600,-812498400,-79677e4,-781048800,-765320400,-340840800,-324507600,-308786400,-293058e3,-277336800,-261608400,-245887200,-230158800,-214437600,-198709200,-182988e3,-166654800,-147909600,-135205200,323834400,338958e3,354679200,370407600,386128800,401857200,417578400,433306800,449028e3,465361200,481082400,496810800,512532e3,528260400,543981600,55971e4,575431200,591159600,606880800,622609200,638330400,654663600,670384800,686113200,701834400,717562800,733284e3,749012400,764733600,780462e3,796183200,811911600,828237600,846385200,859687200,877834800,891136800,909284400,922586400,941338800,954036e3,972788400,985485600,1004238e3,101754e4,1035687600,1048989600,1067137200,1080439200,1099191600,1111888800,1130641200,1143338400,1162090800,1174788e3,1193540400,1206842400,122499e4,1238292e3,1256439600,1269741600,1288494e3,1301191200,1319943600,1332640800,1351393200,1364695200,1382842800,1396144800,1414292400,1427594400,1445742e3,1459044e3,1477796400,1490493600,1509246e3,1521943200,1540695600,1553997600,1572145200,1585447200,1603594800,1616896800,1635649200,1648346400,1667098800,1679796e3,1698548400,1711850400,1729998e3,17433e5,1761447600,1774749600,1792897200,1806199200,1824951600,1837648800,1856401200,1869098400,1887850800,1901152800,1919300400,1932602400],offset:[2580,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600,7200,3600]},"Atlantic/Azores":{
time:[-2713910400,-1830383672,-1689555600,-1677798e3,-1667433600,-1647734400,-1635897600,-1616198400,-1604361600,-1584662400,-1572739200,-155304e4,-1541203200,-1521504e3,-1442451600,-1427673600,-1379293200,-1364774400,-1348448400,-1333324800,-1316394e3,-1301270400,-1284339600,-1269820800,-1221440400,-1206921600,-1191200400,-1175472e3,-1127696400,-1111968e3,-1096851600,-1080518400,-1063587600,-1049068800,-1033347600,-1017619200,-1002502800,-986169600,-969238800,-950486400,-942022800,-922492800,-906944400,-891129600,-877309200,-873680400,-864e6,-857952e3,-845859600,-842835600,-831340800,-825897600,-81441e4,-810781200,-799891200,-794448e3,-782960400,-779331600,-768441600,-762998400,-749091600,-733363200,-717631200,-701902800,-686181600,-670453200,-654732e3,-639003600,-623282400,-607554e3,-591832800,-575499600,-559778400,-54405e4,-528328800,-512600400,-496879200,-481150800,-465429600,-449701200,-43398e4,-417646800,-401925600,-386197200,-370476e3,-354747600,-339026400,-323298e3,-307576800,-291848400,-276127200,-260398800,-244677600,-228344400,-212623200,-196894800,-181173600,-165445200,-149724e3,-133995600,-118274400,-102546e3,386121600,40185e4,417571200,433299600,449020800,465354e3,481075200,496803600,512524800,528253200,543974400,559702800,575424e3,591152400,606873600,622602e3,638323200,654656400,670377600,686106e3,701827200,717555600,725418e3,733280400,740282400,749005200,764726400,780454800,796176e3,811904400,828230400,846378e3,85968e4,877827600,891129600,909277200,922579200,941331600,954028800,972781200,985478400,1004230800,1017532800,1035680400,1048982400,106713e4,1080432e3,1099184400,1111881600,1130634e3,1143331200,1162083600,1174780800,1193533200,1206835200,1224982800,1238284800,1256432400,1269734400,1288486800,1301184e3,1319936400,1332633600,1351386e3,1364688e3,1382835600,1396137600,1414285200,1427587200,1445734800,1459036800,1477789200,1490486400,1509238800,1521936e3,1540688400,1553990400,1572138e3,158544e4,1603587600,1616889600,1635642e3,1648339200,1667091600,1679788800,1698541200,1711843200,1729990800,1743292800,1761440400,1774742400,179289e4,1806192e3,1824944400,1837641600,1856394e3,1869091200,1887843600,1901145600,1919293200,1932595200],
offset:[-6160,-6872,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,0,-3600,-7200,-3600,0,-3600,-7200,-3600,0,-3600,-7200,-3600,0,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-7200,-3600,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600]},"Asia/Kabul":{time:[-2524521600,-788918400,1925008200],offset:[16608,14400,16200]}}},56616:(e,t,i)=>{"use strict";function s(){return navigator.clipboard}function o(e){return n(e,null)}function n(e,t){const i=e.files&&e.files.length>0;if(!i&&t&&t.eventPhase>0)return r(t,e),Promise.resolve();if(!i){let t=!1;const i=i=>{i.stopImmediatePropagation(),r(i,e),t=!0};try{document.addEventListener("copy",i,!0),document.execCommand("copy")}finally{document.removeEventListener("copy",i,!0)}if(t)return Promise.resolve()}return async function(e){const t=s();if(!t||!t.write||!window.ClipboardItem)throw new DOMException("ClipboardApi is not supported","NotSupportedError");const i={};for(const t of e.files||[])i[t.type]=t;e.text&&(i["text/plain"]=e.text);e.html&&(i["text/html"]=e.html);return t.write([new window.ClipboardItem(i)])}(e)}function r(e,t){e.preventDefault();const i=e.clipboardData;t.text&&i.setData("text/plain",t.text),t.html&&i.setData("text/html",t.html)}async function a(e,t){const i=s();if("text/plain"===t&&!i.write){const t=await e;return i.writeText(await t.text())}if(!i||!i.write||!window.ClipboardItem)throw new DOMException("ClipboardApi is not supported","NotSupportedError");let o=null;try{o=new window.ClipboardItem({[t]:e})}catch(i){o=new window.ClipboardItem({[t]:await e})}if(o)return i.write([o]);throw new Error("ClipboardApi is not supported")}i.d(t,{copyToClipboard:()=>o,getClipboard:()=>s,writeImpl:()=>n,writePromiseUsingApi:()=>a})},97725:(e,t,i)=>{"use strict";function s(e){return o(e,2)}function o(e,t=2){const i=e.toString();return"0".repeat(Math.max(0,t-i.length))+i}i.d(t,{addLeadingZero:()=>s,addLeadingZeros:()=>o})},16879:(e,t,i)=>{"use strict";i.d(t,{compareTwoCollectionsByIds:()=>y,indexOf:()=>f,intersect:()=>p,join:()=>m,lowerbound:()=>r,lowerboundExt:()=>n,lowerbound_int:()=>a,mapEntriesGenerator:()=>S,moveAfter:()=>u,moveBefore:()=>_,moveToHead:()=>d,nestedMapGenerator:()=>b,removeItemFromArray:()=>g,subtract:()=>h,sum:()=>v,upperbound:()=>l,upperbound_int:()=>c});var s=i(50151);function o(e,t){return e<t
}function n(e,t,i,s,o){let n=o-s;for(;0<n;){const o=n>>1,r=s+o;i(e(r),t)?(s=r+1,n-=o+1):n=o}return s}function r(e,t,i,s=0,o=e.length){return n((t=>e[t]),t,i,s,o)}function a(e,t,i=0,s=e.length){return r(e,t,o,i,s)}function l(e,t,i,s=0,o=e.length){let n=o-s;for(;0<n;){const o=n>>1,r=s+o;i(t,e[r])?n=o:(s=r+1,n-=o+1)}return s}function c(e,t,i=0,s=e.length){return l(e,t,o,i,s)}function h(e,t){return e.filter((e=>!t.includes(e)))}function d(e,t){const i=e.indexOf(t);return i<0?e.slice():[t].concat(e.slice(0,i)).concat(e.slice(i+1))}function u(e,t,i){const s=new Set(t),o=[],n=[],r=[];return e.forEach(((e,t)=>{s.has(e)?n.push(e):(o.push(e),r.push(t))})),i=i<e.length-1?a(r,i+1):o.length,o.splice(i,0,...n),{newItems:o,movedItemsStartIndex:i}}function _(e,t,i){const s=new Set(t),o=[],n=[],r=[];return e.forEach(((e,t)=>{s.has(e)?n.push(e):(o.push(e),r.push(t))})),i=i<=e.length-1?a(r,i):o.length,o.splice(i,0,...n),{newItems:o,movedItemsStartIndex:i}}function p(e,t){const i=new Set;return e.forEach((e=>{t.has(e)&&i.add(e)})),i}function m(e,t){const i=new Set(e);return t.forEach((e=>i.add(e))),i}function g(e,t){const i=e.indexOf(t);(0,s.assert)(-1!==i,"Item is not found"),e.splice(i,1)}function f(e,t){for(let i=0;i<e.length;i++)if(t(e[i]))return i;return-1}function y(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(e[i].id()!==t[i].id())return!1;return!0}function v(e){return e.reduce(((e,t)=>e+t),0)}function*S(e){for(const[t,i]of e)yield[t,i]}function*b(e,t){for(const[i,s]of e)if(void 0===t)for(const[,e]of s)yield[i,e];else{const e=s.get(t);void 0!==e&&(yield[i,e])}}},95406:(e,t,i)=>{"use strict";function s(e){if(!r(e))throw e}function o(e){return e?.aborted?Promise.reject(n()):new Promise(((t,i)=>{e?.addEventListener("abort",(()=>i(n())),{once:!0})}))}function n(){return new DOMException("Aborted","AbortError")}function r(e){return e instanceof Error&&"AbortError"===e.name||"object"==typeof e&&null!==e&&"name"in e&&"AbortError"===e.name}function a(e,t){return Promise.race([o(e),t])}async function l(e,t){let i;try{await a(e,new Promise((e=>{i=setTimeout(e,t)})))}finally{clearTimeout(i)}}i.d(t,{delay:()=>l,isAbortError:()=>r,respectAbort:()=>a,skipAbortError:()=>s})},4226:(e,t,i)=>{"use strict";i.d(t,{guid:()=>n,randomHash:()=>r,randomHashN:()=>a});const s="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",o="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function n(){return s.replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function r(){return a(12)}function a(e){let t="";for(let i=0;i<e;++i){const e=Math.floor(Math.random()*o.length);t+=o[e]}return t}},52499:(e,t,i)=>{"use strict";i.d(t,{WatchedObject:()=>o.WatchedObject,WatchedValue:()=>s.WatchedValue});var s=i(2072),o=i(59998)},77914:(e,t,i)=>{"use strict";function s(e,t,i){return Math.min(Math.max(e,t),i)}function o(e){return e<0?-1:e>0?1:0}function n(e){if(e<0)return!1;if(e>1e18)return!0;for(let t=e;t>1;t/=10)if(t%10!=0)return!1;return!0}function r(e,t,i){return t-e<=i}function a(e,t,i){return Math.abs(e-t)<i}
function l(e){return e<=0?NaN:Math.log(e)/Math.log(10)}function c(e,t){return e<t?-1:e>t?1:0}function h(e,t=c){if(e.length<1)throw Error("array is empty");let i=e[0];for(let s=0;s<e.length;++s)t(e[s],i)>0&&(i=e[s]);return i}function d(e){const t=Math.ceil(e);return t%2!=0?t-1:t}function u(e){return e>0?Math.floor(e):Math.ceil(e)}function _(e){return e%2==0}i.d(t,{ceiledEven:()=>d,clamp:()=>s,equal:()=>a,greaterOrEqual:()=>r,isBaseDecimal:()=>n,isEven:()=>_,log10:()=>l,max:()=>h,sign:()=>o,toInt:()=>u})},87465:(e,t,i)=>{"use strict";function s(e){return"number"==typeof e&&isFinite(e)}function o(e){if(!e||"object"!=typeof e)return e;let t;t=Array.isArray(e)?[]:{};for(const i in e)if(e.hasOwnProperty(i)){const s=e[i];t[i]=s&&"object"==typeof s?o(s):s}return t}function n(e,t){for(const i in t)null!==t[i]&&"object"==typeof t[i]&&e.hasOwnProperty(i)?n(e[i],t[i]):e[i]=t[i];return e}function r(e){return"object"==typeof e&&null!==e}function a(e){return null!=e&&(e.constructor===Function||"[object Function]"===Object.prototype.toString.call(e))}function l(e,t,i=""){if(e===t)return[!0,i];if(a(e)&&(e=void 0),a(t)&&(t=void 0),null==e||null==t)return[e===t,i];if("object"!=typeof e&&"object"!=typeof t)return[e===t,i];if(Array.isArray(e)&&Array.isArray(t)){const s=e.length;if(s!==t.length)return[!1,i];for(let o=0;o<s;o++){const s=l(e[o],t[o],i+"["+o+"]");if(!s[0])return s}return[!0,i]}if(Array.isArray(e)||Array.isArray(t))return[!1,i];if(Object.keys(e).length!==Object.keys(t).length)return[!1,i];for(const s in e){const o=l(e[s],t[s],i+"["+s+"]");if(!o[0])return o}return[!0,i]}i.r(t),i.d(t,{clone:()=>o,declareClassAsPureInterface:()=>v,deepEquals:()=>l,inherit:()=>y,isAbsent:()=>u,isArray:()=>c,isExistent:()=>_,isFunction:()=>a,isHashObject:()=>h,isInteger:()=>m,isNaN:()=>d,isNumber:()=>s,isObject:()=>r,isPromise:()=>f,isSameType:()=>p,isString:()=>g,merge:()=>n,notNull:()=>b,notUndefined:()=>w,requireFullInterfaceImplementation:()=>S});const c=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function h(e){return r(e)&&-1!==e.constructor.toString().indexOf("function Object")}function d(e){return!(e<=0||e>0)}function u(e){return null==e}function _(e){return null!=e}function p(e,t){return Number.isNaN(e)||Number.isNaN(t)?Number.isNaN(e)===Number.isNaN(t):{}.toString.call(e)==={}.toString.call(t)}function m(e){return"number"==typeof e&&e%1==0}function g(e){return null!=e&&e.constructor===String}function f(e){return r(e)&&"then"in e&&a(e.then)}function y(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function v(e,t){for(const i in e.prototype)"function"==typeof e.prototype[i]&&e.prototype.hasOwnProperty(i)&&(e.prototype[i]=function(){throw new Error(t+"::"+i+" is an interface member declaration and must be overloaded in order to be called")})}function S(e,t,i,s){
for(const o in i.prototype)if("function"==typeof i.prototype[o]&&!e.prototype[o])throw new Error("Interface implementation assertion failed: "+t+" does not implement "+s+"::"+o+" function")}function b(e){return null!==e}function w(e){return void 0!==e}Number.isNaN=Number.isNaN||function(e){return e!=e}},59998:(e,t,i)=>{"use strict";i.d(t,{WatchedObject:()=>r});var s=i(87465),o=i(2072);function n(e,t){return(0,s.deepEquals)(e,t)[0]}class r extends o.WatchedValue{constructor(e,t=n){super(e),this._comparator=t}setValue(e,t){!t&&this._comparator(this.value(),e)||super.setValue(e,t)}}},2072:(e,t,i)=>{"use strict";i.d(t,{WatchedValue:()=>n});const s=(0,i(9343).getLogger)("Common.WatchedValue");function o(e){s.logError(`${e&&(e.stack||e.message)}`)}class n{constructor(...e){this._listeners=[],e.length>0?this._value=e[0]:delete this._value}destroy(){this.unsubscribe()}value(){return this._owner?this._owner._value:this._value}setValue(e,t){const i=this._owner?this._owner:this;if(i.writeLock)return;const s=i._value===e||Number.isNaN(i._value)&&Number.isNaN(e);if(!t&&s&&i.hasOwnProperty("_value"))return;i._value=e;const n=i._listeners.slice();let r=0;for(let t=0;t<n.length;t++){n[t].once&&(i._listeners.splice(t-r,1),r++);try{n[t].cb(e)}catch(e){o(e)}}}deleteValue(){this.setValue(void 0)}subscribe(e,t){if("function"!=typeof e)throw new TypeError("callback must be a function");const i=!!t&&!!t.once,s=!!t&&!!t.callWithLast,n=this._owner?this._owner:this;if(s&&n.hasOwnProperty("_value")){try{e(n._value)}catch(e){o(e)}if(i)return}n._listeners.push({cb:e,owner:this,once:!!t&&!!t.once})}unsubscribe(e){const t=this._owner?this._owner:this;void 0===e&&(e=null);const i=t._listeners;for(let s=i.length;s--;)i[s].owner!==this&&t!==this||i[s].cb!==e&&null!==e||i.splice(s,1)}readonly(){if(this._readonlyInstance)return this._readonlyInstance;const e={subscribe:this.subscribe.bind(this),unsubscribe:this.unsubscribe.bind(this),value:this.value.bind(this),when:this.when.bind(this),ownership:this.ownership.bind(this),spawnOwnership:this.spawnOwnership.bind(this),weakReference:this.weakReference.bind(this),spawn:e=>this.spawn(e).readonly(),destroy:this.destroy.bind(this)};return this._readonlyInstance=e,e}spawn(e){return this._spawn(e)}when(e){!function(e,t,i){if(t(e.value()))return void i();const s=o=>{t(o)&&(e.unsubscribe(s),i())};e.subscribe(s,{callWithLast:!0})}(this,(e=>Boolean(e)),(()=>{try{e(this.value())}catch(e){o(e)}}))}assertNoSubscriptions(){0}ownership(){return this}release(){this.destroy()}spawnOwnership(){return this._spawn()}weakReference(){return this._spawn(void 0,!0)}_spawn(e,t){return new r(this._owner||this,e,t)}}class r extends n{constructor(e,t,i){super(),delete this._listeners,this._owner=e,this._onDestroy=t,this._weakReference=!!i}destroy(){try{this._onDestroy?.()}catch(e){o(e)}super.destroy()}readonly(){return this._readonlySpawnInstance||(this._readonlySpawnInstance={...super.readonly(),destroy:()=>this.destroy(),readonly(){return this}}),this._readonlySpawnInstance}release(){this._weakReference||super.release()}}},
93132:(e,t,i)=>{"use strict";i.d(t,{ActionGroup:()=>o});class s{constructor(e,t){this._group=e;const{hotkey:i,handler:s,desc:o,isDisabled:n,element:r=null,isRepeatAccepted:a=!1}=t;this.hotkey=i,this.handler=s,this.desc=o,this.element=r,this.isRepeatAccepted=a,this.isDisabled=n?"function"==typeof n?n:()=>!0:()=>!1}destroy(){this._group&&(this._group.remove(this),this._group=null)}}class o{constructor(e,t){this._actions=new Map,this._manager=e,this.order=t?.order??0,this.modal=!(!t||!t.modal),t&&(this.desc=t.desc),t&&t.isDisabled?"function"==typeof t.isDisabled?this.isDisabled=t.isDisabled:this.isDisabled=()=>!0:this.isDisabled=()=>!1,this._manager.registerGroup(this)}add(e){let t=this._actions.get(e.hotkey);t||(t=[],this._actions.set(e.hotkey,t));const i=new s(this,e);return t.push(i),i}remove(e){const t=this._actions.get(e.hotkey);if(!t)return;const i=t.findIndex((t=>t===e));i>=0&&(1===t.length?this._actions.delete(e.hotkey):t.splice(i,1))}handleHotkey(e,t){const i=this._actions.get(e);if(!i)return!1;for(const s of i)if((!s.element||t.target&&s.element.contains(t.target))&&!s.isDisabled(t))return t.repeat&&!s.isRepeatAccepted||(s.handler(t),this._callMatchedHotkeyHandler(e)),t.preventDefault(),!0;return!1}promote(){this._manager.promoteGroup(this)}destroy(){for(const[,e]of this._actions)for(const t of e)t.destroy();this._actions.clear(),this._manager.unregisterGroup(this)}static setMatchedHotkeyHandler(e){o._matchedHotkeyHandler=e}_callMatchedHotkeyHandler(e){o._matchedHotkeyHandler&&o._matchedHotkeyHandler(e)}}},43222:(e,t,i)=>{"use strict";i.d(t,{ACTION_API_GROUP_ORDER:()=>_,createGroup:()=>p,keyboardPressedKeysState:()=>u,pressedKeys:()=>d,registerWindow:()=>m});var s=i(52499),o=i(3343),n=i(54717);class r{constructor(e,t){this.modifiers=e,this.code=t}altOrOptionCode(){return"AltLeft"===this.code||"AltRight"===this.code}controlOrMetaCode(){return o.isMacKeyboard?"MetaLeft"===this.code||"MetaRight"===this.code||"OSLeft"===this.code||"OSRight"===this.code:"ControlLeft"===this.code||"ControlRight"===this.code}}class a extends s.WatchedValue{setValue(e,t){const i=this.value();(t||void 0===i||i.code!==e.code||i.modifiers!==e.modifiers)&&super.setValue(e)}}function l(e,t){return e.order+(e.modal?t:0)}var c=i(93132);const h=new class{constructor(){this._groups=[],this._pressedKeys=new s.WatchedValue(0),this._keyboardPressedKeysState=new a(new r(0)),this._keyDownListener=e=>{if(e.defaultPrevented)return;const t=(0,o.hashFromEvent)(e);if(this._pressedKeys.setValue(t),this._keyboardPressedKeysState.setValue(new r((0,o.modifiersFromEvent)(e),e.code)),!(0,n.isNativeUIInteraction)(t,e.target))for(let i=this._groups.length;i-- >0;){const s=this._groups[i];if(!s.isDisabled()){if(s.handleHotkey(t,e))return;if(s.modal)return}}},this._keyUpListener=e=>{const t=(0,o.hashFromEvent)(e);this._pressedKeys.setValue(t),this._keyboardPressedKeysState.setValue(new r((0,o.modifiersFromEvent)(e),""))},this._blurEvent=()=>{this._pressedKeys.setValue(0),this._keyboardPressedKeysState.setValue(new r(0,""))},this._mouseEvent=e=>{const t=(0,
o.modifiersFromEvent)(e),i=255&(this._pressedKeys.value()??0);this._pressedKeys.setValue(t|i)}}listen(e){e.addEventListener("keydown",this._keyDownListener),e.addEventListener("keyup",this._keyUpListener),e.addEventListener("blur",this._blurEvent),e.addEventListener("mousemove",this._mouseEvent)}unlisten(e){e.removeEventListener("keydown",this._keyDownListener),e.removeEventListener("keyup",this._keyUpListener),e.removeEventListener("blur",this._blurEvent),e.removeEventListener("mousemove",this._mouseEvent)}registerGroup(e){this._groups.push(e),this.sortGroups()}unregisterGroup(e){for(let t=this._groups.length;t--;)this._groups[t]===e&&this._groups.splice(t,1)}promoteGroup(e){const t=this._getModalOrderEpoch(),i=l(e,t);let s=this._groups.findIndex((e=>l(e,t)===i)),o=0;for(;s<this._groups.length&&l(this._groups[s],t)===i;){const n=this._groups[s];n===e?o=1:l(n,t)===i&&(this._groups[s-o]=n),s++}this._groups[s-o]=e}pressedKeys(){return this._pressedKeys.readonly()}keyboardPressedKeysState(){return this._keyboardPressedKeysState.readonly()}sortGroups(){const e=this._getModalOrderEpoch();this._groups.sort(((t,i)=>l(i,e)-l(t,e)))}_getMinOrder(){return this._groups.reduce(((e,t)=>Math.min(e,t.order)),0)}_getModalOrderEpoch(){return-2*(Math.abs(this._getMinOrder())-1)}},d=h.pressedKeys(),u=h.keyboardPressedKeysState(),_=-100;function p(e){return new c.ActionGroup(h,e)}function m(e){h.listen(e)}},3343:(e,t,i)=>{"use strict";i.d(t,{Modifiers:()=>r,hashFromEvent:()=>l,humanReadableHash:()=>u,humanReadableModifiers:()=>c,isMacKeyboard:()=>n,modifiersFromEvent:()=>a});var s,o=i(75774);!function(e){e[e.KeyCode=255]="KeyCode",e[e.Control=256]="Control",e[e.Alt=512]="Alt",e[e.Shift=1024]="Shift",e[e.Meta=2048]="Meta"}(s||(s={}));const n=o.isMac||o.isIOS;var r;function a(e){let t=0;return e.shiftKey&&(t+=1024),e.altKey&&(t+=512),e.ctrlKey&&(t+=256),e.metaKey&&(t+=2048),t}function l(e){return a(e)|e.keyCode}!function(e){e[e.None=0]="None",e[e.Alt=512]="Alt",e[e.Shift=1024]="Shift",e[e.Mod=n?2048:256]="Mod",e[e.Control=256]="Control",e[e.Meta=2048]="Meta"}(r||(r={}));function c(e,t=!n){let i="";return 256&e&&(i+=_(n?"^":"Ctrl",t)),512&e&&(i+=_(n?"⌥":"Alt",t)),1024&e&&(i+=_(n?"⇧":"Shift",t)),2048&e&&(i+=_(n?"⌘":"Win",t)),i}const h={9:"⇥",13:"↵",27:"Esc",8:n?"⌫":"Backspace",32:"Space",35:"End",36:"Home",37:"←",38:"↑",39:"→",40:"↓",45:"Ins",46:"Del",188:",",191:"/"},d={9:"Tab",13:"Enter",27:"Esc",8:"Backspace",32:"Space",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Ins",46:"Del",188:",",191:"/"};for(let e=1;e<=16;e++)h[e+111]=`F${e}`,d[e+111]=`F${e}`;function u(e){let t=c(e);const i=255&e;return t+=i in h?h[i]:String.fromCharCode(i),t}function _(e,t){return`${e}${t?" + ":n?" ":""}`}},54717:(e,t,i)=>{"use strict";i.d(t,{isNativeUIInteraction:()=>n,isTextEditingField:()=>o});var s=i(3343);function o(e){if("INPUT"===e.tagName){const t=e.type;return"text"===t||"email"===t||"number"===t||"password"===t||"search"===t||"tel"===t||"url"===t}return"TEXTAREA"===e.tagName||e.isContentEditable}function n(e,t){
if(!t)return!1;const i=255&e;if(27===i||i>>>4==7)return!1;switch(e^i){case s.Modifiers.Alt:return(38===i||40===i)&&"SELECT"===t.tagName||o(t);case s.Modifiers.Alt+s.Modifiers.Shift:return o(t);case s.Modifiers.Mod:if(67===i||!s.isMacKeyboard&&45===i){const e=t.ownerDocument&&t.ownerDocument.getSelection();if(e&&!e.isCollapsed)return!0}return o(t);case s.Modifiers.Mod+s.Modifiers.Shift:return i>=33&&i<=40&&o(t);case s.Modifiers.Shift:case 0:return 9===i?!(!t.ownerDocument||t===t.ownerDocument.body||t===t.ownerDocument.documentElement):(!function(e){if("BUTTON"===e.tagName)return!0;if("INPUT"===e.tagName){const t=e.type;if("submit"===t||"button"===t||"reset"===t||"checkbox"===t||"radio"===t)return!0}return!1}(t)||13===i||32===i||9===i)&&("form"in t||t.isContentEditable)}return!1}},89880:(e,t,i)=>{"use strict";i.d(t,{t:()=>s});const s=i.i18next},58978:(e,t,i)=>{"use strict";i.d(t,{colorsPalette:()=>d,getHexColorByName:()=>u});var s=i(30714)
;const o=JSON.parse('{"color-header-bg":"color-white","color-body-bg":"color-white","color-body-secondary-bg":"color-cold-gray-100","color-bg-primary":"color-white","color-bg-primary-hover":"color-cold-gray-100","color-bg-secondary":"color-white","color-bg-highlight":"color-cold-gray-50","color-bg-scroll-buttons":"color-cold-gray-100","color-legacy-bg-scroll-buttons":"color-cold-gray-850","color-legacy-bg-widget":"color-white","color-text-primary":"color-cold-gray-900","color-text-secondary":"color-cold-gray-550","color-text-tertiary":"color-cold-gray-400","color-text-disabled":"color-cold-gray-300","color-accent-content":"color-cold-gray-900","color-box-shadow":"color-cold-gray-300","color-divider":"color-cold-gray-150","color-divider-hover":"color-cold-gray-100","color-divider-secondary":"color-cold-gray-100","color-active-hover-text":"color-cold-gray-900","color-alert-text":"color-cold-gray-900","color-border-table":"color-cold-gray-100","color-brand":"color-tv-blue-500","color-brand-active":"color-tv-blue-700","color-brand-hover":"color-tv-blue-600","color-chart-page-bg":"color-cold-gray-150","color-common-tooltip-bg":"color-cold-gray-800","color-danger":"color-ripe-red-400","color-danger-hover":"color-ripe-red-500","color-danger-active":"color-ripe-red-600","color-depthrenderer-stroke-style":"color-cold-gray-100","color-halal":"color-iguana-green-400","color-continuous":"color-cold-gray-500","color-tv-calculated-pair":"color-grapes-purple-400","color-highlight-new":"color-tan-orange-50","color-input-bg":"color-white","color-input-publish-bg":"color-white","color-link":"color-tv-blue-500","color-link-hover":"color-tv-blue-600","color-link-active":"color-tv-blue-700","color-list-nth-child-bg":"color-cold-gray-50","color-pane-bg":"color-white","color-pane-secondary-bg":"color-cold-gray-100","color-popup-menu-item-hover-bg":"color-cold-gray-100","color-popup-menu-separator":"color-cold-gray-150","color-primary-symbol":"color-sky-blue-500","color-screener-description":"color-cold-gray-650","color-success":"color-minty-green-500","color-success-hover":"color-minty-green-600","color-success-active":"color-minty-green-700","color-toolbar-button-text":"color-cold-gray-900","color-toolbar-button-text-hover":"color-cold-gray-900","color-toolbar-button-text-active":"color-tv-blue-500","color-toolbar-button-text-active-hover":"color-tv-blue-600","color-toolbar-button-background-hover":"color-cold-gray-100","color-toolbar-button-background-secondary-hover":"color-cold-gray-150","color-toolbar-button-background-active":"color-tv-blue-50","color-toolbar-button-background-active-hover":"color-tv-blue-100","color-toolbar-toggle-button-background-active":"color-tv-blue-500","color-toolbar-toggle-button-background-active-hover":"color-tv-blue-600","color-toolbar-toggle-button-icon":"color-cold-gray-200","color-toolbar-interactive-element-text-normal":"color-cold-gray-900","color-toolbar-opened-element-bg":"color-cold-gray-100","color-toolbar-divider-background":"color-cold-gray-150","color-popup-background":"color-white","color-popup-element-text":"color-cold-gray-900","color-popup-element-text-hover":"color-cold-gray-900","color-popup-element-background-hover":"color-cold-gray-100","color-popup-element-secondary-text":"color-cold-gray-500","color-popup-element-hint-text":"color-cold-gray-400","color-popup-element-text-active":"color-white","color-popup-element-background-active":"color-tv-blue-500","color-popup-element-toolbox-text":"color-cold-gray-500","color-popup-element-toolbox-text-hover":"color-cold-gray-900","color-popup-element-toolbox-text-active-hover":"color-tv-blue-200","color-popup-element-toolbox-background-hover":"color-cold-gray-150","color-popup-element-toolbox-background-active-hover":"color-tv-blue-700","color-tooltip-bg":"color-cold-gray-800","color-tv-dialog-caption":"color-cold-gray-650","color-tv-dropdown-item-hover-bg":"color-cold-gray-100","color-underlined-text":"color-cold-gray-550","color-widget-pages-bg":"color-white","color-warning":"color-tan-orange-500","color-growing":"color-minty-green-500","color-falling":"color-ripe-red-500","color-forex-icon":"color-cold-gray-750","color-list-item-active-bg":"color-tv-blue-400","color-list-item-hover-bg":"color-tv-blue-50","color-list-item-text":"color-cold-gray-800","color-price-axis-label-back":"color-cold-gray-150","color-price-axis-label-text":"color-cold-gray-650","color-price-axis-gear":"color-cold-gray-900","color-price-axis-gear-hover":"color-black","color-price-axis-highlight":"color-cold-gray-150","color-bid":"color-tv-blue-500","color-border":"color-cold-gray-150","color-border-chat-fields":"color-cold-gray-250","color-border-hover":"color-cold-gray-250","color-button-hover-bg":"color-cold-gray-150","color-depthrenderer-fill-style":"color-cold-gray-650","color-disabled-border-and-color":"color-cold-gray-150","color-disabled-input":"color-cold-gray-150","color-empty-container-message":"color-cold-gray-550","color-icons":"color-cold-gray-550","color-input-textarea-readonly":"color-cold-gray-650","color-input-placeholder-text":"color-cold-gray-350","color-item-active-blue":"color-tv-blue-50","color-item-hover-active-bg":"color-tv-blue-100","color-item-hover-bg":"color-tv-blue-100","color-item-hover-blue":"color-tv-blue-100","color-item-selected-blue":"color-tv-blue-50","color-item-active-text":"color-white","color-item-active-bg":"color-tv-blue-500","color-list-item":"color-cold-gray-550","color-news-highlight":"color-tv-blue-100","color-placeholder":"color-cold-gray-350","color-row-hover-active-bg":"color-cold-gray-100","color-sb-scrollbar-body-bg":"color-cold-gray-200","color-section-separator-border":"color-cold-gray-300","color-separator-table-chat":"color-cold-gray-150","color-tag-active-bg":"color-cold-gray-200","color-tag-hover-bg":"color-cold-gray-150","color-text-regular":"color-cold-gray-700","color-tv-button-checked":"color-cold-gray-550","color-scroll-bg":"color-cold-gray-400","color-scroll-border":"color-cold-gray-100","color-widget-border":"color-cold-gray-100","color-scroll-buttons-arrow":"color-white","color-control-intent-default":"color-cold-gray-200","color-control-intent-success":"color-minty-green-500","color-control-intent-primary":"color-tv-blue-500","color-control-intent-warning":"color-tan-orange-500","color-control-intent-danger":"color-ripe-red-500","color-goto-label-background":"color-cold-gray-800","color-pre-market":"color-tan-orange-600","color-pre-market-bg":"color-tan-orange-400","color-post-market":"color-tv-blue-500","color-post-market-bg":"color-tv-blue-400","color-market-open":"color-minty-green-500","color-market-open-bg":"color-minty-green-400","color-market-closed":"color-cold-gray-400","color-market-holiday":"color-cold-gray-400","color-market-expired":"color-ripe-red-500","color-invalid-symbol":"color-ripe-red-400","color-invalid-symbol-hover":"color-ripe-red-700","color-delisted-symbol":"color-ripe-red-600","color-delisted-symbol-hover":"color-ripe-red-800","color-replay-mode":"color-tv-blue-500","color-replay-mode-point-select":"color-cold-gray-350","color-replay-mode-icon":"color-white","color-replay-mode-hover":"color-tv-blue-600","color-notaccurate-mode":"color-berry-pink-600","color-delay-mode":"color-tan-orange-700","color-delay-mode-bg":"color-tan-orange-400","color-eod-mode":"color-grapes-purple-700","color-eod-mode-bg":"color-grapes-purple-400","color-data-problem":"color-ripe-red-600","color-data-problem-bg":"color-ripe-red-400","color-data-problem-hover":"color-ripe-red-700","color-list-item-bg-highlighted":"color-tv-blue-50","color-list-item-bg-selected":"color-tv-blue-100","color-list-item-bg-highlighted-hover":"color-tv-blue-100","color-list-item-bg-selected-hover":"color-tv-blue-200","color-screener-header-bg":"color-white","color-screener-header-bg-hover":"color-cold-gray-100","color-marker-flagged":"color-ripe-red-400","color-marker-flagged-hovered":"color-ripe-red-600","color-ask":"color-ripe-red-400","color-sell":"color-ripe-red-400","color-buy":"color-tv-blue-500","color-neutral":"color-cold-gray-550","color-pro":"color-minty-green-400","color-pro-hover":"color-minty-green-600","color-pro-plus":"color-tv-blue-500","color-pro-plus-hover":"color-tv-blue-600","color-pro-premium":"color-tan-orange-500","color-pro-premium-hover":"color-tan-orange-700","color-trial":"color-cold-gray-550","color-trial-hover":"color-cold-gray-550","color-mod":"color-ripe-red-400","color-mod-hover":"color-ripe-red-600","color-ad":"color-tan-orange-500","color-broker-featured":"color-minty-green-400","color-broker-featured-hover":"color-minty-green-600","color-alert-status-active":"color-minty-green-400","color-alert-status-stopped":"color-ripe-red-500","color-alert-status-triggered":"color-tan-orange-500","color-overlay":"color-cold-gray-400","color-search-button-hover":"color-cold-gray-150","color-boost-button-content-selected":"color-tv-blue-600","color-boost-button-content-hover":"color-cold-gray-900","color-boost-button-bg-hover":"color-cold-gray-150","color-boost-button-border-hover":"color-cold-gray-150","color-boost-button-border-default":"color-cold-gray-150","color-common-tooltip-text":"color-cold-gray-100","color-replay-data-mode":"color-ripe-red-400","color-legacy-success":"color-minty-green-300","color-collapse-tabs-border":"color-cold-gray-100","color-site-widget-hover":"color-cold-gray-50","color-attention":"color-banana-yellow-700","color-x-twitter-content":"color-cold-gray-900","color-card-border":"color-cold-gray-150","color-card-border-hover":"color-cold-gray-300","color-background-special-primary":"color-white","color-stroke-special-primary":"color-cold-gray-150","color-selection-bg":"color-tv-blue-100","color-default-gray":"color-cold-gray-550","color-featured-broker-badge-bg":"color-cold-gray-900","color-featured-broker-badge-bg-hover":"color-cold-gray-800","color-featured-broker-badge-text":"color-white"}')
;var n=i(50151);const r={...s,...o},a={},l=Object.keys(r).length,c=/^#(([a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i;function h(e,t=[],i=r){const s=i[e];if(!s)return null;if(c.test(s))return s;const o=s;return t.push(e),-1!==t.indexOf(o)?(console.warn("Colors definitions cycled"),s):t.length>l?(console.warn("Too many variables-link in HEX-color search: "+t[0]),null):h(o,t,i)}Object.keys(r).forEach((e=>{const t=h(e);a[e]=(0,n.ensureNotNull)(t)}));const d=a;function u(e,t=d){const i=t[e];if(!i){if(c.test(e))return e;throw new Error("No such color "+e)}return i}},74991:(e,t,i)=>{"use strict";i.d(t,{CubicBezier:()=>n,dur:()=>s,easingFunc:()=>o});const s=350,o={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1- --e*e*e*e,easeInOutQuart:e=>e<.5?8*e*e*e*e:1-8*--e*e*e*e,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1+--e*e*e*e*e,easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e};class n{constructor(e,t,i,s){this._mX1=e,this._mY1=t,this._mX2=i,this._mY2=s}easingFunc(e){return this._mX1===this._mY1&&this._mX2===this._mY2?e:this._calcBezier(this._getTForX(e))}_a(e,t){return 1-3*t+3*e}_b(e,t){return 3*t-6*e}_c(e){return 3*e}_calcBezier(e){return((this._a(this._mY1,this._mY2)*e+this._b(this._mY1,this._mY2))*e+this._c(this._mY1))*e}_getSlope(e){return 3*this._a(this._mX1,this._mX2)*e*e+2*this._b(this._mX1,this._mX2)*e+this._c(this._mX1)}_getTForX(e){let t=e;for(let i=0;i<4;++i){const i=this._getSlope(t);if(0===i)return t;t-=(this._calcBezier(t)-e)/i}return t}}},58096:(e,t,i)=>{"use strict";i.d(t,{DEFAULT_SIZE:()=>s,spinnerSizeMap:()=>o});const s="large",o={mini:"xsmall",xxsmall:"xxsmall",xsmall:"xsmall",small:"small",medium:"medium",large:"large"}},34811:(e,t,i)=>{"use strict";i.d(t,{FOCUS_TRAP_DATA_ATTRIBUTE:()=>s});const s="data-focus-trap"},15754:(e,t,i)=>{"use strict";i.d(t,{FOCUSABLE_SELECTOR:()=>o,createScopedVisibleElementFilter:()=>h,getActiveElementSelectors:()=>c,isInertRoot:()=>a,isVisibilityVisible:()=>n});const s=["button","fieldset","optgroup","option","select","textarea","input"],o=["button","input","select","textarea","a[href]","audio[controls]","video[controls]",'[tabindex="0"]','[contenteditable="true"]'].map((e=>s.includes(e)?`${e}:not(:disabled)`:e)).map((e=>`${e}:not([tabindex="-1"])`)).join(",");function n(e){return"visible"===getComputedStyle(e).visibility}function r(e,t){if(e.matches("[inert],[inert] *"))return!0;let i=e;for(;i!==t&&null!==i;){if(l(i))return!0;i=i.parentElement}return!1}function a(e){return e.matches("[inert]")||l(e)}function l(e){return"none"===getComputedStyle(e).display}function c(){return o}function h(e){return t=>n(t)&&!r(t,e)}},76460:(e,t,i)=>{"use strict";function s(e){return 0===e.detail}i.d(t,{isKeyboardClick:()=>s})},91682:(e,t,i)=>{"use strict";i.d(t,{capitalizeFirstLetterInWord:()=>u,decodeHTMLEntities:()=>l,getFirstSegmentOrCodePointString:()=>_,htmlEscape:()=>c,removeSpaces:()=>d,removeTags:()=>h})
;const s=/[<"'&>]/g,o=e=>`&#${e.charCodeAt(0)};`,n={"&lt;":"<","&gt;":">","&quot;":'"',"&apos;":"'","&amp;":"&","&#60;":"<","&#62;":">","&#34;":'"',"&#39;":"'","&#039;":"'","&#38;":"&"},r=Object.assign({},...Object.entries(n).map((([e,t])=>({[t]:e})))),a=new RegExp(Object.keys(n).join("|"),"g");new RegExp(Object.keys(r).join("|"),"g");function l(e){return e.replace(a,(e=>n[e]||e))}function c(e){return e.replace(s,o)}function h(e=""){return e.replace(/(<([^>]+)>)/gi,"")}function d(e=""){return e.replace(/\s+/g,"")}function u(e=""){return e.replace(/\b\w/g,(e=>e.toUpperCase()))}function _(e){const t=Intl.Segmenter;if(t){const i=new t(void 0,{granularity:"grapheme"}),[{segment:s}={segment:null}]=i.segment(e);return s?.toUpperCase()??null}{const t=e.codePointAt(0);return t?String.fromCodePoint(t).toUpperCase():null}}},30947:(e,t,i)=>{"use strict";i.r(t),i.d(t,{QUOTE_FIELDS:()=>n,QUOTE_FIELDS_CACHE:()=>r,QuoteCache:()=>o});var s=i(50151);class o{constructor(e){this._cache=new Map,this._times=new Map,this._fields=[...e.fields]}update(e,t,i){const o=(0,s.ensureDefined)(e.symbolname),n=Date.now();if(this._cache.has(o)||this._cache.set(o,{symbolname:o,status:e.status,values:{}}),this._times.has(o)||this._times.set(o,new Map),"error"===e.status)return;const r=(0,s.ensureDefined)(this._cache.get(o)),a=(0,s.ensureDefined)(this._times.get(o));r.status=e.status;for(const s of this._fields)t.has(s)&&(i||void 0!==e.values[s])&&(r.values[s]=e.values[s],a.set(s,n))}get(e){return this._cache.get(e)??null}getTimes(e){return this._times.get(e)??null}fields(){return this._fields}}
const n=new Set(["pro_name","base_name","logoid","currency-logoid","base-currency-logoid","source-logoid","short_name","web_site_url","pro_perm","timezone","current_session","last_price","lp_time","subsessions","prev_close_price","open_price","high_price","low_price","price_52_week_high","price_52_week_low","ask","ask_size","bid","bid_size","rch","rchp","rtc","rtc_time","data_frequency","reference-last-period-start","business_description","web_site_url","figi","number_of_employees","float_shares_outstanding","earnings_release_next_calendar_date","root","description","exchange","listed_exchange","type","country_code","provider_id","sector","typespecs","visible-plots-set","industry","currency_id","last_price","fractional","minmov","minmove2","pricescale","variable_tick_size","change","change_percent","volume","average_volume","market_cap_basic","market_cap_calc","total_revenue","earnings_per_share_basic_ttm","price_earnings_ttm","beta_1_year","dps_common_stock_prim_issue_fy","dividends_yield","earnings_release_next_date","earnings_per_share_forecast_next_fq","earnings_publication_type_next_fq","earnings_release_date","earnings_per_share_fq","earnings_per_share_forecast_fq","forecast_raw","last_release_date","next_release_date","reference_last_period","fundamental_currency_code","number_of_employees","web_site_url","business_description","founded","ceo","float_shares_outstanding","total_shares_outstanding","dividend_payout_ratio_ttm","dividends_yield_current","dividend_ex_date_upcoming","dividend_amount_upcoming","dividend_amount_recent","dividend_ex_date_recent","dividend_amount_h","dividend_payment_date_upcoming","dividend_payment_date_recent","total_revenue_fq_h","total_revenue_fy_h","net_income_fy_h","net_income_fq_h","total_assets_fy_h","total_assets_fq_h","total_liabilities_fy_h","total_liabilities_fq_h","cash_f_operating_activities_fy_h","cash_f_operating_activities_fq_h","cash_f_investing_activities_fy_h","cash_f_investing_activities_fq_h","cash_f_financing_activities_fy_h","cash_f_financing_activities_fq_h","fiscal_period_fy_h","fiscal_period_fq_h","fiscal_period_fh_h","earnings_release_date_fq_h","earnings_release_next_date_fq","earnings_per_share_forecast_next_fq","earnings_per_share_forecast_fq_h","earnings_per_share_fq_h","earnings_fiscal_period_fq_h","next_earnings_fiscal_period_fq","is_next_earnings_release_date_estimated","symbol-primaryname","currency_code","rates_mc","rates_fy","rates_ttm","measure","value_unit_id","value-unit-id","update_mode","language","local_description","short_description","source","source2","format","recommendation_mark","last_report_frequency","price_target_estimates_num","price_target_average","update_mode_seconds","recommendation_total","recommendation_buy","recommendation_over","recommendation_hold","recommendation_under","recommendation_sell","recommendation_total","price_target_high","price_target_low","rates_pt","rates_pt","total_revenue_fy_h","total_revenue_fq_h","total_revenue_fh_h","net_income_fy_h","net_income_fq_h","net_income_fh_h","total_assets_fy_h","total_assets_fq_h","total_assets_fh_h","total_liabilities_fy_h","total_liabilities_fq_h","total_liabilities_fh_h","cash_f_operating_activities_fy_h","cash_f_operating_activities_fq_h","cash_f_operating_activities_fh_h","cash_f_investing_activities_fy_h","cash_f_investing_activities_fq_h","cash_f_investing_activities_fh_h","cash_f_financing_activities_fy_h","cash_f_financing_activities_fq_h","cash_f_financing_activities_fh_h","fiscal_period_fy","fiscal_period_fq","fiscal_period_fh","earnings_release_date_fq_h","earnings_release_date_fy_h","earnings_release_date_fh_h","earnings_release_next_date_fq","earnings_release_next_date_fy","earnings_release_next_date_fh","earnings_release_next_time","earnings_release_time","is_next_earnings_release_date_estimated","earnings_per_share_forecast_next_fq","earnings_per_share_forecast_next_fy","earnings_per_share_forecast_next_fh","earnings_per_share_forecast_fq_h","earnings_per_share_forecast_fy_h","earnings_per_share_forecast_fh_h","earnings_per_share_fq_h","earnings_per_share_fy_h","earnings_per_share_fh_h","earnings_fiscal_period_fq_h","earnings_fiscal_period_fy_h","earnings_fiscal_period_fh_h","next_earnings_fiscal_period_fq","next_earnings_fiscal_period_fy","next_earnings_fiscal_period_fh","revenue_fq_h","revenue_fy_h","revenue_fh_h","revenue_forecast_fq_h","revenue_forecast_fy_h","revenue_forecast_fh_h","revenue_forecast_next_fq","revenue_forecast_next_fy","revenue_forecast_next_fh","revenue_seg_by_business_h","revenue_seg_by_region_h","total_revenue_fy","total_revenue_fq","total_revenue_fh","gross_profit_fy","gross_profit_fq","gross_profit_fh","ebitda_fy","ebit_fy","net_income_fy","net_income_fq","net_income_fh","total_debt_fy_h","total_debt_fq_h","total_debt_fh_h","free_cash_flow_fy_h","free_cash_flow_fq_h","free_cash_flow_fh_h","cash_n_equivalents_fy_h","cash_n_equivalents_fq_h","cash_n_equivalents_fh_h","total_current_assets_fy","total_current_assets_fq","total_current_assets_fh","total_current_liabilities_fy","total_current_liabilities_fq","total_current_liabilities_fh","total_non_current_assets_fy","total_non_current_assets_fq","total_non_current_assets_fh","total_non_current_liabilities_fy","total_non_current_liabilities_fq","total_non_current_liabilities_fh","loans_net_fy","loans_net_fy_h","loans_net_fq_h","loans_net_fh_h","total_deposits_fy","total_deposits_fy_h","total_deposits_fq_h","total_deposits_fh_h","loan_loss_allowances_fy","loan_loss_allowances_fy_h","loan_loss_allowances_fq_h","loan_loss_allowances_fh_h","reserve_to_total_capital_fy_h","reserve_to_total_capital_fq_h","reserve_to_total_capital_fh_h","unearned_premium_to_total_capital_fy_h","unearned_premium_to_total_capital_fq_h","unearned_premium_to_total_capital_fh_h","insurance_reserves_fy_h","insurance_reserves_fq_h","insurance_reserves_fh_h","policy_claims_fy_h","policy_claims_fq_h","policy_claims_fh_h","premiums_earned_fy_h","premiums_earned_fq_h","premiums_earned_fh_h","price_earnings_fq_h","price_earnings_fy_h","price_earnings_fh_h","price_sales_fq_h","price_sales_fy_h","price_sales_fh_h","diluted_net_income_ttm","total_revenue_ttm","price_earnings_current","price_sales_current","isin-displayed","interest_income_fy_h","interest_income_fq_h","interest_income_fh_h","non_interest_income_fy_h","non_interest_income_fq_h","non_interest_income_fh_h","website","doc","explorer","sources","contracts","crypto_common_categories","crypto_asset","community","dividends_availability","earnings_availability","financials_availability","etf_asset_type_exposure","etf_region_exposure","top_holdings","unit-id","options-info","interest_income_fy","interest_income_fq","interest_income_fh","non_interest_income_fy","non_interest_income_fq","non_interest_income_fh","interest_expense_fy","interest_expense_fq","interest_expense_fh","loan_loss_provision_fy","loan_loss_provision_fq","loan_loss_provision_fh","non_interest_expense_fy","non_interest_expense_fq","non_interest_expense_fh","non_oper_income_fy","non_oper_income_fq","non_oper_income_fh","unusual_expense_inc_fy","unusual_expense_inc_fq","unusual_expense_inc_fh","pretax_income_fy","pretax_income_fq","pretax_income_fh","income_tax_fy","income_tax_fq","income_tax_fh","after_tax_other_income_fy","after_tax_other_income_fq","after_tax_other_income_fh","total_non_oper_income_fy","total_non_oper_income_fq","total_non_oper_income_fh","oper_income_fy","oper_income_fq","oper_income_fh","operating_expenses_fy","operating_expenses_fq","operating_expenses_fh","cost_of_goods_fy","cost_of_goods_fq","cost_of_goods_fh","equity_in_earnings_fy","equity_in_earnings_fq","equity_in_earnings_fh","minority_interest_exp_fy","minority_interest_exp_fq","minority_interest_exp_fh","discontinued_operations_fy","discontinued_operations_fq","discontinued_operations_fh","front_contract","pointvalue","unit_id","expiration","aum","asset_class","focus","expense_ratio","launch_date","issuer","brand","homepage","index_tracked","actively_managed","fund_view_mode","common_equity_tier1_ratio_fy_h","common_equity_tier1_ratio_fq_h","common_equity_tier1_ratio_fh_h","tier1_capital_ratio_fy_h","tier1_capital_ratio_fq_h","tier1_capital_ratio_fh_h","total_capital_ratio_fy_h","total_capital_ratio_fq_h","total_capital_ratio_fh_h","preferred_stock_carrying_value_fh","preferred_stock_carrying_value_fq","total_debt_fq","minority_interest_fh","minority_interest_fq","cash_n_short_term_invest_fq","cash_n_due_f_banks_fh","cash_n_due_f_banks_fq","enterprise_value_current","etf_holdings_count","contract-description","reference-last-period","all_time_high","all_time_high_day","all_time_low","all_time_low_day","outstanding_amount","nominal_value","denom_min","current_coupon","coupon_type_general","coupon_frequency","yield_to_maturity","maturity-date","days_to_maturity","bond_issuer","issue_date","bond_issuer_stock_symbol","total_issued_amount","paid_amount","bond_snp_rating_lt_h","placement_type","duration_type","maturity_type","offer_type","redemption_type","conversion_option","sinking_fund","ownership_form","daily-summary-ast","issue_status","coupon_h","sinking_fund_next_date","sinking_fund_min_amount_next","call_next_date","redemptions_h","call_notice_days","put_next_date","put_notice_days_min","seniority_level","inflation_protection","pledge_status","bond_issuer_country_of_risk","bond_issuer_cr_parent","credit_enhancement_type","credit_enhancement_status","use_of_proceeds","bond_issuer_snp_rating_lt_h","bond_issuer_snp_rating_st_h","bond_agents_tr","first_bar_time_1d","financial-indicator-id","exchange-info","underlying-symbol","strike","lotsize","option-style","has_bonds","open_time","has_bonds","dex_buys_15m","dex_sells_15m","dex_buy_volume_15m","dex_sell_volume_15m","dex_buyers_15m","dex_sellers_15m","dex_buys_1h","dex_sells_1h","dex_buy_volume_1h","dex_sell_volume_1h","dex_buyers_1h","dex_sellers_1h","dex_buys_4h","dex_sells_4h","dex_buy_volume_4h","dex_sell_volume_4h","dex_buyers_4h","dex_sellers_4h","dex_buys_12h","dex_sells_12h","dex_buy_volume_12h","dex_sell_volume_12h","dex_buyers_12h","dex_sellers_12h","dex_buys_24h","dex_sells_24h","dex_buy_volume_24h","dex_sell_volume_24h","dex_buyers_24h","dex_sellers_24h","dex_converted_symbol","dex_trading_volume_24h","dex_created_time","dex_currency","dex_currency_logoid","blockchain_addresses_urls","blockchain_addresses","base_currency","available_data_range_begin_date","available_data_range_end_date"]),r=new o({
fields:n})},98422:(e,t,i)=>{"use strict";i.r(t),i.d(t,{getNewPeveCloseMode:()=>n,setNewPrevCloseMode:()=>o});let s=!1;function o(e){s=e}function n(){return s}},76220:(e,t,i)=>{"use strict";i.r(t),i.d(t,{QuoteSession:()=>o});var s=i(4226);class o{constructor(e,t=(0,s.randomHash)()){this._sessionstarted=!1,this._globalHandler=null,this._chartApi=e,this._sessionid="qs_"+t}destroy(){this._sessionstarted&&(this._chartApi.quoteDeleteSession(this._sessionid),this._sessionstarted=!1)}connected(){return this._chartApi.connected()}connect(e){this._globalHandler=e,this._chartApi.createSession(this._sessionid,this),this._chartApi.connect()}disconnect(){this._chartApi.disconnect()}quoteAddSymbols(e){this._chartApi.quoteAddSymbols(this._sessionid,e)}quoteRemoveSymbols(e){this._chartApi.quoteRemoveSymbols(this._sessionid,e)}quoteFastSymbols(e){this._chartApi.quoteFastSymbols(this._sessionid,e)}quoteSetFields(e){this._chartApi.quoteSetFields(this._sessionid,e)}onMessage(e){switch(e.method){case"connected":this._sessionstarted||(this._chartApi.quoteCreateSession(this._sessionid),this._sessionstarted=!0);break;case"disconnected":this._sessionstarted=!1}this._globalHandler?.(e)}quoteHibernateAll(){this._chartApi.quoteHibernateAll(this._sessionid)}}},52706:(e,t,i)=>{"use strict";function s(e){if(void 0===e)return null;const t=e.match(/(delayed_streaming)_(\d+)/);return null===t?null:{mode:t[1],interval:parseInt(t[2])}}function o(e){const t=s(e.update_mode);return null===t||(e.update_mode=t.mode,e.update_mode_seconds=t.interval),e}i.r(t),i.d(t,{normalizeUpdateMode:()=>o,parseUpdateMode:()=>s})},94194:(e,t,i)=>{"use strict";i.d(t,{getTooltipData:()=>o,setTooltipData:()=>n});const s=new WeakMap;function o(e,t){const i=s.get(e);return i instanceof Function?i(t):i&&i[t]}function n(e,t,i){if(i instanceof Function)return void s.set(e,i);const o=s.get(e),n=void 0===o||o instanceof Function?{}:o;n[t]=i,s.set(e,n)}},61814:(e,t,i)=>{"use strict";i.d(t,{hotKeyDeserialize:()=>n,hotKeySerialize:()=>o});var s=i(91682);function o(e){return(0,s.htmlEscape)(JSON.stringify(e))}function n(e){return JSON.parse((0,s.decodeHTMLEntities)(e))}},38780:(e,t,i)=>{"use strict";i.d(t,{hide:()=>K,show:()=>G,showOnElement:()=>j});var s=i(32563),o=i(50151),n=i(26709);let r=0,a=0,l=0;function c(){clearTimeout(r),clearTimeout(a),clearTimeout(l)}function h(e,t){r=setTimeout(e,t)}const d="tooltip-root-element";let u;function _(){const e=document.getElementById(d);e?u=e:(u=document.createElement("div"),u.id=d,document.body.appendChild(u))}function p(){u&&(u.innerHTML="")}function m(e){p(),u||_(),u.appendChild(e)}"interactive"===document.readyState?_():document.addEventListener("DOMContentLoaded",_);var g=i(50470),f=i(24640),y=(i(40167),i(26867)),v=i(77914),S=i(49483);const b={default:"",white:"theme-white",chart:"theme-chart","round-shadow":"theme-round-shadow"},w=Object.keys(b);var C,T=i(94194),P=i(61814),x=i(46021);function M(e){const t=function(e){const t=e.hasAttribute("data-tooltip")?e.getAttribute("data-tooltip"):e.getAttribute("title");return t&&((0,
T.setTooltipData)(e,"text",t),e.removeAttribute("title")),(0,T.getTooltipData)(e,"text")||""}(e),i=e.getBoundingClientRect(),s={h:i.height,w:i.width,x:i.left,y:i.top},o=e.getAttribute("data-color-theme")||"",n=e.classList.contains("common-tooltip-html"),r=parseInt(e.getAttribute("data-tooltip-delay")||""),a=parseInt(e.getAttribute("data-tooltip-debounce")||"");let l={type:"none"};return t&&(l={type:n?"html":"text",data:t}),{above:e.classList.contains("common-tooltip-above"),below:e.classList.contains("common-tooltip-below"),otl:e.classList.contains("common-tooltip-otl"),otr:e.classList.contains("common-tooltip-otr"),vertical:e.classList.contains("common-tooltip-vertical"),hotkey:e.getAttribute("data-tooltip-hotkey"),narrow:e.classList.contains("common-tooltip-narrow"),wide:e.classList.contains("common-tooltip-wide"),colorTheme:o,tooltipDelay:r,tooltipDebounce:a,rect:s,content:l,target:e}}function I(e){const t=(0,o.ensureNotNull)(V).cloneNode(!0),i=O(t),{content:s}=e;switch(s.type){case"element":i.innerHTML="",i.appendChild(s.data);break;case"html":i.innerHTML=s.data;break;case"text":if(e.hotkey){const e=(0,o.ensureNotNull)(N).cloneNode(!0);e.innerText=s.data,i.appendChild(e)}else i.innerText=s.data}if(e.hotkey){const t="none"!==s.type,n=(0,o.ensureNotNull)(R).cloneNode(!0),r=(0,P.hotKeyDeserialize)(e.hotkey),a=r.keys.map((e=>`<span class="${x["common-tooltip__hotkey-button"]}">${e}</span>`));n.innerHTML=function(e,t){const i=/{\d}|{hotkey_\d}/gi;return e.replace(i,(e=>{const i=Number(e.match(/\d/));return t[i]}))}(r.text,a).replace(/\s\+\s/g,`<span class="${x["common-tooltip__plus-sign"]}">+</span>`),i.classList.add(x["common-tooltip__body--with-hotkey"]),t&&n.classList.add(x["common-tooltip__hotkey-block--divider"]),i.appendChild(n)}return t.addEventListener("contextmenu",y.preventDefault),t}function A(e,t){const i=t.rect;if(!i)return;!function(e,t){const i=w.includes(t)?b[t]:"";e.classList.remove(...w.map((e=>b[e])).filter((e=>!!e))),i&&!e.classList.contains(i)&&e.classList.add(i)}(e,t.colorTheme||"default"),t.addClass&&e.classList.add(t.addClass);const s=O(e),o=e.querySelector(`.${x["common-tooltip__button-container"]}`);s.classList.toggle(x["common-tooltip__body--width_wide"],Boolean(t.wide)),s.classList.toggle(x["common-tooltip__body--no-padding"],Boolean(t.noPadding)),s.classList.toggle(x["common-tooltip__body--width_narrow"],Boolean(t.narrow)),s.classList.toggle(x["common-tooltip__body--no-buttons"],!0),s.style.left=k(0),s.style.width=k(s.clientWidth+(Boolean(t.noPadding)?0:2));const n=document.body.clientWidth,r=S.CheckMobile.iOS()||S.CheckMobile.Android()||(0,S.supportTouch)()&&(0,S.isMac)()?window.innerHeight:document.body.clientHeight,a=t.vertical,l=t.extendMargin||a&&i.w<20||!a&&i.h<20;e.classList.toggle(x["common-tooltip--farther"],l),e.classList.toggle(x["common-tooltip--vertical"],a),e.classList.toggle(x["common-tooltip--horizontal"],!a);const c=function(e){return e.querySelector(`.${x["common-tooltip__ear-holder"]}`)}(e),h=e.offsetHeight;if(a){const a=10,l=r-10,d=12,u=a+d,_=l-d,p=(0,
v.clamp)(i.y+i.h/2,u,_)-h/2,m=p+h;e.style.left=k(i.x+i.w),e.style.top=k(p),p<a?s.style.top=o.style.top=k(a-p):m>l&&(s.style.top=o.style.top=k(l-m));const{right:g}=(e.querySelector(":last-child")||s).getBoundingClientRect(),y=g+10>n;e.classList.toggle(x["common-tooltip--direction_reversed"],y),e.classList.toggle(x["common-tooltip--direction_normal"],!y);let S=y?"after":"before";(0,f.isRtl)()?(S=t.otr?"after":S,S=t.otl?"before":S):(S=t.otr?"before":S,S=t.otl?"after":S),c.classList.toggle(x["common-tooltip__ear-holder--before"],"before"===S),c.classList.toggle(x["common-tooltip__ear-holder--after"],"after"===S),"after"===S&&(e.style.left="auto",e.style.right=k(n-i.x))}else{const a=i.x-(s.offsetWidth-i.w)/2,l=n-e.offsetWidth-20<=0?(n-e.offsetWidth)/2:10,d=n-l-e.offsetWidth,u=Math.max(l,Math.min(a,d));e.style.left=k(u);const _=d<a;e.classList.toggle(x["common-tooltip--direction_reversed"],_),e.classList.toggle(x["common-tooltip--direction_normal"],!_);const p=function(e,t,i,s){if(e.above)return F(t,s)?"above":"below";if(e.below)return function(e,t,i){return i.y+i.h+t+10<e}(t,i,s)?"below":"above";return F(i,s)?"above":"below"}(t,r,h,i);"above"===p?e.style.bottom=k(r-i.y):e.style.top=k(i.y+i.h),c.classList.add("above"===p?x["common-tooltip__ear-holder--above"]:x["common-tooltip__ear-holder--below"]);const{left:m}=s.getBoundingClientRect();let g=Math.trunc(i.x+i.w/2-(m+s.clientWidth/2));e.style.left=k(u+g),e.style.width=k(s.clientWidth+o.clientWidth),g=_?Math.max(0,g):Math.min(0,g),o.style.left=k(-g),s.style.left=k(-g)}}function L(e){e.classList.toggle(x["common-tooltip--hidden"],!0)}function k(e){return`${Math.floor(e)}px`}!function(e){e[e.ViewportPadding=10]="ViewportPadding"}(C||(C={}));const E=`\n\t<div id="common-tooltip-wrapper" class="${x["common-tooltip"]}">\n\t\t<div class="${x["common-tooltip__ear-holder"]}" >\n\t\t\t<div class="${x["common-tooltip__body"]} js-tooltip-body"></div>\n\t\t</div>\n\t\t<div class="${x["common-tooltip__button-container"]}"></div>\n\t</div>\n`,D=`\n\t<div class="${x["common-tooltip__hotkey-block"]}"></div>\n`,B=`\n\t<div class="${x["common-tooltip__hotkey-text"]}"></div>\n`,V=(0,g.parseHtmlElement)(E),R=(0,g.parseHtmlElement)(D),N=(0,g.parseHtmlElement)(B);function O(e){return e.querySelector(`.${x["common-tooltip__body"]}`)}function F(e,t){return 10+e<t.y}let W=!1,H=null,z=null;s.mobiletouch||(document.addEventListener("mouseover",q,!0),document.addEventListener("focus",(function(e){const t=e.target;if(!(t instanceof HTMLElement&&t.closest('[data-tooltip-show-on-focus="true"]')&&t.matches(":focus-visible")))return;q(e,!0)}),{capture:!0}),document.addEventListener("active-descendant-focus",(function(e){e.target instanceof HTMLElement&&q(e,!0)}),{capture:!0}));const U=new MutationObserver((()=>{if(H&&H.options.target){let e;e="isConnected"in H.options.target?H.options.target.isConnected:document.body.contains(H.options.target),e||K()}})),j=(e,t={})=>{const{content:i,...s}=X(t),o=M(e),n=Object.assign(o,s);return"none"!==i.type&&(n.content=i),
!("none"===n.content.type&&!n.hotkey)&&(n.target=e,G(n),!0)},G=e=>{const t=X(e),i=I(t);if(H={options:t,element:i},m(i),c(),!W)return L(i),void h((()=>Y(i)),function(e){return"number"!=typeof e.tooltipDelay||isNaN(e.tooltipDelay)?500:e.tooltipDelay}(t));const{tooltipDebounce:s}=e;"number"!=typeof s||isNaN(s)?Y(i):h((()=>Y(i)),s)};function q(e,t){if("sourceCapabilities"in e&&e.sourceCapabilities?.firesTouchEvents)return;const i=function(e,t,i){const s=[];for(;e&&e!==t;)e.classList&&e.classList.contains(i)&&s.push(e),e=e.parentElement||Z(e.parentNode);return s}(e.target,e.currentTarget,"apply-common-tooltip");for(const s of i){if(e instanceof MouseEvent)if("buttons"in e){if(1&e.buttons)continue}else if(1===e.which)continue;const i=()=>j(s);if(i()){const e=e=>o(null,!0),o=(n,r=!1)=>{s.removeEventListener("common-tooltip-update",i),s.removeEventListener("mouseleave",o),s.removeEventListener("mousedown",o),document.removeEventListener("scroll",e,{capture:!0}),t&&(s.removeEventListener("blur",o),s.removeEventListener("active-descendant-blur",o)),z&&(z.destroy(),z=null),K(r)};s.addEventListener("common-tooltip-update",i),s.addEventListener("mouseleave",o),s.addEventListener("mousedown",o),document.addEventListener("scroll",e,{capture:!0}),t&&(s.addEventListener("blur",o),s.addEventListener("active-descendant-blur",o)),null===z&&(z=(0,n.createGroup)({desc:"Tooltip"}),z.add({desc:"Hide",hotkey:27,handler:o}));break}}}function $(){p(),W=!1,H=null}const K=(e,t)=>{if(c(),(0,o.ensureNotNull)(U).disconnect(),!H)return;if(!e&&!W)return;const{element:i,options:s}=H,n=()=>{i.removeEventListener("mouseleave",n),L(i),e?$():l=setTimeout((()=>{$()}),250),t?.()};var r,h;s.tooltipHideDelay?(r=()=>{i.querySelector(":hover")?i.addEventListener("mouseleave",n):n()},h=s.tooltipHideDelay,a=setTimeout(r,h)):n()};function Y(e){const{options:t}=(0,o.ensureNotNull)(H);if(A(e,t),function(e){e.classList.toggle(x["common-tooltip--hidden"],!1)}(e),(0,o.ensureNotNull)(U).observe(document,{childList:!0,subtree:!0}),W=!0,t.forceHideOnMove){const e=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("touchmove",e),K()};document.addEventListener("mousemove",e),document.addEventListener("touchmove",e)}}function Z(e){return e&&(e.nodeType===Node.ELEMENT_NODE?e:null)}function X(e){if(function(e){return"content"in e}(e))return e;const{inner:t,html:i,text:s,...o}=e;let n={type:"none"};return t&&(n={type:"element",data:t}),s&&(n={type:i?"html":"text",data:s}),{content:n,...o}}},32112:(e,t,i)=>{"use strict";function s(e,t){const i=e.dataSourceForId(t);if(null===i)throw new Error(`Chart has no study or shape with id "${t}"`);return i}i.d(t,{SelectionApi:()=>o});class o{constructor(e){this._model=e}add(e){Array.isArray(e)?this._model.selectionMacro((t=>{e.map(s.bind(null,this._model)).forEach((e=>t.addSourceToSelection(e)))})):this.add([e])}canBeAddedToSelection(e){const t=s(this._model,e);return this._model.selection().canBeAddedToSelection(t)}set(e){Array.isArray(e)?this._model.selectionMacro((t=>{t.clearSelection(),
e.map(s.bind(null,this._model)).forEach((e=>t.addSourceToSelection(e)))})):this.set([e])}remove(e){Array.isArray(e)?this._model.selectionMacro((t=>{e.map(s.bind(null,this._model)).forEach((e=>t.removeSourceFromSelection(e)))})):this.remove([e])}contains(e){const t=s(this._model,e);return this._model.selection().isSelected(t)}allSources(){return this._model.selection().dataSources().map((e=>e.id()))}isEmpty(){return this._model.selection().isEmpty()}clear(){this._model.selectionMacro((e=>{e.clearSelection()}))}onChanged(){return this._model.onSelectedSourceChanged()}}},68659:(e,t,i)=>{"use strict";i.r(t);var s=i(9343),o=i(11417);const n="tv.logger.loglevel",r="tv.logger.logHighRate",a=(0,s.getLogger)("logger");function l(){try{o.TVLocalStorage.setItem(r,String((0,s.isHighRateEnabled)())),o.TVLocalStorage.setItem(n,String((0,s.getLogLevel)()))}catch(e){a.logWarn(`Cannot save logger state (level: ${(0,s.getLogLevel)()}, high-rate: ${(0,s.isHighRateEnabled)()}) to localStorage: ${e.message}`)}}window.lget=s.getLogHistory,window.lon=(e,t)=>{a.logNormal("Debug logging enabled"),(0,s.loggingOn)(e,t),l()},window.loff=()=>{a.logInfo("Debug logging disabled"),(0,s.loggingOff)(),l()},window.llevel=e=>{a.logInfo("Changed logging level"),(0,s.setLogLevel)(e),l()},function(){const e="true"===o.TVLocalStorage.getItem(r);(0,s.setHighRateStatus)(e);let t=parseInt(o.TVLocalStorage.getItem(n)||"");Number.isNaN(t)&&(t=s.LOGLEVEL.WARNING),(0,s.setLogLevel)(t),a.logNormal(`Init with settings - level: ${(0,s.getLogLevel)()}, high-rate: ${(0,s.isHighRateEnabled)()}`)}(),a.logNormal(`Sync logger and perf times, now is ${performance.now()}`)},23024:(e,t,i)=>{"use strict";i.d(t,{getChartStorage:()=>n});var s=i(34840);let o=null;async function n(){const e=(0,s.getCustomAdapter)();if(null===o)if(null!==e){const{ChartStorageExternalAdapter:t}=await i.e(8313).then(i.bind(i,33047));o=new t(e)}else{const{ChartStorageHttpLibrary:e}=await i.e(6124).then(i.bind(i,64998));o=new e}return null===o&&(o=new ChartStorageHttp),o}},38881:(e,t,i)=>{"use strict";i.d(t,{ChunkLoader:()=>o});var s=i(95406);class o{constructor(){this._retries=5,this._cache=null,this._tryLoad=(e,t)=>{this._retries=this._retries-1;this._startLoading(e).then(t,0!==this._retries?i=>{(0,s.isAbortError)(i)||setTimeout((()=>this._tryLoad(e,t)),3e3)}:void 0)}}load(e){return this._cache||(this._cache=new Promise(this._tryLoad.bind(this,e??null))),this._cache}}},80007:(e,t,i)=>{"use strict";function s(e){e.cancelable&&e.preventDefault()}function o(e){return t=>{s(t),e(t)}}i.d(t,{preventDefault:()=>s,wrapHandlerWithPreventEvent:()=>o})},56186:(e,t,i)=>{"use strict";function s(e){if(e instanceof Error)return e.stack||e.message;try{return e.outerHTML.slice(0,1024)}catch{}try{if(void 0!==e)return JSON.stringify(e).slice(0,1024)}catch{}return String(e)}function o(){window.__tv_js_errors||(window.__tv_js_errors=[]),window.addEventListener("error",(e=>{const t=(new Date).toISOString()
;window.__tv_js_errors.push(`${t} ${e.message||"JS error"}. ${e.filename||"<unknown url>"}, line ${e.lineno}, col ${e.colno}.\nError: ${s(e.error)}`)}),!1),window.addEventListener("unhandledrejection",(e=>{const t=(new Date).toISOString();window.__tv_js_errors.push(`${t} Unhandled rejection.\nReason: ${s(e.reason)}`)}),!1),document.addEventListener("securitypolicyviolation",(e=>{if(String(e.sourceFile).startsWith("https://securepubads.g.doubleclick.net")&&String(e.blockedURI).startsWith("https://adservice.google."))return;const t=(new Date).toISOString(),i="report"===e.disposition?"CSP report-only":"CSP violation";window.__tv_js_errors.push(`${t} ${i}: ${e.violatedDirective||e.effectiveDirective}. ${e.sourceFile||"<unknown url>"}, line ${e.lineNumber}, col ${e.columnNumber}.\nBlocked URI: ${e.blockedURI}\nSample: ${e.sample}\nTarget: ${s(e.target)}`)}),!1)}i.d(t,{install:()=>o})},76422:(e,t,i)=>{"use strict";i.r(t),i.d(t,{emit:()=>u,emitOnce:()=>_,on:()=>c,subscribe:()=>h,subscribeToAll:()=>d,unsubscribe:()=>a,unsubscribeAll:()=>l});var s=i(48096);const o={},n=[],r={};function a(e,t,i){o[e].unsubscribe(i,t)}function l(e,t){o[e].unsubscribeAll(t)}function c(e,t,i){h(e,t,i)}function h(e,t,i,n){o.hasOwnProperty(e)||(o[e]=new s.Delegate),r[e]?t.call(i):o[e].subscribe(i,t,n)}function d(e){n.push(e)}function u(e,...t){const i=[e].concat(t);n.forEach((e=>{e.apply(null,i)})),o.hasOwnProperty(e)&&o[e].fire.apply(o[e],t)}function _(e){r[e]&&console.warn(`Something went wrong: emitOnce called multiple times with same event (${e})`),r[e]=!0,u.apply(null,arguments)}},26709:(e,t,i)=>{"use strict";i.d(t,{Modifiers:()=>n.Modifiers,createGroup:()=>s.createGroup,keyboardPressedKeysState:()=>s.keyboardPressedKeysState,pressedKeys:()=>s.pressedKeys});var s=i(43222),o=i(93132),n=i(3343),r=i(51768);(0,s.registerWindow)(window),o.ActionGroup.setMatchedHotkeyHandler((e=>{(0,r.trackEvent)("Keyboard Shortcuts",(0,n.humanReadableHash)(e))}))},68335:(e,t,i)=>{"use strict";i.d(t,{Modifiers:()=>s.Modifiers,hashFromEvent:()=>s.hashFromEvent,humanReadableHash:()=>s.humanReadableHash,humanReadableModifiers:()=>s.humanReadableModifiers,isMacKeyboard:()=>s.isMacKeyboard,modifiersFromEvent:()=>s.modifiersFromEvent});var s=i(3343)},35749:(e,t,i)=>{"use strict";i.d(t,{isNativeUIInteraction:()=>s.isNativeUIInteraction,isTextEditingField:()=>s.isTextEditingField});var s=i(54717)},71382:(e,t,i)=>{"use strict";i.d(t,{isTouchEvent:()=>o});var s=i(32563);function o(e){const t=e.sourceCapabilities;let i=t&&t.firesTouchEvents;return void 0===i&&(i=s.touch),i}},29803:(e,t,i)=>{"use strict";i.d(t,{linking:()=>f});var s=i(90484),o=i(50151),n=i(9343),r=i(22613),a=(i(37103),i(46082)),l=i(95059),c=i(48943),h=i(8811);var d=i(54370),u=i(69109);const _=(0,n.getLogger)("Linking");var p,m;!function(e){e[e.NotBound=0]="NotBound",e[e.BoundToWidget=1]="BoundToWidget",e[e.BoundToModel=2]="BoundToModel"}(p||(p={})),function(e){e[e.Symbol=0]="Symbol",e[e.Resolution=1]="Resolution"}(m||(m={}));class g{constructor(e,t,i){this.watchedSymbols=new r.WatchedValue([]),
this.watchedSymbol=new r.WatchedValue,this.seriesShortSymbol=new r.WatchedValue,this.proSymbol=new r.WatchedValue,this.ensuredProSymbol=new r.WatchedValue,this.watchedInterval=new r.WatchedValue,this.watchedIntraday=new r.WatchedValue,this.watchedSeconds=new r.WatchedValue,this.watchedTicks=new r.WatchedValue,this.watchedDataFrequencyResolution=new r.WatchedValue,this.watchedRange=new r.WatchedValue,this.watchedSupportedResolutions=new r.WatchedValue,this.watchedSupportedChartStyles=new r.WatchedValue,this.symbolNamesList=new r.WatchedValue,this._chartWidgetCollection=null,this._chartWidgetBindingState=0,this._activeChartWidget=null,this._linkingGroupCharts=null,this._boundChartWidget=null,this._watchedSymbolListenerBound=this._watchedSymbolListener.bind(this),this._watchedIntervalListenerBound=this._watchedIntervalListener.bind(this),this._setGroupSymbolCancellationToken={cancelled:!1},this._muted=!1,this.updateBoundChartWidget=()=>{const e=this._chartToBind();e!==this._boundChartWidget&&(null===e?this.unbindFromChartWidget():this.bindToChartWidget(e))},this._updateAllGroupChartWidgets=()=>{this._destroySymbolIntervalPropertySubscriptions?.();const e=(0,o.ensureNotNull)(this._linkingGroupCharts).value(),t=[],i=[];for(const s of e){const e=s.symbolWV().spawn(),o=s.resolutionWV().spawn();e.subscribe(this._updateSymbolByProperty.bind(this,s)),o.subscribe(this._updateIntervalByProperty.bind(this,s)),t.push(e),i.push(o)}this._destroySymbolIntervalPropertySubscriptions=()=>{t.forEach((e=>e.destroy())),i.forEach((e=>e.destroy())),this._destroySymbolIntervalPropertySubscriptions=void 0};const s=this.watchedSymbol.value();e.length>1&&this._needApplySymbol(s)&&!this._muted&&this._setGroupSymbol(s);const n=this.watchedInterval.value();e.length>1&&this._needApplyInterval(n)&&!this._muted&&this._setGroupInterval(n),this.updateBoundChartWidget()},this._groupIndex=e;const s=(e,t)=>{e.subscribe((e=>{i()===this&&t.setValue(e)}),{callWithLast:!0})};s(this.watchedSymbols,t.watchedSymbols),s(this.watchedSymbol,t.watchedSymbol),s(this.seriesShortSymbol,t.seriesShortSymbol),s(this.proSymbol,t.proSymbol),s(this.ensuredProSymbol,t.ensuredProSymbol),s(this.watchedInterval,t.watchedInterval),s(this.watchedIntraday,t.watchedIntraday),s(this.watchedSeconds,t.watchedSeconds),s(this.watchedTicks,t.watchedTicks),s(this.watchedDataFrequencyResolution,t.watchedDataFrequencyResolution),s(this.watchedRange,t.watchedRange),s(this.watchedSupportedResolutions,t.watchedSupportedResolutions),s(this.watchedSupportedChartStyles,t.watchedSupportedChartStyles),s(this.symbolNamesList,t.symbolNamesList),this.watchedSymbol.subscribe((e=>{this._boundChartWidget&&this._boundChartWidget.hasModel()&&this.mainSeries().symbolSameAsCurrent(e)||this.proSymbol.setValue(e)}),{callWithLast:!0})}mute(e){this._muted=e}bindToChartWidgetCollection(e){this.unbindFromChartWidgetCollection(),this._chartWidgetCollection=e,this._activeChartWidget=e.activeChartWidget.spawn(),this._activeChartWidget.subscribe(this.updateBoundChartWidget),
this._linkingGroupCharts=e.linkingGroupsCharts(this._groupIndex).spawn(),this._linkingGroupCharts.subscribe(this._updateAllGroupChartWidgets),this.updateBoundChartWidget(),this._updateAllGroupChartWidgets();const t=function(e){const t=(0,c.combine)((()=>e.getAll().filter((e=>e.isVisible()&&e.hasModel())).map((e=>(0,h.createWVFromGetterAndSubscription)((()=>e.model().mainSeries().symbol()),e.model().mainSeries().symbolResolved()).ownership()))),e.chartModels().weakReference(),e.layout.weakReference());return(0,c.accumulate)((e=>e),t.ownership())}(e);t.subscribe((e=>{this.watchedSymbols.setValue(e)})),this.watchedSymbols.setValue(t.value())}unbindFromChartWidgetCollection(){this.unbindFromChartWidget(),this._chartWidgetCollection=null,this._activeChartWidget?.destroy(),this._activeChartWidget=null,this._linkingGroupCharts?.destroy(),this._linkingGroupCharts=null,this._destroySymbolIntervalPropertySubscriptions?.()}bindToChartWidget(e){if(this.unbindFromChartWidget(),this._boundChartWidget=e,e.hasModel())return void this._onChartModelCreated(e.model());e.modelCreated().subscribe(this,this._onChartModelCreated,!0),this._chartWidgetBindingState=1;const t=e.mainSeriesProperties().childs();this.watchedSymbol.setValue(t.symbol.value()),this.watchedInterval.setValue(t.interval.value()),this._boundChartWidget.linkingGroupIndex().subscribe(this.updateBoundChartWidget)}unbindFromChartWidget(){const e=this._boundChartWidget;if(null!==e){switch(this._chartWidgetBindingState){case 1:e.modelCreated().unsubscribeAll(this);break;case 2:this.watchedSymbol.unsubscribe(this._watchedSymbolListenerBound);const t=this.mainSeries().dataEvents();t.symbolResolved().unsubscribeAll(this),t.symbolError().unsubscribeAll(this),this.mainSeries().onIntervalChanged().unsubscribeAll(this),this.watchedInterval.unsubscribe(this._watchedIntervalListenerBound),delete this.watchedSymbol.writeLock}e.linkingGroupIndex().unsubscribe(this.updateBoundChartWidget),this._boundChartWidget=null,this._chartWidgetBindingState=0}}boundChartWidget(){return this._boundChartWidget}mainSeries(){if(!this._boundChartWidget)throw new Error("ChartWidget is undefined");return this._boundChartWidget.model().mainSeries()}_watchedSymbolListener(e){this._needApplySymbol(e)&&!this._muted&&this._setGroupSymbol(e)}_updateSymbolByProperty(e,t){const i=this._symbolLock();i&&this._needApplySymbol(t)&&!this._muted&&this._setGroupSymbol(t),(i||e===this._boundChartWidget)&&this.watchedSymbol.setValue(t)}_watchedIntervalListener(e){const t=a.Interval.normalize(e);t&&this._needApplyInterval(t)&&!this._muted&&this._setGroupInterval(t)}_updateIntervalByProperty(e,t){const i=this._intervalLock(),s=a.Interval.normalize(t);i&&s&&this._needApplyInterval(s)&&!this._muted&&this._setGroupInterval(s),(i||e===this._boundChartWidget)&&this.watchedInterval.setValue(s??t)}_updateSeriesSymbolInfo(){this.seriesShortSymbol.setValue((0,o.ensureNotNull)(this._boundChartWidget).getSymbol(!0));const e=this.mainSeries().symbolInfo();if(e){const t=e.pro_name||!1
;this.proSymbol.setValue(t||this.watchedSymbol.value()),this.ensuredProSymbol.setValue(this.proSymbol.value()),e.aliases&&this.symbolNamesList.setValue(e.aliases);{const t=e.supported_resolutions;t?this.watchedSupportedResolutions.setValue(t):this.watchedSupportedResolutions.setValue(void 0)}let i=(0,d.allChartStyles)();((0,l.isCloseBasedSymbol)(e)||this.mainSeries().intervalObj().value().is1Tick())&&(i=i.filter((e=>(0,l.isSingleValueBasedStyle)(e)))),"hlc"===e.visible_plots_set&&(i=i.filter((e=>(0,l.isHLCBasedStyle)(e)||(0,l.isSingleValueBasedStyle)(e)))),this.watchedSupportedChartStyles.setValue(i),this.watchedIntraday.setValue(!!e.has_intraday),this.watchedSeconds.setValue(!!e.has_seconds),this.watchedTicks.setValue(!(0,l.isCloseBasedSymbol)(e)&&!!e["is-tickbars-available"]),this.watchedRange.setValue(!(0,l.isCloseBasedSymbol)(e));const s=e.data_frequency?e.data_frequency:void 0;this.watchedDataFrequencyResolution.setValue(s)}else this.watchedIntraday.setValue(!1),this.watchedSeconds.setValue(!1),this.watchedTicks.setValue(!1),this.watchedRange.setValue(!1),this.mainSeries().isFailed()&&this.ensuredProSymbol.setValue(this.proSymbol.value())}_onChartModelCreated(e){if(!this._boundChartWidget)throw new Error("ChartWidget is undefined");this._chartWidgetBindingState=2,this.watchedSymbol.setValue(this._boundChartWidget.symbolWV().value()),this.watchedSymbol.subscribe(this._watchedSymbolListenerBound);const t=e.mainSeries().dataEvents();t.symbolResolved().subscribe(this,this._updateSeriesSymbolInfo),t.symbolError().subscribe(this,this._updateSeriesSymbolInfo),e.mainSeries().onIntervalChanged().subscribe(this,this._updateSeriesSymbolInfo),this._updateSeriesSymbolInfo(),this.watchedInterval.setValue(this._boundChartWidget.resolutionWV().value()),this.watchedInterval.subscribe(this._watchedIntervalListenerBound),this._boundChartWidget.readOnly()&&(this.watchedSymbol.writeLock=!0)}_chartToBind(){const e=this._chartWidgetCollection;return null===e?null:e.activeChartWidget.value()}_symbolLock(){return!!this._chartWidgetCollection?.lock.symbol.value()}_intervalLock(){return!!this._chartWidgetCollection?.lock.interval.value()}_chartsForLock(e){return(0===e?this._symbolLock():this._intervalLock())?(0,o.ensureNotNull)(this._linkingGroupCharts).value():this._boundChartWidget?[this._boundChartWidget]:[]}_setGroupSymbol(e){this.mute(!0),this._setGroupSymbolCancellationToken.cancelled=!0;const t=this._setGroupSymbolCancellationToken={cancelled:!1};(0,o.ensureNotNull)(this._chartWidgetCollection).setSymbol(e,this._groupIndex,(0,o.ensureNotNull)(this._boundChartWidget)).finally((()=>{if(this._boundChartWidget&&!t.cancelled){const t=this._boundChartWidget.model().mainSeries();t.symbolSameAsCurrent(e)||(this.watchedSymbol.setValue(t.symbol()),this.proSymbol.setValue(t.proSymbol()))}})),this.mute(!1)}_needApplySymbol(e){const t=this._chartsForLock(0),i=t.find((t=>t.hasModel()&&t.model().mainSeries().symbolInfo()&&t.model().mainSeries().symbolSameAsResolved(e)));if(i){const e=i.model().mainSeries()
;if(t.every((t=>e.symbolSameAsResolved(t.symbolWV().value()))))return!1}return t.some((t=>t.symbolWV().value()!==e))}_setGroupInterval(e){this.mute(!0),(0,o.ensureNotNull)(this._chartWidgetCollection).setResolution(e,this._groupIndex).finally((()=>{if(this._boundChartWidget){const t=this._boundChartWidget.resolutionWV().value();a.Interval.isEqual(t,e)||this.watchedInterval.setValue(t)}})),this.mute(!1)}_needApplyInterval(e){return this._chartsForLock(1).some((t=>!a.Interval.isEqual(t.resolutionWV().value(),e)))}}const f=new class{constructor(){this._watchedSymbols=new r.WatchedValue([]),this._watchedSymbol=new r.WatchedValue,this._seriesShortSymbol=new r.WatchedValue,this._proSymbol=new r.WatchedValue,this._ensuredProSymbol=new r.WatchedValue,this._watchedInterval=new r.WatchedValue,this._watchedIntraday=new r.WatchedValue,this._watchedSeconds=new r.WatchedValue,this._watchedTicks=new r.WatchedValue,this._watchedDataFrequencyResolution=new r.WatchedValue,this._watchedRange=new r.WatchedValue,this._watchedSupportedResolutions=new r.WatchedValue,this._watchedSupportedChartStyles=new r.WatchedValue([]),this._symbolNamesList=new r.WatchedValue,this._chartWidgetCollection=null,this._onSymbolLinkBound=this._onSymbolLink.bind(this),this._searchCharts=null,this._searchChartsLoadDebounced=null,this._selfEmit=!1,this._preventFeedBySymbol=!1,this._feedBySymbolDebounceCounter=0,this._linkingGroups=new Map,this._activeLinkingGroup=new r.WatchedValue,this._activeLinkingGroupIndex=null,this._updateLinkingGroups=()=>{(0,o.ensureNotNull)(this._chartWidgetCollection).allLinkingGroups().value().forEach((e=>this._linkingGroup(e))),this._linkingGroups.forEach((e=>e.updateBoundChartWidget()))},this._activeLinkingGroup.setValue(this._linkingGroup(null));const e=(e,t)=>{e.subscribe((e=>t().setValue(e)),{callWithLast:!0})};e(this._watchedSymbols,(()=>this._activeLinkingGroup.value().watchedSymbols)),e(this._watchedSymbol,(()=>this._activeLinkingGroup.value().watchedSymbol)),e(this._seriesShortSymbol,(()=>this._activeLinkingGroup.value().seriesShortSymbol)),e(this._proSymbol,(()=>this._activeLinkingGroup.value().proSymbol)),e(this._ensuredProSymbol,(()=>this._activeLinkingGroup.value().ensuredProSymbol)),e(this._watchedInterval,(()=>this._activeLinkingGroup.value().watchedInterval)),e(this._watchedIntraday,(()=>this._activeLinkingGroup.value().watchedIntraday)),e(this._watchedSeconds,(()=>this._activeLinkingGroup.value().watchedSeconds)),e(this._watchedTicks,(()=>this._activeLinkingGroup.value().watchedTicks)),e(this._watchedDataFrequencyResolution,(()=>this._activeLinkingGroup.value().watchedDataFrequencyResolution)),e(this._watchedRange,(()=>this._activeLinkingGroup.value().watchedRange)),e(this._watchedSupportedResolutions,(()=>this._activeLinkingGroup.value().watchedSupportedResolutions)),e(this._watchedSupportedChartStyles,(()=>this._activeLinkingGroup.value().watchedSupportedChartStyles)),e(this._symbolNamesList,(()=>this._activeLinkingGroup.value().symbolNamesList));const t=e=>{this._watchedSymbol.setValue(e.watchedSymbol.value()),
this._seriesShortSymbol.setValue(e.seriesShortSymbol.value()),this._proSymbol.setValue(e.proSymbol.value()),this._ensuredProSymbol.setValue(e.ensuredProSymbol.value()),this._watchedInterval.setValue(e.watchedInterval.value()),this._watchedIntraday.setValue(e.watchedIntraday.value()),this._watchedSeconds.setValue(e.watchedSeconds.value()),this._watchedTicks.setValue(e.watchedTicks.value()),this._watchedDataFrequencyResolution.setValue(e.watchedDataFrequencyResolution.value()),this._watchedRange.setValue(e.watchedRange.value()),this._watchedSupportedResolutions.setValue(e.watchedSupportedResolutions.value()),this._watchedSupportedChartStyles.setValue(e.watchedSupportedChartStyles.value()),this._symbolNamesList.setValue(e.symbolNamesList.value())};this._activeLinkingGroup.subscribe(t),t(this._activeLinkingGroup.value()),(0,u.setMuteLinkingGroup)(((e,t)=>{this._linkingGroup(e).mute(t)}))}get symbols(){return this._watchedSymbols}get symbol(){return this._watchedSymbol}get proSymbol(){return this._proSymbol.readonly()}get ensuredProSymbol(){return this._ensuredProSymbol.readonly()}get symbolNamesList(){return this._symbolNamesList.readonly()}get seriesShortSymbol(){return this._seriesShortSymbol.readonly()}get interval(){return this._watchedInterval}get intraday(){return this._watchedIntraday.readonly()}get seconds(){return this._watchedSeconds.readonly()}get ticks(){return this._watchedTicks.readonly()}get range(){return this._watchedRange.readonly()}get supportedResolutions(){return this._watchedSupportedResolutions.readonly()}get supportedChartStyles(){return this._watchedSupportedChartStyles.readonly()}get preventFeedBySymbol(){return this._preventFeedBySymbol}get dataFrequencyResolution(){return this._watchedDataFrequencyResolution.readonly()}activeLinkingGroup(){return this._activeLinkingGroup.readonly()}getChartWidget(){return this.activeLinkingGroup().value().boundChartWidget()}bindToChartWidgetCollection(e){this._chartWidgetCollection?.onAboutToBeDestroyed.unsubscribeAll(this),this._unbindFromChartWidgetCollection(),this._chartWidgetCollection=e,this._chartWidgetCollection.onAboutToBeDestroyed.subscribe(this,this._unbindFromChartWidgetCollection),this._chartWidgetCollection.allLinkingGroups().subscribe(this._updateLinkingGroups),this._updateLinkingGroups(),this._activeLinkingGroupIndex=e.activeLinkingGroup().spawn(),this._activeLinkingGroupIndex.subscribe((e=>{this._activeLinkingGroup.setValue(this._linkingGroup(e))}),{callWithLast:!0}),this._linkingGroups.forEach((t=>t.bindToChartWidgetCollection(e)))}bindToSearchCharts(e){this.unbindFromSearchCharts(),this._searchCharts=e,e.onSearchBySymbol.subscribe(this,this._onSearchBySymbol),e.loadingSymbol.subscribe((e=>{!1===e&&(this._feedBySymbolDebounceCounter=0)})),this._watchedSymbol.subscribe(this._onSymbolLinkBound)}unbindFromSearchCharts(){this._searchCharts&&(this._searchCharts.onSearchBySymbol.unsubscribe(this,this._onSearchBySymbol),this._watchedSymbol.unsubscribe(this._onSymbolLinkBound),this._searchCharts=null)}setPreventFeedBySymbol(e){
this._preventFeedBySymbol=e}setSymbolAndLogInitiator(e,t,i,s=!1){(this.symbol.value()!==e||i)&&(_.logInfo(`Change linking symbol to ${e}, initiator: ${t}`),this.symbol.setValue(e,i))}setIntervalAndLogInitiator(e,t){a.Interval.isEqual(this.interval.value(),e)||this.interval.setValue(e)}_onSearchBySymbol(e){if(!e.resolved_symbol)throw new Error("no resolved_symbol");this._selfEmit=!0,this._watchedSymbol.setValue(e.resolved_symbol),this._selfEmit=!1}_onSymbolLink(e){if(!this._selfEmit){if(!this._searchCharts){const e="No search charts defined";throw _.logError(e),new Error(e)}this._preventFeedBySymbol||this._loadSearchCharts(e)}}_loadSearchCharts(e){if(!this._searchCharts){const e="No search charts defined";throw _.logError(e),new Error(e)}if(this._searchChartsLoadDebounced)return void(this._feedBySymbolDebounceCounter<100&&(this._feedBySymbolDebounceCounter++,this._searchChartsLoadDebounced(e)));const t=e=>this._searchCharts?(!0===this._searchCharts.loadingSymbol.value()?this._feedBySymbolDebounceCounter<100&&(this._feedBySymbolDebounceCounter++,this._searchChartsLoadDebounced=(0,s.default)(t,2e3),this._searchChartsLoadDebounced(e)):this._searchChartsLoadDebounced=null,this._searchCharts.feedBySymbol.call(this._searchCharts,e)):()=>{};!0===this._searchCharts.loadingSymbol.value()?this._feedBySymbolDebounceCounter<100&&(this._feedBySymbolDebounceCounter++,this._searchChartsLoadDebounced=(0,s.default)(t,2e3),this._searchChartsLoadDebounced(e)):this._searchCharts.feedBySymbol(e)}_linkingGroup(e){e=null;let t=this._linkingGroups.get(e);if(void 0===t){const i={watchedSymbols:this._watchedSymbols,watchedSymbol:this._watchedSymbol,seriesShortSymbol:this._seriesShortSymbol,proSymbol:this._proSymbol,ensuredProSymbol:this._ensuredProSymbol,watchedInterval:this._watchedInterval,watchedIntraday:this._watchedIntraday,watchedSeconds:this._watchedSeconds,watchedTicks:this._watchedTicks,watchedDataFrequencyResolution:this._watchedDataFrequencyResolution,watchedRange:this._watchedRange,watchedSupportedResolutions:this._watchedSupportedResolutions,watchedSupportedChartStyles:this._watchedSupportedChartStyles,symbolNamesList:this._symbolNamesList};t=new g(e,i,(()=>this._activeLinkingGroup.value())),this._linkingGroups.set(e,t),this._chartWidgetCollection&&t.bindToChartWidgetCollection(this._chartWidgetCollection)}return t}_unbindFromChartWidgetCollection(){null!==this._chartWidgetCollection&&(this._activeLinkingGroupIndex?.destroy(),this._activeLinkingGroupIndex=null,this._linkingGroups.forEach((e=>e.unbindFromChartWidgetCollection())),this._chartWidgetCollection.allLinkingGroups().unsubscribe(this._updateLinkingGroups),this._chartWidgetCollection=null)}};window.TradingViewApi||(window.TradingViewApi={linking:f})},11417:(e,t,i)=>{"use strict";const{getLogger:s}=i(9343),o=s("TVLocalStorage");var n=function(){try{this.isAvailable=!0,this.localStorage=window.localStorage,this.localStorage.setItem("tvlocalstorage.available","true")}catch(e){delete this.isAvailable,delete this.localStorage}this._updateLength();try{this._report()}catch(e){}}
;n.prototype._report=function(){if(this.isAvailable){const e=10,t=[];for(let e=0;e<this.localStorage.length;e++){const i=this.key(e);t.push({key:i,length:String(this.getItem(i)).length})}t.sort(((e,t)=>t.length-e.length));const i=t.slice(0,e);t.sort(((e,t)=>t.key.length-e.key.length));const s=t.slice(0,e);o.logNormal(`Total amount of keys in Local Storage: ${this.length}`),o.logNormal(`Top ${e} keys with longest values: ${JSON.stringify(i)}`),o.logNormal(`Top ${e} longest key names: ${JSON.stringify(s)}`);try{navigator.storage.estimate().then((e=>{o.logNormal(`Storage estimate: ${JSON.stringify(e)}`)}))}catch(e){}}},n.prototype.length=0,n.prototype.isAvailable=!1,n.prototype.localStorage={"tvlocalstorage.available":"false"},n.prototype._updateLength=function(){if(this.isAvailable)this.length=this.localStorage.length;else{var e,t=0;for(e in this.localStorage)this.localStorage.hasOwnProperty(e)&&t++;this.length=t}},n.prototype.key=function(e){return this.isAvailable?this.localStorage.key(e):Object.keys(this.localStorage)[e]},n.prototype.getItem=function(e){return this.isAvailable?this.localStorage.getItem(e):void 0===this.localStorage[e]?null:this.localStorage[e]},n.prototype.setItem=function(e,t){this.isAvailable?this.localStorage.setItem(e,t):this.localStorage[e]=t,this._updateLength()},n.prototype.removeItem=function(e){this.isAvailable?this.localStorage.removeItem(e):delete this.localStorage[e],this._updateLength()},n.prototype.clear=function(){this.isAvailable?this.localStorage.clear():this.localStorage={},this._updateLength()},window.TVLocalStorage=new n,e.exports.TVLocalStorage=window.TVLocalStorage},84015:(e,t,i)=>{"use strict";function s(e,t=!1){return!1}function o(e,t=!1){return e}i.d(t,{isOnMobileAppPage:()=>s,urlWithMobileAppParams:()=>o})},69109:(e,t,i)=>{"use strict";let s;function o(e,t){s?.(e,t)}function n(e){s=e}i.d(t,{muteLinkingGroup:()=>o,setMuteLinkingGroup:()=>n})},19334:(e,t,i)=>{"use strict";i.d(t,{addPerfMark:()=>c,perfMeasureOperation:()=>h});var s=i(4226);function o(){}const n=console.timeStamp?console.timeStamp.bind(console):o,r=window.performance&&performance.mark?performance.mark.bind(performance):o,a=window.performance&&performance.measure?performance.measure.bind(performance):o,l=window.performance&&performance.clearMarks?performance.clearMarks.bind(performance):o;function c(e){n(e),r(e)}async function h(e,t){const i=`measure-${e}-${(0,s.randomHash)()}`;r(i);try{return await t()}finally{a(e,i),l(i)}}},16216:(e,t,i)=>{"use strict";i.d(t,{hasService:()=>r,registerService:()=>n,service:()=>a});const s={},o=new Map;function n(e,t){if(r(e))throw new Error("Service already registered");s[e.id]=t;const i=o.get(e.id);void 0!==i&&(o.delete(e.id),i.resolve(t))}function r(e){return void 0!==s[e.id]}function a(e){const t=s[e.id];if(void 0===t)throw new Error("ServiceLocator: Service "+e.id+" not found");return t}},1765:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>z,getBool:()=>T,getFloat:()=>P,getInt:()=>x,getJSON:()=>w,getValue:()=>b,keys:()=>A,keysMask:()=>L,loaded:()=>F,loadedModel:()=>W,
onSync:()=>R,remove:()=>C,setJSON:()=>I,setSettingsAdapter:()=>O,setValue:()=>M,sync:()=>N});i(49483),i(32925);var s=i(21097),o=i(11417),n=i(48096),r=i(37103);window.TradingView=window.TradingView||{};const a=["s.tradingview.com","betacdn.tradingview.com"],l=r.enabled("use_localstorage_for_settings"),c=(window.environment,10),h=window.TradingView.onWidget?.()?"tradingview-widget":"tradingview",d=h+".";let u,_=!1,p=null,m={};const g=[/^widgetbar\.widget\.watchlist.+/,/.+quicks$/,/^widgetbar\.layout-settings$/,/^ChartSideToolbarWidget\.visible$/,/^onwidget\.watchlist$/,/^chart\.favoriteDrawings$/,/^chart\.favoriteDrawingsPosition$/,/^chart\.favoriteLibraryIndicators$/,/^loadChartDialog.favorites$/,/^ChartFavoriteDrawingToolbarWidget\.visible/,/^trading\.chart\.proterty$/,/^trading_floating_toolbar\.position$/,/^trading\.orderWidgetMode\./,/^symbolWatermark$/,/^pinereference\.size$/,/^pinereference\.position$/,/^hint\.+/,/^ChartDrawingToolbarWidget\.visible/];g.push(/^savedwatch\..+/);const f=()=>!p&&l,y=e=>d+e,v=e=>{},S=(e,t={})=>{if(p)null==m[e]?p.removeValue(e):p.setValue(e,m[e]);else if(f())try{null==m[e]?o.TVLocalStorage.removeItem(y(e)):o.TVLocalStorage.setItem(y(e),m[e])}catch(e){}else 0;t.skipCrossWindowEvent||s.TVXWindowEvents.emit("settings",JSON.stringify({key:e,value:m[e]}))};function b(e,t){const i=m[e];return i??t}function w(e,t){const i=b(e);if(null==i)return t;try{return JSON.parse(i)}catch(i){return C(e),t}}function C(e,t={}){return null!=m[e]&&(delete m[e],S(e)),t.forceFlush&&v(),H}function T(e,t){const i=b(e);return null==i?t:!(!i||"false"===i||0==+i)}function P(e,t){const i=b(e);if(null==i)return t;const s=parseFloat(i);if(!isFinite(s))throw new TypeError('"'+i+'" is not float (key: "'+e+'")');return s}function x(e,t){const i=b(e);if(null==i)return t;const s=parseInt(i,10);if(!isFinite(s))throw new TypeError('"'+i+'" is not int (key: "'+e+'")');return s}function M(e,t,i={}){const s=""+t;return m[e]!==s&&(m[e]=s,S(e,i)),i.forceFlush&&!u&&(u=setTimeout((()=>{u=void 0,v()}),c)),H}function I(e,t,i){return M(e,JSON.stringify(t),i),H}function A(){return Object.keys(m)}function L(e){const t=A(),i=[],s=new RegExp("^"+(o=e,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/\\\*\\\*/gi,".+").replace(/\\\*/gi,"[^.]+")+"$","gi");var o;for(let e=t.length-1;e>=0;e--)s.test(t[e])&&i.push(t[e]),s.lastIndex=0;return i}s.TVXWindowEvents.on("settings",(e=>{const t=JSON.parse(e);null==t.value?delete m[t.key]:m[t.key]=t.value}));const k=e=>{for(let t=0;t<g.length;++t)if(g[t].exec(e))return!0;return!1},E=e=>e.substring(0,d.length)===d,D=()=>{m={};const e=!r.enabled("save_chart_properties_to_local_storage");for(let t=o.TVLocalStorage.length;t--;){const i=o.TVLocalStorage.key(t);if(!i||!E(i))continue;const s=i.substring(d.length);e&&!k(s)||(m[s]=o.TVLocalStorage.getItem(i))}},B=e=>{m={};const t=0===Object.keys(e).length;t||(e=>{Object.keys(e).forEach((t=>{m[t]=e[t]+""}))})(e),(e=>{for(let t=o.TVLocalStorage.length;t--;){const i=o.TVLocalStorage.key(t);i&&E(i)&&(e&&M(i.substring(d.length),o.TVLocalStorage.getItem(i)),
o.TVLocalStorage.removeItem(i))}})(t)},V=()=>{if(!window.TradingView.onWidget?.()||!a.includes(window.location.host))return;const e="tradingview.";for(let t=o.TVLocalStorage.length;t--;){const i=o.TVLocalStorage.key(t);if(0===i.indexOf(e)){const t=i.replace(e,h+".");o.TVLocalStorage.setItem(t,o.TVLocalStorage.getItem(i)),o.TVLocalStorage.removeItem(i)}}},R=new n.Delegate;function N(e){null!==e?(p?B(p.initialSettings||{}):f()?(V(),D()):B(e||{}),R.fire()):_=!0}function O(e){p=e}const F=!1,W=!1,H={loaded:F,loadedModel:W,getValue:b,getJSON:w,getBool:T,getFloat:P,getInt:x,setValue:M,setJSON:I,remove:C,keys:A,keysMask:L,sync:N,onSync:R,setSettingsAdapter:O},z=H;window.TVSettings=H},97995:(e,t,i)=>{"use strict";i.d(t,{trackDrawingToolSelected:()=>s});i(11946),i(78861);function s(e,t){0}},88145:(e,t,i)=>{"use strict";function s(e){return void 0!==e&&e.includes("crypto")}function o(e){return"bond"===e}function n(e){return"economic"===e}function r(e){return"spread"===e}function a(e){return"futures"===e}function l(e){return Boolean(e.typespecs?.includes("yield"))}function c(e){return e?.includes("discontinued")??!1}i.d(t,{hasCryptoTypespec:()=>s,isBond:()=>o,isEconomicSymbol:()=>n,isFutures:()=>a,isSpread:()=>r,isSymbolDelisted:()=>c,isYield:()=>l})},49156:(e,t,i)=>{"use strict";i.d(t,{colors:()=>a});var s=i(58978),o=i(52859);const n={colorBlack:(0,s.getHexColorByName)("color-black"),colorWhite:(0,s.getHexColorByName)("color-white"),colorTvBlue50:(0,s.getHexColorByName)("color-tv-blue-50"),colorTvBlue200:(0,s.getHexColorByName)("color-tv-blue-200"),colorTvBlue400:(0,s.getHexColorByName)("color-tv-blue-400"),colorTvBlue500:(0,s.getHexColorByName)("color-tv-blue-500"),colorTvBlue600:(0,s.getHexColorByName)("color-tv-blue-600"),colorTvBlue800:(0,s.getHexColorByName)("color-tv-blue-800"),colorTvBlueA800:(0,s.getHexColorByName)("color-tv-blue-a800"),colorDeepBlue200:(0,s.getHexColorByName)("color-deep-blue-200"),colorDeepBlue300:(0,s.getHexColorByName)("color-deep-blue-300"),colorDeepBlue500:(0,s.getHexColorByName)("color-deep-blue-500"),colorDeepBlueA200:(0,s.getHexColorByName)("color-deep-blue-a200"),colorDeepBlueA400:(0,s.getHexColorByName)("color-deep-blue-a400"),colorDeepBlueA700:(0,s.getHexColorByName)("color-deep-blue-a700"),colorSkyBlue400:(0,s.getHexColorByName)("color-sky-blue-400"),colorSkyBlue500:(0,s.getHexColorByName)("color-sky-blue-500"),colorSkyBlue700:(0,s.getHexColorByName)("color-sky-blue-700"),colorDefaultRed:(0,s.getHexColorByName)("color-youtube"),colorRipeRed200:(0,s.getHexColorByName)("color-ripe-red-200"),colorRipeRed300:(0,s.getHexColorByName)("color-ripe-red-300"),colorRipeRed400:(0,s.getHexColorByName)("color-ripe-red-400"),colorRipeRed500:(0,s.getHexColorByName)("color-ripe-red-500"),colorRipeRed600:(0,s.getHexColorByName)("color-ripe-red-600"),colorRipeRed800:(0,s.getHexColorByName)("color-ripe-red-800"),colorRipeRedA900:(0,s.getHexColorByName)("color-ripe-red-a900"),colorRipeRedA700:(0,s.getHexColorByName)("color-ripe-red-a700"),colorGrapesPurpleA200:(0,
s.getHexColorByName)("color-grapes-purple-a200"),colorGrapesPurpleA400:(0,s.getHexColorByName)("color-grapes-purple-a400"),colorGrapesPurple500:(0,s.getHexColorByName)("color-grapes-purple-500"),colorBerryPink400:(0,s.getHexColorByName)("color-berry-pink-400"),colorBerryPink500:(0,s.getHexColorByName)("color-berry-pink-500"),colorMintyGreen100:(0,s.getHexColorByName)("color-minty-green-100"),colorMintyGreen200:(0,s.getHexColorByName)("color-minty-green-200"),colorMintyGreen400:(0,s.getHexColorByName)("color-minty-green-400"),colorMintyGreen500:(0,s.getHexColorByName)("color-minty-green-500"),colorMintyGreen600:(0,s.getHexColorByName)("color-minty-green-600"),colorMintyGreen800:(0,s.getHexColorByName)("color-minty-green-800"),colorMintyGreenA900:(0,s.getHexColorByName)("color-minty-green-a900"),colorIguanaGreen300:(0,s.getHexColorByName)("color-iguana-green-300"),colorIguanaGreen500:(0,s.getHexColorByName)("color-iguana-green-500"),colorIguanaGreenA700:(0,s.getHexColorByName)("color-iguana-green-a700"),colorTanOrange300:(0,s.getHexColorByName)("color-tan-orange-300"),colorTanOrange500:(0,s.getHexColorByName)("color-tan-orange-500"),colorTanOrange600:(0,s.getHexColorByName)("color-tan-orange-600"),colorTanOrange700:(0,s.getHexColorByName)("color-tan-orange-700"),colorColdGray100:(0,s.getHexColorByName)("color-cold-gray-100"),colorColdGray150:(0,s.getHexColorByName)("color-cold-gray-150"),colorColdGray200:(0,s.getHexColorByName)("color-cold-gray-200"),colorColdGray300:(0,s.getHexColorByName)("color-cold-gray-300"),colorColdGray400:(0,s.getHexColorByName)("color-cold-gray-400"),colorColdGray450:(0,s.getHexColorByName)("color-cold-gray-450"),colorColdGray500:(0,s.getHexColorByName)("color-cold-gray-500"),colorColdGray550:(0,s.getHexColorByName)("color-cold-gray-550"),colorColdGray600:(0,s.getHexColorByName)("color-cold-gray-600"),colorColdGray650:(0,s.getHexColorByName)("color-cold-gray-650"),colorColdGray700:(0,s.getHexColorByName)("color-cold-gray-700"),colorColdGray750:(0,s.getHexColorByName)("color-cold-gray-750"),colorColdGray800:(0,s.getHexColorByName)("color-cold-gray-800"),colorColdGray850:(0,s.getHexColorByName)("color-cold-gray-850"),colorColdGray900:(0,s.getHexColorByName)("color-cold-gray-900"),colorForestGreen300:(0,s.getHexColorByName)("color-forest-green-300")},r={colorWhiteAlpha25:(0,o.generateColor)(n.colorWhite,75),colorTvBlue500Alpha40:(0,o.generateColor)(n.colorTvBlue500,60),colorTvBlue500Alpha30:(0,o.generateColor)(n.colorTvBlue500,70),colorTvBlue500Alpha28:(0,o.generateColor)(n.colorTvBlue500,72),colorTvBlue500Alpha25:(0,o.generateColor)(n.colorTvBlue500,75),colorTvBlue500Alpha20:(0,o.generateColor)(n.colorTvBlue500,80),colorDeepBlue500Alpha20:(0,o.generateColor)(n.colorDeepBlue500,80),colorSkyBlue400Alpha5:(0,o.generateColor)(n.colorSkyBlue400,95),colorSkyBlue400Alpha50:(0,o.generateColor)(n.colorSkyBlue400,50),colorSkyBlue400Alpha75:(0,o.generateColor)(n.colorSkyBlue400,25),colorSkyBlue500Alpha20:(0,o.generateColor)(n.colorSkyBlue500,80),colorSkyBlue500Alpha25:(0,
o.generateColor)(n.colorSkyBlue500,75),colorSkyBlue700Alpha70:(0,o.generateColor)(n.colorSkyBlue700,30),colorRipeRed400Alpha5:(0,o.generateColor)(n.colorRipeRed400,95),colorRipeRed500Alpha5:(0,o.generateColor)(n.colorRipeRed500,95),colorRipeRed500Alpha20:(0,o.generateColor)(n.colorRipeRed500,80),colorRipeRed500Alpha28:(0,o.generateColor)(n.colorRipeRed500,72),colorRipeRed500Alpha30:(0,o.generateColor)(n.colorRipeRed500,70),colorRipeRed500Alpha50:(0,o.generateColor)(n.colorRipeRed500,50),colorGrapesPurpleA200Alpha15:(0,o.generateColor)(n.colorGrapesPurpleA200,85),colorGrapesPurple500Alpha0:(0,o.generateColor)(n.colorGrapesPurple500,100),colorGrapesPurple500Alpha20:(0,o.generateColor)(n.colorGrapesPurple500,80),colorGrapesPurple500Alpha70:(0,o.generateColor)(n.colorGrapesPurple500,30),colorBerryPink400Alpha50:(0,o.generateColor)(n.colorBerryPink400,50),colorBerryPink400Alpha75:(0,o.generateColor)(n.colorBerryPink400,25),colorBerryPink500Alpha20:(0,o.generateColor)(n.colorBerryPink500,80),colorBerryPink500Alpha25:(0,o.generateColor)(n.colorBerryPink500,75),colorMintyGreen500Alpha20:(0,o.generateColor)(n.colorMintyGreen500,80),colorMintyGreen500Alpha28:(0,o.generateColor)(n.colorMintyGreen500,72),colorMintyGreen500Alpha50:(0,o.generateColor)(n.colorMintyGreen500,50),colorMintyGreen500Alpha5:(0,o.generateColor)(n.colorMintyGreen500,95),colorIguanaGreen500Alpha20:(0,o.generateColor)(n.colorIguanaGreen500,80),colorTanOrange500Alpha20:(0,o.generateColor)(n.colorTanOrange500,80),colorForestGreen300Alpha5:(0,o.generateColor)(n.colorForestGreen300,95),colorColdGray100Alpha0:(0,o.generateColor)(n.colorColdGray100,100),colorColdGray100Alpha6:(0,o.generateColor)(n.colorColdGray100,94),colorColdGray800Alpha0:(0,o.generateColor)(n.colorColdGray800,100),colorColdGray800Alpha6:(0,o.generateColor)(n.colorColdGray800,94)},a={...n,...r}},2433:(e,t,i)=>{"use strict";i.d(t,{light:()=>te});var s=i(49156),o=i(93201);const{colorWhite:n,colorBlack:r,colorColdGray150:a,colorColdGray300:l,colorColdGray400:c,colorColdGray450:h,colorColdGray800Alpha0:d,colorColdGray800Alpha6:u,colorColdGray900:_,colorGrapesPurpleA400:p,colorGrapesPurpleA200Alpha15:m,colorMintyGreen200:g,colorMintyGreen400:f,colorMintyGreen500:y,colorMintyGreen600:v,colorMintyGreen800:S,colorMintyGreen500Alpha5:b,colorMintyGreen500Alpha28:w,colorMintyGreen500Alpha50:C,colorRipeRed200:T,colorRipeRed400:P,colorRipeRed500:x,colorRipeRed600:M,colorRipeRedA700:I,colorRipeRed500Alpha5:A,colorRipeRed500Alpha28:L,colorRipeRed500Alpha50:k,colorDeepBlueA700:E,colorBerryPink500:D,colorBerryPink500Alpha25:B,colorBerryPink400Alpha50:V,colorBerryPink400Alpha75:R,colorIguanaGreenA700:N,colorSkyBlue400Alpha5:O,colorSkyBlue400Alpha50:F,colorSkyBlue400Alpha75:W,colorSkyBlue500:H,colorSkyBlue500Alpha25:z,colorDeepBlueA400:U,colorTvBlue200:j,colorTvBlue400:G,colorTvBlue500:q,colorTvBlue500Alpha28:$,colorTvBlue600:K,colorTvBlue800:Y,colorTanOrange500:Z,colorTanOrange600:X}=s.colors,J={},Q={},ee={},te={content:{chartProperties:{scalesProperties:{textColor:_,lineColor:d,backgroundColor:n},
paneProperties:{vertGridProperties:{color:u},horzGridProperties:{color:u},crossHairProperties:{color:c},backgroundType:o.ColorType.Solid,background:n,backgroundGradientStartColor:n,backgroundGradientEndColor:n,separatorColor:a}},sessions:{sessionHighlight:{backgrounds:{outOfSession:{color:q,transparency:92},preMarket:{color:Z,transparency:92},postMarket:{color:q,transparency:92},electronic:{color:q,transparency:92}},vertlines:{sessBreaks:{color:"#4985e7"}}}},mainSourceProperties:{baseLineColor:l,prevClosePriceLineColor:"#555555",priceLineColor:"",highLowAvgPrice:{highLowPriceLinesColor:"",averagePriceLineColor:""},bidAsk:{bidLineColor:q,askLineColor:P},prePostMarket:{preMarketColor:X,postMarketColor:q},candleStyle:{borderColor:"#378658",upColor:y,wickColor:"#737375",wickUpColor:y,wickDownColor:x,downColor:x,borderUpColor:y,borderDownColor:x},volCandlesStyle:{borderColor:"#378658",upColor:y,wickColor:"#737375",wickUpColor:y,wickDownColor:x,downColor:x,borderUpColor:y,borderDownColor:x},haStyle:{borderColor:"#378658",upColor:y,wickColor:"#737375",wickUpColor:y,wickDownColor:x,downColor:x,borderUpColor:y,borderDownColor:x},hlcAreaStyle:{highLineColor:H,lowLineColor:D,closeLineColor:q,highCloseFillColor:z,closeLowFillColor:B},hollowCandleStyle:{upColor:y,downColor:x,borderColor:"#378658",borderUpColor:y,borderDownColor:x,wickColor:"#737375",wickUpColor:y,wickDownColor:x},barStyle:{downColor:x,upColor:y},pnfStyle:{downColor:x,upColor:y,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae"},baselineStyle:{baselineColor:h,topFillColor1:w,topFillColor2:b,bottomFillColor1:A,bottomFillColor2:L,topLineColor:y,bottomLineColor:x},areaStyle:{transparency:100,color1:$,color2:q,linecolor:q},hiloStyle:{color:q,borderColor:q,labelColor:q},columnStyle:{upColor:C,downColor:k},renkoStyle:{upColor:y,downColor:x,borderUpColor:y,borderDownColor:x,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae",wickUpColor:y,wickDownColor:x},lineStyle:{colorType:o.ColorType.Gradient,color:q,gradientStartColor:p,gradientEndColor:"#00BCE5"},lineWithMarkersStyle:{colorType:o.ColorType.Gradient,color:q,gradientStartColor:p,gradientEndColor:"#00BCE5"},steplineStyle:{colorType:o.ColorType.Gradient,color:q,gradientStartColor:p,gradientEndColor:"#00BCE5"},kagiStyle:{downColor:x,upColor:y,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae"},pbStyle:{upColor:y,downColor:x,borderUpColor:y,borderDownColor:x,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae"},rangeStyle:{upColor:y,downColor:x,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",candlesUpColor:y,candlesDownColor:x,candlesBorderUpColor:y,candlesBorderDownColor:x,candlesWickUpColor:y,candlesWickDownColor:x},tpoStyle:J,volFootprintStyle:Q,svpStyle:ee,hlcBarsStyle:{color:q}}}}},24317:(e,t,i)=>{"use strict";i.r(t),i.d(t,{darkTheme:()=>ce,getStdChartTheme:()=>_e,getStdThemeNames:()=>ue,lightTheme:()=>le,overrideStdTheme:()=>he,
restoreStdThemes:()=>de,translateThemeName:()=>pe});var s=i(11542),o=i(87465),n=i(2433),r=i(93201),a=i(49156);const{colorWhite:l,colorColdGray100Alpha0:c,colorColdGray100Alpha6:h,colorColdGray200:d,colorColdGray300:u,colorColdGray400:_,colorColdGray450:p,colorColdGray600:m,colorColdGray800:g,colorColdGray850:f,colorColdGray900:y,colorDeepBlueA200:v,colorGrapesPurpleA400:S,colorGrapesPurpleA200Alpha15:b,colorMintyGreen400:w,colorMintyGreen500:C,colorMintyGreen600:T,colorMintyGreen800:P,colorMintyGreen500Alpha5:x,colorMintyGreen500Alpha28:M,colorMintyGreen500Alpha50:I,colorMintyGreenA900:A,colorRipeRed400:L,colorRipeRed500:k,colorRipeRed600:E,colorRipeRed800:D,colorRipeRed500Alpha5:B,colorRipeRed500Alpha28:V,colorRipeRed500Alpha50:R,colorRipeRedA900:N,colorBerryPink500Alpha25:O,colorBerryPink400Alpha50:F,colorBerryPink400Alpha75:W,colorBerryPink500:H,colorIguanaGreenA700:z,colorSkyBlue400Alpha5:U,colorSkyBlue400Alpha50:j,colorSkyBlue400Alpha75:G,colorSkyBlue500:q,colorSkyBlue500Alpha25:$,colorDeepBlueA400:K,colorTvBlue400:Y,colorTvBlue500:Z,colorTvBlue500Alpha28:X,colorTvBlue600:J,colorTvBlue800:Q,colorTvBlueA800:ee,colorTanOrange500:te,colorTanOrange600:ie}=a.colors,se={},oe={},ne={},re={content:{chartProperties:{scalesProperties:{textColor:u,lineColor:c,backgroundColor:l},paneProperties:{vertGridProperties:{color:h},horzGridProperties:{color:h},crossHairProperties:{color:_},background:y,backgroundGradientStartColor:f,backgroundGradientEndColor:y,backgroundType:"solid",separatorColor:g}},sessions:{sessionHighlight:{backgrounds:{outOfSession:{color:Z,transparency:92},preMarket:{color:te,transparency:92},postMarket:{color:Z,transparency:92},electronic:{color:Z,transparency:92}},vertlines:{sessBreaks:{color:"#4985e7"}}}},mainSourceProperties:{baseLineColor:m,prevClosePriceLineColor:"#555555",priceLineColor:"",highLowAvgPrice:{highLowPriceLinesColor:"",averagePriceLineColor:""},bidAsk:{bidLineColor:Z,askLineColor:L},prePostMarket:{preMarketColor:ie,postMarketColor:Z},candleStyle:{borderColor:"#378658",upColor:C,wickColor:"#737375",wickUpColor:C,wickDownColor:k,downColor:k,borderUpColor:C,borderDownColor:k},volCandlesStyle:{borderColor:"#378658",upColor:C,wickColor:"#737375",wickUpColor:C,wickDownColor:k,downColor:k,borderUpColor:C,borderDownColor:k},haStyle:{borderColor:"#378658",upColor:C,wickColor:"#737375",wickUpColor:C,wickDownColor:k,downColor:k,borderUpColor:C,borderDownColor:k},hlcAreaStyle:{highLineColor:q,lowLineColor:H,closeLineColor:Z,highCloseFillColor:$,closeLowFillColor:O},hollowCandleStyle:{upColor:C,downColor:k,borderColor:"#378658",borderUpColor:C,borderDownColor:k,wickColor:"#737375",wickUpColor:C,wickDownColor:k},barStyle:{downColor:k,upColor:C},pnfStyle:{downColor:k,upColor:C,upColorProjection:"#336854",downColorProjection:"#7f323f"},baselineStyle:{baselineColor:p,topFillColor1:M,topFillColor2:x,bottomFillColor1:B,bottomFillColor2:V,topLineColor:C,bottomLineColor:k},areaStyle:{transparency:100,color1:X,color2:Z,linecolor:Z},hiloStyle:{color:Z,borderColor:Z,labelColor:Z},columnStyle:{upColor:I,
downColor:R},renkoStyle:{upColor:C,downColor:k,borderUpColor:C,borderDownColor:k,upColorProjection:"#336854",downColorProjection:"#7f323f",borderUpColorProjection:"#336854",borderDownColorProjection:"#7f323f",wickUpColor:C,wickDownColor:k},lineStyle:{colorType:r.ColorType.Gradient,color:Z,gradientStartColor:S,gradientEndColor:"#00BCE5"},lineWithMarkersStyle:{colorType:r.ColorType.Gradient,color:Z,gradientStartColor:S,gradientEndColor:"#00BCE5"},steplineStyle:{colorType:r.ColorType.Gradient,color:Z,gradientStartColor:S,gradientEndColor:"#00BCE5"},kagiStyle:{downColor:k,upColor:C,upColorProjection:"#336854",downColorProjection:"#7f323f"},pbStyle:{upColor:C,downColor:k,borderUpColor:C,borderDownColor:k,upColorProjection:"#336854",downColorProjection:"#7f323f",borderUpColorProjection:"#336854",borderDownColorProjection:"#7f323f"},rangeStyle:{upColor:C,downColor:k,upColorProjection:"#336854",downColorProjection:"#7f323f",candlesUpColor:C,candlesDownColor:k,candlesBorderUpColor:C,candlesBorderDownColor:k,candlesWickUpColor:C,candlesWickDownColor:k},tpoStyle:se,volFootprintStyle:oe,svpStyle:ne,hlcBarsStyle:{color:Z}}}};var ae=i(24633);let le=(0,o.clone)(n.light),ce=(0,o.clone)(re);function he(e,t){switch(e){case ae.StdTheme.Light:le=(0,o.merge)((0,o.clone)(le),t);break;case ae.StdTheme.Dark:ce=(0,o.merge)((0,o.clone)(ce),t)}}function de(){le=(0,o.clone)(n.light),ce=(0,o.clone)(re)}function ue(){return[ae.StdTheme.Light,ae.StdTheme.Dark]}function _e(e){return(0,o.clone)(e===ae.StdTheme.Light?le:e===ae.StdTheme.Dark?ce:void 0)}function pe(e){return{[ae.StdTheme.Light]:s.t(null,{context:"colorThemeName"},i(96870)),[ae.StdTheme.Dark]:s.t(null,{context:"colorThemeName"},i(85119))}[e]||e}},24633:(e,t,i)=>{"use strict";var s;i.d(t,{StdTheme:()=>s}),function(e){e.Light="light",e.Dark="dark"}(s||(s={}))},22489:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DEFAULT_THEME:()=>h,getCurrentTheme:()=>g,getStdTheme:()=>P,getStdThemeNames:()=>C,getStdThemedValue:()=>x,getTheme:()=>b,getThemeNames:()=>w,getThemedColor:()=>f,isStdThemeName:()=>T,isStdThemedDefaultValue:()=>M,isThemeExist:()=>L,removeTheme:()=>A,restoreTheme:()=>y,saveTheme:()=>I,savedThemeName:()=>v,syncTheme:()=>S,themeListChanged:()=>E,themes:()=>m,translateStdThemeName:()=>k});var s=i(24377),o=i(48096),n=i(1765);function r(){return(0,n.getValue)("current_theme.name")||null}const a=i(34840);var l=i(24317),c=i(45345);const h="light";var d=i(24633),u=i(11542)
;const _=JSON.parse('{"color-header-bg":"color-black","color-body-bg":"color-black","color-body-secondary-bg":"color-cold-gray-900","color-bg-primary":"color-cold-gray-850","color-bg-primary-hover":"color-cold-gray-800","color-bg-secondary":"color-cold-gray-900","color-bg-highlight":"color-cold-gray-900","color-bg-scroll-buttons":"color-cold-gray-800","color-legacy-bg-scroll-buttons":"color-cold-gray-550","color-legacy-bg-widget":"color-cold-gray-900","color-text-primary":"color-cold-gray-200","color-text-secondary":"color-cold-gray-450","color-text-tertiary":"color-cold-gray-400","color-text-disabled":"color-cold-gray-650","color-accent-content":"color-white","color-divider":"color-cold-gray-700","color-divider-hover":"color-cold-gray-800","color-divider-secondary":"color-cold-gray-800","color-box-shadow":"color-cold-gray-900","color-active-hover-text":"color-cold-gray-200","color-alert-text":"color-cold-gray-200","color-border":"color-cold-gray-750","color-border-chat-fields":"color-cold-gray-750","color-border-hover":"color-cold-gray-650","color-border-table":"color-cold-gray-800","color-brand":"color-tv-blue-500","color-brand-hover":"color-tv-blue-600","color-brand-active":"color-tv-blue-700","color-button-hover-bg":"color-cold-gray-850","color-chart-page-bg":"color-cold-gray-800","color-common-tooltip-bg":"color-cold-gray-750","color-danger":"color-ripe-red-600","color-danger-hover":"color-ripe-red-500","color-danger-active":"color-ripe-red-400","color-depthrenderer-fill-style":"color-cold-gray-150","color-depthrenderer-stroke-style":"color-cold-gray-650","color-disabled-border-and-color":"color-cold-gray-800","color-disabled-input":"color-cold-gray-750","color-empty-container-message":"color-cold-gray-450","color-halal":"color-iguana-green-400","color-continuous":"color-cold-gray-500","color-highlight-new":"color-tv-blue-a800","color-icons":"color-cold-gray-450","color-input-bg":"color-cold-gray-800","color-input-textarea-readonly":"color-cold-gray-650","color-input-placeholder-text":"color-cold-gray-700","color-input-publish-bg":"color-cold-gray-900","color-item-active-blue":"color-tv-blue-a900","color-item-hover-active-bg":"color-cold-gray-800","color-item-hover-bg":"color-cold-gray-800","color-item-hover-blue":"color-tv-blue-a800","color-item-selected-blue":"color-tv-blue-a800","color-item-active-text":"color-cold-gray-200","color-item-active-bg":"color-tv-blue-500","color-link":"color-tv-blue-500","color-link-hover":"color-tv-blue-600","color-link-active":"color-tv-blue-700","color-list-item":"color-cold-gray-450","color-list-nth-child-bg":"color-cold-gray-850","color-news-highlight":"color-cold-gray-800","color-pane-bg":"color-cold-gray-900","color-pane-secondary-bg":"color-cold-gray-850","color-placeholder":"color-cold-gray-650","color-popup-menu-item-hover-bg":"color-cold-gray-800","color-popup-menu-separator":"color-cold-gray-700","color-primary-symbol":"color-sky-blue-500","color-row-hover-active-bg":"color-cold-gray-800","color-sb-scrollbar-body-bg":"color-cold-gray-650","color-screener-description":"color-cold-gray-200","color-section-separator-border":"color-cold-gray-750","color-search-button-hover":"color-cold-gray-700","color-separator-table-chat":"color-cold-gray-750","color-success":"color-minty-green-700","color-success-hover":"color-minty-green-600","color-success-active":"color-minty-green-500","color-tag-active-bg":"color-cold-gray-750","color-tag-hover-bg":"color-cold-gray-800","color-text-regular":"color-cold-gray-200","color-toolbar-button-text":"color-cold-gray-200","color-toolbar-button-text-hover":"color-cold-gray-200","color-toolbar-button-text-active":"color-tv-blue-500","color-toolbar-button-text-active-hover":"color-tv-blue-600","color-toolbar-button-background-hover":"color-cold-gray-800","color-toolbar-button-background-secondary-hover":"color-cold-gray-750","color-toolbar-button-background-active":"color-tv-blue-a900","color-toolbar-button-background-active-hover":"color-tv-blue-a800","color-toolbar-toggle-button-background-active":"color-tv-blue-500","color-toolbar-toggle-button-background-active-hover":"color-tv-blue-600","color-toolbar-toggle-button-icon":"color-cold-gray-650","color-toolbar-interactive-element-text-normal":"color-cold-gray-200","color-toolbar-opened-element-bg":"color-cold-gray-800","color-toolbar-divider-background":"color-cold-gray-700","color-popup-background":"color-cold-gray-850","color-popup-element-text":"color-cold-gray-200","color-popup-element-text-hover":"color-cold-gray-250","color-popup-element-background-hover":"color-cold-gray-800","color-popup-element-secondary-text":"color-cold-gray-500","color-popup-element-hint-text":"color-cold-gray-600","color-popup-element-text-active":"color-cold-gray-200","color-popup-element-background-active":"color-tv-blue-500","color-popup-element-toolbox-text":"color-cold-gray-500","color-popup-element-toolbox-text-hover":"color-cold-gray-200","color-popup-element-toolbox-text-active-hover":"color-tv-blue-200","color-popup-element-toolbox-background-hover":"color-cold-gray-750","color-popup-element-toolbox-background-active-hover":"color-tv-blue-700","color-tooltip-bg":"color-cold-gray-750","color-tv-button-checked":"color-cold-gray-450","color-tv-dialog-caption":"color-cold-gray-50","color-tv-dropdown-item-hover-bg":"color-cold-gray-800","color-underlined-text":"color-cold-gray-450","color-widget-pages-bg":"color-cold-gray-900","color-warning":"color-tan-orange-700","color-forex-icon":"color-white","color-list-item-active-bg":"color-tv-blue-500","color-list-item-hover-bg":"color-cold-gray-800","color-list-item-text":"color-cold-gray-200","color-price-axis-label-back":"color-cold-gray-800","color-price-axis-label-text":"color-cold-gray-500","color-price-axis-gear":"color-cold-gray-200","color-price-axis-gear-hover":"color-cold-gray-400","color-price-axis-highlight":"color-cold-gray-800","color-bid":"color-tv-blue-500","color-scroll-bg":"color-cold-gray-750","color-scroll-border":"color-cold-gray-850","color-widget-border":"color-cold-gray-800","color-scroll-buttons-arrow":"color-white","color-control-intent-default":"color-cold-gray-650","color-control-intent-success":"color-minty-green-500","color-control-intent-primary":"color-tv-blue-500","color-control-intent-warning":"color-tan-orange-500","color-control-intent-danger":"color-ripe-red-500","color-growing":"color-minty-green-500","color-falling":"color-ripe-red-500","color-goto-label-background":"color-cold-gray-650","color-pre-market":"color-tan-orange-600","color-pre-market-bg":"color-tan-orange-400","color-post-market":"color-tv-blue-500","color-post-market-bg":"color-tv-blue-400","color-market-open":"color-minty-green-500","color-market-open-bg":"color-minty-green-400","color-market-closed":"color-cold-gray-400","color-market-holiday":"color-cold-gray-400","color-market-expired":"color-ripe-red-500","color-invalid-symbol":"color-ripe-red-400","color-invalid-symbol-hover":"color-ripe-red-500","color-delisted-symbol":"color-ripe-red-600","color-delisted-symbol-hover":"color-ripe-red-800","color-replay-mode":"color-tv-blue-500","color-replay-mode-point-select":"color-cold-gray-250","color-replay-mode-icon":"color-tv-blue-50","color-replay-mode-hover":"color-tv-blue-600","color-notaccurate-mode":"color-berry-pink-600","color-delay-mode":"color-tan-orange-700","color-delay-mode-bg":"color-tan-orange-400","color-eod-mode":"color-grapes-purple-700","color-eod-mode-bg":"color-grapes-purple-400","color-data-problem":"color-ripe-red-600","color-data-problem-bg":"color-ripe-red-400","color-data-problem-hover":"color-ripe-red-500","color-list-item-bg-highlighted":"color-tv-blue-a900","color-list-item-bg-selected":"color-tv-blue-a800","color-list-item-bg-highlighted-hover":"color-tv-blue-a800","color-list-item-bg-selected-hover":"color-tv-blue-a700","color-screener-header-bg":"color-cold-gray-850","color-screener-header-bg-hover":"color-cold-gray-800","color-overlay":"color-cold-gray-950","color-boost-button-content-selected":"color-tv-blue-100","color-boost-button-content-hover":"color-white","color-boost-button-bg-hover":"color-cold-gray-750","color-boost-button-border-hover":"color-cold-gray-750","color-boost-button-border-default":"color-cold-gray-700","color-x-twitter-content":"color-white","color-card-border":"color-cold-gray-700","color-card-border-hover":"color-cold-gray-600","color-background-special-primary":"color-black","color-stroke-special-primary":"color-cold-gray-800","color-selection-bg":"color-tv-blue-a700","color-default-gray":"color-cold-gray-450","color-featured-broker-badge-bg":"color-white","color-featured-broker-badge-bg-hover":"color-cold-gray-100","color-featured-broker-badge-text":"color-cold-gray-900"}')
;var p=i(58978);const m={[d.StdTheme.Light]:{name:d.StdTheme.Light,label:()=>u.t(null,{context:"colorThemeName"},i(96870)),order:2,getThemedColor:e=>(0,p.getHexColorByName)(e)},[d.StdTheme.Dark]:{name:d.StdTheme.Dark,label:()=>u.t(null,{context:"colorThemeName"},i(85119)),order:1,getThemedColor:e=>{const t=_[e]||e;return(0,p.getHexColorByName)(t)}}};function g(){return m[c.watchedTheme.value()]||m[h]}function f(e){return g().getThemedColor(e)}function y(){(0,c.setTheme)(r()||h)}function v(){return r()}function S(){var e;e=g().name,(0,n.setValue)("current_theme.name",e,{forceFlush:!0})}function b(e){return a.loadTheme(e)}function w(){return a.loadThemes()}function C(){return l.getStdThemeNames()}function T(e){return C().includes(e)}function P(e){return l.getStdChartTheme(e)||{content:void 0}}function x(e,t){const i=t||g().name,s=l.getStdChartTheme(i),o=0!==e.length&&e.split(".");return s&&s.content&&o?o.reduce(((e,t)=>e[t]),s.content):null}function M(e,t,i){const o=x(e,i);return null!==o&&(0,s.areEqualRgba)((0,s.parseRgba)(o),(0,s.parseRgba)(String(t)))}async function I(e,t){try{return await a.saveTheme(e,t)}finally{E.fire()}}async function A(e){try{return await a.removeTheme(e)}finally{E.fire()}}function L(e){return a.isThemeExist(e)}function k(e){return l.translateThemeName(e)}const E=new o.Delegate},45345:(e,t,i)=>{"use strict";i.d(t,{setTheme:()=>r,watchedTheme:()=>n});var s,o=i(22613);!function(e){e.ThemeClassPrefix="theme-"}(s||(s={}));const n=new o.WatchedValue;function r(e){n.setValue(e)}n.subscribe((e=>{!function(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),t.document.documentElement.dataset.theme=e}(e,window)}))},51768:(e,t,i)=>{"use strict";i.d(t,{disableTrackingEvents:()=>a,trackEvent:()=>r});var s=i(76422);i(37103);(0,i(9343).getLogger)("Common.TrackEvent");const o=[/Study_(Drawing)_(.*)/,/(Study)_(.*)@tv-basicstudies/,/(Study)_(.*)/,/(Chart Style) (.*)/];let n=!1;const r=(e,t,i)=>{n||((e,t,i)=>{t=t||e||i||"";let n="";for(let e=0;e<o.length;e++){const i=t.match(o[e]);if(i&&3===i.length){t=i[1],n=i[2];break}}(0,s.emit)(t.toLowerCase().replace(" ","_"),{category:e,label:i,value:n})})(e,t,i)};function a(){n=!0}var l,c,h;"undefined"!=typeof window&&(window.TradingView=window.TradingView||{},window.TradingView.trackEvent=r),function(e){e.GUI="GUI"}(l||(l={})),function(e){e.ChartHeaderToolbar="Chart Header Toolbar",e.ChartBottomToolbar="Chart Bottom Toolbar",e.ChartLeftToolbar="Chart Left Toolbar",e.TimeInterval="Time Interval",e.LoadChartLayout="Load chart layout"}(c||(c={})),function(e){e.Range="range",e.GoTo="go to",e.ChartProperties="chart properties",e.Compare="compare",e.SelectLayout="select layout",e.MagnetMode="magnet mode",e.MagnetSnaps="magnet snaps",e.DrawingMode="drawing mode",e.LockAllDrawing="lock all drawing",e.RemoveDrawing="remove drawing",e.RemoveIndicator="remove indicator",e.RemoveAll="remove all",e.HideDrawings="hide drawings",e.HideIndicators="hide indicators",
e.HidePositions="hide positions",e.HideAll="hide all",e.Sync="sync",e.SyncMode="sync mode",e.SwitchChartLayout="Switch chart layout",e.DeleteChartLayout="Delete chart layout",e.LoadChartLayout="Load chart layout",e.AddToFavorites="Add to favorites",e.Sort="Sort"}(h||(h={}))},21097:(e,t,i)=>{"use strict";i.d(t,{TVXWindowEvents:()=>r});i(40167);var s=i(9343),o=i(11417);const n=(0,s.getLogger)("XWindowEvents");var r;!function(e){const t="tvxwevents.",i={};let s;window.BroadcastChannel?(s=new BroadcastChannel("tvxwevents"),s.addEventListener("message",(function(e){const{data:{event:t,value:s}}=e;i[t]&&i[t].forEach((e=>{e(s)}))})),function(){const e=[],i=performance.now();for(let i=0;i<o.TVLocalStorage.length;i++){const s=o.TVLocalStorage.key(i);s.startsWith(t)&&e.push(s)}const s=o.TVLocalStorage.length;for(const t of e)o.TVLocalStorage.removeItem(t);const r=performance.now()-i;n.logNormal(`Total keys amount in local storage on operation start: ${s}`),n.logNormal(`Keys amount in local storage to be deleted: ${e.length}`),n.logNormal(`Keys to be deleted from local storage: ${JSON.stringify(e)}`),n.logNormal(`Removing keys from local storage took ${r} ms`)}()):window.addEventListener("storage",(function(e){const{newValue:s,key:n}=e;if(null===s||!n||!n.startsWith(t))return;const r=n.substring(11);i[r]&&i[r].forEach((t=>{t(e.newValue)}));o.TVLocalStorage.removeItem(n)})),e.on=function(e,t){i[e]||(i[e]=[]),i[e].push(t)},e.off=function(e,t){if(!i[e])return;const s=i[e].indexOf(t);-1!==s&&(1===i[e].length?delete i[e]:i[e].splice(s,1))},e.emit=function(e,i=Date.now()){try{s?s.postMessage({event:e,value:i}):o.TVLocalStorage.setItem(t+e,i.toString())}catch(e){n.logError(e.message)}}}(r||(r={}))},96937:(e,t,i)=>{"use strict";i.d(t,{activateKeyPressHandler:()=>m,showDialog:()=>g});const s=[];let o=null;function n(e){for(let t=0;t<s.length;t++)if(s[t].name===e)return t;return-1}function r(e){if(!o)for(let t=s.length-1;t>=0&&!0!==s[t].func(e);t--);}window.addEventListener("keypress",r,!1);var a=i(4745),l=i(37103),c=i(59613),h=i(59672),d=i(8686),u=i(51768);let _=null;function p(e){if(!(0,a.globalKeypressMatches)(e))return!1;e.preventDefault();const t=String.fromCharCode(e.charCode);return l.enabled("show_interval_dialog_on_key_press")&&function(e){return/[1-9]/.test(e)}(t)?(0,c.showChangeIntervalDialogAsync)({initVal:t}):l.enabled("symbol_search_hot_key")&&(g({defaultValue:t,selectSearchOnInit:!1,source:"keyboard",trackResultsOptions:{trackResults:!1,emptySearchType:"empty_result__supercharts"},enableOptionsChain:l.enabled("symbol_search_option_chain_selector")}),(0,u.trackEvent)("GUI","SS","hotkey")),!0}function m(){(0,h.loadChangeIntervalDialog)(),function(e,t){const i={name:e,func:t},o=n(i.name);o>-1&&s.splice(o,1),s.unshift(i)}("symbolEdit",p)}function g(e){const t=_=(0,d.loadNewSymbolSearch)().then((i=>{t===_&&i.showDefaultSearchDialog(e)}));return t}},78136:(e,t,i)=>{"use strict";let s;function o(){return s}function n(e){s=e}i.d(t,{getSearchRequestDelay:()=>o,setSearchRequestDelay:()=>n})},52092:(e,t,i)=>{"use strict";i.d(t,{
CLOSE_POPUPS_AND_DIALOGS_COMMAND:()=>s});const s="CLOSE_POPUPS_AND_DIALOGS_COMMAND";var o;!function(e){e[e.Mobile=0]="Mobile",e[e.TabletSmall=480]="TabletSmall",e[e.Tablet=768]="Tablet",e[e.TabletLarge=1024]="TabletLarge",e[e.DesktopSmall=1280]="DesktopSmall",e[e.Desktop=1440]="Desktop",e[e.DesktopLarge=1920]="DesktopLarge"}(o||(o={}))},3615:(e,t,i)=>{"use strict";async function s(e,t){const s=await Promise.all([i.e(3581),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(1171),i.e(6032),i.e(3672),i.e(2537),i.e(8894),i.e(5743),i.e(7780),i.e(4495),i.e(9323),i.e(159),i.e(683),i.e(6633),i.e(9658),i.e(2227),i.e(4931),i.e(3179),i.e(769),i.e(5705),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.renameModule,t)}async function o(e,t){const s=await Promise.all([i.e(3581),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(1171),i.e(6032),i.e(3672),i.e(2537),i.e(8894),i.e(5743),i.e(7780),i.e(4495),i.e(9323),i.e(159),i.e(683),i.e(6633),i.e(9658),i.e(2227),i.e(4931),i.e(3179),i.e(769),i.e(5705),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.confirmModule,t)}async function n(e,t){const s=await Promise.all([i.e(3581),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(1171),i.e(6032),i.e(3672),i.e(2537),i.e(8894),i.e(5743),i.e(7780),i.e(4495),i.e(9323),i.e(159),i.e(683),i.e(6633),i.e(9658),i.e(2227),i.e(4931),i.e(3179),i.e(769),i.e(5705),i.e(8890)]).then(i.bind(i,70493));return s.showSimpleDialog(e,s.warningModule,t)}i.d(t,{showConfirm:()=>o,showRename:()=>s,showWarning:()=>n})},14881:(e,t,i)=>{"use strict";i.d(t,{hideStateChange:()=>n});var s,o=i(48096);!function(e){e.Drawings="drawings",e.Indicators="indicators",e.Positions="positions",e.All="all"}(s||(s={}));const n=new o.Delegate},90995:(e,t,i)=>{"use strict";i.d(t,{getHideModeStateValue:()=>u,getHideOptions:()=>h,getSavedHideMode:()=>_,toggleHideMode:()=>d});var s=i(50151),o=i(11542),n=i(1765),r=i(49470),a=i(78861),l=i(14881);let c=null;function h(){if(null!==c)return c;const e=(0,r.tradingService)();return c=new Map([["drawings",{label:o.t(null,void 0,i(3217)),dataName:"hide-drawing-tools",tooltip:{active:o.t(null,void 0,i(85891)),inactive:o.t(null,void 0,i(52563))},getBoxedValue:()=>(0,a.hideAllDrawings)(),trackLabel:"hide drawings"}],["indicators",{label:o.t(null,void 0,i(72351)),dataName:"hide-indicators",tooltip:{active:o.t(null,void 0,i(98753)),inactive:o.t(null,void 0,i(78525))},getBoxedValue:()=>(0,a.hideAllIndicators)(),trackLabel:"hide indicators"}],["positions",{label:o.t(null,void 0,i(92226)),dataName:"hide-positions-and-orders",tooltip:{active:o.t(null,void 0,i(20506)),inactive:o.t(null,void 0,i(42164))},getBoxedValue:()=>(0,s.ensureNotNull)(e).showTradedSources,inverted:!0,trackLabel:"hide positions"}],["all",{label:o.t(null,void 0,i(47074)),dataName:"hide-all",tooltip:{active:e?o.t(null,void 0,i(86738)):o.t(null,void 0,i(25881)),inactive:e?o.t(null,void 0,i(18216)):o.t(null,void 0,i(90763))},trackLabel:"hide all"}]]),e||c.delete("positions"),c}function d(e){e?n.setValue("ChartToolsHideMode",e):e=_();const t=p();let i=!t;return"all"===e?(m(((e,t,s)=>{
e.setValue(s?!i:i)})),l.hideStateChange.fire({hideMode:e,isActive:i}),i):(m(((s,o,n)=>{if(o===e){const e=t?!n:!s.value();s.setValue(e),i=n?!e:e}else s.setValue(Boolean(n))})),l.hideStateChange.fire({hideMode:e,isActive:i}),i)}function u(e){if("all"===e)return p();const t=(0,s.ensureDefined)(h().get(e)),i=(0,s.ensureDefined)(t.getBoxedValue)().value();return t.inverted?!i:i}function _(){const e=n.getValue("ChartToolsHideMode","drawings");return h().has(e)?e:"drawings"}function p(){let e=!0;return m(((t,i,s)=>{const o=t.value();e=e&&(s?!o:o)})),e}function m(e){h().forEach(((t,i)=>{const s=t.getBoxedValue?.();s&&e(s,i,t.inverted)}))}},25338:(e,t,i)=>{"use strict";i.d(t,{runOrSignIn:()=>s,runOrSignInWithPromo:()=>o});function s(e,t){e()}function o(e,t,i){i()}},87713:(e,t,i)=>{"use strict";i.d(t,{globalCloseDelegate:()=>s,globalCloseMenu:()=>o});const s=new(i(48096).Delegate);function o(){s.fire()}},41183:e=>{e.exports={"css-value-header-toolbar-height":"38px"}},69600:e=>{e.exports={chartsSplitter:"chartsSplitter-L0xapso5",hovered:"hovered-L0xapso5"}},85552:e=>{e.exports={"css-value-pane-controls-padding":"4px"}},15266:e=>{e.exports={paneSeparator:"paneSeparator-uqBaC1Ki",handle:"handle-uqBaC1Ki",mobile:"mobile-uqBaC1Ki",hovered:"hovered-uqBaC1Ki",selected:"selected-uqBaC1Ki",active:"active-uqBaC1Ki"}},34840:(e,t,i)=>{"use strict";i.r(t),i.d(t,{favorStandardStudyTemplate:()=>E,favorStudyTemplate:()=>k,getChartContent:()=>C,getCharts:()=>S,getChartsCount:()=>v,getCustomAdapter:()=>g,getDrawingTemplates:()=>R,getStandardStudyTemplateById:()=>D,getStorageURL:()=>p,getStudyTemplateById:()=>M,getStudyTemplatesList:()=>A,initialize:()=>f,invalidateStudyTemplatesList:()=>L,isThemeExist:()=>j,loadDrawingTemplate:()=>N,loadLayout:()=>T,loadTheme:()=>W,loadThemes:()=>H,openLayoutLink:()=>P,removeChart:()=>b,removeDrawingTemplate:()=>O,removeStudyTemplate:()=>x,removeTheme:()=>U,renameStudyTemplate:()=>B,replaceStudyTemplate:()=>V,saveChart:()=>w,saveDrawingTemplate:()=>F,saveStudyTemplate:()=>I,saveTheme:()=>z,setCustomAdapter:()=>m,updateUser:()=>y});var s=i(9343),o=i(39058),n=i(1765);const r=(0,s.getLogger)("Chart.SaveloadAdapter.Library"),a={error:""};let l,c,h,d,u=null,_=null;function p(e){return`${h}/${encodeURIComponent(d)}/${e}?client=${encodeURIComponent(l)}&user=${encodeURIComponent(c)}`}function m(e){u=e}function g(){return u}function f(e,t,i,s){l=e,c=t,h=i,d=s}function y(e){c=e}function v(e,t){throw new Error("Not implemented")}async function S(){const e=e=>e.map((e=>({id:e.id,name:e.name,image_url:String(e.id),modified_iso:e.timestamp,short_symbol:e.symbol,interval:e.resolution})));if(u)return u.getAllCharts().then(e);try{const t=await fetch(`${p("charts")}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Getting chart content response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get chart content request failed: "+i.message);return e(i.data)}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}async function b(e){if(u)return u.removeChart(e);try{
const t=await fetch(`${p("charts")}&chart=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove chart response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove drawing template request failed: "+i.message)}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}async function w(e,t,i,s,n){const a=n.id,l={name:e,content:JSON.stringify(s),symbol:t,resolution:i};try{if(u){return{result:await u.saveChart({...l,id:a,timestamp:Math.round(Date.now()/1e3)})}}const e=new FormData;for(const t in l)e.append(t,l[t]);let t=p("charts");null!=a&&(t+=`&chart=${encodeURIComponent(a)}`);const i=await fetch(t,{credentials:"same-origin",method:"POST",body:e});if(!i.ok)throw new Error(`Saving chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Saving chart content request failed: "+s.message);return{result:(s.id??a).toString(),response:i}}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}async function C(e){const t=t=>{const i=JSON.parse(t);return i.uid=e.id,i};if(u)return u.getChartContent(e.id).then((e=>t(e)));try{const i=await fetch(`${p("charts")}&chart=${encodeURIComponent(e.id)}`,{credentials:"same-origin"});if(!i.ok)throw new Error(`Getting chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Get chart content request failed: "+s.message);return t(s.data.content)}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}async function T(e){try{return{chartWidgetCollectionState:await C(e),description:e.name,id:e.id,lastModified:e.modified_iso,name:e.name,uid:e.url,username:"",isPrivate:!0}}catch(e){throw r.logWarn("Error loading chart"),e}}function P(e,t){throw new Error("Opening layout link is not supported")}async function x(e){try{const t=G().filter((t=>t!==e));if(u)return q(t),u.removeStudyTemplate({name:e});const i=await fetch(`${p("study_templates")}&template=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!i.ok)throw new Error(`Remove study template response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Remove study template request failed: "+s.message);q(t)}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}async function M(e){try{if(u){return{content:await u.getStudyTemplateContent({name:e})}}const t=await fetch(`${p("study_templates")}&template=${encodeURIComponent(e)}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Get study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get study template request failed: "+i.message);return i.data}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}async function I(e){try{if(u)return u.saveStudyTemplate(e).then((()=>({error:""}))).catch((e=>({error:null!=e?(0,o.errorToString)(e):"error"})));const t=new FormData;t.append("name",e.name),t.append("content",e.content);const i=await fetch(p("study_templates"),{method:"POST",
body:t,credentials:"same-origin"});if(!i.ok)throw new Error(`Save study template response was not OK. Status: ${i.status}.`);const s=await i.json();return{error:"ok"===s.status?"":s.status}}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}async function A(){try{if(_)return _;_=[];const e=e=>(_=e.map((e=>{const t=G().indexOf(e.name);return{id:e.name,is_default:!1,is_fundamental:!1,name:e.name,favorite_date:-1!==t?t:null}})),_);if(u)return u.getAllStudyTemplates().then(e);const t=await fetch(p("study_templates"),{method:"GET",credentials:"same-origin"});if(!t.ok)throw new Error(`Study templates list response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Study templates list request failed: "+i.message);return e(i.data)}catch(e){throw r.logWarn((0,o.errorToString)(e)),e}}function L(){_=null}function k(e,t,i){const s=G();q(t?[...s,e]:s.filter((t=>t!==e))),i?.(null)}function E(e,t,i){k(e,t,i)}async function D(e,t){throw new Error("Not implemented")}function B(e,t,i){throw new Error("Not implemented")}function V(e,t,i){throw new Error("Not implemented")}async function R(e){throw new Error("Not implemented")}async function N(e,t){throw new Error("Not implemented")}async function O(e,t){throw new Error("Not implemented")}async function F(e,t,i){throw new Error("Not implemented")}function W(e){if(null!==u)return u.getChartTemplateContent(e);throw new Error("Not implemented")}function H(){return null!==u?u.getAllChartTemplates():Promise.resolve([])}async function z(e,t){if(null!==u)try{return await u.saveChartTemplate(e,t),a}catch(e){return console.error(e),{error:e instanceof Error?e.message:e.toString()}}throw new Error("Not implemented")}async function U(e){if(null!==u)try{return await u.removeChartTemplate(e),a}catch(e){return console.error(e),{error:e instanceof Error?e.message:e.toString()}}throw new Error("Not implemented")}function j(e){return W(e).then((e=>Boolean(e.content)))}function G(){return n.getJSON("StudyTemplates.quicks",[])}function q(e){n.setJSON("StudyTemplates.quicks",e)}},7304:(e,t,i)=>{"use strict";var s=i(37103);window.onload=function(){location.hostname.indexOf(".")>=0&&!function(){try{return/^(192|172|10)\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]/.test(location.hostname)||/^.*((?:\.local)|localhost)$/.test(location.hostname)}catch(e){return!1}}()&&setTimeout((function(){try{var e=function(){var e=0;return JSON.parse(urlParams.logo).image&&(e="C",s.enabled("link_to_tradingview")||(e="D")),e}();window.ga&&(0!==e&&window.ga("send","event","s",e),urlParams.utm||window.ga("send","event","l"))}catch(e){}}),3e4)}},78966:(e,t,i)=>{"use strict";var s,o=i(51101),n={};e.exports=function(e,t,i,r){var a,l,c,h,d={},u=n[i]||"out_of_session",_=!1,p=i,m=t,g=null,f=null;function y(){var e={};e.symbolname=p,e.status="ok",e.values={},e.values.current_session=u,n[p]=u,r.getChartApiMessager(m).onQuotesData([m].concat([e]))}function v(){if(a)if(h)u="out_of_session";else{var e=(new Date).getTime(),t=o.isTradingNow(e,a)?"market":"out_of_session"
;l&&o.isTradingNow(e,l)?t="pre_market":c&&o.isTradingNow(e,c)&&(t="post_market"),t!==u&&(u=t)}}return e(i,null,(function(e){_||function(e){a=new o.SessionInfo(e.timezone,e.session_display??e.session,e.session_holidays,e.corrections),h=e.expired,e.subsession_id&&e.subsessions?e.subsessions.forEach((t=>{switch(t.id){case"regular":a=new o.SessionInfo(e.timezone,t["session-display"]??t.session,e.session_holidays,t["session-correction"]||e["session-correction"]||e.corrections);break;case"premarket":l=new o.SessionInfo(e.timezone,t["session-display"]??t.session,e.session_holidays,t["session-correction"]||e["session-premarket-correction"]||e.corrections);break;case"postmarket":c=new o.SessionInfo(e.timezone,t["session-display"]??t.session,e.session_holidays,t["session-correction"]||e["session-postmarket-correction"]||e.corrections)}})):(l=void 0,c=void 0);const t=60-new Date(Date.now()).getSeconds();s&&s?.ticker===e.ticker||(s={ticker:e.ticker,timer:t},clearTimeout(s.timeout)),f=setTimeout((()=>{g=setInterval((()=>{v(),y()}),6e4),v(),y()}),1e3*s.timer),s&&void 0!==s?.timeout||(s.timeout=f),v(),y()}(e)}),(function(){})),d.stop=function(){_=!0,g&&clearInterval(g),f&&clearInterval(f)},d.marketStatus=function(){return u},d}},47132:(e,t,i)=>{"use strict";let s;function o(e,t,i,o){return s?.(e,t,i,o)??e}function n(e){s=e}i.d(t,{getVolumeProfileResolutionForPeriod:()=>o,overwriteVolumeProfileResolutionForPeriodGetter:()=>n})},4622:(e,t,i)=>{"use strict";i.d(t,{findSuitableResolutionToBuildFrom:()=>n});var s=i(46082);function o(e,t){const i=t.multiplier();for(let s=e.length-1;s>=0;s--){const o=Number(e[s]);if(i%o==0)return{error:!1,resolution:`${o}${t.letter()}`}}return{error:!0,errorMessage:(s=t.value(),`Misconfiguration error: it is trying to request ${s} but we cannot build it from lower resolution`)};var s}function n(e,t){const i=s.Interval.parse(e);if((i.isWeeks()||i.isMonths())&&t.has_weekly_and_monthly){let e=["1"];i.isWeeks()&&void 0!==t.weekly_multipliers&&(e=t.weekly_multipliers),i.isMonths()&&void 0!==t.monthly_multipliers&&(e=t.monthly_multipliers);const s=o(e,i);if(!s.error)return s}if(i.isDWM()&&(void 0===t.has_daily||t.has_daily))return i.isDays()&&void 0!==t.daily_multipliers?o(t.daily_multipliers,i):void 0===t.daily_multipliers||t.daily_multipliers.includes("1")?{error:!1,resolution:"1D"}:{error:!0,errorMessage:"unsupported_resolution"};if(i.isDWM())return{error:!0,errorMessage:"unsupported_resolution"};if(i.isMinutes()&&!t.has_intraday)return{error:!0,errorMessage:"unsupported_resolution"};if(i.isSeconds()&&!t.has_seconds)return{error:!0,errorMessage:"unsupported_resolution"};const n=t.seconds_multipliers??["1"],r=0===n.length,a=r||n.every((e=>parseInt(e,10)>i.multiplier())),l=t.build_seconds_from_ticks&&(r||a)&&t["is-tickbars-available"];if(i.isSeconds()&&l)return{error:!1,resolution:"1T"};if(i.isTicks())return t["is-tickbars-available"]?{error:!1,resolution:e}:{error:!0,errorMessage:"unsupported_resolution"};const c=i.isSeconds()?t.seconds_multipliers:t.intraday_multipliers;return void 0===c?{error:!1,
resolution:i.value()}:o(c,i)}},45:(e,t,i)=>{"use strict";const s=i(58978).getHexColorByName;var o=i(19979).Std;i(4783);var n=i(32503).pivotPointsStandardStudyItem,r=i(53690).volumeProfileVisibleRangeStudyItem,a=i(74109).volumeProfileFixedRangeVbPStudyItem,l=i(74109).volumeProfileFixedRangeBSStudyItem,c=i(24451).spreadStudyItem,h=i(52691).ratioStudyItem,d=i(57622).regressionTrendStudyItem,u=i(34378).anchoredVWAPStudyItem,_=i(51052).overlayStudyItem,p=i(95603).inactivityGapsStudyItem;const m=s("color-ripe-red-400"),g=s("color-minty-green-400");JSServer.studyLibrary=JSServer.studyLibrary.concat([{name:"Compare",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{compare:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#9C27B0"}},inputs:{source:"close",symbol:""}},plots:[{id:"compare",type:"line"}],styles:{compare:{title:"Plot",histogramBase:0}},description:"Compare",shortDescription:"Compare",is_price_study:!0,inputs:[{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"text"},{id:"symbol",name:"Symbol",type:"symbol",isHidden:!0}],id:"Compare@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(1),o.period(this._context))},this.main=function(e,t){this._context=e;var i=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var s=this._context.new_unlimited_var(this._context.symbol.time),n=o[t(0)](this._context),r=this._context.new_unlimited_var(n);return this._context.select_sym(0),[r.adopt(s,i,0)]}}},_,{name:"Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{vol:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:50,visible:!0,color:"#000080"},vol_ma:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"}},palettes:{volumePalette:{colors:{0:{color:m,width:1,style:0},1:{color:g,width:1,style:0}}}},inputs:{showMA:!1,volumeMA:"SMA",length:20,col_prev_close:!1,symbol:"",smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"vol",type:"line"},{id:"volumePalette",palette:"volumePalette",target:"vol",type:"colorer"},{id:"vol_ma",type:"line"},{id:"smoothedMA",type:"line"}],styles:{vol:{title:"Volume",histogramBase:0},vol_ma:{title:"Volume MA",histogramBase:0},smoothedMA:{title:"Smoothed MA",histogramBase:0}},description:"Volume",shortDescription:"Volume",is_price_study:!1,palettes:{volumePalette:{colors:{0:{name:"Falling"},1:{name:"Growing"}}}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"showMA",name:"show MA",defval:!1,type:"bool",isHidden:!0},{id:"length",name:"MA Length",defval:20,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["vol_ma"]},{id:"volumeMA",name:"Volume MA",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],
hideWhenPlotsHidden:["vol_ma"]},{defval:!1,id:"col_prev_close",name:"Color based on previous close",type:"bool"},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],hideWhenPlotsHidden:["smoothedMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4,hideWhenPlotsHidden:["smoothedMA"]}],id:"Volume@tv-basicstudies-1",format:{type:"volume"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.f_0=function(e,t){return o.gt(e,t)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=o.volume(this._context),s=o.open(this._context),n=o.close(this._context),r=this._context.new_var(this._context.symbol.time),a=this._input(5),l=this._input(6),c=this._input(2),h=this._input(3);if(this._context.setMinimumAdditionalDepth(c+l),""!==this._input(0)){this._context.select_sym(1);var d=this._context.new_var(this._context.symbol.time),u=this._context.new_var(o.volume(this._context)),_=this._context.new_var(o.open(this._context)),p=this._context.new_var(o.close(this._context));i=u.adopt(d,r,1),s=_.adopt(d,r,1),n=p.adopt(d,r,1),this._context.select_sym(0)}var m=this._context.new_var(i),g=o[h.toLowerCase()](m,c,this._context),f=this._context.new_var(g),y=this._context.new_var(n);return[i,y.get(1)&&this._input(4)?this.f_0(y.get(1),n):this.f_0(s,n),g,o[a.toLowerCase()](f,l,this._context)]}}},{name:"ZigZag",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:5,in_1:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",target:"plot_0",type:"dataoffset"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Zig Zag",shortDescription:"ZigZag",is_price_study:!0,classId:"ScriptWithDataOffset",inputs:[{id:"in_0",name:"deviation",defval:5,type:"float",min:.001,max:100},{id:"in_1",name:"depth",defval:10,type:"integer",min:2,max:1e3}],id:"ZigZag@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=i/100,r=Math.ceil(s/2);return[o.zigzag(n,r,this._context),o.zigzagbars(n,r,this._context)]}}},{name:"Sessions",metainfo:{_metainfoVersion:52,defaults:{graphics:{vertlines:{sessBreaks:{color:"#4985e7",style:2,visible:!1,width:1}},backgrounds:{preMarket:{color:"#FF9800",transparency:92,visible:!0},postMarket:{color:"#2196F3",transparency:92,visible:!0}}},linkedToSeries:!0},description:"Sessions",graphics:{vertlines:{sessBreaks:{name:"Session Break",halign:"left"}},backgrounds:{preMarket:{name:"Pre market"},postMarket:{name:"Post market"}}},id:"Sessions@tv-basicstudies-1",inputs:[],is_hidden_study:!0,is_price_study:!0,name:"Sessions@tv-basicstudies",palettes:{},plots:[],shortDescription:"Sessions",format:{type:"inherit"}},constructor:function(){function e(e,t){return{id:e,index:e,extendBottom:!0,extendTop:!0}}
function t(e){return{id:e.start,start:e.start,stop:e.stop}}this.init=function(){this._times=[]},this._getVerticalLineData=function(t){return o.selectSessionBreaks(t,this._times).map(e)},this._getPreAndPostMarketBackgroundsData=function(e){const i=o.selectPreAndPostMarketTimes(e,this._times);return{preMarket:i.preMarket.map(t),postMarket:i.postMarket.map(t)}},this.main=function(e,t){if(o.isdwm(e))return null;var i=o.time(e);if(isNaN(i))return null;var s=this._times.length;if(0!==s&&this._times[s-1]===i||this._times.push(i),!e.symbol.isLastBar||!e.symbol.isNewBar)return null;var n=this._getVerticalLineData(e),r=this._getPreAndPostMarketBackgroundsData(e);return 0===n.length&&0===r.preMarket.length&&0===r.postMarket?null:{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{vertlines:[{styleId:"sessBreaks",data:n}],backgrounds:[{styleId:"preMarket",data:r.preMarket},{styleId:"postMarket",data:r.postMarket}]},erase:[{action:"all"}]}}}}}},{name:"SuperTrend",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:3,plottype:0,trackPrice:!1,transparency:35,visible:!0,color:"#000080"},plot_2:{linestyle:0,linewidth:3,plottype:"shape_arrow_up",trackPrice:!1,location:"BelowBar",transparency:35,visible:!0,color:"#00FF00"},plot_3:{linestyle:0,linewidth:3,plottype:"shape_arrow_down",trackPrice:!1,location:"AboveBar",transparency:35,visible:!0,color:"#FF0000"}},palettes:{palette_0:{colors:{0:{color:"#008000",width:3,style:0},1:{color:"#800000",width:3,style:0}}}},inputs:{in_0:10,in_1:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"},{id:"plot_2",type:"shapes"},{id:"plot_3",type:"shapes"}],styles:{plot_0:{title:"SuperTrend",histogramBase:0,joinPoints:!1,isHidden:!1},plot_2:{title:"Up Arrow",histogramBase:0,joinPoints:!1,isHidden:!1},plot_3:{title:"Down Arrow",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"SuperTrend",shortDescription:"SuperTrend",is_price_study:!0,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}},valToIndex:{0:0,1:1}}},inputs:[{id:"in_0",name:"Length",defval:10,type:"integer",min:1,max:100},{id:"in_1",name:"Factor",defval:3,type:"float",min:1,max:100}],id:"SuperTrend@tv-basicstudies-1",scriptIdPart:"",name:"SuperTrend",isCustomIndicator:!0,format:{type:"inherit"}},constructor:function(){this.main=function(e,t){var i=t(0),s=t(1),[n,r]=o.supertrend(s,i,e),a=e.new_var(r).get(1);return[n,-1===r?0:1,-1===r&&a!==r?1:NaN,1===r&&a!==r?1:NaN]}}},n,r,a,l,c,h,d,u,p])},19979:(e,t,i)=>{"use strict";i.d(t,{Std:()=>h});var s=i(37236),o=i(51101);class n{constructor(e,t,i){this._timezone=e,this._preMarketSessionSpec=t,this._postMarketSessionSpec=i}getPreAndPostMarketTimes(e){if(0===e.length)return{preMarket:[],postMarket:[]};const t=[],i=[];let o=null,n=null,r=e[0],a=(0,s.utc_to_cal)(this._timezone,r);this._isInPreMarketSession(a)&&(n=r),this._isInPostMarketSession(a)&&(o=r);for(let l=1;l<e.length;l++){const c=e[l],h=(0,s.utc_to_cal)(this._timezone,c)
;null!==o&&this._isInPostMarketSession(a)&&!this._isInPostMarketSession(h)&&(i.push({start:o,stop:r}),o=null),null===n&&this._isInPreMarketSession(h)&&(n=c),null===o&&this._isInPostMarketSession(h)&&(o=c),null!==n&&this._isInPreMarketSession(a)&&!this._isInPreMarketSession(h)&&(t.push({start:n,stop:r}),n=null),r=c,a=h}return null!==n&&t.push({start:n,stop:e[e.length-1]}),null!==o&&i.push({start:o,stop:e[e.length-1]}),{preMarket:t,postMarket:i}}_isInPreMarketSession(e){if(null===this._preMarketSessionSpec)return!1;const t=this._preMarketSessionSpec.getWeekIndex(e);return this._anyEntryContains(this._preMarketSessionSpec.getEntriesForWeek(t).list(),e)}_isInPostMarketSession(e){if(null===this._postMarketSessionSpec)return!1;const t=this._postMarketSessionSpec.getWeekIndex(e);return this._anyEntryContains(this._postMarketSessionSpec.getEntriesForWeek(t).list(),e)}_anyEntryContains(e,t){if(void 0===e)return!1;for(let i=0;i<e.length;i++)if(e[i].contains(t))return!0;return!1}}var r=i(51829),a=i(4659);const l=1e-10,c=e=>e?1:0,h={};function d(e,t,i,s,o){let n=o,r=0;if(isNaN(e.get(t-1)))return{index:NaN,value:NaN};for(let i=0;i<t;++i)s(e.get(i),n)&&(r=i,n=e.get(i));return{index:r,value:n}}h.max_series_default_size=10001,h.n=e=>e.symbol.index+1,h.nz=(e,t=0)=>isFinite(e)?e:t,h.na=function(e){return 0===arguments.length?NaN:isNaN(e)?1:0},h.isZero=e=>Math.abs(e)<=1e-10?1:0,h.toBool=e=>isFinite(e)&&!h.isZero(e),h.eq=(e,t)=>h.isZero(e-t),h.neq=(e,t)=>c(!h.eq(e,t)),h.ge=(e,t)=>c(h.isZero(e-t)||e>t),h.gt=(e,t)=>c(!h.isZero(e-t)&&e>t),h.lt=(e,t)=>c(!h.isZero(e-t)&&e<t),h.le=(e,t)=>c(h.isZero(e-t)||e<t),h.and=(e,t)=>isNaN(e)||isNaN(t)?NaN:h.isZero(e)||h.isZero(t)?0:1,h.or=(e,t)=>isNaN(e)||isNaN(t)?NaN:h.isZero(e)&&h.isZero(t)?0:1,h.not=e=>isNaN(e)?NaN:h.isZero(e)?1:0,h.eps=()=>l,h.greaterOrEqual=(e,t,i)=>t-e<(i||l),h.lessOrEqual=(e,t,i)=>e-t<(i||l),h.equal=(e,t,i)=>Math.abs(e-t)<(i||l),h.greater=(e,t,i)=>e-t>(i||l),h.less=(e,t,i)=>t-e>(i||l),h.compare=(e,t,i)=>h.equal(e,t,i)?0:h.greater(e,t,i)?1:-1,h.max=Math.max,h.min=Math.min,h.pow=Math.pow,h.abs=Math.abs,h.log=Math.log,h.log10=e=>Math.log(e)/Math.LN10,h.sqrt=Math.sqrt,h.sign=e=>isNaN(e)?NaN:h.isZero(e)?0:e>0?1:-1,h.exp=Math.exp,h.sin=Math.sin,h.cos=Math.cos,h.tan=Math.tan,h.asin=Math.asin,h.acos=Math.acos,h.atan=Math.atan,h.floor=Math.floor,h.ceil=Math.ceil,h.round=Math.round,h.avg=(...e)=>{if(2===e.length)return(e[0]+e[1])/2;let t=0;for(let i=0;i<e.length;i++)t+=e[i];return t/e.length},h.open=e=>e.symbol.open,h.high=e=>e.symbol.high,h.low=e=>e.symbol.low,h.close=e=>e.symbol.close,h.hl2=e=>(e.symbol.high+e.symbol.low)/2,h.hlc3=e=>(e.symbol.high+e.symbol.low+e.symbol.close)/3,h.ohlc4=e=>(e.symbol.open+e.symbol.high+e.symbol.low+e.symbol.close)/4,h.volume=e=>e.symbol.volume,h.updatetime=e=>e.symbol.updatetime,h.time=e=>e.symbol.bartime(),h.period=e=>e.symbol.period,h.tickerid=e=>e.symbol.tickerid,h.currencyCode=e=>e.symbol.currencyCode,h.unitId=e=>e.symbol.unitId,h.ticker=e=>e.symbol.ticker,h.interval=e=>e.symbol.interval,h.isdwm=e=>e.symbol.isdwm(),h.isintraday=e=>!e.symbol.isdwm(),
h.isdaily=e=>"D"===e.symbol.resolution,h.isweekly=e=>"W"===e.symbol.resolution,h.ismonthly=e=>"M"===e.symbol.resolution,h.year=(e,t)=>h.timepart(e.symbol,s.YEAR,t),h.month=(e,t)=>h.timepart(e.symbol,s.MONTH,t),h.weekofyear=(e,t)=>h.timepart(e.symbol,s.WEEK_OF_YEAR,t),h.dayofmonth=(e,t)=>h.timepart(e.symbol,s.DAY_OF_MONTH,t),h.dayofweek=(e,t)=>h.timepart(e.symbol,s.DAY_OF_WEEK,t),h.hour=(e,t)=>h.timepart(e.symbol,s.HOUR_OF_DAY,t),h.minute=(e,t)=>h.timepart(e.symbol,s.MINUTE,t),h.second=(e,t)=>h.timepart(e.symbol,s.SECOND,t),h.add_days_considering_dst=(e,t,i)=>(0,s.add_days_considering_dst)((0,s.get_timezone)(e),t,i),h.add_years_considering_dst=(e,t,i)=>(0,s.add_years_considering_dst)((0,s.get_timezone)(e),t,i),h.selectSessionBreaks=(e,t)=>{if(h.isdwm(e)||void 0===e.symbol.session.timezone)return[];const i=(0,o.newBarBuilder)(e.symbol.period,e.symbol.session,null),s=[],n=t.length;if(i.moveTo(t[n-1]),1===n&&i.startOfBar(0)===t[0])s.push(t[0]);else{for(let e=n-2;e>=0;--e){const o=t[e];if(o>=i.startOfBar(0))continue;i.moveTo(o);const n=t[e+1];s.push(n)}s.reverse()}return s},h.selectPreAndPostMarketTimes=(e,t)=>{if(h.isdwm(e)||void 0===e.symbol.session.timezone)return{preMarket:[],postMarket:[]};return new n(e.symbol.session.timezone,e.symbol.preMarketSubsession??null,e.symbol.postMarketSubsession??null).getPreAndPostMarketTimes(t)},h.iff=(e,t,i)=>h.not(e)?i:t,h.rising=(e,t)=>{for(let i=1;i<t+1;++i)if(e.get(i)>e.get(0))return 0;return 1},h.falling=(e,t)=>{for(let i=1;i<t+1;++i)if(e.get(i)<e.get(0))return 0;return 1},h.timepart=(e,t,i)=>{const o=(0,s.utc_to_cal)(e.session.timezone,i||e.bartime());return(0,s.get_part)(o,t)},h.rsi=(e,t)=>h.isZero(t)?100:h.isZero(e)?0:100-100/(1+e/t),h.sum=(e,t,i)=>{const s=i.new_var(),o=h.nz(e.get())+h.nz(s.get(1))-h.nz(e.get(t));return s.set(o),o},h.sma=(e,t,i)=>{const s=h.sum(e,t,i);return h.na(e.get(t-1))?NaN:s/t},h.smma=(e,t,i)=>{const s=i.new_var(e),o=h.sma(s,t,i),n=i.new_var(),r=(n.get(1)*(t-1)+e)/t;return n.set(h.na(n.get(1))?o:r),n.get(0)},h.rma=(e,t,i)=>{const s=h.sum(e,t,i),o=t-1,n=e.get(o),r=i.new_var(),a=r.get(1),l=e.get(),c=h.na(n)?NaN:h.na(a)?s/t:(l+a*o)/t;return r.set(c),c},h.fixnan=(e,t)=>{const i=t.new_var();return isNaN(e)?i.get(1):(i.set(e),e)},h.tr=(e,t)=>{let i=t.new_var(h.close(t)).get(1);return e&&isNaN(i)&&(i=h.close(t)),h.max(h.max(h.high(t)-h.low(t),h.abs(h.high(t)-i)),h.abs(h.low(t)-i))},h.atr=(e,t)=>{const i=t.new_var(h.tr(void 0,t));return h.rma(i,e,t)},h.ema=(e,t,i)=>{const s=h.sum(e,t,i),o=i.new_var(),n=e.get(0),r=e.get(t-1),a=o.get(1),l=h.na(r)?NaN:h.na(a)?s/t:2*(n-a)/(t+1)+a;return o.set(l),l},h.wma=(e,t,i)=>{let s=0;for(let i=t=Math.round(t);i>=0;i--){s+=(t-i)*e.get(i)}return 2*s/(t*(t+1))},h.vwma=(e,t,i)=>{const s=i.new_var(h.volume(i)),o=i.new_var(e.get(0)*h.volume(i));return h.sma(o,t,i)/h.sma(s,t,i)},h.swma=(e,t)=>(e.get(0)+2*e.get(1)+2*e.get(2)+e.get(3))/6,h.supertrend=(e,t,i)=>{const s=h.atr(t,i),o=i.new_var(s).get(1),n=h.hl2(i);let r=n+s*e,a=n-s*e;const l=h.close(i),c=i.new_var(l).get(1),d=i.new_var(),u=h.nz(d.get(1)),_=i.new_var(),p=h.nz(_.get(1))
;a=h.gt(a,u)||h.lt(c,u)?a:u,d.set(a),r=h.lt(r,p)||h.gt(c,p)?r:p,_.set(r);let m=h.na();const g=i.new_var(),f=g.get(1);m=h.na(o)?1:f===p?l>r?-1:1:l<a?1:-1;const y=-1===m?a:r;return g.set(y),h.n(i)<=t?[Number.NaN,0]:[y,m]},h.lowestbars=(e,t,i)=>-d(e,t,0,((e,t)=>h.lt(e,t)),Number.MAX_SAFE_INTEGER).index,h.lowest=(e,t,i)=>d(e,t,0,((e,t)=>h.lt(e,t)),Number.MAX_SAFE_INTEGER).value,h.highestbars=(e,t,i)=>-d(e,t,0,((e,t)=>h.gt(e,t)),Number.MIN_SAFE_INTEGER).index,h.highest=(e,t,i)=>d(e,t,0,((e,t)=>h.gt(e,t)),Number.MIN_SAFE_INTEGER).value,h.cum=(e,t)=>{const i=t.new_var(),s=h.nz(i.get(1))+e;return i.set(s),s},h.accdist=e=>{const t=h.high(e),i=h.low(e),s=h.close(e),o=h.volume(e);return h.cum(s===t&&s===i||t===i?0:o*(2*s-i-t)/(t-i),e)},h.correlation=(e,t,i,s)=>{const o=h.sma(e,i,s),n=h.sma(t,i,s),r=s.new_var(e.get()*t.get());return(h.sma(r,i,s)-o*n)/Math.sqrt(h.variance2(e,o,i)*h.variance2(t,n,i))},h.stoch=(e,t,i,s,o)=>{const n=h.highest(t,s,o),r=h.lowest(i,s,o);return h.fixnan(100*(e.get()-r)/(n-r),o)},h.tsi=(e,t,i,s)=>{const o=s.new_var(h.change(e)),n=s.new_var(h.abs(h.change(e))),r=s.new_var(h.ema(o,i,s)),a=s.new_var(h.ema(n,i,s));return h.ema(r,t,s)/h.ema(a,t,s)},h.cross=(e,t,i)=>{if(isNaN(e)||isNaN(t))return!1;const s=i.new_var((o=e-t)<0?-1:0===o?0:1);var o;return!isNaN(s.get(1))&&s.get(1)!==s.get()},h.linreg=(e,t,i)=>{let s=0,o=0,n=0,r=0;for(let i=0;i<t;++i){const a=e.get(i),l=t-1-i+1;s+=l,o+=a,n+=l*l,r+=a*l}const a=(t*r-s*o)/(t*n-s*s);return o/t-a*s/t+a+a*(t-1-i)},h.sar=(e,t,i,s)=>{const o=s.new_var(),n=s.new_var(),r=s.new_var(),a=h.high(s),l=h.low(s),c=h.close(s),d=s.new_var(a),u=s.new_var(l),_=s.new_var(c),p=s.new_var();let m=p.get(1),g=n.get(1),f=r.get(1);n.set(g),r.set(f);let y=!1;const v=u.get(1),S=u.get(2),b=d.get(1),w=d.get(2),C=_.get(),T=_.get(1);2===h.n(s)&&(h.greater(C,T)?(o.set(1),r.set(d.get()),m=v,f=d.get()):(o.set(-1),r.set(u.get()),m=b,f=u.get()),y=!0,n.set(e),g=e);let P=m+g*(f-m);return 1===o.get()?h.greater(P,u.get())&&(y=!0,o.set(-1),P=Math.max(d.get(),r.get()),r.set(u.get()),n.set(e)):h.less(P,d.get())&&(y=!0,o.set(1),P=Math.min(u.get(),r.get()),r.set(d.get()),n.set(e)),y||(1===o.get()?h.greater(d.get(),r.get())&&(r.set(d.get()),n.set(Math.min(n.get()+t,i))):h.less(u.get(),r.get())&&(r.set(u.get()),n.set(Math.min(n.get()+t,i)))),1===o.get()?(P=Math.min(P,v),h.n(s)>2&&(P=Math.min(P,S))):(P=Math.max(P,b),h.n(s)>2&&(P=Math.max(P,w))),p.set(P),P},h.alma=(e,t,i,s)=>{const o=Math.floor(i*(t-1)),n=t/s*(t/s),r=[];let a=0;for(let e=0;e<t;++e){const t=Math.exp(-1*Math.pow(e-o,2)/(2*n));a+=t,r.push(t)}for(let e=0;e<t;++e)r[e]/=a;let l=0;for(let i=0;i<t;++i)l+=r[i]*e.get(t-i-1);return l},h.change=e=>e.get()-e.get(1),h.roc=(e,t)=>{const i=e.get(t);return 100*(e.get()-i)/i},h.dev=(e,t,i)=>{const s=h.sma(e,t,i);return h.dev2(e,t,s)},h.dev2=(e,t,i)=>{let s=0;for(let o=0;o<t;o++){const t=e.get(o);s+=h.abs(t-i)}return s/t},h.stdev=(e,t,i)=>{const s=h.variance(e,t,i);return h.sqrt(s)},h.variance=(e,t,i)=>{const s=h.sma(e,t,i);return h.variance2(e,s,t)},h.variance2=(e,t,i)=>{let s=0;for(let o=0;o<i;o++){
const i=e.get(o),n=h.abs(i-t);s+=n*n}return s/i},h.percentrank=(e,t)=>{if(h.na(e.get(t-1)))return NaN;let i=0;const s=e.get();for(let o=1;o<t;o++){const t=e.get(o);h.ge(s,t)&&i++}return 100*i/t},h.createNewSessionCheck=e=>{if(void 0===e.symbol.session.timezone)return()=>!1;const t=(0,o.newBarBuilder)(e.symbol.period,e.symbol.session,null);return e=>t.indexOfBar(e)===r.SessionStage.POST_SESSION&&(t.moveTo(e),!0)},h.createNthBarInSessionCheck=e=>{if(void 0===e.symbol.session.timezone)return()=>!1;const t=(0,o.newBarBuilder)(e.symbol.period,e.symbol.session,null);return(e,i)=>(t.indexOfBar(e)===r.SessionStage.POST_SESSION&&t.moveTo(e),t.indexOfBar(e)===i)},h.error=(e,t)=>{throw new a.StudyError(e,t)},h.dmi=(e,t,i)=>{const s=i.new_var(h.high(i)),o=i.new_var(h.low(i)),n=h.change(s),r=-h.change(o),a=i.new_var(h.na(n)||h.na(r)?h.na():h.and(h.gt(n,r),h.gt(n,0))?n:0),l=i.new_var(h.na(r)?h.na():h.and(h.gt(r,n),h.gt(r,0))?r:0),c=h.atr(e,i),d=h.fixnan(100*h.rma(a,e,i)/c,i),u=h.fixnan(100*h.rma(l,e,i)/c,i);let _=d+u;h.isZero(_)&&(_+=1);const p=Math.abs(d-u)/_*100,m=i.new_var(p),g=h.rma(m,t,i),f=i.new_var(g);return[d,u,p,g,(f.get(0)+f.get(e-1))/2]},h.zigzag=(e,t,i)=>new m(e,t,i).lastPrice(),h.zigzagbars=(e,t,i)=>{const s=new m(e,t,i);return-1===s.lastIndex()?NaN:s.lastIndex()-h.n(i)};const u=0,_=1;class p{constructor(e,t,i,s,o){this._areaRight=e,this._areaLeft=t,this._pivotType=i,this._series=s,this._currentIndex=o.new_var(0),this._currentValue=o.new_var(NaN),this._pivotIndex=o.new_var(-1),this._index=h.n(o),this._isNewBar=o.symbol.isNewBar;const n=this._currentIndex.get(1),r=this._currentValue.get(1),a=this._pivotIndex.get(1);this._index>1&&(this._currentIndex.set(n),this._currentValue.set(r),this._pivotIndex.set(a))}isPivotFound(){return-1!==this._pivotIndex.get()}pivotIndex(){return this._pivotIndex.get()}currentValue(){return this._currentValue.get()}pivotType(){return this._pivotType}reset(){this._currentValue.set(NaN),this._currentIndex.set(0),this._pivotIndex.set(-1)}isRightSideOk(e){return e-this._currentIndex.get()===this._areaRight}isViolate(e,t){if(e<1||isNaN(this._currentValue.get()))return!0;const i=this._series.get(this._index-e);return!!isNaN(i)||(i===this._currentValue.get()?t:this._pivotType===_?i>this._currentValue.get():i<this._currentValue.get())}processPoint(e){this.isViolate(e,!1)&&(this._currentValue.set(this._series.get()),this._currentIndex.set(e))}isRestartNeeded(e){return e-this._currentIndex.get()>this._areaRight}update(){if(this._isNewBar&&this.isPivotFound()&&this.reset(),this.processPoint(this._index),this.isRightSideOk(this._index)){if(-1===this._pivotIndex.get()){let e=!0;for(let t=0;t<this._areaLeft;++t)if(this.isViolate(this._currentIndex.get()-1-t,!0)){e=!1;break}e&&this._pivotIndex.set(this._currentIndex.get())}}else-1!==this._pivotIndex.get()&&this._pivotIndex.set(-1);if(this.isRestartNeeded(this._index)){this.reset();for(let e=0;e<=this._areaRight;++e)this.processPoint(this._index-this._areaRight+e)}}}p.LOW=0,p.HIGH=1;class m{constructor(e,t,i){this._deviation=e
;const s=i.new_var(h.high(i)),o=i.new_var(h.low(i));s.get(2*t+1),o.get(2*t+1),this._pivotHigh=new p(t,t,_,s,i),this._pivotLow=new p(t,t,u,o,i),this._lastVal=i.new_var(NaN),this._lastIndex=i.new_var(-1),this._lastType=i.new_var(),this._index=h.n(i),this._isBarClosed=i.symbol.isBarClosed;const n=this._lastIndex.get(1),r=this._lastVal.get(1),a=this._lastType.get(1);this._index>1&&this.addPivot(n,r,a),this.processPivot(this._pivotHigh),this.processPivot(this._pivotLow)}addPivot(e,t,i){this._lastIndex.set(e),this._lastVal.set(t),this._lastType.set(i)}updatePivot(e,t){this._lastIndex.set(e),this._lastVal.set(t)}lastPrice(){return this._lastVal.get()}lastIndex(){return this._lastIndex.get()}addPoint(e,t,i){if(isNaN(this._lastVal.get()))return void this.addPivot(e,t,i);const s=this._lastVal.get();if(this._lastType.get()===i){return void((i===_?t>s:t<s)&&this.updatePivot(e,t))}Math.abs(s-t)/t>this._deviation&&this.addPivot(e,t,i)}processPivot(e){e.update(),this._isBarClosed&&e.isPivotFound()&&this.addPoint(e.pivotIndex(),e.currentValue(),e.pivotType())}}h.vwap=(e,t,i)=>{const s=i.new_var(),o=i.new_var();return t&&(s.reset_hist(),o.reset_hist()),s.set(h.nz(s.get(1))+e.get(0)*h.volume(i)),o.set(h.nz(o.get(1))+h.volume(i)),s.get(0)/o.get(0)},h.vwapBands=(e,t,i,s)=>{const o=s.new_var(),n=s.new_var();t&&(o.reset_hist(),n.reset_hist());const r=e.get(0);let a=h.volume(s),l=r*a;l+=h.nz(o.get(1)),a+=h.nz(n.get(1)),o.set(l),n.set(a);const c=l/a,d=s.new_var();t&&d.reset_hist();let u=h.volume(s)*h.pow(r,2);u+=h.nz(d.get(1)),d.set(u);const _=h.max(u/a-h.pow(c,2),0),p=Math.sqrt(_);return[c,c+p*i,c-p*i]}},34378:(e,t,i)=>{"use strict";i.d(t,{anchoredVWAPStudyItem:()=>r});const s={_metainfoVersion:51,description:"Anchored VWAP",shortDescription:"Anchored VWAP",format:{type:"inherit"},id:"AnchoredVWAP@tv-basicstudies-1",is_hidden_study:!0,is_price_study:!0,defaults:{areaBackground:{backgroundColor:"#4caf50",fillBackground:!0,transparency:95},filledAreasStyle:{Background_1:{fillType:void 0,color:"#4caf50",transparency:95,visible:!0}},inputs:{start_time:0,"Bands Calculation Mode":"Standard Deviation",bands_multiplier:1,bands_multiplier_2:2,bands_multiplier_3:3,calculate_stDev:!0,calculate_stDev_2:!1,calculate_stDev_3:!1,source:"hlc3"},styles:{VWAP:{color:"#1e88e5",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,display:15},LowerBand:{display:15,color:"#4caf50",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0},LowerBand_2:{display:15,color:"#808000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0},LowerBand_3:{display:15,color:"#00897b",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0},UpperBand:{display:15,color:"#4caf50",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0},UpperBand_2:{display:15,color:"#808000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0},UpperBand_3:{display:15,color:"#00897b",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0}}},inputs:[{defval:0,id:"start_time",isHidden:!0,max:Number.MAX_SAFE_INTEGER,
min:-Number.MAX_SAFE_INTEGER,name:"Start time",type:"time"},{defval:"Standard Deviation",group:"Bands Settings",id:"Bands Calculation Mode",name:"Bands Calculation Mode",options:["Standard Deviation","Percentage"],tooltip:"Determines the units used to calculate the distance of the bands. When 'Percentage' is selected, a multiplier of 1 means 1%.",type:"text",display:15},{defval:!0,group:"Bands Settings",id:"calculate_stDev",inline:"band_1",name:" ",type:"bool",display:0},{defval:1,group:"Bands Settings",id:"bands_multiplier",inline:"band_1",max:Number.MAX_VALUE,min:0,name:"Bands Multiplier #1",step:.5,type:"float",display:15},{defval:!1,group:"Bands Settings",id:"calculate_stDev_2",inline:"band_2",name:" ",type:"bool",display:0},{defval:2,group:"Bands Settings",id:"bands_multiplier_2",inline:"band_2",max:Number.MAX_VALUE,min:0,name:"Bands Multiplier #2",step:.5,type:"float",display:15},{defval:!1,group:"Bands Settings",id:"calculate_stDev_3",inline:"band_3",name:" ",type:"bool",display:0},{defval:3,group:"Bands Settings",id:"bands_multiplier_3",inline:"band_3",max:Number.MAX_VALUE,min:0,name:"Bands Multiplier #3",step:.5,type:"float",display:15},{defval:"hlc3",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"source"}],plots:[{id:"VWAP",type:"line"},{id:"UpperBand",type:"line"},{id:"LowerBand",type:"line"},{id:"UpperBand_2",type:"line"},{id:"LowerBand_2",type:"line"},{id:"UpperBand_3",type:"line"},{id:"LowerBand_3",type:"line"}],styles:{VWAP:{histogramBase:0,title:"VWAP"},LowerBand:{histogramBase:0,title:"Lower Band #1"},LowerBand_2:{histogramBase:0,title:"Lower Band #2"},LowerBand_3:{histogramBase:0,title:"Lower Band #3"},UpperBand:{histogramBase:0,title:"Upper Band #1"},UpperBand_2:{histogramBase:0,title:"Upper Band #2"},UpperBand_3:{histogramBase:0,title:"Upper Band #3"}},filledAreas:[{title:"Background #1",id:"Background_1",objAId:"UpperBand",objBId:"LowerBand",type:"plot_plot"}],area:[{name:"UpperBand",visible:!0},{name:"LowerBand",visible:!0}]};var o=i(50151),n=i(19979);const r={name:"Anchored VWAP",metainfo:s,constructor:class{constructor(){this._isNewSession=null,this._firstBarTime=0}init(e,t){this._firstBarTime=t(0),this._isNewSession=null}main(e,t,i){if(void 0===i)return[NaN];(0,o.assert)(e.symbol.time===i.time);const s=i.time;if(s&&s<this._firstBarTime)return[NaN];const r=n.Std.volume(e),a=n.Std[t(8)](e),l=e.new_unlimited_var(),c=e.new_unlimited_var(),h=e.new_unlimited_var(),d=e.symbol.time;null!==d&&(null===this._isNewSession&&(this._isNewSession=n.Std.createNewSessionCheck(e)),this._isNewSession&&this._isNewSession(d)&&(this._resetHist(l),this._resetHist(c),this._resetHist(h))),l.set(n.Std.nz(l.get())+a*r),c.set(n.Std.nz(c.get())+r),h.set(n.Std.nz(h.get())+a*a*r);const u=l.get()/c.get(),_=h.get()/c.get()-Math.pow(u,2),p=Math.sqrt(Math.max(0,_)),m="Standard Deviation"===t(1)?p:.01*u,g=t(2),f=t(3),y=t(4),v=t(5),S=t(6),b=t(7);return[u,g?u+m*f:NaN,g?u-m*f:NaN,y?u+m*v:NaN,y?u-m*v:NaN,S?u+m*b:NaN,S?u-m*b:NaN]}_resetHist(e){e.reset_hist()}}}},95603:(e,t,i)=>{"use strict"
;i.d(t,{inactivityGapsStudyItem:()=>d});var s=i(47312),o=i(51101),n=i(51829),r=i(99955),a=i(37236),l=i(50151),c=i(19979);const h={historyCalculationMayChange:!0,_metainfoVersion:52,description:"Inactivity Gaps",id:"InactivityGaps@tv-basicstudies-1",is_hidden_study:!0,is_price_study:!0,name:"InactivityGaps@tv-basicstudies",inputs:[{id:"display_session",name:"Gap Display Session",defval:"session",type:"text",display:0}],palettes:{},plots:[],defaults:{inputs:{display_session:"session"}},shortDescription:"Inactivity Gaps",format:{type:"inherit"},canExtendTimeScale:!0};const d={name:"InactivityGaps",metainfo:h,constructor:class{constructor(){this._lastRange=null,this._range={from:null,to:null}}init(e,t){const i=t(0);"string"!=typeof i&&c.Std.error(`Unexpected non-string value for ${h.inputs[0].name}`),this._displaySession=i,this._range={from:null,to:null},this._lastRange=null;const n=e.symbol.info;if(void 0===n)return;const r="session"===this._displaySession?e.symbol.info?.session??"24x7":this._displaySession,a=s.SessionInfo.create(n.timezone,r,e.symbol.session.state().holidays,e.symbol.session.state().corrections);this._mainSeriesBarBuilder=(0,o.newBarBuilder)(e.symbol.period,e.symbol.session),this._extrapolationBarBuilder=(0,o.newBarBuilder)(e.symbol.period,a)}main(e,t){const i=e.symbol,s=c.Std.time(e);if("number"==typeof s&&isFinite(s)&&(null===this._range.from&&(this._range.from=s),this._range.to=s),i.isLastBar&&null!==(d=this._range)&&null!==d.from&&null!==d.to&&(o=this._range,h=this._lastRange,o?.from!==h?.from||o?.to!==h?.to)){this._lastRange={...this._range};const t=(0,r.extrapolateBarsFrontToTime)(this._extrapolationBarBuilder,this._range.from,this._range.to,1/0,!0).times;for(let s=0;s<t.length;s++)if(this._mainSeriesBarBuilder.moveTo(t[s]),i.isdwm()){const i=(0,a.get_cal_from_unix_timestamp_ms)((0,l.ensure)(e.symbol.timezone,"timezone"),t[s]);e.symbol.session.spec.includesDay(i)&&(t[s]=this._mainSeriesBarBuilder.startOfBar(0))}else{const e=this._mainSeriesBarBuilder.indexOfBar(t[s]);if(e!==n.SessionStage.PRE_SESSION&&e!==n.SessionStage.POST_SESSION){const i=this._mainSeriesBarBuilder.startOfBar(e);t[s]=i}}return{nonseries:!0,type:"study_gap",displaySession:this._displaySession,times:t}}var o,h,d;return null}}}},51052:(e,t,i)=>{"use strict";i.d(t,{overlayStudyItem:()=>n});var s=i(19979),o=i(37103);const n={name:"Overlay",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{},inputs:{symbol:"",extendTimeScale:!1}},plots:[{id:"open",type:"line"},{id:"high",type:"line"},{id:"low",type:"line"},{id:"close",type:"line"}],styles:{open:{title:"Open"},high:{title:"High"},low:{title:"Low"},close:{title:"Close"}},description:"Overlay",shortDescription:"Overlay",is_price_study:!1,inputs:[{id:"symbol",name:"symbol",defval:"",type:"symbol",isHidden:!0},{id:"extendTimeScale",name:"extendTimeScale",defval:!1,type:"bool",isHidden:!0}],id:"Overlay@tv-basicstudies-1",format:{type:"price",precision:4},canExtendTimeScale:!0},constructor:class{constructor(){
this._extendTimeScaleFeatureEnabled=!1}init(e,t){this._context=e,this._extendTimeScaleFeatureEnabled=o.enabled("secondary_series_extend_time_scale"),this._context.new_sym(t(0),s.Std.period(this._context))}main(e,t){this._context=e;const i=!this._extendTimeScaleFeatureEnabled||!0!==t(1),o=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);const n=this._context.new_unlimited_var(this._context.symbol.time),r=this._context.new_unlimited_var(s.Std.open(this._context)),a=this._context.new_unlimited_var(s.Std.high(this._context)),l=this._context.new_unlimited_var(s.Std.low(this._context)),c=this._context.new_unlimited_var(s.Std.close(this._context));if(i){this._context.select_sym(0);const t=n.adopt(n,o,1);if(s.Std.na(t))return[NaN,NaN,NaN,NaN];const i=n.indexOf(t),h=-1===i?NaN:r.get(i),d=-1===i?NaN:a.get(i),u=-1===i?NaN:l.get(i),_=-1===i?NaN:c.get(i);return n.symbol.isBarUpdate&&t!==e.symbol.time?[{timeMs:t,value:NaN,offset:NaN},h,d,u,_]:[h,d,u,_]}return[r.get(0),a.get(0),l.get(0),c.get(0)]}}}},32503:(e,t,i)=>{"use strict";i.d(t,{pivotPointsStandardStudyItem:()=>p});var s,o,n=i(51101),r=i(50151),a=i(51829),l=i(46082),c=i(4622),h=i(19979);!function(e){e[e.TRADITIONAL=0]="TRADITIONAL",e[e.FIBONACCI=1]="FIBONACCI",e[e.WOODIE=2]="WOODIE",e[e.CLASSIC=3]="CLASSIC",e[e.DEMARK=4]="DEMARK",e[e.CAMARILLA=5]="CAMARILLA",e[e.FLOOR=6]="FLOOR"}(s||(s={})),function(e){e.AUTO="Auto",e.DAILY="Daily",e.WEEKLY="Weekly",e.MONTHLY="Monthly",e.YEARLY="Yearly"}(o||(o={}));class d{constructor(){this.p=NaN,this.r1=NaN,this.s1=NaN,this.r2=NaN,this.s2=NaN,this.r3=NaN,this.s3=NaN,this.r4=NaN,this.s4=NaN,this.r5=NaN,this.s5=NaN,this.startIndex__t=NaN,this.endIndex__t=NaN}}class u{constructor(){this.pivots=[]}}function _(e,t){let i;switch(t){case"Auto":i=function(e){const t=l.Interval.parse(e.interval+e.resolution);switch(t.kind()){case l.ResolutionKind.Weeks:case l.ResolutionKind.Months:return"12M";case l.ResolutionKind.Days:return"1M";case l.ResolutionKind.Minutes:return t.multiplier()>=1&&t.multiplier()<=15?"1D":"1W";case l.ResolutionKind.Seconds:case l.ResolutionKind.Ticks:return"1D"}throw new Error("Unexpected resolution type: "+e.resolution)}(e);break;case"Daily":i="1D";break;case"Weekly":i="1W";break;case"Monthly":i="1M";break;case"Yearly":i="12M";break;default:throw new Error("No such pivTimeFrame: "+t)}const s="D"===e.resolution&&"Daily"===t,o="W"===e.resolution&&("Daily"===t||"Weekly"===t),n="M"===e.resolution&&("Daily"===t||"Weekly"===t||"Monthly"===t);return(s||o||n||e.info&&(0,c.findSuitableResolutionToBuildFrom)(i,e.info).error)&&h.Std.error("You cannot see this pivot timeframe on this resolution"),i}const p={name:"Pivot Points Standard",metainfo:{_metainfoVersion:44,defaults:{inputs:{kind:"Traditional",lookBack:15,pivTimeFrame:"Auto",showHistoricalPivots:!0,symbol:""},precision:"4"},description:"Pivot Points Standard",id:"PivotPointsStandard@tv-basicstudies-80",inputs:[{defval:"Traditional",id:"kind",name:"Type",options:["Traditional","Fibonacci","Woodie","Classic","DeMark","Camarilla","Floor"],
type:"text"},{defval:!0,id:"showHistoricalPivots",name:"Show historical pivots",type:"bool"},{defval:"Auto",id:"pivTimeFrame",name:"Pivots Timeframe",options:["Auto","Daily","Weekly","Monthly","Yearly"],type:"text"},{defval:15,id:"lookBack",max:5e3,min:1,name:"Number of Pivots Back",type:"integer"},{defval:"",id:"symbol",name:"Other Symbol",type:"symbol",optional:!0}],is_price_study:!0,linkedToSeries:!0,shortDescription:"Pivots",format:{type:"price",precision:4}},constructor:class{constructor(){this._firstMainSeriesBarTime=NaN}init(e,t){this._isValidResolution=!1;const i=t(0),s=t(1),o=t(2),a=t(3);this._data=new u,this._firstMainSeriesBarTime=NaN,this._kindPP=function(e){switch(e){case"Traditional":return 0;case"Fibonacci":return 1;case"Woodie":return 2;case"Classic":return 3;case"DeMark":return 4;case"Camarilla":return 5;case"Floor":return 6;default:throw new Error("Unknown kind "+e)}}(i),this._showHistoricalPivots=s,this._historicalPivotsToKeep=a,this._pivTimeFrame=o;const l=t(4);let c;c=""===l?e.new_sym(e.symbol.tickerid,_(e.symbol,this._pivTimeFrame)):e.new_sym(l,_(e.symbol,o)),this._isValidResolution=!0,(0,r.assert)(c.isdwm(),"a DWM resolution is required to use a multi-day bar builder"),this._barBuilder=(0,n.newBarBuilder)(c.period,e.symbol.session)}main(e,t,i){if(!this._isValidResolution)return null;if(e.is_main_symbol(i))return isNaN(this._firstMainSeriesBarTime)&&(this._firstMainSeriesBarTime=e.symbol.time,this._removeUnusedPivots()),e.symbol.isLastBar&&e.symbol.isNewBar?this._createResponse():null;e.select_sym(1);const s=e.new_var(h.Std.open(e)),o=e.new_var(h.Std.high(e)),n=e.new_var(h.Std.low(e)),r=e.new_var(h.Std.close(e)),l=this._data,c=s.get(0),u=s.get(1),_=o.get(1),p=n.get(1),m=r.get(1),g=e.symbol.isLastBar;if(0===e.symbol.index||!e.symbol.isNewBar)return e.select_sym(0),null;this._barBuilder.moveTo(e.symbol.time);const f=function(e,t,i,s,o,n,r,a){const l=new d;let c=NaN;const u=i-s;switch(a){case 0:c=(i+s+o)/3,l.p=c,l.r1=2*c-s,l.s1=2*c-i,l.r2=c+(i-s),l.s2=c-(i-s),l.r3=2*c+(i-2*s),l.s3=2*c-(2*i-s),l.r4=3*c+(i-3*s),l.s4=3*c-(3*i-s),l.r5=4*c+(i-4*s),l.s5=4*c-(4*i-s);break;case 1:c=(i+s+o)/3,l.p=c,l.r1=c+.382*u,l.s1=c-.382*u,l.r2=c+.618*u,l.s2=c-.618*u,l.r3=c+u,l.s3=c-u;break;case 2:c=(i+s+2*e)/4,l.p=c,l.r1=2*c-s,l.s1=2*c-i,l.r2=c+u,l.s2=c-u,l.r3=i+2*(c-s),l.s3=s-2*(i-c),l.r4=l.r3+u,l.s4=l.s3-u;break;case 3:c=(i+s+o)/3,l.p=c,l.r1=2*c-s,l.s1=2*c-i,l.r2=c+u,l.s2=c-u,l.r3=c+2*u,l.s3=c-2*u,l.r4=c+3*u,l.s4=c-3*u;break;case 4:let n=NaN;n=h.Std.equal(t,o)?i+s+2*o:h.Std.greater(o,t)?2*i+s+o:2*s+i+o,c=n/4,l.p=c,l.r1=n/2-s,l.s1=n/2-i;break;case 5:c=(i+s+o)/3,l.p=c,l.r1=o+1.1*u/12,l.s1=o-1.1*u/12,l.r2=o+1.1*u/6,l.s2=o-1.1*u/6,l.r3=o+1.1*u/4,l.s3=o-1.1*u/4,l.r4=o+1.1*u/2,l.s4=o-1.1*u/2;break;case 6:c=(i+s+o)/3,l.p=c,l.r1=2*c-s,l.s1=2*c-i,l.r2=c+(i-s),l.s2=c-(i-s),l.r3=c-l.s1+l.r2,l.s3=2*c-(2*i-s);break;default:throw new Error("Unknown kind")}return l.startIndex__t=n,l.endIndex__t=r,l}(c,u,_,p,m,this._barBuilder.startOfBar(0),this._barBuilder.startOfBar(a.SessionStage.POST_SESSION),this._kindPP);return e.select_sym(0),
this._showHistoricalPivots||(l.pivots=[]),l.pivots.push(f),l.pivots.length>this._historicalPivotsToKeep&&l.pivots.shift(),g?this._createResponse():null}_createResponse(){return 0===this._data.pivots.length?null:{nonseries:!0,type:"non_series_data",data:{data:this._data}}}_removeUnusedPivots(){const e=Math.max(this._data.pivots.findIndex((e=>e.startIndex__t>this._firstMainSeriesBarTime))-1,0);e>0&&this._data.pivots.splice(0,e)}}}},52691:(e,t,i)=>{"use strict";i.d(t,{ratioStudyItem:()=>n});var s=i(70680);class o extends s.SpreadRatioBase{_doCalculation(e,t,i,s){return e*t/(i*s)}}const n={name:"Ratio",metainfo:{_metainfoVersion:15,defaults:s.spreadRatioDefaults,plots:s.spreadRatioPlots,styles:s.spreadRatioStyles,description:"Ratio",shortDescription:"Ratio",is_price_study:!1,inputs:s.spreadRatioInputs,id:"Ratio@tv-basicstudies-1",format:{type:"price",precision:2}},constructor:o}},57622:(e,t,i)=>{"use strict";i.d(t,{regressionTrendStudyItem:()=>n});var s=i(19979);function o(e,t,i){const o={slope:NaN,average:NaN,intercept:NaN,stdDev:NaN,upDev:NaN,downDev:NaN,pearsons:NaN};return 0===e.length||(function(e,t){let i=0,s=0,o=0,n=0;for(let t=0;t<e.length;++t){const r=e[t],a=t+1;i+=a,s+=r,o+=a*a,n+=r*a}t.slope=(e.length*n-i*s)/(e.length*o-i*i),t.average=s/e.length,t.intercept=t.average-t.slope*i/e.length+t.slope}(e,o),function(e,t,i,o){let n=0,r=0,a=0,l=0,c=0,h=0,d=o.intercept;const u=e.length-1,_=o.intercept+o.slope*u/2;for(let s=0;s<=u;++s){let u=t[s]-d;u>n&&(n=u),u=d-i[s],u>r&&(r=u),u=e[s];const p=u-o.average,m=d-_;u-=d,a+=u*u,l+=p*p,c+=m*m,h+=p*m,d+=o.slope}o.stdDev=Math.sqrt(a/(0===u?1:u)),o.pearsons=s.Std.isZero(l)||s.Std.isZero(c)?0:h/Math.sqrt(l*c),o.upDev=n,o.downDev=r}(e,t,i,o)),o}const n={name:"Regression Trend",metainfo:{_metainfoVersion:51,description:"Regression Trend",format:{type:"inherit"},id:"RegressionTrend@tv-basicstudies-144",is_hidden_study:!0,is_price_study:!0,shortDescription:"Reg Trend",defaults:{inputs:{"first bar time":0,"last bar time":0,"lower diviation":-2,source:"close","upper diviation":2,"use lower diviation":!0,"use upper diviation":!0},styles:{}},inputs:[{defval:2,id:"upper diviation",max:500,min:-500,name:"Upper Deviation",type:"float"},{defval:-2,id:"lower diviation",max:500,min:-500,name:"Lower Deviation",type:"float"},{defval:!0,id:"use upper diviation",name:"Use Upper Deviation",type:"bool"},{defval:!0,id:"use lower diviation",name:"Use Lower Deviation",type:"bool"},{defval:0,id:"first bar time",isHidden:!0,max:253370764800,min:-253370764800,name:"First bar time",type:"time"},{defval:0,id:"last bar time",isHidden:!0,max:253370764800,min:-253370764800,name:"Last bar time",type:"time"},{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"source"}],plots:[]},constructor:class{constructor(){this._resultSent=!1}init(e,t){this._resultSent=!1,this._data={baseLine:{startPrice:NaN,endPrice:NaN},upLine:{startPrice:NaN,endPrice:NaN},downLine:{startPrice:NaN,endPrice:NaN},pearsons:NaN,startIndex__t:NaN,endIndex__t:NaN}}main(e,t){
const i=t(6),n=e.new_unlimited_var(s.Std.time(e)),r=e.new_unlimited_var(s.Std.high(e)),a=e.new_unlimited_var(s.Std.low(e)),l=e.new_unlimited_var(s.Std[i](e));if(!e.symbol.isLastBar)return null;if(this._resultSent)return null;const c=t(0),h=t(1),d=t(2),u=t(3),_=t(4),p=t(5),m=n.indexOf(_),g=n.indexOf(p),f=[],y=[],v=[],S=[];for(let e=m;e>=g;--e)f.push(n.get(e)),y.push(r.get(e)),v.push(a.get(e)),S.push(l.get(e));return this._updateData(f,d,c,u,h,_,p,o(S,y,v)),this._resultSent=!0,{type:"non_series_data",nonseries:!0,data:{data:this._data}}}_updateData(e,t,i,s,o,n,r,a){const l=e.length-1;this._data.baseLine.startPrice=a.intercept,this._data.baseLine.endPrice=a.intercept+a.slope*l;const c=a.intercept+(t?a.stdDev*i:a.upDev);this._data.upLine.startPrice=c,this._data.upLine.endPrice=c+a.slope*l;const h=a.intercept+(s?a.stdDev*o:-a.downDev);this._data.downLine.startPrice=h,this._data.downLine.endPrice=h+a.slope*l,this._data.pearsons=a.pearsons,this._data.startIndex__t=n,this._data.endIndex__t=r}}}},70680:(e,t,i)=>{"use strict";i.d(t,{SpreadRatioBase:()=>l,spreadRatioDefaults:()=>c,spreadRatioFilledAreas:()=>p,spreadRatioInputs:()=>h,spreadRatioPalettes:()=>_,spreadRatioPlots:()=>d,spreadRatioStyles:()=>u});var s=i(58978),o=i(4359),n=i(19979),r=i(52859);const a="rgba(0, 0, 0, 0)";class l{init(e,t){e.new_sym(t(1),n.Std.period(e)),this._source=t(0),this._scaleFactor1=1,this._scaleFactor2=1}main(e,t){const i=n.Std[this._source](e),s=e.new_unlimited_var(e.symbol.time);e.select_sym(1);const o=e.new_unlimited_var(e.symbol.time),r=e.new_unlimited_var(n.Std[this._source](e));e.select_sym(0);const a=r.adopt(o,s,1),l=this._doCalculation(this._scaleFactor1,i,this._scaleFactor2,a);return isNaN(l)?null:[l,0,n.Std.ge(l,0),n.Std.lt(l,0)]}}const c={styles:{plot1:{linestyle:0,linewidth:2,plottype:o.LineStudyPlotStyle.Line,trackPrice:!1,transparency:35,color:"#800080",display:15},plotBaseline:{linestyle:0,linewidth:2,plottype:o.LineStudyPlotStyle.Line,trackPrice:!1,transparency:0,color:a,display:0}},palettes:{negativePalette:{colors:[{color:(0,r.applyAlpha)((0,s.getHexColorByName)("color-ripe-red-500"),.5),style:0,width:0},{color:a,style:0,width:0}]},positivePalette:{colors:[{color:(0,r.applyAlpha)((0,s.getHexColorByName)("color-minty-green-500"),.5),style:0,width:0},{color:a,style:0,width:0}]}},filledAreasStyle:{negativeFill:{color:"",transparency:0,visible:!0,fillType:void 0},positiveFill:{color:"",transparency:0,visible:!0,fillType:void 0}},precision:2,inputs:{source:"close",symbol2:""}},h=[{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"text"},{id:"symbol2",name:"Symbol",type:"symbol",confirm:!0}],d=[{id:"plot1",type:"line"},{id:"plotBaseline",type:"line"},{id:"plotNegativeFill",type:"colorer",target:"negativeFill",palette:"negativePalette"},{id:"plotPositiveFill",type:"colorer",target:"positiveFill",palette:"positivePalette"}],u={plot1:{title:"Plot",histogramBase:0},plotBaseline:{title:"Baseline",isHidden:!0}},_={negativePalette:{valToIndex:{0:0,1:1},colors:[{name:"Color"}]},
positivePalette:{valToIndex:{0:0,1:1},colors:[{name:"Color"}]}},p=[{id:"negativeFill",objAId:"plot1",objBId:"plotBaseline",type:"plot_plot",title:"Negative fill",palette:"negativePalette",fillToIntersection:!0},{id:"positiveFill",objAId:"plot1",objBId:"plotBaseline",type:"plot_plot",title:"Positive fill",palette:"positivePalette",fillToIntersection:!0}]},24451:(e,t,i)=>{"use strict";i.d(t,{spreadStudyItem:()=>n});var s=i(70680);class o extends s.SpreadRatioBase{_doCalculation(e,t,i,s){return e*t-i*s}}const n={name:"Spread",metainfo:{_metainfoVersion:15,defaults:s.spreadRatioDefaults,plots:s.spreadRatioPlots,styles:s.spreadRatioStyles,palettes:s.spreadRatioPalettes,filledAreas:s.spreadRatioFilledAreas,description:"Spread",shortDescription:"Spread",is_price_study:!1,inputs:s.spreadRatioInputs,id:"Spread@tv-basicstudies-1",format:{type:"price",precision:2}},constructor:o}},60755:(e,t,i)=>{"use strict";i.d(t,{VbPCheckHaveVolumeExpr:()=>o});var s=i(19979);class o{constructor(e){this._haveAnyVolume=!1,this._isDisabled=!1,this._seriesGetter=e}update(e,t){if(this._haveAnyVolume||this._isDisabled)return;const i=this._seriesGetter.volume().get(e);0!==i&&Number.isFinite(i)&&(this._haveAnyVolume=!0),t&&(this._haveAnyVolume||s.Std.error("The data vendor doesn't provide volume data for this symbol."),this._isDisabled=!0)}}},96777:(e,t,i)=>{"use strict";i.d(t,{VolumeByPriceExpr:()=>g});var s=i(50151),o=i(77914),n=i(46082),r=i(86811);class a extends r.GraphicsObj{constructor(e,t,i,o,n,r){super(e),(0,s.assert)(t<i),this._priceLow=this._mixinJSONObject.createDoubleField(t,"priceLow"),this._priceHigh=this._mixinJSONObject.createDoubleField(i,"priceHigh"),this._rate=this._mixinJSONObject.createDoubleArrayField(o,"rate"),this._firstBarTime=this._mixinJSONObject.createTimeField(n,"firstBarTime"),this._lastBarTime=this._mixinJSONObject.createTimeField(r,"lastBarTime")}isNaN(){return super.isNaN()||Number.isNaN(this._priceLow.get())||Number.isNaN(this._priceHigh.get())||0===this._rate.get().length}jsonName(){return"hhists"}primitiveData(){return{id:this.id(),priceHigh:this._priceHigh.get(),priceLow:this._priceLow.get(),rate:this._rate.get().slice(),firstBarTime:this._firstBarTime.get(),lastBarTime:this._lastBarTime.get()}}setPriceLow(e){this._priceLow.set(e)&&this._processObjUpdate()}priceLow(){return this._priceLow.get()}priceHigh(){return this._priceHigh.get()}setPriceHigh(e){this._priceHigh.set(e)&&this._processObjUpdate()}rate(){return this._rate.get().slice()}setRate(e){this._rate.set(e)&&this._processObjUpdate()}rateAt(e){return this._rate.get()[e]}ratesSum(){let e=0;for(const t of this._rate.get())!Number.isNaN(t)&&Number.isFinite(t)&&(e+=t);return e}firstBarTime(){return this._firstBarTime.get()}setFirstBarTime(e){this._firstBarTime.set(e)&&this._processObjUpdate()}lastBarTime(){return this._lastBarTime.get()}setLastBarTime(e){this._lastBarTime.set(e)&&this._processObjUpdate()}}var l,c,h=i(30376),d=i(19979);class u{constructor(e,t,i){this.index=e,this.offset=i,this.level=t}isNaN(){return Number.isNaN(this.level)}equals(e){
return e instanceof u&&(!this.isNaN()&&(!e.isNaN()&&(this.index===e.index&&this.offset===e.offset&&d.Std.equal(this.level,e.level))))}getLevel(){return this.level}getIndex(){return this.index}}class _ extends r.GraphicsObj{constructor(e,t){super(e),this._points=[],t&&(this._points=t)}addPoint(e){this._processObjUpdate(),this._points.push(e)}addPoints(e){this._processObjUpdate(),this._points.push(...e)}setPoint(e,t){const i=this._points[e];t.equals(i)||(this._processObjUpdate(),this._points[e]=t)}point(e){const t=this._points[e];return new u(t.index,t.level,t.offset)}points(){return this._points}pointsCount(){return this._points.length}setPoints(e){if(e.length===this._points.length){let t=!0;for(let i=0;i<e.length;++i)if(!e[i].equals(this._points[i])){t=!1;break}if(t)return}this._processObjUpdate(),this._points=[],this._points.push(...e)}clearPoints(){this._processObjUpdate(),this._points=[]}isNaN(){return super.isNaN()||this._points.length<3}jsonName(){return"polygons"}primitiveData(){return{id:this.id(),points:this._points.map((e=>({index:e.index,offset:e.offset,level:e.level})))}}}class p extends r.GraphicsObj{constructor(e,t,i,s,o=!1,n=!1){super(e),this._endIndex=this._mixinJSONObject.createTimeField(i,"endIndex"),this._extendLeft=this._mixinJSONObject.createField(o,"extendLeft"),this._extendRight=this._mixinJSONObject.createField(n,"extendRight"),this._level=this._mixinJSONObject.createDoubleField(s,"level"),this._startIndex=this._mixinJSONObject.createTimeField(t,"startIndex")}isNaN(){return super.isNaN()||Number.isNaN(this._level.get())||this._startIndex.get()<0||this._endIndex.get()<0||this._startIndex.get()===this._endIndex.get()&&!this._extendLeft.get()&&!this._extendRight.get()}jsonName(){return"horizlines"}primitiveData(){return{id:this.id(),startIndex:this._startIndex.get(),endIndex:this._endIndex.get(),extendLeft:this._extendLeft.get(),extendRight:this._extendRight.get(),level:this._level.get()}}startIndex(){return this._startIndex.get()}setStartIndex(e){this._startIndex.set(e)&&this._processObjUpdate()}endIndex(){return this._endIndex.get()}setEndIndex(e){this._endIndex.set(e)&&this._processObjUpdate()}level(){return this._level.get()}setLevel(e){this._level.set(e)&&this._processObjUpdate()}isExtendLeft(){return this._extendLeft.get()}setExtendLeft(e){this._extendLeft.set(e)&&this._processObjUpdate()}extendLeft(){return this.isExtendLeft()}isExtendRight(){return this._extendRight.get()}setExtendRight(e){this._extendRight.set(e)&&this._processObjUpdate()}extendRight(){return this.isExtendRight()}}!function(e){e[e.AssertAccuracy=.05]="AssertAccuracy"}(l||(l={})),function(e){e[e.START=0]="START",e[e.END=1]="END"}(c||(c={}));class m{constructor(){this._map=new Map}get(e){const t=this._innerMap(e.start);return t&&t.get(e.end)}set(e,t){this._innerMap(e.start,!0).set(e.end,t)}clear(){this._map.clear()}size(){let e=0;return this._map.forEach((t=>e+=t.size)),e}_innerMap(e,t){let i=this._map.get(e);return void 0===i&&t&&(i=new Map,this._map.set(e,i)),i}}class g{constructor(e,t,i,o,n,r,a,l,c,d,u,_,p,g,f){
this._freezedBoxes=new h.GraphicsList,this._freezedHists=new h.GraphicsList,this._freezedPocs=new h.GraphicsList,this._freezedVAHists=new h.GraphicsList,this._currentHistsGr=new h.GraphicsList,this._currentVAHistsGr=new h.GraphicsList,this._currentHists=[],this._currentHistsMap=new m,this._currentBox=null,this._currentPoc=null,this._historyBarSet=[],this._prevRtBar=null,this._minPrice=Number.POSITIVE_INFINITY,this._maxPrice=Number.NEGATIVE_INFINITY,this._leftBoxTime=null,this._rightBoxTime=null,this._actualRightBoxTime=null,this._needRecalc=!1,this._largestHistItem=null,this._rowsLayout=null,this._currentVAStart=0,this._currentVAEnd=0,this._previousVAStart=0,this._previousVAEnd=0,this._idsGenerator=null,(0,s.assert)(1===e||2===e),this._numOfSubHists=e,this._outHists=o,this._outBoxLines=n,this._outPocLines=r,this._extendPocLeftRight=a,this._outVAHists=l,this._vaVolumePercent=c,this._rowsLayoutSupplier=d,this._outHists.addStable(this._freezedHists),this._outVAHists.addStable(this._freezedVAHists),this._maxHHistItems=u,this._layoutIsAutoselected=g,this._leftBoxTimeMutable=_,this._rightBoxTimeMutable=p,this._actualRightBoxTime=f??p,this._ctx=t,this._seriesGetter=i}update(e){this._supplyRowsLayout(this._ctx),null===this._currentBox&&this._initCurrentBox(),null===this._currentPoc&&this._initCurrentPoc();const t=this._timeScale().get(e);this._leftBoxTime=this._leftBoxTimeMutable,this._rightBoxTime=this._rightBoxTimeMutable,this._ctx.symbol.isLastBar&&!Number.isNaN(this._rightBoxTime)&&(this._rightBoxTime=Math.min(t+n.Interval.parse(this._ctx.symbol.interval+this._ctx.symbol.resolution).inMilliseconds(t)-1,this._rightBoxTime));const i=d.Std.greaterOrEqual(this._seriesClose().get(e),this._seriesOpen().get(e)),s={high:this._seriesHigh().get(e),low:this._seriesLow().get(e),volume:this._seriesVol().get(e),isUp:i,time:t};this._updateCurrentHistogram(s),this._currentHists.length>0&&(this._largestHistItem=this._getLargestHistItem(),this._updateCurrentPoc(),this._seriesGetter.developingPoc().set(this._currentPoc.level()),this._updateValueArea(),this._vaVolumePercent>0&&(this._seriesGetter.developingVAHigh().set(this._currentHists[this._currentVAEnd].priceHigh()),this._seriesGetter.developingVALow().set(this._currentHists[this._currentVAStart].priceLow()))),this._updateCurrentBox(),this._rebuildOutData()}setIdsGeneratorProxy(e){this._idsGenerator=e}nextGraphicsObjId(){return(0,s.ensureNotNull)(this._idsGenerator).nextGraphicsObjId()}pushEraseObjCmd(e,t){(0,s.ensureNotNull)(this._idsGenerator).pushEraseObjCmd(e,t)}popEraseCmds(){return(0,s.ensureNotNull)(this._idsGenerator).popEraseCmds()}_timeScale(){return this._seriesGetter.time()}_seriesLow(){return this._seriesGetter.low()}_seriesHigh(){return this._seriesGetter.high()}_seriesVol(){return this._seriesGetter.volume()}_seriesOpen(){return this._seriesGetter.open()}_seriesClose(){return this._seriesGetter.close()}_freezeCurrentHistogramAndCleanup(){null!==this._currentBox&&this._freezedBoxes.add(this._currentBox),
d.Std.greater(this._getVolume(this._currentHists),0)&&(this._freezedHists.addAll(this._currentHistsGr),this._freezedVAHists.addAll(this._currentVAHistsGr),null!==this._currentPoc&&this._freezedPocs.add(this._currentPoc)),this._currentHists=[],this._currentHistsGr.clear(),this._currentHistsMap.clear(),this._initCurrentBox(),this._initCurrentPoc(),this._currentVAHistsGr.clear(),this._historyBarSet=[],this._minPrice=Number.POSITIVE_INFINITY,this._maxPrice=Number.NEGATIVE_INFINITY,this._prevRtBar=null,this._leftBoxTime=null,this._rightBoxTime=null}_supplyRowsLayout(e){null===this._rowsLayout&&e.symbol.isFirstBar&&e.symbol.isNewBar&&(this._rowsLayout=this._rowsLayoutSupplier())}_updateCurrentHistogram(e){if(this._needRecalc=!1,d.Std.greater(this._minPrice,e.low)&&(this._minPrice=e.low,this._needRecalc=!0),d.Std.less(this._maxPrice,e.high)&&(this._maxPrice=e.high,this._needRecalc=!0),this._ctx.symbol.isBarClosed&&this._historyBarSet.length>0){const t=this._historyBarSet[this._historyBarSet.length-1];t.time===e.time&&(this._prevRtBar=t,this._historyBarSet.pop())}this._needRecalc&&0===(0,s.ensureNotNull)(this._rowsLayout).type()?(this._recalculateCurrentResultsOnHistoryBarSet(),this._applyUpdateToCurrentResults(e,!1)):this._applyUpdateToCurrentResults(e,!0),this._ctx.symbol.isBarClosed?((0,s.assert)(null===this._prevRtBar||e.time===this._prevRtBar.time),this._historyBarSet.push(e),this._prevRtBar=null):this._prevRtBar=e}_getMidLevel(e){return(e.priceHigh()+e.priceLow())/2}_getMidLevelFromList(e){return e.length%2==0?e[e.length/2].priceLow():this._getMidLevel(e[Math.floor(e.length/2)])}_getLargestHistItem(){let e=[],t=this._currentHists[0];for(const i of this._currentHists)d.Std.greater(i.ratesSum(),t.ratesSum())?(t=i,e=[t]):d.Std.equal(i.ratesSum(),t.ratesSum())&&e.push(i);if(e.length>1){const i=this._getMidLevelFromList(this._currentHists);t=e[e.length-1];for(let s=e.length-2;s>=0;s--){const o=e[s];d.Std.lessOrEqual(Math.abs(this._getMidLevel(o)-i),Math.abs(this._getMidLevel(t)-i))&&(t=o)}}return t}_initCurrentPoc(){this._currentPoc=new p(this,0,0,0)}_updateCurrentPoc(){const e=(0,s.ensureNotNull)(this._currentPoc);e.setStartIndex((0,s.ensureNotNull)(this._leftBoxTime)),e.setEndIndex((0,s.ensureNotNull)(this._actualRightBoxTime)),e.setExtendLeft(this._extendPocLeftRight),e.setExtendRight(this._extendPocLeftRight);const t=this._getMidLevel((0,s.ensureNotNull)(this._largestHistItem));e.setLevel(t)}_getVolume(e){let t=0;for(const i of e)t+=i.ratesSum();return t}_getPocHistItemIndex(){for(let e=0;e<this._currentHists.length;e++)if(this._currentHists[e]===this._largestHistItem)return e;return-1}_calculateValueArea(){const e=this._getPocHistItemIndex();(0,s.assert)(e>=0,`ERROR - PocHistItemIndex == ${e}`),this._currentVAStart=e-1,this._currentVAEnd=e+1;const t=this._getVolume(this._currentHists)*this._vaVolumePercent*.01;let i=this._currentHists[e].ratesSum(),o=0,n=null;for(;d.Std.lessOrEqual(i+o,t)&&(i+=o,0===n?--this._currentVAStart:1===n&&++this._currentVAEnd,
-1!==this._currentVAStart||this._currentVAEnd!==this._currentHists.length);){let t,i;if(this._currentVAStart>-1)if(t=this._currentHists[this._currentVAStart].ratesSum(),this._currentVAEnd<this._currentHists.length)if(i=this._currentHists[this._currentVAEnd].ratesSum(),d.Std.greater(t,i))o=t,n=0;else if(d.Std.greater(i,t))o=i,n=1;else{const s=Math.abs(e-this._currentVAStart),r=Math.abs(e-this._currentVAEnd);s<r?(o=t,n=0):r<=s&&(o=i,n=1)}else o=t,n=0;else o=this._currentHists[this._currentVAEnd].ratesSum(),n=1}this._currentVAStart++,this._currentVAEnd--}_isVA(e){return e.priceHigh()>this._getMidLevel(this._currentHists[this._currentVAStart])&&e.priceLow()<this._getMidLevel(this._currentHists[this._currentVAEnd])}_updateValueArea(){if(this._calculateValueArea(),this._needRecalc||this._previousVAStart!==this._currentVAStart||this._previousVAEnd!==this._currentVAEnd){let e=0,t=0;for(;e<this._currentHistsGr.size()&&t<this._currentVAHistsGr.size();){for(;e<this._currentHistsGr.size()&&!this._isVA(this._currentHistsGr.get(e));)e++;for(;t<this._currentVAHistsGr.size()&&this._isVA(this._currentVAHistsGr.get(t));)t++;if(e<this._currentHistsGr.size()&&t<this._currentVAHistsGr.size()){const i=this._currentHistsGr.get(e);this._currentHistsGr.set(e,this._currentVAHistsGr.get(t)),this._currentVAHistsGr.set(t,i)}}for(;e<this._currentHistsGr.size();e++){const t=this._currentHistsGr.get(e);this._isVA(t)&&(this._currentHistsGr.remove(e),e--,this._currentVAHistsGr.add(t))}for(;t<this._currentVAHistsGr.size();t++){const e=this._currentVAHistsGr.get(t);this._isVA(e)||(this._currentVAHistsGr.remove(t),t--,this._currentHistsGr.add(e))}}this._previousVAStart=this._currentVAStart,this._previousVAEnd=this._currentVAEnd}_initCurrentBox(){this._currentBox=new _(this)}_updateCurrentBox(){let e=this._minPrice,t=this._maxPrice;this._currentHists.length>0&&(e=this._currentHists[0].priceLow(),t=this._currentHists[this._currentHists.length-1].priceHigh());const i=[],o=(0,s.ensureNotNull)(this._leftBoxTime),n=(0,s.ensureNotNull)(this._actualRightBoxTime);i.push(new u(o,e)),i.push(new u(o,t)),i.push(new u(n,t)),i.push(new u(n,e)),(0,s.ensureNotNull)(this._currentBox).setPoints(i)}_recalculateCurrentResultsOnHistoryBarSet(){for(let e=0;e<this._currentHists.length;++e)this._currentHists[e].erase();this._currentHists=[],this._currentHistsGr.clear(),this._currentVAHistsGr.clear(),this._currentHistsMap.clear();for(let e=0;e<this._historyBarSet.length;e++)this._addHistoryBarToHistogram(this._historyBarSet[e],e,this._currentHists,this._currentHistsMap,1);this._currentHists.length>0&&(this._largestHistItem=this._getLargestHistItem(),this._updateCurrentPoc()),this._updateCurrentBox()}_applyUpdateToCurrentResults(e,t){t&&null!==this._prevRtBar&&this._addHistoryBarToHistogram(this._prevRtBar,this._historyBarSet.length-1,this._currentHists,this._currentHistsMap,-1),this._addHistoryBarToHistogram(e,this._historyBarSet.length-1,this._currentHists,this._currentHistsMap,1),this._updateLastBarTimeInHistogram(this._currentHists)}_addHistoryBarToHistogram(e,t,i,o,n){(0,
s.assert)(-1===n||1===n,"Please set sign argument either +1 or -1");const r=e.low,a=e.high,l=isNaN(e.volume)?0:e.volume,c=e.isUp,h=(0,s.ensureNotNull)(this._rowsLayout);h.init(this._ctx.symbol.minTick,this._minPrice,this._maxPrice,r,a);const u=h.rowWidth();if(!d.Std.greater(u,0))return;h.calculate();const _=h.getIndexLowVbP(),p=h.getIndexHighVbP(),m=h.getStartPrice();if(_===p){const e=_*u+m,t=(_+1)*u+m;this._updateResult({start:e,end:t},n*l,c,i,o)}else{let e=0;for(let t=_;t<=p;t++){const s=t*u+m,h=(t+1)*u+m,d=this._rowCoeff(s,h,r,a),_=d*l;e+=d,this._updateResult({start:s,end:h},n*_,c,i,o)}(0,s.assert)(d.Std.equal(e,1,.05),`totalCoeff not equal 1! totalConf = ${e}`)}}_updateResult(e,t,i,o,n){const r=this._createRates(i,t);(0,s.assert)(null!==this._leftBoxTime,"leftBoxTime is not set (equals null)"),(0,s.assert)(null!==this._rightBoxTime,"rightBoxTime is not set (equals null)");const l=(0,s.ensureNotNull)(this._leftBoxTime),c=(0,s.ensureNotNull)(this._actualRightBoxTime);let h=n.get(e);if(void 0===h)h=new a(this,e.start,e.end,r,l,c),n.set(e,h),this._verifyHistogramSizeIsNotTooLarge(n.size()),this._currentHistsGr.add(h),g._addInOrder(h,o,0,o.length,((e,t)=>{let i=d.Std.compare(e.firstBarTime(),t.firstBarTime());return 0!==i?i:(i=d.Std.compare(e.priceLow(),t.priceLow()),0!==i?i:d.Std.compare(e.priceHigh(),t.priceHigh()))}));else{const e=[];for(let t=0;t<r.length;t++)e[t]=h.rateAt(t)+r[t];h.setRate(e)}}_rebuildOutData(){const e=this._currentHistsMap.size(),t=this._currentHists.length,i=this._currentHistsGr.size(),o=this._currentVAHistsGr.size();(0,s.assert)(e===t&&t===i+o,`Collections of HHistItems are out of sync ${e} ${t} ${i} ${o}`),this._outPocLines.clear(),this._outPocLines.addAll(this._freezedPocs),d.Std.greater(this._getVolume(this._currentHists),0)?(this._outHists.setVariable(this._currentHistsGr),this._outPocLines.add((0,s.ensureNotNull)(this._currentPoc)),this._outVAHists.setVariable(this._currentVAHistsGr)):(this._outHists.setVariable(null),this._outVAHists.setVariable(null)),this._outBoxLines.clear(),this._outBoxLines.addAll(this._freezedBoxes),this._outBoxLines.add((0,s.ensureNotNull)(this._currentBox))}_verifyHistogramSizeIsNotTooLarge(e){if(this._layoutIsAutoselected)return;if(e<=this._maxHHistItems)return;const t=(0,s.ensureNotNull)(this._rowsLayout);0===t.type()?d.Std.error('Histogram is too large, please reduce "Row Size" input.'):((0,s.assert)(1===t.type(),`Unexpected rowsLayout type ${t.type()}`),d.Std.error('Histogram is too large, please increase "Row Size" input.'))}_createRates(e,t){if(1===this._numOfSubHists)return[t];if(2===this._numOfSubHists){const i=[0,0];return i[e?0:1]=t,i}return(0,s.assert)(!1,`Incorrect value of numOfSubHists = ${this._numOfSubHists}`),[]}_updateLastBarTimeInHistogram(e){const t=(0,s.ensureNotNull)(this._actualRightBoxTime);for(const i of e)i.setLastBarTime(t)}_rowCoeff(e,t,i,s){const o=s-i;return(t-e-Math.max(t-s,0)-Math.max(0,i-e))/o}static _addInOrder(e,t,i,s,n){if(i===s)return void t.splice(i,0,e);const r=(0,o.toInt)((i+s)/2),a=t[r]
;n(e,a)<0?g._addInOrder(e,t,i,r,n):n(e,a)>0?g._addInOrder(e,t,r+1,s,n):t.splice(r,0,e)}}},13823:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileBase:()=>p,maxHHistItems:()=>u,numOfSubHists:()=>_});var s,o=i(37103),n=i(46082);!function(e){e[e.NumberOfRows=0]="NumberOfRows",e[e.TicksPerRow=1]="TicksPerRow"}(s||(s={}));class r{constructor(e,t){this._minTick=NaN,this._minPrice=NaN,this._maxPrice=NaN,this._low=NaN,this._high=NaN,this._startPrice=NaN,this._indexLowVbP=NaN,this._indexHighVbP=NaN,this._rowSize=e,this._type=t}init(e,t,i,s,o){this._minTick=e,this._minPrice=t,this._maxPrice=i,this._low=s,this._high=o}getStartPrice(){return this._startPrice}setStartPrice(e){this._startPrice=e}getIndexLowVbP(){return this._indexLowVbP}setIndexLowVbP(e){this._indexLowVbP=e}getIndexHighVbP(){return this._indexHighVbP}setIndexHighVbP(e){this._indexHighVbP=e}type(){return this._type}}class a extends r{constructor(e){super(e,0)}calculate(){this.setStartPrice(this._minPrice);const e=this.rowWidth();let t=Math.floor((this._low-this._minPrice)/e),i=Math.ceil((this._high-this._minPrice)/e)-1;t=Math.max(t,0),i=Math.max(i,0),i=Math.min(i,this._rowSize-1),t=Math.min(t,i),this.setIndexLowVbP(t),this.setIndexHighVbP(i)}rowWidth(){return Math.max((this._maxPrice-this._minPrice)/this._rowSize,this._minTick)}}class l extends r{constructor(e){super(e,1)}calculate(){this.setStartPrice(0);const e=this.rowWidth();let t=Math.floor(this._low/e);const i=Math.ceil(this._high/e)-1;t=Math.min(t,i),this.setIndexLowVbP(t),this.setIndexHighVbP(i)}rowWidth(){return this._minTick*this._rowSize}}var c,h=i(19979),d=i(47132);function u(){return 6e3}function _(e){switch(e){case"Delta":case"Up/Down":return 2;case"Total":return 1;default:h.Std.error(`Invalid study argument value: ${e}`)}}!function(e){e.VolumeUpDown="Up/Down",e.VolumeTotal="Total",e.VolumeDelta="Delta",e.NumberOfRows="Number Of Rows",e.TicksPerRow="Ticks Per Row"}(c||(c={}));class p{findBasicResolutionForFromTo(e,t,i,s){const r=(0,d.getVolumeProfileResolutionForPeriod)(e.value(),t,i,s),a=n.Interval.parse(r);return o.enabled("charting_library_debug_mode")&&console.log(`${(new Date).toISOString()} Selected resolution ${a.value()} for (${e.value()}, ${t}, ${i})`),a}verifyRowSizeInput(e,t){"Number Of Rows"===t&&e>6e3&&h.Std.error('Histogram is too large, please reduce "Row Size" input.')}_getRowsLayout(e,t){return"Number Of Rows"===e?new a(t):new l(t)}}},74109:(e,t,i)=>{"use strict";i.d(t,{volumeProfileFixedRangeBSStudyItem:()=>w,volumeProfileFixedRangeVbPStudyItem:()=>b});var s=i(50151),o=i(13823),n=i(4359),r=i(99481),a=i(46082),l=i(3186),c=i(45591),h=i(75719),d=i(30376),u=i(13421),_=i(60755),p=i(18330),m=i(96777);class g extends m.VolumeByPriceExpr{constructor(e,t,i,s,o,n,r,a,l,c,h,d,u){super(e,t,i,n,r,a,!1,l,c,(()=>h),d,s,o,!1,u),this._firstBarTime=s,this._lastBarTime=o}update(e){this._supplyRowsLayout(this._ctx),this.timeInRequestedRange(e)&&super.update(e)}timeInRequestedRange(e){const t=this._timeScale().get(e);return this._firstBarTime<=t&&t<this._lastBarTime}}var f=i(28056),y=i(19979)
;class v extends o.VolumeProfileBase{constructor(){super(...arguments),this._rowsLayout="Number Of Rows",this._rowSize=24,this._volume="Up/Down",this._firstBarTime=0,this._lastBarTime=0,this._vaVolumePercent=70,this._anInt=0,this._eraseCmds=[]}nextGraphicsObjId(){return++this._anInt}pushEraseObjCmd(e,t){this._eraseCmds.push(new h.EraseObj(e,t))}popEraseCmds(){const e=this._eraseCmds;return this._eraseCmds=[],e}init(e,t){this._studyDataUpdate=new u.JStudyDataUpdate(!0),this._hists=new l.GraphicsListColl,this._boxPolygons=new d.GraphicsList,this._pocLines=new d.GraphicsList,this._valueAreaHists=new l.GraphicsListColl;const i=new c.StudyGraphicsData;i.getObjsContainer("hhists").push(new c.Container("histBars2",this._hists)),i.getObjsContainer("hhists").push(new c.Container("histBarsVA",this._valueAreaHists)),i.getObjsContainer("horizlines").push(new c.Container("pocLines",this._pocLines)),i.getObjsContainer("polygons").push(new c.Container("histBoxBg",this._boxPolygons)),this._studyDataUpdate.init(i),this._rowsLayout=t(0),this._rowSize=t(1),this._volume=t(2),this._firstBarTime=t(3),this._lastBarTime=t(4),this._vaVolumePercent=t(5),this.verifyRowSizeInput(this._rowSize,this._rowsLayout),this._originalResolution=a.Interval.parse(e.symbol.interval+e.symbol.resolution);const n=this._lastBarTime+this._originalResolution.inMilliseconds(this._lastBarTime);0===this._firstBarTime&&0===this._lastBarTime?this._basicResolution=this._originalResolution:this._basicResolution=this.findBasicResolutionForFromTo(this._originalResolution,this._firstBarTime,n,(0,s.ensureDefined)(e.symbol.info)),this._hasSecondarySymbol=!this._originalResolution.isEqualTo(this._basicResolution),this._hasSecondarySymbol&&e.new_sym(e.symbol.tickerid,this._basicResolution.value());const r=this._getRowsLayout(this._rowsLayout,this._rowSize);this._vbPCheckHaveVolumeExpr=new _.VbPCheckHaveVolumeExpr(this),this._volumeByPriceExpr=new g((0,o.numOfSubHists)(this._volume),e,this,this._firstBarTime,n,this._hists,this._boxPolygons,this._pocLines,this._valueAreaHists,this._vaVolumePercent,r,(0,o.maxHHistItems)(),this._lastBarTime),this._volumeByPriceExpr.setIdsGeneratorProxy(this),this._developingPocSeries=new f.VolumeProfileOutputSeries,this._developingVAHighSeries=new f.VolumeProfileOutputSeries,this._developingVALowSeries=new f.VolumeProfileOutputSeries}main(e,t,i){this._hasSecondarySymbol&&e.select_sym(1),this._timeSeries=e.new_unlimited_var(),this._openSeries=e.new_unlimited_var(),this._highSeries=e.new_unlimited_var(),this._lowSeries=e.new_unlimited_var(),this._closeSeries=e.new_unlimited_var(),this._volumeSeries=e.new_unlimited_var();const o={type:"composite",data:[]};if(i&&i.period===this._basicResolution.value()&&(this._timeSeries.set(y.Std.time(e)),this._openSeries.set(y.Std.open(e)),this._highSeries.set(y.Std.high(e)),this._lowSeries.set(y.Std.low(e)),this._closeSeries.set(y.Std.close(e)),this._volumeSeries.set(y.Std.volume(e)),this._developingPocSeries.addHist(y.Std.time(e)),this._developingVAHighSeries.addHist(y.Std.time(e)),
this._developingVALowSeries.addHist(y.Std.time(e)),this._vbPCheckHaveVolumeExpr.update(0,e.symbol.isLastBar),this._volumeByPriceExpr.update(0),this._developingPocSeries.removeLastIfNaN(),this._developingVAHighSeries.removeLastIfNaN(),this._developingVALowSeries.removeLastIfNaN(),e.symbol.isLastBar)){this._studyDataUpdate.setEraseCmds(this.popEraseCmds()),this._studyDataUpdate.update();const e=this._studyDataUpdate.getUpdate();e.json&&o.data.push({nonseries:!0,type:"study_graphics",data:e.json}),e.jsonUpdate&&o.data.push({nonseries:!0,type:"study_graphics",data:e.jsonUpdate})}if(this._hasSecondarySymbol&&e.select_sym(0),i&&i.period===this._originalResolution.value()){(0,s.assert)(e.symbol.time===i.time);const t=i.time,n=t+this._originalResolution.inMilliseconds(t)-1;if(t&&t>=this._firstBarTime){const e=this._developingPocSeries.getLeftOrEqual(n),t=this._developingVAHighSeries.getLeftOrEqual(n),i=this._developingVALowSeries.getLeftOrEqual(n);o.data.push([e,t,i])}else o.data.push([NaN,NaN,NaN])}return o}time(){return this._timeSeries}open(){return this._openSeries}high(){return this._highSeries}low(){return this._lowSeries}close(){return this._closeSeries}volume(){return this._volumeSeries}developingPoc(){return this._developingPocSeries}developingVAHigh(){return this._developingVAHighSeries}developingVALow(){return this._developingVALowSeries}}function S(e){return{constructor:v,name:e.description,metainfo:{_metainfoVersion:51,shortDescription:"VPFR",format:{type:"volume"},is_price_study:!0,defaults:{graphics:{hhists:{histBars2:{colors:["",""],direction:r.HHistDirection.LeftToRight,percentWidth:30,showValues:!1,transparencies:[76,76],valuesColor:"#424242",visible:!0},histBarsVA:{colors:["#1592e6","#fbc123"],direction:r.HHistDirection.LeftToRight,percentWidth:30,showValues:!1,transparencies:[30,30],valuesColor:"",visible:!0}},horizlines:{pocLines:{color:"",style:p.LineStyle.Solid,visible:!0,width:2}},polygons:{histBoxBg:{color:"",transparency:94}}},inputs:{first_bar_time:0,last_bar_time:0,rows:24,rowsLayout:"Number Of Rows",subscribeRealtime:!0,vaVolume:70,volume:"Up/Down"},styles:{developingPoc:{color:"",linestyle:p.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0},developingVAHigh:{color:"",linestyle:p.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0},developingVALow:{color:"",linestyle:p.LineStyle.Solid,linewidth:1,plottype:n.LineStudyPlotStyle.StepLine,trackPrice:!1,transparency:0,display:0}}},graphics:{hhists:{histBars2:{location:r.HHistLocation.Absolute,title:"Volume Profile",titles:["Up Volume","Down Volume"]},histBarsVA:{location:r.HHistLocation.Absolute,title:"Value Area",titles:["Value Area Up","Value Area Down"]}},horizlines:{pocLines:{name:"POC",showPrice:!0}},polygons:{histBoxBg:{mouseTouchable:!1,name:"Histogram Box",showBorder:!1}}},inputs:[{defval:"Number Of Rows",id:"rowsLayout",name:"Rows Layout",options:["Number Of Rows","Ticks Per Row"],type:"text"},{defval:24,id:"rows",max:1e6,min:1,
name:"Row Size",type:"integer"},{defval:"Up/Down",id:"volume",name:"Volume",options:["Up/Down","Total","Delta"],type:"text"},{defval:0,id:"first_bar_time",isHidden:!0,max:253370764800,min:-253370764800,name:"First Bar Time",type:"time"},{defval:0,id:"last_bar_time",isHidden:!0,max:253370764800,min:-253370764800,name:"Last Bar Time",type:"time"},{defval:70,id:"vaVolume",max:100,min:0,name:"Value Area Volume",type:"integer"},{defval:!0,id:"subscribeRealtime",isHidden:!0,name:"SubscribeRealtime",type:"bool"}],plots:[{id:"developingPoc",type:"line"},{id:"developingVAHigh",type:"line"},{id:"developingVALow",type:"line"}],styles:{developingPoc:{histogramBase:0,title:"Developing Poc"},developingVAHigh:{histogramBase:0,title:"Developing VA High"},developingVALow:{histogramBase:0,title:"Developing VA Low"}},...e}}}const b=S({id:"VbPFixed@tv-volumebyprice-57",description:"Volume Profile Fixed Range"}),w=S({id:"VbPFixed@tv-basicstudies-152",description:"Fixed Range",is_hidden_study:!0})},28056:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileOutputSeries:()=>n});var s=i(50151),o=i(12217);class n{constructor(){this._histPos=-1,this._hist=new Float64Array(2e3),this._times=new Float64Array(2e3)}addHist(e){if(this._histPos>=0){const t=this._times[this._histPos];(0,s.assert)(t<=e,"History order violation"),this._histPos+=t===e?0:1}else this._histPos+=1;if(this._histPos===this._hist.length){const e=new Float64Array(2*this._hist.length);e.set(this._hist),this._hist=e;const t=new Float64Array(this._hist.length);t.set(this._times),this._times=t}this._hist[this._histPos]=NaN,this._times[this._histPos]=e}removeLastIfNaN(){Number.isNaN(this.get(0))&&(this._histPos-=1)}get(e){(0,s.assert)(0===e);const t=this._histPos-e;return this._hist[t]}getLeftOrEqual(e){const t=(0,o.upperbound)(this._times,e,((e,t)=>e<t),0,this._histPos+1);return 0===t?NaN:this._hist[t-1]}set(e){this._hist[this._histPos]=e}indexOf(e){throw new Error("Not implemented")}adopt(e,t,i){throw new Error("Method not implemented.")}}},53690:(e,t,i)=>{"use strict";i.d(t,{volumeProfileVisibleRangeStudyItem:()=>y});var s=i(50151),o=i(13823),n=i(99481),r=i(46082),a=i(3186),l=i(96777),c=i(30376);class h extends l.VolumeByPriceExpr{constructor(e,t,i,s,o,n,r,a,l,h,d){super(e,t,i,n,new c.GraphicsList,r,!0,a,l,(()=>h),d,s,o,!1),this._firstBarTime=s,this._lastBarTime=o}update(e){this._supplyRowsLayout(this._ctx),this.timeInRequestedRange(e)&&super.update(e)}timeInRequestedRange(e){const t=this._timeScale().get(e);return this._firstBarTime<=t&&t<this._lastBarTime}}var d=i(45591),u=i(75719),_=i(13421),p=i(60755),m=i(28056),g=i(19979);class f extends o.VolumeProfileBase{constructor(){super(...arguments),this._rowsLayout="Number Of Rows",this._rowSize=24,this._volume="Up/Down",this._firstBarTime=0,this._lastBarTime=0,this._vaVolumePercent=70,this._anInt=0,this._eraseCmds=[]}nextGraphicsObjId(){return++this._anInt}pushEraseObjCmd(e,t){this._eraseCmds.push(new u.EraseObj(e,t))}popEraseCmds(){const e=this._eraseCmds;return this._eraseCmds=[],e}init(e,t){
this._studyDataUpdate=new _.JStudyDataUpdate(!0),this._hists=new a.GraphicsListColl,this._pocLines=new c.GraphicsList,this._valueAreaHists=new a.GraphicsListColl;const i=new d.StudyGraphicsData;i.getObjsContainer("hhists").push(new d.Container("histBars2",this._hists)),i.getObjsContainer("hhists").push(new d.Container("histBarsVA",this._valueAreaHists)),i.getObjsContainer("horizlines").push(new d.Container("pocLines",this._pocLines)),this._studyDataUpdate.init(i),this._rowsLayout=t(0),this._rowSize=t(1),this._volume=t(2),this._firstBarTime=t(3),this._lastBarTime=t(4),this._vaVolumePercent=t(5),this.verifyRowSizeInput(this._rowSize,this._rowsLayout),this._originalResolution=r.Interval.parse(e.symbol.interval+e.symbol.resolution);const n=this._lastBarTime+this._originalResolution.inMilliseconds(this._lastBarTime);0===this._firstBarTime&&0===this._lastBarTime?this._basicResolution=this._originalResolution:this._basicResolution=this.findBasicResolutionForFromTo(this._originalResolution,this._firstBarTime,n,(0,s.ensureDefined)(e.symbol.info)),this._hasSecondarySymbol=!this._originalResolution.isEqualTo(this._basicResolution),this._hasSecondarySymbol&&e.new_sym(e.symbol.tickerid,this._basicResolution.value());const l=this._getRowsLayout(this._rowsLayout,this._rowSize);this._vbPCheckHaveVolumeExpr=new p.VbPCheckHaveVolumeExpr(this),this._volumeByPriceExpr=new h((0,o.numOfSubHists)(this._volume),e,this,this._firstBarTime,n,this._hists,this._pocLines,this._valueAreaHists,this._vaVolumePercent,l,(0,o.maxHHistItems)()),this._volumeByPriceExpr.setIdsGeneratorProxy(this),this._developingPocSeries=new m.VolumeProfileOutputSeries,this._developingVAHighSeries=new m.VolumeProfileOutputSeries,this._developingVALowSeries=new m.VolumeProfileOutputSeries}main(e,t,i){this._hasSecondarySymbol&&e.select_sym(1),this._timeSeries=e.new_unlimited_var(),this._openSeries=e.new_unlimited_var(),this._highSeries=e.new_unlimited_var(),this._lowSeries=e.new_unlimited_var(),this._closeSeries=e.new_unlimited_var(),this._volumeSeries=e.new_unlimited_var();const o={type:"composite",data:[]};if(i&&i.period===this._basicResolution.value()&&(this._timeSeries.set(g.Std.time(e)),this._openSeries.set(g.Std.open(e)),this._highSeries.set(g.Std.high(e)),this._lowSeries.set(g.Std.low(e)),this._closeSeries.set(g.Std.close(e)),this._volumeSeries.set(g.Std.volume(e)),e.symbol.isFirstBar&&e.symbol.isLastBar||(this._developingPocSeries.addHist(g.Std.time(e)),this._developingVAHighSeries.addHist(g.Std.time(e)),this._developingVALowSeries.addHist(g.Std.time(e))),this._vbPCheckHaveVolumeExpr.update(0,e.symbol.isLastBar),this._volumeByPriceExpr.update(0),this._developingPocSeries.removeLastIfNaN(),this._developingVAHighSeries.removeLastIfNaN(),this._developingVALowSeries.removeLastIfNaN(),e.symbol.isLastBar)){this._studyDataUpdate.setEraseCmds(this.popEraseCmds()),this._studyDataUpdate.update();const e=this._studyDataUpdate.getUpdate();e.json&&o.data.push({nonseries:!0,type:"study_graphics",data:e.json}),e.jsonUpdate&&o.data.push({nonseries:!0,type:"study_graphics",
data:e.jsonUpdate})}if(this._hasSecondarySymbol&&e.select_sym(0),i&&i.period===this._originalResolution.value()){(0,s.assert)(e.symbol.time===i.time);const t=i.time,n=t+this._originalResolution.inMilliseconds(t)-1;if(t&&t>=this._firstBarTime){const e=this._developingPocSeries.getLeftOrEqual(n),t=this._developingVAHighSeries.getLeftOrEqual(n),i=this._developingVALowSeries.getLeftOrEqual(n);o.data.push([e,t,i])}else o.data.push([NaN,NaN,NaN])}return o}time(){return this._timeSeries}open(){return this._openSeries}high(){return this._highSeries}low(){return this._lowSeries}close(){return this._closeSeries}volume(){return this._volumeSeries}developingPoc(){return this._developingPocSeries}developingVAHigh(){return this._developingVAHighSeries}developingVALow(){return this._developingVALowSeries}}const y={constructor:f,name:"Volume Profile Visible Range",metainfo:{_metainfoVersion:51,id:"VbPVisible@tv-basicstudies-49",description:"Volume Profile Visible Range",shortDescription:"VPVR",format:{type:"volume"},is_price_study:!0,linkedToSeries:!0,palettes:{},inputs:[{id:"rowsLayout",name:"Rows Layout",defval:"Number Of Rows",options:["Number Of Rows","Ticks Per Row"],type:"text"},{id:"rows",name:"Row Size",defval:24,max:1e6,min:1,type:"integer"},{id:"volume",name:"Volume",defval:"Up/Down",options:["Up/Down","Total","Delta"],type:"text"},{id:"first_visible_bar_time",name:"First Visible Bar Time",defval:0,isHidden:!0,max:253370764800,min:-253370764800,type:"time"},{id:"last_visible_bar_time",name:"Last Visible Bar Time",defval:0,isHidden:!0,max:253370764800,min:-253370764800,type:"time"},{id:"vaVolume",name:"Value Area Volume",defval:70,max:100,min:0,type:"integer"}],plots:[{id:"developingPoc",type:"line"},{id:"developingVAHigh",type:"line"},{id:"developingVALow",type:"line"}],graphics:{hhists:{histBars2:{location:n.HHistLocation.Relative,title:"Volume Profile",titles:["Up Volume","Down Volume"]},histBarsVA:{location:n.HHistLocation.Relative,title:"Value Area",titles:["Value Area Up","Value Area Down"]}},horizlines:{pocLines:{name:"POC",showPrice:!0}}},defaults:{graphics:{hhists:{histBars2:{colors:["",""],direction:n.HHistDirection.RightToLeft,percentWidth:30,showValues:!1,transparencies:[76,76],valuesColor:"",visible:!0},histBarsVA:{colors:["",""],direction:n.HHistDirection.RightToLeft,percentWidth:30,showValues:!1,transparencies:[30,30],valuesColor:"",visible:!0}},horizlines:{pocLines:{color:"",style:0,visible:!0,width:2},vahLines:{color:"",style:0,visible:!1,width:2},valLines:{color:"",style:0,visible:!1,width:2}}},inputs:{first_visible_bar_time:0,last_visible_bar_time:0,rows:24,rowsLayout:"Number Of Rows",vaVolume:70,volume:"Up/Down"},styles:{developingPoc:{color:"",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0},developingVAHigh:{color:"",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0},developingVALow:{color:"",linestyle:0,linewidth:1,plottype:9,trackPrice:!1,transparency:0,display:0}}},styles:{developingPoc:{histogramBase:0,title:"Developing Poc"},developingVAHigh:{
histogramBase:0,title:"Developing VA High"},developingVALow:{histogramBase:0,title:"Developing VA Low"}}}}},4659:(e,t,i)=>{"use strict";i.d(t,{StudyError:()=>s});class s extends Error{constructor(e,t){super(e),this.studyError=!0,this.title=t}}},75719:(e,t,i)=>{"use strict";var s;i.d(t,{EraseAll:()=>n,EraseObj:()=>o,GraphicsCmds:()=>r}),function(e){e.One="one",e.All="all"}(s||(s={}));class o{constructor(e,t){this.id=e,this.type=t}primitiveData(){return{action:"one",id:this.id,type:this.type}}}class n{primitiveData(){return{action:"all"}}}class r{constructor(){this.erase=[],this.create=null,this._modified=!1}primitiveData(e){if(this.isNaN())return null;const t={},i=this.create&&this.create.primitiveData(e);return null!==i&&(t.create=i),null!==this.erase&&this.erase.length>0&&(t.erase=this.erase.map((e=>e.primitiveData()))),void 0===t.create&&void 0===t.erase?null:t}setCreate(e){this.create=e,this.create.forEachList((e=>e.setOwner(this)))}isNaN(){return(null===this.erase||0===this.erase.length)&&null===this.create}isModified(){return this._modified}setModified(e){this._modified=e}dirty(){this._modified=!0}setOwner(e){throw new Error("Unsupported")}}},3186:(e,t,i)=>{"use strict";i.d(t,{GraphicsListColl:()=>s});class s{constructor(){this._stable=[],this._variable=null,this._owner=null}addStable(e){e.setOwner(this),this._stable.push(e)}setVariable(e){this._variable=e,null!==this._variable&&this._variable.setOwner(this)}primitivesData(e){const t=[];return this._forEach((i=>t.push(...i.primitivesData(e)))),t}deleteErasedItems(){this._forEach((e=>e.deleteErasedItems()))}markPostedItems(){this._forEach((e=>e.markPostedItems()))}isNaN(){return this._all((e=>e.isNaN()))}dirty(){null!==this._owner&&this._owner.dirty()}setOwner(e){this._owner=e}_forEach(e){for(const t of this._stable)e(t);null!==this._variable&&e(this._variable)}_all(e){for(const t of this._stable)if(!e(t))return!1;return null===this._variable||e(this._variable)}}},30376:(e,t,i)=>{"use strict";i.d(t,{GraphicsList:()=>n});var s=i(86811),o=i(31645);class n{constructor(){this._items=[],this._owner=null}primitivesData(e){const t=[];for(const i of this._items)e.isIgnoredObj(i)||t.push(i.primitiveData());return t}get(e){return this._items[e]}set(e,t){return this.dirty(),t.setOwner(this),this._items[e]=t,t}addAtIndex(e,t){this.dirty(),t.setOwner(this),this._items[e]=t}clear(){this._unsetOwner(this._items),this._items=[],this.dirty()}addAllFromNumber(e,t){this.setOwner(t),this._items.splice(e,0,...t._items);const i=!0;return this._setCachedDataValid(!1),i}addAll(e){this.setOwner(e),this._items.push(...e._items);const t=!0;return this._setCachedDataValid(!1),t}remove(e){const t=this._items[e];return this._items.splice(e,1),t.unsetOwner(this),this.dirty(),t}getItems(){return this._items}size(){return this._items.length}add(e){e.setOwner(this),this._items.push(e);const t=!0;return this._setCachedDataValid(!1),t}deleteErasedItems(){this._items=this._items.filter((e=>!e.isErased()))}markPostedItems(){for(const e of this._items)e.markAsPosted()}isNaN(){
if(0===this._items.length)return!0;for(const e of this._items){if(!(0,o.isNaNable)(e))return!1;if(!e.isNaN())return!1}return!0}setOwner(e){this._owner=e}dirty(){null!==this._owner&&this._owner.dirty()}_unsetOwner(e){for(const t of e)t instanceof s.GraphicsObj&&t.unsetOwner(this)}_setCachedDataValid(e){e||this.dirty()}}},86811:(e,t,i)=>{"use strict";i.d(t,{GraphicsObj:()=>l});var s=i(19979);class o{constructor(e,t,i,s){this._value=e,this._name=t,this._owner=i,this._comparer=void 0!==s?s:(e,t)=>null==e?null!=t:e===t}getName(){return this._name}set(e){const t=this._comparer(this._value,e);return t&&this._owner.dirty(),this._value=e,t}get(){return this._value}}class n{constructor(e,t,i){this._owner=null,this._value=e,this._name=t,this._owner=i}getName(){return this._name}set(e){return this._value!==e&&(this._value=e,null!==this._owner&&this._owner.dirty(),!0)}get(){return this._value}}class r extends o{constructor(e,t,i,s){super(e,t,i,s)}}class a{constructor(e){this._owner=e}createField(e,t){return new o(e,t,this)}createDoubleField(e,t){return new o(e,t,this,((e,t)=>!s.Std.equal(e,t)))}createDoubleArrayField(e,t){return new r(e,t,this,((e,t)=>{if(e===t)return!1;const i=e.length;if(t.length!==i)return!0;for(let o=0;o<i;o++){const i=e[o],n=t[o];if(!s.Std.equal(i,n))return!0}return!1}))}createTimeField(e,t){return new n(e,t,this)}dirty(){null!==this._owner&&this._owner.dirty()}setOwner(e){this._owner=e}}class l{constructor(e){this._mixinJSONObject=new a(this),this._state=0,this._owner=null,this._gen=e,this._id=e.nextGraphicsObjId(),this._id2=this._mixinJSONObject.createField(this.id(),"id")}dirty(){null!==this._owner&&this._owner.dirty()}setOwner(e){this._owner=e}id(){return this._id}unsetOwner(e){this._owner===e&&(this._owner=null)}state(){return this._state}erase(){1===this._state&&this._gen.pushEraseObjCmd(this._id,this.jsonName()),this._state=2,this.dirty()}markAsPosted(){1!==this._state&&(this._state=1,this.dirty())}isErased(){return 2===this._state}isPosted(){return 1===this._state}isNaN(){return!1}_processObjUpdate(){1===this._state&&(this._gen.pushEraseObjCmd(this._id,this.jsonName()),this._id=this._gen.nextGraphicsObjId(),this._id2.set(this._id),this._state=0),this.dirty()}}},31645:(e,t,i)=>{"use strict";function s(e){return Boolean(e.isNaN)}i.d(t,{isNaNable:()=>s})},13421:(e,t,i)=>{"use strict";i.d(t,{JStudyDataUpdate:()=>p});var s=i(75719);class o{constructor(){this.isUpdate=!1,this.graphicsCmds=new s.GraphicsCmds,this._offsetsChanged=!1,this._disableGraphicsAndData=!1}isNaN(){return this.graphicsCmds.isNaN()}primitiveData(e){const t={};if(!this._disableGraphicsAndData){const i=this.graphicsCmds.primitiveData(e);null!==i&&(t.graphicsCmds=i)}return this.isUpdate&&(t.isUpdate=!0),void 0===t.graphicsCmds?void 0:t}disable(){this._disableGraphicsAndData=!0}checkForChangeAndResetChangedState(e){const t=this._offsetsChanged,i=this.graphicsCmds.isModified();this.graphicsCmds.setModified(!1),this._offsetsChanged=!1;return i||t||0!==e.length}}class n{constructor(e){this._dataObj=new o,this._isDirty=!1,this._eraseCmds=[],
this._enableCmdDataStudy=e}init(e){this._dataObj.graphicsCmds.setCreate(e),this.update(!0)}dataObj(){return this._dataObj}setEraseCmds(e){this._eraseCmds=e}resetDirtyState(){this._isDirty=!1}disable(){this._dataObj.disable()}}var r,a=i(87465),l=i(31645);function c(e){return Boolean(e.isPosted)}!function(e){e[e.New=0]="New",e[e.Posted=1]="Posted",e[e.Erased=2]="Erased"}(r||(r={}));class h{isIgnoredObj(e,t){return h.isIgnoredObjDefault(e,t)}static isIgnoredObjDefault(e,t){if(void 0===t)return h.isIgnoredObjNaNable(e);const i=e[t];return h.isIgnoredByGeneralRules(e,t)||h.isIgnoredObjNaNable(i)||h.isIgnoredObjListOfNaNables(i)}static isIgnoredObjNaNable(e){return(0,l.isNaNable)(e)&&e.isNaN()}static isIgnoredObjListOfNaNables(e){if(!(0,a.isArray)(e))return!1;let t=!0;for(const i of e)if(!(0,l.isNaNable)(i)||!i.isNaN()){t=!1;break}return t}static isIgnoredObjPosted(e){return c(e)&&e.isPosted()}static isIgnoredObjErased(e){return c(e)&&e.isErased()}static isIgnoredByGeneralRules(e,t){const i=e[t];return(0,a.isArray)(i)&&0===i.length}}class d{isIgnoredObj(e,t){if(void 0===t)return h.isIgnoredObjDefault(e)||h.isIgnoredObjErased(e);const i=e[t];return h.isIgnoredObjDefault(e,t)||h.isIgnoredObjErased(i)}}class u extends n{constructor(e){super(e),this._snapshotPredicate=new d,this._dataSnapShot={}}getData(){return this._dataSnapShot}getUpdate(){return this._isDirty?this._dataSnapShot:{}}update(e){(this._dataObj.checkForChangeAndResetChangedState(this._eraseCmds)||e)&&(null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.create.deleteErasedObjs(),this._dataObj.graphicsCmds.erase=[new s.EraseAll]),this._makeSnapshot(),this._isDirty=!0)}_makeSnapshot(){this._json=this._dataObj.primitiveData(this._snapshotPredicate),this._dataSnapShot={json:this._json}}}class _{isIgnoredObj(e,t){if(void 0===t)return h.isIgnoredObjDefault(e)||h.isIgnoredObjErased(e)||h.isIgnoredObjPosted(e);const i=e[t];return h.isIgnoredObjDefault(e,t)||h.isIgnoredObjErased(i)||h.isIgnoredObjPosted(i)}}class p extends u{constructor(e){super(e),this._updatePredicate=new _,this._sendShapshotOnly=!0,this._isFirstNotForcedUpdate=!0}update(e){(this._dataObj.checkForChangeAndResetChangedState(this._eraseCmds)||e)&&(null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.erase=[new s.EraseAll]),this._dataObj.isUpdate=!0,this._makeSnapshot(),null!==this._dataObj.graphicsCmds.create&&(this._dataObj.graphicsCmds.erase=this._eraseCmds),this._dataObj.isUpdate=!0,this._jsonUpdate=this._dataObj.primitiveData(this._updatePredicate),null!==this._dataObj.graphicsCmds.create&&this._dataObj.graphicsCmds.create.deleteErasedAndMarkPostedObjs(),this._sendShapshotOnly=e||this._isFirstNotForcedUpdate,this._isFirstNotForcedUpdate=Boolean(e),this._isDirty=!0)}getUpdate(){return this._isDirty?this._enableCmdDataStudy?{json:this._sendShapshotOnly?this._json:void 0,jsonUpdate:this._sendShapshotOnly?void 0:this._jsonUpdate}:{json:this._json,jsonUpdate:this._sendShapshotOnly?void 0:this._jsonUpdate}:{}}}},45591:(e,t,i)=>{"use strict";i.d(t,{Container:()=>n,
StudyGraphicsData:()=>o});var s=i(50151);class o{constructor(){this._horizlines=[],this._hhists=[],this._polygons=[],this._vertlines=[],this._containersCache=[],this._containerNamesCache=[],this._containersMapCache=new Map,this._addToCache("horizlines",this._horizlines),this._addToCache("hhists",this._hhists),this._addToCache("polygons",this._polygons),this._addToCache("vertlines",this._vertlines)}primitiveData(e){const t={};let i=!1;for(const s of this._containerNamesCache){const o=[],n=this.getObjsContainer(s);for(const t of n){if(t.isNaN())continue;const i=t.primitiveData(e);i.data.length>0&&o.push(i)}o.length>0&&(t[s]=o,i=!0)}return i?t:null}deleteErasedAndMarkPostedObjs(){this.forEachList((e=>{e.deleteErasedItems(),e.markPostedItems()}))}deleteErasedObjs(){this.forEachList((e=>e.deleteErasedItems()))}getObjsContainer(e){return(0,s.ensureDefined)(this._containersMapCache.get(e))}forEachList(e){for(const t of this._containersCache)for(const i of t)e(i.data)}_addToCache(e,t){this._containersCache.push(t),this._containerNamesCache.push(e),this._containersMapCache.set(e,t)}}class n{constructor(e,t){this.styleId=e,this.data=t}isNaN(){return this.data.isNaN()}primitiveData(e){return{styleId:this.styleId,data:this.data.primitivesData(e)}}}},4783:(e,t,i)=>{"use strict";const s=i(58978).getHexColorByName,o=i(19979).Std,n=s("color-ripe-red-100"),r=s("color-ripe-red-200"),a=s("color-ripe-red-500"),l=s("color-ripe-red-900"),c=s("color-ripe-red-a200"),h=s("color-minty-green-100"),d=s("color-minty-green-400"),u=s("color-minty-green-500");JSServer.studyLibrary=[{name:"Accumulation/Distribution",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Accumulation/Distribution",shortDescription:"Accum/Dist",is_price_study:!1,inputs:[],id:"Accumulation/Distribution@tv-basicstudies-1",scriptIdPart:"",name:"Accumulation/Distribution",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i,s){return o.or(o.and(o.eq(e,t),o.eq(e,i)),o.eq(t,i))?0:(2*e-i-t)/(t-i)*s},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0(o.close(this._context),o.high(this._context),o.low(this._context),o.volume(this._context));return[o.cum(i,this._context)]}}},{name:"Accumulative Swing Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ASI",histogramBase:0,joinPoints:!1}},description:"Accumulative Swing Index",shortDescription:"ASI",is_price_study:!1,inputs:[{id:"in_0",name:"Limit Move Value",defval:10,type:"float",min:.1,max:1e5}],id:"Accumulative Swing Index@tv-basicstudies-1",scriptIdPart:"",name:"Accumulative Swing Index",format:{
type:"volume"}},constructor:function(){this.f_0=function(e,t){var i=t.new_var(o.open(t)),s=t.new_var(o.high(t)),n=t.new_var(o.low(t)),r=t.new_var(o.close(t)),a=o.abs(s-r.get(1)),l=o.abs(n-r.get(1)),c=o.abs(s-n),h=o.abs(r.get(1)-i.get(1)),d=o.max(a,l),u=o.iff(a>=o.max(l,c),a-.5*l+.25*h,o.iff(l>=o.max(a,c),l-.5*a+.25*h,c+.25*h));return o.iff(0===u,0,(r-r.get(1)+.5*(r-i)+.25*(r.get(1)-i.get(1)))/u*d/e*50)},this.f_1=function(e,t){var i=this.f_0(e,t);return o.cum(i,t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);return[this.f_1(i,this._context)]}}},{name:"Advance/Decline",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Advance/Decline",shortDescription:"AD",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:10,type:"integer",min:1,max:2e3}],id:"Advance/Decline@tv-basicstudies-1",scriptIdPart:"",name:"Advance/Decline",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t){return o.gt(e,t)},this.f_1=function(e,t){return o.lt(e,t)},this.f_2=function(e,t){return 0===t?e:e/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this.f_0(o.close(this._context),o.open(this._context)),n=this._context.new_var(s),r=o.sum(n,i,this._context),a=this.f_1(o.close(this._context),o.open(this._context)),l=this._context.new_var(a),c=o.sum(l,i,this._context);return[this.f_2(r,c)]}}},{name:"Arnaud Legoux Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:.85,in_2:6}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Arnaud Legoux Moving Average",shortDescription:"ALMA",is_price_study:!0,inputs:[{id:"in_0",name:"Window Size",defval:9,type:"integer",min:0,max:5e3},{id:"in_1",name:"Offset",defval:.85,type:"float",min:-1e12,max:1e12},{id:"in_2",name:"Sigma",defval:6,type:"float",min:-1e12,max:1e12}],id:"Arnaud Legoux Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Arnaud Legoux Moving Average",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._input(1),r=this._input(2),a=this._context.new_var(i);return[o.alma(a,s,n,r)]}}},{name:"Aroon",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FB8C00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Upper",
histogramBase:0,joinPoints:!1},plot_1:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Aroon",shortDescription:"Aroon",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Aroon@tv-basicstudies-1",scriptIdPart:"",name:"Aroon",format:{precision:2,type:"percent"}},constructor:function(){this.f_0=function(e,t){return 100*(e+t)/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=o.high(this._context),n=i+1,r=this._context.new_var(s),a=o.highestbars(r,n,this._context),l=this.f_0(a,i),c=o.low(this._context),h=this._context.new_var(c),d=o.lowestbars(h,n,this._context);return[l,this.f_0(d,i)]}}},{name:"Average Price",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"AveragePrice@tv-basicstudies-1",scriptIdPart:"",name:"Average Price",description:"Average Price",shortDescription:"Average Price",is_price_study:!0,plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{symbol:""}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){if(this._context=e,this._input=t,""===this._input(0))return[o.ohlc4(this._context)];this._context.select_sym(0);const i=this._context.new_var(this._context.symbol.time);this._context.select_sym(1);const s=this._context.new_var(o.ohlc4(this._context)).adopt(this._context.new_var(this._context.symbol.time),i,1);return this._context.select_sym(0),[s]}}},{name:"Average Directional Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{in_0:14,in_1:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ADX",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Average Directional Index",shortDescription:"ADX",is_price_study:!1,inputs:[{id:"in_0",name:"ADX Smoothing",defval:14,type:"integer",min:-1e12,max:1e12},{id:"in_1",name:"DI Length",defval:14,type:"integer",min:-1e12,max:1e12}],id:"average_directional_Index@tv-basicstudies-1",scriptIdPart:"",name:"Average Directional Index",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e){var t=this._context.new_var(o.high(this._context)),i=o.change(t),s=this._context.new_var(o.low(this._context)),n=-o.change(s),r=this._context.new_var(o.tr(void 0,this._context)),a=o.rma(r,e,this._context),l=this._context.new_var(o.and(o.gt(i,n),o.gt(i,0))?i:0),c=o.fixnan(100*o.rma(l,e,this._context)/a,this._context),h=this._context.new_var(o.and(o.gt(n,i),o.gt(n,0))?n:0);return[c,o.fixnan(100*o.rma(h,e,this._context)/a,this._context)]},this.f_1=function(e,t){
var i=this.f_0(e),s=i[0],n=i[1],r=s+n,a=this._context.new_var(o.abs(s-n)/(o.eq(r,0)?1:r));return[100*o.rma(a,t,this._context)]},this.main=function(e,t){return this._context=e,this._input=t,this._context.setMinimumAdditionalDepth(this._input(0)+this._input(1)),this.f_1(this._input(1),this._input(0))}}},{name:"Average True Range",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:l}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Average True Range",shortDescription:"ATR",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Average True Range@tv-basicstudies-1",scriptIdPart:"",name:"Average True Range",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){var i=t(0);return[o.atr(i,e)]}}},{name:"Awesome Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:a,width:1,style:0},1:{color:u,width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Awesome Oscillator",shortDescription:"AO",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}}}},inputs:[],id:"Awesome Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Awesome Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e){return o.le(e,0)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=o.hl2(this._context),s=this._context.new_var(i),n=o.sma(s,5,this._context),r=this._context.new_var(i),a=o.sma(r,34,this._context),l=this.f_0(n,a),c=l,h=this._context.new_var(l),d=o.change(h);return[c,this.f_1(d)]}}},{name:"Accelerator Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:a,width:1,style:0},1:{color:u,width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Accelerator Oscillator",shortDescription:"AO",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}}}},inputs:[],id:"Accelerator Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Accelerator Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e){return o.le(e,0)?0:1},this.main=function(e,t){this._context=e,this._input=t
;var i=o.hl2(this._context),s=this._context.new_var(i),n=o.sma(s,5,this._context),r=this._context.new_var(i),a=o.sma(r,34,this._context),l=this.f_0(n,a),c=this._context.new_var(l),h=o.sma(c,5,this._context),d=this.f_0(l,h),u=this._context.new_var(d),_=o.change(u);return[d,this.f_1(_)]}}},{name:"Balance of Power",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Balance of Power",shortDescription:"Balance of Power",is_price_study:!1,inputs:[],id:"Balance of Power@tv-basicstudies-1",scriptIdPart:"",name:"Balance of Power",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t,i,s){return(e-t)/(i-s)},this.main=function(e,t){return this._context=e,this._input=t,[this.f_0(o.close(this._context),o.open(this._context),o.high(this._context),o.low(this._context))]}}},{name:"Bollinger Bands",metainfo:{_metainfoVersion:53,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1},inputs:{in_0:20,in_1:2,symbol:"",offset:0,maType:"SMA"}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Median",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Bollinger Bands",shortDescription:"BB",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_2",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50},{id:"offset",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4},{id:"maType",name:"MA Type",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],hideWhenPlotsHidden:["maType"]}],id:"Bollinger Bands@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o.time(this._context)),s=o.close(this._context),n=this._input(0),r=this._input(1),a=this._input(2),l=this._input(3),c=this._input(4)
;if(""!==n){this._context.select_sym(1);var h=this._context.new_var(o.time(this._context));s=this._context.new_var(o.close(this._context)).adopt(h,i,1),this._context.select_sym(0)}var d,u=this._context.new_var(s);"EMA"===c?d=o.ema(u,r,this._context):"WMA"===c?d=o.wma(u,r,this._context):"SMA"===c&&(d=o.sma(u,r,this._context));var _=this._context.new_var(s),p=o.stdev(_,r,this._context),m=this.f_0(a,p);return[{value:d,offset:l},{value:this.f_1(d,m),offset:l},{value:this.f_2(d,m),offset:l}]}}},{name:"Bollinger Bands %B",metainfo:{_metainfoVersion:53,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:d}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:1},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],filledAreasStyle:{fill_0:{color:"#26A69A",transparency:90,visible:!0}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Bollinger Bands %B",shortDescription:"BB %B",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"Bollinger Bands %B@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands %B",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.f_3=function(e,t,i){return(e-t)/(i-t)},this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._input(1),r=this._context.new_var(i),a=o.sma(r,s,this._context),l=this._context.new_var(i),c=o.stdev(l,s,this._context),h=this.f_0(n,c),d=this.f_1(a,h),u=this.f_2(a,h);return[this.f_3(i,u,d)]}}},{name:"Bollinger Bands Width",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},inputs:{in_0:20,in_1:2}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Bollinger Bands Width",shortDescription:"BBW",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"Bollinger Bands Width@tv-basicstudies-1",scriptIdPart:"",name:"Bollinger Bands Width",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t){return e*t},this.f_1=function(e,t){return e+t},this.f_2=function(e,t){return e-t},this.f_3=function(e,t,i){return(e-t)/i},this.main=function(e,t){this._context=e,this._input=t
;var i=o.close(this._context),s=this._input(0),n=this._input(1),r=this._context.new_var(i),a=o.sma(r,s,this._context),l=this._context.new_var(i),c=o.stdev(l,s,this._context),h=this.f_0(n,c),d=this.f_1(a,h),u=this.f_2(a,h);return[this.f_3(d,u,a)]}}},{name:"Chaikin Money Flow",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:20}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Chaikin Money Flow",shortDescription:"CMF",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Chaikin Money Flow@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Money Flow",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i,s){return o.or(o.and(o.eq(e,t),o.eq(e,i)),o.eq(t,i))?0:(2*e-i-t)/(t-i)*s},this.f_1=function(e,t){return e/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this.f_0(o.close(this._context),o.high(this._context),o.low(this._context),o.volume(this._context)),n=this._context.new_var(s),r=o.sum(n,i,this._context),a=o.volume(this._context),l=this._context.new_var(a),c=o.sum(l,i,this._context);return[this.f_1(r,c)]}}},{name:"Chaikin Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#EC407A"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:3,in_1:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Chaikin Oscillator",shortDescription:"Chaikin Osc",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"short",defval:3,type:"integer",min:1,max:2e3},{id:"in_1",name:"long",defval:10,type:"integer",min:1,max:2e3}],id:"Chaikin Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Oscillator",format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.accdist(this._context),r=this._context.new_var(n),a=o.ema(r,i,this._context),l=this._context.new_var(n),c=o.ema(l,s,this._context);return[this.f_0(a,c)]}}},{name:"Chaikin Volatility",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Chaikin Volatility@tv-basicstudies-1",scriptIdPart:"",name:"Chaikin Volatility",description:"Chaikin Volatility",shortDescription:"Chaikin Volatility",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#AB47BC"}},bands:[{color:"#787B86",
linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{periods:10,rocLookback:10}},styles:{plot_0:{title:"Plot",zorder:1}},bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"periods",type:"integer",name:"Periods"},{id:"rocLookback",type:"integer",name:"Rate of Change Lookback"}],format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.rocLookback=this._input(1)},this.main=function(e,t){this._context=e,this._input=t,this._context.setMinimumAdditionalDepth(this.period+this.rocLookback);var i=this._context.new_var(o.high(this._context)-o.low(this._context)),s=this._context.new_var(o.ema(i,this.period,this._context));return[o.roc(s,this.rocLookback)]}}},{name:"Chande Kroll Stop",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},inputs:{in_0:10,in_1:1,in_2:9}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Long",histogramBase:0,joinPoints:!1},plot_1:{title:"Short",histogramBase:0,joinPoints:!1}},description:"Chande Kroll Stop",shortDescription:"Chande Kroll Stop",is_price_study:!0,inputs:[{id:"in_0",name:"p",defval:10,type:"integer",min:1,max:4999},{id:"in_1",name:"x",defval:1,type:"integer",min:1,max:1e12},{id:"in_2",name:"q",defval:9,type:"integer",min:1,max:1e12}],id:"Chande Kroll Stop@tv-basicstudies-1",scriptIdPart:"",name:"Chande Kroll Stop",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t,i){return e-t*i},this.f_1=function(e,t,i){return e+t*i},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2),r=o.high(this._context),a=this._context.new_var(r),l=o.highest(a,i,this._context),c=o.atr(i,this._context),h=this.f_0(l,s,c),d=this._context.new_var(r),u=o.lowest(d,i,this._context),_=this.f_1(u,s,c),p=this._context.new_var(h),m=o.highest(p,n,this._context),g=this._context.new_var(_);return[o.lowest(g,n,this._context),m]}}},{name:"Chande Momentum Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Chande Momentum Oscillator",shortDescription:"ChandeMO",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:2e3}],id:"Chande Momentum Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Chande Momentum Oscillator",format:{type:"price",precision:2}},constructor:function(){this.f_0=function(e){return o.ge(e,0)?e:0},this.f_1=function(e){return o.ge(e,0)?0:-e},this.f_2=function(e,t){return 100*e/t},this.f_3=function(e,t){return this.f_2(e-t,e+t)},
this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=o.close(this._context),n=this._context.new_var(s),r=o.change(n),a=this.f_0(r),l=this.f_1(r),c=this._context.new_var(a),h=o.sum(c,i,this._context),d=this._context.new_var(l),u=o.sum(d,i,this._context);return[this.f_3(h,u)]}}},{name:"Chop Zone",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:0,visible:!0,color:"#000080"}},palettes:{palette_0:{colors:{0:{color:"#26C6DA",width:1,style:0},1:{color:"#43A047",width:1,style:0},2:{color:"#A5D6A7",width:1,style:0},3:{color:u,width:1,style:0},4:{color:"#D50000",width:1,style:0},5:{color:"#E91E63",width:1,style:0},6:{color:"#FF6D00",width:1,style:0},7:{color:"#FFB74D",width:1,style:0},8:{color:"#FDD835",width:1,style:0}}}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Chop Zone",shortDescription:"Chop Zone",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"},2:{name:"Color 2"},3:{name:"Color 3"},4:{name:"Color 4"},5:{name:"Color 5"},6:{name:"Color 6"},7:{name:"Color 7"},8:{name:"Color 8"}},valToIndex:{0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8}}},inputs:[],id:"chop_zone@tv-basicstudies-1",scriptIdPart:"",name:"Chop Zone",format:{precision:0,type:"price"}},constructor:function(){this.f_0=function(){var e=o.close(this._context),t=o.hlc3(this._context),i=this._context.new_var(o.high(this._context)),s=o.highest(i,30,this._context),n=o.lowest(i,30,this._context),r=25/(s-n)*n,a=this._context.new_var(e),l=this._context.new_var(o.ema(a,34,this._context)),c=(l.get(1)-l.get(0))/t*r,h=o.sqrt(1+c*c),d=o.round(180*o.acos(1/h)/3.141592653589793),u=o.iff(o.gt(c,0),-d,d),_=o.and(o.gt(u,-2.14),o.le(u,-.71))?7:8,p=o.and(o.gt(u,-3.57),o.le(u,-2.14))?6:_,m=o.and(o.gt(u,-5),o.le(u,-3.57))?5:p,g=o.le(u,-5)?4:m,f=o.and(o.lt(u,2.14),o.ge(u,.71))?3:g,y=o.and(o.lt(u,3.57),o.ge(u,2.14))?2:f,v=o.and(o.lt(u,5),o.ge(u,3.57))?1:y;return[1,o.ge(u,5)?0:v]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Choppiness Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:61.8},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:38.2}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Choppiness Index",shortDescription:"CHOP",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",
title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Choppiness Index@tv-basicstudies-1",scriptIdPart:"",name:"Choppiness Index",format:{type:"price",precision:2},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i,s){return 100*o.log10(e/(t-i))/s},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=o.atr(1,this._context),n=this._context.new_var(s),r=o.sum(n,i,this._context),a=o.high(this._context),l=this._context.new_var(a),c=o.highest(l,i,this._context),h=o.low(this._context),d=this._context.new_var(h),u=o.lowest(d,i,this._context),_=o.log10(i);return[this.f_0(r,c,u,_)]}}},{name:"Commodity Channel Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:100},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:-100}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:20,smoothingLine:"SMA",smoothingLength:20}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:2},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1,zorder:1}},description:"Commodity Channel Index",shortDescription:"CCI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],hideWhenPlotsHidden:["smoothedMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:20,type:"integer",min:1,max:1e4,hideWhenPlotsHidden:["smoothedMA"]}],id:"Commodity Channel Index@tv-basicstudies-1",scriptIdPart:"",name:"Commodity Channel Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i){return(e-t)/(.015*i)},this.main=function(e,t){this._context=e,this._input=t;var i=o.hlc3(this._context),s=this._input(0),n=this._input(1),r=this._input(2);this._context.setMinimumAdditionalDepth(s+r);var a,l=this._context.new_var(i),c=o.sma(l,s,this._context),h=this._context.new_var(i),d=o.dev(h,s,this._context),u=this.f_0(i,c,d),_=this._context.new_var(u);return"EMA"===n?a=o.ema(_,r,this._context):"WMA"===n?a=o.wma(_,r,this._context):"SMA"===n&&(a=o.sma(_,r,this._context)),[u,a]}}},{name:"Connors RSI",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:70},{
color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:30}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:3,in_1:2,in_2:100}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"CRSI",histogramBase:0,joinPoints:!1,zorder:1}},description:"Connors RSI",shortDescription:"CRSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"RSI Length",defval:3,type:"integer",min:1},{id:"in_1",name:"UpDown Length",defval:2,type:"integer",min:1},{id:"in_2",name:"ROC Length",defval:100,type:"integer",min:1}],id:"Connors RSI@tv-basicstudies-1",scriptIdPart:"",name:"Connors RSI",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){var e;this.f_1=function(e,t,i){var s=i.new_var(o.max(o.change(e),0));return o.rma(s,t,i)},this.f_2=function(e,t,i){var s=i.new_var(-o.min(o.change(e),0));return o.rma(s,t,i)},this.f_3=(e=0,function(t){var i=t.get(0),s=t.get(1);return e=i===s?0:i>s?o.nz(e)<=0?1:o.nz(e)+1:o.nz(e)>=0?-1:o.nz(e)-1,this._context.new_var(e)}),this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._context.new_var(i),n=this._input(0),r=this._input(1),a=this._input(2);this._context.setMinimumAdditionalDepth(a);var l=o.rsi(this.f_1(s,n,this._context),this.f_2(s,n,this._context)),c=this.f_3(s),h=o.rsi(this.f_1(c,r,this._context),this.f_2(c,r,this._context)),d=this._context.new_var(o.roc(s,1)),u=o.percentrank(d,a);return[o.avg(l,h,u)]}}},{name:"Coppock Curve",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10,in_1:14,in_2:11}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Coppock Curve",shortDescription:"Coppock Curve",is_price_study:!1,inputs:[{id:"in_0",name:"WMA Length",defval:10,type:"integer",min:-1e12,max:5e3},{id:"in_1",name:"Long RoC Length",defval:14,type:"integer",min:1,max:4999},{id:"in_2",name:"Short RoC Length",defval:11,type:"integer",min:1,max:4999}],id:"Coppock Curve@tv-basicstudies-1",scriptIdPart:"",name:"Coppock Curve",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e+t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(i+Math.max(s,n));var r=o.close(this._context),a=this._context.new_var(r),l=o.roc(a,s),c=this._context.new_var(r),h=o.roc(c,n),d=this.f_0(l,h),u=this._context.new_var(d);return[o.wma(u,i,this._context)]}}},{name:"Correlation Coeff",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:4,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:"",in_1:20
}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Correlation Coefficient",shortDescription:"CC",is_price_study:!1,inputs:[{id:"in_0",name:"symbol",defval:"",type:"symbol"},{id:"in_1",name:"length",defval:20,type:"integer",min:1,max:2e3}],id:"Correlation Coeff@tv-basicstudies-1",scriptIdPart:"",name:"Correlation Coeff",format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._context.new_sym(this._input(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_unlimited_var(this._context.symbol.time),s=(this._input(0),o.period(this._context),o.close(this._context)),n=this._input(1);this._context.select_sym(1);var r=this._context.new_unlimited_var(this._context.symbol.time),a=o.close(this._context),l=this._context.new_unlimited_var(a);this._context.select_sym(0);var c=l.adopt(r,i,0),h=this._context.new_var(s),d=this._context.new_var(c);return[o.correlation(h,d,n,this._context)]}}},{name:"Correlation - Log",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Correlation - Log@tv-basicstudies-1",scriptIdPart:"",name:"Correlation - Log",description:"Correlation - Log",shortDescription:"Correlation - Log",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{instrument:"",instrument2:"",periods:25}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"instrument",name:"Instrument 1",type:"symbol",defval:"",confirm:!0},{id:"instrument2",name:"Instrument 2",type:"symbol",defval:"",confirm:!0},{id:"periods",name:"Periods",type:"integer",defval:25}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._context.new_sym(this._input(0),o.period(this._context)),this._context.new_sym(this._input(1),o.period(this._context)),this.period=this._input(2)},this.correlationLog=function(e,t,i,s){var n=o.sma(e,i,s),r=o.sma(t,i,s),a=s.new_var(e.get()*t.get());return(o.sma(a,i,s)-n*r)/Math.sqrt(o.variance2(e,n,i)*o.variance2(t,r,i))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(this._context.symbol.time);this._context.select_sym(2);var s=this._context.new_var(o.close(this._context)),n=this._context.new_var(o.log(s.get()/s.get(1))),r=this._context.new_var(this._context.symbol.time);this._context.select_sym(1);var a=this._context.new_var(this._context.symbol.time),l=this._context.new_var(o.close(this._context)),c=this._context.new_var(o.log(l.get()/l.get(1))),h=this._context.new_var(n.adopt(r,a,0)),d=this._context.new_var(this.correlationLog(c,h,this.period,this._context)),u=this._context.new_var(d.adopt(a,i,0)).get(),_=o.round(1e3*u)/1e3;return this._context.select_sym(0),[_]}}},{name:"Detrended Price Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,
plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:21,in_1:!1}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"DPO",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1}},description:"Detrended Price Oscillator",shortDescription:"DPO",is_price_study:!1,is_hidden_study:!1,id:"detrended_price_oscillator@tv-basicstudies-1",bands:[{id:"hline_0",name:"Zero",isHidden:!1,zorder:-1}],inputs:[{id:"in_0",name:"Period",defval:21,type:"integer",min:1,max:1e12},{id:"in_1",name:"isCentered",defval:!1,type:"bool"}],scriptIdPart:"",name:"Detrended Price Oscillator",format:{type:"price",precision:2},usePlotsZOrder:!0},constructor:function(){this.f_0=function(){var e=this._input(0),t=this._input(1),i=Math.floor(e/2+1);this._context.setMinimumAdditionalDepth(e+i);var s=this._context.new_var(o.close(this._context)),n=this._context.new_var(o.sma(s,e,this._context)),r=this._context.new_var(o.close(this._context)).get(i)-n,a=o.close(this._context)-n.get(i);return[t?r:a,t?-i:0]},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0();return[{value:i[0],offset:i[1]}]}}},{name:"Directional Movement Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_3:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FFA726"},plot_4:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#ab47bc"}},inputs:{in_0:14,in_1:14}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"},{id:"plot_3",type:"line"},{id:"plot_4",type:"line"}],styles:{plot_0:{title:"+DI",histogramBase:0,joinPoints:!1},plot_1:{title:"-DI",histogramBase:0,joinPoints:!1},plot_2:{title:"DX",histogramBase:0,joinPoints:!1},plot_3:{title:"ADX",histogramBase:0,joinPoints:!1},plot_4:{title:"ADXR",histogramBase:0,joinPoints:!1}},description:"Directional Movement",shortDescription:"DMI",is_price_study:!1,inputs:[{id:"in_0",name:"DI Length",defval:14,type:"integer",min:1,max:2e3},{id:"in_1",name:"ADX Smoothing",defval:14,type:"integer",min:1,max:50}],id:"Directional Movement Index@tv-basicstudies-1",scriptIdPart:"",name:"Directional Movement Index",format:{precision:4,type:"price"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1);return this._context.setMinimumAdditionalDepth(2*i+s),o.dmi(i,s,this._context)}}},{name:"Donchian Channels",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,
trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20,offset:0}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Lower",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Basis",histogramBase:0,joinPoints:!1}},description:"Donchian Channels",shortDescription:"DC",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_0",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"length",defval:20,type:"integer",min:1,max:2e3},{id:"offset",name:"Offset",defval:0,type:"integer",min:-1e3,max:1e3}],id:"Donchian Channels@tv-basicstudies-1",scriptIdPart:"",name:"Donchian Channels",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.low(this._context),r=this._context.new_var(n);this._context.setMinimumAdditionalDepth(i+Math.max(s,0));var a=o.lowest(r,i,this._context),l=o.high(this._context),c=this._context.new_var(l),h=o.highest(c,i,this._context);return[{value:a,offset:s},{value:h,offset:s},{value:o.avg(h,a),offset:s}]}}},{name:"Double Exponential Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Double EMA",shortDescription:"DEMA",is_price_study:!0,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e4}],id:"Double Exponential Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Double Exponential Moving Average",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return 2*e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);this._context.setMinimumAdditionalDepth(2*i);var s=o.close(this._context),n=this._context.new_var(s),r=o.ema(n,i,this._context),a=this._context.new_var(r),l=o.ema(a,i,this._context);return[this.f_0(r,l)]}}},{name:"Ease of Movement",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},inputs:{in_0:1e4,in_1:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Ease Of Movement",shortDescription:"EOM",is_price_study:!1,inputs:[{id:"in_0",name:"Divisor",defval:1e4,type:"integer",min:1,max:1e9},{id:"in_1",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Ease of Movement@tv-basicstudies-1",scriptIdPart:"",name:"Ease of Movement",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i,s,o){return e*t*(i-s)/o},
this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.hl2(this._context),r=this._context.new_var(n),a=o.change(r),l=this.f_0(i,a,o.high(this._context),o.low(this._context),o.volume(this._context)),c=this._context.new_var(l);return[o.sma(c,s,this._context)]}}},{name:"Elders Force Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:13}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Elder's Force Index",shortDescription:"EFI",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"length",defval:13,type:"integer",min:1,max:2e3}],id:"Elders Force Index@tv-basicstudies-1",scriptIdPart:"",name:"Elders Force Index",format:{type:"volume"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return e*t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=o.close(this._context),n=this._context.new_var(s),r=o.change(n),a=this.f_0(r,o.volume(this._context)),l=this._context.new_var(a);return[o.ema(l,i,this._context)]}}},{name:"EMA Cross",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"},plot_2:{linestyle:0,linewidth:4,plottype:3,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:26}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Short",histogramBase:0,joinPoints:!1},plot_1:{title:"Long",histogramBase:0,joinPoints:!1},plot_2:{title:"Crosses",histogramBase:0,joinPoints:!1}},description:"EMA Cross",shortDescription:"EMA Cross",is_price_study:!0,inputs:[{id:"in_0",name:"Short",defval:9,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_0","plot_2"]},{id:"in_1",name:"Long",defval:26,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_1","plot_2"]}],id:"EMA Cross@tv-basicstudies-1",scriptIdPart:"",name:"EMA Cross",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e?t:o.na()},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.close(this._context),r=this._context.new_var(n),a=o.ema(r,i,this._context),l=this._context.new_var(n),c=o.ema(l,s,this._context),h=a,d=c,u=o.cross(a,c,this._context);return[h,d,this.f_0(u,a)]}}},{name:"Envelopes",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,
color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:20,in_1:10,in_2:10,in_3:"Simple",in_4:"close"}},plots:[{id:"plot_1",type:"line"},{id:"plot_0",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Average",histogramBase:0,joinPoints:!1},plot_1:{title:"Upper",histogramBase:0,joinPoints:!1},plot_2:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Envelopes",shortDescription:"Envelopes",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_1",objBId:"plot_2",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"Length",defval:20,type:"integer",min:1,max:2e3},{id:"in_1",name:"Upper Percentage",defval:2,type:"float",min:0},{id:"in_2",name:"Lower Percentage",defval:2,type:"float",min:0},{id:"in_3",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]},{id:"in_4",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]}],id:"Envelope@tv-basicstudies-1",scriptIdPart:"",name:"Envelopes",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e*(1+t)},this.f_1=function(e,t){return e*(1-t)},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o[this._input(4)](this._context)),s=o.sma(i,this._input(0),this._context);return"Exponential"===this._input(3)?s=o.ema(i,this._input(0),this._context):"Weighted"===this._input(3)&&(s=o.wma(i,this._input(0),this._context)),[this.f_0(s,this._input(1)/100),s,this.f_1(s,this._input(2)/100)]}}},{name:"Standard Error",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Standard Error@tv-basicstudies-1",scriptIdPart:"",name:"Standard Error",description:"Standard Error",shortDescription:"Standard Error",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"}},inputs:{length:14}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"length",type:"integer",name:"Length",min:3}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0)},this.main=function(e,t){this._context=e,this._input=t;for(var i,s,n=this._context.new_var(o.close(this._context)),r=0,a=0,l=0;l<this.period;l++)r+=l+1,a+=n.get(l);i=r/this.period,s=a/this.period;var c=0,h=0,d=0;for(l=0;l<this.period;l++)d+=Math.pow(s-n.get(l),2),h+=(i-l-1)*(s-n.get(l)),c+=Math.pow(i-l-1,2);return h=Math.pow(h,2),[Math.sqrt((d-h/c)/(this.period-2))]}}},{name:"Standard Error Bands",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Standard Error Bands@tv-basicstudies-1",scriptIdPart:"",name:"Standard Error Bands",description:"Standard Error Bands",shortDescription:"Standard Error Bands",plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],
defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#2196F3"},plot_1:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#FF6D00"},plot_2:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{periods:21,errors:2,method:"Simple",averagePeriods:3}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"},plot_2:{title:"Plot 3"}},filledAreas:[{id:"fill_0",objAId:"plot_0",objBId:"plot_2",type:"plot_plot",title:"Background"}],inputs:[{id:"periods",type:"integer",name:"Periods"},{id:"errors",type:"float",name:"Standard Errors"},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]},{id:"averagePeriods",type:"integer",name:"Averaging Periods"}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.errorDeviation=this._input(1),this.maMethod=this._input(2),this.averagePeriod=this._input(3)},this.main=function(e,t){this._context=e,this._input=t;for(var i,s,n=this._context.new_var(o.close(this._context)),r=0,a=0,l=0;l<this.period;l++)r+=l+1,a+=n.get(l);i=r/this.period,s=a/this.period;var c=0,h=0,d=0;for(l=0;l<this.period;l++)d+=Math.pow(s-n.get(l),2),h+=(i-l-1)*(s-n.get(l)),c+=Math.pow(i-l-1,2);h=Math.pow(h,2);var u,_,p,m=Math.sqrt((d-h/c)/(this.period-2)),g=o.linreg(n,this.period,0),f=this._context.new_var(g+this.errorDeviation*m),y=this._context.new_var(g),v=this._context.new_var(g-this.errorDeviation*m);return"Simple"===this.maMethod?(u=o.sma(f,this.averagePeriod,this._context),_=o.sma(y,this.averagePeriod,this._context),p=o.sma(v,this.averagePeriod,this._context)):"Exponential"===this.maMethod?(u=o.ema(f,this.averagePeriod,this._context),_=o.ema(y,this.averagePeriod,this._context),p=o.ema(v,this.averagePeriod,this._context)):(u=o.wma(f,this.averagePeriod,this._context),_=o.wma(y,this.averagePeriod,this._context),p=o.wma(v,this.averagePeriod,this._context)),[u,_,p]}}},{name:"Fisher Transform",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},bands:[{color:"#E91E63",linestyle:2,linewidth:1,visible:!0,value:1.5},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:.75},{color:"#E91E63",linestyle:2,linewidth:1,visible:!0,value:0},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:-.75},{color:"#E91E63",linestyle:2,linewidth:1,visible:!0,value:-1.5}],inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Fisher",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1},plot_1:{title:"Trigger",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1.1}},description:"Fisher Transform",shortDescription:"Fisher",
is_price_study:!1,bands:[{id:"hline_0",name:"Level",isHidden:!1,zorder:-1.1},{id:"hline_1",name:"Level",isHidden:!1,zorder:-1.11},{id:"hline_2",name:"Level",isHidden:!1,zorder:-1.111},{id:"hline_3",name:"Level",isHidden:!1,zorder:-1.1111},{id:"hline_4",name:"Level",isHidden:!1,zorder:-1.11111}],inputs:[{id:"in_0",name:"Length",defval:9,type:"integer",min:1,max:1e12}],id:"fisher_transform@tv-basicstudies-1",scriptIdPart:"",name:"Fisher Transform",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e){var t=o.lt(e,-.99)?-.999:e;return[o.gt(e,.99)?.999:t]},this.f_1=function(){var e=this._input(0),t=this._context.new_var(o.hl2(this._context)),i=o.highest(t,e,this._context),s=this._context.new_var(o.hl2(this._context)),n=o.lowest(s,e,this._context),r=this._context.new_var(),a=this.f_0(.66*((o.hl2(this._context)-n)/o.max(i-n,.001)-.5)+.67*o.nz(r.get(1)));r.set(a[0]);var l=this._context.new_var();l.set(.5*o.log((1+r.get(0))/o.max(1-r.get(0),.001))+.5*o.nz(l.get(1)));var c=l.get(1);return[l.get(0),c]},this.main=function(e,t){return this._context=e,this._input=t,this.f_1()}}},{name:"Historical Volatility",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Historical Volatility",shortDescription:"HV",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:10,type:"integer",min:1,max:1e12}],id:"historical_volatility@tv-basicstudies-1",scriptIdPart:"",name:"Historical Volatility",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(){var e=this._input(0),t=o.or(o.isintraday(this._context),o.and(o.isdaily(this._context),o.eq(o.interval(this._context),1)))?1:7,i=this._context.new_var(o.close(this._context)),s=this._context.new_var(o.log(o.close(this._context)/i.get(1)));return[100*o.stdev(s,e,this._context)*o.sqrt(365/t)]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Hull MA",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Hull Moving Average",shortDescription:"HMA",is_price_study:!0,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e4}],id:"Hull MA@tv-basicstudies-1",scriptIdPart:"",name:"Hull MA",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return 2*e-t},this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=s/2;this._context.setMinimumAdditionalDepth(Math.ceil(s+n))
;var r=this._context.new_var(i),a=o.wma(r,n,this._context),l=this._context.new_var(i),c=o.wma(l,s,this._context),h=this.f_0(a,c),d=o.sqrt(s),u=o.floor(d),_=this._context.new_var(h);return[o.wma(_,u,this._context)]}}},{name:"Ichimoku Cloud",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:l},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"},plot_3:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#A5D6A7"},plot_4:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:r}},palettes:{palette_0:{colors:{0:{color:"#43A047",width:1,style:0},1:{color:a,width:1,style:0}}}},filledAreasStyle:{fill_0:{color:"#000080",transparency:90,visible:!0}},inputs:{symbol:"",in_0:9,in_1:26,in_2:52,in_3:26,in_4:26}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"},{id:"plot_3",type:"line"},{id:"plot_4",type:"line"},{id:"plot_5",palette:"palette_0",target:"fill_0",type:"colorer"}],styles:{plot_0:{title:"Conversion Line",histogramBase:0,joinPoints:!1,isHidden:!1},plot_1:{title:"Base Line",histogramBase:0,joinPoints:!1,isHidden:!1},plot_2:{title:"Lagging Span",histogramBase:0,joinPoints:!1,isHidden:!1},plot_3:{title:"Leading Span A",histogramBase:0,joinPoints:!1,isHidden:!1},plot_4:{title:"Leading Span B",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Ichimoku Cloud",shortDescription:"Ichimoku",is_price_study:!0,is_hidden_study:!1,id:"Ichimoku Cloud@tv-basicstudies-1",palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"}},valToIndex:{0:0,1:1}}},filledAreas:[{id:"fill_0",objAId:"plot_3",objBId:"plot_4",type:"plot_plot",title:"Plots Background",isHidden:!1,palette:"palette_0"}],inputs:[{id:"symbol",name:"Another symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"in_0",name:"Conversion Line Periods",defval:9,type:"integer",min:1,max:1e12},{id:"in_1",name:"Base Line Periods",defval:26,type:"integer",min:1,max:1e12},{id:"in_2",name:"Leading Span Periods",defval:52,type:"integer",min:1,max:1e12},{id:"in_3",name:"Lagging Span Periods",defval:26,type:"integer",min:1,max:1e12},{id:"in_4",name:"Leading Shift Periods",defval:26,type:"integer",min:1,max:1e12}],scriptIdPart:"",name:"Ichimoku Cloud",format:{type:"inherit"}},constructor:function(){this.donchian=function(e,t,i){var s=this._context.new_var(e),n=this._context.new_var(t);return o.avg(o.lowest(s,i,this._context),o.highest(n,i,this._context))},this.f_1=function(){var e=this._input(1),t=this._input(2),i=this._input(3),s=this._input(4)-1,n=this._input(5)-1,r=this._context.new_var(o.time(this._context)),a=o.close(this._context),l=o.low(this._context),c=o.high(this._context);if(""!==this._input(0)){this._context.select_sym(1)
;var h=this._context.new_var(o.time(this._context)),d=o.close(this._context),u=o.low(this._context),_=o.high(this._context);a=this._context.new_var(d).adopt(h,r,1),l=this._context.new_var(u).adopt(h,r,1),c=this._context.new_var(_).adopt(h,r,1),this._context.select_sym(0)}var p=this.donchian(l,c,e),m=this.donchian(l,c,t),g=o.avg(p,m),f=this.donchian(l,c,i);return[p,m,a,g,f,-s,s,n,o.gt(g,f)?0:1]},this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_1();return[i[0],i[1],{value:i[2],offset:i[5]},{value:i[3],offset:i[7]},{value:i[4],offset:i[7]},i[8]]}}},{name:"Keltner Channels",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:95,visible:!0}},inputs:{in_0:!0,in_1:20,in_2:1}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Upper",histogramBase:0,joinPoints:!1},plot_1:{title:"Middle",histogramBase:0,joinPoints:!1},plot_2:{title:"Lower",histogramBase:0,joinPoints:!1}},description:"Keltner Channels",shortDescription:"KC",is_price_study:!0,filledAreas:[{id:"fill_0",objAId:"plot_0",objBId:"plot_2",type:"plot_plot",title:"Plots Background"}],inputs:[{id:"in_0",name:"useTrueRange",defval:!0,type:"bool"},{id:"in_1",name:"length",defval:20,type:"integer",min:1,max:2e3},{id:"in_2",name:"mult",defval:1,type:"float",min:-1e12,max:1e12}],id:"Keltner Channels@tv-basicstudies-1",scriptIdPart:"",name:"Keltner Channels",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t,i,s){return e?t:i-s},this.f_1=function(e,t,i){return e+t*i},this.f_2=function(e,t,i){return e-t*i},this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._input(1),r=this._input(2),a=this._context.new_var(i),l=o.ema(a,n,this._context),c=this.f_0(s,o.tr(void 0,this._context),o.high(this._context),o.low(this._context)),h=this._context.new_var(c),d=o.ema(h,n,this._context);return[this.f_1(l,d,r),l,this.f_2(l,d,r)]}}},{name:"Klinger Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"}},inputs:{}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1}},description:"Klinger Oscillator",shortDescription:"Klinger Oscillator",is_price_study:!1,inputs:[],
id:"Klinger Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Klinger Oscillator",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t){return o.ge(e,0)?t:-t},this.f_1=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=o.hlc3(this._context);this._context.setMinimumAdditionalDepth(66);var s=this._context.new_var(i),n=o.change(s),r=this.f_0(n,o.volume(this._context)),a=this._context.new_var(r),l=o.ema(a,34,this._context),c=this._context.new_var(r),h=o.ema(c,55,this._context),d=this.f_1(l,h),u=this._context.new_var(d);return[d,o.ema(u,13,this._context)]}}},{name:"Know Sure Thing",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:u},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:10,in_1:15,in_2:20,in_3:30,in_4:10,in_5:10,in_6:10,in_7:15,in_8:9}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"KST",histogramBase:0,joinPoints:!1,zorder:1.1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1,zorder:1.11}},description:"Know Sure Thing",shortDescription:"KST",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"roclen1",defval:10,type:"integer",min:1,max:2e3},{id:"in_1",name:"roclen2",defval:15,type:"integer",min:1,max:2e3},{id:"in_2",name:"roclen3",defval:20,type:"integer",min:1,max:2e3},{id:"in_3",name:"roclen4",defval:30,type:"integer",min:1,max:2e3},{id:"in_4",name:"smalen1",defval:10,type:"integer",min:1,max:2e3},{id:"in_5",name:"smalen2",defval:10,type:"integer",min:1,max:2e3},{id:"in_6",name:"smalen3",defval:10,type:"integer",min:1,max:2e3},{id:"in_7",name:"smalen4",defval:15,type:"integer",min:1,max:2e3},{id:"in_8",name:"siglen",defval:9,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_1"]}],id:"Know Sure Thing@tv-basicstudies-1",scriptIdPart:"",name:"Know Sure Thing",format:{type:"price",precision:4},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i,s){return e+2*t+3*i+4*s},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2),r=this._input(3),a=this._input(4),l=this._input(5),c=this._input(6),h=this._input(7),d=this._input(8);this._context.setMinimumAdditionalDepth(Math.max(a+i,l+s,c+n,h+r)+d);var u=o.close(this._context),_=i,p=this._context.new_var(u),m=o.roc(p,_),g=a,f=this._context.new_var(m),y=o.sma(f,g,this._context),v=s,S=this._context.new_var(u),b=o.roc(S,v),w=l,C=this._context.new_var(b),T=o.sma(C,w,this._context),P=n,x=this._context.new_var(u),M=o.roc(x,P),I=c,A=this._context.new_var(M),L=o.sma(A,I,this._context),k=r,E=this._context.new_var(u),D=o.roc(E,k),B=h,V=this._context.new_var(D),R=o.sma(V,B,this._context),N=this.f_0(y,T,L,R),O=this._context.new_var(N);return[N,o.sma(O,d,this._context)]}}},{name:"Least Squares Moving Average",metainfo:{
_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:25,in_1:0}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Least Squares Moving Average",shortDescription:"LSMA",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:25,type:"integer",min:1,max:1e12},{id:"in_1",name:"Offset",defval:0,type:"integer",min:-1e12,max:1e12}],id:"Least Squares Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Least Squares Moving Average",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.close(this._context),r=this._context.new_var(n);return[o.linreg(r,i,s)]}}},{name:"Linear Regression Curve",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Linear Regression Curve",shortDescription:"LRC",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:9,type:"integer",min:1,max:2e3}],id:"Linear Regression Curve@tv-basicstudies-1",scriptIdPart:"",name:"Linear Regression Curve",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._context.new_var(i);return[o.linreg(n,s,0)]}}},{name:"Linear Regression Slope",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Linear Regression Slope@tv-basicstudies-1",scriptIdPart:"",name:"Linear Regression Slope",description:"Linear Regression Slope",shortDescription:"Linear Regression Slope",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:c}},inputs:{periods:14}},styles:{plot_0:{title:"Plot",histogramBase:0}},inputs:[{id:"periods",type:"integer",name:"Periods",min:2}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0)},this.linregSlope=function(e,t,i){var s,o,n,r=0,a=0,l=0,c=0;for(s=0;s<t;++s)r+=n=t-1-s+1,a+=o=e.get(s),l+=n*n,c+=o*n;return(t*c-r*a)/(t*l-r*r)},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o.close(this._context));return[this.linregSlope(i,this.period,0)]}}},{name:"MA Cross",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_2:{linestyle:0,linewidth:4,plottype:3,trackPrice:!1,transparency:0,visible:!0,
color:"#2196F3"}},inputs:{in_0:9,in_1:26}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Short",histogramBase:0,joinPoints:!1},plot_1:{title:"Long",histogramBase:0,joinPoints:!1},plot_2:{title:"Crosses",histogramBase:0,joinPoints:!1}},description:"MA Cross",shortDescription:"MA Cross",is_price_study:!0,inputs:[{id:"in_0",name:"Short",defval:9,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_0","plot_2"]},{id:"in_1",name:"Long",defval:26,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_1","plot_2"]}],id:"MA Cross@tv-basicstudies-1",scriptIdPart:"",name:"MA Cross",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e?t:o.na()},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.close(this._context),r=this._context.new_var(n),a=o.sma(r,i,this._context),l=this._context.new_var(n),c=o.sma(l,s,this._context),h=a,d=c,u=o.cross(a,c,this._context);return[h,d,this.f_0(u,a)]}}},{name:"MA with EMA Cross",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#43A047"},plot_2:{linestyle:0,linewidth:4,plottype:3,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10,in_1:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"MA",histogramBase:0,joinPoints:!1},plot_1:{title:"EMA",histogramBase:0,joinPoints:!1},plot_2:{title:"Crosses",histogramBase:0,joinPoints:!1}},description:"MA with EMA Cross",shortDescription:"MA/EMA Cross",is_price_study:!0,inputs:[{id:"in_0",name:"Length MA",defval:10,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_0","plot_2"]},{id:"in_1",name:"Length EMA",defval:10,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_1","plot_2"]}],id:"MA with EMA Cross@tv-basicstudies-1",scriptIdPart:"",name:"MA with EMA Cross",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e?t:o.na()},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.close(this._context),r=this._context.new_var(n),a=o.sma(r,i,this._context),l=this._context.new_var(n),c=o.ema(l,s,this._context),h=a,d=c,u=o.cross(a,c,this._context);return[h,d,this.f_0(u,a)]}}},{name:"Mass Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Mass Index",shortDescription:"Mass Index",is_price_study:!1,inputs:[{id:"in_0",name:"length",defval:10,type:"integer",min:1,max:2e3}],id:"Mass Index@tv-basicstudies-1",scriptIdPart:"",name:"Mass Index",format:{precision:2,
type:"price"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e,t){return e/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this.f_0(o.high(this._context),o.low(this._context)),n=this._context.new_var(s),r=o.ema(n,9,this._context),a=this._context.new_var(r),l=o.ema(a,9,this._context),c=this.f_1(r,l),h=this._context.new_var(c);return[o.sum(h,i,this._context)]}}},{name:"McGinley Dynamic",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"McGinley Dynamic",shortDescription:"McGinley Dynamic",is_price_study:!0,is_hidden_study:!1,id:"mcginley_dynamic@tv-basicstudies-1",inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:1e12}],scriptIdPart:"",name:"McGinley Dynamic",format:{type:"inherit"}},constructor:function(){this.f_0=function(){var e=this._input(0),t=o.close(this._context),i=this._context.new_var(t),s=o.ema(i,e,this._context),n=this._context.new_var(),r=n.get(1)+(t-n.get(1))/(e*o.pow(t/n.get(1),4));return n.set(o.na(n.get(1))?s:o.nz(r,s)),[n.get(0)]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Median Price",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"Median Price@tv-basicstudies-1",scriptIdPart:"",name:"Median Price",description:"Median Price",shortDescription:"Median Price",is_price_study:!0,plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"}},inputs:{}},styles:{plot_0:{title:"Plot"}},inputs:[],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){return this._context=e,this._input=t,[o.hl2(this._context)]}}},{name:"Momentum",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:10,in_1:"close"}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Mom",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:0}},description:"Momentum",shortDescription:"Mom",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"Length",defval:10,type:"integer",min:1,max:2e3},{id:"in_1",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]}],id:"Momentum@tv-basicstudies-1",scriptIdPart:"",name:"Momentum",format:{type:"inherit"},usePlotsZOrder:!0},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=o[this._input(1)](this._context),n=this._context.new_var(s).get(i);return[n?s-n:null]}}},{name:"Money Flow Index",metainfo:{_metainfoVersion:52,isTVScript:!1,
isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#7E57C2"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:80},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:20}],filledAreasStyle:{fill_0:{color:"#7E57C2",transparency:90,visible:!0}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Money Flow Index",shortDescription:"MFI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"Length",defval:14,type:"integer",min:1,max:2e3}],id:"Money Flow@tv-basicstudies-1",scriptIdPart:"",name:"Money Flow Index",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t,i){return e*(o.le(t,0)?0:i)},this.f_1=function(e,t,i){return e*(o.ge(t,0)?0:i)},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=o.hlc3(this._context),n=this._context.new_var(s),r=o.change(n),a=this.f_0(o.volume(this._context),r,s),l=this._context.new_var(a),c=o.sum(l,i,this._context),h=this.f_1(o.volume(this._context),r,s),d=this._context.new_var(h),u=o.sum(d,i,this._context);return[o.rsi(c,u)]}}},{name:"Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},inputs:{symbol:"",length:9,source:"close",offset:0,smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1}},description:"Moving Average",shortDescription:"MA",is_price_study:!0,inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"length",name:"Length",defval:9,type:"integer",min:1,max:1e4},{id:"source",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"offset",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],hideWhenPlotsHidden:["smoothedMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4,hideWhenPlotsHidden:["smoothedMA"]}],id:"Moving Average@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average",format:{type:"inherit"},symbolSource:{type:"symbolInputSymbolSource",inputId:"symbol"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t
;var i=this._context.new_var(this._context.symbol.time),s=o[this._input(2)](this._context),n=this._input(1),r=this._input(3),a=this._input(4),l=this._input(5);if(this._context.setMinimumAdditionalDepth(n+l),""!==this._input(0)){this._context.select_sym(1);var c=this._context.new_var(this._context.symbol.time),h=o[this._input(2)](this._context);s=this._context.new_var(h).adopt(c,i,1),this._context.select_sym(0)}var d,u=this._context.new_var(s),_=o.sma(u,n,this._context),p=this._context.new_var(_);return"EMA"===a?d=o.ema(p,l,this._context):"WMA"===a?d=o.wma(p,l,this._context):"SMA"===a&&(d=o.sma(p,l,this._context)),[{value:_,offset:r},{value:d,offset:r}]}}},{name:"Moving Average Channel",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:20,in_1:20,in_2:0,in_3:0}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"Upper",histogramBase:0,joinPoints:!1},plot_1:{title:"Lower",histogramBase:0,joinPoints:!1}},filledAreas:[{id:"fill_0",objAId:"plot_0",objBId:"plot_1",type:"plot_plot",title:"Plots Background"}],description:"Moving Average Channel",shortDescription:"MAC",is_price_study:!0,inputs:[{id:"in_0",name:"Upper Length",defval:20,type:"integer",min:1,max:1e4},{id:"in_1",name:"Lower Length",defval:20,type:"integer",min:1,max:1e4},{id:"in_2",name:"Upper Offset",defval:0,type:"integer",min:-1e4,max:1e4},{id:"in_3",name:"Lower Offset",defval:0,type:"integer",min:-1e4,max:1e4}],id:"Moving Average Channel@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Channel",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=o.high(this._context),s=o.low(this._context),n=this._input(0),r=this._input(1),a=this._input(2),l=this._input(3),c=this._context.new_var(i),h=this._context.new_var(s);return[{value:o.sma(c,n,this._context),offset:a},{value:o.sma(h,r,this._context),offset:l}]}}},{name:"Moving Average Convergence/Divergence",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:0,visible:!0,color:c},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},palettes:{palette_0:{colors:{0:{color:d,width:1,style:0},1:{color:h,width:1,style:0},2:{color:n,width:1,style:0},3:{color:"#FF5252",width:1,style:0}}}},inputs:{symbol:"",in_0:12,in_1:26,in_3:"close",in_2:9,oscillatorMAType:"EMA",signalLineMAType:"EMA"}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"},{id:"plot_3",palette:"palette_0",target:"plot_0",type:"colorer"}],styles:{
plot_0:{title:"Histogram",histogramBase:0,joinPoints:!1},plot_1:{title:"MACD",histogramBase:0,joinPoints:!1},plot_2:{title:"Signal",histogramBase:0,joinPoints:!1}},description:"MACD",shortDescription:"MACD",is_price_study:!1,palettes:{palette_0:{colors:{0:{name:"Color 0"},1:{name:"Color 1"},2:{name:"Color 2"},3:{name:"Color 3"}}}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"in_0",name:"Fast Length",defval:12,type:"integer",min:1,max:2e3},{id:"in_1",name:"Slow Length",defval:26,type:"integer",min:1,max:2e3},{id:"in_3",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"in_2",name:"Signal Length",defval:9,type:"integer",min:1,max:50},{id:"oscillatorMAType",name:"Oscillator MA Type",defval:"EMA",type:"text",options:["SMA","EMA","WMA"]},{id:"signalLineMAType",name:"Signal Line MA Type",defval:"EMA",type:"text",options:["SMA","EMA","WMA"]}],id:"Moving Average Convergence/Divergence@tv-basicstudies-1",scriptIdPart:"",name:"MACD",format:{type:"inherit"},symbolSource:{type:"symbolInputSymbolSource",inputId:"symbol"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e){var t=e>0?1:3,i=o.change(this._context.new_var(e));return t-(o.le(i,0)?0:1)},this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(this._context.symbol.time),s=o[this._input(3)](this._context),n=this._input(1),r=this._input(2),a=this._input(4),l=this._input(5),c=this._input(6);if(this._context.setMinimumAdditionalDepth(Math.max(n,r)+a),""!==this._input(0)){this._context.select_sym(1);var h=this._context.new_var(this._context.symbol.time),d=o[this._input(3)](this._context);s=this._context.new_var(d).adopt(h,i,0),this._context.select_sym(0)}var u,_,p=this._context.new_var(s);"EMA"===l?u=o.ema(p,n,this._context):"WMA"===l?u=o.wma(p,n,this._context):"SMA"===l&&(u=o.sma(p,n,this._context)),"EMA"===l?_=o.ema(p,r,this._context):"WMA"===l?_=o.wma(p,r,this._context):"SMA"===l&&(_=o.sma(p,r,this._context));var m,g=this.f_0(u,_),f=this._context.new_var(g);"EMA"===c?m=o.ema(f,a,this._context):"WMA"===c?m=o.wma(f,a,this._context):"SMA"===c&&(m=o.sma(f,a,this._context));var y=this.f_0(g,m);return[y,g,m,this.f_1(y)]}}},{name:"Moving Average Exponential",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},inputs:{length:9,source:"close",offset:0,smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1}},description:"Moving Average Exponential",shortDescription:"EMA",is_price_study:!0,inputs:[{id:"length",name:"Length",
defval:9,type:"integer",min:1,max:1e4},{id:"source",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"offset",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],hideWhenPlotsHidden:["smoothedMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4,hideWhenPlotsHidden:["smoothedMA"]}],id:"Moving Average Exponential@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Exponential",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=o[this._input(1)](this._context),s=this._input(0),n=this._input(2),r=this._input(3),a=this._input(4);this._context.setMinimumAdditionalDepth(s+a);var l,c=this._context.new_var(i),h=o.ema(c,s,this._context),d=this._context.new_var(h);return"EMA"===r?l=o.ema(d,a,this._context):"WMA"===r?l=o.wma(d,a,this._context):"SMA"===r&&(l=o.sma(d,a,this._context)),[{value:h,offset:n},{value:l,offset:n}]}}},{name:"Moving Average Weighted",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9,in_1:"close",in_2:0}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Moving Average Weighted",shortDescription:"WMA",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:9,type:"integer",min:1,max:1e4},{id:"in_1",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"in_2",name:"Offset",defval:0,type:"integer",min:-1e4,max:1e4}],id:"Moving Average Weighted@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Weighted",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=o[this._input(1)](this._context),s=this._input(0),n=this._input(2),r=this._context.new_var(i);return[{value:o.wma(r,s,this._context),offset:n}]}}},{name:"Moving Average Double",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"Moving Average Double@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Double",description:"Moving Average Double",shortDescription:"Moving Average Double",is_price_study:!0,plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"},plot_1:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{symbol:"",firstPeriods:14,secondPeriods:21,method:"Simple"}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"}},inputs:[{id:"symbol",name:"Another symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"firstPeriods",name:"1st Period",type:"integer",defval:14,min:1,max:1e4},{id:"secondPeriods",name:"2nd Period",type:"integer",defval:21,min:1,max:1e4
},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o.time(this._context)),s=o.close(this._context);if(""!==this._input(0)){this._context.select_sym(1);var n=this._context.new_var(o.time(this._context)),r=o.close(this._context);s=this._context.new_var(r).adopt(n,i,1),this._context.select_sym(0)}var a,l,c=this._context.new_var(s);return"Exponential"===this._input(3)?(a=o.ema(c,this._input(1),this._context),l=o.ema(c,this._input(2),this._context)):"Weighted"===this._input(3)?(a=o.wma(c,this._input(1),this._context),l=o.wma(c,this._input(2),this._context)):(a=o.sma(c,this._input(1),this._context),l=o.sma(c,this._input(2),this._context)),[a,l]}}},{name:"Moving Average Triple",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Triple@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Triple",description:"Moving Average Triple",shortDescription:"Moving Average Triple",plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#FF6D00"},plot_1:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#2196F3"},plot_2:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#26C6DA"}},inputs:{symbol:"",firstPeriods:14,secondPeriods:21,thirdPeriods:35,method:"Simple"}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"},plot_2:{title:"Plot 3"}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"firstPeriods",name:"1st Period",type:"integer",defval:14,min:1,max:1e4,hideWhenPlotsHidden:["plot_0"]},{id:"secondPeriods",name:"2nd Period",type:"integer",defval:21,min:1,max:1e4,hideWhenPlotsHidden:["plot_1"]},{id:"thirdPeriods",name:"3rd Period",type:"integer",defval:35,min:1,max:1e4,hideWhenPlotsHidden:["plot_2"]},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(this._context.symbol.time),s=o.close(this._context);if(""!==this._input(0)){this._context.select_sym(1);var n=this._context.new_var(this._context.symbol.time),r=o.close(this._context);s=this._context.new_var(r).adopt(n,i,1),this._context.select_sym(0)}var a,l,c,h=this._context.new_var(s);return"Exponential"===this._input(4)?(a=o.ema(h,this._input(1),this._context),l=o.ema(h,this._input(2),this._context),c=o.ema(h,this._input(3),this._context)):"Weighted"===this._input(4)?(a=o.wma(h,this._input(1),this._context),
l=o.wma(h,this._input(2),this._context),c=o.wma(h,this._input(3),this._context)):(a=o.sma(h,this._input(1),this._context),l=o.sma(h,this._input(2),this._context),c=o.sma(h,this._input(3),this._context)),[a,l,c]}}},{name:"Moving Average Adaptive",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Adaptive@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Adaptive",description:"Moving Average Adaptive",shortDescription:"Moving Average Adaptive",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#AB47BC"}},inputs:{periods:10}},styles:{plot_0:{title:"Plot 1"}},inputs:[{id:"periods",name:"Period",type:"integer",defval:10,min:2,max:1e4}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.periods=this._input(0)},this.ama=function(e,t){var i=this.periods,s=this._context.new_var(),n=e.get(),r=o.stdev(t,i,this._context),a=o.log(n/e.get(i))/(r*Math.sqrt(i)),l=.1*Math.abs(a),c=(n-s.get(1))*l+s.get(1);return s.set(isNaN(c)?n:c),c},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o.close(this._context)),s=this._context.new_var(o.log(i.get()/i.get(1)));return[this.ama(i,s)]}}},{name:"Moving Average Hamming",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Hamming@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Hamming",description:"Moving Average Hamming",shortDescription:"Moving Average Hamming",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#4CAF50"}},inputs:{periods:10}},styles:{plot_0:{title:"Plot 1"}},inputs:[{id:"periods",name:"Period",type:"integer",defval:10,min:1,max:1e4}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.periods=this._input(0);for(var i=[],s=0,o=1;o<=this.periods;++o){var n=Math.sin((1+o)/this.periods*Math.PI/2);i.unshift(n),s+=n}this.hmaFactors=i,this.hmaFactorsSum=s},this.hma=function(e){for(var t=this.periods,i=0,s=0;s<t;++s)i+=e.get(t-s-1)*this.hmaFactors[s];return i/=this.hmaFactorsSum},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o.close(this._context));return[this.hma(i)]}}},{name:"Moving Average Multiple",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Moving Average Multiple@tv-basicstudies-1",scriptIdPart:"",name:"Moving Average Multiple",description:"Moving Average Multiple",shortDescription:"Moving Average Multiple",plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"},{id:"plot_3",type:"line"},{id:"plot_4",type:"line"},{id:"plot_5",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,transparency:0,trackPrice:!1,color:"#9C27B0"},plot_1:{linestyle:0,visible:!0,
linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#FF6D00"},plot_2:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#43A047"},plot_3:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#26C6DA"},plot_4:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#F50057"},plot_5:{linestyle:0,visible:!0,linewidth:1,transparency:0,plottype:0,trackPrice:!1,color:"#2196F3"}},inputs:{symbol:"",firstPeriods:14,secondPeriods:21,thirdPeriods:35,fourthPeriods:50,fifthPeriods:100,sixthPeriods:200,method:"Simple"}},styles:{plot_0:{title:"Plot 1"},plot_1:{title:"Plot 2"},plot_2:{title:"Plot 3"},plot_3:{title:"Plot 4"},plot_4:{title:"Plot 5"},plot_5:{title:"Plot 6"}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"firstPeriods",name:"1st Period",type:"integer",defval:14,min:1,max:1e4,hideWhenPlotsHidden:["plot_0"]},{id:"secondPeriods",name:"2nd Period",type:"integer",defval:21,min:1,max:1e4,hideWhenPlotsHidden:["plot_1"]},{id:"thirdPeriods",name:"3rd Period",type:"integer",defval:35,min:1,max:1e4,hideWhenPlotsHidden:["plot_2"]},{id:"fourthPeriods",name:"4th Period",type:"integer",defval:50,min:1,max:1e4,hideWhenPlotsHidden:["plot_3"]},{id:"fifthPeriods",name:"5th Period",type:"integer",defval:100,min:1,max:1e4,hideWhenPlotsHidden:["plot_4"]},{id:"sixthPeriods",name:"6th Period",type:"integer",defval:200,min:1,max:1e4,hideWhenPlotsHidden:["plot_5"]},{id:"method",name:"Method",type:"text",defval:"Simple",options:["Simple","Exponential","Weighted"]}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(this._context.symbol.time),s=o.close(this._context);if(""!==this._input(0)){this._context.select_sym(1);var n=this._context.new_var(this._context.symbol.time),r=o.close(this._context);s=this._context.new_var(r).adopt(n,i,1),this._context.select_sym(0)}var a,l,c,h,d,u,_=this._context.new_var(s);return"Exponential"===this._input(7)?(a=o.ema(_,this._input(1),this._context),l=o.ema(_,this._input(2),this._context),c=o.ema(_,this._input(3),this._context),h=o.ema(_,this._input(4),this._context),d=o.ema(_,this._input(5),this._context),u=o.ema(_,this._input(6),this._context)):"Weighted"===this._input(7)?(a=o.wma(_,this._input(1),this._context),l=o.wma(_,this._input(2),this._context),c=o.wma(_,this._input(3),this._context),h=o.wma(_,this._input(4),this._context),d=o.wma(_,this._input(5),this._context),u=o.wma(_,this._input(6),this._context)):(a=o.sma(_,this._input(1),this._context),l=o.sma(_,this._input(2),this._context),c=o.sma(_,this._input(3),this._context),h=o.sma(_,this._input(4),this._context),d=o.sma(_,this._input(5),this._context),u=o.sma(_,this._input(6),this._context)),[a,l,c,h,d,u]}}},{name:"Majority Rule",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,
id:"Majority Rule@tv-basicstudies-1",scriptIdPart:"",name:"Majority Rule",description:"Majority Rule",shortDescription:"Majority Rule",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:c}},inputs:{rollingPeriod:14}},styles:{plot_0:{title:"Majority Rule"}},inputs:[{id:"rollingPeriod",type:"integer",name:"Rolling Period",min:1}],format:{precision:2,type:"price"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.rollingPeriod=this._input(0)},this.main=function(e,t){this._context=e,this._input=t;var i,s=o.close(this._context);return i=s>this._context.new_var(s).get(1)?1:0,[100*o.sma(this._context.new_var(i),this.rollingPeriod,this._context)]}}},{name:"Net Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Net Volume",shortDescription:"Net Volume",is_price_study:!1,inputs:[],id:"Net Volume@tv-basicstudies-1",scriptIdPart:"",name:"Net Volume",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i){return o.gt(e,0)?t:o.lt(i,0)?-t:0*t},this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._context.new_var(i),n=o.change(s);return[this.f_0(n,o.volume(this._context),n)]}}},{name:"On Balance Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},inputs:{smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1}},description:"On Balance Volume",shortDescription:"OBV",is_price_study:!1,inputs:[{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],hideWhenPlotsHidden:["smoothedMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4,hideWhenPlotsHidden:["smoothedMA"]}],id:"On Balance Volume@tv-basicstudies-1",scriptIdPart:"",name:"On Balance Volume",format:{type:"volume"}},constructor:function(){this.f_0=function(e,t,i){return o.gt(e,0)?t:o.lt(i,0)?-t:0*t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.close(this._context),r=this._context.new_var(n),a=o.change(r),l=this.f_0(a,o.volume(this._context),a),c=o.cum(l,this._context);this._context.setMinimumAdditionalDepth(s);var h,d=this._context.new_var(c);return"EMA"===i?h=o.ema(d,s,this._context):"WMA"===i?h=o.wma(d,s,this._context):"SMA"===i&&(h=o.sma(d,s,this._context)),[c,h]}}},{name:"Parabolic SAR",metainfo:{
_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:3,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:.02,in_1:.02,in_2:.2,symbol:""}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Parabolic SAR",shortDescription:"SAR",is_price_study:!0,inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"in_0",name:"start",defval:.02,type:"float",min:-1e12,max:1e12},{id:"in_1",name:"increment",defval:.02,type:"float",min:-1e12,max:1e12},{id:"in_2",name:"maximum",defval:.2,type:"float",min:-1e12,max:1e12}],id:"Parabolic SAR@tv-basicstudies-1",scriptIdPart:"",name:"Parabolic SAR",format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),o.period(this._context))},this.main=function(e,t){this._context=e,this._input=t;const i=()=>o.sar(this._input(1),this._input(2),this._input(3),this._context);if(""===this._input(0))return[i()];this._context.select_sym(0);const s=this._context.new_var(this._context.symbol.time);this._context.select_sym(1);const n=this._context.new_var(i()).adopt(this._context.new_var(this._context.symbol.time),s,1);return this._context.select_sym(0),[n]}}},{name:"Price Channel",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#F50057"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:20,in_1:0}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Highprice Line",histogramBase:0,joinPoints:!1},plot_1:{title:"Lowprice Line",histogramBase:0,joinPoints:!1},plot_2:{title:"Centerprice Line",histogramBase:0,joinPoints:!1}},description:"Price Channel",shortDescription:"PC",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:20,type:"integer",min:1,max:2e3},{id:"in_1",name:"Offset Length",defval:0,type:"integer",min:1,max:2e3}],id:"Price Channel@tv-basicstudies-1",scriptIdPart:"",name:"Price Channel",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=o.high(this._context),s=this._context.new_var(i),n=o.low(this._context),r=this._context.new_var(n),a=this._input(0),l=this._input(1),c=o.highest(s,a,this._context),h=o.lowest(r,a,this._context);return[{value:c,offset:l},{value:h,offset:l},{value:o.avg(c,h),offset:l}]}}},{name:"Price Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:u}},inputs:{in_0:10,in_1:21}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,
joinPoints:!1}},description:"Price Oscillator",shortDescription:"PPO",is_price_study:!1,inputs:[{id:"in_0",name:"shortlen",defval:10,type:"integer",min:1,max:2e3},{id:"in_1",name:"longlen",defval:21,type:"integer",min:1,max:2e3}],id:"Price Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Price Oscillator",format:{type:"price",precision:2}},constructor:function(){this.f_0=function(e,t){return(e-t)/t*100},this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._input(1),r=this._context.new_var(i),a=o.sma(r,s,this._context),l=this._context.new_var(i),c=o.sma(l,n,this._context);return[this.f_0(a,c)]}}},{name:"Price Volume Trend",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"PVT",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Price Volume Trend",shortDescription:"PVT",is_price_study:!1,is_hidden_study:!1,id:"price_volume_trend@tv-basicstudies-1",inputs:[],scriptIdPart:"",name:"Price Volume Trend",format:{type:"volume"}},constructor:function(){this.f_0=function(){var e=this._context.new_var(o.close(this._context));return[o.cum(o.change(e)/e.get(1)*o.volume(this._context),this._context)]},this.main=function(e,t){return this._context=e,this._input=t,[this.f_0()[0]]}}},{name:"Rank Correlation Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:12}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"RCI",histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1}},description:"Rank Correlation Index",shortDescription:"RCI",is_price_study:!1,bands:[{id:"hline_0",name:"Zero Line",isHidden:!1,zorder:-1}],inputs:[{id:"in_0",name:"length",defval:12,type:"integer",min:1,max:1e12}],id:"rank_correlation_index@tv-basicstudies-1",scriptIdPart:"",name:"Rank Correlation Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.orderRank=function(e,t,i){let s=e.get(t),n=1,r=0;for(let t=0;t<i;t++){const i=e.get(t);if(o.na(i))return o.na();s<i?n+=1:s===i&&(r+=1)}return n+(r-1)/2},this.rankDifferences=function(e,t){var i=0;for(let s=0;s<t;s++)i+=Math.pow(s+1-this.orderRank(e,s,t),2);return i},this.rci=function(e,t){return 1-6*this.rankDifferences(e,t)/(t*(t*t-1))},this.main=function(e,t){var i=e.new_var(o.close(e)),s=t(0);return[this.rci(i,s)]}}},{name:"Rate Of Change",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"ROC",
histogramBase:0,joinPoints:!1,isHidden:!1,zorder:1}},description:"Rate Of Change",shortDescription:"ROC",is_price_study:!1,bands:[{id:"hline_0",name:"Zero Line",isHidden:!1,zorder:-1}],inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e12}],id:"rate_of_change@tv-basicstudies-1",scriptIdPart:"",name:"Rate Of Change",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o.close(this._context)),s=this._input(0);return[100*(i.get(0)-i.get(s))/i.get(s)]}}},{name:"Relative Strength Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#7E57C2"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:70,zorder:-1.1},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:50,zorder:-1.11},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:30,zorder:-1.111}],filledAreasStyle:{fill_0:{color:"#7E57C2",transparency:90,visible:!0}},inputs:{length:14,smoothingLine:"SMA",smoothingLength:14}},plots:[{id:"plot_0",type:"line"},{id:"smoothedMA",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1},smoothedMA:{title:"Smoothed MA",histogramBase:0,joinPoints:!1,zorder:2}},description:"Relative Strength Index",shortDescription:"RSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_2",name:"MiddleLimit",zorder:-1.11},{id:"hline_1",name:"LowerLimit",zorder:-1.111}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"length",name:"Length",defval:14,type:"integer",min:1,max:2e3},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"],hideWhenPlotsHidden:["smoothedMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:14,type:"integer",min:1,max:1e4,hideWhenPlotsHidden:["smoothedMA"]}],id:"Relative Strength Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Strength Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e){return o.max(e,0)},this.f_1=function(e){return-o.min(e,0)},this.f_2=function(e,t){return o.eq(e,0)?100:o.eq(t,0)?0:100-100/(1+t/e)},this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._input(1),r=this._input(2);this._context.setMinimumAdditionalDepth(s+r);var a,l=this._context.new_var(i),c=o.change(l),h=this.f_0(c),d=this._context.new_var(h),u=o.rma(d,s,this._context),_=this.f_1(c),p=this._context.new_var(_),m=o.rma(p,s,this._context),g=this.f_2(m,u),f=this._context.new_var(g);return"EMA"===n?a=o.ema(f,r,this._context):"WMA"===n?a=o.wma(f,r,this._context):"SMA"===n&&(a=o.sma(f,r,this._context)),[{value:g},{value:a}]}}},{name:"Relative Vigor Index",metainfo:{_metainfoVersion:52,
isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:u},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"RVGI",histogramBase:0,joinPoints:!1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1}},description:"Relative Vigor Index",shortDescription:"RVGI",is_price_study:!1,inputs:[{id:"in_0",name:"Length",defval:10,type:"integer",min:1,max:2e3}],id:"Relative Vigor Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Vigor Index",format:{precision:4,type:"price"}},constructor:function(){this.f_0=function(e,t){return e-t},this.f_1=function(e,t){return e/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this.f_0(o.close(this._context),o.open(this._context)),n=this._context.new_var(s),r=o.swma(n,this._context),a=this._context.new_var(r),l=o.sum(a,i,this._context),c=this.f_0(o.high(this._context),o.low(this._context)),h=this._context.new_var(c),d=o.swma(h,this._context),u=this._context.new_var(d),_=o.sum(u,i,this._context),p=this.f_1(l,_),m=this._context.new_var(p);return[p,o.swma(m,this._context)]}}},{name:"Relative Volatility Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#7E57C2"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:80},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:20}],filledAreasStyle:{fill_0:{color:"#7E57C2",transparency:90,visible:!0}},inputs:{in_0:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Relative Volatility Index",shortDescription:"RVI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:10,type:"integer",min:1,max:2e3}],id:"Relative Volatility Index@tv-basicstudies-1",scriptIdPart:"",name:"Relative Volatility Index",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return o.le(e,0)?0:t},this.f_1=function(e,t){return o.gt(e,0)?0:t},this.f_2=function(e,t){return e/(e+t)*100},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);this._context.setMinimumAdditionalDepth(i+12);var s=o.close(this._context),n=this._context.new_var(s),r=o.stdev(n,i,this._context),a=this._context.new_var(s),l=o.change(a),c=this.f_0(l,r),h=this._context.new_var(c),d=o.ema(h,14,this._context),u=this.f_1(l,r),_=this._context.new_var(u),p=o.ema(_,14,this._context);return[this.f_2(d,p)]}}},{name:"SMI Ergodic Indicator/Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,
defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"},plot_2:{linestyle:0,linewidth:1,plottype:1,trackPrice:!1,transparency:0,visible:!0,color:c}},inputs:{in_0:5,in_1:20,in_2:5}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Indicator",histogramBase:0,joinPoints:!1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1},plot_2:{title:"Oscillator",histogramBase:0,joinPoints:!1}},description:"SMI Ergodic Indicator/Oscillator",shortDescription:"SMIIO",is_price_study:!1,inputs:[{id:"in_0",name:"shortlen",defval:5,type:"integer",min:1,max:2e3},{id:"in_1",name:"longlen",defval:20,type:"integer",min:1,max:2e3},{id:"in_2",name:"siglen",defval:5,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_1"]}],id:"SMI Ergodic Indicator/Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"SMI Ergodic Indicator/Oscillator",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t){return e-t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(i+s+n);var r=o.close(this._context),a=this._context.new_var(r),l=o.tsi(a,i,s,this._context),c=this._context.new_var(l),h=o.ema(c,n,this._context);return[l,h,this.f_0(l,h)]}}},{name:"Smoothed Moving Average",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#673AB7"}},inputs:{in_0:7,in_1:"close"}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Smoothed Moving Average",shortDescription:"SMMA",is_price_study:!0,inputs:[{id:"in_0",name:"Length",defval:7,type:"integer",min:1,max:1e12},{id:"in_1",name:"Source",defval:"close",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]}],id:"smoothed_moving_average@tv-basicstudies-1",scriptIdPart:"",name:"Smoothed Moving Average",format:{type:"inherit"}},constructor:function(){this.f_0=function(){var e=this._input(0),t=o[this._input(1)](this._context);return[o.smma(t,e,this._context)]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Standard Deviation",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"Standard Deviation@tv-basicstudies-1",scriptIdPart:"",name:"Standard Deviation",description:"Standard Deviation",shortDescription:"Standard Deviation",is_price_study:!1,plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:u}},inputs:{periods:5,deviations:1}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"periods",name:"Periods",type:"integer"},{id:"deviations",name:"Deviations",type:"float"}],format:{precision:2,type:"price"}},constructor:function(){
this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._context.new_var(o.close(this._context));return[o.stdev(n,i,this._context)*s]}}},{name:"Stochastic",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:80},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:20}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:14,in_1:1,in_2:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"%K",histogramBase:0,joinPoints:!1,zorder:1.1},plot_1:{title:"%D",histogramBase:0,joinPoints:!1,zorder:1.11}},description:"Stochastic",shortDescription:"Stoch",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"%K Length",defval:14,type:"integer",min:1,max:1e4},{id:"in_1",name:"%K Smoothing",defval:1,type:"integer",min:1,max:1e4},{id:"in_2",name:"%D Smoothing",defval:3,type:"integer",min:1,max:1e4}],id:"Stochastic@tv-basicstudies-1",scriptIdPart:"",name:"Stochastic",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(i+s+n);var r=o.close(this._context),a=o.high(this._context),l=o.low(this._context),c=this._context.new_var(r),h=this._context.new_var(a),d=this._context.new_var(l),u=o.stoch(c,h,d,i,this._context),_=this._context.new_var(u),p=o.sma(_,s,this._context),m=this._context.new_var(p);return[p,o.sma(m,n,this._context)]}}},{name:"Stochastic RSI",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#FF6D00"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:80},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:20}],filledAreasStyle:{fill_0:{color:"#2196F3",transparency:90,visible:!0}},inputs:{in_0:14,in_1:14,in_2:3,in_3:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"%K",histogramBase:0,joinPoints:!1,zorder:1.1},plot_1:{title:"%D",histogramBase:0,joinPoints:!1,zorder:1.11}},description:"Stochastic RSI",shortDescription:"Stoch RSI",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",
title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"lengthRSI",defval:14,type:"integer",min:1,max:1e4},{id:"in_1",name:"lengthStoch",defval:14,type:"integer",min:1,max:1e4},{id:"in_2",name:"smoothK",defval:3,type:"integer",min:1,max:1e4},{id:"in_3",name:"smoothD",defval:3,type:"integer",min:1,max:1e4}],id:"Stochastic RSI@tv-basicstudies-1",scriptIdPart:"",name:"Stochastic RSI",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_1=function(e,t,i){var s=i.new_var(o.max(o.change(e),0));return o.rma(s,t,i)},this.f_2=function(e,t,i){var s=i.new_var(-o.min(o.change(e),0));return o.rma(s,t,i)},this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._input(1),r=this._input(2),a=this._input(3);e.setMinimumAdditionalDepth(s+n+r+a);var l=this._context.new_var(i),c=o.rsi(this.f_1(l,s,this._context),this.f_2(l,s,this._context)),h=this._context.new_var(c),d=this._context.new_var(c),u=this._context.new_var(c),_=o.stoch(h,d,u,n,this._context),p=this._context.new_var(_),m=o.sma(p,r,this._context),g=this._context.new_var(m);return[m,o.sma(g,a,this._context)]}}},{name:"TRIX",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:18}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"TRIX",histogramBase:0,joinPoints:!1,zorder:1}},description:"TRIX",shortDescription:"TRIX",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"length",defval:18,type:"integer",min:1,max:2e3}],id:"TRIX@tv-basicstudies-1",scriptIdPart:"",name:"TRIX",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e){return o.log(e)},this.f_1=function(e){return 1e4*e},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);e.setMinimumAdditionalDepth(3*i);var s=this.f_0(o.close(this._context)),n=this._context.new_var(s),r=o.ema(n,i,this._context),a=this._context.new_var(r),l=o.ema(a,i,this._context),c=this._context.new_var(l),h=o.ema(c,i,this._context),d=this._context.new_var(h),u=o.change(d);return[this.f_1(u)]}}},{name:"Triple EMA",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:9}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Triple EMA",shortDescription:"TEMA",is_price_study:!0,inputs:[{id:"in_0",name:"length",defval:9,type:"integer",min:1,max:1e4}],id:"Triple EMA@tv-basicstudies-1",scriptIdPart:"",name:"Triple EMA",format:{type:"inherit"}},constructor:function(){this.f_0=function(e,t,i){return 3*(e-t)+i},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0);this._context.setMinimumAdditionalDepth(3*i)
;var s=o.close(this._context),n=this._context.new_var(s),r=o.ema(n,i,this._context),a=this._context.new_var(r),l=o.ema(a,i,this._context),c=this._context.new_var(l),h=o.ema(c,i,this._context);return[this.f_0(r,l,h)]}}},{name:"True Strength Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#E91E63"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:25,in_1:13,in_2:13}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"True Strength Index",histogramBase:0,joinPoints:!1,zorder:1.1},plot_1:{title:"Signal",histogramBase:0,joinPoints:!1,zorder:1.11}},description:"True Strength Index",shortDescription:"True Strength Index",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"long",defval:25,type:"integer",min:1,max:4999},{id:"in_1",name:"short",defval:13,type:"integer",min:1,max:4999},{id:"in_2",name:"siglen",defval:13,type:"integer",min:1,max:4999,hideWhenPlotsHidden:["plot_1"]}],id:"True Strength Indicator@tv-basicstudies-1",scriptIdPart:"",name:"True Strength Index",format:{precision:4,type:"price"},usePlotsZOrder:!0},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2);this._context.setMinimumAdditionalDepth(this._input(0)+this._input(1)+this._input(2));var r=o.close(this._context),a=this._context.new_var(r),l=o.tsi(a,s,i,this._context),c=this._context.new_var(l);return[l,o.ema(c,n,this._context)]}}},{name:"Trend Strength Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Trend Strength Index@tv-basicstudies-1",scriptIdPart:"",name:"Trend Strength Index",description:"Trend Strength Index",shortDescription:"Trend Strength Index",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:c}},inputs:{periods:14}},styles:{plot_0:{title:"Plot",histogramBase:0}},inputs:[{id:"periods",type:"integer",name:"Periods"}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.invertedPeriod=1/this.period,this.sumX=(this.period-1)*this.period/2,this.sumXX=(this.period-1)*this.period*(2*this.period-1)/6,this.invertedPeriodSumXSumX=this.invertedPeriod*this.sumX*this.sumX},this.trendStrengthIndex=function(){for(var e=this._context.new_var(o.close(this._context)),t=o.sum(e,this.period,this._context),i=0,s=0,n=0;n<this.period;n++){var r=e.get(n);s+=(this.period-1-n)*r,i+=r*r}var a=s-this.invertedPeriod*this.sumX*t,l=(this.sumXX-this.invertedPeriodSumXSumX)*(i-this.invertedPeriod*t*t);return l<0?0==a?0:a>0?1:-1:a/(l=Math.sqrt(l))},this.main=function(e,t){return this._context=e,this._input=t,
[this.trendStrengthIndex()]}}},{name:"Typical Price",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,id:"TypicalPrice@tv-basicstudies-1",scriptIdPart:"",name:"Typical Price",description:"Typical Price",shortDescription:"Typical Price",is_price_study:!0,plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#FF6D00"}},inputs:{}},styles:{plot_0:{title:"Plot"}},inputs:[],format:{type:"inherit"}},constructor:function(){this.main=function(e,t){return this._context=e,this._input=t,[o.hlc3(this._context)]}}},{name:"Ultimate Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:a}},inputs:{in_0:7,in_1:14,in_2:28}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"UO",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Ultimate Oscillator",shortDescription:"UO",is_price_study:!1,inputs:[{id:"in_0",name:"length7",defval:7,type:"integer",min:1,max:1e12},{id:"in_1",name:"length14",defval:14,type:"integer",min:1,max:1e12},{id:"in_2",name:"length28",defval:28,type:"integer",min:1,max:1e12}],id:"ultimate_oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Ultimate Oscillator",format:{precision:2,type:"price"}},constructor:function(){this.f_0=function(e,t,i){var s=this._context.new_var(e),n=this._context.new_var(t);return[o.sum(s,i,this._context)/o.sum(n,i,this._context)]},this.f_1=function(){var e=this._input(0),t=this._input(1),i=this._input(2),s=this._context.new_var(o.close(this._context)),n=o.max(o.high(this._context),s.get(1)),r=this._context.new_var(o.close(this._context)),a=o.min(o.low(this._context),r.get(1)),l=o.close(this._context)-a,c=n-a,h=this.f_0(l,c,e),d=this.f_0(l,c,t),u=this.f_0(l,c,i);return[100*(4*h[0]+2*d[0]+u[0])/7]},this.main=function(e,t){return this._context=e,this._input=t,this.f_1()}}},{name:"Volatility Close-to-Close",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Volatility Close-to-Close@tv-basicstudies-1",scriptIdPart:"",name:"Volatility Close-to-Close",description:"Volatility Close-to-Close",shortDescription:"Volatility Close-to-Close",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{periods:10,daysPerYear:252}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"periods",name:"Periods",type:"integer",defval:10,min:2},{id:"daysPerYear",name:"Days Per Year",type:"integer",defval:252,min:1,max:366}],format:{precision:2,type:"percent"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.daysPerYear=this._input(1)},this.stdev=function(e,t,i){var s=this.variance(e,t,i);return o.sqrt(s)},this.variance=function(e,t,i){var s=o.sma(e,t,i);return this.variance2(e,s,t)},this.variance2=function(e,t,i){var s,o,n=0
;for(s=0;s<i;s++)n+=(o=e.get(s)-t)*o;return n/(i-1)},this.standardHistVol=function(){var e=this._context.new_var(o.close(this._context)),t=this._context.new_var(o.log(e.get()/e.get(1)));return 100*this.stdev(t,this.period,this._context)*o.sqrt(this.daysPerYear)},this.main=function(e,t){return this._context=e,this._input=t,[this.standardHistVol()]}}},{name:"Volatility Zero Trend Close-to-Close",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Volatility Zero Trend Close-to-Close@tv-basicstudies-1",scriptIdPart:"",name:"Volatility Zero Trend Close-to-Close",description:"Volatility Zero Trend Close-to-Close",shortDescription:"Volatility Zero Trend Close-to-Close",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#2196F3"}},inputs:{periods:10,daysPerYear:252}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"periods",name:"Periods",type:"integer",min:0,max:1e4},{id:"daysPerYear",name:"Days Per Year",type:"integer"}],format:{precision:2,type:"percent"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.daysPerYear=this._input(1)},this.volatliityZTCTC=function(){this._context.setMinimumAdditionalDepth(this._input(0)+1);for(var e=this._context.new_var(o.close(this._context)),t=this._context.new_var(e.symbol.time),i=Math.sqrt((t.get(0)-t.get(1))/864e5/this.daysPerYear),s=Math.log(o.close(this._context)/e.get(1)),n=this._context.new_var(s/i),r=this._context.new_var(Math.pow(n,2)),a=0,l=0;l<this.period;l++)a+=r.get(l);return 100*Math.sqrt(a/this.period)},this.main=function(e,t){return this._context=e,this._input=t,[this.volatliityZTCTC()]}}},{name:"Volatility O-H-L-C",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!1,id:"Volatility O-H-L-C@tv-basicstudies-1",scriptIdPart:"",name:"Volatility O-H-L-C",description:"Volatility O-H-L-C",shortDescription:"Volatility O-H-L-C",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:c}},inputs:{periods:10,marketClosedPercentage:0,daysPerYear:252}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"periods",type:"integer",name:"Periods"},{id:"marketClosedPercentage",type:"float",name:"Market Closed Percentage",min:0,max:.999},{id:"daysPerYear",type:"integer",name:"Days Per Year"}],format:{precision:2,type:"percent"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.marketClosedPercentage=this._input(1),this.daysPerYear=this._input(2),this.secondsPerYear=86400*this.daysPerYear},this.square=function(e){return e*e},this.volatilityOHLC=function(){
var e=this._context.new_var(Math.log(o.open(this._context))),t=this._context.new_var(Math.log(o.high(this._context))),i=this._context.new_var(Math.log(o.low(this._context))),s=this._context.new_var(Math.log(o.close(this._context))),n=this._context.new_var(o.close(this._context)),r=this._context.new_var(n.symbol.time),a=(r.get(0)-r.get(1))/1e3,l=.5*this.square(t.get()-i.get());l-=(Math.log(4)-1)*this.square(s.get()-e.get()),this.marketClosedPercentage>0&&(l=.12*this.square(e.get()-s.get(1))/this.marketClosedPercentage+.88*l/(1-this.marketClosedPercentage)),l/=a,l*=this.secondsPerYear;var c=this._context.new_var(l);return 100*Math.sqrt(o.sum(c,this.period,this._context)/this.period)},this.main=function(e,t){return this._context=e,this._input=t,[this.volatilityOHLC()]}}},{name:"Volatility Index",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,is_price_study:!0,id:"Volatility Index@tv-basicstudies-1",scriptIdPart:"",name:"Volatility Index",description:"Volatility Index",shortDescription:"Volatility Index",plots:[{id:"plot_0",type:"line"}],defaults:{styles:{plot_0:{linestyle:0,visible:!0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:c}},inputs:{periods:10,atrMult:3,method:"Wilder Smoothing"}},styles:{plot_0:{title:"Plot"}},inputs:[{id:"periods",name:"Periods",type:"integer"},{id:"atrMult",name:"ATR Mult",type:"float"},{id:"method",name:"Method",type:"text",defval:"Exponential",options:["Exponential","Wilder Smoothing"]}],format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this.period=this._input(0),this.atrMult=this._input(1),this.maMethod=this._input(2),this.nextsar=null,this.position=null,this.sic=null,this.bars=[],this.count=0,this.lastSar=null,this._context.setMinimumAdditionalDepth("Exponential"===this.maMethod?2*this.period+2:this.period)},this.computeATR=function(){var e=o.high(this._context)-o.low(this._context),t=o.high(this._context)-this.bars[this.bars.length-2],i=this.bars[this.bars.length-2]-o.low(this._context);return this.tr=Math.max(e,t,i),"Exponential"===this.maMethod?this.atr=o.ema(this._context.new_var(this.tr),this.period,this._context):this.atr=this.tr/this.period+(1-1/this.period)*this.atr,this.atr*this.atrMult},this.calculateVolatility=function(){if(o.close(this._context)===this.bars[this.bars.length-1])return this.lastSar;if(this.bars.push(o.close(this._context)),1===this.count)this.atr=o.high(this._context)-o.low(this._context),this.sic=o.close(this._context);else if(this.count<this.period){var e=o.high(this._context)-o.low(this._context),t=o.high(this._context)-this.bars[this.bars.length-2],i=this.bars[this.bars.length-2]-o.low(this._context);this.atr+=Math.max(e,t,i),o.close(this._context)>this.sic&&(this.sic=o.close(this._context))}else if(this.count===this.period){e=o.high(this._context)-o.low(this._context),t=o.high(this._context)-this.bars[this.bars.length-2],i=this.bars[this.bars.length-2]-o.low(this._context);this.atr+=Math.max(e,t,i),this.atr*=1/this.period,
o.close(this._context)>this.sic&&(this.sic=o.close(this._context)),this.position="LONG",this.nextsar=this.sic-this.atr*this.atrMult}else{var s=this.nextsar;"LONG"===this.position?o.close(this._context)<s?(this.position="SHORT",this.sic=o.close(this._context),this.nextsar=this.sic+this.computeATR()):(this.position="LONG",this.sic=Math.max(o.close(this._context),this.sic),this.nextsar=this.sic-this.computeATR()):"SHORT"===this.position&&(o.close(this._context)>s?(this.position="LONG",this.sic=o.close(this._context),this.nextsar=this.sic-this.computeATR()):(this.position="SHORT",this.sic=Math.min(o.close(this._context),this.sic),this.nextsar=this.sic+this.computeATR())),this.lastSar=s}return this.count++,s},this.main=function(e,t){return this._context=e,this._input=t,this._context.select_sym(0),[this.calculateVolatility()]}}},{name:"VWAP",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{inputs:{in_0:"hlc3",in_anchor:"Session"},styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:0,transparency:0,visible:!0,color:"#2196F3"}}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"VWAP",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"VWAP",shortDescription:"VWAP",is_price_study:!0,inputs:[{id:"in_0",name:"Source",defval:"hlc3",type:"source",options:["open","high","low","close","hl2","hlc3","ohlc4"]},{id:"in_anchor",name:"Anchor Period",defval:"Session",type:"text",options:["Session","Week","Month","Quarter","Year","Decade","Century"]}],id:"VWAP@tv-basicstudies-1",scriptIdPart:"",name:"VWAP",format:{type:"inherit"}},constructor:function(){this.f_1=function(e){e.reset_hist()},this.createAnchorChecker=function(e,t){switch(t){case"Week":return function(t,i){return o.weekofyear(e,t)!==o.weekofyear(e,i)||o.year(e,t)!==o.year(e,i)};case"Month":return function(t,i){return o.month(e,t)!==o.month(e,i)||o.year(e,t)!==o.year(e,i)};case"Quarter":return function(t,i){return Math.floor(o.month(e,t)/3)!==Math.floor(o.month(e,i)/3)||o.year(e,t)!==o.year(e,i)};case"Year":return function(t,i){return o.year(e,t)!==o.year(e,i)};case"Decade":return function(t,i){return Math.floor(o.year(e,t)/10)!==Math.floor(o.year(e,i)/10)};case"Century":return function(t,i){return Math.floor(o.year(e,t)/100)!==Math.floor(o.year(e,i)/100)};default:return e=>this._isFirstBarInSession(e)}},this.init=function(e,t){this._input=t,this._isFirstBarInSession=null;const i=this._input(1)||"Session";this._anchorChecker=this.createAnchorChecker(e,i),e.setTargetAnchor(i)},this.main=function(e,t){this._context=e,this._input=t;const i=this._input(0);var s=e.new_var(),n=e.new_var(),r=e.new_var();const a=o.time(this._context),l=this._context.new_unlimited_var(a).get(1);if(a){if(null===this._isFirstBarInSession){const t=o.createNthBarInSessionCheck(e);this._isFirstBarInSession=e=>t(e,0)}this._anchorChecker(a,l)&&(this.f_1(s),this.f_1(n),r.set(a))}return s.set(o.nz(s.get(1))+o[i](this._context)*o.volume(this._context)),n.set(o.nz(n.get(1))+o.volume(this._context)),[s.get(0)/n.get(0)]}}},{name:"VWMA",metainfo:{
_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:20}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"VWMA",shortDescription:"VWMA",is_price_study:!0,inputs:[{id:"in_0",name:"len",defval:20,type:"integer",min:1,max:1e4}],id:"VWMA@tv-basicstudies-1",scriptIdPart:"",name:"VWMA",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=o.close(this._context),s=this._input(0),n=this._context.new_var(i);return[o.vwma(n,s,this._context)]}}},{name:"Volume Oscillator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:0}],inputs:{in_0:5,in_1:10}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Volume Oscillator",shortDescription:"Volume Osc",is_price_study:!1,bands:[{id:"hline_0",name:"Zero",zorder:-1}],inputs:[{id:"in_0",name:"shortlen",defval:5,type:"integer",min:1,max:4999},{id:"in_1",name:"longlen",defval:10,type:"integer",min:1,max:4999}],id:"Volume Oscillator@tv-basicstudies-1",scriptIdPart:"",name:"Volume Oscillator",format:{precision:2,type:"percent"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t){return 100*(e-t)/t},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=o.volume(this._context),r=this._context.new_var(n),a=o.ema(r,i,this._context),l=this._context.new_var(n),c=o.ema(l,s,this._context);return[this.f_0(a,c)]}}},{name:"Vortex Indicator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#E91E63"}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"}],styles:{plot_0:{title:"VI +",histogramBase:0,joinPoints:!1,isHidden:!1},plot_1:{title:"VI -",histogramBase:0,joinPoints:!1,isHidden:!1}},description:"Vortex Indicator",shortDescription:"VI",is_price_study:!1,is_hidden_study:!1,id:"vortex_indicator@tv-basicstudies-1",inputs:[{id:"in_0",name:"Period",defval:14,type:"integer",min:2,max:1e12}],scriptIdPart:"",name:"Vortex Indicator",format:{precision:4,type:"price"}},constructor:function(){this.f_0=function(){var e=this._input(0),t=this._context.new_var(o.low(this._context)),i=this._context.new_var(o.abs(o.high(this._context)-t.get(1))),s=o.sum(i,e,this._context),n=this._context.new_var(o.high(this._context)),r=this._context.new_var(o.abs(o.low(this._context)-n.get(1))),a=o.sum(r,e,this._context),l=this._context.new_var(o.atr(1,this._context)),c=o.sum(l,e,this._context)
;return[s/c,a/c]},this.main=function(e,t){return this._context=e,this._input=t,this.f_0()}}},{name:"Willams %R",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#7E57C2"}},bands:[{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:-20},{color:"#787B86",linestyle:2,linewidth:1,visible:!0,value:-80}],filledAreasStyle:{fill_0:{color:"#7E57C2",transparency:90,visible:!0}},inputs:{in_0:14}},plots:[{id:"plot_0",type:"line"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1,zorder:1}},description:"Williams %R",shortDescription:"%R",is_price_study:!1,bands:[{id:"hline_0",name:"UpperLimit",zorder:-1.1},{id:"hline_1",name:"LowerLimit",zorder:-1.11}],filledAreas:[{id:"fill_0",objAId:"hline_0",objBId:"hline_1",type:"hline_hline",title:"Hlines Background",zorder:-2}],inputs:[{id:"in_0",name:"length",defval:14,type:"integer",min:1,max:2e3}],id:"Willams %R@tv-basicstudies-1",scriptIdPart:"",name:"Willams %R",format:{precision:2,type:"price"},usePlotsZOrder:!0},constructor:function(){this.f_0=function(e,t,i){return 100*(e-t)/(t-i)},this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=o.high(this._context),n=this._context.new_var(s),r=o.highest(n,i,this._context),a=o.low(this._context),l=this._context.new_var(a),c=o.lowest(l,i,this._context);return[this.f_0(o.close(this._context),r,c)]}}},{name:"Williams Alligator",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#E91E63"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#66BB6A"}},inputs:{in_0:21,in_1:13,in_2:8,in_3:8,in_4:5,in_5:3}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",type:"line"},{id:"plot_2",type:"line"}],styles:{plot_0:{title:"Jaw",histogramBase:0,joinPoints:!1},plot_1:{title:"Teeth",histogramBase:0,joinPoints:!1},plot_2:{title:"Lips",histogramBase:0,joinPoints:!1}},description:"Williams Alligator",shortDescription:"Alligator",is_price_study:!0,inputs:[{id:"in_0",name:"Jaw Length",defval:21,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_0"]},{id:"in_1",name:"Teeth Length",defval:13,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_1"]},{id:"in_2",name:"Lips Length",defval:8,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_2"]},{id:"in_3",name:"Jaw Offset",defval:8,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_0"]},{id:"in_4",name:"Teeth Offset",defval:5,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_1"]},{id:"in_5",name:"Lips Offset",defval:3,type:"integer",min:1,max:2e3,hideWhenPlotsHidden:["plot_2"]}],id:"Williams Alligator@tv-basicstudies-1",scriptIdPart:"",name:"Williams Alligator",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,
this._input=t;var i=this._input(0),s=this._input(1),n=this._input(2),r=this._input(3),a=this._input(4),l=this._input(5),c=o.hl2(this._context);return[{value:o.smma(c,i,this._context),offset:r},{value:o.smma(c,s,this._context),offset:a},{value:o.smma(c,n,this._context),offset:l}]}}},{name:"Williams Fractals",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,defaults:{styles:{plot_0:{plottype:"shape_triangle_down",visible:!0,location:"BelowBar",transparency:0,color:a},plot_1:{plottype:"shape_triangle_up",visible:!0,location:"AboveBar",transparency:0,color:u}},inputs:{in_0:2}},plots:[{id:"plot_0",type:"shapes"},{id:"plot_1",type:"shapes"}],styles:{plot_0:{title:"Down fractals",isHidden:!1},plot_1:{title:"Up fractals",isHidden:!1}},description:"Williams Fractal",shortDescription:"Fractals",is_price_study:!0,is_hidden_study:!1,id:"Williams Fractals@tv-basicstudies-1",inputs:[{id:"in_0",name:"Periods",defval:2,type:"integer",min:2,max:1e12}],scriptIdPart:"",name:"Williams Fractals",isCustomIndicator:!0,format:{type:"inherit"}},constructor:function(){this.f_0=function(){for(var e=this._input(0),t=this._context.new_var(o.high(this._context)),i=!0,s=!0,n=!0,r=!0,a=!0,l=!0,c=1;c<=e;c++)i=o.and(i,o.lt(t.get(e-c),t.get(e))),s=o.and(s,o.lt(t.get(e+c),t.get(e))),n=o.and(n,o.and(o.le(t.get(e+1),t.get(e)),o.lt(t.get(e+c+1),t.get(e)))),r=o.and(r,o.and(o.le(t.get(e+1),t.get(e)),o.and(o.le(t.get(e+2),t.get(e)),o.lt(t.get(e+c+2),t.get(e))))),a=o.and(a,o.and(o.le(t.get(e+1),t.get(e)),o.and(o.le(t.get(e+2),t.get(e)),o.and(o.le(t.get(e+3),t.get(e)),o.lt(t.get(e+c+3),t.get(e)))))),l=o.and(l,o.and(o.le(t.get(e+1),t.get(e)),o.and(o.le(t.get(e+2),t.get(e)),o.and(o.le(t.get(e+3),t.get(e)),o.and(o.le(t.get(e+4),t.get(e)),o.lt(t.get(e+c+4),t.get(e)))))));var h=o.or(s,o.or(n,o.or(r,o.or(a,l)))),d=o.and(i,h),u=this._context.new_var(o.low(this._context)),_=1,p=1,m=1,g=1,f=1,y=1;for(c=1;c<=e;c++)_=o.and(_,o.gt(u.get(e-c),u.get(e))),p=o.and(p,o.gt(u.get(e+c),u.get(e))),m=o.and(m,o.and(o.ge(u.get(e+1),u.get(e)),o.gt(u.get(e+c+1),u.get(e)))),g=o.and(g,o.and(o.ge(u.get(e+1),u.get(e)),o.and(o.ge(u.get(e+2),u.get(e)),o.gt(u.get(e+c+2),u.get(e))))),f=o.and(f,o.and(o.ge(u.get(e+1),u.get(e)),o.and(o.ge(u.get(e+2),u.get(e)),o.and(o.ge(u.get(e+3),u.get(e)),o.gt(u.get(e+c+3),u.get(e)))))),y=o.and(y,o.and(o.ge(u.get(e+1),u.get(e)),o.and(o.ge(u.get(e+2),u.get(e)),o.and(o.ge(u.get(e+3),u.get(e)),o.and(o.ge(u.get(e+4),u.get(e)),o.gt(u.get(e+c+4),u.get(e)))))));var v=o.or(p,o.or(m,o.or(g,o.or(f,y))));return[o.and(_,v),d]},this.main=function(e,t){this._context=e,this._input=t;var i=this.f_0();return[{value:i[0],offset:-this._input(0)},{value:i[1],offset:-this._input(0)}]}}},{name:"Guppy Multiple Moving Average",metainfo:{isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,description:"Guppy Multiple Moving Average",shortDescription:"GMMA",is_price_study:!0,id:"Guppy Multiple Moving Average@tv-basicstudies-1",_metainfoVersion:52,format:{type:"inherit"},defaults:{inputs:{traderEMA1Length:3,traderEMA2Length:5,traderEMA3Length:8,traderEMA4Length:10,
traderEMA5Length:12,traderEMA6Length:15,investorEMA1Length:30,investorEMA2Length:35,investorEMA3Length:40,investorEMA4Length:45,investorEMA5Length:50,investorEMA6Length:60},styles:{traderEMA1:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:15,visible:!0},traderEMA2:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:12,visible:!0},traderEMA3:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:9,visible:!0},traderEMA4:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:6,visible:!0},traderEMA5:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:3,visible:!0},traderEMA6:{color:"#00FFFF",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0},investorEMA1:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:15,visible:!0},investorEMA2:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:12,visible:!0},investorEMA3:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:9,visible:!0},investorEMA4:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:6,visible:!0},investorEMA5:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:3,visible:!0},investorEMA6:{color:"#FF0000",linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!0}}},inputs:[{defval:3,id:"traderEMA1Length",max:1e3,min:1,name:"Trader EMA 1 length",type:"integer",hideWhenPlotsHidden:["traderEMA1"]},{defval:5,id:"traderEMA2Length",max:1e3,min:1,name:"Trader EMA 2 length",type:"integer",hideWhenPlotsHidden:["traderEMA2"]},{defval:8,id:"traderEMA3Length",max:1e3,min:1,name:"Trader EMA 3 length",type:"integer",hideWhenPlotsHidden:["traderEMA3"]},{defval:10,id:"traderEMA4Length",max:1e3,min:1,name:"Trader EMA 4 length",type:"integer",hideWhenPlotsHidden:["traderEMA4"]},{defval:12,id:"traderEMA5Length",max:1e3,min:1,name:"Trader EMA 5 length",type:"integer",hideWhenPlotsHidden:["traderEMA5"]},{defval:15,id:"traderEMA6Length",max:1e3,min:1,name:"Trader EMA 6 length",type:"integer",hideWhenPlotsHidden:["traderEMA6"]},{defval:30,id:"investorEMA1Length",max:1e3,min:1,name:"Investor EMA 1 length",type:"integer",hideWhenPlotsHidden:["investorEMA1"]},{defval:35,id:"investorEMA2Length",max:1e3,min:1,name:"Investor EMA 2 length",type:"integer",hideWhenPlotsHidden:["investorEMA2"]},{defval:40,id:"investorEMA3Length",max:1e3,min:1,name:"Investor EMA 3 length",type:"integer",hideWhenPlotsHidden:["investorEMA3"]},{defval:45,id:"investorEMA4Length",max:1e3,min:1,name:"Investor EMA 4 length",type:"integer",hideWhenPlotsHidden:["investorEMA4"]},{defval:50,id:"investorEMA5Length",max:1e3,min:1,name:"Investor EMA 5 length",type:"integer",hideWhenPlotsHidden:["investorEMA5"]},{defval:60,id:"investorEMA6Length",max:1e3,min:1,name:"Investor EMA 6 length",type:"integer",hideWhenPlotsHidden:["investorEMA6"]}],plots:[{id:"traderEMA1",type:"line"},{id:"traderEMA2",type:"line"},{
id:"traderEMA3",type:"line"},{id:"traderEMA4",type:"line"},{id:"traderEMA5",type:"line"},{id:"traderEMA6",type:"line"},{id:"investorEMA1",type:"line"},{id:"investorEMA2",type:"line"},{id:"investorEMA3",type:"line"},{id:"investorEMA4",type:"line"},{id:"investorEMA5",type:"line"},{id:"investorEMA6",type:"line"}],styles:{traderEMA1:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 1"},traderEMA2:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 2"},traderEMA3:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 3"},traderEMA4:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 4"},traderEMA5:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 5"},traderEMA6:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Trader EMA 6"},investorEMA1:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 1"},investorEMA2:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 2"},investorEMA3:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 3"},investorEMA4:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 4"},investorEMA5:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 5"},investorEMA6:{histogramBase:0,isHidden:!1,joinPoints:!1,title:"Investor EMA 6"}}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._context.new_var(o.close(this._context)),s=this._input(0),n=this._input(1),r=this._input(2),a=this._input(3),l=this._input(4),c=this._input(5),h=o.ema(i,s,this._context),d=o.ema(i,n,this._context),u=o.ema(i,r,this._context),_=o.ema(i,a,this._context),p=o.ema(i,l,this._context),m=o.ema(i,c,this._context),g=this._input(6),f=this._input(7),y=this._input(8),v=this._input(9),S=this._input(10),b=this._input(11);return[h,d,u,_,p,m,o.ema(i,g,this._context),o.ema(i,f,this._context),o.ema(i,y,this._context),o.ema(i,v,this._context),o.ema(i,S,this._context),o.ema(i,b,this._context)]}}},{name:"52 Week High/Low",metainfo:{_metainfoVersion:52,id:"52 Week High/Low@tv-basicstudies-1",description:"52 Week High/Low",shortDescription:"52W H/L",is_price_study:!0,format:{type:"inherit"},plots:[],graphics:{horizlines:{highest:{name:"Highest"},lowest:{name:"Lowest"}}},inputs:[{defval:"close",id:"highestSource",name:"High source",options:["close","high"],type:"text"},{defval:"close",id:"lowestSource",name:"Low source",options:["close","low"],type:"text"}],defaults:{graphics:{horizlines:{highest:{color:"rgb(93, 96, 107)",showPrice:!0,style:1,visible:!0,width:2},lowest:{color:"rgb(93, 96, 107)",showPrice:!0,style:1,visible:!0,width:2}}},inputs:{highestSource:"close",lowestSource:"close"}}},constructor:function(){this.init=function(e,t){this._context=e,this._input=t,this._symbolSupports1DResolution=!this._context.symbol.info.supported_resolutions||-1!==this._context.symbol.info.supported_resolutions.indexOf("1D"),this._symbolSupports1DResolution&&"1D"!==o.period(this._context)&&this._context.new_sym(this._context.symbol.ticker,"1D")},this.main=function(e,t){
this._symbolSupports1DResolution||o.error(`Daily bars are not available for ${this._context.symbol.info.name}`),this._context=e,this._input=t,"1D"!==o.period(this._context)&&this._context.select_sym(1);const i=this._input(0),s=this._input(1),n=o.time(this._context),r=this._context.new_unlimited_var(n),a=this._context.new_unlimited_var(o[i](this._context)),l=this._context.new_unlimited_var(o[s](this._context));if(r.get(365),!this._context.symbol.isLastBar||!this._context.symbol.isNewBar)return null;const c=o.add_years_considering_dst(this._context.symbol.info.timezone,new Date(n),-1),h=r.indexOf(c.getTime()),d=-1===h?NaN:o.highest(a,h,this._context),u=-1===h?NaN:o.lowest(l,h,this._context);if(isNaN(d)||isNaN(u))return{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{erase:[{action:"all"}]}}};return{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{horizlines:[{styleId:"highest",data:[{startIndex:n,endIndex:n,level:d,extendLeft:!0,extendRight:!0}]},{styleId:"lowest",data:[{startIndex:n,endIndex:n,level:u,extendLeft:!0,extendRight:!0}]}]},erase:[{action:"all"}]}}}}}}]},30342:(e,t,i)=>{"use strict";var s;i.d(t,{SubsessionId:()=>s}),function(e){e.Regular="regular",e.Extended="extended",e.PreMarket="premarket",e.PostMarket="postmarket"}(s||(s={}))},81593:(e,t,i)=>{"use strict";i.d(t,{backend:()=>s});const s=i(34840)},48480:()=>{"use strict";TradingView.Pro=function(){this.hasPackage=function(){return!1}},window.user={is_pro:!1,settings:{}},TradingView.Pro.prototype.isPaidPro=function(){return!1},TradingView.Pro.prototype.isSupportAvailable=function(){return!1},TradingView.Pro.prototype.getProduct=function(){return{}},TradingView.Pro.prototype.getStudiesOrder=function(){return[]}},32544:(e,t,i)=>{"use strict";i.d(t,{destroyQuoteSessions:()=>r,getQuoteSessionInstance:()=>n});var s=i(13607);const o={};function n(e="full"){return o[e]||function(e="full",t){o[e]=t}(e,new s(e)),o[e]}function r(){for(const e in o)if(o.hasOwnProperty(e)){const t=o[e];void 0!==t&&t.destroy(),delete o[e]}}},13607:(e,t,i)=>{"use strict";e=i.nmd(e);var s=i(20057).default,o=i(90484).default,n=i(67563).PriceFormatter;const{uniq:r}=i(53470);var a=i(4168);const{normalizeUpdateMode:l}=i(52706);var c=i(39527).deepExtend;const{QUOTE_FIELDS_CACHE:h,QUOTE_FIELDS:d}=i(30947);var u=i(48096).Delegate;const{getNewPeveCloseMode:_}=i(98422),{QuoteSession:p}=i(76220);function m(e,t){this.options=Object.assign({throttleTimeout:125},t),this._connected=!1,this._symbol_data={},this._subscriptions={},this.onConnect=new u,this.onDisconnect=new u,this._quoteApi=new p(window.ChartApiInstance),this._type=e||"full",this._delayUpdateFastSymbols=o(this._updateFastSymbols,250),this._throttledSymbolData={},this._formatterValuesCache={},this._waitingForFormatters={},this._snapshotValuesCache={},this._waitingForSnapshot={},this.connect()}m.prototype.destroy=function(){this._quoteApi.destroy(),this._quoteApi=null,this._connected=!1,this.onDisconnect.fire()},m.prototype.typeFields={},
m.prototype.typeFields.simple=["base-currency-logoid","ch","chp","currency-logoid","currency_code","currency_id","base_currency_id","current_session","description","exchange","format","fractional","is_tradable","language","local_description","listed_exchange","logoid","lp","lp_time","minmov","minmove2","original_name","pricescale","pro_name","short_name","type","typespecs","update_mode","volume","variable_tick_size","value_unit_id","unit_id","measure"],m.prototype.typeFields.simpleDetailed=[].concat(m.prototype.typeFields.simple,["ask","bid","fundamentals","high_price","is_tradable","low_price","open_price","prev_close_price","rch","rchp","rtc","rtc_time","status","basic_eps_net_income","beta_1_year","earnings_per_share_basic_ttm","industry","market_cap_basic","price_earnings_ttm","sector","volume","dividends_yield","timezone"]),m.prototype.typeFields.full=[],m.prototype.typeFields.watchlist=[].concat(m.prototype.typeFields.simple,["rchp","rtc","country_code","provider_id","dividends_availability","financials_availability","earnings_availability"]),m.prototype.typeFields.portfolio=["pro_name","short_name","exchange","listed_exchange","description","local_description","language","sector","type","typespecs","industry","currency_code","currency_id","ch","chp","logoid","currency-logoid","base-currency-logoid","earnings_per_share_forecast_next_fq","earnings_release_next_date","earnings_release_date","earnings_per_share_fq","lp","fractional","minmov","minmove2","pricescale","volume","average_volume","market_cap_calc","market_cap_basic","total_revenue","earnings_per_share_basic_ttm","price_earnings_ttm","beta_1_year","dps_common_stock_prim_issue_fy","dividends_yield","fundamental_currency_code","rates_mc","rates_fy","rates_ttm","format","value_unit_id","unit_id","measure"],m.prototype.typeFields.notes=["short_name","pro_name","logoid","currency-logoid","base-currency-logoid","symbol-primaryname","type","typespecs"],m.prototype.typeFields.estimates=["fundamental_data","type","typespecs","earnings_per_share_forecast_next_symbol_currency_fq","earnings_release_next_aligned_date","earnings_release_next_calendar_date","earnings_release_next_date"],m.prototype.typeFields.economic=["reference-last-period","lp","currency_code","value_unit_id","unit_id","measure"],m.prototype.typeFields.options=["ask","bid","lp","volume"],m.prototype.connect=function(e){this._quoteApi.connect(this.quoteHandler.bind(this))},m.prototype.quoteHandler=function(e){var t=e.method,i=e.params;switch(t){case"connected":this._connected||(this._connected=!0,this.onConnected());break;case"quote_list_fields":break;case"quote_symbol_data":this._connected&&this.onSymbolData(i[0]);break;case"quote_completed":this._connected&&this.onSymbolData({symbolname:i[0],complete:performance.now(),values:{}});break;case"disconnected":this._connected&&(this._connected=!1,this.onDisconnect.fire())}},m.prototype.onConnected=function(){this.setFields();var e=Object.keys(this._symbol_data);e.length&&(this._quoteApi.quoteAddSymbols(e),this._delayUpdateFastSymbols()),
this.onConnect.fire()},m.prototype.setFields=function(){var e=m.prototype.typeFields[this._type];e&&e.length&&this._quoteApi.quoteSetFields(e)},m.prototype.onSymbolData=function(e){try{e.status&&h.update(e,d,!1)}catch(e){}var t=e.symbolname,i=this._throttledSymbolData[t];_()&&(delete e.values.prev_close_price,void 0!==e.values.regular_close&&(e.values.prev_close_price=e.values.regular_close)),i||(i=this._throttledSymbolData[t]={fnDispatch:s(this.dipatchSymbolData.bind(this),this.options.throttleTimeout)}),i.cache?c(i.cache,e):i.cache=e,i.fnDispatch(t)},m.prototype._parseUpdateMode=function(e){l(e)},m.prototype.dipatchSymbolData=function(e){var t=this._symbol_data[e],i=this._throttledSymbolData[e].cache;if(delete this._throttledSymbolData[e].cache,this._symbol_data[e])for(var s in c(t,i),t.values&&this._parseUpdateMode(t.values),this._subscriptions){var o=this._subscriptions[s];o.has(e)&&[...o.get(e)].forEach((function(e){e(t,i)}))}},m.prototype.subscribe=function(e,t,i){this._subscriptions[e]=this._subscriptions[e]||new Map;var s=this._subscriptions[e];t=[].concat(t);var o=[];t.forEach((function(e){this._symbol_data[e]?s&&s.has(e)||this._symbol_data[e].subscribers_count++:(this._symbol_data[e]={subscribers_count:1},o.push(e)),s.has(e)||s.set(e,[]),s.get(e).push(i),s.get(e).fast=!0,this._symbol_data[e]&&this._symbol_data[e].values&&i(this._symbol_data[e],this._symbol_data[e])}),this),o.length&&this._connected&&(this._quoteApi.quoteAddSymbols(o),this._delayUpdateFastSymbols())},m.prototype.unsubscribe=function(e,t,i){t=[].concat(t);for(var s=this._subscriptions[e],o=[],n=0;n<t.length;n++){var r=t[n];if(s)if(s.has(r)&&i){var a=s.get(r).indexOf(i);~a&&s.get(r).splice(a,1),s.get(r).length||s.delete(r)}else s.delete(r);s&&0===s.size&&delete this._subscriptions[e],this._symbol_data.hasOwnProperty(r)&&(s&&!s.has(r)&&this._symbol_data[r].subscribers_count--,this._symbol_data[r].subscribers_count||(delete this._symbol_data[r],o.push(r)))}o.length&&this._connected&&(this._quoteApi.quoteRemoveSymbols(o),this._delayUpdateFastSymbols())},m.prototype.setFastSymbols=function(e,t){if(this._subscriptions[e])for(var i=this._subscriptions[e],s=Array.from(i.keys()),o=0;o<s.length;++o){var n=s[o];i.get(n).fast=-1!==t.indexOf(n)}this._delayUpdateFastSymbols()},m.prototype._updateFastSymbols=function(){if(this._connected){var e=this._fastSymbols();0===e.length?this._quoteApi.quoteHibernateAll():this._quoteApi.quoteFastSymbols(e)}},m.prototype._delayUpdateFastSymbols=m.prototype._updateFastSymbols,m.prototype._fastSymbols=function(){var e=[];for(var t in this._subscriptions)for(var i=this._subscriptions[t],s=Array.from(i.keys()),o=0;o<s.length;++o){var n=s[o];i.get(n).fast&&e.push(n)}return e=r(e)},m.prototype.formatter=function(e,t){var i=this;if(this._waitingForFormatters[e])return this._waitingForFormatters[e];function s(e){var i=t&&!e.fractional?1:e.minmov;return new n({priceScale:e.pricescale,minMove:i,fractional:e.fractional,minMove2:e.minmove2})}var o=new Promise((function(t,o){
if(i._formatterValuesCache[e])t(s(i._formatterValuesCache[e]));else{var n=a.guid();i.subscribe(n,[e],(function(r){"error"===r.status&&(i._waitingForFormatters[e]=null,o("Quotes snapshot is not received")),function(e){return e&&null!=e.pricescale&&null!=e.minmov}(r.values)&&(i._waitingForFormatters[e]=null,i._formatterValuesCache[e]=r.values,t(s(r.values)),i.unsubscribe(n,e))}))}}));return this._waitingForFormatters[e]=o,o},m.prototype.snapshot=function(e){var t=this;if(this._waitingForSnapshot[e])return this._waitingForSnapshot[e];var i=new Promise((function(i,s){if(t._snapshotValuesCache[e])i(t._snapshotValuesCache[e]);else{var o=a.guid();t.subscribe(o,[e],(function(n){"error"===n.status&&(t._waitingForSnapshot[e]=null,s("Quotes snapshot is not received"));var r=n.values;r&&r.minmov&&r.pricescale&&(t._waitingForSnapshot[e]=null,t._snapshotValuesCache[e]=r,i(r),t.unsubscribe(o,e))}))}}));return this._waitingForSnapshot[e]=i,i},window.TradingView=window.TradingView||{},window.TradingView.QuoteSessionMultiplexer=m,e&&e.exports&&(e.exports=m)},12178:(e,t,i)=>{"use strict";i.d(t,{getServerInterval:()=>o});var s=i(46082);function o(e){return s.Interval.isRange(e)?"1":e}},45720:(e,t,i)=>{"use strict";function s(e,t,i){const s=e.get(t);return void 0!==s?s:(e.set(t,i),i)}function o(e,t,i){const s=e.get(t);if(void 0!==s)return s;const o=i();return e.set(t,o),o}function n(e,t,i,n){return o(s(e,t,new Map),i,n)}function r(e,t,i,o,n){const r=s(e,t,new Map),a=s(r,i,new Map);return s(a,o,n)}i.d(t,{AbstractMapContainer:()=>a,getDefault2Lazy:()=>n,getDefault3:()=>r});class a{constructor(){this._map=new Map,this._size=0}size(){return this._size}clear(){this._map.clear(),this._size=0}}},12217:(e,t,i)=>{"use strict";i.d(t,{compareTwoCollectionsByIds:()=>s.compareTwoCollectionsByIds,indexOf:()=>s.indexOf,intersect:()=>s.intersect,join:()=>s.join,lowerbound:()=>s.lowerbound,lowerboundExt:()=>s.lowerboundExt,lowerbound_int:()=>s.lowerbound_int,mapEntriesGenerator:()=>s.mapEntriesGenerator,moveAfter:()=>s.moveAfter,moveBefore:()=>s.moveBefore,moveToHead:()=>s.moveToHead,nestedMapGenerator:()=>s.nestedMapGenerator,removeItemFromArray:()=>s.removeItemFromArray,subtract:()=>s.subtract,sum:()=>s.sum,upperbound:()=>s.upperbound,upperbound_int:()=>s.upperbound_int});var s=i(16879)},69558:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LINESTYLE_DASHED:()=>n,LINESTYLE_DOTTED:()=>o,LINESTYLE_LARGE_DASHED:()=>r,LINESTYLE_SMALL_DASHED:()=>l,LINESTYLE_SOLID:()=>s,LINESTYLE_SPARSE_DOTTED:()=>a});const s=0,o=1,n=2,r=3,a=4,l=5},16659:(e,t,i)=>{"use strict";i.d(t,{CircularCacheBuffer:()=>r});var s,o=i(50151);function n(e){const{prevItem:t,nextItem:i}=e;null!==t&&(t.nextItem=i),null!==i&&(i.prevItem=t)}!function(e){e[e.CapacityFactor=1.3]="CapacityFactor"}(s||(s={}));class r{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&&(n(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){const t=this._cache.get(e);if(void 0===t)return t;if(t===this._firstItem&&(this._firstItem=t.nextItem??t),t!==this._lastItem){n(t);const e=(0,o.ensureNotNull)(this._lastItem);e.nextItem=t,t.prevItem=e,t.nextItem=null,this._lastItem=t}return t.value}clear(){this._cache.clear(),this._firstItem=null,this._lastItem=null}delete(e){const t=this._cache.get(e);return void 0!==t&&(n(t),t===this._lastItem&&(this._lastItem=t.prevItem),t===this._firstItem&&(this._firstItem=t.nextItem)),this._cache.delete(e)}*entries(){if(null!==this._firstItem)for(let e=this._firstItem;null!==e;e=e.nextItem)yield[e.key,e.value]}state(){const e=[];for(const[t,i]of this.entries())e.push([t,i]);return e}restoreState(e){for(const t of e)this.set(t[0],t[1])}_removeExtraItems(){const e=this._cache.size-this._size;let t=(0,o.ensureNotNull)(this._firstItem);for(let i=0;i<e;i+=1)this._cache.delete(t.key),t=(0,o.ensureNotNull)(t.nextItem);t.prevItem=null,this._firstItem=t}}},48943:(e,t,i)=>{"use strict";i.d(t,{accumulate:()=>a,combine:()=>r,combineWithFilteredUpdate:()=>n});var s=i(22613);function o(e,t,...i){let o=null;const n=(...t)=>e(...t.map((e=>e.value())),o?.value()),r=o=new s.WatchedValue(n(...i)),a=()=>{const e=i.map(((e,t)=>e.value()));t(...e)&&r.setValue(n(...i))},l=i.map((e=>e.spawn()));for(const e of l)e.subscribe(a);return r.readonly().spawn((()=>{l.forEach((e=>e.destroy())),i.forEach((e=>e.release()))}))}function n(e,t,...i){return o(e,t,...i)}function r(e,...t){return o(e,(()=>!0),...t)}function a(e,t,...i){let o=null;const n=r(((...e)=>(e.splice(-1),e)),...i),a=t.spawn(),l=(t,...i)=>{const s=t.map((e=>e.value()));return e(s,...i,o?.value())},c=o=new s.WatchedValue(l(a.value(),...n.value()));let h=[];const d=()=>{c.setValue(l(h,...n.value()))},u=e=>{h.forEach((e=>e.destroy())),h=e.map((e=>e.spawn())),h.forEach((e=>e.subscribe(d))),d()};u(a.value()),a.subscribe(u),n.subscribe(d);return c.readonly().spawn((()=>{h.forEach((e=>e.destroy())),a.destroy(),n.destroy(),t.release()}))}},10845:(e,t,i)=>{"use strict";i.d(t,{availableTimezones:()=>l,timezoneIsAvailable:()=>u,timezoneIsSupported:()=>_,timezoneTitle:()=>p,updateAvailableTimezones:()=>d});var s=i(95523),o=i(11542);const n=[{id:"Etc/UTC",get title(){return o.t(null,void 0,i(1833))}},{id:"exchange",get title(){return o.t(null,void 0,i(86905))}}],r=[{id:"Africa/Cairo",get title(){return o.t(null,void 0,i(65736))},offset:0},{id:"Africa/Casablanca",get title(){return o.t(null,void 0,i(70409))},offset:0},{id:"Africa/Johannesburg",get title(){return o.t(null,void 0,i(39585))},offset:0},{id:"Africa/Lagos",get title(){return o.t(null,void 0,i(19931))},offset:0},{id:"Africa/Nairobi",get title(){return o.t(null,void 0,i(40977))},offset:0},{id:"Africa/Tunis",get title(){return o.t(null,void 0,i(21007))},
offset:0},{id:"America/Anchorage",get title(){return o.t(null,void 0,i(42630))},offset:0},{id:"America/Argentina/Buenos_Aires",get title(){return o.t(null,void 0,i(25282))},offset:0},{id:"America/Bogota",get title(){return o.t(null,void 0,i(73905))},offset:0},{id:"America/Caracas",get title(){return o.t(null,void 0,i(30948))},offset:0},{id:"America/Chicago",get title(){return o.t(null,void 0,i(72452))},offset:0},{id:"America/El_Salvador",get title(){return o.t(null,void 0,i(55502))},offset:0},{id:"America/Juneau",get title(){return o.t(null,void 0,i(67560))},offset:0},{id:"America/Lima",get title(){return o.t(null,void 0,i(59444))},offset:0},{id:"America/Los_Angeles",get title(){return o.t(null,void 0,i(28733))},offset:0},{id:"America/Mexico_City",get title(){return o.t(null,void 0,i(73332))},offset:0},{id:"America/New_York",get title(){return o.t(null,void 0,i(40544))},offset:0},{id:"America/Phoenix",get title(){return o.t(null,void 0,i(14055))},offset:0},{id:"America/Santiago",get title(){return o.t(null,void 0,i(30231))},offset:0},{id:"America/Sao_Paulo",get title(){return o.t(null,void 0,i(91912))},offset:0},{id:"America/Toronto",get title(){return o.t(null,void 0,i(10095))},offset:0},{id:"America/Vancouver",get title(){return o.t(null,void 0,i(32838))},offset:0},{id:"US/Mountain",get title(){return o.t(null,void 0,i(27358))},offset:0},{id:"Asia/Almaty",get title(){return o.t(null,void 0,i(98128))},offset:0},{id:"Asia/Ashkhabad",get title(){return o.t(null,void 0,i(63627))},offset:0},{id:"Asia/Bahrain",get title(){return o.t(null,void 0,i(90594))},offset:0},{id:"Asia/Bangkok",get title(){return o.t(null,void 0,i(47045))},offset:0},{id:"Asia/Chongqing",get title(){return o.t(null,void 0,i(50349))},offset:0},{id:"Asia/Colombo",get title(){return o.t(null,void 0,i(10871))},offset:0},{id:"Asia/Dhaka",get title(){return o.t(null,void 0,i(24959))},offset:0},{id:"Asia/Dubai",get title(){return o.t(null,void 0,i(23650))},offset:0},{id:"Asia/Ho_Chi_Minh",get title(){return o.t(null,void 0,i(34491))},offset:0},{id:"Asia/Hong_Kong",get title(){return o.t(null,void 0,i(48861))},offset:0},{id:"Asia/Jakarta",get title(){return o.t(null,void 0,i(14995))},offset:0},{id:"Asia/Jerusalem",get title(){return o.t(null,void 0,i(36057))},offset:0},{id:"Asia/Karachi",get title(){return o.t(null,void 0,i(70913))},offset:0},{id:"Asia/Kabul",get title(){return o.t(null,void 0,i(99563))},offset:0},{id:"Asia/Kathmandu",get title(){return o.t(null,void 0,i(54533))},offset:0},{id:"Asia/Kolkata",get title(){return o.t(null,void 0,i(31561))},offset:0},{id:"Asia/Kuala_Lumpur",get title(){return o.t(null,void 0,i(38561))},offset:0},{id:"Asia/Kuwait",get title(){return o.t(null,void 0,i(76614))},offset:0},{id:"Asia/Manila",get title(){return o.t(null,void 0,i(48991))},offset:0},{id:"Asia/Muscat",get title(){return o.t(null,void 0,i(9865))},offset:0},{id:"Asia/Nicosia",get title(){return o.t(null,void 0,i(94600))},offset:0},{id:"Asia/Qatar",get title(){return o.t(null,void 0,i(28756))},offset:0},{id:"Asia/Riyadh",get title(){
return o.t(null,void 0,i(37974))},offset:0},{id:"Asia/Seoul",get title(){return o.t(null,void 0,i(26820))},offset:0},{id:"Asia/Shanghai",get title(){return o.t(null,void 0,i(1852))},offset:0},{id:"Asia/Singapore",get title(){return o.t(null,void 0,i(77377))},offset:0},{id:"Asia/Taipei",get title(){return o.t(null,void 0,i(11034))},offset:0},{id:"Asia/Tehran",get title(){return o.t(null,void 0,i(6686))},offset:0},{id:"Asia/Tokyo",get title(){return o.t(null,void 0,i(69122))},offset:0},{id:"Asia/Yangon",get title(){return o.t(null,void 0,i(53168))},offset:0},{id:"Atlantic/Azores",get title(){return o.t(null,void 0,i(87580))},offset:0},{id:"Atlantic/Reykjavik",get title(){return o.t(null,void 0,i(13386))},offset:0},{id:"Australia/Adelaide",get title(){return o.t(null,void 0,i(37265))},offset:0},{id:"Australia/Brisbane",get title(){return o.t(null,void 0,i(79336))},offset:0},{id:"Australia/Perth",get title(){return o.t(null,void 0,i(24436))},offset:0},{id:"Australia/Sydney",get title(){return o.t(null,void 0,i(31622))},offset:0},{id:"Europe/Amsterdam",get title(){return o.t(null,void 0,i(36485))},offset:0},{id:"Europe/Athens",get title(){return o.t(null,void 0,i(73702))},offset:0},{id:"Europe/Belgrade",get title(){return o.t(null,void 0,i(71797))},offset:0},{id:"Europe/Berlin",get title(){return o.t(null,void 0,i(64313))},offset:0},{id:"Europe/Bratislava",get title(){return o.t(null,void 0,i(70876))},offset:0},{id:"Europe/Brussels",get title(){return o.t(null,void 0,i(91499))},offset:0},{id:"Europe/Bucharest",get title(){return o.t(null,void 0,i(33672))},offset:0},{id:"Europe/Budapest",get title(){return o.t(null,void 0,i(20313))},offset:0},{id:"Europe/Copenhagen",get title(){return o.t(null,void 0,i(38917))},offset:0},{id:"Europe/Dublin",get title(){return o.t(null,void 0,i(79716))},offset:0},{id:"Europe/Helsinki",get title(){return o.t(null,void 0,i(48203))},offset:0},{id:"Europe/Istanbul",get title(){return o.t(null,void 0,i(78326))},offset:0},{id:"Europe/Lisbon",get title(){return o.t(null,void 0,i(53375))},offset:0},{id:"Europe/London",get title(){return o.t(null,void 0,i(19439))},offset:0},{id:"Europe/Luxembourg",get title(){return o.t(null,void 0,i(81038))},offset:0},{id:"Europe/Madrid",get title(){return o.t(null,void 0,i(52066))},offset:0},{id:"Europe/Malta",get title(){return o.t(null,void 0,i(38365))},offset:0},{id:"Europe/Moscow",get title(){return o.t(null,void 0,i(64039))},offset:0},{id:"Europe/Oslo",get title(){return o.t(null,void 0,i(75722))},offset:0},{id:"Europe/Paris",get title(){return o.t(null,void 0,i(61879))},offset:0},{id:"Europe/Prague",get title(){return o.t(null,void 0,i(81248))},offset:0},{id:"Europe/Riga",get title(){return o.t(null,void 0,i(94022))},offset:0},{id:"Europe/Rome",get title(){return o.t(null,void 0,i(52961))},offset:0},{id:"Europe/Stockholm",get title(){return o.t(null,void 0,i(86716))},offset:0},{id:"Europe/Tallinn",get title(){return o.t(null,void 0,i(79995))},offset:0},{id:"Europe/Vienna",get title(){return o.t(null,void 0,i(23160))},offset:0},{id:"Europe/Vilnius",
get title(){return o.t(null,void 0,i(60534))},offset:0},{id:"Europe/Warsaw",get title(){return o.t(null,void 0,i(5959))},offset:0},{id:"Europe/Zurich",get title(){return o.t(null,void 0,i(62859))},offset:0},{id:"Pacific/Auckland",get title(){return o.t(null,void 0,i(66103))},offset:0},{id:"Pacific/Chatham",get title(){return o.t(null,void 0,i(36549))},offset:0},{id:"Pacific/Fakaofo",get title(){return o.t(null,void 0,i(98549))},offset:0},{id:"Pacific/Honolulu",get title(){return o.t(null,void 0,i(79668))},offset:0},{id:"Pacific/Norfolk",get title(){return o.t(null,void 0,i(67891))},offset:0}];function a(e,t,i){const o=function(e){return e.map((e=>{const{id:t}=e,{string:i,offset:o}=(0,s.parseTzOffset)(t);return{id:t,offset:o,get title(){return`(${i}) ${e.title}`}}}))}(e),n=i.filter((({alias:e})=>Boolean(e))).map((e=>{const{alias:t,id:i}=e,{string:o,offset:n}=(0,s.parseTzOffset)(t);return{id:i,offset:n,get title(){return`(${o}) ${e.title}`},alias:t}})),r=function(e){return e.sort(((e,t)=>{const i=e.offset-t.offset;return 0!==i?i:e.title.localeCompare(t.title)}))}(o.concat(n));return t.concat(r)}const l=a(r,n,[]),c=new Map;l.forEach((e=>{c.set(e.id,!0)}));const h=new Map;n.concat(r).forEach((e=>{h.set(e.id,!0)}));const d=e=>{l.splice(0,l.length,...a(r,n,e)),l.forEach((e=>{c.set(e.id,!0)}))};function u(e){return c.has(e)}function _(e){return h.get(e)||!1}function p(e){for(const{id:t,title:i}of r)if(t===e){return`${i} (${(0,s.parseTzOffset)(e).string})`}for(const{id:t,title:i}of l)if(t===e)return`${i}`;return e}},48096:(e,t,i)=>{"use strict";i.d(t,{Delegate:()=>n});const s=(0,i(9343).getLogger)("Common.Delegate");function o(e){return!e.singleShot}class n{constructor(){this.fire=this._fireImpl.bind(this),this._listeners=[]}subscribe(e,t,i){this._listeners.push({object:e,member:t,singleShot:!!i,skip:!1})}unsubscribe(e,t){for(let i=0;i<this._listeners.length;++i){const s=this._listeners[i];if(s.object===e&&s.member===t){s.skip=!0,this._listeners.splice(i,1);break}}}unsubscribeAll(e){for(let t=this._listeners.length-1;t>=0;--t){const i=this._listeners[t];i.object===e&&(i.skip=!0,this._listeners.splice(t,1))}}destroy(){this._listeners=[]}_fireImpl(...e){const t=this._listeners;this._listeners=this._listeners.filter(o);const i=t.length;for(let o=0;o<i;++o){const i=t[o];if(!i.skip)try{i.member.apply(i.object||null,e)}catch(e){s.logError(`${e&&(e.stack||e.message)}`)}}}}},50605:(e,t,i)=>{"use strict";var s,o;i.d(t,{HorizontalAlign:()=>s,VerticalAlign:()=>o}),function(e){e.Left="left",e.Right="right",e.Center="center"}(s||(s={})),function(e){e.Top="top",e.Bottom="bottom",e.Middle="middle"}(o||(o={}))},55014:(e,t,i)=>{"use strict";i.d(t,{formatStudyError:()=>n,triesTranslateError:()=>o});var s=i(11542);function o(e){return r.get(e)||e}function n(e){return e.format({boldHighlightStart:"<b>",boldHighlightEnd:"</b>"})}
const r=new Map([["You cannot see this pivot timeframe on this resolution",s.t(null,void 0,i(25059))],["The data vendor doesn't provide volume data for this symbol.",s.t(null,void 0,i(81657))],['Histogram is too large, please increase "Row Size" input.',s.t(null,void 0,i(72819))],["Histogram is too large, please reduce 'Row Size' input.",s.t(null,void 0,i(66751))],['Histogram is too large, please increase "Ticks Per Row" input.',s.t(null,void 0,i(94966))],["This script is invite-only. To request access, please contact its author.",s.t(null,void 0,i(76989))],["Volume Profile indicator available only on our upgraded plans.",s.t(null,void 0,i(39903))],["VOLUME_BIST_MIXED",s.t(null,void 0,i(69156))],["Runtime error",s.t(null,void 0,i(60630))],["Access error",s.t(null,void 0,i(77401))],["User-defined error",s.t(null,void 0,i(8580))],["Compilation error",s.t(null,void 0,i(12086))],["Metric error",s.t(null,void 0,i(83111))],["There's no data for your selected period and chart timeframe.",s.t(null,void 0,i(43716))],["The request took too long to process. Ensure you have a stable internet connection. If the issue persists, try decreasing the length of the requested time interval.",s.t(null,void 0,i(99274))],["Unexpected error in Deep Backtesting mode. Contact support for more information.",s.t(null,void 0,i(56815))],["check study unexpected error",s.t(null,void 0,i(83524))],["To calculate the VWAP indicator, more data is needed. Zoom out or scroll left to load more historical data.",s.t(null,void 0,i(41446))],["VWAP is waiting for more data",s.t(null,void 0,i(81030))],["The Bar Magnifier feature is only available to Premium users",s.t(null,void 0,i(45328))],["The bar magnifier is only available to the Premium plan or higher.",s.t(null,void 0,i(35601))]])},64971:(e,t,i)=>{"use strict";i.d(t,{getImage:()=>n});const s=new Map;function o(e){e.crossOrigin="anonymous"}function n(e,t,i=o){let n=s.get(e);return void 0===n&&(n=new Promise(((e,s)=>{const o=new Image;o.onload=()=>{e(o),o.onload=null,o.onerror=null},o.onerror=()=>{s(),o.onload=null,o.onerror=null},i(o),o.src=t})),s.set(e,n)),n}},38486:(e,t,i)=>{"use strict";function s(e){const t=Object.create(e);return t.release=()=>{},t.ownership=()=>t,t}function o(e){const t=e;return t.release=()=>t.destroy(),t.ownership=()=>t,t}i.d(t,{ownership:()=>o,weakReference:()=>s})},95523:(e,t,i)=>{"use strict";i.d(t,{parseTzOffset:()=>o});var s=i(37236);function o(e,t=Date.now()){const i=(0,s.get_timezone)(e).offset_utc(t);let o="";const n=i/1e3/60/60;n%1&&(o=":"+Math.round(Math.abs(n%1*60)).toString().padStart(2,"0"));let r="";return r=n>0?"+"+(n-n%1)+o:0===n?"":String(n-n%1+o),{offset:i,string:"UTC"+r}}},4148:(e,t,i)=>{"use strict";i.d(t,{clone:()=>s.clone,isNumber:()=>s.isNumber,isObject:()=>s.isObject});var s=i(87465)},59149:e=>{"use strict";var t=[{d:"E-Mini S&P 500",t:"ES"},{d:"E-Mini Nasdaq 100",t:"NQ"},{d:"Gold",t:"GC"},{d:"Silver",t:"SI"},{d:"Crude Oil WTI",t:"CL"},{d:"Natural Gas",t:"NG"},{d:"Australian Dollar",t:"6A"},{d:"Australian Dollar (Floor)",t:"AD"},{d:"Euro FX",t:"6E"},{
d:"Euro FX (Floor)",t:"EC"},{d:"Corn",t:"ZC"},{d:"Corn (Floor)",t:"C"},{d:"Eurodollar",t:"GE"},{d:"Eurodollar (Floor)",t:"ED"}],i=function(){var e=[{pattern:"(",ctor:n},{pattern:")",ctor:r},{pattern:"+",ctor:l},{pattern:"-",ctor:c},{pattern:"*",ctor:h},{pattern:"/",ctor:d},{pattern:"^",ctor:u},{pattern:/\d+(?:\.\d*|(?![a-zA-Z0-9_!:.&]))|\.\d+/,ctor:g},{pattern:/\./,ctor:v},{pattern:/[a-zA-Z0-9_\u0370-\u1FFF_\u2E80-\uFFFF^][a-zA-Z0-9_\u0020\u0370-\u1FFF_\u2E80-\uFFFF_!:.&]*|'.+?'/,ctor:m},{pattern:/'[^']*/,ctor:y},{pattern:/[\0-\x20\s]+/,ctor:o}];function i(e,t){var i=function(){};return i.prototype=t.prototype,e.prototype=new i,e}function s(){}function o(e){this.value=e}function n(){}function r(){}function a(){}function l(){}function c(){}function h(){}function d(){}function u(){}s.prototype.toString=function(){return this.value},i(o,s),i(n,s),n.prototype.value="(",i(r,s),r.prototype.value=")",i(a,s),i(l,a),l.prototype.value="+",l.prototype.precedence=0,l.prototype.commutative=!0,i(c,a),c.prototype.value="-",c.prototype.precedence=0,c.prototype.commutative=!1,i(h,a),h.prototype.value="*",h.prototype.precedence=1,h.prototype.commutative=!0,i(d,a),d.prototype.value="/",d.prototype.precedence=1,d.prototype.commutative=!1,i(u,a),u.prototype.value="^",u.prototype.precedence=2,u.prototype.commutative=!1;var _=/^'?(?:([A-Z0-9_]+):)?(.*?)'?$/i,p=/[+\-/*]/;function m(e){this.value=e}function g(e){this.value=e}function f(e){this.value=e}function y(){m.apply(this,arguments)}function v(){g.apply(this,arguments)}i(m,s),m.prototype.toString=function(){if(this.hasOwnProperty("_ticker")){var e=p.test(this._ticker)?"'":"";return e+(this._exchange?this._exchange+":":"")+this._ticker+e}return this.value},m.prototype.parse=function(){var e=_.exec(this.value);e[1]&&(this._exchange=e[1]),this._ticker=e[2]},m.prototype.parseAsFutures=function(){this.hasOwnProperty("_ticker")||this.parse();for(var e=function(e){return t.some((function(t){return t.t===e}))},i=2;i>=1;--i){var s=this._ticker.slice(0,i);if(e(s)){this._root=s,this._contract=this._ticker.slice(i);break}}},m.prototype.exchange=function(e){if(this.hasOwnProperty("_ticker")||this.parse(),!(arguments.length>0))return this._exchange;null==e?delete this._exchange:this._exchange=e+""},m.prototype.ticker=function(e){if(this.hasOwnProperty("_ticker")||this.parse(),!(arguments.length>0))return this._ticker;null==e?delete this._ticker:this._ticker=e+"",delete this._root,delete this._contract},m.prototype.root=function(e){if(this.hasOwnProperty("_root")||this.parseAsFutures(),!(arguments.length>0))return this._root;null==e?delete this._root:(this._root=e+"",this._root&&(this._ticker=this._root+(this._contract||"")))},m.prototype.contract=function(e){if(this.hasOwnProperty("_contract")||this.parseAsFutures(),!(arguments.length>0))return this._root;null==e?delete this._contract:(this._contract=e+"",this._root&&(this._ticker=this._root+this._contract))},i(g,s),g.prototype.toString=function(){return this.hasOwnProperty("_normalizedValue")?this._normalizedValue:this.value},
g.prototype.parse=function(){this._normalizedValue=this.value.replace(/^0+|\.0*$/g,"").replace(/(\.\d*?)0+$/,"$1").replace(/^(\.|$)/,"0$1")},f.prototype.toString=function(){return this.value},i(y,m),y.prototype.isIncomplete=!0,y.prototype.incompleteSuggest=function(){if("'"!==this.value)return String("'")},i(v,g),v.prototype.isIncomplete=!0;var S=new RegExp(e.map((function(e){return"("+("string"==typeof e.pattern?e.pattern.replace(/[\^$()[\]{}*+?|\\]/g,"\\$&"):e.pattern.source)+")"})).concat(".").join("|"),"g");function b(t,i){var s,n=[];e:for(;s=S.exec(t);){for(var r=e.length;r--;)if(s[r+1]){if(e[r].ctor){var a=new e[r].ctor(s[r+1]);a._offset=s.index,n.push(a)}continue e}var l=new f(s[0]);l._offset=s.index,n.push(l)}if(i&&i.recover){var c;for(r=n.length;r--;){var h=n[r];if(h instanceof g||h instanceof m){if(void 0!==c){var d=new m(""),u=n.splice(r,c-r+1,d);d.value=u.map((function(e){return e.value})).join("")}c=r}else h instanceof o||(c=void 0)}}return n}function w(e){for(var t=[],i=0;i<e.length;i++)e[i]instanceof o||t.push(e[i]);return t}function C(e){e=w(e);for(var t,i=[],s=[],o=0;o<e.length;o++){var l=e[o];if(l instanceof a)s.length&&s[s.length-1].minPrecedence>l.precedence&&(s[s.length-1].minPrecedence=l.precedence);else if(l instanceof n)s.push(t={minPrecedence:1/0,openBraceIndex:o});else if(l instanceof r){var c=e[(t=s.pop()).openBraceIndex-1],h=e[o+1];h instanceof a&&!(h.precedence<=t.minPrecedence)||!(!(c instanceof a)||c.precedence<t.minPrecedence||c.precedence===t.minPrecedence&&c.commutative)||(i.unshift(t.openBraceIndex),i.push(o),s.length&&s[s.length-1].minPrecedence>t.minPrecedence&&(s[s.length-1].minPrecedence=t.minPrecedence))}}for(o=i.length;o--;)e.splice(i[o],1);return e}function T(e){if("string"!=typeof e)throw new TypeError("expression must be a string");return(e=b(e)).filter((function(e){return e instanceof m})).map((function(e){return e.exchange()})).filter((function(e){return e}))}function P(e){return 1!==(e=T(e)).length?null:e[0]}function x(e,t){return(e=T(e)).some((function(e){return t.includes((e||"").toUpperCase())}))}function M(e){return e.join("")}return{tokenize:b,validate:function(e){return{currentState:"var"}},factorOutBraces:C,normalizeTokens:function(e){for(var t=0;t<e.length;t++)e[t].parse&&e[t].parse();return e},flip:function(e){var t=function(e){for(var t,i=0,s=1,l=2,c=3,h=i,u=0,_=0;_<e.length;_++){var p=e[_];if(!(p instanceof o))switch(h){case i:if(!(p instanceof g&&1==+p.value))return!1;h=s;break;case s:if(!(h===s&&p instanceof d))return!1;h=l,t=_+1;break;case l:if(p instanceof n)h=c,u=1;else if(p instanceof a)return!1;break;case c:p instanceof n?u++:p instanceof r&&--u<=0&&(h=l)}}return e.slice(t)}(e);return C(t||[new g("1"),new d,new n].concat(e).concat(new r))},hasBatsSymbols:function(e){return x(e,["BATS"])},hasEodSymbols:function(e){return(e=P(e))&&-1!==e.toUpperCase().indexOf("_EOD")},hasChxjpySymbols:function(e){return x(e,["CHXJPY"])},hasFreeDelaySymbols:function(e){return x(e,pro.getProductsByType(pro.PRODUCT_TYPES.exchange).map((function(e){
return e.exchange.toUpperCase()+"_DLY"})))},getExchange:P,getExchanges:T,isExchange:function(e,t){return!!(e=P(e))&&e.substring(0,t.length)===t},SymbolToken:m,IncompleteSymbolToken:y,NumberToken:g,BinaryOperatorToken:a,OpenBraceToken:n,CloseBraceToken:r,ticker:function(e){return new m(e).ticker()},shortName:function(e){if("string"!=typeof e)throw new TypeError("expression must be a string");var t=C(w(b(e)));return t.forEach((function(e){e instanceof m&&e.exchange(null)})),M(t)},normalize:function(e){if("string"!=typeof e)throw new TypeError("expression must be a string");return M(C(w(b(e))))}}}();e.exports=i},95804:(e,t,i)=>{"use strict";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 o of Object.keys(e)){const n=e[o];n instanceof s?(t[o]=n.originalText(),i[o]=n.translatedText()):(t[o]=n.toString(),i[o]=n.toString())}const o=this._originalText.format(t),n=this._translatedText.format(i);return new s(o,n)}}},9787:(e,t,i)=>{"use strict";i.d(t,{Version:()=>o});var s=i(50151);class o{constructor(e,t){this._major=e,this._minor=t}major(){return this._major}minor(){return this._minor}isZero(){return 0===this._major&&0===this._minor}toString(){return this._major+"."+this._minor}compareTo(e){return this._major<e._major?-1:this._major>e._major?1:this._minor<e._minor?-1:this._minor>e._minor?1:0}isLess(e){return this.compareTo(e)<0}isLessOrEqual(e){return this.compareTo(e)<=0}isEqual(e){return 0===this.compareTo(e)}isGreater(e){return this.compareTo(e)>0}isGreaterOrEqual(e){return this.compareTo(e)>=0}static parse(e){if(e instanceof o)return new o(e.major(),e.minor());if("number"==typeof e)return(0,s.assert)(Math.floor(e)===e,"Version should not be a float number"),new o(e,0);if("string"==typeof e){const t=e.split(".");if(1===t.length){const i=parseInt(t[0],10);return(0,s.assert)(!isNaN(i),"Bad version string: "+e),new o(i,0)}if(2===t.length){const i=parseInt(t[0],10);(0,s.assert)(!isNaN(i),"Bad version string: "+e);const n=parseInt(t[1],10);return(0,s.assert)(!isNaN(n),"Bad version string: "+e),new o(i,n)}throw new Error("Bad version string (one dot expected): "+e)}throw new Error("Bad version: "+e)}}o.ZERO=new o(0,0)},22613:(e,t,i)=>{"use strict";i.d(t,{WatchedValue:()=>s.WatchedValue});var s=i(52499)},62773:(e,t,i)=>{"use strict";i.d(t,{WatchedObject:()=>s.WatchedObject});var s=i(52499)},99247:(e,t,i)=>{"use strict";i.d(t,{MouseClickAutoBlurHandler:()=>r,initMouseClickAutoBlurHandler:()=>a});var s=i(81251),o=i(76460);const n="data-mouse-click-auto-blur";class r{constructor(){this._handler=e=>{document.activeElement instanceof HTMLElement&&((0,o.isKeyboardClick)(e)||e.target instanceof Element&&"INPUT"!==document.activeElement.tagName&&null!==document.activeElement.closest(`[${n}]`)&&document.activeElement.blur())},window.addEventListener("click",this._handler,!0)}static attributes(e=!0){return e?{[n]:!0}:{}}}const a=(0,s.default)((()=>new r))},
22692:(e,t,i)=>{"use strict";i.d(t,{mapKeyCodeToDirection:()=>h,navigationOrderComparator:()=>r,queryFocusableElements:()=>l,queryTabbableElements:()=>a,updateTabIndexes:()=>c});var s,o=i(24640),n=i(15754);function r(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function a(e){return Array.from(e.querySelectorAll('button:not([disabled]):not([aria-disabled]):not([tabindex="-1"]), [tabindex]:not([disabled]):not([aria-disabled]):not([tabindex="-1"])')).filter((0,n.createScopedVisibleElementFilter)(e))}function l(e){return Array.from(e.querySelectorAll('button:not([disabled]):not([aria-disabled="true"]):not([aria-disabled=""]), [tabindex]:not([disabled]):not([aria-disabled="true"]):not([aria-disabled=""])')).filter((0,n.createScopedVisibleElementFilter)(e))}function c(){window.dispatchEvent(new CustomEvent("keyboard-navigation-activation",{bubbles:!0}))}function h(e){const t=(0,o.isRtl)();switch(e){case 38:return"blockPrev";case 40:return"blockNext";case 37:return t?"inlineNext":"inlinePrev";case 39:return t?"inlinePrev":"inlineNext";default:return null}}!function(e){e.BlockPrev="blockPrev",e.BlockNext="blockNext",e.InlinePrev="inlinePrev",e.InlineNext="inlineNext"}(s||(s={}))},66593:(e,t,i)=>{"use strict";i.d(t,{TOOLBAR_WIDTH_COLLAPSED:()=>o,TOOLBAR_WIDTH_EXPANDED:()=>s});const s=52,o=5},55308:(e,t,i)=>{"use strict";i.d(t,{isDrawingToolbarVisible:()=>l});var s=i(1765),o=i(37103),n=i(22613);const r=!o.enabled("hide_left_toolbar_by_default"),a=s.getBool("ChartDrawingToolbarWidget.visible",r),l=new n.WatchedValue(a)},9753:(e,t,i)=>{"use strict";i.d(t,{HEADER_TOOLBAR_HEIGHT_COLLAPSED:()=>n,HEADER_TOOLBAR_HEIGHT_EXPANDED:()=>o});var s=i(41183);const o=parseInt(s["css-value-header-toolbar-height"]),n=3},23745:(e,t,i)=>{"use strict";i.d(t,{shouldShowQuickSearchOnLib:()=>r});var s=i(49483),o=i(84015),n=i(37103);function r(){return!s.CheckMobile.any()&&!(0,o.isOnMobileAppPage)("any")&&!n.enabled("widget")&&n.enabled("header_quick_search")}},14429:(e,t,i)=>{"use strict";i.d(t,{ActionWithStandardIcon:()=>n});var s=i(41706),o=i(84696);class n extends s.Action{constructor(e){const{options:t,customActionOptions:i}=e;t.iconId&&(t.icon=t.icon??o.icons.get(t.iconId)),i&&i.iconId&&(i.icon=i.icon??o.icons.get(i.iconId)),super(e)}}},41706:(e,t,i)=>{"use strict";i.d(t,{Action:()=>c,Separator:()=>h});var s,o=i(50151),n=i(68335),r=i(4226),a=i(48096);class l extends a.Delegate{constructor(e){super(),this._onStartListening=null,this._onStopListening=null,this._onStartListening=e||null}subscribe(e,t,i){const s=0===this._listeners.length;super.subscribe(e,t,i),s&&this._listeners.length>0&&this._onStartListening&&(this._onStopListening=this._onStartListening())}unsubscribe(e,t){const i=0===this._listeners.length;super.unsubscribe(e,t),!i&&0===this._listeners.length&&this._onStopListening&&(this._onStopListening(),this._onStopListening=null)}unsubscribeAll(e){const t=0===this._listeners.length;super.unsubscribeAll(e),!t&&0===this._listeners.length&&this._onStopListening&&(this._onStopListening(),
this._onStopListening=null)}destroy(){this._onStopListening&&(this._onStopListening(),this._onStopListening=null),super.destroy()}}!function(e){e.Normal="normal",e.Big="big"}(s||(s={}));class c{constructor(e){this.type="action",this._destroyed=!1,this._loadOptionsPromise=null,this._customAction=null;const{actionId:t,options:i,optionsLoader:s,customActionOptions:n,customActionOptionsLoader:a,id:h=r.guid(),onStartListening:d}=e;(0,o.assert)(void 0!==t,"actionId must be defined"),this.id=h,this._onUpdate=new l(d),this._options={actionId:t,...i},this.update(i),this._loadOptionsGetter=s??null,this._loadOptionsGetter&&(this._options.loading=!0),n&&(this._customAction=new c({actionId:t,options:n,optionsLoader:a,id:h}))}custom(){return this._customAction}execute(){this._options.checkable&&this.update({checked:!this._options.checked}),this._options.onExecute&&this._options.onExecute(this)}getLabel(){return this._options.label||""}getSubItems(){return this._options.subItems||[]}isDisabled(){return!0===this._options.disabled}isActive(){return!0===this._options.active}isCheckable(){return!0===this._options.checkable}isChecked(){return!0===this._options.checked}isLoading(){return!0===this._options.loading}loadOptions(){return this._loadOptionsPromise?this._loadOptionsPromise:this._loadOptionsGetter?(this._loadOptionsPromise=this._loadOptionsGetter().then((e=>this.update({...e,loading:!1}))),this._loadOptionsPromise):null}getSize(){return this._options.size??"normal"}getPayload(){return this._options.payload}update(e){this._destroyed||(this._unbindShortcut(),e.hotkeyHash&&(this._options.shortcutHint=(0,n.humanReadableHash)(e.hotkeyHash)),this._options=Object.assign(this._options,e),this._bindShortcut(),this._onUpdate.fire(this))}onUpdate(){return this._onUpdate}getState(){return this.loadOptions(),{actionId:this._options.actionId,label:this.getLabel(),styledLabel:this._options.styledLabel,disabled:this.isDisabled(),active:this.isActive(),subItems:this.getSubItems(),checkable:this.isCheckable(),checked:this.isChecked(),loading:this.isLoading(),size:this.getSize(),doNotCloseOnClick:this._options.doNotCloseOnClick||!1,shortcutHint:this._options.shortcutHint,hint:this._options.hint,icon:this._options.icon,iconId:this._options.iconId,iconChecked:this._options.iconChecked,toolbox:this._options.toolbox,showToolboxOnHover:this._options.showToolboxOnHover||!1,statName:this._options.statName,name:this._options.name,invisibleHotkey:this._options.invisibleHotkey,noInteractive:this._options.noInteractive,jsxLabel:"jsxLabel"in this._options?this._options.jsxLabel:void 0,isRepeatAccepted:this._options.isRepeatAccepted}}destroy(){this._destroyed=!0,this._onUpdate.destroy(),this._unbindShortcut(),this._options.onDestroy?.(),this._customAction?.destroy()}options(){return this._options}_bindShortcut(){if(!this._options.hotkeyGroup||!this._options.hotkeyHash)return;const e="string"==typeof this._options.label?this._options.label:this._options.name;this._hotkeyAction=this._options.hotkeyGroup.add({hotkey:this._options.hotkeyHash,
isRepeatAccepted:this._options.isRepeatAccepted,desc:e,handler:()=>this.execute(),isDisabled:()=>this.isDisabled()})}_unbindShortcut(){this._hotkeyAction&&(this._hotkeyAction.destroy(),delete this._hotkeyAction)}}class h{constructor(e){this.type="separator",this.id=r.guid(),this._hint=e}getHint(){return this._hint}}},84696:(e,t,i)=>{"use strict";i.d(t,{icons:()=>w});var s,o=i(53573),n=i(34369),r=i(39267),a=i(93544),l=i(84959),c=i(34487),h=i(11890),d=i(16911),u=i(25191),_=i(54190),p=i(6862),m=i(97874),g=i(2872),f=i(29453),y=i(94839),v=i(5845),S=i(1457),b=i(93379);!function(e){e.ChartShowDataWindow="Chart.ShowDataWindow",e.ChartReset="Chart.Reset",e.ChartRemoveSelectedObject="Chart.RemoveSelectedObject",e.Settings="Settings",e.ChartHide="Chart.Hide",e.ChartSymbolInfo="Chart.SymbolInfo",e.ChartFinancials="Chart.Financials",e.ChartTechnicals="Chart.Technicals",e.ChartDetailsMetrics="Chart.DetailsMetrics",e.ChartSeasonals="Chart.Seasonals",e.ChartAnalysis="Chart.Analysis",e.ChartStockBonds="Chart.StockBonds",e.ChartForecast="Chart.Forecast",e.ChartOptions="Chart.Options",e.ChartEconomyIdicators="Chart.EconomyIndicators",e.AlertAdd="Alert.Add",e.AlertEdit="Alert.Edit",e.AlertRestart="Alert.Restart",e.AlertStop="Alert.Stop",e.AlertFiresDownload="Alert.FiresDownload",e.ClearAll="Alert.Clear",e.ChartVisualOrder="Chart.VisualOrder",e.ChartShowObject="Chart.ShowObject",e.ChartPriceScale="Chart.PriceScale",e.ChartMove="Chart.Move",e.ChartApplyIndicator="Chart.ApplyIndicator",e.ChartUnlockObject="Chart.UnlockObject",e.ChartLockObject="Chart.LockObject",e.ChartAnchorLineTool="Chart.AnchorLineTool",e.ChartInsertRowTable="Chart.InsertRowTable",e.ChartInsertColumnTable="Chart.InsertColumnTable",e.ChartRemoveRowTable="Chart.RemoveRowTable",e.ChartRemoveColumnTable="Chart.RemoveColumnTable",e.ChartClone="Chart.Clone",e.ChartAddHorzLine="Chart.AddHorzLine",e.WatchlistAddSymbol="Watchlist.AddSymbol",e.WatchlistCreateNew="Watchlist.CreateNew",e.TextNoteAdd="TextNote.Add",e.TradingSell="Trading.Sell",e.TradingBuy="Trading.Buy",e.TradingAddOrder="Trading.AddOrder",e.ObjectsTreeCreateGroup="ObjectsTree.CreateGroup",e.ObjectsTreeRenameItem="ObjectsTree.RenameItem",e.IndicatorAddToFavorites="Indicator.AddToFavorites"}(s||(s={}));const w=new Map([["Chart.Reset",r],["Chart.RemoveSelectedObject",a],["Settings",n],["Chart.Hide",l],["Chart.SymbolInfo",c],["Chart.VisualOrder",h],["Chart.ShowObject",d],["Chart.PriceScale",u],["Chart.Move",_],["Chart.ApplyIndicator",p],["Chart.UnlockObject",m],["Chart.LockObject",g],["Chart.AnchorLineTool",f],["Chart.InsertRowTable",y],["Chart.InsertColumnTable",v],["Chart.RemoveRowTable",a],["Chart.RemoveColumnTable",a],["Chart.Clone",S],["Chart.AddHorzLine",b],["Indicator.AddToFavorites",o]])},31932:(e,t,i)=>{"use strict";function s(){return Promise.all([i.e(3462),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(6602)]).then(i.bind(i,95616))}i.d(t,{actionsProviderModule:()=>s})},72104:(e,t,i)=>{"use strict";i.d(t,{defaultChartWidgetActionsOptions:()=>s});const s={general:!0,mainSeries:!0,mainSeriesTrade:!1,esdStudies:!0,
studies:!0,fundamentals:!0,lineTools:!0,publishedCharts:!0,ordersAndPositions:!0,alerts:!0,chartEvents:!0,objectTree:!0,gotoLineTool:!1};var o;!function(e){e.Copy="Copy"}(o||(o={}))},92848:(e,t,i)=>{"use strict";i.d(t,{clipboardDataForSources:()=>l,isLineToolClipboardData:()=>a});var s=i(50151),o=i(36313),n=i(2088),r=i(26610);function a(e){return"drawing"===e.type}function l(e,t){if(1===t.length&&(0,n.isStudy)(t[0])){const e=t[0];return{title:e.title(o.TitleDisplayTarget.StatusLine),sources:[{source:(0,s.ensureNotNull)(e.state()),type:"study"}]}}const i={sources:[],title:""};return i.sources=t.filter((e=>e.copiable()&&(0,r.isLineTool)(e))).map((t=>{const i={type:"drawing",geometry:t.geometry(),source:{...t.state(!1),points:t.normalizedPoints()},modelId:e};return delete i.source.alertId,i})),i.sources.length>0?(1===i.sources.length?i.title=t[0].title(o.TitleDisplayTarget.StatusLine):i.title="Drawings",i):null}},33350:(e,t,i)=>{"use strict";i.d(t,{addExclusionArea:()=>T,addExclusionAreaByScope:()=>C,calcTextHorizontalShift:()=>b,clearRect:()=>p,createBoundCanvas:()=>v,createDisconnectedCanvas:()=>g,createDisconnectedCanvasByRenderingInfo:()=>f,disableSelection:()=>w,drawScaled:()=>m,drawWithExclusionAreaByScope:()=>P,fillRect:()=>_,getBindingRenderingInfo:()=>h,getContext2D:()=>d,getPrescaledContext2D:()=>u,measureText:()=>M,tryApplySuggestedCanvasBitmapSize:()=>S});var s=i(27714),o=i(50151),n=i(59239),r=i(57658),a=i(24640),l=i(49483);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 h(e){return{...c(e),bitmapSize:e.bitmapSize,mediaSize:e.canvasElementClientSize}}function d(e){const t=(0,o.ensureNotNull)(e.getContext("2d"));return t.setTransform(1,0,0,1,0,0),t}function u(e){const t=(0,o.ensureNotNull)(e.getContext("2d")),i=(0,n.getCanvasDevicePixelRatio)(e);return t.setTransform(i,0,0,i,0,0),t}function _(e,t,i,s,o,n){e.save(),e.fillStyle=n,e.fillRect(t,i,s,o),e.restore()}function p(e,t,i,s,o,n){e.save(),e.globalCompositeOperation="copy",e.fillStyle=n,e.fillRect(t,i,s,o),e.restore()}function m(e,t,i,s){e.save(),e.scale(t,i),s(),e.restore()}function g(e,t,i){const s=y(e);return void 0===i&&(i=(0,n.getCanvasDevicePixelRatio)(s)),s.width=t.width*i,s.height=t.height*i,s}function f(e,t){const{bitmapSize:i,mediaSize:s}=t,o=y(e);return o.style.width=`${s.width}px`,o.style.height=`${s.height}px`,o.width=i.width,o.height=i.height,o}function y(e){const t=e.createElement("canvas");return w(t),t}function v(e,t){const i=y((0,o.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 S(e){const t=e.suggestedBitmapSize;return null!==t&&t.width>0&&t.height>0&&(e.applySuggestedBitmapSize(),!0)}function b(e,t){return"center"===e.textAlign?0:(0,
a.isRtl)()?"start"===e.textAlign||"right"===e.textAlign?t:0:"start"===e.textAlign||"left"===e.textAlign?0:t}function w(e){e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.msUserSelect="none",e.style.MozUserSelect="none",e.style.webkitTapHighlightColor="transparent"}function C(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o,bitmapSize:n}=e;i.beginPath(),i.rect(0,0,n.width,n.height);for(let e=0;e<t.length;e++){let{x:n,y:r}=t[e];n*=s,r*=o,0!==e?i.lineTo(n,r):i.moveTo(n,r)}i.closePath(),i.clip("evenodd")}function T(e,t,i){C({context:e,...t},i)}function P(e,t,i){e.context.save(),C(e,t),i(),e.context.restore()}let x;function M(e,t,i){return x||function(){const e=document.createElement("canvas");e.width=0,e.height=0,(0,l.isMac)()&&(e.style.display="none",document.body.append(e)),x=(0,o.ensureNotNull)(e.getContext("2d")),x.textBaseline="alphabetic",x.textAlign="center"}(),t&&x.font!==t&&(x.font=t),i?i.getMetrics(x,e):(0,r.getMinTextMetrics)(x.measureText(e))}},14411:(e,t,i)=>{"use strict";i.d(t,{ChartChangesWatcher:()=>a,changedAll:()=>r});var s,o=i(67455),n=i(48096);!function(e){e[e.NothingChanged=0]="NothingChanged",e[e.ContentChanged=1]="ContentChanged",e[e.LineToolsChanged=2]="LineToolsChanged"}(s||(s={}));const r=3;class a{constructor(e,t,i){this._undoHistoryHasChanges=!1,this._changesMask=0,this._handleLayoutNameChanged=()=>{this._changesMask=1|this._changesMask},this._recalculateHaveChanges=()=>{const e=this._changesMask,t=this._undoHistoryHasChanges?1:0,i=this._lineToolsHaveChanges.value()?2:0;this._changesMask=t|i,e!==this._changesMask&&this._onValueChanged.fire(0!==this._changesMask)},this._chartWidgetCollection=e,this._undoHistory=e.undoHistory,this._lineToolsHaveChanges=e.lineToolsSynchronizerHasChanges,this._chartSaver=t,this._globalEvents=i,this._onValueChanged=new n.Delegate,this._hasChangesWV=(0,o.createWVFromGetterAndSubscription)((()=>this.hasChanges()),this.getOnChange()),this._subscribe()}destroy(){this._unsubscribe(),this._onValueChanged.destroy(),this._hasChangesWV.destroy()}changes(){return this._changesMask}hasChanges(){return this._changesMask>0}hasChangesWV(){return this._hasChangesWV}getOnChange(){return this._onValueChanged}_subscribe(){this._globalEvents.subscribe("chart_loaded",this._handleChartLoaded,this),this._globalEvents.subscribe("layout_loaded",this._handleLayoutLoaded,this),this._globalEvents.subscribe("chart_migrated",this._handleChartMigrated,this),this._globalEvents.subscribe("lineToolsResavedFromContent",this._handleChartMigrated,this),this._undoHistory.undoStack().onChange().subscribe(this,this._handleUndoHistoryChange),this._chartSaver?.chartSaved().subscribe(this,this._handleChartSaved),this._lineToolsHaveChanges.subscribe(this._recalculateHaveChanges);this._chartWidgetCollection.metaInfo.name.subscribe(this._handleLayoutNameChanged)}_unsubscribe(){this._globalEvents.unsubscribe("chart_loaded",this._handleChartLoaded,this),this._globalEvents.unsubscribe("layout_loaded",this._handleLayoutLoaded,this),
this._globalEvents.unsubscribe("chart_migrated",this._handleChartMigrated,this),this._globalEvents.unsubscribe("lineToolsResavedFromContent",this._handleChartMigrated,this),this._undoHistory.undoStack().onChange().unsubscribe(this,this._handleUndoHistoryChange),this._chartSaver?.chartSaved().unsubscribe(this,this._handleChartSaved),this._lineToolsHaveChanges.unsubscribe(this._recalculateHaveChanges);this._chartWidgetCollection.metaInfo.name.unsubscribe(this._handleLayoutNameChanged)}_setUndoHistoryHasChanges(e){this._undoHistoryHasChanges=e,this._recalculateHaveChanges()}_handleChartLoaded(){this._setUndoHistoryHasChanges(!1)}_handleLayoutLoaded(){this._setUndoHistoryHasChanges(!1)}_handleUndoHistoryChange(e){e?.affectsState()&&this._setUndoHistoryHasChanges(!0)}_handleChartMigrated(){this._setUndoHistoryHasChanges(!0)}_handleChartSaved(e){e&&this._setUndoHistoryHasChanges(!1)}}},57340:(e,t,i)=>{"use strict";i.d(t,{chartFloatingTooltipEnabledWV:()=>a});var s=i(1765),o=i(22613);const n="chart_floating_tooltip_enabled";function r(){return s.getJSON(n,true)}const a=new o.WatchedValue(r());a.subscribe((()=>s.setValue(n,a.value()))),s.onSync.subscribe(null,(()=>a.setValue(r())))},75579:(e,t,i)=>{"use strict";i.d(t,{ChartHotkeysListener:()=>g,globalEnvironmentState:()=>m,modifierPressed:()=>p,shiftPressed:()=>_});var s=i(26709),o=i(68335),n=i(35749),r=i(26610);var a=i(22613),l=i(93946);const c=new a.WatchedValue(Boolean((s.pressedKeys.value()??0)&o.Modifiers.Shift)),h=new a.WatchedValue(Boolean((s.pressedKeys.value()??0)&o.Modifiers.Mod)),d=new a.WatchedValue(Boolean((s.pressedKeys.value()??0)&o.Modifiers.Alt)),u=[o.Modifiers.None,o.Modifiers.Alt,o.Modifiers.Mod,o.Modifiers.Alt+o.Modifiers.Shift];function _(){return c}function p(){return h}function m(){return new l.EnvironmentState({altKey:d.value(),ctrlKey:p().value(),metaKey:p().value(),shiftKey:_().value()})}s.pressedKeys.subscribe(((e=0)=>{c.setValue(Boolean(e&o.Modifiers.Shift)),h.setValue(Boolean(e&o.Modifiers.Mod)),d.setValue(Boolean(e&o.Modifiers.Alt))}));class g{constructor(e,t){this._pressedKeyCode=null,this._boundKeydownHandler=null,this._boundKeyupHandler=null,this._chartWidget=e,this._parent=t,this._boundKeydownHandler=this._keydownHandler.bind(this),this._boundKeyupHandler=this._keyupHandler.bind(this),this._parent.ownerDocument.addEventListener("keydown",this._boundKeydownHandler),this._parent.ownerDocument.addEventListener("keyup",this._boundKeyupHandler)}destroy(){null!==this._boundKeydownHandler&&(this._parent.ownerDocument.removeEventListener("keydown",this._boundKeydownHandler),this._boundKeydownHandler=null),null!==this._boundKeyupHandler&&(this._parent.ownerDocument.removeEventListener("keyup",this._boundKeyupHandler),this._boundKeyupHandler=null)}_keydownHandler(e){
this._chartWidget.hasModel()&&this._chartWidget.isActive().value()&&(e.defaultPrevented||("text-editor"===window.document.activeElement?.getAttribute("data-name")&&this._handleTabKeyDown(e)||window.document.activeElement===window.document.body&&(this._handleMoveDrawingsKeyDown(e)||this._handleScrollKeyDown(e)||this._handleZoomKeyDown(e)))&&e.preventDefault())}_keyupHandler(e){this._chartWidget.hasModel()&&this._handleScrollKeyUp(e)}_handleTabKeyDown(e){const t=255&(0,o.hashFromEvent)(e),i=this._chartWidget.model();if(9===t){const t=i.selection().dataSources()[0];if(void 0!==t&&(s=t,(0,r.isLineTool)(s)&&"LineToolTable"===s.state().type)){const i=(0,o.modifiersFromEvent)(e);return t.switchActiveCell(i===o.Modifiers.Shift)}return!1}var s;return!1}_handleMoveDrawingsKeyDown(e){const t=255&(0,o.hashFromEvent)(e),i=this._chartWidget.model();switch(t){case 37:return i.moveSelectedToolsLeft();case 39:return i.moveSelectedToolsRight();case 38:return i.moveSelectedToolsUp();case 40:return i.moveSelectedToolsDown()}return!1}_handleScrollKeyDown(e){if(null!==this._pressedKeyCode)return!1;const t=(0,o.hashFromEvent)(e),i=255&t,s=(0,o.modifiersFromEvent)(e);let r;if(37===i)r=1;else{if(39!==i)return!1;r=-1}if(o.isMacKeyboard&&s===o.Modifiers.Mod||!u.includes(s))return!1;if((0,n.isNativeUIInteraction)(t,e.target))return!1;this._pressedKeyCode=i;const a=this._chartWidget.scrollHelper();return s===o.Modifiers.None?a.moveByBar(r):s===o.Modifiers.Alt||s===o.Modifiers.Mod?a.move(r):-1===r?a.scrollToRealtime(!0):a.scrollToFirstBar(),!0}_handleScrollKeyUp(e){if(null===this._pressedKeyCode)return!1;const t=(0,o.hashFromEvent)(e);if((0,n.isNativeUIInteraction)(t,e.target))return!1;return(255&t)===this._pressedKeyCode&&(this._pressedKeyCode=null,this._chartWidget.scrollHelper().stopMove(),!0)}_handleZoomKeyDown(e){const t=(0,o.hashFromEvent)(e),i=255&t;if((0,o.modifiersFromEvent)(e)!==o.Modifiers.Mod||(0,n.isNativeUIInteraction)(t,e.target))return!1;const s=this._chartWidget.model();if(38===i)s.zoomIn();else{if(40!==i)return!1;s.zoomOut()}return!0}}},64236:(e,t,i)=>{"use strict";i.d(t,{getChartWidgetApiTimeConverter:()=>l});var s=i(50151),o=i(32955),n=i(37103);const r=n.enabled("end_of_period_timescale_marks"),a=n.enabled("secondary_series_extend_time_scale");function l(e,t,i){return new h(function(e,t){const i=function(e,t){return e+t.session+t.timezone+(t.corrections||"")+(t.session_holidays||"")}(e,t);let s=c.get(i);void 0===s&&(s=(0,o.createDwmAligner)(e,t),c.set(i,s));return s}(e,t),i)}const c=new Map;class h{constructor(e,t){this._dwmAligner=e,this._chartModel=t}convertPublicTimeToInternalTime(e){return null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(1e3*e)/1e3:e}convertInternalTimeToPublicTime(e){return null!==this._dwmAligner?this._dwmAligner.timeToExchangeTradingDay(1e3*e)/1e3:e}convertTimePointIndexToPublicTime(e){const t=this._chartModel.timeScale();if(t.isEmpty())return null;let i=r?function(e,t){const i=e.indexToUserTime(t);if(null===i)return null;return i.getTime()/1e3
}(t,e):this.convertTimePointIndexToInternalTime(e);if(null!==i){const t=this._chartModel.mainSeries().bars(),s=t.contains(e),o=t.firstIndex(),n=t.lastIndex();!s&&(null!==o&&null!==n&&o<=e&&e<=n)&&a||(i=this.convertInternalTimeToPublicTime(i))}return i}convertTimePointIndexToInternalTime(e){const t=this._chartModel.timeScale();if(t.isEmpty())return null;const i=t.points(),{firstIndex:o,lastIndex:n}=(0,s.ensureNotNull)(i.range().value());let r=null;if(o<=e&&e<=n)r=i.valueAt(e);else if(e>n){const i=this._chartModel.mainSeries().syncModel();if(null!==i){const o=(0,s.ensureNotNull)(t.indexToTimePoint(n));r=i.projectTime(o,e-n)}}return r}}},84617:(e,t,i)=>{"use strict";i.d(t,{CHART_FONT_FAMILY:()=>n,setChartFontFamily:()=>o});const s="'Trebuchet MS', Roboto, Ubuntu, sans-serif";function o(e){n=e}let n=`-apple-system, BlinkMacSystemFont, ${s}`},31269:(e,t,i)=>{"use strict";i.d(t,{ContextMenuManager:()=>s});var s,o=i(12217),n=i(41706),r=i(87713);!function(e){let t=null,s=null;const a=[],l={createAction:e=>new n.Action({actionId:"Chart.CustomActionId",options:e}),createAsyncAction:e=>new n.Action({actionId:"Chart.CustomActionId",options:{},optionsLoader:e}),createSeparator:()=>new n.Separator};async function c(e,n={},r={menuName:""},c){null!==t&&(e=await t(e,l,r));let d=null;const u=()=>{const e=(0,o.indexOf)(a,(e=>e.renderer===d));-1!==e&&a.splice(e,1),void 0!==c&&c()};let _=!1;if(null!==s&&(d=await s(e,r,u)),d)_=!0,h();else{const t=await Promise.all([i.e(4109),i.e(1681),i.e(6032),i.e(3425),i.e(8260),i.e(1979),i.e(7780),i.e(1667),i.e(3290),i.e(2227),i.e(3179),i.e(6376),i.e(1584)]).then(i.bind(i,14474));d=new t.ContextMenuRenderer(e,n,u,h)}return a.push({renderer:d,isExternal:_}),d}function h(){(0,r.globalCloseMenu)(),a.forEach((e=>{e.isExternal&&e.renderer.isShown()&&e.renderer.hide()}))}e.createMenu=c,e.showMenu=function(e,t,i={},s,o){return c(e,i,s,o).then((e=>e.show(t)))},e.setCustomRendererFactory=function(e){s=e},e.setCustomItemsProcessor=function(e){t=e},e.hideAll=h,e.getShown=function(){for(let e=0;e<a.length;e++)if(a[e].renderer.isShown())return a[e].renderer;return null}}(s||(s={}))},89947:(e,t,i)=>{"use strict";i.d(t,{deleteLockedLineToolsProperty:()=>c});var s=i(1765),o=i(41072),n=i(5734);const r="delete_locked_linetools",a="toggle_delete_locked_linetools";function l(){const e=s.getBool(r,!0)&&s.getBool(n.doNotShowDeleteLockedLineKey,!1),t=s.getBool(a,e);return s.remove(r),s.setValue(a,t),t}const c=(0,o.createPrimitiveProperty)(l());c.subscribe(null,(()=>s.setValue(a,c.value()))),s.onSync.subscribe(null,(()=>c.setValue(l())))},5734:(e,t,i)=>{"use strict";i.d(t,{doNotShowDeleteLockedLineConfirmProperty:()=>a,doNotShowDeleteLockedLineKey:()=>n});var s=i(1765),o=i(41072);const n="do_not_show_delete_locked_line_confirm";function r(){return s.getBool(n,!1)}const a=(0,o.createPrimitiveProperty)(r());a.subscribe(null,(()=>s.setValue(n,a.value()))),s.onSync.subscribe(null,(()=>a.setValue(r())))},38414:(e,t,i)=>{"use strict";i.d(t,{DialogRenderer:()=>o});var s=i(22613);class o{constructor(){
this._container=document.createElement("div"),this._visibility=new s.WatchedValue(!1),this._rootInstance=null}visible(){return this._visibility.readonly()}_setVisibility(e){this._visibility.setValue(e)}}},70002:(e,t,i)=>{"use strict";var s;i.d(t,{TabNames:()=>s}),function(e){e.background="Background",e.coordinates="Coordinates",e.drawings="Drawings",e.events="Events",e.alerts="Alerts",e.inputs="Inputs",e.properties="Properties",e.scales="Scales",e.legend="Legend",e.sourceCode="Source Code",e.style="Style",e.symbol="Symbol",e.timezoneSessions="Timezone/Sessions",e.trading="Trading",e.visibility="Visibility",e.text="Text"}(s||(s={}))},69455:(e,t,i)=>{"use strict";i.d(t,{createFavoriteDrawingToolbar:()=>a,getFavoriteDrawingToolbarPromise:()=>r});var s=i(9753);let o=null,n=null;function r(){return n}function a(){null===n&&(n=Promise.all([i.e(7617),i.e(8185),i.e(1681),i.e(3439),i.e(8933),i.e(6032),i.e(3672),i.e(2537),i.e(3359),i.e(3425),i.e(8260),i.e(1979),i.e(7780),i.e(7827),i.e(8220),i.e(9590),i.e(1667),i.e(9836),i.e(3290),i.e(6178),i.e(7777),i.e(2227),i.e(3179),i.e(1890),i.e(6193),i.e(6376),i.e(2306)]).then(i.bind(i,63027)).then((({FavoriteDrawingToolbar:e})=>(o=null!==o?o:new e({left:window.innerWidth/2,top:s.HEADER_TOOLBAR_HEIGHT_EXPANDED+61}),o))))}},59239:(e,t,i)=>{"use strict";function s(e){return Math.max(1,e.ownerDocument?.defaultView?.devicePixelRatio||1)}i.d(t,{getCanvasDevicePixelRatio:()=>s})},96708:(e,t,i)=>{"use strict";i.d(t,{getPriceAxisNameInfo:()=>r});const s=["Z","Y","X","W","V","U","T","S"],o=["A","B","C","D","E","F","G","H"];class n{constructor(e){this.label=e}equals(e){return null!==e&&this.label===e.label}}function r(e,t){const i="left"===e?s:o,r=t<i.length?i[t]:"";return new n(r)}},3618:(e,t,i)=>{"use strict";i.d(t,{getTranslatedInputTitle:()=>n});var s=i(11542);const o={PercentageLTP:"Percentage LTP",Labels:"Pane labels",LineFills:"Line fills"};function n(e){return s.t(o[e]??e,{context:"input"},i(32856))}},60709:(e,t,i)=>{"use strict";i.d(t,{CHART_WIDGET_COLLECTION_SERVICE:()=>n,chartWidgetCollectionService:()=>r});var s,o=i(16216);!function(e){e.Multichart="multichart",e.ForceFullscreen="force-fullscreen"}(s||(s={}));const n={id:"ChartWidgetCollectionService"};function r(){return(0,o.hasService)(n)?(0,o.service)(n):null}},51304:(e,t,i)=>{"use strict";i.d(t,{InvalidationLevel:()=>s,InvalidationMask:()=>l,defaultInvalidationLevel:()=>r});var s,o=i(50151);class n{constructor(e=r){this._paneInvalidationLevel=r,this._leftPriceScalesInvalidationMap=new Map,this._rightPriceScalesInvalidationMap=new Map,this._legendWidgetInvalidated=!1,this._invalidationLevel=e}fullInvalidation(){return this._invalidationLevel}invalidateAll(e){this._invalidationLevel=Math.max(this._invalidationLevel,e)}invalidatePane(e){this._paneInvalidationLevel=Math.max(this._invalidationLevel,e)}invalidateLegendWidgetLayout(){this._legendWidgetInvalidated=!0}invalidatePriceScale(e,t,i){const s="left"===e?this._leftPriceScalesInvalidationMap:this._rightPriceScalesInvalidationMap,o=s.get(t)||r;s.set(t,Math.max(o,i))}
invalidationLevelForPane(){return Math.max(this._paneInvalidationLevel,this._invalidationLevel)}legendWidgetLayoutInvalidated(){return this._legendWidgetInvalidated||this._invalidationLevel===s.Full}getterForPriceScaleInvalidationLevelBySide(e){const t="left"===e?this._leftPriceScalesInvalidationMap:this._rightPriceScalesInvalidationMap;return e=>Math.max(t.get(e)||r,this._invalidationLevel)}priceScaleSideMaxLevel(e){const t="left"===e?this._leftPriceScalesInvalidationMap:this._rightPriceScalesInvalidationMap;let i=this._invalidationLevel;return t.size>0&&t.forEach((e=>{e>i&&(i=e)})),i}merge(e){this._invalidationLevel=Math.max(this._invalidationLevel,e._invalidationLevel),this._paneInvalidationLevel=Math.max(this._paneInvalidationLevel,e._paneInvalidationLevel),e._leftPriceScalesInvalidationMap.forEach(((e,t)=>{const i=this._leftPriceScalesInvalidationMap.get(t)||r;this._leftPriceScalesInvalidationMap.set(t,Math.max(i,e))})),e._rightPriceScalesInvalidationMap.forEach(((e,t)=>{const i=this._rightPriceScalesInvalidationMap.get(t)||r;this._rightPriceScalesInvalidationMap.set(t,Math.max(i,e))})),this._legendWidgetInvalidated=this._legendWidgetInvalidated||e._legendWidgetInvalidated}}!function(e){e[e.None=0]="None",e[e.Cursor=1]="Cursor",e[e.Light=2]="Light",e[e.Full=3]="Full"}(s||(s={}));const r=s.None;var a;!function(e){e[e.ScrollAnimation=0]="ScrollAnimation",e[e.StopAnimation=1]="StopAnimation"}(a||(a={}));class l{constructor(e=r){this._panesOrderChanged=!1,this._keepVisibleTimeRangeOnResize=!1,this._timeScaleInvalidation={level:r,animations:[],invalidateStubs:!1},this._invalidatedPanes=new Map,this._additionalActions=[],this._invalidationLevel=e}invalidateAll(e){this._invalidationLevel!==e&&(this._invalidationLevel=Math.max(this._invalidationLevel,e),this._invalidatedPanes.forEach((e=>{e.invalidateAll(this._invalidationLevel)})))}invalidateAllPane(e,t){this._invalidatedPanes.has(e)||this._invalidatedPanes.set(e,new n(this._invalidationLevel)),(0,o.ensureDefined)(this._invalidatedPanes.get(e)).invalidateAll(t)}invalidatePriceScale(e,t,i,s){this._invalidatedPanes.has(e)||this._invalidatedPanes.set(e,new n(this._invalidationLevel)),(0,o.ensureDefined)(this._invalidatedPanes.get(e)).invalidatePriceScale(t,i,s)}invalidateTimeScale(e,t=!1){this._timeScaleInvalidation.level=Math.max(this._timeScaleInvalidation.level,e),this._timeScaleInvalidation.invalidateStubs=this._timeScaleInvalidation.invalidateStubs||t}invalidatePanesOrder(){this._panesOrderChanged=!0}lockVisibleTimeRangeOnResize(){this._keepVisibleTimeRangeOnResize=!0}fullInvalidation(){return this._invalidationLevel}maxPaneInvalidation(){const e=[];return this._invalidatedPanes.forEach((t=>{e.push(t.fullInvalidation())})),Math.max(...e,this._invalidationLevel)}invalidationForPane(e){return this._invalidatedPanes.get(e)||new n(this._invalidationLevel)}invalidationForTimeScale(){return{...this._timeScaleInvalidation,level:Math.max(this._timeScaleInvalidation.level,this._invalidationLevel)}}validationActions(){return this._additionalActions}addValidationAction(e){
this._additionalActions.push(e)}merge(e){this._invalidationLevel=Math.max(this._invalidationLevel,e._invalidationLevel),this._panesOrderChanged=this._panesOrderChanged||e._panesOrderChanged,this._keepVisibleTimeRangeOnResize=this._keepVisibleTimeRangeOnResize||e._keepVisibleTimeRangeOnResize,this._invalidatedPanes.forEach((e=>{e.invalidateAll(this._invalidationLevel)})),e._invalidatedPanes.forEach(((e,t)=>{this._invalidatedPanes.has(t)||this._invalidatedPanes.set(t,new n(this._invalidationLevel)),(0,o.ensureDefined)(this._invalidatedPanes.get(t)).merge(e)})),this._timeScaleInvalidation.level=Math.max(this._timeScaleInvalidation.level,e._timeScaleInvalidation.level),this._timeScaleInvalidation.invalidateStubs=this._timeScaleInvalidation.invalidateStubs||e._timeScaleInvalidation.invalidateStubs;for(let t=0;t<e._additionalActions.length;t++)this._additionalActions.push(e._additionalActions[t]);for(const t of e._timeScaleInvalidation.animations)this._applyTimeScaleAnimationInvalidation(t)}panesOrderInvalidated(){return this._panesOrderChanged}isVisibleTimeRangeLockedOnResize(){return this._keepVisibleTimeRangeOnResize}setTimeScaleAnimation(e,t){this._removeTimeScaleAnimation(),this._timeScaleInvalidation.animations.push({type:0,value:e,rightOffsetPx:t}),this._invalidationLevel=Math.max(this._invalidationLevel,s.Light)}stopTimeScaleAnimation(){this._removeTimeScaleAnimation(),this._timeScaleInvalidation.animations.push({type:1}),this._invalidationLevel=Math.max(this._invalidationLevel,s.Light)}static cursor(){return new l(s.Cursor)}static light(){return new l(s.Light)}static full(){return new l(s.Full)}static timeScale(e,t=!1){const i=new l;return i.invalidateTimeScale(e,t),i}static panesOrder(){const e=l.full();return e.invalidatePanesOrder(),e}static invalidateLegendWidgetLayout(e){const t=new l;return t._invalidatedPanes.set(e,new n),t._invalidatedPanes.get(e)?.invalidateLegendWidgetLayout(),t}static validateAction(e){const t=new l;return t._additionalActions.push(e),t}_applyTimeScaleAnimationInvalidation(e){switch(e.type){case 0:this.setTimeScaleAnimation(e.value,e.rightOffsetPx);break;case 1:this._removeTimeScaleAnimation()}}_removeTimeScaleAnimation(){const e=this._timeScaleInvalidation.animations.findIndex((e=>0===e.type));if(-1!==e){const[t]=this._timeScaleInvalidation.animations.splice(e,1);t.value.onFinish?.(!1)}}}},39612:(e,t,i)=>{"use strict";i.d(t,{lastMouseOrTouchEventInfo:()=>o,setLastMouseOrTouchEventInfo:()=>n});let s=(0,i(49483).supportTouch)()?{isTouch:!0,stylus:!1}:{isTouch:!1};function o(){return s}function n(e){s=e.isTouch?{isTouch:!0,stylus:e.stylus}:{isTouch:!1}}},62548:(e,t,i)=>{"use strict";i.d(t,{layoutInitialSizingState:()=>o});var s=i(69708);i(50151);function o(e){const[,...t]=e;return function(e){const t=1/e.length;return e.map((e=>({percent:t,substate:(0,s.default)(e)?void 0:o(e)})))}(t)}},3354:(e,t,i)=>{"use strict";i.d(t,{isMultipleLayout:()=>r,isSupportedLayout:()=>a,layouts:()=>o,tryGuessingTheMostSuitableLayout:()=>l});i(26743),i(62548);let s;s={};const o={...{s:{title:"1 chart",
count:1,layoutType:"s",sizer:(e,t)=>{if(0!==t)throw new RangeError("invalid index");return e},splitters:()=>[],resizeApplier:(e,t,i,s,o)=>o,syncSublayoutsBySplitter:(e,t)=>t,expression:["h",0]}},...s};function n(e){return"s"===e}function r(e){return!n(e)}function a(e){return n(e)||s.hasOwnProperty(e)}function l(e){return"s"}},81360:(e,t,i)=>{"use strict";i.d(t,{lineToolsSelectHotkeys:()=>o});i(40167);var s=i(68335);const o={LineToolFibRetracement:{hash:s.Modifiers.Alt+70,action:"setTool",description:"Draw Fib Retracement"},LineToolHorzLine:{hash:s.Modifiers.Alt+72,action:"drawRightThere",description:"Draw Horizontal Line here"},LineToolHorzRay:{hash:s.Modifiers.Alt+74,action:"drawRightThere",description:"Draw Horizontal Ray here"},LineToolRectangle:{hash:s.Modifiers.Alt+s.Modifiers.Shift+82,action:"setTool",description:"Draw Rectangle"},LineToolTrendLine:{hash:s.Modifiers.Alt+84,action:"setTool",description:"Draw Trend Line"},LineToolVertLine:{hash:s.Modifiers.Alt+86,action:"drawRightThere",description:"Draw Vertical Line here"},LineToolCrossLine:{hash:s.Modifiers.Alt+67,action:"drawRightThere",description:"Draw Cross Line here"}}},62153:(e,t,i)=>{"use strict";i.d(t,{MouseEventHandler:()=>f,defaultPreventedHandler:()=>m,getClickPosition:()=>_,isTouchMouseEvent:()=>p});var s=i(81251),o=i(50151),n=i(87465),r=i(49483),a=i(80007),l=i(39612);const c=r.isSafari?"click":"auxclick";var h,d;!function(e){e[e.ResetClick=500]="ResetClick",e[e.LongTap=333]="LongTap",e[e.PreventFiresTouchEvents=500]="PreventFiresTouchEvents"}(h||(h={})),function(e){e[e.CancelClickManhattanDistance=5]="CancelClickManhattanDistance",e[e.CancelTapManhattanDistance=5]="CancelTapManhattanDistance",e[e.DoubleClickManhattanDistance=5]="DoubleClickManhattanDistance",e[e.DoubleTapManhattanDistance=30]="DoubleTapManhattanDistance"}(d||(d={}));const u={treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!1,ignoreClickAndTapOnDblClickOrDblTap:!1};function _(e){if(p(e))return{x:e.clientX,y:e.clientY};if("touches"in(t=e)&&void 0!==t.touches){if(1===e.touches.length){const t=(0,o.ensureNotNull)(e.target).getBoundingClientRect(),i=e.touches[0];return{x:i.clientX-t.left,y:i.clientY-t.top}}return null}var t;return{x:e.offsetX,y:e.offsetY}}function p(e){return"isTouch"in e&&"stylus"in e}function m(e){return t=>{t.preventDefault(),e(t)}}function g(e,t){let i=!1;return{clickOrTap:(...s)=>{t?.()?e.clickOrTap(...s):(i=!1,setTimeout((()=>!i&&e.clickOrTap(...s)),501))},doubleClickOrDoubleTap:(...t)=>{i=!0,e.doubleClickOrDoubleTap?.(...t)}}}class f{constructor(e,t,i){if(this._clickCount=0,this._clickTimeoutId=null,this._clickPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._tapCount=0,this._tapTimeoutId=null,this._tapPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._longTapTimeoutId=null,this._longTapActive=!1,this._mouseMoveStartPosition=null,this._touchMoveStartPosition=null,this._touchMoveExceededManhattanDistance=!1,this._cancelClick=!1,this._cancelTap=!1,this._unsubscribeOutsideMouseEvents=null,
this._unsubscribeOutsideTouchEvents=null,this._unsubscribeMobileSafariEvents=null,this._unsubscribeMousemove=null,this._unsubscribeRootMouseEvents=null,this._unsubscribeRootTouchEvents=null,this._unsubscribePinchEvents=null,this._unsubscribeTargetElementEvents=null,this._pinchInfo=null,this._pinchPrevented=!1,this._preventTouchDragProcess=!1,this._mousePressed=!1,this._lastTouchEventTimeStamp=0,this._activeTouchId=null,this._acceptMouseLeave=!r.CheckMobile.iOS(),this._onFirefoxOutsideMouseUp=e=>{this._mouseUpHandler(e)},this._onMobileSafariDoubleClick=e=>{if(this._firesTouchEvents(e)){const t=this._makeCompatEvent(e);if(++this._tapCount,this._tapTimeoutId&&this._tapCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(v(e),this._tapPosition);i<30&&!this._cancelTap&&this._processTouchEvent(t,this._handlers.doubleTapEvent),this._resetTapTimeout()}}else{const t=this._makeCompatEvent(e);if(++this._clickCount,this._clickTimeoutId&&this._clickCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(v(e),this._clickPosition);i<5&&!this._cancelClick&&this._processMouseEvent(t,this._handlers.mouseDoubleClickEvent),this._resetClickTimeout()}}},this._target=e,this._options=(0,n.merge)((0,n.clone)(u),i||{}),this._options.ignoreClickAndTapOnDblClickOrDblTap){if(t.mouseClickEvent&&t.mouseDoubleClickEvent){const e=g({clickOrTap:t.mouseClickEvent.bind(t),doubleClickOrDoubleTap:t.mouseDoubleClickEvent.bind(t)});t.mouseClickEvent=e.clickOrTap,t.mouseDoubleClickEvent=e.doubleClickOrDoubleTap}if(t.tapEvent&&t.doubleTapEvent){const e=g({clickOrTap:t.tapEvent.bind(t),doubleClickOrDoubleTap:t.doubleTapEvent.bind(t)});t.tapEvent=e.clickOrTap,t.doubleTapEvent=e.doubleClickOrDoubleTap}}this._handlers=t,this._init()}destroy(){null!==this._unsubscribeOutsideMouseEvents&&(this._unsubscribeOutsideMouseEvents(),this._unsubscribeOutsideMouseEvents=null),null!==this._unsubscribeOutsideTouchEvents&&(this._unsubscribeOutsideTouchEvents(),this._unsubscribeOutsideTouchEvents=null),null!==this._unsubscribeMousemove&&(this._unsubscribeMousemove(),this._unsubscribeMousemove=null),null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null),null!==this._unsubscribeMobileSafariEvents&&(this._unsubscribeMobileSafariEvents(),this._unsubscribeMobileSafariEvents=null),null!==this._unsubscribePinchEvents&&(this._unsubscribePinchEvents(),this._unsubscribePinchEvents=null),null!==this._unsubscribeTargetElementEvents&&(this._unsubscribeTargetElementEvents(),this._unsubscribeTargetElementEvents=null),this._clearLongTapTimeout(),this._resetClickTimeout()}_mouseEnterHandler(e){this._unsubscribeMousemove&&this._unsubscribeMousemove();const t=this._mouseMoveHandler.bind(this);if(this._unsubscribeMousemove=()=>{this._target.removeEventListener("mousemove",t)},this._target.addEventListener("mousemove",t),this._firesTouchEvents(e))return;const i=this._makeCompatEvent(e)
;this._processMouseEvent(i,this._handlers.mouseEnterEvent),this._acceptMouseLeave=!0}_resetClickTimeout(){null!==this._clickTimeoutId&&clearTimeout(this._clickTimeoutId),this._clickCount=0,this._clickTimeoutId=null,this._clickPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}}_resetTapTimeout(){null!==this._tapTimeoutId&&clearTimeout(this._tapTimeoutId),this._tapCount=0,this._tapTimeoutId=null,this._tapPosition={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}}_mouseMoveHandler(e){if(this._mousePressed||null!==this._touchMoveStartPosition)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handlers.mouseMoveEvent),this._acceptMouseLeave=!0}_touchMoveHandler(e){const t=w(e.changedTouches,(0,o.ensureNotNull)(this._activeTouchId));if(null===t)return;if(this._lastTouchEventTimeStamp=b(e),null!==this._pinchInfo)return;if(this._preventTouchDragProcess)return;this._pinchPrevented=!0;const i=this._touchMouseMoveWithDownInfo(v(t),(0,o.ensureNotNull)(this._touchMoveStartPosition)),{xOffset:s,yOffset:n,manhattanDistance:r}=i;if(this._touchMoveExceededManhattanDistance||!(r<5)){if(!this._touchMoveExceededManhattanDistance){const e=.5*s,t=this._options.shouldAllowTouchDrag?.()??!1,i=n>=e&&(!this._options.treatVertTouchDragAsPageScroll||t),o=e>n&&(!this._options.treatHorzTouchDragAsPageScroll||t);i||o||(this._preventTouchDragProcess=!0),this._touchMoveExceededManhattanDistance=!0,this._cancelTap=!0,this._clearLongTapTimeout(),this._resetTapTimeout()}if(!this._preventTouchDragProcess){const i=this._makeCompatEvent(e,t);this._processTouchEvent(i,this._handlers.touchMoveEvent),(0,a.preventDefault)(e)}}}_mouseMoveWithDownHandler(e){if(0!==e.button)return;const t=this._touchMouseMoveWithDownInfo(v(e),(0,o.ensureNotNull)(this._mouseMoveStartPosition)),{manhattanDistance:i}=t;if(i>=5&&(this._cancelClick=!0,this._resetClickTimeout()),this._cancelClick){const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handlers.pressedMouseMoveEvent)}}_touchMouseMoveWithDownInfo(e,t){const i=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return{xOffset:i,yOffset:s,manhattanDistance:i+s}}_touchEndHandler(e){let t=w(e.changedTouches,(0,o.ensureNotNull)(this._activeTouchId));if(null===t&&0===e.touches.length&&(t=e.changedTouches[0]),null===t)return;this._activeTouchId=null,this._lastTouchEventTimeStamp=b(e),this._clearLongTapTimeout(),this._touchMoveStartPosition=null,this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);const i=this._makeCompatEvent(e,t);if(this._processTouchEvent(i,this._handlers.touchEndEvent),++this._tapCount,this._tapTimeoutId&&this._tapCount>1){const{manhattanDistance:e}=this._touchMouseMoveWithDownInfo(v(t),this._tapPosition);e<30&&!this._cancelTap&&this._processTouchEvent(i,this._handlers.doubleTapEvent),this._resetTapTimeout()}else this._cancelTap||(this._processTouchEvent(i,this._handlers.tapEvent),this._handlers.tapEvent&&(0,a.preventDefault)(e));0===this._tapCount&&(0,a.preventDefault)(e),
0===e.touches.length&&this._longTapActive&&(this._longTapActive=!1,(0,a.preventDefault)(e))}_touchCancelHandler(e){this._touchEndHandler(e)}_mouseUpHandler(e){if(0!==e.button)return;const t=this._makeCompatEvent(e);if(this._mouseMoveStartPosition=null,this._mousePressed=!1,this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),r.isFF){this._target.ownerDocument.documentElement.removeEventListener("mouseleave",this._onFirefoxOutsideMouseUp)}if(!this._firesTouchEvents(e))if(this._processMouseEvent(t,this._handlers.mouseUpEvent),++this._clickCount,this._clickTimeoutId&&this._clickCount>1){const{manhattanDistance:i}=this._touchMouseMoveWithDownInfo(v(e),this._clickPosition);i<5&&!this._cancelClick&&this._processMouseEvent(t,this._handlers.mouseDoubleClickEvent),this._resetClickTimeout()}else this._cancelClick||this._processMouseEvent(t,this._handlers.mouseClickEvent)}_clearLongTapTimeout(){null!==this._longTapTimeoutId&&(clearTimeout(this._longTapTimeoutId),this._longTapTimeoutId=null)}_touchStartHandler(e){if(null!==this._activeTouchId)return this._clearLongTapTimeout(),void this._resetTapTimeout();const t=e.changedTouches[0];this._activeTouchId=t.identifier,this._lastTouchEventTimeStamp=b(e);const i=this._target.ownerDocument.documentElement;this._cancelTap=!1,this._touchMoveExceededManhattanDistance=!1,this._preventTouchDragProcess=!1,this._touchMoveStartPosition=v(t),this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);{const t=this._touchMoveHandler.bind(this),s=this._touchEndHandler.bind(this);this._unsubscribeRootTouchEvents=()=>{i.removeEventListener("touchmove",t),i.removeEventListener("touchend",s)},i.addEventListener("touchmove",t,{passive:!1}),i.addEventListener("touchend",s,{passive:!1}),this._clearLongTapTimeout(),this._longTapTimeoutId=setTimeout(this._longTapHandler.bind(this,e),333)}const s=this._makeCompatEvent(e,t);this._processTouchEvent(s,this._handlers.touchStartEvent),this._tapTimeoutId||(this._tapCount=0,this._tapTimeoutId=setTimeout(this._resetTapTimeout.bind(this),500),this._tapPosition=v(t))}_wheelClickHandler(e){if(1!==e.button)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handlers.wheelClickEvent)}_mouseDownHandler(e){if(0!==e.button)return;const t=this._target.ownerDocument.documentElement;r.isFF&&t.addEventListener("mouseleave",this._onFirefoxOutsideMouseUp),this._cancelClick=!1,this._mouseMoveStartPosition=v(e),this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null);{const e=this._mouseMoveWithDownHandler.bind(this),i=this._mouseUpHandler.bind(this);this._unsubscribeRootMouseEvents=()=>{t.removeEventListener("mousemove",e),t.removeEventListener("mouseup",i)},t.addEventListener("mousemove",e),t.addEventListener("mouseup",i)}if(this._mousePressed=!0,this._firesTouchEvents(e))return;const i=this._makeCompatEvent(e);this._processMouseEvent(i,this._handlers.mouseDownEvent),
this._clickTimeoutId||(this._clickCount=0,this._clickTimeoutId=setTimeout(this._resetClickTimeout.bind(this),500),this._clickPosition=v(e))}_init(){const e=this._mouseEnterHandler.bind(this);this._target.addEventListener("mouseenter",e);const t=this._touchCancelHandler.bind(this);this._target.addEventListener("touchcancel",t);{const e=this._target.ownerDocument,t=e=>!e.target||!this._target.contains(e.target),i=e=>{if(!t(e))return;const i=e.changedTouches[0];this._lastTouchEventTimeStamp=b(e),this._processTouchEvent(this._makeCompatEvent(e,i),this._handlers.touchStartOutsideEvent)},s=e=>{t(e)&&!this._firesTouchEvents(e)&&this._processMouseEvent(this._makeCompatEvent(e),this._handlers.mouseDownOutsideEvent)};this._unsubscribeOutsideTouchEvents=()=>{e.removeEventListener("touchstart",i)},this._unsubscribeOutsideMouseEvents=()=>{e.removeEventListener("mousedown",s)},e.addEventListener("mousedown",s),e.addEventListener("touchstart",i,{passive:!0})}r.CheckMobile.iOS()&&(this._unsubscribeMobileSafariEvents=()=>{this._target.removeEventListener("dblclick",this._onMobileSafariDoubleClick)},this._target.addEventListener("dblclick",this._onMobileSafariDoubleClick));const i=this._mouseLeaveHandler.bind(this);this._target.addEventListener("mouseleave",i);const s=this._contextMenuHandler.bind(this);this._target.addEventListener("contextmenu",s);const o=this._touchStartHandler.bind(this);let n;this._target.addEventListener("touchstart",o,{passive:!0}),r.isChrome&&(n=e=>{if(1===e.button)return e.preventDefault(),!1},this._target.addEventListener("mousedown",n));const a=this._mouseDownHandler.bind(this);this._target.addEventListener("mousedown",a);const l=this._wheelClickHandler.bind(this);this._target.addEventListener(c,l);const h=()=>{};this._target.addEventListener("touchmove",h,{passive:!1}),this._unsubscribeTargetElementEvents=()=>{this._target.removeEventListener("mouseleave",i),this._target.removeEventListener("contextmenu",s),this._target.removeEventListener("touchstart",o),n&&this._target.removeEventListener("mousedown",n),this._target.removeEventListener("mousedown",a),this._target.removeEventListener(c,l),this._target.removeEventListener("touchmove",h)},this._initPinch()}_initPinch(){if(void 0===this._handlers.pinchStartEvent&&void 0===this._handlers.pinchEvent&&void 0===this._handlers.pinchEndEvent)return;const e=e=>this._checkPinchState(e.touches);this._target.addEventListener("touchstart",e,{passive:!0});const t=e=>{if(null===this._pinchInfo)return;const t=w(e.touches,(0,o.ensureNotNull)(this._activeTouchId)),i=w(e.touches,this._pinchInfo.secondTouchId);if(t&&i&&void 0!==this._handlers.pinchEvent){const{startPinchDistance:s,startPinchMiddlePoint:o}=this._pinchInfo,n=S(t,i)/s,r=y(this._target);this._handlers.pinchEvent(o,{x:t.clientX-r.left,y:t.clientY-r.top},{x:i.clientX-r.left,y:i.clientY-r.top},n),(0,a.preventDefault)(e)}};this._target.addEventListener("touchmove",t,{passive:!1});const i=e=>this._checkPinchState(e.touches);this._target.addEventListener("touchend",i),this._unsubscribePinchEvents=()=>{
this._target.removeEventListener("touchstart",e),this._target.removeEventListener("touchmove",t),this._target.addEventListener("touchend",i)}}_checkPinchState(e){1===e.length&&(this._pinchPrevented=!1),2!==e.length||this._pinchPrevented||this._longTapActive?this._stopPinch():this._startPinch(e)}_startPinch(e){if(void 0!==this._handlers.pinchStartEvent&&null===this._pinchInfo){const t=y(this._target);let i,s;e[0].identifier===this._activeTouchId?(i=e[0],s=e[1]):(i=e[1],s=e[0]);const o={x:i.clientX-t.left,y:i.clientY-t.top},n={x:s.clientX-t.left,y:s.clientY-t.top},r={x:(o.x+n.x)/2,y:(o.y+n.y)/2};this._handlers.pinchStartEvent(r,o,n,{bothPointsOnTargetElement:this._target.contains(s.target)})&&(this._pinchInfo={startPinchDistance:S(i,s),startPinchMiddlePoint:r,secondTouchId:s.identifier})}this._clearLongTapTimeout()}_stopPinch(){null!==this._pinchInfo&&(this._pinchInfo=null,this._handlers.pinchEndEvent?.())}_mouseLeaveHandler(e){if(this._unsubscribeMousemove&&this._unsubscribeMousemove(),this._firesTouchEvents(e))return;if(!this._acceptMouseLeave)return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handlers.mouseLeaveEvent),this._acceptMouseLeave=!r.CheckMobile.iOS()}_longTapHandler(e){const t=w(e.touches,(0,o.ensureNotNull)(this._activeTouchId));if(null===t)return;const i=this._makeCompatEvent(e,t);this._processTouchEvent(i,this._handlers.longTapEvent),this._processTouchEvent(i,this._handlers.touchContextMenuEvent),this._cancelTap=!0,this._longTapActive=!0}_contextMenuHandler(e){if((0,a.preventDefault)(e),null!==this._touchMoveStartPosition)return;if(this._firesTouchEvents(e))return;const t=this._makeCompatEvent(e);this._processMouseEvent(t,this._handlers.contextMenuEvent),this._cancelClick=!0}_firesTouchEvents(e){return e.sourceCapabilities&&void 0!==e.sourceCapabilities.firesTouchEvents?e.sourceCapabilities.firesTouchEvents:b(e)<this._lastTouchEventTimeStamp+500}_processTouchEvent(e,t){(0,l.setLastMouseOrTouchEventInfo)(e),t&&t.call(this._handlers,e)}_processMouseEvent(e,t){"mouseleave"!==e.srcType&&(0,l.setLastMouseOrTouchEventInfo)(e),t&&t.call(this._handlers,e)}_makeCompatEvent(e,t){const i=t||e,o=t?void 0:e.buttons,n=(0,s.default)((()=>this._target.getBoundingClientRect()||{left:0,top:0}));return{clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,get localX(){return i.clientX-n().left},get localY(){return i.clientY-n().top},ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,buttons:o,isTouch:!e.type.startsWith("mouse")&&"contextmenu"!==e.type&&"click"!==e.type,stylus:"stylus"===t?.touchType,srcType:e.type,target:i.target,view:e.view,preventDefault:()=>{"touchstart"!==e.type&&(0,a.preventDefault)(e)}}}}function y(e){return e.getBoundingClientRect()||{left:0,top:0}}function v(e){return{x:e.pageX,y:e.pageY}}function S(e,t){const i=e.clientX-t.clientX,s=e.clientY-t.clientY;return Math.sqrt(i*i+s*s)}function b(e){return e.timeStamp||performance.now()}function w(e,t){for(let i=0;i<e.length;++i)if(e[i].identifier===t)return e[i]
;return null}},23714:(e,t,i)=>{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>r,navigationButtonsVisibilityKey:()=>o,property:()=>n,restoreNavigationButtonsVisibilitySettingsValue:()=>l});var s=i(64876);const o="NavigationButtons.visibility",{property:n,availableValues:r,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)(o)},61786:(e,t,i)=>{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>r,property:()=>n,restorePaneButtonsVisibilitySettingsValue:()=>l});var s=i(64876),o=i(23714);const{property:n,availableValues:r,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)("PaneButtons.visibility",o.navigationButtonsVisibilityKey)},67763:(e,t,i)=>{"use strict";i.d(t,{AbstractJsonStoreService:()=>o,CommonJsonStoreService:()=>n});var s=i(48096);class o{constructor(e,t,i,o,n){this._onChange=new s.Delegate,this._handleChange=()=>{this._onChange.fire(this.get())},this._crossTabEvents=e,this._jsonKeyValueStore=t,this.CROSSTAB_EVENT_NAME=i,this.JSON_STORE_KEY=o,this.defaultStoreValue=this._serialize(n),this._subscribe()}get(){const e=this._jsonKeyValueStore.getJSON(this.JSON_STORE_KEY,this.defaultStoreValue);return this._deserialize(e)}set(e,t){const i=this._serialize(e);this._jsonKeyValueStore.setJSON(this.JSON_STORE_KEY,i,t),this._crossTabEvents.emit(this.CROSSTAB_EVENT_NAME),this._onChange.fire(e)}getOnChange(){return this._onChange}destroy(){this._unsubscribe(),this._onChange.destroy(),delete this._onChange}_subscribe(){this._crossTabEvents.on(this.CROSSTAB_EVENT_NAME,this._handleChange),this._jsonKeyValueStore.onSync.subscribe(this,this._handleChange)}_unsubscribe(){this._crossTabEvents.off(this.CROSSTAB_EVENT_NAME,this._handleChange),this._jsonKeyValueStore.onSync.unsubscribe(this,this._handleChange)}}class n extends o{_serialize(e){return e}_deserialize(e){return e}}},68028:(e,t,i)=>{"use strict";i.d(t,{CustomStatusModel:()=>c});var s=i(22613);const o="#9598a1",n=!1,r=null,a='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"></svg>';class l{constructor(e){this._visible=new s.WatchedValue(n),this._tooltip=new s.WatchedValue(r),this._icon=new s.WatchedValue(a),this._color=new s.WatchedValue(o),this._tooltipContent=new s.WatchedValue(null),this._symbol=e}symbol(){return this._symbol}tooltip(){return this._tooltip}icon(){return this._icon}color(){return this._color}visible(){return this._visible}tooltipContent(){return this._tooltipContent}}class c{constructor(){this._symbolCustomStatuses=new Map}getSymbolCustomStatus(e){if(this._symbolCustomStatuses.has(e))return this._symbolCustomStatuses.get(e);const t=new l(e);return this._symbolCustomStatuses.set(e,t),t}hideAll(){for(const e of this._symbolCustomStatuses.values())e.visible().setValue(!1)}static getInstance(){return null===this._instance&&(this._instance=new c),this._instance}}c._instance=null},87911:(e,t,i)=>{"use strict";i.d(t,{restoreShowMarketOpenStatusProperty:()=>c,showMarketOpenStatusProperty:()=>l});var s=i(41072),o=i(1765);const n="Chart.ShowMarketOpenStatus",r=!0
;function a(){return o.getBool(n,r)}const l=(0,s.createPrimitiveProperty)(a());function c(){l.setValue(r),o.remove(n)}o.onSync.subscribe(null,(()=>l.setValue(a()))),l.subscribe(null,(()=>o.setValue(n,l.value())))},53107:(e,t,i)=>{"use strict";i.d(t,{MarketStatusModel:()=>u});var s,o=i(50151),n=i(37236),r=i(22613),a=i(48943),l=i(16329),c=i(95059);function h(e){return window.ChartApiInstance.serverTime()/1e3-e}function d(e,t,i){return e<=i?t<=i?1/0:t/1e3:Math.min(e,t)/1e3}!function(e){e.Open="market",e.Pre="pre_market",e.Post="post_market",e.Close="out_of_session",e.Holiday="holiday",e.Delisted="delisted",e.Expired="expired"}(s||(s={}));class u{constructor(e){this._currentSession=new r.WatchedValue(null),this._delistedByTypespecs=new r.WatchedValue(!1),this._sessionsSpec=null,this._nextSessionEdgeInternal=null,this._nextSessionEdge=new r.WatchedValue(null),this._recalcNextSessionEdgeTimerId=null,this._delay=0,this._futuresContractExpirationTime=null,this._quotesProvider=e;const{current_session:t}=e.quotes()??{};t&&this._currentSession.setValue(t),this._marketStatus=(0,a.combine)(((e,t,i)=>null===e?e:t?"delisted":i?"expired":function(e){switch(e){case"market":return"market";case"pre_market":return"pre_market";case"post_market":return"post_market";case"out_of_session":return"out_of_session";case"holiday":return"holiday"}(0,o.ensureNever)(e)}(e)),this._currentSession.weakReference(),this._delistedByTypespecs.weakReference(),(this._futuresContractExpirationTime?.expired()??new r.WatchedValue(!1)).weakReference()),e.quotesUpdate().subscribe(this,(e=>{this._currentSession.setValue(e?.values.current_session??null)})),e.quoteSymbolChanged().subscribe(this,(()=>{this._currentSession.setValue(null)}))}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._quotesProvider.quoteSymbolChanged().unsubscribeAll(this),null!==this._recalcNextSessionEdgeTimerId&&clearTimeout(this._recalcNextSessionEdgeTimerId),this._marketStatus.destroy()}futuresContractExpirationTime(){return this._futuresContractExpirationTime}setSymbolInfo(e){if(this._nextSessionEdgeInternal=null,null===e)return void(this._sessionsSpec=null);this._delay=(0,c.getSymbolDelaySeconds)(e);const t=new l.SessionsSpec(e.timezone,e.session_display??e.session,e.session_holidays,e.corrections);let i,s;const o=e.subsessions?.find((e=>"premarket"===e.id)),n=e.subsessions?.find((e=>"postmarket"===e.id));void 0!==o&&(i=new l.SessionsSpec(e.timezone,o["session-display"]??o.session,e.session_holidays,o["session-correction"])),void 0!==n&&(s=new l.SessionsSpec(e.timezone,n["session-display"]??n.session,e.session_holidays,n["session-correction"])),this._sessionsSpec={general:t,preMarket:i,postMarket:s},this._recalculateNextSessionEdge()}status(){return this._marketStatus}currentSession(){return this._currentSession}nextSessionEdge(){return this._nextSessionEdge}_getNextSessionEdgeInternal(){if(null===this._sessionsSpec)return null;const e=1e3*h(this._delay);if(null===this._nextSessionEdgeInternal||(this._nextSessionEdgeInternal.timestamp??1/0)<=e/1e3){
const{general:t,preMarket:i,postMarket:s}=this._sessionsSpec,o=(0,n.get_timezone)(t.timezone()),r=(0,n.utc_to_cal)(o,e),a=d((0,n.cal_to_utc)(o,t.alignToNearestSessionStart(r,1)),(0,n.cal_to_utc)(o,t.alignToNearestSessionEnd(r,1)),e),l=d(void 0!==i?(0,n.cal_to_utc)(o,i.alignToNearestSessionStart(r,1)):1/0,void 0!==i?(0,n.cal_to_utc)(o,i.alignToNearestSessionEnd(r,1)):1/0,e),c=d(void 0!==s?(0,n.cal_to_utc)(o,s.alignToNearestSessionStart(r,1)):1/0,void 0!==s?(0,n.cal_to_utc)(o,s.alignToNearestSessionEnd(r,1)):1/0,e);let u=Math.min(a,l,c);if(u===1/0){const e=h(this._delay),i=6e4,s=new Date(Math.round(new Date(1e3*e).getTime()/i)*i).getTime()+i,r=(0,n.utc_to_cal)(o,s),a=d((0,n.cal_to_utc)(o,t.alignToNearestSessionStart(r,1)),(0,n.cal_to_utc)(o,t.alignToNearestSessionEnd(r,1)),s),_=Math.min(a,l,c);_!==1/0?(this._nextSessionEdgeInternal={timestamp:u},u=_):this._nextSessionEdgeInternal={timestamp:null}}this._nextSessionEdgeInternal=u===c?{timestamp:u,status:"post_market"}:u===l?{timestamp:u,status:"pre_market"}:{timestamp:u}}return this._nextSessionEdgeInternal}_recalculateNextSessionEdge(){const e=this._getNextSessionEdgeInternal();if(null===e||null===e.timestamp)return void this._nextSessionEdge.setValue(null);const t={status:e.status,remainingSeconds:Math.max(0,e.timestamp-h(this._delay))};if(null===this._recalcNextSessionEdgeTimerId){const e=Number.isFinite(t.remainingSeconds)?Math.ceil(t.remainingSeconds%60):1;this._recalcNextSessionEdgeTimerId=setTimeout((()=>this._recalculateNextSessionEdgeByTimer()),1e3*e)}this._nextSessionEdge.setValue(t)}_recalculateNextSessionEdgeByTimer(){this._recalcNextSessionEdgeTimerId=null,this._recalculateNextSessionEdge()}}},50888:(e,t,i)=>{"use strict";i.d(t,{CRUCIAL_REALTIME_BATS:()=>l,firstReplacedByBatsExchange:()=>c,isAmexToCboeMigratedSymbol:()=>_,isDelay:()=>d,isEod:()=>h,witoutRealtime:()=>u});i(50151);var s=i(59149),o=i.n(s);const n=["DJ","JSE","BELEX"],r=["NZX"],a=["BIVA"],l=["AMEX","NASDAQ","NYSE"];function c(e){return null}function h(e,t){return o().hasEodSymbols(e.full_name)||6===t}function d(e){return void 0!==e&&e>0}function u(e){return"index"===e.type&&n.includes(e.listed_exchange)||"futures"===e.type&&r.includes(e.listed_exchange)||a.includes(e.listed_exchange)}function _(e,t){return"amex"===t&&"CBOE"===e}},18041:(e,t,i)=>{"use strict";i.d(t,{getStudyTemplateDescString:()=>r,getStudyTemplateMetaInfo:()=>o,getStudyTemplateSaveData:()=>n});var s=i(36313);function o(e,t){return{indicators:e.allStudies(!0).map((e=>({id:e.metaInfo().id,description:e.title(s.TitleDisplayTarget.StatusLine,!0,void 0,!0)}))),interval:t}}function n(e,t,i,s){const n=t.studyTemplate(i,s);return{name:e,content:JSON.stringify(n),meta_info:o(t,n.interval)}}function r(e){const t=new Map;return e.forEach((e=>{const[i,s]=t.get(e.id)||[e.description,0];t.set(e.id,[i,s+1])})),Array.from(t.values()).map((([e,t])=>`${e}${t>1?` x ${t}`:""}`)).join(", ")}},4745:(e,t,i)=>{"use strict";i.d(t,{canShowSpreadActions:()=>o,globalKeypressMatches:()=>n});var s=i(37103);function o(){let e=!1
;return s.enabled("show_spread_operators")&&(e=!0),e}function n(e){if(e.ctrlKey)return!1;if(e.metaKey)return!1;if(!e.charCode)return!1;if(!e.which||e.which<=32)return!1;const t=e.target;return!t||!/^(input|textarea)$/i.test(t.tagName)&&"listbox"!==t.getAttribute("role")}},8686:(e,t,i)=>{"use strict";function s(){return Promise.all([i.e(8836),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(3672),i.e(3359),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(445),i.e(846),i.e(2227),i.e(4931),i.e(9418),i.e(3179),i.e(4426),i.e(9026),i.e(1754)]).then(i.bind(i,89324))}i.d(t,{loadNewSymbolSearch:()=>s})},49470:(e,t,i)=>{"use strict";i.d(t,{tradingService:()=>n});var s=i(16216);const o={id:"TradingService"};function n(){return(0,s.hasService)(o)?(0,s.service)(o):null}},28477:(e,t,i)=>{"use strict";i.d(t,{AbstractBarColorer:()=>s});class s{constructor(){this._backColorers=[]}barStyle(e,t,i){const s={};for(const o of this._backColorers)o.applyBarStyle(e,t,s,i);return this.applyBarStyle(e,t,s,i),s}pushBackBarColorer(e){this._backColorers.unshift(e)}firstColoredBar(e){return null}}},33718:(e,t,i)=>{"use strict";i.d(t,{addPlusButtonProperty:()=>p,restoreAddPlusButtonSettingsValue:()=>m,showPlusButtonOnCursor:()=>d});var s=i(26709),o=i(37103),n=i(1765),r=i(41072),a=i(22613);const l="add_plus_button";function c(){const e=s.keyboardPressedKeysState.value();return void 0!==e&&(Boolean(e.modifiers&s.Modifiers.Alt&&e.modifiers&s.Modifiers.Mod)&&(void 0===e.code||e.altOrOptionCode()||e.controlOrMetaCode()))}const h=new a.WatchedValue(c());s.keyboardPressedKeysState.subscribe((()=>h.setValue(c())));const d=h.readonly();function u(){return o.enabled("chart_crosshair_menu")}function _(){return n.getBool(l,u())}const p=(0,r.createPrimitiveProperty)(_());function m(){p.setValue(u()),n.remove(l)}n.onSync.subscribe(null,(()=>p.setValue(_()))),p.subscribe(null,(()=>{n.setValue(l,p.value()),o.setEnabled("chart_crosshair_menu",!o.enabled("chart_crosshair_menu"))}))},62301:(e,t,i)=>{"use strict";i.d(t,{alignToStep:()=>n});var s=i(60521),o=i.n(s);function n(e,t){return o()(e).div(t).round(0,o().roundHalfUp).mul(t).toNumber()}},25246:(e,t,i)=>{"use strict";i.d(t,{actualAutoLogButtonsVisibility:()=>l,autoLogButtonsVisibilityOptions:()=>r,autoLogButtonsVisibilityProperty:()=>n,restoreAutoLogButtonsVisibilitySettingsValue:()=>a});var s,o=i(64876);!function(e){e.SettingsKey="PriceAxisAutoLogButtons.visibility"}(s||(s={}));const{property:n,availableValues:r,restoreDefaultValue:a,actualBehavior:l}=(0,o.createVisibilityController)("PriceAxisAutoLogButtons.visibility")},72755:(e,t,i)=>{"use strict";i.d(t,{axisLabelBackgroundColor:()=>o});var s=i(58978);const o={common:s.colorsPalette["color-tv-blue-500"],active:s.colorsPalette["color-tv-blue-800"]};var n;!function(e){e.BorderColor="#2E84A6"}(n||(n={}))},32955:(e,t,i)=>{"use strict";i.d(t,{createDwmAligner:()=>h,createTimeToBarTimeAligner:()=>d,isAlignmentEnabled:()=>c});var s=i(37236),o=i(10892),n=i(47312),r=i(51101)
;const a=new n.SessionInfo("Etc/UTC","0000-0000:1234567");var l=i(37103);function c(){return!l.enabled("disable_resolution_rebuild")}const h=function(e,t,i){if(!e||!o.Interval.isDWM(t))return null;const l=new n.SessionInfo(i.timezone,i.session,i.session_holidays,i.corrections),c=(0,r.newBarBuilder)(t,l,a);return{timeToSessionStart:e=>c.tradingDayToSessionStart(e),timeToExchangeTradingDay:e=>{const t=(0,s.utc_to_cal)(l.timezone,e),i=l.spec.correctTradingDay(t);return(0,s.set_hms)(i,0,0,0,0,(0,s.get_timezone)("Etc/UTC")),i.getTime()}}}.bind(null,c()),d=function(e,t,i){if(!e)return e=>e;const s=new n.SessionInfo(i.timezone,i.session,i.session_holidays,i.corrections),o=(0,r.newBarBuilder)(t,s,s,!1);return e=>o.alignTimeIfPossible(e)}.bind(null,c())},17776:(e,t,i)=>{"use strict";i.d(t,{barFunctionByStyle:()=>o});var s=i(52746);function o(e,t){switch(e){case 12:return(0,s.barFunction)("low","low","close");case 2:case 18:case 20:case 14:case 15:case 3:case 10:case 13:return(0,s.barFunction)(t??"close");default:return(0,s.barFunction)("close","open")}}},28001:(e,t,i)=>{"use strict";i.d(t,{BarsRange:()=>o});var s=i(50151);class o{constructor(e,t){(0,s.assert)(e<=t,"The last bar in the bars range should be greater than or equal to the first bar"),this._firstBar=e,this._lastBar=t}firstBar(){return this._firstBar}lastBar(){return this._lastBar}count(){return this._lastBar-this._firstBar+1}contains(e){return this._firstBar<=e&&e<=this._lastBar}unite(e){return null===e?this:new o(Math.min(this._firstBar,e.firstBar()),Math.max(this._lastBar,e.lastBar()))}equals(e){return this._firstBar===e.firstBar()&&this._lastBar===e.lastBar()}static compare(e,t){return null===e||null===t?e===t:e.equals(t)}}},54370:(e,t,i)=>{"use strict";i.d(t,{allChartStyles:()=>o});var s=i(37103);function o(){return function(){const e=[0,1,9,13,2,14,15,3,16,10];return s.enabled("chart_style_hilo")&&e.push(12),e.push(21),e}().concat((s.enabled("japanese_chart_styles"),[8]))}},32853:(e,t,i)=>{"use strict";var s=i(49251).makeFont,o=i(49251).parseFont,n=i(9343).getLogger;const{drawPoly:r}=i(58221);var a=n("Model.ChartTradingUtils"),l={_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 o=100*(1-s.a);i.setValue(Math.max(0,Math.min(o,100)))},getFontFromProperties:function(e,t,i,o){return s(t.value(),e.value(),o.value()?"italic":"",i.value()?"bold":"")},setFontToProperties:function(e,t,i,s,n){var r=o(e);null!==r?(r.family.length>0&&t.setValue(r.family),
i.setValue(r.size),s.setValue(r.bold),n.setValue(r.italic)):a.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)",r(e,t,!0),e.restore()):i&&(e.save(),e.fillStyle="rgba(0, 0, 0, 0.1)",r(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=l},93201:(e,t,i)=>{"use strict";var s;i.d(t,{ColorType:()=>s}),function(e){e.Solid="solid",e.Gradient="gradient"}(s||(s={}))},55803:(e,t,i)=>{"use strict";i.d(t,{ConflatedChunksBuilder:()=>r});var s=i(50151),o=i(12217);const n=[{barsToMerge:10,forBarspacingLargerThen:.03},{barsToMerge:30,forBarspacingLargerThen:.01},{barsToMerge:100,forBarspacingLargerThen:.003},{barsToMerge:500,forBarspacingLargerThen:0}];class r{constructor(e,t){this._plots=e,this._state={chunks:new Map,priceSource:null,priceSourcesProvider:t},this._setEmptyConflatedChunks()}conflatedChunks(e,t){if(t!==this._state.priceSource){this._state.priceSource=t;const e=this._plots.first();e&&(this._setEmptyConflatedChunks(),this._rebuildConflatedChunks(e))}const i=(0,s.ensureDefined)(n.find((t=>t.forBarspacingLargerThen<=e)));return(0,s.ensureDefined)(this._state.chunks.get(i.barsToMerge))}mergeData(e){const t=this._plots.size(),i=this._plots.merge(e);return i&&null!==this._state.priceSource&&(t===this._plots.size()&&i.index===this._plots.lastIndex()?this._updateLatestChunks():this._rebuildConflatedChunks(i)),i}moveData(e){this._plots.move(e),this._plots.size()>0&&this._clearState()}clearData(){this._plots.clear(),this._clearState()}_rebuildConflatedChunks(e){const t=this._state.priceSource;if(null===t)return;const i=e.index,r=this._state.priceSourcesProvider(t),a=(e,t,i)=>{let s=null;for(const o of e){const e=r(o.value);s&&o.index-s.startTime>=i.barsToMerge&&(t.push(s),s=null),s?(s.endTime=o.index,s.high=Math.max(s.high,e),s.low=Math.min(s.low,e),s.close=e):s={startTime:o.index,endTime:o.index,open:e,high:e,low:e,close:e}}s&&t.push(s)};n.forEach((e=>{const t=(0,s.ensureDefined)(this._state.chunks.get(e.barsToMerge)),n=(0,o.lowerbound)(t,i,((e,t)=>e.endTime<t));if(0===n&&t.length>0){const i=t[0].startTime-1,o=(0,s.ensureNotNull)(this._plots.firstIndex()),n=this._plots.rangeIterator(o,i),r=[];a(n,r,e);const l=r.concat(t);this._state.chunks.set(e.barsToMerge,l)}else{const i=(0,s.ensureNotNull)(this._plots.lastIndex());t.splice(n);let o=(0,s.ensureNotNull)(this._plots.firstIndex());t.length&&(o=t[t.length-1].endTime+1);const r=this._plots.rangeIterator(o,i);a(r,t,e)}}))}_updateLatestChunks(){const e=(0,s.ensureNotNull)(this._plots.last()),t=this._state.priceSourcesProvider("close");n.forEach((i=>{const o=(0,
s.ensureDefined)(this._state.chunks.get(i.barsToMerge)),n=t(e.value),r=o[o.length-1];r.high=Math.max(r.high,n),r.low=Math.min(r.low,n),r.close=n,r.endTime=e.index}))}_setEmptyConflatedChunks(){n.forEach((e=>this._state.chunks.set(e.barsToMerge,[])))}_clearState(){this._state.chunks.clear(),this._state.priceSource=null}}},91106:(e,t,i)=>{"use strict";i.d(t,{actualCurrencyUnitVisibility:()=>c,currencyUnitVisibilityOptions:()=>a,currencyUnitVisibilityProperty:()=>r,migrateShowCurrencyAndShowUnitProperties:()=>d,restoreCurrencyUnitVisibilitySettingsValue:()=>l});var s,o=i(64876),n=i(1765);!function(e){e.SettingsKey="PriceAxisCurrencyAndUnit.visibility"}(s||(s={}));const{property:r,availableValues:a,restoreDefaultValue:l,actualBehavior:c}=(0,o.createVisibilityController)("PriceAxisCurrencyAndUnit.visibility");let h=!1;function d(e,t){h||(h=!0,void 0===n.default.getValue("PriceAxisCurrencyAndUnit.visibility")&&r().setValue(e||t?"alwaysOn":"alwaysOff"))}},66786:(e,t,i)=>{"use strict";i.d(t,{CustomSourceBase:()=>s});class s{constructor(e,t){this._id=e,this._model=t}id(){return this._id}isHoveredEnabled(){return!0}isSelectionEnabled(){return!1}priceScale(){return null}paneViews(e){return[]}labelPaneViews(e){return[]}priceAxisViews(e,t){return[]}updateViewsForPane(e,t){e.containsMainSeries()&&this.updateAllViews(t)}}},29447:(e,t,i)=>{"use strict";i.d(t,{isLineToolState:()=>r,isMainSeriesState:()=>o,isStudyLineToolState:()=>a,isStudyState:()=>n});var s=i(11946);function o(e){return"MainSeries"===e.type}function n(e){return Boolean(e.type)&&e.type.toLowerCase().startsWith("study")}function r(e){return Boolean(e.type)&&(0,s.isLineToolName)(e.type)}function a(e){return Boolean(e.type)&&(0,s.isStudyLineToolName)(e.type)}},72207:(e,t,i)=>{"use strict";i.d(t,{DataSource:()=>d,getTranslatedStringForSource:()=>c,toInputDisplayFlags:()=>h});var s=i(95804),o=i(36313),n=i(4226),r=i(48096),a=i(22613),l=i(69422);function c(e,t){return new s.TranslatedString(t.name(),t.title(e))}function h(e){switch(e){case o.TitleDisplayTarget.DataWindow:return l.InputDisplayFlags.DataWindow;case o.TitleDisplayTarget.StatusLine:case o.TitleDisplayTarget.Alerts:return l.InputDisplayFlags.StatusLine}}class d{constructor(e){this.isSeries=!1,this._isDestroyed=!1,this._hasAlert=new a.WatchedValue(!1),this._alertStatus=new a.WatchedValue(0),this._alertCreationAvailable=new a.WatchedValue(!1),this._zorder=0,this._priceScale=null,this._ownerSource=null,this._userEditEnabled=!0,this._priceScaleChanged=new r.Delegate,this._isSelectionEnabled=!0,this._instanceId=(0,n.randomHashN)(6),this._ownerSourceChanged=new r.Delegate,this._zOrderChanged=new r.Delegate,this._id=new a.WatchedValue(e??(0,n.randomHashN)(6))}destroy(){this._isDestroyed=!0}id(){return this._id.value()}idWV(){return this._id.readonly()}instanceId(){return this._instanceId}preferNoScale(){return!1}setId(e){this._id.setValue(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}hasPriceScale(){return null!==this._priceScale}setPriceScale(e){this._priceScale!==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}propertyByPath(e){const t=e.split(".");if(t.length<1)throw new Error("Invalid path");const i=t[0];if("properties"===i){const e=this.properties();return 1===t.length?e:e.childByPath(t.slice(1).join("."))}throw new Error(`Unknown property root: ${i}`)}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}allowsMovingBetweenPanes(){return!0}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}async stateForAlertAsync(){return this.stateForAlert()}canHasAlert(){return!1}canHasAlertOnLineTools(){return!1}hasAlert(){return this._hasAlert.readonly()}alertCreationAvailable(){return this._alertCreationAvailable.readonly()}hasStateForAlert(){return!1}idForAlert(){return this._id.value()}alertStatus(){return this._alertStatus.readonly()}_getAlertCreationAvailable(){return!1}_updateAlertCreationAvailable(){0}}},40137:(e,t,i)=>{"use strict";i.d(t,{DataWindowItem:()=>s,DataWindowView:()=>o});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 o{constructor(){this._items=[],
this._header="",this._title=""}header(){return this._header}title(){return this._title}items(){return this._items}canShowItems(){return!0}update(e){}}},97363:(e,t,i)=>{"use strict";i.d(t,{dateFormatProperty:()=>l,restoreDateFormatSettingsValue:()=>c});var s=i(1765),o=i(41072),n=i(10718);const r="date_format";function a(){return s.getValue(r,(0,n.defaultDateFormat)())}const l=(0,o.createPrimitiveProperty)(a());function c(){l.setValue((0,n.defaultDateFormat)()),s.remove(r)}s.onSync.subscribe(null,(()=>l.setValue(a()))),l.subscribe(null,(()=>s.setValue(r,l.value())))},78176:(e,t,i)=>{"use strict";i.d(t,{DefaultProperty:()=>F,allowSavingDefaults:()=>A,cleanUpStateKeys:()=>x,createDefaultsState:()=>M,extractAllPropertiesKeys:()=>L,extractState:()=>E,extractThemedColors:()=>D});var s=i(90054),o=i(16738),n=i(81960),r=i(54029),a=i(47339),l=i(28569),c=i(50279),h=i(15943),d=i(82433),u=i(83873),_=i(50151),p=i(24377),m=i(9343),g=i(29970),f=i(24633),y=i(45345),v=i(22489),S=i(48096),b=i(55114),w=i(60973),C=i(43337);const T=(0,m.getLogger)("ThemedDefaults");function P(e){return e.value()===f.StdTheme.Dark?f.StdTheme.Dark:f.StdTheme.Light}function x(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,r.default)(e,t);if(!(0,d.default)(i)||0!==Object.keys(i).length)break;(0,n.default)(e,t),t.pop()}}}function M(e,t,i,n){const r=e?w.defaults:w.factoryDefaults,a=t.startsWith("study_")?(0,s.default)(r("study")):{};let l=(0,s.default)(r(t,n));return t.startsWith("study_")&&l.inputs&&delete l.inputs.symbol,"linetoolicon"===t&&e&&(l.icon=(0,w.defaults)(t).icon),"linetooemoji"===t&&e&&(l.emoji=(0,w.defaults)(t).emoji),"linetoolsticker"===t&&e&&(l.sticker=(0,w.defaults)(t).sticker),l=(0,s.default)(l),x(l,i),(0,o.default)(a,l),a}let I=!1;function A(e){I=e}function L(e){const t=Object.keys(e),i=[];return t.forEach((t=>{const s=e[t];if((0,d.default)(s)){L(s).forEach((e=>i.push(`${t}.${e}`)))}else i.push(t)})),i}function k(e,t,i=""){if(1===t.length&&"*"===t[0])return e;const s={};for(const o of t){const n=o.split("."),r=n[0],a=e[r],l=""===i?r:`${i}.${r}`;if(e.hasOwnProperty(r))if(n.length>1){if(!(0,d.default)(a)){T.logError(`path ${l} must be an object, but it is a primitive`);continue}{const e=t.filter((e=>e.startsWith(`${r}.`))).map((e=>e.split(".").slice(1).join(".")));s[r]=k(a,e,l)}}else{if((0,d.default)(a)){T.logError(`path ${l} must be a primitive, but it is an object`);continue}s[r]=a}}return s}function E(e,t,i){if(!e)return{};let s=e;return t&&(s=k(e,t)),i&&x(s,i,!0),s}function D(e,t){const i=L(e),s=[];for(const o of i){const i=(0,r.default)(e,o),n=(0,r.default)(t,o);(0,_.assert)(void 0!==i,`Light theme value for ${o} is undefined`),(0,_.assert)(void 0!==n,`Dark theme value for ${o} is undefined`),s.push({path:o,colors:[i,n]})}return s}function B(e,t){e.includes(t)||e.push(t)}function V(e,t){const i=e.indexOf(t);-1!==i&&e.splice(i,1)}function R(e,t){const i=(0,l.default)(e,((e,i,s)=>{if(void 0===t[s])return e;if(!(0,c.default)(i,t[s]))if((0,d.default)(i)&&(0,d.default)(t[s])){
const o=R(i,t[s]);void 0!==o&&(e[s]=o)}else e[s]=i;return e}),{});return(0,h.default)(i)?void 0:i}function N(e){return e===f.StdTheme.Dark?1:0}function O(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(!(0,u.default)(e)||!(0,u.default)(t))return!1;const i=(0,p.tryParseRgba)(e),s=(0,p.tryParseRgba)(t);return!(!i||!s)&&!!(0,g.colorsAreCloseEnough)(e,t)}class F extends C.Property{constructor(e){const{defaultName:t,nonThemedDefaultsKeys:i,themedDefaultsKeys:s,excludedDefaultsKeys:n=[],themedColors:r,replaceThemedColorsOnThemeChange:a=!1,allStateKeys:l,excludedStateKeys:c=[],excludedTemplateKeys:h=[],state:d,useUserPreferences:u=!0,saveNonDefaultUserPreferencesOnly:p=!1,ignoreAllowSavingDefaults:m=!1,alwaysSaveDefaultKeys:g=["version"],saveDefaultsConsumer:C=w.saveDefaults,factoryDefaultsSupplier:T=()=>M(!1,t,[],null),schema:x=(0,b.createPropertySchema)(T()),theme:I=y.watchedTheme.spawnOwnership()}=e;super(void 0,x),this._themedColors=[],this._restoreFactoryDefaultsEvent=new S.Delegate,this._replaceThemedColorsOnThemeChange=!1,this._forbidSavingDefaults=!1,this._defaultName=t,this._useUserPreferences=u,this._saveNonDefaultUserPreferencesOnly=p,this._ignoreAllowSavingDefaults=m,this._saveDefaultsConsumer=C,this._factoryDefaultsSupplier=T,this._allStateKeys=l,this._excludedStateKeys=c,this._nonThemedDefaultsKeys=i,this._themedDefaultsKeys=s,this._allDefaultsKeys=i||s?[...i??[],...s??[]]:void 0,this._excludedDefaultsKeys=n,this._excludedTemplateKeys=h,this._themedColors=r,this._alwaysSaveDefaultKeys=g,(0,_.assert)(void 0===this._allDefaultsKeys||0===this._excludedDefaultsKeys.length,"Defaults keys and excluded defaults keys cannot be used at the same time"),(0,_.assert)(void 0===this._allStateKeys||0===this._excludedStateKeys.length,"State keys and excluded state keys cannot be used at the same time"),this._theme=I;const A=P(this._theme);this.merge((0,o.default)(this._factoryDefaultsForTheme((0,v.isStdThemeName)(A)?A:f.StdTheme.Light),this._userSettings(),E(d,l,c))),r&&a&&this.setThemedColors(r),this._restoreFactoryDefaultsEvent=new S.Delegate}destroy(){this._theme?.release(),this._unsubscribeWatchedTheme?.(),super.destroy()}applyTemplate(e,t){this.mergeAndFire(E((0,o.default)((0,s.default)(t),e),this._allStateKeys,this._excludedTemplateKeys))}preferences(){return E(this.state(this._excludedDefaultsKeys),this._allDefaultsKeys)}template(){return E(this.state(void 0,4),void 0,this._excludedTemplateKeys)}mergePreferences(e){this.mergeAndFire(E(e,this._allDefaultsKeys,this._excludedDefaultsKeys))}addExcludedKey(e,t){1&t&&B(this._excludedDefaultsKeys,e),2&t&&B(this._excludedStateKeys,e),4&t&&B(this._excludedTemplateKeys,e)}removeExcludedKey(e,t){1&t&&V(this._excludedDefaultsKeys,e),2&t&&V(this._excludedStateKeys,e)}restoreFactoryDefaults(){const e=this.factoryDefaults();x(e,this._excludedDefaultsKeys),this.mergeAndFire(e),this._defaultName.startsWith("study_")&&!this._defaultName.startsWith("study_VbPFixed")||this._saveDefaultsConsumer(this._defaultName),this._restoreFactoryDefaultsEvent.fire()}
onRestoreFactoryDefaults(){return this._restoreFactoryDefaultsEvent}saveDefaults(){if(!this._useUserPreferences||this._forbidSavingDefaults)return;let e;if(this._saveNonDefaultUserPreferencesOnly){const t=this.state(this._excludedDefaultsKeys),i=this.factoryDefaults();if(e=R(E(t,this._nonThemedDefaultsKeys),E(i,this._nonThemedDefaultsKeys,this._excludedDefaultsKeys)),this._alwaysSaveDefaultKeys.length){const i=E(t,this._alwaysSaveDefaultKeys);e=e??{},(0,o.default)(e,i)}const s=this.themeDefaults(P(this._theme)),n=this.themeState(),r=R(n,s);(0,h.default)(r)||(e=e??{},(0,o.default)(e,n))}else e=this.preferences();this._saveDefaultsConsumer(this._defaultName,e)}themeDefaults(e){if(this._themedColors)return function(e,t){const i={};for(const{path:s,colors:o}of e)(0,a.default)(i,s,o[N(t)]);return i}(this._themedColors,e===f.StdTheme.Dark?f.StdTheme.Dark:f.StdTheme.Light);return E(this._factoryDefaultsSupplier(),this._themedDefaultsKeys,this._excludedDefaultsKeys)}factoryDefaults(){return this._factoryDefaultsForTheme(P(this._theme))}themeState(){const e=super.state(this._excludedDefaultsKeys),t=this._themedColors;return E(e,t?t.map((e=>e.path)):this._themedDefaultsKeys)}allThemePropertiesAreDefault(e){(0,_.assert)(!!this._themedColors,"This method should not be called if themed colors are not set");return function(e,t,i=[]){for(const s of i){const i=s.path;if(!O((0,r.default)(e,i),(0,r.default)(t,i)))return!1}return!0}(this.themeState(),this.themeDefaults(e),this._themedColors)}clone(e){return new F(this._options())}setThemedColors(e){if(this._themedColors=e,void 0===this._unsubscribeWatchedTheme){const e=()=>{this._updateThemedColors(!1)};this._theme.subscribe(e),this._unsubscribeWatchedTheme=()=>this._theme.unsubscribe(e)}this._updateThemedColors(!0)}applyDefaultThemedProperties(e){this._themedColors&&this.mergeAndFire(this.themeDefaults(e))}state(e,t){return E(super.state([...this._excludedStateKeys,...e??[]],t),this._allStateKeys)}_updateThemedColors(e){if(!this._themedColors)return;const t=P(this._theme),i=t===f.StdTheme.Light?f.StdTheme.Dark:f.StdTheme.Light;for(const s of this._themedColors){const o=(0,_.ensureDefined)(this.childByPath(s.path)),n=s.colors[N(i)];(""===o.value()||!e&&O(o.value(),n))&&o.setValue(s.colors[N(t)])}}_userSettings(){if(!this._useUserPreferences)return;const e=M(!0,this._defaultName,[],null);if(!e)return;return E((0,b.extractStateWithSchema)(e,this._schema,1),this._allDefaultsKeys,this._excludedDefaultsKeys)}_options(){return{defaultName:this._defaultName,factoryDefaultsSupplier:this._factoryDefaultsSupplier,state:this.state(),nonThemedDefaultsKeys:this._nonThemedDefaultsKeys,themedDefaultsKeys:this._themedDefaultsKeys,excludedDefaultsKeys:this._excludedDefaultsKeys,themedColors:this._themedColors,replaceThemedColorsOnThemeChange:this._replaceThemedColorsOnThemeChange,allStateKeys:this._allStateKeys,excludedStateKeys:this._excludedDefaultsKeys,excludedTemplateKeys:this._excludedTemplateKeys,useUserPreferences:this._useUserPreferences,
saveNonDefaultUserPreferencesOnly:this._saveNonDefaultUserPreferencesOnly,ignoreAllowSavingDefaults:this._ignoreAllowSavingDefaults,saveDefaultsConsumer:this._saveDefaultsConsumer,alwaysSaveDefaultKeys:this._alwaysSaveDefaultKeys,theme:this._theme.spawnOwnership()}}_childChanged(e,t){super._childChanged(e,t),this._propertyAffectsDefaults(t)&&this.saveDefaults()}_fireMergeAndFireChangedProps(e){this._forbidSavingDefaults=!0,super._fireMergeAndFireChangedProps(e),this._forbidSavingDefaults=!1,e.some((e=>this._propertyAffectsDefaults(e.pathToRootProperty())))&&this.saveDefaults()}_factoryDefaultsForTheme(e){return(0,o.default)(this._factoryDefaultsSupplier(),this.themeDefaults(e))}_propertyAffectsDefaults(e){return(this._ignoreAllowSavingDefaults||I)&&!this._defaultName.startsWith("replayStudyStrategy")&&(!this._defaultName.startsWith("study_")||this._defaultName.startsWith("study_VbPFixed"))&&(this._allDefaultsKeys&&this._allDefaultsKeys.includes(e)||!this._allDefaultsKeys&&!this._excludedDefaultsKeys?.includes(e))&&(0,C.isPrimitiveType)(this.childByPath(e)?.value())}}},60973:(e,t,i)=>{"use strict";var{clone:s,merge:o}=i(87465),n=i(86572).PlDisplay;const{generateColor:r}=i(52859),{getStdChartTheme:a}=i(24317),{DEFAULT_THEME:l}=i(22489),c=i(49156).colors;var h=i(86572).TradedGroupHorizontalAlignment,d=i(82095),u=i(36947).LineToolPitchforkStyle,_=i(45580).LineToolBarsPatternMode,p=i(4359),m=p.LineStudyPlotStyle,g=p.STUDYPLOTDISPLAYTARGET,f=i(19679),y=i(97902).PriceAxisLastValueMode,v=i(7024).MagnetMode,S=i(25672).LineEnd,b=i(93201).ColorType;const w=i(59883).DEFAULT_LINE_TOOL_LINE_WIDTH;var C=i(97760).StatsPosition,T=i(57511).sessionsPreferencesDefault,P=i(72755).axisLabelBackgroundColor,x=i(59064).mainSeriesProperties;const{LINESTYLE_SOLID:M,LINESTYLE_DASHED:I}=i(69558);var A=i(9343).getLogger("Chart.Defaults");const{colorWhite:L,colorWhiteAlpha25:k,colorTvBlue50:E,colorTvBlue500:D,colorTvBlue500Alpha30:B,colorTvBlue500Alpha25:V,colorTvBlue500Alpha20:R,colorTvBlue600:N,colorDeepBlue200:O,colorDeepBlue300:F,colorDeepBlue500:W,colorDeepBlue500Alpha20:H,colorSkyBlue500:z,colorSkyBlue500Alpha20:U,colorSkyBlue500Alpha25:j,colorSkyBlue700:G,colorSkyBlue700Alpha70:q,colorDefaultRed:$,colorRipeRed200:K,colorRipeRed300:Y,colorRipeRed400:Z,colorRipeRed400Alpha5:X,colorRipeRed500:J,colorRipeRed500Alpha30:Q,colorRipeRed500Alpha20:ee,colorRipeRed600:te,colorGrapesPurple500:ie,colorGrapesPurple500Alpha0:se,colorGrapesPurple500Alpha20:oe,colorGrapesPurple500Alpha70:ne,colorBerryPink400:re,colorBerryPink500:ae,colorBerryPink500Alpha20:le,colorBerryPink500Alpha25:ce,colorMintyGreen100:he,colorMintyGreen400:de,colorMintyGreen500:ue,colorMintyGreen500Alpha20:_e,colorIguanaGreen300:pe,colorIguanaGreen500:me,colorIguanaGreen500Alpha20:ge,colorTanOrange300:fe,colorTanOrange500:ye,colorTanOrange500Alpha20:ve,colorTanOrange600:Se,colorTanOrange700:be,colorColdGray150:we,colorColdGray400:Ce,colorColdGray450:Te,colorColdGray500:Pe,colorColdGray550:xe,colorColdGray900:Me,colorColdGray750:Ie,colorForestGreen300:Ae,colorForestGreen300Alpha5:Le}=c
;var ke=function(e){var t=function(e,t){return{color:e,visible:t}},i=function(e,t,i,s){const o={coeff:e,color:t,visible:i};return s&&(o.text=""),o},p=function(e,t,i,s,o){return{coeff:e,color:t,visible:i,linestyle:void 0===s?M:s,linewidth:void 0===o?w:o}},A=function(e,t,i){return{color:e,width:void 0===i?w:i,visible:t}},ke=function(e,t,i,s,o){return{color:e,visible:t,width:i,x:s,y:o}},Ee=function(e,t,i,s,o,n){return{coeff1:e,coeff2:t,color:i,visible:s,linestyle:void 0===o?M:o,linewidth:void 0===n?w:n}};if(void 0===TradingView.defaultProperties){var Be;switch(window.locale){case"ar_AE":Be="Asia/Dubai";break;case"au":Be="Australia/Sydney";break;case"br":Be="America/Sao_Paulo";break;case"ca":Be="America/Toronto";break;case"de_DE":case"it":Be="Europe/Berlin";break;case"es":Be="Europe/Madrid";break;case"he_IL":case"tr":Be="Europe/Athens";break;case"hu_HU":case"pl":Be="Europe/Warsaw";break;case"id":case"th_TH":case"vi_VN":Be="Asia/Bangkok";break;case"in":Be="Asia/Kolkata";break;case"ja":case"kr":Be="Asia/Tokyo";break;case"ms_MY":Be="Asia/Singapore";break;case"ru":Be="Europe/Moscow";break;case"uk":Be="Europe/London";break;case"zh_CN":case"zh_TW":Be="Asia/Shanghai";break;default:Be="Etc/UTC"}const e=a(l);TradingView.defaultProperties={chartproperties:o({timezone:Be,priceScaleSelectionStrategyName:"auto",inactivityGaps:!1,paneProperties:{backgroundType:b.Solid,gridLinesMode:"both",vertGridProperties:{style:M},horzGridProperties:{style:M},crossHairProperties:{style:I,transparency:0,width:1},topMargin:10,bottomMargin:8,axisProperties:{autoScale:!0,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,indexedTo100:!1,log:!1,logDisabled:!1,alignLabels:!0,isInverted:!1},legendProperties:{showStudyArguments:!0,showStudyTitles:!0,showStudyValues:!0,showSeriesTitle:!0,showSeriesOHLC:!0,showLegend:!0,showLastDayChange:!1,showBarChange:!0,showVolume:!1,showBackground:!0,showPriceSource:!0,backgroundTransparency:50,showLogo:!0,showTradingButtons:!0,showTradingButtonsMobile:!0,showSeriesLegendCloseOnMobile:!0,barChangeUpColor:ue,barChangeDownColor:J,useBarChangeCustomColors:!1},separatorColor:we},scalesProperties:{fontSize:12,scaleSeriesOnly:!1,showSeriesLastValue:!0,seriesLastValueMode:y.LastValueAccordingToScale,showSeriesPrevCloseValue:!1,showStudyLastValue:!0,showSymbolLabels:!1,showStudyPlotLabels:!1,showBidAskLabels:!1,showPrePostMarketPriceLabel:!0,showFundamentalNameLabel:!1,showFundamentalLastValue:!0,barSpacing:f.DEFAULT_BAR_SPACING,axisHighlightColor:V,axisLineToolLabelBackgroundColorCommon:P.common,axisLineToolLabelBackgroundColorActive:P.active,showPriceScaleCrosshairLabel:!0,showTimeScaleCrosshairLabel:!0,crosshairLabelBgColorLight:Me,crosshairLabelBgColorDark:Ie,saveLeftEdge:!1},mainSeriesProperties:o(x,e.content.mainSourceProperties),chartEventsSourceProperties:{visible:!0,futureOnly:!0,breaks:{color:"#555555",visible:!1,style:I,width:1}},tradingProperties:{showPositions:!0,positionPL:{visibility:!0,display:n.Money},bracketsPL:{visibility:!0,display:n.Money},positionAndBracketsPL:!0,showOrders:!0,
showExecutions:!0,showExecutionsLabels:!1,showReverse:!0,horizontalAlignment:h.Right,extendLeft:!0,lineLength:5,lineWidth:1,lineStyle:M},volumePaneSize:"large"},e.content.chartProperties),sessions:o(T,e.content.sessions),drawings:{magnet:!1,magnetSnapsToIndicators:!1,magnetMode:v.WeakMagnet,stayInDrawingMode:!1,drawOnAllCharts:!0,drawOnAllChartsMode:1},linetoolorder:{extendLeft:"inherit",lineLength:"inherit",lineLengthUnit:"percentage",lineColor:$,lineActiveBuyColor:"#4094e8",lineInactiveBuyColor:"rgba(64, 148, 232, 0.5)",lineActiveSellColor:"#e75656",lineInactiveSellColor:"rgba(231, 86, 86, 0.5)",lineStyle:"inherit",lineWidth:"inherit",bodyBorderActiveBuyColor:"#4094e8",bodyBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",bodyBorderActiveSellColor:"#e75656",bodyBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",bodyBackgroundColor:k,bodyBackgroundTransparency:25,bodyTextInactiveLimitColor:"rgba(38, 140, 2, 0.5)",bodyTextActiveLimitColor:"#268c02",bodyTextInactiveStopColor:"rgba(231, 86, 86, 0.5)",bodyTextActiveStopColor:"#e75656",bodyTextInactiveBuyColor:"rgba(64, 148, 232, 0.5)",bodyTextActiveBuyColor:"#4094e8",bodyTextInactiveSellColor:"rgba(231, 86, 86, 0.5)",bodyTextActiveSellColor:"#e75656",bodyFontFamily:"Verdana",bodyFontSize:9,bodyFontBold:!0,bodyFontItalic:!1,quantityBorderActiveBuyColor:"#4094e8",quantityBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",quantityBorderActiveSellColor:"#e75656",quantityBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",quantityBackgroundInactiveBuyColor:"rgba(64, 148, 232, 0.5)",quantityBackgroundActiveBuyColor:"#4094e8",quantityBackgroundInactiveSellColor:"rgba(231, 86, 86, 0.5)",quantityBackgroundActiveSellColor:"#e75656",quantityTextColor:L,quantityTextTransparency:0,quantityFontFamily:"Verdana",quantityFontSize:9,quantityFontBold:!0,quantityFontItalic:!1,cancelButtonBorderActiveBuyColor:"#4094e8",cancelButtonBorderInactiveBuyColor:"rgba(64, 148, 232, 0.5)",cancelButtonBorderActiveSellColor:"#e75656",cancelButtonBorderInactiveSellColor:"rgba(231, 86, 86, 0.5)",cancelButtonBackgroundColor:k,cancelButtonBackgroundTransparency:25,cancelButtonIconActiveBuyColor:"#4094e8",cancelButtonIconInactiveBuyColor:"rgba(64, 148, 232, 0.5)",cancelButtonIconActiveSellColor:"#e75656",cancelButtonIconInactiveSellColor:"rgba(231, 86, 86, 0.5)",tooltip:"",modifyTooltip:"",cancelTooltip:""},linetoolposition:{extendLeft:"inherit",lineLength:"inherit",lineLengthUnit:"percentage",lineBuyColor:"#4094e8",lineSellColor:"#e75656",lineStyle:"inherit",lineWidth:"inherit",bodyBorderBuyColor:"#4094e8",bodyBorderSellColor:"#e75656",bodyBackgroundColor:k,bodyBackgroundTransparency:25,bodyTextPositiveColor:"#268c02",bodyTextNeutralColor:"#646464",bodyTextNegativeColor:"#e75656",bodyFontFamily:"Verdana",bodyFontSize:9,bodyFontBold:!0,bodyFontItalic:!1,quantityBorderBuyColor:"#4094e8",quantityBorderSellColor:"#e75656",quantityBackgroundBuyColor:"#4094e8",quantityBackgroundSellColor:"#e75656",quantityTextColor:L,quantityTextTransparency:0,quantityFontFamily:"Verdana",quantityFontSize:9,quantityFontBold:!0,
quantityFontItalic:!1,reverseButtonBorderBuyColor:"#4094e8",reverseButtonBorderSellColor:"#e75656",reverseButtonBackgroundColor:k,reverseButtonBackgroundTransparency:25,reverseButtonIconBuyColor:"#4094e8",reverseButtonIconSellColor:"#e75656",closeButtonBorderBuyColor:"#4094e8",closeButtonBorderSellColor:"#e75656",closeButtonBackgroundColor:k,closeButtonBackgroundTransparency:25,closeButtonIconBuyColor:"#4094e8",closeButtonIconSellColor:"#e75656",tooltip:"",protectTooltip:"",closeTooltip:"",reverseTooltip:""},linetoolexecution:{direction:"buy",arrowHeight:8,arrowSpacing:1,arrowBuyColor:"#4094e8",arrowSellColor:"#e75656",text:"",textColor:c.colorBlack,textTransparency:0,fontFamily:"Verdana",fontSize:10,fontBold:!1,fontItalic:!1,tooltip:""},linetoolimage:{transparency:0,cssWidth:0,cssHeight:0,angle:0},linetoolbezierquadro:{linecolor:D,linewidth:w,fillBackground:!1,backgroundColor:R,transparency:50,linestyle:M,extendLeft:!1,extendRight:!1,leftEnd:S.Normal,rightEnd:S.Normal},linetoolbeziercubic:{linecolor:W,linewidth:w,fillBackground:!1,backgroundColor:H,transparency:80,linestyle:M,extendLeft:!1,extendRight:!1,leftEnd:S.Normal,rightEnd:S.Normal},linetooltrendline:{linecolor:D,linewidth:w,linestyle:M,extendLeft:!1,extendRight:!1,leftEnd:S.Normal,rightEnd:S.Normal,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:D,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:C.Right},linetoolinfoline:{linecolor:D,linewidth:w,linestyle:M,extendLeft:!1,extendRight:!1,leftEnd:S.Normal,rightEnd:S.Normal,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:D,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!0,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!0,showPercentPriceRange:!0,showPipsPriceRange:!0,showBarsRange:!0,showDateTimeRange:!0,showDistance:!0,showAngle:!0,statsPosition:C.Center},linetooltimecycles:{linecolor:"#159980",linewidth:w,fillBackground:!0,backgroundColor:"rgba(106, 168, 79, 0.5)",transparency:50,linestyle:M},linetoolsineline:{linecolor:"#159980",linewidth:w,linestyle:M},linetooltrendangle:{linecolor:D,linewidth:w,linestyle:M,fontsize:12,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,extendRight:!1,extendLeft:!1,statsPosition:C.Right},linetooldisjointangle:{linecolor:ue,linewidth:w,linestyle:M,fillBackground:!0,backgroundColor:_e,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:S.Normal,rightEnd:S.Normal,textcolor:ue,fontsize:12,bold:!1,italic:!1,showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1,labelVisible:!1,labelHorzAlign:"left",labelVertAlign:"bottom",labelTextColor:ue,labelFontSize:14,labelBold:!1,labelItalic:!1},linetoolflatbottom:{linecolor:ye,linewidth:w,linestyle:M,fillBackground:!0,backgroundColor:ve,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:S.Normal,
rightEnd:S.Normal,textcolor:ye,fontsize:12,bold:!1,italic:!1,showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1,labelVisible:!1,labelHorzAlign:"left",labelVertAlign:"bottom",labelTextColor:ye,labelFontSize:14,labelBold:!1,labelItalic:!1},linetoolriskrewardshort:{linecolor:Pe,linewidth:1,textcolor:L,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:ee,profitBackground:_e,stopBackgroundTransparency:80,profitBackgroundTransparency:80,drawBorder:!1,borderColor:"#667b8b",compact:!1,riskDisplayMode:"percents",accountSize:1e3,lotSize:1,risk:25,alwaysShowStats:!1,showPriceLabels:!0,currency:"NONE"},linetoolriskrewardlong:{linecolor:Pe,linewidth:1,textcolor:L,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:ee,profitBackground:_e,stopBackgroundTransparency:80,profitBackgroundTransparency:80,drawBorder:!1,borderColor:"#667b8b",compact:!1,riskDisplayMode:"percents",accountSize:1e3,lotSize:1,risk:25,alwaysShowStats:!1,showPriceLabels:!0,currency:"NONE"},linetoolarrow:{linecolor:D,linewidth:w,linestyle:M,extendLeft:!1,extendRight:!1,leftEnd:S.Normal,rightEnd:S.Arrow,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:D,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:C.Right},linetoolray:{linecolor:D,linewidth:w,linestyle:M,extendLeft:!1,extendRight:!0,leftEnd:S.Normal,rightEnd:S.Normal,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:D,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:C.Right},linetoolextended:{linecolor:D,linewidth:w,linestyle:M,extendLeft:!0,extendRight:!0,leftEnd:S.Normal,rightEnd:S.Normal,horzLabelsAlign:"center",vertLabelsAlign:"bottom",textcolor:D,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:C.Right},linetoolhorzline:{linecolor:D,linewidth:w,linestyle:M,showPrice:!0,textcolor:D,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"middle"},linetoolhorzray:{linecolor:D,linewidth:w,linestyle:M,showPrice:!0,textcolor:D,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"top"},linetoolvertline:{linecolor:D,linewidth:w,linestyle:M,extendLine:!0,showTime:!0,horzLabelsAlign:"center",vertLabelsAlign:"middle",textcolor:D,textOrientation:"vertical",fontsize:14,bold:!1,italic:!1},linetoolcrossline:{linecolor:D,linewidth:w,linestyle:M,showPrice:!0,showTime:!0},linetoolfibtimezone:{horzLabelsAlign:"right",vertLabelsAlign:"bottom",showLabels:!0,fillBackground:!1,transparency:80,trendline:{visible:!0,
color:"#808080",linewidth:1,linestyle:I},level1:p(0,Pe,!0),level2:p(1,D,!0),level3:p(2,D,!0),level4:p(3,D,!0),level5:p(5,D,!0),level6:p(8,D,!0),level7:p(13,D,!0),level8:p(21,D,!0),level9:p(34,D,!0),level10:p(55,D,!0),level11:p(89,D,!0)},linetooltext:{color:D,fontsize:14,fillBackground:!1,backgroundColor:V,backgroundTransparency:70,drawBorder:!1,borderColor:xe,bold:!1,italic:!1,fixedSize:!0,wordWrap:!1,wordWrapWidth:200},linetooltextabsolute:{color:D,fontsize:14,fillBackground:!1,backgroundColor:V,backgroundTransparency:70,drawBorder:!1,borderColor:xe,bold:!1,italic:!1,fixedSize:!1,wordWrap:!1,wordWrapWidth:200},linetoolballoon:{color:L,backgroundColor:ne,borderColor:se,fontsize:14,transparency:30},linetoolcomment:{color:L,backgroundColor:D,borderColor:D,fontsize:16,transparency:0},linetoolbrush:{linecolor:z,linewidth:w,smooth:5,fillBackground:!1,backgroundColor:z,transparency:50,leftEnd:S.Normal,rightEnd:S.Normal},linetoolhighlighter:{linecolor:ee,smooth:5,transparency:80,width:20},linetoolpolyline:{linecolor:z,linewidth:w,linestyle:M,fillBackground:!0,backgroundColor:U,transparency:80,filled:!1},linetoolsignpost:{emoji:"🙂",showImage:!1,plateColor:D,fontSize:12,bold:!1,italic:!1},linetoolpath:{lineColor:D,lineWidth:w,lineStyle:M,leftEnd:S.Normal,rightEnd:S.Arrow},linetoolarrowmarkleft:{color:D,arrowColor:D,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkup:{color:ue,arrowColor:ue,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkright:{color:D,arrowColor:D,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkdown:{color:te,arrowColor:te,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolflagmark:{flagColor:D},linetoolpricelabel:{color:L,backgroundColor:D,borderColor:D,fontWeight:"bold",fontsize:14,transparency:0},linetoolarrowmarker:{backgroundColor:N,textColor:N,bold:!0,italic:!1,fontsize:16},linetoolrotatedrectangle:{color:me,fillBackground:!0,backgroundColor:ge,transparency:50,linewidth:w},linetoolcircle:{color:ye,backgroundColor:ve,fillBackground:!0,linewidth:w,textColor:ye,fontSize:14,bold:!1,italic:!1},linetoolellipse:{color:J,fillBackground:!0,backgroundColor:ee,transparency:50,linewidth:w,textColor:J,fontSize:14,bold:!1,italic:!1},linetoolarc:{color:ae,fillBackground:!0,backgroundColor:le,transparency:80,linewidth:w},linetoolprediction:{linecolor:D,linewidth:w,sourceBackColor:D,sourceTextColor:L,sourceStrokeColor:D,targetStrokeColor:D,targetBackColor:D,targetTextColor:L,successBackground:me,successTextColor:L,failureBackground:J,failureTextColor:L,intermediateBackColor:"#ead289",intermediateTextColor:"#6d4d22",transparency:10,centersColor:"#202020"},linetooltriangle:{color:ue,fillBackground:!0,backgroundColor:_e,transparency:80,linewidth:w},linetoolcallout:{color:L,backgroundColor:q,transparency:50,linewidth:w,fontsize:14,bordercolor:G,bold:!1,italic:!1,wordWrap:!1,wordWrapWidth:200},linetoolparallelchannel:{linecolor:D,linewidth:w,linestyle:M,extendLeft:!1,extendRight:!1,fillBackground:!0,backgroundColor:R,transparency:20,showMidline:!0,midlinecolor:D,midlinewidth:1,
midlinestyle:I,labelVisible:!1,labelHorzAlign:"left",labelVertAlign:"bottom",labelTextColor:D,labelFontSize:14,labelBold:!1,labelItalic:!1},linetoolelliottimpulse:{degree:7,showWave:!0,color:"#3d85c6",linewidth:w},linetoolelliotttriangle:{degree:7,showWave:!0,color:ye,linewidth:w},linetoolelliotttriplecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:w},linetoolelliottcorrection:{degree:7,showWave:!0,color:"#3d85c6",linewidth:w},linetoolelliottdoublecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:w},linetoolbarspattern:{color:D,mode:_.Bars,mirrored:!1,flipped:!1},linetoolghostfeed:{averageHL:20,variance:50,candleStyle:{upColor:he,downColor:K,drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:ue,borderDownColor:J,wickColor:Pe},transparency:50},study:{inputs:{},styles:{},bands:{},graphics:{},ohlcPlots:{},palettes:{},filledAreasStyle:{},filledAreas:{},visible:!0,showLegendValues:!0,showLegendInputs:!0,showLabelsOnPriceScale:!0,precision:"default"},linetoolpitchfork:{fillBackground:!0,transparency:80,style:u.Original,median:{visible:!0,color:J,linewidth:w,linestyle:M},extendLines:!1,level0:p(.25,fe,!1),level1:p(.382,pe,!1),level2:p(.5,ue,!0),level3:p(.618,ue,!1),level4:p(.75,z,!1),level5:p(1,D,!0),level6:p(1.5,ie,!1),level7:p(1.75,ae,!1),level8:p(2,Y,!1)},linetoolpitchfan:{fillBackground:!0,transparency:80,median:{visible:!0,color:J,linewidth:w,linestyle:M},level0:p(.25,fe,!1),level1:p(.382,pe,!1),level2:p(.5,z,!0),level3:p(.618,ue,!1),level4:p(.75,z,!1),level5:p(1,D,!0),level6:p(1.5,ie,!1),level7:p(1.75,ae,!1),level8:p(2,Y,!1)},linetoolgannfan:{linewidth:w,showLabels:!0,fillBackground:!0,transparency:80,level1:Ee(1,8,ye,!0),level2:Ee(1,4,ue,!0),level3:Ee(1,3,me,!0),level4:Ee(1,2,ue,!0),level5:Ee(1,1,z,!0),level6:Ee(2,1,D,!0),level7:Ee(3,1,ie,!0),level8:Ee(4,1,ae,!0),level9:Ee(8,1,J,!0)},linetoolganncomplex:{fillBackground:!1,arcsBackground:{fillBackground:!0,transparency:80},reverse:!1,scaleRatio:"",showLabels:!0,labelsStyle:{fontSize:12,bold:!1,italic:!1},levels:[A(Pe,!0),A(ye,!0),A(z,!0),A(me,!0),A(ue,!0),A(Pe,!0)],fanlines:[ke(O,!1,w,8,1),ke(J,!1,w,5,1),ke(Pe,!1,w,4,1),ke(ye,!1,w,3,1),ke(z,!0,w,2,1),ke(me,!0,w,1,1),ke(ue,!0,w,1,2),ke(ue,!1,w,1,3),ke(D,!1,w,1,4),ke(F,!1,w,1,5),ke(O,!1,w,1,8)],arcs:[ke(ye,!0,w,1,0),ke(ye,!0,w,1,1),ke(ye,!0,w,1.5,0),ke(z,!0,w,2,0),ke(z,!0,w,2,1),ke(me,!0,w,3,0),ke(me,!0,w,3,1),ke(ue,!0,w,4,0),ke(ue,!0,w,4,1),ke(D,!0,w,5,0),ke(D,!0,w,5,1)]},linetoolgannfixed:{fillBackground:!1,arcsBackground:{fillBackground:!0,transparency:80},reverse:!1,levels:[A(Pe,!0),A(ye,!0),A(z,!0),A(me,!0),A(ue,!0),A(Pe,!0)],fanlines:[ke(O,!1,w,8,1),ke(J,!1,w,5,1),ke(Pe,!1,w,4,1),ke(ye,!1,w,3,1),ke(z,!0,w,2,1),ke(me,!0,w,1,1),ke(ue,!0,w,1,2),ke(ue,!1,w,1,3),ke(D,!1,w,1,4),ke(F,!1,w,1,5),ke(O,!1,w,1,8)],arcs:[ke(ye,!0,w,1,0),ke(ye,!0,w,1,1),ke(ye,!0,w,1.5,0),ke(z,!0,w,2,0),ke(z,!0,w,2,1),ke(me,!0,w,3,0),ke(me,!0,w,3,1),ke(ue,!0,w,4,0),ke(ue,!0,w,4,1),ke(D,!0,w,5,0),ke(D,!0,w,5,1)]},linetoolgannsquare:{color:"rgba(21, 56, 153, 0.8)",linewidth:w,linestyle:M,showTopLabels:!0,showBottomLabels:!0,
showLeftLabels:!0,showRightLabels:!0,fillHorzBackground:!0,horzTransparency:80,fillVertBackground:!0,vertTransparency:80,reverse:!1,fans:t(Ce,!1),hlevel1:i(0,Pe,!0),hlevel2:i(.25,ye,!0),hlevel3:i(.382,z,!0),hlevel4:i(.5,me,!0),hlevel5:i(.618,ue,!0),hlevel6:i(.75,D,!0),hlevel7:i(1,Pe,!0),vlevel1:i(0,Pe,!0),vlevel2:i(.25,ye,!0),vlevel3:i(.382,z,!0),vlevel4:i(.5,me,!0),vlevel5:i(.618,ue,!0),vlevel6:i(.75,D,!0),vlevel7:i(1,Pe,!0)},linetoolfibspeedresistancefan:{fillBackground:!0,transparency:80,grid:{color:"rgba(21, 56, 153, 0.8)",linewidth:1,linestyle:M,visible:!0},linewidth:w,linestyle:M,showTopLabels:!0,showBottomLabels:!0,showLeftLabels:!0,showRightLabels:!0,reverse:!1,hlevel1:i(0,Pe,!0),hlevel2:i(.25,ye,!0),hlevel3:i(.382,z,!0),hlevel4:i(.5,me,!0),hlevel5:i(.618,ue,!0),hlevel6:i(.75,D,!0),hlevel7:i(1,Pe,!0),vlevel1:i(0,Pe,!0),vlevel2:i(.25,ye,!0),vlevel3:i(.382,z,!0),vlevel4:i(.5,me,!0),vlevel5:i(.618,ue,!0),vlevel6:i(.75,D,!0),vlevel7:i(1,Pe,!0)},linetoolfibretracement:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLines:!1,extendLinesLeft:!1,horzLabelsAlign:"left",vertLabelsAlign:"middle",showText:!0,horzTextAlign:"center",vertTextAlign:"middle",reverse:!1,coeffsAsPercents:!1,fibLevelsBasedOnLogScale:!1,labelFontSize:12,trendline:{visible:!0,color:Pe,linewidth:w,linestyle:I},levelsStyle:{linewidth:w,linestyle:M},level1:i(0,Pe,!0,!0),level2:i(.236,J,!0,!0),level3:i(.382,ye,!0,!0),level4:i(.5,me,!0,!0),level5:i(.618,ue,!0,!0),level6:i(.786,z,!0,!0),level7:i(1,Pe,!0,!0),level8:i(1.618,D,!0,!0),level9:i(2.618,J,!0,!0),level10:i(3.618,ie,!0,!0),level11:i(4.236,ae,!0,!0),level12:i(1.272,ye,!1,!0),level13:i(1.414,J,!1,!0),level16:i(2,ue,!1,!0),level14:i(2.272,ye,!1,!0),level15:i(2.414,me,!1,!0),level17:i(3,z,!1,!0),level18:i(3.272,Pe,!1,!0),level19:i(3.414,D,!1,!0),level20:i(4,J,!1,!0),level21:i(4.272,ie,!1,!0),level22:i(4.414,ae,!1,!0),level23:i(4.618,ye,!1,!0),level24:i(4.764,ue,!1,!0)},linetoolfibchannel:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLeft:!1,extendRight:!1,horzLabelsAlign:"left",vertLabelsAlign:"middle",coeffsAsPercents:!1,labelFontSize:12,levelsStyle:{linewidth:w,linestyle:M},level1:i(0,Pe,!0),level2:i(.236,J,!0),level3:i(.382,ye,!0),level4:i(.5,me,!0),level5:i(.618,ue,!0),level6:i(.786,z,!0),level7:i(1,Pe,!0),level8:i(1.618,D,!0),level9:i(2.618,J,!0),level10:i(3.618,ie,!0),level11:i(4.236,ae,!0),level12:i(1.272,ye,!1),level13:i(1.414,J,!1),level16:i(2,ue,!1),level14:i(2.272,ye,!1),level15:i(2.414,me,!1),level17:i(3,z,!1),level18:i(3.272,Pe,!1),level19:i(3.414,D,!1),level20:i(4,J,!1),level21:i(4.272,ie,!1),level22:i(4.414,ae,!1),level23:i(4.618,ye,!1),level24:i(4.764,ue,!1)},linetoolprojection:{showCoeffs:!0,fillBackground:!0,transparency:80,color1:R,color2:oe,linewidth:w,trendline:{visible:!0,color:Ce,linestyle:M},level1:p(1,"#808080",!0)},linetool5pointspattern:{color:D,textcolor:L,fillBackground:!0,backgroundColor:D,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:w},linetoolcypherpattern:{color:D,textcolor:L,fillBackground:!0,backgroundColor:D,
fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:w},linetooltrianglepattern:{color:W,textcolor:L,fillBackground:!0,backgroundColor:W,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:w},linetoolabcd:{color:ue,textcolor:L,fontsize:12,bold:!1,italic:!1,linewidth:w},linetoolthreedrivers:{color:W,textcolor:L,fillBackground:!0,backgroundColor:"rgba(149, 40, 204, 0.5)",fontsize:12,bold:!1,italic:!1,transparency:50,linewidth:w},linetoolheadandshoulders:{color:ue,textcolor:L,fillBackground:!0,backgroundColor:ue,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:w},linetoolfibwedge:{showCoeffs:!0,fillBackground:!0,transparency:80,trendline:{visible:!0,color:"#808080",linewidth:w,linestyle:M},level1:p(.236,J,!0),level2:p(.382,ye,!0),level3:p(.5,me,!0),level4:p(.618,ue,!0),level5:p(.786,z,!0),level6:p(1,Pe,!0),level7:p(1.618,D,!1),level8:p(2.618,J,!1),level9:p(3.618,W,!1),level10:p(4.236,ae,!1),level11:p(4.618,ae,!1)},linetoolfibcircles:{showCoeffs:!0,fillBackground:!0,transparency:80,coeffsAsPercents:!1,trendline:{visible:!0,color:Pe,linewidth:w,linestyle:I},level1:p(.236,J,!0),level2:p(.382,ye,!0),level3:p(.5,ue,!0),level4:p(.618,me,!0),level5:p(.786,z,!0),level6:p(1,Pe,!0),level7:p(1.618,D,!0),level8:p(2.618,ae,!0),level9:p(3.618,D,!0),level10:p(4.236,ae,!0),level11:p(4.618,J,!0)},linetoolfibspeedresistancearcs:{showCoeffs:!0,fillBackground:!0,transparency:80,fullCircles:!1,trendline:{visible:!0,color:Pe,linewidth:w,linestyle:I},level1:p(.236,J,!0),level2:p(.382,ye,!0),level3:p(.5,ue,!0),level4:p(.618,me,!0),level5:p(.786,z,!0),level6:p(1,Pe,!0),level7:p(1.618,D,!0),level8:p(2.618,ae,!0),level9:p(3.618,D,!0),level10:p(4.236,ae,!0),level11:p(4.618,J,!0)},linetooltrendbasedfibextension:{showCoeffs:!0,showPrices:!0,fillBackground:!0,transparency:80,extendLines:!1,extendLinesLeft:!1,horzLabelsAlign:"left",vertLabelsAlign:"middle",showText:!0,horzTextAlign:"center",vertTextAlign:"middle",reverse:!1,coeffsAsPercents:!1,fibLevelsBasedOnLogScale:!1,labelFontSize:12,trendline:{visible:!0,color:Pe,linewidth:w,linestyle:I},levelsStyle:{linewidth:w,linestyle:M},level1:i(0,Pe,!0,!0),level2:i(.236,J,!0,!0),level3:i(.382,ye,!0,!0),level4:i(.5,me,!0,!0),level5:i(.618,ue,!0,!0),level6:i(.786,z,!0,!0),level7:i(1,Pe,!0,!0),level8:i(1.618,D,!0,!0),level9:i(2.618,J,!0,!0),level10:i(3.618,ie,!0,!0),level11:i(4.236,ae,!0,!0),level12:i(1.272,ye,!1,!0),level13:i(1.414,J,!1,!0),level16:i(2,ue,!1,!0),level14:i(2.272,ye,!1,!0),level15:i(2.414,me,!1,!0),level17:i(3,z,!1,!0),level18:i(3.272,Pe,!1,!0),level19:i(3.414,D,!1,!0),level20:i(4,J,!1,!0),level21:i(4.272,ie,!1,!0),level22:i(4.414,ae,!1,!0),level23:i(4.618,ye,!1,!0),level24:i(4.764,ue,!1,!0)},linetooltrendbasedfibtime:{showCoeffs:!0,fillBackground:!0,transparency:80,horzLabelsAlign:"right",vertLabelsAlign:"bottom",trendline:{visible:!0,color:Pe,linewidth:w,linestyle:I},level1:p(0,Pe,!0),level2:p(.382,J,!0),level3:p(.5,pe,!1),level4:p(.618,me,!0),level5:p(1,ue,!0),level6:p(1.382,z,!0),level7:p(1.618,Pe,!0),level8:p(2,D,!0),level9:p(2.382,ae,!0),level10:p(2.618,ie,!0),
level11:p(3,W,!0)},linetoolschiffpitchfork:{fillBackground:!0,transparency:80,style:u.Schiff,median:{visible:!0,color:J,linewidth:w,linestyle:M},extendLines:!1,level0:p(.25,fe,!1),level1:p(.382,pe,!1),level2:p(.5,ue,!0),level3:p(.618,ue,!1),level4:p(.75,z,!1),level5:p(1,D,!0),level6:p(1.5,ie,!1),level7:p(1.75,ae,!1),level8:p(2,Y,!1)},linetoolschiffpitchfork2:{fillBackground:!0,transparency:80,style:u.Schiff2,median:{visible:!0,color:J,linewidth:w,linestyle:M},extendLines:!1,level0:p(.25,fe,!1),level1:p(.382,pe,!1),level2:p(.5,ue,!0),level3:p(.618,ue,!1),level4:p(.75,z,!1),level5:p(1,D,!0),level6:p(1.5,ie,!1),level7:p(1.75,ae,!1),level8:p(2,Y,!1)},linetoolinsidepitchfork:{fillBackground:!0,transparency:80,style:u.Inside,median:{visible:!0,color:J,linewidth:w,linestyle:M},extendLines:!1,level0:p(.25,fe,!1),level1:p(.382,pe,!1),level2:p(.5,ue,!0),level3:p(.618,ue,!1),level4:p(.75,z,!1),level5:p(1,D,!0),level6:p(1.5,ie,!1),level7:p(1.75,ae,!1),level8:p(2,Y,!1)},linetoolregressiontrend:{linewidth:1,linestyle:M,styles:{upLine:{display:g.All,color:B,linestyle:M,linewidth:w},downLine:{display:g.All,color:B,linestyle:M,linewidth:w},baseLine:{display:g.All,color:Q,linestyle:I,linewidth:1},extendLines:!1,showPearsons:!0,transparency:70}}},De(TradingView.defaultProperties.chartproperties),Ve()}if(void 0===TradingView.defaultProperties["study_MA@tv-basicstudies"]&&(TradingView.defaultProperties["study_MA@tv-basicstudies"]={description:"Moving Average",shortDescription:"MA",inputs:{length:9,source:"close"},styles:{MovAvg:{display:g.All,color:D,linestyle:M,linewidth:1,plottype:m.Line,histogramBase:0,title:"MA"}}}),void 0===TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]&&(TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]={fontsize:10,borderColor:D,backColor:E,textColor:Me}),void 0===TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]){var Re=!0;TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]={_hardCodedDefaultsVersion:1,fontsize:11,levelsStyle:{showLabels:!0,visibility:{P:Re,"S1/R1":Re,"S2/R2":Re,"S3/R3":Re,"S4/R4":Re,"S5/R5":Re},colors:{P:Se,"S1/R1":Se,"S2/R2":Se,"S3/R3":Se,"S4/R4":Se,"S5/R5":Se},widths:{P:1,"S1/R1":1,"S2/R2":1,"S3/R3":1,"S4/R4":1,"S5/R5":1}}}}void 0===TradingView.defaultProperties["study_ZigZag@tv-basicstudies"]&&(TradingView.defaultProperties["study_ZigZag@tv-basicstudies"]={color:D,linewidth:2});const Ne={styles:{splitByBlocks:!1},graphics:{tpoLevels:{tpo:{tpoPoc:{color:""},tpoPoorHigh:{color:""},tpoPoorLow:{color:""},tpoSingleprints:{color:""},tpoVah:{color:""},tpoVal:{color:""},volumePoc:{color:""},volumeVah:{color:""},volumeVal:{color:""}}},tpoVolumeRows:{tpo:{valuesColor:"",colors:{nonVa:"",va:""}}}}};function Oe(e){const t={styles:{developingPoc:{color:""},developingVAHigh:{color:""},developingVALow:{color:""}},graphics:{horizlines:{pocLines:{color:""},vahLines:{color:""},valLines:{color:""}},hhists:{histBars2:{colors:["",""],valuesColor:""},histBarsVA:{colors:["",""],valuesColor:""}}}}
;return e&&(t.graphics.polygons={histBoxBg:{color:""}}),t}void 0===TradingView.defaultProperties["study_TPOPeriodic@tv-volumebyprice"]&&(TradingView.defaultProperties["study_TPOPeriodic@tv-volumebyprice"]=Ne),void 0===TradingView.defaultProperties["study_TPOSessions@tv-volumebyprice"]&&(TradingView.defaultProperties["study_TPOSessions@tv-volumebyprice"]=Ne),void 0===TradingView.defaultProperties["study_VbPSessions@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPSessions@tv-volumebyprice"]=Oe(!0)),void 0===TradingView.defaultProperties["study_VbPSessionsRoughDetailed@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPSessionsRoughDetailed@tv-volumebyprice"]=Oe(!0)),void 0===TradingView.defaultProperties["study_VbPPeriodic@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPPeriodic@tv-volumebyprice"]=Oe(!0)),void 0===TradingView.defaultProperties["study_VbPVisible@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPVisible@tv-volumebyprice"]=Oe(!1));const Fe={styles:{developingPoc:{color:""},developingVAHigh:{color:""},developingVALow:{color:""}},graphics:{hhists:{histBars2:{colors:["",""],valuesColor:""},histBarsVA:{colors:["",""],valuesColor:""}},horizlines:{pocLines:{color:""},vahLines:{color:""},valLines:{color:""}},polygons:{histBoxBg:{color:""}}}};if(void 0===TradingView.defaultProperties["study_VbPFixed@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPFixed@tv-volumebyprice"]=Fe),void 0===TradingView.defaultProperties["study_VbPFixed@tv-basicstudies"]&&(TradingView.defaultProperties["study_VbPFixed@tv-basicstudies"]=Fe),void 0===TradingView.defaultProperties.linetoolanchoredvp&&(TradingView.defaultProperties.linetoolanchoredvp=Oe(!0)),void 0===TradingView.defaultProperties["study_VbPAutoAnchored@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPAutoAnchored@tv-volumebyprice"]=Oe(!0)),void 0===TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]&&(TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]={inputs:{},level0:t($,!1),level1:t("#008000",!1),level2:t("#0000ff",!1),level3:t("#ff00ff",!1),level4:t("#0080ff",!0),level5:t($,!0),level6:t("#008000",!0),level7:t("#0000ff",!0),level8:t("#ff00ff",!0)}),void 0===TradingView.defaultProperties["study_LinearRegression@tv-basicstudies"]&&(TradingView.defaultProperties["study_LinearRegression@tv-basicstudies"]={styles:{upLine:{display:g.All,color:B,linestyle:M,linewidth:1},downLine:{display:g.All,color:B,linestyle:M,linewidth:1},baseLine:{display:g.All,color:Q,linestyle:M,linewidth:1},extendLines:!0,showPearsons:!0,backgroundColor:"rgba(153, 21, 21, 0.3)",transparency:70}}),void 0===TradingView.defaultProperties["study_Compare@tv-basicstudies"]&&(TradingView.defaultProperties["study_Compare@tv-basicstudies"]={minTick:"default"}),void 0===TradingView.defaultProperties["study_Overlay@tv-basicstudies"]){TradingView.defaultProperties["study_Overlay@tv-basicstudies"]={style:d.STYLE_LINE,allowExtendTimeScale:!1,showPriceLine:!1,minTick:"default",candleStyle:{upColor:de,downColor:re,
drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:de,borderDownColor:re,wickColor:"#737375",wickUpColor:de,wickDownColor:re,barColorsOnPrevClose:!1},hollowCandleStyle:{upColor:de,downColor:re,drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:de,borderDownColor:re,wickColor:"#737375",wickUpColor:de,wickDownColor:re,barColorsOnPrevClose:!1},barStyle:{upColor:de,downColor:re,barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},lineStyle:{color:be,linestyle:M,linewidth:2,priceSource:"close"},lineWithMarkersStyle:{color:be,linestyle:M,linewidth:2,priceSource:"close"},steplineStyle:{color:be,linestyle:M,linewidth:2,priceSource:"close"},areaStyle:{color1:D,color2:D,linecolor:D,linestyle:M,linewidth:2,priceSource:"close",transparency:95},baselineStyle:{baselineColor:Te,topFillColor1:Le,topFillColor2:Le,bottomFillColor1:X,bottomFillColor2:X,topLineColor:Ae,bottomLineColor:Z,topLineWidth:2,bottomLineWidth:2,topLineStyle:0,bottomLineStyle:2,priceSource:"close",transparency:50,baseLevelPercentage:50},hiloStyle:{color:D,showBorders:!0,borderColor:D,showLabels:!0,labelColor:D,drawBody:!0},columnStyle:{upColor:r(ue,50),downColor:r(J,50),barColorsOnPrevClose:!0,priceSource:"close",baselinePosition:"bottom"},hlcAreaStyle:{highLineVisible:!0,highLineColor:z,highLineStyle:M,highLineWidth:2,lowLineVisible:!0,lowLineColor:ae,lowLineStyle:M,lowLineWidth:2,closeLineColor:D,closeLineStyle:M,closeLineWidth:2,highCloseFillColor:j,closeLowFillColor:ce},hlcBarsStyle:{color:D,barColorsOnPrevClose:!1,thinBars:!0},styles:{open:{display:g.All,color:$,linestyle:M,linewidth:1,plottype:m.Line,histogramBase:0},high:{display:g.All,color:$,linestyle:M,linewidth:1,plottype:m.Line,histogramBase:0},low:{display:g.All,color:$,linestyle:M,linewidth:1,plottype:m.Line,histogramBase:0},close:{display:g.All,color:$,linestyle:M,linewidth:1,plottype:m.Line,histogramBase:0}}}}for(var We=e.split("."),He=TradingView.defaultProperties,ze=0;ze<We.length;ze++)He&&(He=He[We[ze]]);return null!=He?s(He):{}};function Ee(e,t,i,s,o){if(s)for(var n in s){var r=n.split("."),a=c(r[0]),l=void 0!==o&&o===r[0];0!==r.length&&l&&(a=c((r=r.slice(1))[0])),0!==r.length&&e.hasOwnProperty(a)?h(e,r,s[n])||d(n):l&&d(n)}function c(e){return t&&t[e]?t[e]:e}function h(e,t,i,s){var o=c(t[0]);return!!e.hasOwnProperty(o)&&(t.length>1?h(e[o],t.slice(1),i):(e[o]&&e[o].setValue?e[o].setValue(i):e[o]=i,!0))}function d(e){i||A.logWarn("Path `"+e+"` does not exist.")}}function De(e,t,i,s){window.__defaultsOverrides&&Ee(e,t,i,window.__defaultsOverrides,s)}function Be(e,t){window.__settingsOverrides&&Ee(e,null,!1,window.__settingsOverrides,t)}function Ve(){var e=/^linetool.+/;Object.keys(TradingView.defaultProperties).forEach((function(t){e.test(t)&&De(TradingView.defaultProperties[t],null,!1,t)}))}function Re(e,t){return t?function(e,t){var i=ke(e);if(!window._UNIT_TESTS){var n=s(TVSettings.getJSON(e,null));if(function(e){var t=new Set(["linetoolregressiontrend"]);return e.startsWith("study_")||t.has(e)}(e)&&n&&function(e){if(!e)return!1;e=e.toString()
;var t=new RegExp("\\d+").exec(e),i=null!==t&&t[0]===e;return i}(n.version)){var r=n.inputs,a=t.updateStudyInputs(n.id,n.version,"last",r,null);n.inputs=a,n=t.updateStudyState(n,n)}o(i,n),Be(i,e)}return i}(e,t):function(e){var t=ke(e);if(!window._UNIT_TESTS){var i=s(TVSettings.getJSON(e,null));if(i){o(t,i);const s=e.split(".");Be(t,void 0===s[1]?e:s[1])}}return t}(e)}Re.create=function(e,t){if(t){var i=ke(e);TradingView.defaultProperties[e]=o(t,i)}},Re.remove=function(e){TradingView.defaultProperties[e]=void 0},TradingView.saveDefaults=function(e,t){void 0===t?TVSettings.remove(e):TVSettings.setJSON(e,t)},TradingView.factoryDefaults=ke,window.applyDefaultOverridesToLinetools=Ve,window.applyDefaultsOverrides=De,window.applyPropertiesOverrides=Ee,window.defaults=Re,t.applyDefaultOverridesToLinetools=Ve,t.applyDefaultsOverrides=De,t.applyPropertiesOverrides=Ee,t.defaults=Re,t.factoryDefaults=ke,t.saveDefaults=TradingView.saveDefaults,t.createDefaults=Re.create,t.removeDefaults=Re.remove},78861:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DrawingSyncMode:()=>s,SelectPointMode:()=>o,activePointSelectionMode:()=>J,alignTo45Degrees:()=>Ie,barTimesUnderCursor:()=>ee,beenSetLineToolLastPoint:()=>F,cancelLineTool:()=>ne,cancelledLineTool:()=>O,changeLineStyle:()=>me,changeLineTool:()=>de,changedLineStyle:()=>K,changedLineTool:()=>j,continueLineTool:()=>oe,continuedLineTool:()=>N,copiedLineTool:()=>Y,copyLineTool:()=>ge,createLineTool:()=>se,createdLineTool:()=>R,crosshairLock:()=>x,cursorTool:()=>k,drawOnAllCharts:()=>Ae,drawOnAllChartsMode:()=>Le,emojiTool:()=>A,finishChangingLineTool:()=>ue,finishLineTool:()=>pe,finishMovingLineTool:()=>ce,finishedChangingLineTool:()=>G,finishedLineTool:()=>$,finishedMovingLineTool:()=>z,hideAllDrawings:()=>Te,hideAllIndicators:()=>Pe,hideMarksOnBars:()=>Me,iconTool:()=>I,init:()=>be,isDirectionalMovementActive:()=>V,isStudyEditingNow:()=>Q,isToolCreatingNow:()=>E,isToolEditingNow:()=>D,isToolMovingNow:()=>B,lockDrawings:()=>xe,moveLineTool:()=>le,movedLineTool:()=>H,properties:()=>Ce,removeLineTool:()=>_e,removedLineTool:()=>q,resetToCursor:()=>v,restoreLineTool:()=>fe,restoreLineToolState:()=>ye,restoredLineTool:()=>Z,restoredLineToolState:()=>X,runOnDrawingStateReady:()=>we,setLineToolLastPoint:()=>re,startChangingLineTool:()=>he,startMovingLineTool:()=>ae,startedChangingLineTool:()=>U,startedMovingLineTool:()=>W,stickerTool:()=>L,tool:()=>M,toolIsCursor:()=>m,toolIsDemonstration:()=>f,toolIsEraser:()=>g,toolIsMeasure:()=>y});var s,o,n=i(50151),r=i(41072),a=i(78176),l=i(22613),c=i(62773),h=i(48096),d=i(1765),u=i(76422),_=i(51768);!function(e){e[e.Layout=1]="Layout",e[e.Global=2]="Global"}(s||(s={})),function(e){e[e.None=0]="None",e[e.Replay=1]="Replay",e[e.Study=2]="Study"}(o||(o={}));const p=new Set(["cursor","arrow","dot","performance","demonstration"]);function m(e){return p.has(e)}function g(e){return"eraser"===e}function f(e){return"demonstration"===e}function y(e){return"measure"===e}function v(e=!1){if(!e&&S){if(S.childs().stayInDrawingMode.value())return}M.setValue(k.value())}
let S=null,b=null,w=null,C=null,T=null,P=null;const x=new c.WatchedObject(null),M=new l.WatchedValue,I=new l.WatchedValue,A=new l.WatchedValue,L=new l.WatchedValue,k=new l.WatchedValue,E=new l.WatchedValue(!1),D=new l.WatchedValue(!1),B=new l.WatchedValue(!1),V=new l.WatchedValue(!1),R=new h.Delegate,N=new h.Delegate,O=new h.Delegate,F=new h.Delegate,W=new h.Delegate,H=new h.Delegate,z=new h.Delegate,U=new h.Delegate,j=new h.Delegate,G=new h.Delegate,q=new h.Delegate,$=new h.Delegate,K=new h.Delegate,Y=new h.Delegate,Z=new h.Delegate,X=new h.Delegate,J=new l.WatchedValue(o.None),Q=new l.WatchedValue(!1),ee=new Map;function te(e,t){const i=t||{value:!1};return t=>{i.value||(i.value=!0,e.fire(t),i.value=!1)}}const ie={value:!1},se=te(R,ie),oe=te(N,ie),ne=te(O,ie),re=te(F,ie),ae=te(W),le=te(H),ce=te(z),he=te(U),de=te(j),ue=te(G),_e=te(q),pe=te($),me=te(K,ie),ge=te(Y,ie),fe=te(Z),ye=te(X);let ve=!1,Se=[];function be(){if(ve)return;const e=d.getValue("chart.cursorPreference","cursor");M.setValue(m(e)?e:"cursor"),M.subscribe((e=>{m(e)?k.setValue(e):g(e)&&(0,_.trackEvent)("Chart cursors",e)}),{callWithLast:!0}),k.subscribe((e=>{(0,_.trackEvent)("Chart cursors",e),e&&"performance"!==e&&!f(e)&&d.setValue("chart.cursorPreference",e)})),S=new a.DefaultProperty({defaultName:"drawings"}),b=(0,r.createPrimitiveProperty)(!1),w=(0,r.createPrimitiveProperty)(!1),C=(0,r.createPrimitiveProperty)(!1),T=(0,r.createPrimitiveProperty)(!d.getBool("BarsMarksContainer.visibile",!0)),P=(0,r.createPrimitiveProperty)(!1),M.subscribe((e=>{(0,u.emit)("onSelectedLineToolChanged")})),ve=!0,Se.forEach((e=>e())),Se=[]}function we(e){ve?e():Se.push(e)}function Ce(){return(0,n.ensureNotNull)(S)}function Te(){return(0,n.ensureNotNull)(b)}function Pe(){return(0,n.ensureNotNull)(w)}function xe(){return(0,n.ensureNotNull)(C)}function Me(){return(0,n.ensureNotNull)(T)}function Ie(){return(0,n.ensureNotNull)(P)}function Ae(){return Ce().childs().drawOnAllCharts}function Le(){return Ce().childs().drawOnAllChartsMode}},93946:(e,t,i)=>{"use strict";i.d(t,{EnvironmentState:()=>o});var s=i(49483);class o{constructor(e,t=!1){this._shift=!1,this._mod=!1,this._alt=!1,void 0!==e&&(this._shift=Boolean(e.shiftKey),this._mod=Boolean((0,s.isMac)()?e.metaKey:e.ctrlKey),this._alt=Boolean(e.altKey)),this._isApiEvent=t}shift(){return this._shift}mod(){return this._mod}alt(){return this._alt}shiftOnly(){return this._shift&&!this._mod&&!this._alt}modOnly(){return this._mod&&!this._shift&&!this._alt}altOnly(){return this._alt&&!this._shift&&!this._mod}modShift(){return this._shift&&this._mod&&!this._alt}isApiEvent(){return this._isApiEvent}static create(e=!1,t=!1,i=!1){return new o({shiftKey:e,ctrlKey:t,metaKey:t,altKey:i})}}},60911:(e,t,i)=>{"use strict";i.d(t,{decodeExtendedSymbol:()=>h,encodeExtendedSymbolOrGetSimpleSymbolString:()=>l,extractExtendedSymbol:()=>d,isEncodedExtendedSymbol:()=>c,isStudySymbol:()=>a,replaceExtendedSymbol:()=>u});var s=i(87465);function o(e){return"="+JSON.stringify(n(e))}function n(e){
return Object.keys(e).sort().reduce(((t,i)=>("[object Object]"===Object.prototype.toString.call(e[i])?t[i]=n(e[i]):t[i]=e[i],t)),{})}function r(e){return(0,s.isString)(e)}function a(e){return!r(e)&&"inputs"in e}function l(e){return o(e)}function c(e){return"="===e[0]}function h(e){if(!c(e))return{symbol:e};try{return JSON.parse(e.slice(1))}catch(t){return{symbol:e}}}function d(e){if(r(e))return{symbol:e};let t=e;for(;!r(t.symbol);)t=t.symbol;return t}function u(e,t){let i=e;for(;!r(i.symbol);)i=i.symbol;i.symbol=t}},92211:(e,t,i)=>{"use strict";i.d(t,{extractSymbolNameFromSymbolInfo:()=>l});var s=i(37103);const o=s.enabled("pay_attention_to_ticker_not_symbol"),n=s.enabled("charting_library_single_symbol_request"),r=s.enabled("use_ticker_on_symbol_info_update"),a=s.enabled("uppercase_instrument_names");function l(e,t,i,s){let l=e&&(i&&e.pro_name||e.full_name||e.name);return n&&t?l=t:(r||!s&&o)&&e&&e.ticker&&(l=e.ticker),a&&l&&(l=l.toUpperCase()),l}},35727:(e,t,i)=>{"use strict";i.d(t,{customFormatters:()=>s});const s={dateFormatter:null,timeFormatter:null,tickMarkFormatter:null,priceFormatterFactory:null,studyFormatterFactory:null}},10718:(e,t,i)=>{"use strict";i.d(t,{availableDateFormats:()=>v,dateFormatFunctions:()=>f,defaultDateFormat:()=>S,getDateFormatWithWeekday:()=>y});var s=i(11542),o=i(28865),n=i(95322);const r={1:()=>s.t(null,void 0,i(62310)),2:()=>s.t(null,void 0,i(2507)),3:()=>s.t(null,void 0,i(92767)),4:()=>s.t(null,void 0,i(27072)),5:()=>s.t(null,{context:"short"},i(13132)),6:()=>s.t(null,void 0,i(429)),7:()=>s.t(null,void 0,i(53786)),8:()=>s.t(null,void 0,i(46450)),9:()=>s.t(null,void 0,i(6816)),10:()=>s.t(null,void 0,i(12179)),11:()=>s.t(null,void 0,i(26899)),12:()=>s.t(null,void 0,i(32084))},a={1:()=>s.t(null,void 0,i(14568)),2:()=>s.t(null,void 0,i(13534)),3:()=>s.t(null,void 0,i(14530)),4:()=>s.t(null,void 0,i(3762))},l=(e,t)=>(t?e.getMonth():e.getUTCMonth())+1,c=(e,t)=>t?e.getFullYear():e.getUTCFullYear(),h=(e,t)=>e.toLocaleDateString(window.language?(0,o.getIsoLanguageCodeFromLanguage)(window.language):void 0,{weekday:"short",timeZone:"local"===t?void 0:t}),d=(e,t)=>a[((e,t)=>Math.floor((l(e,t)-1)/3)+1)(e,t)](),u=(e,t)=>(0,n.numberToStringWithLeadingZero)(((e,t)=>t?e.getDate():e.getUTCDate())(e,t),2),_=(e,t)=>r[l(e,t)](),p=(e,t)=>(0,n.numberToStringWithLeadingZero)(l(e,t),2),m=(e,t)=>(0,n.numberToStringWithLeadingZero)(c(e,t)%100,2),g=(e,t)=>(0,n.numberToStringWithLeadingZero)(c(e,t),4),f={"qq 'yy":(e,t)=>`${d(e,t)} '${m(e,t)}`,"qq yyyy":(e,t)=>`${d(e,t)} ${g(e,t)}`,"dd MMM 'yy":(e,t)=>`${u(e,t)} ${_(e,t)} '${m(e,t)}`,"MMM 'yy":(e,t)=>`${_(e,t)} '${m(e,t)}`,"MMM dd, yyyy":(e,t)=>`${_(e,t)} ${u(e,t)}, ${g(e,t)}`,"MMM yyyy":(e,t)=>`${_(e,t)} ${g(e,t)}`,"MMM dd":(e,t)=>`${_(e,t)} ${u(e,t)}`,"dd MMM":(e,t)=>`${u(e,t)} ${_(e,t)}`,"yyyy-MM-dd":(e,t)=>`${g(e,t)}-${p(e,t)}-${u(e,t)}`,"yy-MM-dd":(e,t)=>`${m(e,t)}-${p(e,t)}-${u(e,t)}`,"yy/MM/dd":(e,t)=>`${m(e,t)}/${p(e,t)}/${u(e,t)}`,"yyyy/MM/dd":(e,t)=>`${g(e,t)}/${p(e,t)}/${u(e,t)}`,"dd-MM-yyyy":(e,t)=>`${u(e,t)}-${p(e,t)}-${g(e,t)}`,
"dd-MM-yy":(e,t)=>`${u(e,t)}-${p(e,t)}-${m(e,t)}`,"dd/MM/yy":(e,t)=>`${u(e,t)}/${p(e,t)}/${m(e,t)}`,"dd/MM/yyyy":(e,t)=>`${u(e,t)}/${p(e,t)}/${g(e,t)}`,"MM/dd/yy":(e,t)=>`${p(e,t)}/${u(e,t)}/${m(e,t)}`,"MM/dd/yyyy":(e,t)=>`${p(e,t)}/${u(e,t)}/${g(e,t)}`};function y(e,t){return"ja"===window.language?(i,s)=>`${f[e](i,s)} (${h(i,t)})`:(i,s)=>`${h(i,t)} ${f[e](i,s)}`}const v=Object.keys(f),S=()=>-1!==["ja","ko","zh","zh_TW"].indexOf(window.language||"")?"yyyy-MM-dd":"dd MMM 'yy"},60336:(e,t,i)=>{"use strict";i.d(t,{DateFormatter:()=>n});var s=i(35727),o=i(10718);class n{constructor(e="yyyy-MM-dd",t=!1,i="UTC"){this._dateFormatFunc=t?(0,o.getDateFormatWithWeekday)(e,i):o.dateFormatFunctions[e]}format(e){return s.customFormatters&&s.customFormatters.dateFormatter?s.customFormatters.dateFormatter.format(e):this._dateFormatFunc(e,!1)}formatLocal(e){return s.customFormatters.dateFormatter?s.customFormatters.dateFormatter.formatLocal?s.customFormatters.dateFormatter.formatLocal(e):s.customFormatters.dateFormatter.format(e):this._dateFormatFunc(e,!0)}parse(e){if(""===e)return{res:!1};let t=e;return s.customFormatters&&s.customFormatters.dateFormatter&&!s.customFormatters.dateFormatter.parse&&console.warn("You need to provide a `parse` function as part of `dateFormatter`"),s.customFormatters&&s.customFormatters.dateFormatter&&s.customFormatters.dateFormatter.parse&&(t=String(s.customFormatters.dateFormatter.parse(e))),{res:!0,value:t}}}},86957:(e,t,i)=>{"use strict";i.d(t,{DateTimeFormatter:()=>r});var s=i(82087),o=i(60336);const n={dateFormat:"yyyy-MM-dd",withWeekday:!1,timeFormat:s.hourMinuteSecondFormat,dateTimeSeparator:" "};class r{constructor(e={}){const t=Object.assign({},n,e);this._dateFormatter=new o.DateFormatter(t.dateFormat,t.withWeekday,t.timezone),this._timeFormatter=new s.TimeFormatter(t.timeFormat),this._separator=t.dateTimeSeparator}format(e,t){const i=t?.dateTimeSeparator??this._separator;return`${this._dateFormatter.format(e)}${i}${this._timeFormatter.format(e)}`}formatLocal(e,t){const i=t?.dateTimeSeparator??this._separator;return`${this._dateFormatter.formatLocal(e)}${i}${this._timeFormatter.formatLocal(e)}`}}},95322:(e,t,i)=>{"use strict";i.d(t,{numDependencyFormatter:()=>n,numberToStringWithLeadingZero:()=>o});var s=i(87465);function o(e,t){if(!(0,s.isNumber)(e))return"n/a";if(!(0,s.isInteger)(t))throw new TypeError("invalid length");if(t<0||t>24)throw new TypeError("invalid length");if(0===t)return e.toString();return("00000000000000000000"+e.toString()).slice(-t)}function n(e){const t=new Map;return i=>{const s=i??-1;let o=t.get(s);return o||(o=e(i),t.set(s,o)),o}}},9860:(e,t,i)=>{"use strict";i.d(t,{LimitedPrecisionNumericFormatter:()=>n});var s,o=i(97906);!function(e){e[e.DefaultPrecision=1]="DefaultPrecision"}(s||(s={}));class n{constructor(e,t){this._precision=e??1,this._numericFormatter=new o.NumericFormatter({precision:this._precision,ignoreLocaleNumberFormat:t})}format(e,t){const i=e.toFixed(this._precision),s=Math.pow(10,-this._precision)
;return this._numericFormatter.format(Math.max(parseFloat(i),s),t)}parse(e,t){const i=this._numericFormatter.parse(e,t);return i.res?{res:!0,value:i.value,suggest:this.format(i.value)}:i}}},91799:(e,t,i)=>{"use strict";i.d(t,{formatNumber:()=>r,parseNumber:()=>l});var s=i(60521),o=i(59332),n=i(24640);function r(e,t,i,o,n){if(!Number.isFinite(e))return`${e}`;const r=-1===Math.sign(e)?"-":"";e=Math.abs(e);let a=void 0===i?e.toString():e.toFixed(i);if(a.includes("e")){if(!o)return`${r}${a.replace(".",t.decimalSign)}`;{const i=new s.Big(e);if(a=i.lt(1)?i.toFixed():i.toString(),a.includes("e"))return`${r}${a.replace(".",t.decimalSign)}`}}const l=a.split("."),c=l[0];let h=l[1];const d=function(e,t){let i=e.length;const s=[];for(;i>0;)s.unshift(e.slice(Math.max(i-3,0),i)),i-=3;return s.join(t)}(c,t.groupingSeparator);return void 0!==i&&(h=0===i?void 0:e.toFixed(i).slice(-i)),void 0!==n&&void 0!==h&&(h=function(e,t){let i=e.length-1;for(let s=i;s>=t&&"0"===e[s];s-=1)i-=1;return e.slice(0,i+1)}(h,n)),h?`${r}${d}${t.decimalSign}${h}`:`${r}${d}`}const a=(0,o.default)((e=>{const t=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");return new RegExp(t,"gm")}));function l(e,t){if(/^(NaN|[+|-]?Infinity)$/.test(e))return parseFloat(e);e=(0,n.stripLTRMarks)(e);const i=a(t.groupingSeparator);return i&&(e=e.replace(i,"")),e=e.replace(t.decimalSign,"."),/^(\+|-)?\d+(\.\d+|\.)?(e(\+|-)?\d+)?$/.test(e)?parseFloat(e):NaN}},26010:(e,t,i)=>{"use strict";let s;i.d(t,{formatterOptions:()=>o,formatterOptionsLibraryOverrides:()=>n,getNumberFormat:()=>d});const o={decimalSign:".",decimalSignFractional:"'"},n={};const r={groupingSeparator:",",decimalSign:"."},a={groupingSeparator:".",decimalSign:","},l={groupingSeparator:" ",decimalSign:","},c={groupingSeparator:"",decimalSign:"."},h=new Map([["en",r],["th",r],["ja",r],["ko",r],["zh",r],["zh_TW",r],["ar",r],["he_IL",r],["ms_MY",r],["vi",r],["de",a],["es",a],["it",a],["tr",a],["pt",a],["id_ID",a],["fr",l],["pl",l],["ru",l]]);function d(e){if(e)return{decimalSign:o.decimalSign,groupingSeparator:""};return{...h.get(s||window.language||"")??c,...n}}},97906:(e,t,i)=>{"use strict";i.d(t,{NumericFormatter:()=>n});var s=i(91799),o=i(26010);class n{constructor(e={}){this._options=e}format(e,t={}){if(!Number.isFinite(e))return String(e);const{ignoreLocaleNumberFormat:i=this._options.ignoreLocaleNumberFormat,noExponentialForm:r=this._options.noExponentialForm}=t,{minPrecision:a,precision:l}=this._options,c=(0,o.getNumberFormat)(i);return void 0===l?n._formatNoEImpl(e,c,l,a):(0,s.formatNumber)(e,c,l,r,a)}parse(e,t){const{ignoreLocaleNumberFormat:i,precision:n}=this._options,r=(0,o.getNumberFormat)(i||t?.ignoreLocaleNumberFormat);let a=(0,s.parseNumber)(e,r);return Number.isFinite(a)?(n&&(a=+a.toFixed(n)),{res:!0,value:a}):{res:!1}}static formatNoE(e,t){return this._formatNoEImpl(e,t)}static _formatNoEImpl(e,t,i,o){return Number.isFinite(e)?(t=t??{groupingSeparator:"",decimalSign:"."},(0,s.formatNumber)(e,t,i,!0,o)):String(e)}}},38888:(e,t,i)=>{"use strict";i.d(t,{PercentageFormatter:()=>n})
;var s=i(67563),o=i(24640);class n extends s.PriceFormatter{constructor(e={}){void 0!==e.decimalPlaces&&(e.priceScale=Math.pow(10,e.decimalPlaces)),super(e),this.type="percentage"}state(){return{...super.state(),percent:!0}}parse(e,t){return e=e.replace("%",""),super.parse(e,t)}format(e,t={}){const{useRtlFormat:i=!0}=t,s=super.format(e,{...t,useRtlFormat:!1})+"%";return i?(0,o.forceLTRStr)(s):s}static serialize(e){return e.state()}static deserialize(e){return new n(e)}}},67563:(e,t,i)=>{"use strict";i.d(t,{PriceFormatter:()=>M});var s=i(60521),o=i.n(s),n=i(9343),r=i(50151),a=i(11542),l=i(50335);var c=i(77914);function h(e){return e?(0,s.Big)(e.minMove).div(e.priceScale).toNumber():NaN}function d(e){const{minTick:t,price:i,variableMinTickData:s,shouldCheckForEquality:o}=e,n=(0,l.isNumber)(t)?u(t):t;return void 0===s?n:function(e,t,i=!1){for(let s=0;s<t.length;s++){if(e<t[s].price)return t[s].minTick;if(i&&e===t[s].price)return t[s].minTick}return t[t.length-1].minTick}(i,s,o)}function u(e){const t=function(e){return(new(o())(e).toFixed().split(".")[1]||"").length}(e),i=Math.pow(10,t);return{priceScale:i,minMove:(0,s.Big)(e).mul(i).toNumber()}}function _(e,t){const i=[{minTick:(0,l.isNumber)(e)?u(e):e,price:1/0,maxIndex:1/0}];try{const e=t.split(" ").map(((e,t)=>(0,c.isEven)(t)?function(e){const t=Number(e);if(Number.isFinite(t))return u(t);{const t=e.split("/");if(t.length<2||t.length>3)throw new Error(`Unexpected mintick: ${e}`);const i=Number(t[1]),s=Number(t[0]);if(!Number.isFinite(i)||!Number.isFinite(s))throw new Error(`Unexpected mintick: ${e}`);const o=3===t.length?Number(t[2]):void 0;if(void 0!==o&&!Number.isFinite(o))throw new Error(`Unexpected mintick: ${e}`);const n={priceScale:i,minMove:s};return void 0!==o&&(n.minMove2=o),n}}(e):function(e){const t=Number(e);if(Number.isNaN(t))throw new Error(`Unexpected price limit: ${e}`);return t}(e)));if((0,c.isEven)(e.length))throw new Error("Theme must not be event number of elements");const i=[];for(let t=0;t<e.length;t+=2){const o=e[t+1]??1/0,n=i[i.length-1]?.price??0,r=i[i.length-1]?.maxIndex??0,a=o===1/0?1/0:new s.Big(o).minus(n).div(h(e[t])).plus(r).toNumber();i.push({minTick:e[t],price:o,maxIndex:a})}return i}catch{return i}}var p=i(24640);const m=new RegExp(/^(-?)[0-9]+$/);function g(e,t,i,s){let o=0;if(e>0&&t>0){let t=e;for(i&&s&&(t/=s);t>1;)t/=10,o++}return o}function f(e,t,i){const s=(0,r.ensureNotNull)(d({price:i,minTick:null,variableMinTickData:t,shouldCheckForEquality:!0})),{priceScale:o,minMove:n,minMove2:a}=s;return{priceScale:o,minMove:n,fractionalLength:g(o,n,e,a)}}class y{constructor(e){this._formatterErrors={custom:a.t(null,void 0,i(66123)),fraction:a.t(null,void 0,i(39643)),secondFraction:a.t(null,void 0,i(70784))};const{priceScale:t,minMove:s,minMove2:o,ignoreMinMove:n,variableMinTick:r,fractionalLength:l}=e;this._priceScale=t,this._minMove=s,this._minMove2=o,this._ignoreMinMove=n,this._variableMinTickData=void 0===r?void 0:_({priceScale:t,minMove:s,minMove2:o},r),this._fractionalLength=l}formatImpl(e,t={}){
const{signPositive:i,signNegative:s=!0,tailSize:o,cutFractionalByPrecision:n=!1,useRtlFormat:r=!0,variableMinTickDataPrice:a,ignoreLocaleNumberFormat:l,noExponentialForm:c,removeAllEndingZeros:h}=t;let d="";e<0?d=!1===s?"":"−":e&&!0===i&&(d="+");const u=this._formatUnsigned(Math.abs(e),{tailSize:o,cutFractionalByPrecision:n,variableMinTickDataPrice:a,ignoreLocaleNumberFormat:l,noExponentialForm:c,removeAllEndingZeros:h}),_="0"===u?u:d+u;return r?(0,p.forceLTRStr)(_):_}parse(e,t){return"+"===(e=(e=(0,p.stripLTRMarks)(e)).replace("−","-"))[0]&&(e=e.substring(1)),this._parseUnsigned(e,t)}_removeEndingZeros(e,t){for(let i=0;i<t&&"0"===e[e.length-1];i++)e=e.substring(0,e.length-1);return e}}var v=i(91799),S=i(95322),b=i(26010);const w=(0,n.getLogger)("Chart.DecimalPriceFormatter");class C extends y{constructor(e){super(e);const{minMove2:t,ignoreLocaleNumberFormat:i,noExponentialForm:s}=e;void 0!==t&&10!==t&&0!==t&&1!==t&&w.logDebug("invalid minmove2"),this._ignoreLocaleNumberFormat=i,this._noExponentialForm=s}hasForexAdditionalPrecision(){return 10===this._minMove2}_parseUnsigned(e,t){return this._parseAsDecimal(e,t)}_formatUnsigned(e,t){const{tailSize:i,cutFractionalByPrecision:s=!1,variableMinTickDataPrice:o,ignoreLocaleNumberFormat:n,noExponentialForm:r,removeAllEndingZeros:a=!1}=t,l={price:Math.abs(e),priceScale:this._priceScale,minMove:this._minMove,fractionalLength:this._fractionalLength,tailSize:i,cutFractionalByPrecision:s,ignoreLocaleNumberFormat:n,noExponentialForm:r,removeAllEndingZeros:a};return void 0!==this._variableMinTickData&&(Object.assign(l,f(!1,this._variableMinTickData,o??l.price)),this._ignoreMinMove&&(l.minMove=1)),this._formatAsDecimal(l)}_formatAsDecimal(e){const{price:t,priceScale:i,minMove:o,fractionalLength:n=0,tailSize:r=0,cutFractionalByPrecision:a,ignoreLocaleNumberFormat:l=this._ignoreLocaleNumberFormat,noExponentialForm:c=this._noExponentialForm,removeAllEndingZeros:h}=e,d=(0,b.getNumberFormat)(l);if(t>=1e21&&!c)return t.toString().replace(".",d.decimalSign);const u=Math.pow(10,r)*i/(a?1:o),_=1/u;let p;if(u>1)p=Math.floor(t);else{const e=Math.floor(Math.round(t/_)*_);p=0===Math.round((t-e)/_)?e:e+_}let m="";if(u>1){let e=a?new s.Big(t).mul(u).round(void 0,0).minus(new s.Big(p).mul(u)).toNumber():parseFloat((Math.round(t*u)-p*u).toFixed(n));e>=u&&(e-=u,p+=1),e=a?new s.Big(e).round(n,0).toNumber():parseFloat(e.toFixed(n))*o;const i=(0,S.numberToStringWithLeadingZero)(e,n+r);if(!c&&t<1&&n>=10&&i.startsWith("0000")){let e=4;for(let t=e;t<i.length&&"0"===i[t];t++)e++;const t=this._removeEndingZeros(i.slice(e),n);return""===t?"0":`0${d.decimalSign}${t}e-${e}`}const l=this._removeEndingZeros(i,h?i.length:r);m=l?d.decimalSign+l:l}const g=(0,v.formatNumber)(p,d,void 0,c);return g.includes("e")?g:g+m}_parseAsDecimal(e,t={}){const{ignoreLocaleNumberFormat:i}=t,s=(0,b.getNumberFormat)(this._ignoreLocaleNumberFormat||i),o=(0,v.parseNumber)(e,s);return Number.isFinite(o)?{value:o,res:!0,suggest:this.formatImpl(o)}:{error:this._formatterErrors.custom,res:!1}}}const T=(0,
n.getLogger)("Chart.FractionalPriceFormatter");class P extends y{constructor(e){super(e);const{minMove2:t}=e;null!=t&&t>0&&2!==t&&4!==t&&8!==t&&T.logDebug("invalid minmove2")}hasForexAdditionalPrecision(){return!1}_parseUnsigned(e){return this._minMove2?this._parseAsDoubleFractional(e):this._parseAsSingleFractional(e)}_formatUnsigned(e,t){const{tailSize:i,variableMinTickDataPrice:s}=t,o={price:Math.abs(e),priceScale:this._priceScale,minMove:this._minMove,minMove2:this._minMove2,fractionalLength:(0,r.ensureDefined)(this._fractionalLength),tailSize:i};return void 0!==this._variableMinTickData&&Object.assign(o,f(!0,this._variableMinTickData,s??o.price)),this._formatAsFractional(o)}_parseAsSingleFractional(e){let t=m.exec(e);if(t){const t=parseFloat(e);return{value:t,res:!0,suggest:this.formatImpl(t)}}if(t=new RegExp("^(-?)([0-9]+)\\"+b.formatterOptions.decimalSignFractional+"([0-9]+)$").exec(e),t){const e=!!t[1],i=parseInt(t[2]),s=this._priceScale,o=this._patchFractPart(parseInt(t[3]),1,s);if(o>=s||o<0)return{error:this._formatterErrors.fraction,res:!1};let n=i+o/s;return e&&(n=-n),{value:n,res:!0,suggest:this.formatImpl(n)}}return{error:this._formatterErrors.custom,res:!1}}_parseAsDoubleFractional(e){let t=m.exec(e);if(t){const t=parseFloat(e);return{value:t,res:!0,suggest:this.formatImpl(t)}}if(t=new RegExp("^(-?)([0-9]+)\\"+b.formatterOptions.decimalSignFractional+"([0-9]+)\\"+b.formatterOptions.decimalSignFractional+"([0-9]+)$").exec(e),t){const e=!!t[1],i=parseInt(t[2]),s=void 0!==this._minMove2&&null!==this._minMove2?this._minMove2:NaN,o=this._priceScale/s,n=this._minMove2,r=this._patchFractPart(parseInt(t[3]),1,o),a=this._patchFractPart(parseInt(t[4]),2,n);if(r>=o||r<0)return{error:this._formatterErrors.fraction,res:!1};if(null!=n&&a>=n||a<0)return{error:this._formatterErrors.secondFraction,res:!1};let l=null!=n?i+r/o+a/(o*n):NaN;return e&&(l=-l),{value:l,res:!0,suggest:this.formatImpl(l)}}return{error:this._formatterErrors.custom,res:!1}}_patchFractPart(e,t,i){const s={0:0,5:1},o={0:0,2:1,5:2,7:3},n={0:0,1:1,2:2,3:3,5:4,6:5,7:6,8:7};return 2===i?void 0===s[e]?-1:s[e]:4===i?void 0===o[e]?-1:o[e]:8===i&&2===t?void 0===n[e]?-1:n[e]:e}_formatAsFractional(e){const{price:t,tailSize:i,priceScale:s,minMove:o,minMove2:n,fractionalLength:r}=e,a=s/o;let l=Math.floor(t),c=i?Math.floor(t*a)-l*a:Math.round(t*a)-l*a;c===a&&(c=0,l+=1);let h="";if(i){let e=(t-l-c/a)*a;e=Math.round(e*Math.pow(10,i)),h=(0,S.numberToStringWithLeadingZero)(e,i),h=this._removeEndingZeros(h,i)}if(!r)throw new Error("_fractionalLength is not calculated");let d="";if(n){const e=c%n;c=(c-e)/n;const t=(0,S.numberToStringWithLeadingZero)(c,r),i=this._getFractPart(e,2,n);d=t+b.formatterOptions.decimalSignFractional+i}else c=this._getFractPart(c,1,s),d=(0,S.numberToStringWithLeadingZero)(c*o,r);return l.toString()+b.formatterOptions.decimalSignFractional+d+h}_getFractPart(e,t,i){const s=[0,5],o=[0,2,5,7],n=[0,1,2,3,5,6,7,8];return 2===i?void 0===s[e]?-1:s[e]:4===i?void 0===o[e]?-1:o[e]:8===i&&2===t?void 0===n[e]?-1:n[e]:e}}var x=i(87465);class M{
constructor(e={}){this.type="price";const{minMove2:t,fractional:i,variableMinTick:s,ignoreMinMove:o,ignoreLocaleNumberFormat:n}=e,r=!e.minMove||o?1:e.minMove,a=(0,x.isNumber)(e.priceScale)&&(0,x.isInteger)(e.priceScale)?e.priceScale:100,l=g(a,r,i,t),c={...e,minMove:r,priceScale:a,fractionalLength:l};if(a<0)throw new TypeError("invalid base");this._priceScale=a,this._minMove=r,this._minMove2=t,this._fractional=i,this._variableMinTick=s,this._ignoreMinMove=o,this._fractionalLength=l,this._ignoreLocaleNumberFormat=n,this._noExponentialForm=e.noExponentialForm,this._implementation=i?new P(c):new C(c)}isFractional(){return!!this._fractional}state(){return{minMove:this._minMove,minMove2:this._minMove2,priceScale:this._priceScale,variableMinTick:this._variableMinTick,ignoreMinMove:this._ignoreMinMove,fractional:this._fractional,noExponentialForm:this._noExponentialForm}}formatChange(e,t,i){return this._implementation.formatImpl(e-t,{...i,variableMinTickDataPrice:Math.min(Math.abs(e),Math.abs(t))})}format(e,t){return this._implementation.formatImpl(e,t)}parse(e,t){return this._implementation.parse(e,t)}hasForexAdditionalPrecision(){return this._implementation.hasForexAdditionalPrecision()}static serialize(e){return e.state()}static deserialize(e){return new M(e)}}},82087:(e,t,i)=>{"use strict";i.d(t,{TimeFormatter:()=>_,hourMinuteFormat:()=>l,hourMinuteNonZeroSecondFormat:()=>r,hourMinuteSecondFormat:()=>n,hourMinuteSecondMillisecFormat:()=>a,twelveHourMinuteFormat:()=>d,twelveHourMinuteNonZeroSecondFormat:()=>h,twelveHourMinuteSecondFormat:()=>c});var s=i(35727),o=i(95322);const n="%h:%m:%s",r="%h:%m:%s+",a="%h:%m:%s.%ss+",l="%h:%m",c="%h:%m:%s %ampm",h="%h:%m:%s+ %ampm",d="%h:%m %ampm";var u;!function(e){e.TwentyFourHours="24-hours",e.TwelveHours="12-hours"}(u||(u={}));class _{constructor(e){this._isTwelveHoursFormat=!1,this._valuesAndDelimeters=[];const t=e||n,i=new RegExp("%h|%m|%s\\+|%ss\\+|%ss|%ampm|%s","g");let s=i.exec(t),o=0;for(;null!==s;){const e=s[0];"%ampm"===e&&(this._isTwelveHoursFormat=!0);const n=t.substring(o,s.index);""!==n&&this._valuesAndDelimeters.push(n),this._valuesAndDelimeters.push(e),o=s.index+e.length,s=i.exec(t)}}format(e){return s.customFormatters.timeFormatter?s.customFormatters.timeFormatter.format(e):this._formatTime(e,!1)}formatLocal(e){return s.customFormatters.timeFormatter?s.customFormatters.timeFormatter.formatLocal?s.customFormatters.timeFormatter.formatLocal(e):s.customFormatters.timeFormatter.format(e):this._formatTime(e,!0)}_formatTime(e,t){let i=t?e.getHours():e.getUTCHours();const s=t?e.getMinutes():e.getUTCMinutes(),n=t?e.getSeconds():e.getUTCSeconds(),r=t?e.getMilliseconds():e.getUTCMilliseconds();let a="";this._isTwelveHoursFormat&&(a=i>=12?"PM":"AM",i%=12,i=i||12);let l="",c=!1;for(let e=this._valuesAndDelimeters.length-1;e>=0;e--){const t=this._valuesAndDelimeters[e];let h;switch(t){case"%h":h=(0,o.numberToStringWithLeadingZero)(i,2);break;case"%m":h=(0,o.numberToStringWithLeadingZero)(s,2);break;case"%s+":0!==n?h=(0,o.numberToStringWithLeadingZero)(n,2):(h="",c=!0);break
;case"%s":h=(0,o.numberToStringWithLeadingZero)(n,2);break;case"%ss":h=(0,o.numberToStringWithLeadingZero)(r,3);break;case"%ss+":0!==r?h=(0,o.numberToStringWithLeadingZero)(r,3):(h="",c=!0);break;case"%ampm":h=a;break;default:if(c){c=!1;continue}h=t}l=h+l}return l}}},18185:(e,t,i)=>{"use strict";i.d(t,{TimeSpanFormatter:()=>r});var s=i(11542),o=i(91799),n=i(26010);class r{format(e,t){const r=e<0;e=Math.abs(e);const a=Math.floor(e/86400);e-=86400*a;const l=Math.floor(e/3600);e-=3600*l;const c=Math.floor(e/60);e-=60*c;let h="";if(a){const e=(0,n.getNumberFormat)(t?.ignoreLocaleNumberFormat);h+=(0,o.formatNumber)(a,e)+s.t(null,{context:"dates"},i(85886))+" "}return l&&(h+=l+s.t(null,{context:"dates"},i(44634))+" "),c&&(h+=c+s.t(null,{context:"dates"},i(5977))+" "),e&&(h+=e+s.t(null,{context:"dates"},i(21492))+" "),r&&(h="-"+h),h.trim()}}},91565:(e,t,i)=>{"use strict";i.d(t,{VolumeFormatter:()=>l});var s=i(11542),o=i(97906),n=i(87465);const r=[{value:3,letter:"K"},{value:6,letter:"M"},{value:9,letter:"B"},{value:12,letter:"T"}];function a(e,t){const i=e-t;return r.find((e=>e.value>=i))??r[r.length-1]}class l{constructor(e={}){this.type="volume";const{precision:t=0,minPrecision:i=0,dimensionPrecision:s=2,dimensionMinPrecision:n=0,significantDigits:r=3,ignoreLocaleNumberFormat:a,noExponentialForm:l,removeSpaceBeforeDimension:c}=e;this._precision=t,this._formatter=new o.NumericFormatter({ignoreLocaleNumberFormat:a,precision:this._precision,minPrecision:i,noExponentialForm:l}),this._dimensionPrecision=s,this._dimensionFormatter=new o.NumericFormatter({ignoreLocaleNumberFormat:a,precision:this._dimensionPrecision,minPrecision:n,noExponentialForm:l}),this._significantDigits=r,this._fractionalValues=void 0!==t&&t>0,this._spaceBeforeDimension=c?"":" ",this._options=e}state(){const{ignoreLocaleNumberFormat:e,...t}=this._options;return t}format(e,t){if(!(0,n.isNumber)(e))return"---";if(Math.abs(e)>=1e100)return s.t(null,void 0,i(96935));let o="";Math.abs(e)<1&&(e=+e.toFixed(this._precision)),e<0?o="−":e>0&&t?.signPositive&&(o="+"),e=Math.abs(e);const r=!!(t?.ignoreLocaleNumberFormat??this._options.ignoreLocaleNumberFormat);let l,c,h=Math.floor(Math.log10(e))+1;if(h<=this._significantDigits&&(e=+e.toFixed(this._precision),h=Math.floor(Math.log10(e))+1),h<=this._significantDigits)l=this._formatNumber(e,r,this._formatter);else{let t=a(h,this._significantDigits);const i=Math.pow(10,t.value);e=+(e/i).toFixed(this._dimensionPrecision)*i,t=a(Math.floor(Math.log10(e))+1,this._significantDigits),l=this._formatNumber(e/Math.pow(10,t.value),r,this._dimensionFormatter),c=t.letter}return c?`${o}${l}${this._spaceBeforeDimension}${c}`:`${o}${l}`}parse(e,t){if("---"===e)return{error:"not a number",res:!1,value:NaN};const i={K:1e3,M:1e6,B:1e9,T:1e12},s=(e=e.replace("−","-")).slice(-1);if(i.hasOwnProperty(s)){const o=this._formatter.parse(e.slice(0,-1).trim(),t),r=o.res?o.value:NaN;return(0,n.isNumber)(r)?{res:!0,value:r*i[s]}:{error:"not a number",res:!1,value:NaN}}{const i=this._formatter.parse(e.trim(),t);let s=i.res?i.value:NaN
;return-0===s&&(s=0),(0,n.isNumber)(s)?{res:!0,value:s}:{error:"not a number",res:!1,value:NaN}}}static serialize(e){return e.state()}static deserialize(e){return new l(e)}_formatNumber(e,t,i){if(this._fractionalValues&&0!==e){const t=14-Math.ceil(Math.log10(e)),i=Math.pow(10,t);e=Math.round(e*i)/i}return i.format(e,{ignoreLocaleNumberFormat:t})}}},63903:(e,t,i)=>{"use strict";i.d(t,{getPriceValueFormatterForSource:()=>l,getPriceValueFormatterForStudy:()=>c,shouldBeFormattedAsIndexedTo100:()=>r,shouldBeFormattedAsPercent:()=>n});var s=i(95059),o=i(22455);function n(e){const t=e.priceScale();return!(null===t||!t.isPercentage())&&(!(0,o.isActingAsSymbolSource)(e)||(0,s.isPriceSourceStyle)(e.style()))}function r(e){const t=e.priceScale();return!(null===t||!t.isIndexedTo100())&&(!(0,o.isActingAsSymbolSource)(e)||(0,s.isPriceSourceStyle)(e.style()))}function a(e){const t=e.priceScale();return r(e)&&null!==t?(i,s)=>t.formatPriceIndexedTo100(i,e.firstValue()??100,s):n(e)&&null!==t?(i,s)=>t.formatPricePercentage(i,e.firstValue()??100,s):null}function l(e){const t=a(e);if(t)return t;const i=e.formatter();return i.format.bind(i)}function c(e,t){const i=a(e);if(i)return i;const s=e.plotFormatter(t);return s.format.bind(s)}},2383:(e,t,i)=>{"use strict";i.d(t,{AreaName:()=>s,HitTarget:()=>n,HitTestResult:()=>d,hitTestResultDataAreEqual:()=>h,shouldDefaultActionBeExecuted:()=>c,tryCallHandler:()=>l});var s,o,n,r=i(50279),a=i(50151);function l(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 c(e,t,i,s){return void 0!==t.executeDefaultAction&&(e.isTouch?Boolean(t.executeDefaultAction[s]):Boolean(t.executeDefaultAction[i]))}function h(e,t){return e&&t&&e.equals&&t.equals?e.equals(t):(0,r.default)(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.Both=0]="Both",e[e.Horz=1]="Horz",e[e.Vert=2]="Vert"}(o||(o={})),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"}(n||(n={}));class d{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,a.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&&l(e,t,this._data.mouseDownHandler,this._data.touchStartHandler)}tryCallMouseUpOrTouchEndHandler(e,t){return null!==this._data&&l(e,t,this._data.mouseUpHandler,this._data.touchEndHandler)}tryCallMouseEnterHandler(e,t){return null!==this._data&&l(e,t,this._data.mouseEnterHandler)}tryCallMouseLeaveHandler(e,t){return null!==this._data&&l(e,t,this._data.mouseLeaveHandler)}
tryCallMouseMoveHandler(e,t){return null!==this._data&&l(e,t,this._data.mouseMoveHandler)}tryCallClickOrTapHandler(e,t){return null!==this._data&&l(e,t,this._data.clickHandler,this._data.tapHandler)}tryCallDblClickOrDblTapHandler(e,t){return null!==this._data&&l(e,t,this._data.doubleClickHandler,this._data.doubleTapHandler)}tryCallContextMenuHandler(e,t){return null!==this._data&&l(e,t,this._data.contextMenuHandler,this._data.touchContextMenuHandler)}eraseMarker(){return this._eraseMarker}}},40738:(e,t,i)=>{"use strict";i.d(t,{HorizontalLinePaneView:()=>n});var s=i(94119),o=i(69558);class n{constructor(){this._lineRendererData={y:0,color:"rgba(0, 0, 0, 0)",linewidth:1,linestyle:o.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}}},86572:(e,t,i)=>{"use strict";var s,o,n;i.d(t,{CustomSourceLayer:()=>a,PlDisplay:()=>o,RecalcVisibleRangeStudiesReason:()=>c,TradedGroupHorizontalAlignment:()=>n,tradingPreferencesDefault:()=>r}),function(e){e[e.Initial=2]="Initial",e[e.SeriesZOrderIsAlwaysZero=3]="SeriesZOrderIsAlwaysZero",e[e.Current=3]="Current"}(s||(s={})),function(e){e[e.Money=0]="Money",e[e.Pips=1]="Pips",e[e.Percentage=2]="Percentage"}(o||(o={})),function(e){e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right"}(n||(n={}));const r={showPositions:!1,positionAndBracketsPL:!1,positionPL:{visibility:!1,display:o.Money},bracketsPL:{visibility:!1,display:o.Money},showOrders:!1,showExecutions:!1,showExecutionsLabels:!1,showReverse:!1,extendLeft:!1,lineLength:0,horizontalAlignment:n.Right,lineWidth:0,lineStyle:0};var a,l,c,h;!function(e){e[e.Background=0]="Background",e[e.Foreground=1]="Foreground",e[e.Topmost=2]="Topmost"}(a||(a={})),function(e){e[e.Unavailable=0]="Unavailable",e[e.AvailableReadonlyAlwaysDisabled=1]="AvailableReadonlyAlwaysDisabled",e[e.AvailableReadonlyAlwaysEnabled=2]="AvailableReadonlyAlwaysEnabled",e[e.Available=3]="Available"}(l||(l={})),function(e){e[e.ViewportChangeUserAction=0]="ViewportChangeUserAction",e[e.DataUpdate=1]="DataUpdate",e[e.SeriesRestart=2]="SeriesRestart",e[e.SeriesCompleted=3]="SeriesCompleted",e[e.StudyCreation=4]="StudyCreation"}(c||(c={})),function(e){e[e.Chart=0]="Chart"}(h||(h={}))},1395:(e,t,i)=>{"use strict";var s;i.d(t,{CreateLineToolSyncMode:()=>s}),function(e){e[e.Default=0]="Default",e[e.ForceOn=1]="ForceOn",e[e.ForceOff=2]="ForceOff"}(s||(s={}))},36313:(e,t,i)=>{"use strict";var s,o,n;i.d(t,{TitleDisplayTarget:()=>n}),function(e){e[e.AfterMainSeries=0]="AfterMainSeries"}(s||(s={})),function(e){e[e.Idle=0]="Idle",e[e.Processing=1]="Processing",e[e.Active=2]="Active",e[e.Stopped=3]="Stopped"}(o||(o={})),function(e){e[e.DataWindow=1]="DataWindow",e[e.StatusLine=2]="StatusLine",e[e.Alerts=3]="Alerts"}(n||(n={}))},46082:(e,t,i)=>{"use strict";i.d(t,{Interval:()=>s.Interval,ResolutionKind:()=>s.ResolutionKind,
SpecialResolutionKind:()=>s.SpecialResolutionKind,isHour:()=>s.isHour});var s=i(10892)},37293:(e,t,i)=>{"use strict";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}},97719:(e,t,i)=>{"use strict";i.d(t,{IntervalsVisibilitiesProperty:()=>o});var s=i(43337);i(81922);class o extends s.Property{state(e,t){return super.state(e,t)}storeStateIfUndefined(){return!1}}},81922:(e,t,i)=>{"use strict";i.d(t,{getIntervalsVisibilitiesForMode:()=>_,isActualInterval:()=>d,makeIntervalsVisibilitiesVisibleAtInterval:()=>c,mergeIntervalVisibilitiesDefaults:()=>u});var s,o=i(16738),n=i(90054),r=i(50151),a=i(46082),l=i(37293);function c(e,t){let i=t.multiplier();if(t.isTicks()&&(e.ticks=!0),t.isSeconds()&&(i<60?(e.seconds=!0,e.secondsFrom=Math.min(e.secondsFrom,i),e.secondsTo=Math.max(e.secondsTo,i)):(i=Math.floor(i/60),t=new a.Interval(a.ResolutionKind.Minutes,i))),t.isMinutes())if(i<60)e.minutes=!0,e.minutesFrom=Math.min(e.minutesFrom,i),e.minutesTo=Math.max(e.minutesTo,i);else{const t=Math.floor(i/60);e.hours=!0,e.hoursFrom=Math.min(e.hoursFrom,t),e.hoursTo=Math.max(e.hoursTo,t)}t.isDays()&&(e.days=!0,e.daysFrom=Math.min(e.daysFrom,i),e.daysTo=Math.max(e.daysTo,i)),t.isWeeks()&&(e.weeks=!0,e.weeksFrom=Math.min(e.weeksFrom,i),e.weeksTo=Math.max(e.weeksTo,i)),t.isMonths()&&(e.months=!0,e.monthsFrom=Math.min(e.monthsFrom,i),e.monthsTo=Math.max(e.monthsTo,i)),t.isRange()&&(e.ranges=!0)}function h(e,t,i,s){return e&&s>=t&&s<=i}function d(e,t){const i=t.childs();switch(e.kind()){case a.ResolutionKind.Ticks:return i.ticks.value();case a.ResolutionKind.Seconds:if(e.multiplier()<60)return h(i.seconds.value(),i.secondsFrom.value(),i.secondsTo.value(),e.multiplier());{const t=Math.floor(e.multiplier()/60);return h(i.minutes.value(),i.minutesFrom.value(),i.minutesTo.value(),t)}case a.ResolutionKind.Minutes:if(e.multiplier()<60)return h(i.minutes.value(),i.minutesFrom.value(),i.minutesTo.value(),e.multiplier());{const t=Math.floor(e.multiplier()/60);return h(i.hours.value(),i.hoursFrom.value(),i.hoursTo.value(),t)}case a.ResolutionKind.Days:return h(i.days.value(),i.daysFrom.value(),i.daysTo.value(),e.multiplier());case a.ResolutionKind.Weeks:return h(i.weeks.value(),i.weeksFrom.value(),i.weeksTo.value(),e.multiplier());case a.ResolutionKind.Months:return h(i.months.value(),i.monthsFrom.value(),i.monthsTo.value(),e.multiplier());case a.ResolutionKind.Range:return i.ranges.value()}return(0,r.assert)(!1,`Unsupported resolution: ${e.value()}`),!1}function u(e){return(0,o.default)((0,n.default)(l.intervalsVisibilitiesDefaults),e??{})}function _(e,t){if(0===t||e.isTicks()&&3===t||e.isRange()&&2===t)return u();let i=!1;const s={ticks:!1,seconds:!1,minutes:!1,hours:!1,days:!1,weeks:!1,months:!1,ranges:!1},o=e=>e.multiplier();return[{checker:e=>e.isTicks(),getIntervalMultiplier:o,markIntervalAsVisible:(e,t)=>{s.ticks=!0}},{
checker:e=>e.isSeconds()&&e.multiplier()<60,getIntervalMultiplier:o,markIntervalAsVisible:(e,t)=>{s.seconds=!0,s.secondsFrom=e,s.secondsTo=t}},{checker:e=>e.isSeconds()&&e.multiplier()>=60,getIntervalMultiplier:e=>Math.floor(e.multiplier()/60),markIntervalAsVisible:(e,t)=>{s.minutes=!0,s.minutesFrom=e,s.minutesTo=t}},{checker:e=>e.isMinutes()&&e.multiplier()<60,getIntervalMultiplier:o,markIntervalAsVisible:(e,t)=>{s.minutes=!0,s.minutesFrom=e,s.minutesTo=t}},{checker:e=>e.isMinutes()&&e.multiplier()>=60,getIntervalMultiplier:e=>Math.floor(e.multiplier()/60),markIntervalAsVisible:(e,t)=>{s.hours=!0,s.hoursFrom=e,s.hoursTo=t}},{checker:e=>e.isDays(),getIntervalMultiplier:o,markIntervalAsVisible:(e,t)=>{s.days=!0,s.daysFrom=e,s.daysTo=t}},{checker:e=>e.isWeeks(),getIntervalMultiplier:o,markIntervalAsVisible:(e,t)=>{s.weeks=!0,s.weeksFrom=e,s.weeksTo=t}},{checker:e=>e.isMonths(),getIntervalMultiplier:o,markIntervalAsVisible:(e,t)=>{s.months=!0,s.monthsFrom=e,s.monthsTo=t}},{checker:e=>e.isRange(),getIntervalMultiplier:o,markIntervalAsVisible:(e,t)=>{s.ranges=!0}}].forEach((s=>{if(s.checker(e)){i=!0;const o=s.getIntervalMultiplier(e);1===t?s.markIntervalAsVisible(o,o):3===t?s.markIntervalAsVisible(o,void 0):s.markIntervalAsVisible(void 0,o)}else(!i&&2===t||i&&3===t)&&s.markIntervalAsVisible(void 0,void 0)})),u(s)}!function(e){e[e.All=0]="All",e[e.OnlyCurrent=1]="OnlyCurrent",e[e.CurrentAndBelow=2]="CurrentAndBelow",e[e.CurrentAndAbove=3]="CurrentAndAbove"}(s||(s={}))},55396:(e,t,i)=>{"use strict";var s,o,n;i.d(t,{PaneMode:()=>n}),function(e){e.Left="left",e.Right="right"}(s||(s={})),function(e){e.Tiny="tiny",e.Small="small",e.Medium="medium",e.Large="large"}(o||(o={})),function(e){e[e.Regular=0]="Regular",e[e.Widget=1]="Widget"}(n||(n={}))},5471:(e,t,i)=>{"use strict";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={}))},7543:(e,t,i)=>{"use strict";function s(e){return Boolean(e.showInObjectTree)}i.d(t,{isDataSource:()=>s})},15574:(e,t,i)=>{"use strict";i.d(t,{isTicksEnabled:()=>o});var s=i(37103);function o(){return s.enabled("tick_resolution")}},6652:(e,t,i)=>{"use strict";var s,o,n;function r(e){return e.isSeries}i.d(t,{isSeries:()=>r}),function(e){e[e.Bars=0]="Bars",e[e.Candles=1]="Candles",e[e.Line=2]="Line",e[e.Area=3]="Area",e[e.HeikenAshi=8]="HeikenAshi",e[e.HollowCandles=9]="HollowCandles",e[e.Baseline=10]="Baseline",e[e.HiLo=12]="HiLo",e[e.Column=13]="Column",e[e.LineWithMarkers=14]="LineWithMarkers",e[e.Stepline=15]="Stepline",e[e.HLCArea=16]="HLCArea",e[e.VolCandle=19]="VolCandle",e[e.HLCBars=21]="HLCBars",e[e.Renko=4]="Renko",e[e.Kagi=5]="Kagi",e[e.PointAndFigure=6]="PointAndFigure",e[e.LineBreak=7]="LineBreak"}(s||(s={})),function(e){e.Value="_seriesId"}(o||(o={})),function(e){e[e.InvalidSymbol=0]="InvalidSymbol",e[e.ReplayUnsupported=1]="ReplayUnsupported",e[e.UnsupportedDepth=2]="UnsupportedDepth",e[e.UnsupportedIntradyReplay=3]="UnsupportedIntradyReplay"}(n||(n={}))},98155:(e,t,i)=>{"use strict";var s
;i.d(t,{SymbolErrorPermissionDeniedReason:()=>s,invalidSymbol:()=>n,permissionDenied:()=>o}),function(e){e.Symbol="symbol",e.GroupPermission="group"}(s||(s={}));const o="permission denied",n="invalid symbol"},22455:(e,t,i)=>{"use strict";function s(e){return e?.symbolSource&&e.symbolSource()===e||void 0!==e?.isActingAsSymbolSource}function o(e){return s(e)&&"quotesProvider"in e}function n(e){return s(e)&&e.isActingAsSymbolSource().value()}i.d(t,{isActingAsSymbolSource:()=>n,isSymbolSource:()=>s,isSymbolSourceWithQuotesProvider:()=>o})},17161:(e,t,i)=>{"use strict";i.d(t,{alwaysShowLastPriceAndLastDayChange:()=>s,lastDayChangeAvailable:()=>o});i(37103);const s=!1,o=!1},13896:(e,t,i)=>{"use strict";i.d(t,{lineToolsDoNotAffectChartInvalidation:()=>s});const s=!1},45580:(e,t,i)=>{"use strict";var s;i.d(t,{LineToolBarsPatternMode:()=>s}),function(e){e[e.Bars=0]="Bars",e[e.Line=1]="Line",e[e.OpenClose=2]="OpenClose",e[e.LineOpen=3]="LineOpen",e[e.LineHigh=4]="LineHigh",e[e.LineLow=5]="LineLow",e[e.LineHL2=6]="LineHL2"}(s||(s={}))},55393:(e,t,i)=>{"use strict";i.d(t,{LineToolBrushBase:()=>r});var s=i(50151),o=i(41414),n=i(22613);class r extends o.LineDataSource{constructor(){super(...arguments),this._hasEditableCoordinates=new n.WatchedValue(!1),this._finished=!1}pointsCount(){return-1}finished(){return this._finished}finish(){this._finished=!0,this._lastPoint=null,this._normalizePoints(),this.createServerPoints()}hasOnlyOnePoint(){return 1===this._points.length}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}}},39697:(e,t,i)=>{"use strict";i.d(t,{CircleRenderer:()=>r});var s=i(6453),o=i(2383),n=i(4539);class r{constructor(e){this._data=e??null}setData(e){this._data=e}draw(e,t){if(null===this._data)return;const{center:i,radius:s,lineWidth:o,color:n,backColor:r}=this._data;e.save();const{horizontalPixelRatio:a,verticalPixelRatio:l}=t,c=Math.max(1,Math.floor(a)),h=c%2/2,d=Math.round(i.x*a)+h,u=Math.round(i.y*l)+h,_=Math.round(d+s*a),p=Math.max(1,Math.floor(o*a)),m=_-d-p;m>0&&(e.fillStyle=r,e.beginPath(),e.moveTo(d+m,u),e.arc(d,u,m,0,2*Math.PI,!1),e.fill());const g=Math.max(c/2,_-d-p/2);e.strokeStyle=n,e.lineWidth=p,e.beginPath(),e.moveTo(d+g,u),e.arc(d,u,g,0,2*Math.PI,!1),e.stroke(),e.restore()}hitTest(e){if(null===this._data||this._data.disableInteractions)return null;const{center:t,radius:i,backgroundHitTarget:r}=this._data,a=(0,n.interactionTolerance)().curve;if(!(0,s.pointInCircle)(e,t,i+a))return null;const l=i>a&&(0,s.pointInCircle)(e,t,i-a)?r??o.HitTarget.MovePointBackground:o.HitTarget.MovePoint;return new o.HitTestResult(l)}}},59883:(e,t,i)=>{"use strict";i.d(t,{DEFAULT_LINE_TOOL_LINE_WIDTH:()=>s});const s=2},10544:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineToolElliott:()=>m,
LineToolElliottCorrection:()=>P,LineToolElliottDegree:()=>s,LineToolElliottDoubleCombo:()=>M,LineToolElliottImpulse:()=>y,LineToolElliottTriangle:()=>S,LineToolElliottTripleCombo:()=>w});var s,o,n=i(11542),r=i(95804),a=i(41414),l=i(41706),c=i(78176),h=i(65045),d=i(13896);!function(e){e[e.Supermillennium=0]="Supermillennium",e[e.Millennium=1]="Millennium",e[e.Submillennium=2]="Submillennium",e[e.GrandSupercycle=3]="GrandSupercycle",e[e.Supercycle=4]="Supercycle",e[e.Cycle=5]="Cycle",e[e.Primary=6]="Primary",e[e.Intermediate=7]="Intermediate",e[e.Minor=8]="Minor",e[e.Minute=9]="Minute",e[e.Minuette=10]="Minuette",e[e.Subminuette=11]="Subminuette",e[e.Micro=12]="Micro",e[e.Submicro=13]="Submicro",e[e.Minuscule=14]="Minuscule"}(s||(s={})),function(e){e[e.Current=4]="Current"}(o||(o={}));const u=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],_=new r.TranslatedString("change Elliott degree",n.t(null,void 0,i(47977))),p=[{value:0,title:n.t(null,void 0,i(3348))},{value:1,title:n.t(null,void 0,i(87957))},{value:2,title:n.t(null,void 0,i(63375))},{value:3,title:n.t(null,void 0,i(57726))},{value:4,title:n.t(null,void 0,i(67948))},{value:5,title:n.t(null,void 0,i(87380))},{value:6,title:n.t(null,void 0,i(59189))},{value:7,title:n.t(null,void 0,i(10268))},{value:8,title:n.t(null,{context:"wave"},i(51077))},{value:9,title:n.t(null,{context:"wave"},i(922))},{value:10,title:n.t(null,void 0,i(14724))},{value:11,title:n.t(null,void 0,i(30585))},{value:12,title:n.t(null,void 0,i(24866))},{value:13,title:n.t(null,void 0,i(1145))},{value:14,title:n.t(null,void 0,i(78273))}];class m extends a.LineDataSource{constructor(e,t,s,o){super(e,t??m.createProperties(e.backgroundTheme().spawnOwnership()),s,o),this.version=4,Promise.all([i.e(6290),i.e(986),i.e(6668),i.e(1583)]).then(i.bind(i,60509)).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"}async additionalActions(e){return{actions:[new l.Action({actionId:"Chart.LineTool.Elliot.ChangeDegreeProperty",options:{label:n.t(null,void 0,i(23403)),subItems:u.map((t=>{const i=p.filter((e=>e.value===t))[0];return new l.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,_,d.lineToolsDoNotAffectChartInvalidation)}}})}))}})],placement:"CustomAction"}}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 p}static createProperties(e,t){const i=new c.DefaultProperty({defaultName:"linetoolelliott",state:t,theme:e});return this._configureProperties(i),i}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(3198),i.e(5410),i.e(2745),i.e(8823),i.e(8537)]).then(i.bind(i,6238))).ElliottPatternDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e),e.addChild("linesColors",new h.LineToolColorsProperty([e.childs().color])),e.addExcludedKey("linesColors",3)}}class g extends m{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 y extends g{constructor(e,t,i,s){super(e,t??y.createProperties(e.backgroundTheme().spawnOwnership()),i,s)}name(){return"Elliott Impulse Wave (12345)"}labelsGroup(){return f}static createProperties(e,t){const i=new c.DefaultProperty({defaultName:"linetoolelliottimpulse",state:t,theme:e});return this._configureProperties(i),i}}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 S extends g{constructor(e,t,i,s){super(e,t??S.createProperties(e.backgroundTheme().spawnOwnership()),i,s)}name(){return"Elliott Triangle Wave (ABCDE)"}labelsGroup(){return v}static createProperties(e,t){const i=new c.DefaultProperty({defaultName:"linetoolelliotttriangle",state:t,theme:e});return this._configureProperties(i),i}}const b=[["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 w extends g{constructor(e,t,i,s){super(e,t??w.createProperties(e.backgroundTheme().spawnOwnership()),i,s)}name(){return"Elliott Triple Combo Wave (WXYXZ)"}labelsGroup(){return b}static createProperties(e,t){const i=new c.DefaultProperty({defaultName:"linetoolelliotttriplecombo",state:t,theme:e});return this._configureProperties(i),i}}class C extends m{pointsCount(){return 4}}const T=[["0","A","B","C"],["0","a","b","c"],["0","A","B","C"],["0","a","b","c"],["0","A","B","C"]];class P extends C{constructor(e,t,i,s){super(e,t??P.createProperties(e.backgroundTheme().spawnOwnership()),i,s)}name(){
return"Elliott Correction Wave (ABC)"}labelsGroup(){return T}static createProperties(e,t){const i=new c.DefaultProperty({defaultName:"linetoolelliottcorrection",state:t,theme:e});return this._configureProperties(i),i}}const x=[["0","W","X","Y"],["0","w","x","y"],["0","W","X","Y"],["0","w","x","y"],["0","W","X","Y"]];class M extends C{constructor(e,t,i,s){super(e,t??M.createProperties(e.backgroundTheme().spawnOwnership()),i,s)}name(){return"Elliott Double Combo Wave (WXY)"}labelsGroup(){return x}static createProperties(e,t){const i=new c.DefaultProperty({defaultName:"linetoolelliottdoublecombo",state:t,theme:e});return this._configureProperties(i),i}}},27593:(e,t,i)=>{"use strict";i.r(t),i.d(t,{ExecutionLineAdapter:()=>_,ExecutionsPositionController:()=>u,LineToolExecution:()=>p});var s=i(50151),o=i(41414),n=i(32853),r=i(78176),a=i(5471),l=i(37103),c=i(67777),h=i(40472);const d=c.sortSourcesPreOrdered.LineToolExecution;class u{constructor(e){this._pane=e}getXYCoordinate(e,t,i){let o=0;const n=e.getDirection(),r="buy"===n,l=this._pane.model().mainSeries();if(l.bars){const e=r?10:-10,t=l.bars().search(i,a.PlotRowSearchMode.NearestLeft);if(null!==t){i=t.index;const n=r?t.value[3]:t.value[2],a=l.priceScale(),c=(0,s.ensureNotNull)(l.firstValue());o=a.priceToCoordinate(n,c)+e}}e.setAlignedTimePointIndex(i);const c=t.visibleBarsStrictRange();if(!isFinite(i)||null===c||i>c.lastBar()||i<c.firstBar())return{x:-1,y:-1};const h=u._cachedByBarIndexOrderedExecutions[i]||this._pane.sourcesByGroup().all();for(let s=h.length-1;s>=0;--s){const a=h[s];if(!(a instanceof p))continue;if((a.adapter().alignedTimePointIndex()??t.timePointToIndex(a.adapter().getTime(),1))!==i||a.adapter().getDirection()!==n)continue;if(a===e.line())break;const l=a.adapter().height();o=r?o+l:o-l}return{x:t.indexToCoordinate(i),y:o}}static recreateOrderedByBarsSourcesCache(e){this.clearOrderedByBarsSourcesCache();const t=e.sourcesByGroup().all();for(const e of t){if(!(e instanceof p))continue;const t=e.adapter().alignedTimePointIndex();if(void 0===t)continue;const i=u._cachedByBarIndexOrderedExecutions[t]||[];u._cachedByBarIndexOrderedExecutions[t]=i,i.push(e)}}static clearOrderedByBarsSourcesCache(){u._cachedByBarIndexOrderedExecutions={}}}u._cachedByBarIndexOrderedExecutions={};class _{constructor(e,t){this._unixtime=NaN,this._line=e,this._model=t}alignedTimePointIndex(){return this._alignedTimePointIndex}setAlignedTimePointIndex(e){this._alignedTimePointIndex=e}line(){return this._line}getIndex(){return this._model.timeScale().baseIndex()-this._line.points()[0].index}setIndex(e){const t=this._model.timeScale().baseIndex()-Math.abs(e);this._line.startMoving({logical:this._line.points()[0]});const i={...this._line.points()[0]};return i.index=t,this._line.move({logical:i}),this._line.endMoving(!1),this}getTime(){return this._unixtime}setTime(e){return this._unixtime=e,this._line.restorePoints([{offset:0,price:this.getPrice(),time_t:this._unixtime}],[]),this._line.createServerPoints(),this}getPrice(){
return this._line.points().length>0?this._line.points()[0].price:this._line.normalizedPoints().length>0?this._line.normalizedPoints()[0].price:NaN}setPrice(e){return this._line.points().length>0&&(this._line.points()[0].price=e),this._line.normalizedPoints().length>0&&(this._line.normalizedPoints()[0].price=e),this}getText(){return this._line.properties().childs().text.value()}setText(e){return this._line.properties().childs().text.setValue(e||""),this._line.updateAllViewsAndRedraw((0,h.sourceChangeEvent)(this._line.id())),this}getArrowHeight(){return this._line.properties().childs().arrowHeight.value()}setArrowHeight(e){return this._line.properties().childs().arrowHeight.setValue(e||5),this}getArrowSpacing(){return this._line.properties().childs().arrowSpacing.value()}setArrowSpacing(e){return this._line.properties().childs().arrowSpacing.setValue(e||1),this}getDirection(){return this._line.properties().childs().direction.value()}setDirection(e){return this._line.properties().childs().direction.setValue(e||"buy"),this}getArrowColor(){const e=this._line.properties().childs();return"buy"===this.getDirection()?e.arrowBuyColor.value():e.arrowSellColor.value()}setArrowColor(e){return"buy"===this.getDirection()?this.setArrowBuyColor(e):this.setArrowSellColor(e),this}setArrowBuyColor(e){return this._line.properties().childs().arrowBuyColor.setValue(e),this}setArrowSellColor(e){return this._line.properties().childs().arrowSellColor.setValue(e),this}getTextColor(){const e=this._line.properties().childs();return n.getColorFromProperties(e.textColor,e.textTransparency)}setTextColor(e){const t=this._line.properties().childs();return n.setColorToProperties(e,t.textColor,t.textTransparency),this}getFont(){const e=this._line.properties().childs();return n.getFontFromProperties(e.fontFamily,e.fontSize,e.fontBold,e.fontItalic)}setFont(e){const t=this._line.properties().childs();return n.setFontToProperties(e,t.fontFamily,t.fontSize,t.fontBold,t.fontItalic),this}setTooltip(e){return null==e?e="":e+="",this._line.properties().childs().tooltip.setValue(e),this}getTooltip(){return this._line.properties().childs().tooltip.value()}remove(){this._model.removeSource(this._line)}getPoints(){return this._line.points()}height(){const e=this.getArrowHeight(),t=this.getArrowSpacing();let i=0;this.getText()&&(i=n.fontHeight(this.getFont()));return e+t+i+10}}class p extends o.LineDataSource{constructor(e,t,s,o){super(e,t??p.createProperties(e.backgroundTheme().spawnOwnership()),s,o),this._adapter=new _(this,e),this.customization.forcePriceAxisLabel=!1,this.customization.disableErasing=!0,this.setSelectionEnabled(!1),Promise.all([i.e(6290),i.e(986),i.e(6668),i.e(1583)]).then(i.bind(i,52361)).then((e=>{this._setPaneViews([new e.ExecutionPaneView(this,this._model)])}))}adapter(){return this._adapter}zorder(){return d}isSpeciallyZOrderedSource(){return!0}pointsCount(){return 1}name(){return"Execution"}hasContextMenu(){return!1}state(){return{}}updateAllViews(e){if(this._isVisible())return super.updateAllViews(e)}priceAxisViews(e,t){
return this._isVisible()?super.priceAxisViews(e,t):null}paneViews(){return window.TradingView.printing&&!l.enabled("snapshot_trading_drawings")?null:this._isVisible()?super.paneViews():null}userEditEnabled(){return!1}showInObjectTree(){return!1}cloneable(){return!1}copiable(){return!1}isSynchronizable(){return!1}static createProperties(e,t){const i=new r.DefaultProperty({defaultName:"linetoolexecution",state:t,useUserPreferences:!1,theme:e});return p._configureProperties(i),i}_isVisible(){return this._model.properties().childs().tradingProperties.childs().showExecutions.value()}}},10980:(e,t,i)=>{"use strict";i.d(t,{checkImageSize:()=>c,generateLink:()=>a,getMaxImageSizeInBytes:()=>d,getMaxImageSizeLabel:()=>u,imageIsOversized:()=>l,setImageStorageAdapter:()=>r,uploadImage:()=>h});var s=i(11542);const o=/data:(.+?);base64,(.+)/;let n=2e6;function r(e){n=e.getMaxImageSizeInBytes()}async function a(e){return new Promise(((t,i)=>{const s=new FileReader;s.addEventListener("load",(()=>t(s.result))),s.addEventListener("error",i),s.addEventListener("abort",i),s.readAsDataURL(e)}))}function l(e){return function(e){const t=e.match(o);if(null===t)return 1/0;const[i,s,n]=t,r=atob(n),a=new Array(r.length);for(let e=0;e<r.length;e++)a[e]=r.charCodeAt(e);const l=new Uint8Array(a);return new Blob([l],{type:s}).size}(e.src)>n}async function c(e){return e.size<=n}async function h(e){if(!await c(e))throw new Error(s.t(null,{replace:{value:u()}},i(93738)));return a(e)}function d(){return n}function u(){const e=Math.floor(Math.log(n)/Math.log(1e3));return`${(n/Math.pow(1e3,e)).toFixed(2)}${["Bytes","KB","MB","GB","TB","PB"][e]}`}},14715:(e,t,i)=>{"use strict";i.d(t,{blobImageFilter:()=>o,checkImageSize:()=>a,generateLink:()=>r,getMaxImageSizeInBytes:()=>c,getMaxImageSizeLabel:()=>h,imageIsOversized:()=>n,uploadImage:()=>l});var s=i(10980);function o(e){return"image/png"===e.type||"image/jpeg"===e.type||"image/webp"===e.type}function n(e){return s.imageIsOversized(e)}async function r(e){return{status:"ok",data:{url:await s.generateLink(e),fields:{}},filename:"",filepath:""}}async function a(e){return s.checkImageSize(e)}async function l(e){return s.uploadImage(e)}function c(){return s.getMaxImageSizeInBytes()}function h(){return s.getMaxImageSizeLabel()}},73041:(e,t,i)=>{"use strict";i.d(t,{drawSelection:()=>r,getSymbolCoordinatesInfo:()=>n});var s=i(24640),o=i(33350);function n(e){const{symbolPosition:t,textWidth:i,textByLines:n,lineHeight:r,font:a,textAlign:l,lineSpacing:c=0}=e;let[h,d]=function(e,t){let i=0;switch(e){case"center":i=t/2;break;case"start":i=(0,s.isRtl)()?t:0;break;case"end":i=(0,s.isRtl)()?0:t;break;case"right":i=t}return[i,0]}(l,i);const u=(0,s.isRtl)(),_=r+c;let p=0,m=0,g="";for(let e=0;e<n.length;e++){let s=t-p;const{wrappedLinePart:r,wrappedLineEnd:c,hidden:f,text:y}=n[e],v=e<n.length-1?n[e+1]:null;if(f||(g=y),v&&s>y.length){p+=y.length+(r&&!c?0:1),f||(d+=_);continue}f&&(d-=_);const S=r&&!c&&y.length===s&&v&&!v.hidden;if(f&&(g+=" ",s=g.length),"center"===l)if(S)h=i/2;else{const e=(0,o.measureText)(g,a).width,t=(0,
o.measureText)(g.slice(0,s),a).width,n=i/2;h=u?n+e/2-t:n-e/2+t}else if("right"===l&&!u||"left"===l&&u||"end"===l)if(S)h=i;else{const e=(0,o.measureText)(g.slice(s),a).width;h=u?e:i-e}else if(S)h=0;else{const e=(0,o.measureText)(g.slice(0,s),a).width;h=u?i-e:e}S?(m=e+1,d+=_):m=e;break}return{x:h,y:d,lineNumber:m}}function r(e,t,i){const{lines:n,selectionStart:r,selectionEnd:l,left:c,right:h,color:d,font:u,lineHeight:_,lineSpacing:p=0}=i;e.save();const m=(c+h)/2,g=_+p,f=(0,s.isRtl)();e.fillStyle=d;const{horizontalPixelRatio:y,verticalPixelRatio:v}=t;if(r.lineNumber===l.lineNumber){const t=Math.round(r.x*y),i=Math.round(r.y*v),s=Math.round(l.x*y);e.fillRect(Math.min(t,s),i,Math.abs(t-s),Math.round(g*v))}else{const t=(0,o.measureText)(" ",u).width;let i=0;for(let s=r.lineNumber;s<=l.lineNumber;s+=1){const o=s===r.lineNumber,d=s===l.lineNumber,_=n[s];if(_.hidden)continue;const p=a(_.text,u);let S,b,w=!1;"center"===e.textAlign?(S=o?r.x:f?m+p/2:m-p/2,b=d?l.x:f?m-p/2:m+p/2):"right"===e.textAlign||f&&"start"===e.textAlign||!f&&"end"===e.textAlign?(S=o?r.x:h-p,b=d?l.x:h,w=!0):(S=o?r.x:c,b=d?l.x:c+p);let C=Math.min(S,b),T=Math.max(S,b);d||_.wrappedLinePart&&!_.wrappedLineEnd||(w?C-=t:T+=t);const P=Math.round(C*y),x=Math.round(T*y),M=Math.round((r.y+i*g)*v),I=Math.round((r.y+(i+1)*g)*v);e.fillRect(P,M,x-P,I-M),i+=1}}e.restore()}function a(e,t){return(0,o.measureText)(e,t).width}},11946:(e,t,i)=>{"use strict";i.d(t,{isLineDrawnWithPressedButton:()=>l,isLineToolDrawWithoutPoints:()=>h,isLineToolFinishRequiredWhenCreatedByApi:()=>c,isLineToolName:()=>a,isMtpPredictorToolName:()=>n,isStudyLineToolName:()=>r,isTextToolName:()=>d})
;const s=new Set([]),o=new Set(["LineToolFibRetracement","LineToolFibChannel","LineToolFibSpeedResistanceArcs","LineToolProjection","LineToolTrendBasedFibExtension","LineToolElliott","LineToolFibCircles","LineToolVertLine","LineToolCrossLine","LineToolBarsPattern","LineToolTrendBasedFibTime","LineToolFibTimeZone","LineToolCircleLines","LineToolDateRange","LineToolPriceRange","LineToolDateAndPriceRange","LineToolParallelChannel","LineToolTrendAngle","LineToolTrendLine","LineToolInfoLine","LineToolArrowMark","LineToolPitchfan","LineToolGannSquare","LineToolFibSpeedResistanceFan","LineToolGannComplex","LineToolGannFixed","LineToolGannFan","LineToolFibWedge","LineToolPitchfork","LineToolDisjointAngle","LineToolFlatBottom","LineToolIcon","LineToolEmoji","LineToolSticker","LineToolRotatedRectangle","LineToolFibSpiral","LineToolHeadAndShoulders","LineToolTriangle","LineToolTrianglePattern","LineTool5PointsPattern","LineToolThreeDrivers","LineToolABCD","LineToolPolyline","LineToolPath","LineToolPrediction","LineToolPriceLabel","LineToolPriceNote","LineToolTextNote","LineToolNote","LineToolNoteAbsolute","LineToolArrowMarker","LineToolSignpost","LineToolBrush","LineToolArc","LineToolCallout","LineToolBalloon","LineToolComment","LineToolText","LineToolHorzLine","LineToolHorzRay","LineToolRectangle","LineToolCircle","LineToolEllipse","LineToolTimeCycles","LineToolSineLine","LineToolGhostFeed","LineToolBezierQuadro","LineToolBezierCubic","LineToolArrow","LineToolRay","LineToolExtended","LineToolSchiffPitchfork","LineToolSchiffPitchfork2","LineToolInsidePitchfork","LineToolTextAbsolute","LineToolArrowMarkLeft","LineToolArrowMarkRight","LineToolArrowMarkUp","LineToolArrowMarkDown","LineToolFlagMark","LineToolCypherPattern","LineToolElliottImpulse","LineToolElliottTriangle","LineToolElliottTripleCombo","LineToolElliottCorrection","LineToolElliottDoubleCombo","LineToolRiskRewardLong","LineToolRiskRewardShort","LineToolPosition","LineToolOrder","LineToolHighlighter","LineToolTable","LineToolImage"]);function n(e){return s.has(e)}function r(e){return"LineToolRegressionTrend"===e||"LineToolVbPFixed"===e||"LineToolFixedRangeVolumeProfile"===e||"LineToolAnchoredVolumeProfile"===e||"LineToolAnchoredVWAP"===e}function a(e){return o.has(e)||r(e)}function l(e){return"LineToolBrush"===e||"LineToolHighlighter"===e}function c(e){return l(e)||"LineToolPath"===e||"LineToolPolyline"===e||"LineToolGhostFeed"===e}function h(e){return"LineToolTweet"===e||"LineToolIdea"===e||"LineToolImage"===e}function d(e){switch(e){case"LineToolBalloon":case"LineToolComment":case"LineToolText":case"LineToolTextAbsolute":case"LineToolCallout":case"LineToolNote":case"LineToolNoteAbsolute":case"LineToolSignpost":return!0}return!1}o.add("LineToolExecution")},97217:(e,t,i)=>{"use strict";i.d(t,{isLineTool:()=>o});var s=i(30551);function o(e){return(0,s.isObject)(e)&&"isLineTool"in e&&e.isLineTool}},75550:(e,t,i)=>{"use strict";i.d(t,{LineDataSourcePointIndexProperty:()=>o});var s=i(43337);class o 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)}}},47432:(e,t,i)=>{"use strict";i.d(t,{LineToolPriceAxisView:()=>r});var s=i(50151),o=i(36281),n=i(52859);class r extends o.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 o=this._source.priceScale();if(null===o||o.isEmpty())return;if(!s.selection().isSelected(this._source)&&!this._source.isForcedDrawPriceAxisLabel())return;if(null===s.timeScale().visibleBarsStrictRange())return;const r=this._source.priceAxisPoints(),a=this._data.pointIndex;if(r.length<=a)return;const l=r[a];if(!isFinite(l.price))return;const c=this._source.ownerSource(),h=null!==c?c.firstValue():null;if(null===h)return;let d=this._data.backgroundPropertyGetter?this._data.backgroundPropertyGetter():null;null===d&&(d=this._getBgColor()),i.background=(0,n.resetTransparency)(d),i.borderColor="#2E84A6",i.textColor=this.generateTextColor(i.background),i.coordinate=o.priceToCoordinate(l.price,h),e.text=this._formatPrice(l.price,h),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)}}},79740:(e,t,i)=>{"use strict";i.d(t,{LineDataSourceTimeAxisView:()=>o});var s=i(23752);class o 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}}},41414:(e,t,i)=>{"use strict";i.d(t,{LineDataSource:()=>U,changePointUndoText:()=>z})
;var s=i(89880),o=i(10555),n=i(50151),r=i(87465),a=i(76422),l=i(9343),c=i(37103),h=i(32955),d=i(99955),u=i(48943),_=i(48096),p=i(58043),m=i(22613),g=i(51304),f=i(12178),y=i(81922),v=i(37293),S=i(95059),b=i(36597),w=i(46082),C=i(43337),T=i(78861),P=i(72207),x=i(97719),M=i(40472),I=i(22455),A=i(95804),L=i(75550);class k extends C.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,n.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)}}var E=i(79740),D=i(47432),B=i(65045),V=i(56876),R=i(60973),N=i(76559);const O=(0,l.getLogger)("Chart.LineDataSource"),F=c.enabled("datasource_copypaste");class W{constructor(){this._states=[]}start(e){this._states.push(e)}finish(e){const t=(0,n.ensureDefined)(this._states.pop());return s=t,(i=e).length!==s.length?{indexesChanged:!0,pricesChanged:!0}:i.reduce(((e,t,i)=>{const o=s[i];return e.indexesChanged=e.indexesChanged||t.index!==o.index,e.pricesChanged=e.pricesChanged||t.price!==o.price,e}),{indexesChanged:!1,pricesChanged:!1});var i,s}isEmpty(){return 0===this._states.length}}let H=0;const z=new A.TranslatedString("change point",s.t(null,void 0,i(76660)));class U extends P.DataSource{constructor(e,t,i,s){if(super(s),this.isLineTool=!0,this.version=1,this.toolname="",this.customization={forcePriceAxisLabel:!1,disableErasing:!1,disableSave:!1,showInObjectsTree:!0},this._currentPointsetAndSymbolId=null,this._pointChanged=new _.Delegate,this._pointAdded=new _.Delegate,this._priceAxisViews=[],this._timeAxisViews=[],this._timePoint=[],this._points=[],this._lastPoint=null,this._paneViews=new Map,this._signaturesPaneViews=new Map,this._normalizedPointsChanged=new _.Delegate,this._fixedPointsChanged=new _.Delegate,this._changeStatesStack=new W,this._startMovingPoint=null,this._currentMovingPoint=null,this._isActualSymbol=!1,this._isActualInterval=!1,this._isActualCurrency=!1,this._isActualUnit=!1,this._symbolSource=null,this._symbolSourceSymbolInfo=null,this._sharingMode=new m.WatchedValue(0),this._onTemplateApplying=new _.Delegate,this._onTemplateApplied=new _.Delegate,this._syncStateExclusions=["interval"],this._definitionsViewModel=null,this._hasEditableCoordinates=new m.WatchedValue(!0),this._syncLineStyleMuted=!1,this._onIsActualIntervalChange=new _.Delegate,this._onIsActualSymbolChange=new _.Delegate,this._onPointsetUpdatedDelegate=new _.Delegate,
this._onServerUpdateTime=new _.Delegate,this._linkKey=new m.WatchedValue(null),this._serverUpdateTime=null,this._boundCalcIsActualSymbol=this.calcIsActualSymbol.bind(this),this._alignerCache=null,this._alertUndoMode=!1,this._targetSignature=new m.WatchedValue(null),this._firstSignatureOwnerSource=null,this._sourcesSignatures=null,this._onAlertStatusChanged=()=>{this.updateAllViewsAndRedraw((0,M.sourceChangeEvent)(this.id()))},this._model=e,this._properties=t,this._localAndServerAlertsMismatch=!1,this._properties.hasChild("interval")||this._properties.addChild("interval",new C.Property(e.mainSeries().interval())),this.calcIsActualSymbol(),this._properties.childs().intervalsVisibilities.subscribe(this,this.calcIsActualSymbol),this._properties.subscribe(this,this.propertiesChanged.bind(this,!1,void 0)),this.zOrderChanged().subscribe(this,this.propertiesChanged.bind(this,!0,void 0)),this._createPointsProperties(),this.pointsCount()>0)for(let e=0;e<this.pointsCount();e++)this._priceAxisViews.push(this.createPriceAxisView(e)),this._timeAxisViews.push(new E.LineDataSourceTimeAxisView(this,e));this._properties.childs().visible.subscribe(this,(e=>{const t=!1===(0,T.hideAllDrawings)().value();e.value()?e.value()&&t&&a.emit("drawing_event",this._id.value(),"show"):(this._model.selection().isSelected(this)&&this._model.selectionMacro((e=>{e.removeSourceFromSelection(this)})),t&&a.emit("drawing_event",this._id.value(),"hide")),this._onSourceHiddenMayChange()})),(0,T.hideAllDrawings)().subscribe(this,this._onSourceHiddenMayChange),this._sessionConnected=this._model.chartApi().isConnected().spawn(),this._sessionConnected.subscribe((e=>{e||(this._currentPointsetAndSymbolId=null)})),this._alertStatus.subscribe(this._onAlertStatusChanged),this._definitionsViewModel=null,this._properties.setNameInOwner((0,N.propertyPathForSource)(this)),this._sourcesSignatures=e.sourcesSignatures().spawn(),this._sourcesSignatures.subscribe(this._updateSignaturesPaneViews.bind(this)),this._targetSignature.subscribe(this._updateSignaturesPaneViews.bind(this))}destroy(){this._paneViews.forEach(((e,t)=>this._destroyPanePaneViews(t))),this.stop(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),null!==this._ownerSource&&(this._ownerSource.currencyChanged().unsubscribeAll(this),this._ownerSource.unitChanged().unsubscribeAll(this),(0,I.isSymbolSource)(this._ownerSource)&&(this._ownerSource.symbolResolved().unsubscribeAll(this),this._ownerSource.isActingAsSymbolSource().unsubscribe(this._boundCalcIsActualSymbol))),this.ownerSourceChanged().unsubscribeAll(this),this._symbolSource?.destroy(),this._symbolSourceSymbolInfo?.destroy(),(0,T.hideAllDrawings)().unsubscribeAll(this),this._sessionConnected.destroy(),this._alertStatus.unsubscribe(this._onAlertStatusChanged),this._properties.destroy(),this._sourcesSignatures?.destroy(),this._firstSignatureOwnerSource?.destroy(),super.destroy()}setId(e){super.setId(e),this._properties.setNameInOwner((0,N.propertyPathForSource)(this))}priceScale(){
return this._ownerSource?this._ownerSource.priceScale():null}createPriceAxisView(e){return new D.LineToolPriceAxisView(this,{pointIndex:e})}model(){return this._model}symbol(){return this._properties.childs().symbol.value()}linkKey(){return this._linkKey}serverUpdateTime(){return this._serverUpdateTime}setServerUpdateTime(e){this._serverUpdateTime=e,this._onServerUpdateTime.fire()}serverUpdateTimeChanged(){return this._onServerUpdateTime}adjustedToSplitTime(){return null}adjustToSplit(e,t){}boundToSymbol(){return!0}isAvailableInFloatingWidget(){return!0}points(){const e=[];for(let t=0;t<this._points.length;t++){const i=this._points[t];e.push({index:i.index,price:i.price,time:i.time})}return this._lastPoint&&e.push(this._correctLastPoint(this._lastPoint)),!this.isFixed()&&this._currentMovingPoint&&this._startMovingPoint&&this._correctPoints(e),e}timeAxisPoints(){return this.points()}priceAxisPoints(){return this.points()}fixedPoint(e){if(!this.isFixed())return;let t;const i=e?e.priceScale():this.priceScale();if(this._positionPercents&&null!==i&&!i.isEmpty()){const e=this._positionPercents,s=this._model.timeScale().width()*e.x,n=i.height()*e.y;t=new o.Point(s,n)}else void 0!==this._fixedPoint&&(t=this._fixedPoint?.clone());if(this._currentMovingPoint&&this._startMovingPoint&&void 0!==t){const e=this._correctFixedPoint(t);e.didCorrect&&(t=e.point)}return t}positionPercents(){return this.isFixed()?this._positionPercents:void 0}clearFixedPoint(){this._fixedPoint=void 0,this._positionPercents=void 0}normalizedPoints(){return this._timePoint}normalizedPointsForCreating(){return this.normalizedPoints()}normalizedPointsChanged(){return this._normalizedPointsChanged}fixedPointChanged(){return this._fixedPointsChanged}geometry(){const e=(0,n.ensureNotNull)(this.priceScale());return this.points().map((t=>{const i=(0,n.ensureNotNull)(this.pointToScreenPoint(t)),s=i.x/this._model.timeScale().width(),r=i.y/e.height();return new o.Point(s,r)}))}widthsProperty(){return this._properties.childs().linesWidths??null}lineColorsProperty(){return this._properties.childs().linesColors??null}backgroundColorsProperty(){return this._properties.childs().backgroundsColors??null}textColorsProperty(){return this._properties.childs().textsColors??null}pointsProperty(){return this._pointsProperty}hasEditableCoordinates(){return this._hasEditableCoordinates}startMoving(e,t,i,s){this.isFixed()&&this.restoreFixedPoint(),this._startMovingPoint=e}move(e,t,i,s){if(i&&(i.shiftOnly()||i.modShift()))if(this.isFixed()){const t=this._alignScreenPointHorizontallyOrVertically((0,n.ensureDefined)(e.screen));this._currentMovingPoint={screen:t}}else{const t=this._alignPointHorizontallyOrVertically((0,n.ensureDefined)(e.logical)),i=(0,n.ensureNotNull)(this.pointToScreenPoint(t));this._currentMovingPoint={logical:t,screen:i}}else this._currentMovingPoint=e;this.updateAllViews((0,M.sourceChangeEvent)(this.id()))}endMoving(e,t,i){let s=!1,o=!1;if(this._currentMovingPoint&&this._startMovingPoint){if(this.isFixed()){const e=this._correctFixedPoint((0,
n.ensureDefined)(this._fixedPoint));e.didCorrect&&(this._fixedPoint=e.point,this._fixedPointsChanged.fire())}else{const e=(0,n.ensureDefined)(this._currentMovingPoint.logical),t=(0,n.ensureDefined)(this._startMovingPoint.logical);s=e.index!==t.index,o=e.price!==t.price;if(this._correctPoints(this._points,i)){const e=this._id.value();a.emit("drawing_event",e,"move"),a.emit("drawing_event",e,"points_changed"),this._updateAdjustedToSplitTimeValue();for(let e=0;e<this._points.length;e++)this._pointChanged.fire(e)}}this._startMovingPoint=null,this._currentMovingPoint=null}const r={indexesChanged:s,pricesChanged:o};return this.isFixed()?(this.calcPositionPercents(),this.updateAllViews((0,M.sourceChangeEvent)(this.id())),r):(s&&this._points.forEach((e=>e.interval=this._model.mainSeries().interval())),this.updateAllViews((0,M.sourceChangeEvent)(this.id())),s&&!e?(this._properties.childs().interval.setValue(this._model.mainSeries().interval()),this._normalizePoints(),this.createServerPoints()):(this._copyPricesWithoutNormalization(),this._normalizedPointsChanged.fire()),r)}startMovingPoint(){return this._startMovingPoint?{...this._startMovingPoint}:null}currentMovingPoint(){return this._currentMovingPoint?{...this._currentMovingPoint}:null}changePointUndoText(e){return z}startChanging(e,t){this.isFixed()&&this.restoreFixedPoint(),void 0!==e&&void 0!==t&&(e<this._priceAxisViews.length&&this._priceAxisViews[e].setActive(!0),e<this._timeAxisViews.length&&this._timeAxisViews[e].setActive(!0)),this._changeStatesStack.start(this.points())}endChanging(e,t,i){const s=this._changeStatesStack.finish(this.points());s.indexesChanged&&this._changeStatesStack.isEmpty()?(this._normalizePoints(),t||this.createServerPoints()):(this._copyPricesWithoutNormalization(),this._normalizedPointsChanged.fire()),a.emit("drawing_event",this._id.value(),"points_changed"),this._updateAdjustedToSplitTimeValue();for(let e=0;e<this._priceAxisViews.length;e++)this._priceAxisViews[e].setActive(!1);for(let e=0;e<this._timeAxisViews.length;e++)this._timeAxisViews[e].setActive(!1);return s}setPoint(e,t,i,s){if(this._snapTo45DegreesApplicable(i)){const i=0===e?1:e-1;this.snapPoint45Degree(t,this.points()[i])}this._setPoint(e,{...t,interval:this._model.mainSeries().interval()})}getPoint(e){return this.points()[e]||null}alignCrossHairToAnchor(e){return!0}alignCrossHairToMovePoint(){return!1}setLastPoint(e,t,i=!0){return this._lastPoint=i?this._preparePoint(e,t):e,this.updateAllViews((0,M.sourceChangeEvent)(this.id())),this._lastPoint}lastPoint(){return this._lastPoint}getChangePointForSync(e){return this.getPoint(e)}setPoints(e){const t=this._model.mainSeries().interval();this._points=e.map((e=>({...e,interval:e.interval??t})))}isForcedDrawPriceAxisLabel(){return this.customization.forcePriceAxisLabel}clearData(){this._points=[]}denormalizeTimePoints(){let e=[];const t=this._model.mainSeries().interval();for(let i=0;i<this._timePoint.length;i++){const s=this._model.timeScale().denormalizeTimePoint(this._timePoint[i]);if(void 0===s){e=[];break}e.push({index:s,
price:this._timePoint[i].price,interval:this._timePoint[i].interval??t})}e.length>0&&(this._points=e)}restorePoints(e,t,i){const s=this._timePoint.length>0&&!(0,r.deepEquals)(this._timePoint,e)[0],o=this._properties.childs().interval.value();this._timePoint=e.map((e=>({...e,interval:e.interval??o})));const n=this._model.mainSeries().interval();this._points=t.map((e=>({...e,interval:n}))),i||this.denormalizeTimePoints(),s&&this._normalizedPointsChanged.fire()}restorePositionPercents(e){this._positionPercents=e,this.restoreFixedPoint()}calcIsActualSymbol(){const e=this.ownerSource(),t=this._isActualSymbol;if(null===e)this._isActualSymbol=!1;else{const e=this._symbolSource?.value(),t=this._symbolSourceSymbolInfo?.value();if(t&&e){this._migrateSymbolProperty(t);const i=this._properties.childs().symbol,s=i.value();if(this._isActualSymbol=e.symbolSameAsCurrent(s),this._isActualSymbol){const o=(0,S.extractLineToolSymbolFromSymbolInfo)(t,e.symbol());(0,b.areEqualSymbols)(s,o)||(O.logWarn('Possible drawing "migrating" detected from "'+s+'" to "'+o+'"'),O.logWarn("Series symbolInfo: "+JSON.stringify(e.symbolInfo())),O.logWarn(`${(new Error).stack}`)),i.setValue(o)}}}this._isActualSymbol!==t&&this._onIsActualSymbolChange.fire(),this.calcIsActualInterval(),this.calcIsActualCurrency(),this.calcIsActualUnit(),this._onSourceHiddenMayChange()}calcIsActualCurrency(){const e=this.ownerSource();if(null===e)return void(this._isActualCurrency=!1);let t=this._properties.childs().currencyId.value();if(null!==t){const i=e.symbolSource();0,this._isActualCurrency=t===(0,S.symbolCurrency)(i.symbolInfo(),void 0,!0)}else{const t=(0,n.ensureNotNull)(e.symbolSource());this._isActualCurrency=null!==t.symbolInfo()&&!t.isConvertedToOtherCurrency()}this._onSourceHiddenMayChange()}calcIsActualUnit(){const e=this.ownerSource();if(null===e)return void(this._isActualUnit=!1);const t=this._properties.childs().unitId.value();if(null!==t)this._isActualUnit=t===(0,n.ensureNotNull)(e.symbolSource()).unit();else{const t=(0,n.ensureNotNull)(e.symbolSource());this._isActualUnit=null!==t.symbolInfo()&&!t.isConvertedToOtherUnit()}this._onSourceHiddenMayChange()}calcIsActualInterval(){const e=this._isActualInterval,t=this._properties,i=this._model.mainSeries();this._isActualInterval=(0,y.isActualInterval)(w.Interval.parse(i.interval()),t.childs().intervalsVisibilities),!this._isActualInterval&&this._model.selection().isSelected(this)&&this._model.selectionMacro((e=>e.removeSourceFromSelection(this))),this._isActualInterval!==e&&this._onIsActualIntervalChange.fire(),this._onSourceHiddenMayChange()}paneViews(e){if(this.isSourceHidden())return null;const t=this._getPaneViews(this.isMultiPaneAvailable()?e:void 0);if(null===t)return null;if(1===t.length)return[t[0]];const i=[];for(let e=t.length-1;e>=0;--e)i.push(t[e]);return i}priceAxisViews(e,t){if(this.isFixed())return null;if(t!==this.priceScale()||this.isSourceHidden())return null;if(this._model.lineBeingEdited()===this){const e=this._model.linePointBeingEdited();if(null!==e&&e<this._priceAxisViews.length){
const t=this._priceAxisViews.slice(),i=t[e];return t.splice(e,1),t.push(i),t}return this._priceAxisViews}return this._priceAxisViews}timeAxisViews(){if(this.isSourceHidden()||this.isFixed())return null;if(this._model.lineBeingEdited()===this){const e=this._model.linePointBeingEdited();if(null!==e&&e<this._timeAxisViews.length){const t=this._timeAxisViews.slice(),i=t[e];return t.splice(e,1),t.push(i),t}return this._timeAxisViews}return this._timeAxisViews}isSavedInChart(){return!this.customization.disableSave}isSavedInStudyTemplates(){return!1}setSavingInChartEnabled(e){this.customization.disableSave=!e}shouldBeRemovedOnDeselect(){return!1}getOrderTemplate(){return null}getSourceIcon(){return{type:"loadSvg",svgId:"linetool."+this.toolname}}alertId(){return this._alertId}async waitSettingAlertId(){this._pendingAlertIdPromise&&(this._alertId=await this._pendingAlertIdPromise)}async setAlert(e,t={}){throw new Error("not implemented")}async restoreAlert(e,t){throw new Error("not implemented")}editAlert(e){}async getAlert(){try{const e=await this._getChartAlert();if(!e)throw O.logError("Failed to get alert, alert will not be saved with drawing in chart"),new Error("got_no_alert");return e}catch(e){if(e instanceof Error&&"not implemented"===e.message)throw e;if("not_exists"===e)throw new Error(e);return O.logError(`Getting alert failed: ${e instanceof Error?e.message:e}`),null}}getAlertSync(){return null}async synchronizeAlert(e=!1){}syncAlert(e){0}stateForAlert(){return null}async stateForAlertAsync(){return null}getAlertIsActive(){return!1}detachAlert(){}removeAlert(){}deleteAlert(){}areLocalAndServerAlertsMismatch(){return!1}showInObjectTree(){return this.customization.showInObjectsTree}setShowInObjectsTreeEnabled(e){this.customization.showInObjectsTree=e}start(){this.createServerPoints()}processHibernate(){this.canBeHibernated()?this.isStarted()&&this.stop():this.isStarted()||this.start()}canBeHibernated(){return this.isSourceHidden()}onData(e){"pointset_error"!==e.method?e.params.customId===this._currentPointsetIdWithPrefix()&&this._onPointsetUpdated(e.params.plots):O.logError(`Error getting pointset: ${e.params[0]} ${e.params[1]}`)}isBeingEdited(){return this===this._model.lineBeingEdited()}isActualSymbol(){return this._isActualSymbol}isActualCurrency(){return this._isActualCurrency}isActualInterval(){return this._isActualInterval}isActualUnit(){return this._isActualUnit}onIsActualIntervalChange(){return this._onIsActualIntervalChange}onIsActualSymbolChange(){return this._onIsActualSymbolChange}setOwnerSource(e){if(null!==this._ownerSource&&(this._ownerSource.currencyChanged().unsubscribeAll(this),this._ownerSource.unitChanged().unsubscribeAll(this),this._symbolSource?.destroy(),this._symbolSource=null,this._symbolSourceSymbolInfo?.destroy(),this._symbolSourceSymbolInfo=null),super.setOwnerSource(e),e){this._symbolSource=e.symbolSourceWV().spawn();const t=(0,u.combine)((e=>[e.symbolInfoWV().weakReference()]),this._symbolSource.weakReference());this._symbolSourceSymbolInfo=(0,
u.accumulate)((e=>e[0]??null),t.ownership()),this._symbolSourceSymbolInfo.subscribe(this._boundCalcIsActualSymbol),this.setPriceScale(e.priceScale()),e.currencyChanged().subscribe(this,this.calcIsActualCurrency),e.unitChanged().subscribe(this,this.calcIsActualUnit),this.calcIsActualSymbol(),this._migrateZOrder(),this._updateAlertCreationAvailable()}(0,I.isSymbolSource)(e)&&(e.symbolResolved().subscribe(this,this._boundCalcIsActualSymbol),e.isActingAsSymbolSource().subscribe(this._boundCalcIsActualSymbol))}dataAndViewsReady(){return this._paneViews.size>0}pointAdded(){return this._pointAdded}pointChanged(){return this._pointChanged}pointsetUpdated(){return this._onPointsetUpdatedDelegate}pointToScreenPoint(e,t){const i=this._model.timeScale(),s=t?t.priceScale():this.priceScale(),n=(t??this.ownerSource())?.firstValue();if(!s||s.isEmpty()||i.isEmpty()||null==n)return null;const r=i.indexToCoordinate(e.index),a=s.priceToCoordinate(e.price,n);return new o.Point(r,a)}screenPointToPoint(e,t,i){const s=i?i.priceScale():this.priceScale(),o=(i??this.ownerSource())?.firstValue();if(null==o||!isFinite(o)||null===s)return null;const n=this._model.timeScale(),r=t?n.coordinateToFloatIndex(e.x):n.coordinateToIndex(e.x);return{price:s.coordinateToPrice(e.y,o),index:r}}calcMiddlePoint(e,t){return new o.Point((e.x+t.x)/2,(e.y+t.y)/2)}addPoint(e,t,i){const s=this._preparePoint(e,t);return this._addPointIntenal(s,t,i)}addFixedPoint(e){return this._fixedPoint=e,this.calcPositionPercents(),!0}calcPositionPercents(){const e=this.priceScale();if(!e||e.isEmpty()||void 0===this._fixedPoint)return;const t=this._fixedPoint.x/this._model.timeScale().width(),i=this._fixedPoint.y/e.height();return this._positionPercents={x:t,y:i},this._positionPercents}restoreFixedPoint(){this._fixedPoint=this.fixedPoint()}propertiesChanged(e,t){this.calcIsActualInterval(),this.updateAllViewsAndRedraw((0,M.sourceChangeEvent)(this.id())),t||this._syncLineStyleIfNeeded(e),e||void 0!==this._pendingPropertyChangedEvent||(this._pendingPropertyChangedEvent=setTimeout((()=>{this._pendingPropertyChangedEvent=void 0,a.emit("drawing_event",this._id.value(),"properties_changed")}),0))}state(e){const t=this.toolname,i=this.ownerSource(),s={type:t,id:this.id(),state:this.properties().state(this._propertiesStateExclusions()),points:(0,p.deepCopy)(this._timePoint),zorder:this.zorder(),ownerSource:i?.id()};this._targetSignature.value();return s.isSelectionEnabled=this.isSelectionEnabled(),s.userEditEnabled=this.userEditEnabled(),this.linkKey().value()&&(s.linkKey=this.linkKey().value()),delete s.state.points,e&&(s.indexes=this._points),this.isFixed()&&(s.positionPercents=this._positionPercents||this.calcPositionPercents()),"version"in this&&1!==this.version&&(s.version=this.version),s}updateAllViews(e){this.isSourceHidden()||"data-source-change"===e.type&&this._ignoreSourceEvent(e)||(this._updateAllPaneViews(e),this._priceAxisViews.forEach((t=>t.update(e))),this._timeAxisViews.forEach((t=>t.update(e))))}updateAllViewsAndRedraw(e){this.updateAllViews(e),
this._model.updateSource(this)}tags(){return[this.toolname]}properties(){return this._properties}restoreExternalPoints(e,t){try{if(this._timePoint=(0,p.deepCopy)(e.points),t.indexesChanged){if(this.properties().childs().interval.setValue(e.interval),!this.isActualSymbol())return void this._clearServerPoints();this.createServerPoints()}else{const t=Math.min(this._points.length,e.points.length);for(let i=0;i<t;i++)this._points[i].price=e.points[i].price}this.updateAllViewsAndRedraw((0,M.sourceChangeEvent)(this.id()))}finally{this._normalizedPointsChanged.fire()}}restoreExternalState(e){this.properties().mergeAndFire(e)}applyTemplate(e){this._onTemplateApplying.fire(e),this._applyTemplateImpl(e),this.calcIsActualSymbol(),this.updateAllViews((0,M.sourceChangeEvent)(this.id())),this.model().lightUpdate(),this._onTemplateApplied.fire()}template(){return this.properties().preferences()}isFixed(){return!1}anchorable(){return!1}isLocked(){const e=this.properties().child("frozen");return void 0!==e&&e.value()}isSourceHidden(){return!this._properties.childs().visible.value()||(0,T.hideAllDrawings)().value()&&this.canBeHidden()||!this._isActualInterval||!this._isActualSymbol||!this._isActualCurrency||!this._isActualUnit}isSynchronizable(){return this.priceScale()===this._model.mainSeries().priceScale()}copiable(){return F}cloneable(){return null!==this._ownerSource&&null!==this._ownerSource.firstValue()}movable(){return!0}allowsMovingBetweenPanes(){return!1}async getPropertyDefinitionsViewModel(){if(null===this._definitionsViewModel){const e=await this._getPropertyDefinitionsViewModelClass();return null===e||this._isDestroyed?null:(this._definitionsViewModel=new e(this._model.undoModel(),this),this._definitionsViewModel)}return this._definitionsViewModel}title(){return this.translatedType()}translatedType(){return V.lineToolsLocalizedNames[this.toolname]??"Line Tool"}name(){return"Line Tool"}createServerPoints(){if(!this._isActualSymbol)return;if(!this._model.chartApi().isConnected().value())return;if(this._clearServerPoints(),this._model.timeScale().isEmpty())return;if(0===this._timePoint.length&&this._points.length>0&&this._normalizePoints(),!this._readyToCreatePointset())return;const e=this._pointsForPointset();if(0===e.length)return;++H,this._currentPointsetAndSymbolId={pointsetId:H,symbolId:(0,n.ensureNotNull)(this._model.mainSeries().seriesSource().symbolInstanceId())};const t=(0,f.getServerInterval)(this.properties().childs().interval.value());this._model.chartApi().createPointset(this._currentPointsetIdWithPrefix(),"turnaround",this._currentPointsetAndSymbolId.symbolId,t,e,this.onData.bind(this))}finish(){}realign(){this.calcIsActualSymbol(),this.isFixed()||this.isSourceHidden()||this._model.lineBeingCreated()===this||this._model.lineBeingEdited()===this||this._currentPointsetAndSymbolId?.symbolId===this._model.mainSeries().seriesSource().symbolInstanceId()||this._clearServerPoints(),null===this._model.mainSeries().symbolInfo()&&(this._alignerCache=null),this.updateAllViews((0,M.sourceChangeEvent)(this.id()))}stop(){
this._clearServerPoints()}restart(){this.isFixed()||(this._currentPointsetAndSymbolId=null,this.createServerPoints())}isStarted(){return null!==this._currentPointsetAndSymbolId}convertYCoordinateToPriceForMoving(e,t){const i=(0,n.ensureNotNull)(this.priceScale());if(i.isEmpty())return null;const s=this.ownerSource(),o=(0,n.ensure)((s||t)?.firstValue());return i.coordinateToPrice(e,o)}syncMultichartState(e){const t={points:this._timePoint,pointPositionPercents:this.positionPercents(),interval:this._model.mainSeries().interval()},i=this.linkKey().value();if(null!==i&&this.isSynchronizable()){const s={model:this._model,linkKey:i,symbol:this._model.mainSeries().symbol(),finalState:t,changes:e};(0,T.finishChangingLineTool)(s)}}enableCurrentIntervalVisibility(){let e=this.properties().childs().intervalsVisibilities.state();void 0!==e&&(e=(0,y.mergeIntervalVisibilitiesDefaults)(e),(0,y.makeIntervalsVisibilitiesVisibleAtInterval)(e,this._model.mainSeries().intervalObj().value()),this.properties().childs().intervalsVisibilities.mergeAndFire(e))}clonePositionOffset(){return this.isFixed()?{barOffset:0,xCoordOffset:20,yCoordOffset:20}:{barOffset:0,xCoordOffset:0,yCoordOffset:-40}}sharingMode(){return this._sharingMode}share(e){this.isSynchronizable()&&this._sharingMode.setValue(e)}syncLineStyleState(e){if(e)return{zOrder:this.zorder()};const{intervalsVisibilities:t,...i}=this.properties().state(this._syncStateExclusions);return{...i,intervalsVisibilities:(0,y.mergeIntervalVisibilitiesDefaults)(t),zOrder:this.zorder()}}moveLineTool(e){const t=this._model.mainSeries().interval();e.forEach(((e,i)=>this._setPoint(i,{...e,interval:t}))),this._normalizePoints()}targetSignature(){return this._targetSignature.readonly()}setTargetSignature(e){(0,n.assert)(this.supportsTargetSignature()),this._targetSignature.setValue(e)}supportsTargetSignature(){return!1}snapTo45DegreesAvailable(){return!1}alignTo45DegreesPoints(){if(this.snapTo45DegreesAvailable()){const[e,t]=this.points();if(e&&t)return[{...e,pointIndex:0},{...t,pointIndex:1}]}return null}snapPoint45Degree(e,t,i){const s=this._model.timeScale(),o=s.indexToCoordinate(t.index),r=s.indexToCoordinate(e.index)-o,a=(0,n.ensureNotNull)(this.priceScale()),l=t.price,c=e.price,h=(0,n.ensureNotNull)((0,n.ensureNotNull)(this.ownerSource()).firstValue()),d=a.priceToCoordinate(l,h),u=a.priceToCoordinate(c,h)-d,_=Math.round(Math.atan2(r,u)/Math.PI*4);if(2===Math.abs(_))i||(e.price=l);else if(0===Math.abs(_)||4===Math.abs(_))i||(e.index=t.index);else{const t=Math.sqrt(r*r+u*u),i=r<0?-1:1,n=u<0?-1:1;let l=Math.max(Math.abs(u),Math.abs(r));l/=l*Math.sqrt(2)/t;const c=Math.round(s.coordinateToIndex(o+l*i)),_=Math.abs(s.indexToCoordinate(c)-o),p=a.coordinateToPrice(d+_*n,h);e.index=c,e.price=p}}contextMenuStatName(){return"LineToolContextMenu"}_ignoreSourceEvent(e){return e.sourceId!==this.id()}_pointsForPointset(){return this._timePoint.map((({interval:e,time_t:t,offset:i})=>e?[t,i,(0,f.getServerInterval)(e)]:[t,i]))}_setPoint(e,t){
this._points[e]&&(this._points[e].index===t.index?this._points[e].price=t.price:this._points[e]=t,this._pointChanged.fire(e))}_correctLastPoint(e){return(0,r.clone)(e)}_snapTo45DegreesApplicable(e){return this.snapTo45DegreesAvailable()&&(e?.shift()||(0,T.alignTo45Degrees)().value())}_normalizePoint(e,t){return{...this._model.timeScale().normalizeBarIndex(e.index),price:e.price,interval:e.interval}}_normalizePointWithoutOffset(e){const t=this._model.timeScale().indexToTimePoint(e.index)??this._utcTimeInCurrentResolution(e);return null===t?null:{price:e.price,time_t:t,offset:0,interval:e.interval}}_normalizePoints(){let e=[];const t=this._model.mainSeries().interval();for(let i=0;i<this._points.length;i++)if(w.Interval.isEqual(this._points[i].interval,t)){if(void 0!==this._points[i].index){const t=this._normalizePoint(this._points[i],i);if(!t.time_t){e=[];break}e.push(t)}}else e.push({...this._timePoint[i],price:this._points[i].price});this._timePoint=e,this._normalizedPointsChanged.fire()}_getStartBarAligner(){const e=this._model.mainSeries().interval();if(null===this._alignerCache||this._alignerCache.resolution!==this._model.mainSeries().interval()){const t=this._model.mainSeries().symbolInfo();if(!t)return null;this._alignerCache={resolution:e,aligner:(0,h.createTimeToBarTimeAligner)(e,t)}}return this._alignerCache.aligner}_utcTimeInCurrentResolution(e){const t=this._model.timeScale().points(),i=t.firstPoint(),s=t.lastPoint(),o=this._model.mainSeries().syncModel();if(null===i||null===s||null===o)return null;const r=(0,n.ensureNotNull)(t.indexOf(i,!1)),a=(0,n.ensureNotNull)(t.indexOf(s,!1));if(e.index>=r&&e.index<=a)return null;const l=e.index<r?r:a,c=(0,n.ensureNotNull)(t.valueAt(l)),h=e.index-l;return(0,d.extrapolateBarsFrontByCount)(o.barBuilder(),1e3*c,h).time/1e3}_setPaneViews(e,t,i){if(this._isDestroyed)for(const t of e)t.destroy&&t.destroy();else this._paneViews.set(t,e),void 0!==t&&i&&t.onDestroyed().subscribe(this,(()=>this._destroyPanePaneViews(t))),this._model.lightUpdate()}_getPaneViews(e){return this._paneViews.get(e)??[]}_updateAllPaneViews(e){this._paneViews.forEach((t=>{for(const i of t)i.update(e)}));for(const[,t]of this._signaturesPaneViews)for(const i of t)i.update(e)}_alignPointHorizontallyOrVertically(e){const t=(0,n.ensureNotNull)(this.pointToScreenPoint(e)),i=(0,n.ensureDefined)((0,n.ensureNotNull)(this._startMovingPoint).logical),s=(0,n.ensureDefined)((0,n.ensureNotNull)(this._startMovingPoint).screen),o=Math.abs(s.x-t.x),r=Math.abs(s.y-t.y);if(o<10&&r<10)return e;return{index:o<r?i.index:e.index,price:o<r?e.price:i.price}}_alignScreenPointHorizontallyOrVertically(e){const t=(0,n.ensureDefined)((0,n.ensureNotNull)(this._startMovingPoint).screen),i=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);return i<10&&s<10?e:i<s?new o.Point(t.x,e.y):new o.Point(e.x,t.y)}_correctPoints(e,t){const i=(0,n.ensure)(this._currentMovingPoint?.screen),s=(0,n.ensure)(this._startMovingPoint?.screen),o=i.subtract(s);if(o.length()<1&&!t)return!1;const r=Math.round((0,n.ensure)(this._currentMovingPoint?.logical).index-(0,
n.ensure)(this._startMovingPoint?.logical).index);for(const t of e){const e=(0,n.ensureNotNull)(this.pointToScreenPoint(t)).add(o);t.index=t.index+r,t.price=(0,n.ensureNotNull)(this.screenPointToPoint(e)).price}return!0}_correctFixedPoint(e){if(void 0===this._fixedPoint)return{didCorrect:!1,point:e};const t=(0,n.ensureDefined)((0,n.ensureNotNull)(this._currentMovingPoint).screen),i=(0,n.ensureDefined)((0,n.ensureNotNull)(this._startMovingPoint).screen),s=t.subtract(i);return s.length()>=1?{didCorrect:!0,point:e.add(s)}:{didCorrect:!1,point:e}}_currentPointsetIdWithPrefix(){return"pointset_"+(0,n.ensureNotNull)(this._currentPointsetAndSymbolId).pointsetId}_clearServerPoints(){null!==this._currentPointsetAndSymbolId&&this._model.chartApi().isConnected().value()&&this._model.chartApi().removePointset(this._currentPointsetIdWithPrefix()),this._currentPointsetAndSymbolId=null}_createPointProperty(e){const t=this._pointsProperty.childs().points;t.addChild(""+e,new C.Property({}));const i=t[e];i.addChild("price",new k(this,e)),i.addChild("bar",new L.LineDataSourcePointIndexProperty(this,e))}_createPointsProperties(){this._pointsProperty=new C.Property,this._pointsProperty.addChild("points",new C.Property);for(let e=0;e<this.pointsCount();e++)this._createPointProperty(e)}_alignPointToRangeOfActualData(e){const t=(0,n.ensureNotNull)(this._model.mainSeries().bars().firstIndex()),i=(0,n.ensureNotNull)(this._model.mainSeries().bars().lastIndex());let s=Math.max(e.index,t);return s=Math.min(s,i),{...e,index:s}}_migrateSymbolProperty(e){const t=this._properties.childs();if(t.symbolStateVersion.value()<2){const i=(0,n.ensureNotNull)(this.ownerSource()),s=(0,n.ensureNotNull)(i.symbolSource()),o=this._model.mainSeries();if(s===o)return void t.symbolStateVersion.setValueSilently(2);if(null===o.symbolInfo())return;if(null===s.symbolInfo())return;o.symbolSameAsCurrent(t.symbol.value())&&t.symbol.setValueSilently((0,S.extractLineToolSymbolFromSymbolInfo)(e,s.symbol())),t.symbolStateVersion.setValueSilently(2)}}_migrateZOrder(){const e=this._properties.childs();e.zOrderVersion.value()<2&&(this.ownerSource()===this.model().mainSeries()&&this.setZorder(this.zorder()-this.model().mainSeries().obsoleteZOrder()),e.zOrderVersion.setValueSilently(2))}_preparePoint(e,t){const i=e;return this._snapTo45DegreesApplicable(t)&&this.points().length>=2&&this.snapPoint45Degree(i,this.points()[this.points().length-2]),i}_addPointIntenal(e,t,i){this._points.push({...e,interval:this._model.mainSeries().interval()});const s=this._points.length===this.pointsCount();return s?(this._lastPoint=null,i||(this._normalizePoints(),this.createServerPoints())):this._lastPoint=e,this._pointAdded.fire(this._points.length-1),s}_onSourceHiddenMayChange(){this.isSourceHidden()&&this._model.selectionMacro((e=>{e.removeSourceFromSelection(this)})),this._model.invalidate(g.InvalidationMask.validateAction((()=>{this!==this._model.lineBeingCreated()&&(this._isDestroyed||this.processHibernate())})))}_saveAlertIdInState(){return!0}_onPointsetUpdated(e){if(0===e.length)return
;const t=this.properties().childs().interval.value();for(const{index:i,value:s}of e){const{price:e,interval:o=t}=(0,n.ensureDefined)(this._timePoint[i]),[r,a]=s,l={index:r,time:a,price:e,interval:o};if(this._points.length<=i){const e=this._points.push(l);this._pointAdded.fire(e-1)}else this._points[i]=l,this._pointChanged.fire(i)}this._onPointsetUpdatedDelegate.fire(),this.updateAllViewsAndRedraw((0,M.sourceChangeEvent)(this.id()))}_onMainSeriesSymbolResolved(){const e=this.ownerSource();null===e||this._model.mainSeries()===e.symbolSource()||this.isSourceHidden()||this.createServerPoints()}_readyToCreatePointset(){return this._timePoint.length>0}_propertiesStateExclusions(){return[]}_syncLineStyleIfNeeded(e){const t=this.linkKey().value();t&&!this._syncLineStyleMuted&&this._syncLineStyleChanges(t,this.syncLineStyleState(e))}_muteSyncLineStyle(){this._syncLineStyleMuted=!0}_unmuteSyncLineStyleWithoutApplyingChanges(){this.propertiesChanged(),this._syncLineStyleMuted=!1}_applyTemplateImpl(e){e.intervalsVisibilities=(0,y.mergeIntervalVisibilitiesDefaults)(e.intervalsVisibilities);const t=this.properties();t.applyTemplate(e,(0,R.factoryDefaults)(this.toolname.toLowerCase())),t.saveDefaults(),this.propertiesChanged()}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_getAlertPlots(){return[]}_getUndoHistory(){return this._model.undoModel().undoHistory()}async _synchronizeAlert(e){}_linePointsToAlertPlot(e,t,i,s){return null}_getAlertCreationAvailable(){return!1}_onAnchoredChange(){if(this.isFixed()){const e=(0,n.ensureNotNull)(this.pointToScreenPoint(this.points()[0]));this.addFixedPoint(e)}else{if(!this._fixedPoint)return;const e=(0,n.ensureNotNull)(this.screenPointToPoint(this._fixedPoint));this._points[0]={...e,interval:this._model.mainSeries().interval()},this.startChanging(),this.setPoint(0,e),this.endChanging(!1,!1),this._timePoint[0]=this._normalizePoint(this._points[0],0),this.clearFixedPoint()}const e=this.linkKey().value();null!==e&&this.isSynchronizable()&&(0,T.restoreLineToolState)({model:this._model,linkKey:e,state:this.state()})}_syncLineStyleChanges(e,t,i){this.anchorable()&&this.isFixed()!==Boolean(this._positionPercents)&&this._onAnchoredChange(),(0,T.changeLineStyle)({linkKey:e,state:t,alertId:i,model:this._model})}_updateAdjustedToSplitTimeValue(e){}_createSignatureSourcePaneViews(e){return[]}_updateSignaturesPaneViews(){const e=this.targetSignature().value();if(null!==e||0!==this._signaturesPaneViews.size){for(const[t,i]of this._signaturesPaneViews)t.signature().value()!==e&&(i.forEach((e=>e.destroy?.())),this._signaturesPaneViews.delete(t));for(const t of this._model.studiesWV(!0).value())t.signature().value()!==e||this._signaturesPaneViews.has(t)||this._signaturesPaneViews.set(t,this._createSignatureSourcePaneViews(t))}}static _configureProperties(e){if(this._addCollectedProperties(e),e.hasChild("symbolStateVersion")||e.addProperty("symbolStateVersion",1),e.hasChild("zOrderVersion")||e.addProperty("zOrderVersion",1),e.hasChild("visible")||e.addProperty("visible",!0),
e.hasChild("frozen")||e.addProperty("frozen",!1),e.hasChild("symbol")||e.addProperty("symbol",""),e.hasChild("currencyId")||e.addProperty("currencyId",null),e.hasChild("unitId")||e.addProperty("unitId",null),e.hasChild("adjustedToSplitTime")||e.addProperty("adjustedToSplitTime",null),e.hasChild("intervalsVisibilities")){const t=(0,r.merge)((0,r.clone)(v.intervalsVisibilitiesDefaults),e.childs().intervalsVisibilities.state());e.removeProperty("intervalsVisibilities"),e.addChild("intervalsVisibilities",new x.IntervalsVisibilitiesProperty(t))}else e.addChild("intervalsVisibilities",new x.IntervalsVisibilitiesProperty(v.intervalsVisibilitiesDefaults));e.hasChild("title")||e.addProperty("title",""),["symbolStateVersion","zOrderVersion","visible","frozen","symbol","currencyId","unitId","symbolInfo","points","interval","title"].forEach((t=>e.addExcludedKey(t,5))),e.hasChild("singleChartOnly")&&e.removeProperty("singleChartOnly"),e.hasChild("font")&&e.removeProperty("font")}static _addCollectedProperties(e){e.hasChild("linewidth")&&e.addChild("linesWidths",new B.LineToolWidthsProperty([(0,n.ensureDefined)(e.child("linewidth"))])),e.hasChild("linecolor")&&e.addChild("linesColors",new B.LineToolColorsProperty([(0,n.ensureDefined)(e.child("linecolor"))])),e.hasChild("backgroundColor")&&e.addChild("backgroundsColors",new B.LineToolColorsProperty([(0,n.ensureDefined)(e.child("backgroundColor"))])),e.hasChild("textColor")&&e.addChild("textsColors",new B.LineToolColorsProperty([(0,n.ensureDefined)(e.child("textColor"))])),e.hasChild("linestyle")&&e.addChild("linesStyles",new B.LineToolCollectedProperty([(0,n.ensureDefined)(e.child("linestyle"))])),["linesWidths","linesColors","backgroundsColors","textsColors","linesStyles"].forEach((t=>{e.addExcludedKey(t,7)}))}_areAlertsOnLineToolProhibited(){return null!==this._ownerSource&&!this._ownerSource.canHasAlertOnLineTools()}_removeAlertSubscriptions(){this._unsubscribeAlertCallbacks?.(),this._unsubscribeAlertCallbacks=void 0}_addAlertSubscriptions(e,t={}){}_destroyPanePaneViews(e){const t=this._paneViews.get(e);if(void 0!==t)for(const e of t)e.destroy&&e.destroy();void 0!==e&&e.onDestroyed().unsubscribeAll(this),this._paneViews.delete(e)}_copyPricesWithoutNormalization(){const e=Math.min(this._points.length,this._timePoint.length);for(let t=0;t<e;t++)this._timePoint[t].price=this._points[t].price}async _getChartAlert(){throw new Error("not implemented")}async _syncAlertWithAlertFacade(e={}){try{const t=await this.getAlert();if(!t)return;this._addAlertSubscriptions(t,e)}catch(e){if(e instanceof Error&&"not_exists"===e.message&&this.hasAlert().value()){this._alertStatus.setValue(0);return void(await getChartAlertsFacade()).removeAlertFromAllChartsSilently(this.id(),(0,n.ensureDefined)(this._alertId))}O.logError("Failed to set alert, alert will not be saved with drawing in chart")}}async _awaitForPointset(){const e={};try{await Promise.race([new Promise(((e,t)=>{setTimeout((()=>t(new Error("Timeout"))),3e3)})),new Promise((t=>{this.pointsetUpdated().subscribe(e,(()=>t()))}))])}catch(e){
throw e}finally{this.pointsetUpdated().unsubscribeAll(e)}}}},65045:(e,t,i)=>{"use strict";i.d(t,{LineToolCollectedProperty:()=>c,LineToolColorsProperty:()=>d,LineToolWidthsProperty:()=>h,MultipleLineColorsProperty:()=>p,MultipleLineWidthsProperty:()=>_});var s=i(9343),o=i(38486),n=i(79603);const r=(0,s.getLogger)("Chart.LineToolCollectedProperty");class a{applyValue(e,t){e.setValue(t)}}class l extends n.PropertyBase{constructor(e,t){super(),this._properties=e,e.forEach(((e,t)=>e.subscribe(this,((e,i)=>{this._listeners.fire(this,`${t}.${i}`)})))),this._showIfProperty=t}visible(){return!this._showIfProperty||this._showIfProperty?.value()}value(){if(0===this._properties.length)return r.logError("Incorrect call, should not request value of 0 properties"),"mixed";const e=this._properties[0].value();return 1===this._properties.length||this._properties.every((t=>t.value()===e))?e:"mixed"}setValueSilently(e){"mixed"!==e&&this._properties.forEach((t=>t.setValueSilently(e)))}hasChild(e){const t=parseInt(e,10);return!isNaN(t)&&t>=0&&t<this._properties.length}childCount(){return this._properties.length}childNames(){return this._properties.map(((e,t)=>t.toString()))}child(e){const t=parseInt(e,10);return!isNaN(t)&&t>=0&&t<this._properties.length?this._properties[t]:void 0}destroy(){this._properties.forEach((e=>e.unsubscribeAll(this))),this._listeners.destroy()}storeStateIfUndefined(){return!0}weakReference(){return(0,o.weakReference)(this)}ownership(){return(0,o.ownership)(this)}}class c extends l{setValue(e,t,i){if("mixed"===e)return;const s=i??new a;this._properties.forEach((t=>s.applyValue(t,e)))}}class h extends c{}class d extends c{firstColor(){return this._properties[0].value()}}class u extends l{setValue(e,t,i){if("mixed"===e)return;const s=i??new a;this._properties.forEach((t=>t.setValue(e,void 0,s)))}}class _ extends u{}class p extends u{}},58570:(e,t,i)=>{"use strict";i.d(t,{asLineToolName:()=>f,ensureLineToolLoaded:()=>g,getLoadedLineTool:()=>v,isAsyncGenericLineToolName:()=>d,isAsyncStudyLineToolName:()=>u,isLineToolLoaded:()=>_,loadLineTool:()=>m,loadMetaInfoForLinetoolIfRequired:()=>y});var s=i(50151),o=i(72972),n=i(35107);const r=new Map;const a=async e=>{const[t,s]=await Promise.all([Promise.all([i.e(2342),i.e(3952)]).then(i.bind(i,85834)),Promise.all([i.e(2342),i.e(3952)]).then(i.bind(i,92483))]),o=t.LineToolRiskRewardLong,n=s.LineToolRiskRewardShort;return r.set("LineToolRiskRewardLong",o),r.set("LineToolRiskRewardShort",n),"LineToolRiskRewardLong"===e?o:n
},l=new Map([["LineToolPriceNote",async()=>(await Promise.all([i.e(9426),i.e(5410),i.e(2745),i.e(380)]).then(i.bind(i,97865))).LineToolPriceNote],["LineToolTextNote",async()=>(await Promise.all([i.e(6645),i.e(5410),i.e(2745),i.e(986),i.e(9123)]).then(i.bind(i,55241))).LineToolTextNote],["LineToolNote",async()=>(await Promise.all([i.e(3355),i.e(5410),i.e(2745),i.e(986),i.e(3248)]).then(i.bind(i,77977))).LineToolNote],["LineToolFibSpiral",async()=>(await Promise.all([i.e(3181),i.e(5410),i.e(2745),i.e(8090)]).then(i.bind(i,40882))).LineToolFibSpiral],["LineToolCircleLines",async()=>(await Promise.all([i.e(8896),i.e(5410),i.e(2745),i.e(9445)]).then(i.bind(i,75249))).LineToolCyclicLines],["LineToolNoteAbsolute",async()=>(await Promise.all([i.e(3355),i.e(5410),i.e(2745),i.e(986),i.e(3248)]).then(i.bind(i,77977))).LineToolNoteAbsolute],["LineToolTable",async()=>(await Promise.all([i.e(9494),i.e(5410),i.e(2745),i.e(986),i.e(319)]).then(i.bind(i,53768))).LineToolTable],["LineToolFibSpeedResistanceArcs",async()=>(await Promise.all([i.e(1427),i.e(5410),i.e(2745),i.e(986),i.e(3710)]).then(i.bind(i,2709))).LineToolFibSpeedResistanceArcs],["LineToolPitchfan",async()=>(await Promise.all([i.e(7952),i.e(5410),i.e(2745),i.e(8823),i.e(1313)]).then(i.bind(i,23712))).LineToolPitchfan],["LineToolFibSpeedResistanceFan",async()=>(await Promise.all([i.e(1308),i.e(5410),i.e(2745),i.e(906)]).then(i.bind(i,5352))).LineToolFibSpeedResistanceFan],["LineToolFibWedge",async()=>(await Promise.all([i.e(6760),i.e(5410),i.e(2745),i.e(986),i.e(3314)]).then(i.bind(i,39653))).LineToolFibWedge],["LineToolEmoji",async()=>(await Promise.all([i.e(6155),i.e(5410),i.e(2745),i.e(6668),i.e(5529)]).then(i.bind(i,97879))).LineToolEmoji],["LineToolBalloon",async()=>(await Promise.all([i.e(2303),i.e(5410),i.e(2745),i.e(2891),i.e(1277)]).then(i.bind(i,12891))).LineToolBalloon],["LineToolComment",async()=>(await Promise.all([i.e(2303),i.e(5410),i.e(2745),i.e(986),i.e(2891),i.e(3966)]).then(i.bind(i,67046))).LineToolComment],["LineToolBezierCubic",async()=>(await Promise.all([i.e(1432),i.e(5410),i.e(2745),i.e(9014)]).then(i.bind(i,42318))).LineToolBezierCubic],["LineToolInsidePitchfork",async()=>(await Promise.all([i.e(8763),i.e(8468)]).then(i.bind(i,72298))).LineToolInsidePitchfork]]);l.set("LineToolFibRetracement",(async()=>(await Promise.all([i.e(7850),i.e(3723)]).then(i.bind(i,91308))).LineToolFibRetracement)),l.set("LineToolFibChannel",(async()=>(await Promise.all([i.e(7850),i.e(2283)]).then(i.bind(i,5871))).LineToolFibChannel)),l.set("LineToolProjection",(async()=>(await Promise.all([i.e(7122),i.e(3945)]).then(i.bind(i,11437))).LineToolProjection)),l.set("LineToolTrendBasedFibExtension",(async()=>(await Promise.all([i.e(7850),i.e(4731)]).then(i.bind(i,1086))).LineToolTrendBasedFibExtension)),l.set("LineToolElliott",(async()=>(await Promise.resolve().then(i.bind(i,10544))).LineToolElliott)),l.set("LineToolFibCircles",(async()=>(await Promise.all([i.e(7850),i.e(2816)]).then(i.bind(i,33985))).LineToolFibCircles)),
l.set("LineToolVertLine",(async()=>(await Promise.all([i.e(7122),i.e(1282)]).then(i.bind(i,94894))).LineToolVertLine)),l.set("LineToolCrossLine",(async()=>(await i.e(7203).then(i.bind(i,9431))).LineToolCrossLine)),l.set("LineToolBarsPattern",(async()=>(await Promise.all([i.e(4543),i.e(5206)]).then(i.bind(i,66807))).LineToolBarsPattern)),l.set("LineToolTrendBasedFibTime",(async()=>(await Promise.all([i.e(5111),i.e(7127)]).then(i.bind(i,42232))).LineToolTrendBasedFibTime)),l.set("LineToolFibTimeZone",(async()=>(await Promise.all([i.e(5111),i.e(1506)]).then(i.bind(i,40228))).LineToolFibTimeZone)),l.set("LineToolDateRange",(async()=>(await i.e(4273).then(i.bind(i,65096))).LineToolDateRange)),l.set("LineToolPriceRange",(async()=>(await i.e(6477).then(i.bind(i,27223))).LineToolPriceRange)),l.set("LineToolDateAndPriceRange",(async()=>(await i.e(1455).then(i.bind(i,22003))).LineToolDateAndPriceRange)),l.set("LineToolParallelChannel",(async()=>(await i.e(2050).then(i.bind(i,31191))).LineToolParallelChannel)),l.set("LineToolTrendAngle",(async()=>(await Promise.all([i.e(7122),i.e(8372)]).then(i.bind(i,75820))).LineToolTrendAngle)),l.set("LineToolTrendLine",(async()=>(await Promise.all([i.e(7122),i.e(8673)]).then(i.bind(i,42150))).LineToolTrendLine)),l.set("LineToolInfoLine",(async()=>(await Promise.all([i.e(7122),i.e(7488)]).then(i.bind(i,43470))).LineToolInfoLine)),l.set("LineToolArrowMark",(async()=>(await i.e(569).then(i.bind(i,70214))).LineToolArrowMark)),l.set("LineToolGannSquare",(async()=>(await i.e(9478).then(i.bind(i,26141))).LineToolGannSquare)),l.set("LineToolGannComplex",(async()=>(await i.e(1963).then(i.bind(i,68991))).LineToolGannComplex)),l.set("LineToolGannFixed",(async()=>(await i.e(6336).then(i.bind(i,44934))).LineToolGannFixed)),l.set("LineToolGannFan",(async()=>(await Promise.all([i.e(5111),i.e(4981)]).then(i.bind(i,646))).LineToolGannFan)),l.set("LineToolPitchfork",(async()=>(await Promise.all([i.e(8763),i.e(5055)]).then(i.bind(i,7029))).LineToolPitchfork)),l.set("LineToolDisjointAngle",(async()=>(await i.e(9581).then(i.bind(i,56348))).LineToolDisjointChannel)),l.set("LineToolFlatBottom",(async()=>(await i.e(9310).then(i.bind(i,28121))).LineToolFlatBottom)),l.set("LineToolIcon",(async()=>(await i.e(7806).then(i.bind(i,37130))).LineToolIcon)),l.set("LineToolSticker",(async()=>(await i.e(8949).then(i.bind(i,13238))).LineToolSticker)),l.set("LineToolRotatedRectangle",(async()=>(await i.e(4015).then(i.bind(i,92417))).LineToolRotatedRectangle)),l.set("LineToolHeadAndShoulders",(async()=>(await i.e(3378).then(i.bind(i,43684))).LineToolHeadAndShoulders)),l.set("LineToolTriangle",(async()=>(await i.e(6432).then(i.bind(i,41160))).LineToolTriangle)),l.set("LineToolTrianglePattern",(async()=>(await i.e(3383).then(i.bind(i,94407))).LineToolTrianglePattern)),l.set("LineTool5PointsPattern",(async()=>(await i.e(1155).then(i.bind(i,77657))).LineTool5PointsPattern)),l.set("LineToolThreeDrivers",(async()=>(await i.e(4602).then(i.bind(i,95400))).LineToolThreeDrivers)),
l.set("LineToolABCD",(async()=>(await i.e(5283).then(i.bind(i,21730))).LineToolABCD)),l.set("LineToolPolyline",(async()=>(await i.e(3866).then(i.bind(i,52982))).LineToolPolyline)),l.set("LineToolPath",(async()=>(await i.e(961).then(i.bind(i,18441))).LineToolPath)),l.set("LineToolPrediction",(async()=>(await i.e(9534).then(i.bind(i,45372))).LineToolPrediction)),l.set("LineToolPriceLabel",(async()=>(await i.e(6484).then(i.bind(i,60594))).LineToolPriceLabel)),l.set("LineToolArrowMarker",(async()=>(await i.e(1470).then(i.bind(i,14638))).LineToolArrowMarker)),l.set("LineToolSignpost",(async()=>(await Promise.all([i.e(7122),i.e(4674)]).then(i.bind(i,4838))).LineToolSignpost)),l.set("LineToolBrush",(async()=>(await i.e(5122).then(i.bind(i,71514))).LineToolBrush)),l.set("LineToolArc",(async()=>(await i.e(5967).then(i.bind(i,20272))).LineToolArc)),l.set("LineToolCallout",(async()=>(await Promise.all([i.e(7122),i.e(688)]).then(i.bind(i,9587))).LineToolCallout)),l.set("LineToolText",(async()=>(await Promise.all([i.e(7122),i.e(2312)]).then(i.bind(i,77532))).LineToolText)),l.set("LineToolHorzLine",(async()=>(await Promise.all([i.e(7122),i.e(4201)]).then(i.bind(i,66605))).LineToolHorzLine)),l.set("LineToolHorzRay",(async()=>(await i.e(574).then(i.bind(i,80102))).LineToolHorzRay)),l.set("LineToolRectangle",(async()=>(await Promise.all([i.e(7122),i.e(8422)]).then(i.bind(i,22132))).LineToolRectangle)),l.set("LineToolCircle",(async()=>(await Promise.all([i.e(7122),i.e(6748)]).then(i.bind(i,40283))).LineToolCircle)),l.set("LineToolEllipse",(async()=>(await Promise.all([i.e(7122),i.e(7660)]).then(i.bind(i,95121))).LineToolEllipse)),l.set("LineToolTimeCycles",(async()=>(await i.e(8334).then(i.bind(i,79327))).LineToolTimeCycles)),l.set("LineToolSineLine",(async()=>(await i.e(1713).then(i.bind(i,49684))).LineToolSineLine)),l.set("LineToolGhostFeed",(async()=>(await i.e(7563).then(i.bind(i,46350))).LineToolGhostFeed)),l.set("LineToolBezierQuadro",(async()=>(await i.e(8061).then(i.bind(i,12148))).LineToolBezierQuadro)),l.set("LineToolArrow",(async()=>(await Promise.all([i.e(7122),i.e(8607)]).then(i.bind(i,81817))).LineToolArrow)),l.set("LineToolRay",(async()=>(await Promise.all([i.e(7122),i.e(4934)]).then(i.bind(i,94984))).LineToolRay)),l.set("LineToolExtended",(async()=>(await Promise.all([i.e(7122),i.e(925)]).then(i.bind(i,81951))).LineToolExtended)),l.set("LineToolSchiffPitchfork",(async()=>(await Promise.all([i.e(8763),i.e(7175)]).then(i.bind(i,28216))).LineToolSchiffPitchfork)),l.set("LineToolSchiffPitchfork2",(async()=>(await Promise.all([i.e(8763),i.e(341)]).then(i.bind(i,23366))).LineToolSchiffPitchfork2)),l.set("LineToolTextAbsolute",(async()=>(await Promise.all([i.e(7122),i.e(2312)]).then(i.bind(i,77532))).LineToolTextAbsolute)),l.set("LineToolArrowMarkLeft",(async()=>(await i.e(569).then(i.bind(i,70214))).LineToolArrowMarkLeft)),l.set("LineToolArrowMarkRight",(async()=>(await i.e(569).then(i.bind(i,70214))).LineToolArrowMarkRight)),l.set("LineToolArrowMarkUp",(async()=>(await i.e(569).then(i.bind(i,70214))).LineToolArrowMarkUp)),
l.set("LineToolArrowMarkDown",(async()=>(await i.e(569).then(i.bind(i,70214))).LineToolArrowMarkDown)),l.set("LineToolFlagMark",(async()=>(await i.e(8820).then(i.bind(i,23283))).LineToolFlagMark)),l.set("LineToolCypherPattern",(async()=>(await i.e(6740).then(i.bind(i,573))).LineToolCypherPattern)),l.set("LineToolElliottImpulse",(async()=>(await Promise.resolve().then(i.bind(i,10544))).LineToolElliottImpulse)),l.set("LineToolElliottTriangle",(async()=>(await Promise.resolve().then(i.bind(i,10544))).LineToolElliottTriangle)),l.set("LineToolElliottTripleCombo",(async()=>(await Promise.resolve().then(i.bind(i,10544))).LineToolElliottTripleCombo)),l.set("LineToolElliottCorrection",(async()=>(await Promise.resolve().then(i.bind(i,10544))).LineToolElliottCorrection)),l.set("LineToolElliottDoubleCombo",(async()=>(await Promise.resolve().then(i.bind(i,10544))).LineToolElliottDoubleCombo)),l.set("LineToolRiskRewardLong",(()=>a("LineToolRiskRewardLong"))),l.set("LineToolRiskRewardShort",(()=>a("LineToolRiskRewardShort"))),l.set("LineToolPosition",(async()=>(await i.e(1314).then(i.t.bind(i,69593,19))).LineToolPosition)),l.set("LineToolOrder",(async()=>(await i.e(2232).then(i.t.bind(i,28837,19))).LineToolOrder)),l.set("LineToolHighlighter",(async()=>(await i.e(2087).then(i.bind(i,50991))).LineToolHighlighter)),l.set("LineToolImage",(async()=>(await Promise.all([i.e(5402),i.e(5231)]).then(i.bind(i,62414))).LineToolImage)),l.set("LineToolExecution",(async()=>(await Promise.resolve().then(i.bind(i,27593))).LineToolExecution));const c=new Map,h=new Map([["LineToolAnchoredVWAP",async()=>(await Promise.all([i.e(6025),i.e(9378),i.e(5500)]).then(i.bind(i,55157))).LineToolAnchoredVWAP],["LineToolRegressionTrend",async()=>(await i.e(9748).then(i.bind(i,1232))).LineToolRegressionTrend],["LineToolVbPFixed",async()=>(await Promise.all([i.e(6025),i.e(5695)]).then(i.bind(i,71112))).LineToolVbPFixed],["LineToolFixedRangeVolumeProfile",async()=>(await Promise.all([i.e(6025),i.e(5695)]).then(i.bind(i,57296))).LineToolFixedRangeVolumeProfile]]);function d(e){return l.has(e)||h.has(e)||r.has(e)}function u(e){return h.has(e)}function _(e){return!d(e)||r.has(e)||c.has(e)}let p=0;async function m(e){if(_(e))return v(e);const t=u(e);p+=1;const i=(0,s.ensureDefined)((t?h:l).get(e)),o=await i();return p-=1,t?(c.set(e,(0,s.ensureDefined)(o)),v(e)):(r.set(e,(0,s.ensureDefined)(o)),v(e))}async function g(e){await y(e),d(e)&&!_(e)&&await m(e)}function f(e){return e}async function y(e){(function(e){return["LineToolRiskRewardLong","LineToolRiskRewardShort"].includes(e),(0,n.isStudyLineTool)(e)||u(e)})(e)&&await(0,o.studyMetaInfoRepository)().findAllJavaStudies()}function v(e){return u(e)?(0,s.ensureDefined)(c.get(e),`Study line tool ${e}`):(0,s.ensureDefined)(r.get(e),`Line tool ${e}`)}},56876:(e,t,i)=>{"use strict";i.d(t,{lineToolsLocalizedNames:()=>o});var s=i(11542);const o={LineTool5PointsPattern:s.t(null,void 0,i(42231)),LineToolABCD:s.t(null,void 0,i(46712)),LineToolArc:s.t(null,void 0,i(59324)),LineToolArrow:s.t(null,void 0,i(11858)),
LineToolArrowMarkDown:s.t(null,void 0,i(73193)),LineToolArrowMarkLeft:s.t(null,void 0,i(1949)),LineToolArrowMarkRight:s.t(null,void 0,i(86275)),LineToolArrowMarkUp:s.t(null,void 0,i(62453)),LineToolBalloon:s.t(null,void 0,i(70540)),LineToolComment:s.t(null,void 0,i(9818)),LineToolBarsPattern:s.t(null,void 0,i(81994)),LineToolBezierCubic:s.t(null,void 0,i(77125)),LineToolBezierQuadro:s.t(null,void 0,i(78609)),LineToolBrush:s.t(null,void 0,i(43539)),LineToolCallout:s.t(null,void 0,i(25381)),LineToolCircleLines:s.t(null,void 0,i(84031)),LineToolCypherPattern:s.t(null,void 0,i(93191)),LineToolDateAndPriceRange:s.t(null,void 0,i(47017)),LineToolDateRange:s.t(null,void 0,i(85444)),LineToolDisjointAngle:s.t(null,void 0,i(91544)),LineToolElliottCorrection:s.t(null,void 0,i(80943)),LineToolElliottDoubleCombo:s.t(null,void 0,i(75112)),LineToolElliottImpulse:s.t(null,void 0,i(61114)),LineToolElliottTriangle:s.t(null,void 0,i(72359)),LineToolElliottTripleCombo:s.t(null,void 0,i(76129)),LineToolEllipse:s.t(null,void 0,i(78996)),LineToolExtended:s.t(null,void 0,i(52788)),LineToolFibChannel:s.t(null,void 0,i(59005)),LineToolFibCircles:s.t(null,void 0,i(82330)),LineToolFibRetracement:s.t(null,void 0,i(55986)),LineToolFibSpeedResistanceArcs:s.t(null,void 0,i(33880)),LineToolFibSpeedResistanceFan:s.t(null,void 0,i(2395)),LineToolFibSpiral:s.t(null,void 0,i(39014)),LineToolFibTimeZone:s.t(null,void 0,i(30622)),LineToolFibWedge:s.t(null,void 0,i(85042)),LineToolFlagMark:s.t(null,void 0,i(14600)),LineToolImage:s.t(null,void 0,i(68065)),LineToolFlatBottom:s.t(null,void 0,i(45051)),LineToolAnchoredVWAP:s.t(null,void 0,i(84541)),LineToolGannComplex:s.t(null,void 0,i(44763)),LineToolGannFixed:s.t(null,void 0,i(60707)),LineToolGannFan:s.t(null,void 0,i(48683)),LineToolGannSquare:s.t(null,void 0,i(47460)),LineToolHeadAndShoulders:s.t(null,void 0,i(21928)),LineToolHorzLine:s.t(null,void 0,i(21795)),LineToolHorzRay:s.t(null,void 0,i(25487)),LineToolIcon:s.t(null,void 0,i(37913)),LineToolEmoji:s.t(null,void 0,i(73456)),LineToolSticker:s.t(null,void 0,i(43114)),LineToolInsidePitchfork:s.t(null,void 0,i(41686)),LineToolNote:s.t(null,void 0,i(86631)),LineToolTextNote:s.t(null,void 0,i(94389)),LineToolSignpost:s.t(null,void 0,i(67751)),LineToolParallelChannel:s.t(null,void 0,i(59256)),LineToolPitchfan:s.t(null,void 0,i(34156)),LineToolPitchfork:s.t(null,void 0,i(19634)),LineToolPolyline:s.t(null,void 0,i(39949)),LineToolPath:s.t(null,void 0,i(371)),LineToolPrediction:s.t(null,void 0,i(20138)),LineToolPriceLabel:s.t(null,void 0,i(91282)),LineToolArrowMarker:s.t(null,void 0,i(36352)),LineToolPriceRange:s.t(null,void 0,i(68941)),LineToolProjection:s.t(null,void 0,i(75747)),LineToolRay:s.t(null,void 0,i(50318)),LineToolRectangle:s.t(null,void 0,i(26001)),LineToolCircle:s.t(null,void 0,i(91944)),LineToolRegressionTrend:s.t(null,void 0,i(2460)),LineToolRiskRewardLong:s.t(null,void 0,i(74832)),LineToolRiskRewardShort:s.t(null,void 0,i(8075)),LineToolFixedRangeVolumeProfile:s.t(null,{context:"study"},i(25705)),LineToolAnchoredVolumeProfile:s.t(null,{
context:"study"},i(89633)),LineToolRotatedRectangle:s.t(null,void 0,i(56820)),LineToolSchiffPitchfork:s.t(null,void 0,i(57681)),LineToolSchiffPitchfork2:s.t(null,void 0,i(42608)),LineToolSineLine:s.t(null,void 0,i(39090)),LineToolText:s.t(null,{context:"tool"},i(91405)),LineToolTextAbsolute:s.t(null,void 0,i(42669)),LineToolThreeDrivers:s.t(null,void 0,i(46982)),LineToolTimeCycles:s.t(null,void 0,i(46852)),LineToolTrendAngle:s.t(null,void 0,i(35757)),LineToolTrendBasedFibExtension:s.t(null,void 0,i(80583)),LineToolTrendBasedFibTime:s.t(null,void 0,i(72159)),LineToolTrendLine:s.t(null,void 0,i(97339)),LineToolInfoLine:s.t(null,void 0,i(15992)),LineToolTriangle:s.t(null,void 0,i(1671)),LineToolTrianglePattern:s.t(null,void 0,i(90148)),LineToolVertLine:s.t(null,void 0,i(29535)),LineToolCrossLine:s.t(null,void 0,i(74334)),LineToolHighlighter:s.t(null,void 0,i(69476)),LineToolPriceNote:s.t(null,void 0,i(97512)),LineToolVbPFixed:s.t(null,void 0,i(40693)),LineToolGhostFeed:s.t(null,void 0,i(46808)),LineToolTable:s.t(null,void 0,i(17981))}},91111:(e,t,i)=>{"use strict";i.d(t,{lineToolsStudyIds:()=>s});const s={LineToolAnchoredVWAP:"AnchoredVWAP@tv-basicstudies",LineToolRegressionTrend:"RegressionTrend@tv-basicstudies",LineToolFixedRangeVolumeProfile:"VbPFixed@tv-basicstudies",LineToolVbPFixed:"VbPFixed@tv-volumebyprice"}},26610:(e,t,i)=>{"use strict";i.d(t,{cloneLineTool:()=>B,createLineTool:()=>T,createLineToolProperties:()=>x,createStudyLineToolProperties:()=>M,ensureAllLineToolsLoadedForLayout:()=>w,initAllLineToolsFromContent:()=>C,initLineTool:()=>y,isBrushBasedLineTool:()=>A,isEditableTextLineTool:()=>E,isLineTool:()=>p.isLineTool,isTrading:()=>L,prepareLineToolPropertiesByOwnerSource:()=>P,setNewToolProperties:()=>g,supportsPhantomMode:()=>I,tryFindStudyLineToolNameByStudyId:()=>D,unsetNewToolProperties:()=>f});var s=i(82433),o=i(50151),n=i(10555),r=i(9343),a=i(81922),l=i(52974),c=i(95059),h=i(11946),d=i(91111),u=i(55393),_=i(58570),p=i(97217);let m=null;function g(e,t,i){return null!==m&&m.tool===e&&m.toolData===t||(f(!0),m={properties:x(i.backgroundTheme().spawnOwnership(),e,!i.readOnly()),tool:e,toolData:t}),m.properties}function f(e){e&&m?.properties.destroy(),m=null}async function y(e){await(0,_.loadMetaInfoForLinetoolIfRequired)(e);const t=(0,_.asLineToolName)(e);(0,_.isLineToolLoaded)(t)||(0,h.isLineToolName)(t)&&await(0,_.loadLineTool)(t)}function v(e,t){const i="charts"in e?e.charts:[e];for(const e of i){for(const i of e.panes)for(const e of i.sources)t(e.type);e.lineToolsGroups?.groups.forEach((e=>{e.tools.forEach((e=>t(e)))}))}}class S extends Error{constructor(e,t){super(`Failed to load line tool: ${e}`),this.name="LineToolLoadError",this.toolName=e,this.originalError=t}}const b=(0,r.getLogger)("LineToolsSynchronizer");async function w(e){const t=new Set,i=e=>{(0,_.isAsyncGenericLineToolName)(e)&&t.add(e)};for(const t of e)v(t,i);const s=[...t],o=(await Promise.allSettled(s.map((e=>(0,_.ensureLineToolLoaded)(e).catch((t=>{throw new S(e,t)})))))).filter((e=>"rejected"===e.status))
;o.length>0&&o.forEach((e=>{const t=e.reason;b.logError(`Failed to load line tool: ${t.toolName}`)}))}async function C(e){if(!e)return;const t=new Set;v(e,(e=>{(0,h.isLineToolName)(e)&&t.add(e)})),await Promise.all(Array.from(t).map((e=>y(e))))}function T(e,t,i,s,n,r,a){(0,o.assert)((0,h.isLineToolName)(e),"Unknown line tool: "+e);const l=(0,_.asLineToolName)(e);let c;if((0,o.assert)((0,_.isLineToolLoaded)(l),`Line tool ${l} is not loaded`),n||i||null===m||m.tool!==e||(i=m.properties,f(!1)),(0,_.isAsyncStudyLineToolName)(l)){c=new((0,_.getLoadedLineTool)(l))(t,i,(0,o.ensureDefined)(s),n,r)}else{c=new((0,_.getLoadedLineTool)(l))(t,i,n,r)}return c.toolname=e,f(!0),c}function P(e,t){const i=(0,o.ensureNotNull)(t.symbolSource()),s=i.symbolInfo(),n=s?(0,c.extractLineToolSymbolFromSymbolInfo)(s,i.symbol()):i.symbol();e.childs().symbol.setValue(n),i.model().currencyConversionEnabled()&&i.isConvertedToOtherCurrency()&&e.childs().currencyId.setValue(i.currency()),i.model().unitConversionEnabled()&&i.isConvertedToOtherUnit()&&e.childs().unitId.setValue(i.unit()),e.childs().symbolStateVersion.setValue(2),e.childs().zOrderVersion.setValue(2)}function x(e,t,i,s){(0,o.assert)((0,h.isLineToolName)(t),`${t} should be name of the line tool`);const n=(0,_.asLineToolName)(t);if((0,o.assert)((0,_.isLineToolLoaded)(n),`Line tool ${n} is not loaded`),(0,_.isAsyncStudyLineToolName)(n)){return(0,_.getLoadedLineTool)(n).createProperties(e,s)}return(0,_.getLoadedLineTool)(n).createProperties(e,s,i)}function M(e,t,i,s,n,r){(0,o.assert)((0,h.isStudyLineToolName)(t),`${t} should be name of the study line tool`);const a=(0,_.asLineToolName)(t);if((0,_.isAsyncStudyLineToolName)(a)){return(0,_.getLoadedLineTool)(a).createPropertiesFromStudyMetaInfoAndState(i,s,n,r,e)}throw new Error(`Property creation is not implemented for study line tool ${t}`)}function I(e){(0,o.assert)((0,h.isLineToolName)(e),`${e} should be name of the line tool`);const t=(0,_.asLineToolName)(e);(0,o.assert)((0,_.isLineToolLoaded)(t),`Line tool ${t} is not loaded`);const i=(0,_.getLoadedLineTool)(t);return void 0!==i&&Boolean(i.supportPhantomMode)}function A(e){return e instanceof u.LineToolBrushBase}function L(e){return e instanceof l.LineToolTrading}const k=["editableTextStyle","editableText","editableTextProperties"];function E(e){return(0,s.default)(e)&&k.every((t=>t in e))}function D(e){let t=null;return e===d.lineToolsStudyIds.LineToolRegressionTrend?t="LineToolRegressionTrend":e===d.lineToolsStudyIds.LineToolVbPFixed?t="LineToolVbPFixed":e===d.lineToolsStudyIds.LineToolFixedRangeVolumeProfile&&(t="LineToolFixedRangeVolumeProfile"),t}function B(e,t,i,s,r){const l=t.toolname,c=t.properties().state();c.intervalsVisibilities=(0,a.mergeIntervalVisibilitiesDefaults)(c?.intervalsVisibilities);const h=x(e.backgroundTheme().spawnOwnership(),t.toolname,!e.readOnly(),c);h.childs().visible.setValue(!0);const d=(0,o.ensureNotNull)(t.ownerSource()),u=T(l,e,h,null,void 0,void 0);void 0!==s&&u.setId(s),u.setOwnerSource(d),u.toolname=l;const _=u.clonePositionOffset();if(t.isFixed()){
const e=(0,o.ensureDefined)(t.fixedPoint()),s=i?e.add(new n.Point(_.xCoordOffset,_.yCoordOffset)):e;u.addFixedPoint(s)}const p=t.normalizedPoints(),m=i?function(e,t,i){const s=(0,o.ensureNotNull)(t.priceScale()),n=(0,o.ensureNotNull)(t.firstValue());return e.map((e=>{const t=e.price,o=s.priceToCoordinate(t,n)+i.yCoordOffset,r=s.coordinateToPrice(o,n),a=e.interval;return{time_t:e.time_t,price:r,offset:e.offset+i.barOffset,interval:a}}))}(p,d,_):p,g=t.points();return u.restorePoints(m,g),u.cloneData&&u.cloneData(t),u.recalculateStateByData&&u.recalculateStateByData(),u}},36947:(e,t,i)=>{"use strict";var s;i.d(t,{LineToolPitchforkStyle:()=>s}),function(e){e[e.Original=0]="Original",e[e.Schiff=1]="Schiff",e[e.Inside=2]="Inside",e[e.Schiff2=3]="Schiff2"}(s||(s={}))},35107:(e,t,i)=>{"use strict";i.d(t,{StudyLineDataSource:()=>w,isStudyLineTool:()=>b});var s=i(72187),o=i(41414),n=i(78176),r=i(19844),a=i(45530),l=i(69422),c=i(19136),h=i(86252);class d extends c.StudyDataSource{constructor(e,t,i,s){super(e,t.seriesSource(),i,s),this._series=t}_createStudyError(e){return(0,h.createStudyError)(this._getStudyErrorDescription(e),this._series.symbolInfo()?.exchange)}}var u=i(63681),_=i(64717),p=i(23502),m=i(40472),g=i(52479);class f extends g.StatusProviderBase{constructor(e){super(),this._source=e}errorStatus(){const e=this._source.status();return e.type===h.StudyStatusType.Error?{error:this.sourceStatusText(),solutionId:(0,h.studyStatusSolutionId)(e),title:(0,h.studyStatusTitle)(e),studyFeature:(0,h.studyStatusFeature)(e)}:null}getSplitTitle(){return this._source.titleInParts()}getInputsTitles(){return null}text(){return this._source.translatedType()}sourceStatusText(){return(0,h.convertStudyStatusToString)(this._source.status(),!0)}}var y=i(51304),v=i(13651);class S extends v.StatusView{constructor(e){super(e.statusProvider({}))}getSplitTitle(){return this._statusProvider.getSplitTitle()}}function b(e){return e instanceof w}class w extends o.LineDataSource{constructor(e,t,s,o,n,r){super(e,o,n,r),this._indexes=null,this._inputs=null,this._definitionsViewModel=null,this._pointsetPoints=null,this._loadedPlots=null,this._loadedGraphics=null,this._beingCreatedPaneView=null,this._anchorsPaneView=null,this._isLegendDisplayed=!1,Promise.all([Promise.all([i.e(6290),i.e(986),i.e(6668),i.e(1583)]).then(i.bind(i,72306)),Promise.all([i.e(6290),i.e(986),i.e(6668),i.e(1583)]).then(i.bind(i,51272))]).then((t=>{const{LineToolBeingCreatedPaneView:i}=t[0],{StudyLineDataSourceAnchorsPaneView:s}=t[1];this._beingCreatedPaneView=new i(this,e),this._anchorsPaneView=new s(this,this.model()),this._model.lightUpdate()})),this._metaInfo=t,this._dataSource=new d(e.chartApi(),e.mainSeries(),s,t),this._dataSource.dataCleared().subscribe(this,this._onDataCleared),this._dataSource.dataUpdated().subscribe(this,this._onDataUpdated),this._dataSource.studyStatusChanged().subscribe(this,this._onStudyStatusChanged),this._statusProvider=new f(this),this._statusView=new S(this),
this._showStudyArgumentsProperty=e.properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments}isDisplayedInLegend(){return this._isLegendDisplayed}titleInParts(){const e=[];if(this._showStudyArgumentsProperty.value()&&this._inputs)for(const t of this._metaInfo.inputs){if(!0===t.isHidden||"bool"===t.type)continue;const i=this._inputs[t.id];e.push(i.toString())}return[this.name(),e]}destroy(){this._dataSource.dataUpdated().unsubscribeAll(this),this._dataSource.dataCleared().unsubscribeAll(this),this._dataSource.studyStatusChanged().unsubscribeAll(this),this._dataSource.destroy(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),this._unsubscribeApplyInputsOnSeriesCompleted(),this._isDestroyed=!0,super.destroy()}stop(){super.stop(),this._stopDataSource()}start(){super.start(),this._startDataSource()}metaInfo(){return this._metaInfo}graphicsInfo(){return this._metaInfo.graphics}series(){return this._model.mainSeries()}translatedType(){return this._metaInfo.description}name(){return this._metaInfo.description}studyId(){return this._metaInfo.id}setPoint(e,t,i){super.setPoint(e,this._preparePoint(t,i))}move(e){}clearData(){this._pointsetPoints=null,this._clearAllDataExceptPointsetPoints(),this._onStudyInputsMayChange(),this.updateAllViews((0,m.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),super.clearData()}data(){return this.plots()}plots(){return this._loadedPlots||this._dataSource.plots()}graphics(){return this._loadedGraphics||this._dataSource.graphics()}valueAt(e,t){return this.ownerSource()?.symbolSource().valueAt(e,t)??null}firstValue(){return this._model.mainSeries().firstValue()}state(e){const t={...super.state(e),metaInfo:this.metaInfo().state()};return e&&(t.data=this.plots().state(),t.nonseriesindexes=this._indexes,t.graphics=(0,a.saveStudyGraphics)(this.graphics(),null)),t}restoreData(e){void 0!==e.data&&(this._loadedPlots=new s.PlotList((0,_.studyPlotFunctionMap)(this._metaInfo),_.studyEmptyPlotValuePredicate),this._loadedPlots.restoreState(e.data)),this._indexes=e.nonseriesindexes??this._indexes,this._loadedGraphics=e.graphics?(0,a.loadStudyGraphics)(e.graphics):this._loadedGraphics}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)}paneViews(e){let t=[];if(this.isSourceHidden())return t;if(this._isReady()&&this._changeStatesStack.isEmpty()){const i=super.paneViews(e);null!==i&&(t=t.concat(i))}else null!==this._beingCreatedPaneView&&t.push(this._beingCreatedPaneView);return null!==this._anchorsPaneView&&t.push(this._anchorsPaneView),t}propertiesChanged(e){super.propertiesChanged(e),this._onStudyInputsMayChange()}dataAndViewsReady(){return super.dataAndViewsReady()&&this._isReady()}endChanging(e,t){const i=super.endChanging(e,t)
;return i.indexesChanged?this.clearData():this._updateAnchorsPrice(!0),i}moveData(e){this._dataSource.moveData(e)}restorePoints(e,t,i){super.restorePoints(e,t,i),this._updateAnchorsPrice(!0)}statusProvider(e){return this._statusProvider}alertSourceModel(){return null}statusView(){return this._statusView}legendView(){return null}dataProblemModel(){return null}dataUpdatedModeModel(){return null}marketStatusModel(){return null}onStatusChanged(){return this._dataSource.studyStatusChanged()}status(){return this._dataSource.studyStatus()}recalcStudyIfNeeded(){}stateForAlert(){return null}static createPropertiesFromStudyMetaInfoAndState(e,t,i,s,o){const n=(0,p.prepareStudyPropertiesForLoadChart)(e,t,i,s,void 0,o);return this._configureProperties(n),n}_getPointsetPoints(){return this._pointsetPoints}_onStudyStatusChanged(e,t){let i;switch(t.type){case u.StudyStatusType.Error:i=!0;break;case u.StudyStatusType.Completed:i=!1;break;default:return}if(i===this._isLegendDisplayed)return;this._isLegendDisplayed=i;const s=this._model.paneForSource(this);if(s){const e=this._model.panes().indexOf(s),t=y.InvalidationMask.invalidateLegendWidgetLayout(e);this.model().invalidate(t)}}_studyId(){return this._dataSource.studyId()}_isReady(){return!0}_updateAllPaneViews(e){super._updateAllPaneViews(e),this._beingCreatedPaneView?.update(),this._anchorsPaneView?.update(e)}_getPointTime(e,t){const i=e.index,s=this._model.timeScale().indexToTimePoint(i);return null!==s?s:t||void 0===e.time?null:this._utcTimeInCurrentResolution(e)}_updateAnchorsPrice(e){}_onPointsetUpdated(e){super._onPointsetUpdated(e),this._pointsetPoints=this._points.map((e=>({price:e.price,index:e.index,time:e.time}))),this._onStudyInputsMayChange()}_onDataCleared(){this.updateAllViews((0,m.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._model.updateSource(this)}_onDataUpdated(e,t,i){this._updateAnchorsPrice(),this.updateAllViews((0,m.sourceChangeEvent)({sourceId:this.id(),firstUpdatedTimePointIndex:e[0]?.index})),this._model.updateSource(this)}_onStudyInputsMayChange(){let e=null;const t=this._pointsetPoints;if(t?.length===this.pointsCount()){if(e=this._studyInputs(t),e){const t=this.metaInfo().inputs.map((e=>e.id));for(const i of Object.keys(e))t.includes(i)||delete e[i]}}else this._isDataSourceStarted()&&this._stopDataSource(!1);e?this._unsubscribeApplyInputsOnSeriesCompleted():this._subscribeApplyInputsOnSeriesCompleted(),this._areInputsEqual(this._inputs,e)||(this._applyStudyInputs(e),e?this._isDataSourceStarted()||this._startDataSource():(this._clearAllDataExceptPointsetPoints(),this.updateAllViews((0,m.sourceChangeEvent)(this.id()))))}_preparePoint(e,t){return super._preparePoint(this._alignPointToRangeOfActualData(e),t)}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_subscribeApplyInputsOnSeriesCompleted(){this._unsubscribeApplyInputsOnSeriesCompleted(),this._model.mainSeries().dataEvents().completed().subscribe(this,(()=>this._onStudyInputsMayChange()),!0)}_unsubscribeApplyInputsOnSeriesCompleted(){
this._model.mainSeries().dataEvents().completed().unsubscribeAll(this)}_onInputsChanged(){0}_clearAllDataExceptPointsetPoints(){this._loadedPlots=null,this._indexes=null,this._loadedGraphics=null,this._dataSource.clearData()}_stopDataSource(e=!0){this._isDestroyed||(this._dataSource.stop(),e&&this.clearData())}_startDataSource(){this._isDestroyed||null===this._inputs||this._dataSource.start()}_isDataSourceStarted(){return this._dataSource.isStarted()}static _createPropertiesFromStudyIdAndState(e,t){const i=r.StudyMetaInfo.getStudyPropertyRootNameById(e),s=new n.DefaultProperty({defaultName:i,state:t});return this._configureProperties(s),s}static _configureProperties(e){super._configureProperties(e),e.removeExcludedKey("intervalsVisibilities",1),e.removeProperty("showLegendValues"),e.removeProperty("showLegendInputs")}_areInputsEqual(e,t){return null===t?null===e:null!==e&&(0,l.areStudyInputsEqual)(this._metaInfo.inputs,e,t)}_applyStudyInputs(e){this._inputs=e,null!==e&&this._dataSource.setInputs(e),this._onInputsChanged()}}},52974:(e,t,i)=>{"use strict";const s=i(41414).LineDataSource,o=i(62301).alignToStep,n=i(35727).customFormatters,r=i(95059).createSeriesFormatter;class a extends s{constructor(e,t){super(e,t),this.customization.forcePriceAxisLabel=!0,this.customization.disableErasing=!0,this.customization.showInObjectsTree=!1,this._createFormatter(e.mainSeries().symbolInfo()),this.setSelectionEnabled(!1)}isSynchronizable(){return!1}pointsCount(){return a.POINTS_COUNT}hasContextMenu(){return!1}state(){return null}startMoving(){super.startMoving.apply(this,arguments),this._cursorMoved=!1}endMoving(){super.endMoving.apply(this,arguments),this._cursorMoved=!1}userEditEnabled(){return!0}movable(){return!1}canBeHidden(){return!1}isUserDeletable(){return!1}showInObjectTree(){return!1}doesMovingAffectsUndo(){return!1}isAvailableInFloatingWidget(){return!1}timeAxisViews(){return null}cloneable(){return!1}copiable(){return!1}_correctPoints(e,t){this._currentMovingPoint&&this._startMovingPoint?this._currentMovingPoint.logical.price-this._startMovingPoint.logical.price&&(this._cursorMoved=!0):this._cursorMoved=!1;for(var i=1/this.priceScale().mainSource().base(),s=0;s<e.length;s++){var n=e[s];this._cursorMoved&&(n.price=this._currentMovingPoint.logical.price),n.price=o(n.price,i),e[s]=n}}_createFormatter(e){let t=null;t=n&&n.priceFormatterFactory&&n.priceFormatterFactory(e),null==t&&(t=null),this._formatter=null!==t?t:r(e,"default",!1,!0)}}a.POINTS_COUNT=1,e.exports.LineToolTrading=a},71843:(e,t,i)=>{"use strict";i.r(t),i.d(t,{loadTheme:()=>r});var s=i(22489),o=i(76422),n=i(60973);async function r(e,t){const{themeName:i,standardTheme:r,syncState:a=!0,noUndo:l=!1,applyOverrides:c=!1,onlyActiveChart:h=!1}=t,d=await(r?Promise.resolve((0,s.getStdTheme)(i)):(0,s.getTheme)(i)),u=!r;if(void 0!==d.content){const t=!r||h;c&&(void 0!==(_=d.content).chartProperties&&(0,n.applyDefaultsOverrides)(_.chartProperties),void 0!==_.mainSourceProperties&&(0,n.applyDefaultsOverrides)(_.mainSourceProperties,void 0,!0,"mainSeriesProperties")),
await e.applyTheme({theme:d.content,onlyActiveChart:t,restoreNonThemeDefaults:u,themeName:i,standardTheme:r,syncState:a,noUndo:l}),(0,o.emit)("chart_theme_changed",i,r,t)}var _;return d}},7024:(e,t,i)=>{"use strict";var s;i.d(t,{MagnetMode:()=>s}),function(e){e[e.WeakMagnet=0]="WeakMagnet",e[e.StrongMagnet=1]="StrongMagnet"}(s||(s={}))},94322:(e,t,i)=>{"use strict";i.d(t,{magnetEnabled:()=>g,magnetMode:()=>f,magnetSnapsToIndicators:()=>y,setIsMagnetEnabled:()=>v,setMagnetMode:()=>S,setMagnetSnapsToIndicators:()=>b});var s=i(78176),o=i(22613),n=i(7024),r=i(78861),a=i(11946),l=i(75579);const c=new o.WatchedValue(!1),h=new o.WatchedValue(n.MagnetMode.WeakMagnet),d=new o.WatchedValue(!1),u=(0,l.modifierPressed)(),_=(0,l.shiftPressed)();function p(){const e=u.value();if(_.value()&&(r.isToolEditingNow.value()||r.isToolCreatingNow.value()))return void c.setValue(!1);let t,i;if(r.activePointSelectionMode.value()===r.SelectPointMode.Replay)t=i=!1;else{const s=r.tool.value(),o=r.isStudyEditingNow.value()||r.activePointSelectionMode.value()===r.SelectPointMode.Study;t=e&&((0,a.isLineToolName)(s)||r.isToolEditingNow.value()||(0,r.toolIsMeasure)(s)||o),i=(0,r.properties)().childs().magnet.value()}h.setValue(!i&&t?n.MagnetMode.StrongMagnet:(0,r.properties)().childs().magnetMode.value()),c.setValue(t?!i:i)}function m(){d.setValue((0,r.properties)().childs().magnetSnapsToIndicators.value())}function g(){return c}function f(){return h}function y(){return d}function v(e){(0,s.allowSavingDefaults)(!0),(0,r.properties)().childs().magnet.setValue(e),(0,s.allowSavingDefaults)(!1)}function S(e){(0,s.allowSavingDefaults)(!0),(0,r.properties)().childs().magnetMode.setValue(e),(0,r.properties)().childs().magnet.setValue(!0),(0,s.allowSavingDefaults)(!1)}function b(e){(0,s.allowSavingDefaults)(!0),(0,r.properties)().childs().magnetSnapsToIndicators.setValue(e),(0,s.allowSavingDefaults)(!1)}(0,r.runOnDrawingStateReady)((()=>{(0,r.properties)().childs().magnet.subscribe(null,p),(0,r.properties)().childs().magnetMode.subscribe(null,p),(0,r.properties)().childs().magnetSnapsToIndicators.subscribe(null,m),u.subscribe(p),_.subscribe(p),r.tool.subscribe(p),r.isToolEditingNow.subscribe(p),p(),m()}))},40472:(e,t,i)=>{"use strict";i.d(t,{crosshairMoveEvent:()=>m,globalChangeEvent:()=>a,hoverChangeEvent:()=>_,selectionChangeEvent:()=>d,sourceChangeEvent:()=>n,viewportChangeEvent:()=>c});var s,o=i(83873);function n(e){return(0,o.default)(e)?{type:"data-source-change",sourceId:e}:{type:"data-source-change",...e}}!function(e){e.DataSourceChange="data-source-change",e.ViewportChange="viewport-change",e.GlobalChange="global-change",e.SelectionChange="selection-change",e.HoverChange="hover-change",e.CrosshairMove="crosshair-move"}(s||(s={}));const r={type:"global-change"};function a(){return r}const l={type:"viewport-change"};function c(e){return e?{type:"viewport-change",pane:e}:l}const h={type:"selection-change"};function d(){return h}const u={type:"hover-change"};function _(){return u}const p={type:"crosshair-move"};function m(){return p}},29806:(e,t,i)=>{
"use strict";i.d(t,{unpackNonSeriesData:()=>n});var s=i(30551),o=i(50151);async function n(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=function(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,o.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,o.assert)("all"===e.action||"one"===e.action,"Erase command action should be 'all' or 'one'")}}return e}(t.graphicsCmds)),i}},53660:(e,t,i)=>{"use strict";i.d(t,{notAvailable:()=>o});var s=i(11542);const o=i(37103).enabled("use_na_string_for_not_available_values")?s.t(null,void 0,i(90091)):"∅"},56265:(e,t,i)=>{"use strict";i.d(t,{getNumericFormatter:()=>c,getPercentageFormatter:()=>h,getPipFormatter:()=>_,getVolumeFormatter:()=>d});var s=i(97906),o=i(38888);var n=i(67563);class r extends n.PriceFormatter{constructor(e){const{priceScale:t,minMove:i=1,type:s,typespecs:o,minMove2:n,ignoreLocaleNumberFormat:r}=e;("forex"===s||function(e,t){return Boolean(t?.includes("cfd"))&&["commodity","futures","index","stock","fund"].includes(e)}(s,o))&&n?(super({priceScale:n,ignoreLocaleNumberFormat:r}),this._isForex=!0):(super({priceScale:1,ignoreLocaleNumberFormat:r}),this._isForex=!1),this._pipPriceScale=t,this._pipMinMove=i,this._pipMinMove2=n}format(e,t={}){const{signPositive:i,tailSize:s,ignoreLocaleNumberFormat:o,noExponentialForm:n}=t;let r=this._isForex?this._pipMinMove2:this._pipMinMove;return void 0===r&&(r=NaN),super.format(e*this._pipPriceScale/r,{signPositive:i,tailSize:s,ignoreLocaleNumberFormat:o,noExponentialForm:n})}}var a=i(91565),l=i(95322);const c=(0,l.numDependencyFormatter)((e=>new s.NumericFormatter({precision:e}))),h=(0,l.numDependencyFormatter)((e=>new o.PercentageFormatter({priceScale:Math.pow(10,e??2),minMove:1}))),d=(0,l.numDependencyFormatter)((e=>new a.VolumeFormatter({precision:e}))),u=new WeakMap;function _(e){let t=u.get(e);return t||(t=new r({priceScale:e.pricescale,minMove:e.minmov,minMove2:e.minmove2,type:e.type,typespecs:e.typespecs}),u.set(e,t)),t}},43838:(e,t,i)=>{"use strict";var s;i.d(t,{PaneCursorType:()=>s}),function(e){e[e.Default=0]="Default",e[e.Pointer=1]="Pointer",e[e.Eraser=2]="Eraser",e[e.Dot=3]="Dot",e[e.Grabbing=4]="Grabbing",e[e.ZoomIn=5]="ZoomIn",e[e.VerticalResize=6]="VerticalResize",e[e.HorizontalResize=7]="HorizontalResize",
e[e.DiagonalNeSwResize=8]="DiagonalNeSwResize",e[e.DiagonalNwSeResize=9]="DiagonalNwSeResize",e[e.Text=10]="Text",e[e.None=11]="None"}(s||(s={}))},69555:(e,t,i)=>{"use strict";i.d(t,{PanePriceAxisView:()=>n});var s=i(57658);class o{constructor(e){this._priceAxisViewRenderer=null,this._rendererOptions=null,this._align="right",this._textWidthCache=e}setParams(e,t,i,s,o){this._priceAxisViewRenderer=e,this._rendererOptions=t,this._align=o}draw(e,t){null!==this._rendererOptions&&null!==this._priceAxisViewRenderer&&this._priceAxisViewRenderer.draw(e,t,this._rendererOptions,this._textWidthCache,this._align)}hitTest(e,t){return void 0===this._priceAxisViewRenderer?.hitTest?null:this._priceAxisViewRenderer?.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 o(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()}}},4699:(e,t,i)=>{"use strict";i.d(t,{applyColor:()=>c});var s=i(83873),o=i(16659),n=i(93201);const r=new WeakMap;var a,l;function c(e,t,i=0,a=3){const{context:l,bitmapSize:c,mediaSize:h}=e;let d;if((0,s.default)(t))d=t;else if(t.type===n.ColorType.Solid)d=t.color;else{let e=r.get(l);void 0===e&&(e=new o.CircularCacheBuffer(1e3),r.set(l,e));const s=0===i?h.height:c.height,n=`${t.startColor}_${t.endColor}_${s}`;let a=e.get(n);void 0===a&&(a=l.createLinearGradient(0,0,0,s),a.addColorStop(0,t.startColor),a.addColorStop(1,t.endColor),e.set(n,a)),d=a}1&a&&(l.strokeStyle=d),2&a&&(l.fillStyle=d)}!function(e){e[e.Stroke=1]="Stroke",e[e.Fill=2]="Fill",e[e.Both=3]="Both"}(a||(a={})),function(e){e[e.Media=0]="Media",e[e.Bitmap=1]="Bitmap"}(l||(l={}))},97126:(e,t,i)=>{"use strict";i.d(t,{AreaBackgroundItem:()=>h,AreaBackgroundItemsGroup:()=>l,AreaBackgroundRenderer:()=>d,CachedMap:()=>c});var s,o,n=i(50151),r=i(10307),a=i(7793);!function(e){e[e.Solid=0]="Solid",e[e.Gradient=1]="Gradient"}(s||(s={})),function(e){e[e.PurgeCachedMapCacheIterations=50]="PurgeCachedMapCacheIterations"}(o||(o={}));class l extends a.CachedContainer{constructor(e){super(),this.color=e}}class c{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,n.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 h extends a.CachedContainer{constructor(){super(),this.points1=new a.CachedContainer,this.points2=new a.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 d extends r.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._data=e??null}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){if(null===this._data)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e,o=.25*this._data.barSpacing;for(const[,e]of this._data.colorAreas){t.beginPath();for(let n=0;n<e.length();n++){const r=e.at(n);if(r.points1.isEmpty()||r.points2.isEmpty())continue;const a=r.points1.at(0).x,l=r.points1.at(0).y;if(t.moveTo(Math.round(a*i),l*s),1!==r.points1.length()&&1!==r.points2.length()){for(const e of r.points1.iterator(1))t.lineTo(Math.round(e.x*i),e.y*s);for(const e of r.points2.iterator(r.points2.length()-1,!0))t.lineTo(Math.round(e.x*i),e.y*s)}else{const e=r.points2.at(0).x,n=r.points2.at(0).y;t.lineTo(Math.round((a+o)*i),l*s),t.lineTo(Math.round((e+o)*i),n*s),t.lineTo(Math.round((e-o)*i),n*s),t.lineTo(Math.round((a-o)*i),l*s)}}if(t.closePath(),0===e.color.type)t.fillStyle=e.color.color;else{const i=t.createLinearGradient(0,e.color.coordinate1*s,0,e.color.coordinate2*s);i.addColorStop(0,e.color.color1??"transparent"),i.addColorStop(1,e.color.color2??"transparent"),t.fillStyle=i}t.fill()}}}},93463:(e,t,i)=>{"use strict";i.d(t,{PaneRendererArea:()=>l});var s=i(10555),o=i(79268),n=i(4539),r=i(58221),a=i(4699);class l extends o.PaneRendererLine{constructor(e){e.forceLineColor=!1,super(e)}_drawImpl(e){const t=this._data;if(0===t.items.length)return;let i=this._data.visibleItemsRange?.startItemIndex??0,l=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1;for(;i<l&&!(0,n.coordinateIsValid)(t.items[i].y);)i++;for(;l>=0&&!(0,n.coordinateIsValid)(t.items[l].y);)l--;if(i>l)return
;const{context:c,horizontalPixelRatio:h,verticalPixelRatio:d}=e;c.save(),c.scale(h,d),c.lineCap="round",(0,a.applyColor)(e,t.lineColor,0,1),c.lineWidth=t.lineWidth,(0,r.setLineStyle)(c,t.lineStyle),c.lineWidth=1;const u=new Map,_=new o.PaneRendererLineItemsIterator(this._data.items,i,l+1,this._data.skipHoles);for(;_.next();){const e=_.currentValue();let i;i=(0,o.isValidPoint)(e)&&e.style?e.style.color:t.lineColor;const s=_.nextValue();if((0,o.isValidPoint)(s)&&s?.style){const t=s.style.color;if(i!==t){const i=u.get(t)??[];i.push(e),u.set(t,i)}}const n=u.get(i)??[];n.push(e),u.set(i,n)}for(const[i,n]of u){c.beginPath();let r=0;for(let e=0;e<n.length;e++){const a=n[e];if(!(0,o.isValidPoint)(a))continue;if(!a.style||a.style?.color===i)continue;const l=(0,s.point)(Math.round(n[r].center),t.bottom);c.moveTo(l.x,l.y),this._walkLine(c,n.slice(r,e),!0,t.bottom,!0,!1,l),r=e}{const o=(0,s.point)(Math.round(n[r].center),t.bottom);if(c.moveTo(o.x,o.y),this._walkLine(c,n.slice(r,n.length),!0,t.bottom,!0,!1,o),c.closePath(),t.isSeries){const e=c.createLinearGradient(0,0,0,t.bottom);e.addColorStop(0,t.color1),e.addColorStop(1,t.color2),c.fillStyle=e,t.simpleMode=!0}else(0,a.applyColor)(e,i,0,2);c.fill()}}c.lineWidth=t.lineWidth,c.restore(),super._drawImpl(e)}}},10307:(e,t,i)=>{"use strict";i.d(t,{BitmapCoordinatesPaneRenderer:()=>o});var s=i(27714);class o{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){}}},94602:(e,t,i)=>{"use strict";i.d(t,{CompositeRenderer:()=>s});class s{constructor(){this._renderers=[],this._globalAlpha=1}setGlobalAlpha(e){this._globalAlpha=e}append(e){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<this._renderers.length;i++)e.save(),e.globalAlpha=this._globalAlpha,this._renderers[i].draw(e,t),e.restore()}drawBackground(e,t){e.save(),e.globalAlpha=this._globalAlpha;for(let i=0;i<this._renderers.length;i++){const s=this._renderers[i];s.drawBackground&&s.drawBackground(e,t)}e.restore()}hitTest(e,t){let i=null;for(let s=this._renderers.length-1;s>=0;s--){const o=this._renderers[s].hitTest(e,t);null!==o&&(null===i||o.target()>i.target())&&(i=o)}return i}doesIntersectWithBox(e,t){return this._renderers.some((i=>!!i.doesIntersectWithBox&&i.doesIntersectWithBox(e,t)))}}},58221:(e,t,i)=>{"use strict";i.r(t),i.d(t,{addHorizontalLineToPath:()=>d,addLineToPath:()=>P,addPixelPerfectLineToPath:()=>M,addVerticalLineToPath:()=>_,clearRectWithGradient:()=>c,clipPolygonByEdge:()=>A,computeDashPattern:()=>T,createCircle:()=>b,drawHorizontalLine:()=>u,drawLine:()=>x,drawPixelPerfectLine:()=>I,drawPoly:()=>w,drawRoundRect:()=>f,drawRoundRectWithInnerBorder:()=>y,drawVerticalLine:()=>p,fillRectInnerBorder:()=>h,fillRectWithBorder:()=>S,scaleDrawRoundRectRadii:()=>m,scalePath2D:()=>L,
scaledDashPattern:()=>v,setLineStyle:()=>C});var s=i(10555),o=i(48892),n=i(69558),r=i(18330),a=i(33350),l=i(33065);function c(e,t,i,s,o,n,r){e.save(),e.globalCompositeOperation="copy";const a=e.createLinearGradient(0,0,0,o);a.addColorStop(0,n),a.addColorStop(1,r),e.fillStyle=a,e.fillRect(t,i,s,o),e.restore()}function h(e,t,i,s,o,n){e.fillRect(t+n,i,s-2*n,n),e.fillRect(t+n,i+o-n,s-2*n,n),e.fillRect(t,i,n,o),e.fillRect(t+s-n,i,n,o)}function d(e,t,i,s){const o=e.lineWidth%2?.5:0;e.moveTo(i,t+o),e.lineTo(s,t+o)}function u(e,t,i,s){e.beginPath(),d(e,t,i,s),e.stroke()}function _(e,t,i,s){const o=e.lineWidth%2?.5:0;e.moveTo(t+o,i),e.lineTo(t+o,s)}function p(e,t,i,s){e.beginPath(),_(e,t,i,s),e.stroke()}function m(e,t){return Array.isArray(e)?e.map((e=>Math.round(e*t))):Math.round(e*t)}function g(e,t){return Array.isArray(e)?e.map((e=>0===e?e:e+t)):e+t}function f(e,t,i,s,o,n,r){let a,l,c,h;if(Array.isArray(n))if(2===n.length){const e=Math.max(0,n[0]),t=Math.max(0,n[1]);a=e,l=e,c=t,h=t}else{if(4!==n.length)throw new Error("Wrong border radius - it should be like css border radius");a=Math.max(0,n[0]),l=Math.max(0,n[1]),c=Math.max(0,n[2]),h=Math.max(0,n[3])}else{const e=Math.max(0,n);a=e,l=e,c=e,h=e}r||e.beginPath(),e.moveTo(t+a,i),e.lineTo(t+s-l,i),0!==l&&e.arcTo(t+s,i,t+s,i+l,l),e.lineTo(t+s,i+o-c),0!==c&&e.arcTo(t+s,i+o,t+s-c,i+o,c),e.lineTo(t+h,i+o),0!==h&&e.arcTo(t,i+o,t,i+o-h,h),e.lineTo(t,i+a),0!==a&&e.arcTo(t,i,t+a,i,a)}function y(e,t,i,s,o,n,a=0,l=0,c="",h=r.LineStyle.Solid){if(e.save(),!l||!c||c===n)return f(e,t,i,s,o,a),e.fillStyle=n,e.fill(),void e.restore();const d=l/2;if("transparent"!==n){const d="transparent"!==c&&h!==r.LineStyle.Solid;f(e,d?t:t+l,d?i:i+l,d?s:s-2*l,d?o:o-2*l,d?a:g(a,-l)),e.fillStyle=n,e.fill()}if("transparent"!==c){f(e,t+d,i+d,s-l,o-l,g(a,-d)),e.lineWidth=l,e.strokeStyle=c,C(e,h),e.closePath(),e.stroke()}e.restore()}function v(e,t){return t=Math.max(1,t),e.map((e=>e*t))}function S(e,t,i,s,o,l,c,h,d){const{context:_}=e,p=l%2/2,m=t+p,g=s+p;let f,y;if(h){const{borderMode:e,borderWidth:r,color:a,dashPattern:c,lineStyle:d}=h;switch(e){case"outer":{const e=-l/2-r/2,t=-r/2;y={left:m+e,right:g-e,top:i+t,bottom:o-t};break}case"center":{const e=r%2/2;y={left:t+e,right:s+e,top:i+e,bottom:o+e};break}case"inner":{const e=-l/2+r/2,t=r/2;y={left:m+e,right:g-e,top:i+t,bottom:o-t}}}_.strokeStyle=a,_.lineWidth=r;let u=-1;c?_.setLineDash(v(c,r)):void 0!==d&&(C(_,d),d===n.LINESTYLE_SOLID&&(u=1)),f={left:y.left+u*r/2,top:y.top+u*r/2,right:y.right-u*r/2,bottom:y.bottom-u*r/2}}if(c&&(_.fillStyle=c.color,f||(f={left:m-l/2,right:g+l/2,top:i,bottom:o}),_.fillRect(f.left,f.top,f.right-f.left,f.bottom-f.top)),d){const{lineWidth:n,lineColor:r,lineStyle:l,excludeBoundaries:c}=d;_.save(),_.lineCap="butt",_.lineWidth=n,_.strokeStyle=r,C(_,l);const p=()=>u(_,Math.floor((i+o)/2),h?.rightToLeftStroke?s:t,h?.rightToLeftStroke?t:s);c?(0,a.drawWithExclusionAreaByScope)(e,c,p):p(),_.restore()}if(y){if((h?.lineStyle??r.LineStyle.Solid)===r.LineStyle.Solid)_.strokeRect(y.left,y.top,y.right-y.left,y.bottom-y.top);else{
const e=h?.rightToLeftStroke?y.right:y.left,t=h?.rightToLeftStroke?y.left:y.right,i=y.top,s=y.bottom;_.lineCap="butt",[[e,i,t,i],[e,s,t,s],[e,i,e,s],[t,i,t,s]].forEach((([e,t,i,s])=>{_.beginPath(),_.moveTo(e,t),_.lineTo(i,s),_.stroke()}))}}}function b(e,t,i,s){e.beginPath(),e.arc(t,i,s,0,2*Math.PI,!1),e.closePath()}function w(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 C(e,t){let i=[];t!==n.LINESTYLE_SOLID&&(i=T(e.lineWidth,t)),e.setLineDash(i)}function T(e,t){return[[e,2*e],[5*e,6*e],[6*e,6*e],[e,4*e],[2*e,e]][t-1]}function P(e,t,i,s,o){e.moveTo(t,i),e.lineTo(s,o)}function x(e,t,i,s,o){isFinite(t)&&isFinite(s)&&isFinite(i)&&isFinite(o)&&(e.beginPath(),P(e,t,i,s,o),e.stroke())}function M(e,t,i,s,o,n){const{horizontalPixelRatio:r,verticalPixelRatio:a}=n;let l;return t===s?(l=[Math.round(t*r),i*a,Math.round(t*r),o*a],_(e,l[0],l[1],l[3])):i===o?(l=[t*r,Math.round(i*a),s*r,Math.round(i*a)],d(e,l[1],l[0],l[2])):(l=[t*r,i*a,s*r,o*a],P(e,l[0],l[1],l[2],l[3])),l}function I(e,t,i,s,o,n=l.dpr1PixelRatioInfo){e.beginPath(),M(e,t,i,s,o,n),e.stroke()}function A(e,t,i,n){const r=(0,s.equalPoints)(i,n[0])?(0,s.equalPoints)(i,n[1])?null:n[1]:n[0];return null!==e&&null!==r?(0,o.intersectPolygonAndHalfplane)(e,(0,s.halfplaneThroughPoint)((0,s.lineThroughPoints)(t,i),r)):null}function L(e,t){const i=new Path2D;return i.addPath(e,(new DOMMatrix).scaleSelf(t,t)),i}},4539:(e,t,i)=>{"use strict";i.d(t,{coordinateIsValid:()=>g,extendAndClipLineSegment:()=>h,fillScaledRadius:()=>y,getArrowPoints:()=>d,interactionTolerance:()=>m,optimalBarWidth:()=>u,optimalCandlestickWidth:()=>_,optimalHiLoWidth:()=>p,roundToMax:()=>S,setValidLineStyle:()=>f,strokeScaledRadius:()=>v});var s=i(87465),o=i(10555),n=i(48892),r=i(39612),a=i(58221);const l={common:13,line:13,tradingLine:16,minDistanceBetweenPoints:10,series:14,curve:10,anchor:13,esd:4},c={common:3,line:3,tradingLine:3,minDistanceBetweenPoints:5,series:2,curve:3,anchor:2,esd:0};function h(e,t,i,s,r,a){if((0,o.equalPoints)(e,t))return null;const l=new o.Point(0,0),c=new o.Point(i,s);if(r){if(a){const i=(0,n.intersectLineAndBox)((0,o.lineThroughPoints)(e,t),(0,o.box)(l,c));return Array.isArray(i)?i:null}{const i=(0,n.intersectRayAndBox)(t,e,(0,o.box)(l,c));return null===i||(0,o.equalPoints)(t,i)?null:(0,o.lineSegment)(t,i)}}if(a){const i=(0,n.intersectRayAndBox)(e,t,(0,o.box)(l,c));return null===i||(0,o.equalPoints)(e,i)?null:(0,o.lineSegment)(e,i)}{const i=(0,n.intersectLineSegmentAndBox)((0,o.lineSegment)(e,t),(0,o.box)(l,c));return Array.isArray(i)?i:null}}function d(e,t,i,s,o){const n=.5*i,r=Math.sqrt(2),a=t.subtract(e),l=a.normalized();let c=5*i;s&&(c=Math.min(c,.35*a.length()));const h=1*n;if(c*r*.2<=h)return[]
;const d=l.scaled(c),u=t.subtract(d),_=l.transposed(),p=1*c,m=_.scaled(p),g=u.add(m),f=u.subtract(m),y=g.subtract(t).normalized().scaled(h),v=f.subtract(t).normalized().scaled(h),S=o?t:t.add(y),b=o?t:t.add(v),w=n*(r-1),C=_.scaled(w),T=Math.min(c-1*n/r,n*r*1),P=l.scaled(T),x=t.subtract(C),M=t.add(C),I=t.subtract(P);return[[g,S],[b,f],[x,I.subtract(C)],[M,I.add(C)]]}function u(e,t){return t=t||1,Math.floor(.3*e*t)}function _(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),o=Math.floor(e*t),n=Math.min(s,o);return Math.max(Math.floor(t),n)}function p(e){return.4*e}function m(){return(0,r.lastMouseOrTouchEventInfo)().isTouch?l:c}function g(e){return null!=e&&!(0,s.isNaN)(e)}function f(e,t){void 0!==t&&(0,a.setLineStyle)(e,t)}function y(e,t){const i=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+i}function v(e,t,i){const s=Math.max(1,Math.floor(t))%2?.5:0;return Math.round(e*t)+(s!==i%2?.5:0)}function S(e){return Math.max(Math.floor(e),1)}},94119:(e,t,i)=>{"use strict";i.d(t,{HorizontalLineRenderer:()=>l});var s=i(2383),o=i(58221),n=i(4539),r=i(10307),a=i(33350);class l extends r.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,o=void 0===this._data.right||e.x-this._data.right<=t;return i&&s&&o?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,o.setLineStyle)(t,this._data.linestyle);const r=void 0!==this._data.left?Math.max(this._data.left,0):0,l=void 0!==this._data.right?Math.min(this._data.right,n.width):n.width,c=Math.round(this._data.y*s),h=Math.round(r*i),d=Math.round(l*i),u=this._data.excludeBoundaries;void 0!==u&&(0,a.addExclusionAreaByScope)(e,u),(0,o.drawHorizontalLine)(t,c,h,d)}}},25672:(e,t,i)=>{"use strict";var s;i.d(t,{LineEnd:()=>s}),function(e){e[e.Normal=0]="Normal",e[e.Arrow=1]="Arrow",e[e.Circle=2]="Circle"}(s||(s={}))},79268:(e,t,i)=>{"use strict";i.d(t,{PaneRendererLine:()=>g,PaneRendererLineItemsIterator:()=>m,isValidPoint:()=>p});var s=i(50151),o=i(10555),n=i(2624),r=i(2383),a=i(4539),l=i(58221),c=i(10307),h=i(4699),d=i(12217),u=i(85565);const _={y:NaN};function p(e){return null!==e&&!isNaN(e.y)}class m{constructor(e,t,i,o){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)(t<e.length,"First index must be less then array length"),(0,s.assert)(i<=e.length,"Last index must be less or equal to array length")),this._items=e,this._firstIndexWithRange=t,this._lastIndexWithRange=i,this._skipHoles=o}next(){if(0===this._items.length)return!1;if(null!==this._calculatedNext.index)return null!==this._calculatedNext.value&&(this._calculatedPrev=this._calculatedCurrent,this._calculatedCurrent=this._calculatedNext,this._calculatedNext={index:null,currentBreakProcessed:!1,value:null},!0);let e;this._preallocatedVariable={...this._calculatedCurrent};do{null===this._preallocatedVariable.index?(this._preallocatedVariable.index=this._firstIndexWithRange,this._preallocatedVariable.currentBreakProcessed=!1,e=this._preallocatedVariable.index<this._lastIndexWithRange):(this._incrementPointer(this._preallocatedVariable),e=this._isValidPointer(this._preallocatedVariable)),e&&this._calcVaue(this._preallocatedVariable)}while(e&&this._skipHoles&&!p(this._preallocatedVariable.value));return e&&(this._calculatedPrev=this._calculatedCurrent,this._calculatedCurrent=this._preallocatedVariable,this._calculatedNext={index:null,currentBreakProcessed:!1,value:null}),e}prevValue(){return this._calculatedPrev.value}currentValue(){return(0,s.ensureNotNull)(this._calculatedCurrent.value)}currentValueIsLast(){return(0,s.ensureNotNull)(this._calculatedCurrent.index)===this._items.length-1}currentValueIsFirst(){return 0===(0,s.ensureNotNull)(this._calculatedCurrent.index)}nextValue(){if(null!==this._calculatedNext.index)return this._calculatedNext.value;let e;this._calculatedNext={...this._calculatedCurrent,value:null};do{this._incrementPointer(this._calculatedNext),e=this._isValidPointer(this._calculatedNext),e?this._calcVaue(this._calculatedNext):this._calculatedNext.value=null}while(e&&this._skipHoles&&!p(this._calculatedNext.value));return this._calculatedNext.value}atStart(){return this._calculatedCurrent.index===this._firstIndexWithRange&&!this._calculatedCurrent.currentBreakProcessed}atEnd(){const e=(0,s.ensureNotNull)(this._calculatedCurrent.index);return e<this._lastIndexWithRange&&(this._calculatedCurrent.currentBreakProcessed||!this._needBreakBefore(e))}_needBreakBefore(e){return!!this._items[e].breakBefore&&!this._skipHoles}_calcVaue(e){const t=(0,s.ensureNotNull)(e.index);this._needBreakBefore(t)&&!e.currentBreakProcessed?e.value=_:e.value=this._items[t]}_incrementPointer(e){const t=(0,s.ensureNotNull)(e.index);this._needBreakBefore(t)&&!this._calculatedCurrent.currentBreakProcessed?e.currentBreakProcessed=!0:(e.index=t+1,e.currentBreakProcessed=!1)}_isValidPointer(e){const t=(0,s.ensureNotNull)(e.index);return t<this._lastIndexWithRange||t===this._lastIndexWithRange-1&&this._needBreakBefore(t)&&e.currentBreakProcessed}}class g extends c.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){
const t=(0,a.interactionTolerance)().series+this._data.lineWidth/2;let i=this._data.visibleItemsRange?.startItemIndex??0,s=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1;for(;s-i>2;){const t=Math.round((s+i)/2);this._data.items[t].center<=e.x?i=t:s=t}i=Math.max(1,i-1),s=Math.min(this._data.items.length-1,s+1);for(let a=i;a<=s;++a){const i=this._data.items[a-1],s=this._data.items[a],l=i.center,c=s.center;if((0,n.distanceToSegment)(new o.Point(l,i.y),new o.Point(c,s.y),new o.Point(e.x,e.y)).distance<=t)return this._data.hittest?this._data.hittest:new r.HitTestResult(r.HitTarget.Regular)}return null}_drawImpl(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;t.scale(i,s),t.lineCap="round",t.lineJoin="round",(0,h.applyColor)(e,this._data.lineColor,0,3),t.lineWidth=this._data.lineWidth,(0,l.setLineStyle)(t,this._data.lineStyle),(0,a.setValidLineStyle)(t,this._data.lineStyle),this._data.simpleMode?this._drawSimpleMode(e):this._drawLines(t)}_drawSimpleMode(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;t.beginPath(),this._walkLine(t,this._data.items,!1,NaN),t.stroke();const o=this._data.lineWidth+2;if(this._data.withMarkers&&2*o<this._data.barSpacing){t.scale(1/i,1/s),(0,h.applyColor)(e,this._data.lineColor,1,2);const n=Math.max(1,Math.floor(i))%2/2,r=o*s+n,a=2*Math.PI;t.beginPath();const l=this._data.visibleItemsRange?.startItemIndex??0;for(let e=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1+1;e-- >=l;){const o=this._data.items[e];if(o){const e=Math.round(o.center*i)+n,l=o.y*s;t.moveTo(e,l),t.arc(e,l,r,0,a)}}t.fill()}}_walkLine(e,t,i,s,o,n,r){if(!t)return{distance:0,dashPattern:[]};const a=.25*this._data.barSpacing;let l,c,h=null;const _=o?0:this._data.visibleItemsRange?.startItemIndex??0,g=o?t.length:Math.min(this._data.visibleItemsRange?.endItemIndex??t.length,t.length);if(_>g||_>=t.length)return{distance:0,dashPattern:[]};if(!n){const{distance:n,dashPattern:a}=this._walkLine(e,t,i,s,o,!0,r),l=(0,d.sum)(a);if(l>0){const t=n%l;e.lineDashOffset=l-t-a[1]}}const f=new u.SmartDashCanvas(e,!!n,r),y=new m(t,_,g,this._data.skipHoles);for(;y.next();){if(l=y.currentValue(),c=y.nextValue(),p(l)){const e=Math.round(l.center);h&&p(h)?(f.lineTo(e,l.y),i&&!p(c)&&f.lineTo(e,s)):c&&p(c)?i?(y.atStart()||f.lineTo(e,s),f.lineTo(e,l.y)):f.moveTo(e,l.y):i?(y.atStart()||f.lineTo(e-a,s),f.lineTo(e-a,l.y),f.lineTo(e+a,l.y),f.lineTo(e+a,s)):(f.moveTo(e-a,l.y),f.lineTo(e+a,l.y))}h=l}return{distance:f.lastSegmentDistance(),dashPattern:f.lastSegmentDashPattern()}}_drawLines(e,t){if(!this._data.items.length||0===this._data.lineWidth)return{distance:0,dashPattern:[]};let i,s,o=null;const n=.25*this._data.barSpacing,r=new u.SmartDashCanvas(e,!!t);let a=0;if(!t){const{distance:t,dashPattern:i}=this._drawLines(e,!0),s=(0,d.sum)(i);if(s>0){const o=t%s;e.lineDashOffset=a=s-o-i[1]}}r.beginPath();const l=this._data.visibleItemsRange?.startItemIndex??0,c=this._data.visibleItemsRange?.endItemIndex??this._data.items.length;if(l>c||l>=this._data.items.length)return{distance:0,
dashPattern:[]};const h=this._data.items[l];h&&r.moveTo(h.center,h.y);let _,g=e.strokeStyle,f=e.lineWidth;const y=new m(this._data.items,l,c,this._data.skipHoles);for(;y.next();){let l,c,h;o=y.prevValue(),i=y.currentValue(),s=y.nextValue();let u=!1,m=!1,w=!1;if(p(i)&&(i.style&&!this._data.forceLineColor?(l=i.style.color,c=i.style.width,h=i.style.style):(l=this._data.lineColor,c=this._data.lineWidth,h=this._data.lineStyle),this._data.ignorePaletteLineWidth&&(c=this._data.lineWidth),m=h!==_,w=c!==f,u=l!==g||m||w),u){if(g=l,f=c,_=h,r.stroke(),r.beginPath(),!t){r.setStrokeStyle(l);const t=r.lastSegmentDistance(),i=r.lastSegmentDashPattern(),s=(0,d.sum)(i);if(s>0){const i=t%s;e.lineDashOffset=i+a}}if(r.setLineWidth(c),r.setLineStyle(h),p(o))r.moveTo(o.center,o.y);else{const e=i;r.moveTo(e.center,e.y)}}v=o,b=s,p(S=i)&&(p(v)?r.lineTo(S.center,S.y):b&&p(b)?r.moveTo(S.center,S.y):(r.moveTo(S.center-n,S.y),r.lineTo(S.center+n,S.y)))}var v,S,b;return r.stroke(),{distance:r.lastSegmentDistance(),dashPattern:r.lastSegmentDashPattern()}}}},20820:(e,t,i)=>{"use strict";i.d(t,{MediaCoordinatesPaneRenderer:()=>o});var s=i(27714);class o{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){}}},7793:(e,t,i)=>{"use strict";var s;i.d(t,{CachedContainer:()=>n,ObjectValuesCache:()=>r}),function(e){e[e.PurgeCachedContainerCacheIterations=3e3]="PurgeCachedContainerCacheIterations"}(s||(s={}));class o{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 n{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 o(this._items,this._actualLength,e,t)}}class r extends n{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]}}},86228:(e,t,i)=>{
"use strict";i.d(t,{RectangleRenderer:()=>_});var s,o=i(50151),n=i(10555),r=i(6453),a=i(2624),l=i(52859),c=i(2383),h=i(18330),d=i(58221),u=i(10307);!function(e){e[e.HitTestTolerance=3]="HitTestTolerance"}(s||(s={}));class _ extends u.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._forceOverrideTransparency=Boolean(e)}setData(e){this._data=e}hitTest(e,t){if(null===this._data||this._data.points.length<2||this._data.disableInteractions)return null;const i=t.mediaSize.width,s=(0,n.box)(...this._data.points),o=s.min,r=s.max,l=new n.Point(r.x,o.y),h=new n.Point(o.x,r.y),d=this._extendAndHitTestLineSegment(e,o,l,i);if(null!==d)return d;const u=this._extendAndHitTestLineSegment(e,h,r,i);if(null!==u)return u;let _=(0,a.distanceToSegment)(l,r,e);if(_.distance<=3)return new c.HitTestResult(c.HitTarget.MovePoint);if(_=(0,a.distanceToSegment)(o,h,e),_.distance<=3)return new c.HitTestResult(c.HitTarget.MovePoint);if(this._data.middleLine){const t=s.min.add(s.max).scaled(.5),o=this._extendAndHitTestLineSegment(e,new n.Point(s.min.x,t.y),new n.Point(s.max.x,t.y),i);if(null!==o)return o}return this._data.fillBackground?this._hitTestBackground(e,o,r,i):null}getColor(){const e=(0,o.ensure)(this._data);return void 0===e.transparency?e.backcolor:(0,l.generateColor)(e.backcolor,e.transparency,this._forceOverrideTransparency)}visibleRectSegment(e){const t=this._data;if(null===t)return null;const i=(0,n.box)(...t.points),s=i.min,o=i.max,r=e.width,a=e.height,l=t.extendLeft?0:Math.max(s.x,0),c=t.extendRight?r:Math.min(o.x,r);if(l>c||c<=0||l>=r)return null;const h=Math.max(s.y,0),d=Math.min(o.y,a);return h>d||d<=0||h>a?null:[new n.Point(l,h),new n.Point(c,d)]}_drawImpl(e){if(null===this._data||this._data.points.length<2||this._data.linewidth<=0&&!this._data.fillBackground)return;const{horizontalPixelRatio:t,verticalPixelRatio:i,bitmapSize:s}=e,{extendLeft:o,extendRight:r,linewidth:a,middleLine:l}=this._data,c=(0,n.box)(...this._data.points),u=this._data.linewidth?Math.max(1,Math.floor(this._data.linewidth*t)):0,_=this._data.fillBackground?this.getColor():void 0,p=Math.max(1,Math.floor(t)),m=o?-a:Math.round(c.min.x*t),g=r?s.width+a:Math.round(c.max.x*t),f=Math.round(c.min.y*i),y=Math.round(c.max.y*i);(0,d.fillRectWithBorder)(e,m,f,g,y,p,void 0===_?void 0:{color:_},0===u?void 0:{color:this._data.color,lineStyle:this._data.linestyle??h.LineStyle.Solid,borderWidth:u,borderMode:"center",rightToLeftStroke:o&&!r},l?{...l,lineWidth:Math.max(1,Math.floor(l.lineWidth*i))}:void 0)}_extendAndHitTestLineSegment(e,t,i,s){const o=this._extendAndClipLineSegment(t,i,s);if(null!==o){if((0,a.distanceToSegment)(o[0],o[1],e).distance<=3)return new c.HitTestResult(c.HitTarget.MovePoint)}return null}_extendAndClipLineSegment(e,t,i){const s=(0,o.ensureNotNull)(this._data);if((0,n.equalPoints)(e,t)&&!s.extendLeft&&!s.extendRight)return null;const r=Math.min(e.x,t.x),a=Math.max(e.x,t.x),l=s.extendLeft?0:Math.max(r,0),c=s.extendRight?i:Math.min(a,i);return l>c||c<=0||l>=i?null:[new n.Point(l,e.y),new n.Point(c,t.y)]}
_hitTestBackground(e,t,i,s){const o=this._extendAndClipLineSegment(t,i,s);return null!==o&&(0,r.pointInBox)(e,(0,n.box)(o[0],o[1]))?new c.HitTestResult(this._data?.backgroundHitTarget??c.HitTarget.MovePointBackground):null}}},87347:(e,t,i)=>{"use strict";i.d(t,{svgRenderer:()=>x});var s=i(50151),o=i(9343);const n=(0,o.getLogger)("Chart.SvgParser");function r(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<t)return null;s+=1}return i}const a=/([a-zA-Z]+)\((.*)\)/g;function l(e,t){const i=e.getAttribute("transform")?.toLowerCase();if(void 0===i)return null;const s=[];let o;a.lastIndex=0;do{if(o=a.exec(i),null!==o){const e=o[1],i=o[2];switch(e){case"matrix":const o=r(i,6);null!==o&&s.push({type:e,a:o[0],b:o[1],c:o[2],d:o[3],e:o[4],f:o[5]});break;case"rotate":const a=r(i,1);null!==a&&s.push({type:e,a:a[0],x:a[1]??(t?t.width/2:void 0),y:a[2]??(t?t.height/2:void 0)});break;case"translate":const l=r(i,1);null!==l&&s.push({type:e,x:l[0],y:l[1]});break;case"scale":const c=r(i,1);null!==c&&s.push({type:e,x:c[0],y:c[1]});break;default:n.logWarn(`Unsupported transform operation: ${e}`)}}}while(null!==o);return 0===s.length?null:s}function c(e,t){for(const i of t)switch(i.type){case"matrix":e.transform(i.a,i.b,i.c,i.d,i.e,i.f);break;case"rotate":void 0!==i.x&&void 0!==i.y&&e.translate(i.x,i.y),e.rotate(i.a*Math.PI/180),void 0!==i.x&&void 0!==i.y&&e.translate(-i.x,-i.y);break;case"scale":e.scale(i.x,i.y??i.x);break;case"translate":e.translate(i.x,i.y??0)}}function h(e,t){return parseFloat(e.getAttribute(t)??"")}const d=/^url\(#(.*)\)/;function u(e){return d.exec(e)?.[1]??null}function _(e,t,i){const o={},n=e.getAttribute("fill");if(null!==n){const e=u(n);o.getFillStyle=null!==e?i=>(0,s.ensureDefined)(t.getStyle(e,i)):e=>n}const r=e.getAttribute("stroke");if(null!==r){const e=u(r);o.getStrokeStyle=null!==e?i=>(0,s.ensureDefined)(t.getStyle(e,i)):e=>r}const a=h(e,"stroke-width");Number.isFinite(a)&&(o.strokeWidth=a);const c=h(e,"opacity");Number.isFinite(c)&&(o.fillOpacity=c,o.strokeOpacity=c);const d=h(e,"stroke-opacity");Number.isFinite(d)&&(o.strokeOpacity=d);const _=h(e,"fill-opacity");if(Number.isFinite(_)&&(o.fillOpacity=_),i){const t=l(e);null!==t&&(o.transform=t)}return o}class p{constructor(e){this._transformOperations=e}apply(e,t){null!==this._transformOperations?(e.save(),c(e,this._transformOperations)):e.restore()}}class m{constructor(e,t,i){this._styleData={...i,..._(e,t,!0)}}apply(e,t){if(!this._isValid())return;const{getFillStyle:i,getStrokeStyle:s,strokeWidth:o,transform:n,strokeOpacity:r,fillOpacity:a}=this._styleData,l=void 0!==n||void 0!==r||void 0!==a;l&&(e.save(),void 0!==n&&c(e,n)),this._render(e);const h=i?.(e);"none"!==h&&(t.doNotApplyColors||(void 0!==a&&(e.globalAlpha=a),e.fillStyle=h??"black"),this._fill(e));const d=s?.(e);void 0!==d&&"none"!==d&&(void 0!==o&&(e.lineWidth=o),t.doNotApplyColors||(void 0!==a&&(e.globalAlpha=a),e.strokeStyle=d),this._stroke(e)),l&&e.restore()}_fill(e){e.fill()}_stroke(e){e.stroke()}}class g extends m{
constructor(e,t,i){super(e,t,i);const s=e.getAttribute("d");this._path=null!==s?new Path2D(s):null,this._fillRule=e.getAttribute("fill-rule")??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 f extends m{constructor(e,t,i){super(e,t,i),this._cx=h(e,"cx"),this._cy=h(e,"cy"),this._r=h(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 y extends m{constructor(e,t,i){super(e,t,i),this._cx=h(e,"cx"),this._cy=h(e,"cy"),this._rx=h(e,"rx"),this._ry=h(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 v{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 S=(0,o.getLogger)("Chart.SvgParser");function b(e){const t=e.getAttribute("gradientUnits");if("objectBoundingBox"===t)return void S.logWarn(`Unsupported linearGradient gradientUnits: ${t}`);const i=[],s=e.getElementsByTagName("stop");for(let e=0;e<s.length;++e){const t=s[e],o=h(t,"offset"),n=t.getAttribute("stop-color");null!==n&&i.push([Number.isFinite(o)?o:0,n])}const o=h(e,"x1"),n=h(e,"y1"),r=h(e,"x2"),a=h(e,"y2");return e=>{const t=e.createLinearGradient(o,n,r,a);for(const e of i)t.addColorStop(e[0],e[1]);return t}}const w=(0,o.getLogger)("Chart.SvgParser");const C=new DOMParser,T=(0,o.getLogger)("Chart.SvgParser");function P(e,t,i,s,o,n){const r=e.children;let a,c=n;"g"!==e.tagName&&"svg"!==e.tagName||(c={...c,..._(e,o,!1)},a=l(e,{width:i,height:s})??void 0),void 0!==a&&t.push(new p(a));for(let e=0;e<r.length;++e){const n=r[e];"defs"!==n.tagName&&P(n,t,i,s,o,c)}switch(void 0!==a&&t.push(new p(null)),e.tagName){case"g":case"svg":case"defs":break;case"path":t.push(new g(e,o,n));break;case"circle":t.push(new f(e,o,n));break;case"ellipse":t.push(new y(e,o,n));break;default:T.logWarn(`Unsupported tag name: ${e.tagName}`)}}function x(e){const t=C.parseFromString(e,"application/xml"),i=[],o=t.getElementsByTagName("svg")[0],n=(0,s.ensureNotNull)(o.getAttribute("viewBox")).split(" ").map(parseFloat),r=n[2],a=n[3],l={x:n[0],y:n[1],width:r,height:a};i.push(new v(l));let c={getStyle:()=>{}};const h=o.getElementsByTagName("defs");return h.length>0&&(c=function(e){const t={},i=e.children;for(let e=0;e<i.length;++e){const s=i[e],o=s.getAttribute("id");o&&("linearGradient"===s.tagName?t[o]=b(s):w.logWarn(`Unsupported defs tag: ${s.tagName}`))}const s=new WeakMap;return{getStyle:(e,i)=>{const o=t[e];if(!o)return;let n=s.get(i);void 0===n&&(n=new Map,s.set(i,n));const r=n.get(e)
;if(void 0!==r)return r;const a=o(i);return n.set(e,a),a}}}(h[0])),P(o,i,r,a,c),{viewBox:()=>l,render:(e,t)=>{e.save();for(const s of i)s.apply(e,t);e.restore()}}}},85565:(e,t,i)=>{"use strict";i.d(t,{SmartDashCanvas:()=>l});var s=i(50151),o=i(10555),n=i(4539),r=i(69558),a=i(58221);class l{constructor(e,t,i){this._lastSegmentDistance=0,this._lastLineWidth=-1,this._lastLineStyle=-1,this._ctx=e,this._calculateOnly=t,this._lastDashPattern=e.getLineDash(),this._lastPoint=i??null}beginPath(){this._calculateOnly||this._ctx.beginPath()}stroke(){this._calculateOnly||this._ctx.stroke()}fill(){this._calculateOnly||this._ctx.fill()}lastSegmentDistance(){return this._lastSegmentDistance}lastSegmentDashPattern(){return this._lastDashPattern}lastLineWidth(){return this._lastLineWidth}moveTo(e,t){this._lastPoint=(0,o.point)(e,t),this._calculateOnly||this._ctx.moveTo(e,t)}lineTo(e,t){const i=(0,s.ensureNotNull)(this._lastPoint),n=i.x-e,r=i.y-t;this._lastSegmentDistance+=Math.sqrt(n*n+r*r),this._calculateOnly||this._ctx.lineTo(e,t),this._lastPoint=(0,o.point)(e,t)}setLineWidth(e){this._lastLineWidth!==e&&(this._lastLineWidth=e,this._lastDashPattern=this._lastLineStyle===r.LINESTYLE_SOLID?[]:(0,a.computeDashPattern)(e,this._lastLineStyle),this._calculateOnly||(this._ctx.lineWidth=e,this._lastLineStyle>=0&&(0,n.setValidLineStyle)(this._ctx,this._lastLineStyle)))}setLineStyle(e){this._lastLineStyle!==e&&(this._lastLineStyle=e??this._lastLineStyle),void 0!==e&&this._lastLineWidth>0&&(this._lastDashPattern=e===r.LINESTYLE_SOLID?[]:(0,a.computeDashPattern)(this._lastLineWidth,e)),this._calculateOnly||(0,n.setValidLineStyle)(this._ctx,e)}setStrokeStyle(e){this._calculateOnly||(this._ctx.strokeStyle=e)}context(){return this._ctx}}},97760:(e,t,i)=>{"use strict";var s;i.d(t,{StatsPosition:()=>s}),function(e){e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e[e.Auto=3]="Auto"}(s||(s={}))},60876:(e,t,i)=>{"use strict";i.d(t,{PaneRendererStepLine:()=>v,StepLineDecoration:()=>s});var s,o,n=i(2624),r=i(10555),a=i(2383),l=i(4539),c=i(58221),h=i(10307),d=i(79268),u=i(4699),_=i(85565),p=i(12217);!function(e){e[e.None=0]="None",e[e.Diamonds=1]="Diamonds"}(s||(s={})),function(e){e[e.SmallDiamondsSize=8]="SmallDiamondsSize",e[e.SmallDiamondsRadius=2]="SmallDiamondsRadius",e[e.LargeDiamondsSize=21]="LargeDiamondsSize",e[e.LargeDiamondsRadius=5]="LargeDiamondsRadius",e[e.LargeDiamondsAlpha=.15]="LargeDiamondsAlpha",e[e.LeftUnplottableXCoord=-50]="LeftUnplottableXCoord"}(o||(o={}));class m{constructor(e){this._forceExtendFirstBar=!!e}initialize(e,t,i,s){const{context:o,horizontalPixelRatio:n,verticalPixelRatio:r}=i,a=t.lineStyle;o.lineCap="butt",o.lineJoin="round";const l=Math.max(Math.floor(s.style?.width??t.lineWidth*n));e.setLineStyle(a);const c=l%2?.5:0;e.moveTo(Math.round(s.center*n)+c,Math.round(s.y*r)+c),(0,u.applyColor)(i,s.style?.color??t.lineColor,1,1),e.setLineWidth(l)}startFragment(e,t,i,s,o){e.beginPath();const n=s.firstItem&&s.extendToBarsEndings?i.center:i.left;e.moveTo(isNaN(n)?-50:n,o?.y??i.y)}finishFragment(e,t,i,s){
i&&s&&e.lineTo(i.left,s.y),e.stroke()}hitTest(e,t,i,s){if(!(0,d.isValidPoint)(t))return!1;const o=t.style?.width??e.lineWidth,a=(0,l.interactionTolerance)().series+o/2,{left:c,y:h}=t,u=isNaN(c)?-50:c;let _,p;return i&&(0,d.isValidPoint)(i)?(_=i.left,p=i.y):(_=t.right,p=t.y),!(u<s.x-a&&_<s.x-a||u>s.x+a&&_>s.x+a)&&((0,n.distanceToSegment)((0,r.point)(u,h),(0,r.point)(_,h),s).distance<a||h!==p&&(0,n.distanceToSegment)((0,r.point)(_,h),(0,r.point)(_,p),s).distance<a)}applyColor(e,t){(0,u.applyColor)(e,t,1,1)}applyLineWidth(e,t,i){e.setLineWidth(i)}applyLineStyle(e,t,i){e.setLineStyle(i)}drawItem(e,t,i,s,o){void 0!==o&&e.lineTo(i.left,o.y),e.lineTo(!s.firstItem||s.extendToBarsEndings||this._forceExtendFirstBar?i.left:i.center,i.y),e.lineTo(s.lastItem&&!s.extendToBarsEndings?i.center:i.right,i.y)}needDashOffset(){return!0}}class g{constructor(){this._lineWidth=1,this._initialAlpha=1}initialize(e,t,i,s){this._initialAlpha=i.context.globalAlpha,this.applyColor(i,s.style?.color??t.lineColor),this._lineWidth=Math.max(Math.floor(s.style?.width??t.lineWidth*i.horizontalPixelRatio))}startFragment(e,t,i,s,o){e.beginPath()}finishFragment(e,t){t.fill()}drawItem(e,t,i,s,o){if(s.valIsNotSameAsPrev&&!isNaN(i.left)){const e=t.context;e.save(),e.translate(i.left,i.y),e.rotate(Math.PI/4);const s=this._scaleByLineWidth(this._lineWidth);e.scale(s,s),this._drawItemRotatedAndTranslated(t),e.restore()}}applyLineWidth(e,t,i){this._lineWidth=i}applyLineStyle(e,t,i){}hitTest(e,t,i,s){if(!t.valIsNotSameAsPrev)return!1;const o=s.subtract((0,r.point)(t.left,t.y));return this._hitTestTranslated(o,t.style?.width??e.lineWidth)}needDashOffset(){return!1}_scaleByLineWidth(e){return Math.sqrt(e)}}class f extends g{applyColor(e,t){(0,u.applyColor)(e,t,1,2)}_hitTestTranslated(e,t){return Math.abs(e.x)+Math.abs(e.y)<8*this._scaleByLineWidth(t)/2}_drawItemRotatedAndTranslated(e){(0,c.drawRoundRect)(e.context,-4,-4,8,8,2,!0)}}class y extends g{applyColor(e,t){e.context.globalAlpha=.15*this._initialAlpha,(0,u.applyColor)(e,t,1,2)}_hitTestTranslated(e,t){return Math.abs(e.x)+Math.abs(e.y)<21*this._scaleByLineWidth(t)/2}_drawItemRotatedAndTranslated(e){(0,c.drawRoundRect)(e.context,-10.5,-10.5,21,21,5,!0)}}class v extends h.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=null,this._data=e??null}setData(e){this._data=e}hitTest(e){const t=this._data;if(null===t||0===t.items.length)return null;const{items:i,visibleItemsRange:o,skipHoles:n}=t,r=o?.startItemIndex??0,l=o?.endItemIndex??i.length;if(l<=r)return null;const c=t.decoration===s.Diamonds?[new m,new y]:[new m];const h=new d.PaneRendererLineItemsIterator(i,r,l,n);for(;h.next();){const i=h.currentValue(),s=h.nextValue();for(const o of c)if((0,d.isValidPoint)(i)&&o.hitTest(t,i,(0,d.isValidPoint)(s)?s:null,e))return new a.HitTestResult(a.HitTarget.Regular)}return null}_drawImpl(e){if(null===this._data||0===this._data.items.length)return;(this._data.decoration===s.Diamonds?[new m(!0),new f,new y]:[new m]).forEach((t=>this._drawDecorationItem(e,t)))}_drawDecorationItem(e,t,i){
if(null===this._data||0===this._data.items.length)return{distance:0,dashPattern:[]};const{lineWidth:s,lineColor:o,lineStyle:n,items:r,visibleItemsRange:a,skipHoles:l,extendToBarsEndings:c}=this._data,{context:h,horizontalPixelRatio:u,verticalPixelRatio:m}=e;let g=!1,f=Math.max(Math.floor((r[0].style?.width??s)*u)),y=f%2?.5:0;const v=a?.startItemIndex??0,S=a?.endItemIndex??r.length;if(S<=v)return{distance:0,dashPattern:[]};const b=new _.SmartDashCanvas(h,!!i);let w,C,T,P,x=0;if(!i&&t.needDashOffset()){const{distance:i,dashPattern:s}=this._drawDecorationItem(e,t,!0),o=(0,p.sum)(s);if(o>0){const e=i%o;h.lineDashOffset=x=o-e-s[1]}}t.initialize(b,this._data,e,r[0]),t.applyColor(e,r[v].style?.color??o),t.applyLineWidth(b,h,f),t.applyLineStyle(b,h,n);let M=!1;const I=new d.PaneRendererLineItemsIterator(r,v,S,l);for(;I.next();){const r=I.currentValue();if(!(0,d.isValidPoint)(r)){w=void 0,M=!0;continue}const a=r.style?.color??o,l=r.style?.width??s,_=r.style?.style??n,v=a!==C,S=l!==T,A=_!==P,L={firstItem:I.currentValueIsFirst(),lastItem:I.currentValueIsLast(),extendToBarsEndings:c,valIsNotSameAsPrev:r.valIsNotSameAsPrev},k={y:Math.round(r.y*m)+y,left:Math.round(r.left*u)+y,center:Math.round(r.center*u)+y,right:Math.round(r.right*u)+y};if(v||S||M||A){if(C&&T&&g&&(t.finishFragment(b,h,k,w),g=!1),v&&t.applyColor(e,a),S&&(f=Math.max(1,Math.floor(l*u)),y=f%2?.5:0,t.applyLineWidth(b,h,f)),A&&t.applyLineStyle(b,h,_),!i){const e=b.lastSegmentDistance(),t=b.lastSegmentDashPattern(),i=(0,p.sum)(t);if(i>0){const t=e%i;h.lineDashOffset=t+x}}t.startFragment(b,h,k,L,w),g=!0,M=!1,C=a,T=l,P=_}t.drawItem(b,e,k,L,w),w=k}return g&&(t.finishFragment(b,h),g=!1),{distance:b.lastSegmentDistance(),dashPattern:b.lastSegmentDashPattern()}}}},4753:(e,t,i)=>{"use strict";i.d(t,{TextRenderer:()=>k,calculateLabelPosition:()=>m,fontSize:()=>M,getTextAlignInBox:()=>L,getTextBoundaries:()=>g,lineSpacing:()=>x,needTextExclusionPath:()=>f,wordWrap:()=>S});var s=i(10555),o=i(50151),n=i(6453),r=i(24640),a=i(50605),l=i(2383),c=i(58221),h=i(73041),d=i(87465),u=i(33350),_=i(12217),p=i(57658);function m(e,t,i,o,n){const r=.5*(t.x+i.x);let a=i.y;return t.y>i.y?(a-=e.height/2+o.y,a=Math.max(e.height/2,a)):(a+=e.height/2+o.y,a=Math.min(n-e.height/2,a)),new s.Point(r,a)}function g(e,t,i){if(e.isOutOfScreen(t,i))return null;const s=e.getPolygonPoints();return 0===s.length?null:s}function f(e){const t=e.getLinesInfo().lines;if(t.length%2==0)return!1;if(""===t[Math.floor(t.length/2)].text.trim())return!1;return!0}function y(e){const t=[];do{const i=e.match(/\s+/);if(!i||void 0===i.index||-1===i.index){t.push({word:e,spaces:""});break}t.push({word:e.slice(0,i.index),spaces:i[0]}),e=e.slice(i.index+i[0].length)}while(e.length);return t}function v(e,t,i,s){const o=[],n=[];for(let t=0;t<e.length;++t)n.push(t);for(;e.length;){const r=Math.max(1,(0,_.upperbound)(n,s,((s,o)=>(0,u.measureText)(e.slice(0,o+1),t,i).width>s),0,e.length));o.push(e.slice(0,r)),e=e.slice(r)}return o}function S(e,t,i,s=!0,o){o=(0,d.isString)(o)?parseInt(o):o
;const n=(e+="").split(/\r\n|\r|\n|$/).map((e=>({text:e,hidden:!1,wrappedLinePart:!1,wrappedLineEnd:!1})));if(!(0,d.isNumber)(o)||!isFinite(o)||o<=0)return n;if((0,u.measureText)("x",t,i).width>o)return n;const r=[];for(let e=0;e<n.length;e++){const a=n[e];if((0,u.measureText)(a.text,t,i).width<=o){r.push(a);continue}const l=y(a.text),c=!0;let h="",d=0;for(;d<l.length;){const e=l[d];let n=`${h}${e.word}`,a=(0,u.measureText)(n,t,i).width;if(a>o){if(""!==h)r.push({text:h,hidden:!1,wrappedLinePart:c,wrappedLineEnd:!1}),h="";else if(1===n.length)r.push({text:n,hidden:!1,wrappedLinePart:c,wrappedLineEnd:!0}),e.word="";else{const s=v(n,t,i,o);for(let e=0;e<s.length-1;e+=1)r.push({text:s[e],hidden:!1,wrappedLinePart:c,wrappedLineEnd:!1});e.word=s[s.length-1]}continue}let _=n.length;if(n=`${h}${e.word}${e.spaces}`,a=(0,u.measureText)(n,t,i).width,a<o){h=n,d+=1;continue}const p=v(n,t,i,o);for(let e=0;e<p.length;e+=1){const t=p[e];_-=t.length;const i={text:t,hidden:e>0,wrappedLinePart:c,wrappedLineEnd:d===l.length-1&&e===p.length-1};i.hidden&&s||r.push(i)}h="",d+=1}""!==h&&r.push({text:h,wrappedLinePart:c,hidden:!1,wrappedLineEnd:!0})}return r}function b(e,t,i){if(0===i)return e.clone();const o=(e.x-t.x)*Math.cos(i)-(e.y-t.y)*Math.sin(i)+t.x,n=(e.x-t.x)*Math.sin(i)+(e.y-t.y)*Math.cos(i)+t.y;return(0,s.point)(o,n)}function w(e){return void 0!==e.boxPaddingVert?e.boxPaddingVert*A(e):void 0!==e.boxPadding?e.boxPadding*A(e):M(e)/3}function C(e){return void 0!==e.boxPaddingHorz?e.boxPaddingHorz*A(e):void 0!==e.boxPadding?e.boxPadding*A(e):M(e)/3}function T(e){return void 0!==e.boxPaddingLeft?e.boxPaddingLeft*A(e):C(e)}function P(e){return void 0!==e.boxPaddingRight?e.boxPaddingRight*A(e):C(e)}function x(e){let t=e.lineSpacing;return void 0===t&&e.lineHeight&&(t=(e.lineHeight-1)*I(e)),(t??0)*A(e)}function M(e){return Math.ceil(I(e)*A(e))}function I(e){return e.fontsize||e.fontSize||30}function A(e){const t=Math.min(1,Math.max(.2,e.scale||1));if(1===t)return t;const i=I(e);return Math.ceil(t*i)/i}function L(e){const{horzAlign:t,extendLeft:i=!1,extendRight:o=!1,width:n,leftPoint:r,rightPoint:l}=e,c=(r.x<=n||i)&&(l.x>=0||o);let h,d,u=t;switch(u){case a.HorizontalAlign.Left:d=r.y,i?h=c?0:l.x:(h=r.x,u=a.HorizontalAlign.Right);break;case a.HorizontalAlign.Right:d=l.y,o?h=c?n:r.x:(h=l.x,u=a.HorizontalAlign.Left);break;default:h=((i&&c?0:r.x)+(o&&c?n:l.x))/2,d=(r.y+l.y)/2;break}return[(0,s.point)(h,d),u]}class k{constructor(e,t){this._data=null,this._textWidthCache=new p.TextWidthCache,this._internalData=null,this._boxSize=null,this._box=null,this._polygonPoints=null,this._linesInfo=null,this._fontInfo=null,this._centerTextRotationPoint=null,this._rotationPoint=null,this._hitTest=t||new l.HitTestResult(l.HitTarget.MovePoint,{areaName:l.AreaName.Text}),void 0!==e&&this.setData(e)}setHitTest(e){this._hitTest=e}data(){return this._data}updateData(e){this.setData({...(0,o.ensureNotNull)(this._data),...e})}setData(e){null!==e?((0,o.assert)(!e.decorator||void 0===e.wordWrapWidth,"Decorator is not supported with wordWrapWidth"),
void 0===e.text&&(e.text=""),e.horzTextAlign||(e.horzTextAlign=e.horzAlign),!function(e,t){if(null===e||null===t)return null===e==(null===t);if(void 0===e.points!=(void 0===t.points))return!1;if(void 0!==e.points&&void 0!==t.points){if(e.points.length!==t.points.length)return!1;for(let o=0;o<e.points.length;++o)if(i=e.points[o],s=t.points[o],i.x!==s.x||i.y!==s.y)return!1}var i,s;return e.text===t.text&&e.decorator===t.decorator&&e.vertAlign===t.vertAlign&&e.horzAlign===t.horzAlign&&e.horzTextAlign===t.horzTextAlign&&e.font===t.font&&e.offsetX===t.offsetX&&e.offsetY===t.offsetY&&e.bold===t.bold&&e.italic===t.italic&&e.fontsize===t.fontsize&&e.fontSize===t.fontSize&&e.backgroundRoundRect===t.backgroundRoundRect&&e.forceTextAlign===t.forceTextAlign&&e.wordWrapWidth===t.wordWrapWidth&&e.forceCalculateMaxLineWidth===t.forceCalculateMaxLineWidth&&e.lineHeight===t.lineHeight&&e.lineSpacing===t.lineSpacing&&e.scale===t.scale&&e.boxPadding===t.boxPadding&&e.boxPaddingVert===t.boxPaddingVert&&e.boxPaddingLeft===t.boxPaddingLeft&&e.boxPaddingRight===t.boxPaddingRight&&e.boxPaddingHorz===t.boxPaddingHorz&&e.angle===t.angle&&e.maxHeight===t.maxHeight&&e.outlineBorder?.width===t.outlineBorder?.width&&e.outlineBorder?.color===t.outlineBorder?.color}(this._data,e)?(this._data=e,this._internalData=null,this._boxSize=null,this._polygonPoints=null,this._centerTextRotationPoint=null,this._rotationPoint=null,this._linesInfo=null,this._fontInfo=null,this._box=null):this._data=e):this._data=null}hitTest(e){return null===this._data||void 0===this._data.points||0===this._data.points.length?null:(0,n.pointInPolygon)(e,this.getPolygonPoints())?this._hitTest:null}doesIntersectWithBox(e){return null!==this._data&&void 0!==this._data.points&&0!==this._data.points.length&&(0,n.pointInBox)(this._data.points[0],e)}measure(){if(null===this._data)return{boxWidth:0,boxHeight:0,width:0,height:0};const e=this._getBoxSize();return{boxWidth:e.boxWidth,boxHeight:e.boxHeight,width:e.textBoxWidth,height:e.textBoxHeight}}rect(){if(null===this._data)return{x:0,y:0,width:0,height:0};const{boxLeft:e,boxTop:t,boxWidth:i,boxHeight:s}=this._getBox();return{x:e,y:t,width:i,height:s}}isOutOfScreen(e,t){if(null===this._data||void 0===this._data.points||0===this._data.points.length)return!0;const{boxLeft:i,boxWidth:o}=this._getBox();if(i+o<0||i>e){const i=(0,s.box)((0,s.point)(0,0),(0,s.point)(e,t));return this.getPolygonPoints().every((e=>!(0,n.pointInBox)(e,i)))}return!1}setPoints(e,t){(0,o.ensureNotNull)(this._data).points=e,this._hitTest=t||new l.HitTestResult(l.HitTarget.MovePoint)}setPoint(e,t,i){const s=(0,o.ensureNotNull)(this._data);this.setData({...s,points:[e],offsetX:t??s.offsetX,offsetY:i??s.offsetY})}point(){return this._data?.points?.[0]??null}fontStyle(e){return null===this._data?"":this._getFontInfo().fontStyle}lineHeight(){return null===this._data?0:M(this._data)}lineSpacing(){return null===this._data?0:x(this._data)}draw(e,t){if(null===this._data||void 0===this._data.points||0===this._data.points.length)return
;const{mediaSize:i,horizontalPixelRatio:n,verticalPixelRatio:r}=t;if(this.isOutOfScreen(i.width,i.height))return;const a=this._getInternalData(),l=(0,o.ensureNotNull)(this.rotation()),h=(0,s.point)(l.x*n,l.y*r);e.save(),0!==l.angle&&(e.translate(h.x,h.y),e.rotate(l.angle),e.translate(-h.x,-h.y));const d=this._getFontInfo().fontSize;e.textBaseline=a.textBaseLine,e.textAlign=a.textAlign,e.font=this.fontStyle();const{scaledLeft:_,scaledRight:p,scaledTop:m,scaledBottom:g}=function(e,t){const{horizontalPixelRatio:i,verticalPixelRatio:s}=t,o=Math.round(e.boxLeft*i),n=Math.round(e.boxTop*s);return{scaledLeft:o,scaledRight:o+Math.round(e.boxWidth*i),scaledTop:n,scaledBottom:n+Math.round(e.boxHeight*s)}}(a,t),f=this._data.borderWidth||Math.max(d/12,1),y=Math.round(f*n),v=y/2;if(this._data.backgroundColor||this._data.borderColor){let t=!1;if(this._data.boxShadow){e.save();const{shadowColor:i,shadowBlur:s,shadowOffsetX:o=0,shadowOffsetY:a=0}=this._data.boxShadow;e.shadowColor=i,e.shadowBlur=s*n,e.shadowOffsetX=o*n,e.shadowOffsetY=a*r,t=!0}if(this._data.backgroundRoundRect){const{borderColor:i,backgroundColor:s,backgroundRoundRect:o}=this._data;s&&((0,c.drawRoundRect)(e,_,m,p-_,g-m,o*n),e.closePath(),e.fillStyle=s,e.fill(),t&&(e.restore(),t=!1)),i&&((0,c.drawRoundRect)(e,_-v,m-v,p-_+y,g-m+y,o*n+y),e.closePath(),e.strokeStyle=i,e.lineWidth=y,e.stroke(),t&&e.restore())}else{const{borderColor:i,backgroundColor:s}=this._data;s&&(e.fillStyle=s,e.fillRect(_,m,p-_,g-m),t&&(e.restore(),t=!1)),i&&(e.strokeStyle=i,e.lineWidth=y,e.beginPath(),e.moveTo(_-v,m-v),e.lineTo(_-v,g+v),e.lineTo(p+v,g+v),e.lineTo(p+v,m-v),e.lineTo(_-v,m-v),e.closePath(),e.stroke(),t&&e.restore())}}this._drawSelectionIfNeeded(e,t),e.fillStyle=this._data.color;const S=(_+Math.round(a.textHorizStart*n))/n,b=.05*d;let w=(m+Math.round((a.textVertStart+b)*r))/r;const C=x(this._data),T=this.getLinesInfo();for(const t of T.lines)(0,u.drawScaled)(e,n,r,(()=>e.fillText(t.text,S,w))),w+=d+C;if(this._data.decorator?.draw(e,t,this._data,a),this._data.outlineBorder){const{outlineBorder:{width:t,color:i}}=this._data,s=Math.round(t*n),o=this._data.borderColor?y:0,r={x:_-o,y:m-o,w:p-_+2*o,h:g-m+2*o},a=new Path2D;a.rect(r.x-s,r.y-s,r.w+2*s,r.h+2*s),a.rect(r.x,r.y,r.w,r.h),e.fillStyle=i,e.fill(a,"evenodd")}e.restore()}getPolygonPoints(){if(null!==this._polygonPoints)return this._polygonPoints;if(null===this._data)return[];const e=this._data.angle||0,{boxLeft:t,boxTop:i,boxWidth:o,boxHeight:n}=this._getBox(),r=this._getRotationPoint();return this._polygonPoints=[b((0,s.point)(t,i),r,e),b((0,s.point)(t+o,i),r,e),b((0,s.point)(t+o,i+n),r,e),b((0,s.point)(t,i+n),r,e)],this._polygonPoints}centerTextRotation(){if(null===this._centerTextRotationPoint&&null!==this._data){const e=this._data.angle??0,t=this._getRotationPoint(),{textLeft:i,textTop:o,textRight:n,textBottom:r}=this._getInternalData(),a=b((0,s.point)((i+n)/2,(o+r)/2),t,e);this._centerTextRotationPoint={x:a.x,y:a.y,angle:e}}return this._centerTextRotationPoint}rotation(){if(null===this._rotationPoint&&null!==this._data){
const e=this._data.angle??0,t=this._getRotationPoint();this._rotationPoint={x:t.x,y:t.y,angle:e}}return this._rotationPoint}getLinesInfo(){if(null===this._linesInfo){const e=(0,o.ensureNotNull)(this._data),t=S(e.text,this.fontStyle(),this._textWidthCache,!1,e.wordWrapWidth);let i=t.filter((e=>!e.hidden));if(void 0!==e.maxHeight){const t=function(e){const t=(0,o.ensureDefined)(e.maxHeight),i=M(e),s=x(e);return Math.floor((t+s)/(i+s))}(e);i.length>t&&(i=i.slice(0,t))}this._linesInfo={linesMaxWidth:this._getLinesMaxWidth(i),linesIncludingHidden:t,lines:i}}return this._linesInfo}positionToCoordinate(e){const t=(0,o.ensureNotNull)(this._data),i=this._getInternalData(),s=this.getLinesInfo(),{x:n,y:r,lineNumber:a}=(0,h.getSymbolCoordinatesInfo)({symbolPosition:e,textWidth:i.textRight-i.textLeft,textByLines:s.linesIncludingHidden,lineHeight:M(t),font:this.fontStyle(),textAlign:i.textAlign,lineSpacing:this.lineSpacing()});return{x:n+i.textLeft,y:r+i.textTop,lineNumber:a}}_getInternalData(){if(null!==this._internalData)return this._internalData;const e=(0,o.ensureNotNull)(this._data),{boxLeft:t,boxTop:i,boxWidth:s,boxHeight:n,textBoxWidth:l,textBoxHeight:c}=this._getBox(),h=T(e),d=P(e),u=w(e),_=e.decorator?.geometry(e),p=_?.width??0,m=0===e.text.length?0:_?.decoratorAndTextMargin??0,g=_?.ignoreRtl,f=p+m;let y;const v=i+u+M(e)/2;let S;const b=(0,r.isRtl)(),C=b&&!g,x=C?t+s-d-p:t+h;switch((0,o.ensureDefined)(e.horzTextAlign)){case a.HorizontalAlign.Left:S="start",y=x+f,b&&(e.forceTextAlign?S="left":(y=C?x-m:t+s-d,S="right"));break;case a.HorizontalAlign.Center:S="center";const i=s-h-d-f;y=C?x-m-i/2:x+f+i/2;break;case a.HorizontalAlign.Right:S="end",y=C?x-m:t+s-d,b&&e.forceTextAlign&&(S="right")}return this._internalData={boxLeft:t,boxTop:i,boxWidth:s,boxHeight:n,textBoxWidth:l,textBoxHeight:c,textLeft:t+h+(C?0:f),textRight:t+s-d-(C?f:0),textTop:i+u,textBottom:i+n-u,textHorizStart:y-t,textVertStart:v-i,textAlign:S,textBaseLine:"middle",decoratorLeft:x,decoratorWidth:p},this._internalData}_getFontInfo(){if(null===this._fontInfo){const e=(0,o.ensureNotNull)(this._data),t=M(e),i=`${e.bold?"bold ":""}${e.italic?"italic ":""}${t}px ${e.font}`;this._fontInfo={fontStyle:i,fontSize:t}}return this._fontInfo}_drawSelectionIfNeeded(e,t){const i=(0,o.ensureNotNull)(this._data),s=M((0,o.ensureNotNull)(this._data));if(i.selectionHighlight){const o=this.positionToCoordinate(i.selectionHighlight.start),n=this.positionToCoordinate(i.selectionHighlight.end),r=this._getInternalData();(0,h.drawSelection)(e,t,{lines:this.getLinesInfo().linesIncludingHidden,selectionStart:o,selectionEnd:n,left:r.textLeft,right:r.textRight,color:i.selectionHighlight.color,font:this.fontStyle(),lineHeight:s,lineSpacing:this.lineSpacing()})}}_getLinesMaxWidth(e){const t=this.fontStyle();if(null!==this._data&&this._data.wordWrapWidth&&!this._data.forceCalculateMaxLineWidth)return this._data.wordWrapWidth*A(this._data);let i=0;for(const s of e)i=Math.max(i,(0,u.measureText)(s.text,t,this._textWidthCache).width);return i}_getBoxSize(){if(null===this._boxSize){
const e=this.getLinesInfo(),t=(0,o.ensureNotNull)(this._data),i=function(e,t){const i=e.decorator?.geometry(e),s=Math.round(t+T(e)+P(e)+(i?.width??0)+(0===e.text.length?0:i?.decoratorAndTextMargin??0));return s%2?s+1:s}(t,e.linesMaxWidth),s=function(e,t){return M(e)*t+x(e)*(t-1)+2*w(e)}(t,e.lines.length);this._boxSize={textBoxWidth:i,textBoxHeight:s,boxWidth:t.boxWidth??i,boxHeight:t.boxHeight??s}}return this._boxSize}_getBox(){if(this._box)return this._box;const e=(0,o.ensureNotNull)(this._data),[t]=(0,o.ensureDefined)(e.points),{boxWidth:i,boxHeight:s,textBoxWidth:n,textBoxHeight:r}=this._getBoxSize();let{y:l,x:c}=t;switch(e.vertAlign){case a.VerticalAlign.Bottom:l-=s+e.offsetY;break;case a.VerticalAlign.Middle:l-=s/2;break;case a.VerticalAlign.Top:l+=e.offsetY}switch(e.horzAlign){case a.HorizontalAlign.Left:c+=e.offsetX;break;case a.HorizontalAlign.Center:c-=i/2;break;case a.HorizontalAlign.Right:c-=i+e.offsetX}return this._box={boxLeft:c,boxTop:l,boxWidth:i,boxHeight:s,textBoxWidth:n,textBoxHeight:r}}_getRotationPoint(){const{boxLeft:e,boxTop:t,boxWidth:i,boxHeight:n}=this._getBox(),{horzAlign:r,vertAlign:l}=(0,o.ensureNotNull)(this._data);let c,h;switch(r){case a.HorizontalAlign.Center:c=e+i/2;break;case a.HorizontalAlign.Left:c=e;break;case a.HorizontalAlign.Right:c=e+i}switch(l){case a.VerticalAlign.Middle:h=t+n/2;break;case a.VerticalAlign.Top:h=t;break;case a.VerticalAlign.Bottom:h=t+n}return(0,s.point)(c,h)}}},80819:(e,t,i)=>{"use strict";i.d(t,{TrendLineRenderer:()=>_,drawArrow:()=>u});var s=i(50151),o=i(2624),n=i(25672),r=i(2383),a=i(58221),l=i(4539),c=i(33350),h=i(69558);function d(e,t,i,s,o){t.save(),t.fillStyle="#000000",t.beginPath(),t.arc(e.x*o,e.y*o,i*o,0,2*Math.PI,!1),t.fill(),s.strokeWidth&&(t.lineWidth=s.strokeWidth,t.stroke()),t.restore()}function u(e,t,i,s,o,n=!1){if(t.subtract(e).length()<1)return;const r=(0,l.getArrowPoints)(e,t,s,n,!0).slice(0,2);let a=null;const{horizontalPixelRatio:c,verticalPixelRatio:h}=o;for(let e=0;e<r.length;++e){const t=r[e][0],s=r[e][1];(null===a||a.subtract(t).length()>1)&&i.moveTo(t.x*c,t.y*h),i.lineTo(s.x*c,s.y*h),a=s}}class _{constructor(){this._data=null,this._hittest=new r.HitTestResult(r.HitTarget.MovePoint)}setData(e){this._data=e}setHitTest(e){this._hittest=e}draw(e,t){const i=this._data;if(null===i)return;if("points"in i&&i.points.length<2)return;const{horizontalPixelRatio:s}=t;if(void 0!==i.excludeBoundaries){e.save();for(const s of i.excludeBoundaries)(0,c.addExclusionArea)(e,t,s)}const{linestyle:o,lineCap:n=(o===h.LINESTYLE_SOLID?"round":"butt")}=i;e.lineCap=n,e.lineJoin="round",e.strokeStyle=i.color,e.lineWidth=Math.max(1,Math.floor(i.linewidth*s)),(0,a.setLineStyle)(e,o);const r=i.points[0],l=i.points[1];let d=[];e.beginPath(),i.overlayLineEndings?d=[r.clone(),l.clone()]:this._drawEnds(e,[r,l],i.linewidth,t);const u=this._extendAndClipLineSegment(r,l,t);null!==u&&i.linewidth>0&&(0,a.addPixelPerfectLineToPath)(e,u[0].x,u[0].y,u[1].x,u[1].y,t),i.overlayLineEndings&&this._drawEnds(e,d,i.linewidth,t),e.stroke(),void 0!==i.excludeBoundaries&&e.restore()}
hitTest(e,t){const i=this._data;if(null===i)return null;if("points"in i&&i.points.length<2)return null;const s=(i.hitTestTolerance??(0,l.interactionTolerance)().line)+i.linewidth/2,n=i.points[0],r=i.points[1],a=this._extendAndClipLineSegment(n,r,t);if(null!==a){if((0,o.distanceToSegment)(a[0],a[1],e).distance<=s)return this._hittest}return null}_extendAndClipLineSegment(e,t,i){const o=(0,s.ensureNotNull)(this._data);return(0,l.extendAndClipLineSegment)(e,t,i.mediaSize.width,i.mediaSize.height,o.extendleft,o.extendright)}_drawEnds(e,t,i,o){const r=t[0],a=t[1],l=(0,s.ensureNotNull)(this._data);switch(l.leftend){case n.LineEnd.Arrow:u(a,r,e,i,o);break;case n.LineEnd.Circle:d(r,e,i,(0,s.ensureDefined)(l.endstyle),o.horizontalPixelRatio)}switch(l.rightend){case n.LineEnd.Arrow:u(r,a,e,i,o);break;case n.LineEnd.Circle:d(a,e,i,(0,s.ensureDefined)(l.endstyle),o.horizontalPixelRatio)}}}},64960:(e,t,i)=>{"use strict";i.d(t,{VerticalLineRenderer:()=>l});var s=i(2383),o=i(58221),n=i(4539),r=i(33350),a=i(10307);class l extends a.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._hitTest=new s.HitTestResult(s.HitTarget.MovePoint)}setData(e){this._data=e}setHitTest(e){this._hitTest=e}hitTest(e){if(null===this._data||null===this._hitTest)return null;const t=(0,n.interactionTolerance)().line,i=Math.abs(e.x-this._data.x)<=t+this._data.linewidth/2,s=void 0===this._data.top||this._data.top-e.y<=t,o=void 0===this._data.bottom||e.y-this._data.bottom<=t;return i&&s&&o?this._hitTest:null}_drawImpl(e){if(null===this._data||this._data.linewidth<=0)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s,mediaSize:n}=e;if(this._data.x<-this._data.linewidth/2||this._data.x>n.width+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,o.setLineStyle)(t,this._data.linestyle);const a=void 0!==this._data.top?Math.max(this._data.top,0):0,l=void 0!==this._data.bottom?Math.min(this._data.bottom,n.height):n.height,c=Math.round(this._data.x*i),h=Math.floor(a*s),d=Math.ceil(l*s),u=this._data.excludeBoundaries;void 0!==u&&(0,r.addExclusionAreaByScope)(e,u),(0,o.drawVerticalLine)(t,c,h,d)}}},67777:(e,t,i)=>{"use strict";i.d(t,{sortSources:()=>o,sortSourcesPreOrdered:()=>s});const s={KeyFactsToday:10000001,LatestUpdates:10000002,BarMarks:10000003,TimeScaleMarks:10000004,ChartEventsSource:10000005,Dividends:10000006,Splits:10000007,Earnings:10000008,RollDates:10000009,FutureContractExpiration:10000010,LineToolOrder:10000011,LineToolPosition:10000012,LineToolExecution:10000013,AlertLabelInactive:10000014,AlertLabel:10000015};function o(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),o=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?o(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))}},72187:(e,t,i)=>{"use strict";i.d(t,{PlotList:()=>u,mergeMinMax:()=>_});var s=i(50151),o=i(12217),n=i(82284),r=i(9343),a=i(5471);const l=(0,r.getLogger)("Chart.PlotList"),c=30;function h(e){return e.index}function d(e){return e.value[0]}class u{constructor(e=null,t=null){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache=new Map,this._rowSearchCacheByIndex=new Map,this._rowSearchCacheByIndexWithoutEmptyValues=new Map,this._rowSearchCacheByTime=new Map,this._rowSearchCacheByTimeWithoutEmptyValues=new Map,this._plotFunctions=e||new Map,this._emptyValuePredicate=t}clear(){this._items=[],this._start=0,this._end=0,this._shareRead=!1,this._minMaxCache.clear(),this._invalidateSearchCaches()}first(){return this.size()>0?this._items[this._start]:null}last(){return this.size()>0?this._items[this._end-1]:null}firstIndex(){return this.size()>0?this._indexAt(this._start):null}firstPlottableIndex(){if(this.isEmpty())return null;for(let e=this._start;e<this._end;++e){const t=this._indexAt(e);if(t>n.UNPLOTTABLE_TIME_POINT_INDEX)return t}return null}lastIndex(){return this.size()>0?this._indexAt(this._end-1):null}clone(){const e=this.firstIndex(),t=this.lastIndex();return null===e||null===t?new u:this.range(e,t)}size(){return this._end-this._start}isEmpty(){return 0===this.size()}contains(e){return null!==this.search(e,a.PlotRowSearchMode.Exact)}valueAt(e){const t=this.search(e);return null!==t?t.value:null}add(e,t){if(this._shareRead)return l.logDebug("add: readonly collection modification attempt"),!1;const i={index:e,value:t},s=this._nonCachedSearch(e,a.PlotRowSearchMode.Exact,h);return this._invalidateSearchCaches(),null===s?(this._items.splice(this._lowerbound(e,h),0,i),this._start=0,this._end=this._items.length,!0):(this._items[s]=i,!1)}search(e,t=a.PlotRowSearchMode.Exact,i){return this._searchImpl(e,t,this._rowSearchCacheByIndex,this._rowSearchCacheByIndexWithoutEmptyValues,h,i)}searchByTime(e,t=a.PlotRowSearchMode.Exact,i){return this._searchImpl(e,t,this._rowSearchCacheByTime,this._rowSearchCacheByTimeWithoutEmptyValues,d,i)}fold(e,t){let i=t;for(let t=this._start;t<this._end;++t){i=e(this._indexAt(t),this._valueAt(t),i)}return i}findFirst(e,t){const i=void 0!==t&&Math.min(this._start+t,this._end)||this._end;for(let t=this._start;t<i;++t){const i=this._indexAt(t),s=this._valueAt(t);if(e(i,s))return{index:i,value:s}}return null}findLast(e,t){const i=void 0!==t&&Math.max(this._end-t,this._start)||this._start;for(let t=this._end-1;t>=i;--t){const i=this._indexAt(t),s=this._valueAt(t);if(e(i,s))return{index:i,value:s}}return null}each(e){for(let t=this._start;t<this._end;++t){if(e(this._indexAt(t),this._valueAt(t)))break}}reduce(e,t){let i=t;for(let t=this._start;t<this._end;++t){
i=e(i,this._indexAt(t),this._valueAt(t))}return i}range(e,t){const i=new u(this._plotFunctions,this._emptyValuePredicate);return i._items=this._items,i._start=this._lowerbound(e,h),i._end=this._upperbound(t),i._shareRead=!0,i}plottableRange(e){const t=new u(this._plotFunctions,this._emptyValuePredicate);return t._items=this._items,t._start=this._upperbound(n.UNPLOTTABLE_TIME_POINT_INDEX),t._end=this._end,t._shareRead=!0,!0===e&&t._start>this._start&&(t._start-=1),t}rangeCountback(e,t){if(null===this.firstIndex())return new u;const i=new u(this._plotFunctions,this._emptyValuePredicate);return i._items=this._items,i._end=this._upperbound(e),i._start=Math.max(this._start,i._end-t),i._shareRead=!0,i}rangeIterator(e,t){const i=this._lowerbound(e,h),s=this._upperbound(t);return this._rangeIteratorImpl(i,s)}fullRangeIterator(){return this._rangeIteratorImpl(this._start,this._end)}minMaxOnRangeCached(e,t,i){if(this.isEmpty())return null;let s=null;for(const o of i){s=_(s,this._minMaxOnRangeCachedImpl(e-o.offset,t-o.offset,o.name))}return s}minMaxOnRange(e,t,i){if(this.isEmpty())return null;let s=null;for(const o of i){s=_(s,this._minMaxOnRange(e-o.offset,t-o.offset,o.name))}return s}merge(e){return this._shareRead?(l.logDebug("merge: readonly collection modification attempt"),null):0===e.length?null:this.isEmpty()||e[e.length-1].index<this._items[0].index?this._prepend(e):e[0].index>this._items[this._items.length-1].index?this._append(e):1===e.length&&e[0].index===this._items[this._items.length-1].index?(this._updateLast(e[0]),e[0]):this._merge(e)}addTail(e,t=!1){if(0===e.length)return;let i=0;t&&this._end-this._start>0&&(i=1,this._items[this._end-this._start-1].value=e[0].value);for(let t=i;t<e.length;++t){const i=e[t],s=this.lastIndex();if(null===s){l.logError("Can't add tail to the empty plotlist");break}this.add(s+1,i.value)}this._invalidateSearchCaches()}move(e){if(this._shareRead)return void l.logDebug("move: readonly collection modification attempt");if(0===e.length)return;const t=this._items.slice();for(const i of e){const e=this._bsearch(i.old,h);if(null!==e&&void 0!==t[e])if(i.new===n.INVALID_TIME_POINT_INDEX)t[e]=void 0;else{t[e]={index:i.new,value:t[e].value};const s=this._bsearch(i.new,h);if(null!==s){const e=t[s];void 0!==e&&e.index===i.new&&(t[s]=void 0)}}}this._items=t.filter((e=>void 0!==e)).sort(((e,t)=>e.index-t.index)),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._start=0,this._end=this._items.length}remove(e){if(this._shareRead)return l.logDebug("remove: readonly collection modification attempt"),null;const t=this._nonCachedSearch(e,a.PlotRowSearchMode.NearestRight,h);if(null===t)return null;const i=this._items.splice(t);return this._end=this._items.length,this._minMaxCache.clear(),this._invalidateSearchCaches(),i.length>0?i[0]:null}state(){const e=this._items.slice(this._start,this._end);return{start:0,end:e.length,data:e}}restoreState(e){e?(this._start=e.start,this._end=e.end,this._shareRead=!1,this._items=e.data,this._minMaxCache.clear(),this._invalidateSearchCaches()):this.clear()}
_indexAt(e){return this._items[e].index}_valueAt(e){return this._items[e].value}_length(){return this._items.length}_searchImpl(e,t,i,s,o,n){const r=void 0!==n?i:s,a=void 0!==n?1e4*(t+1)+n:t;let l=r.get(e);if(void 0!==l){const e=l.get(a);if(void 0!==e)return e}const c=this._nonCachedSearch(e,t,o,n);if(null===c)return null;const h={index:this._indexAt(c),value:this._valueAt(c)};return void 0===l&&(l=new Map,r.set(e,l)),l.set(a,h),h}_nonCachedSearch(e,t,i,s){const o=this._lowerbound(e,i),n=o===this._end||e!==i(this._items[o]);if(n&&t!==a.PlotRowSearchMode.Exact)switch(t){case a.PlotRowSearchMode.NearestLeft:return this._searchNearestLeft(o,s);case a.PlotRowSearchMode.NearestRight:return this._searchNearestRight(o,s);default:throw new TypeError("Unknown search mode")}if(void 0===s||n||t===a.PlotRowSearchMode.Exact)return n?null:o;switch(t){case a.PlotRowSearchMode.NearestLeft:return this._nonEmptyNearestLeft(o,s);case a.PlotRowSearchMode.NearestRight:return this._nonEmptyNearestRight(o,s);default:throw new TypeError("Unknown search mode")}}_nonEmptyNearestRight(e,t){const i=(0,s.ensure)(this._emptyValuePredicate),o=(0,s.ensure)(t);for(;e<this._end&&i(this._valueAt(e),o);)e+=1;return e===this._end?null:e}_nonEmptyNearestLeft(e,t){const i=(0,s.ensureNotNull)(this._emptyValuePredicate),o=(0,s.ensure)(t);for(;e>=this._start&&i(this._valueAt(e),o);)e-=1;return e<this._start?null:e}_searchNearestLeft(e,t){if(e===this._start)return null;const i=e-1,s=i!==this._end?i:null;return void 0!==t&&null!==s?this._nonEmptyNearestLeft(s,t):s}_searchNearestRight(e,t){const i=e,s=i!==this._end?i:null;return void 0!==t&&null!==s?this._nonEmptyNearestRight(s,t):s}_bsearch(e,t){const i=this._lowerbound(e,t);return i!==this._end&&e===t(this._items[i])?i:null}_lowerbound(e,t){return(0,o.lowerbound)(this._items,e,((e,i)=>t(e)<i),this._start,this._end)}_upperbound(e){return(0,o.upperbound)(this._items,e,((e,t)=>t.index>e),this._start,this._end)}_plotMinMax(e,t,i){let s=null;const o=this._plotFunctions.get(i);if(void 0===o)throw new Error(`Plot "${i}" is not registered`);for(let i=e;i<t;i++){const e=o(this._items[i].value);null==e||Number.isNaN(e)||(null===s?s={min:e,max:e}:(e<s.min&&(s.min=e),e>s.max&&(s.max=e)))}return s}_invalidateCacheForRow(e){const t=Math.floor(e.index/c);this._minMaxCache.forEach((e=>e.delete(t)))}_prepend(e){return(0,s.assert)(!this._shareRead,"collection should not be readonly"),(0,s.assert)(0!==e.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=e.concat(this._items),this._start=0,this._end=this._items.length,e[0]}_append(e){return(0,s.assert)(!this._shareRead,"collection should not be readonly"),(0,s.assert)(0!==e.length,"plotRows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=this._items.concat(e),this._start=0,this._end=this._items.length,e[0]}_updateLast(e){(0,s.assert)(!this.isEmpty(),"plot list should not be empty");const t=this._items[this._end-1];(0,
s.assert)(t.index===e.index,"last row index should match new row index"),this._invalidateCacheForRow(e),this._invalidateSearchCaches(),this._items[this._end-1]=e}_merge(e){return(0,s.assert)(0!==e.length,"plot rows should not be empty"),this._invalidateSearchCaches(),this._minMaxCache.clear(),this._items=function(e,t){const i=function(e,t){const i=e.length,s=t.length;let o=i+s,n=0,r=0;for(;n<i&&r<s;)e[n].index<t[r].index?n++:e[n].index>t[r].index?r++:(n++,r++,o--);return o}(e,t),s=new Array(i);let o=0,n=0;const r=e.length,a=t.length;let l=0;for(;o<r&&n<a;)e[o].index<t[n].index?(s[l]=e[o],o++):e[o].index>t[n].index?(s[l]=t[n],n++):(s[l]=t[n],o++,n++),l++;for(;o<r;)s[l]=e[o],o++,l++;for(;n<a;)s[l]=t[n],n++,l++;return s}(this._items,e),this._start=0,this._end=this._items.length,e[0]}_minMaxOnRangeCachedImpl(e,t,i){if(this.isEmpty())return null;let o=null;const n=(0,s.ensureNotNull)(this.firstIndex()),r=(0,s.ensureNotNull)(this.lastIndex()),a=Math.max(e,n),l=Math.min(t,r),h=Math.ceil(a/c)*c,d=Math.max(h,Math.floor(l/c)*c);o=_(o,this._minMaxOnRange(a,Math.min(h,t,l),i));let u=this._minMaxCache.get(i);void 0===u&&(u=new Map,this._minMaxCache.set(i,u));for(let e=Math.max(h+1,a);e<d;e+=c){const t=Math.floor(e/c);let s=u.get(t);if(void 0===s){const e=t*c,o=(t+1)*c-1;s=this._minMaxOnRange(e,o,i),u.set(t,s)}o=_(o,s)}o=_(o,this._minMaxOnRange(d,l,i));return o}_minMaxOnRange(e,t,i){return this._plotMinMax(this._lowerbound(e,h),this._upperbound(t),i)}_rangeIteratorImpl(e,t){let i=e-1;return{[Symbol.iterator](){return this},next:()=>(i+=1,i>=t?{done:!0,value:void 0}:{done:!1,value:this._items[i]})}}_invalidateSearchCaches(){this._rowSearchCacheByIndex.clear(),this._rowSearchCacheByIndexWithoutEmptyValues.clear(),this._rowSearchCacheByTime.clear(),this._rowSearchCacheByTimeWithoutEmptyValues.clear()}}function _(e,t){if(null===e)return t;if(null===t)return e;return{min:Math.min(e.min,t.min),max:Math.max(e.max,t.max)}}},36281:(e,t,i)=>{"use strict";i.d(t,{PriceAxisView:()=>_});var s,o=i(10555),n=i(6453),r=i(39612),a=i(24640),l=i(33350),c=i(2383),h=i(58221);!function(e){e[e.HitTestTolerance=0]="HitTestTolerance",e[e.HitTestToleranceTouch=20]="HitTestToleranceTouch",e[e.AdditionalVisibilityTolerance=3]="AdditionalVisibilityTolerance",e[e.IconLabelExistingAlertWidth=12]="IconLabelExistingAlertWidth",e[e.IconLabelExistingAlertHeight=10.73]="IconLabelExistingAlertHeight",e[e.IconLabelExistingAlertHorzMargin=11]="IconLabelExistingAlertHorzMargin"}(s||(s={}));new Path2D("");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,s,n){const r=this._data,{mediaSize:c,bitmapSize:d,horizontalPixelRatio:u,verticalPixelRatio:_}=t;if(!r.visible||this._isOutOfScreen(i,c.height))return;const p=this._commonData,m=void 0!==r.labelIcon,g=i.paddingTop+p.additionalPaddingTop,f=i.paddingBottom+p.additionalPaddingBottom,{paddingOuter:y,paddingInner:v,fontSize:S,borderSize:b}=i,w=r.ignoreAdditionalPaddingInner?0:i.additionalPaddingInner
;let C=r.text,T=r.textColor||p.textColor,P=r.secondLine||"",x=p.secondLineTextColor||T,M=r.thirdLine||"";const I=p.thirdLineTextColor||T;0===P.length&&(P=M,x=I,M=""),0===C.length&&(C=P,T=x,P=M,x=I,M=""),e.save(),void 0!==p.globalAlpha&&(e.globalAlpha*=p.globalAlpha),e.font=i.font;const A=s.yMidCorrection(e,C)*_,L=S+g+f,k=(r.labelIconMinWidth??0)*u,E=Boolean(P),D=Boolean(M),B=v+y+w,V=[Math.ceil(s.measureText(e,C)),E?Math.ceil(s.measureText(e,P)):0,D?Math.ceil(s.measureText(e,M)):0],R=Math.max(1,Math.floor(_));let N=Math.round(L*_);N%2!=R%2&&(N+=1);const O=Math.round((S+i.lineSpacing)*_),F=Math.round(2*(S+i.lineSpacing)*_),W=Math.max(1,Math.floor(b*u)),H=r.separatorVisible?W:0,z=r.borderVisible?W:0,U=m?Math.max(N,k):Math.round((Math.max(...V)+B)*u),j=Math.round(w*u),G=d.width,q=Math.ceil(v*u),$=Math.round((p.fixedCoordinate??p.coordinate)*_)-Math.floor(.5*_),K=Math.floor($+R/2-N/2),Y=K+N,Z="right"===n,X=void 0!==r.xCoord?Math.round(r.xCoord*u)+(Z?1:-1)*Math.round(U/2):Z?G-H:H;let J,Q=X;const ee=r.backgroung??p.background;e.fillStyle=ee;const te=2*_;if(e.textAlign=Z?"right":"left",e.textBaseline="middle",Z?(Q=X-U,J=X-j-q+H):(Q=X+U,J=X+j+q-H),this._bodyBox=null,C||m){const t=D?N+F:E?N+O:N,i=p.borderColor??ee,s=void 0!==r.xCoord?te:0;if(((i,n,a)=>{if(Z){(0,h.drawRoundRectWithInnerBorder)(e,Q,K,U,t,i,r.overridenRadius?(0,h.scaleDrawRoundRectRadii)(r.overridenRadius,_):[te,s,s,te],z,n,a);const l=(0,o.point)(Q/u,K/_),c=l.add((0,o.point)(U/u,t/_));this._bodyBox=(0,o.box)(l,c)}else{(0,h.drawRoundRectWithInnerBorder)(e,X,K,U,t,i,r.overridenRadius?(0,h.scaleDrawRoundRectRadii)(r.overridenRadius,_):[s,te,te,s],z,n,a);const l=(0,o.point)(X/u,K/_),c=l.add((0,o.point)(U/u,t/_));this._bodyBox=(0,o.box)(l,c)}})(ee,i,p.borderStyle),m){if(0===r.labelIcon)this._drawPlusIcon(e,X,Q,K,$,Y,R);return void e.restore()}e.save(),e.translate(J,(K+Y)/2+A),(0,l.drawScaled)(e,u,_,(()=>{e.fillStyle=T,e.fillText(C,0,0)})),e.restore()}E&&(e.fillStyle=x,e.save(),e.translate(J,(K+Y)/2+A+O),(0,l.drawScaled)(e,u,_,(()=>{e.fillText((0,a.startWithLTR)(P),0,0)})),e.restore()),D&&(e.fillStyle=I,e.save(),e.translate(J,(K+Y)/2+A+F),(0,l.drawScaled)(e,u,_,(()=>{e.fillText((0,a.startWithLTR)(M),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 function(e,t){const i=(0,r.lastMouseOrTouchEventInfo)().isTouch?20:0,s=e.hitTestData;if(void 0===s||!e.visible)return null;const{itemBox:a,clickHandler:l,tooltip:h}=s;if(a){const r=(0,o.box)(new o.Point(a.min.x-i,a.min.y-i),new o.Point(a.max.x+i,a.max.y+i));if((0,n.pointInBox)(t,r))return new c.HitTestResult(e.hitTarget??c.HitTarget.Custom,{clickHandler:l?.bind(null,t),tapHandler:l?.bind(null,t),hoverModelFromAxis:s.hoverModelFromAxis,activeItem:s.activeItem,tooltip:h})}return null}(this._data,e)}
_drawPlusIcon(e,t,i,s,o,n,r){e.fillStyle=this._commonData.textColor,e.strokeStyle=this._commonData.textColor,e.lineWidth=r;const a=Math.abs(t-i);let l=Math.round(.35*a);l%2!=r%2&&(l+=1);let c=Math.round(.65*a);c%2!=r%2&&(c+=1);const h=Math.floor((a-l)/2),d=Math.min(t,i),u=d+Math.floor(a/2-r/2);e.fillRect(d+h,o,l,r),e.fillRect(u,s+h,r,l),e.beginPath(),e.arc(u+r/2,o+r/2,c/2,0,2*Math.PI,!1),e.stroke()}_drawClockExistingAlertIcon(e,t,i,s,o,n){}_lines(){const e=this._data;return(e.text?1:0)+(e.secondLine?1:0)+(e.thirdLine?1:0)}_isOutOfScreen(e,t){const i=this._commonData,s=i.fixedCoordinate??i.coordinate,{total:o}=this.topBottomTotalHeight(e),n=o/this._lines();return s-n/2-3>t||s+(o-n/2)+3<0}}var u=i(52859);class _{constructor(e){this._commonRendererData={coordinate:0,textColor:"#FFF",background:"#000",additionalPaddingBottom:0,additionalPaddingTop:0},this._axisRendererData={text:"",visible:!1,separatorVisible:!0,borderVisible:!1,ignoreAdditionalPaddingInner:!1},this._paneRendererData={text:"",visible:!1,separatorVisible:!1,borderVisible:!1,ignoreAdditionalPaddingInner:!0},this._invalidated=!0,this._active=!1,this._axisRenderer=new(e||d)(this._axisRendererData,this._commonRendererData),this._paneRenderer=new(e||d)(this._paneRendererData,this._commonRendererData)}setActive(e){this._active=e}text(){return this._updateRendererDataIfNeeded(),this._axisRendererData.text}secondLineText(){return this._updateRendererDataIfNeeded(),this._axisRendererData.secondLine}thirdLineText(){return this._updateRendererDataIfNeeded(),this._axisRendererData.thirdLine}background(){return this._updateRendererDataIfNeeded(),this._commonRendererData.background}color(){return this._updateRendererDataIfNeeded(),this.generateTextColor(this.background())}generateTextColor(e){return(0,u.colorFromBackground)(e)}coordinate(){return this._updateRendererDataIfNeeded(),this._commonRendererData.coordinate}floatCoordinate(){return this._updateRendererDataIfNeeded(),this._commonRendererData.floatCoordinate??this._commonRendererData.coordinate}update(e){this._invalidated=!0}topBottomTotalHeight(e){this._updateRendererDataIfNeeded();const{top:t,bottom:i,total:s}=this._axisRenderer.topBottomTotalHeight(e),{top:o,bottom:n,total:r}=this._paneRenderer.topBottomTotalHeight(e);return{top:Math.max(t,o),bottom:Math.max(i,n),total:Math.max(s,r)}}getFixedCoordinate(){return this._commonRendererData.fixedCoordinate||0}setFixedCoordinate(e){this._commonRendererData.fixedCoordinate=e}isVisible(){return this._updateRendererDataIfNeeded(),this._axisRendererData.visible||this._paneRendererData.visible}isAxisLabelVisible(){return this._updateRendererDataIfNeeded(),this._axisRendererData.visible}isPaneLabelVisible(){return this._updateRendererDataIfNeeded(),this._paneRendererData.visible}renderer(){return this._updateRendererDataIfNeeded(),this._axisRenderer}paneRenderer(){return this._updateRendererDataIfNeeded(),this._paneRenderer}setPaneRendererLabelIcon(e){this._paneRendererData.labelIcon=e}setPaneLabelVisible(e){this._paneRendererData.visible=e,this._invalidated=!0}
ignoreAlignment(){return!1}_updateRendererDataIfNeeded(){this._invalidated&&(this._commonRendererData.fixedCoordinate=void 0,this._updateRendererData(this._axisRendererData,this._paneRendererData,this._commonRendererData),this._invalidated=!1)}}},67135:(e,t,i)=>{"use strict";i.d(t,{PriceDataSource:()=>c,isPriceDataSource:()=>l});var s=i(50151),o=i(2072),n=i(72207),r=i(48096),a=i(22455);function l(e){return e instanceof c}class c extends n.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._dataRangeUpdated=new r.Delegate,this._priceStep=null,this._signature=new o.WatchedValue(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}signature(){return this._signature.readonly()}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}tableViewValuesProvider(){return null}chartFloatingTooltipValuesProvider(){return this.valuesProvider()}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}alertSourceModel(){return null}canHasAlertOnLineTools(){return!0}dataRangeUpdated(){return this._dataRangeUpdated}_onIndexDiffsApplied(e){const[t,i]=(0,s.ensureNotNull)(this._plotsDataRange());let o=1/0,n=-1/0;for(const t of e)o=Math.min(o,t.old,t.new),n=Math.max(n,t.old,t.new);this._dataRangeUpdated.fire({type:"partial",startIndex:Math.max(o,t),endIndex:Math.min(n,i)})}_plotsDataRange(){return null}_enablePriceRangeReady(){this._priceRangeReady=!0,this._priceRangeReadyChanged.fire(!0)}_onSourceCurrencyChanged(){(0,a.isActingAsSymbolSource)(this)||this._currencyChanged.fire()}_onSourceUnitChanged(){(0,a.isActingAsSymbolSource)(this)||this._unitChanged.fire()}_onSourcePriceRangeReadyChanged(e){(0,a.isActingAsSymbolSource)(this)||e||this.disablePriceRangeReady()}}},30693:(e,t,i)=>{"use strict";i.d(t,{PriceLineAxisView:()=>l,SeriesPriceLineAxisView:()=>c,StudyPriceLineAxisView:()=>h});var s=i(36281),o=i(50151),n=i(69558),r=i(58221);class a{constructor(e,t){this.setData(e,t)}setData(e,t){this._data=e,this._commonData=t}draw(e,t,i,s,a){if(!this._data.visible)return
;const{bitmapSize:l,verticalPixelRatio:c}=t,h=this._commonData.fixedCoordinate??this._commonData.coordinate;e.lineWidth=Math.max(1,Math.floor((0,o.ensureDefined)(this._data.linewidth)*c)),e.lineCap="butt",(0,r.setLineStyle)(e,void 0===this._data.linestyle?n.LINESTYLE_DOTTED:this._data.linestyle),e.strokeStyle=this._commonData.textColor,(0,r.drawHorizontalLine)(e,Math.round(h*c),0,l.width)}topBottomTotalHeight(e){return{top:0,bottom:0,total:0}}}class l extends s.PriceAxisView{constructor(e){super(e||a)}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 l{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 h extends l{constructor(e,t){super(),this._study=e,this._plotname=t}update(e){"hover-change"!==e.type&&super.update(e)}_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}}},97902:(e,t,i)=>{"use strict";var s;i.d(t,{PriceAxisLastValueMode:()=>s}),function(e){e[e.LastPriceAndPercentageValue=0]="LastPriceAndPercentageValue",e[e.LastValueAccordingToScale=1]="LastValueAccordingToScale"}(s||(s={}))},52945:(e,t,i)=>{"use strict";i.d(t,{fromIndexedTo100:()=>h,fromLog:()=>p,fromPercent:()=>a,getCurrentModePriceText:()=>f,getOppositeModePriceText:()=>y,logFormulaForBase:()=>m,logFormulasAreSame:()=>g,toIndexedTo100:()=>d,toIndexedTo100Range:()=>u,toLog:()=>_,toPercent:()=>l,toPercentRange:()=>c});var s=i(24062),o=i(77914);const n={logicalOffset:4,coordOffset:1e-4},r=305;function a(e,t){return t<0&&(e=-e),e/100*t+t}function l(e,t){const i=100*(e-t)/(t||1);return t<0?-i:i}function c(e,t){const i=l(e.minValue(),t),o=l(e.maxValue(),t);return new s.PriceRange(i,o)}function h(e,t){return t<0&&(e=-e),(e-=100)/100*t+t}function d(e,t){
const i=100*(e-t)/t+100;return t<0?-i:i}function u(e,t){const i=d(e.minValue(),t),o=d(e.maxValue(),t);return new s.PriceRange(i,o)}function _(e,t){const i=Math.min(10**r-t.coordOffset,Math.abs(e));if(i<1e-25)return 0;const s=(0,o.log10)(i+t.coordOffset)+t.logicalOffset;return e<0?-s:s}function p(e,t){const i=Math.abs(e);if(i<1e-15)return 0;const s=Math.pow(10,Math.min(i-t.logicalOffset,r))-t.coordOffset;return e<0?-s:s}function m(e){if(null===e)return n;const t=1/e;if(t>=n.coordOffset||t<1e-15)return n;const i=Math.abs(Math.log10(e));return{logicalOffset:i,coordOffset:1/Math.pow(10,i)}}function g(e,t){return e.logicalOffset===t.logicalOffset&&e.coordOffset===t.coordOffset}function f(e,t){return e.isPercentage()?t.formattedPricePercentage:e.isIndexedTo100()?t.formattedPriceIndexedTo100:t.formattedPriceAbsolute}function y(e,t){return e.isPercentage()||e.isIndexedTo100()?t.formattedPriceAbsolute:t.formattedPricePercentage}},31789:(e,t,i)=>{"use strict";i.d(t,{priceSourceTitles:()=>o});var s=i(11542);const o={open:s.t(null,{context:"price source"},i(6976)),high:s.t(null,{context:"price source"},i(93496)),low:s.t(null,{context:"price source"},i(17887)),close:s.t(null,{context:"price source"},i(37054)),hl2:s.t(null,{context:"price source"},i(68916)),hlc3:s.t(null,{context:"price source"},i(4821)),ohlc4:s.t(null,{context:"price source"},i(68163)),hlcc4:s.t(null,{context:"price source"},i(4767))}},24062:(e,t,i)=>{"use strict";i.d(t,{PriceRange:()=>n});var s=i(4148);const o=(0,i(9343).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 o.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):o.logDebug("PriceRange.shift: invalid coeff")}containsStrictly(e){return e.minValue()>this._minValue&&e.maxValue()<this._maxValue}containPrice(e){return e>=this._minValue&&e<=this._maxValue}intersection(e){
return this.containPrice(e.minValue())||this.containPrice(e.maxValue())||e.containPrice(this._minValue)?new n(Math.max(this._minValue,e.minValue()),Math.min(this._maxValue,e.maxValue())):null}static compare(e,t){return null===e||null===t?e===t:e.equals(t)}}},41072:(e,t,i)=>{"use strict";i.d(t,{createPrimitiveProperty:()=>o});var s=i(43337);function o(e){return new s.Property(e)}},76559:(e,t,i)=>{"use strict";i.d(t,{isRootPath:()=>a,propertyByPath:()=>r,propertyPathForSource:()=>o});var s=i(50151);function o(e,t="properties"){return`charts.${e.model().id()}.sources.${e.id()}.${t}`}function n(e,t){if(t.length<4)throw new Error("Invalid chart path");const i=function(e,t){return(0,s.ensureDefined)(e.getAll().find((e=>e.hasModel()&&e.model().model().id()===t))).model().model()}(e,t[0]),o=t[1];if("sources"===o){return(0,s.ensureNotNull)(i.dataSourceForId(t[2])).propertyByPath(t.slice(3).join("."))}throw new Error(`Invalid chart path, unknown root: ${o}`)}function r(e,t){const i=t.split(".");if(i.length<1)throw new Error("Invalid path");const s=i[0];if("charts"===s)return n(e,i.slice(1));throw new Error(`Invalid path, unknown root: ${s}`)}function a(e){return e.startsWith("charts.")}},79603:(e,t,i)=>{"use strict";i.d(t,{PropertyBase:()=>n});var s=i(50151),o=i(48096);class n{constructor(){this._listeners=new o.Delegate,this._muteChildChanges=!1,this._owner=null,this._name=""}nameInOwner(){return this._name}setNameInOwner(e){this._name=e}owner(){return this._owner}setOwner(e){this._owner=e}pathToRoot(){const e=this._owner?.pathToRoot();return e?`${e}.${this._name}`:this._name}pathToRootProperty(){if(!this._owner)return"";const e=this._owner.pathToRootProperty?.();return e?`${e}.${this._name}`:this._name}removeProperty(e){(0,s.assert)(!1,`Trying to call "removeProperty" on property ${this.pathToRoot()}`)}addChild(e,t){(0,s.assert)(!1,`Trying to call "addChild" on property ${this.pathToRoot()}`)}hasChild(e){return!1}childCount(){return 0}childNames(){return[]}childs(){(0,s.assert)(!1,`Trying to call "childs" on property ${this.pathToRoot()}`)}state(e,t){return this.value()}merge(e,t){(0,s.assert)(!1,`Trying to call "merge" on property ${this.pathToRoot()}`)}mergeAndFire(e){(0,s.assert)(!1,`Trying to call "mergeAndFire" on property ${this.pathToRoot()}`)}child(e){if(this.hasChild(e))return this.childs()[e]}muteChildChanges(e){this._muteChildChanges=e}fireChanged(){this._listeners.fire(this,this.pathToRootProperty())}listeners(){return this._listeners}subscribe(e,t){this.listeners().subscribe(e,t,!1)}unsubscribe(e,t){this.listeners().unsubscribe(e,t)}unsubscribeAll(e){this.listeners().unsubscribeAll(e)}}},55114:(e,t,i)=>{"use strict";i.d(t,{DataTypes:()=>s,createPropertySchema:()=>_,dataType:()=>h,extractStateWithSchema:()=>p,isArraySchema:()=>u,validateSchema:()=>d});var s,o=i(69708),n=i(83873),r=i(83350),a=i(56052),l=i(82433),c=i(81960);function h(e){return(0,o.default)(e)?s.NUMBER:(0,n.default)(e)?s.STRING:(0,r.default)(e)?s.BOOLEAN:(0,a.default)(e)?s.ARRAY:null===e?s.UNKNOWN:"object"==typeof e?s.OBJECT:s.UNKNOWN}
function d(e,t){const i=h(e);switch(t.type){case s.ARRAY:return i===s.ARRAY&&e.every((e=>d(e,t.subschema)));case s.OBJECT:{if(i!==s.OBJECT)return!1;const o=Object.entries(t.subschema);for(const t of o)if(!d(e[t[0]],t[1]))return!1;return!0}default:return i===t.type||t.type===s.UNKNOWN}}function u(e){return e.type===s.ARRAY}function _(e,t){let i;const o=h(e);switch(o){case s.NUMBER:case s.STRING:case s.BOOLEAN:i={type:o,saveFlags:t};break;case s.ARRAY:i={type:s.ARRAY,saveFlags:t,subschema:_(e[0],t)};break;case s.OBJECT:{const o={};for(const[i,s]of Object.entries(e))o[i]=_(s,t);i={type:s.OBJECT,saveFlags:t,subschema:o};break}default:i={type:s.UNKNOWN,saveFlags:t}}return i}function p(e,t,i){if(!function(e){return e.type===s.OBJECT}(t)||!(0,l.default)(e))return e;const o=Object.keys(e);for(const s of o){const o=t.subschema[s];void 0===t.saveFlags||o||(0,c.default)(e,s);const n=o?.saveFlags;void 0===n||n&i||(0,c.default)(e,s),o&&p(e[s],o,i)}return e}!function(e){e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.OBJECT="object",e.ARRAY="array",e.UNKNOWN="unknown"}(s||(s={}))},89959:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>o});var s=i(41072);function o(e,...t){const i=()=>e(...t.map((e=>e.value()))),o=(0,s.createPrimitiveProperty)(i()),n=()=>o.setValue(i()),r={};for(const e of t)e.subscribe(r,n);return o.destroy=()=>{t.forEach((e=>e.unsubscribeAll(r))),t.forEach((e=>e.release()))},o}},18712:(e,t,i)=>{"use strict";i.d(t,{convertPropertyToWatchedValue:()=>o});var s=i(22613);function o(e){const t=new s.WatchedValue(e.value());let i=!1;e.subscribe(t,(()=>{i||(i=!0,t.setValue(e.value()),i=!1)}));const o=()=>{i||(i=!0,e.setValue(t.value()),i=!1)};return t.subscribe(o),t.spawn((()=>{e.unsubscribeAll(t),t.unsubscribe(o)}))}},67455:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>r.combineProperty,createWVFromGetterAndSubscription:()=>s.createWVFromGetterAndSubscription,createWVFromGetterAndSubscriptions:()=>o.createWVFromGetterAndSubscriptions,createWVFromProperty:()=>n.createWVFromProperty});var s=i(8811),o=i(11751),n=i(70548);i(41072);var r=i(89959)},8811:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscription:()=>o});var s=i(22613);function o(e,t){const i=new s.WatchedValue(e()),o={};t.subscribe(o,(()=>{i.setValue(e(i.value()))}));return i.readonly().spawn((()=>t.unsubscribeAll(o)))}},11751:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscriptions:()=>o});var s=i(22613);function o(e,t){const i=new s.WatchedValue(e()),o={};t.forEach((t=>t.subscribe(o,(()=>{i.setValue(e())}))));return i.readonly().spawn((()=>t.forEach((e=>e.unsubscribeAll(o)))))}},70548:(e,t,i)=>{"use strict";i.d(t,{createWVFromProperty:()=>o});var s=i(8811);function o(e){return(0,s.createWVFromGetterAndSubscription)((()=>e.value()),e)}},43337:(e,t,i)=>{"use strict";i.d(t,{Property:()=>m,isPrimitiveType:()=>p});var s=i(69708),o=i(83873),n=i(83350),r=i(88987),a=i(56052),l=i(50151),c=i(9343),h=i(38486),d=i(79603),u=i(55114);const _=(0,c.getLogger)("Property");function p(e){return null===e||(0,s.default)(e)&&Number.isFinite(e)||(0,
o.default)(e)||(0,n.default)(e)}class m extends d.PropertyBase{constructor(e,t){if(super(),this._childs=[],this._dependents=[],this._schema=t||(0,u.createPropertySchema)(e),void 0!==e)if((0,u.validateSchema)(e,this._schema)||_.logWarn(`The state with a data type: ${(0,u.dataType)(e)} does not match a schema`),p(e))this._value=e;else{let t=Object.entries(e);(0,u.isArraySchema)(this._schema)&&(t=t.filter((([e])=>!Number.isNaN(+e))));for(const[e,i]of t)this.addProperty(e,i)}}destroy(){this.listeners().destroy();for(const e of this._childs)this.child(e)?.destroy?.()}merge(e,t){let i=null,s=0;if(t&&(i=[],s=i.length),void 0===e)return i;if(p(e))return this._value!==e&&i?.push(this),this._value=e,i;if((0,a.default)(e)){(0,u.isArraySchema)(this._schema)||_.logWarn("Property is not an array");for(let s=0;s<e.length;s++){const o=this.childs()[s];if(o){const n=o.merge(e[s],t);i?.push(...n)}else{const t=this.addProperty(`${s}`,e[s]);i?.push(t)}}}else{let s=Object.entries(e);(0,u.isArraySchema)(this._schema)&&(s=s.filter((([e])=>!Number.isNaN(+e))));for(const[e,o]of s){const s=this.childs()[e];if(s){const e=s.merge(o,t);i?.push(...e)}else{const t=this.addProperty(e,o);i?.push(t)}}}return i&&i.length>s&&i.push(this),i}mergeAndFire(e){const t=(0,l.ensureNotNull)(this.merge(e,!0));this._fireMergeAndFireChangedProps(t)}state(e,t){const i=(0,r.default)(this.value)?this.value():void 0;if(void 0!==i)return i;const s=(0,u.isArraySchema)(this._schema)?[]:{};for(const i of this._childs){if(e&&-1!==e.indexOf(i))continue;if((0,u.isArraySchema)(this._schema)&&Number.isNaN(+i))continue;if(void 0!==t&&"subschema"in this._schema){const e=(0,u.isArraySchema)(this._schema)?this._schema.subschema:this._schema.subschema[i];if(void 0!==this._schema.saveFlags&&!e)continue;if(void 0!==e?.saveFlags&&!(e.saveFlags&t))continue}const o=this.childs()[i];let n;if(e){const s=[];for(const t of e)t.startsWith(i+".")&&s.push(t.substring(i.length+1));n=o?.state(s,t)}else n=o?.state();(void 0!==n||o?.storeStateIfUndefined())&&((0,a.default)(s)?s[+i]=n:s[i]=n)}return s}clone(){return new m(this.state())}value(){return this._value}childCount(){return this._childs.length}childNames(){return this._childs}childByPath(e){let t=this;for(const i of e.split(".")){if(void 0===t)break;t=t.child(i)}return t}hasChild(e){return this._childs.includes(e)}setValue(e,t){(this._value!==e||t)&&(this._value=e,this.fireChanged())}setValueSilently(e){this._value=e}addProperty(e,t){let i;(0,u.isArraySchema)(this._schema)&&Number.isNaN(+e)&&_.logWarn("Property is an array"),this.removeProperty(e),this._schema.type===u.DataTypes.OBJECT?i=this._schema.subschema[e]:this._schema.type===u.DataTypes.ARRAY&&(i=this._schema.subschema);const s=new m(t,i);return this[e]=s,this._childs.push(e),s.subscribe(this,((e,t)=>{this._childChanged(e,t)})),s.setOwner(this),s.setNameInOwner(e),s}removeProperty(e){const t=this.child(e);t&&(t.setNameInOwner(""),t.setOwner(null),t.unsubscribeAll(this),delete this[e],this._childs=this._childs.filter((t=>t!==e)))}addChild(e,t){if((0,
u.isArraySchema)(this._schema)&&Number.isNaN(+e))throw new Error("Property is an array");this[e]&&this.removeProperty(e),this[e]=t,-1===this._childs.indexOf(e)&&this._childs.push(e),t.subscribe(this,((e,t)=>this._childChanged(e,t))),t.setOwner(this),t.setNameInOwner(e)}childs(){return this}storeStateIfUndefined(){return!0}ownership(){return(0,h.ownership)(this)}weakReference(){return(0,h.weakReference)(this)}addDependent(e){this._dependents.push(e)}removeDependent(e){const t=this._dependents.indexOf(e);t>=0&&this._dependents.splice(t,1)}dependents(){return this._dependents}_childChanged(e,t){this._muteChildChanges||this._listeners.fire(this,t)}_fireMergeAndFireChangedProps(e){this.muteChildChanges(!0);for(const t of e)t.muteChildChanges(!0);for(const t of e)t.muteChildChanges(!1),t.fireChanged();this.muteChildChanges(!1)}}},57025:(e,t,i)=>{"use strict";i.d(t,{QuotesProvider:()=>r});var s=i(32544),o=i(48096),n=i(4226);class r{constructor(e="full",t){this._quotes=null,this._quoteSessionSymbol=null,this._quoteSessionClientId="",this._pausedQuoteSessionSymbol=null,this._quotesUpdate=new o.Delegate,this._quoteSymbolChanged=new o.Delegate,this._multiplexerType=e,this._hibernated=t,this._hibernated?.subscribe((e=>{e?this.pause():this.resume()}))}setQuotesSessionSymbol(e){this._quoteSessionSymbol!==e&&(this._pausedQuoteSessionSymbol=null,this._quoteSessionClientId||(this._quoteSessionClientId="series-"+(0,n.guid)()),this._unsubscribeQuoteSession(),this._quoteSessionSymbol=e,this._quoteSymbolChanged.fire(),e&&this._subscribeQuoteSession(e))}symbol(){return this._quoteSessionSymbol}quotesUpdate(){return this._quotesUpdate}quoteSymbolChanged(){return this._quoteSymbolChanged}quotes(){return this._quotes}async quotesSnapshot(e){return(0,s.getQuoteSessionInstance)("simple").snapshot(e)}isPaused(){return null!==this._pausedQuoteSessionSymbol}pause(){null===this._pausedQuoteSessionSymbol&&(this._pausedQuoteSessionSymbol=this._quoteSessionSymbol,this._unsubscribeQuoteSession())}resume(){null!==this._pausedQuoteSessionSymbol&&(this._subscribeQuoteSession(this._pausedQuoteSessionSymbol),this._pausedQuoteSessionSymbol=null)}destroy(){this._unsubscribeQuoteSession(),this._hibernated?.release()}_onUpdate(e,t){this._quotes=e&&e.values||null,t&&t.values&&this._quotesUpdate.fire(e,t)}_subscribeQuoteSession(e){this._quoteSessionSymbol=e,(0,s.getQuoteSessionInstance)(this._multiplexerType).subscribe(this._quoteSessionClientId,this._quoteSessionSymbol,this._onUpdate.bind(this))}_unsubscribeQuoteSession(){this._quoteSessionSymbol&&((0,s.getQuoteSessionInstance)(this._multiplexerType).unsubscribe(this._quoteSessionClientId,this._quoteSessionSymbol),this._quoteSessionSymbol=null,this._quotes=null)}}},33065:(e,t,i)=>{"use strict";i.d(t,{dpr1PixelRatioInfo:()=>s,equalPixelRatios:()=>o});i(27714);const s={horizontalPixelRatio:1,verticalPixelRatio:1};function o(e,t){return e.horizontalPixelRatio===t.horizontalPixelRatio&&e.verticalPixelRatio===t.verticalPixelRatio}},87296:(e,t,i)=>{"use strict";i.d(t,{compareResolutions:()=>m,
convertResolutionsFromSettings:()=>P,getApplicableIntervalForFrequency:()=>g,getCustomResolutions:()=>I,getMaxResolutionValue:()=>T,getResolutionByChartStyle:()=>b,getTranslatedResolution:()=>A,getTranslatedResolutionModel:()=>L,intervalIsSupported:()=>V,isAvailable:()=>v,isIntervalEnabled:()=>B,isResolutionMultiplierValid:()=>w,isSecondsEnabled:()=>E,mergeResolutions:()=>x,normalizeIntervalString:()=>y,setLastUsedResolution:()=>S,sortResolutions:()=>M});var s=i(87465),o=i(11542),n=i(46082),r=i(95059),a=i(1765),l=i(29803),c=i(53470),h=i(37103),d=i(15574);const u={[n.ResolutionKind.Ticks]:1,[n.ResolutionKind.Seconds]:60,[n.ResolutionKind.Minutes]:1440,[n.SpecialResolutionKind.Hours]:24,[n.ResolutionKind.Days]:365,[n.ResolutionKind.Weeks]:52,[n.ResolutionKind.Months]:12,[n.ResolutionKind.Range]:1e6,[n.ResolutionKind.Invalid]:NaN},_={[n.ResolutionKind.Ticks]:0,[n.ResolutionKind.Seconds]:1,[n.ResolutionKind.Minutes]:2,[n.SpecialResolutionKind.Hours]:3,[n.ResolutionKind.Days]:4,[n.ResolutionKind.Weeks]:5,[n.ResolutionKind.Months]:6,[n.ResolutionKind.Range]:7,[n.ResolutionKind.Invalid]:8};function p(e){const t=n.Interval.parse(e),i=t.multiplier()||1;return t.isMinuteHours()?[n.SpecialResolutionKind.Hours,i/60]:[t.kind(),i]}function m(e,t){if(e===t)return 0;const[i,s]=p(e),[o,n]=p(t);return i!==o?_[i]-_[o]:s-n}function g(e,t){return m(t,e)>=0?t:e}var f;function y(e){return n.Interval.parse(e).value()}function v(e){const t=n.Interval.parse(e);if(!E()&&t.isSeconds())return!1;if(!(0,d.isTicksEnabled)()&&t.isTicks())return!1;const i=t.value(),s=l.linking.dataFrequencyResolution.value();if(void 0!==s&&m(i,s)<0)return!1;const o=l.linking.supportedResolutions.value();return void 0!==o?void 0!==o.find((e=>y(e)===i)):t.isSeconds()?Boolean(l.linking.seconds.value()):t.isTicks()?Boolean(l.linking.ticks.value()):t.isIntraday()?Boolean(l.linking.intraday.value()):t.isDWM()}function S(e){n.Interval.isValid(e)&&(n.Interval.isRange(e)?a.setValue("chart.lastUsedRangeResolution",e):a.setValue("chart.lastUsedTimeBasedResolution",e))}function b(e,t,i){const s=r.isRangeStyle(e),o=n.Interval.isRange(t);return!s&&o?function(e){const t=a.getValue("chart.lastUsedTimeBasedResolution");if(void 0!==t&&n.Interval.isTimeBased(t))return t;let i="1D";for(const t of e){const e=n.Interval.parse(t);if(e.isTimeBased()){const t=e.value();if("1D"===t)return t;i=t}}return i}(i):s&&!o?function(e){const t=a.getValue("chart.lastUsedRangeResolution");if(void 0!==t&&n.Interval.isRange(t))return t;let i="100R";for(const t of e){const e=n.Interval.parse(t);if(e.isRange()){const t=e.value();if("100R"===t)return t;i=t}}return i}(i):t}function w(e){const{interval:t,guiResolutionKind:i}=n.Interval.parseExt(e);if(!t.isValid())return!1;const s=t.multiplier();if((0,d.isTicksEnabled)()&&i===n.ResolutionKind.Ticks)return!0;return(i===n.SpecialResolutionKind.Hours?s/60:s)<=C(i)}function C(e){const t=u[e];return Number.isNaN(t)?1:t}function T(e){return C(n.Interval.parseExt(e).guiResolutionKind)}function P(e){
return Array.isArray(e)?e:Object.keys(e).map(n.Interval.normalize).filter(s.notNull)}function x(...e){let t=[].concat(...e);return t=(0,c.uniq)(t.filter(w).map(y)),M(t)}function M(e){return e.sort(m)}function I(){return[]}function A(e){const{multiplier:t,shortKind:i}=L(e);return`${t}${i}`}function L(e,t){const i=n.Interval.parse(e);let s=i.multiplier(),o=i.kind();if(!i.isValid()){if(t)return null;throw new TypeError(`Can't translate invalid interval: ${e}`)}return i.isMinuteHours()&&(s=Math.floor(s/60),o=n.SpecialResolutionKind.Hours),{multiplier:s.toString(),shortKind:k(o),hint:`${s} ${k(o,s)}`,mayOmitMultiplier:i.isDWM()&&1===s,mayOmitShortKind:i.isMinutes()&&!i.isMinuteHours()}}function k(e,t){if(!t)return{[n.ResolutionKind.Invalid]:"",[n.ResolutionKind.Ticks]:o.t(null,{context:"interval_short"},i(82901)),[n.ResolutionKind.Seconds]:o.t(null,{context:"interval_short"},i(68823)),[n.ResolutionKind.Minutes]:o.t(null,{context:"interval_short"},i(68430)),[n.SpecialResolutionKind.Hours]:o.t(null,{context:"interval_short"},i(38048)),[n.ResolutionKind.Days]:o.t(null,{context:"interval_short"},i(38691)),[n.ResolutionKind.Weeks]:o.t(null,{context:"interval_short"},i(7408)),[n.ResolutionKind.Months]:o.t(null,{context:"interval_short"},i(77995)),[n.ResolutionKind.Range]:o.t(null,{context:"interval_short"},i(93934))}[e];switch(e){case n.ResolutionKind.Ticks:return o.t(null,{plural:"ticks",count:t},i(11913));case n.ResolutionKind.Days:return o.t(null,{plural:"days",count:t},i(41807));case n.ResolutionKind.Weeks:return o.t(null,{plural:"weeks",count:t},i(48898));case n.ResolutionKind.Months:return o.t(null,{plural:"months",count:t},i(98393));case n.ResolutionKind.Seconds:return o.t(null,{plural:"seconds",count:t},i(33232));case n.ResolutionKind.Minutes:return o.t(null,{plural:"minutes",count:t},i(78318));case n.SpecialResolutionKind.Hours:return o.t(null,{plural:"hours",count:t},i(42328));case n.ResolutionKind.Range:return o.t(null,{plural:"ranges",count:t},i(89937));default:return e}}function E(){return h.enabled("seconds_resolution")}function D(e){return!(!E()&&e.isSeconds()||!(0,d.isTicksEnabled)()&&e.isTicks())&&!(!(0,d.isTicksEnabled)()&&e.isTicks())}function B(e){return D(n.Interval.parse(e))}function V(e){if(h.enabled("allow_supported_resolutions_set_only")){const t=n.Interval.normalize(e);return null!==t&&v(t)}{const t=n.Interval.parse(e);if(!t.isValid()||!D(t))return!1;if(!h.enabled("custom_resolutions")){const t=n.Interval.normalize(e),i=window.ChartApiInstance.defaultResolutions().filter(B);if(!t||-1===i.indexOf(t))return!1}const i=l.linking.dataFrequencyResolution.value();if(void 0!==i&&g(i,t.value())!==t.value())return!1;if(t.isTicks())return l.linking.ticks.value();if(t.isIntraday())return l.linking.intraday.value();{const e=l.linking.supportedResolutions.value();return!e||e.includes(t.value())}}}!function(e){e.CustomUserResolutionsKey="IntervalWidget.intervals",e.LastUsedRangeResolutionKey="chart.lastUsedRangeResolution",e.LastUsedTimeBasedResolutionKey="chart.lastUsedTimeBasedResolution",
e.DefaultRangeResolution="100R",e.DefaultTimeBasedResolution="1D"}(f||(f={}))},66142:(e,t,i)=>{"use strict";i.d(t,{barSpacingByScaleRatio:()=>a,priceRangeByScaleRatio:()=>r,scaleRatio:()=>n});var s=i(24062);const o=1e-10;function n(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(o,i)}function r(e,t,i){if(e.isLog()||null===i||e.isEmpty())return null;const o=e.priceRange();if(null===o||o.isEmpty())return null;const n=e.internalHeight()/(t/i),r=o.length();if(n===r)return o;const a=(n-r)/2;return new s.PriceRange(o.minValue()-a,o.maxValue()+a)}function a(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}},28450:(e,t,i)=>{"use strict";i.d(t,{allPriceScaleSelectionStrategyInfo:()=>c,createPriceScaleSelectionStrategy:()=>l});var s=i(50151),o=i(11542),n=i(2088);class r{constructor(e){this._priceScalesLimit=8,this._metaInfo=e}metaInfo(){return this._metaInfo}findSuitableScale(e,t,i,s){if(void 0!==s)return this._tryToGetDesiredPriceScale(e,t,s,i);if((0,n.isStudy)(t)){const s=t.metaInfo();if("Volume"===s.shortId&&e.containsMainSeries())return e.createPriceScaleAtPosition("overlay");const o=t.desiredPriceScalePosition();if(null!==o)return this._tryToGetDesiredPriceScale(e,t,o,i);if(void 0!==i&&((0,n.isStudy)(i)||e.isMainPane().value())&&s.is_price_study)return this._getPriceScaleTheSameAsForSource(i,e)}let o=!1;if((0,n.isStudy)(t)){const i=t.metaInfo().groupingKey;if(void 0!==i){const t=e.model().findNonOverlayStudyWithGroupingKey(i,e);if(null!==t)return this._getPriceScaleTheSameAsForSource(t.study,t.pane)}o=Boolean(t.metaInfo().is_price_study)}else t===e.model().mainSeries()&&(o=!0);if(o){const t=this._findFirstScaleForPriceStudy(e);if(null!==t)return t}return this.createNewPriceScaleIfPossible(e)}canCreateNewPriceScale(e){return e.leftPriceScales().length+e.rightPriceScales().length<this._priceScalesLimit}_getPriceScaleTheSameAsForSource(e,t){return t.isOverlay(e)?t.createPriceScaleAtPosition("overlay"):(0,s.ensureNotNull)(e.priceScale())}_priceScaleIsPrice(e,t){const i=e.mainSource();return!!i&&(i===t.mainSeries()||!!(0,n.isStudy)(i)&&Boolean(i.metaInfo().is_price_study))}_findFirstScaleForPriceStudy(e){const t=e.model();for(let i=0;i<this._priceScalesLimit;i++){if(e.rightPriceScales().length>i&&this._priceScaleIsPrice(e.rightPriceScales()[i],t))return e.rightPriceScales()[i];if(e.leftPriceScales().length>i&&this._priceScaleIsPrice(e.leftPriceScales()[i],t))return e.leftPriceScales()[i]}return null}_targetPriceScaleIndex(e,t){if(e.mainSource()===t.mainSeries())return 0}_tryToGetDesiredPriceScale(e,t,i,o){switch(i){case"left":return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("left"):e.createPriceScaleAtPosition("overlay");case"right":
return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("right"):e.createPriceScaleAtPosition("overlay");case"as-series":return void 0!==o?(0,s.ensureNotNull)(o.priceScale()):e.isMainPane().value()?(0,s.ensureNotNull)((0,s.ensureNotNull)(e.mainDataSource()).priceScale()):this.createNewPriceScaleIfPossible(e);case"overlay":return e.createPriceScaleAtPosition("overlay")}}}const a=[{name:"left",title:o.t(null,void 0,i(61507)),ctor:class extends r{constructor(e){super(e)}apply(e){const t=e.model();e.rightPriceScales().slice(0).forEach((i=>e.movePriceScale(i,"left",this._targetPriceScaleIndex(i,t))))}createNewPriceScaleIfPossible(e){return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("left"):e.createPriceScaleAtPosition("overlay")}}},{name:"right",title:o.t(null,void 0,i(97800)),ctor:class extends r{constructor(e){super(e)}apply(e){const t=e.model();e.leftPriceScales().slice(0).forEach((i=>e.movePriceScale(i,"right",this._targetPriceScaleIndex(i,t))))}createNewPriceScaleIfPossible(e){return this.canCreateNewPriceScale(e)?e.createPriceScaleAtPosition("right"):e.createPriceScaleAtPosition("overlay")}}},{name:"auto",title:o.t(null,void 0,i(21469)),ctor:class extends r{constructor(e){super(e)}apply(e){if(e.containsMainSeries()){const t=(0,s.ensureNotNull)((0,s.ensureNotNull)(e.mainDataSource()).priceScale());e.movePriceScale(t,"right",0)}const t=e.model();for(;e.leftPriceScales().length>e.rightPriceScales().length;){const i=e.leftPriceScales()[e.leftPriceScales().length-1];e.movePriceScale(i,"right",this._targetPriceScaleIndex(i,t))}for(;e.rightPriceScales().length-e.leftPriceScales().length>1;){const i=e.rightPriceScales()[e.rightPriceScales().length-1];e.movePriceScale(i,"left",this._targetPriceScaleIndex(i,t))}}createNewPriceScaleIfPossible(e){if(!this.canCreateNewPriceScale(e))return e.createPriceScaleAtPosition("overlay");const t=e.leftPriceScales().length<e.rightPriceScales().length?"left":"right";return e.createPriceScaleAtPosition(t)}}}];function l(e){const t=(0,s.ensureDefined)(a.find((t=>t.name===e)));return new t.ctor(t)}function c(){return a}},13173:(e,t,i)=>{"use strict";i.d(t,{SelectionIndexes:()=>o});var s=i(50151);class o{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 o=this._timescale.baseIndex();this._baseIndex!==o&&(this._baseIndex=o,this._offsetInBar=(0,s.ensureNotNull)(this._timescale.timePointToIndex(this._offsetInTime)));const n=(0,s.ensureNotNull)(this._offsetInBar),r=[];let a=Math.floor((t-n)/this._barsBetweenPoints);const l=Math.floor((i-n)/this._barsBetweenPoints)
;for(;a<=l;a++)r.push(n+a*this._barsBetweenPoints);return r}clear(){this._offsetInBar=null,this._offsetInTime=null,this._baseIndex=null,this._barsBetweenPoints=null}}},45801:(e,t,i)=>{"use strict";i.d(t,{SelectionRenderer:()=>d});var s=i(10555),o=i(6453),n=i(58978),r=i(2383),a=i(43838),l=i(10307);const c=n.colorsPalette["color-tv-blue-600"];var h;!function(e){e[e.Radius=4]="Radius",e[e.Tolerance=2]="Tolerance"}(h||(h={}));class d 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<this._data.points.length;t++){const i=this._data.points[t];if(i.point.subtract(e).length()<=6)return i.hitTestResult?i.hitTestResult:new r.HitTestResult(this._data.hittestResult,{pointIndex:i.pointIndex,cursorType:i.cursorType??a.PaneCursorType.Default,ownerSourceId:this._data.ownerSourceId})}return null}doesIntersectWithBox(e){return!!this._data&&this._data.points.some((t=>(0,o.pointInBox)(t.point,e)))}_drawImpl(e){if(null===this._data||!this._data.visible)return;const{points:t,bgColors:i,vertOffset:o=0}=this._data;for(let r=0;r<t.length;++r){const{point:a,lineWidth:l}=t[r];(n=a,Number.isFinite(n.x)&&Number.isFinite(n.y))&&this._drawMarker(e,a.add((0,s.point)(0,o)),this._data,i[r],l)}var n}_drawMarker(e,t,i,o,n=1){const{context:r,horizontalPixelRatio:a,verticalPixelRatio:l}=e,{color:h=c,withOutline:d=!0}=i,_=Math.max(1,Math.floor(a))%2/2,p=(0,s.point)(Math.round(t.x*a)+_,Math.round(t.y*l)+_),m=u(p,Math.round(4*a));r.fillStyle=o,r.fill(d?u(p,Math.round(5*a)+_):m),r.fillStyle=h,m.addPath(u(p,Math.floor((4-n)*a))),r.fill(m,"evenodd")}}function u(e,t){const i=new Path2D;return i.arc(e.x,e.y,t,0,2*Math.PI,!0),i}},70859:(e,t,i)=>{"use strict";i.d(t,{SeriesBarColorer:()=>_});var s=i(58978),o=i(50151),n=(i(22033),i(5471)),r=i(28477);const a=(0,s.getHexColorByName)("color-minty-green-500"),l=(0,s.getHexColorByName)("color-ripe-red-500");function c(e){return{barColor:e.upColor.value(),barBorderColor:e.borderUpColor?e.borderUpColor.value():e.borderColor.value()}}function h(e){return{barColor:e.downColor.value(),barBorderColor:e.borderDownColor?e.borderDownColor.value():e.borderColor.value()}}function d(e,t){return e.borderUpColorProjection&&e.borderUpColor?{barColor:t?e.upColorProjection.value():e.upColor.value(),barBorderColor:t?e.borderUpColorProjection.value():e.borderUpColor.value()}:{barColor:t?e.upColorProjection.value():e.upColor.value()}}function u(e,t){return e.borderDownColorProjection&&e.borderDownColor?{barColor:t?e.downColorProjection.value():e.downColor.value(),barBorderColor:t?e.borderDownColorProjection.value():e.borderDownColor.value()}:{barColor:t?e.downColorProjection.value():e.downColor.value()}}class _ extends r.AbstractBarColorer{constructor(e){super(),this._series=e}applyBarStyle(e,t,i,s){const o=i;o.barColor=void 0,o.barBorderColor=void 0,o.barWickColor=void 0,o.isBarHollow=void 0,o.isBarUp=void 0,o.upColor=void 0,o.downColor=void 0,o.isTwoColorBar=void 0,o.isMergedBar=void 0
;const n=this._series.properties();switch(n.childs().style.value()){case 2:case 14:case 15:this._applyLineStyle(e,t,i,s,n);break;case 18:this._applyLineStyle(e,t,i,s,n,!0);break;case 3:this._applyAreaStyle(i,n);break;case 16:this._applyHLCAreaStyle(e,t,i,s,n);break;case 0:this._applyBarStyle(e,i,s,n);break;case 17:case 1:case 19:this._applyCandleStyle(e,i,s,n);break;case 9:this._applyHollowCandleStyle(e,i,s,n);break;case 8:this._applyHAStyle(e,t,i,s,n);break;case 10:this._applyBaseLineStyle(e,t,i,s,n);break;case 12:this._applyHiLoStyle(t,i,n);break;case 13:this._applyColumnStyle(e,i,s,n);break;case 4:this._applyRenkoStyle(e,t,i,s,n);break;case 7:this._applyPBStyle(e,t,i,s,n);break;case 5:this._applyKagiStyle(e,t,i,s,n);break;case 6:this._applyPnfStyle(e,t,i,s,n);break;case 11:this._applyRangeStyle(e,t,i,s,n);break;case 20:0;break;case 21:this._applyHLCBarsStyle(e,i,s,n)}return i}static upColor(e,t){const i=e.childs(),s=i.style.value();switch(s){case 18:return{barColor:i.tpoStyle.childs().color.value()};case 20:return{barColor:i.svpStyle.childs().volumeProfile.childs().volumeColorUp.value()};case 2:return{barColor:i.lineStyle.childs().color.value()};case 14:return{barColor:i.lineWithMarkersStyle.childs().color.value()};case 15:return{barColor:i.steplineStyle.childs().color.value()};case 3:return{barColor:i.areaStyle.childs().linecolor.value()};case 16:return{barColor:i.hlcAreaStyle.childs().closeLineColor.value(),barBorderColor:a};case 0:return{barColor:i.barStyle.childs().upColor.value()};case 17:return c(i.volFootprintStyle.childs());case 19:return c(i.volCandlesStyle.childs());case 1:return c(i.candleStyle.childs());case 9:return c(i.hollowCandleStyle.childs());case 8:return c(i.haStyle.childs());case 10:return{barColor:i.baselineStyle.childs().topLineColor.value()};case 12:return{barColor:i.hiloStyle.childs().color.value(),barBorderColor:e.childs().hiloStyle.childs().borderColor.value()};case 13:return{barColor:i.columnStyle.childs().upColor.value()};case 4:return d(i.renkoStyle.childs(),t);case 7:return d(i.pbStyle.childs(),t);case 5:return d(i.kagiStyle.childs(),t);case 6:return d(i.pnfStyle.childs(),t);case 11:return{barColor:""};case 21:return{barColor:i.hlcBarsStyle.childs().color.value()}}(0,o.ensureNever)(s)}static downColor(e,t){const i=e.childs(),s=i.style.value();switch(s){case 2:return{barColor:i.lineStyle.childs().color.value()};case 18:return{barColor:i.tpoStyle.childs().color.value()};case 20:return{barColor:i.svpStyle.childs().volumeProfile.childs().volumeColorUp.value()};case 14:return{barColor:i.lineWithMarkersStyle.childs().color.value()};case 15:return{barColor:i.steplineStyle.childs().color.value()};case 3:return{barColor:i.areaStyle.childs().linecolor.value()};case 16:return{barColor:i.hlcAreaStyle.childs().closeLineColor.value(),barBorderColor:l};case 0:return{barColor:i.barStyle.childs().downColor.value()};case 17:return h(i.volFootprintStyle.childs());case 1:return h(i.candleStyle.childs());case 19:return h(i.volCandlesStyle.childs());case 9:return h(i.hollowCandleStyle.childs());case 8:
return h(i.haStyle.childs());case 10:return{barColor:i.baselineStyle.childs().bottomLineColor.value()};case 12:return{barColor:i.hiloStyle.childs().color.value(),barBorderColor:e.childs().hiloStyle.childs().borderColor.value()};case 13:return{barColor:i.columnStyle.childs().downColor.value()};case 4:return u(i.renkoStyle.childs(),t);case 7:return u(i.pbStyle.childs(),t);case 5:return u(i.kagiStyle.childs(),t);case 6:return u(i.pnfStyle.childs(),t);case 11:return{barColor:""};case 21:return{barColor:i.hlcBarsStyle.childs().color.value()}}(0,o.ensureNever)(s)}_applyLineStyle(e,t,i,s,n,r){if(i.barColor=_.upColor(n).barColor,r)return;const a=this._findBar(e,t,s),l=this._series.barFunction()(a),c=this._series.priceScale(),h=this._series.firstValue();if(null==l||c.isEmpty()||null==h)return;const d=c.priceToCoordinate(l,h);i.barColor=(0,o.ensureNotNull)(this._series.lineColorAtYPercentFromTop(d/c.height()))}_applyAreaStyle(e,t){e.barColor=_.upColor(t).barColor}_applyHLCAreaStyle(e,t,i,s,o){const n=this._isUp(e,!1,s,this._series.data().first()?.index!==e)?_.upColor(o,t):_.downColor(o,t);i.barColor=n.barColor,i.barBorderColor=n.barBorderColor}_applyBarStyle(e,t,i,s){const o=this._isUp(e,!1,i,s.childs().barStyle.childs().barColorsOnPrevClose.value())?_.upColor(s):_.downColor(s);t.barColor=o.barColor,t.barBorderColor=o.barBorderColor}_applyCandleStyle(e,t,i,s){const o=s.childs(),n=1===o.style.value()?o.candleStyle.childs():19===o.style.value()?o.volCandlesStyle.childs():o.volFootprintStyle.childs(),r=this._isUp(e,!1,i,n.barColorsOnPrevClose.value()&&this._series.data().first()?.index!==e),a=r?_.upColor(s):_.downColor(s);t.barColor=a.barColor,t.barBorderColor=a.barBorderColor,t.barWickColor=r?n.wickUpColor?n.wickUpColor.value():n.wickColor.value():n.wickDownColor?n.wickDownColor.value():n.wickColor.value()}_applyHollowCandleStyle(e,t,i,s){const o=s.childs().hollowCandleStyle.childs(),n=this._isUp(e,!1,i,this._series.data().first()?.index!==e),r=n?_.upColor(s):_.downColor(s);t.barColor=r.barColor,t.barBorderColor=r.barBorderColor,t.barWickColor=n?o.wickUpColor?o.wickUpColor.value():o.wickColor.value():o.wickDownColor?o.wickDownColor.value():o.wickColor.value();const a=this._findBar(e,!1,i);t.isBarHollow=a[1]<=a[4]}_applyHAStyle(e,t,i,s,o){const n=o.childs().haStyle.childs(),r=this._isUp(e,t,s,n.barColorsOnPrevClose.value()),a=r?_.upColor(o):_.downColor(o);i.barColor=a.barColor,i.barBorderColor=a.barBorderColor,i.barWickColor=r?n.wickUpColor.value():n.wickDownColor.value()}_applyBaseLineStyle(e,t,i,s,n){const r=this._findBar(e,t,s),a=n.childs().baselineStyle.childs(),l=this._series.priceScale(),c=Math.round(l.height()*(Math.abs(100-a.baseLevelPercentage.value())/100)),h=(0,o.ensureNotNull)(this._series.firstValue()),d=l.coordinateToPrice(c,h);r[4]>d?i.barColor=_.upColor(n,t).barColor:i.barColor=_.downColor(n,t).barColor}_applyHiLoStyle(e,t,i){const s=_.upColor(i,e);t.barColor=s.barColor,t.barBorderColor=s.barBorderColor}_applyColumnStyle(e,t,i,s){
const o=s.childs().columnStyle.childs(),n=this._isUp(e,!1,i,o.barColorsOnPrevClose.value())?_.upColor(s):_.downColor(s);t.color=n.barColor,t.barColor=t.color}_applyRenkoStyle(e,t,i,s,o){}_applyPBStyle(e,t,i,s,o){}_applyKagiStyle(e,t,i,s,o){}_applyPnfStyle(e,t,i,s,o){}_applyRangeStyle(e,t,i,s,o){}_applySVPStyle(e,t,i,s){}_applyHLCBarsStyle(e,t,i,s){t.barColor=s.childs().hlcBarsStyle.childs().color.value()}_findBar(e,t,i){return i?i.value:this._getSeriesBars(t).valueAt(e)||[]}_findPrevBar(e,t,i){if(i&&i.previousValue)return i.previousValue;const s=this._series.bars().search(e-1,n.PlotRowSearchMode.NearestLeft,4);return null!==s?s.value:[]}_getSeriesBars(e){return e?this._series.nsBars():this._series.bars()}_isUp(e,t,i,s){const o=this._findBar(e,t,i);if(s){return this._findPrevBar(e,t,i)[4]<=o[4]}return o[1]<=o[4]}}},82095:(e,t,i)=>{"use strict";var s;i.r(t),i.d(t,{ChartStyle:()=>H,OldLineStyleTypes:()=>w,SERIES_STATUS_TEXT:()=>b,STATUS_CALCULATION_ERROR:()=>f,STATUS_DELAYED:()=>u,STATUS_DELAYED_STREAMING:()=>_,STATUS_EOD:()=>h,STATUS_ERROR:()=>g,STATUS_INVALID_SYMBOL:()=>l,STATUS_LOADING:()=>r,STATUS_NO_BARS:()=>p,STATUS_OFFLINE:()=>o,STATUS_PULSE:()=>d,STATUS_READY:()=>a,STATUS_REPLAY:()=>m,STATUS_RESOLVING:()=>n,STATUS_SNAPSHOT:()=>c,STATUS_UNSUPPORTED_RESOLUTION:()=>y,STYLE_AREA:()=>x,STYLE_BARS:()=>C,STYLE_BASELINE:()=>D,STYLE_CANDLES:()=>T,STYLE_COLUMNS:()=>R,STYLE_HEIKEN_ASHI:()=>k,STYLE_HILO:()=>V,STYLE_HLC_AREA:()=>F,STYLE_HLC_BARS:()=>W,STYLE_HOLLOW_CANDLES:()=>E,STYLE_KAGI:()=>I,STYLE_LINE:()=>P,STYLE_LINE_WITH_MARKERS:()=>N,STYLE_PB:()=>L,STYLE_PNF:()=>A,STYLE_RANGE:()=>B,STYLE_RENKO:()=>M,STYLE_SHORT_NAMES:()=>z,STYLE_STEPLINE:()=>O,SYMBOL_STRING_DATA:()=>U,Status:()=>s,chartStylesWithAttachedStudies:()=>j,seriesLoadingStatuses:()=>S,seriesReadyStatuses:()=>v}),function(e){e[e.Offline=0]="Offline",e[e.Resolving=1]="Resolving",e[e.Loading=2]="Loading",e[e.Ready=3]="Ready",e[e.InvalidSymbol=4]="InvalidSymbol",e[e.Snapshot=5]="Snapshot",e[e.EOD=6]="EOD",e[e.Pulse=7]="Pulse",e[e.Delayed=8]="Delayed",e[e.DelayedSteaming=9]="DelayedSteaming",e[e.NoBars=10]="NoBars",e[e.Replay=11]="Replay",e[e.Error=12]="Error",e[e.CalculationError=13]="CalculationError",e[e.UnsupportedResolution=14]="UnsupportedResolution"}(s||(s={}));const o=0,n=1,r=2,a=3,l=4,c=5,h=6,d=7,u=8,_=9,p=10,m=11,g=12,f=13,y=14,v=new Set([3,6,7,8,9,11]),S=new Set([1,2]),b={[o]:"connecting",[n]:"loading",[r]:"loading",[a]:"realtime",[l]:"invalid",[c]:"snapshot",[h]:"endofday",[d]:"endofday",[u]:"delayed",[_]:"delayed_streaming",[p]:"forbidden",[m]:"replay",[g]:"error",[f]:"calculation_error",[y]:"unsupported_resolution"};var w;!function(e){e[e.Markers=0]="Markers",e[e.Stepline=1]="Stepline",e[e.Simple=2]="Simple"}(w||(w={}));const C=0,T=1,P=2,x=3,M=4,I=5,A=6,L=7,k=8,E=9,D=10,B=11,V=12,R=13,N=14,O=15,F=16,W=21;var H;!function(e){e[e.Bar=0]="Bar",e[e.Candle=1]="Candle",e[e.Line=2]="Line",e[e.Area=3]="Area",e[e.Renko=4]="Renko",e[e.Kagi=5]="Kagi",e[e.PnF=6]="PnF",e[e.LineBreak=7]="LineBreak",e[e.HeikinAshi=8]="HeikinAshi",e[e.HollowCandle=9]="HollowCandle",
e[e.Baseline=10]="Baseline",e[e.Range=11]="Range",e[e.HiLo=12]="HiLo",e[e.Column=13]="Column",e[e.LineWithMarkers=14]="LineWithMarkers",e[e.Stepline=15]="Stepline",e[e.HLCArea=16]="HLCArea",e[e.VolFootprint=17]="VolFootprint",e[e.TPO=18]="TPO",e[e.VolCandle=19]="VolCandle",e[e.SVP=20]="SVP",e[e.HLCBars=21]="HLCBars"}(H||(H={}));const z={0:"bar",1:"candle",9:"hollowCandle",2:"line",14:"lineWithMarkers",15:"stepline",3:"area",16:"hlcArea",4:"renko",7:"pb",5:"kagi",6:"pnf",8:"ha",10:"baseline",11:"range",12:"hilo",13:"column",17:"volFootprint",18:"tpo",19:"volCandles",20:"svp",21:"hlcBars"},U={4:{type:"BarSetRenko@tv-prostudies",basicStudyVersion:73},7:{type:"BarSetPriceBreak@tv-prostudies",basicStudyVersion:34},5:{type:"BarSetKagi@tv-prostudies",basicStudyVersion:73},6:{type:"BarSetPnF@tv-prostudies",basicStudyVersion:73},8:{type:"BarSetHeikenAshi@tv-basicstudies",basicStudyVersion:60},11:{type:"BarSetRange@tv-basicstudies",basicStudyVersion:72},17:{type:"Footprint@tv-volumebyprice",basicStudyVersion:104},18:{type:"TPOPeriodic@tv-volumebyprice",basicStudyVersion:104},20:{type:"VbPSessions@tv-volumebyprice",basicStudyVersion:126}},j=[17,18,20]},52746:(e,t,i)=>{"use strict";i.d(t,{SeriesData:()=>p,barFunction:()=>u,barFunctions:()=>h,seriesPlotFunctionMap:()=>d});var s,o,n=i(50151),r=i(72187),a=i(55803);!function(e){e[e.FromLeft=-1]="FromLeft",e[e.FromRight=1]="FromRight"}(s||(s={})),function(e){e[e.Time=0]="Time",e[e.Open=1]="Open",e[e.High=2]="High",e[e.Low=3]="Low",e[e.Close=4]="Close",e[e.Volume=5]="Volume",e[e.Adt=6]="Adt"}(o||(o={}));const l=["open","high","low","close","hl2","hlc3","ohlc4"];var c;!function(e){e[e.FirstPrice=0]="FirstPrice",e[e.LastPrice=1]="LastPrice",e[e.LastValuePrice=2]="LastValuePrice"}(c||(c={}));const h={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};function d(){const e=new Map;return l.forEach(((t,i)=>{e.set(t,u(t))})),e}function u(e,t,i){const s=h[t??e],o=h[e],n=h[i??e];return(e,t)=>{switch(t){case 0:return s(e);case 2:return n(e);default:return o(e)}}}function _(e,t){return null==e[t]}class p{constructor(){this.m_bars=new r.PlotList(d(),_),this.m_nsBars=new r.PlotList(d(),_),this._conflatedChunksBuilder=new a.ConflatedChunksBuilder(this.m_bars,(e=>h[e]))}bars(){return this.m_bars}nsBars(){return this.m_nsBars}conflatedChunks(e,t){return this._conflatedChunksBuilder.conflatedChunks(e,t)}mergeRegularBars(e){return this._conflatedChunksBuilder.mergeData(e)}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_nsBars.clear(),this.lastProjectionPrice=void 0,this._conflatedChunksBuilder.clearData()}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,n.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 o=s[t];return null!=o&&e>=o},s=this.m_bars.findLast(i);if(null!==s)return s.index;const o=this.m_nsBars.findLast(i);return null!==o?o.index:this.m_bars.firstIndex()}if(i===s.FromLeft){const i=(i,s)=>{const o=s[t];return null!=o&&e<=o},s=this.m_bars.findFirst(i);if(null!==s)return s.index;const o=this.m_nsBars.findFirst(i);return null!==o?o.index:this.m_bars.lastIndex()}throw new Error("plotValueToTimePointIndex: unsupported search mode")}moveData(e){this._conflatedChunksBuilder.moveData(e),this.m_nsBars.move(e)}}},19233:(e,t,i)=>{"use strict";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(),o=s.firstIndex(),n=s.lastIndex();if(null!==o&&e<o&&t<o||null!==n&&e>n&&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)}}},95059:(e,t,i)=>{"use strict";i.d(t,{actualSymbol:()=>he,chartStyleStudyId:()=>F,createSeriesFormatter:()=>U,displayedSymbolExchange:()=>ce,displayedSymbolName:()=>le,extractLineToolSymbolFromSymbolInfo:()=>se,getChartStyleByResolution:()=>O,getDefaultStyle:()=>N,getLastUsedSingleValueBasedStyle:()=>R,getLastUsedStyle:()=>V,getSeriesDisplayErrorWV:()=>be,getSeriesPriceFormattingState:()=>z,getSourceForEconomySymbol:()=>re,getSymbolDelaySeconds:()=>we,getSymbolListedExchange:()=>ve,getSymbolTradedExchange:()=>Se,getTranslatedChartStyleName:()=>T,hasVolume:()=>ge,isCloseBasedSymbol:()=>_e,isConvertedToOtherCurrency:()=>K,isConvertedToOtherUnit:()=>J,isEconomicSymbol:()=>fe,isHLCBasedStyle:()=>D,isMeasureUnitSymbol:()=>pe,isPriceSourceStyle:()=>H,isRangeBasedStyle:()=>x,isRangeStyle:()=>I,isRegularSessionId:()=>ue,isSingleValueBasedStyle:()=>E,isSpreadSymbolWithManyLegs:()=>ye,isStyleSupportedForReplay:()=>L,isTimeBasedStyle:()=>A,isValidStyle:()=>k,measureUnitId:()=>me,preparePriceAxisProperties:()=>W,proSymbol:()=>de,setLastUsedStyle:()=>B,styleChangeRequiresRestart:()=>M,symbolBaseCurrency:()=>$,symbolCurrency:()=>G,symbolCurrencyConvertible:()=>j,symbolHasElectronicSession:()=>te,symbolHasPreOrPostMarket:()=>ee,
symbolHasSeveralSessions:()=>ie,symbolOriginalCurrency:()=>q,symbolOriginalUnit:()=>X,symbolTitle:()=>ae,symbolTitleSeparator:()=>ne,symbolToSaveInState:()=>oe,symbolUnit:()=>Z,symbolUnitConvertibleGroupsIfExist:()=>Q});var s=i(11542),o=i(1765),n=(i(49483),i(88145)),r=i(82095),a=i(46082),l=i(67563),c=i(37103),h=i(91565),d=i(38888),u=i(48943),_=i(67455),p=i(52959),m=i(92211);const g=c.enabled("uppercase_instrument_names"),f=c.enabled("hide_object_tree_and_price_scale_exchange_label"),y=!1;var v;!function(e){e.LastUsedStyleKey="chart.lastUsedStyle",e.LastUsedSingleValueBasedStyle="chart.lastUsedSingleValueBasedStyle",e.LastUsedRawDataStyle="chart.rawDataStyle"}(v||(v={}));const S=[4,5,6,7,8],b=[4,5,6,7,11],w=[0,1,9,19,2,14,15,3,16,10,8,12,13,18,17,20],C=[2,14,15,10,3,13,18];function T(e){return{0:s.t(null,void 0,i(27377)),1:s.t(null,void 0,i(45054)),2:s.t(null,void 0,i(3554)),14:s.t(null,void 0,i(9394)),15:s.t(null,void 0,i(69217)),3:s.t(null,void 0,i(34456)),16:s.t(null,void 0,i(99906)),9:s.t(null,void 0,i(13459)),10:s.t(null,void 0,i(59213)),12:s.t(null,void 0,i(98236)),13:s.t(null,void 0,i(55761)),4:s.t(null,void 0,i(88130)),7:s.t(null,void 0,i(43588)),5:s.t(null,void 0,i(83490)),6:s.t(null,void 0,i(76519)),11:s.t(null,void 0,i(55169)),8:s.t(null,void 0,i(63876)),17:s.t(null,void 0,i(92763)),18:s.t(null,void 0,i(17809)),19:s.t(null,void 0,i(93722)),20:s.t(null,void 0,i(83298)),21:s.t(null,void 0,i(886))}[e]}function P(e){return-1!==S.indexOf(e)}function x(e){return-1!==b.indexOf(e)}function M(e,t){return!I(e)&&!I(t)&&!(e===t||!P(e)&&!P(t))}function I(e){return 11===e}function A(e){return-1!==w.indexOf(e)}function L(e){return!(!y&&8===e||17===e||18===e||20===e)&&A(e)}function k(e){return x(e)||A(e)}function E(e){switch(e){case 3:case 10:case 2:case 14:case 15:case 13:return!0;default:return!1}}function D(e){switch(e){case 16:case 21:return!0;default:return!1}}function B(e,t){var i;k(e)&&(11!==e&&o.setValue("chart.lastUsedStyle",e),i=e,r.SYMBOL_STRING_DATA[i]||function(e){o.setValue("chart.rawDataStyle",e)}(e),_e(t)&&E(e)&&o.setValue("chart.lastUsedSingleValueBasedStyle",e))}function V(){const e=o.getInt("chart.lastUsedStyle");return void 0===e?1:e}function R(){const e=o.getInt("chart.lastUsedSingleValueBasedStyle");return void 0===e?14:e}function N(e){return e?11:1}function O(e,t){const i=I(t),s=a.Interval.isRange(e);return!i&&s?N(!0):i&&!s?N(!1):t}function F(e,t){const i=r.SYMBOL_STRING_DATA[e];return void 0===i?null:t?`${i.type}-${i.basicStudyVersion}`:i.type}function W(e){const t=e.priceAxisProperties,i=t.lockScale.value(),s=6===e.style.value();(s||i)&&(t.log.setValue(!1),t.percentage.setValue(!1)),t.logDisabled.setValue(!(!s&&!i)),t.percentageDisabled.setValue(!(!s&&!i))}function H(e){return C.includes(e)}function z(e,t="default",i=!1){let s,o,n,r,a=100,l=1;if("default"===t)null!=e&&(({pricescale:a,minmov:l,minmove2:o,fractional:s}=e),n=e.variable_tick_size||void 0);else{let e=t.split(",");3!==e.length&&(e=["100","1","false"]),a=parseInt(e[0]),l=parseInt(e[1]),s="true"===e[2],r=!0}return i&&(l=1),{priceScale:a,
minMove:l,fractional:s,minMove2:o,variableMinTick:n,ignoreMinMove:i,noExponentialForm:r}}function U(e,t,i=!1){const{priceScale:s,minMove:o,fractional:n,minMove2:r,variableMinTick:a,noExponentialForm:c}=z(e,t,i);if(null!=e){const l=e.format;if("default"===t&&"volume"===l)return new h.VolumeFormatter({precision:2});if("percent"===l)return new d.PercentageFormatter({priceScale:s,minMove:o,fractional:n,minMove2:r,variableMinTick:a,ignoreMinMove:i})}return new l.PriceFormatter({priceScale:s,minMove:o,fractional:n,minMove2:r,variableMinTick:a,ignoreMinMove:i,noExponentialForm:c})}function j(e){return null!==e&&!(0,n.isSpread)(e.type)}function G(e,t,i){if(null===e)return null;const s=!t||i?e.currency_id:e.currency_code;return void 0===s||""===s?null:s}function q(e,t){return(t?e.original_currency_code:e.original_currency_id)??G(e,t)}function $(e){return e.base_currency_id||null}function K(e){if(null===e||!j(e))return!1;const t=q(e);return null!==t&&t!==G(e)}function Y(e,t){return t&&null!==e&&!(0,n.isSpread)(e.type)}function Z(e,t){if(null===e||!t)return null;const i=e.unit_id;return void 0===i||""===i?null:i}function X(e,t){return t?e.original_unit_id||Z(e,t):null}function J(e,t){return!(null===e||!Y(e,t))&&(void 0!==e.original_unit_id&&e.original_unit_id!==e.unit_id)}function Q(e,t){return null!==e&&Y(e,t)?e.unit_conversion_types||null:[]}function ee(e){return null!==e&&void 0!==e.subsessions&&e.subsessions.some((e=>"premarket"===e.id||"postmarket"===e.id))}function te(e){return null!==e&&void 0!==e.subsessions&&(e.subsessions.some((e=>"regular"===e.id))&&e.subsessions.some((e=>"us_regular"===e.id)))}function ie(e){return null!==e&&void 0!==e.subsessions&&e.subsessions.filter((e=>!e.private)).length>1}function se(e,t){return(0,m.extractSymbolNameFromSymbolInfo)(e,null,!0,!0)||t}function oe(e,t){return e?e.ticker??e.pro_name??t:t}const ne="·";function re(e,t){return fe(e)?e.source2?.description??null:null}function ae(e,t){const i=ve(e);return t||f?e.name:`${e.name} ${ne} ${i}`}function le(e){let t=e&&(function(e){return(0,n.isFutures)(e.type)&&e.front_contract||null}(e)||e.name)||"";return t.length>40&&(t=t.substring(0,37)+"..."),t.trim()}function ce(e){const t=e?e.exchange:"";return g?t.toUpperCase():t}function he(e,t){return null!==e?e.full_name:t}function de(e,t){return e?.pro_name??t}function ue(e,t){return(0,p.getChartingLibraryGlobalContext)()?.configurationData?.is_tradingview_data?["stock","fund","index","dr"].includes(t.type)&&"regular"===e||(0,n.isFutures)(t.type)&&"us_regular"===e:"regular"===e}function _e(e){return"c"===e?.visible_plots_set}function pe(e){return null!==e&&("unit"===e.measure&&null!==me(e))}function me(e){return e?.value_unit_id??null}function ge(e){return"ohlcv"===e.visible_plots_set}function fe(e){return null!==e&&(0,n.isEconomicSymbol)(e.type)}function ye(e){return function(e){return null!==e&&(0,n.isSpread)(e.type)}(e)&&(e?.legs??[]).length>1}function ve(e){const t=re(e);if(null!==t)return t;return e.exchange}function Se(e){return e.exchange}function be(e){return(0,u.combine)(((t,i)=>{
switch(t){case 4:{const t=e.seriesErrorMessage();return null!==t&&("resolution_not_entitled"===t||"custom_resolution"===t||"seconds_not_entitled"===t||"ticks_not_entitled"===t||t.startsWith("study_not_auth:"))?null:{type:"invalid_symbol"}}case 13:{const t=e.seriesErrorMessage();return null===t?null:{type:"calculations_error",errorMessage:t}}case 14:{const t=e.unsupportedResolutionState().value();return null===t?null:{type:"unsupported_resolution",reason:t.reason}}case 1:case 2:return null;default:if(i)return{type:"no_data"}}return null}),e.statusWV().weakReference(),(0,_.createWVFromGetterAndSubscription)((()=>!e.bars().size()&&!e.isInReplay().value()),e.dataEvents().dataUpdated()).ownership())}function we(e){return Math.max(0,e?.delay??0)}},2115:(e,t,i)=>{"use strict";i.d(t,{Series:()=>wi});var s=i(50279),o=i(50151),n=i(9343),r=i(51768),a=i(76422),l=i(88723),c=i(67135),h=i(86572),d=i(52746),u=i(72187),_=i(5471),p=i(24062),m=i(43337),g=i(95059),f=i(92211),y=i(30342),v=i(67563),S=i(82095),b=i(13651),w=i(11542),C=i(37103),T=i(19e3),P=i(52479),x=(i(3618),i(75641));i(40080);function M(e){const t="QUANDL"===(e=e||{}).listedExchange,s={title:"",description:"",interval:"",listedExchange:"",provider:"",chartStyle:"",sessionDescription:"",priceSource:"",adjustment:"",backadjustment:"",settlement:""};let o="";if(e.description&&t)if(2===e.description.split("/").length)o=e.description.split("/")[1];else{e.description.split("'").filter((e=>e.length)).forEach((e=>{let t=[];t=e&&("/"===e[0]||/\d+\/\(?/.test(e))?[e]:e.split("/").filter((e=>e.length)),o+=t[2===t.length?1:0]}))}else o=e.description?e.description:e.symbol;if(e.ticker?(s.title=e.ticker,s.description=I(o)):s.title=I(o),e.interval&&(s.interval=(0,x.translatedIntervalString)(e.interval)),t&&e.description){const t=/[\w_]+\/[\w_]+/.exec(e.description);t&&t[0]?s.provider=I(t[0].split("/")[0]):s.provider=I(e.description.split("/")[0])}return e.listedExchange&&(s.listedExchange=I(e.listedExchange)),s.chartStyle=I(function(e){return e.inputs,8===e.style?w.t(null,void 0,i(63876)):""}(e)),e.sessionDescription&&(s.sessionDescription=I(e.sessionDescription)),void 0!==e.priceSource&&(s.priceSource=I(e.priceSource)),e.adjustment&&"dividends"===e.adjustment&&(s.adjustment=w.t(null,{context:"adjustments"},i(94920))),void 0!==e.backadjustment&&(s.backadjustment=w.t(null,{context:"adjustments"},i(16755))),e["settlement-as-close"]&&(s.settlement=w.t(null,{context:"adjustments"},i(82631))),s}function I(e){return e.replace(/'/g,"")}var A=i(89837);const L=w.t(null,void 0,i(70963)),k=w.t(null,void 0,i(75546)),E=C.enabled("hide_unresolved_symbols_in_legend"),D=C.enabled("symbol_info_price_source");class B extends P.StatusProviderBase{constructor(e,t,i){super(),this._series=e,this._statusViewProperties=t,this._options=i||{}}text(){return function(e){const t=M(e);return(e.ticker?t.description:t.title)+(t.interval?", "+t.interval:"")+function(e,t=", "){
return(e.provider?`${t}${e.provider}`:"")+(e.listedExchange?`${t}${e.listedExchange}`:"")+(e.chartStyle?`${t}${e.chartStyle}`:"")+(e.adjustment?`${t}${e.adjustment}`:"")+(e.backadjustment?`${t}${e.backadjustment}`:"")+(e.settlement?`${t}${e.settlement}`:"")+(e.sessionDescription?`${t}${e.sessionDescription}`:"")+(e.priceSource?`${t}${e.priceSource}`:"")}(t)}(this._getTitleGenerationOptions())}getSplitTitle(){return M(this._getTitleGenerationOptions())}getInputsTitles(){return null}bold(){return!1}size(){return this._statusViewProperties.childs().fontSize.value()+"px"}errorStatus(){const e=this._series.unsupportedResolutionState().value(),t=e?(0,A.getErrorFromUnsupportedResolutionState)(e):this._series.seriesErrorMessage();return null!==t?{error:t,title:e?k:L}:null}_getTitleGenerationOptions(){const e=this._series.symbolInfo(),t=this._statusViewProperties.childs(),i=this._series.symbolTextSourceProxyProperty().value();let s;t.showExchange.value()&&e&&(s=(0,g.getSymbolListedExchange)(e));const o=(D&&e?.price_source_id?this._series.model().availablePriceSources(this._series.getSymbolString()).name(e.price_source_id):null)??void 0,n=this._series.getInputsProperties().state();17===this._series.style()&&(n.type=this._series.properties().childs().volFootprintStyle.childs().type.value());const r=this._series.aliasSymbolInfo();return{description:R(i,r),listedExchange:s,symbol:E&&null===r?"":this._series.symbolOrAlias(),interval:t.showInterval.value()&&!this._options.hideResolution?this._series.interval():void 0,style:this._series.properties().childs().style.value(),inputs:n,boxSize:this._series.data().boxSize,reversalAmount:this._series.data().reversalAmount,ticker:V(i,r),priceSource:o}}}function V(e,t){return"ticker-and-description"!==e?"":null!==t?t.name:void 0}function R(e,t){if(null!==t)return"ticker"===e?t.name:"long-description"===e&&void 0!==t.long_description?t.long_description:(0,T.getTranslatedSymbolDescription)({pro_name:t.pro_name||void 0,short_name:t.name||void 0,description:t.description||void 0,short_description:t.short_description||void 0,local_description:t.local_description||void 0,language:t.language||void 0})}class N extends b.StatusView{constructor(e,t,i){super(new B(e,t,i)),this._invalidated=!0,this._series=e,this._series.onRestarted().subscribe(this,this.update),this._series.dataEvents().symbolResolved().subscribe(this,this.update),this._series.dataEvents().completed().subscribe(this,this.update),this._series.boxSizeValue().subscribe(this.update.bind(this)),t.childs().symbolTextSource.subscribe(this,this.update)}getSeriesPrecision(){let e=4;const t=this._series.symbolInfo();return t&&t.pricescale&&(e=Math.round(Math.log(t.pricescale)/Math.log(10))),e}round(e){const t=this.getSeriesPrecision(),i=Math.round(e*Math.pow(10,t))/Math.pow(10,t);return i?i.toString():""}update(){this._invalidated=!0}text(){return this._updateImpl(),super.text()}bold(){return this._updateImpl(),super.bold()}size(){return this._updateImpl(),super.size()}getSplitTitle(){return this._updateImpl(),
this._statusProvider.getSplitTitle()}_updateImpl(){this._invalidated&&(this._bold=this._statusProvider.bold(),this._size=this._statusProvider.size(),this._text=this._statusProvider.text(),this._invalidated=!1)}}var O=i(50335),F=i(40137),W=i(49483),H=i(78861),z=i(11946),U=i(24640);const j=W.CheckMobile.any(),G=C.enabled("hide_resolution_in_legend");class q extends F.DataWindowView{constructor(e,t){super(),this._invalidated=!0,this._series=e,this._model=t,this.update()}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}series(){return this._series}canShowItems(){return!!this._model.mainPane()?.maximized().value()||void 0===this._model.panes().find((e=>e.maximized().value()))}_updateImpl(){const e=this._getValuesProvider();this._valuesProvider!==e&&(this._valuesProvider=e,this._items=this._valuesProvider.getItems().map((e=>new F.DataWindowItem(e.id,e.title,"",e.unimportant))));const t=this._series.aliasSymbolInfo();if(t){const e=[t.name];G||e.push((0,U.forceRTLStr)((0,x.translatedIntervalString)(this._series.interval()))),e.push((0,g.getSymbolListedExchange)(t)),this._header=e.join(` ${g.symbolTitleSeparator} `),this._title=t.description}else this._header=this._series.symbolOrAlias();let i=this._model.crosshairSource().appliedIndex();C.enabled("use_last_visible_bar_value_in_legend")&&!(0,O.isNumber)(i)&&(i=this._model.timeScale().visibleBarsStrictRange()?.lastBar()??NaN);const s=this._valuesProvider.getValues(i);for(let e=0;e<s.length;++e){const t=s[e],i=this._items[e];i.setValue(t.value),i.setVisible(t.visible),i.setColor(t.color),i.setTitle(t.title)}}_getValuesProvider(){return this._series.dataWindowValuesProvider()}_showLastPriceAndChangeOnly(){return j&&(null===this._model.crosshairSource().pane||(0,z.isLineToolName)(H.tool.value())||null!==this._model.lineBeingEdited())}}var $=i(67455);const K=w.t(null,void 0,i(72445));class Y extends q{constructor(e,t){super(e,t),this._backgroundColorSpawn=t.backgroundTopColor().spawn(),this._backgroundColorSpawn.subscribe(this.update.bind(this));const i=t.properties().childs().paneProperties.childs().legendProperties.childs();this._visibilityProperty=(0,$.combineProperty)(((e,t,i,s,o)=>`${e}:${t}:${i}:${s}:${o}`),i.showBarChange.weakReference(),i.showSeriesOHLC.weakReference(),i.showVolume.weakReference(),i.showLastDayChange.weakReference(),i.showSeriesLegendCloseOnMobile.weakReference()),this._visibilityProperty.subscribe(this,this.update)}areValuesVisible(){return this._visibilityProperty.value().includes("true")}additional(){return null}marketTitle(){const e=this._series.marketStatusModel().status().value();return this._showLastPriceAndChangeOnly()&&("pre_market"===e||"post_market"===e)?`${K}:`:""}destroy(){this._backgroundColorSpawn.destroy(),this._visibilityProperty.destroy()}_getValuesProvider(){return this._series.legendValuesProvider()}}var Z,X=i(53107),J=i(91106),Q=i(46082),ee=i(47312),te=i(51101),ie=i(99955),se=i(4226);!function(e){e[e.ExtrapolateBarsLimit=2e3]="ExtrapolateBarsLimit"}(Z||(Z={}))
;let oe=0;class ne{constructor(e,t){this._extrapolatedData=[],this._cacheForFuture=!1,this._modelId=oe++,this._builderCache=null,this._uniqueId=(0,se.randomHashN)(6),this._resolution=t,this._symbolInfo=e,this._valid=Boolean(e.timezone)&&Boolean(e.session),this._session=new ee.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections)}syncSourceTarget(){return{uniqueId:this._uniqueId,resolution:this._resolution,session:this._session.state()}}getSymbolInfo(){return this._symbolInfo}getSession(){return this._session}getResolution(){return this._resolution}uniqueId(){return this._modelId}distance(e,t){if(!this.isValid())return{success:!1};if(e>t)return{success:!1};if(e===t)return{success:!0,result:0};let i=this._extrapolatedData.length,s=0!==i?this._extrapolatedData[0]:null,o=null!==s?this._extrapolatedData[i-1]:null;const n=e<t;if(1e3*e===s&&this._cacheForFuture===n||(this._extrapolatedData=[1e3*e],i=1,s=null,o=null),null===s||null!==o&&1e3*t>o){const s=(0,ie.extrapolateBarsFrontToTime)(this.barBuilder(),o||1e3*e,1e3*t,2e3,!0);this._extrapolatedData=this._extrapolatedData.concat(s.times),i=this._extrapolatedData.length,this._cacheForFuture=n}if(o=this._extrapolatedData[i-1],o<1e3*t)return{success:!1};const r=this._extrapolatedData.indexOf(1e3*t);return-1===r?{success:!1}:{success:!0,result:r}}projectTime(e,t){if(!this.isValid())return e;let i=this._extrapolatedData.length,s=i>0?this._extrapolatedData[0]:null,o=null!==s?this._extrapolatedData[i-1]:null;const n=t>=0;1e3*e===s&&this._cacheForFuture===n||(this._extrapolatedData=[1e3*e],i=1,s=null,o=null);const r=Math.abs(t);if(null===s||r>=i){const s=(0,ie.extrapolateBarsFrontByCount)(this.barBuilder(),o||1e3*e,Math.sign(t)*(r-i+1),!0);this._extrapolatedData=this._extrapolatedData.concat(s.times),i=this._extrapolatedData.length,this._cacheForFuture=n}return i<r?e:this._extrapolatedData[r]/1e3}isValid(){return this._valid}dataSize(){return this._extrapolatedData.length}createNewModelWithResolution(e){return new ne(this._symbolInfo,e)}barBuilder(){return null===this._builderCache&&(this._builderCache=(0,te.newBarBuilder)(this._resolution,this._session,this._session)),this._builderCache}}var re=i(62773),ae=i(50888);i(59149);(0,n.getLogger)("Chart.Definitions.Series");function le(e,t){return"TickByTick"===e?{mode:e,updatePeriod:t}:{mode:e}}async function ce(e,t,i){const s=[];return(0,ae.isDelay)(e.delay)?async function(e){const t=[];return(0,ae.witoutRealtime)(e)?t.push(le("DelayNoRealtime")):t.push(le("DelayToRealtime")),t}(e):(0,ae.isEod)(e,t)?(s.push(le("EOD")),s):s}class he{constructor(e,t,i){this._dataUpdatedInfoStatus=new re.WatchedObject(null),this._symbolInfo=e,this._status=t,this._updatePeriod=i,this._symbolInfo.subscribe(this._update.bind(this)),this._status.subscribe(this._update.bind(this)),this._updatePeriod.subscribe(this._update.bind(this))}destroy(){this._symbolInfo.release(),this._status.release(),this._updatePeriod.release()}status(){return this._dataUpdatedInfoStatus.readonly()}symbolName(){const e=this._symbolInfo.value();return null!==e?e.name:""}
time(){const e=this._symbolInfo.value(),t=null!==e&&e.delay&&e.delay>0?e.delay:900;return Math.round(t/60)}listedExchange(){const e=this._symbolInfo.value();return null!==e?(0,g.getSymbolListedExchange)(e):""}async description(){const e=this._symbolInfo.value();if(null===e)return"";return{}.description||e.listed_exchange}tradedExchange(){const e=this._symbolInfo.value();return null!==e?(0,g.getSymbolTradedExchange)(e):""}proName(){const e=this._symbolInfo.value();return null!==e?e.pro_name:""}country(){return this._symbolInfo.value()?.country||""}proPerm(){const e=this._symbolInfo.value();return null!==e?e.pro_perm:""}firstReplacedByBatsExchange(){const e=this._symbolInfo.value();return e&&(0,ae.firstReplacedByBatsExchange)(e)}isSpread(){const e=this._symbolInfo.value();return null!==e&&"spread"===e.type}isDelay(){const e=this._symbolInfo.value();return Boolean(e?.delay)}async _update(){const e=this._symbolInfo.value();if(null===e)return void this._dataUpdatedInfoStatus.setValue(null);const t=this._status.value();if("string"==typeof t)return void this._dataUpdatedInfoStatus.setValue(null);if(2===t||1===t)return;const i=await ce(e,t,this._updatePeriod.value());0!==i.length?this._dataUpdatedInfoStatus.setValue(i):this._dataUpdatedInfoStatus.setValue(null)}}i(32925);var de=i(87465);(0,n.getLogger)("Chart.DataProblemModel");class ue{constructor(e,t){this._mainDataProblem=new re.WatchedObject(null),this._supportPortalProblems=new re.WatchedObject([]),this._allDataProblems=new re.WatchedObject([]),this._pushStreamHandler=null,this._destroyed=!1,this._quotesProvider=e,this._quotesProvider.quotesUpdate().subscribe(this,this._update.bind(this)),this._symbolInfo=t,this._symbolInfo.subscribe((e=>{e||this._mainDataProblem.setValue(null)})),this._mainDataProblem.subscribe((()=>this._updateAllDataProblems())),this._supportPortalProblems.subscribe((()=>this._updateAllDataProblems())),this._requestSupportPortalProblems()}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._symbolInfo.release(),this._destroyed=!0}dataProblems(){return this._allDataProblems}_resetStatus(){this._mainDataProblem.setValue(null)}_update(e){void 0===e.values||void 0===e.values.data_problem?this._resetStatus():this._mainDataProblem.setValue((0,de.clone)(e.values.data_problem))}_updateAllDataProblems(){const e=this._mainDataProblem.value(),t=this._supportPortalProblems.value();this._allDataProblems.setValue(null===e?t:[e,...t])}async _requestSupportPortalProblems(){0}}var _e=i(57025),pe=i(52859),me=i(36281),ge=i(97902),fe=i(97725),ye=i(52945),ve=i(40472);const Se=C.enabled("force_exchange_as_title"),be=C.enabled("chart_style_hilo_last_price");const we={alwaysShowGlobalLast:!1,visibleOnHistoryOnly:!1,showCountdown:!0,showSymbolLabel:!0,useSolidBodyColor:!0};class Ce extends me.PriceAxisView{constructor(e,t,i){super(),this._previousCountdown="",this._source=e,this._model=t,this._options={...we,...i}}updateCountdown(){this._countdownText()!==this._previousCountdown&&(this.update((0,ve.sourceChangeEvent)(this._source.id())),
this._model.updateSourcePriceScale(this._source))}_getSource(){return this._source}_getModel(){return this._model}_isCountdownEnabled(){return this._options.showCountdown}_countdownText(){const e=Q.Interval.parse(this._source.interval());if(e.isDWM()||e.isTicks()||e.isSeconds()&&1===e.multiplier())return"";const t=this._source.data().bars().last();if(null===t)return"";const i=1e3*(0,o.ensure)(t.value[0]),s=Q.Interval.parse(this._source.interval()).inMilliseconds(),n=i.valueOf()+s;let r=Math.round((n-this._currentTime())/1e3);if(r<=0)return"";r=Math.min(r,s/1e3);let a=null;r>=3600&&(a=(0,fe.addLeadingZero)(Math.floor(r/3600))),r%=3600;const l=(0,fe.addLeadingZero)(Math.floor(r/60));r%=60;const c=(0,fe.addLeadingZero)(Math.floor(r));return null!==a?`${a}:${l}:${c}`:`${l}:${c}`}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,!this._source.isVisible())return;const s=this._source.properties().childs();if(!be&&12===s.style.value())return;const n=this._model.timeScale().visibleBarsStrictRange(),r=this._source.data().last();if(null===n||null===r)return;if(this._options.visibleOnHistoryOnly&&n.contains(r.index))return;const a=this._model.properties().childs().scalesProperties.childs();let l=a.showSeriesLastValue.value(),c=this._isCountdownEnabled()&&s.showCountdown.value()&&(12===(h=s.style.value())?be:(0,g.isTimeBasedStyle)(h))&&(this._options.alwaysShowGlobalLast||n.contains(r.index));var h;let d=this._options.showSymbolLabel&&a.showSymbolLabels.value();const u=a.seriesLastValueMode.value()===ge.PriceAxisLastValueMode.LastPriceAndPercentageValue,_=this._source.lastValueData(void 0,this._options.alwaysShowGlobalLast);if(_.noData)return;const p=8===s.style.value();if((l||c||d)&&p&&s.haStyle.childs().showRealLastPrice.value()){const e=this._source.lastValueData(void 0,!1),t=this._source.lastValueData(void 0,!0);e.noData||t.noData||e.index!==t.index||(l=!1,c=!1,d=!1)}const m=(0,pe.resetTransparency)(this._source.priceLineColor(_.color));if(this._options.useSolidBodyColor?(i.background=m,i.borderColor=void 0):(i.background=this._model.backgroundColorAtYPercentFromTop((i.fixedCoordinate??i.coordinate)/(0,o.ensureNotNull)(this._model.paneForSource(this._source)).height()),i.borderColor=m),i.coordinate=_.coordinate,i.floatCoordinate=_.floatCoordinate,l||c){const t=this._axisFirstLineText(_,l);e.text=t,this._options.useSolidBodyColor?(i.textColor=this.generateTextColor(i.background),e.borderVisible=!1):(e.borderVisible=!0,i.textColor=m),e.textColor=i.textColor;const s=l&&u?(0,ye.getOppositeModePriceText)(this._source.priceScale(),_):"";e.secondLine=s,i.secondLineTextColor=i.textColor;const o=c?this._countdownText():"";this._previousCountdown=o,e.thirdLine=o,i.thirdLineTextColor=(0,pe.generateColor)(i.textColor,25),0===t.length&&0===s.length&&0===o.length||(e.visible=!0)}d&&(t.text=this._paneText(d),t.visible=t.text.length>0)}_paneText(e){let t="";const i=this._source.aliasSymbolInfo();return Se?t=(0,g.displayedSymbolExchange)(i):e&&(t=(0,g.displayedSymbolName)(i)),t}_axisFirstLineText(e,t){return t?(0,
ye.getCurrentModePriceText)(this._source.priceScale(),e):""}_currentTime(){return window.ChartApiInstance.serverTime()}}var Te=i(18113),Pe=i(67225),xe=i(30693);class Me extends Ce{lastPrice(){return this._getSource().data().lastProjectionPrice}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const s=this._getModel(),n=this._getSource(),r=n.priceScale(),a=s.timeScale(),l=this.lastPrice();if(a.isEmpty()||r.isEmpty()||void 0===l)return;const c=a.visibleBarsStrictRange();if(null===c)return;const h=c.firstBar(),d=c.lastBar(),u=n.data(),p=u.search(d,_.PlotRowSearchMode.NearestLeft);if(null===p)return;const m=n.nearestIndex(h,_.PlotRowSearchMode.NearestRight);if(void 0===m)return;const g=n.model().properties().childs().scalesProperties.childs(),f=(0,o.ensureNotNull)(u.valueAt(m))[4];let y=i.background,v=g.showSeriesLastValue.value(),S=!1,b=!1,w=!1;const C=n.lastValueData(4,!1),T=n.properties().childs();if(8===T.style.value()&&T.haStyle.childs().showRealLastPrice.value()){const e=n.lastValueData(4,!0);if(e.noData||e.color===i.background||(y=(0,pe.resetTransparency)(e.color)),!e.noData&&!C.noData){const t=e.index===C.index;S=t&&g.showSymbolLabels.value(),b=g.seriesLastValueMode.value()===ge.PriceAxisLastValueMode.LastPriceAndPercentageValue,v=v&&t,w=t&&this._isCountdownEnabled()&&T.showCountdown.value()}}else{const e=n.barColorer().barStyle(p.index,!0);y=(0,pe.resetTransparency)(e.barColor)}if(i.background=y,i.textColor=this.generateTextColor(y),i.secondLineTextColor=i.textColor,i.thirdLineTextColor=(0,pe.generateColor)(i.textColor,25),i.coordinate=r.priceToCoordinate(l,f),e.visible=v||w,!C.noData){const i=n.priceScale().isPercentage();C.formattedPriceAbsolute=r.formatPriceAbsolute(l),C.formattedPricePercentage=r.formatPricePercentage(l,f,{signPositive:!0}),C.text=i?C.formattedPricePercentage:C.formattedPriceAbsolute,e.text=this._axisFirstLineText(C,v),e.secondLine=v&&b?i?C.formattedPriceAbsolute:C.formattedPricePercentage:"",e.thirdLine=w?this._countdownText():"",t.text=this._paneText(S)}t.visible=S}}var Ie=i(69555),Ae=i(40738),Le=i(58978),ke=i(69558);const Ee={light:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,backgroundColor:Le.colorsPalette["color-tv-blue-50"],lineColor:Le.colorsPalette["color-cold-gray-500"]},dark:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,backgroundColor:Le.colorsPalette["color-tv-blue-a800"],lineColor:Le.colorsPalette["color-cold-gray-500"]}};function De(e){return e?Ee.dark:Ee.light}class Be extends Ae.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._isVisible=t.lineVisible,this._lineColor=t.lineColor,this._lineWidth=t.lineWidth,this._getValue=i}_updateImpl(){const e=this._lineRendererData;if(e.visible=!1,!this._isVisible.value())return;const t=this._model.mainSeries(),i=t.priceScale(),s=t.firstValue(),o=this._getValue();if(null===s||null===o)return;const n=De(this._model.dark().value()),r=this._lineColor.value()||n.lineColor,a=this._lineWidth.value()||n.lineWidth;e.visible=!0,e.y=i.priceToCoordinate(o,s),e.linestyle=n.lineStyle,e.linewidth=a,e.color=r}}
class Ve extends me.PriceAxisView{constructor(e,t,i,s){super(),this._model=e,this._label=t,this._isVisible=i.labelVisible,this._backgroundColor=i.lineColor,this._getValue=s}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,!this._isVisible.value())return;const s=this._model.mainSeries(),o=s.priceScale(),n=s.firstValue(),r=this._getValue();if(null===n||null===r)return;const a=De(this._model.dark().value()),l=(0,pe.resetTransparency)(this._backgroundColor.value()||a.backgroundColor);e.visible=!0,t.visible=!0,e.text=o.formatPriceAbsolute(r),t.text=this._label,i.coordinate=o.priceToCoordinate(r,n),i.background=l,i.textColor=this.generateTextColor(l)}}class Re extends xe.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return De(this._model.dark().value()).lineWidth}_lineStyle(){return De(this._model.dark().value()).lineStyle}_priceLineColor(e){return De(this._model.dark().value()).lineColor}_value(){const e=this._model.mainSeries(),t=e.priceScale(),i=e.firstValue(),s=this._getValue();if(null===i||null===s)return{noData:!0};const o=t.priceToCoordinate(s,i);return{noData:!1,floatCoordinate:o,coordinate:o,color:"",formattedPricePercentage:"",formattedPriceAbsolute:"",formattedPriceIndexedTo100:"",text:"",index:0}}}var Ne;!function(e){e[e.High=0]="High",e[e.Low=1]="Low"}(Ne||(Ne={}));const Oe=w.t(null,void 0,i(78254)),Fe=w.t(null,void 0,i(65318));function We(e,t,i,s){const o=new Be(e,i,s),n=new Ve(e,i.label,i,s);return{paneView:o,panePriceAxisView:new Ie.PanePriceAxisView(n,t,e),priceAxisView:n,priceLineAxisView:new Re(e,i.lineVisible,s)}}const He={light:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:(0,Le.getHexColorByName)("color-cold-gray-900"),backgroundColor:(0,Le.getHexColorByName)("color-tv-blue-50"),lineColor:(0,Le.getHexColorByName)("color-cold-gray-500")},dark:{lineStyle:ke.LINESTYLE_DOTTED,lineWidth:1,textColor:(0,Le.getHexColorByName)("color-white"),backgroundColor:(0,Le.getHexColorByName)("color-tv-blue-a800"),lineColor:(0,Le.getHexColorByName)("color-cold-gray-500")}};function ze(e){return e?He.dark:He.light}class Ue extends Ae.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._isVisible=t.lineVisible,this._lineColor=t.lineColor,this._lineWidth=t.lineWidth,this._getValue=i}_updateImpl(){const e=this._lineRendererData;if(e.visible=!1,!this._isVisible.value())return;const t=this._model.mainSeries(),i=t.priceScale(),s=t.firstValue(),o=this._getValue();if(null===s||null===o)return;const n=ze(this._model.dark().value()),r=this._lineColor.value()?this._lineColor.value():n.lineColor,a=this._lineWidth.value()?this._lineWidth.value():n.lineWidth;e.visible=!0,e.y=i.priceToCoordinate(o,s),e.linestyle=n.lineStyle,e.linewidth=a,e.color=r}}class je extends me.PriceAxisView{constructor(e,t,i,s){super(),this._model=e,this._label=t,this._isVisible=i,this._getValue=s}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,!this._isVisible.value())return
;const s=this._model.mainSeries(),o=s.priceScale(),n=s.firstValue(),r=this._getValue();if(null===n||null===r)return;const a=ze(this._model.dark().value());e.visible=!0,t.visible=!0,e.text=o.formatPriceAbsolute(r),t.text=this._label,i.coordinate=o.priceToCoordinate(r,n),i.background=a.backgroundColor,i.textColor=a.textColor}}class Ge extends xe.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return ze(this._model.dark().value()).lineWidth}_lineStyle(){return ze(this._model.dark().value()).lineStyle}_priceLineColor(e){return ze(this._model.dark().value()).lineColor}_value(){const e=this._model.mainSeries(),t=e.priceScale(),i=e.firstValue(),s=this._getValue();if(null===i||null===s)return{noData:!0};const o=t.priceToCoordinate(s,i);return{noData:!1,floatCoordinate:o,coordinate:o,color:"",formattedPricePercentage:"",formattedPriceAbsolute:"",formattedPriceIndexedTo100:"",text:"",index:0}}}var qe;!function(e){e[e.Avg=0]="Avg"}(qe||(qe={}));const $e=w.t(null,void 0,i(73025));function Ke(e,t,i,s){const o=i.childs(),n=function(e,t,i,s){const o=new Ue(e,i,s),n=new je(e,i.label,i.labelVisible,s),r=new Ie.PanePriceAxisView(n,t,e),a=new Ge(e,i.lineVisible,s);return{paneView:o,panePriceAxisView:r,priceAxisView:n,priceLineAxisView:a}}(e,t,{label:$e,labelVisible:o.averageClosePriceLabelVisible,lineVisible:o.averageClosePriceLineVisible,lineColor:o.averagePriceLineColor,lineWidth:o.averagePriceLineWidth},(()=>s(0)));return{paneViews:[n.paneView],panePriceAxisViews:[n.panePriceAxisView],priceAxisViews:[n.priceAxisView],priceLineAxisViews:[n.priceLineAxisView]}}var Ye=i(3885);const Ze={open:w.t(null,{context:"in_legend"},i(46728)),high:w.t(null,{context:"in_legend"},i(43253)),low:w.t(null,{context:"in_legend"},i(89923)),close:w.t(null,{context:"in_legend"},i(2696)),hl2:w.t(null,{context:"in_legend"},i(61372)),hlc3:w.t(null,{context:"in_legend"},i(55096)),ohlc4:w.t(null,{context:"in_legend"},i(94174))},Xe=W.CheckMobile.any();class Je extends Ye.SeriesValuesProvider{constructor(e,t){super(e,t);const i=t.properties().childs().paneProperties.childs().legendProperties.childs();this._showBarChangeProp=i.showBarChange,this._showLastDayChangeProp=i.showLastDayChange,this._showSeriesOHLCProp=i.showSeriesOHLC,this._showVolumeProp=i.showVolume,this._showSeriesLegendCloseOnMobile=i.showSeriesLegendCloseOnMobile,this._seriesStyleProp=e.properties().childs().style;const s=this._emptyValues[0],o=this._emptyValues[1],n=this._emptyValues[2];s.title=Ze.open,o.title=Ze.high,n.title=Ze.low,s.unimportant=!0,o.unimportant=!0,n.unimportant=!0,this._emptyValues[6].title="",this._emptyValues[8].title="",this._emptyValues[4].title=""}getValues(e){const t=super.getValues(e),i=this._series.style(),s=12!==i,o=this._showOHLC(),n=s&&this._showBarChangeProp.value(),r=s&&this._showLastDayChange(),a=!Xe||this._showSeriesLegendCloseOnMobile.value(),l=this._mobileNonTrackingMode();if(this._showLastPriceAndChangeOnly()){const e=t[5]
;return e.visible=e.visible&&o&&a&&l,t[6].visible&&=n,t[8].visible=!1,t}const c=12!==i&&16!==i&&21!==i,h=12!==i,d=this._series.intervalObj().value().is1Tick(),u=t[7];u.visible=u.visible&&this._showVolumeProp.value();const _=(0,g.isPriceSourceStyle)(this._seriesStyleProp.value()),p=o&&!_,m=o&&_;if(t[0].visible=p&&c&&!d,t[1].visible=p&&!d,t[2].visible=p&&!d,t[3].visible=p&&h,t[3].title=d?"":Ze.close,t[4].visible=m,t[6].visible&&=n,t[8].visible&&=r,16===i){const e=this._series.properties().childs().hlcAreaStyle.childs();t[1].color=e.highLineColor.value(),t[2].color=e.lowLineColor.value(),t[3].color=e.closeLineColor.value()}return t}_showOHLC(){return this._showSeriesOHLCProp.value()}_showLastDayChange(){return this._showLastDayChangeProp.value()}}class Qe extends Je{_showOHLC(){return!0}_showLastDayChange(){return!1}}var et,tt=i(48096),it=i(36597),st=i(60911),ot=i(10555);class nt{constructor(){this._data=null}setData(e){this._data=e}data(){return this._data}draw(e,t){const i=this._data;if(null===i)return;const{horizontalPixelRatio:s,verticalPixelRatio:o}=t;e.save();const n=Math.max(1,Math.floor(s)),r=n%2/2,a=Math.round(i.center.x*s)+r,l=i.center.y*o;e.fillStyle=i.seriesLineColor,e.beginPath();const c=Math.max(2,1.5*i.seriesLineWidth)*s;e.arc(a,l,c,0,2*Math.PI,!1),e.fill(),e.fillStyle=i.fillColor,e.beginPath(),e.arc(a,l,i.radius*s,0,2*Math.PI,!1),e.fill(),e.lineWidth=n,e.strokeStyle=i.strokeColor,e.beginPath(),e.arc(a,l,i.radius*s+n/2,0,2*Math.PI,!1),e.stroke(),e.restore()}hitTest(e){return null}}function rt(e){return e}!function(e){e[e.AnimationPeriod=2600]="AnimationPeriod",e[e.Stage1Period=.25]="Stage1Period",e[e.Stage2Period=.275]="Stage2Period",e[e.Stage3Period=.475]="Stage3Period",e[e.Stage1StartCircleRadius=4]="Stage1StartCircleRadius",e[e.Stage1EndCircleRadius=10]="Stage1EndCircleRadius",e[e.Stage1StartFillAlpha=.25]="Stage1StartFillAlpha",e[e.Stage1EndFillAlpha=0]="Stage1EndFillAlpha",e[e.Stage1StartStrokeAlpha=.4]="Stage1StartStrokeAlpha",e[e.Stage1EndStrokeAlpha=.8]="Stage1EndStrokeAlpha",e[e.Stage2StartCircleRadius=10]="Stage2StartCircleRadius",e[e.Stage2EndCircleRadius=14]="Stage2EndCircleRadius",e[e.Stage2StartFillAlpha=0]="Stage2StartFillAlpha",e[e.Stage2EndFillAlpha=0]="Stage2EndFillAlpha",e[e.Stage2StartStrokeAlpha=.8]="Stage2StartStrokeAlpha",e[e.Stage2EndStrokeAlpha=0]="Stage2EndStrokeAlpha",e[e.Stage3StartCircleRadius=14]="Stage3StartCircleRadius",e[e.Stage3EndCircleRadius=14]="Stage3EndCircleRadius",e[e.Stage3StartFillAlpha=0]="Stage3StartFillAlpha",e[e.Stage3EndFillAlpha=0]="Stage3EndFillAlpha",e[e.Stage3StartStrokeAlpha=0]="Stage3StartStrokeAlpha",e[e.Stage3EndStrokeAlpha=0]="Stage3EndStrokeAlpha"}(et||(et={}));const at=[{start:0,end:.25,startRadius:4,endRadius:10,startFillAlpha:.25,endFillAlpha:0,startStrokeAlpha:.4,endStrokeAlpha:.8,easing:rt},{start:.25,end:.525,startRadius:10,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:.8,endStrokeAlpha:0,easing:rt},{start:.525,end:1,startRadius:14,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:0,endStrokeAlpha:0,easing:rt}]
;function lt(e,t,i,s){const o=i+(s-i)*t;return(0,pe.applyTransparency)(e,(0,pe.alphaToTransparency)(o))}const ct=(0,Le.getHexColorByName)("color-minty-green-400"),ht=(0,Le.getHexColorByName)("color-ripe-red-500");function dt(e,t,i){const s=e%2600/2600;let o;for(const e of at)if(s>=e.start&&s<=e.end){o=e;break}if(void 0===o)throw new Error("Last price animation internal logic error");const n=o.easing((s-o.start)/(o.end-o.start));return{fillColor:lt(i,n,o.startFillAlpha,o.endFillAlpha),strokeColor:lt(i,n,o.startStrokeAlpha,o.endStrokeAlpha),radius:(r=n,a=o.startRadius,l=o.endRadius,a+(l-a)*r)};var r,a,l}class ut{constructor(e){this._renderer=new nt,this._invalidated=!0,this._stageInvalidated=!0,this._startTime=performance.now(),this._endTime=this._startTime-1,this._prevRenderedPrice=null,this._series=e}update(e){if(this._invalidated=!0,"data-source-change"===e.type&&e.sourceId===this._series.id()&&e.realtime&&this._series.seriesLoaded()){const e=performance.now(),t=this._endTime-e;if(t>0)return void(t<650&&(this._endTime+=2600));this._startTime=e,this._endTime=e+2600}}invalidateStage(){this._stageInvalidated=!0}animationActive(){return performance.now()<=this._endTime}stopAnimation(){this._endTime=this._startTime-1}renderer(e){return this._invalidated?(this._updateImpl(e),this._invalidated=!1,this._stageInvalidated=!1):this._stageInvalidated&&(this._updateRendererDataStage(),this._stageInvalidated=!1),this._renderer}_updateImpl(e){this._renderer.setData(null);const t=this._series.model().timeScale(),i=t.visibleBarsStrictRange(),s=this._series.firstValue(),o=this._series.lastValueData(void 0,!0,!0);if(null===i||null===s||void 0===o.index||void 0===o.price||!i.contains(o.index))return;const n=new ot.Point(t.indexToCoordinate(o.index),this._series.priceScale().priceToCoordinate(o.price,s)),r=o.color,a=this._series.properties().childs();let l;switch(this._series.style()){case 3:l=a.areaStyle.childs().linewidth.value();break;case 10:const t=a.baselineStyle,i=Math.round(e.mediaSize.height*(Math.abs(100-t.childs().baseLevelPercentage.value())/100));l=n.y<=i?t.childs().topLineWidth.value():t.childs().bottomLineWidth.value();break;case 14:l=a.lineWithMarkersStyle.childs().linewidth.value();break;case 15:l=a.steplineStyle.childs().linewidth.value();break;default:l=a.lineStyle.childs().linewidth.value()}this._lastBaseColor=null===this._prevRenderedPrice||this._prevRenderedPrice===o.price?r:this._prevRenderedPrice<o.price?ct:ht;const c=dt(this._duration(),0,this._lastBaseColor);this._renderer.setData({seriesLineColor:r,seriesLineWidth:l,fillColor:c.fillColor,strokeColor:c.strokeColor,radius:c.radius,center:n}),this._prevRenderedPrice=o.price}_updateRendererDataStage(){const e=this._renderer.data();if(null!==e){const t=dt(this._duration(),e.seriesLineColor,this._lastBaseColor);e.fillColor=t.fillColor,e.strokeColor=t.strokeColor,e.radius=t.radius}}_duration(){return this.animationActive()?performance.now()-this._startTime:2599}}var _t=i(51304),pt=i(22613),mt=i(29806),gt=i(98155);class ft{constructor(){this._created=new tt.Delegate,
this._modified=new tt.Delegate,this._loading=new tt.Delegate,this._completed=new tt.Delegate,this._error=new tt.Delegate,this._symbolError=new tt.Delegate,this._symbolResolved=new tt.Delegate,this._seriesError=new tt.Delegate,this._symbolNotPermitted=new tt.Delegate,this._symbolInvalid=new tt.Delegate,this._symbolGroupNotPermitted=new tt.Delegate,this._chartTypeNotPermitted=new tt.Delegate,this._intradaySpreadNotPermitted=new tt.Delegate,this._intradayExchangeNotPermitted=new tt.Delegate,this._customIntervalNotPermitted=new tt.Delegate,this._secondsIntervalNotPermitted=new tt.Delegate,this._ticksIntervalNotPermitted=new tt.Delegate,this._barReceived=new tt.Delegate,this._seriesTimeFrame=new tt.Delegate,this._dataUpdated=new tt.Delegate,this._unsupportedResolutionRequested=new tt.Delegate}destroy(){this._created.destroy(),this._modified.destroy(),this._loading.destroy(),this._completed.destroy(),this._error.destroy(),this._symbolError.destroy(),this._symbolResolved.destroy(),this._seriesError.destroy(),this._symbolInvalid.destroy(),this._symbolNotPermitted.destroy(),this._symbolGroupNotPermitted.destroy(),this._chartTypeNotPermitted.destroy(),this._intradaySpreadNotPermitted.destroy(),this._intradayExchangeNotPermitted.destroy(),this._customIntervalNotPermitted.destroy(),this._secondsIntervalNotPermitted.destroy(),this._ticksIntervalNotPermitted.destroy(),this._barReceived.destroy(),this._seriesTimeFrame.destroy(),this._dataUpdated.destroy(),this._unsupportedResolutionRequested.destroy()}created(){return this._created}modified(){return this._modified}loading(){return this._loading}completed(){return this._completed}error(){return this._error}symbolError(){return this._symbolError}symbolResolved(){return this._symbolResolved}seriesError(){return this._seriesError}symbolInvalid(){return this._symbolInvalid}symbolNotPermitted(){return this._symbolNotPermitted}symbolGroupNotPermitted(){return this._symbolGroupNotPermitted}chartTypeNotPermitted(){return this._chartTypeNotPermitted}intradaySpreadNotPermitted(){return this._intradaySpreadNotPermitted}intradayExchangeNotPermitted(){return this._intradayExchangeNotPermitted}customIntervalNotPermitted(){return this._customIntervalNotPermitted}secondsIntervalNotPermitted(){return this._secondsIntervalNotPermitted}ticksIntervalNotPermitted(){return this._ticksIntervalNotPermitted}barReceived(){return this._barReceived}seriesTimeFrame(){return this._seriesTimeFrame}dataUpdated(){return this._dataUpdated}unsupportedResolutionRequested(){return this._unsupportedResolutionRequested}fireCompleted(e){this._completed.fire(e)}fireCreated(e){this._created.fire(e)}fireModified(){this._modified.fire()}fireLoading(e){this._loading.fire(e)}fireError(){this._error.fire()}fireSymbolError(e){this._symbolError.fire(e),this.fireError()}fireSymbolResolved(e){this._symbolResolved.fire(e)}fireSeriesError(e){this._seriesError.fire(e),this.fireError()}fireSymbolInvalid(){this._symbolInvalid.fire()}fireSymbolNotPermitted(e){this._symbolNotPermitted.fire(e)}fireSymbolGroupNotPermitted(e){
this._symbolGroupNotPermitted.fire(e)}fireChartTypeNotPermitted(e){this._chartTypeNotPermitted.fire(e),this.fireError()}fireIntradaySpreadNotPermitted(){this._intradaySpreadNotPermitted.fire(),this.fireError()}fireIntradayExchangeNotPermitted(){this._intradayExchangeNotPermitted.fire(),this.fireError()}fireCustomIntervalNotPermitted(e){this._customIntervalNotPermitted.fire(e),this.fireError()}fireSecondsIntervalNotPermitted(){this._secondsIntervalNotPermitted.fire(),this.fireError()}fireTicksIntervalNotPermitted(){this._ticksIntervalNotPermitted.fire(),this.fireError()}fireBarReceived(e){this._barReceived.fire(e)}fireSeriesTimeFrame(e,t,i,s,o){this._seriesTimeFrame.fire(e,t,i,s,o)}fireDataUpdated(e,t,i,s,o){this._dataUpdated.fire(e,t,i,s,o)}fireUnsupportedResolutionRequested(){this._unsupportedResolutionRequested.fire()}}var yt=i(77380);const vt=(0,n.getLogger)("Chart.SeriesDataSource");var St;!function(e){e[e.Idle=0]="Idle",e[e.AwaitingConnection=1]="AwaitingConnection",e[e.AwaitingFirstDataUpdate=2]="AwaitingFirstDataUpdate",e[e.Active=3]="Active"}(St||(St={}));let bt=1;let wt=1;function Ct(e){return e.startDate?e.endDate||e.count?e.endDate?["from_to",e.startDate,e.endDate]:["bar_count",e.startDate,(0,o.ensure)(e.count)]:["from_to",e.startDate]:e.count||300}function Tt(e){return(0,st.extractExtendedSymbol)(e).symbol}class Pt{constructor(e,t,i,s){this._extSymbol=null,this._lastResolvedSymbol="",this._createSeriesOverriddenParams=0,this._instanceId=null,this._symbolInstanceId=null,this._resolution=null,this._timeFrame=null,this._data=new d.SeriesData,this._dataEvents=new ft,this._status=St.Idle,this._turnaroundCounter=1,this._boundOnGatewayIsConnectedChanged=this._onGatewayIsConnectedChanged.bind(this),this._ongoingDataUpdate=Promise.resolve(),this._gateway=e,this._turnaroundPrefix=t,this._createSeriesParams=Ct(i??{count:300}),this._timeFrame=s||null,this._gateway.isConnected().subscribe(this._boundOnGatewayIsConnectedChanged)}destroy(){this.stop(),this._gateway.isConnected().unsubscribe(this._boundOnGatewayIsConnectedChanged),this._dataEvents.destroy()}canModifySeries(e,t){const i=!(0,de.deepEquals)(this._extSymbol,e)[0],s=null===this._resolution||!Q.Interval.isEqual(this._resolution,t);return i||s}modifySeries(e,t,i=null,s=!1,n=null){s&&(vt.logNormal("Due to force flag clearing symbol & resolution to force re-requesting data."),this._extSymbol=null,this._resolution=null);const r=Tt(e),a=!this.symbolSameAsResolved(r);if(a&&(this._lastResolvedSymbol=""),this._extSymbol&&!a){const t=Tt(this._extSymbol);(0,st.replaceExtendedSymbol)(e,t)}const l=this._extSymbol,c=this._resolution;if(this._extSymbol=e,this._resolution=t,null===this._instanceId)return void(this._timeFrame=i);const h=!(0,de.deepEquals)(l,e)[0];h&&(0,st.replaceExtendedSymbol)(this._extSymbol,r);const d=null===c||!Q.Interval.isEqual(c,t);(h||d||null!==i)&&(this._timeFrame=null,(h||d)&&this._turnaroundCounter++,h&&this._resolveSymbol(),this._gateway.modifySeries(this._instanceId,this.turnaround(),(0,
o.ensureNotNull)(this._symbolInstanceId),this._resolution,n,i,this._onMessage.bind(this)),this._dataEvents.fireModified())}requestMoreData(e){null!==this._instanceId&&this._gateway.requestMoreData(this._instanceId,e,this._onMessage.bind(this))}requestMoreTickmarks(e){null!==this._instanceId&&this._gateway.requestMoreTickmarks(this._instanceId,e,this._onMessage.bind(this))}setFutureTickmarksMode(e){null!==this._instanceId&&this._gateway.setFutureTickmarksMode(e)}isStarted(){return this._status!==St.Idle}isActive(){return this._status===St.Active}resolution(){return this._resolution}start(){this.isStarted()?vt.logNormal("start: data source is already started, nothing to do"):((0,o.assert)(null!==this._extSymbol,"symbol must be set before start"),(0,o.assert)(null!==this._resolution,"resolution must be set before start"),this._gateway.isConnected().value()?this._createSeries():this._changeStatusTo(St.AwaitingConnection))}stop(){this.isStarted()?(null!==this._instanceId&&(this._gateway.removeSeries(this._instanceId),this._instanceId=null),this._symbolInstanceId=null,this._changeStatusTo(St.Idle)):vt.logNormal("stop: data source is already stopped, nothing to do")}instanceId(){return this._instanceId}data(){return this._data}setData(e){this._data=e}setTimeframe(e){this._timeFrame=e}clearData(){this.isStarted()?this._enqueueUpdate((()=>this._clearDataImpl())):this._clearDataImpl()}dataEvents(){return this._dataEvents}turnaround(){return`${this._turnaroundPrefix}${this._turnaroundCounter}`}symbolInstanceId(){return this._symbolInstanceId}symbol(){return this._extSymbol}updateExtSymbol(e){this._extSymbol=e}moveData(e){return this._enqueueUpdate((()=>this._data.moveData(e)))}setInitialRequestOptions(e){this._createSeriesOverriddenParams=Ct(e)}symbolSameAsResolved(e){return null!==this._extSymbol&&(0,yt.symbolSameAsResolved)(e,Tt(this._extSymbol),this._lastResolvedSymbol)}resolvedSymbol(){return null===this._extSymbol?null:Tt(this._extSymbol)}_resolveSymbol(){null!==this._extSymbol&&(this._symbolInstanceId=this._gateway.resolveSymbol("sds_sym_"+bt++,(0,st.encodeExtendedSymbolOrGetSimpleSymbolString)(this._extSymbol),this._onMessage.bind(this)))}_clearDataImpl(){this._data.clear()}_changeStatusTo(e){(0,o.assert)(this._status!==e,"Source and destination status should be distinct"),vt.logNormal(`Status changed from ${St[this._status]} to ${St[e]}`),this._status=e}_createSeries(){(0,o.assert)(this._status!==St.Active,'Status should not be "Active" when creating a study'),this._instanceId="sds_"+wt++,this._resolveSymbol();const e=this._createSeriesOverriddenParams||this._createSeriesParams;this._createSeriesOverriddenParams&&(this._createSeriesOverriddenParams=0),this._gateway.createSeries(this._instanceId,this.turnaround(),(0,o.ensureNotNull)(this._symbolInstanceId),(0,o.ensureNotNull)(this._resolution),e,this._timeFrame,this._onMessage.bind(this)),this._timeFrame=null,this._changeStatusTo(St.AwaitingFirstDataUpdate),this._dataEvents.fireCreated(this._instanceId)}_onGatewayIsConnectedChanged(e){
e?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===St.AwaitingConnection&&this._createSeries()}_onGatewayDisconnected(){this._status!==St.Idle&&this._status!==St.AwaitingConnection&&(this._instanceId=null,this._changeStatusTo(St.AwaitingConnection)),this._turnaroundCounter=1}_onMessage(e){this._enqueueUpdate((()=>this._onMessageImpl(e)))}async _onMessageImpl(e){switch(e.method){case"symbol_resolved":{const[t,i]=e.params;if(t!==this._symbolInstanceId){null!==this._symbolInstanceId&&vt.logNormal(`Resolve for old symbol, expected: ${this._symbolInstanceId}, actual ${e.params[0]}`);break}this._onSymbolResolved(i);break}case"symbol_error":if(e.params[0]!==this._symbolInstanceId){null!==this._symbolInstanceId&&vt.logNormal(`Symbol error for old symbol, expected: ${this._symbolInstanceId}, actual ${e.params[0]}`);break}this._onSymbolError(e);break;case"series_timeframe":{const[t,i,s,o,n,r,a]=e.params;if(!this._checkTurnaround(t,i)){vt.logNormal(`Time frame for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${i})`);break}this._onSeriesTimeFrame(s,o,n,r,a);break}case"series_error":{const[t,i]=e.params;if(!this._checkTurnaround(t,i)){vt.logNormal(`Series error for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${i})`);break}this._onSeriesError(e.params[2]);break}case"series_loading":{const[t,i]=e.params;if(!this._checkTurnaround(t,i))break;this._onSeriesLoading(e.time);break}case"series_completed":{const[t,i,s,o]=e.params;if(!this._checkTurnaround(t,s)){vt.logNormal(`Series completed for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${t} (${s})`);break}this._onSeriesCompleted(i,e.time,o);break}case"data_update":if(!this._checkTurnaround(e.params.customId,e.params.turnaround)){vt.logNormal(`Data update for old data, expected: ${this._symbolInstanceId} (${this.turnaround()}), actual ${e.params.customId} (${e.params.turnaround})`);break}await this._onDataUpdate(e.params.plots,e.params.nonseries,e.params.lastBar);break;case"clear_data":{if(e.params.turnaround!==this.turnaround()){vt.logNormal(`Clear data for old data, expected: ${this.turnaround()}, actual ${e.params.turnaround}`);break}const t=this._data.first();this._clearDataImpl(),this._dataEvents.fireDataUpdated(void 0,!1,null,!1,t);break}}}_onSeriesError(e){let t,i;if("string"==typeof e)i={error:e},t=e;else if(i=e,e.ctx){const i={};Object.entries(e.ctx).forEach((([e,t])=>{i[e]=t.toString()})),t=e.error.format(i)}else t=e.error;if(t.startsWith("study_not_auth:")){const e=t.split(":",2)[1].split("@",2)[0];if(["BarSetRenko","BarSetPriceBreak","BarSetKagi","BarSetPnF"].includes(e))this._dataEvents.fireChartTypeNotPermitted(e);else{if("BarSetSpread"===e)return void this._dataEvents.fireIntradaySpreadNotPermitted();if("BarSetRange"===e){const e=`${(0,o.ensureNotNull)(this._extSymbol).inputs.range}R`;this._dataEvents.fireCustomIntervalNotPermitted(e)}}}else{
if(t.startsWith("unsupported"))return void this._dataEvents.fireUnsupportedResolutionRequested();"resolution_not_entitled"===t?this._dataEvents.fireIntradayExchangeNotPermitted():"custom_resolution"===t?this._dataEvents.fireCustomIntervalNotPermitted((0,o.ensureNotNull)(this._resolution)):"seconds_not_entitled"===t?this._dataEvents.fireSecondsIntervalNotPermitted():"ticks_not_entitled"===t&&this._dataEvents.fireTicksIntervalNotPermitted()}this._dataEvents.fireSeriesError(i)}_onSeriesTimeFrame(e,t,i,s,o){this._dataEvents.fireSeriesTimeFrame(e,t,i,s??!0,o)}_onSymbolError(e){if(e.params[1]===gt.permissionDenied)switch(e.params[2]){case gt.SymbolErrorPermissionDeniedReason.Symbol:this._dataEvents.fireSymbolNotPermitted(e.params[3]);break;case gt.SymbolErrorPermissionDeniedReason.GroupPermission:this._dataEvents.fireSymbolGroupNotPermitted(e.params[3]);break;default:this._dataEvents.fireSymbolNotPermitted(e.params[2])}else e.params[1]===gt.invalidSymbol&&this._dataEvents.fireSymbolInvalid();this._dataEvents.fireSymbolError(e.params[1])}_onSymbolResolved(e){this._lastResolvedSymbol=(0,o.ensureNotNull)((0,f.extractSymbolNameFromSymbolInfo)(e,"")),this._dataEvents.fireSymbolResolved(e)}async _onDataUpdate(e,t,i){this._onDataUnpacked(e,i,await async function(e){if(void 0===e)return{projectionPlots:[],boxSize:null};if(""===e.d||"nochange"===e.indexes)return null;const t=await(0,mt.unpackNonSeriesData)(e.d);if(null===t||t.indexes_replace)return null;const i=e.indexes,{bars:s,price:o,boxSize:n,reversalAmount:r}=t.data,a=(s||[]).map((e=>{let t;return"factor"in e?t=e.factor:"additionalPrice"in e&&(t=e.additionalPrice),{index:i[e.time],value:[0,e.open,e.high,e.low,e.close,e.volume,t]}}));return{lastPrice:o,projectionPlots:a,reversalAmount:r,boxSize:n}}(t))}_enqueueUpdate(e){return this._ongoingDataUpdate=this._ongoingDataUpdate.then(e,e),this._ongoingDataUpdate}_onDataUnpacked(e,t,i){if(this._status===St.Idle)return;this._status===St.AwaitingFirstDataUpdate&&(this._changeStatusTo(St.Active),this._clearDataImpl());const s=this._data.bars().size(),o=this._data.first(),n=this._data.bars().firstIndex(),r=this._data.mergeRegularBars(e);null!==i&&(this._data.nsBars().clear(),this._data.nsBars().merge(i.projectionPlots),this._data.lastProjectionPrice=i.lastPrice,null!==i.boxSize&&(this._data.boxSize=i.boxSize),this._data.reversalAmount=i.reversalAmount);const a=null===n,l=a||null!==r&&r.index<n;this._dataEvents.fireDataUpdated(t,l,r,a,o),s!==this._data.bars().size()&&null!==r&&this._dataEvents.fireBarReceived(r)}_onSeriesLoading(e){this._dataEvents.fireLoading(e)}_onSeriesCompleted(e,t,i){this._dataEvents.fireCompleted({updateMode:e,time:t,flags:i})}_checkTurnaround(e,t){return this._instanceId===e&&(void 0===t||t===this.turnaround())}}var xt=i(87296),Mt=i(12178);class It extends Ae.HorizontalLinePaneView{constructor(e){super(),this._series=e,this._model=e.model()}}const At=C.enabled("chart_style_hilo_last_price");class Lt extends It{constructor(e){super(e),this._lineRendererData.linestyle=ke.LINESTYLE_DOTTED}_updateImpl(){
this._lineRendererData.visible=!1;const e=this._series.properties().childs();if(!e.showPriceLine.value())return;if(!At&&12===e.style.value())return;const t=8===e.style.value()&&e.haStyle.childs().showRealLastPrice.value(),i=this._series.lastValueData(t?4:void 0,!0);if(i.noData)return;let s=i.coordinate;if(t){const e=this._series.firstValue(),t=this._series.data().lastProjectionPrice;if(null===e||void 0===t)return;s=this._series.priceScale().priceToCoordinate(t,e)}this._lineRendererData.visible=!0,this._lineRendererData.y=s,this._lineRendererData.color=this._series.priceLineColor(i.color),this._lineRendererData.linewidth=e.priceLineWidth.value()}}var kt=i(64651),Et=i(88732),Dt=i(85630),Bt=i(62802),Vt=i(27808),Rt=i(32399),Nt=i(4249),Ot=i(46340),Ft=i(94602),Wt=i(4539),Ht=i(45801),zt=i(48227);class Ut extends Vt.SeriesCandlesPaneView{renderer(){this._invalidated&&(this._updateImpl(null),this._invalidated=!1);const e=this._source.priceScale();if(!e)return null;const t=this._source.properties().childs().haStyle.childs(),i=this._model.timeScale().barSpacing(),s={bars:this._bars,barSpacing:i,bodyVisible:t.drawBody.value(),borderVisible:t.drawBorder.value(),borderColor:t.borderColor.value(),wickColor:t.wickColor.value(),barWidth:(0,Wt.optimalBarWidth)(i),wickVisible:t.drawWick.value(),isPriceScaleInverted:e.isInverted()},o=new Ft.CompositeRenderer;return o.append(new zt.PaneRendererCandles(s)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&o.append(new Ht.SelectionRenderer(this._selectionData)),o}}var jt=i(54405),Gt=i(43501),qt=i(17776),$t=i(70859),Kt=i(2088),Yt=i(35727),Zt=i(88145),Xt=(i(22033),i(36313)),Jt=i(54370);class Qt extends It{constructor(e){super(e)}_updateImpl(){this._lineRendererData.visible=!1;const e=this._series.priceScale().mode();if(!e.percentage&&!e.indexedTo100)return;const t=this._series.firstValue();null!==t&&(this._lineRendererData.visible=!0,this._lineRendererData.y=this._series.priceScale().priceToCoordinate(t,t),this._lineRendererData.color=this._series.properties().childs().baseLineColor.value())}}var ei=i(48943),ti=i(86252),ii=i(93201),si=i(52959),oi=i(31789);class ni{constructor(e){this._items=[],this._invalidated=!0,this._seriesValuesProvider=null,this._model=e}destroy(){}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}update(e){this._invalidated=!0}_updateImpl(){const e=this._model.mainSeries();this._seriesValuesProvider||(this._seriesValuesProvider=new Ye.SeriesValuesProvider(e,this._model));const t=this._model.crosshairSource().appliedIndex(),i=e.chartFloatingTooltipValuesProvider(),s=this._seriesValuesProvider.getValues(t),o=oi.priceSourceTitles[e.priceSource()??"close"],n=!!this._model.mainPane()?.priceDataSources().some((e=>(0,Kt.isStudy)(e)&&"Volume@tv-basicstudies"===e.metaInfo().id)),r=(e,t)=>7===t?e||n:e;this._items=i.getValues(t).map(((e,t)=>({...e,title:4===t?o:s[t].title,visible:r(e.visible,t)}))).filter((e=>e.visible)).map((e=>({titleText:e.title,titleInputs:"",value:e.value,valueColor:e.color
})))}}var ri=i(28334),ai=i(11768);const li=C.enabled("price_scale_always_last_bar_value"),ci=C.enabled("display_data_mode"),hi=!C.enabled("hide_series_legend_item"),di=C.enabled("hide_price_scale_global_last_bar_value"),ui=C.enabled("show_average_close_price_line_and_label"),_i=C.enabled("no_bars_status"),pi=C.enabled("charting_library_debug_mode"),mi=C.enabled("chart_style_hilo_last_price"),gi=(0,n.getLogger)("Chart.Series"),fi=C.enabled("pre_post_market_sessions");const yi={countdownEnabled:!0,lastPriceAnimationEnabled:!0};function vi(e,t,i){return void 0===t?null:`${e}=${t} (${i?"changed":"unchanged"})`}function Si(e){const t=e.state();return t.data.forEach((e=>e.value.splice(7,1))),t}function bi(e){const{seriesStatus:t,additionalStudyStatus:i}=e;if(S.seriesLoadingStatuses.has(t))return 2;if(i){if(4!==t&&i.type===ti.StudyStatusType.Error)return 13;if(S.seriesReadyStatuses.has(t)&&(i.type===ti.StudyStatusType.Loading||i.type===ti.StudyStatusType.Undefined))return 2}return t}class wi extends c.PriceDataSource{constructor(e,t,i,s){t.removeProperty("currencyId"),super(e,"_seriesId"),this.isSeries=!0,this.requestingStyleIsNotSupported=new tt.Delegate,this.requestingStyleSupportRecovered=new tt.Delegate,this._paneView=null,this._futureBarsPaneView=null,this._projectionBarsPaneView=null,this._waterlineView=null,this._priceLineView=null,this._gotoDateView=null,this._baseHorizontalLineView=null,this._priceStep=null,this._symbolInfo=new pt.WatchedValue(null),this._isPrePostMarketPricesAvailableProperty=new m.Property(!1),this._isBackAdjustmentForbiddenProperty=new m.Property(!0),this._isSettlementAsCloseForbiddenProperty=new m.Property(!0),this._highLowPriceCache=new Map,this._averagePriceCache=new Map,this._prevClosePriceAxisView=null,this._priceScaleAboutToBeChanged=new tt.Delegate,this._onRestarted=new tt.Delegate,this._onStatusChanged=new tt.Delegate,this._tagsChanged=new tt.Delegate,this._intervalChanged=new tt.Delegate,this._sessionIdChanged=new tt.Delegate,this._requestMoreDataAvailable=!0,this._lineStyleLastPriceCirclePaneView=new ut(this),this._prevClosePriceLineView=null,this._dataPoweredBy=null,this._symbolResolvingActive=new pt.WatchedValue(!1),this._predictBars=0,this._syncModel=null,this._data=null,this._lastCompleteFlags=null,this._haStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(8,!0))},this._renkoStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(4,!0))},this._pbStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(7,!0))},this._kagiStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(5,!0))},this._pnfStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(6,!0))},this._rangeStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(11,!0))},this._volFootprintStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(17,!0))},this._tpoStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(18,!0))},this._svpStyle={studyId:(0,o.ensureNotNull)((0,g.chartStyleStudyId)(20,!0))},this._barColorerCache=null,this._quotesLastSplits=new pt.WatchedValue(null),
this._overriddenLastSplits=new pt.WatchedValue(null),this._lastSplits=(0,ei.combine)(((e,t)=>t||e),this._quotesLastSplits.weakReference(),this._overriddenLastSplits.weakReference()),this._boxSizeValue=new pt.WatchedValue,this._base=100,this._pointValue=1,this._formattingDeps=null,this._defaultFormatter=new v.PriceFormatter({priceScale:this._base}),this._formatter=new v.PriceFormatter({priceScale:this._base}),this._ignoreMinMoveFormatter=new v.PriceFormatter({priceScale:this._base}),this._ignoreMinMovePriceStep=null,this._lastBarCloseTime=null,this._onSessionIdPropertyChangedBound=this._onSessionIdPropertyChanged.bind(this),this._ignoreSessionIdProxyPropertyChanges=!1,this._textSourceIsAlwaysTickerRestrictionEnabled=!1,this._lastPriceAnimationActive=!1,this._currentSession="out_of_session",this._onStyleChanged=new tt.Delegate,this._obsoleteZOrder=0,this._seriesErrorMessage=null,this._seriesAlwaysFalseHibernatedVW=new pt.WatchedValue(!1),this._styleToRecover=null,this._precomputedBarStyles=new WeakMap,this._doNotShowLastAvailableBar=!1,this._gotoDateResultCleared=!1,this._endOfDataPaneView=null,this._pendingTimeRange=null,this._replaySubscriber=new pt.WatchedValue(null),this._symbolIntervalChanged=new tt.Delegate,this._isReplayResolutionAvailableForUser=null,this._onInReplayStateChanged=new tt.Delegate,this._onReplaySubscriberSeriesModified=new tt.Delegate,this._paramsNotApplicableForReplay=new tt.Delegate,this._onTimeFrameApplied=new tt.Delegate,this._seriesLoaded=!1,this._seriesCompleted=!1,this._status=new pt.WatchedValue({seriesStatus:0}),this._prevRequestedInterval="",this._isActingAsSymbolSource=new pt.WatchedValue(!0),this._unsupportedResolutionState=new pt.WatchedValue(null),this._countdownUpdateTimer=null,this._deferredDestroyed=(0,l.createDeferredPromise)(),this._volumePointWeights=null,this._studyBindings=null,this._lineColorAtYPercentFromTop=new Pe.GradientColorCache,this._savedLeftEdge=null,this._pendingScrollToLeftEdge=null,this._symbolSourceWV=new pt.WatchedValue(this),this._updateTimeScaleTimePointWeights=()=>{0};const n=t.childs().interval;this._intervalObj=new pt.WatchedValue(Q.Interval.parse(n.value())),t.childs().interval.subscribe(this,(()=>this._intervalObj.setValue(Q.Interval.parse(n.value())))),this._seriesStatus=(0,ei.combine)(bi,this._status.weakReference()),this._seriesSource=new Pt(e.chartApi(),"s",s);const r=this._seriesSource.dataEvents();r.symbolResolved().subscribe(this,this._onSymbolResolved),r.symbolError().subscribe(this,this._onSymbolError),r.seriesTimeFrame().subscribe(this,this._onSeriesTimeFrame),r.seriesError().subscribe(this,this._onSeriesError),r.loading().subscribe(this,this._onSeriesLoading),r.completed().subscribe(this,this._onSeriesCompleted),r.dataUpdated().subscribe(this,this._onDataUpdated),r.barReceived().subscribe(this,this._onBarReceived),r.unsupportedResolutionRequested().subscribe(this,this._onUnsupportedResolutionRequested),this._quotesProvider=new _e.QuotesProvider(void 0,e.collapsed().spawnOwnership()),
this._quotesProvider.quotesUpdate().subscribe(this,this._onQuotesUpdate);const a=t.childs();if(t.hasChild("extendedHours")){(0,o.ensureDefined)(a.extendedHours).value()&&!t.hasChild("sessionId")&&t.addChild("sessionId",new m.Property("extended")),t.removeProperty("extendedHours")}t.hasChild("sessionId")||t.addChild("sessionId",new m.Property(y.SubsessionId.Regular)),(0,Jt.allChartStyles)().includes(a.style.value())||a.style.setValueSilently(2);const c=a.lineStyle.childs();if(a.lineStyle.hasChild("styleType")){let e,t;const i=c.styleType.value();0===i&&(t=14,e=a.lineWithMarkersStyle.childs()),1===i&&(t=15,e=a.steplineStyle.childs()),e&&(e.color.setValueSilently(c.color.value()),e.linestyle.setValueSilently(c.linestyle.value()),e.linewidth.setValueSilently(c.linewidth.value()),e.priceSource.setValueSilently(c.priceSource.value())),void 0!==t&&2===a.style.value()&&a.style.setValue(t),a.lineStyle.removeProperty("styleType")}this._studyBindings?.bindToSeriesProperties(t),this._setProperties(t),this._sessionIdProxyProperty=new m.Property(a.sessionId.value()),a.sessionId.subscribe(this,(()=>this._updateSessionIdProxyProperty())),this._sessionIdProxyProperty.subscribe(this,this._onSessionIdProxyPropertyChanged),this._symbolTextSourceProxyProperty=new m.Property,this._recalcSymbolTextSourceProxyProperty(),a.statusViewStyle.childs().symbolTextSource.subscribe(this,this._recalcSymbolTextSourceProxyProperty),this._symbolTextSourceProxyProperty.subscribe(this,(()=>e.lightUpdate())),this._options=(0,de.merge)((0,de.clone)(yi),i),this._prevChartStyle=a.style.value(),this._priceAxisView=new Ce(this,e,{alwaysShowGlobalLast:!di,showCountdown:i.countdownEnabled});let h=null;li||di||(h=new Ce(this,e,{visibleOnHistoryOnly:!0,showSymbolLabel:!1,showCountdown:!1,alwaysShowGlobalLast:!1,useSolidBodyColor:!1})),this._priceLinePriceAxisView=new xe.SeriesPriceLineAxisView(this),this._priceLineAxisViews=[this._priceLinePriceAxisView],this._projectionPriceAxisView=new Me(this,e,{showCountdown:i.countdownEnabled}),this._priceAxisViews=[this._priceAxisView,this._projectionPriceAxisView],null!==h&&this._priceAxisViews.push(h),this._panePriceAxisView=new Ie.PanePriceAxisView(this._priceAxisView,this,e),this._historyPricePanePriceAxisView=null!==h?new Ie.PanePriceAxisView(h,this,e):null,this._projectionPanePriceAxisView=new Ie.PanePriceAxisView(this._projectionPriceAxisView,this,e),this._labelPaneViews=[this._panePriceAxisView,this._projectionPanePriceAxisView],null!==this._historyPricePanePriceAxisView&&this._labelPaneViews.push(this._historyPricePanePriceAxisView),this._highLowAvgPaneViews=[],this._averagePaneViews=[],ui&&this._createAverageViews(),this._createHighLowAvgViews(),this._subscribeRestartToSessionIdChange(),a.visible.subscribe(this,this._updateLastPriceAnimationActive),this._updateLastPriceAnimationActive(),a.minTick.subscribe(this,this._onFormatterPropsChanged),this._dataWindowView=new q(this,e),this._legendView=new Y(this,e),this._statusView=new N(this,a.statusViewStyle),this._floatingTooltipView=new ni(e),
this._marketStatusModel=new X.MarketStatusModel(this._quotesProvider),this._dataUpdatedModeModel=ci?new he(this._symbolInfo.spawn().ownership(),this._seriesStatus.spawn().ownership(),(0,$.createWVFromGetterAndSubscription)((()=>this._lastCompleteFlags?.rt_update_period),r.completed()).ownership()):null,this._dataProblemModel=new ue(this._quotesProvider,this._symbolInfo.spawn().ownership()),this._symbolResolvingActive.subscribe((()=>e.realignLineTools())),this._intervalChanged.subscribe(this,(()=>e.realignLineTools())),this._intervalChanged.subscribe(this,(()=>this._checkChartStyle())),this._studyBindings?.syncStudy(this.style()),this.createPaneView(),this._properties.addExcludedKey("visible",1),this._properties.addExcludedKey("currencyId",1),this._futureBarsPaneView=null,this._priceLineView=null,this._baseHorizontalLineView=new Qt(this);for(const[,e]of Object.entries(S.STYLE_SHORT_NAMES))this._properties.child(`${e}Style`)?.subscribe(this,(()=>this.invalidateBarStylesCache()));const d=a.renkoStyle.childs().inputs.childs();d.boxSize.subscribe(this,(()=>this._restartIfStyleMatches(4))),d.style.subscribe(this,(()=>this._restartIfStyleMatches(4))),d.atrLength.subscribe(this,(()=>this._restartIfStyleMatches(4))),d.percentageLTP.subscribe(this,(()=>this._restartIfStyleMatches(4))),d.wicks.subscribe(this,(()=>this._restartIfStyleMatches(4))),d.sources.subscribe(this,(()=>this._restartIfStyleMatches(4))),a.pbStyle.childs().inputs.childs().lb.subscribe(this,(()=>this._restartIfStyleMatches(7)));const u=a.kagiStyle.childs().inputs.childs();u.reversalAmount.subscribe(this,(()=>this._restartIfStyleMatches(5))),u.style.subscribe(this,(()=>this._restartIfStyleMatches(5))),u.atrLength.subscribe(this,(()=>this._restartIfStyleMatches(5))),u.percentageLTP.subscribe(this,(()=>this._restartIfStyleMatches(5)));const _=a.pnfStyle.childs().inputs.childs();_.boxSize.subscribe(this,(()=>this._restartIfStyleMatches(6))),_.reversalAmount.subscribe(this,(()=>this._restartIfStyleMatches(6))),_.sources.subscribe(this,(()=>this._restartIfStyleMatches(6))),_.style.subscribe(this,(()=>this._restartIfStyleMatches(6))),_.atrLength.subscribe(this,(()=>this._restartIfStyleMatches(6))),_.percentageLTP.subscribe(this,(()=>this._restartIfStyleMatches(6))),_.oneStepBackBuilding.subscribe(this,(()=>this._restartIfStyleMatches(6))),a.rangeStyle.childs().inputs.childs().phantomBars.subscribe(this,(()=>this._restartIfStyleMatches(11))),this._isDWMProperty=new m.Property(this.isDWM()),this._onRestarted.subscribe(this,(()=>this._isDWMProperty.setValue(this.isDWM()))),a.showCountdown.subscribe(this,this._onShowCountdownChanged),this._onShowCountdownChanged(a.showCountdown),this._recreatePriceFormattingDependencies(),a.lineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),a.lineWithMarkersStyle.childs().priceSource.subscribe(this,this._updateBarFunction),a.steplineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),a.areaStyle.childs().priceSource.subscribe(this,this._updateBarFunction),
a.baselineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),a.columnStyle.childs().priceSource.subscribe(this,this._updateBarFunction),this._updateBarFunction(),this._isInReplay=(0,ei.combine)((e=>null!==e),this._replaySubscriber.weakReference()),this._valuesProvider=new Ye.SeriesValuesProvider(this,this.model()),this._legendValuesProvider=new Je(this,this.model()),this._tableViewValuesProvider=new ai.SeriesTableViewValuesProvider(this,this.model()),this._dataWindowValuesProvider=new Ye.SeriesValuesProvider(this,this.model()),this._valuesProvider=new Ye.SeriesValuesProvider(this,this.model()),this._chartFloatingTooltipValuesProvider=new Qe(this,this.model())}setId(e){super.setId(e),(0,Te.getPersistentLogger)()?.addPersistentLogEntry(`Set series Id to ${e}`,n.LOGLEVEL.INFO,"chart.series")}supportsConflatedChunks(){return!0}conflatedChunks(e,t){return this.data().conflatedChunks(e,t)}seriesErrorMessage(){const{seriesStatus:e,additionalStudyStatus:t}=this._status.value();return this.isFailed()?this._seriesErrorMessage:S.seriesLoadingStatuses.has(e)?null:t?.type===ti.StudyStatusType.Error?(0,ti.convertStudyStatusToString)({type:ti.StudyStatusType.Error,errorDescription:t.errorDescription},!0):null}destroy(){this._lastSplits.destroy(),this._seriesStatus.destroy(),this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._quotesProvider.destroy(),this.clearGotoDateResult(),this._legendView.destroy(),this._floatingTooltipView.destroy(),this._marketStatusModel.destroy(),this._model.symbolAliasService()?.onAliasChanged().unsubscribeAll(this),this._aliasSymbolInfo?.release(),this._studyBindings?.destroy(),this._dataUpdatedModeModel?.destroy(),this._dataProblemModel.destroy(),this._paneView&&this._paneView.destroy&&this._paneView.destroy(),this._seriesSource.destroy(),this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._model.timeScale().visibleBarsStrictRangeChanged().unsubscribeAll(this),this._unsubscribeRestartToSessionIdChange(),this._paramsNotApplicableForReplay.destroy(),this._onTimeFrameApplied.destroy(),this._deferredDestroyed.resolve(),this._properties.destroy(),this._isInReplay.destroy(),super.destroy()}isActingAsSymbolSource(){return this._isActingAsSymbolSource.readonly()}barColorer(){if(this._barColorerCache)return this._barColorerCache;let e=null;const t=this._model.panes();for(let i=t.length-1;i>=0;i--){const s=t[i].dataSources().filter(Kt.isStudy).filter((e=>e.hasBarColorer()&&!e.isSourceHidden())).sort(((e,t)=>e.zorder()-t.zorder()));for(let t=0;t<s.length;t++){const i=(0,o.ensureNotNull)(s[t].barColorer());null===e?e=i:e.pushBackBarColorer(i)}}return null===e?e=new $t.SeriesBarColorer(this):e.pushBackBarColorer(new $t.SeriesBarColorer(this)),this._barColorerCache=e,e}createPaneView(){this._paneView=null,this._projectionBarsPaneView=null,this._waterlineView=null,this._priceLineView=this.hasClosePrice()?new Lt(this):null;const e=this._properties.childs().style.value();switch(e){case 0:this._paneView=new Bt.SeriesBarsPaneView(this,this._model);break;case 17:case 19:case 1:
this._paneView=new Vt.SeriesCandlesPaneView(this,this._model,1===e||19===e?1:.2);break;case 2:case 18:case 14:case 15:this._paneView=new Rt.SeriesLinePaneView(this,this._model);break;case 3:this._paneView=new Nt.SeriesAreaPaneView(this,this._model);break;case 16:this._paneView=new Ot.SeriesHLCAreaPaneView(this,this._model);break;case 8:this._paneView=new Ut(this,this._model);break;case 9:this._paneView=new jt.SeriesHollowCandlesPaneView(this,this._model);break;case 13:this._paneView=new Dt.SeriesColumnsPaneView(this,this._model);break;case 10:{this._paneView=new Gt.SeriesBaselinePaneView(this,this._model);const e=this._properties.childs().baselineStyle.childs();this._waterlineView=new kt.SeriesWaterlinePaneView({paneHeight:()=>this.priceScale().height(),color:()=>e.baselineColor.value(),baseLevelPercentage:()=>e.baseLevelPercentage.value()});break}case 12:this._paneView=new Et.SeriesHiLoPaneView(this,this._model);break;case 21:this._paneView=new ri.SeriesHLCBarsPaneView(this,this._model)}if(null===this._paneView)throw Error("Unknown chart style assigned: "+e)}properties(){return this._properties}zorder(){return 0}quotesProvider(){return this._quotesProvider}currentSession(){return this._currentSession}syncModel(){if(!this._syncModel){const e=this.symbolInfo(),t=this.interval();if(!e||!t)return null;this._syncModel=new ne(e,t)}return this._syncModel}labelPaneViews(){return this._labelPaneViews}topPaneViews(){const e=[];if(null!==this._gotoDateView&&e.push(this._gotoDateView),this._lastPriceAnimationActive){const t=this._lineStyleLastPriceCirclePaneView;t.animationActive()&&setTimeout((()=>this._model.invalidate(_t.InvalidationMask.cursor())),0),t.invalidateStage(),e.push(t)}return 0!==e.length?e:null}paneViews(e){if(!this.properties().childs().visible.value()||!this._model.isSnapshot()&&!this._wasCompletedBefore())return null;const t=e===this._model.paneForSource(this),i=t?[(0,o.ensureNotNull)(this._baseHorizontalLineView),(0,o.ensureNotNull)(this._paneView)]:[];return i.push(...this._studyBindings?.paneViews(e)??[]),t&&(this._endOfDataPaneView&&i.push(this._endOfDataPaneView),this._futureBarsPaneView&&i.push(this._futureBarsPaneView),this._projectionBarsPaneView&&i.push(this._projectionBarsPaneView),null!==this._waterlineView&&i.push(this._waterlineView),null!==this._priceLineView&&i.push(this._priceLineView),window.TradingView.printing&&this._lastPriceAnimationActive&&(this._lineStyleLastPriceCirclePaneView.stopAnimation(),i.push(this._lineStyleLastPriceCirclePaneView)),i.push(...this._highLowAvgPaneViews),i.push(...this._averagePaneViews)),i}widgetSideAreaViews(e){return this._studyBindings?.widgetSideAreaViews(e)??null}priceAxisViews(e,t){return e.findTargetPriceAxisViews(this,t,this._priceAxisViews,this._priceLineAxisViews)}clearHighLowPriceCache(){this._highLowPriceCache.clear()}clearAveragePriceCache(){this._averagePriceCache.clear()}priceScale(){return(0,o.ensureNotNull)(this._priceScale)}setPriceScale(e){this._priceScale!==e&&(this._priceScaleAboutToBeChanged.fire(),this._priceScale=e,
this._properties.removeProperty("priceAxisProperties"),this._properties.addChild("priceAxisProperties",e.properties()),this._properties.childs().priceAxisProperties.fireChanged(),(0,a.emit)("series_event","price_scale_changed"),this._priceScaleChanged.fire(e))}priceScaleChanged(){return this._priceScaleChanged}priceScaleAboutToBeChanged(){return this._priceScaleAboutToBeChanged}applyPreferences(e){const t=(0,de.clone)(e);this.priceScale().setMode({autoScale:t.priceAxisProperties.autoScale,percentage:t.priceAxisProperties.percentage,log:t.priceAxisProperties.log,lockScale:t.priceAxisProperties.lockScale}),this.setChartStyleWithIntervalIfNeeded(t.style);const{style:i,interval:s,...o}=t;this._properties.mergePreferences(o),this._properties.saveDefaults(),this.createPaneView(),this.invalidateBarStylesCache()}disconnect(){this._studyBindings?.stop(),this._seriesSource.stop(),this._predictBars=0,this._updateStatus({...this._status.value(),seriesStatus:0}),this._model.isSnapshot()||this.purgeSymbolInfo()}isStarted(){return this._seriesSource.isStarted()}isCompleted(){return this._seriesCompleted}restart(e){if(5===this._status.value().seriesStatus)return;let t=null;this._pendingTimeRange&&(t=this._pendingTimeRange,this._seriesSource.isStarted()||(this._seriesSource.setTimeframe(t),this._pendingTimeRange=null));const i=this._properties.childs().interval.value(),s=(0,Mt.getServerInterval)(i),o=this._getResolvingSymbolObject();this._seriesSource.canModifySeries(o,s)?(this._seriesLoaded=!1,this._seriesCompleted=!1,this._lastCompleteFlags=null,this._onRestarted.fire(),this._setStatus(1),this._updateSymbolInfo(null),Q.Interval.isEqual(i,this._prevRequestedInterval)||this._notifyIntervalChanged(i),this._onBeforeModifySeries(this.getSymbolString(),i),this._onTimeFrameApplied.fire(t),this._data=null,this.model().recalcVisibleRangeStudies(h.RecalcVisibleRangeStudiesReason.SeriesRestart),this._seriesSource.modifySeries(o,s,t),this._seriesSource.isStarted()||this._seriesSource.start(),this._prevRequestedInterval=this.interval(),this._pendingTimeRange=null,this.updateAllViews((0,ve.sourceChangeEvent)(this.id())),this._model.lightUpdate()):this._seriesSource.isStarted()||(this._updateSymbolInfo(null),this._seriesSource.start())}isSymbolInvalid(){return 4===this._status.value().seriesStatus}getSymbolString(){return(0,st.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject())}getAlertSymbolString(){return(0,st.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(this.actualSymbol()))}getAlertProSymbolString(){return(0,st.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(this.proSymbol()))}getQuotesSymbolString(){return(0,st.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getExtendedSymbolObject())}invalidateBarStylesCache(e){gi.logDebug("Invalidate style cache starting from "+e),this._clearStylePlot(this.bars(),e),this._clearStylePlot(this.nsBars())}isLoading(){return S.seriesLoadingStatuses.has(this.statusWV().value())}isFailed(){const e=this.status();return 12===e||4===e||10===e||14===e}
isStatusError(){return 12===this.status()}unsupportedResolutionState(){return this._unsupportedResolutionState.readonly()}actualSymbol(){return(0,g.actualSymbol)(this.symbolInfo(),this.symbol())}proSymbol(){return(0,g.proSymbol)(this.symbolInfo(),this.symbol())}onStyleChanged(){return this._onStyleChanged}style(){return this.properties().childs().style.value()}setStyle(e){this.setSymbolParams({style:e})}isRangeBasedStyle(){return(0,g.isRangeBasedStyle)(this.style())}symbolSameAsCurrent(e){return this.symbol()===e||(0,it.symbolSameAsCurrent)(e,this.symbolInfo())}symbolSameAsResolved(e){return this._model.isSnapshot()?this.symbolSameAsCurrent(e):this._seriesSource.symbolSameAsResolved(e)}status(){return this._seriesStatus.value()}statusWV(){return this._seriesStatus}compositeStatusVW(){return this._status}symbol(){return this.properties().childs().symbol.value()}symbolOrAlias(){const e=this.symbol(),t=this._model.symbolAliasService()?.getAliasByProName(e);return t?.aliasName??e}symbolChanged(){return this.properties().childs().symbol}seriesSource(){return this._seriesSource}symbolInfo(){return this._symbolInfo.value()}aliasSymbolInfo(){return(this._aliasSymbolInfo??this._symbolInfo).value()}symbolInfoWV(){return this._symbolInfo.readonly()}lastSplits(){return this._lastSplits}overrideLastSplits(e){this._overriddenLastSplits.setValue(e)}symbolResolved(){return this.dataEvents().symbolResolved()}symbolResolvingActive(){return this._symbolResolvingActive}symbolHibernated(){return this._seriesAlwaysFalseHibernatedVW}getSymbolName(){return this.symbolInfo()?.name??""}firstValue(){const e=this.firstBar();return null===e?null:this._barFunction(e,0)}firstBar(){const e=this.model().timeScale().visibleBarsStrictRange();if(null===e)return null;const t=e.firstBar(),i=this.data().search(t,_.PlotRowSearchMode.NearestRight);return null!==i?i.value:null}formatter(e=!0){return e?this._formatter:this._ignoreMinMoveFormatter}defaultFormatter(){return this._defaultFormatter}priceStep(e=!0){return e?this._priceStep:this._ignoreMinMovePriceStep}bars(){return this.data().bars()}nsBars(){return this.data().nsBars()}interval(){return this.properties().childs().interval.value()}setInterval(e){this.setSymbolParams({interval:e})}intervalObj(){return this._intervalObj.readonly()}prevClose(){const e=this.priceScale();if(e.isEmpty()||this.data().isEmpty())return null;const t=this.quotes(),i=this.firstValue();if(null===t||null===i)return null;const s=t.prev_close_price;return void 0===s?null:{coordinate:e.priceToCoordinate(s,i),floatCoordinate:e.priceToCoordinate(s,i),formattedPricePercentage:e.formatPricePercentage(s,i,{signPositive:!0}),formattedPriceAbsolute:e.formatPriceAbsolute(s),formattedPriceIndexedTo100:e.formatPriceIndexedTo100(s,i)}}priceLineColor(e){return this.properties().childs().priceLineColor.value()||e}hasClosePrice(){return mi||12!==this.properties().childs().style.value()}lastValueData(e,t,i){const s={noData:!0},o=this.priceScale();if(this.model().timeScale().isEmpty()||o.isEmpty()||this.data().isEmpty())return s
;const n=this.model().timeScale().visibleBarsStrictRange(),r=this.firstValue();if(null===n||null===r)return s;let a,l;if(t){const e=this.data().bars().last();if(null===e)return s;a=e.value,l=e.index}else{const e=this.data().bars().search(n.lastBar(),_.PlotRowSearchMode.NearestLeft);if(null===e)return s;a=e.value,l=e.index}const c=(void 0!==e?a[e]:this._barFunction(a,2))??NaN,h=this.barColorer().barStyle(l,!1),d=o.priceToCoordinate(c,r),u={...o.getFormattedValues(c,r,!0),noData:!1,color:h.barColor,floatCoordinate:d,coordinate:d,index:l};return i&&(u.price=c),u}isDWM(){return this.intervalObj().value().isDWM()}isPulse(){const e=this.symbolInfo();return null!==e&&(e.resolutions??[]).length>0}data(){return this._data??this._seriesSource.data()}clearData(){(0,o.assert)(null===this._data,"Cannot clear loaded data"),this._studyBindings?.clearData(),this._seriesSource.clearData(),this._dataRangeUpdated.fire({type:"full"})}nearestData(e,t){return this.data().search(e,t)??void 0}nearestIndex(e,t){return this.nearestData(e,t)?.index}nearestValue(e,t,i){const s=this.nearestData(e,i);return s?.value[t]??void 0}onSymbolIntervalChanged(){return this._symbolIntervalChanged}onIntervalChanged(){return this._intervalChanged}onStatusChanged(){return this._onStatusChanged}onRestarted(){return this._onRestarted}fixLastBar(e){0}requestMoreData(e){if(!S.seriesReadyStatuses.has(this._status.value().seriesStatus))return;if(this._model.timeScale().isEmpty())return;const t=this._model.timeScale().visibleBarsStrictRange();if(null===t)return;if(0===this.bars().size())return;const i=t.lastBar()-(0,o.ensureNotNull)(this.data().last()).index;if(this._predictBars<i&&(this._predictBars=i,this._seriesSource.requestMoreTickmarks(i)),!this._requestMoreDataAvailable)return;const s=(0,o.ensureNotNull)(this.bars().firstIndex()),n=e||Math.max(s-t.firstBar(),s-(this._studyBindings?.requestMoreDataIndex()??s));if(n<=0)return;if(!Number.isFinite(n))return void gi.logWarn("requestMoreData: invalid bar count: "+n+", visible bars: ["+t.firstBar()+", "+t.lastBar()+"], last index: "+(0,o.ensureNotNull)(this.data().last()).index+", predicted bars: "+this._predictBars+", required bars:"+e);this._requestMoreDataAvailable=!1;const r=this._colorOnPrevBar()?2:0;this._seriesSource.requestMoreData(n+r),this._setStatus(2)}isNeedRestart(e){return 5!==this._status.value().seriesStatus&&(void 0===e&&(e=this.properties().childs().style.value()),(0,g.styleChangeRequiresRestart)(this._prevChartStyle,e))}isStyleSupported(e){return!0}sessionId(){return this.properties().childs().sessionId.value()}sessionIdChanged(){return this._sessionIdChanged}priceRange(e,t,i){const s=this._priceScale;if(this.data().isEmpty()||!s)return null;if(s.isLockScale()){const e=this._model.mainSeriesScaleRatio();if(null!==e){const i=s.internalHeight()/(this.model().timeScale().barSpacing()/e),n=(0,o.ensureNotNull)(this.data().search(t,_.PlotRowSearchMode.NearestLeft)).value,r=((0,o.ensure)(n[2])+(0,o.ensure)(n[3]))/2;return new p.PriceRange(r-.5*i,r+.5*i)}}const n=this.priceSource();let r,a,l
;if(null!==n?(r=this.data().bars().minMaxOnRangeCached(e,t,[{name:n,offset:0}]),a=this.data().nsBars().minMaxOnRangeCached(e,t,[{name:n,offset:0}])):(r=this.data().bars().minMaxOnRangeCached(e,t,[{name:"low",offset:0},{name:"high",offset:0}]),a=this.data().nsBars().minMaxOnRange(e,t,[{name:"low",offset:0},{name:"high",offset:0}])),r=(0,u.mergeMinMax)(r,a),null===r)l=new p.PriceRange(-.5,.5);else if(r.min===r.max){const e=5/(this.symbolInfo()?.pricescale??100);l=new p.PriceRange(r.min-e,r.max+e)}else l=new p.PriceRange(r.min,r.max);return s.isLog()?new p.PriceRange(s.priceToLogical(l.minValue()),s.priceToLogical(l.maxValue())):l}autoScaleInfo(e,t,i){let s={range:this.priceRange(e,t,{...i,scaleSeriesOnly:!0}),topPixelMargin:this._paneView?.topPixelMargin?.(),bottomPixelMargin:this._paneView?.bottomPixelMargin?.()};if(!i.scaleSeriesOnly){const o=this._model.allStudies().filter((e=>e.isVisible())),n=(e,t)=>void 0===e?t:void 0===t?e:Math.max(e,t),r=o.map((s=>s.autoScaleInfo(e,t,{...i,forceOverlayOnly:!0})));this._studyBindings&&r.push(...this._studyBindings.autoScaleInfos(e,t,i));const a=(e,t)=>({range:e.range?t.range?e.range.merge(t.range):e.range:t.range,topPixelMargin:n(e.topPixelMargin,t.topPixelMargin),bottomPixelMargin:n(e.bottomPixelMargin,t.bottomPixelMargin)});s=r.reduce(a,s)}return s}onChartStyleChanged(){if(this._updateBarFunction(),this.isNeedRestart()){this.data().clear();const e=(0,g.isStyleSupportedForReplay)(this.style());0,this._saveLeftEdgeIfRequired(!1)||this.model().timeScale().scrollToRealtime(!1),this.restart(e)}const e=this.properties();this._prevChartStyle!==e.childs().style.value()&&this._studyBindings?.syncStudy(this.style()),this._prevChartStyle=e.childs().style.value(),this._onStyleChanged.fire(e.childs().style.value()),this.invalidateBarStylesCache(),this._updateLastPriceAnimationActive(),this._styleToRecover?.originalStyle!==this.style()&&(this._styleToRecover=null),this._updateTimeScaleTimePointWeights()}setChartStyleWithIntervalIfNeeded(e,t){const i=this.interval(),s=t??(0,xt.getResolutionByChartStyle)(e,i,this._model.defaultResolutions()),o=Q.Interval.isEqual(s,i);this.setSymbolParams({interval:o?void 0:s,style:e})}getInputsProperties(){const e=this._properties.child(`${this.getStyleShortName()}Style`);return e?.childs().inputs??new m.Property}getInputsInfoProperties(){const e=this._studyBindings?.getInputsInfoProperties();if(e)return e;const t=this._properties.child(`${this.getStyleShortName()}Style`);return t?.childs().inputInfo??new m.Property}getSourceIcon(){return{type:"loadSvg",svgId:`series.${this.style()}`}}onSourceIconChanged(){return this._onStyleChanged}purgeSymbolInfo(){this._symbolInfo.setValue(null),this._quotesLastSplits.setValue(null)}idForAlert(){return super.idForAlert()}hasStateForAlert(){return!1}stateForAlert(){throw new Error("Not implemented")}async stateForAlertAsync(){return this.stateForAlert()}styleStudyInfos(){return{haStyle:this._haStyle,renkoStyle:this._renkoStyle,pbStyle:this._pbStyle,kagiStyle:this._kagiStyle,pnfStyle:this._pnfStyle,
rangeStyle:this._rangeStyle,volFootprintStyle:this._volFootprintStyle,tpoStyle:this._tpoStyle,svpStyle:this._svpStyle}}dataEvents(){return this._seriesSource.dataEvents()}isSpread(){return"spread"===this.symbolInfo()?.type}isYield(){const e=this.symbolInfo();return null!==e&&(0,Zt.isYield)(e)}dividendsAdjustmentProperty(){return null}sessionIdProxyProperty(){return this._sessionIdProxyProperty}symbolTextSourceProxyProperty(){return this._symbolTextSourceProxyProperty}setTextSourceIsAlwaysTickerRestrictionEnabled(e){this._textSourceIsAlwaysTickerRestrictionEnabled=e,this._recalcSymbolTextSourceProxyProperty()}isDWMProperty(){return this._isDWMProperty}isPrePostMarketPricesAvailableProperty(){return this._isPrePostMarketPricesAvailableProperty}isSettlementAsCloseForbiddenProperty(){return this._isSettlementAsCloseForbiddenProperty}isBackAdjustmentForbiddenProperty(){return this._isBackAdjustmentForbiddenProperty}getStyleShortName(){const e=this.style(),t=S.STYLE_SHORT_NAMES[e];return(0,o.assert)(!!t,`Missed short name for style ${e}`),t}invalidateBarColorerCache(){this._barColorerCache=null,this.invalidateBarStylesCache()}paramsNotApplicableForReplay(){throw new Error("Not implemented")}onTimeFrameApplied(){return this._onTimeFrameApplied}onInReplayStateChanged(){throw new Error("Not implemented")}onReplayModified(){throw new Error("Not implemented")}dataWindowView(){return this._dataWindowView}chartFloatingTooltipView(){return this._floatingTooltipView}statusView(){return hi?this._statusView:null}legendView(){return this._legendView}marketStatusModel(){return this._marketStatusModel}isMainSeries(){return!0}dataUpdatedModeModel(){return this._dataUpdatedModeModel}dataProblemModel(){return this._dataProblemModel}setDefaultTimeframe(e){this._pendingTimeRange=e}loadDataTo(e){const t=this._properties.childs().interval.value();this._onTimeFrameApplied.fire(e),this._seriesSource.modifySeries(this._getResolvingSymbolObject(),(0,Mt.getServerInterval)(t),e)}isInReplay(){return this._isInReplay}quotes(){return this.data().isEmpty()?null:this._quotesProvider.quotes()}base(){return this._base}pointValue(){return this._pointValue}barCloseTime(){return this._lastBarCloseTime}priceSource(){let e=null;const t=this._properties.childs();switch(t.style.value()){case 2:e=t.lineStyle.childs().priceSource.value();break;case 18:e=t.tpoStyle.childs().priceSource.value();break;case 14:e=t.lineWithMarkersStyle.childs().priceSource.value();break;case 15:e=t.steplineStyle.childs().priceSource.value();break;case 3:e=t.areaStyle.childs().priceSource.value();break;case 10:e=t.baselineStyle.childs().priceSource.value();break;case 13:e=t.columnStyle.childs().priceSource.value()}return e}lineColorAtYPercentFromTop(e){let t;switch(this.style()){case 2:t=this.properties().childs().lineStyle.childs();break;case 14:t=this.properties().childs().lineWithMarkersStyle.childs();break;case 15:t=this.properties().childs().steplineStyle.childs();break;default:t=null}
return t?t.colorType?.value()===ii.ColorType.Solid?t.color.value():this._lineColorAtYPercentFromTop.gradientColor((0,o.ensureDefined)(t.gradientStartColor).value(),(0,o.ensureDefined)(t.gradientEndColor).value(),e):null}updateAllViews(e){this._studyBindings?.updateAllViews(e),"hover-change"!==e.type&&(this._paneView?.update(e),this._dataWindowView.update(),this._legendView.update(),this._statusView.update(),this._floatingTooltipView.update(e),this._averagePaneViews.forEach((t=>t.update(e))),this._highLowAvgPaneViews.forEach((t=>t.update(e))),this._labelPaneViews.forEach((t=>t.update(e))),this._priceAxisViews.forEach((t=>t.update(e))),this._priceLineAxisViews.forEach((t=>t.update(e))),this._futureBarsPaneView?.update(e),this._projectionBarsPaneView?.update(e),this._waterlineView?.update(e),this._priceLineView?.update(e),this._gotoDateView?.update(e),this._endOfDataPaneView?.update(e),this._baseHorizontalLineView?.update(e),this._model.activeStrategySource().value()?.updateAllViews(e),this._model.replayStudyStrategy().value()?.updateAllViews(e),this._lineStyleLastPriceCirclePaneView.update(e))}styleStudyInfo(e){return this.styleStudyInfos()[e]}barFunction(){return this._barFunction}precomputedBarStyle(e){return this._precomputedBarStyles.get(e)}setPrecomputedBarStyle(e,t){this._precomputedBarStyles.set(e,t)}symbolParams(){return(0,it.symbolParams)(this)}compareSymbolParams(e){return(0,it.compareSymbolParams)(this,e,this._model.unitConversionEnabled())}setSymbolParams(e){const{symbol:t,currency:i,unit:s,style:n,interval:r}=e,{symbolChanged:a,intervalChanged:l,currencyChanged:c,unitChanged:h,styleChanged:d}=this.compareSymbolParams(e),u=[vi("symbol",t,a),vi("interval",r,l),vi("currency",i,c),vi("unit",s,h),vi("style",n,d)].filter((e=>null!==e)).join("; ");gi.logInfo(`Applying series symbol params: ${u}`);const _=this.properties().childs();void 0!==t&&_.symbol.setValue(t),void 0!==i&&_.currencyId.setValue(i),void 0!==s&&_.unitId.setValue(s),l&&_.interval.setValue((0,o.ensureDefined)(r)),void 0!==n&&d&&_.style.setValue(n);let p=!1;d&&(p=this.isNeedRestart(),this.onChartStyleChanged());let m=Promise.resolve();return!p&&(a||l||c||h)&&(m=this._applySymbolParamsChanges({symbolChanged:a,currencyChanged:c,unitChanged:h,intervalChanged:l,styleChanged:d})),(a||c||h)&&this.model().checkLineToolSelection(),m}setSymbol(e){this.setSymbolParams({symbol:e})}currency(){return this.properties().childs().currencyId.value()||null}setCurrency(e){this.setSymbolParams({currency:e})}isConvertedToOtherCurrency(){return(0,g.isConvertedToOtherCurrency)(this.symbolInfo())}unit(){return this.properties().childs().unitId.value()||null}setUnit(e){this.setSymbolParams({unit:e})}measureUnitId(){return(0,g.measureUnitId)(this.symbolInfo())}isConvertedToOtherUnit(){return(0,g.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}valueAt(e,t){return this.data().search(e)?.value[t]??null}symbolSource(){return this}symbolSourceWV(){return this._symbolSourceWV.readonly()}barsProvider(){return this}title(e){return this.symbolTitle(e)}
name(){return this.symbolTitle(Xt.TitleDisplayTarget.StatusLine)}symbolTitle(e,t,i){let s=this.properties().childs().symbol.value();const o=this.aliasSymbolInfo();if(null!==o&&(s=(0,g.symbolTitle)(o,t)),i)return s;let n=(0,x.translatedIntervalString)(this.properties().childs().interval.value());return e===Xt.TitleDisplayTarget.DataWindow&&(n=(0,U.forceRTLStr)(n)),`${s}, ${n}`}setObsoleteZOrder(e){this._obsoleteZOrder=e}obsoleteZOrder(){return this._obsoleteZOrder}valuesProvider(){return this._valuesProvider}legendValuesProvider(){return this._legendValuesProvider}tableViewValuesProvider(){return this._tableViewValuesProvider}dataWindowValuesProvider(){return this._dataWindowValuesProvider}chartFloatingTooltipValuesProvider(){return this._chartFloatingTooltipValuesProvider}statusProvider(e){return new B(this,this.properties().childs().statusViewStyle,e)}moveItem(e,t,i){if(10===this.style()&&0===t){const t=this.priceScale(),i=this.properties().childs().baselineStyle,s=t.height(),o=100-e.y/s*100,n=o<0?0:Math.round(10*o)/10;i.childs().baseLevelPercentage.setValue(Math.max(Math.min(n,100),0))}}rerequestData(){this._applySymbolParamsChanges({force:!0})}switchToReplay(e,t){throw new Error("Not implemented")}switchToRealtime(){throw new Error("Not implemented")}async canChangeResolution(e){return!0}async canChangeSymbol(e){return{result:!0}}requestMoreDataAvailable(){return this._requestMoreDataAvailable}seriesLoaded(){return this._seriesLoaded}endOfData(){return void 0!==this._lastCompleteFlags?.data_completed}endOfDataType(){return this._lastCompleteFlags?.data_completed??null}dataPoweredBy(){return null}boxSizeValue(){return this._boxSizeValue}isUserDeletable(){return!1}changeTimeFrame(){(0,r.trackEvent)("GUI","Change timeframe")}onTagsChanged(){return this._tagsChanged}state(e){const t=this.obsoleteZOrder();let i={type:"MainSeries",id:this.id(),zorder:t,haStyle:this._haStyle,renkoStyle:this._renkoStyle,pbStyle:this._pbStyle,kagiStyle:this._kagiStyle,pnfStyle:this._pnfStyle,rangeStyle:this._rangeStyle,volFootprintStyle:this._volFootprintStyle,tpoStyle:this._tpoStyle,svpStyle:this._svpStyle,formattingDeps:this._formattingDeps,studyBindings:this._studyBindings?.state(!!e)};const s=this.properties().state(void 0,2);if(s.symbol=(0,g.symbolToSaveInState)(this.symbolInfo()??this._model.chartApi().lastSymbolResolveInfo(s.symbol),s.symbol),this._model.unitConversionEnabled()||(s.unitId=null),i.state=s,e){let e=this.bars();const t=this._model.timeScale().visibleExtendedDataRange(e,0);null!==t&&(e=e.range(t.firstBar(),t.lastBar())),i={...i,bars:Si(e),nsBars:Si(this.nsBars()),symbolInfo:this.symbolInfo(),rtPrice:this.data().lastProjectionPrice,boxSize:this.data().boxSize,reversalAmount:this.data().reversalAmount}}return i}restoreState(e,t){t&&this._setStatus(5),!this._model.unitConversionEnabled()&&e.state&&delete e.state.unitId,e.state&&Q.Interval.isRange(e.state.interval)&&(e.state.style=11);const i=e.state;if(void 0!==i){const e=i.style,t=void 0;t&&!this._model.isSnapshot()&&(i.style=2,runOrGoProWithoutSync((()=>{i.style=e
}),t.feature,{feature:t.featureName}))}if(this._properties.mergeAndFire(e.state),this._prevChartStyle=this.properties().childs().style.value(),this.createPaneView(),t){const t=e;this.restoreData(t.bars,t.nsBars,t.symbolInfo,t.rtPrice,t.boxSize,t.reversalAmount)}e.formattingDeps&&(this._formattingDeps=e.formattingDeps,this._recreatePriceFormattingDependencies()),this._studyBindings?.restoreState(e.studyBindings??{},t),this._studyBindings?.syncStudy(this.style())}restoreData(e,t,i,s,o,n){this._updateStatus({seriesStatus:5}),this._data=new d.SeriesData,this._data.bars().restoreState(e),this._data.nsBars().restoreState(t),this._updateSymbolInfo(i),this._data.lastProjectionPrice=s,this._data.boxSize=o;const r=this.properties().childs();o||(6===r.style.value()?this._data.boxSize=r.pnfStyle.childs().inputs.childs().boxSize.value():4===r.style.value()&&(this._data.boxSize=r.renkoStyle.childs().inputs.childs().boxSize.value())),this._data.reversalAmount=n,n||5===r.style.value()&&(this._data.reversalAmount=r.kagiStyle.childs().inputs.childs().reversalAmount.value())}async setGotoDateResult(e,t){this._gotoDateResultCleared=!1;const s=await Promise.all([i.e(6778),i.e(4079)]).then(i.bind(i,75203));this._gotoDateResultCleared||(this._gotoDateView=new s.GotoDateView(this,e,t),this._gotoDateView.doNotShowLastAvailableBar(this._doNotShowLastAvailableBar),this._model.updateSource(this))}clearGotoDateResult(){this._gotoDateView=null,this._gotoDateResultCleared=!0}doNotShowLastAvailableBar(e){this._doNotShowLastAvailableBar=e,this._gotoDateView?.doNotShowLastAvailableBar(e)}dataUpdated(){return this.dataEvents().dataUpdated()}moveData(e){const t=this._seriesSource.moveData(e);null!==this._volumePointWeights&&this._volumePointWeights.moveData(e),t.then((()=>{this._isDestroyed||this.bars().isEmpty()||this._onIndexDiffsApplied(e)}))}async seriesCreated(){const e=this._seriesSource.instanceId();if(null!==e)return e;const t=await Promise.race([this._deferredDestroyed.promise.then((()=>{})),this._model.isSnapshot()?Promise.resolve(null):new Promise((e=>{this.dataEvents().created().subscribe(this,e,!0)}))]);if(void 0===t)throw new Error("Series has been destroyed");return t}activeStudyBinding(){return this._studyBindings?.activeStudy()??null}contextMenuStatName(){return"SeriesContextMenu"}_updateBarFunction(){this._barFunction=(0,qt.barFunctionByStyle)(this.style(),this.priceSource())}_setProperties(e){e.hasChild("timeframe")||e.merge({timeframe:""}),e.hasChild("shortName")||e.merge({shortName:""}),e.hasChild("currencyId")||e.addChild("currencyId",new m.Property(null)),e.hasChild("unitId")||e.addChild("unitId",new m.Property(null)),this._properties=e;const t=e.childs();t.currencyId.subscribe(this,this._onCurrencyChanged),t.unitId.subscribe(this,this._onUnitChanged),t.timeframe.subscribe(this,this.changeTimeFrame),e.subscribe(this,this._onPropertiesChanged)}_updateSessionIdProxyProperty(e){const t=this._properties.childs().sessionId.value();let i=t;if(e){const e=this.symbolInfo();null!==e&&(i=e.subsession_id||t)}
this._ignoreSessionIdProxyPropertyChanges=!0,this._sessionIdProxyProperty.setValue(i),this._ignoreSessionIdProxyPropertyChanges=!1}_onSessionIdProxyPropertyChanged(){this._ignoreSessionIdProxyPropertyChanges||this._properties.childs().sessionId.setValue(this._sessionIdProxyProperty.value()),this._updateLastPriceAnimationActive()}_onSymbolResolved(e){this._seriesErrorMessage=null,this._updateSymbolInfo(e),this._model.updateSource(this),this._model.onWidget()||((0,r.trackEvent)("Symbol",e.listed_exchange,e.name),(0,r.trackEvent)("Symbol Type",e.type,e.listed_exchange));const t=e.minmov/e.pricescale,i=this.properties().childs();4===i.style.value()&&i.renkoStyle.childs().inputs.childs().boxSize.value()<t?i.renkoStyle.childs().inputs.merge({boxSize:t}):6===i.style.value()&&i.pnfStyle.childs().inputs.childs().boxSize.value()<t?i.pnfStyle.childs().inputs.merge({boxSize:t}):5===i.style.value()&&i.kagiStyle.childs().inputs.childs().reversalAmount.value()<t&&i.kagiStyle.childs().inputs.merge({reversalAmount:t}),this._checkChartStyle(),this._formattingDeps={format:e.format,pricescale:e.pricescale,minmov:e.minmov,fractional:e.fractional,minmove2:e.minmove2,variable_tick_size:e.variable_tick_size},this._updateLastPriceAnimationActive()}_onSymbolError(e){this._setStatus(4),this._properties.childs().shortName.setValue(this._properties.childs().symbol.value()),this._model.clearAllStudies(),this.updateAllViews((0,ve.sourceChangeEvent)(this.id())),this._model.updateSource(this),this._symbolResolvingActive.setValue(!1)}_sendTelemetryCounter(e,t){}_getTelemetryAdditionalData(e,t){return{}}_onSeriesTimeFrame(e,t,i,s,o){const n=(0,g.isSingleValueBasedStyle)(this.style())?e+.5:e;let r=t;if(void 0===o)null!==i&&"period-back"!==i.type||(r+=this._model.studyAwareDefaultRightOffset());else if(o.applyDefaultRightMargin)r+=this._model.studyAwareDefaultRightOffset();else if(o.percentRightMargin){const e=t-n+1,i=Math.max(0,Math.min(.99,o.percentRightMargin/100));r+=i*e/(1-i)}this._model.setTimeViewport(n,r)}_onSeriesError(e){let t=e.error;const i=e.ctx;if(i){const e={};Object.keys(i).forEach((t=>{e[t]=i[t].toString()})),t=t.format(e)}pi&&gi.logNormal("Error reason: "+t),this._seriesErrorMessage=decodeURIComponent(t.split(":",2)[0]);const s="unknown_symbol"!==t?12:_i&&this.symbolInfo()?10:4;this._setStatus(s),this._seriesLoaded=!0,this._enablePriceRangeReady()}_onSeriesLoading(e){this._setStatus(2)}_onDataUpdated(e,t,i,s,n){t&&n&&this._colorOnPrevBar()&&this._precomputedBarStyles.delete(n.value);this.symbolInfo();if(null!==this._volumePointWeights){const e=t?this.bars().fullRangeIterator():i?this.bars().rangeIterator(i.index,(0,o.ensureNotNull)(this.bars().lastIndex())):null;if(null!==e)for(const t of e)this._volumePointWeights.setVolume(t.index,t.value[5])}t?this._requestMoreDataAvailable=!0:this._lastPriceAnimationActive&&this._seriesLoaded&&this._lineStyleLastPriceCirclePaneView.update((0,ve.sourceChangeEvent)(this.id())),this._lastBarCloseTime=e&&e.closeTime||null,this._boxSizeValue.setValue(this.data().boxSize),this._statusView.update()
;const r=this.bars().firstIndex(),a=this.bars().lastIndex();null!==r&&null!==a?this._dataRangeUpdated.fire({type:"partial",startIndex:i?.index??r,endIndex:t?n?.index??a:a}):this._dataRangeUpdated.fire({type:"full"}),this.clearAveragePriceCache(),this.clearHighLowPriceCache();const l=this.model(),c=(0,o.ensureNotNull)(l.paneForSource(this));l.recalculatePane(c,(0,ve.sourceChangeEvent)({sourceId:this.id(),realtime:!t,firstUpdatedTimePointIndex:i?.index??void 0})),l.updateSource(this)}_plotsDataRange(){const e=this.bars().firstIndex(),t=this.bars().lastIndex();return null!==e&&null!==t?[e,t]:null}_setStatus(e){const t={...this._status.value(),seriesStatus:e};this._updateStatus(t),this._statusView.update(),this.model().updateSource(this),this._onStatusChanged.fire()}_onBarReceived(e){this.model().recalcVisibleRangeStudies(h.RecalcVisibleRangeStudiesReason.DataUpdate)}_onUnsupportedResolutionRequested(){const e=(0,o.ensureNotNull)(this._getStateForUnsupportedResolution());this._seriesErrorMessage=e.reason,this._unsupportedResolutionState.setValue(e),this._setStatus(14),this._seriesLoaded=!0,this.clearData(),this._model.timeScale().points().clear(),this._enablePriceRangeReady()}_getStateForUnsupportedResolution(){const e=this.symbolInfo();if(null===e)return null;const t=this.interval(),i=(0,A.getResolutionUnsupportedReason)(e,t);if(null===i)return null;const s=e.name;if("less_than_frequency"!==i){let o=["D","W","M"];return!0!==(0,si.getChartingLibraryGlobalContext)().configurationData.is_tradingview_data&&(o=e.supported_resolutions),{ticker:s,reason:i,unsupportedResolution:t,applicableResolution:o[0],supportedResolutions:o}}{const n=(0,o.ensureDefined)(e.data_frequency);let r=(0,xt.getApplicableIntervalForFrequency)(n,t);this._model.defaultResolutions();return{ticker:s,reason:i,applicableResolution:r,unsupportedResolution:t,supportedResolutions:[]}}}_recreateFormatter(){let e=null;e=Yt.customFormatters?.priceFormatterFactory?.(this.symbolInfo(),this.properties().childs().minTick.value())??null,null!==e?(this._formatter=e,this._ignoreMinMoveFormatter=e):(this._defaultFormatter=(0,g.createSeriesFormatter)(this.aliasSymbolInfo()??this._formattingDeps,"default"),this._formatter=(0,g.createSeriesFormatter)(this.aliasSymbolInfo()??this._formattingDeps,this.properties().childs().minTick.value()),this._ignoreMinMoveFormatter=(0,g.createSeriesFormatter)(this.symbolInfo(),this.properties().childs().minTick.value(),!0)),this._priceScale?.updateFormatter(),this._formatterChanged.fire()}_recreatePriceStep(){const{minMove:e,priceScale:t}=(0,g.getSeriesPriceFormattingState)(this.symbolInfo()),i=e/t;this._ignoreMinMovePriceStep=1/t,this._priceStep!==i&&(this._priceStep=i,this._priceStepChanged.fire())}_recreatePriceFormattingDependencies(){this._recreateFormatter(),this._recreatePriceStep()}_onQuotesUpdate(e,t){void 0!==e.values.current_session&&e.values.current_session!==this._currentSession&&(this._currentSession=e.values.current_session,this._updateLastPriceAnimationActive())}_updateIsPrePostMarketPricesForbiddenProperty(){
const e=this.symbolInfo(),t=(0,g.symbolHasPreOrPostMarket)(e)&&(this.isDWM()||!!e&&(0,g.isRegularSessionId)(this.sessionIdProxyProperty().value(),e));this._isPrePostMarketPricesAvailableProperty.setValue(t)}_updateSettlementAsCloseForbiddenProperty(){}_updateBackAdjustmentForbiddenProperty(){}_removeReplaySubscriber(){throw new Error("Not implemented")}_getSymbolForApi(){return this.symbol()}_getSymbolObject(e){const t=this._getExtendedSymbolObject(e),i=this.properties().childs().style.value();if(S.SYMBOL_STRING_DATA.hasOwnProperty(i)&&!S.chartStylesWithAttachedStudies.includes(i)){return{symbol:t,type:this.styleStudyInfo(this.getStyleShortName()+"Style").studyId+"!",inputs:this.getInputsProperties().state()}}return t}_getExtendedSymbolObject(e){const t={symbol:e??this._getSymbolForApi()},i=this.properties().childs();null!==this.currency()&&(t["currency-id"]=this.currency());const s=this.unit();return this._model.unitConversionEnabled()&&null!==s&&(t["unit-id"]=s),!this.isDWM()&&fi&&(t.session=i.sessionId.value()),t}_checkChartStyle(){const e=this.style();(0,g.isCloseBasedSymbol)(this.symbolInfo())||this.intervalObj().value().is1Tick()?(0,g.isSingleValueBasedStyle)(e)||(this.requestingStyleIsNotSupported.fire(),this._styleToRecover={correctedStyle:this.style(),originalStyle:e}):"hlc"===this.symbolInfo()?.visible_plots_set?(0,g.isHLCBasedStyle)(e)||(0,g.isSingleValueBasedStyle)(e)||(this.requestingStyleIsNotSupported.fire(),this._styleToRecover={correctedStyle:this.style(),originalStyle:e}):null!==this._styleToRecover&&(this.requestingStyleSupportRecovered.fire(this._styleToRecover.originalStyle),this._styleToRecover=null)}_updateSymbolInfo(e){if(this._symbolInfo.setValue(e),e){const t=this._getResolvingSymbolObject(),i=this._properties.childs();i.shortName.setValue(e.name);const o=(0,f.extractSymbolNameFromSymbolInfo)(e,this.symbol());o&&i.symbol.setValue(o);const n=(0,g.symbolCurrency)(e),r=(0,g.symbolUnit)(e,this._model.unitConversionEnabled());"alwaysOff"===(0,J.currencyUnitVisibilityProperty)().value()||n===i.currencyId.value()&&r===i.unitId.value()||this._model.fullUpdate(),i.currencyId.setValue(n),i.unitId.setValue(r);const a=this._getResolvingSymbolObject(),l=this._seriesSource.symbol();(0,s.default)(t,l)&&!(0,s.default)(a,l)&&this._seriesSource.updateExtSymbol(a),this._updateSessionIdProxyProperty(!0)}const t=this.aliasSymbolInfo();this._base=t?t.pricescale/t.minmov:100,this._pointValue=e&&e.pointvalue||1;const i=this.getQuotesSymbolString();i!==this._quotesProvider.symbol()&&this._quotesLastSplits.setValue(null),this._quotesProvider.setQuotesSessionSymbol(i),this._marketStatusModel.setSymbolInfo(e),e&&this._recreatePriceFormattingDependencies(),this._statusView.update(),this.priceScale().updateFormatter(),this._symbolResolvingActive.setValue(!e),fi&&this._updateIsPrePostMarketPricesForbiddenProperty()}_createHighLowAvgViews(){const e=this.properties().childs().highLowAvgPrice,t=this._getHighLowPrice.bind(this),i=function(e,t,i,s){const o=i.childs(),n=We(e,t,{label:Oe,labelVisible:o.highLowPriceLabelsVisible,
lineVisible:o.highLowPriceLinesVisible,lineColor:o.highLowPriceLinesColor,lineWidth:o.highLowPriceLinesWidth},(()=>s(0))),r=We(e,t,{label:Fe,labelVisible:o.highLowPriceLabelsVisible,lineVisible:o.highLowPriceLinesVisible,lineColor:o.highLowPriceLinesColor,lineWidth:o.highLowPriceLinesWidth},(()=>s(1)));return{paneViews:[n.paneView,r.paneView],panePriceAxisViews:[n.panePriceAxisView,r.panePriceAxisView],priceAxisViews:[n.priceAxisView,r.priceAxisView],priceLineAxisViews:[n.priceLineAxisView,r.priceLineAxisView]}}(this._model,this,e,t);this._highLowAvgPaneViews.push(...i.paneViews),this._labelPaneViews.push(...i.panePriceAxisViews),this._priceAxisViews.push(...i.priceAxisViews),this._priceLineAxisViews.push(...i.priceLineAxisViews)}_createAverageViews(){const e=this.properties().childs().highLowAvgPrice,t=this._getAveragePrice.bind(this),i=Ke(this._model,this,e,t);this._averagePaneViews.push(...i.paneViews),this._labelPaneViews.push(...i.panePriceAxisViews),this._priceAxisViews.push(...i.priceAxisViews),this._priceLineAxisViews.push(...i.priceLineAxisViews)}_getHighLowPrice(e){if(!this._highLowPriceCache.has(e)){const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return null;const t=function(e,t,i){return e.minMaxOnRangeCached(t,i,[{name:"low",offset:0},{name:"high",offset:0}])}(this._model.mainSeries().bars(),e.firstBar(),e.lastBar());if(null===t)return null;this._highLowPriceCache.set(1,t.min),this._highLowPriceCache.set(0,t.max)}return this._highLowPriceCache.get(e)}_getAveragePrice(e){if(!this._averagePriceCache.has(e)){const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return null;const t=function(e,t,i){0;const s=(0,d.barFunction)("close");let o=0,n=0;for(let r=t;r<=i;r++){const t=e.valueAt(r);null!==t&&(o+=s(t),n++)}return n?o/n:null}(this._model.mainSeries().bars(),e.firstBar(),e.lastBar());if(null===t)return null;this._averagePriceCache.set(0,t)}return this._averagePriceCache.get(e)}_updateCompleteStatusMode(e){switch(e="pulsed"===e?"delayed":e){case"streaming":this._setStatus(3);break;case"endofday":this._setStatus(6);break;case"delayed":this._setStatus(8);break;case"replay":this._setStatus(11)}e.match(/delayed_streaming/)&&this._setStatus(9)}_onSeriesCompleted(e){if(14===this._status.value().seriesStatus)return;this._seriesErrorMessage=null,this._updateCompleteStatusMode(e.updateMode),this._lastCompleteFlags=e.flags??null;const t=(0,o.ensureNotNull)(this._model.paneForSource(this));t.recalculatePriceScale(this.priceScale(),(0,ve.sourceChangeEvent)(this.id()));const i=_t.InvalidationMask.full();if(null!==this._model.appliedTimeFrame().value()&&i.lockVisibleTimeRangeOnResize(),this._model.invalidate(i),!this.priceScale().isLockScale()||this.model().timeScale().isEmpty()||this._seriesLoaded||(this.model().timeScale().correctOffset(),this.model().timeScale().correctBarSpacing(),this.model().resetPriceScale(t,this.priceScale())),this._seriesLoaded=!0,this._seriesCompleted=!0,this.model().recalcVisibleRangeStudies(h.RecalcVisibleRangeStudiesReason.SeriesCompleted),
this.model().recalcStudyBasedLineTools(),null!==this._savedLeftEdge&&2!==this._status.value().seriesStatus){const e=1e3*this._savedLeftEdge,t=this._pendingScrollToLeftEdge;setTimeout((()=>{this._model.syncTimeWithModel((0,o.ensureNotNull)(this.syncModel()).syncSourceTarget(),e,{targetPointAlignment:"left",alignIfTargetPointIsVisible:!0,autoscaleAfterScroll:!1}).then((()=>{t?.resolve()})).catch((()=>{}))}),0),this._savedLeftEdge=null,this._pendingScrollToLeftEdge=null}this._enablePriceRangeReady()}_notifyIntervalChanged(e){const t={timeframe:this._pendingTimeRange??void 0};this._intervalChanged.fire(e,t),this._pendingTimeRange=t.timeframe??null}_onCurrencyChanged(){this._currencyChanged.fire()}_onUnitChanged(){this._unitChanged.fire()}_saveLeftEdgeIfRequired(e,t=null){if(this._savedLeftEdge=null,!t&&!e&&this._model.properties().childs().scalesProperties.childs().saveLeftEdge.value()){const e=this._model.timeScale();if(!e.isEmpty()){let t=e.visibleBarsStrictRange()?.firstBar();if(void 0!==t){const i=this._seriesSource.data()?.bars().first();return null!=i&&(t=Math.max(t,i.index)),this._savedLeftEdge=e.indexToTimePoint(t),this._pendingScrollToLeftEdge=(0,l.createDeferredPromise)(),!0}}}return!1}async _processReplayOnApplySymbolParamsChanges(e,t){}async _applySymbolParamsChanges(e){this._lastCompleteFlags=null,this.clearGotoDateResult();const t=this.interval();this.currency(),this.unit();Q.Interval.isRange(t)&&this._properties.childs().rangeStyle.childs().inputs.childs().range.setValue(Q.Interval.parse(t).multiplier());const{symbolChanged:i,intervalChanged:s,currencyChanged:o,unitChanged:n,force:r}=e,a=fi&&s&&Q.Interval.parse(t).isDWM()!=Q.Interval.parse(t).isDWM();if(this._syncModel=null,this._prevRequestedInterval=t,5!==this._status.value().seriesStatus&&(!this._seriesSource.isStarted()||i||o||n||a)&&this._updateSymbolInfo(null),this._processReplayOnApplySymbolParamsChanges(!!s,t),5===this._status.value().seriesStatus)return void this._model.realignLineTools();this._setStatus(1),fi&&this._updateIsPrePostMarketPricesForbiddenProperty(),this._symbolIntervalChanged.fire(),s&&this._notifyIntervalChanged(t),this._onRestarted.fire(),this._seriesLoaded=!1,this._seriesCompleted=!1,this._lineStyleLastPriceCirclePaneView.stopAnimation();let l=null;this._pendingTimeRange&&(l=this._pendingTimeRange,this._pendingTimeRange=null),this._onTimeFrameApplied.fire(l),this._onBeforeModifySeries(this.getSymbolString(),t);const c=this._shouldDefineNumberOfBarsForModifySeries(e)&&this._visibleBarsCount()||null;this.model().recalcVisibleRangeStudies(h.RecalcVisibleRangeStudiesReason.SeriesRestart),this._saveLeftEdgeIfRequired(!!i,l),this._data=null,this._seriesSource.modifySeries(this._getResolvingSymbolObject(),(0,Mt.getServerInterval)(t),l,r,c),this._seriesSource.isStarted()||(this._predictBars=0,this._seriesSource.start()),(i||o||n)&&this.disablePriceRangeReady(),this.updateAllViews((0,ve.sourceChangeEvent)(this.id())),this._model.lightUpdate(),this._pendingScrollToLeftEdge&&await this._pendingScrollToLeftEdge.promise}
async _onBeforeModifySeries(e,t){const i=null;i?.modifySeries(e,t)}_getResolvingSymbolObject(){let e=this._getSymbolObject(this._symbolForResolve());const t=null;return t&&(e=t.generateReplaySymbol(e)),e}_onSessionIdPropertyChanged(){this._sessionIdChanged.fire(),this.isDWM()||(this._saveLeftEdgeIfRequired(!1),this.restart(!0),this._updateLastPriceAnimationActive()),this._syncModel=null}_subscribeRestartToSessionIdChange(){this.properties().childs().sessionId.subscribe(this,this._onSessionIdPropertyChangedBound)}_unsubscribeRestartToSessionIdChange(){this.properties().childs().sessionId.unsubscribe(this,this._onSessionIdPropertyChangedBound)}_updateLastPriceAnimationActive(){if(!this._options.lastPriceAnimationEnabled||C.enabled("disable_pulse_animation"))return;const e=this._lastPriceAnimationActive,t=this.properties().childs(),i=t.style.value(),s=3===i||10===i||2===i||14===i||15===i,o=this.symbolInfo();if(!this._model.isSnapshot()&&t.visible.value()&&s&&o){const e=this.currentSession(),t=!(0,g.isRegularSessionId)(this.sessionIdProxyProperty().value(),o)&&!this.isDWM();this._lastPriceAnimationActive="market"===e||t&&("pre_market"===e||"post_market"===e)}else this._lastPriceAnimationActive=!1;this._lastPriceAnimationActive&&e!==this._lastPriceAnimationActive&&this.model().invalidate(_t.InvalidationMask.cursor())}_onPropertiesChanged(e){const t=this._properties.childs();if(e===t.symbol||e===t.interval||e===t.timeframe)return;const i=this._id.value();this._tagsChanged.fire(),this.createPaneView(),this.updateAllViews((0,ve.sourceChangeEvent)(i)),this.model().updateSource(this),(0,a.emit)("series_properties_changed",i)}_recalcSymbolTextSourceProxyProperty(){this._textSourceIsAlwaysTickerRestrictionEnabled?this._symbolTextSourceProxyProperty.setValue("ticker"):this._symbolTextSourceProxyProperty.setValue(this._properties.childs().statusViewStyle.childs().symbolTextSource.value())}_clearStylePlot(e,t){if(0===e.size())return;if(void 0===t&&e!==this.nsBars())return void(this._precomputedBarStyles=new WeakMap);const i=t??(0,o.ensureNotNull)(e.firstIndex()),s=(0,o.ensureNotNull)(e.lastIndex())+1;e.range(i,s).each(((e,t)=>(this._precomputedBarStyles.delete(t),!1)))}_visibleBarsCount(){const e=this._model.timeScale().visibleBarsStrictRange();return e?.count()}_symbolForResolve(){const e=this.symbol();return this._seriesSource.symbolSameAsResolved(e)?this._seriesSource.resolvedSymbol()??e:e}_shouldDefineNumberOfBarsForModifySeries(e){return C.enabled("request_only_visible_range_on_reset")&&e.force||!1}_onShowCountdownChanged(e){e.value()?this._countdownUpdateTimer=this._model.setInterval((()=>{this._priceAxisView.updateCountdown?.(),this._projectionPriceAxisView.updateCountdown?.()}),500):null!==this._countdownUpdateTimer&&(this._model.clearInterval(this._countdownUpdateTimer),this._countdownUpdateTimer=null)}_onFormatterPropsChanged(){this._recreateFormatter(),this._model.fullUpdate()}_updateStatus(e){14!==e.seriesStatus&&this._unsupportedResolutionState.setValue(null),this._status.setValue(e)}_wasCompletedBefore(){
return this.isCompleted()&&(this._studyBindings?.wasCompletedBefore()??!0)}_colorOnPrevBar(){const e=new Map([[1,"candleStyle"],[0,"barStyle"],[19,"volCandlesStyle"],[8,"haStyle"],[13,"columnStyle"]]).get(this.style());return!!e&&this._properties.childs()[e].childs().barColorsOnPrevClose.value()}_restartIfStyleMatches(e){this.style()===e&&this.restart()}}},4249:(e,t,i)=>{"use strict";i.d(t,{SeriesAreaPaneView:()=>l});var s=i(52859),o=i(93463),n=i(94602),r=i(45801),a=i(73773);class l extends a.SeriesSingleLinePaneView{renderer(){this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e=this._source.priceScale();if(!e)return null;const t=this._source.properties().childs().areaStyle.childs(),i=t.transparency.value(),a={simpleMode:!1,barSpacing:this._model.timeScale().barSpacing(),items:this._items,lineColor:t.linecolor.value(),lineStyle:t.linestyle.value(),lineWidth:t.linewidth.value(),isSeries:!0,withMarkers:!1,bottom:e.height(),color1:(0,s.generateColor)(t.color1.value(),i),color2:(0,s.generateColor)(t.color2.value(),i),skipHoles:!0},l=new n.CompositeRenderer;return l.append(new o.PaneRendererArea(a)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&l.append(new r.SelectionRenderer(this._selectionData)),l}}},64138:(e,t,i)=>{"use strict";i.d(t,{PaneRendererBars:()=>n});var s=i(4539),o=i(33505);class n extends o.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 o=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 r=this._thinBars?Math.min(n,Math.floor(i)):n,a=r<=n&&e.right-e.left>=Math.floor(1.5*i);o!==e.color&&(t.fillStyle=e.color,o=e.color);const l=Math.floor(.5*r),c=Math.round(e.center*i),h=c-l,d=r,u=h+d-1,_=Math.min(e.high,e.low),p=Math.max(e.high,e.low),m=Math.round(_*s)-l,g=Math.round(p*s)+l,f=Math.max(g-m,r);t.fillRect(h,m,d,f);const y=Math.ceil(1.5*n);if(a){const i=c-y,o=c+y,n=Math.min(h-i,o-u);if(!this._dontDrawOpen){let o=Math.max(m,Math.round(e.open*s)-l),r=o+d-1;r>m+f-1&&(r=m+f-1,o=r-d+1),t.fillRect(i,o,n,r-o+1)}let r=Math.max(m,Math.round(e.close*s)-l),a=r+d-1;a>m+f-1&&(a=m+f-1,r=a-d+1),t.fillRect(u+1,r,n,a-r+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)))}}},62802:(e,t,i)=>{"use strict";i.d(t,{SeriesBarsPaneView:()=>a});var s=i(94602),o=i(45801),n=i(68735),r=i(64138);class a extends n.SeriesBarCandlesPaneView{renderer(){this._invalidated&&(this._updateImpl(null),this._invalidated=!1);const e=this._source.properties().childs(),t={bars:this._bars,dontDrawOpen:e.barStyle.childs().dontDrawOpen.value(),thinBars:11===e.style.value()?e.rangeStyle.childs().thinBars.value():e.barStyle.childs().thinBars.value()},i=new s.CompositeRenderer;return i.append(new r.PaneRendererBars(t)),
this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&i.append(new o.SelectionRenderer(this._selectionData)),i}_createItem(e,t,i){const s={center:NaN,open:NaN,high:NaN,low:NaN,close:NaN,color:i.barColor,left:NaN,right:NaN,timePointIndex:e};return(0,n.baseBarCandlesUpdater)(t,s)?s:null}}},43501:(e,t,i)=>{"use strict";i.d(t,{SeriesBaselinePaneView:()=>f});var s,o=i(52859),n=i(94602),r=i(10555),a=i(48892),l=i(2624),c=i(4539),h=i(12217),d=i(20820),u=i(2383),_=i(58221);!function(e){e[e.Top=0]="Top",e[e.Bottom=1]="Bottom"}(s||(s={}));class p extends d.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){if(null===this._data)return null;const{items:t,topLineWidth:i,bottomLineWidth:s}=this._data,o=(0,c.interactionTolerance)().series+(i+s)/4,n=(0,h.lowerbound)(t,e,((e,t)=>e.center<=t.x)),a=Math.max(1,n-1),d=Math.min(t.length-1,n+1);for(let i=a;i<=d;++i){const s=t[i-1],n=t[i],{distance:a}=(0,l.distanceToSegment)((0,r.point)(s.center,s.y),(0,r.point)(n.center,n.y),(0,r.point)(e.x,e.y));if(a<=o)return new u.HitTestResult(u.HitTarget.Regular)}return null}_drawImpl(e){if(null===this._data)return;const{items:t,baseLevelCoordinate:i,bottom:s,bottomFillColor1:o,bottomFillColor2:n,topFillColor1:l,topFillColor2:h,topLineColor:d,bottomLineColor:u,topLineWidth:p,bottomLineWidth:m,topLineStyle:g,bottomLineStyle:f}=this._data;if(!function(e){if(0===e.length)return!1;const t=e.findIndex((e=>(0,c.coordinateIsValid)(e.y)));if(-1===t)return!1;let i=e.length-1;for(;i>t&&!(0,c.coordinateIsValid)(e[i].y);)i--;return!(t>i)}(t))return;const y=e.context,{topItems:v,bottomItems:S}=function(e,t){const i=[],s=[];let o=null;for(let n=0;n<e.length;n++){let l=e[n];const h=e[n+1]||{};if((0,c.coordinateIsValid)(l.y))l.y<=t&&i.push(l),l.y>=t&&s.push(l),o=l;else{if(null===o)continue;l=o}if((0,c.coordinateIsValid)(h.y)&&(l.y>t&&h.y<t||l.y<t&&h.y>t))if(Math.abs(l.center-h.center)<1){const e={center:l.center,y:t};i.push(e),s.push(e)}else{const e=(0,a.intersectLineSegments)((0,r.point)(l.center,l.y),(0,r.point)(h.center,h.y),(0,r.point)(l.center,t),(0,r.point)(h.center,t));if(null!==e){const t={center:l.center+(h.center-l.center)*e,y:l.y+(h.y-l.y)*e};i.push(t),s.push(t)}}}return{topItems:i,bottomItems:s}}(t,i);y.lineCap="round",y.lineJoin="round",0!==v.length&&(y.beginPath(),y.moveTo(v[0].center,i),this._makeLine(y,v,!0,0),y.closePath(),y.fillStyle=this._makeLinearGradient(y,l,h,i-s,i),y.fill(),y.beginPath(),this._makeLine(y,v,!1,0),y.lineWidth=p,y.strokeStyle=d,(0,_.setLineStyle)(y,g),y.stroke()),0!==S.length&&(y.beginPath(),y.moveTo(S[0].center,i),this._makeLine(y,S,!0,1),y.closePath(),y.fillStyle=this._makeLinearGradient(y,o,n,i,i+s),y.fill(),y.beginPath(),this._makeLine(y,S,!1,1),y.lineWidth=m,y.strokeStyle=u,(0,_.setLineStyle)(y,f),y.stroke())}_makeLine(e,t,i,s){if(null===this._data)return;const o=t.findIndex((e=>(0,c.coordinateIsValid)(e.y)));if(-1===o)return;const{barSpacing:n,baseLevelCoordinate:r}=this._data,a=.25*n;let l;const h=t.length
;for(let n=o;n<h;n++){const h=t[n],d=t[n+1]||{};if((0,c.coordinateIsValid)(h.y)){if(0===s){if(l&&l.y>=r&&h.y>=r){e.moveTo(h.center,h.y);continue}}else if(l&&l.y<=r&&h.y<=r){e.moveTo(h.center,h.y);continue}if(l&&(0,c.coordinateIsValid)(l.y))e.lineTo(h.center,h.y),i&&!(0,c.coordinateIsValid)(d.y)&&e.lineTo(h.center,r);else if(d&&(0,c.coordinateIsValid)(d.y))i?(n!==o&&e.lineTo(h.center,r),e.lineTo(h.center,h.y)):e.moveTo(h.center,h.y);else if(i){if(0===n)continue;n!==o&&e.lineTo(h.center-a,r),e.lineTo(h.center-a,h.y),e.lineTo(h.center+a,h.y),e.lineTo(h.center+a,r)}else e.moveTo(h.center-a,h.y),e.lineTo(h.center+a,h.y);l=h}}}_makeLinearGradient(e,t,i,s,o){const n=e.createLinearGradient(0,s,0,o);return n.addColorStop(0,t),n.addColorStop(1,i),n}}var m=i(45801),g=i(73773);class f extends g.SeriesSingleLinePaneView{constructor(){super(...arguments),this._renderer=new p,this._topFillColor1="",this._topFillColor2="",this._bottomFillColor1="",this._bottomFillColor2="",this._topLineColor="",this._bottomLineColor="",this._topLineWidth=0,this._bottomLineWidth=0,this._topLineStyle=0,this._bottomLineStyle=0,this._barSpacing=0,this._bottom=0,this._baseLevelCoordinate=0}renderer(){this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._renderer.setData({items:this._items,topFillColor1:this._topFillColor1,topFillColor2:this._topFillColor2,bottomFillColor1:this._bottomFillColor1,bottomFillColor2:this._bottomFillColor2,topLineColor:this._topLineColor,bottomLineColor:this._bottomLineColor,topLineWidth:this._topLineWidth,bottomLineWidth:this._bottomLineWidth,topLineStyle:this._topLineStyle,bottomLineStyle:this._bottomLineStyle,barSpacing:this._barSpacing,baseLevelCoordinate:this._baseLevelCoordinate,bottom:this._bottom});const e=new n.CompositeRenderer;return e.append(this._renderer),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&e.append(new m.SelectionRenderer(this._selectionData)),e}_updateImpl(){super._updateImpl();const e=this._source.priceScale();if(!e)return;const t=this._source.properties().childs().baselineStyle.childs(),i=t.transparency.value();this._topFillColor1=(0,o.generateColor)(t.topFillColor1.value(),i),this._topFillColor2=(0,o.generateColor)(t.topFillColor2.value(),i),this._bottomFillColor1=(0,o.generateColor)(t.bottomFillColor1.value(),i),this._bottomFillColor2=(0,o.generateColor)(t.bottomFillColor2.value(),i),this._topLineColor=t.topLineColor.value(),this._bottomLineColor=t.bottomLineColor.value(),this._topLineWidth=t.topLineWidth.value(),this._bottomLineWidth=t.bottomLineWidth.value(),this._topLineStyle=t.topLineStyle.value(),this._bottomLineStyle=t.bottomLineStyle.value(),this._barSpacing=this._model.timeScale().barSpacing(),this._bottom=e.height(),this._baseLevelCoordinate=Math.round(this._bottom*(Math.abs(100-t.baseLevelPercentage.value())/100))}}},64651:(e,t,i)=>{"use strict";i.d(t,{SeriesWaterlinePaneView:()=>a});var s=i(40738),o=i(43838),n=i(2383),r=i(69558);class a extends s.HorizontalLinePaneView{constructor(e){super(),this._getters=e;const t={
cursorType:o.PaneCursorType.VerticalResize,activeItem:0,areaName:n.AreaName.SourceItemMove};this._lineRenderer.setHitTest(new n.HitTestResult(n.HitTarget.MovePoint,t)),this._lineRendererData.visible=!0,this._lineRendererData.linestyle=r.LINESTYLE_SPARSE_DOTTED}_updateImpl(){const{baseLevelPercentage:e,paneHeight:t,color:i}=this._getters,s=Math.abs(100-e());this._lineRendererData.y=Math.round(t()*(s/100)),this._lineRendererData.color=i()}}},33505:(e,t,i)=>{"use strict";i.d(t,{PaneRendererSeriesBase:()=>n});var s=i(2383),o=i(10307);class n extends o.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],o=t[t.length-1];if(e.x<s.left-i)return null;if(e.x>o.right+i)return null;let n=0,r=t.length-1,a=-1;for(;n<=r;){const i=Math.floor((n+r)/2),s=t[i];if(e.x>=s.left&&e.x<=s.right){a=i;break}e.x>s.right?n=i+1:r=i-1}if(-1===a)return null;if(this._isPointAtBar(t[a],e.y,i))return this._getHitTest();let l=a;for(;l>=1&&e.x-t[l-1].right<i;)l--;let c=a;for(;c<=t.length-2&&t[c+1].left-e.x<i;)c++;const h=Math.max(0,l),d=Math.min(t.length-1,c);for(let s=h;s<=d;s++)if(s!==a&&this._isPointAtBar(t[s],e.y,i))return this._getHitTest();return null}_getHitTest(){return new s.HitTestResult(s.HitTarget.Regular)}_isPointAtBar(e,t,i){const s=Math.min(e.high,e.low),o=Math.max(e.high,e.low);return s-i<=t&&t<=o+i}}},48227:(e,t,i)=>{"use strict";i.d(t,{PaneRendererCandles:()=>h});var s,o=i(50151),n=i(2383),r=i(58221),a=i(4539),l=i(33505);function c(e,t,i,s){const o=Math.floor(t);return e.map((e=>{let n=(0,a.optimalCandlestickWidth)((e.right-e.left)*s,t);n>=2&&o%2!=n%2&&n--;const r=Math.floor(.5*n),l=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),h=c-r,d=h+n-1,u=Math.abs(Math.max(e.open,e.close)-Math.min(e.open,e.close))*i,_=Math.round(Math.min(e.open,e.close)*i),p=Math.round(Math.max(e.open,e.close)*i);let m=Math.min(Math.floor(t),Math.floor(n*t));m=Math.max(Math.floor(t),Math.min(m,n));const g=Math.floor(.5*m);return{rawBodyHeight:u,top:_,bottom:p,center:c,left:h,right:d,candleWidth:n,high:Math.round(e.high*i),low:Math.round(e.low*i),wickWidth:m,wickOffset:g,borderWidth:l}}))}!function(e){e[e.BarBorderWidth=1]="BarBorderWidth"}(s||(s={}));class h 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){this._bars=e.bars,this._scaleCoeff=e.scaleCoeff??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 o=c(this._bars,i,s,this._scaleCoeff);this._wickVisible&&this._drawWicks(t,o),this._borderVisible&&this._drawBorder(t,o),this._bodyVisible&&this._drawCandles(t,o)}_getTolerance(){return(0,a.interactionTolerance)().series}_getHitTest(){return this._hittest||new n.HitTestResult(n.HitTarget.Regular)}_isPointAtBar(e,t,i){const s=this._bodyVisible||this._borderVisible,o=this._wickVisible;if(!s&&!o)return!1;if(s){const s=o?Math.min(e.high,e.low):Math.min(e.open,e.close),n=o?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),o=Math.max(e.open,e.close);return e.high-i<=t&&t<=s+i||o-i<=t&&t<=e.low+i}}_drawWicks(e,t){let i="",s=null;this._bars.forEach(((n,r)=>{const a=n.wickColor?n.wickColor:(0,o.ensureDefined)(this._wickColor);a!==i&&(e.fillStyle=a,i=a);let{top:l,bottom:c}=t[r];const{rawBodyHeight:h,borderWidth:d,center:u,high:_,low:p,wickWidth:m,wickOffset:g}=t[r];this._isPriceScaleInverted&&([c,l]=[l,c]);let f=u-g;const y=f+m-1;null!==s&&(f=Math.max(s+1,f),f=Math.min(f,y));const v=y-f+1;h<=d&&(l!==_&&(l=Math.round(l-.5*d)),c=c!==p?Math.round(l-.5*d)+d-1:p-1),l!==_&&e.fillRect(f,_,v,l-_),p-c-1&&e.fillRect(f,c+1,v,p-c-1),s=y}))}_drawBorder(e,t){let i="",s=null;this._bars.forEach(((n,a)=>{if(n.borderColor!==i&&(e.fillStyle=n.borderColor?n.borderColor:(0,o.ensureDefined)(this._borderColor),i=n.borderColor),this._bodyVisible&&n.hollow)return;let{left:l}=t[a];const{rawBodyHeight:c,top:h,bottom:d,right:u,borderWidth:_}=t[a];null!==s&&(l=Math.max(s+1,l),l=Math.min(l,u));const p=u-l+1;c<=_?e.fillRect(l,Math.round(h-.5*_),p,_):p>2*_?(0,r.fillRectInnerBorder)(e,l,h,u-l+1,d-h+1,_):e.fillRect(l,h,p,d-h+1),s=u}))}_drawCandles(e,t){let i="";this._bars.forEach(((s,o)=>{let{top:n,bottom:a,left:l,right:c}=t[o];const{rawBodyHeight:h,borderWidth:d,candleWidth:u}=t[o];if(!(this._borderVisible&&u<=2*d)||s.hollow){if(s.color!==i){const t=s.color;e.fillStyle=t,i=t}if(s.hollow)e.fillStyle=s.color,h<=d?e.fillRect(l,Math.round(n-.5*d),u,d):(0,r.fillRectInnerBorder)(e,l,n,c-l+1,a-n+1,d);else{if(!this._borderVisible&&h<=d)return void e.fillRect(l,Math.round(n-.5*d),u,d);if(this._borderVisible&&(l+=d,n+=d,c-=d,a-=d),n>a)return;e.fillRect(l,n,c-l+1,a-n+1)}}}))}}},27808:(e,t,i)=>{"use strict";i.d(t,{SeriesCandlesPaneView:()=>l});var s=i(94602),o=i(4539),n=i(45801),r=i(68735),a=i(48227);class l extends r.SeriesBarCandlesPaneView{constructor(e,t,i=1){super(e,t),this._scaleCoeff=1,this._scaleCoeff=i}renderer(){this._invalidated&&(this._updateImpl(null),this._invalidated=!1);const e=this._source.priceScale();if(!e)return null;const t=this._source.properties().childs(),i=1===t.style.value()?t.candleStyle.childs():19===t.style.value()?t.volCandlesStyle.childs():t.volFootprintStyle.childs(),r=this._model.timeScale().barSpacing(),l={bars:this._bars,barSpacing:r,bodyVisible:i.drawBody.value(),
borderVisible:i.drawBorder.value(),borderColor:i.borderColor.value(),wickColor:i.wickColor.value(),barWidth:(0,o.optimalBarWidth)(r),wickVisible:i.drawWick.value(),isPriceScaleInverted:e.isInverted(),scaleCoeff:this._scaleCoeff},c=new s.CompositeRenderer;return c.append(new a.PaneRendererCandles(l)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&c.append(new n.SelectionRenderer(this._selectionData)),c}_createItem(e,t,i){const s={center:NaN,open:NaN,high:NaN,low:NaN,close:NaN,left:NaN,right:NaN,timePointIndex:e,color:i.barColor,borderColor:i.barBorderColor,wickColor:i.barWickColor,hollow:i.isBarHollow};return(0,r.baseBarCandlesUpdater)(t,s)?s:null}}},85630:(e,t,i)=>{"use strict";i.d(t,{SeriesColumnsPaneView:()=>p});var s=i(50151),o=i(10555),n=i(37103),r=i(69708),a=i(2383),l=i(94602),c=i(5471),h=i(13173),d=i(45801),u=i(93387),_=i(52945);class p{constructor(e,t){this._items=[],this._invalidated=!0,this._isMarkersEnabled=(0,n.enabled)("source_selection_markers"),this._selectionData=null,this._histogramBase=0,this._source=e,this._model=t,this._selectionIndexer=new h.SelectionIndexes(t.timeScale())}update(){this._invalidated=!0}renderer(){this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e={barSpacing:this._model.timeScale().barSpacing(),items:this._items,lineColor:"",histogramBase:this._histogramBase},t=new l.CompositeRenderer;return t.append(new u.PaneRendererColumns(e)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&t.append(new d.SelectionRenderer(this._selectionData)),t}_updateImpl(){this._items=[];const e=this._model.timeScale(),t=this._source.priceScale();if(e.isEmpty()||!t||t.isEmpty())return;const i=e.visibleBarsStrictRange();if(null===i)return;if(0===this._source.bars().size())return;const n=this._source.nearestIndex(i.firstBar(),c.PlotRowSearchMode.NearestRight),l=this._source.nearestIndex(i.lastBar(),c.PlotRowSearchMode.NearestLeft);if(void 0===n||void 0===l)return;const h=this._source.barColorer(),d={},u=this._source.barFunction();for(const{index:e,value:t}of this._source.bars().rangeIterator(n,l)){const i=u(t);if(!(0,r.default)(i))continue;d.value=t;let s=this._source.precomputedBarStyle(t);void 0===s&&(s=h.barStyle(e,!1,d),this._source.setPrecomputedBarStyle(t,s)),this._items.push({timePointIndex:e,left:NaN,center:NaN,right:NaN,y:i,style:s}),d.previousValue=t}const p=this._source.firstValue();if(null===p)return;t.pointsArrayToCoordinates(this._items,p),e.fillBarBorders(this._items);const m=this._source.properties().childs().columnStyle.childs().baselinePosition?.value();if("zero"===m){const e=t.isPercentage()?(0,_.fromPercent)(0,p):0;this._histogramBase=t.priceToCoordinate(e,p)}else this._histogramBase=t.isInverted()?0:t.height();if(this._model.selection().isSelected(this._source)){const i=this._selectionIndexer.indexes();this._selectionData={points:[],bgColors:[],visible:!0,barSpacing:e.barSpacing(),hittestResult:a.HitTarget.Regular};const n=(0,
s.ensureNotNull)(this._model.paneForSource(this._source)).height();this._selectionData.hittestResult=a.HitTarget.Regular;for(let s=0;s<i.length;s++){const r=i[s],a=this._source.bars().valueAt(r);if(null===a)continue;const l=u(a),c=e.indexToCoordinate(r),h=t.priceToCoordinate(l,p);this._selectionData.points.push({point:new o.Point(c,h)}),this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(h/n))}}else this._selectionIndexer.clear()}}},88732:(e,t,i)=>{"use strict";i.d(t,{SeriesHiLoPaneView:()=>f});var s=i(59332),o=i(49251),n=i(12217),r=i(4539),a=i(2383),l=i(20820);class c extends l.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._barWidth=null}setData(e){this._data=e,this._barWidth=Math.max(1,Math.round((0,r.optimalHiLoWidth)(e.barSpacing)))}hitTest(e){if(null===this._data||null===this._barWidth)return null;const t=this._data.bars,i=.5*this._data.barSpacing;if(0===t.length)return null;if(e.x<t[0].center-i)return null;if(e.x>t[t.length-1].center+i)return null;const s=t[(0,n.lowerbound)(t,e.x-i,((e,t)=>e.center<t))];if(e.x<s.center-i||e.x>s.center+i)return null;const o=(0,r.interactionTolerance)().series+this._barWidth/2,l=Math.min(s.high,s.low),c=Math.max(s.high,s.low),h=this._data.fontSize;return l-o-h<=e.y&&e.y<=l+o||c-o<=e.y&&e.y<=c+o+h?new a.HitTestResult(a.HitTarget.Regular):null}_drawImpl(e){if(null===this._data||null===this._barWidth)return;const{font:t,fontSize:i,labelColor:s,bars:n,inverted:r,labelsPadding:a}=this._data,l=e.context;l.textAlign="center",l.fillStyle=s,l.font=(0,o.makeFont)(i,t);for(let e=0;e<n.length;++e){const t=n[e],i=Math.round(Math.min(t.high,t.low)),s=Math.round(Math.max(t.high,t.low)),o=Math.round(t.center);l.textBaseline="alphabetic",l.fillText(r?t.lowLabel:t.highLabel,o,i-a),l.textBaseline="top",l.fillText(r?t.highLabel:t.lowLabel,o,s+a)}}}var h,d=i(94602),u=i(45801),_=i(84617),p=i(33350),m=i(48227),g=i(68735);!function(e){e[e.MaxFontSize=36]="MaxFontSize",e[e.MinFontSize=8]="MinFontSize"}(h||(h={}));class f extends g.SeriesBarCandlesPaneView{constructor(e,t){super(e,t),this._labelsRenderer=new c,this._candlesRenderer=new m.PaneRendererCandles,this._maxLengthLabel="",this._calculateFontSize=(0,s.default)(((e,t)=>Math.max(1,(0,n.lowerboundExt)((e=>e+1),null,(i=>{const s=(0,o.makeFont)(i,_.CHART_FONT_FAMILY);return(0,p.measureText)(e,s).width<=t}),7,36))),((e,t)=>`${e}/${t}`))}renderer(){const e=this._source.priceScale();if(!e||e.isEmpty())return null;const t=new d.CompositeRenderer,i=this._needLabels(),s=this._source.properties().childs().hiloStyle.childs(),o=this._model.timeScale().barSpacing();if(this._invalidated){const e=this._source.formatter();this._maxLengthLabel="",this._updateImpl({generateLabels:i,formatter:e}),this._invalidated=!1}if(this._candlesRenderer.setData({bars:this._bars,wickVisible:!1,bodyVisible:s.drawBody.value(),barSpacing:o,borderVisible:s.showBorders.value(),barWidth:(0,r.optimalHiLoWidth)(o),isPriceScaleInverted:e.isInverted()}),t.append(this._candlesRenderer),i){const i=this._calculateLabelFontSize()
;i&&i>=8&&(this._labelsRenderer.setData({bars:this._bars,barSpacing:o,font:_.CHART_FONT_FAMILY,fontSize:i,labelColor:s.labelColor.value(),inverted:e.isInverted(),labelsPadding:.4*i}),t.append(this._labelsRenderer))}return this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&t.append(new u.SelectionRenderer(this._selectionData)),t}topPixelMargin(){return this._margin()}bottomPixelMargin(){return this._margin()}_createItem(e,t,i,s){const o={center:NaN,left:NaN,right:NaN,open:NaN,high:NaN,low:NaN,close:NaN,color:i.barColor,borderColor:i.barBorderColor,hollow:!1,highLabel:"",lowLabel:"",timePointIndex:e};if(!(0,g.baseBarCandlesUpdater)(t,o))return null;if(o.open=o.high,o.close=o.low,s.generateLabels){const e=s.formatter.format(o.high),t=s.formatter.format(o.low);o.highLabel=e,o.lowLabel=t;const i=(e.length>t.length?e:t).replace(/\d/g,"0");i.length>this._maxLengthLabel.length&&(this._maxLengthLabel=i)}return o}_margin(){if(this._needLabels()){const e=this._calculateLabelFontSize();if(e&&e>=8)return 1.4*e}return 0}_calculateLabelFontSize(){return""===this._maxLengthLabel?null:this._calculateFontSize(this._maxLengthLabel,Math.floor(this._model.timeScale().barSpacing())-2)}_needLabels(){const e=this._source.properties().childs().hiloStyle.childs().showLabels.value(),t=this._model.timeScale().barSpacing();return e&&t>5}}},46340:(e,t,i)=>{"use strict";i.d(t,{SeriesHLCAreaPaneView:()=>g});var s=i(10555),o=i(50151),n=i(37103),r=i(97126),a=i(13173),l=i(45801),c=i(5471),h=i(4539),d=i(94602),u=i(2383),_=i(79268),p=i(7793);class m extends p.ObjectValuesCache{_newObject(){return{high:void 0,close:void 0,low:void 0}}_clearObject(e){e.high=void 0,e.close=void 0,e.low=void 0}}class g{constructor(e,t){this._isMarkersEnabled=(0,n.enabled)("source_selection_markers"),this._hlcAreaCache=new m,this._highPoints=new p.CachedContainer,this._closePoints=new p.CachedContainer,this._lowPoints=new p.CachedContainer,this._barsBorders=new p.CachedContainer,this._filledAreas=new r.CachedMap,this._renderer=new d.CompositeRenderer,this._invalidated=!0,this._source=e,this._model=t,this._selectionIndexer=new a.SelectionIndexes(t.timeScale())}update(){this._invalidated=!0}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._renderer}_updateImpl(){this._renderer.clear();const e=this._model.timeScale(),t=this._source.priceScale();if(e.isEmpty()||!t||t.isEmpty())return;const i=e.visibleBarsStrictRange();if(null===i)return;if(0===this._source.bars().size())return;const n=this._source.firstValue();if(null===n)return;const a=this._source.nearestIndex(i.firstBar()-1,c.PlotRowSearchMode.NearestLeft)??i.firstBar()-1,d=this._source.nearestIndex(i.lastBar()+1,c.PlotRowSearchMode.NearestRight)??i.lastBar()+1;this._hlcAreaCache.invalidateCache(),this._hlcAreaCache.setStartIndex(a),this._barsBorders.invalidateCache(),this._highPoints.invalidateCache(),this._lowPoints.invalidateCache(),this._closePoints.invalidateCache(),this._filledAreas.invalidateCache();let p,m,g
;this._source.bars().range(a,d).each(((e,t)=>{if(this._hlcAreaCache.isValidIndex(e)){const i=this._hlcAreaCache.at(e);i.close=t[4],i.high=t[2],i.low=t[3]}return!1}));const f=new Map,y=a+this._hlcAreaCache.length();for(let e=a;e<y;e++){const t=this._hlcAreaCache.at(e),i=t.close??null,s=t.high??null,o=t.low??null;(null!==i||null!==s||null!==o||Number.isFinite(p)||Number.isFinite(m)||Number.isFinite(g))&&(p=i,m=s,g=o,this._highPoints.push(s),this._closePoints.push(i),this._lowPoints.push(o),this._barsBorders.push({timePointIndex:e,left:NaN,center:NaN,right:NaN}),f.set(e,this._barsBorders.length()-1))}t.pricesArrayToCoordinates(this._highPoints.data(),n,this._highPoints.length()),t.pricesArrayToCoordinates(this._closePoints.data(),n,this._closePoints.length()),t.pricesArrayToCoordinates(this._lowPoints.data(),n,this._lowPoints.length()),e.fillBarBorders(this._barsBorders.data(),{startItemIndex:0,endItemIndex:this._barsBorders.length()});const v=this._source.properties().childs().hlcAreaStyle.childs(),S=v.highCloseFillColor.value(),b=v.closeLowFillColor.value(),w=this._filledAreas.get(S)??new r.AreaBackgroundItemsGroup({type:0,color:S}),C=w.newItem()??new r.AreaBackgroundItem;w.push(C),this._filledAreas.set(S,w);const T=this._filledAreas.get(b)??new r.AreaBackgroundItemsGroup({type:0,color:b}),P=T.newItem()??new r.AreaBackgroundItem;T.push(P),this._filledAreas.set(b,T);const x=[],M=[],I=[],A=this._barsBorders.length();for(let e=0;e<A;e++){const t=this._closePoints.at(e),i=this._highPoints.at(e),s=this._lowPoints.at(e),o=this._barsBorders.at(e),n=o.center,r=(0,h.coordinateIsValid)(t),a=(0,h.coordinateIsValid)(i),l=(0,h.coordinateIsValid)(s);r&&a&&l&&(C.addPoints1Point(n,i),C.addPoints2Point(n,t),P.addPoints1Point(n,t),P.addPoints2Point(n,s),x.push({y:i,...o}),M.push({y:t,...o}),I.push({y:s,...o}))}const L=e.barSpacing();if(this._renderer.append(new r.AreaBackgroundRenderer({barSpacing:L,colorAreas:this._filledAreas})),v.lowLineVisible.value()&&this._renderer.append(new _.PaneRendererLine({barSpacing:L,items:I,simpleMode:!0,withMarkers:!1,lineColor:v.lowLineColor.value(),lineStyle:v.lowLineStyle.value(),lineWidth:v.lowLineWidth.value(),skipHoles:!0})),v.highLineVisible.value()&&this._renderer.append(new _.PaneRendererLine({barSpacing:L,items:x,simpleMode:!0,withMarkers:!1,lineColor:v.highLineColor.value(),lineStyle:v.highLineStyle.value(),lineWidth:v.highLineWidth.value(),skipHoles:!0})),this._renderer.append(new _.PaneRendererLine({barSpacing:L,items:M,simpleMode:!0,withMarkers:!1,lineColor:v.closeLineColor.value(),lineStyle:v.closeLineStyle.value(),lineWidth:v.closeLineWidth.value(),skipHoles:!0})),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled){const t=this._selectionIndexer.indexes(),i=[],n=[],r=(0,o.ensureNotNull)(this._model.paneForSource(this._source)).height();for(let e=0;e<t.length;e++){const o=t[e],a=f.get(o);if(void 0===a)continue;const l=this._closePoints.at(a),c=this._barsBorders.at(a).center;i.push({point:new s.Point(c,l)}),n.push(this._model.backgroundColorAtYPercentFromTop(l/r))}
this._renderer.append(new l.SelectionRenderer({bgColors:n,points:i,visible:!0,barSpacing:e.barSpacing(),hittestResult:u.HitTarget.Regular}))}else this._selectionIndexer.clear()}}},28334:(e,t,i)=>{"use strict";i.d(t,{SeriesHLCBarsPaneView:()=>l});var s=i(94602),o=i(45801),n=i(64138),r=i(62802);function a(e){return null!=e}class l extends r.SeriesBarsPaneView{renderer(){this._invalidated&&(this._updateImpl(null),this._invalidated=!1);const e=this._source.properties().childs(),t={bars:this._bars,dontDrawOpen:!0,thinBars:e.hlcBarsStyle.childs().thinBars.value()},i=new s.CompositeRenderer;return i.append(new n.PaneRendererBars(t)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&i.append(new o.SelectionRenderer(this._selectionData)),i}_createItem(e,t,i){const s=t[2],o=t[3],n=t[4];if(!a(s)||!a(o)||!a(n))return null;return{center:NaN,open:NaN,high:s,low:o,close:n,color:i.barColor,left:NaN,right:NaN,timePointIndex:e}}}},54405:(e,t,i)=>{"use strict";i.d(t,{SeriesHollowCandlesPaneView:()=>l});var s=i(94602),o=i(4539),n=i(45801),r=i(48227),a=i(27808);class l extends a.SeriesCandlesPaneView{renderer(){this._invalidated&&(this._updateImpl(null),this._invalidated=!1);const e=this._source.priceScale();if(!e)return null;const t=this._source.properties().childs().hollowCandleStyle.childs(),i=this._model.timeScale().barSpacing(),a={bars:this._bars,barSpacing:i,bodyVisible:t.drawBody.value(),borderVisible:t.drawBorder.value(),borderColor:t.borderColor.value(),wickColor:t.wickColor.value(),barWidth:(0,o.optimalBarWidth)(i),wickVisible:t.drawWick.value(),isPriceScaleInverted:e.isInverted()},l=new s.CompositeRenderer;return l.append(new r.PaneRendererCandles(a)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&l.append(new n.SelectionRenderer(this._selectionData)),l}}},32399:(e,t,i)=>{"use strict";i.d(t,{SeriesLinePaneView:()=>h});var s=i(2383),o=i(94602),n=i(79268),r=i(60876),a=i(45801),l=i(73773),c=i(93201);class h extends l.SeriesSingleLinePaneView{renderer(){this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e=this._source.properties().childs(),t=e.style.value();let i,l=!1;2===t?i=e.lineStyle.childs():14===t?(i=e.lineWithMarkersStyle.childs(),l=!0):15===t?i=e.steplineStyle.childs():18===t&&(i=e.tpoStyle.childs());const h=this._model.timeScale().barSpacing(),d=i.colorType?.value()!==c.ColorType.Gradient?{type:c.ColorType.Solid,color:i.color.value()}:{type:c.ColorType.Gradient,startColor:i.gradientStartColor.value(),endColor:i.gradientEndColor.value()},u={barSpacing:h,items:this._items,lineColor:d,lineStyle:i.linestyle.value(),withMarkers:l,lineWidth:i.linewidth.value(),simpleMode:!0,hitTestResult:s.HitTarget.Regular,skipHoles:!0};let _,p;if(_=15===t?new r.PaneRendererStepLine(u):new n.PaneRendererLine(u),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData){const e=new o.CompositeRenderer;e.append(_),e.append(new a.SelectionRenderer(this._selectionData)),p=e}else p=_;return p}}},
68735:(e,t,i)=>{"use strict";i.d(t,{SeriesBarCandlesPaneView:()=>h,baseBarCandlesUpdater:()=>c});var s=i(10555),o=i(37103),n=i(13173),r=i(5471),a=i(2383);function l(e){return null!=e}function c(e,t){const i=e[1],s=e[2],o=e[3],n=e[4];return!!(l(i)&&l(s)&&l(o)&&l(n))&&(t.open=i,t.high=s,t.low=o,t.close=n,!0)}class h{constructor(e,t){this._bars=[],this._invalidated=!0,this._isMarkersEnabled=(0,o.enabled)("source_selection_markers"),this._selectionData=null,this._source=e,this._model=t,this._selectionIndexer=new n.SelectionIndexes(t.timeScale())}items(){return this._bars}update(){this._invalidated=!0}_updateImpl(e){const t=this._model.timeScale(),i=this._source.priceScale();if(this._bars=[],t.isEmpty()||!i||i.isEmpty())return;const o=t.visibleBarsStrictRange();if(null===o)return;if(0===this._source.bars().size())return;let n=this._source.nearestIndex(o.firstBar(),r.PlotRowSearchMode.NearestRight);const l=this._source.nearestIndex(o.lastBar(),r.PlotRowSearchMode.NearestLeft);if(void 0===n||void 0===l)return;for(;n<=l;n++){if(null!==this._source.bars().valueAt(n))break}if(n>l)return;const c=this._source.bars().range(n,l),h=this._source.barColorer(),d={};if(c.each(((t,i)=>{d.value=i;const s=h.firstColoredBar(t);let o;null!==s&&s>=t?this._source.setPrecomputedBarStyle(i,void 0):o=this._source.precomputedBarStyle(i),void 0===o&&(o=h.barStyle(t,!1,d),this._source.setPrecomputedBarStyle(i,o));const n=this._createItem(t,i,o,e);return!!n&&(d.previousValue=i,this._bars.push(n),!1)})),0===this._bars.length)return;const u=this._source.firstValue();if(null!==u)if(i.barPricesToCoordinates(this._bars,u),t.fillBarBorders(this._bars),this._model.selection().isSelected(this._source)){const e=this._selectionIndexer.indexes();this._selectionData={points:[],bgColors:[],visible:!0,hittestResult:a.HitTarget.Regular,barSpacing:t.barSpacing()};const o=this._model.paneForSource(this._source);if(!o)return;const n=o.height();for(let o=0;o<e.length;o++){const r=e[o],a=this._source.bars().valueAt(r);if(null===a)continue;const l=a[1],c=a[4];if(null==l||null==c)continue;const h=.5*(l+c),d=t.indexToCoordinate(r),_=i.priceToCoordinate(h,u);this._selectionData.points.push({point:new s.Point(d,_)}),this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(_/n))}}else this._selectionIndexer.clear()}}},59064:(e,t,i)=>{"use strict";i.d(t,{mainSeriesProperties:()=>n});var s=i(69558),o=(i(18330),i(40080),i(22033));const n={style:1,esdShowDividends:!0,esdShowSplits:!0,esdShowEarnings:!0,esdShowBreaks:!1,esdFlagSize:2,showContinuousContractSwitches:!0,showContinuousContractSwitchesBreaks:!1,showFuturesContractExpiration:!0,showLastNews:!0,showCountdown:!0,bidAsk:{visible:!1,lineStyle:s.LINESTYLE_DOTTED,lineWidth:1},prePostMarket:{visible:!0,lineStyle:s.LINESTYLE_DOTTED,lineWidth:1},highLowAvgPrice:{highLowPriceLinesVisible:!1,highLowPriceLabelsVisible:!1,averageClosePriceLineVisible:!1,averageClosePriceLabelVisible:!1,highLowPriceLinesWidth:1,averagePriceLineWidth:1},visible:!0,showPriceLine:!0,priceLineWidth:1,showPrevClosePriceLine:!1,
prevClosePriceLineWidth:1,minTick:"default",dividendsAdjustment:void 0,backAdjustment:!1,settlementAsClose:!0,sessionId:"regular",sessVis:!1,statusViewStyle:{fontSize:16,showExchange:!0,showInterval:!0,symbolTextSource:"description"},candleStyle:{drawWick:!0,drawBorder:!0,barColorsOnPrevClose:!1,drawBody:!0},volCandlesStyle:{drawWick:!0,drawBorder:!0,barColorsOnPrevClose:!1,drawBody:!0},hollowCandleStyle:{drawWick:!0,drawBorder:!0,drawBody:!0},haStyle:{drawWick:!0,drawBorder:!0,showRealLastPrice:!1,barColorsOnPrevClose:!1,inputs:{},inputInfo:{},drawBody:!0},barStyle:{barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},hiloStyle:{showBorders:!0,showLabels:!0,drawBody:!0},columnStyle:{barColorsOnPrevClose:!0,priceSource:"close",baselinePosition:"bottom"},lineStyle:{linestyle:s.LINESTYLE_SOLID,linewidth:2,priceSource:"close"},tpoStyle:{},svpStyle:{},lineWithMarkersStyle:{linestyle:s.LINESTYLE_SOLID,linewidth:2,priceSource:"close"},steplineStyle:{linestyle:s.LINESTYLE_SOLID,linewidth:2,priceSource:"close"},areaStyle:{linestyle:s.LINESTYLE_SOLID,linewidth:2,priceSource:"close"},hlcAreaStyle:{highLineVisible:!0,highLineStyle:s.LINESTYLE_SOLID,highLineWidth:2,lowLineVisible:!0,lowLineStyle:s.LINESTYLE_SOLID,lowLineWidth:2,closeLineStyle:s.LINESTYLE_SOLID,closeLineWidth:2},priceAxisProperties:{autoScale:!0,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,indexedTo100:!1,log:!1,logDisabled:!1,isInverted:!1,alignLabels:!0},renkoStyle:{inputs:{source:"close",sources:"Close",boxSize:3,style:"ATR",atrLength:14,percentageLTP:1,wicks:!0},inputInfo:{source:{name:"Source"},sources:{name:"Source"},boxSize:{name:"Box size"},style:{name:"Style"},atrLength:{name:"ATR length"},percentageLTP:{name:"Percentage"},wicks:{name:"Wicks"}}},pbStyle:{inputs:{source:"close",lb:3},inputInfo:{source:{name:"Source"},lb:{name:"Number of line"}}},kagiStyle:{inputs:{source:"close",style:"ATR",atrLength:14,percentageLTP:1,reversalAmount:1},inputInfo:{source:{name:"Source"},style:{name:"Style"},atrLength:{name:"ATR length"},percentageLTP:{name:"Percentage"},reversalAmount:{name:"Reversal amount"}}},pnfStyle:{inputs:{sources:"Close",reversalAmount:3,boxSize:1,style:"ATR",atrLength:14,percentageLTP:1,oneStepBackBuilding:!1},inputInfo:{sources:{name:"Source"},boxSize:{name:"Box size"},reversalAmount:{name:"Reversal amount"},style:{name:"Style"},atrLength:{name:"ATR length"},percentageLTP:{name:"Percentage"},oneStepBackBuilding:{name:"One step back building"}}},baselineStyle:{topLineWidth:2,bottomLineWidth:2,topLineStyle:s.LINESTYLE_SOLID,bottomLineStyle:s.LINESTYLE_SOLID,priceSource:"close",transparency:50,baseLevelPercentage:50},rangeStyle:{barStyle:o.RangeBarStyle.Bars,thinBars:!0,inputs:{range:10,phantomBars:!1},inputInfo:{range:{name:"Range"},phantomBars:{name:"Phantom bars"}}},volFootprintStyle:{},hlcBarsStyle:{barColorsOnPrevClose:!1,thinBars:!0}}},73773:(e,t,i)=>{"use strict";i.d(t,{SeriesSingleLinePaneView:()=>d});var s=i(69708),o=i(10555),n=i(50151),r=i(37103),a=i(13173),l=i(5471),c=i(2383),h=i(12217);class d{constructor(e,t){
this._items=[],this._invalidated=!0,this._isMarkersEnabled=(0,r.enabled)("source_selection_markers"),this._selectionData=null,this._source=e,this._model=t,this._selectionIndexer=new a.SelectionIndexes(t.timeScale())}update(){this._invalidated=!0}_updateImpl(){this._items=[];const e=this._model.timeScale(),t=this._source.priceScale();if(e.isEmpty()||!t||t.isEmpty())return;const i=e.visibleBarsStrictRange();if(null===i)return;if(0===this._source.bars().size())return;const r=this._source.nearestIndex(i.firstBar()-1,l.PlotRowSearchMode.NearestLeft)??i.firstBar()-1,a=this._source.nearestIndex(i.lastBar()+1,l.PlotRowSearchMode.NearestRight)??i.lastBar()+1,d=this._source.barFunction(),u=this._model.timeScale().barSpacing();if(u<.1&&this._source.supportsConflatedChunks()){const e=this._source.conflatedChunks(u,(0,n.ensureNotNull)(this._source.priceSource())),t=(0,h.lowerbound)(e,r,((e,t)=>e.startTime<t)),i=Math.min(e.length-1,(0,h.lowerbound)(e,a,((e,t)=>e.endTime<t)));for(let s=t;s<=i;s++){const t=e[s];[t.open,t.high,t.low,t.close].forEach((e=>{this._items.push({timePointIndex:t.startTime,y:e,left:NaN,center:NaN,right:NaN})}))}}else for(const{index:e,value:t}of this._source.bars().rangeIterator(r,a)){const i=d(t);(0,s.default)(i)&&this._items.push({timePointIndex:e,y:i,left:NaN,center:NaN,right:NaN})}const _=this._source.firstValue();if(null!==_)if(t.pointsArrayToCoordinates(this._items,_),e.fillBarBorders(this._items),this._model.selection().isSelected(this._source)){const i=this._selectionIndexer.indexes();this._selectionData={points:[],bgColors:[],visible:!0,barSpacing:e.barSpacing(),hittestResult:c.HitTarget.Regular};const s=(0,n.ensureNotNull)(this._model.paneForSource(this._source)).height();this._selectionData.hittestResult=c.HitTarget.Regular;for(let n=0;n<i.length;n++){const r=i[n],a=this._source.bars().valueAt(r);if(null===a)continue;const l=d(a),c=e.indexToCoordinate(r),h=t.priceToCoordinate(l,_);this._selectionData.points.push({point:new o.Point(c,h)}),this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(h/s))}}else this._selectionIndexer.clear();else this._items=[]}}},22033:(e,t,i)=>{"use strict";i.d(t,{RangeBarStyle:()=>y,areaStylePreferencesDefault:()=>c,barStylePreferencesDefault:()=>r,baselineStylePreferencesDefault:()=>d,candleStylePreferencesDefault:()=>o,columnStylePreferencesDefault:()=>S,haStylePreferencesDefault:()=>_,hiloStylePreferencesDefault:()=>u,hlcAreaStylePreferencesDefault:()=>h,hlcBarsStylePreferencesDefault:()=>a,hollowCandlePreferencesStyleDefault:()=>n,kagiStylePreferencesDefault:()=>g,lineStyleDefault:()=>l,pbStylePreferencesDefault:()=>m,pnfStylePreferencesDefault:()=>f,rangeStylePreferencesDefault:()=>v,renkoStylePreferencesDefault:()=>p});var s=i(93201);const o={upColor:"",downColor:"",drawWick:!1,drawBorder:!1,drawBody:!0,borderColor:"",borderUpColor:"",borderDownColor:"",wickColor:"",wickUpColor:"",wickDownColor:"",barColorsOnPrevClose:!1},n={upColor:"",downColor:"",drawWick:!1,drawBorder:!1,drawBody:!0,borderColor:"",borderUpColor:"",borderDownColor:"",
wickColor:"",wickUpColor:"",wickDownColor:""},r={upColor:"",downColor:"",barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},a={color:"",thinBars:!0},l={color:"",linestyle:0,linewidth:0,colorType:s.ColorType.Gradient,gradientStartColor:"",gradientEndColor:""},c={color1:"",color2:"",linecolor:"",linestyle:0,linewidth:0,transparency:0},h={highLineVisible:!0,highLineColor:"",highLineStyle:0,highLineWidth:0,lowLineVisible:!0,lowLineColor:"",lowLineStyle:0,lowLineWidth:0,closeLineColor:"",closeLineStyle:0,closeLineWidth:0,highCloseFillColor:"",closeLowFillColor:""},d={topFillColor1:"",topFillColor2:"",bottomFillColor1:"",bottomFillColor2:"",topLineColor:"",bottomLineColor:"",baselineColor:"",topLineWidth:0,bottomLineWidth:0,topLineStyle:0,bottomLineStyle:0,transparency:0,baseLevelPercentage:0},u={color:"",showBorders:!1,borderColor:"",showLabels:!1,labelColor:"",drawBody:!0},_={upColor:"",downColor:"",drawWick:!1,drawBorder:!1,drawBody:!0,borderColor:"",borderUpColor:"",borderDownColor:"",wickColor:"",wickUpColor:"",wickDownColor:"",showRealLastPrice:!1,barColorsOnPrevClose:!1,inputs:{}},p={upColor:"",downColor:"",borderUpColor:"",borderDownColor:"",upColorProjection:"",downColorProjection:"",borderUpColorProjection:"",borderDownColorProjection:"",wickUpColor:"",wickDownColor:"",inputs:{boxSize:0,style:"",atrLength:0,percentageLTP:0,wicks:!1,sources:"",source:""}},m={upColor:"",downColor:"",borderUpColor:"",borderDownColor:"",upColorProjection:"",downColorProjection:"",borderUpColorProjection:"",borderDownColorProjection:"",inputs:{source:"",lb:0}},g={upColor:"",downColor:"",upColorProjection:"",downColorProjection:"",inputs:{style:"",atrLength:0,percentageLTP:0,reversalAmount:0}},f={upColor:"",downColor:"",upColorProjection:"",downColorProjection:"",inputs:{reversalAmount:0,boxSize:0,style:"",atrLength:0,percentageLTP:0,oneStepBackBuilding:!1,sources:"Close"}};var y;!function(e){e[e.Bars=0]="Bars",e[e.Candles=1]="Candles"}(y||(y={}));const v={barStyle:0,upColor:"",downColor:"",upColorProjection:"",downColorProjection:"",thinBars:!1,candlesUpColor:"",candlesDownColor:"",candlesBorderUpColor:"",candlesBorderDownColor:"",candlesWickUpColor:"",candlesWickDownColor:"",inputs:{range:0,phantomBars:!1}},S={upColor:"",downColor:"",barColorsOnPrevClose:!1,baselinePosition:"bottom"}},11768:(e,t,i)=>{"use strict";i.d(t,{SeriesTableViewValuesProvider:()=>a,fillSymbolSourceValuesProviderItemsVisibility:()=>r});var s=i(3885),o=i(95059),n=i(31789);function r(e,t,i,s){const r=12!==i,a=s.properties().childs().paneProperties.childs().legendProperties.childs(),l=12!==i&&16!==i&&21!==i,c=12!==i,h=(0,o.isPriceSourceStyle)(i),d=!h;e[5].visible=!1;const u=s.mainSeries().intervalObj().value().is1Tick();e[0].visible=d&&l&&!u,e[1].visible=d&&!u,e[2].visible=d&&!u,e[3].visible=d&&c,e[6].visible=a.showBarChange.value()&&r,e[4].visible=h,e[4].title=t?n.priceSourceTitles[t]:""}class a{constructor(e,t){this._model=t,this._series=e,this._valuesProvider=new s.SeriesValuesProvider(e,t,!1)}getItems(){
const e=this._valuesProvider.getItems(),t=this._series.style();r(e,this._series.priceSource(),t,this._model);const i=this._model.properties().childs().paneProperties.childs().legendProperties.childs();return e[8].visible=!1,e[7].visible=i.showVolume.value(),e}getValues(e){const t=this._series.bars().lastIndex();return null===t||t<e?null:this._valuesProvider.getValues(e)}}},89837:(e,t,i)=>{"use strict";i.d(t,{getErrorFromUnsupportedResolutionState:()=>c,getResolutionUnsupportedReason:()=>h});var s=i(11542),o=i(46082),n=i(87296);const r=s.t(null,void 0,i(64818)),a=s.t(null,void 0,i(80254)),l=s.t(null,void 0,i(80185));function c(e,t=!1){const i=t?`<b>${e.ticker}</b>`:e.ticker;switch(e.reason){case"unsupported_resolution":{const s=t?`<b>${e.supportedResolutions.join(", ")}</b>`:e.supportedResolutions.join(", ");return r.format({ticker:i,availableResolutions:s})}case"unsupported_ticks":return a.format({ticker:i});case"less_than_frequency":{const s=t?`<b>${e.applicableResolution}</b>`:e.applicableResolution;return l.format({ticker:i,resolution:s})}}}function h(e,t){if(null===e)return null;const i=e.data_frequency;if(void 0!==i){if((0,n.getApplicableIntervalForFrequency)(i,t)!==t)return"less_than_frequency"}if(o.Interval.isIntraday(t)&&!e.has_intraday)return"unsupported_resolution";if(o.Interval.isTicks(t)&&!e["is-tickbars-available"])return"unsupported_ticks";{const i=o.Interval.isSeconds(t)&&!e.has_seconds,s=o.Interval.isDays(t)&&!e.has_daily,n=o.Interval.isTicks(t)&&!e?.supported_resolutions?.includes(t);if(i||s||n)return"unsupported_resolution"}return null}},3885:(e,t,i)=>{"use strict";i.d(t,{SeriesValuesProvider:()=>A,calculateColor:()=>M,changesData:()=>I});var s=i(50151),o=i(50335),n=i(24377),r=i(11542),a=i(49483),l=i(37103),c=i(52859),h=i(24640),d=i(5471),u=i(78861),_=i(56265),p=i(70859),m=i(95059);function g(e,t){return 100*(t-e)/Math.abs(e||1)}var f=i(63903),y=i(11946),v=i(53660),S=i(17161);const b=S.lastDayChangeAvailable||S.alwaysShowLastPriceAndLastDayChange,w=a.CheckMobile.any(),C=(0,_.getPercentageFormatter)(),T=(0,_.getVolumeFormatter)(2),P=`${v.notAvailable} (${v.notAvailable}%)`;var x;function M(e,t){const i=(0,n.parseRgb)(t),s=(0,n.parseRgb)(e);return(0,n.distanceRgb)(i,s)<70?(0,n.rgbToHexString)((0,n.invertRgb)(i)):t}function I(e,t,i,s,o){let n,r;if(null!==t){const e=o[4],i=t.change||0;r={change:i,currentPrice:e,prevPrice:e-i,percentChange:t.change_percent||0}}const a=i[4],l=e.search(s-1,d.PlotRowSearchMode.NearestLeft,1),c=l?.value[4]??null;return null!==c&&null!=a&&(n={change:a-c,currentPrice:a,prevPrice:c,percentChange:g(c,a)}),{barChange:n,lastDayChange:r}}!function(e){e[e.Open=0]="Open",e[e.High=1]="High",e[e.Low=2]="Low",e[e.Close=3]="Close",e[e.Source=4]="Source",e[e.LastPrice=5]="LastPrice",e[e.Change=6]="Change",e[e.Volume=7]="Volume",e[e.LastDayChange=8]="LastDayChange"}(x||(x={}));class A{constructor(e,t,s=!0){this._series=e,this._model=t,this._searchNearestLeftValue=s,this._emptyValues=[{title:r.t(null,void 0,i(16610)),visible:!1,value:"",index:0,orderIndex:0,id:"open"},{
title:r.t(null,void 0,i(78254)),visible:!1,value:"",index:1,orderIndex:1,id:"high"},{title:r.t(null,void 0,i(65318)),visible:!1,value:"",index:2,orderIndex:2,id:"low"},{title:r.t(null,{context:"input"},i(51408)),visible:!1,value:"",index:3,orderIndex:3,id:"close"},{title:"",visible:!1,value:"",index:4,orderIndex:4,id:"source"},{title:"",visible:!1,value:"",index:5,orderIndex:5,id:"lastPrice"},{title:r.t(null,void 0,i(37276)),visible:!1,value:"",index:6,orderIndex:6,id:"change"},{title:r.t(null,{context:"study"},i(24261)),visible:!1,value:"",index:7,orderIndex:7,id:"volume"},{title:r.t(null,void 0,i(63815)),visible:!1,value:"",index:8,orderIndex:8,id:"lastDayChange"}]}getItems(){return this._emptyValues}getValues(e){const t=this._showLastPriceAndChangeOnly(),i=this._emptyValues.map(((e,i)=>({...e,value:6===i||8===i?P:v.notAvailable,visible:5!==i&&4!==i&&!t})));if(this._model.timeScale().isEmpty()||0===this._series.bars().size()||this._series.priceScale().isEmpty())return i;const n=(0,s.ensureNotNull)(this._series.data().bars().last());(0,o.isNumber)(e)||(e=n.index);const r=this._searchNearestLeftValue?d.PlotRowSearchMode.NearestLeft:d.PlotRowSearchMode.Exact,a=this._series.nearestIndex(e,r);if(void 0===a)return i;const u=this._series.data().valueAt(a),_=this._model.backgroundTopColor().value();if(null===u)return i;const p=u[1],m=u[2],g=u[3],y=u[4],{barChange:S,lastDayChange:w}=I(this._series.data(),this._series.quotes(),u,a,n.value),x=(0,f.getPriceValueFormatterForSource)(this._series);if((0,f.shouldBeFormattedAsPercent)(this._series)||(0,f.shouldBeFormattedAsIndexedTo100)(this._series))i[6].value="",i[8].value="";else{const e=this._series.formatter(),t={signPositive:!0};if(void 0!==S){const{currentPrice:s,prevPrice:o,change:n,percentChange:r}=S,a=e.formatChange?.(s,o,t)??e.format(n,t);i[6].value=(0,h.forceLTRStr)(`${a} (${C.format(r,t)})`)}if(void 0!==w){const{currentPrice:s,prevPrice:o,change:n,percentChange:r}=w,a=e.formatChange?.(s,o,t)??e.format(n,t);i[8].value=(0,h.forceLTRStr)(`${a} (${C.format(r,t)})`)}}let A=null;if(t)i[5].value=null==y?v.notAvailable:x(y),i[5].visible=!0,A=this._getChangeColor(S?.change,a),i[6].visible=void 0!==S,i[8].visible=void 0!==w||b;else{i[0].value=null==p?v.notAvailable:x(p),i[1].value=null==m?v.notAvailable:x(m),i[2].value=null==g?v.notAvailable:x(g),i[3].value=null==y?v.notAvailable:x(y),i[4].value=x(this._series.barFunction()(u));const e=u[5];(0,o.isNumber)(e)?i[7].value=T.format(e):i[7].visible=!1;const t=this._series.intervalObj().value().is1Tick(),s=21!==this._series.style();i[0].visible=!t&&s,i[1].visible=!t,i[2].visible=!t,i[8].visible=void 0!==w||b,i[6].visible=void 0!==S;const n=this._series.barColorer().barStyle(a,!1);A=M(_,n.barBorderColor??n.barColor)}A=(0,c.resetTransparency)(M(_,A));for(const e of i)e.color||(e.color=A);{const e=this._series.model().properties().childs().paneProperties.childs().legendProperties.childs();i[6].visible&&l.enabled("legend_bar_change_colors_based_on_value")&&e.useBarChangeCustomColors&&(i[6].color=(0,
c.resetTransparency)(M(_,this._getChangeColor(S?.change,a))))}return i[8].visible&&(i[8].color=(0,c.resetTransparency)(M(_,this._getChangeColor(w?.change,n.index)))),i}_mobileNonTrackingMode(){return w&&(null===this._model.crosshairSource().pane||(0,y.isLineToolName)(u.tool.value())||null!==this._model.lineBeingEdited())}_showLastPriceAndChangeOnly(){return S.alwaysShowLastPriceAndLastDayChange||this._mobileNonTrackingMode()}_getChangeColor(e,t){const i=this._series.style();{const t=this._series.model().properties().childs().paneProperties.childs().legendProperties.childs();if(((0,m.isHLCBasedStyle)(i)||(0,m.isSingleValueBasedStyle)(i))&&l.enabled("legend_bar_change_colors_based_on_value")&&t&&t.useBarChangeCustomColors&&t.useBarChangeCustomColors.value()){const i=void 0===e||e>=0?t.barChangeUpColor&&t.barChangeUpColor.value():t.barChangeDownColor&&t.barChangeDownColor.value();if(i)return i}}if(2===i||15===i||14===i)return this._series.barColorer().barStyle(t,!1).barColor;const s=void 0===e||e>=0?p.SeriesBarColorer.upColor(this._series.properties()):p.SeriesBarColorer.downColor(this._series.properties());return s.barBorderColor??s.barColor}}},57511:(e,t,i)=>{"use strict";i.d(t,{sessionsPreferencesDefault:()=>o});var s=i(58978);const o={sessionHighlight:{backgrounds:{preMarket:{color:"#FF9800",transparency:92},postMarket:{color:s.colorsPalette["color-tv-blue-500"],transparency:92},electronic:{color:s.colorsPalette["color-tv-blue-500"],transparency:92},outOfSession:{color:s.colorsPalette["color-tv-blue-500"],transparency:92}},vertlines:{sessBreaks:{color:"#4985e7",style:2,visible:!1,width:1}}}}},42516:(e,t,i)=>{"use strict";i.d(t,{sourcesAffectState:()=>n});var s=i(97217),o=i(13896);function n(e){return!o.lineToolsDoNotAffectChartInvalidation||e.some((e=>!(0,s.isLineTool)(e)))}},52479:(e,t,i)=>{"use strict";i.d(t,{StatusProviderBase:()=>s});class s{size(){return"13px"}bold(){return!1}titleTooltip(){}}},13651:(e,t,i)=>{"use strict";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]}getInputsTitles(){return null}titleTooltip(){return this._statusProvider.titleTooltip()}bold(){return this._bold}size(){return this._size}}},23502:(e,t,i)=>{"use strict";i.d(t,{prepareStudyProperties:()=>w,prepareStudyPropertiesForLoadChart:()=>g});var s=i(16738),o=i(30551),n=i(9343),r=i(87465),a=i(19844),l=i(69558),c=i(60973),h=i(15219),d=i(37293),u=i(78176),_=i(97719),p=i(4359);const m=(0,n.getLogger)("Chart.Study");function g(e,t,i,o,n,l){return function(e,t,i,o,n,l,h){const d=function(e,t,i,o,n){e.version&&i.version&&e.version!==i.version&&m.logWarn("Serialized metaInfo version "+e.version+" is not equal to the saved state version "+i.version);const l=t||e,h=(0,r.clone)(l.defaults)??{},d=a.StudyMetaInfo.getStudyPropertyRootName(l),u=a.StudyMetaInfo.getStudyPropertyRootName(e);let _=y();(0,s.default)(_,f(e)),(0,s.default)(_,(0,r.clone)(e.defaults)),(0,s.default)(_,h),(0,s.default)(_,(0,
c.factoryDefaults)(d)),(0,s.default)(_,(0,c.factoryDefaults)(u)),(0,s.default)(_,v(l,o,d)),(0,s.default)(_,v(e,o,u)),(0,s.default)(_,i),_=o.updateStudyState(_,e,t),void 0!==n&&t&&(_=n(i,_,e,t));a.StudyMetaInfo.versionOf(l)>=1&&(0,s.default)(_,S(h,_));return _}(e,t,i,o,l);return T(t||e,n,d,h,!0)}(e,t,i,o,a.StudyMetaInfo.getStudyPropertyRootName(e),n,l)}function f(e){const t={};if(e.plots)for(let i=0;i<e.plots.length;i++){const s=e.plots[i],o=s.id;if((0,p.isColorerPlot)(s))continue;const n={display:15,color:"#0496FF",linestyle:l.LINESTYLE_SOLID,linewidth:2,plottype:p.LineStudyPlotStyle.Line,trackPrice:!1};(0,p.isBarColorerPlot)(s)&&(n.transparency=0),n.plottype=s.type,n.title=o,t[o]=n}return{styles:t}}function y(){const e=(0,r.clone)((0,c.defaults)("study"));return e.intervalsVisibilities=(0,r.clone)(d.intervalsVisibilitiesDefaults),e}function v(e,t,i){let s=(0,r.clone)((0,c.defaults)(i,t));return"Overlay"!==e.shortId&&"Compare"!==e.shortId||(s.currencyId=null,s.unitId=null),e.isTVScript&&e.TVScriptSourceCode!==s.TVScriptSourceCode&&(s=(0,r.clone)((0,c.factoryDefaults)(i))),s}function S(e,t){const i={};return h.StudyVersioning.mergeInputsObjPart(i,e.inputs??{}),h.StudyVersioning.mergeInputsObjPart(i,t.inputs),{inputs:i}}function b(e,t,i,n){if(a.StudyMetaInfo.versionOf(e)<1)throw new Error("This function cannot work with metainfo of the old format version. Required format version >= 1");const l=a.StudyMetaInfo.getStudyPropertyRootName(e),h=(0,r.clone)(e.defaults),d=(0,c.factoryDefaults)(l),u=y();if((0,s.default)(u,f(e)),(0,s.default)(u,h),(0,s.default)(u,d),(0,s.default)(u,v(e,n,l)),(0,s.default)(u,t),(0,s.default)(u,S(h,u)),null!==i){const t=i.model().studiesColorRotatorFactory().getColorRotator(e);null!==t&&("Overlay@tv-basicstudies"===e.id?u.lineStyle.color=t.getColor(u.lineStyle.color,d.lineStyle.color===u.lineStyle.color):(0,s.default)(u,function(e,t){for(const i of Object.keys(e.styles)){const s=e.styles[i];if((0,o.isObject)(s)&&"color"in s){const e=s.color;s.color=t.getColor(e)}}return e}(u,t)))}return n.updateStudyInputsIfNeeded(u,u.version??e.version,e),u}function w(e,t,i,s,o){return function(e,t,i,s,o,n){const l=b(e,t,i,s),c=a.StudyMetaInfo.getSourceInputIds(e);return c.forEach(((e,t)=>{const i=l.inputs[e];t<n.length?l.inputs[e]=`${n[t].id()}$0`:(0,r.isString)(i)&&i.includes("$")&&(l.inputs[e]="close")})),T(e,o,l)}(e,t,i,s,a.StudyMetaInfo.getStudyPropertyRootName(e),o)}const C=["id","description","description_localized","shortDescription","_metainfoVersion","is_price_study","is_hidden_study","priceScale","fullId","shortId","scriptIdPart","packageId","productId","isTVScriptStub","defaults","symbolSource","historyCalculationMayChange","format","linkedToSeries","isTVLibrary","docs","exports","exportTypes","extra","usesPrivateLib","financialPeriod","groupingKey","pine","isRGB","isTVScript","TVScriptMetaInfoExprs","usePlotsZOrder","isTVScriptStrategy","TVScriptSourceCode","lookaheadFutureData","hasAlertFunction","defaultStrategyAlertMessage","tags","canBeChild","canNotBeChild","_serverMetaInfoVersion","warnings"]
;function T(e,t,i,s,o){for(const e of C)delete i[e];const n=["visible","precision","minTick","intervalsVisibilities","inputs.first_visible_bar_time","inputs.last_visible_bar_time","inputs.subscribeRealtime","patchMetaInfoDefaults"];for(let t=0;t<e.inputs.length;++t){const i=e.inputs[t];i.isHidden&&(n.push(`inputs.${t}`),n.push(`inputs.${i.id}`))}const r=new u.DefaultProperty({defaultName:t,state:i,excludedDefaultsKeys:n,excludedStateKeys:["version"],theme:s});r.removeProperty("intervalsVisibilities"),r.addChild("intervalsVisibilities",new _.IntervalsVisibilitiesProperty(i&&i.intervalsVisibilities)),"PivotPointsStandard@tv-basicstudies"!==e.id&&"PivotPointsHighLow@tv-basicstudies"!==e.id||!r.hasChild("font")||r.removeProperty("font");const l=a.StudyMetaInfo.versionOf(e);return r.hasChild("version")?r.childs().version?.setValue(l):r.addProperty("version",l),r}},69866:(e,t,i)=>{"use strict";i.d(t,{containsBackgroundTimePointIndexes:()=>r,dematerializeBackground:()=>l,isBackgroundInBarsRange:()=>c,materializeBackground:()=>a});var s=i(50151),o=i(82284),n=i(33952);const r=!0;function a(e,t){if(e.start>=t.length||e.stop>=t.length)return null;const i=t[e.start],n=t[e.stop];return n===o.INVALID_TIME_POINT_INDEX?null:((0,s.assert)(i===o.INVALID_TIME_POINT_INDEX||i<=n,"start should not exceed stop"),{start:i===o.INVALID_TIME_POINT_INDEX?null:i,stop:n})}function l(e,t,i){return{id:t,start:(0,n.ensureTimePointIndexIndex)(i.indexOf(null!==e.start?e.start:o.INVALID_TIME_POINT_INDEX)),stop:(0,n.ensureTimePointIndexIndex)(i.indexOf(e.stop))}}function c(e,t){if(null===e.start)return t.firstBar()<=e.stop;const i=Math.min(e.start,e.stop),s=Math.max(e.start,e.stop);return t.contains(i)||t.contains(s)||i<t.firstBar()&&s>t.lastBar()}},45530:(e,t,i)=>{"use strict";i.d(t,{LiveStudyGraphics:()=>r.LiveStudyGraphics,createGraphicsPaneViews:()=>_,createGraphicsPriceAxisViews:()=>m,emptyStudyGraphics:()=>n.emptyStudyGraphics,isStudyGraphicsEmpty:()=>o.isStudyGraphicsEmpty,loadStudyGraphics:()=>n.loadStudyGraphics,saveStudyGraphics:()=>n.saveStudyGraphics});var s=i(9343),o=i(82130),n=i(39488),r=i(24437),a=i(36281),l=i(52859);class c extends a.PriceAxisView{constructor(e,t){super(),this._source=e,this._data=t}_updateRendererData(e,t,i){e.visible=!1;const s=this._source.priceScale(),o=this._source.properties().childs(),n=o.visible.value();if(!s||s.isEmpty()||!n)return;const r=o.graphics.childs()[this._data.lineType]?.childs()[this._data.styleId]?.childs();if(!(void 0!==r&&r.visible&&r.visible.value()&&r.showPrice&&r.showPrice.value()&&this._isLabelVisibleAccordinglyToProperties()))return;const a=this._source.firstValue();if(null===a)return;const c=this._data.line.level,h=(0,l.resetTransparency)(r.color.value());i.background=h,i.textColor=this.generateTextColor(h),i.coordinate=s.priceToCoordinate(c,a),e.text=s.formatPrice(c,a,{signPositive:s.isPercentage()}),e.visible=!0}_isLabelVisibleAccordinglyToProperties(){
return!!this._source.model().properties().childs().scalesProperties.childs().showStudyLastValue.value()&&this._source.properties().childs().showLabelsOnPriceScale.value()}}const h=(0,s.getLogger)("Chart.StudyGraphics"),d=new Set(["dwgtablecells","tpoBlockSets","tpoLevels","tpoVolumeRows","logs","performance"]);async function u(e,t,s,o){const n=e=>({regularPaneView:new e(t,s,o)});switch(e){case"hhists":return n((await i.e(507).then(i.bind(i,70588))).HHistPaneView);case"horizlines":return n((await i.e(507).then(i.bind(i,65212))).HorizLinePaneView);case"vertlines":return n((await i.e(507).then(i.bind(i,14832))).VertLinePaneView);case"polygons":return n((await i.e(507).then(i.bind(i,94053))).PolygonPaneView);case"backgrounds":return n((await i.e(507).then(i.bind(i,97173))).BackgroundPaneView)}return null}async function _(e,t,i){const s=[],o=[],n=Object.keys(e.graphicsInfo());n.sort(((e,t)=>p(e)-p(t)));for(const r of n){const n=await u(r,e,t,i);null!==n?(s.push(n.regularPaneView),n.forceOverlayPaneView&&o.push(n.forceOverlayPaneView)):d.has(r)||h.logWarn(`${r} is not supported by this build of graphics subsystem, skipping`)}return{regularPaneViews:s,forceOverlayPaneViews:o}}function p(e){return o.primitivesZOrders.get(e)??0}function m(e){const t=Object.keys(e.graphicsInfo()),i=[];for(const s of t)switch(s){case"hlines":e.graphics().hlines().forEach(((t,o)=>{t.forEach((t=>{void 0!==t.level&&i.push(new c(e,{line:{level:t.level},styleId:o,lineType:s}))}))}));break;case"horizlines":e.graphics().horizlines().forEach(((t,o)=>{t.forEach((t=>{void 0!==t.level&&i.push(new c(e,{line:{level:t.level},styleId:o,lineType:s}))}))}))}return i}},99481:(e,t,i)=>{"use strict";i.d(t,{HHistDirection:()=>s,HHistLocation:()=>o,HHistVolumeMode:()=>n,containsHHistTimePointIndexes:()=>c,dematerializeHHist:()=>d,isHHistInBarsRange:()=>u,materializeHHist:()=>h});var s,o,n,r=i(50151),a=i(82284),l=i(33952);!function(e){e.LeftToRight="left_to_right",e.RightToLeft="right_to_left"}(s||(s={})),function(e){e.Relative="relative",e.Absolute="absolute"}(o||(o={})),function(e){e.UpDown="Up/Down",e.Total="Total",e.Delta="Delta"}(n||(n={}));const c=!0;function h(e,t){if(e.lastBarTime>=t.length)return null;const i=t[e.firstBarTime],s=t[e.lastBarTime];return s===a.INVALID_TIME_POINT_INDEX?null:((0,r.assert)(i<=s,"firstBarTime should not exceed lastBarTime"),(0,r.assert)(e.priceLow<=e.priceHigh,"priceLow should not exceed priceHigh"),{firstBarTime:i===a.INVALID_TIME_POINT_INDEX?null:i,lastBarTime:s,rate:e.rate,priceHigh:e.priceHigh,priceLow:e.priceLow})}function d(e,t,i){const s=(0,l.ensureTimePointIndexIndex)(i.indexOf(e.firstBarTime??a.INVALID_TIME_POINT_INDEX)),o=(0,l.ensureTimePointIndexIndex)(i.indexOf(e.lastBarTime));return{id:t,...e,firstBarTime:s,lastBarTime:o}}function u(e,t){const i=Math.min(e.firstBarTime??a.INVALID_TIME_POINT_INDEX,e.lastBarTime),s=Math.max(e.firstBarTime??a.INVALID_TIME_POINT_INDEX,e.lastBarTime);return t.contains(i)||t.contains(s)||i<t.firstBar()&&s>t.lastBar()}},60661:(e,t,i)=>{"use strict";i.d(t,{
containsHorizLineTimePointIndexes:()=>r,dematerializeHorizLine:()=>l,isHorizLineInBarsRange:()=>c,materializeHorizLine:()=>a});var s=i(50151),o=i(82284),n=i(33952);const r=!0;function a(e,t){if(e.startIndex>=t.length||e.endIndex>=t.length)return null;const i=t[e.startIndex],n=t[e.endIndex];return n===o.INVALID_TIME_POINT_INDEX?null:((0,s.assert)(i<=n,"startIndex should not exceed endIndex"),{startIndex:i===o.INVALID_TIME_POINT_INDEX?null:i,endIndex:n,level:e.level,extendLeft:e.extendLeft,extendRight:e.extendRight})}function l(e,t,i){const s=(0,n.ensureTimePointIndexIndex)(i.indexOf(e.startIndex??o.INVALID_TIME_POINT_INDEX)),r=(0,n.ensureTimePointIndexIndex)(i.indexOf(e.endIndex));return{id:t,...e,startIndex:s,endIndex:r}}function c(e,t){if(null===e.startIndex)return t.firstBar()<=e.endIndex;const i=Math.min(e.startIndex,e.endIndex),s=Math.max(e.startIndex,e.endIndex);if(t.contains(i)||t.contains(s)||i<t.firstBar()&&s>t.lastBar())return!0;const o=e.startIndex<e.endIndex?e.extendLeft:e.extendRight,n=e.startIndex<e.endIndex?e.extendRight:e.extendLeft;return s<t.firstBar()&&n||i>t.lastBar()&&o}},24437:(e,t,i)=>{"use strict";i.d(t,{LiveStudyGraphics:()=>_});var s=i(50151),o=i(12217),n=i(48096),r=i(99481),a=i(60661),l=i(58554),c=i(30798),h=i(69866),d=i(82130),u=i(39488);class _{constructor(e={}){this._indexes=[],this._hhistsByTimePointIndex=new Map,this._primitivesCollection=function(e){const t={};for(const i of d.primitiveNames){t[i]=new Map;const s=e[i];if(void 0!==s)for(const e in s)if(s.hasOwnProperty(e))switch(i){case"horizlines":t[i].set(e,v.horizlines());break;case"vertlines":t[i].set(e,v.vertlines());break;case"backgrounds":t[i].set(e,v.backgrounds());break;case"polygons":t[i].set(e,v.polygons());break;case"hhists":t[i].set(e,v.hhists())}}0;return t}(e)}horizlines(){return this._primitivesCollection.horizlines}vertlines(){return this._primitivesCollection.vertlines}lines(){return this._primitivesCollection.lines}hlines(){return this._primitivesCollection.hlines}textmarks(){return this._primitivesCollection.textmarks}shapemarks(){return this._primitivesCollection.shapemarks}backgrounds(){return this._primitivesCollection.backgrounds}polygons(){return this._primitivesCollection.polygons}trendchannels(){return this._primitivesCollection.trendchannels}hhists(){return this._primitivesCollection.hhists}dwglabels(){return this._primitivesCollection.dwglabels}dwglines(){return this._primitivesCollection.dwglines}dwgpolylines(){return this._primitivesCollection.dwgpolylines}dwgboxes(){return this._primitivesCollection.dwgboxes}dwgtables(){return this._primitivesCollection.dwgtables}dwgtablecells(){return this._primitivesCollection.dwgtablecells}dwglinefills(){return this._primitivesCollection.dwglinefills}tpos(){return this._primitivesCollection.tpos}tpoBlockSets(){return this._primitivesCollection.tpoBlockSets}tpoLevels(){return this._primitivesCollection.tpoLevels}tpoVolumeRows(){return this._primitivesCollection.tpoVolumeRows}tpoSummaryInfo(){return this._primitivesCollection.tpoSummaryInfo}logs(){
return this._primitivesCollection.logs}observableLogs(){return this._primitivesCollection.logs}performance(){return this._primitivesCollection.performance}observablePerformance(){return this._primitivesCollection.performance}footprints(){return this._primitivesCollection.footprints}footprintLevels(){return this._primitivesCollection.footprintLevels}hhistsByTimePointIndex(){return this._hhistsByTimePointIndex}clear(){this._indexes=[];for(const e of d.regularPrimitiveNames)this._primitivesCollection[e].forEach((e=>e.clear()));for(const e of d.groupedPrimitiveNames)this._primitivesCollection[e].forEach((e=>{e.forEach((e=>e.clear()))}));this._hhistsByTimePointIndex=new Map}extract(){const e={indexes:this._indexes,horizlines:g(this._primitivesCollection.horizlines),vertlines:g(this._primitivesCollection.vertlines),lines:g(this._primitivesCollection.lines),hlines:g(this._primitivesCollection.hlines),textmarks:g(this._primitivesCollection.textmarks),shapemarks:g(this._primitivesCollection.shapemarks),backgrounds:g(this._primitivesCollection.backgrounds),polygons:g(this._primitivesCollection.polygons),trendchannels:g(this._primitivesCollection.trendchannels),hhists:g(this._primitivesCollection.hhists),dwglabels:f(this._primitivesCollection.dwglabels),dwglines:f(this._primitivesCollection.dwglines),dwgpolylines:f(this._primitivesCollection.dwgpolylines),dwgboxes:f(this._primitivesCollection.dwgboxes),dwgtables:f(this._primitivesCollection.dwgtables),dwgtablecells:g(this._primitivesCollection.dwgtablecells),dwglinefills:g(this._primitivesCollection.dwglinefills),tpos:g(this._primitivesCollection.tpos),tpoBlockSets:f(this._primitivesCollection.tpoBlockSets),tpoLevels:f(this._primitivesCollection.tpoLevels),tpoVolumeRows:f(this._primitivesCollection.tpoVolumeRows),tpoSummaryInfo:f(this._primitivesCollection.tpoSummaryInfo),logs:new Map,performance:new Map,footprints:g(this._primitivesCollection.footprints),footprintLevels:g(this._primitivesCollection.footprintLevels)};return this._hhistsByTimePointIndex=new Map,new u.StaticStudyGraphics("data",e)}replaceIndexesTo(e){this._indexes=e;const t=e=>e.replaceIndexesTo(this._indexes);for(const e of d.regularPrimitiveNames)this._primitivesCollection[e].forEach(t);for(const e of d.groupedPrimitiveNames)this._primitivesCollection[e].forEach((e=>{e.forEach(t)}));this._hhistsByTimePointIndex=(0,d.splitHHistsByTimePointIndex)(this._primitivesCollection.hhists)}processCommands(e){void 0!==e.erase&&this._processEraseCommands(e.erase),void 0!==e.create&&this._processCreateCommands(e.create)}_processCreateCommands(e){for(const t in e){if(!e.hasOwnProperty(t))continue;const i=t;switch(i){case"hhists":y(this._indexes,this._primitivesCollection.hhists,e[i]);break;case"horizlines":y(this._indexes,this._primitivesCollection.horizlines,e[i]);break;case"vertlines":y(this._indexes,this._primitivesCollection.vertlines,e[i]);break;case"polygons":y(this._indexes,this._primitivesCollection.polygons,e[i]);break;case"backgrounds":y(this._indexes,this._primitivesCollection.backgrounds,e[i])}}
this._hhistsByTimePointIndex=(0,d.splitHHistsByTimePointIndex)(this._primitivesCollection.hhists)}_processEraseCommands(e){for(const t of e)if("all"===t.action){for(const e of d.regularPrimitiveNames)this._primitivesCollection[e].forEach((e=>e.clearPrimitives()));for(const e of d.groupedPrimitiveNames)this._primitivesCollection[e].forEach((e=>{e.forEach((e=>e.clearPrimitives()))}))}else{const e=e=>e.deleteById(t.id);(0,d.isRegularPrimiriveName)(t.type)?this._primitivesCollection[t.type].forEach(e):this._primitivesCollection[t.type].forEach((t=>{t.forEach(e)}))}this._hhistsByTimePointIndex=(0,d.splitHHistsByTimePointIndex)(this._primitivesCollection.hhists)}}class p{constructor(e,t){this._primitivesDataById=new Map,this._primitiveById=new Map,this._changed=new n.Delegate,this._cleared=new n.Delegate,this._materializePrimitive=e,this._isRematerializationRequiredWithNewIndexes=t}changed(){return this._changed}cleared(){return this._cleared}forEach(e,t){this._primitiveById.forEach((i=>{e.call(t,i,i,this)}))}has(e){let t=!1;return this._primitiveById.forEach((i=>{t=t||i===e})),t}get size(){return this._primitiveById.size}[Symbol.iterator](){return this._primitiveById.values()}entries(){throw new Error("Not implemented")}keys(){throw new Error("Not implemented")}union(){throw new Error("Not implemented")}intersection(){throw new Error("Not implemented")}difference(){throw new Error("Not implemented")}symmetricDifference(){throw new Error("Not implemented")}isSubsetOf(){throw new Error("Not implemented")}isSupersetOf(){throw new Error("Not implemented")}isDisjointFrom(){throw new Error("Not implemented")}values(){return this._primitiveById.values()}hasId(e){return this._primitiveById.has(e)}addData(e,t){const i=[];e.forEach((e=>{this._primitivesDataById.set(e.id,e);const s=this._tryMaterialize(t,e);null!==s&&i.push(s)})),i.length>0&&this._changed.fire({created:i,removed:[]})}deleteById(e){const t=this._primitiveById.get(e);t&&(this._primitiveById.delete(e),this._primitivesDataById.delete(e),this._changed.fire({created:[],removed:[t]}))}clear(){this.clearPrimitives()}clearPrimitives(){this._primitivesDataById.clear(),this._primitiveById.clear(),this._cleared.fire()}replaceIndexesTo(e){if(!this._isRematerializationRequiredWithNewIndexes)return;const t=Array.from(this._primitiveById.values());this._primitiveById.clear(),this._primitivesDataById.forEach(this._tryMaterialize.bind(this,e),this);const i=Array.from(this._primitiveById.values());this._changed.fire({created:i,removed:t})}extract(){const e=new Set(this._primitivesDataById.values());return this.clearPrimitives(),e}_tryMaterialize(e,t){const i=this._materializePrimitive(t,e);return null!==i&&((0,s.assert)(!this._primitiveById.has(t.id),"primitive with specified id should not exist"),this._primitiveById.set(t.id,i)),i}}function m(e){const t=new Map;for(const[n,r]of e)t.set(n,(i=r,(s=t.get(n))?(0,o.join)(s,i.extract()):i.extract()));var i,s;return t}function g(e){return m((0,o.mapEntriesGenerator)(e))}function f(e){return m((0,o.nestedMapGenerator)(e))}
function y(e,t,i=[]){for(const o of i){const i=o.styleId,n=t.get(i);(0,s.assert)(void 0!==n,"Every style used by graphics primitive should be declared in study metainfo"),n.addData(o.data,e)}}const v={horizlines:()=>new p(a.materializeHorizLine,a.containsHorizLineTimePointIndexes),vertlines:()=>new p(l.materializeVertLine,l.containsVertLineTimePointIndexes),lines:()=>new p(materializeLine,containsLineTimePointIndexes),hlines:()=>new p(materializeLevel,containsLevelTimePointIndexes),textmarks:()=>new p(materializeTextMark,containsTextMarkTimePointIndexes),shapemarks:()=>new p(materializeShapeMark,containsShapeMarkTimePointIndexes),backgrounds:()=>new p(h.materializeBackground,h.containsBackgroundTimePointIndexes),polygons:()=>new p(c.materializePolygon,c.containsPolygonTimePointIndexes),trendchannels:()=>new p(materializeTrendChannel,containsTrendChannelTimePointIndexes),hhists:()=>new p(r.materializeHHist,r.containsHHistTimePointIndexes),dwglines:()=>new p(materializeDwgLine,containsDwgLineTimePointIndexes),dwglinefills:()=>new p(materializeDwgLineFill,containsDwgLineFillTimePointIndexes),dwglabels:()=>new p(materializeDwgLabel,containsDwgLabelTimePointIndexes),dwgtablecells:()=>new p(materializeDwgTableCell,containsDwgTableCellTimePointIndexes),dwgpolylines:()=>new p(materializeDwgPolyline,containsDwgPolylineTimePointIndexes),dwgboxes:()=>new p(materializeDwgBox,containsDwgBoxTimePointIndexes),dwgtables:()=>new p(materializeDwgTable,containsDwgTableTimePointIndexes),tpos:()=>new p(materializeTpo,containsTpoTimePointIndexes),tpoBlockSets:()=>new p(materializeTpoBlockSet,containsTpoBlockSetTimePointIndexes),tpoLevels:()=>new p(materializeTpoLevelGroup,containsTpoLevelGroupTimePointIndexes),tpoVolumeRows:()=>new p(materializeTpoVolumeRow,containsTpoVolumeRowTimePointIndexes),tpoSummary:()=>new p(materializeTpoSummary,containsTpoSummaryTimePointIndexes),logs:()=>new p(materializeLog,containsLogTimePointIndexes),footprints:()=>new p(materializeVolumeFootprint,containsFootprintTimePointIndexes),footprintLevels:()=>new p(materializeVolumeFootprintPriceLevel,containsFootprintPriceLevelTimePointIndexes)}},30798:(e,t,i)=>{"use strict";i.d(t,{containsPolygonTimePointIndexes:()=>n,dematerializePolygon:()=>a,isPolygonInBarsRange:()=>l,materializePolygon:()=>r});var s=i(82284),o=i(33952);const n=!0;function r(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 a(e,t,i){return{id:t,points:e.points.map((e=>({...e,index:(0,o.ensureTimePointIndexIndex)(i.indexOf(e.index))})))}}function l(e,t){if(e.points.some((e=>t.contains(e.index+(e.offset??0)))))return!0;let i=!1,s=!1;const o=t.firstBar();for(const t of e.points)t.index+(t.offset??0)<o?i=!0:s=!0;return i&&s}},33952:(e,t,i)=>{"use strict";function s(e){if(e<0)throw new Error("TimePointIndexIndex should be non-negative integer");return e}i.d(t,{ensureTimePointIndexIndex:()=>s})},39488:(e,t,i)=>{"use strict";i.d(t,{
StaticStudyGraphics:()=>d,emptyStudyGraphics:()=>g,loadStudyGraphics:()=>f,saveStudyGraphics:()=>y});var s=i(82284),o=i(60661),n=i(58554),r=i(99481),a=i(30798),l=i(69866),c=i(82130),h=i(87465);class d{constructor(e,t){if(this._indexes=[],this._horizlines=new Map,this._vertlines=new Map,this._lines=new Map,this._hlines=new Map,this._textmarks=new Map,this._shapemarks=new Map,this._backgrounds=new Map,this._polygons=new Map,this._trendchannels=new Map,this._hhists=new Map,this._dwglabels=new Map,this._dwglines=new Map,this._dwgpolylines=new Map,this._dwgboxes=new Map,this._dwgtables=new Map,this._dwgtablecells=new Map,this._dwglinefills=new Map,this._tpos=new Map,this._tpoBlockSets=new Map,this._tpoLevelGroups=new Map,this._tpoVolumeRows=new Map,this._tpoSummaryInfo=new Map,this._logs=new Map,this._performance=new Map,this._footprints=new Map,this._footprintLevels=new Map,"data"===e){const e=t;this._indexes=e.indexes,this._vertlines=u(e.vertlines,this._indexes,n.materializeVertLine),this._horizlines=u(e.horizlines,this._indexes,o.materializeHorizLine),this._polygons=u(e.polygons,this._indexes,a.materializePolygon),this._hhists=u(e.hhists,this._indexes,r.materializeHHist),this._backgrounds=u(e.backgrounds,this._indexes,l.materializeBackground)}else if("state"===e){const e=t;this._indexes=e.indexes||[],this._vertlines=_(e.vertlines,this._indexes,n.materializeVertLine),this._horizlines=_(e.horizlines,this._indexes,o.materializeHorizLine),this._polygons=_(e.polygons,this._indexes,a.materializePolygon),this._hhists=_(e.hhists,this._indexes,r.materializeHHist),this._backgrounds=_(e.backgrounds,this._indexes,l.materializeBackground)}this._hhistsByTimePointIndex=(0,c.splitHHistsByTimePointIndex)(this._hhists)}horizlines(){return this._horizlines}vertlines(){return this._vertlines}lines(){return this._lines}hlines(){return this._hlines}textmarks(){return this._textmarks}shapemarks(){return this._shapemarks}backgrounds(){return this._backgrounds}polygons(){return this._polygons}trendchannels(){return this._trendchannels}hhists(){return this._hhists}dwglabels(){return this._dwglabels}dwglines(){return this._dwglines}dwgpolylines(){return this._dwgpolylines}dwgboxes(){return this._dwgboxes}dwgtables(){return this._dwgtables}dwgtablecells(){return this._dwgtablecells}dwglinefills(){return this._dwglinefills}tpos(){return this._tpos}tpoBlockSets(){return this._tpoBlockSets}tpoLevels(e){return this._tpoLevelGroups}tpoVolumeRows(e){return this._tpoVolumeRows}tpoSummaryInfo(e){return this._tpoSummaryInfo}logs(){return this._logs}performance(){return this._performance}footprints(){return this._footprints}footprintLevels(){return this._footprintLevels}hhistsByTimePointIndex(){return this._hhistsByTimePointIndex}}function u(e,t,i){return new Map(Array.from(e.entries()).map((e=>[e[0],new Set(Array.from(e[1]).map((e=>i(e,t))).filter(h.notNull))])))}function _(e,t,i){const s=new Map;if(void 0===e)return s;for(const o of e){const e=o.styleId,n=s.get(e)||new Set;o.data.forEach((e=>{const s=i(e,t);null!==s&&n.add(s)})),s.set(e,n)}return s}
function p(e,t,i){let s=null;for(const i of e)i.styleId===t&&(s=i);null===s&&(s={styleId:t,data:[]},e.push(s)),s.data.push(i)}function m(e,t,i,s,o,n){const r=[];return e.forEach(((e,a)=>{e.forEach((e=>{(null===o||s(e,o))&&p(r,a,n(e,t(e),i))}))})),r.length>0?r:void 0}function g(){return new d}function f(e){return new d("state",e)}function y(e,t){const i=function(e){const t=new Set,i=e=>{null!=e&&t.add(e)};e.horizlines().forEach(((e,i)=>{e.forEach((e=>{t.add(e.startIndex??s.INVALID_TIME_POINT_INDEX),t.add(e.endIndex)}))})),e.vertlines().forEach(((e,i)=>{e.forEach((e=>{t.add(e.index)}))})),e.lines().forEach(((e,i)=>{e.forEach((e=>{t.add(e.startIndex),t.add(e.endIndex)}))})),e.textmarks().forEach(((e,i)=>{e.forEach((e=>{t.add(e.time)}))})),e.shapemarks().forEach(((e,i)=>{e.forEach((e=>{t.add(e.time)}))})),e.backgrounds().forEach(((e,i)=>{e.forEach((e=>{t.add(null!==e.start?e.start:s.INVALID_TIME_POINT_INDEX),t.add(e.stop)}))})),e.polygons().forEach(((e,i)=>{e.forEach((e=>{e.points.forEach((e=>{t.add(e.index)}))}))})),e.trendchannels().forEach(((e,i)=>{e.forEach((e=>{t.add(e.startIndex),t.add(e.endIndex)}))})),e.hhists().forEach(((e,i)=>{e.forEach((e=>{t.add(e.firstBarTime??s.INVALID_TIME_POINT_INDEX),t.add(e.lastBarTime)}))})),e.dwglabels().forEach((e=>{e.forEach((e=>{e.forEach((e=>{t.add(e.x)}))}))})),e.dwglines().forEach((e=>{e.forEach((e=>{e.forEach((e=>{t.add(e.x1??s.INVALID_TIME_POINT_INDEX),t.add(e.x2??s.INVALID_TIME_POINT_INDEX)}))}))})),e.dwgpolylines().forEach((e=>{e.forEach((e=>{e.forEach((e=>{for(const i of e.points)t.add(i.x??s.INVALID_TIME_POINT_INDEX)}))}))})),e.dwgboxes().forEach((e=>{e.forEach((e=>{e.forEach((e=>{t.add(e.left??s.INVALID_TIME_POINT_INDEX),t.add(e.right??s.INVALID_TIME_POINT_INDEX)}))}))})),e.tpos().forEach((e=>{e.forEach((e=>{t.add(e.firstBarTime),t.add(e.lastBarTime)}))})),e.tpoLevels().forEach((e=>{e.forEach((e=>{e.forEach((e=>{i(e.poorHighExtendTo),i(e.poorLowExtendTo),i(e.tpoPocExtendTo),(e.singleprints??[]).map((e=>e.extendTo)).map(i)}))}))})),e.footprints().forEach((e=>{e.forEach((e=>{t.add(e.index)}))})),e.footprintLevels().forEach((e=>{e.forEach((e=>{t.add(e.startIndex),i(e.extendTo)}))}));const o=Array.from(t);return o.sort(((e,t)=>e-t)),o}(e),c={indexes:i};let h=0;const d=()=>++h;return c.vertlines=m(e.vertlines(),d,i,n.isVertLineInBarsRange,t,n.dematerializeVertLine),c.horizlines=m(e.horizlines(),d,i,o.isHorizLineInBarsRange,t,o.dematerializeHorizLine),c.polygons=m(e.polygons(),d,i,a.isPolygonInBarsRange,t,a.dematerializePolygon),c.hhists=m(e.hhists(),d,i,r.isHHistInBarsRange,t,r.dematerializeHHist),c.backgrounds=m(e.backgrounds(),d,i,l.isBackgroundInBarsRange,t,l.dematerializeBackground),c}},18330:(e,t,i)=>{"use strict";var s,o,n,r;i.d(t,{HAlign:()=>o,LineStyle:()=>r,MarkLocation:()=>s}),function(e){e.AboveBar="AboveBar",e.BelowBar="BelowBar",e.Top="Top",e.Bottom="Bottom",e.Right="Right",e.Left="Left",e.Absolute="Absolute",e.AbsoluteUp="AbsoluteUp",e.AbsoluteDown="AbsoluteDown"}(s||(s={})),function(e){e.Left="left",e.Center="center",e.Right="right"}(o||(o={})),function(e){
e.Top="top",e.Middle="middle",e.Bottom="bottom"}(n||(n={})),function(e){e[e.Solid=0]="Solid",e[e.Dotted=1]="Dotted",e[e.Dashed=2]="Dashed"}(r||(r={}))},82130:(e,t,i)=>{"use strict";i.d(t,{groupedPrimitiveNames:()=>n,hasForceOverlayPrimitives:()=>d,isRegularPrimiriveName:()=>a,isStudyGraphicsEmpty:()=>c,primitiveNames:()=>r,primitivesZOrders:()=>l,regularPrimitiveNames:()=>o,splitHHistsByTimePointIndex:()=>h});const s=["dwglines","dwgboxes","dwglabels","dwgpolylines","dwgtables"];const o=["horizlines","vertlines","lines","hlines","textmarks","shapemarks","backgrounds","polygons","trendchannels","hhists","dwgtablecells","dwglinefills","tpos","logs","performance","footprints","footprintLevels"],n=s.concat(["tpoBlockSets","tpoLevels","tpoVolumeRows","tpoSummaryInfo"]),r=o.concat(n);function a(e){return o.includes(e)}const l=new Map([["logs",-4],["performance",-4],["polygons",-4],["trendchannels",-3],["textmarks",-2],["shapemarks",-2],["backgrounds",-1],["footprints",1],["footprintLevels",1],["hlines",1],["horizlines",1],["hhists",1],["dwglinefills",2],["vertlines",3],["lines",3],["dwglines",3],["dwgpolylines",3],["dwgboxes",4],["dwglabels",5],["dwgtables",6],["dwgtablecells",6],["tpos",7],["tpoBlockSets",7],["tpoLevels",7],["tpoVolumeRows",7],["tpoSummaryInfo",1]]);function c(e){return!r.some((t=>{const i=e[t]();for(const[,e]of i)if(e.size>0)return!0;return!1}))}function h(e){const t=new Map;return e.forEach(((e,i)=>{e.forEach((e=>{const s={...e,styleId:i},o=e.firstBarTime;let n=t.get(o);void 0===n&&(n=new Set,t.set(o,n)),n.add(s)}))})),t}function d(e){return!!(e.graphics.dwglines||e.graphics.dwgboxes||e.graphics.dwglabels||e.graphics.dwgpolylines||e.graphics.dwgtables)}},58554:(e,t,i)=>{"use strict";i.d(t,{containsVertLineTimePointIndexes:()=>n,dematerializeVertLine:()=>a,isVertLineInBarsRange:()=>l,materializeVertLine:()=>r});var s=i(82284),o=i(33952);const n=!0;function r(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 a(e,t,i){const s=(0,o.ensureTimePointIndexIndex)(i.indexOf(e.index));return{id:t,...e,index:s}}function l(e,t){return t.contains(e.index)}},40080:(e,t,i)=>{"use strict";var s,o,n;!function(e){e.BuyAndSell="Buy and sell",e.Delta="Delta",e.Total="Total",e.Ladder="Ladder"}(s||(s={})),function(e){e[e.Cluster=0]="Cluster",e[e.Profile=1]="Profile"}(o||(o={})),function(e){e[e.InfoBox=0]="InfoBox",e[e.Table=1]="Table"}(n||(n={}))},63681:(e,t,i)=>{"use strict";var s;i.d(t,{StudyStatusType:()=>s}),function(e){e[e.Undefined=0]="Undefined",e[e.Loading=1]="Loading",e[e.Completed=2]="Completed",e[e.Error=3]="Error"}(s||(s={}))},87163:(e,t,i)=>{"use strict";i.d(t,{makeNextStudyId:()=>r,makeNextSymbolId:()=>o});let s=0;function o(){return s++,"ss_"+s}let n=0;function r(){return n++,"st"+n}},43046:(e,t,i)=>{"use strict";i.d(t,{migrateMetaInfoAndPropState:()=>p});var s=i(50151),o=i(19844),n=i(87465)
;const r=["Moving Average@tv-basicstudies","Moving Average Exponential@tv-basicstudies"];class a{targetMetaInfoVersion(){return 53}migrateMetaInfo(e){const t=e;e._metainfoVersion=53,r.includes(t.id)}migratePropState(e){r.includes(e.id)&&(e.inputs.length=e.inputs.length??e.inputs.in_0,e.inputs.source=e.inputs.source??e.inputs.in_1,e.inputs.offset=e.inputs.offset??e.inputs.in_2,delete e.inputs.in_0,delete e.inputs.in_1,delete e.inputs.in_2,e.plots[1]={id:"smoothedMA",type:"line"},e.styles.smoothedMA={display:0,linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#0496ff",histogramBase:0,joinPoints:!1,title:"Smoothed MA"})}}const l=["Volume@tv-basicstudies"];class c{targetMetaInfoVersion(){return 53}migrateMetaInfo(e){const t=e;e._metainfoVersion=53,l.includes(t.id)}migratePropState(e){l.includes(e.id)&&(e.inputs.maLength=e.inputs.length??e.inputs.maLength,delete e.inputs.length,delete e.inputs.offset,delete e.inputs.source,e.plots[1]={id:"smoothedMA",type:"line"},e.styles.smoothedMA={display:0,linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#0496ff",histogramBase:0,joinPoints:!1,title:"Smoothed MA"})}}const h=["Relative Strength Index@tv-basicstudies","Commodity Channel Index@tv-basicstudies","On Balance Volume@tv-basicstudies"];class d{targetMetaInfoVersion(){return 53}migrateMetaInfo(e){const t=e,i=e;i._metainfoVersion=53,h.includes(t.id)&&(i.styles[t.id]={title:"Smoothed MA",histogramBase:0,joinPoints:!1})}migratePropState(e){h.includes(e.id)&&(e.plots[1]={id:"smoothedMA",type:"line"},e.styles.smoothedMA={display:0,linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,color:"#0496ff"})}}var u;!function(e){e[e.InMetaInfoVersion=52]="InMetaInfoVersion",e[e.OutMetaInfoVersion=53]="OutMetaInfoVersion"}(u||(u={}));const _=[new class{targetMetaInfoVersion(){return 47}migrateMetaInfo(e){const t=e,i=e;if(i._metainfoVersion=47,!t.defaults||void 0===t.defaults.precision)return void(i.format={type:"inherit"});const s=t.defaults&&t.defaults.precision,o=(0,n.isNumber)(s)?s:parseInt(s);0===o?i.format={type:"volume"}:isFinite(o)?i.format={type:"price",precision:o}:i.format={type:"inherit"},delete t.defaults.precision}migratePropState(e){}},new class{targetMetaInfoVersion(){return 50}migrateMetaInfo(e){const t=e,i=e;if(i._metainfoVersion=50,void 0===t.defaults||void 0===t.defaults.ohlcPlots||void 0===t.ohlcPlots)return;const o=t.ohlcPlots,n=t.defaults.ohlcPlots,r=(0,s.ensureDefined)((0,s.ensureDefined)(i.defaults).ohlcPlots);for(const e of Object.keys(n)){const t=n[e];if("ohlc_candles"===t.plottype){let i=!1;const s=o[e];void 0!==s&&(i=!!s.drawBorder,delete s.drawBorder),r[e]={borderColor:"#000000",drawBorder:i,...t}}}}migratePropState(e){}},new class{targetMetaInfoVersion(){return 53}migrateMetaInfo(e){const t=e,i=e;if(i._metainfoVersion=53,void 0!==t.defaults){if(void 0!==t.defaults.ohlcPlots&&void 0!==t.ohlcPlots){const e=Object.keys(t.ohlcPlots),o=t.defaults.ohlcPlots,n=(0,s.ensureDefined)((0,s.ensureDefined)(i.defaults).ohlcPlots);for(const t of e){const e=o[t]
;if(void 0===e||void 0===e.visible)continue;const i=e.visible?15:0;delete e.visible,n[t]={display:i,...e}}}if(void 0!==t.defaults.styles&&void 0!==t.plots){const e=t.plots.map((e=>e.id)),o=t.defaults.styles,n=(0,s.ensureDefined)((0,s.ensureDefined)(i.defaults).styles);for(const t of e){const e=o[t];if(void 0===e||void 0===e.visible)continue;const i=e.visible?15:0;delete e.visible,n[t]={display:i,...e}}}}}migratePropState(e){if(e.ohlcPlots)for(const t of Object.keys(e.ohlcPlots)){const i=(0,s.ensureDefined)(e.ohlcPlots[t]);void 0!==i.visible&&(i.display=i.visible?15:0,delete i.visible)}if(e.styles)for(const t of Object.keys(e.styles)){const i=(0,s.ensureDefined)(e.styles[t]);void 0!==i.visible&&(i.display=i.visible?15:0,delete i.visible)}}}];function p(e,t){const i=o.StudyMetaInfo.versionOf(e),n=e;void 0===n._serverMetaInfoVersion&&(n._serverMetaInfoVersion=i);const r=["PennantCP@tv-basicstudies","WedgeCP@tv-basicstudies"].includes(e.id);_.forEach((o=>{(i<0||i>=o.targetMetaInfoVersion())&&!r||(o.migrateMetaInfo(e),void 0!==t&&o.migratePropState(t),(0,s.assert)(e._metainfoVersion===o.targetMetaInfoVersion()))}))}_.push(new a),_.push(new c),_.push(new d),_.sort((function(e,t){return e.targetMetaInfoVersion()-t.targetMetaInfoVersion()}))},93387:(e,t,i)=>{"use strict";i.d(t,{PaneRendererColumns:()=>n});var s=i(10307),o=i(2383);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){if(null===this._data)return null;const t=this._data.visibleItemsRange?.startItemIndex??0,i=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1;for(let s=t;s<=i;s++){const t=this._data.items[s];if(e.x>=t.left&&e.x<=t.right){const i=t.y;if(e.y>=Math.min(i,this._data.histogramBase)&&e.y<=Math.max(i,this._data.histogramBase))return new o.HitTestResult(o.HitTarget.Regular)}}return null}_drawImpl(e){if(null===this._data||0===this._data.items.length)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;this._precalculatedCache.length||this._fillPrecalculatedCache(i);const o=Math.max(1,Math.floor(i)),n=Math.max(1,Math.floor(s)),r=Math.round(this._data.histogramBase*s)-Math.floor(o/2),a=r+o,l=this._data.lineColor,c=this._data.visibleItemsRange?.startItemIndex??0,h=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1;for(let e=c;e<=h;e++){const i=this._data.items[e],o=this._precalculatedCache[e-c],h=Math.round(i.y*s);let d,u;t.fillStyle=i.style?i.style.color:l,h<=r?(d=h,u=a):(d=r,u=h-Math.floor(n/2)+n),t.fillRect(o.left,d,o.right-o.left+1,u-d)}}_fillPrecalculatedCache(e){if(null===this._data||0===this._data.items.length)return void(this._precalculatedCache=[]);const{barSpacing:t,visibleItemsRange:i,items:s}=this._data,o=Math.ceil(t*e)<=1?0:Math.max(1,Math.floor(e)),n=i?.startItemIndex??0,r=(i?.endItemIndex??s.length)-1,a=r-n+1;if(a<=0)return void(this._precalculatedCache=[]);this._precalculatedCache=new Array(a);for(let t=n;t<=r;t++){
const i=s[t],r=Math.round(i.center*e);let a,l;const c=Math.round((i.right-i.left)*e)-o;if(c%2){const e=(c-1)/2;a=r-e,l=r+e}else{const e=c/2;a=r-e,l=r+e-1}this._precalculatedCache[t-n]={left:a,right:l,roundedCenter:r,center:i.center*e,time:i.timePointIndex}}for(let e=n+1;e<=r;e++){const t=this._precalculatedCache[e-n],i=this._precalculatedCache[e-n-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 l=Math.ceil(t*e);for(let e=n+1;e<=r;e++){const t=this._precalculatedCache[e-n];t.right<t.left&&(t.right=t.left);const i=t.right-t.left+1;l=Math.min(i,l)}if(o>0&&l<4)for(let e=n+1;e<=r;e++){const t=this._precalculatedCache[e-n];t.right-t.left+1>l&&(t.roundedCenter>t.center?t.right-=1:t.left+=1)}}}},4359:(e,t,i)=>{"use strict";var s,o,n,r,a,l,c;function h(e){return"line"===e.type}function d(e){return"shapes"===e.type}function u(e){return"chars"===e.type}function _(e){return"arrows"===e.type}function p(e){return"data"===e.type}function m(e){return"dataoffset"===e.type}function g(e){return"ohlc_open"===e.type}function f(e){return"ohlc_high"===e.type}function y(e){return"ohlc_low"===e.type}function v(e){return"ohlc_close"===e.type}function S(e){return g(e)||f(e)||y(e)||v(e)}function b(e){return"colorer"===e.type&&"palette"in e}function w(e){return"colorer"===e.type&&!("palette"in e)}function C(e){return"colorer"===e.type}function T(e){return"bar_colorer"===e.type}function P(e){return"bg_colorer"===e.type}function x(e){return"text_colorer"===e.type}function M(e){return"ohlc_colorer"===e.type}function I(e){return"wick_colorer"===e.type}function A(e){return"border_colorer"===e.type}function L(e){return"up_colorer"===e.type}function k(e){return"down_colorer"===e.type}function E(e){return"alertcondition"===e.type}function D(e){return h(e)||d(e)||u(e)||_(e)}function B(e){return"Plot"!==e}function V(e){return"ohlc_bars"===e.plottype}function R(e){return"ohlc_candles"===e.plottype}function N(e){return C(e)||T(e)||P(e)||p(e)||m(e)||M(e)||E(e)||L(e)||k(e)||A(e)||I(e)||x(e)}function O(e){return C(e)||x(e)||T(e)||p(e)||m(e)||M(e)||I(e)||A(e)||L(e)||k(e)||E(e)}function F(e){return[s.Line,s.LineWithBreaks,s.StepLine,s.StepLineWithBreaks,s.StepLineWithDiamonds,s.Area,s.AreaWithBreaks].includes(e)}i.r(t),i.d(t,{InternalStudyPlotType:()=>n,LineStudyPlotStyle:()=>s,OhlcStudyPlotStyle:()=>l,PlotSymbolSize:()=>c,STUDYPLOTDISPLAYTARGET:()=>a,StudyPlotDisplayTarget:()=>r,StudyPlotType:()=>o,doesLinePlotStyleSupportLineStyle:()=>F,isAlertConditionPlot:()=>E,isArrowsPlot:()=>_,isBarColorerPlot:()=>T,isBgColorerPlot:()=>P,isCandleBorderColorerPlot:()=>A,isCandleWickColorerPlot:()=>I,isCharsPlot:()=>u,isColorerPlot:()=>C,isDataOffsetPlot:()=>m,isDataPlot:()=>p,isDownColorerPlot:()=>k,isLinePlot:()=>h,isNonVisualPlot:()=>O,isOhlcClosePlot:()=>v,isOhlcColorerPlot:()=>M,isOhlcHighPlot:()=>f,isOhlcLowPlot:()=>y,isOhlcOpenPlot:()=>g,isOhlcPlot:()=>S,isOhlcPlotStyleBars:()=>V,isOhlcPlotStyleCandles:()=>R,isPaletteColorerPlot:()=>b,isPlotSupportDisplay:()=>D,isPlotTitleDefined:()=>B,
isPlotWithTechnicalValues:()=>N,isRgbaColorerPlot:()=>w,isShapesPlot:()=>d,isTextColorerPlot:()=>x,isUpColorerPlot:()=>L}),function(e){e[e.Line=0]="Line",e[e.Histogram=1]="Histogram",e[e.Cross=3]="Cross",e[e.Area=4]="Area",e[e.Columns=5]="Columns",e[e.Circles=6]="Circles",e[e.LineWithBreaks=7]="LineWithBreaks",e[e.AreaWithBreaks=8]="AreaWithBreaks",e[e.StepLine=9]="StepLine",e[e.StepLineWithDiamonds=10]="StepLineWithDiamonds",e[e.StepLineWithBreaks=11]="StepLineWithBreaks"}(s||(s={})),function(e){e.Line="line",e.Colorer="colorer",e.BarColorer="bar_colorer",e.BgColorer="bg_colorer",e.TextColorer="text_colorer",e.OhlcColorer="ohlc_colorer",e.CandleWickColorer="wick_colorer",e.CandleBorderColorer="border_colorer",e.UpColorer="up_colorer",e.DownColorer="down_colorer",e.Shapes="shapes",e.Chars="chars",e.Arrows="arrows",e.Data="data",e.DataOffset="dataoffset",e.OhlcOpen="ohlc_open",e.OhlcHigh="ohlc_high",e.OhlcLow="ohlc_low",e.OhlcClose="ohlc_close"}(o||(o={})),function(e){e.AlertCondition="alertcondition"}(n||(n={})),function(e){e[e.None=0]="None",e[e.Pane=1]="Pane",e[e.DataWindow=2]="DataWindow",e[e.PriceScale=4]="PriceScale",e[e.StatusLine=8]="StatusLine",e[e.All=15]="All"}(r||(r={})),function(e){e[e.None=0]="None",e[e.Pane=1]="Pane",e[e.DataWindow=2]="DataWindow",e[e.PriceScale=4]="PriceScale",e[e.StatusLine=8]="StatusLine",e[e.All=15]="All"}(a||(a={})),function(e){e.OhlcBars="ohlc_bars",e.OhlcCandles="ohlc_candles"}(l||(l={})),function(e){e.Auto="auto",e.Tiny="tiny",e.Small="small",e.Normal="normal",e.Large="large",e.Huge="huge"}(c||(c={}))},62312:(e,t,i)=>{"use strict";function s(e,t="shift",i){return{studyConstructorAsyncGetter:e,colorRotationMode:t,colorRotationComparator:i}}i.d(t,{addStudyInfoToMap:()=>n,createStudyInfo:()=>s,getStudyClassName:()=>a,getStudyInfoByName:()=>r});const o=new Map;function n(e,t){o.set(e,t)}function r(e){return o.get(e)}function a(e){for(const[t,i]of o.entries())if(i.studyConstructor===e)return t;return null}},2088:(e,t,i)=>{"use strict";i.d(t,{createStudy:()=>w,hasConfirmInputs:()=>x,hasPendingStudiesModuleLoading:()=>b,isCompareOrOverlayStudy:()=>v,isESDStudy:()=>f,isFundamentalStudy:()=>g,isOverlayStudy:()=>y,isStudy:()=>_,isStudyStrategy:()=>p,isStudyStub:()=>m,isSymbolicStudy:()=>I,studyColorRotationMode:()=>C,useSameColorRotationComparator:()=>P});var s=i(88987),o=i(50151),n=i(37103),r=i(19844),a=i(2258);const l="study_Internal$STD;Fund_";function c(e){const t="study_"+(e.classId||e.shortId);return t.startsWith(l)?l:t}var h=i(62312);i(72207);const d=(0,h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,11485)).then((e=>e.Study))));(0,h.addStudyInfoToMap)("Study",d),(0,h.addStudyInfoToMap)("study_PivotPointsStandard",(0,h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,96664)).then((e=>e.study_PivotPointsStandard))))),(0,h.addStudyInfoToMap)("study_Overlay",(0,
h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,34771)).then((e=>e.study_Overlay))),"sexyColors")),(0,h.addStudyInfoToMap)("study_Compare",(0,h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,55456)).then((e=>e.StudyCompare))),"sexyColors")),(0,h.addStudyInfoToMap)("study_Volume",(0,h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,51106)).then((e=>e.VolumeStudy))))),(0,h.addStudyInfoToMap)("study_VbPVisible",(0,h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,10635)).then((e=>e.VbPVisibleWrapper))),"noRotations")),(0,h.addStudyInfoToMap)("study_VbPFixed",(0,h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,10635)).then((e=>e.VolumeProfileStudyWithThemedColors))),"noRotations")),(0,h.addStudyInfoToMap)("study_ScriptWithDataOffset",(0,h.createStudyInfo)((()=>Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,75848)).then((e=>e.study_ScriptWithDataOffset))))),n.enabled("moving_average_study_changable_currency_unit")&&(0,h.addStudyInfoToMap)("study_Moving Average",(0,h.createStudyInfo)((()=>Promise.all([i.e(7598),i.e(6025),i.e(9378),i.e(1485),i.e(5248)]).then(i.bind(i,45135)).then((e=>e.study_MovingAverage)))));const u=["studyName","guiPlotName","isLinkedToSeries"];function _(e){return u.every((t=>t in e))}function p(e){return!1}function m(e){return e instanceof a.StudyStub}function g(e){return!1}function f(e){return!1}function y(e){return _(e)&&"Overlay@tv-basicstudies"===e.metaInfo().id}function v(e){return y(e)||_(e)&&"Compare@tv-basicstudies"===e.metaInfo().id}let S=0;function b(){return S>0}async function w(e,t,i,s,n,r,a,l){let u;const _=2===a;if(!u){const e=c(s);u=(0,h.getStudyInfoByName)(e??"Study")??d}u.studyConstructor||(S+=1,u.studyConstructor=await(0,o.ensureDefined)(u.studyConstructorAsyncGetter)(),S-=1);const p=new((0,o.ensureDefined)(u?.studyConstructor))(e,t,i,s,n,_,!!l);return void 0!==r&&p.setId(r),p}function C(e){const t=c(e),i=(0,h.getStudyInfoByName)(t);return i?(0,s.default)(i.colorRotationMode)?i.colorRotationMode(e):i.colorRotationMode:void 0===e.pine||r.StudyMetaInfo.isStandardPine(e.id)?1!==e.plots.length?"shift":"loop":null}function T(e,t){return e.id===t.id&&(s=t,((i=e).pine?i.pine.version:void 0)===(s.pine?s.pine.version:void 0));var i,s}function P(e){const t=c(e),i=(0,h.getStudyInfoByName)(t);if(i){const e=i.colorRotationComparator;if(void 0!==e)return e}return T}function x(e){return(e??[]).some((e=>e.confirm))}const M=["Overlay@tv-basicstudies","CorrelationCoefficient@tv-basicstudies","Correlation Coeff@tv-basicstudies","Spread@tv-basicstudies","Ratio@tv-basicstudies"];function I(e){return M.includes(e.id)}},19136:(e,t,i)=>{"use strict";i.d(t,{StudyDataSource:()=>p})
;var s=i(50151),o=i(48096),n=i(72187),r=i(29806),a=i(19844),l=i(87163),c=i(64717),h=i(24437),d=i(63681);const u=(0,i(9343).getLogger)("Chart.StudyDataSource");var _;!function(e){e[e.Idle=0]="Idle",e[e.AwaitingConnection=1]="AwaitingConnection",e[e.AwaitingParent=2]="AwaitingParent",e[e.AwaitingFirstDataUpdate=3]="AwaitingFirstDataUpdate",e[e.Active=4]="Active"}(_||(_={}));class p{constructor(e,t,i,s,r=!1){this._inputs=null,this._status=_.Idle,this._studyId=null,this._turnaroundCounter=1,this._studyStatus={type:d.StudyStatusType.Undefined},this._studyStatusChanged=new o.Delegate,this._dataCleared=new o.Delegate,this._dataUpdated=new o.Delegate,this._boundOnGatewayIsConnectedChanged=this._onGatewayIsConnectedChanged.bind(this),this._ongoingDataUpdate=Promise.resolve(),this._gateway=e,this._metaInfo=s,this._forceUseExclamationMark=r,this._seriesSource=t,this._turnaroundPrefix=i,this._plots=new n.PlotList((0,c.studyPlotFunctionMap)(s),c.studyEmptyPlotValuePredicate),this._gateway.isConnected().subscribe(this._boundOnGatewayIsConnectedChanged),this._graphics=new h.LiveStudyGraphics(s.graphics)}destroy(){this.stop(),this._gateway.isConnected().unsubscribe(this._boundOnGatewayIsConnectedChanged),this._seriesSource.dataEvents().created().unsubscribeAll(this)}metaInfo(){return this._metaInfo}inputs(){return this._inputs}setInputs(e){this._inputs=e,null!==this._studyId&&(this._turnaroundCounter++,this._onStudyStatusChangedTo({type:d.StudyStatusType.Undefined}),this._gateway.modifyStudy(this._studyId,this._turnaround(),e,this._onMessage.bind(this)),this._status===_.Active&&this._changeStatusTo(_.AwaitingFirstDataUpdate))}isStarted(){return this._status!==_.Idle}isActive(){return this._status===_.Active}start(){this.isStarted()?u.logNormal("start: data source is already started, nothing to do"):((0,s.assert)(null!==this._inputs,"Inputs should be defined when starting a study data source"),this._gateway.isConnected().value()?this._createStudy():this._changeStatusTo(_.AwaitingConnection))}stop(){this.isStarted()?(null!==this._studyId&&(this._gateway.isConnected().value()&&this._gateway.removeStudy(this._studyId),this._studyId=null,this._onStudyStatusChangedTo({type:d.StudyStatusType.Undefined})),this._changeStatusTo(_.Idle)):u.logNormal("stop: data source is already stopped, nothing to do")}studyId(){return this._studyId}studyStatus(){return this._studyStatus}studyStatusChanged(){return this._studyStatusChanged}plots(){return this._plots}graphics(){return this._graphics}clearData(){this._plots.clear(),this._graphics.clear(),this._dataCleared.fire()}stopAndStealData(){(0,s.assert)(this._status===_.Active,"Couldn't steal data from non-active data source"),this.stop();const e=this._plots,t=this._graphics.extract();return this._plots=new n.PlotList((0,c.studyPlotFunctionMap)(this._metaInfo),c.studyEmptyPlotValuePredicate),{plots:e,graphics:t}}dataCleared(){return this._dataCleared}dataUpdated(){return this._dataUpdated}moveData(e){this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>{this._plots.move(e)}))}pendingUpdatesReady(){
return this._ongoingDataUpdate}_createStudyError(e){return{type:d.StudyStatusType.Error,errorDescription:this._getStudyErrorDescription(e)}}_getStudyErrorDescription(e){return"string"==typeof e?{error:e.split(":",2)[0]}:e}_changeStatusTo(e){(0,s.assert)(this._status!==e,"Source and destination status should be distinct"),u.logNormal(`Status changed from ${_[this._status]} to ${_[e]}`),this._status=e}_createStudy(){const e=this._seriesSource.instanceId();null!==e?this._createStudyUsingParentId(e):(this._changeStatusTo(_.AwaitingParent),this._seriesSource.dataEvents().created().subscribe(this,this._onSeriesCreated,!0))}_createStudyUsingParentId(e){(0,s.assert)(this._status!==_.Active,'Status should not be "Active" when creating a study'),(0,s.assert)(this._studyStatus.type===d.StudyStatusType.Undefined,'Study status should be "Undefined" when creating a study'),(0,s.assert)(null===this._studyId,"Study id should be empty when creating a study"),this._studyId=(0,l.makeNextStudyId)(),this._gateway.createStudy(this._studyId,this._turnaround(),e,a.StudyMetaInfo.getStudyIdWithLatestVersion(this.metaInfo(),this._forceUseExclamationMark),(0,s.ensureNotNull)(this._inputs),this._onMessage.bind(this),{id:this._metaInfo.id}),this._changeStatusTo(_.AwaitingFirstDataUpdate)}_onGatewayIsConnectedChanged(e){e?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===_.AwaitingConnection&&this._createStudy()}_onGatewayDisconnected(){this._status!==_.Idle&&this._status!==_.AwaitingConnection&&(this._studyId=null,this._changeStatusTo(_.AwaitingConnection),this._studyStatus.type!==d.StudyStatusType.Undefined&&this._onStudyStatusChangedTo({type:d.StudyStatusType.Undefined})),this._turnaroundCounter=1}_onSeriesCreated(){this._status===_.AwaitingParent&&this._createStudyUsingParentId((0,s.ensure)(this._seriesSource.instanceId()))}_onStudyStatusChangedTo(e){const t=this._studyStatus;this._studyStatus=e,u.logNormal(`Study status type changed from ${d.StudyStatusType[t.type]} to ${d.StudyStatusType[e.type]}`),this._studyStatusChanged.fire(t,e)}_onMessage(e){if("data_update"===e.method){const{customId:t,turnaround:i,plots:o,nonseries:n}=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onDataUpdate(o,(0,s.ensureDefined)(n))}else if("study_loading"===e.method){const[t,i]=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onStudyLoading(e.time)}else if("study_completed"===e.method){const[t,i]=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onStudyCompleted(e.time)}else if("study_error"===e.method){const[t,i,s,o]=e.params;t===this._studyId&&this._checkTurnaround(i)&&this._onStudyError(s,o,e.time)}else"clear_data"===e.method&&this._checkTurnaround(e.params.turnaround)&&this.clearData()}_onDataUpdate(e,t){const i=(0,r.unpackNonSeriesData)(t.d);return this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>i),(()=>i)).then(this._onDataUnpacked.bind(this,e,t.indexes)),this._ongoingDataUpdate}_onDataUnpacked(e,t,i){
this._status!==_.Idle&&(this._status===_.AwaitingFirstDataUpdate&&(this._changeStatusTo(_.Active),this.clearData()),this._mergePlots(e),null!==i&&(i.indexes_replace?((0,s.assert)("nochange"!==t),this._graphics.replaceIndexesTo(t)):("nochange"!==t&&this._graphics.replaceIndexesTo(t),void 0!==i.graphicsCmds&&this._graphics.processCommands(i.graphicsCmds))),this._dataUpdated.fire(e,i,t))}_onStudyLoading(e){this._onStudyStatusChangedTo({type:d.StudyStatusType.Loading,startTime:Date.now()})}_onStudyError(e,t,i){this.clearData(),this._onStudyStatusChangedTo(this._createStudyError(e))}_onStudyCompleted(e){this._onStudyStatusChangedTo({type:d.StudyStatusType.Completed})}_mergePlots(e){this._plots.merge(e)}_turnaround(){return`${this._turnaroundPrefix}${this._turnaroundCounter}`}_checkTurnaround(e){const t=this._turnaround();return e===t||e===this._seriesSource.turnaround()||e===`${this._seriesSource.turnaround()}_${t}`}}},64717:(e,t,i)=>{"use strict";function s(e){const t=new Map;return e.plots.forEach(((e,i)=>{t.set(e.id,(e=>e[i+1]))})),t}function o(e,t){return null==e[t]}i.d(t,{studyEmptyPlotValuePredicate:()=>o,studyPlotFunctionMap:()=>s})},69422:(e,t,i)=>{"use strict";i.d(t,{ChartColorDependentStudyInputNames:()=>c,InputDisplayFlags:()=>o,RangeDependentStudyInputNames:()=>l,areStudyInputsEqual:()=>_,editableStudyInputs:()=>m,getInputValue:()=>d,isStudyInputDependsOnChart:()=>f,isStudyInputDependsOnChartColors:()=>g,isStudyInputOptionsInfo:()=>u,isTimeOrPriceNotHiddenInput:()=>p});var s,o,n,r,a,l,c,h=i(82433);function d(e){return function(e){return(0,h.default)(e)}(e)?e.v:e}function u(e){return["text","integer","float","price","session","resolution"].includes(e.type)&&e.hasOwnProperty("options")}function _(e,t,i){for(const s of e)if(t[s.id]!==i[s.id])return!1;return!0}function p(e){return("time"===e.type||"price"===e.type)&&!0!==e.isHidden}function m(e){return[]}function g(e){return Object.values(c).map((e=>e)).includes(e.id)}function f(e){return!!g(e)||Object.values(l).map((e=>e)).includes(e.id)}!function(e){e.Integer="integer",e.Float="float",e.Price="price",e.Bool="bool",e.Text="text",e.Symbol="symbol",e.Session="session",e.Source="source",e.Resolution="resolution",e.Time="time",e.BarTime="bar_time",e.Color="color",e.Textarea="text_area"}(s||(s={})),function(e){e[e.None=0]="None",e[e.DataWindow=2]="DataWindow",e[e.StatusLine=8]="StatusLine",e[e.All=15]="All"}(o||(o={})),function(e){e.InitialCapital="initial_capital",e.Currency="currency",e.DefaultQTYValue="default_qty_value",e.DefaultQTYType="default_qty_type",e.Pyramiding="pyramiding",e.ComissionValue="commission_value",e.ComissionType="commission_type",e.BacktestFillLimitsAssumtion="backtest_fill_limits_assumption",e.Slippage="slippage",e.CalcOnOrderFills="calc_on_order_fills",e.CalcOnEveryTick="calc_on_every_tick",e.MarginLong="margin_long",e.MarginShort="margin_short",e.UseBarMagnifier="use_bar_magnifier",e.ProcessOrdersOnClose="process_orders_on_close",e.FillOrdersOnStandardOHLC="fill_orders_on_standard_ohlc"}(n||(n={})),function(e){e.Fixed="fixed",
e.CashPerOrder="cash_per_order",e.PercentOfEquity="percent_of_equity"}(r||(r={})),function(e){e.Percent="percent",e.CashPerContract="cash_per_contract",e.CashPerOrder="cash_per_order"}(a||(a={})),function(e){e.FirstBar="first_visible_bar_time",e.LastBar="last_visible_bar_time",e.Realtime="subscribeRealtime"}(l||(l={})),function(e){e.FgColor="__chart_fgcolor",e.BgColor="__chart_bgcolor"}(c||(c={}))},72972:(e,t,i)=>{"use strict";i.d(t,{isStudyDescriptor:()=>u,studyMetaInfoRepository:()=>g});var s=i(81251),o=i(11542),n=i(50151),r=i(19844),a=i(43046),l=i(9787),c=i(15219),h=i(9343),d=i(88723);(0,h.getLogger)("Chart.Studies.StudyMetaInfoRepository",{color:"#606"});function u(e){return"object"==typeof e&&null!==e&&"type"in e&&("java"===e.type&&"studyId"in e||"pine"===e.type&&"pineId"in e)}class _{constructor(e){this._isReady=!1,this._studyVersioning=null,this._rawStudiesMetaInfo=[],this._rawStudiesMetaInfoDeferredPromise=null,this._javaStudiesMetaInfo=[],this._pineMetaInfoCache=[],this._compileErrors=new WeakMap,this._studiesMigrations=[],this._chartApi=e}async requestMetaInfo(){if(null===this._rawStudiesMetaInfoDeferredPromise){this._rawStudiesMetaInfoDeferredPromise=(0,d.createDeferredPromise)();const e=(await this._chartApi.requestMetadata()).params[1].metainfo.slice();this._processLibraryMetaInfo(e),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);if(null!==t){const e=this._compileErrors.get(t);return e?Promise.reject(e):Promise.resolve(t)}return"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,t){const i=m(this._pineMetaInfoCache,e);return t&&(!Array.isArray(t)||t.length>0)&&(t=Array.isArray(t)?new PineCompileFailErrorImpl({warnings:[],errors:t},e):t,this._compileErrors.set(i,t)),i}async getLatestMetaInfoForPineStudy(e,t){return null}_processMigrations(e){throw new Error("not implemented")}_processSiteMetaInfo(e,t){throw new Error("not implemented")}_processLibraryMetaInfo(e){for(const t of e)p(t),m(this._javaStudiesMetaInfo,t);this._javaStudiesMetaInfo=this._javaStudiesMetaInfo.sort(((e,t)=>{const i=e.description_localized||e.description,s=t.description_localized||t.description;return i>s?1:i<s?-1:0})),r.StudyMetaInfo.overrideDefaults(this._javaStudiesMetaInfo)}_requestFinished(){this._isReady=!0}_findStudyMetaInfo(e){return"java"===e.type?((0,n.assert)(0!==this._javaStudiesMetaInfo.length,"Java studies metainfo should be define here"),
this._javaStudiesMetaInfo.find((t=>t.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){throw new Error("unsupported")}}function p(e){e.description_localized=o.t(e.description,{context:"study"},i(83477))}function m(e,t){const i=new r.StudyMetaInfo(t).state();(0,a.migrateMetaInfoAndPropState)(i);const s=new r.StudyMetaInfo(i);let o=!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?l.Version.parse(t.pine.version):null,r=void 0!==s.pine?l.Version.parse(s.pine.version):null;null===r||null===i||r.isGreaterOrEqual(i)?(t.removeDefaults(),e[n]=s):o=!1}return o&&s.createDefaults(),s}const g=(0,s.default)((()=>new _(window.ChartApiInstance)))},35990:(e,t,i)=>{"use strict";i.d(t,{StudyStatusProviderBase:()=>l});var s=i(52479),o=i(86252),n=i(36313);const r={NONE:"Default"},a=!1;class l extends s.StatusProviderBase{constructor(e){super(),this._source=e}getSplitTitle(){return this._source.titleInParts(n.TitleDisplayTarget.StatusLine,!0,r,void 0,a)}getInputsTitles(){return this._source.inputsInParts(n.TitleDisplayTarget.StatusLine,!0,r,a)}titleTooltip(){const e=this._source.metaInfo();if(null!==e&&e.shortDescription!==e.description)return this._source.titleInParts(n.TitleDisplayTarget.StatusLine,!1,r,!0,a).join(" ")}text(){const e=this._source.title(n.TitleDisplayTarget.StatusLine,!0,r,void 0,a);return this._source.isActualInterval()?this._source.isFailed()?`${e}: ${this.sourceStatusText()}`:`${e} ${this.sourceStatusText()}`:e}sourceStatusText(){return(0,o.convertStudyStatusToString)(this._source.status(),!0)}errorStatus(){if(!this._source.isActualInterval()||this._source.isSymbolInvalid())return null;const e=this._source.status();return e.type===o.StudyStatusType.Error?{showReportItButton:e.errorDescription.showReportItButton,error:this.sourceStatusText(),solutionId:(0,o.studyStatusSolutionId)(e),title:(0,o.studyStatusTitle)(e),studyFeature:(0,o.studyStatusFeature)(e),stackTrace:(0,o.studyErrorStatusStackTrace)(e.errorDescription.stack_trace),editorError:e.errorDescription.editorError}:null}}},80671:(e,t,i)=>{"use strict";i.d(t,{StudyStatusView:()=>o});var s=i(13651);class o extends s.StatusView{constructor(e){super(e.statusProvider())}getSplitTitle(){return this._statusProvider.getSplitTitle()}titleTooltip(){return this._statusProvider.titleTooltip()}getInputsTitles(){return this._statusProvider.getInputsTitles()}update(e){this._text=this._statusProvider.text()}}},86252:(e,t,i)=>{"use strict";i.d(t,{StudyStatusType:()=>h,convertStudyStatusToString:()=>d,createStudyError:()=>g,studyErrorStatusStackTrace:()=>m,studyStatusFeature:()=>p,studyStatusSolutionId:()=>u,studyStatusTitle:()=>_});var s=i(11542),o=i(55014);const n=s.t(null,void 0,i(50910));const r=new Map,a=new Map,l="loading...",c=s.t(null,void 0,i(62011));var h;function d(e,t){if(e.type===h.Loading)return t?c:l;if(e.type===h.Error){const i=e.errorDescription,s=t?(0,
o.triesTranslateError)(i.error):i.error;if(i.ctx){const e={};return Object.entries(i.ctx).forEach((([t,i])=>{e[t]=i.toString()})),s.format(e)}return s}return""}function u(e){if(e.type===h.Error)return e.errorDescription.solution_id?e.errorDescription.solution_id:function(e){for(const t of Array.from(r.keys()))if(e.includes(t))return r.get(t)}(e.errorDescription.error)}function _(e){if(e.type===h.Error)return function(e){const t=e.toLowerCase();return t.includes("the data vendor doesn't provide volume data for this symbol.")||t.includes("no volume is provided by the data vendor")}(e.errorDescription.error)?n:(0,o.triesTranslateError)(e.errorDescription.title??"Runtime error")}function p(e){const{errorDescription:{error:t}}=e;for(const[e,i]of a)if(t.startsWith(e))return i}function m(e){if(void 0===e)return;const t=[];for(const i of e){const e={functionOrScopeName:i.n,lineNumber:i.p};"id"in i&&(e.id=i.id),"v"in i&&(e.versionScript=i.v),t.push(e)}return t}function g(e,t){const i="check study unexpected error"===e.error;return{type:h.Error,errorDescription:{...e,showReportItButton:i}}}!function(e){e[e.Undefined=0]="Undefined",e[e.Loading=1]="Loading",e[e.Completed=2]="Completed",e[e.Error=3]="Error"}(h||(h={}))},2258:(e,t,i)=>{"use strict";i.d(t,{StudyStub:()=>b,isStudyStubDescriptor:()=>w});var s=i(50279),o=i(30551),n=i(50151),r=i(52499),a=(i(48943),i(51304)),l=i(80671),c=i(67135),h=i(67563),d=i(48096),u=i(43337),_=i(35990),p=i(36313);class m extends _.StudyStatusProviderBase{text(){return this._source.isActualInterval()?`${this._source.title(p.TitleDisplayTarget.StatusLine)} ${this.sourceStatusText()}`:this._source.title(p.TitleDisplayTarget.StatusLine)}}var g=i(86252),f=i(29447),y=i(72972);class v{getItems(){return[]}getValues(e){return[]}}const S=new d.Delegate;class b extends c.PriceDataSource{constructor(e,t,i,s,o=null){super(e),this._priceStep=.01,this._origState=null,this._descriptor=null,this._status={type:g.StudyStatusType.Undefined},this._statusChanged=new d.Delegate,this._descriptorChanged=new d.Delegate,this._formatter=new h.PriceFormatter({priceScale:100}),this._showPineVersionInStatusLine=new r.WatchedValue(!1).spawn(),this._pineSourceCodeModel=null,(0,y.isStudyDescriptor)(t)?this._descriptor=t:this._origState=t,this._title=i,this._alwaysShowInLegend=void 0!==s,this._isOverlay=s,this._studyMetaInfo=o;this._properties=new u.Property({visible:!0}),this._statusView=new l.StudyStatusView(this)}destroy(){this._pineSourceCodeModel?.destroy(),this._showPineVersionInStatusLine.destroy(),super.destroy()}barColorer(){return null}properties(){return this._properties}statusView(){return this._statusView}legendView(){return null}state(e){return this._origState}getDescriptor(){return null===this._descriptor?null:{descriptor:this._descriptor,title:this._title,isOverlay:this._isOverlay,id:this.id(),status:this._status}}updateDescriptor(e){(0,s.default)(this._descriptor,e)||(this._descriptor=e,this._descriptorChanged.fire())}onDescriptorChanged(){return this._descriptorChanged}metaInfo(){return this._studyMetaInfo}
setMetaInfo(e){this._studyMetaInfo=e}setStatus(e){const t=this.isDisplayedInLegend();if(this._status=e,this._statusChanged.fire(),this.isDisplayedInLegend()!==t){const e=this._model.paneForSource(this);if(e){const t=this._model.panes().indexOf(e),i=a.InvalidationMask.invalidateLegendWidgetLayout(t);this.model().invalidate(i)}}}formatter(){return this._formatter}name(){return this._title}title(){return this.titleInParts().join(" ")}titleInParts(){const e=[this._title];return this._showPineVersionInStatusLine.value()&&e.push((0,n.ensureDefined)(this._studyMetaInfo?.pine).version),e}inputsInParts(){return null}isFailed(){return this._status.type===g.StudyStatusType.Error}isLoading(){return this._status.type===g.StudyStatusType.Loading}isDisplayedInLegend(){return this._alwaysShowInLegend||this.isFailed()}setFailed(e,t){this.setStatus({type:g.StudyStatusType.Error,errorDescription:{error:e,title:t}}),this._model.updateSource(this)}isSymbolInvalid(){return!1}isActualInterval(){return!0}onIsActualIntervalChange(){return S}start(){}status(){return this._status}onStatusChanged(){return this._statusChanged}firstValue(){return null}currency(){return null}sessionId(){return this._model.mainSeries().sessionId()}sessionIdChanged(){return this._model.mainSeries().sessionIdChanged()}unit(){return null}symbolSource(){return this._model.mainSeries()}symbolSourceWV(){return this._model.mainSeries().symbolSourceWV()}barsProvider(){return this._model.mainSeries()}valuesProvider(){return new v}legendValuesProvider(){return new v}statusProvider(e){return new m(this)}isRemovedByStudyTemplates(){return null!==this._origState&&(0,f.isStudyState)(this._origState)}pineSourceCodeModel(){return Promise.resolve(null)}contextMenuStatName(){return"StudyStubContextMenu"}}function w(e){return(0,o.isObject)(e)&&"descriptor"in e&&(0,y.isStudyDescriptor)(e.descriptor)}},44862:(e,t,i)=>{"use strict";i.d(t,{applyOverridesToStudy:()=>d,applyOverridesToStudyDefaults:()=>u});var s=i(50151),o=i(4359),n=i(9343);const r={line:o.LineStudyPlotStyle.Line,histogram:o.LineStudyPlotStyle.Histogram,cross:o.LineStudyPlotStyle.Cross,area:o.LineStudyPlotStyle.Area,columns:o.LineStudyPlotStyle.Columns,circles:o.LineStudyPlotStyle.Circles,line_with_breaks:o.LineStudyPlotStyle.LineWithBreaks,area_with_breaks:o.LineStudyPlotStyle.AreaWithBreaks,step_line:o.LineStudyPlotStyle.StepLine,step_line_with_breaks:o.LineStudyPlotStyle.StepLineWithBreaks,step_line_with_diamonds:o.LineStudyPlotStyle.StepLineWithDiamonds},a=(0,n.getLogger)("Chart.Model.StudyPropertiesOverrider");var l,c;function h(e,t,i,s){const o=i.split(".");if(0===o.length||0===o[0].length)return;const n=function(e){const t=e.split(":");return{name:t[0],type:2===t.length?t[1]:null}}(o[0]),r=n.name,h=n.type,d=null!==h,u=!d||"band"===h,_=!d||"area"===h,p=!d||"input"===h,m=!d||"plot"===h?c.getPlotIdByTitle(e,r):null,g=u?c.getBandIndexByName(e,r):null,f=_?c.getFilledAreaIdByTitle(e,r):null,y=p?c.getInputByName(e,r):null,v=t.hasOwnProperty(r)
;if((null!==m?1:0)+(null!==g?1:0)+(null!==f?1:0)+(null!==y?1:0)+(v?1:0)>1)return void a.logWarn(`Study '${e.description}' has ambiguous identifier '${r}'`);const S=o[1];if(null!==m){if(1===o.length)return void a.logWarn(`Path of sub-property of '${r}' plot for study '${e.description}' must be not empty`);const i=o.slice(1);l.applyPlotProperty(e,t,m,i,s)}else if(null!==y)l.applyInputValue(t,y,s);else if(null!==g){if(void 0===S)return void a.logWarn(`Property name of '${r}' band for study '${e.description}' must be set`);l.applyBandProperty(t,g,S,s)}else if(null!==f){if(void 0===S)return void a.logWarn(`Property name of '${r}' area for study '${e.description}' must be set`);l.applyFilledAreaProperty(t,f,S,s)}else v?l.setRootProperty(t,o,s):a.logWarn(`Study '${e.description}' has no plot or input '${r}'`)}function d(e,t){const i=e.properties(),s=i.state();for(const i in t)t.hasOwnProperty(i)&&h(e.metaInfo(),s,i,t[i]);i.mergeAndFire(s)}function u(e,t,i){for(const s in e){if(!e.hasOwnProperty(s))continue;const o=s.indexOf(".");if(-1===o)continue;const n=s.substring(0,o),r=c.getMetaInfoByDescription(t,n);if(null===r){a.logWarn(`There is no such study ${n}`);continue}const l=i(r);null!==l?h(r,l,s.substring(o+1),e[s]):a.logWarn(`Cannot apply overrides for study ${n}`)}}!function(e){e.applyPlotProperty=function(e,t,i,n,l){if(void 0===t.styles)return void a.logWarn("Study does not have styles");const c=n[0];if("color"===c){const r=function(e,t,i){if(void 0===e.plots)return null;for(const s of e.plots){if(!(0,o.isPaletteColorerPlot)(s)||void 0===t.palettes)continue;const e=t.palettes[s.palette];if(s.target===i&&void 0!==e)return e}return null}(e,t,i);return void function(e,t,i,o,n){void 0!==e.styles?null===t&&!isNaN(o)&&o>0?a.logWarn(`Study plot does not have color #${o}`):((0===o||isNaN(o))&&((0,s.ensureDefined)(e.styles[i]).color=String(n),o=0),null!==t&&((0,s.ensureDefined)(t.colors?.[o]).color=String(n))):a.logWarn("Study does not have styles")}(t,r,i,n.length>1?parseInt(n[1]):NaN,l)}const h=t.styles[i];if(void 0!==h&&h.hasOwnProperty(c)){if("plottype"===c){const e=r[String(l)];if(void 0===e)return void a.logWarn(`Unsupported plot type for plot: ${l}`);l=e}h[c]=l}else a.logWarn(`Study plot does not have property '${c}'`)},e.applyBandProperty=function(e,t,i,s){if(void 0===e.bands)return void a.logWarn("Study does not have bands");const o=e.bands[t];if(void 0!==o&&o.hasOwnProperty(i)){if("plottype"===i){const e=r[String(s)];if(void 0===e)return void a.logWarn(`Unsupported plot type for band: ${s}`);s=e}o[i]=s}else a.logWarn(`Study band does not have property '${i}'`)},e.applyFilledAreaProperty=function(e,t,i,s){if(void 0===e.filledAreasStyle)return void a.logWarn("Study does not have areas");const o=e.filledAreasStyle[t];void 0!==o&&o.hasOwnProperty(i)?o[i]=s:a.logWarn(`Study area does not have property '${i}'`)},e.applyInputValue=function(e,t,i){void 0!==e.inputs&&e.inputs.hasOwnProperty(t)?e.inputs[t]=i:a.logWarn(`Study does not have input '${t}'`)},e.setRootProperty=function(e,t,i){if(0===t.length)return;let s=e
;for(const e of t.slice(0,-1)){if(null==s||!s.hasOwnProperty(e))break;s=s[e]}const o=t[t.length-1];null!=s&&s.hasOwnProperty(o)?s[o]=i:a.logWarn(`Study does not have property ${t.join(".")}`)}}(l||(l={})),function(e){e.getInputByName=function(e,t){if(void 0===e.inputs)return null;t=t.toLowerCase();for(const i of e.inputs)if(i.name.toLowerCase()===t)return i.id;return null},e.getPlotIdByTitle=function(e,t){if(void 0===e.styles)return null;t=t.toLowerCase();for(const i in e.styles){const s=e.styles[i];if((void 0!==s&&void 0!==s.title?s.title:i).toLowerCase()===t)return i}return null},e.getFilledAreaIdByTitle=function(e,t){if(void 0===e.filledAreas)return null;t=t.toLowerCase();for(const i of e.filledAreas)if(i.title.toLowerCase()===t)return i.id;return null},e.getBandIndexByName=function(e,t){if(void 0===e.bands)return null;t=t.toLowerCase();for(let i=0;i<e.bands.length;++i)if(e.bands[i].name.toLowerCase()===t)return i;return null},e.getMetaInfoByDescription=function(e,t){t=t.toLowerCase();for(const i of e)if(i.description.toLowerCase()===t||i.shortDescription.toLowerCase()===t)return i;return null}}(c||(c={}))},86821:(e,t,i)=>{"use strict";const{clone:s}=i(87465);var o=i(9787).Version,n=i(9343).getLogger("Chart.StudyMigration");function r(e){this._studyId=e,this._maxToVers=o.ZERO,this._maxFromVers=o.ZERO,this._migrs=[]}r.prototype.addMigration=function(e,t,i){var s=o.parse(e),n=o.parse(t);s.isGreater(this._maxFromVers)&&(this._maxFromVers=s),n.isGreater(this._maxToVers)&&(this._maxToVers=n),this._migrs.push({fromVers:s,toVers:n,rules:i})},r.prototype.updateInputs=function(e,t,i){if(!i)return i;for(var o=s(i),r=e;r.isLess(t);){var a=this._findMigration(r);if(null==a)break;if(n.logNormal("Migrating study inputs from "+a.fromVers+" to "+a.toVers+" version, studyId: "+this._studyId+", migration: "+JSON.stringify(a)+", inputs: "+JSON.stringify(i)),o=this._applyMigration(o,a),!r.isLess(a.toVers))throw new Error("Problems in study migration process... Possible infinite cycle has been detected and stopped.");r=a.toVers}return r>e&&n.logNormal("Study inputs migration is done, studyId: "+this._studyId+", inputs: "+JSON.stringify(o)),o},r.prototype._findMigration=function(e){for(var t=-1,i=this._maxFromVers,s=0;s<this._migrs.length;s++){var o=this._migrs[s];o.fromVers.isLess(e)||o.fromVers.isLessOrEqual(i)&&(i=o.fromVers,t=s)}return t<0?null:this._migrs[t]},r.prototype._applyMigration=function(e,t){for(var i=e,s=0;s<t.rules.length;s++){var o=t.rules[s];i=this._getApplyRuleFun(o.type)(i,o)}return i},r.prototype._getApplyRuleFun=function(e){if("inputRemoved"===e)return r._applyInputRemovedRule;if("inputChangedType"===e)return r._applyInputChangedTypeRule;if("inputChangedMinMax"===e)return r._applyInputChangedMinMaxRule;if("inputChangedOptions"===e)return r._applyInputChangedOptionsRule;throw new Error("Unknown migration rule type: "+e)},r._applyInputRemovedRule=function(e,t){if(!(t.inputId in e))return e;if("removeVal"!==t.action)throw new Error("Unexpected rule.action="+t.action+" in rule.type="+t.type);var i=e[t.inputId]
;return delete e[t.inputId],n.logNormal("Input "+t.inputId+"="+i+" removed"),e},r._applyInputChangedTypeRule=function(e,t){var i=e[t.inputId];if("resetToDefVal"===t.action)return e[t.inputId]=t.defVal,n.logNormal("Input "+t.inputId+"="+i+" reset to default value "+t.defVal),e;if("convertVal"===t.action){if(null==i)return e;if("float"===t.inputTypeFrom&&"integer"===t.inputType)return e[t.inputId]=Math.round(e[t.inputId]),n.logNormal("Input "+t.inputId+"="+i+" converted to value "+e[t.inputId]),e;if("integer"===t.inputTypeFrom&&"float"===t.inputType)return e;if("text"===t.inputTypeFrom&&"source"===t.inputType)return r._isValidSource(i,t.options)||(e[t.inputId]=t.defVal),e;throw new Error("Cannot convertVal from "+t.inputTypeFrom+" to "+t.inputType)}throw new Error("Unknown action "+t.action+" for rule with type "+t.type)},r._isValidSource=function(e,t){return e.indexOf("$")>=0||t.indexOf(e)>=0},r._applyInputChangedMinMaxRule=function(e,t){if("adjustValIfNeeded"!==t.action)throw new Error("Unknown action "+t.action+" for rule with type "+t.type);var i=e[t.inputId];return i<t.minVal?e[t.inputId]=t.minVal:i>t.maxVal&&(e[t.inputId]=t.maxVal),n.logNormal("Input "+t.inputId+"="+i+" adjusted to value "+e[t.inputId]),e},r._applyInputChangedOptionsRule=function(e,t){if(!(["text"].indexOf(t.inputType)>=0&&"resetToDefValIfNeeded"===t.action))throw new Error("Unexpected rule.inputType="+t.inputType+" in rule.action="+t.action);var i=e[t.inputId];return t.options.indexOf(i)<0&&(e[t.inputId]=t.defVal,n.logNormal("Input "+t.inputId+"="+i+" reset to default value "+t.defVal)),e},e.exports=r},15219:(e,t,i)=>{"use strict";i.d(t,{StudyVersioning:()=>m});var s=i(16738),o=i(50151),n=i(19844),r=i(86821),a=i.n(r),l=i(9343),c=i(9787),h=i(43046),d=i(87465);const u=(0,l.getLogger)("Chart.Study.Versioning"),_=1e12;var p;!function(e){e[e.VersionStudyArgSource=41]="VersionStudyArgSource",e[e.MetaInfoFormatVersionSosV2=42]="MetaInfoFormatVersionSosV2",e[e.VersionPineProtectTv4164=43]="VersionPineProtectTv4164",e[e.VersionNewStudyPrecisionFormat=46]="VersionNewStudyPrecisionFormat",e[e.CurrentMetaInfoFormatVersion=54]="CurrentMetaInfoFormatVersion"}(p||(p={}));class m{constructor(e,t){if(this._migrations={},!e)throw new Error("No studies metainfo");if(this._studiesMetainfo=e,!t)throw new Error("No studies migrations");this._studiesMigrations=t;for(let e=0;e<this._studiesMigrations.length;e++){const t=this._studiesMigrations[e],i=t.versFrom,s=t.versTo;for(let e=0;e<t.studyMigrations.length;e++){const o=t.studyMigrations[e],n=o.studyId;if(0===o.rules.length){u.logError("Study Migration should have at least one convertion rule");continue}const r=n in this._migrations?this._migrations[n]:new(a())(n);r.addMigration(i,s,o.rules),this._migrations[n]=r}}this._clientMigrations=[(e,t)=>{if(0===this._studiesMetainfo.length||!e.isTVScript||e.version>=22)return t;const i={};let s=0,o=0,n=t[o];for(;void 0!==n;){const e=t[n.id];n.isFake&&(n.id="in_"+s++),i[o]=n,i[n.id]=e,o++,n=t[o]}return i}]}updateMetaInfoAsync(e,t){n.StudyMetaInfo.versionOf(e);{let t=null
;const i=this._studiesMetainfo;for(let s=0;s<i.length;s++)if(i[s].id===e.id){t=i[s];break}return{sync:!0,result:t?new n.StudyMetaInfo(t.state()):null}}}updateStudyState(e,t,i){if(null==e||null==t||null==i)return e;e=(0,d.clone)(e),this.updateStudyInputsIfNeeded(e,t.version,i);for(const i of this._clientMigrations){const s=i.call(this,t,e.inputs);Object.keys(s).length===Object.keys(e.inputs).length?e.inputs=s:u.logWarn("StudyVersioning._clientMigrations application returned bad result. Skipping it...")}const s=n.StudyMetaInfo.versionOf(t);if(t.isTVScript&&t.TVScriptSourceCode&&s>=12&&s<=26){const s={};for(let e=0;e<t.plots.length;++e){const o=t.plots[e],n=i.plots[e];s[o.id]=n.id}const o=Object.keys(e.styles);for(let t=0;t<o.length;++t){const i=o[t],n=e.styles[i];delete e.styles[i];const r=s[i];e.styles[r]=n}const n=Object.keys(e.plots);for(let t=0;t<n.length;++t){const i=n[t],o=e.plots[i].id;e.plots[i].id=s[o]}}return e}updateStudyInputsIfNeeded(e,t,i){if(!(i.isTVScript||!!i.pine)&&t!==i.version){const s=i&&i.defaults.inputs;e.inputs=this.updateStudyInputs(i.id,t,i.version,e.inputs,s)}}updateStudyInputs(e,t,i,s,o){let n=(0,d.clone)(s);if(e in this._migrations){const s=c.Version.parse(t);let o;if("last"===i){const t=this.lastVersionOfStudy(e);o=c.Version.parse(t)}else o=c.Version.parse(i);n=this._migrations[e].updateInputs(s,o,n)}if(null==o)return n;for(const e in o)e in n||(n[e]=o[e]);for(const i in n)if(!(i in o)){const s=n[i];u.logWarn(`Extra input detected, studyId='${e}', versionFrom='${t}', inputId='${i}', inputValue='${s}', removing it and continue...`),delete n[i]}return n}lastVersionOfStudy(e){return(0,o.ensureDefined)(this._studiesMetainfo.find((t=>t.id===e))).version}updateMetaInfo(e){if(!e)return e;(0,o.assert)(e instanceof n.StudyMetaInfo),(0,o.assert)(!e.isTVScript,"This method should update only built-in java indicators metaInfo. For Pine indicators use updateMetaInfoAsync");const t=this._studiesMetainfo.find((t=>e.id===t.id));return t?new n.StudyMetaInfo(t.state()):null}static patchPointsBasedStudyState(e){return this._fixInputsMaxValue(e.state,e.metaInfo),e}static patchStudyData(e,t,i,s){return{data:t,nsData:i,indexes:s??void 0}}static patchPointsBasedStudyData(e,t){return t}static patchPropsStateAndMetaInfo(e,t,i){let o=t.state();"Script$BOOKER"!==t.productId||o.alerts||delete e.alerts,this._fixInputsOrder(e,o),this._fixInputsMaxValue(e,o);const r=this.splitInputs(e.inputs);e.inputs=r.obj;const a=n.StudyMetaInfo.versionOf(t);a<42&&o.isChildStudy&&(e.isChildStudy=o.isChildStudy);if(t.isTVScript&&t.version<60&&("Script$TV_EARNINGS@tv-scripting"!==t.id&&"Script$TV_DIVIDENDS@tv-scripting"!==t.id&&"Script$TV_SPLITS@tv-scripting"!==t.id||delete o.TVScriptSourceCode),"Volume"!==t.id&&"Volume@tv-basicstudies"!==t.id||0!==t.inputs.length||(o.inputs=[{id:"length",type:"integer",defval:20,min:1,max:1e3}],o.plots.push({id:"vol_ma",type:"line"})),"Volume@tv-basicstudies"===t.id&&t.version&&t.version<=46&&void 0===e.styles.vol.transparency&&(e.styles.vol.transparency=e.transparency||87),
"PivotPointsStandard@tv-basicstudies"===t.id&&(0===o.inputs.length?(e.inputs={kind:"Traditional",showHistoricalPivots:!0},o.inputs=[{defval:"Traditional",id:"kind",type:"text",options:["Traditional","Fibonacci","Woodie","Classic","DeMark","Camarilla"]},{id:"showHistoricalPivots",type:"bool",defval:!0}]):1===o.inputs.length&&(e.inputs={kind:"Traditional"},o.inputs=[{defval:"Traditional",id:"kind",type:"text",options:["Traditional","Fibonacci","Woodie","Classic","DeMark","Camarilla"]},{id:"showHistoricalPivots",type:"bool",defval:!0}]),void 0===e._hardCodedDefaultsVersion)){e._hardCodedDefaultsVersion=1;const t=e.color;delete e.color,e.levelsStyle={colors:{P:t,"S1/R1":t,"S2/R2":t,"S3/R3":t,"S4/R4":t,"S5/R5":t}}}"CMF"===t.shortId&&2===o.inputs.length&&(e.inputs={length:e.inputs["length fast"]},o.inputs=o.inputs.splice(0,1),o.inputs[0].id="length"),o.defaults&&void 0===o.defaults.precision&&a<46&&(-1!==["Volume@tv-basicstudies","VbPVisible@tv-volumebyprice","VbPSessions@tv-volumebyprice"].indexOf(t.id)?o.defaults.precision=0:o.defaults.precision=4);let l=t.id;if(t.version<60){const e=["TV_DIVIDENDS","TV_SPLITS","TV_EARNINGS"],i=6;for(let s=0;s<e.length;s++)t.id.startsWith("Script$"+e[s]+"@tv-scripting")&&(o.fullId="ESD"+o.fullId.substring(i),o.id="ESD"+o.id.substring(i),o.name&&(o.name="ESD"+o.name.substring(i)),o.shortId="ESD"+o.shortId.substring(i),o.productId="ESD"+o.productId.substring(i),l="ESD"+t.id.substring(i))}const c={"ESD$TV_EARNINGS@tv-scripting":{fullId:"Earnings@tv-basicstudies-129!",id:"Earnings@tv-basicstudies",name:"Earnings@tv-basicstudies",shortId:"Earnings",productId:"tv-basicstudies"},"ESD$TV_SPLITS@tv-scripting":{fullId:"Splits@tv-basicstudies-129!",id:"Splits@tv-basicstudies",name:"Splits@tv-basicstudies",shortId:"Splits",productId:"tv-basicstudies"},"ESD$TV_DIVIDENDS@tv-scripting":{fullId:"Dividends@tv-basicstudies-129!",id:"Dividends@tv-basicstudies",name:"Dividends@tv-basicstudies",shortId:"Dividends",productId:"tv-basicstudies"}};if(l in c&&Object.assign(o,c[l]),a<43){const i={"StrategyScript$STD;Consecutive%1Ups/Downs%1Strategy":{pineId:"STD;Consecutive%1Ups%1Downs%1Strategy",className:"StrategyScript"},Script$EDGR_NET_INCOME_FROM_CONTINUING_OPERATIONS_APPLICABLE_TO_COMMON_V2:{pineId:"Script$EDGR_NET_INCOME_FROM_CONTINUING_OPS_APPLICABLE_TO_COMMON_V2",className:"Script"}};if(t.shortId in i){const n=i[t.shortId].className+"$"+i[t.shortId].pineId,r={scriptIdPart:i[t.shortId].pineId,fullId:o.fullId.replace(o.shortId,n),id:o.id.replace(o.shortId,n),name:o.name?.replace(o.shortId,n),shortId:n};(0,s.default)(o,r),(0,s.default)(e,r)}const n=!1,r=n&&n.match(/^(USER)(_\d+)(;)(.*)$/);if(r){const t=r[0],i=r[1]+r[3]+r[2]+r[4],n={scriptIdPart:i,fullId:o.fullId.replace(t,i),id:o.id.replace(t,i),name:o.name?.replace(t,i),shortId:o.shortId.replace(t,i)};(0,s.default)(o,n),(0,s.default)(e,n)}}if("MA"===t.id){const t={id:"MAExp",properties:[{id:"is_price_study",type:"bool",value:"true"}],inputs:[{id:"length",type:"integer",defval:20,min:1,max:500},{id:"source",type:"text",defval:"close",
options:["open","high","low","close"]}],plots:[{id:"MovAvgExp",type:"line"}],palettes:{}},i={id:"MASimple",properties:[{id:"is_price_study",type:"bool",value:"true"}],inputs:[{id:"length",type:"integer",defval:20,min:1,max:500},{id:"source",type:"text",defval:"close",options:["open","high","low","close"]}],plots:[{id:"MovAvgSimple",type:"line"}],palettes:{}},s={id:"MAVolumeWeighted",properties:[{id:"is_price_study",type:"bool",value:"true"}],inputs:[{id:"length",type:"integer",defval:20,min:1,max:500},{id:"source",type:"text",defval:"close",options:["open","high","low","close"]}],plots:[{id:"MovAvgVolumeWeighted",type:"line"}],palettes:{}},n={id:"MAWeighted",properties:[{id:"is_price_study",type:"bool",value:"true"}],inputs:[{id:"length",type:"integer",defval:20,min:1,max:500},{id:"source",type:"text",defval:"close",options:["open","high","low","close"]}],plots:[{id:"MovAvgWeighted",type:"line"}],palettes:{}};switch(e.inputs.type){case"exp":o=t;break;case"simple":o=i;break;case"weighted":o=n;break;case"volume weighted":o=s}e.styles[o.plots[0].id]=e.styles.MovAvg,delete e.styles.MovAvg,delete e.inputs.type}return i.oldShowStudyLastValueProperty&&(e.oldShowLastValue=e.showLastValue),delete e.showLastValue,delete e.showStudyArguments,(0,h.migrateMetaInfoAndPropState)(o,e),{propsState:e,metaInfo:o}}static splitInputs(e){const t={},i={};for(const[s,o]of Object.entries(e))(0,d.isNumber)(parseInt(s,10))?t[s]=o:i[s]=o;return{arr:t,obj:i}}static verifyInputsMaxValue(e){if(e.inputs)for(const t of e.inputs)"integer"===t.type&&t.max&&t.max>_&&u.logWarn("Bad integer input max value in metaInfo id="+e.id+" title="+e.description)}static mergeInputsObjPart(e,t){const i=this.splitInputs(t);(0,s.default)(e,i.obj)}static _fixInputsOrder(e,t){const i=this._getOrderedInputIds(t),o=this.splitInputs(e.inputs),n=o.arr,r=o.obj,a=(0,s.default)({},r);for(let e=0;e<i.length;++e){const t=i[e],s=this._findInputKeyById(n,t);null!==s&&(a[e]=n[s])}e.inputs=a}static _fixInputsMaxValue(e,t){if((0,d.isAbsent)(t))return;const i=_;if(t.inputs)for(const e of t.inputs)"integer"===e.type&&e.max&&e.max>i&&(e.max=i);if(!e||!e.inputs)return;const o=this.splitInputs(e.inputs),n=o.arr;for(const[,e]of Object.entries(n))"integer"===e.type&&e.max&&e.max>i&&(e.max=i);e.inputs=(0,s.default)(o.obj,o.arr)}static _findInputKeyById(e,t){let i=null;for(const s in e)if((0,d.isNumber)(parseInt(s,10))&&e[s].id===t){i=s;break}return i}static _getOrderedInputIds(e){const t=[];for(const i of e.inputs)t.push(i.id);return t}static _patchOldVolumeProfiles(e,t){if(!t?.hhists)return;const i=t.hhists[e].data,s=[];for(const[,e]of Object.entries(i))s.push(e);t.hhists[0].data=s}}},77380:(e,t,i)=>{"use strict";function s(e,t,i){return e===t||e===i}i.d(t,{symbolSameAsResolved:()=>s})},95772:(e,t,i)=>{"use strict";i.d(t,{translateSessionDescription:()=>r,translateSessionShortDescription:()=>l});var s,o=i(11542);!function(e){e.RegularTradingHours="regular trading hours",e.ExtendedTradingHours="extended trading hours",e.ElectronicTradingHours="electronic trading hours",
e.Premarket="premarket",e.Postmarket="postmarket"}(s||(s={}));const n=new Map([["premarket",o.t(null,{context:"sessions"},i(59330))],["postmarket",o.t(null,{context:"sessions"},i(50434))],["regular trading hours",o.t(null,{context:"sessions"},i(84246))],["extended trading hours",o.t(null,{context:"sessions"},i(36862))],["electronic trading hours",o.t(null,{context:"sessions"},i(34647))]]);function r(e){return n.get(e.toLowerCase())??e}const a=new Map([["premarket",o.t(null,{context:"sessions"},i(46273))],["postmarket",o.t(null,{context:"sessions"},i(7807))],["regular trading hours",o.t(null,{context:"sessions"},i(92158))],["extended trading hours",o.t(null,{context:"sessions"},i(8029))],["electronic trading hours",o.t(null,{context:"sessions"},i(8029))]]);function l(e){return a.get(e.toLowerCase())??e}},36597:(e,t,i)=>{"use strict";i.d(t,{areEqualSymbols:()=>a,compareSymbolParams:()=>d,symbolParams:()=>h,symbolSameAsCurrent:()=>c});var s=i(37103),o=i(95059),n=i(46082);const r=s.enabled("uppercase_instrument_names");function a(e,t){return void 0===e?void 0===t:void 0!==t&&(r?e.toUpperCase()===t.toUpperCase():e===t)}function l(e,t){return e.some((e=>a(t,e)))}function c(e,t){if(null===t)return!1;if(t){if(a(t.full_name,e)||a(t.pro_name,e))return!0;if(a(t.ticker,e))return!0;if(t.aliases&&l(t.aliases,e))return!0;if(t.alternatives&&l(t.alternatives,e))return!0;if(0===e.indexOf("FRA:")&&a(t.pro_name,e.replace("FRA:","FWB:")))return!0}return!1}function h(e){return{symbol:e.symbol(),currency:e.currency(),unit:e.unit(),interval:e.interval(),style:e.style()}}function d(e,t,i){const{symbol:s,currency:r,unit:a,style:l,interval:c}=t,h=void 0!==s&&!e.symbolSameAsResolved(s);let d,u;const _=e.symbolInfo();null!==_?(d=void 0!==r&&!function(e,t){return null===e&&!(0,o.isConvertedToOtherCurrency)(t)||e===(0,o.symbolCurrency)(t)}(r,_),u=void 0!==a&&!function(e,t,i){return null===e&&!(0,o.isConvertedToOtherUnit)(t,i)||e===(0,o.symbolUnit)(t,i)}(a,_,i)):(d=void 0!==r&&r!==e.currency(),u=void 0!==a&&a!==e.unit());return{symbolChanged:h,intervalChanged:void 0!==c&&!n.Interval.isEqual(e.interval(),c),currencyChanged:d,unitChanged:u,styleChanged:void 0!==l&&l!==e.style(),styleChangeRequiresRestart:void 0!==l&&(0,o.styleChangeRequiresRestart)(l,e.style())}}},57658:(e,t,i)=>{"use strict";i.d(t,{TextWidthCache:()=>n,getMinTextMetrics:()=>o});var s=i(16659);function o(e){return{width:e.width,actualBoundingBoxAscent:e.actualBoundingBoxAscent,actualBoundingBoxDescent:e.actualBoundingBoxDescent,fontBoundingBoxAscent:e.fontBoundingBoxAscent,fontBoundingBoxDescent:e.fontBoundingBoxDescent}}class n{constructor(e=150){this._fontStyle="",this._cache=new s.CircularCacheBuffer(e,1.5)}reset(){this._cache.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;const s=e.textBaseline;e.textBaseline="middle";const n=o(e.measureText(t));return e.textBaseline=s,0===n.width&&t.length||this._cache.set(t,n),n}}},23752:(e,t,i)=>{"use strict";i.d(t,{TimeAxisView:()=>r});var s=i(52859),o=i(33350);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 r=i.paddingHorizontal,a=n+2*r,l=a/2;let c=s.coordinate,h=Math.floor(c-l)+.5;if(s.alwaysInViewPort){const e=s.width;h<0?(c+=Math.abs(0-h),h=Math.floor(c-l)+.5):h+a>e&&(c-=Math.abs(e-(h+a)),h=Math.floor(c-l)+.5)}const d=h+a,u=Math.ceil(0+i.borderSize+i.offsetSize+i.paddingTop+i.fontSize+i.paddingBottom),{horizontalPixelRatio:_,verticalPixelRatio:p}=t;e.fillStyle=s.background;const m=Math.round(h*_),g=Math.round(0*p),f=Math.round(d*_),y=Math.round(u*p),v=Math.round(2*_);e.beginPath(),e.moveTo(m,g),e.lineTo(m,y-v),e.arcTo(m,y,m+v,y,v),e.lineTo(f-v,y),e.arcTo(f,y,f,y-v,v),e.lineTo(f,g),e.fill();const S=0+i.borderSize+i.offsetSize+i.paddingTop+i.fontSize/2;e.textAlign="left",e.textBaseline="middle",e.fillStyle=s.color;const b=i.widthCache.yMidCorrection(e,"Apr0");e.translate((h+r)*_,(S+b)*p),(0,o.drawScaled)(e,_,p,(()=>e.fillText(s.text,0,0))),e.restore()}}class r{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)}}},82284:(e,t,i)=>{"use strict";i.d(t,{INVALID_TIME_POINT_INDEX:()=>s,UNPLOTTABLE_TIME_POINT_INDEX:()=>o});const s=-2e6,o=-1e6},3190:(e,t,i)=>{"use strict";i.d(t,{restoreTimeHoursFormatSettingsValue:()=>l,timeHoursFormatProperty:()=>a});var s=i(1765),o=i(41072);const n="time_hours_format";function r(){return s.getValue(n,"24-hours")}const a=(0,o.createPrimitiveProperty)(r());function l(){a.setValue("24-hours"),s.remove(n)}s.onSync.subscribe(null,(()=>a.setValue(r()))),a.subscribe(null,(()=>s.setValue(n,a.value())))},19679:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DAY_SPAN:()=>a,DEFAULT_BAR_SPACING:()=>d,HOUR_SPAN:()=>r,MILLISECOND_SPAN:()=>s,MINUTE_SPAN:()=>n,
MONTH_SPAN:()=>c,SECOND_SPAN:()=>o,WEEK_SPAN:()=>l,YEAR_SPAN:()=>h});const s=5,o=10,n=20,r=30,a=40,l=50,c=60,h=70,d=6},20512:(e,t,i)=>{"use strict";i.d(t,{getHourMinuteFormat:()=>o,getHourMinuteSecondFormat:()=>n,getTimeFormatForInterval:()=>r});var s=i(82087);function o(e){return"12-hours"===e?s.twelveHourMinuteFormat:s.hourMinuteFormat}function n(e){return"12-hours"===e?s.twelveHourMinuteSecondFormat:s.hourMinuteSecondFormat}function r(e,t){if(e.isRange())return function(e){return"12-hours"===e?s.twelveHourMinuteNonZeroSecondFormat:s.hourMinuteNonZeroSecondFormat}(t);if(e.isTicks())return s.hourMinuteSecondMillisecFormat;return e.isSeconds()||e.isTicks()?n(t):o(t)}},75641:(e,t,i)=>{"use strict";i.d(t,{translatedIntervalString:()=>o});var s=i(87296);function o(e){const t=(0,s.getTranslatedResolutionModel)(e,!0);return null===t?e:t.multiplier+(t.mayOmitShortKind?"":t.shortKind)}},29603:(e,t,i)=>{"use strict";i.d(t,{ExcludeLineToolsFromGroupUndoCommand:()=>h});var s=i(50151),o=(i(40167),i(11542)),n=i(95804),r=i(87465),a=i(72270),l=i(13896);const c=new n.TranslatedString("exclude line tools from group {group}",o.t(null,void 0,i(99395)));class h extends a.UndoCommand{constructor(e,t,i){super(c.format({group:t.name().value()}),void 0,!l.lineToolsDoNotAffectChartInvalidation),this._model=e,this._groupId=t.id,this._groupName=t.name().value(),this._lineToolsIds=i.map((e=>e.id()))}redo(){const e=(0,s.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId)),t=this._lineToolsIds.map((e=>this._model.dataSourceForId(e))).filter(r.notNull);e.excludeLineTools(t),0===e.lineTools().length&&this._model.lineToolsGroupModel().removeGroup(e)}undo(){const e=this._lineToolsIds.map((e=>this._model.dataSourceForId(e))),t=this._model.lineToolsGroupModel().groupForId(this._groupId);null!==t?t.addLineTools(e):this._model.lineToolsGroupModel().createGroup(e,this._groupName,this._groupId)}}},72270:(e,t,i)=>{"use strict";i.d(t,{UndoCommand:()=>o});var s=i(95804);class o{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")}}},64876:(e,t,i)=>{"use strict";i.d(t,{createVisibilityController:()=>d});var s,o=i(11542),n=i(32563),r=i(41072),a=i(1765);!function(e){e.AlwaysOn="alwaysOn",e.VisibleOnMouseOver="visibleOnMouseOver",e.AlwaysOff="alwaysOff"}(s||(s={}));const l="visibleOnMouseOver";function c(e){return"alwaysOn"===e||"alwaysOff"===e?e:l}var h;function d(e,t){let s,h;function d(){if(!s){s=(0,r.createPrimitiveProperty)();let i=a.getValue(e);void 0===i&&void 0!==t&&(i=a.getValue(t)),s.setValue(c(i)),s.subscribe(s,(t=>{a.setValue(e,c(t.value()))}))}return s}return{property:d,availableValues:function(){return[{id:"visibleOnMouseOver",value:"visibleOnMouseOver",title:n.mobiletouch?o.t(null,void 0,i(58302)):o.t(null,void 0,i(10309))},{id:"alwaysOn",value:"alwaysOn",
title:o.t(null,void 0,i(36299))},{id:"alwaysOff",value:"alwaysOff",title:o.t(null,void 0,i(40452))}]},actualBehavior:function(){if(!h){h=(0,r.createPrimitiveProperty)();const e=d(),t=()=>{const t=function(e){switch(e){case"alwaysOn":return"alwaysOn";case"alwaysOff":return"alwaysOff";case"visibleOnMouseOver":return n.mobiletouch?"visibleOnTapSelection":"visibleOnMouseOver";default:throw new Error(`Unknown visibility type: ${e}`)}}(e.value());h&&h.setValue(t)};e.subscribe(h,t),t()}return h},restoreDefaultValue:function(){d().setValue(l),a.remove(e)}}}!function(e){e.AlwaysOn="alwaysOn",e.VisibleOnMouseOver="visibleOnMouseOver",e.VisibleOnTapSelection="visibleOnTapSelection",e.AlwaysOff="alwaysOff"}(h||(h={}))},40153:(e,t,i)=>{"use strict";i.d(t,{withWeekdayProperty:()=>a});var s=i(1765),o=i(41072);const n="date_format_with_weekday";function r(){return s.getBool(n,!0)}const a=(0,o.createPrimitiveProperty)(r());a.subscribe(null,(()=>s.setValue(n,a.value()))),s.onSync.subscribe(null,(()=>a.setValue(r())))},61710:(e,t,i)=>{"use strict";i.d(t,{moveAfterSource:()=>B,moveBeforeSource:()=>V,newLineToolZOrder:()=>P,newStudyZOrder:()=>x,prepareZOrderFixIfRequired:()=>R,reorderDataSourcesStateZOrder:()=>w});var s,o=i(68192),n=i(50151),r=i(26610),a=i(2088),l=i(6652),c=i(29447),h=i(12217);function d(e){return(0,r.isLineTool)(e)&&!e.isSpeciallyZOrderedSource()}function u(e){return(0,a.isStudy)(e)&&!e.isSpeciallyZOrderedSource()||(0,a.isStudyStub)(e)}function _(e,t){return e.zorder-t.zorder}function p(e,t){(0,c.isMainSeriesState)(e)?e.zorder=0:e.zorder=t}function m(e,t){e.setZorder(t)}function g(e){return e.zorder()}function f(e){return Math.round(1e3*e)/1e3}function y(e,t){const i=Math.max(e,t),s=Math.min(e,t);return Math.max(0,Math.ceil(i)-Math.floor(s)-1)}function v(e,t,i){let s=0;const o=function(e,t){const i=1e3;return Math.abs(t*i-e*i)/i}(t,e);var n;return o>i?(e=Math.trunc(e),s=Math.floor(o/(i+1))):(n=o/(i+1),s=Math.floor(1e3*n)/1e3),{startZOrder:e,zOrderStep:s}}function S(e,t,i,s){let o=e.length,n=t;for(let t=e.length-1;t>=-1;t--)if(-1===t||s(e[t])){const s=t;let r=I(n);if(o-1===s)s>=0&&i(e[s],r);else{const t=y(o,s);let a=0;for(;0===a;){const e=v(n,r,t);n=e.startZOrder,a=e.zOrderStep,0===a&&(r-=1e4,0===r&&(r-=1e4))}let l=o-1;for(;l>s;){const t=f(n-a);i(e[l],t),n=t,l--}s>=0&&i(e[s],r)}n=r,o=s}}function b(e,t,i,s){let o=-1,n=t;for(let t=0;t<=e.length;t++)if(t===e.length||s(e[t])){const s=t;let r=M(n);if(o+1===s)s<=e.length-1&&i(e[s],r);else{const t=y(o,s);let a=0;for(;0===a;){const e=v(n,r,t);n=e.startZOrder,a=e.zOrderStep,0===a&&(r+=1e4,0===r&&(r+=1e4))}let l=o+1;for(;l<=s-1;){const t=f(n+a);i(e[l],t),n=t,l++}s<=e.length-1&&i(e[s],r)}n=r,o=s}}function w(e){!function(e,t,i,s,o,n){let r=null;const a=[];for(const o of e)t(o)?(a.push(o),r=o):(i(o)||s(o))&&a.push(o);a.sort(n),null!==r&&o(r,0);const l=null===r?-1:a.indexOf(r);-1!==l?(S(a.slice(0,l),0,o,i),b(a.slice(l+1),0,o,i)):b(a,0,o,i)}(e,c.isMainSeriesState,c.isStudyState,c.isLineToolState,p,_)}function C(e,t){const i=Math.floor(e/1e4);let s=t.get(i);return void 0===s&&(s=[],
t.set(i,s)),s}function T(e,t,i,s,o,n){let r=-1/0,a=1/0,l=-1/0,c=0;const h=new Map;for(let s=0;s<e.length;++s){const n=e[s],d=o(n);t(n)?(r=Math.max(r,d),C(d,h).push(n)):i(n)&&(d<0&&(a=Math.min(a,d),l=Math.max(l,d)),c=Math.max(c,d))}if(n){const e=Math.max(c,r),t=v(e,M(e),1);return f(t.startZOrder+t.zOrderStep)}if(r===-1/0){const e=a===1/0?0:a,t=v(I(e),e,1);return f(t.startZOrder+t.zOrderStep)}const d=v(r,M(r),1);if(0!==d.zOrderStep)return f(d.startZOrder+d.zOrderStep);const u=C(r,h).sort(((e,t)=>o(e)-o(t)));let _=I(o(u[0]));const p=M(_),m=v(_,p,u.length+1).zOrderStep;return 0!==m?(u.forEach((e=>{const t=f(_+m);s(e,t),_=t})),f(_+m)):f(p+5e3)}function P(e,t){return T(e,d,u,m,g,t)}function x(e){let t=-1e4;for(const i of e)u(i)&&(t=Math.min(t,i.zorder()-1e4));return 0===t?-1e4:t}function M(e){const t=1e4*Math.ceil(e/1e4);return t===e?t+1e4:t}function I(e){const t=1e4*Math.floor(e/1e4);return t===e?t-1e4:t}function A(e,t,i,s,o,n,r){const a=t.length,{newItems:l,movedItemsStartIndex:c}=i>0?(0,h.moveAfter)(e,t,i-1):(0,h.moveBefore)(e,t,0);let d=!1;for(let t=c;t<c+a;t++)if(l[t]!==e[t]){d=!0;break}if(!d)return;if(s(t[0]))return void(i<e.length&&r(e[i])<0?b(l.slice(c+1),0,n,o):S(l.slice(0,c),0,n,o));t.some((e=>o(e)))?function(e,t,i,s,o,n){let r,a,l=-1,c=-1;0===i?(c=L(e,i+t,s),a=n(e[c])):i+t===e.length?(l=k(e,i-1,s),r=n(e[l])):(l=k(e,i-1,s),r=n(e[l]),c=L(e,i+t,s),a=n(e[c]));if((void 0===r||r<0)&&void 0!==a&&a<=0)S(e.slice(0,c),a,o,s);else if((void 0===a||a>0)&&void 0!==r&&r>=0)b(e.slice(l+1),r,o,s);else{i+t<e.length-i?S(e.slice(0,i+t),n(e[i+t]),o,s):b(e.slice(i),n(e[i-1]),o,s)}}(l,a,c,o,n,r):function(e,t,i,s,o,n,r){let a,l;0===i?l=r(e[i+t]):i+t===e.length?a=r(e[i-1]):(a=r(e[i-1]),l=r(e[i+t]));let c=0,h=0,d=0,u=0,_=0;if((void 0===a||a<0)&&void 0!==l&&l<=0){c=l;const e=v(c,void 0!==a?a:I(l),t);c=e.startZOrder,_=e.zOrderStep,d=i+t-1,u=d-t,h=-1}else if((void 0===l||l>0)&&void 0!==a&&a>=0){c=a;const e=v(c,void 0!==l?l:M(a),t);c=e.startZOrder,_=e.zOrderStep,d=i,u=d+t,h=1}if(0!==_)for(;d!==u;){const t=f(c+h*_);n(e[d],t),c=t,d+=h}else{const t=e.findIndex((e=>o(e)));-1!==t?(S(e.slice(0,t),0,n,s),b(e.slice(t+1),0,n,s)):b(e,0,n,s)}}(l,a,c,o,s,n,r)}function L(e,t,i){for(;t<e.length&&i(e[t]);)t++;return Math.min(t,e.length-1)}function k(e,t,i){for(;t>=0&&i(e[t]);)t--;return Math.max(0,t)}function E(e,t,i,s,o,n,r){const a=e.indexOf(i)+1;A(e,t,a,s,o,n,r)}function D(e,t,i,s,o,n,r){const a=e.indexOf(i);A(e,t,a,s,o,n,r)}function B(e,t,i){E(e,t,i,l.isSeries,u,m,g)}function V(e,t,i){D(e,t,i,l.isSeries,u,m,g)}function R(e){const t=function(e){const t=new Map;for(const i of e.panes)for(const e of i.lines)t.set(e.id,{pane:i,line:e});return t}(e),i=new Map;for(const s of e.groups){const e=new Set(s.tools),r=s.tools.map((e=>(0,n.ensureDefined)(t.get(e)))).map((e=>e.line.zOrder)),a=Math.max(...r),l=(0,n.ensureDefined)(t.get(s.tools[0])).pane,c=(0,o.default)(l.lines,(t=>t.zOrder<a&&!e.has(t.id)))?.zOrder??-1/0,h=s.tools.filter((e=>(0,n.ensureDefined)(t.get(e)).line.zOrder<c)).reverse();for(let e=0;e<h.length;e++){const s=c+e+1;i.set(h[e],s);const o=(0,
n.ensureDefined)(t.get(h[e]));o.line.zOrder=s;let r=-1,a=-1;for(let e=0;e<l.lines.length;e++){const t=l.lines[e];if(t.id===o.line.id&&(r=e),t.zOrder>s&&(a=e),r>=0&&a>=0)break}l.lines.splice(-1===a?1/0:a,0,o.line),l.lines.splice(r,1)}}return i}!function(e){e[e.MainSeriesZOrder=0]="MainSeriesZOrder",e[e.StudyBaseZOrder=1e4]="StudyBaseZOrder",e[e.MaxFractionLength=3]="MaxFractionLength"}(s||(s={}))},48961:(e,t,i)=>{"use strict";i.d(t,{getSymbolSearchCompleteOverrideFunction:()=>n,setSymbolSearchCompleteOverrideFunction:()=>o});let s=(e,t)=>Promise.resolve({symbol:e,name:t?.symbol??e});function o(e){s=e}function n(){return s}},19844:(e,t,i)=>{"use strict";i.d(t,{StudyMetaInfo:()=>S,getStudyIdWithVersion:()=>v});var s=i(83873),o=i(90054),n=i(87465),r=i(9343),a=i(18113),l=i(4359),c=i(69422),h=i(60973),d=i(44862);const u=(0,r.getLogger)("Chart.Study.MetaInfo"),_=new Set(["CorrelationCoefficient@tv-basicstudies","Correlation - Log@tv-basicstudies-1"]),p=new Set([]),m=new Set(["line","shapes","chars","arrows","alertcondition"]),g=new Map([["AnchoredVWAP@tv-basicstudies","linetoolanchoredvwap"],["RegressionTrend@tv-basicstudies","linetoolregressiontrend"],["VbPAnchored@tv-basicstudies","linetoolanchoredvp"]]),f=/^([^\$]+)\$\d+$/,y=["bool","color","time","text_area"];function v(e){return S.cutDollarHash(e.id)+"-"+e.version}class S{constructor(e,t=!1){(0,n.merge)(this,{palettes:{},inputs:[],plots:[],graphics:{},defaults:{}}),(0,n.merge)(this,e);const i=e.fullId||e.id;(0,n.merge)(this,S.parseIdString(i)),this._updateInputDisplayDefaults(),this.useVersionFromMetaInfo=t}defaultInputs(){return this.inputs.map((e=>e.defval)).filter(n.isExistent)}state(){const e={};for(const[t,i]of Object.entries(this))"useVersionFromMetaInfo"!==t&&this.hasOwnProperty(t)&&(e[t]=(0,o.default)(i),"id"===t&&(e[t]+="-"+this.version));return e}symbolInputId(){return this.inputs.find((e=>"symbol"===e.type))?.id||null}createDefaults(){if(this.defaults){const e=(0,n.clone)(this.defaults);e.precision="default";const t=S.getStudyPropertyRootName(this);(0,h.createDefaults)(t,e)}}removeDefaults(){(0,h.removeDefaults)(S.getStudyPropertyRootName(this))}isPlotForceOverlay(e){const t=this.styles?.[e],i=this.plots.find((t=>t.id===e));return!!t?.forceOverlay||i&&(0,l.isOhlcPlot)(i)&&this.ohlcPlots?.[i.target]?.forceOverlay||!!this.ohlcPlots?.[e]?.forceOverlay}hasForceOverlayPlots(){return this.plots.some((e=>this.isPlotForceOverlay(e.id)))||Object.values(this.ohlcPlots??{}).some((e=>!!e?.forceOverlay))}static getSourceIdsByInputs(e,t){if(!Array.isArray(e)||!t)return[];const i=[];for(const o of e)if(S.isSourceInput(o)&&(0,s.default)(t[o.id])){const e=t[o.id];e.includes("$")&&i.push(e.split("$")[0])}return i}static isSourceInput(e){return Boolean(e.id&&(("source"===e.id||"src"===e.id)&&("text"===e.type||"source"===e.type)||"source"===e.type))}static getSourceInputIds(e){const t=[];for(const i of e.inputs)S.isSourceInput(i)&&t.push(i.id);return t}static setChildStudyMetaInfoPropertiesSourceId(e,t,i){for(const s of e.inputs){if(!S.isSourceInput(s))continue
;const e=i.childs().inputs&&i.childs().inputs.childs()[s.id];if(e){const i=e.value(),s=f.exec(i);if(2===s?.length){if("{pid}"===s[1]){const s=i.replace(/^[^\$]+/,t);e.setValue(s)}}}}}static canBeChild(e){if((0,s.default)(e))return!0;if(!e)return!1;if(e.extra&&!S.isAllowedSourceInputsCount(e.extra.sourceInputsCount)||!0===e.canNotBeChild||!1===e.canBeChild||_.has(e.id))return!1;let t=0;for(const i of e.inputs)S.isSourceInput(i)&&(t+=1);return S.isAllowedSourceInputsCount(t)}static isAllowedSourceInputsCount(e){return 1===e}static canHaveChildren(e){if(e){if(e.isTVScriptStrategy||e.TVScriptSourceCode&&isStrategy(e.TVScriptSourceCode))return!1;if(e.id&&!p.has(e.id)&&Array.isArray(e.plots))for(const t of e.plots)if(m.has(t.type))return!0}return!1}static getChildSourceInputTitles(e,t,i){const s={};if(t.plots&&t.plots.length&&e.options&&e.options.length)for(const o of e.options){const e=o?+o.split("$")[1]:NaN,n=isFinite(e)&&t.plots[e];n&&m.has(n.type)&&(s[o]=t.styles&&t.styles[n.id]&&t.styles[n.id]?.title||n.id,i&&(s[o]=i+": "+s[o]))}return s}static canPlotBeSourceOfChildStudy(e){return m.has(e)}static getStudyPropertyRootName(e){const t=g.get(e.id);if(void 0!==t)return t;let i="study_"+e.id;return e.pine&&e.pine.version&&(i+="_"+e.pine.version.replace(".","_")),i}static getStudyPropertyRootNameById(e){const t=g.get(e);return void 0!==t?t:"study_"+e}static isScriptStrategy(e){return!1}static isReplayStrategy(e){return"ReplayStrategy@tv-scripting"===e.id}static parseIdString(e){return function(e){const t={};if(-1===e.indexOf("@"))t.shortId=e,t.packageId="tv-basicstudies",t.id=e+"@"+t.packageId,t.version=1;else{const i=e.split("@");t.shortId=i[0];const s=i[1].split("-");if(3===s.length)t.packageId=s.slice(0,2).join("-"),t.id=t.shortId+"@"+t.packageId,t.version=parseInt(s[2]);else if(1===s.length&&"decisionbar"===s[0])t.packageId="les-"+s[0],t.id=t.shortId+"@"+t.packageId,t.version=1;else{if(1!==s.length)throw new Error("unexpected study id:"+e);t.packageId="tv-"+s[0],t.id=t.shortId+"@"+t.packageId,t.version=1}}if(t.fullId=t.id+"-"+t.version,"tv-scripting"===t.packageId){const e=t.shortId;if(0===e.indexOf("Script$")||0===e.indexOf("StrategyScript$")){const i=e.indexOf("_");t.productId=i>=0?e.substring(0,i):t.packageId}else t.productId=t.packageId}else t.productId=t.packageId;return t}(e)}static versionOf(e){const t="_metainfoVersion"in e&&(0,n.isNumber)(e._metainfoVersion)?e._metainfoVersion:0;return t<0&&u.logError("Metainfo format version cannot be negative: "+t),t}static getPackageName(e){const t=/^[^@]+@([^-]+-[^-]+)/.exec(e||"");t?.[1]||(0,a.getPersistentLogger)()?.addPersistentLogEntry(`getStudyPackageName: study id ${e} with stack ${(new Error).stack}`,r.LOGLEVEL.INFO,"chart.StudyMetaInfo");const[,i="tv-basicstudies"]=t||[];return i}static cutDollarHash(e){const t=e.indexOf("$");if(-1===t)return e;const i=e.indexOf("@"),s=i>=0?e.substring(i):"";return e.substring(0,t)+s}static hasPubSuffix(e){return/^PUB;.+$/.test(e)}static hasStdSuffix(e){return/^STD;.+$/.test(e)}static isStandardPine(e){
return/^(Strategy)?Script\$STD;.*@tv-scripting$/.test(e)}static getStudyIdWithLatestVersion(e,t){const i=S.cutDollarHash(e.id);let s=i;return i.indexOf("Portfolio@tv-scripting")>=0?s+=t?"!":"":"ReplayStrategy@tv-scripting"===s?s+="-581!":i.indexOf("@tv-scripting")>=0?s+="-101!":i.endsWith("CP@tv-basicstudies")?s+="-"+Math.min(e.version,207):i.endsWith("CP@tv-chartpatterns")?s+="-"+Math.min(e.version,9):i.endsWith("@tv-volumebyprice")||t?s+="-"+e.version+"!":s+="-"+e.version,s}static overrideDefaults(e){0!==e.length&&(0,d.applyOverridesToStudyDefaults)(this.savedStudiesOverrides,e,(e=>window.TradingView.defaultProperties[S.getStudyPropertyRootName(e)]||null))}static mergeDefaultsOverrides(e){(0,n.merge)(this.savedStudiesOverrides,e)}static findStudyMetaInfoByDescription(e,t){if(e){const i=t.toLowerCase();for(const t of e)if(t.description.toLowerCase()===i)return t;throw new Error("unexpected study id:"+t)}throw new Error("There is no studies metainfo")}_updateInputDisplayDefaults(){this.inputs.filter((e=>void 0===e.display)).forEach((e=>{y.includes(e.type)?e.display=c.InputDisplayFlags.None:e.display=c.InputDisplayFlags.All}))}}S.savedStudiesOverrides={},window.TradingView.StudyMetaInfo=S},94078:(e,t,i)=>{"use strict";window.TradingView=window.TradingView||{},i(32563).setClasses(),i(57298),i(56186).install(),i(49483),i(40167),i(11417),i(29063),i(1765),i(68659)},37150:(e,t,i)=>{"use strict";var s=i(81251),o=i(20057),n=i(50151),r=i(52959),a=i(11542),l=(i(18092),i(32517),i(5992),i(87457),i(34907),i(37103));const c=(0,r.getChartingLibraryGlobalContext)();JSON.parse(c.urlParams.disabledFeatures).forEach((e=>{l.setEnabled(e,!1)})),JSON.parse(c.urlParams.enabledFeatures).forEach((e=>{l.setEnabled(e,!0)}));i(94078);var h=i(60973),d=(i(48480),i(1765));const u=(0,r.getChartingLibraryGlobalContext)(),_=(0,r.getChartingLibraryOwner)();u.__settingsOverrides=_.settingsOverrides||{};const p=_.settingsAdapter;null!=p?(d.setSettingsAdapter(p),d.sync()):l.enabled("use_localstorage_for_settings")&&d.sync();var m=i(84617);const g=(0,r.getChartingLibraryGlobalContext)();g.urlParams.customFontFamily&&(0,m.setChartFontFamily)(g.urlParams.customFontFamily);var f=i(38881);class y extends f.ChunkLoader{_startLoading(){return Promise.all([i.e(5700),i.e(8185),i.e(1681),i.e(3439),i.e(8933),i.e(6032),i.e(3672),i.e(3359),i.e(4587),i.e(8260),i.e(1979),i.e(7780),i.e(4495),i.e(7827),i.e(844),i.e(9836),i.e(683),i.e(6697),i.e(1166),i.e(3946),i.e(6956),i.e(3014),i.e(4240),i.e(2227),i.e(8402),i.e(3179),i.e(6193),i.e(917),i.e(5516)]).then(i.bind(i,92024)).then((e=>e.getRestrictedToolSet()))}}var v,S,b=i(9753),w=i(72877);function C(e=[],t=[]){const i=document.createElement("div"),s=document.createElement("div");return i.appendChild(s),i.classList.add(w.container),s.classList.add(w.inner),e.forEach((e=>{i.classList.add(w[e])})),t.forEach((e=>{i.classList.add(w[e])})),i}!function(e){e.Top="border-top",e.Right="border-right",e.Bottom="border-bottom",e.Left="border-left"}(v||(v={})),function(e){e.TopLeft="top-left-radius",e.TopRight="top-right-radius",
e.BottomLeft="bottom-left-radius",e.BottomRight="bottom-right-radius"}(S||(S={}));class T extends f.ChunkLoader{constructor(e,t){super(),this._toolsBootloader=e,this._headerProps=t,this._headerProps.resizerBridge.negotiateHeight(b.HEADER_TOOLBAR_HEIGHT_EXPANDED),this._headerProps.resizerBridge.container.value().appendChild(C())}_startLoading(){return Promise.all([this._toolsBootloader.load(),this._loadHeaderToolbar()]).then((([e,t])=>new t(this._headerProps.resizerBridge.container.value(),{...this._headerProps,tools:e})))}_loadHeaderToolbar(){return Promise.all([i.e(8370),i.e(9297),i.e(2227),i.e(3005)]).then(i.bind(i,38254)).then((e=>e.HeaderToolbarRenderer))}}var P=i(55308),x=i(66593);class M extends f.ChunkLoader{constructor(e){super(),this._opts=e,P.isDrawingToolbarVisible.value()&&(this._opts.resizerBridge.negotiateWidth(x.TOOLBAR_WIDTH_EXPANDED),this._opts.resizerBridge.container.value().appendChild(C()))}_startLoading(){return Promise.all([i.e(3721),i.e(8185),i.e(1681),i.e(3439),i.e(8933),i.e(6032),i.e(3359),i.e(4587),i.e(8260),i.e(4495),i.e(7827),i.e(9323),i.e(844),i.e(6697),i.e(1166),i.e(6178),i.e(9468),i.e(2227),i.e(4931),i.e(3179),i.e(769),i.e(1890),i.e(1727),i.e(2878)]).then(i.bind(i,7314)).then((e=>new e.DrawingToolbarRenderer(this._opts.resizerBridge.container.value(),{...this._opts})))}}var I=i(14411),A=i(32563),L=i(22489),k=i(45345);var E=i(34840),D=i(26709),B=i(3343);function V(e){if("number"==typeof e)return e;switch(e.toLowerCase()){case"ctrl":return B.Modifiers.Control;case"shift":return B.Modifiers.Shift;case"alt":return B.Modifiers.Alt;default:return e.length>1&&console.warn(`Unsupported key name: "${e}", Only single-letter key names are supported.`),console.warn("Starting from v31, string key names are no longer supported. Please use key codes instead."),e.toUpperCase().charCodeAt(0)}}function R(e){let t=0;for(let i=0;i<e.length;i++)t|=V(e[i]);return t}var N=i(71846),O=i(22613),F=i(70347);function W(e,t){l.enabled("saveload_requires_authentication")?(0,F.runOrSigninWithFeature)(e,{...t,feature:"savedCharts"}):e()}i(40167);l.enabled("atsv2s");var H;!function(e){e[e.OneSecond=1e3]="OneSecond",e[e.OneMinute=6e4]="OneMinute",e[e.TwoMinutes=12e4]="TwoMinutes",e[e.ThreeMinutes=18e4]="ThreeMinutes",e[e.FiveMinutes=3e5]="FiveMinutes",e[e.SevenMinutes=42e4]="SevenMinutes",e[e.TenMinutes=6e5]="TenMinutes",e[e.TwentyMinutes=12e5]="TwentyMinutes",e[e.ThirtyMinutes=18e5]="ThirtyMinutes",e[e.Year=31536e6]="Year"}(H||(H={}));var z=i(81593);async function U(){return!0}var j=i(3615);const G=l.enabled("confirm_overwrite_if_chart_layout_with_name_exists");class q{constructor(e,t,i){this._visibility=new O.WatchedValue(!1),this._chartWidgetCollection=e,this._doSave=t,this._doLoad=i}hide(){this._hide?.(),this._visibility.setValue(!1)}visible(){return this._visibility.readonly()}_showDialog(e,t,s,o){return(0,j.showRename)({title:this._dialogTitle(),text:this._dialogText(),maxLength:64,emojiPicker:!0,initValue:e,onRename:async e=>{if(!G)return void this._actionHandler(e,t,s,o)
;const{newValue:n,dialogClose:r}=e,l=(await this._doLoad()).find((e=>e.name===n));r(),void 0!==l?this._hide=await(0,j.showConfirm)({title:a.t(null,void 0,i(7219)),text:a.t(null,void 0,i(67635)),onConfirm:({dialogClose:e})=>{e(),this._doOverwriteExistingLayout(l.id,n,t,s,o)},onCancel:({dialogClose:e})=>{e(),this._showDialog(n,t,s,o)}}):this._actionHandler({newValue:n,dialogClose:r},t,s,o)},onClose:()=>this._visibility.setValue(!1)})}_doSaveCurrentLayout(e,t,i,s){const o=this._chartWidgetCollection.metaInfo.name.value();this._chartWidgetCollection.metaInfo.name.setValue(e),this._doSave(t,i,(()=>{this._chartWidgetCollection.metaInfo.name.setValue(o),s?.()}))}_doOverwriteExistingLayout(e,t,i,s,o){const n=this._chartWidgetCollection.metaInfo.name.value();this._chartWidgetCollection.metaInfo.id.setValue(e),this._chartWidgetCollection.metaInfo.name.setValue(t),this._doSave(i,s,(()=>{this._chartWidgetCollection.metaInfo.name.setValue(n),o?.()}))}}class $ extends q{cloneChart(){this._cloneChart().then((()=>this._visibility.setValue(!0)))}show(){W((()=>this.cloneChart()),{source:"Clone chart"})}_dialogTitle(){return a.t(null,void 0,i(66134))}_dialogText(){return a.t(null,void 0,i(9541))+":"}_actionHandler({newValue:e,dialogClose:t}){l.enabled("saveload_storage_customization")&&this._doCloneCurrentLayout(e),t()}async _cloneChart(){let e;try{e=await U()}catch{return void showErrorDialog({content:a.t(null,void 0,i(73013))})}e&&(this._hide=await this._showDialog(this._getInitialRenameDialogInput()))}_doCloneCurrentLayout(e){const t=this._chartWidgetCollection.metaInfo.name.value();this._chartWidgetCollection.metaInfo.uid.deleteValue(),this._chartWidgetCollection.metaInfo.id.setValue(null),this._chartWidgetCollection.metaInfo.name.setValue(e),this._doSave(void 0,void 0,(()=>{this._chartWidgetCollection.metaInfo.name.setValue(t)}))}_getInitialRenameDialogInput(){return a.t(null,{context:"ex: AAPL chart copy"},i(97559)).format({title:this._chartWidgetCollection.metaInfo.name.value()})}}class K extends q{show(e,t,i){const s="function"==typeof e?e:void 0;this._saveNewChart(s,t,i).then((()=>this._visibility.setValue(!0)))}_dialogTitle(){return a.t(null,void 0,i(43047))}_dialogText(){return a.t(null,void 0,i(9541))+":"}_actionHandler({newValue:e,dialogClose:t},i,s,o){this._doSaveCurrentLayout(e,i,s,o),t()}async _saveNewChart(e,t,s){let o;try{o=await U()}catch{return void showErrorDialog({content:a.t(null,void 0,i(73013))})}const n=this._chartWidgetCollection.metaInfo.name.value();this._hide=await this._showDialog(n,e,t,s)}}class Y extends q{show(){W((()=>this._show()),{source:"Rename chart"})}_dialogTitle(){return a.t(null,void 0,i(22584))}_dialogText(){return a.t(null,void 0,i(9541))+":"}_actionHandler({newValue:e,dialogClose:t}){this._doSaveCurrentLayout(e),t()}async _show(){await this._renameChart(),this._visibility.setValue(!0)}async _renameChart(){const e=this._chartWidgetCollection.metaInfo.name.value();this._hide=await this._showDialog(e)}}class Z{constructor(e,t,i){if(this._autosaveTimer=null,
this._watchedAutoSaveEnabled=new O.WatchedValue,this._toggleAutoSaveEnabledHandler=this._toggleAutoSaveEnabled.bind(this),this._doSave=(e,t,i,s)=>{void 0!==e&&e();const o=this._chartChangesWatcher.changes();this._chartSaver.saveChartSilently((e=>{var i;e&&e.uid===this.layoutId()&&(i=e.uid,"/chart/"===location.pathname&&(location.href="/chart/"+i)),void 0!==t&&t(e)}),(()=>{void 0!==i&&i()}),{autoSave:Boolean(s),changes:o})},this._doLoad=()=>z.backend.getCharts(),this._chartWidgetCollection=e,this._chartSaver=t,this._createController=new K(e,this._doSave,this._doLoad),this._renameController=new Y(e,this._doSave,this._doLoad),this._saveAsController=new $(e,this._doSave,this._doLoad),this._chartChangesWatcher=i,e.saveKeysPressed().subscribe(this,this.saveChartOrShowTitleDialog),this._chartChangesWatcher.getOnChange().subscribe(this,this._onStateChanged),l.enabled("saveload_separate_drawings_storage")){const e=!0;e&&this._enableAutoSave(),this._watchedAutoSaveEnabled.setValue(e),this._watchedAutoSaveEnabled.subscribe(this._toggleAutoSaveEnabledHandler),this._autoSaveEnabledSetting?.getOnChange().subscribe(this,this._autoSaveEnabledSettingHandler)}}autoSaveEnabled(){return this._watchedAutoSaveEnabled}destroy(){l.enabled("saveload_separate_drawings_storage")&&(this._watchedAutoSaveEnabled.unsubscribe(),delete this._watchedAutoSaveEnabled,this._autoSaveEnabledSetting?.destroy(),delete this._autoSaveEnabledSetting)}getCreateController(){return this._createController}getRenameController(){return this._renameController}getSaveAsController(){return this._saveAsController}cloneChart(){this._saveAsController.cloneChart()}createEmptyChart(){this._createEmptyController?.show()}saveChartAs(){this._saveAsController.show()}renameChart(){this._renameController.show()}saveNewChart(e,t,i){this._createController.show(e,t,i)}saveExistentChart(e,t,i){this._doSave(e,t,i)}changes(){return this._chartChangesWatcher.changes()}hasChanges(){return 0!==this._chartChangesWatcher.changes()}hasChangesWV(){return this._chartChangesWatcher.hasChangesWV()}getOnChanges(){return this._chartChangesWatcher.getOnChange()}saveChartOrShowTitleDialog(e,t,i){const s=window.saver.isSaveInProcess(),o=this._chartChangesWatcher.hasChanges(),n=!!this.layoutId();window.is_authenticated&&(s||!o&&n)||W((()=>{null!=this._chartWidgetCollection.metaInfo.id.value()?this.saveExistentChart(e,t,i):this._chartWidgetCollection.readOnly()?this.cloneChart():this.saveNewChart(e,t,i)}),{source:"Save chart",sourceMeta:"Chart"})}saveToJSON(e){return this._chartSaver.saveToJSON(e)}saveChartSilently(e,t,i){this._chartSaver.saveChartSilently(e,t,i)}setAutoSaveEnabled(e){window.is_authenticated&&window.saver.isSaveInProcess()||W((()=>{this._watchedAutoSaveEnabled.setValue(e)}),{source:"AutoSave chart"})}saveChartLineTools(e,t,i,s){return this._chartSaver.saveChartLineTools(e,t,i,s)}layoutId(){return this._chartWidgetCollection.metaInfo.uid.value()}chartSaved(){return this._chartSaver.chartSaved()}_autoSaveEnabledSettingHandler(e){0}_toggleAutoSaveEnabled(e){0}_enableAutoSave(){0}
_disableAutoSave(){0}_onStateChanged(e){e?this._startAutosave():this._stopAutosave()}_startAutosave(){l.enabled("charts_auto_save")&&null===this._autosaveTimer&&(this._autosaveTimer=setTimeout((()=>{this._autosaveTimer=null,this._chartWidgetCollection.metaInfo.id.value()&&this._doSave(void 0,void 0,void 0,!0)}),6e4))}_stopAutosave(){null!==this._autosaveTimer&&(clearInterval(this._autosaveTimer),this._autosaveTimer=null)}}var X=i(38414),J=i(95406),Q=i(21097),ee=i(76422),te=i(67763);class ie extends te.CommonJsonStoreService{constructor(e,t){super(e,t,"FAVORITE_CHARTS_CHANGED","loadChartDialog.favorites",{})}}function se(){return!(l.enabled("saveload_requires_authentication")&&!window.is_authenticated)}class oe extends X.DialogRenderer{constructor(e=null){super(),this._chartWidgetCollection=null,this._promise=null,this._dialog=null,this._onLoginStateChange=()=>{se()||this._setState({chartList:[],favorites:{},recents:[]})},this._onActiveChartNameChange=e=>{const{chartList:t}=this._state.value(),i=this._chartWidgetCollection;if(!i)return;const s=[];let o;t.forEach((t=>{if(t.id===i.metaInfo.id.value())return o=t,void s.push({...t,name:e});s.push(t)})),o&&this._setState({chartList:s})},this._subscribe=e=>{this._setVisibility(e)},this._getChartEntry=e=>({id:e.id,url:e.url,name:e.name,symbol:e.short_symbol,interval:e.interval,toolsCount:0,modified:e.modified_iso,favorite:void 0,active:()=>this._isActiveChart(e.id),openAction:(t,i)=>this.loadChart(e,t,i),deleteAction:()=>this._deleteChart(e),favoriteAction:()=>this._handleFavorite(e)}),this._isActiveChart=e=>null!==this._chartWidgetCollection&&e===this._chartWidgetCollection.metaInfo.id.value(),this._deleteChart=e=>z.backend.removeChart(e.image_url).then((()=>{const{chartList:t,favorites:i}=this._state.value(),s=t.filter((t=>t.id!==e.id));if(this._favoriteChartsService){const t={...i};t[e.id]&&delete t[e.id],this._favoriteChartsService.set(t)}se()&&this._setState({chartList:s}),this._isActiveChart(e.id)&&(l.enabled("saveload_storage_customization")||isSymphonyEmbed()?null!==this._chartWidgetCollection&&this._chartWidgetCollection.clearChartMetaInfo():location.href="/chart/"+location.search)})),this._chartWidgetCollection=e,this._favoriteChartsService=new ie(Q.TVXWindowEvents,d);const t=this._favoriteChartsService?.get()||{};this._state=new O.WatchedValue({chartList:[],recents:[],favorites:t}),this._chartWidgetCollection?.metaInfo.name.subscribe(this._onActiveChartNameChange),window.loginStateChange.subscribe(null,this._onLoginStateChange)}showLoadDialog(){W(this._showLoadDialog.bind(this),{source:"Load chart",sourceMeta:"Chart"})}show(){this.showLoadDialog()}hide(){this._dialog?.hide(),this._dialog?.visible().unsubscribe(this._subscribe)}state(){return this._state.readonly()}refreshChartList(e){return(se()?z.backend.getCharts():Promise.resolve([])).then((t=>{if(!se())return;const i=t.map(this._getChartEntry);this._setState({chartList:i,favorites:this._initFavorites(i)}),void 0!==e&&e()}))}getRecentCharts(e){}async deleteAllFavorites(){return Promise.resolve()}
async loadChart(e,t,i){{const t=await z.backend.loadLayout(e);ee.emit("chart_load_requested",t.chartWidgetCollectionState)}}async loadChartByUrl(e,t,i){let s=this._state.value().chartList.find((t=>t.url===e));s||(await this.refreshChartList(),s=this._state.value().chartList.find((t=>t.url===e))),await(s?.openAction(t,i))}async _handleFavorite(e){const{favorites:t}=this._state.value(),i={...t};i[e.id]?delete i[e.id]:i[e.id]=!0,this._favoriteChartsService?.set(i),se()&&this._setState({favorites:i})}_showLoadDialog(){this.refreshChartList((()=>{const e=this._promise=Promise.all([i.e(5121),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(8933),i.e(2537),i.e(8894),i.e(1697),i.e(8260),i.e(1979),i.e(4495),i.e(7827),i.e(9970),i.e(683),i.e(1450),i.e(7463),i.e(4),i.e(2227),i.e(4931),i.e(9418),i.e(3179),i.e(917),i.e(5386),i.e(6864),i.e(5009)]).then(i.bind(i,3650)).then((t=>{this._promise===e&&(this._dialog&&(this._dialog.hide(),this._dialog.visible().unsubscribe(this._subscribe)),this._dialog=new t.LoadChartDialogRenderer({chartWidgetCollection:this._chartWidgetCollection,serviceState:this.state()}),this._dialog.visible().subscribe(this._subscribe),this._dialog.show())}))}))}_setState(e){this._state.setValue({...this._state.value(),...e})}async _changeFavoriteState(e,t,i){return Promise.resolve()}_initFavorites(e){if(this._favoriteChartsService)return this._favoriteChartsService.get();const t={};return e.filter((e=>e.favorite)).forEach((e=>{t[e.id]=!0})),t}}var ne=i(9343),re=(i(10892),i(51768)),ae=i(48096);const le=(0,ne.getLogger)("Platform.StudyTemplates"),ce=a.t(null,void 0,i(15096));class he{constructor(e){this._chartWidgetCollection=e.chartWidgetCollection,this._recentStudyTemplatesService=e.recentStudyTemplatesService,window.loginStateChange.subscribe(null,z.backend.invalidateStudyTemplatesList),this._list=new O.WatchedValue([]),this._onChange=new ae.Delegate,this._list.subscribe((()=>this._onChange.fire()))}findRecordByName(e){return this._list.value().find((t=>t.name===e))||null}showSaveAsDialog(e){const t=this._chartWidgetCollection.activeChartWidget.value().model();Promise.all([i.e(7336),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(1171),i.e(6032),i.e(3672),i.e(2537),i.e(8894),i.e(5743),i.e(3425),i.e(7780),i.e(4495),i.e(9487),i.e(9323),i.e(6052),i.e(159),i.e(683),i.e(6633),i.e(7519),i.e(2227),i.e(4931),i.e(9418),i.e(3179),i.e(769),i.e(5705),i.e(6631)]).then(i.bind(i,13657)).then((i=>{new i.StudyTemplateSaver({controller:t,onSave:(e,t)=>{t&&this._recentStudyTemplatesService?.add(t),this._list.setValue(e)}}).show(e)}))}applyTemplate(e){const t=this.findRecordByName(e);null!==t?window.runOrSignIn((async()=>{const{id:e,name:i,is_default:s}=t,o=this._chartWidgetCollection.activeChartWidget.value(),n=e=>{(0,re.trackEvent)("GUI","Load Study Template");const t=JSON.parse(e.content),s=t.symbol;t.interval,Boolean(s)&&o.model().mainSeries().symbolSameAsCurrent(s);o.model().applyStudyTemplate(t,i)}
;s&&"number"==typeof e?await z.backend.getStandardStudyTemplateById(e,n):await z.backend.getStudyTemplateById(e).then(n)}),{source:"Study templates apply"}):le.logNormal(`Template ${e} not found in cache`)}deleteStudyTemplate(e,t,i){const s=this.findRecordByName(e);null!==s?this._removeTemplate(s,t,i):le.logNormal(`Template ${e} not found in cache`)}list(){return this._list.value()}getOnChange(){return this._onChange}refreshStudyTemplateList(e){z.backend.getStudyTemplatesList().then((t=>{this._list.setValue(t),void 0!==e&&e()}))}invalidate(){z.backend.invalidateStudyTemplatesList()}_removeTemplate(e,t,i){window.runOrSignIn((()=>{(0,j.showConfirm)({text:ce.format({name:e.name}),onConfirm:({dialogClose:t})=>new Promise((s=>{z.backend.invalidateStudyTemplatesList(),z.backend.removeStudyTemplate(e.id).then((()=>{this.refreshStudyTemplateList((()=>{const o=this.list();this._list.setValue(o.filter((t=>t!==e))),this._recentStudyTemplatesService&&this._recentStudyTemplatesService.remove(e.id),s(),t(),i?.()}))}))}))},t)}),{source:"Study templates delete"})}}var de=i(29803),ue=i(26010),_e=i(35727);class pe{constructor(e,t){this._visibility=new O.WatchedValue(!1),this._dialogPromise=null,this._dialog=null,this._chartWidgetCollection=e,this._options=t}visible(){return this._visibility.readonly()}show(e,t,i){const s=Array.isArray(e)?e:[],o=Array.isArray(e)?void 0:e;null===this._dialog&&this._requestDialog(s??[],t,i,o),this._dialog?.open(s??[],this._options?.indicatorsPreloader?.getIndicatorPromises(),t,i,o)}hide(){this._dialog?.hide()}getDialog(){return this._dialog}resetAllPages(){this._dialog?.resetAllStudies()}_requestDialog(e,t,s,o){if(null===this._dialogPromise){let n;n=Promise.all([i.e(2346),i.e(8185),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(2537),i.e(1697),i.e(7833),i.e(8260),i.e(509),i.e(7463),i.e(3853),i.e(2227),i.e(9418),i.e(6864),i.e(6456)]).then(i.bind(i,86682)).then((e=>new e.IndicatorsLibraryContainer(this._chartWidgetCollection,this._options))),this._dialogPromise=n.then((i=>{this._dialog=i,this._dialog.visible().subscribe((e=>{this._visibility.setValue(e)})),this._dialog.open(e,this._options?.indicatorsPreloader?.getIndicatorPromises(),t,s,o)}))}return this._dialogPromise}}var me=i(88723),ge=i(39527),fe=i(4226),ye=i(18712),ve=i(23714),Se=i(61786),be=i(97363),we=i(3190),Ce=i(37236),Te=i(87453),Pe=i(10845);const xe=/^Etc\/GMT([+-])(\d{1,2}):?(\d\d)?$/,Me=new Map;function Ie(e){if(Me.has(e))return Me.get(e);const t=xe.test(e);return Me.set(e,t),t}const Ae=new Map;function Le(e){if(Ae.has(e))return Ae.get(e);const t=function(e){const t=e.match(xe);if(!t)return 0;const i="+"===t[1]?-1:1;return 60*(60*parseInt(t[2],10)+parseInt(t[3]||"0",10))*i}(e),i={time:[1924992e3+t],offset:[t]};return Ae.set(e,i),i}let ke=null;const Ee=new Map;class De{constructor(){this._customTimezones=new Map}addTimezones(e){e.forEach((e=>{const{id:t,...i}=e;this._addTimezone(t,i)})),this.updateChartTimezones()}listTimezoneIds(){return[...this._customTimezones.keys()]}listTimezones(){return[...this._customTimezones.entries()].map((([e,t])=>({
id:e,...t})))}getTimezoneInfo(e){if(!this.timezoneIsAvailable(e))throw new Error("Provided timezone alias is not within the list of supported timezones.");return(0,n.ensure)(this._customTimezones.get(e))}getAllTimezoneInfo(){return this.listTimezones()}getAliasTimezone(e){return this.getTimezoneInfo(e).alias}timezoneIsAvailable(e){return this._customTimezones.has(e)}updateChartTimezones(){(0,Pe.updateAvailableTimezones)(this.getAllTimezoneInfo())}getTimezoneData(e){if(Ee.has(e))return Ee.get(e);let t=null;if(Ie(e))t=Le(e);else if(this.timezoneIsAvailable(e)){const i=this.getAliasTimezone(e);Te.tzData[i]&&(t=Te.tzData[i]),!t&&Ie(i)&&(t=Le(i))}return t&&Ee.set(e,t),t}static instance(){return null===ke&&(ke=new De),ke}_addTimezone(e,t){try{if((0,n.ensure)(e,"Custom timezone ID"),(0,n.ensure)(t.alias,"Custom timezone alias"),(0,n.ensure)(t.title,"Custom timezone title"),(0,Pe.timezoneIsAvailable)(e)&&!this.timezoneIsAvailable(e))throw new Error("Custom timezone id already exists.");if(!(0,Pe.timezoneIsSupported)(t.alias)&&!Ie(t.alias))throw new Error("Custom timezone alias is not a supported timezone.");if(e.length<1)throw new Error("Custom timezone id is empty");if(t.title.length<1)throw new Error("Custom timezone title is empty");this._customTimezones.set(e,t)}catch(e){console.warn(`Unable to add custom timezone. ${e}`)}}}(0,Ce.setCustomTimezones)(De);var Be=i(91106);let Ve=null;var Re=i(46082);class Ne{constructor(e){this._alive=new O.WatchedValue,this._container=new O.WatchedValue,this._width=new O.WatchedValue,this._height=new O.WatchedValue,this._fullscreen=new O.WatchedValue,this._detachable=new O.WatchedValue,this._fullscreenable=new O.WatchedValue,this._visible=new O.WatchedValue,this._availWidth=new O.WatchedValue,this._availHeight=new O.WatchedValue,this._owner=new O.WatchedValue,this._ownersStack=[],this.owner=this._owner.readonly(),this._bridge={alive:this._alive.readonly(),container:this._container.readonly(),width:this._width.readonly(),height:this._height.readonly(),fullscreen:this._fullscreen.readonly(),detachable:this._detachable.readonly(),fullscreenable:this._fullscreenable.readonly(),visible:this._visible.readonly(),availWidth:this._availWidth.readonly(),availHeight:this._availHeight.readonly(),remove:()=>{const e=this._owner.value();e&&e.remove&&e.remove()},negotiateWidth:e=>{const t=this._owner.value();t&&t.negotiateWidth&&t.negotiateWidth(e)},negotiateHeight:e=>{const t=this._owner.value();t&&t.negotiateHeight&&t.negotiateHeight(e)},requestFullscreen:()=>{const e=this._owner.value();e&&e.requestFullscreen&&e.requestFullscreen()},exitFullscreen:()=>{const e=this._owner.value();e&&e.exitFullscreen&&e.exitFullscreen()},detach:e=>{const t=this._owner.value();t&&t.detach&&t.detach(e)},attach:()=>{const e=this._owner.value();e&&e.attach&&e.attach()}},e&&this.pushOwner(e)}destroy(){for(const e of this._ownersStack)this._unsubscribeOwner(e)}bridge(){return this._bridge}pushOwner(e){if(!e.alive.value())return;for(const e of this._ownersStack)this._unsubscribeOwner(e);const t={owner:e}
;this._ownersStack.push(t),this._subscribeOwner(t)}_subscribeOwner(e){const t=e.owner;if(e.deathWatcher||(this._alive.setValue(!0),e.deathWatcher=t.alive.spawn(),e.deathWatcher.subscribe((t=>{t||this._deadHandler(e)}))),this._owner.setValue(t),!e.subscriptions){const i=e.subscriptions=[];this._visible.setValue(!1);const s=(e,t)=>{if(e){const s=e.spawn();i.push(s),s.subscribe((e=>{t.setValue(e)}),{callWithLast:!0})}else t.deleteValue()};s(t.container,this._container),s(t.width,this._width),s(t.height,this._height),s(t.fullscreen,this._fullscreen),s(t.detachable,this._detachable),s(t.fullscreenable,this._fullscreenable),s(t.availWidth,this._availWidth),s(t.availHeight,this._availHeight),s(t.visible,this._visible)}}_unsubscribeOwner(e,t){if(e.subscriptions){for(const t of e.subscriptions)t.unsubscribe();e.subscriptions=null}t&&e.deathWatcher&&(e.deathWatcher.unsubscribe(),e.deathWatcher=null)}_deadHandler(e){const t=this._ownersStack.indexOf(e);(0,n.assert)(-1!==t,"sanitized owner should be in stack");for(let e=this._ownersStack.length-1;e>=t;e--)this._unsubscribeOwner(this._ownersStack[e],!0);this._ownersStack.length=t,t>0?this._subscribeOwner(this._ownersStack[t-1]):(this._alive.setValue(!1),this._owner.deleteValue())}}class Oe{constructor(e){this._document=e,this.isFullscreen=new O.WatchedValue;const t=()=>{const e=["fullscreenElement","webkitFullscreenElement","mozFullscreenElement","mozFullScreenElement","msFullscreenElement"];for(let t=0;t<e.length;t++){const i=e[t];if(i in this._document){this.isFullscreen.setValue(!!this._document[i]);break}}};t();for(const i of["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"])e.addEventListener(i,t,!1)}enter(){const e=this._document.documentElement;for(const t of["requestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","msRequestFullscreen"])if("function"==typeof e[t]){e[t]();break}this.isFullscreen.setValue(!0)}exit(){const e=this._document;for(const t of["exitFullscreen","mozCancelFullScreen","mozExitFullscreen","webkitExitFullscreen","msExitFullscreen"])if("function"==typeof e[t]){e[t]();break}this.isFullscreen.setValue(!1)}}class Fe{constructor(e){let t;this.isVisible=new O.WatchedValue(!0);let i=null;for(const s of["","moz","ms","webkit"]){const o=s?`${s}Hidden`:"hidden";if(o in e){t=`${s}visibilitychange`,i=()=>{this.isVisible.setValue(!e[o])},i(),e.addEventListener(t,i,!1);break}}this.destroy=()=>{i&&(e.removeEventListener(t,i,!1),i=null)}}}var We,He=i(84015),ze=i(49483);!function(e){e.Quirks="quirks",e.Visual="visual"}(We||(We={}));function Ue(e,t){let i=0;for(const{min:s,max:o}of t){if(e<s||o<s)continue;const t=Math.min(e,o);if(i=Math.max(i,t),e===i)break}return i}function je(e){const t=[];if(void 0===e)return[];Array.isArray(e)||(e=[e]);for(const i of e){let e,s;isFinite(i)?e=s=Number(i):(e=+i.min,s=+i.max),(e<0||isNaN(e))&&(e=0),isNaN(s)&&(s=1/0),e<=s&&s>0&&t.push({min:e,max:s})}return t.sort(((e,t)=>e.min-t.min||e.max-t.max)),t}function Ge(e,t){if(e.length!==t.length)return!1;for(let i=e.length;i--;){
if(e[i].min!==t[i].min)return!1;if(e[i].max!==t[i].max)return!1}return!0}const qe=l.enabled("no_min_chart_width");var $e;!function(e){e[e.MinChartHeight=300]="MinChartHeight",e[e.MinChartWidth=300]="MinChartWidth",e[e.DefaultOffset=4]="DefaultOffset",e[e.ThinOffset=1]="ThinOffset",e[e.TopToolbarMargin=0]="TopToolbarMargin"}($e||($e={}));const Ke=l.enabled("bypass_chart_height_check");function Ye(e){const t=l.enabled("side_toolbar_in_fullscreen_mode"),i=l.enabled("header_in_fullscreen_mode");return"center"===e||"left"===e&&t||"top"===e&&i}var Ze=i(32544),Xe=i(60709),Je=i(16216),Qe=(i(7304),i(16738)),et=i(83873),tt=i(87465),it=i(69109),st=i(72270);const ot=(0,ne.getLogger)("Common.UndoStack");class nt{constructor(){this._commands=[],this._onChange=new ae.Delegate}onChange(){return this._onChange}isEmpty(){return 0===this._commands.length}size(){return this._commands.length}clear(){this.isEmpty()||(this._commands.length=0,this._onChange.fire())}push(e){if(!(e instanceof st.UndoCommand))throw new TypeError("argument must be an instance of UndoCommand");this._commands.push(e),this._onChange.fire(e)}pop(){if(this.isEmpty())return void ot.logDebug("pop: undo stack is empty");const e=this._commands.pop();return this._onChange.fire(e),e}head(){if(!this.isEmpty())return this._commands[this._commands.length-1]}}class rt extends st.UndoCommand{constructor(e){super(e,!1),this._subcommands=[]}addCommand(e){this._subcommands.push(e)}isEmpty(){return 0===this._subcommands.length}redo(e){for(let t=0;t<this._subcommands.length;t++)this._subcommands[t].redo(e)}undo(e){for(let t=this._subcommands.length-1;t>=0;t--)this._subcommands[t].undo(e)}commands(){return this._subcommands}affectsState(){return this._subcommands.some((e=>e.affectsState()))}}class at extends st.UndoCommand{constructor(e,t,i,s,o=!0){super(s,void 0,o),this._setter=e,this._oldValue=t,this._newValue=i}redo(){this._setter(this._newValue)}undo(){this._setter(this._oldValue)}}class lt extends at{constructor(e,t,i,s,o=!0){super((e=>this._vwState.setValue(e)),t,i,s,o),this._vwState=e}}const ct=(0,ne.getLogger)("Common.UndoHistory");var ht=i(87296),dt=i(95804),ut=i(3354);const _t=new dt.TranslatedString("change chart layout to {title}",a.t(null,void 0,i(68846)));class pt extends st.UndoCommand{constructor(e,t){super(_t.format({title:ut.layouts[t].title})),this._chartWidgetCollection=e,this._newLayoutType=t,this._oldLayoutType=e.layout.value()}redo(){this._chartWidgetCollection.setLayout(this._newLayoutType)}undo(){this._chartWidgetCollection.setLayout(this._oldLayoutType)}}var mt=i(78861),gt=i(68335),ft=i(48943),yt=i(62773);function vt(e){const t={};return{promise:new Promise(((i,s)=>{e.subscribe(t,i,!0)})),destroy:()=>{e.unsubscribeAll(t)}}}var St=i(26867),bt=i(82095),wt=i(29447);class Ct extends X.DialogRenderer{constructor(e){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)},this._chartWidgetCollection=e}show(e){const t=this._chartWidgetCollection,s=t.activeChartWidget.value()
;return s.generalPropertiesDefinitions().then((o=>Promise.all([i.e(7871),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(6032),i.e(3672),i.e(2537),i.e(3359),i.e(8894),i.e(5743),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(1979),i.e(4495),i.e(9487),i.e(445),i.e(846),i.e(7827),i.e(9323),i.e(8220),i.e(3329),i.e(9970),i.e(6052),i.e(844),i.e(9590),i.e(4678),i.e(159),i.e(9965),i.e(9742),i.e(6043),i.e(1488),i.e(509),i.e(3014),i.e(4422),i.e(2227),i.e(4931),i.e(9418),i.e(4426),i.e(9026),i.e(769),i.e(9928),i.e(8604),i.e(5893),i.e(624),i.e(7078)]).then(i.bind(i,56080)).then((i=>{const n=new i.GeneralChartPropertiesDialogRenderer({chartWidgetCollection:t,propertyPages:o,activePageId:this._activePageId,model:s.model()});return this._dialog?.hide(),this._dialog?.visible().unsubscribe(this._subscribe),this._dialog=n,n.visible().subscribe(this._subscribe),n.show(e),this._activePageId=void 0,n}))))}hide(){this._dialog?.hide()}isVisible(){return this.visible().value()}focusOnText(){}setActivePage(e){this._activePageId=e}}class Tt extends X.DialogRenderer{constructor(e){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)},this._chartWidgetCollection=e}show(e){this._load().then((t=>{this._dialog?.hide(),this._dialog?.visible().unsubscribe(this._subscribe),this._dialog=t,t.visible().subscribe(this._subscribe),t.show(e),ee.emit("compare_add")}))}hide(){this._dialog?.hide()}_load(){return Promise.all([Promise.all([i.e(4040),i.e(7271)]).then(i.bind(i,43900)),Promise.all([i.e(8955),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(6032),i.e(3672),i.e(3359),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(445),i.e(846),i.e(6956),i.e(9002),i.e(2227),i.e(4931),i.e(9418),i.e(3179),i.e(4426),i.e(9026),i.e(731)]).then(i.bind(i,14283))]).then((([e,t])=>{const i=new e.CompareModel(this._chartWidgetCollection);return t.getCompareDialogRenderer(i)}))}}var Pt=i(12217),xt=i(95059);const Mt=()=>i.e(4389).then(i.bind(i,67090));function It(e,t={}){return Mt().then((i=>i.copyToClipboardImageOfChart(e,t)))}function At(e,t={}){return Mt().then((i=>i.getImageOfChartSilently(e,t)))}var Lt=i(11946);function kt(e){const t=e.querySelector("#chart-aria-description");if(null!==t)return t;const i=e.createElement("div");return i.id="chart-aria-description",i.tabIndex=-1,i.role="alert",i.ariaLive="assertive",e.body.appendChild(i),i}function Et(e,t){const i={weekday:"long",year:"numeric",month:"long",day:"numeric",hour:t?"2-digit":void 0,minute:t?"2-digit":void 0,hour12:!0};return new Date(1e3*e).toLocaleString(void 0,i)}class Dt{constructor(){this._ariaElement=null,this._customProvider=null,this._lastDescription=null,this._locale="en"}createElement(e){this._ariaElement=kt(e)}setCustomProvider(e){this._customProvider=e}setLocale(e){this._locale=e}async updateChartDescription(e,t,i){const s=function(e){const t=ut.layouts[e];return t?.count??1}(i),o=await this._buildChartContext(e,t,s);if(null===o)return;if(this._customProvider){
const e=await this._customProvider(o);if(null!==e)return void this._setChartDescription(e)}if("en"!==this._locale)return;const n=function(e){const t=function(e){if(!l.enabled("aria_detailed_chart_descriptions")||!e.visibleData)return"";let t;try{t=function(e){let t=e.schema.findIndex((e=>"userTime"===e.type));t<0&&(t=e.schema.findIndex((e=>"time"===e.type)));if(t<0)throw new Error("Exported Data should contain `time`.");const i=Bt(e,(e=>"value"===e.type&&"series"===e.sourceType&&"close"===e.plotTitle),-1);if(i<0)throw new Error("Exported Data should contain `close`.");const s=Bt(e,(e=>"value"===e.type&&"series"===e.sourceType&&"low"===e.plotTitle),i),o=Bt(e,(e=>"value"===e.type&&"series"===e.sourceType&&"high"===e.plotTitle),i),n=Bt(e,(e=>"value"===e.type&&"series"===e.sourceType&&"open"===e.plotTitle),i),r=e.data.map((e=>({time:e[t],open:e[n],high:e[o],low:e[s],close:e[i]}))),a={start:r[0],close:r[r.length-1],low:r[0],high:r[0]};for(const e of r)e.high>a.high.high&&(a.high=e),e.low<a.low.low&&(a.low=e);return a}(e.visibleData)}catch(e){return e instanceof Error&&console.warn("Unable to generate chart description. "+e.message),""}const i=`The first price is ${e.priceFormatter.format(t.start.open)} at ${Et(t.start.time)}.`,s=`The last price is ${e.priceFormatter.format(t.close.close)} at ${Et(t.close.time)}.`,o=t.close.close-t.start.open,n=o/t.start.open*100,r=`The actual change in price was ${e.priceFormatter.format(o)}, corresponding to a percentage change of ${n.toFixed(2)}%.`;let a="";t.low.time!==t.start.time&&t.low.time!==t.close.time&&(a+=`The lowest price was ${e.priceFormatter.format(t.low.low)} at ${Et(t.low.time)}.`);t.high.time!==t.start.time&&t.high.time!==t.close.time&&(a+=` The highest price was ${e.priceFormatter.format(t.high.high)} at ${Et(t.high.time)}.`);return`${i} ${s} ${r} ${a}`.trim()}(e),i=function(e){const t=e.description??e.symbol,i=e.chartTypeName,s=function(e){if(e.chartCount<=1)return"";return`Chart ${e.chartIndex+1} of ${e.chartCount}. `}(e);return`${s}${i} chart of ${t}`}(e);return`${i}. ${t}`}(o);this._setChartDescription(n)}static getInstance(){return null===this._instance&&(this._instance=new Dt),this._instance}async _getExportData(e,t){return(await Promise.all([i.e(2578),i.e(9498)]).then(i.bind(i,99207))).exportData(e,t)}async _getData(e,t,i){const s=e.model().model();return await this._getExportData(s,{from:t,to:i,includeTime:!0,includeUserTime:!0})}_setChartDescription(e){if(!this._ariaElement)return;let t=e;e===this._lastDescription&&(t+="."),this._ariaElement.textContent=t,this._lastDescription=t}async _buildChartContext(e,t,i){const s=e.model().mainSeries().properties().childs().style.value(),o=s,n=(0,xt.getTranslatedChartStyleName)(s),r=e.model().mainSeries().symbolInfo(),a=e.model().timeScale(),c=a.visibleBarsStrictRange();if(!c)return null;const h=c.firstBar(),d=Math.min(c.lastBar(),a.baseIndex()),u=a.indexToTimePoint(h),_=a.indexToTimePoint(d);if(!u||!_)return null;let p;l.enabled("aria_detailed_chart_descriptions")&&(p=await this._getData(e,u,_))
;const m=e.model().mainSeries().interval(),g=Re.Interval.parse(m).isIntraday();return{chartType:o,chartTypeName:n,symbol:e.model().mainSeries().symbol(),description:r?.description,symbolInfo:r,exchange:r?.exchange,ticker:r?.ticker,visibleData:p,visibleRange:{from:u,to:_},chartCount:i,chartIndex:t,priceFormatter:e.model().mainSeries().formatter(),interval:m,isIntraday:g}}}function Bt(e,t,i){const s=e.schema.findIndex(t);return s>=0?s:i}Dt._instance=null;var Vt=i(10555),Rt=i(58978),Nt=i(24377),Ot=i(50279),Ft=i(27714),Wt=i(62153);class Ht{constructor(e,t){this._isDestroyed=!1,this._lollipopTooltipRenderer=null,this._activeLollipop=e,this._cardType=t,this._activeLollipop.subscribe((e=>{null===e&&this._destroyTooltip()}))}destroy(){this._destroyTooltip(),this._activeLollipop.release(),this._isDestroyed=!0}tryToHideTooltipByClickOutside(e,t,i){if(!this._isClickInsideTooltip(i)){if(void 0!==i){const s=t(e,i);if(null!==s&&(0,Ot.default)(s,this._activeLollipop.value()))return}this._activeLollipop.setValue(null)}}async showTooltip(e,t,s,o,r){const a=s();if(null===a||0===a.length)return;const{showLollipopTooltip:l}=await Promise.all([i.e(1681),i.e(1171),i.e(6032),i.e(2641),i.e(2227),i.e(3179),i.e(9039)]).then(i.bind(i,92892)),c=await o();this._isDestroyed||((0,n.assert)(null===this._lollipopTooltipRenderer,"Lollipop tooltip renderer should be null before creating a new one"),this._lollipopTooltipRenderer=l({items:a,position:t,customCloseSubscriptions:r.customCloseSubscriptions,onClose:()=>r.onClose(e),onClickOutside:t=>r.onClickOutside(e,t),onSizeChanged:r.onSizeChanged,showScrollFades:!0,cardType:this._cardType,theme:c}))}_isClickInsideTooltip(e){return null!==this._lollipopTooltipRenderer&&void 0!==e&&this._lollipopTooltipRenderer.isClickInside(e)}_destroyTooltip(){this._lollipopTooltipRenderer?.hide(),this._lollipopTooltipRenderer=null}}var zt,Ut=i(2383),jt=i(94602),Gt=i(6453),qt=i(69558),$t=i(58221),Kt=i(33350),Yt=i(4539);!function(e){e[e.SizeDelta=1]="SizeDelta"}(zt||(zt={}));class Zt{constructor(e,t,i){this._data=e,this._hittest=t,this._textWidthCache=i}draw(e,t){const{horizontalPixelRatio:i,verticalPixelRatio:s}=t,o=this._data.centerPoint,n=Math.round(o.x*i),r=Math.round(o.y*s),a=Math.max(1,Math.floor(i))%2/2,l=Math.max(1,Math.floor(s))%2/2,c=new Vt.Point(n+a,r-l);this._drawLollipop(e,c,t),this._drawLabel(e,c,t)}hitTest(e){const t=(0,Yt.interactionTolerance)().esd,i=this._data.centerPoint.y-this._data.style.lollipop.height/2-t,s=this._data.centerPoint.x-this._data.style.lollipop.width/2-t,o=(0,Vt.box)(new Vt.Point(s,i),new Vt.Point(s+this._data.style.lollipop.width+2*t,i+this._data.style.lollipop.height+2*t));return(0,Gt.pointInBox)(e,o)?this._hittest:null}_drawLollipop(e,t,i){const s=this._data.style,{horizontalPixelRatio:o}=i,n=this._fillRadius(o);s.lollipop.fillCircle&&s.lollipop.backgroundColor&&this._drawFilledCircle(e,t,n,s.lollipop.backgroundColor);const r=Math.round(s.lollipop.lineWidth*o),a=n-Math.round(1*o+r/2);this._drawBorderLine(e,t,r,a),
s.lollipop.fillCircle&&s.lollipop.fillStyle&&this._drawFilledCircle(e,t,a,s.lollipop.fillStyle)}_drawLabel(e,t,i){const s=this._data.style.lollipop.text,o=s.label;if(""===o)return;const{horizontalPixelRatio:n,verticalPixelRatio:r}=i;e.textAlign="center",e.textBaseline="middle",e.fillStyle=s.strokeStyle,e.font=s.font;const a=this._textWidthCache.yMidCorrection(e,o);e.translate(t.x,t.y+((s.deltaY||0)+a)*r),(0,Kt.drawScaled)(e,n,r,(()=>{e.fillText(o,0,0)}))}_fillRadius(e){const t=this._data.style,i=Math.max(1,Math.floor(e));let s=Math.round(t.lollipop.width*e);return s%2!=i%2&&(s+=1),s/2}_drawBorderLine(e,t,i,s){const o=this._data.style;e.strokeStyle=o.lollipop.strokeStyle,e.lineWidth=i,(0,$t.setLineStyle)(e,qt.LINESTYLE_SOLID),(0,$t.createCircle)(e,t.x,t.y,s),e.stroke()}_drawFilledCircle(e,t,i,s){e.fillStyle=s,(0,$t.createCircle)(e,t.x,t.y,i),e.fill()}}var Xt,Jt=i(64960),Qt=i(57658),ei=i(43838);!function(e){e[e.SpaceBetweenRows=25]="SpaceBetweenRows",e[e.TooltipTopMargin=15]="TooltipTopMargin",e[e.SpaceBetweenCardAndLollipop=8]="SpaceBetweenCardAndLollipop"}(Xt||(Xt={}));class ti{constructor(e,t){this._invalidated=!1,this._renderer=new jt.CompositeRenderer,this._textWidthCache=new Qt.TextWidthCache,this._stylesCache=null,this._lollipops={},this._lollipopsCounter=0,this._activeLollipopInfo=new yt.WatchedObject(null),this.onPaneBgChange=()=>{this._recreateStyles(this._model)},this._model=e,this._source=t,this._recreateStyles(e),e.backgroundColor().subscribe(this.onPaneBgChange),e.mainSeries().onSymbolIntervalChanged().subscribe(this,this._onSymbolOrIntervalChanged),this._lollipopTooltip=new Ht(this._activeLollipopInfo.spawnOwnership()),this._activeLollipopInfo.subscribe((()=>{this._source.updateAllViewsAndRepaint()}))}destroy(){this._model.backgroundColor().unsubscribe(this.onPaneBgChange),this._model.mainSeries().onSymbolIntervalChanged().unsubscribeAll(this),this._lollipopTooltip.destroy()}processClickInside(e,t,i){const s=this._lollipops[i];return!(!s||!s.visible)&&(this._lollipopMouseClickHandler(e,this._getLollipopRendererData(s),(0,Ft.size)({width:t.clientWidth,height:t.clientHeight}),{preventDefault:()=>{},target:t}),!0)}processClickOutside(e,t){this._lollipopTooltip.tryToHideTooltipByClickOutside(e,this._getActiveLollipopTooltipInfo.bind(this),t)}update(e){this._invalidated=!0}afterUpdate(e,t,i,s){}getStyle(e,t){let i=t;if(e.stack&&(i+="_stack:"+e.stack),"active"===i)return this._activeStyle;if("hovered"===i)return this._hoveredStyle;if("default"===i)return this._defaultStyle;if(this._stylesCache||(this._stylesCache={}),!this._stylesCache[i]){const s=(0,tt.clone)("active"===t?this._activeStyle:"hovered"===t?this._hoveredStyle:this._defaultStyle);e.stack&&(s.lollipop.incHeight=25*e.stack),this._stylesCache[i]=s}return this._stylesCache[i]}hasTooltip(e){return!0}clearActiveLollipop(){this._activeLollipopInfo.setValue(null)}async _specialTooltipStyles(e){}_getY(){let e=0;const t=this._model.panes();for(let i=t.length;i--;){const s=t[i];s.containsMainSeries()&&(e+=s.height())}return e}_showBarLine(e){
return this.hasTooltip(e)&&(e.hovered||this._isLollipopActive(e))}_getLollipopRendererData(e){const t=this._getLollipopStatus(e),i=this.getStyle(e,t);return{id:e.id,itemIndex:e.itemIndex,centerPoint:new Vt.Point(e.basePoint.x,e.basePoint.y-i.lollipop.bottom-i.lollipop.height/2-(i.lollipop.incHeight||0)),style:i,status:t}}_createRenderers(e){const{mediaSize:t}=e;for(const i of Object.values(this._lollipops))if(void 0!==i&&i.visible){const s=this._getLollipopStatus(i),o=this.getStyle(i,s),n={id:i.id,itemIndex:i.itemIndex,centerPoint:new Vt.Point(i.basePoint.x,i.basePoint.y-o.lollipop.bottom-o.lollipop.height/2-(o.lollipop.incHeight||0)),style:o,status:s},r={cursorType:ei.PaneCursorType.Default,activeItem:{id:i.id,itemIndex:i.itemIndex},hideCrosshairLinesOnHover:!0,clickHandler:(i,s)=>this._lollipopMouseClickHandler(e,n,t,i),tapHandler:(i,s)=>this._lollipopMouseClickHandler(e,n,t,i)};if(this._renderer.append(this._createRendererForLollipop(n,r)),this._showBarLine(i)){const{strokeStyle:e,lineStyle:t,lineWidth:s}=o.barLine,n={color:e,linestyle:t,linewidth:s,x:i.basePoint.x,top:0,bottom:i.basePoint.y-o.lollipop.bottom-o.lollipop.height},r=new Jt.VerticalLineRenderer;r.setData(n),this._renderer.insert(r,0)}}}_recreateStyles(e){this._stylesCache=null}_createRendererForLollipop(e,t){return new Zt(e,new Ut.HitTestResult(Ut.HitTarget.Custom,t),this._textWidthCache)}_onSymbolOrIntervalChanged(){this._lollipops={},this._lollipopsCounter=0,this._renderer.clear(),this._activeLollipopInfo.setValue(null)}async _lollipopMouseClickHandler(e,t,i,s){s.preventDefault();const o={id:t.id,itemIndex:t.itemIndex};if((0,Ot.default)(this._activeLollipopInfo.value(),o))return void this._activeLollipopInfo.setValue(null);this._activeLollipopInfo.setValue(o);const r={target:s.target,targetSize:i,point:new Vt.Point(t.centerPoint.x,t.centerPoint.y-t.style.lollipop.height/2-8),marginTop:15},a=(0,n.ensureDefined)(this._lollipops[t.id]),l=this._model.timeScale();this._lollipopTooltip.showTooltip(e,r,(()=>this._createTooltipContent(a)),(()=>this._specialTooltipStyles(a)),{onClose:this.processClickOutside.bind(this),onClickOutside:(e,t)=>{this._source.onClickOutside?.(e,(0,n.ensureDefined)(t))},customCloseSubscriptions:[l.onScroll(),l.barSpacingChanged(),this._model.mainSeries().onSymbolIntervalChanged()],onSizeChanged:(0,n.ensureNotNull)(this._model.paneForSource(this._source)).onSizeChanged()})}_getLollipopStatus(e){return this._isLollipopActive(e)?"active":e.hovered?"hovered":"default"}_isLollipopActive(e){return null!==this._activeLollipopInfo.value()&&(0,Ot.default)(this._activeLollipopInfo.value(),{id:e.id,itemIndex:e.itemIndex})}_getActiveLollipopTooltipInfo(e,t){const i=(0,Wt.getClickPosition)(t);if(null===i)return null;const s=this.renderer(e)?.hitTest(new Vt.Point(i.x,i.y),e)?.data()?.activeItem??null;return null===s?null:s}}var ii,si=i(49251);class oi extends Zt{_drawLollipop(e,t,i){if(!this._imageLoaded())return void super._drawLollipop(e,t,i);const s=this._data.style,{horizontalPixelRatio:o}=i,n=this._fillRadius(o)
;let r=Math.round(s.lollipop.lineWidth*o),a=n-Math.round(1*o+r/2);if(s.lollipop.fillCircle&&(s.lollipop.backgroundColor&&this._drawFilledCircle(e,t,n,s.lollipop.backgroundColor),s.lollipop.fillStyle&&this._drawFilledCircle(e,t,a,s.lollipop.fillStyle)),this._data.style.lollipop.image?.imageElement){const i=n-Math.round(1*o+2*r),s=2*i;e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality="high",(0,$t.createCircle)(e,t.x,t.y,i),e.clip(),e.drawImage(this._data.style.lollipop.image.imageElement,t.x-i,t.y-i,s,s),e.restore()}"active"===this._data.status&&(a-=r/2,r*=1.5),this._drawBorderLine(e,t,r,a)}_drawLabel(e,t,i){this._imageLoaded()&&!this._data.style.lollipop.text.showWhenImageLoaded||super._drawLabel(e,t,i)}_imageLoaded(){return Boolean(this._data.style.lollipop.image&&this._data.style.lollipop.image.imageElement&&this._data.style.lollipop.image.imageElement.complete&&this._data.style.lollipop.image.imageElement.naturalWidth)}}function ni(e,t,i){Array.isArray(t)?t.forEach((t=>{ni(e,t,i)})):"fill"===t.mode?(e.fillStyle=i,e.fill(t.path)):"stroke"===t.mode&&(e.strokeStyle=i,e.stroke(t.path))}function ri(e,t){return{background:{bodyPath:{path:new Path2D(e),mode:"fill"}},foreground:{bodyPath:{path:new Path2D(t),mode:"fill"},borderPath:{path:new Path2D(t),mode:"stroke"}}}}!function(e){e.PositiveEarningFillPath="M8.961.92a3 3 0 0 1 3.078 0l7.5 4.48A3 3 0 0 1 21 7.975V20a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V7.975A3 3 0 0 1 1.461 5.4l7.5-4.48z",e.PositiveEarningStrokePath="M9.867 2.742c.39-.23.875-.23 1.266 0l7.5 4.406c.382.225.617.635.617 1.078V20c0 .69-.56 1.25-1.25 1.25H3c-.69 0-1.25-.56-1.25-1.25V8.226c0-.443.235-.853.617-1.078l7.5-4.406z",e.NegativeEarningFillPath="M8.961 23.08a3 3 0 0 0 3.078 0l7.5-4.48A3 3 0 0 0 21 16.025V4a3 3 0 0 0-3-3H3a3 3 0 0 0-3 3v12.025A3 3 0 0 0 1.461 18.6l7.5 4.48z",e.NegativeEarningStrokePath="M9.866 21.257c.391.23.877.23 1.268 0l7.5-4.414a1.25 1.25 0 0 0 .616-1.078V4c0-.69-.56-1.25-1.25-1.25H3c-.69 0-1.25.56-1.25 1.25v11.765c0 .443.234.853.616 1.078l7.5 4.414z",e.DefaultEarningFillPath="M3 0h15c1.662 0 3 1.338 3 3v15c0 1.662-1.338 3-3 3H3c-1.662 0-3-1.338-3-3V3c0-1.662 1.338-3 3-3z",e.DefaultEarningStrokePath="M3 1.75h15c.693 0 1.25.557 1.25 1.25v15c0 .693-.557 1.25-1.25 1.25H3c-.692 0-1.25-.558-1.25-1.25V3c0-.692.558-1.25 1.25-1.25z"}(ii||(ii={}))
;const ai=ri("M8.961.92a3 3 0 0 1 3.078 0l7.5 4.48A3 3 0 0 1 21 7.975V20a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V7.975A3 3 0 0 1 1.461 5.4l7.5-4.48z","M9.867 2.742c.39-.23.875-.23 1.266 0l7.5 4.406c.382.225.617.635.617 1.078V20c0 .69-.56 1.25-1.25 1.25H3c-.69 0-1.25-.56-1.25-1.25V8.226c0-.443.235-.853.617-1.078l7.5-4.406z"),li=ri("M8.961 23.08a3 3 0 0 0 3.078 0l7.5-4.48A3 3 0 0 0 21 16.025V4a3 3 0 0 0-3-3H3a3 3 0 0 0-3 3v12.025A3 3 0 0 0 1.461 18.6l7.5 4.48z","M9.866 21.257c.391.23.877.23 1.268 0l7.5-4.414a1.25 1.25 0 0 0 .616-1.078V4c0-.69-.56-1.25-1.25-1.25H3c-.69 0-1.25.56-1.25 1.25v11.765c0 .443.234.853.616 1.078l7.5 4.414z"),ci=ri("M3 0h15c1.662 0 3 1.338 3 3v15c0 1.662-1.338 3-3 3H3c-1.662 0-3-1.338-3-3V3c0-1.662 1.338-3 3-3z","M3 1.75h15c.693 0 1.25.557 1.25 1.25v15c0 .693-.557 1.25-1.25 1.25H3c-.692 0-1.25-.558-1.25-1.25V3c0-.692.558-1.25 1.25-1.25z");new Path2D("M3 0h15a3 3 0 0 1 3 3v15a3 3 0 0 1-3 3H3a3 3 0 0 1-3-3V3a3 3 0 0 1 3-3z"),new Path2D("M.08 13.1c.87 0 1.77.9 2.79.9.74 0 1.28-.3 1.63-.7V7.2c-.35.44-.89.7-1.58.7-.87 0-1.77-.9-2.79-.9-.74 0-1.28.31-1.63.7v6.1c.35-.43.88-.7 1.58-.7Z"),new Path2D("M 17.25 1.7 a 2 2 0 0 1 2 2 v 13.5 a 2 2 0 0 1 -2 2 h -14 a 2 2 0 0 1 -2 -2 v -4.4 L 1.75 13.8 C 1.17 13.44 0.62 13.1 0.08 13.1 C -0.62 13.1 -1.15 13.37 -1.5 13.8 V 7.7 C -1.15 7.31 -0.61 7 0.13 7 C 0.7 7 1.23 7.28 1.75 7.53 L 1.25 7.95 V 3.7 a 2 2 0 0 1 2 -2 z"),new Path2D("M1.75 7.2v-3.5a2 2 0 0 1 2-2h13.5a2 2 0 0 1 2 2v13.5a2 2 0 0 1-2 2h-13.5a2 2 0 0 1-2-2v-3.5"),new Path2D("M2.87 10.3c-1.02 0-1.92-.9-2.79-.9-.7 0-1.23.26-1.58.7V8.7c.35-.39.89-.7 1.63-.7 1.02 0 1.92.91 2.79.91.69 0 1.23-.26 1.58-.71v1.4c-.35.4-.89.7-1.63.7Zm0 2.7c-1.02 0-1.92-.91-2.79-.91-.7 0-1.23.26-1.58.71v-1.35c.35-.4.89-.7 1.63-.7 1.02 0 1.92.9 2.79.9.69 0 1.23-.26 1.58-.7v1.34c-.35.4-.89.71-1.63.71Z"),new Path2D("M2.87 10.3c-1.02 0-1.92-.9-2.79-.9-.7 0-1.23.26-1.58.7V8.7c.35-.39.89-.7 1.63-.7 1.02 0 1.92.91 2.79.91.69 0 1.23-.26 1.58-.71v1.4c-.35.4-.89.7-1.63.7Zm0 2.7c-1.02 0-1.92-.91-2.79-.91-.7 0-1.23.26-1.58.71v-1.35c.35-.4.89-.7 1.63-.7 1.02 0 1.92.9 2.79.9.69 0 1.23-.26 1.58-.7v1.34c-.35.4-.89.71-1.63.71Z");function hi(e,t,i,s,o){const{horizontalPixelRatio:n,verticalPixelRatio:r}=i;e.save(),e.translate(t.x-s.lollipop.width*n/2,t.y-s.lollipop.height*r/2),e.scale(n,r),s.lollipop.fillCircle&&s.lollipop.backgroundColor&&ni(e,o.background.bodyPath,s.lollipop.backgroundColor),s.lollipop.fillCircle&&s.lollipop.fillStyle&&ni(e,o.foreground.bodyPath,s.lollipop.fillStyle),e.lineWidth=Math.round(s.lollipop.lineWidth*n)/n,(0,$t.setLineStyle)(e,qt.LINESTYLE_SOLID),o.foreground.borderPath&&ni(e,o.foreground.borderPath,s.lollipop.strokeStyle),s.lollipop.active&&o.foreground.activePath&&ni(e,o.foreground.activePath,s.lollipop.text.strokeStyle),e.restore()}function di(e,t,i,s){hi(e,t,i,s,ai)}function ui(e,t,i,s){hi(e,t,i,s,li)}function _i(e,t,i,s){hi(e,t,i,s,ci)}class pi extends Zt{_drawLollipop(e,t,i){const s=this._data.style;switch(s.shape){case"earningUp":di(e,t,i,s);break;case"earningDown":ui(e,t,i,s);break;case"earning":_i(e,t,i,s);break;default:
super._drawLollipop(e,t,i)}}}var mi;!function(e){e[e.HoveredColorTransparency=85]="HoveredColorTransparency",e.ActiveTextColor="rgba(255, 255, 255, 0.92)"}(mi||(mi={}));const gi={backgroundDark:(0,Rt.getHexColorByName)("color-cold-gray-900"),backgroundLight:(0,Rt.getHexColorByName)("color-white")};class fi extends ti{constructor(e,t){super(e,t),this.stylesCache={},this.templatesCache={},this._itemIndexToId=new Map,this.source=t}clearCaches(){this._activeLollipopInfo.setValue(null),this._lollipops={},this._lollipopsCounter=0}renderer(e){return this._invalidated&&(this._createLollipops(e),this._invalidated=!1),this._renderer}getStyle(e){const t=this._isLollipopActive(e)?"active":e.hovered?"hovered":"default";return this._generateStyle(t,e)}hasTooltip(e){return Boolean(e.items&&e.items.length)}_createTooltipContent(e){const t=e.items;return t?[{style:{color:e.color},main:{type:"common",title:Array.isArray(t)?t.map((e=>({value:e}))):[{value:t}]}}]:null}_createRendererForLollipop(e,t){return new(e.style.lollipop.image?oi:pi)(e,new Ut.HitTestResult(Ut.HitTarget.Custom,t),this._textWidthCache)}async _lollipopMouseClickHandler(e,t,i,s){(0,ee.emit)("onTimescaleMarkClick",t.id),await super._lollipopMouseClickHandler(e,t,i,s)}_createLollipops(e){this._renderer.clear();const t=this._model.timeScale(),i=super._getY(),s=this._model.lastHittestData(),o=this._model.hoveredSource(),n=this.source.marks(),r=new Map;Object.keys(n).forEach((e=>{const a=n[e],l=a.id,c=a.index;if(null!=c){const e=this._lollipops[l],n=void 0!==e?e.itemIndex:this._lollipopsCounter++;this._itemIndexToId.has(n)||this._itemIndexToId.set(n,l);const h=o===this.source&&null!==s&&void 0!==s.activeItem&&s.activeItem.itemIndex===n,d=(r.get(c)??-1)+1;r.set(c,d),this._lollipops[l]={id:l,itemIndex:n,basePoint:new Vt.Point(t.indexToCoordinate(c)+1,i),hovered:h,label:a.label,color:a.color,items:a.tooltip,visible:!0,stack:d,shape:a.shape,image:this._getImageForUrl(a.imageUrl),showLabelWhenImageLoaded:a.showLabelWhenImageLoaded,textColor:a.labelFontColor}}})),this._createRenderers(e)}_getImageForUrl(e){if(e)return this.source.getImageElement(e)}_generateStyle(e,t){const{color:i,label:s,stack:o,shape:n,image:r,textColor:a}=t;let l=e+i+s+(this._model.dark().value()?"dark":"light");if(void 0!==o&&(l+="_stack"+o),!(l in this.stylesCache)){const c=this._model.dark().value()?gi.backgroundDark:gi.backgroundLight;let h,d=i;if("active"===e)h=i,d="rgba(255, 255, 255, 0.92)";else if("hovered"===e){const e=(0,Nt.tryParseRgba)(i);if(null!==e){const t=e[3]*(1-.85);h=(0,Nt.rgbaToString)((0,Nt.rgba)(e[0],e[1],e[2],t))}}a&&(d=a);let u=23,_=23,p=1,g=0;"earning"===n?(_=21,u=21,p=2):"earningUp"===n?(u=21,g=1,p=2):"earningDown"===n&&(u=21,g=-.5,p=.5);const f={barLine:{lineStyle:qt.LINESTYLE_DASHED,lineWidth:1,strokeStyle:i},lollipop:{width:u,height:_,bottom:p,backgroundColor:c,lineWidth:1.5,fillStyle:h,strokeStyle:i,fillCircle:!0,text:{label:s,deltaY:g,strokeStyle:d,font:(0,si.makeFont)(12,m.CHART_FONT_FAMILY,"bold"),showWhenImageLoaded:t.showLabelWhenImageLoaded},image:r},shape:n}
;void 0!==o&&(f.lollipop.incHeight=25*o),this.stylesCache[l]=f}return this.stylesCache[l]}}var yi=i(78176),vi=i(67777),Si=i(64971),bi=i(72207),wi=i(40472);const Ci=(0,ne.getLogger)("Chart.BarsMarksContainer"),Ti=Math.round(new Date(2037,0,1).getTime()/1e3);var Pi;!function(e){e[e.MaxPlatesPerBar=10]="MaxPlatesPerBar"}(Pi||(Pi={}));class xi extends bi.DataSource{constructor(e,t,i){const s=e.onWidget();let o;o=s?!e.hideIdeas():!!l.enabled("bars_marks")&&d.default.getBool("BarsMarksContainer.visibile",!1),t.merge({visible:o}),t.childs().visible.subscribe(null,(t=>{s||e.isSnapshot()||!l.enabled("bars_marks")||d.default.setValue("BarsMarksContainer.visibile",!!t.value())})),super(i),this._paneViews=[],this._model=e,this._properties=t,this._requests=[],this._marks={},this._loadedRange=null,this._getDataTimeout=null,this._collectedRange=null,this._lastRange=null;const r=this._model.mainSeries();r.onSymbolIntervalChanged().subscribe(this,this.clearMarks),r.dataEvents().symbolResolved().subscribe(this,this.clearMarks),r.dataEvents().completed().subscribe(this,(()=>{const e=r.data();if(0===e.size())return;const t=(0,n.ensureNotNull)(e.first()).index,i=(0,n.ensureNotNull)(e.last()).index,s=this.timeScale();this.getData({start:s.indexToTimePoint(t)??1/0,end:s.indexToTimePoint(i)??-1/0})})),this._initialize(),this._pinnedTooltips={}}destroy(){const e=this._model.mainSeries();e.onSymbolIntervalChanged().unsubscribeAll(this),e.dataEvents().symbolResolved().unsubscribeAll(this),e.dataEvents().completed().unsubscribeAll(this),super.destroy()}model(){return this._model}properties(){return this._properties}marks(){return this._marks}pinTooltip(e,t){this._pinnedTooltips[e]=t}timeScale(){return this._model.timeScale()}getIntervalInTicks(){const e=this._model.mainSeries().properties().childs().interval.value(),t=Re.Interval.parse(e);if(!t.isValid())throw new TypeError("Unexpected interval");return t.isRange()?60:t.inMilliseconds()/1e3}getVisibleTickMarksRange(){if(this.timeScale().isEmpty())return{start:0,end:0};const e=(0,n.ensureNotNull)(this.timeScale().visibleBarsStrictRange()),{firstIndex:t,lastIndex:i}=(0,n.ensureNotNull)(this.timeScale().points().range().value());if(!(e.lastBar()>t&&e.firstBar()<i))return{start:0,end:0};let s;s=e.lastBar()<i?this.timeScale().indexToTimePoint(e.lastBar()):Ti;const o={start:this.timeScale().indexToTimePoint(Math.max(e.firstBar(),t)),end:s};return{start:o.start??1/0,end:o.end??-1/0}}getVisibleRangePlates(){const e=[],t=this.getVisibleTickMarksRange(),i=this.getIntervalInTicks();return Object.keys(this._marks).forEach((s=>{const o=this._marks[s],n=o.tickmark;n>=(t.start??1/0)&&n<=(t.end??-1/0)+i&&e.push(o)})),e}getPublishedPlates(){const e={};return window.is_authenticated?(this.getVisibleRangePlates().forEach((t=>{t.is_public&&(this._pinnedTooltips[t.id]||t.user__id===window.user.id)&&(e[t.id]=t)})),e):e}filterDisplayedPlates(e){const t=e.reduce(((e,t)=>{const i=this._getIndex(t.tickmark);return null!==i&&(e[i]=e[i]||[],e[i].push(t)),e}),{});return Object.keys(t).reduce(((e,i)=>{let s=t[i]
;return s=s.sort(((e,t)=>t.views_count-e.views_count)),s=s.slice(0,10),e.concat(s)}),[])}getPlatesViewData(){const e=this._model.mainSeries();if(e.data().isEmpty())return[];const t=(0,xt.isPriceSourceStyle)(e.style())?e.barFunction():null,i=this.filterDisplayedPlates(this.getVisibleRangePlates()),s={},o=this._model.lastHittestData()??this._model.lastSelectedHittestData();let r=null;null!==o&&this._model.hoveredSource()===this&&(r=o.activeItem??null);const a=[];for(const e of i){const i=(0,n.ensureNotNull)(this._getIndex(e.tickmark)),o=this._getBar(i);if(null===o)continue;const l=this._layout(e.direction),c=this._theme(e.direction),h=r===e.id,d=this.timeScale().indexToCoordinate(i),u=this._offset(l,o,t),_=(0,n.ensureNotNull)(this.priceScale()).isInverted();let p=0;i in s||(s[i]={up:0,down:0}),p=s[i][l]++,a.push({id:e.id,x:d,y:u,yInverted:_,order:p,direction:l,theme:c,hovered:h,pinned:!0===this._pinnedTooltips[e.id],user__id:e.user__id,label:e.label,labelFontColor:e.labelFontColor||"#444",minSize:e.minSize||5,...this._plateViewData(e)})}const l=a.filter((e=>!0===e.hovered));for(let e=0;e<i.length;e++)i[e].user__id===l[0]?.user__id&&(i[e].highlightByAuthor=!0);return a.sort(((e,t)=>e.hovered&&!t.hovered?1:0)),a}priceAxisViews(){return null}updateAllViews(e){for(const t of this._paneViews)t.update(e)}updateAllViewsAndRepaint(){this.updateAllViews((0,wi.sourceChangeEvent)(this.id())),this._model.updateSource(this)}roundRange(e){return{start:Math.round(e.start),end:Math.round(e.end)}}refreshData(){null!==this._lastRange&&this.getData(this._lastRange)}getData(e){(0,tt.isNumber)(e.start)&&(0,tt.isNumber)(e.end)?(this._lastRange=e,e.end=Ti,this._pushGetDataStack(Object.assign({},e))):Ci.logError("Wrong range")}clearMarks(){this._abortAllRequests(),this._marks={},this._loadedRange=null}isUserDeletable(){return!1}isSavedInChart(e){return!1}isSpeciallyZOrderedSource(){return!0}showInObjectTree(){return!1}_plateViewData(e){return{}}_layout(e){switch(e){default:case 0:case 2:case 3:case 4:case 5:case 6:return"up";case 1:return"down"}}_theme(e){switch(e){default:case 0:return"neutral";case 1:case 5:return"green";case 2:case 6:return"red";case 3:return"yellow";case 4:return"blue"}}_offset(e,t,i){let s;switch(e){default:case"up":s=null===i?t[2]:i(t);break;case"down":s=null===i?t[3]:i(t)}return(0,n.ensureNotNull)(this.priceScale()).priceToCoordinate(s,(0,n.ensureNotNull)((0,n.ensureNotNull)(this.ownerSource()).firstValue()))}_getIndex(e){return this.timeScale().timePointToIndex(e)}_getBar(e){return this._model.mainSeries().data().valueAt(e)}_rangeDifference(e){return e=Object.assign({start:1/0,end:-1/0},e),this._loadedRange&&(e.start<this._loadedRange.start?e.end=this._loadedRange.start:e.end>this._loadedRange.end&&(e.start=this._loadedRange.end)),e}_rangeUnion(e,t){return e=Object.assign({start:1/0,end:-1/0},e),t&&(e.start=Math.min(t.start,e.start),e.end=Math.max(t.end,e.end)),e}_pushGetDataStack(e){(0,tt.isNumber)(e.start)&&(0,tt.isNumber)(e.end)?(this._getDataTimeout&&clearTimeout(this._getDataTimeout),
this._collectedRange=this._rangeUnion(e,this._collectedRange),this._getDataTimeout=setTimeout((()=>{this._getData(this._collectedRange),this._getDataTimeout=this._collectedRange=null}),300)):Ci.logError("Wrong tickmark range")}_abortAllRequests(){this._requests.forEach((e=>{e.cancel()})),this._requests=[],this._getDataTimeout&&clearTimeout(this._getDataTimeout),this._getDataTimeout=this._collectedRange=null}}const Mi=(0,ne.getLogger)("Chart.UserDefinedImageMarks");class Ii extends xi{constructor(){super(...arguments),this._imageItems=new Map,this._destroyed=!1}destroy(){this._destroyed=!0,super.destroy()}getImageElement(e){return this._imageItems.has(e)||this.addImageToStore(e),this._imageItems.get(e)}addImageToStore(e){this._imageItems.has(e)||this._loadNewImage(e)}_loadNewImage(e){const t={imageElement:null};(0,Si.getImage)(e,e).then((e=>{this._destroyed||(t.imageElement=e,this.updateAllViewsAndRepaint(),this._model.updateSource(this))})).catch((()=>{Mi.logWarn(`An error ocurred while loading image ${e}`)})),this._imageItems.set(e,t)}}var Ai=i(12178);class Li extends Ii{constructor(e){super(e,new yi.DefaultProperty({defaultName:"UserDefinedTimescaleMarks",state:{visible:!0}})),this._requestedPointsets=new Set,(0,mt.hideMarksOnBars)().subscribe(this,(()=>this._properties.childs().visible.setValue(!(0,mt.hideMarksOnBars)().value()))),this._paneView=new fi(e,this),this._paneViews=[this._paneView]}destroy(){(0,mt.hideMarksOnBars)().unsubscribeAll(this),this._paneView.destroy(),super.destroy()}zorder(){return vi.sortSourcesPreOrdered.TimeScaleMarks}name(){return"UserDefinedTimescaleMarks"}userEditEnabled(){return!1}clearMarks(e=0){if(1===e)return;const t=this._model.chartApi();t.isConnected().value()&&Object.keys(this._marks).forEach((e=>{const i=this._getPointsetId(e);t.removePointset(i)})),this._requestedPointsets.clear(),super.clearMarks(),this._paneView.clearCaches(),this.updateAllViewsAndRepaint()}hasContextMenu(){return!1}paneViews(){return this._properties.childs().visible.value()?this._paneViews:[]}updateAllViews(e){this._paneView.update(e)}onClickOutside(e,t){this._paneView.processClickOutside(e,t)}isVisible(){return this.properties().childs().visible.value()}lollipopsAtIndex(e){throw new Error("Method not implemented.")}contextMenuStatName(){return"UserDefinedTimescaleMarksContextMenu"}_initialize(){this._properties.childs().visible.setValue(!(0,mt.hideMarksOnBars)().value())}_plateViewData(e){return{text:e.text}}_getData(e){const t=this._model.mainSeries().symbolInfo();if(!t)return;const i=this.roundRange(this._rangeDifference(e)),s=this._model.mainSeries(),o=s.seriesSource().symbolInstanceId(),r=(0,Ai.getServerInterval)(s.properties().childs().interval.value());window.ChartApiInstance.getTimescaleMarks(t,i.start,i.end,(t=>{const i=this._model.chartApi();for(const e of t){e.index=null;const t=e.id,s=this._getPointsetId(t.toString()),a=this._marks[t];if(a&&null!==a.index&&(a.tickmark===e.tickmark?e.index=a.index:this._requestedPointsets.has(s)&&i.isConnected().value()&&(i.removePointset(s),
this._requestedPointsets.delete(s))),e.imageUrl&&this.addImageToStore(e.imageUrl),this._marks[t]=e,null===e.index&&i.isConnected().value()){this._requestedPointsets.add(s);const t=[[e.tickmark,0]];i.createPointset(s,"turnaround",(0,n.ensureNotNull)(o),r,t,(e=>this._onPointsetData(e)))}}this._loadedRange=this._rangeUnion(e,this._loadedRange),this.updateAllViewsAndRepaint()}),r)}_getPointsetId(e){return"pointsetMark_"+e}_onPointsetData(e){if("data_update"===e.method){const t=e.params.customId.split(/_(.+)/)[1]??"",i=this._marks[t],s=e.params.plots;i&&1===s.length&&(i.index=s[0].value[0])}this.updateAllViewsAndRepaint()}}var ki,Ei,Di=i(71382);function Bi(e,t){const{horizontalPixelRatio:i,verticalPixelRatio:s}=t,o=Math.max(1,Math.floor(i)),n=Math.round(e.x*i)+o%2/2;let r=Math.round(e.size*i);(n+r/2)%1!=0&&(r+=1);const a=Math.min(Math.max(1,Math.round(i*e.borderWidth)),r/2);let l;const c=("up"===e.direction?-1:1)*(e.yInverted?-1:1),h=c*(Math.round(e.size*s/2)+o%2);if(void 0!==e.fixedSpaceYPosition){const t=Math.round(e.fixedSpaceYPosition.itemSpacing*s),i=e.fixedSpaceYPosition.order,o=c*(r*i+t*(i+1));l=Math.round(e.fixedSpaceYPosition.basePosition*s)+o+h}else l=Math.round(e.y*s)+h;return{x:n,y:l,size:r,borderWidth:a,tickSize:o}}function Vi(e,t,i,s){if(e.save(),i&&!s.highlightByAuthor&&(e.globalAlpha=.4),s.mine)!function(e,t,i){const{borderColor:s,backgroundColor:o,doNotFill:n,direction:r,yInverted:a}=i,{x:l,y:c,borderWidth:h,size:d,tickSize:u}=Bi(i,t);e.strokeStyle=s,e.fillStyle=o,e.lineWidth=h;const _="up"===r!==a?-1:1;let p=Math.round(d/2/Math.tan(Math.PI/6))+u%2/2;(l+p/2)%1!=0&&(p-=1);e.translate(l,c+p/2*_),e.beginPath();const m=h/2;e.moveTo(0,-_*(p-m)),e.lineTo(d/2-m,h/2),e.lineTo(-d/2+m,h/2),e.lineTo(0,-_*(p-h/2)),e.closePath(),n||e.fill();e.stroke()}(e,t,s);else{let i=!1;{const e=s.image&&(o=s.image,Boolean(o&&o.imageElement&&o.imageElement.complete&&o.imageElement.naturalWidth));i=Boolean(e&&!s.showLabelWhenImageLoaded)}!function(e,t,i,s,o){const{borderColor:n,backgroundColor:r,label:a}=i,{x:l,y:c,borderWidth:h,size:d}=Bi(i,t);e.strokeStyle=n,e.fillStyle=r,e.lineWidth=h,e.beginPath();const u=d/2-h/2;e.arc(l,c,u,0,2*Math.PI,!0),e.closePath(),e.fill(),o&&function(e,t,i,s,o){if(t){const n=2*i;e.save(),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality="high",(0,$t.createCircle)(e,s,o,i),e.clip(),e.drawImage(t,s-i,o-i,n,n),e.restore()}}(e,o,u,l,c);e.stroke(),!s&&a&&d/2>=7&&(e.textAlign="center",e.textBaseline="middle",e.font=a.font,e.fillStyle=a.fontColor,(0,Kt.drawScaled)(e,t.horizontalPixelRatio,t.verticalPixelRatio,(()=>{e.fillText(a.text,l/t.horizontalPixelRatio,c/t.verticalPixelRatio)})))}(e,t,s,i,s.image?.imageElement??void 0)}var o;e.restore()}!function(e){e[e.MinRadiusToDrawText=7]="MinRadiusToDrawText"}(ki||(ki={}));class Ri{constructor(e,t,i,s){this._canvas=null,this._clickHandler=e,this._enterHandler=t,this._leaveHandler=i,this._data=s??null}setData(e){this._data=e}hitTest(e,t){if(null===this._data)return null;for(let i=this._data.items.length-1;i>=0;--i){const s=this._hitTestDot(this._data.items[i],e,t)
;if(s)return s}return null}draw(e,t){this._canvas=e.canvas,null!==this._data&&this._data.items.forEach(Vi.bind(null,e,t,this._data.highlightByAuthor))}_hitTestDot(e,t,i){const s=new Vt.Point(e.x,Bi(e,i).y/i.verticalPixelRatio);if((0,Gt.pointInCircle)(t,s,Math.max(e.size/2,8))){const t=this._canvas,i=null===t?void 0:{mouseEnterHandler:()=>this._enterHandler(e,s.y,t),mouseLeaveHandler:()=>this._leaveHandler(),clickHandler:i=>this._clickHandler(e,s.y,t,i),tapHandler:i=>this._clickHandler(e,s.y,t,i)};return new Ut.HitTestResult(Ut.HitTarget.Regular,{activeItem:e.originalItem.id,cursorType:ei.PaneCursorType.Default,...i})}return null}}!function(e){e[e.BarSpacingToSizeRatio=.8]="BarSpacingToSizeRatio",e[e.MinSize=7]="MinSize",e[e.MaxSize=553]="MaxSize"}(Ei||(Ei={}));const Ni={green:{border:(0,Rt.getHexColorByName)("color-minty-green-700"),background:(0,Rt.getHexColorByName)("color-minty-green-a600")},red:{border:(0,Rt.getHexColorByName)("color-ripe-red-700"),background:(0,Rt.getHexColorByName)("color-ripe-red-500")},neutral:{border:(0,Rt.getHexColorByName)("color-tan-orange-700"),background:(0,Rt.getHexColorByName)("color-tan-orange-500")},yellow:{border:"#EAC300",background:"#FFD400"},blue:{border:"#047ACE",background:"#0496FF"}};class Oi{constructor(e,t){this._tooltip=null,this._hoveredBarsMarkData=null,this._destroyed=!1,this._invalidated=!0,this._originalData=[],this._source=e,this._model=t,this._renderer=new Ri(this._onItemClicked.bind(this),this._showItem.bind(this),this._hideItem.bind(this)),this._createTooltipRenderer().then((e=>{this._destroyed?e?.destroy():this._tooltip=e})),e.properties().childs().visible.subscribe(null,(()=>{this._tooltip?.hide(!0)}))}destroy(){this._destroyed=!0,this._tooltip?.destroy()}source(){return this._source}update(){this._invalidated=!0}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._renderer}onClickOutside(e,t){t&&((0,Wt.isTouchMouseEvent)(t)?t.isTouch:(0,Di.isTouchEvent)(t))&&null!==this._tooltip&&!this._tooltip.contains(t.target)&&this._tooltip.hide(!0)}_extractBarMarksRendererItemData(e,t){const i=t.overridedTheme??Ni[t.theme],s=this._calculateSize(e,t),o=this._calculateY(e,s,t);return null===this._hoveredBarsMarkData||this._hoveredBarsMarkData.id!==t.id||this._hoveredBarsMarkData.x===t.x&&this._hoveredBarsMarkData.y===Math.round(o)||(this._tooltip?.hide(!0),this._hoveredBarsMarkData=null),{x:t.x,y:this._calculateY(e,s,t),direction:t.direction,borderColor:i.border,borderWidth:Fi(t),backgroundColor:i.background,size:s,doNotFill:!t.public,yInverted:t.yInverted,label:void 0===t.label?void 0:{text:t.label,fontColor:t.labelFontColor,font:(0,si.makeFont)(Math.ceil(Math.max(10,Math.min(s/2,20))),m.CHART_FONT_FAMILY,"bold")},originalItem:t}}_onItemClicked(e,t,i,s){s.isTouch&&this._showItem(e,t,i)}async _showItem(e,t,i){const s=await this._tooltipProps(e);if(null===s)return;const o=this._model.timeScale().barSpacing(),r=this._calculateSize(o,e.originalItem);this._hoveredBarsMarkData={x:e.x,y:Math.round(this._calculateY(o,r,e.originalItem)),
id:e.originalItem.id},this._tooltip?.show({itemSize:r,container:(0,n.ensureNotNull)(i.parentElement),x:e.x,y:t,factoryProps:s,onClickOutside:()=>this._tooltip?.hide(!0)})}_hideItem(){this._tooltip?.hide()}_calculateSize(e,t){return Math.min(553,Math.max(7,t.minSize,.8*e))}_updateImpl(){this._originalData=this._source.getPlatesViewData();const e=this._model.timeScale().barSpacing(),t=this._originalData.map(this._extractBarMarksRendererItemData.bind(this,e));this._renderer.setData({items:t,barSpacing:e,highlightByAuthor:!1})}}function Fi(e){return e.hovered||e.highlightByAuthor?e.overrideBorderWidth?.hoveredWidth??4:e.overrideBorderWidth?.width??2}class Wi extends Oi{async _createTooltipRenderer(){const[{TooltipRenderer:e},{UserDefinedBarsMarksTooltip:t}]=await Promise.all([Promise.all([i.e(6094),i.e(2227),i.e(8020)]).then(i.bind(i,72233)),Promise.all([i.e(6094),i.e(2227),i.e(8020)]).then(i.bind(i,60430))]);return new e(t)}_calculateY(e,t,i){const s=Math.max(1.4*i.minSize,e+4),o=("up"===i.direction?-1:1)*(i.yInverted?-1:1)*(s*(i.order+.6)+.25*s);return i.y+o}_onItemClicked(e,t,i,s){super._onItemClicked(e,t,i,s),e.originalItem.onClicked?.()}_tooltipProps(e){const t=e.originalItem.text;return t?Promise.resolve({text:t}):Promise.resolve(null)}_extractBarMarksRendererItemData(e,t){return{...super._extractBarMarksRendererItemData(e,t),showLabelWhenImageLoaded:t.showLabelWhenImageLoaded,image:t.image}}}class Hi extends Ii{constructor(e){super(e,new yi.DefaultProperty({defaultName:"UserDefinedBarsMarks",state:{visible:!0}})),this._paneView=new Wi(this,e),this._paneViews=[this._paneView],(0,mt.hideMarksOnBars)().subscribe(this,(()=>{this.properties().childs().visible.setValue(!(0,mt.hideMarksOnBars)().value())}))}destroy(){(0,mt.hideMarksOnBars)().unsubscribeAll(this),this._paneView.destroy(),super.destroy()}zorder(){return vi.sortSourcesPreOrdered.BarMarks}name(){return"UserDefinedBarsMarks"}userEditEnabled(){return!1}clearMarks(e=0){2!==e&&(super.clearMarks(),this.updateAllViewsAndRepaint())}hasContextMenu(){return!1}paneViews(){return this._properties.childs().visible.value()?this._paneViews:[]}isVisible(){return this.properties().childs().visible.value()}onClickOutside(e,t){this._paneView.onClickOutside(e,t)}contextMenuStatName(){return"UserDefinedBarsMarksContextMenu"}_initialize(){this.properties().childs().visible.setValue(!(0,mt.hideMarksOnBars)().value())}_plateViewData(e){const t={text:e.text,onClicked:e.onClicked};"object"==typeof e.color&&(t.theme="user_defined_theme",t.overridedTheme={},t.overridedTheme.border=e.color.border,t.overridedTheme.background=e.color.background);const i=(0,tt.isNumber)(e.borderWidth)?e.borderWidth:void 0,s=(0,tt.isNumber)(e.hoveredBorderWidth)?e.hoveredBorderWidth:void 0;if(void 0===i&&void 0===s||(t.overrideBorderWidth={width:i,hoveredWidth:s}),e.showLabelWhenImageLoaded&&(t.showLabelWhenImageLoaded=!0),e.imageUrl){const i=this.getImageElement(e.imageUrl);t.image=i}return t}_getData(e){const t=this._model.mainSeries().symbolInfo();if(!t)return
;const i=this.roundRange(this._rangeDifference(e)),s=(0,Ai.getServerInterval)(this._model.mainSeries().properties().childs().interval.value());window.ChartApiInstance.getMarks(t,i.start,i.end,(t=>{for(const e of t)this._marks[e.id]=e,e.imageUrl&&this.addImageToStore(e.imageUrl);this._loadedRange=this._rangeUnion(e,this._loadedRange),this.updateAllViewsAndRepaint()}),s)}}var zi=i(55396);class Ui extends st.UndoCommand{constructor(e,t){super(null),this._chartModel=e,this._targetIndex=t}redo(){const e=this._chartModel.createPane(this._targetIndex,void 0,this._paneId);this._paneId=e.id()}undo(){const e=(0,n.ensureDefined)(this._paneId),t=this._chartModel.panes().find((t=>t.id()===e));void 0!==t&&this._chartModel.removePane(t)}createdPaneId(){return this._paneId}}var ji=i(91682),Gi=i(56616);const qi=(0,ne.getLogger)("Clipboard");var $i;!function(e){e.MagicAttrName="data-tradingview-clip"}($i||($i={}));class Ki{constructor(e){this._e=e}write(e){return(0,Gi.writeImpl)(this._toRaw(e),this._e)}_toRaw(e){const t={files:[]};t.text=e.text,void 0!==e.app?t.html=this._serializeAppData(e.app,e.text):e.html&&(t.html=e.html);for(const i of e.files||[])t.files.push(i);return t}_serializeAppData(e,t){return`<meta charset="utf-8"><span data-tradingview-clip="${(0,ji.htmlEscape)(e)}">${t?(0,ji.htmlEscape)(t.slice(0,256)):"&#128200;"}</span>`}}class Yi{constructor(e){this._e=e}async read(){this._e&&0===this._e.eventPhase&&(qi.logWarn("Cannot use an already dispatched ClipboardEvent for reading"),this._e=null);const e=this._e?this._readUsingEvent(this._e):await this._readUsingApi();return this._fromRaw(e)}_readUsingEvent(e){const t=(0,n.ensure)(e.clipboardData);e.preventDefault();const i={files:[]};for(let e=0;e<t.files.length;e++)i.files.push(t.files[e]);for(let e=0;e<t.items.length;e++){const s=t.items[e];"string"===s.kind&&("text/plain"===s.type?i.text=t.getData(s.type):"text/html"===s.type?i.html=t.getData(s.type):i.files.push(new Blob([t.getData(s.type)],{type:s.type})))}return i}async _readUsingApi(){const e=(0,Gi.getClipboard)();if(!e||!e.read)throw new DOMException("ClipboardApi is not supported","NotSupportedError");let t,i;const s=[],o=await e.read();for(const e of o)for(const o of e.types)"text/html"===o?t=e.getType(o).then(this._readBlobAsText):"text/plain"===o?i=e.getType(o).then(this._readBlobAsText):s.push(e.getType(o));return{text:await i,html:await t,files:await Promise.all(s)}}_fromRaw(e){const t={};if(void 0!==e.text&&(t.text=e.text),void 0!==e.html){const i=this._parseAppData(e.html);i?t.app=i:t.html=e.html}return e.files.length>0&&(t.files=e.files),t}_parseAppData(e){if(-1===e.slice(0,1024).indexOf("data-tradingview-clip"))return;const t=(new DOMParser).parseFromString(e,"text/html").querySelector("[data-tradingview-clip]");return t?t.getAttribute("data-tradingview-clip")||"":void 0}_readBlobAsText(e){return new Promise(((t,i)=>{const s=new FileReader;s.onloadend=()=>{t(s.result)},s.onerror=()=>{i(s.error)},s.readAsText(e)}))}}class Zi{constructor(e){this._callbacks=Object.assign({},e),
this._boundOnCopy=this._onCopyEv.bind(this),this._boundOnCut=this._onCutEv.bind(this),this._boundOnPaste=this._onPasteEv.bind(this)}listen(){document.addEventListener("copy",this._boundOnCopy),document.addEventListener("cut",this._boundOnCut),document.addEventListener("paste",this._boundOnPaste)}async peek(){if("granted"!==(await navigator.permissions.query({name:"clipboard-read"})).state)throw new Error("clipboard-read is not granted");return new Yi(null).read()}uiRequestCopy(e){this._callbacks.copyRequested&&this._callbacks.copyRequested(new Ki(null),e)}uiRequestCut(e){this._callbacks.cutRequested&&this._callbacks.cutRequested(new Ki(null),e)}uiRequestPaste(e){this._callbacks.pasteRequested&&this._callbacks.pasteRequested(new Yi(null),e)}destroy(){document.removeEventListener("copy",this._boundOnCopy),document.removeEventListener("cut",this._boundOnCut),document.removeEventListener("paste",this._boundOnPaste)}_onCopyEv(e){e.defaultPrevented||this._callbacks.copyRequested&&this._callbacks.copyRequested(new Ki(e))}_onCutEv(e){e.defaultPrevented||this._callbacks.cutRequested&&this._callbacks.cutRequested(new Ki(e))}_onPasteEv(e){e.defaultPrevented||this._callbacks.pasteRequested&&this._callbacks.pasteRequested(new Yi(e))}}var Xi=i(35749);function Ji(e){const t=e.target;return null!==t&&1===t.nodeType&&(0,Xi.isTextEditingField)(t)}function Qi(e){const t=e.target;if(null===t)return!1;const i=(t.ownerDocument||t).getSelection();return null!==i&&!i.isCollapsed}class es extends Zi{_onCopyEv(e){if(!Ji(e)&&!Qi(e))return super._onCopyEv(e)}_onCutEv(e){if(!Ji(e)&&!Qi(e))return super._onCutEv(e)}_onPasteEv(e){if(!Ji(e))return super._onPasteEv(e)}}const ts=new dt.TranslatedString("apply toolbars theme",a.t(null,void 0,i(86708)));class is extends st.UndoCommand{constructor(e,t,i=!0){super(ts),this._prevThemeName=e,this._themeName=t,this._syncState=i}undo(){(0,L.isStdThemeName)(this._prevThemeName)&&((0,k.setTheme)(this._prevThemeName),this._syncState&&(0,L.syncTheme)())}redo(){(0,L.isStdThemeName)(this._themeName.toLowerCase())&&((0,k.setTheme)(this._themeName.toLowerCase()),this._syncState&&(0,L.syncTheme)())}}var ss=i(11751),os=i(72972),ns=i(19844);i(26352);const rs=new dt.TranslatedString("apply indicators to entire layout",a.t(null,void 0,i(70507))),as=new dt.TranslatedString("apply chart theme",a.t(null,void 0,i(68231)));a.t(null,void 0,i(28298)),a.t(null,void 0,i(78972)),a.t(null,void 0,i(10615)),a.t(null,void 0,i(81518)),a.t(null,void 0,i(92101)),a.t(null,void 0,i(94656));function ls(e,t){for(const i of e.sources){if("study"!==i.type)return!0;if(t.checkIfFeatureAvailable(new ns.StudyMetaInfo(i.source.metaInfo),[]))return!0}return!1}function cs(e){return function(e){return Mt().then((t=>t.downloadClientScreenshot(e)))}(e)}function hs(e){return function(e){return Mt().then((t=>t.copyToClipboardClientScreenshot(e)))}(e).then((()=>{(0,ee.emit)("onClientScreenshotCopiedToClipboard")}))}const ds={s:0,"2h":0,"2v":1,"3h":0,"3v":2,"3s":0,"3r":1,"2-1":1,"1-2":1,4:1,"4v":3,"4h":0,"4s":0,"4s-l":0,"1-3":1,"3-1":3,"2-2-l":0,"2-2-r":1,
"2-2":3,"1-4":1,"5h":0,"5v":0,"5s":0,"5s-l":0,"2-3":2,"3-2":3,"4-1":4,"2-3-l":0,"2-3-r":2,6:1,"6h":0,"6v":0,"6c":4,"2-4":2,"4-2":4,"4-3":4,"7h":0,"7s":0,8:1,"8c":6,"8h":0,"8v":0,"9s":6,"5-4":5,"9h":0,"9v":0,"10c5":1,"10h":0,"10v":0,"12c6":1,"12c4":3,"12h":0,"14c7":1,"16c8":1,"16c4":3};async function us(e,t=this.activeChartWidget.value()){return!!t&&(this.setChartStyle(t,e),!0)}var _s=i(62548),ps=i(15943),ms=i(24317),gs=i(29970),fs=i(31237);function ys(e,t){const i=Object.create(Object.getPrototypeOf(e));for(const s of t)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=e[s]);return i}var vs=i(96937),Ss=i(90995);let bs;class ws extends X.DialogRenderer{constructor(){super(),this._dialog=null,this._subscribe=e=>{this._setVisibility(e)}}show(){this._load().then((e=>e.show()))}hide(){this._dialog?.hide()}static getInstance(){return bs||(bs=new ws),bs}_load(){return Promise.all([i.e(4856),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(8933),i.e(6032),i.e(3672),i.e(3359),i.e(8894),i.e(5743),i.e(7827),i.e(9836),i.e(1450),i.e(4719),i.e(2227),i.e(4931),i.e(7437),i.e(9418),i.e(3179),i.e(6193),i.e(5386),i.e(4862)]).then(i.bind(i,73536)).then((e=>(this._dialog?.hide(),this._dialog?.visible().unsubscribe(this._subscribe),this._dialog=new e.ObjectTreeDialogRenderer,this._dialog.visible().subscribe(this._subscribe),this._dialog)))}}var Cs,Ts=i(69422),Ps=i(43337);async function xs(e,t,s,o,n,r="default"){let l,c=[];const h=e.model().model(),d=(0,tt.clone)(t),u=new Ps.Property({inputs:d}),_=function(e,t){return"symbol"===t?e.inputs.filter((t=>t.id===e.symbolInputId())):e.inputs.filter((e=>e.confirm))}(s,r),p=()=>{l&&h.removeCustomSource(l)},m=()=>{p(),n()},g=e=>{o({inputs:e,parentSources:c}),p()},f=_.filter(Ts.isTimeOrPriceNotHiddenInput);if(f.length>0)try{const t=await Promise.all([i.e(5234),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(3672),i.e(2537),i.e(3359),i.e(8894),i.e(5743),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(9487),i.e(445),i.e(846),i.e(8220),i.e(3329),i.e(9970),i.e(6052),i.e(9590),i.e(4678),i.e(9965),i.e(9742),i.e(4248),i.e(2227),i.e(4931),i.e(9418),i.e(4426),i.e(9026),i.e(9928),i.e(8604),i.e(5893),i.e(3030)]).then(i.bind(i,73339)),o=await t.selectInputValuesOnChart(e,f,u,s.shortDescription,s.inputs);if(l=o.customSourceId,o.destPane&&ns.StudyMetaInfo.getSourceInputIds(s).length>0){const e=o.destPane.mainDataSource();c=e===h.mainSeries()?[]:[e]}else c=[]}catch(e){return void m()}f.length!==_.length?Promise.all([i.e(5234),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(3672),i.e(2537),i.e(3359),i.e(8894),i.e(5743),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(9487),i.e(445),i.e(846),i.e(8220),i.e(3329),i.e(9970),i.e(6052),i.e(9590),i.e(4678),i.e(9965),i.e(9742),i.e(4248),i.e(2227),i.e(4931),i.e(9418),i.e(4426),i.e(9026),i.e(9928),i.e(8604),i.e(5893),i.e(3030)]).then(i.bind(i,29638)).then((t=>{const o=new t.ConfirmInputsDialogRenderer(function(e){
if("symbol"===e)return a.t(null,void 0,i(46501));return a.t(null,void 0,i(48141))}(r),_,u,r,s,e.model(),g,m);return o.show(),o})):g(u.state().inputs||{})}!function(e){e.Default="default",e.Symbol="symbol"}(Cs||(Cs={}));let Ms=null;var Is=i(25338),As=(i(40987),i(50470)),Ls=i(58096);class ks{constructor(e){this._shown=!1,this._el=(0,As.parseHtmlElement)(function(e=""){return`<div class="tv-spinner ${e}" role="progressbar"></div>`}()),this.setSize(Ls.spinnerSizeMap[e||Ls.DEFAULT_SIZE])}spin(e){return this._el.classList.add("tv-spinner--shown"),void 0===this._container&&(this._container=e,void 0!==e&&e.appendChild(this._el)),this._shown=!0,this}stop(e){return e&&void 0!==this._container&&this._container.removeChild(this._el),this._el&&this._el.classList.remove("tv-spinner--shown"),this._shown=!1,this}setStyle(e){return Object.keys(e).forEach((t=>{const i=e[t];void 0!==i&&this._el.style.setProperty(t,i)})),this}style(){return this._el.style}setSize(e){const t=void 0!==e?`tv-spinner--size_${e}`:"";return this._el.className=`tv-spinner ${t} ${this._shown?"tv-spinner--shown":""}`,this}getEl(){return this._el}destroy(){this.stop(),delete this._el,delete this._container}}function Es(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ds(e){return e.reduce(((e,t)=>{for(const i in t)if(Es(t,i)){const s=t[i],o=e[i];o?o.push(s):e[i]=[s]}return e}),{})}var Bs,Vs=i(75579);!function(e){e[e.AccelerationPerMSecPixels=.003]="AccelerationPerMSecPixels",e[e.MaxSpeedPerMSecPixels=1.1]="MaxSpeedPerMSecPixels"}(Bs||(Bs={}));class Rs{constructor(e){this._chartModel=null,this._animation=null,this._chart=e,this._chart.withModel(this,(()=>{this._chartModel=this._chart.model()}))}destroy(){this._animation?.stop()}move(e){if(null!==this._chartModel){if(this._chartModel.timeScale().isEmpty())return;const t=.003,i=1.1,s=Math.round(i/t);this._moveImpl(((o,n,r)=>{const a=Math.min(n,s),l=e*t*Math.pow(a,2)/2;if(n<=s)return o+l;const c=Number.isFinite(r)?Math.max(0,s-r):0;return o+l+e*(n-a-c)*i+e*(i*c-t*Math.pow(c,2)/2)}),(e=>Math.max(0,s-e)+s))}}moveByBar(e){if(null!==this._chartModel){const t=this._chartModel.timeScale(),i=t.visibleBarsStrictRange();if(t.isEmpty()||null===i)return;const s=300,o=i.lastBar();this._moveImpl(((i,n)=>{const r=Math.floor(Math.max(0,n-s)/100)+1,a=o+e*r,l=t.indexToCoordinate(o);return i+(t.indexToCoordinate(a)-l)}),(()=>0),!0)}}stopMove(){this._animation?.stop(),this._animation=null}scrollToRealtime(e,t){if(null===this._chartModel)return;this._chartModel.timeScale().scrollToRealtime(e,t);const i=this._chart.chartWidgetCollection();!i.lock.dateRange.value()&&i.lock.trackTime.value()&&i.chartModels().value().forEach((t=>{t!==this._chartModel&&t.timeScale().scrollToRealtime(e)}))}scrollToFirstBar(){this._chartModel?.timeScale().scrollToFirstBar()}_moveImpl(e,t,i){if(null===this._chartModel)return;const s=this._chartModel.timeScale();if(s.isEmpty())return;if(i&&null!==s.visibleBarsStrictRange()){const e=s.indexToCoordinate(s.visibleBarsStrictRange().lastBar())+s.barSpacing()/2
;Math.abs(s.width()-e)>s.barSpacing()/6&&s.setRightOffset(Math.round(s.rightOffset()))}const o=performance.now();let n=1/0;this._animation={getStartPosition:()=>0,getPosition:t=>(t=Math.min(n,t),e(0,t-o,n-t)),finished:e=>e>=n,stop:()=>{const e=performance.now()-o;n=performance.now()+t(e)}},this._chartModel.model().stopTimeScaleAnimation(),this._chartModel.model().setTimeScaleAnimation(this._animation)}}var Ns=i(70002);let Os=null;function Fs(e,t,s,o,n){return Promise.all([i.e(3240),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(6032),i.e(3672),i.e(2537),i.e(3359),i.e(8894),i.e(5743),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(1979),i.e(4495),i.e(9487),i.e(445),i.e(846),i.e(9323),i.e(8220),i.e(3329),i.e(9970),i.e(6052),i.e(844),i.e(9590),i.e(4678),i.e(159),i.e(9965),i.e(9742),i.e(6043),i.e(4059),i.e(1488),i.e(6697),i.e(903),i.e(5445),i.e(2227),i.e(4931),i.e(9418),i.e(4426),i.e(9026),i.e(769),i.e(9928),i.e(8604),i.e(5893),i.e(624),i.e(6265)]).then(i.bind(i,12981)).then((i=>{Os?.hide();const r=i.EditObjectDialogRenderer;return Os=new r(e,t,o,n),Os.show(s),Os}))}var Ws=i(2088);let Hs=null;var zs=i(26610),Us=i(35107);const js={[Ns.TabNames.symbol]:"symbol",[Ns.TabNames.legend]:"legend",[Ns.TabNames.scales]:"scales",[Ns.TabNames.trading]:"trading",[Ns.TabNames.events]:"events",[Ns.TabNames.alerts]:"alerts",[Ns.TabNames.timezoneSessions]:"canvas",[Ns.TabNames.text]:"text",[Ns.TabNames.style]:"style",[Ns.TabNames.visibility]:"visibility"},Gs={[Ns.TabNames.style]:"style",[Ns.TabNames.visibility]:"visibilities"};async function qs(e,t,s={},o,n){const r=o.activeChartWidget.value(),{initialTab:a,tabName:l}=s;if(l&&!a&&(s.initialTab=Gs[l]),(0,Us.isStudyLineTool)(e)&&function(e){if(!(0,Us.isStudyLineTool)(e))return!1;return["LineToolFixedRangeVolumeProfile","LineToolVbPFixed",null].filter(tt.notNull).some((t=>e.toolname===t))}(e))return r.propertiesDefinitionsForSource(e).then((i=>null!==i?Fs(e,t,s,n,i):null));if((0,Ws.isStudy)(e)&&function(e){const{shortId:t}=e.metaInfo();return"Overlay"===t}(e)||(0,zs.isLineTool)(e))return r.propertiesDefinitionsForSource(e).then((o=>{if(null!==o){return function(e){return Promise.all([i.e(4752),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(6032),i.e(3672),i.e(2537),i.e(3359),i.e(8894),i.e(5743),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(1979),i.e(4495),i.e(9487),i.e(445),i.e(846),i.e(9323),i.e(8220),i.e(3329),i.e(9970),i.e(6052),i.e(9590),i.e(4678),i.e(159),i.e(9965),i.e(9742),i.e(6043),i.e(4059),i.e(1488),i.e(903),i.e(4633),i.e(2227),i.e(4931),i.e(9418),i.e(4426),i.e(9026),i.e(769),i.e(9928),i.e(8604),i.e(5893),i.e(624),i.e(6780)]).then(i.bind(i,75892)).then((t=>{Hs?.hide();const i=t.SourcePropertiesEditorRenderer;return Hs=new i(e),Hs.show({shouldReturnFocus:e.shouldReturnFocus}),Hs}))}({propertyPages:o,model:t,source:e,activePageId:l&&js[l],shouldReturnFocus:s.shouldReturnFocus})}return null}));if((0,Ws.isStudyStub)(e))return null;if((0,Ws.isStudy)(e))return Fs(e,t,s,n);{
const e=l&&js[l],t=o.getChartPropertiesDialogRenderer();return t.setActivePage(e),t.show(s)}}var $s=i(24633);async function Ks(){return(await Promise.all([i.e(1171),i.e(7682),i.e(2227),i.e(139)]).then(i.bind(i,81200))).ErrorCardRenderer}var Ys=i(55014),Zs=i(89837);const Xs=(0,Rt.getHexColorByName)("color-cold-gray-700"),Js=(0,Rt.getHexColorByName)("color-cold-gray-400"),Qs=(0,Rt.getHexColorByName)("color-cold-gray-900"),eo=(0,Rt.getHexColorByName)("color-white"),to=a.t(null,void 0,i(18905)),io=a.t(null,void 0,i(63245));function so(e){return e?{...e,message:(0,Ys.formatStudyError)(e.message),rawHtml:!0}:null}class oo{constructor(e,t=!1){this._container=null,this._errorCardRenderer=null,this._mainSeriesErrorMessage=null,this._banErrorMessage=new O.WatchedValue(null).spawn(),this._hasError=new O.WatchedValue(!1),this._renderInsideContainer=!1,this._errorMessageHandler=e=>{this._hasError.setValue(null!==e),e=so(e),!this._renderInsideContainer&&this._chartWidget.hasModel()?this._updatePaneWidgets(e):this._renderErrorWithoutModel(e)},this._chartWidget=e,this._renderInsideContainer=t,this._subscribeToMainSeriesErrors()}destroy(){this._mainSeriesErrorMessage?.destroy(),this._banErrorMessage.destroy(),this._errorCardRenderer?.then((e=>{e.container.remove(),e.destroy()}))}updatePaneWidgets(){this._updatePaneWidgets()}setContainer(e){if(this._container!==e){this._container=e,this._errorCardRenderer?.then((e=>e.container.remove()));const t=this._getErrorMessage();t&&this._errorMessageHandler(t)}}hasError(){return this._hasError.readonly()}_updatePaneWidgets(e=this._getErrorMessage()){this._chartWidget.paneWidgets().forEach((t=>t.setErrorMessage(e)))}async _renderErrorWithoutModel(e){if(null===this._container||null===e&&null===this._errorCardRenderer)return;const t=await this._getErrorCardRenderer();this._container.contains(t.container)||this._container.appendChild(t.container),t.update(this._createErrorCardRendererState(e))}async _getErrorCardRenderer(){return this._errorCardRenderer||(this._errorCardRenderer=this._createErrorCardRenderer())}async _createErrorCardRenderer(){return new(await Ks())}_createErrorCardRendererState(e){return e?{message:e.message,icon:e.icon,textColor:k.watchedTheme.value()===$s.StdTheme.Dark?Js:Xs,backgroundColor:k.watchedTheme.value()===$s.StdTheme.Dark?Qs:eo,solutionId:e.solutionId,rawHtml:e.rawHtml,buttons:e.buttons}:{message:null}}_subscribeToMainSeriesErrors(){const e=this._chartWidget;e.withModel(this,(()=>{const t=e.model().model().mainSeries();this._mainSeriesErrorMessage=(0,ft.combine)(((t,s)=>{if(t)return t;if(null===s)return null;switch(s.type){case"invalid_symbol":return this._createErrorParamsForInvalidSymbol(e);case"calculations_error":return{message:s.errorMessage,icon:"attention"};case"no_data":return{message:a.t(null,void 0,i(36252)),icon:"ghost"};case"unsupported_resolution":return this._createErrorParamsForUnsupportedResolution(e)}}),this._banErrorMessage.weakReference(),(0,xt.getSeriesDisplayErrorWV)(t).ownership()),this._mainSeriesErrorMessage.subscribe(this._errorMessageHandler,{
callWithLast:!0})}))}_createErrorParamsForInvalidSymbol(e){return{message:`<b>${a.t(null,void 0,i(52969))}</b><br />${a.t(null,void 0,i(53272))}`,icon:"ghost",rawHtml:!0,maxHeight:400,zeroHeight:200,buttons:[{name:io,onClick:async()=>{e.setActive(!0);const t=e.model().mainSeries(),i=t.symbol(),s=t.properties().childs().shortName.value(),o="option"===t.symbolInfo()?.type,n=t.symbolInfo()?.pro_name;let r=t.isSpread()?i:s||i||"";if(l.enabled("symbol_search_option_chain_selector")&&o&&n){const e=await resolveUnderlyingSymbol(n);e&&(r={type:"option",value:n,underlying:e})}(0,vs.showDialog)({defaultValue:r,enableOptionsChain:l.enabled("symbol_search_option_chain_selector")})}}]}}_createErrorParamsForUnsupportedResolution(e){const t=e.model().mainSeries().unsupportedResolutionState().value();return null===t?null:{message:(0,Zs.getErrorFromUnsupportedResolutionState)(t,!0),icon:"unsupported-resolution",rawHtml:!0,maxHeight:400,zeroHeight:200,buttons:[{name:to.format({resolution:t.applicableResolution}),onClick:()=>{e.setActive(!0),de.linking.setIntervalAndLogInitiator(t.applicableResolution,"Error state")}}]}}_getErrorMessage(){return so(this._banErrorMessage.value()||this._mainSeriesErrorMessage?.value()||null)}}var no,ro=i(59239),ao=i(51304),lo=i(39612),co=i(93201),ho=i(98155),uo=i(11044);class _o{constructor(e,t){this._showed=!1,this._additionalReadyPromise=null,this._cw=e,this._element=document.createElement("div"),this._element.classList.add(uo.screen),t.appendChild(this._element),this._cw.withModel(this,this._connectToModel)}destroy(){this.hide(),this._element.remove()}show(e,t){if(e){const e=this._cw.model().mainSeries().status();if(1!==e&&2!==e)return}this._additionalReadyPromise=t,this._cw.setInLoadingState(!0),this._showed||(this._showed=!0,this._show())}hide(){this._cw.setInLoadingState(!1),this._showed&&this._hide()}isShown(){return this._showed}_connectToModel(){const e=this._cw.model().mainSeries(),t=e.dataEvents();t.symbolError().subscribe(this,(e=>{e!==ho.permissionDenied&&this.hide()})),t.seriesError().subscribe(this,(()=>{(0,l.enabled)("hide_loading_screen_on_series_error")&&this.hide()})),e.statusWV().subscribe((e=>{if(4!==e&&12!==e&&13!==e&&14!==e||this.hide(),bt.seriesReadyStatuses.has(e)){const e=this._additionalReadyPromise;e?e.then((()=>{this.hide()})):this.hide()}}))}_show(){const e=this._cw.properties().childs().paneProperties.childs();let t;if(e.backgroundType.value()===co.ColorType.Solid)t=e.background.value();else{t=`linear-gradient(${e.backgroundGradientStartColor.value()},${e.backgroundGradientEndColor.value()})`}this._element.style.background=t,this._element.classList.add(uo.fade)}_hide(){this._showed=!1,this._element.classList.remove(uo.fade)}}function po(e,t){let{deltaX:i,deltaY:s}=e;switch(i/=100,s/=100,t.deltaMode){case t.DOM_DELTA_PAGE:i*=120,s*=120;break;case t.DOM_DELTA_LINE:i*=32,s*=32}return{deltaX:i,deltaY:s}}!function(e){e[e.MaxNextEventDelay=100]="MaxNextEventDelay",e[e.IgnoreSmallerDeltaCoeff=3]="IgnoreSmallerDeltaCoeff"}(no||(no={}));class mo{constructor(){this._totalDeltaX=0,
this._totalDeltaY=0,this._prevWheelTime=0}processWheel(e){e.timeStamp-this._prevWheelTime>100&&this._reset();const t=!(0,ze.isMac)()&&e.shiftKey,i=t?-e.deltaY:e.deltaX,s=t?e.deltaX:e.deltaY;this._totalDeltaX+=i,this._totalDeltaY+=s,this._prevWheelTime=e.timeStamp;const o={deltaX:i,deltaY:s};return 0===this._totalDeltaX||0===this._totalDeltaY||(Math.abs(this._totalDeltaX)>=Math.abs(3*this._totalDeltaY)&&(o.deltaY=0),Math.abs(this._totalDeltaY)>=Math.abs(3*this._totalDeltaX)&&(o.deltaX=0)),po(o,e)}_reset(){this._totalDeltaX=0,this._totalDeltaY=0}}var go,fo=i(77914),yo=i(15266);!function(e){e[e.Height=1]="Height",e[e.MinPaneHeight=30]="MinPaneHeight"}(go||(go={}));class vo{constructor(e,t,i){this._handleEl=null,this._resizeInfo=null,this._colorCache={lineColor:"",backgroundColor:"",color:""},this._selected=new O.WatchedValue,this._chart=e,this._topPaneIndex=t,this._bottomPaneIndex=i,this._element=document.createElement("div"),this._element.classList.add(yo.paneSeparator),this._element.style.background=this._color(),this.adjustSize(),this._element.addEventListener("click",(()=>{}));const s=document.createElement("div");s.classList.add(yo.handle),this._element.appendChild(s),this._mouseEventHandler=new Wt.MouseEventHandler(s,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._handleEl=s,this._handleEl.classList.toggle(yo.mobile,ze.CheckMobile.any()),this._element.setAttribute("aria-hidden","true"),this._selected.subscribe((e=>this._handleEl?.classList.toggle(yo.selected,e)))}destroy(){this._mouseEventHandler.destroy(),this._element.parentElement&&this._element.parentElement.removeChild(this._element)}topPaneIndex(){return this._topPaneIndex}bottomPaneIndex(){return this._bottomPaneIndex}getElement(){return this._element}hide(){this._element.classList.add("js-hidden")}show(){this._element.classList.remove("js-hidden")}selected(){return this._selected.readonly()}adjustSize(){this._element.style.height=vo.height()+"px"}mouseEnterEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0);null!==t&&null!==i&&(0,n.ensureNotNull)(this._handleEl).classList.add(yo.hovered)}mouseLeaveEvent(e){(0,n.ensureNotNull)(this._handleEl).classList.remove(yo.hovered)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}tapEvent(){this._selected.setValue(!this._selected.value())}touchStartEvent(e){this._selected.value()&&this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._selected.value()&&this._pressedMouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._selected.value()&&this._mouseUpOrTouchEndEvent(e)}touchStartOutsideEvent(){this._selected.setValue(!1)}update(){this._element.style.background=this._color().toString()}paint(){}image(){const{topPane:e}=this._topBottomPane(!1),t=e.leftPriceAxisesContainer().getWidth(),i=e.width(),s=e.rightPriceAxisesContainer().getWidth(),o=this._color(),n=(0,Kt.createDisconnectedCanvas)(document,(0,Ft.size)({width:t,height:1})),r=(0,Kt.getPrescaledContext2D)(n)
;r.fillStyle=o,r.fillRect(0,0,t,1);const a=(0,Kt.createDisconnectedCanvas)(document,(0,Ft.size)({width:i,height:1})),l=(0,Kt.getPrescaledContext2D)(a);l.fillStyle=o,l.fillRect(0,0,i,1);const c=(0,Kt.createDisconnectedCanvas)(document,(0,Ft.size)({width:s,height:1})),h=(0,Kt.getPrescaledContext2D)(c);return h.fillStyle=o,h.fillRect(0,0,s,1),{type:"separator",leftAxis:{content:n.toDataURL(),canvas:n,contentWidth:t,contentHeight:1},rightAxis:{content:c.toDataURL(),canvas:c,contentWidth:s,contentHeight:1},content:a.toDataURL(),canvas:a,contentWidth:i,contentHeight:1}}static height(){const e=window.devicePixelRatio||1;return e>=1?1:1/e}_mouseDownOrTouchStartEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0);if(null===t||null===i)return;const s=t.state().stretchFactor()+i.state().stretchFactor(),o=s/(t.height()+i.height()),r=30*o;s<=2*r||(this._resizeInfo={startY:e.pageY,prevStretchTopPane:t.state().stretchFactor(),maxPaneStretch:s-r,totalStretch:s,pixelStretchFactor:o,minPaneStretch:r},(0,n.ensureNotNull)(this._handleEl).classList.add(yo.active))}_pressedMouseOrTouchMoveEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0),s=this._resizeInfo;if(null===s||null===t||null===i)return;const o=(e.pageY-s.startY)*s.pixelStretchFactor,n=(0,fo.clamp)(s.prevStretchTopPane+o,s.minPaneStretch,s.maxPaneStretch);t.state().setStretchFactor(n),i.state().setStretchFactor(s.totalStretch-n),this._chart.model().model().fullUpdate()}_mouseUpOrTouchEndEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0),s=this._resizeInfo;null!==s&&null!==t&&null!==i&&(this._chart.model().addPaneStretchFactorUndoCommand(t.state(),i.state(),s.prevStretchTopPane,t.state().stretchFactor()),this._resizeInfo=null,(0,n.ensureNotNull)(this._handleEl).classList.remove(yo.active))}_color(){const e=this._chart.properties().childs().paneProperties.childs().separatorColor.value(),t=this._chart.model().model().backgroundColor().value();if(this._colorCache.lineColor!==e||this._colorCache.backgroundColor!==t){const i=(0,Nt.parseRgba)(t),s=(0,Nt.parseRgba)(e),o=0===i[3]&&0===s[3]?"rgba(0,0,0,0)":(0,Nt.rgbaToString)((0,Nt.blendRgba)(i,s));this._colorCache={lineColor:e,backgroundColor:t,color:o}}return this._colorCache.color}_topBottomPane(e){const t=this._chart.paneWidgets();let i=null,s=null;for(let s=this._topPaneIndex;s>=0;--s){const o=t[s];if(!e||!o.state().collapsed().value()){i=o;break}}for(let i=this._bottomPaneIndex;i<t.length;++i){const o=t[i];if(!e||!o.state().collapsed().value()){s=o;break}}return{topPane:i,bottomPane:s}}}var So,bo,wo=i(59998),Co=i(86572),To=i(93946),Po=i(7543),xo=i(58570),Mo=i(87347),Io=i(31269),Ao=i(94194),Lo=i(7983);!function(e){e[e.LabelRadius=9.5]="LabelRadius",e[e.LabelFontSize=11]="LabelFontSize"}(So||(So={})),function(e){e[e.Gear=0]="Gear",e[e.Symbol=1]="Symbol",e[e.Auto=2]="Auto"}(bo||(bo={}));const ko={enableTooltip:!0,showLabels:!0,enableMenu:!0,enableHighlight:!0};function Eo(e,t){return Math.max(1,Math.floor(e.borderSize*t))}class Do{constructor(e,t,i,s,o,n=null){this._size=(0,Ft.size)({width:0,height:0}),
this._offset=0,this._axisInfo=null,this._onLabelHovered=new ae.Delegate,this._font=(0,si.makeFont)(11,m.CHART_FONT_FAMILY),this._highlighted=!1,this._isContextMenuOpened=!1,this._isMouseOverStub=!1,this._labelMode=2,this._fixedLabelMode=null,this._textWidthCache=new Qt.TextWidthCache(5),this._gearRenderer=(0,Mo.svgRenderer)(Lo),this._canvasConfiguredHandler=()=>{this.update(),this._textWidthCache.reset()},this._timeAxisWidget=n,this._isLeft="left"===e;const{rendererOptionsProvider:r,sourcesTitlesProvider:a,contextMenuItemsProvider:l,backgroundBasedTheme:c,onActiveOrHoveredChart:h=new O.WatchedValue(!1).ownership(),requestRepaint:d,getBackgroundTopColor:u,getBackgroundBottomColor:_,showHorizontalBorder:p}=s;this._rendererOptionsProvider=r,this._sourcesTitlesProvider=a,this._contextMenuItemsProvider=l,this._backgroundBasedTheme=c,this._onActiveOrHoveredChart=h,this._requestRepaint=d,this._getBackgroundTopColor=u,this._getBackgroundBottomColor=_,this._showHorizontalBorder=Boolean(p),this._properties=t,this._axisInfo=i,this._labelOptions={...ko,...o},this._cell=document.createElement("div"),this._labelOptions.enableTooltip&&this._cell.classList.add("apply-common-tooltip"),this._cell.style.width="25px",this._cell.style.height="100%",this._cell.style.position="absolute",this._cell.style.left="0",this._cell.style.overflow="hidden",this._labelOptions.showLabels&&(this._labelOptions.enableTooltip&&(0,Ao.setTooltipData)(this._cell,"text",(e=>this._tooltipContent())),this._onActiveOrHoveredChart.subscribe(d)),this._properties.lineColor.subscribe(this,(()=>this._requestRepaint())),this._mouseEventHandler=new Wt.MouseEventHandler(this._cell,this,{treatHorzTouchDragAsPageScroll:!0,treatVertTouchDragAsPageScroll:!0}),this._canvasBinding=(0,Kt.createBoundCanvas)(this._cell,(0,Ft.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const g=this._canvasBinding.canvasElement;g.style.position="absolute",g.style.left="0",g.style.top="0",this._cell.setAttribute("aria-hidden","true")}destroy(){this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._properties.lineColor.unsubscribeAll(this),this._mouseEventHandler.destroy(),this._backgroundBasedTheme.release(),this._onActiveOrHoveredChart.unsubscribe(this._requestRepaint),this._onActiveOrHoveredChart.release()}mouseEnterEvent(e){this._mouseOrTouchEnterEvent(e)}touchStartEvent(e){this._mouseOrTouchEnterEvent(e)}mouseLeaveEvent(e){this._mouseOrTouchLeaveEvent(e)}touchEndEvent(e){this._mouseOrTouchLeaveEvent(e)}mouseClickEvent(e){this._mouseClickOrTapEvent(e)}tapEvent(e){this._mouseClickOrTapEvent(e)}update(){}getElement(){return this._cell}onLabelHovered(){return this._onLabelHovered}setSizeAndOffset(e,t){(0,Ft.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._cell.style.width=`${e.width}px`,this._cell.style.minWidth=`${e.width}px`,this._cell.style.height=`${e.height}px`),this._offset!==t&&(this._offset=t,
this._cell.style.left=`${t}px`)}paint(e){0!==this._size.width&&0!==this._size.height&&(e.level===ao.InvalidationLevel.Full||e.invalidateStubs)&&((0,Kt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),this._paintImpl((0,Kt.getContext2D)(this._canvasBinding.canvasElement),(0,Kt.getBindingRenderingInfo)(this._canvasBinding)))}getWidth(){return this._size.width}getImage(){const e=(0,Kt.getBindingRenderingInfo)(this._canvasBinding),t=(0,Kt.createDisconnectedCanvasByRenderingInfo)(document,e);return this._paintImpl((0,Kt.getContext2D)(t),e,!0),t}setLabelMode(e){e!==this._labelMode&&(this._labelMode=e,this._cell.classList.toggle("apply-common-tooltip",1!==e&&this._labelOptions.enableTooltip))}_paintImpl(e,t,i){this._drawBackground(e,t),this._drawVerticalBorder(e,t),this._showHorizontalBorder&&this._drawHorizontalBorder(e,t),this._labelOptions.showLabels&&this._drawLabel(e,t,i)}_setHighlighted(e){this._labelOptions.enableHighlight&&(this._onLabelHovered.fire("stubButton",e),this._highlighted!==e&&(this._highlighted=e),this._requestRepaint())}_drawVerticalBorder(e,t){e.save(),e.fillStyle=this._vertBorderColor();const i=Eo(this._rendererOptionsProvider.options(),t.horizontalPixelRatio),s=this._isLeft?t.bitmapSize.width-i:0;e.fillRect(s,0,i,t.bitmapSize.height),e.restore()}_drawHorizontalBorder(e,t){e.save(),e.fillStyle=this._horzBorderColor();const i=Eo(this._rendererOptionsProvider.options(),t.verticalPixelRatio),s=this._isLeft?0:i;e.fillRect(s,0,t.bitmapSize.width-i,i),e.restore()}_drawBackground(e,t){const i=this._getBackgroundTopColor(),s=this._getBackgroundBottomColor(),{bitmapSize:o}=t;if(i===s?(0,Kt.clearRect)(e,0,0,o.width,o.height,i):(0,$t.clearRectWithGradient)(e,0,0,o.width,o.height,i,s),this._highlighted){const t=L.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight");(0,Kt.fillRect)(e,0,0,o.width,o.height,t),e.globalAlpha=1}}_drawLabel(e,t,i){const s=this._backgroundBasedTheme.value(),o=this._axisInfo;if(null===o||!i&&!this._onActiveOrHoveredChart.value())return;const{bitmapSize:n,horizontalPixelRatio:r,verticalPixelRatio:a}=t,l=Eo(this._rendererOptionsProvider.options(),r),c=Math.round(n.width)-l,h=Eo(this._rendererOptionsProvider.options(),a),d=Math.round(n.height)-h,u=(0,Vt.point)(l+c/2,h+d/2);if(1===this._labelMode||2===this._labelMode&&(!this._highlighted||i)){e.fillStyle=L.themes[s].getThemedColor("color-price-axis-label-back"),e.globalAlpha=.5,e.beginPath(),e.arc(u.x,u.y,9.5*r,0,2*Math.PI,!0),e.fill(),e.globalAlpha=1,e.fillStyle=L.themes[s].getThemedColor("color-price-axis-label-text"),e.font=this._font,e.textAlign="center",e.textBaseline="middle";const t=this._textWidthCache.yMidCorrection(e,o.label);(0,Kt.drawScaled)(e,r,a,(()=>{e.fillText(o.label,u.x/r,u.y/a+t)}))}else if(!i&&this._onActiveOrHoveredChart.value()){const t=this._gearRenderer.viewBox(),i=Math.round(u.x-t.width*r/2),o=Math.round(u.y-t.height*a/2);e.fillStyle=L.themes[s].getThemedColor("color-text-primary"),e.imageSmoothingQuality="high",this._gearRenderer.render(e,{targetViewBox:{x:i,y:o,
width:t.width*r,height:t.height*a},doNotApplyColors:!0})}}_vertBorderColor(){return this._properties.lineColor.value()}_horzBorderColor(){return this._timeAxisWidget?.lineColor()??this._vertBorderColor()}_tooltipContent(){return this._sourcesTitlesProvider().join("\n")}_mouseOrTouchEnterEvent(e){this._isMouseOverStub=!0,this._labelOptions.showLabels&&this._labelOptions.enableHighlight&&!this._timeAxisWidget?.chart.model().model().chartFloatingTooltipVisible().value()&&this._setHighlighted(!0)}_mouseOrTouchLeaveEvent(e){this._isMouseOverStub=!1,this._labelOptions.showLabels&&this._labelOptions.enableHighlight&&!this._isContextMenuOpened&&this._setHighlighted(!1)}async _mouseClickOrTapEvent(e){if(e.preventDefault(),null!==this._fixedLabelMode||1===this._labelMode||!this._labelOptions.enableMenu||!this._labelOptions.showLabels)return void Io.ContextMenuManager.hideAll();this._fixedLabelMode=this._labelMode,this.setLabelMode(0);const t=this._cell.getBoundingClientRect(),i=await this._contextMenuItemsProvider();this._isContextMenuOpened=!0,this._labelOptions.showLabels&&this._labelOptions.enableHighlight&&this._setHighlighted(!0),Io.ContextMenuManager.showMenu(i,{clientX:this._isLeft?t.left:t.right,clientY:t.top,attachToXBy:this._isLeft?"left":"right",attachToYBy:"bottom"},{statName:"PriceScaleLabelContextMenu",doNotCloseOn:this.getElement()},{menuName:"PriceScaleLabelContextMenu"},(()=>{this._isMouseOverStub||this._setHighlighted(!1),this._isContextMenuOpened=!1,this.setLabelMode((0,n.ensureNotNull)(this._fixedLabelMode)),this._fixedLabelMode=null}))}}var Bo=i(96708);class Vo{constructor(e,t,i,s,o,n=null){this._axises=[],this._stubs=[],this._size=(0,Ft.size)({width:0,height:0}),this._onLabelHovered=new ae.Delegate,this._scalesProperties=e,this._priceAxisWidgetFactory=i,this._timeAxisWidget=n,this._rendererOptionsProvider=s.rendererOptionsProvider,this._titlesProvider=s.titlesProvider,this._stubContextMenuProvider=s.stubContextMenuProvider,this._backgroundBasedTheme=s.backgroundBasedTheme,this._onActiveOrHoveredChart=s.onActiveOrHoveredChart,this._getBackgroundTopColor=s.getBackgroundTopColor,this._getBackgroundBottomColor=s.getBackgroundBottomColor,this._requestRepaint=s.requestRepaint,this._showHorisontalBorder=Boolean(s.showHorizontalBorder),this._labelsOptions={...ko,...o};const r=this._scalesProperties.childs();this._stubProperties={lineColor:r.lineColor,fontSize:r.fontSize},this._side=t,this._cell=document.createElement("div"),this._cell.classList.add("chart-markup-table","price-axis-container"),this._cell.style.width="25px",this._cell.style.position="relative"}destroy(){this.setScales([],0,0,0),this._backgroundBasedTheme.release(),this._onActiveOrHoveredChart?.release()}onLabelHovered(){return this._onLabelHovered}setScales(e,t,i,s){for(;e.length>this._axises.length&&this._axises.length<t;){const e=(0,Bo.getPriceAxisNameInfo)(this._side,this._axises.length),t=this._priceAxisWidgetFactory(this._side,this._rendererOptionsProvider,this._scalesProperties,e,this._backgroundBasedTheme);this._axises.push(t),
this._cell.appendChild(t.getElement())}for(;e.length<this._axises.length;){const e=(0,n.ensureDefined)(this._axises.pop());this._cell.removeChild(e.getElement()),e.destroy()}for(let t=0;t<this._axises.length;++t)this._axises[t].setPriceScale(e[t]);const o=t-e.length,r=Math.max(0,o);for(;this._stubs.length>r;){const e=(0,n.ensureDefined)(this._stubs.pop());e.onLabelHovered().unsubscribeAll(this),this._cell.removeChild(e.getElement()),e.destroy()}for(;this._stubs.length<o;){const e=this._labelsOptions.showLabels?(0,Bo.getPriceAxisNameInfo)(this._side,this._stubs.length):null,t=new Do(this._side,this._stubProperties,e,this._stubParams(this._stubs.length),this._labelsOptions,this._timeAxisWidget);t.onLabelHovered().subscribe(this,((t,i)=>{this._labelsOptions.showLabels&&this._labelsOptions.enableHighlight&&this._onLabelHovered.fire({owner:t,axis:(0,n.ensureNotNull)(e)},i)})),this._stubs.push(t),this._cell.appendChild(t.getElement())}const a=this._labelsOptions.enableMenu;1===s?this._stubs.forEach(((e,t)=>e.setLabelMode(a?0:1))):this._stubs.forEach(((e,t)=>e.setLabelMode(t<i&&a?2:1)))}getElement(){return this._cell}updateCurrencyLabels(){return this._axises.forEach((e=>e.updateCurrencyLabel()))}optimalWidths(){return this._axises.map((e=>e.optimalWidth()))}setSizes(e,t){this._size=(0,Ft.size)({width:t.reduce(((e,t)=>e+t),0),height:e}),this._cell.style.width=this._size.width+"px",this._cell.style.minWidth=this._size.width+"px",this._cell.style.height=this._size.height+"px",t.length!==this._axises.length+this._stubs.length&&(0,n.assert)(t.length===this._axises.length+this._stubs.length,"Widgets count should be the same as widths one");let i=0;this._forEachWidgetFromLeft(((s,o)=>{const n=t[o];s.setSizeAndOffset((0,Ft.size)({width:n,height:e}),i),i+=n}))}update(){this._axises.forEach((e=>e.update())),this._stubs.forEach((e=>e.update()))}paint(e,t){this._axises.forEach(((t,i)=>t.paint(e(i)))),this._stubs.forEach(((e,i)=>e.paint(t)))}paintStubs(e){this._stubs.forEach((t=>t.paint(e)))}restoreDefaultCursor(){this._axises.forEach((e=>e.restoreDefaultCursor()))}getWidth(){return this._size.width}findAxisWidgetForScale(e){const t=this._axises.find((t=>t.priceScale()===e));return void 0===t?null:t}getScreenshotData(){const e=this._getImage();return{canvas:e,content:e.toDataURL(),contentHeight:this._size.height,contentWidth:this._size.width}}getImage(){return this._getImage()}slotsCount(){return this._axises.length+this._stubs.length}setHighlightedPriceAxises(e){this._axises.forEach((t=>{const i=t.axisInfo(),s=e.find((e=>e.label===i?.label));t.setHighlighted(void 0!==s)}))}axes(){return this._axises}_stubParams(e){return{rendererOptionsProvider:this._rendererOptionsProvider,backgroundBasedTheme:this._backgroundBasedTheme.spawnOwnership(),onActiveOrHoveredChart:this._onActiveOrHoveredChart?.spawnOwnership(),sourcesTitlesProvider:()=>this._titlesProvider(this._side,e),contextMenuItemsProvider:()=>this._stubContextMenuProvider(this._side,e),getBackgroundTopColor:this._getBackgroundTopColor,
getBackgroundBottomColor:this._getBackgroundBottomColor,requestRepaint:this._requestRepaint,showHorizontalBorder:this._showHorisontalBorder}}_getImage(){const e=(0,Kt.createDisconnectedCanvas)(document,this._size),t=(0,Kt.getPrescaledContext2D)(e);let i=0;return this._forEachWidgetFromLeft(((e,s)=>{const o=e.getWidth();0!==o&&0!==this._size.height&&(t.drawImage(e.getImage(),i,0,o,this._size.height),i+=o)})),e}_forEachWidgetFromLeft(e){const t=[...this._axises,...this._stubs],i="left"===this._side,s=i?-1:t.length,o=i?-1:1;for(let n=i?t.length-1:0;n!==s;n+=o)e(t[n],n,t)}}var Ro=i(52859),No=i(55824),Oo=i(93688);class Fo{constructor(e=0){this._width=null,this._labelBottom=null,this._currencyInfo=null,this._unitInfo=null,this._measureUnitIdInfo=null,this._currencyAndUnitLabelsWrapper=document.createElement("div"),this._currencyAndUnitLabelsWrapper.className=Oo["price-axis-currency-label-wrapper"],this._currencyAndUnitLabelsWrapper.setAttribute("data-name","currency-unit-label-wrapper"),this._controlsContainer=document.createElement("div"),this._controlsContainer.className=Oo["price-axis-currency-label"],this._currencyAndUnitLabelsWrapper.appendChild(this._controlsContainer),this._currencyLabelDiv=document.createElement("div"),this._currencyLabelDiv.classList.add(Oo.row,"apply-common-tooltip"),this._currencyLabelDiv.dataset.name="currency-label-selector",(0,Ao.setTooltipData)(this._currencyLabelDiv,"text",(e=>this._currencyTooltipContent())),this._currencyText=document.createElement("div"),this._currencyText.className=Oo["price-axis-currency-label-text"],this._currencyLabelDiv.appendChild(this._currencyText),this._currencyArrowDown=document.createElement("div"),this._currencyArrowDown.className=Oo["price-axis-currency-label-arrow-down"],this._currencyArrowDown.innerHTML=No,this._currencyLabelDiv.appendChild(this._currencyArrowDown),this._measureUnitIdLabelDiv=document.createElement("div"),this._measureUnitIdLabelDiv.className=Oo.row,this._measureUnitIdLabelDiv.classList.add("apply-common-tooltip"),this._measureUnitIdLabelDiv.classList.add("readonly"),(0,Ao.setTooltipData)(this._measureUnitIdLabelDiv,"text",(e=>this._measureUnitIdTooltipContent())),this._measureUnitIdText=document.createElement("div"),this._measureUnitIdText.className=Oo["price-axis-currency-label-text"],this._measureUnitIdLabelDiv.appendChild(this._measureUnitIdText),this._unitLabelDiv=document.createElement("div"),this._unitLabelDiv.classList.add(Oo.row,"apply-common-tooltip"),this._unitLabelDiv.dataset.name="unit-label-selector",(0,Ao.setTooltipData)(this._unitLabelDiv,"text",(e=>this._unitTooltipContent())),this._unitText=document.createElement("div"),this._unitText.className=Oo["price-axis-currency-label-text"],this._unitLabelDiv.appendChild(this._unitText),this._unitArrowDown=document.createElement("div"),this._unitArrowDown.className=Oo["price-axis-currency-label-arrow-down"],this._unitArrowDown.innerHTML=No,this._unitLabelDiv.appendChild(this._unitArrowDown),this._controlsContainer.appendChild(this._currencyLabelDiv),
this._controlsContainer.appendChild(this._measureUnitIdLabelDiv),this._controlsContainer.appendChild(this._unitLabelDiv),this.disableCurrency(),this.disableUnit(),this.setFontSize(e)}element(){return this._currencyAndUnitLabelsWrapper}currencyLabelElement(){return this._currencyLabelDiv}unitLabelElement(){return this._unitLabelDiv}isEnabled(){return this.currencyLabelEnabled()||this.unitLabelEnabled()||this.measureUnitIdLableEnabled()}isHidden(){return this._currencyAndUnitLabelsWrapper.classList.contains(Oo.hidden)}setCurrencyExpanded(e){this._currencyLabelDiv.classList.toggle(Oo.expanded,e)}setUnitExpanded(e){this._unitLabelDiv.classList.toggle(Oo.expanded,e)}width(){if(null!==this._width)return this._width;let e=0;if(this.currencyLabelEnabled()){const t=this._currencyText.getBoundingClientRect(),i=this._currencyArrowDown.getBoundingClientRect();e=Math.max(e,t.width+i.width+2*this._textMarginAndPadding())}if(this.measureUnitIdLableEnabled()){const t=this._measureUnitIdText.getBoundingClientRect();e=Math.max(e,t.width+2*this._textMarginAndPadding())}if(this.unitLabelEnabled()){const t=this._unitText.getBoundingClientRect(),i=this._unitArrowDown.getBoundingClientRect();e=Math.max(e,t.width+i.width+2*this._textMarginAndPadding())}return this._width=e}drawLabel(e,t,i){if(!this.isEnabled())return;const s=Math.round(Number(Oo.css_wrapper_margin)*i),o=(0,fo.ceiledEven)(t*i)-2*s,n=Math.round(this.labelBottom()*i),r=n-2*s,a=Math.round(Number(Oo.css_value_currency_label_radius)*i);e.fillStyle=getComputedStyle(this._currencyAndUnitLabelsWrapper).backgroundColor,e.fillRect(0,0,Math.ceil(t*i),n);const l=[];l.push(this.currencyLabelEnabled()?this._currencyText.textContent??"":""),l.push(this.measureUnitIdLableEnabled()?this._measureUnitIdText.textContent??"":""),l.push(this.unitLabelEnabled()?this._unitText.textContent??"":""),e.font=(0,si.makeFont)(this._fontSize,m.CHART_FONT_FAMILY);const c=new Qt.TextWidthCache;let h=0;const d=[];l.forEach((t=>{let i=0;""!==t&&(i=c.yMidCorrection(e,t),h++),d.push(i)}));const u=r/h;e.beginPath();const _=getComputedStyle(this._controlsContainer);e.fillStyle=_.backgroundColor,e.strokeStyle=_.borderColor,(0,$t.drawRoundRect)(e,s,s,o,r,a),e.fill(),e.stroke(),e.fillStyle=getComputedStyle(this._currencyLabelDiv).color,e.textBaseline="middle",e.textAlign="left";const p=Math.round(this._textMarginAndPadding()*i)+s,g=u/2;let f=s+g;l.forEach(((t,s)=>{""!==t&&((0,Kt.drawScaled)(e,i,i,(()=>{e.fillText(t,p/i,(f+d[s])/i)})),f=Math.ceil(f+2*g))}))}setHidden(e){this._currencyAndUnitLabelsWrapper.classList.toggle(Oo.hidden,e)}enableCurrency(){this._currencyLabelDiv.classList.remove("js-hidden"),this._resetSizesAndVisibility()}disableCurrency(){this._currencyLabelDiv.classList.add("js-hidden"),this._resetSizesAndVisibility()}enableUnit(){this._unitLabelDiv.classList.remove("js-hidden"),this._resetSizesAndVisibility()}disableUnit(){this._unitLabelDiv.classList.add("js-hidden"),this._resetSizesAndVisibility()}enableMeasureUnitId(){this._measureUnitIdLabelDiv.classList.remove("js-hidden"),
this._resetSizesAndVisibility()}disableMeasureUnitId(){this._measureUnitIdLabelDiv.classList.add("js-hidden"),this._resetSizesAndVisibility()}currencyLabelEnabled(){return!this._currencyLabelDiv.classList.contains("js-hidden")}unitLabelEnabled(){return!this._unitLabelDiv.classList.contains("js-hidden")}measureUnitIdLableEnabled(){return!this._measureUnitIdLabelDiv.classList.contains("js-hidden")}currencyConversionAvailable(){return!this._currencyLabelDiv.classList.contains("readonly")}unitConversionAvailable(){return!this._unitLabelDiv.classList.contains("readonly")}setCurrencyInfo(e){if(this._currencyInfo===e)return!1;this._currencyInfo=e;const t=null===e.selectedCurrency?a.t(null,void 0,i(54215)):(0,n.ensureDefined)(e.displayedValues.get(e.selectedCurrency));return this._currencyText.textContent!==t&&(this._currencyText.textContent=t,this._width=null),this._currencyArrowDown.classList.contains("js-hidden")!==e.readOnly&&(this._currencyArrowDown.classList.toggle("js-hidden",e.readOnly),this._currencyLabelDiv.classList.toggle("readonly",e.readOnly),this._width=null),!0}setUnitInfo(e){if(null!==this._unitInfo&&this._unitInfo.selectedUnit===e.selectedUnit&&0===this._unitInfo.availableGroups.size==(0===e.availableGroups.size)&&this._unitInfo.originalUnits.size===e.originalUnits.size)return this._unitInfo=e,!1;this._unitInfo=e;const t=null===e.selectedUnit?a.t(null,void 0,i(54215)):(0,n.ensureDefined)(e.names.get(e.selectedUnit));return this._unitText.textContent!==t&&(this._unitText.textContent=t,this._width=null),this._unitArrowDown.classList.contains("js-hidden")!==(0===e.availableGroups.size)&&(this._unitArrowDown.classList.toggle("js-hidden",0===e.availableGroups.size),this._unitLabelDiv.classList.toggle("readonly",0===e.availableGroups.size),this._width=null),!0}setMeasureUnitIdInfo(e){if(this._measureUnitIdInfo===e)return!1;this._measureUnitIdInfo=e;const t=null===e.selectedMeasureUnitId?a.t(null,void 0,i(54215)):(0,n.ensureDefined)(e.names.get(e.selectedMeasureUnitId));return this._measureUnitIdText.textContent!==t&&(this._measureUnitIdText.textContent=t,this._width=null),this._measureUnitIdLabelDiv.classList.contains("js-hidden")!==(0===e.names.size)&&(this._measureUnitIdLabelDiv.classList.toggle("js-hidden",0===e.names.size),this._width=null),!0}currencyInfo(){return this._currencyInfo}unitInfo(){return this._unitInfo}measureUnitIdInfo(){return this._measureUnitIdInfo}setFontSize(e){this._fontSize!==e&&(this._fontSize=e,this._currencyLabelDiv.style.fontSize=e+"px",this._measureUnitIdLabelDiv.style.fontSize=e+"px",this._unitLabelDiv.style.fontSize=e+"px",this._width=null,this._labelBottom=null)}labelBottom(){if(null!==this._labelBottom)return this._labelBottom;const e=this._controlsContainer.getBoundingClientRect(),t=this._currencyAndUnitLabelsWrapper.getBoundingClientRect(),i=e.y-t.y;return this._labelBottom=e.height+2*i}_resetSizesAndVisibility(){this._width=null,this._labelBottom=null,this._updateVisibility()}_textMarginAndPadding(){return Number(Oo.css_wrapper_margin)+Number(Oo.css_row_left_right_padding)+2}
_currencyTooltipContent(){const e=this._currencyInfo;return null===e?"":null===e.selectedCurrency?Array.from(e.currencies).map((t=>(0,n.ensureDefined)(e.displayedValues.get(t)))).join(", "):e.readOnly?a.t(null,void 0,i(43931)):a.t(null,void 0,i(48566))}_unitTooltipContent(){const e=this._unitInfo;return null===e?"":null===e.selectedUnit?Array.from(e.units).map((t=>(0,n.ensureDefined)(e.names.get(t)))).join(", "):0===e.availableGroups.size?a.t(null,void 0,i(40012)):a.t(null,void 0,i(85110))}_measureUnitIdTooltipContent(){const e=this._measureUnitIdInfo;return null===e?"":null===e.selectedMeasureUnitId?Array.from(e.measureUnitIds).map((t=>(0,n.ensureDefined)(e.names.get(t)))).join(", "):e.descriptions.get(e.selectedMeasureUnitId)||""}_updateVisibility(){const e=this.isEnabled();this._currencyAndUnitLabelsWrapper.classList.toggle("js-hidden",!e)}}async function Wo(e,t,s,o){const{UnitConversionRenderer:n}=await Promise.all([i.e(1095),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(3672),i.e(1697),i.e(8260),i.e(844),i.e(3946),i.e(7399),i.e(2227),i.e(9418),i.e(3179),i.e(2704)]).then(i.bind(i,28587));return new n(e,s,t,o)}async function Ho(e,t,s){const{CurrencyMenuResultEvents:o}=await i.e(5639).then(i.bind(i,78712));return new o(e,t,s)}var zo=i(41706);class Uo{constructor(e){const{action:t,property:i,undoModel:s,undoText:o,callback:n=null}=e;this._property=i,this._undoModel=s,this._undoText=o,this._action=t,this.setValue(i.value()),i.subscribe(this,this._propertyChanged),null!==n?t.update({onExecute:n.bind(this)}):t.update({onExecute:this._onActionCallback.bind(this)})}destroy(){this._property.unsubscribe(this,this._propertyChanged)}value(){return this._action.isChecked()}setValue(e){this._action.update({checked:Boolean(e)})}_onActionCallback(){this._undoModel.setProperty(this._property,this.value(),this._undoText)}_propertyChanged(e){this.setValue(e.value())}}class jo extends zo.Action{constructor(e,t){super(e),this._binding=new Uo({action:this,...t})}destroy(){this._binding.destroy(),super.destroy()}}var Go=i(31932),qo=i(9860),$o=i(25246),Ko=i(14429);i(65810);const Yo=new dt.TranslatedString("change no overlapping labels",a.t(null,void 0,i(61557))),Zo=new dt.TranslatedString("toggle auto scale",a.t(null,void 0,i(42240))),Xo=new dt.TranslatedString("toggle log scale",a.t(null,void 0,i(49403))),Jo=a.t(null,void 0,i(88314)),Qo=a.t(null,void 0,i(5119)),en=a.t(null,void 0,i(59396)),tn=a.t(null,void 0,i(15432)),sn=a.t(null,void 0,i(15332)),on=a.t(null,void 0,i(24157)),nn=a.t(null,{context:"scale_menu"},i(34954)),rn=a.t(null,{context:"scale_menu"},i(35210)),an=a.t(null,{context:"scale_menu"},i(31340)),ln=a.t(null,{context:"scale_menu"},i(55300)),cn=a.t(null,{context:"scale_menu"},i(19405)),hn=a.t(null,{context:"scale_menu"},i(75163));const dn=function(e){const t=new qo.LimitedPrecisionNumericFormatter(e);return(e,i)=>(0,tt.isNumber)(i)&&!e.isLog()?t.format(i):""}(4),un=l.enabled("currency_menu_disabled"),_n=l.enabled("unit_menu_disabled"),pn={contextMenuEnabled:!0,currencyConversionEnabled:!1,
unitConversionEnabled:!1,countdownEnabled:!0,contextMenu:{general:!0,source:!0},pressedMouseMoveScale:!0,mouseWheelScale:!0,pinchScale:!0,croppedTickMarks:!0};var mn,gn,fn;!function(e){e[e.LabelOffset=4]="LabelOffset",e[e.DefaultOptimalWidth=34]="DefaultOptimalWidth",e[e.WheelScaleCoeff=15]="WheelScaleCoeff",e[e.CurrencyLabelFontSize=12]="CurrencyLabelFontSize"}(mn||(mn={})),function(e){e[e.Back=0]="Back",e[e.Top=1]="Top",e[e.All=2]="All"}(gn||(gn={}));class yn{constructor(e,t,i,s,o,n,r,a,l){this._actions=null,this._priceScale=null,this._scaleModeButtons=null,this._widthCache=new Qt.TextWidthCache(1e3),this._color=null,this._fontSize=null,this._isVisible=!0,this._currencyMenu=null,this._unitMenu=null,this._size=(0,Ft.size)({width:0,height:0}),this._currentCursorClassName="",this._destroyed=!1,this._highlighted=!1,this._highlightColorCache=null,this._mouseWheelHelper=null,this._dragScaleActive=!1,this._offset=NaN,this._pinching=!1,this._lastHittestResult=null,this._isHovered=new O.WatchedValue(!1),this._selectedViaTap=new O.WatchedValue(!1),this._recalcCurrencyAndUnitVisibility=()=>{if(null===this._currencyLabel)return;const e=(0,Be.actualCurrencyUnitVisibility)().value();let t=!this._pane.visuallyCollapsed().value();if(t)switch(e){case"alwaysOff":t=!1;break;case"visibleOnMouseOver":const e=this._chart.anyPriceAxisHovered().value(),i=!!this._currencyMenu,s=!!this._unitMenu;t=e||i||s;break;case"visibleOnTapSelection":t=this._selectedViaTap.value()}this._currencyLabel.setHidden(!t)},this._handleActualAutoLogButtonsVisibility=async e=>{const t=e.value();"alwaysOff"===t?this._scaleModeButtons&&this._destroyScaleModeButtons():(this._scaleModeButtons||(this._scaleModeButtons=await this._createScaleModeButtons(),this._pane.visuallyCollapsed().subscribe(this._updatePriceScaleModeButtonsVisibility)),"alwaysOn"===t?(this._isHovered.unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._selectedViaTap.unsubscribe(this._updatePriceScaleModeButtonsVisibility)):"visibleOnMouseOver"===t?(this._selectedViaTap.unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._isHovered.subscribe(this._updatePriceScaleModeButtonsVisibility)):(this._isHovered.unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._selectedViaTap.subscribe(this._updatePriceScaleModeButtonsVisibility)),this._updatePriceScaleModeButtonsVisibility()),this.onOptimalWidthNeedToBeRecalculated()},this._updatePriceScaleModeButtonsVisibility=()=>{const e=this._isHovered.value(),t=this._selectedViaTap.value();let i=!1;if(!this._pane.visuallyCollapsed().value()&&!this._undoModel.model().chartFloatingTooltipVisible().value())switch((0,$o.actualAutoLogButtonsVisibility)().value()){case"visibleOnMouseOver":i=e;break;case"visibleOnTapSelection":i=t;break;case"alwaysOn":i=!0}this._scaleModeButtons?.element().classList.toggle("price-axis__modeButtons_hidden",!i)},this._updateScaleModeButtons=()=>{this._scaleModeButtons?.update()},this._chart=e,this._pane=t,this._undoModel=i,this._properties=s,this._isLeft="left"===n,this._options=(0,tt.merge)((0,
tt.clone)(pn),r),this._rendererOptionsProvider=o,this._backgroundBasedTheme=l,this._cell=document.createElement("div"),this._cell.className="price-axis",this._cell.dataset.name=`price-axis-${a.label}`,this._cell.style.width="25px",this._cell.style.left="0",this._canvasConfiguredHandler=()=>{this._undoModel.model().lightUpdate()},this._canvasBinding=(0,Kt.createBoundCanvas)(this._cell,(0,Ft.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const c=this._canvasBinding.canvasElement;c.style.position="absolute",c.style.zIndex="1",c.style.left="0",c.style.top="0",this._topCanvasBinding=(0,Kt.createBoundCanvas)(this._cell,(0,Ft.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const h=this._topCanvasBinding.canvasElement;h.style.position="absolute",h.style.zIndex="2",h.style.left="0",h.style.top="0",this._cell.setAttribute("aria-hidden","true"),this._mouseEventHandler=new Wt.MouseEventHandler(this._cell,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._options.currencyConversionEnabled||this._options.unitConversionEnabled?(this._currencyLabel=new Fo(12),this._cell.appendChild(this._currencyLabel.element())):this._currencyLabel=null,this._properties.childs().fontSize.subscribe(this,this._onFontSizeChanged),this._options.mouseWheelScale&&(this._mouseWheelHelper=new mo,this._cell.addEventListener("wheel",this._onMousewheel.bind(this),{passive:!1})),this._axisInfo=a,this._offset=0,this.restoreDefaultCursor(),(0,Be.actualCurrencyUnitVisibility)().subscribe(this,this._recalcCurrencyAndUnitVisibility),this._selectedViaTap.subscribe(this._recalcCurrencyAndUnitVisibility.bind(this)),(0,$o.actualAutoLogButtonsVisibility)().subscribe(this,this._handleActualAutoLogButtonsVisibility),this._handleActualAutoLogButtonsVisibility((0,$o.actualAutoLogButtonsVisibility)()).catch((()=>{})),this._chart.anyPriceAxisHovered().subscribe(this._recalcCurrencyAndUnitVisibility,{callWithLast:!0}),this._pane.visuallyCollapsed().subscribe(this._recalcCurrencyAndUnitVisibility,{callWithLast:!0}),this.update()}async getContextMenuActions(e){this._initActions();const t=(0,n.ensureNotNull)(this._actions),i=this._chart.actions(),s=[];if(this._priceScale?.resetScaleAvailable().value()&&s.push(t.reset,new zo.Separator),s.push(this._autoScaleAction()),this._isMainSeriesAxis()&&s.push(this._lockScaleAction()),s.push(i.scaleSeriesOnly,this._invertAction(),new zo.Separator,this._regularScaleAction(),this._percentageAction(),this._indexedTo100Action(),this._logAction(),new zo.Separator,this._createMergeScalesAction(),new zo.Separator),!l.enabled("fundamental_widget")){const e=[i.showSymbolLabelsAction,i.showSeriesLastValue,null,null,i.showHighLowPriceLabels,l.enabled("show_average_close_price_line_and_label")?i.showAverageClosePriceLabel:null,null,i.showStudyPlotNamesAction,i.showStudyLastValue,this._options.countdownEnabled?i.showCountdown:null,new zo.Separator,t.alignLabels].filter(tt.notNull)
;s.push(new zo.Action({actionId:"Chart.PriceScale.Labels",options:{label:Qo,subItems:e}}))}const{createLinesAction:o}=await(0,Go.actionsProviderModule)();return s.push(o(this._chart)),this._undoModel.crosshairSource().isMenuEnabled()&&s.push(i.addPlusButton),e&&!this._chart.onWidget()&&l.enabled("show_chart_property_page")&&l.enabled("chart_property_page_scales")&&i.scalesProperties&&s.push(new zo.Separator,i.scalesProperties),s}getElement(){return this._cell}onOptimalWidthNeedToBeRecalculated(e){(this._size.width<this.optimalWidth()||e)&&this._undoModel.model().fullUpdate()}optimalWidth(){if(!this.isVisible())return 0;let e=0;const t=this.rendererOptions();if(this._pane.hasState()){const t=(0,Kt.getContext2D)(this._canvasBinding.canvasElement);t.font=this.baseFont();const i=this._views(2,this._groupedSources());for(const s of i){if(!s.isAxisLabelVisible())continue;const i=this._widthCache.measureText(t,s.text());e=Math.max(e,i);const o=s.secondLineText();o&&(e=Math.max(e,this._widthCache.measureText(t,o)));const n=s.thirdLineText();n&&(e=Math.max(e,this._widthCache.measureText(t,n)))}const s=this.priceScale();for(const i of s.marks())e=Math.max(e,this._widthCache.measureText(t,i.label));const o=s.mainSource()?.firstValue()||null;if(null!==o&&!s.isPercentage()&&!s.isIndexedTo100()){const i=s.coordinateToPrice(1,o),n=s.coordinateToPrice(this._size.height-2,o);if(Math.abs(i-n)>1e-14){const r=Math.max(0,-Math.log10(Math.max(Math.abs(i),Math.abs(n)))),a=.11111111111111/Math.pow(10,Math.floor(r)),l=s.formatPrice(Math.min(i,n)-a,o),c=s.formatPrice(Math.max(i,n)+a,o);e=Math.max(e,this._widthCache.measureText(t,l),this._widthCache.measureText(t,c))}}}const i=this._isCurrencyLabelEnabled()?Math.round((0,n.ensureNotNull)(this._currencyLabel).width()):0,s=e||34;let o=Math.max(i,this._scaleModeButtons?.width()??0,Math.ceil(t.borderSize+t.additionalPaddingInner+t.paddingInner+t.paddingOuter+s+4));return o+=o%2,o}setSizeAndOffset(e,t){(0,Ft.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._cell.style.width=e.width+"px",this._cell.style.height=e.height+"px",this._cell.style.minWidth=e.width+"px"),this._offset!==t&&(this._offset=t,this._cell.style.left=t+"px")}getWidth(){return this._size.width}getImage(){const e=this._size,t=(0,Kt.createDisconnectedCanvas)(document,e);return(0,Kt.getPrescaledContext2D)(t).drawImage(this._canvasBinding.canvasElement,0,0,e.width,e.height),null===this._currencyLabel||this._currencyLabel.isHidden()||this._currencyLabel.drawLabel((0,Kt.getContext2D)(t),e.width,(0,ro.getCanvasDevicePixelRatio)(t)),t}update(){null!==this._priceScale&&(this._priceScale.marks(),this.rendererOptions())}paint(e){if(!this._isVisible||0===this._size.width||0===this._size.height)return;if(e===ao.InvalidationLevel.None)return;const t=this._pane.state(),i=!t.maximized().value()&&t.collapsed().value();if(i&&e<ao.InvalidationLevel.Full)return;const s=this._pane.hasState();(0,Kt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),(0,
Kt.tryApplySuggestedCanvasBitmapSize)(this._topCanvasBinding);const o=null!==this._currencyLabel&&!this._currencyLabel.isHidden(),r=(e,t,i)=>{if(o){e.save(),e.beginPath();const i=(0,n.ensureNotNull)(this._currencyLabel).labelBottom();e.rect(0,i*t.verticalPixelRatio,t.bitmapSize.width,t.bitmapSize.height),e.clip()}i(),o&&e.restore()};let a;if(e>ao.InvalidationLevel.Cursor){const e=(0,Kt.getContext2D)(this._canvasBinding.canvasElement),t=(0,Kt.getBindingRenderingInfo)(this._canvasBinding);if(i||(this._alignLabels(),s&&this.updateCurrencyLabel()),this._drawBackground(e,t),i||r(e,t,(()=>{this._drawDrawingsHighlight(e,t)})),this._drawBorder(e,t),s&&!i){this._scaleModeButtons&&(this._scaleModeButtons.element().style.background=this._highlighted?this._highlightColor():this.backgroundColor());const i=this._groupedSources();r(e,t,(()=>{this._drawTickMarks(e,t),this._drawLabels(this._views(0,i),e,t)})),a=i}}if(s&&!i){const e=(0,Kt.getContext2D)(this._topCanvasBinding.canvasElement),t=(0,Kt.getBindingRenderingInfo)(this._topCanvasBinding);e.clearRect(0,0,t.bitmapSize.width,t.bitmapSize.height),r(e,t,(()=>{this._drawLabels(this._views(1,a??this._groupedSources()),e,t),this._drawCrossHairLabel(e,t)}))}}restoreDefaultCursor(){this._setCursor("")}priceScale(){return(0,n.ensureNotNull)(this._priceScale)}setPriceScale(e){this._priceScale!==e&&(null!==this._priceScale&&(this._priceScale.onMarksChanged().unsubscribe(this,this.onOptimalWidthNeedToBeRecalculated),this._priceScale.modeChanged().unsubscribeAll(this)),this._priceScale=e,null!==e&&(e.onMarksChanged().subscribe(this,this.onOptimalWidthNeedToBeRecalculated),e.modeChanged().subscribe(this,(()=>this.onOptimalWidthNeedToBeRecalculated(!0))),this.onOptimalWidthNeedToBeRecalculated(),this._scaleModeButtons&&(e.modeChanged().subscribe(this,this._updateScaleModeButtons),this._updateScaleModeButtons())))}isVisible(){return this._isVisible}setVisible(e){(e=!!e)!==this._isVisible&&(this._cell.style.display=e?"table-cell":"none",this._isVisible=e)}destroy(){null!==this._currencyMenu&&(this._currencyMenu.destroy(),this._currencyMenu=null),null!==this._unitMenu&&(this._unitMenu.destroy(),this._unitMenu=null),this._pane.visuallyCollapsed().unsubscribe(this._recalcCurrencyAndUnitVisibility),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),null!==this._priceScale&&(this._priceScale.onMarksChanged().unsubscribe(this,this.onOptimalWidthNeedToBeRecalculated),this._priceScale.modeChanged().unsubscribeAll(this)),this._priceScale=null,this._mouseEventHandler.destroy(),this._properties.childs().fontSize.unsubscribe(this,this._onFontSizeChanged),null!==this._actions&&(Object.values(this._actions).forEach((e=>{e.destroy()})),this._actions=null),(0,Be.actualCurrencyUnitVisibility)().unsubscribeAll(this),this._chart.anyPriceAxisHovered().unsubscribe(this._recalcCurrencyAndUnitVisibility),(0,
$o.actualAutoLogButtonsVisibility)().unsubscribeAll(this),this._chart.setPriceAxisHovered(this,!1),this._destroyScaleModeButtons(),this._destroyed=!0}axisInfo(){return this._axisInfo}setHighlighted(e){this._highlighted=e}backgroundColor(){return this._pane.state().model().backgroundColor().value()}backgroundTopColor(){return this._pane.state().model().backgroundTopColor().value()}lineColor(){return this._properties.childs().lineColor.value()}textColor(){return this._properties.childs().textColor.value()}fontSize(){return this._properties.childs().fontSize.value()}baseFont(){return(0,si.makeFont)(this.fontSize(),m.CHART_FONT_FAMILY,"")}rendererOptions(){let e=this._rendererOptionsProvider.options();return this._color===e.color&&this._fontSize===e.fontSize||(this._color=e.color),this._fontSize!==e.fontSize&&(this._widthCache.reset(),this._fontSize=e.fontSize,this.onOptimalWidthNeedToBeRecalculated()),e}mouseEnterEvent(e){this._undoModel.model().chartFloatingTooltipVisible().value()||(this._chart.setPriceAxisHovered(this,!0),this._isHovered.setValue(!0),this._applyLightUpdateIfRequired(),this._mouseEnterOrTouchStartEvent(e))}mouseMoveEvent(e){this._mouseOrTouchMoveEvent(e)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseOrTouchMoveEvent(e),this._mouseEnterOrTouchStartEvent(e),this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}pinchStartEvent(e,t,i,s){return s.bothPointsOnTargetElement}pinchEvent(e,t,i){if(this._zoomAvailable()&&this._options.pinchScale){if(this._dragScaleActive&&this._finishScale(),!this._pinching)return this._pinching=!0,void this._undoModel.startTwoPointsScalePrice(this._pane.state(),this.priceScale(),t.y,i.y);this._undoModel.twoPointsScalePriceTo(this._pane.state(),this.priceScale(),t.y,i.y)}}pinchEndEvent(){this._pinching=!1,this._undoModel.endTwoPointsScalePrice(this._pane.state(),this.priceScale())}mouseDownOutsideEvent(){this._finishScale()}touchStartOutsideEvent(){this._finishScale(),this._selectedViaTap.setValue(!1)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseLeaveOrTouchEndEvent(e),this._mouseUpOrTouchEndEvent(e)}mouseClickEvent(e){this._mouseClickOrTapEvent(e)}tapEvent(e){this._mouseClickOrTapEvent(e)}mouseLeaveEvent(e){this._chart.setPriceAxisHovered(this,!1),this._isHovered.setValue(!1),this._applyLightUpdateIfRequired(),this._mouseLeaveOrTouchEndEvent(e)}mouseDoubleClickEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}doubleTapEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}contextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}touchContextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}dataSourceAtPoint(e,t){const i=this._pane.state();if(!i.maximized().value()&&i.collapsed().value())return null;const s=this._groupedSources(),o=[...s.sources,...s.topLevelSources,...i.customSources(),...i.sourcesByGroup().multipaneSources()];let n=null,r=null;if(!this._priceScale)return null;const a=(e,t)=>{
const i=r?.target()??0;e.target()>i&&(r=e,n=t)},l=new Vt.Point(e,t),c=(0,Kt.getBindingRenderingInfo)(this._canvasBinding);for(let e=o.length-1;e>=0;--e){const t=o[e],s=t.priceAxisViews(i,this._priceScale);if(s&&0!==s.length)for(let e=s.length-1;e>=0;--e){const i=s[e].renderer();if(void 0!==i.hitTest){const e=i.hitTest(l,c,this._isLeft?"left":"right");null!==e&&a(e,t)}}}return this._lastHittestResult=r,n}reset(){const e=this._pane.state(),t=this.priceScale();this._undoModel.resetPriceScale(e,t),this.onOptimalWidthNeedToBeRecalculated(!0)}updateCurrencyLabel(){if(null!==this._currencyLabel){if(this._options.currencyConversionEnabled){const e=this.priceScale().currency(this._undoModel.model().availableCurrencies());null===e||"alwaysOff"===(0,Be.actualCurrencyUnitVisibility)().value()?this._currencyLabel.disableCurrency():(this._currencyLabel.enableCurrency(),this._currencyLabel.setCurrencyInfo(e))}else this._currencyLabel.disableCurrency();if(this._options.unitConversionEnabled){const e="alwaysOff"===(0,Be.actualCurrencyUnitVisibility)().value(),t=this._undoModel.model().availableUnits(),i=this.priceScale().unit(t);null===i||e?this._currencyLabel.disableUnit():(this._currencyLabel.enableUnit(),this._currencyLabel.setUnitInfo(i));const s=this.priceScale().measureUnitId(t);null===s||e?this._currencyLabel.disableMeasureUnitId():(this._currencyLabel.enableMeasureUnitId(),this._currencyLabel.setMeasureUnitIdInfo(s))}else this._currencyLabel.disableUnit(),this._currencyLabel.disableMeasureUnitId()}}_groupedSources(){const e=this._pane.state(),t=e.model(),i=this._pane.state().sourcesByGroup(),s=this._isLeft?i.leftPriceScalesSources():i.rightPriceScalesSources(),o=this._priceScale===e.defaultPriceScale(),n=new Set(e.customSources()),r=t=>!!n.has(t)||(t.priceScale()===this._priceScale||o&&e.isOverlay(t)),a={sources:[...s.filter(r),...e.customSources()],topLevelSources:new Set};if(o){const t=this._pane.state().dataSources();for(const i of t)e.isOverlay(i)&&a.sources.push(i)}const l=t.lineBeingEdited()??t.lineBeingCreated();l&&r(l)&&(a.topLevelSources.add(l),a.lineBeingEditedOrCreated=l);const c=t.customSourceBeingMoved();c&&r(c)&&(a.topLevelSources.add(c),a.customSourceBeingMoved=c);const h=t.sourcesBeingMoved().filter(r);h.length>0&&(t.sourcesBeingMoved().forEach((e=>a.topLevelSources.add(e))),a.sourcesBeingMoved=h);const d=t.selection().allSources().filter(r);d.length>0&&(d.forEach((e=>a.topLevelSources.add(e))),a.selectedSources=d);const u=t.hoveredSource();return u&&r(u)&&(a.topLevelSources.add(u),a.hoveredSource=u),a}_isCurrencyLabelEnabled(){return null!==this._currencyLabel&&this._currencyLabel.isEnabled()}_alignLabels(){const e=this._size.height;let t=e/2;const i=[],s=this.priceScale(),o=s.orderedSources().slice(),n=this._pane.state(),r=this.rendererOptions();if(s===n.defaultPriceScale()){const e=n.priceDataSources();for(let t=0;t<e.length;t++)n.isOverlay(e[t])&&o.push(e[t])}const a=s.mainSource(),l=n.sourcesByGroup().multipaneSources();for(const c of[o,n.customSources(),l])for(let o=0;o<c.length;++o){
const l=c[o],h=[...l.priceAxisViews(n,s)??[],...l.topPriceAxisViews?.(n,s)??[]];if(h){const s=h.filter((t=>{if(t.ignoreAlignment()||!t.isVisible())return!1;const{total:i}=t.topBottomTotalHeight(r),s=t.floatCoordinate();return s>-i&&s<e+i}));if(!s.length)continue;i.push(...s),a===l&&(t=s[0].floatCoordinate())}}const c=i.filter((e=>e.floatCoordinate()<=t)),h=i.filter((e=>e.floatCoordinate()>t));c.sort(((e,t)=>t.floatCoordinate()-e.floatCoordinate())),c.length>0&&h.length>0&&h.push(c[0]),h.sort(((e,t)=>e.floatCoordinate()-t.floatCoordinate()));for(const e of i)e.setFixedCoordinate(e.coordinate());if(s.properties().childs().alignLabels.value()){if(h.length>0||c.length>0){{const t=c[0]??h[0],i=t.getFixedCoordinate(),{top:s,bottom:o,total:n}=t.topBottomTotalHeight(r);n<e&&i-s<0&&i+o>0&&t.setFixedCoordinate(s)}{const t=h[0]??c[0],i=t.getFixedCoordinate(),{top:s,bottom:o,total:n}=t.topBottomTotalHeight(r);n<e&&i-s<e&&i+o>e&&t.setFixedCoordinate(e-o)}}for(let e=1;e<c.length;e++){const t=c[e],i=c[e-1],{top:s,bottom:o,total:n}=t.topBottomTotalHeight(r),a=t.getFixedCoordinate(),l=i.getFixedCoordinate();if(a>l-n)t.setFixedCoordinate(l-n);else if(l>0&&a-s<0&&a+o>0){const{top:e}=i.topBottomTotalHeight(r);t.setFixedCoordinate(Math.min(l-e-o,s))}}for(let t=1;t<h.length;t++){const i=h[t],s=h[t-1],{bottom:o,total:n}=s.topBottomTotalHeight(r),a=i.getFixedCoordinate(),l=s.getFixedCoordinate();if(a<l+n)i.setFixedCoordinate(l+n);else if(l<e){const{top:t,bottom:s}=i.topBottomTotalHeight(r);a-t<e&&a+s>e&&i.setFixedCoordinate(Math.max(l+o+t,e-s))}}}}_drawTickMarks(e,t){const i=this.priceScale().marks();e.save(),e.font=this.baseFont();const s=this.rendererOptions(),{horizontalPixelRatio:o,verticalPixelRatio:r}=t,a=this._isLeft?Math.floor((this._size.width-s.additionalPaddingInner)*o):0,l=this._isLeft?Math.round(a-s.paddingInner*o):Math.round(a+(s.additionalPaddingInner+s.paddingInner)*o),c=this.fontSize(),h=this._isCurrencyLabelEnabled()?(0,n.ensureNotNull)(this._currencyLabel).labelBottom():0,d=i.map((t=>{if(this._options.croppedTickMarks)return{visible:!0,yCorrection:this._widthCache.yMidCorrection(e,t.label)};const i=t.coord-c/2,s=t.coord+c/2,o=!(s>this._size.height||i<h);return{visible:!(s>this._size.height||i<h),yCorrection:o?this._widthCache.yMidCorrection(e,t.label):0}}));e.fillStyle=this.textColor(),e.textAlign=this._isLeft?"right":"left",e.textBaseline="middle",(0,Kt.drawScaled)(e,o,r,(()=>{for(let t=i.length;t--;){if(!d[t].visible)continue;const s=i[t];e.fillText(s.label,l/o,s.coord+d[t].yCorrection)}})),e.restore()}async _showCurrenciesContextMenu(){if(this._currencyMenu)return this._currencyMenu.destroy(),void(this._currencyMenu=null);let e;(0,re.trackEvent)("GUI","Currency conversion");const t=()=>{this._currencyMenu=null,this._recalcCurrencyAndUnitVisibility(),this._currencyLabel?.setCurrencyExpanded(!1)};if(un)e=await Ho((0,n.ensureNotNull)(this._currencyLabel).currencyLabelElement(),["toggle_currency_menu_inner",this._undoModel.model().id(),this._pane.state().id(),this.priceScale().id()],t);else{
const{currencyActions:s}=await Promise.all([i.e(1095),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(3672),i.e(1697),i.e(8260),i.e(844),i.e(3946),i.e(7399),i.e(2227),i.e(9418),i.e(3179),i.e(2704)]).then(i.bind(i,27056));e=await Wo(en,(()=>s(this._undoModel,(0,n.ensureNotNull)(this._currencyLabel).currencyInfo(),this.priceScale())),(0,n.ensureNotNull)(this._currencyLabel).currencyLabelElement(),t)}this._destroyed?e.destroy():(this._currencyLabel?.setCurrencyExpanded(!0),this._currencyMenu=e)}async _showUnitsContextMenu(){if(this._unitMenu)return this._unitMenu.destroy(),void(this._unitMenu=null);let e;(0,re.trackEvent)("GUI","Unit conversion");const t=()=>{this._unitMenu=null,this._recalcCurrencyAndUnitVisibility(),this._currencyLabel?.setUnitExpanded(!1)};if(_n)e=await Ho((0,n.ensureNotNull)(this._currencyLabel).unitLabelElement(),["toggle_unit_menu_inner",this._undoModel.model().id(),this._pane.state().id(),this.priceScale().id()],t);else{const{unitActions:s}=await Promise.all([i.e(1095),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(3672),i.e(1697),i.e(8260),i.e(844),i.e(3946),i.e(7399),i.e(2227),i.e(9418),i.e(3179),i.e(2704)]).then(i.bind(i,81664));e=await Wo(tn,(()=>s(this._undoModel,(0,n.ensureNotNull)(this._currencyLabel).unitInfo(),this.priceScale())),(0,n.ensureNotNull)(this._currencyLabel).unitLabelElement(),t)}this._destroyed?e.destroy():(this._currencyLabel?.setUnitExpanded(!0),this._unitMenu=e)}_onFontSizeChanged(){this.onOptimalWidthNeedToBeRecalculated()}_mouseOrTouchMoveEvent(e){if(!this._priceScale)return;if(this._undoModel.model().chartFloatingTooltipVisible().value())return void this._setCursorClassName("default");if(e.localX<0||e.localY<0||e.localX>=this._size.width||e.localY>=this._size.height)return;let t=!0;const i=this.dataSourceAtPoint(e.localX,e.localY);i?(this._setCursorClassName("pointer"),this._lastHittestResult?.data()?.hoverModelFromAxis&&(this._undoModel.model().setHoveredSource(i,this._lastHittestResult?.data()??null,0),t=!1)):this._setResizeCursor(),t&&this._undoModel.model().setHoveredSource(null,null)}_mouseDownOrTouchStartEvent(e){this._zoomAvailable()&&this._options.pressedMouseMoveScale&&!this._pinching&&(this._dragScaleActive=!0,this._undoModel.startScalePrice(this._pane.state(),this.priceScale(),e.localY))}_mouseEnterOrTouchStartEvent(e){this._setResizeCursor()}_pressedMouseOrTouchMoveEvent(e){if(this._dragScaleActive){const t=this.priceScale();this._undoModel.scalePriceTo(this._pane.state(),t,e.localY)}}_mouseUpOrTouchEndEvent(e){this._finishScale()}_finishScale(){this._dragScaleActive&&(this._undoModel.endScalePrice(this._pane.state(),this.priceScale()),this.restoreDefaultCursor(),this._dragScaleActive=!1)}_mouseClickOrTapEvent(e){if(this._currencyLabel){if(this._currencyLabel.currencyConversionAvailable()&&this._currencyLabel.currencyLabelElement().contains(e.target))return this._showCurrenciesContextMenu(),void e.preventDefault()
;if(this._currencyLabel.unitConversionAvailable()&&this._currencyLabel.unitLabelElement().contains(e.target))return this._showUnitsContextMenu(),void e.preventDefault()}e.isTouch&&this._selectedViaTap.setValue(!this._selectedViaTap.value());const t=this.dataSourceAtPoint(e.localX,e.localY);t&&this._undoModel.selectionMacro((e=>{e.selection().isSelected(t)&&this._undoModel.model().lastSelectedHittestData()===this._lastHittestResult?.data()||(e.clearSelection(),e.addSourceToSelection(t,this._lastHittestResult?.data()??null))})),e.target instanceof HTMLCanvasElement&&this._undoModel.model().setActivationChartFloatingTooltipHint(null)}_mouseLeaveOrTouchEndEvent(e){this._setCursorClassName("")}_mouseDoubleClickOrDoubleTapEvent(e){if(this._currencyLabel?.currencyLabelElement().contains(e.target)||this._currencyLabel?.unitLabelElement().contains(e.target))return;const t=this.dataSourceAtPoint(e.localX,e.localY);t?this._pane.processDoubleClickOnSource(t,this._lastHittestResult??void 0,{origin:"price_scale"}):(this.reset(),(0,re.trackEvent)("GUI","Double click price scale"))}async _contextMenuOrTouchContextMenuEvent(e){if(this._options.contextMenuEnabled){const t=this.dataSourceAtPoint(e.localX,e.localY);if(null!==t&&this._options.contextMenu.source){return void this._undoModel.model().selectionMacro((i=>{i.selection().isSelected(t)||(i.clearSelection(),i.addSourceToSelection(t)),this._pane.showContextMenuForSelection(e,{origin:"price_scale"})}))}if(this._options.contextMenu.general){const t=await this.getContextMenuActions(!0),i=this._undoModel.model().panes().findIndex((e=>e.id()===this._pane.state().id())),s=this._chart.chartWidgetCollection().chartModels().value().findIndex((e=>e.id()===this._undoModel.id())),o=this._priceScale?.id()&&-1!==i&&-1!==s;Io.ContextMenuManager.showMenu(t,e,{statName:"PriceScaleContextMenu"},{menuName:"PriceScaleContextMenu",...o&&{detail:{type:"priceScale",id:this._priceScale?.id()??"",paneIndex:i,chartIndex:s}}})}}}_setResizeCursor(){const e=this.priceScale();e.isPercentage()||e.isIndexedTo100()?this._setCursorClassName(""):this._zoomAvailable()&&(this._options.pressedMouseMoveScale||this._options.mouseWheelScale)&&this._setCursorClassName("ns-resize")}_setCursorClassName(e){let t="";e&&!this._pane.visuallyCollapsed().value()&&(t="price-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t)}_zoomAvailable(){return!this.priceScale().isEmpty()&&this.priceScale().hasCalculatedPriceRange()&&this._undoModel.model().zoomEnabled()}_onMousewheel(e){if(!this._zoomAvailable()||!this._options.mouseWheelScale)return;const t=(0,n.ensureNotNull)(this._mouseWheelHelper).processWheel(e).deltaY;if(0===t)return;e.cancelable&&e.preventDefault();const i=this._undoModel,s=this._pane.state(),o=this.priceScale(),r=this._cell.getBoundingClientRect(),a=e.clientY-r.top,l=a+15*t;i.startScalePrice(s,this.priceScale(),a,!0),i.scalePriceTo(s,o,l),i.endScalePrice(s,o),
e.stopPropagation()}_drawCrossHairLabel(e,t){const i=this._pane.state(),s=i.model(),o=this.priceScale(),n=s.crosshairSource().priceAxisViews(i,o);n&&n.length>0&&this._drawLabels(n,e,t)}_drawBackground(e,t){const i=this.backgroundTopColor(),s=this.backgroundColor(),{bitmapSize:o}=t;if(i===s?(0,Kt.clearRect)(e,0,0,o.width,o.height,this.backgroundColor()):(0,$t.clearRectWithGradient)(e,0,0,o.width,o.height,i,s),this._highlighted){e.globalAlpha=.5;const t=L.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight");(0,Kt.fillRect)(e,0,0,o.width,o.height,t),e.globalAlpha=1}}_drawDrawingsHighlight(e,t){const i=this._pane.state().model(),s=this.priceScale(),o=i.selection().lineDataSources().filter((e=>!e.isFixed()&&e.priceScale()===s)).reduce(((e,t)=>{const i=t.priceAxisPoints();return 0===i.length?e:e.concat(i)}),[]);o.length>0&&this._hightlightBackground(e,o,this.priceScale().mainSource(),t);const n=i.crosshairSource();n.startMeasurePoint()&&this._hightlightBackground(e,n.measurePoints(),this.priceScale().mainSource(),t)}_drawBorder(e,t){e.save(),e.fillStyle=this.lineColor();const{horizontalPixelRatio:i}=t,s=Math.max(1,Math.floor(this.rendererOptions().borderSize*i)),o=this._isLeft?t.bitmapSize.width-s:0;e.fillRect(o,0,s,t.bitmapSize.height),e.restore()}_drawLabels(e,t,i){const s=this.rendererOptions(),o=this._isLeft?"right":"left";for(const n of e)n.isAxisLabelVisible()&&(t.save(),n.renderer().draw(t,i,s,this._widthCache,o),t.restore())}_hightlightBackground(e,t,i,s){if(!i)return;const o=i.firstValue();if(null===o)return;let n=t[0].price,r=t[0].price;for(let e=1;e<t.length;e++)n=Math.min(n,t[e].price),r=Math.max(r,t[e].price);const{horizontalPixelRatio:a,verticalPixelRatio:l}=s,c=this.priceScale(),h=Math.floor(c.priceToCoordinate(n,o)*l),d=Math.ceil(c.priceToCoordinate(r,o)*l);(0,Kt.fillRect)(e,Math.floor(a),h,s.bitmapSize.width,d-h,this._properties.childs().axisHighlightColor.value())}_viewsOrMaxMinViews(e){const t=this._pane.state(),i=this.priceScale();if(0===e.length)return[];if(1===e.length)return e[0].priceAxisViews(t,i)??[];{let s=1/0,o=-1/0,n=null,r=null;for(const a of e){const e=a.priceAxisViews(t,i)??[];for(const t of e){const e=t.coordinate();e>=o&&(o=e,r=t),e<=s&&(s=e,n=t)}}return r&&n?[r,n]:[]}}_views(e,t){const i=this._pane.state(),s=this.priceScale(),o=[];if(1!==e)for(const e of t.sources)t.topLevelSources.has(e)||o.push(...e.priceAxisViews(i,s)??[]);if(0!==e){const e=new Set,n=t=>!e.has(t),r=t=>{const i=t.filter(n);o.push(...this._viewsOrMaxMinViews(i));for(const t of i)e.add(t)};t.customSourceBeingMoved&&r([t.customSourceBeingMoved]),t.sourcesBeingMoved&&r(t.sourcesBeingMoved),t.selectedSources&&r(t.selectedSources),t.hoveredSource&&r([t.hoveredSource]),t.lineBeingEditedOrCreated&&r([t.lineBeingEditedOrCreated]);for(const e of[...t.sources,...i.customSources()])e.topPriceAxisViews&&o.push(...e.topPriceAxisViews(i,s)??[])}return o}_initActions(){if(!this._pane.hasState()||null!==this._actions)return;const e=this._undoModel,t=new Ko.ActionWithStandardIcon({
actionId:"Chart.PriceScale.Reset",options:{label:sn,iconId:"Chart.Reset",shortcutHint:(0,gt.humanReadableHash)(gt.Modifiers.Alt+82),statName:"ResetScale",onExecute:()=>this.reset()}}),i=new zo.Action({actionId:"Chart.PriceScale.ToggleAutoScale",options:{label:on,checkable:!0,checked:!0,statName:"ToggleAutoScale",onExecute:()=>{e.togglePriceScaleAutoScaleMode(this.priceScale()),this._updateScalesActions()}}}),s=new zo.Action({actionId:"Chart.PriceScale.TogglePercentage",options:{label:nn,checkable:!0,checked:this.priceScale().isPercentage(),statName:"TogglePercantage",onExecute:()=>{e.togglePriceScalePercentageScaleMode(this.priceScale()),this._updateScalesActions()}}}),o=new zo.Action({actionId:"Chart.PriceScale.ToggleIndexedTo100",options:{label:rn,checkable:!0,checked:this.priceScale().isIndexedTo100(),statName:"ToggleIndexedTo100",onExecute:()=>{e.togglePriceScaleIndexedTo100ScaleMode(this.priceScale()),this._updateScalesActions()}}}),n=new zo.Action({actionId:"Chart.PriceScale.ToggleLogarithmic",options:{label:an,checkable:!0,checked:this.priceScale().isLog(),statName:"ToggleLogScale",onExecute:()=>{e.togglePriceScaleLogScaleMode(this.priceScale()),this._updateScalesActions()}}}),r=new zo.Action({actionId:"Chart.PriceScale.ToggleRegular",options:{label:ln,checkable:!0,checked:this.priceScale().isRegular(),statName:"ToggleRegularScale",onExecute:()=>{e.setPriceScaleRegularScaleMode(this.priceScale()),this._updateScalesActions()}}}),a=new jo({actionId:"Chart.PriceScale.Labels.ToggleNoOverlappingLabelsVisibility",options:{label:cn,checkable:!0,checked:this.priceScale().properties().childs().alignLabels.value(),statName:"TogglePreciseLabels"}},{property:this.priceScale().properties().childs().alignLabels,undoModel:e,undoText:Yo}),l=new zo.Action({actionId:"Chart.PriceScale.ToggleInvertScale",options:{label:hn,checkable:!0,checked:this.priceScale().isInverted(),statName:"Invert Scale",onExecute:()=>{e.invertPriceScale(this.priceScale()),this._updateScalesActions()}}});this._actions={reset:t,setAutoScale:i,setPercentage:s,setIndexedTo100:o,setLog:n,setRegular:r,alignLabels:a,invertScale:l},this._updateScalesActions()}_logAction(){return this._isMainSeriesAxis()?this._chart.actions().logSeriesScale:(0,n.ensureNotNull)(this._actions).setLog}_percentageAction(){return this._isMainSeriesAxis()?this._chart.actions().percentSeriesScale:(0,n.ensureNotNull)(this._actions).setPercentage}_indexedTo100Action(){return this._isMainSeriesAxis()?this._chart.actions().indexedTo100SeriesScale:(0,n.ensureNotNull)(this._actions).setIndexedTo100}_autoScaleAction(){return this._isMainSeriesAxis()?this._chart.actions().autoSeriesScale:(0,n.ensureNotNull)(this._actions).setAutoScale}_regularScaleAction(){return this._isMainSeriesAxis()?this._chart.actions().regularSeriesScale:(0,n.ensureNotNull)(this._actions).setRegular}_lockScaleAction(){const e=this._chart.actions().lockSeriesScale,t=dn(this.priceScale(),this._undoModel.model().mainSeriesScaleRatio());return e.update({hint:t}),e}_invertAction(){
return this._isMainSeriesAxis()?this._chart.actions().invertSeriesScale:(0,n.ensureNotNull)(this._actions).invertScale}_isMainSeriesAxis(){return this.priceScale().hasMainSeries()}_updateScalesActions(){const e=this.priceScale(),t=this._isMainSeriesAxis(),i=(0,n.ensureNotNull)(e.mainSource()).properties(),s=t&&e.isLockScale(),o=t&&6===i.style.value(),r=(0,n.ensureNotNull)(this._actions);r.setRegular.update({checked:e.isRegular(),disabled:s||o}),r.setPercentage.update({checked:e.isPercentage(),disabled:s||o}),r.setIndexedTo100.update({checked:e.isIndexedTo100(),disabled:s||o}),r.setLog.update({checked:e.isLog(),disabled:s||o}),r.setAutoScale.update({checked:e.isAutoScale(),disabled:e.properties().childs().autoScaleDisabled.value()})}_createMergeScalesAction(){const e=this._chart.actions(),t=this._undoModel.model().priceScaleSlotsCount();if(t.left+t.right===1)return 0===t.left?e.moveScaleToLeft:e.moveScaleToRight;const i=[];return i.push(e.mergeLeftScalesAction),i.push(e.mergeRightScalesAction),new zo.Action({actionId:"Chart.PriceScale.MergeAllScales",options:{label:Jo,subItems:i}})}_setCursor(e){let t="";"grabbing"!==e&&"ns-resize"!==e||(t="price-axis--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t,this._cell.style.cursor)}async _createScaleModeButtons(){const{PriceScaleModeButtonsRenderer:e}=await Promise.all([i.e(8975),i.e(2318),i.e(2227),i.e(3555)]).then(i.bind(i,34419)),t=new e({className:"price-axis__modeButtons",setMode:e=>{this._priceScale&&("log"===e?this._chart.model().setPriceScaleMode({log:!this._priceScale.isLog()},this._priceScale,Xo):this._chart.model().setPriceScaleMode({autoScale:!this._priceScale.isAutoScale()},this._priceScale,Zo))},getMode:()=>this._priceScale?.mode()});return t.element().style.background=this.backgroundColor(),this._cell.appendChild(t.element()),this._priceScale?.modeChanged().subscribe(this,this._updateScaleModeButtons),t}_destroyScaleModeButtons(){this._scaleModeButtons&&(this._isHovered.unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._selectedViaTap.unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._pane.visuallyCollapsed().unsubscribe(this._updatePriceScaleModeButtonsVisibility),this._priceScale?.modeChanged().unsubscribe(this,this._updateScaleModeButtons),this._scaleModeButtons.destroy(),this._scaleModeButtons=null)}_highlightColor(){const e=this.backgroundColor(),t=this._backgroundBasedTheme.value();if(null===this._highlightColorCache||this._highlightColorCache.backgroundColor!==e||this._highlightColorCache.theme!==t){const i=(0,Ro.applyTransparency)(L.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight"),50),s=(0,Nt.rgbaToString)((0,Nt.blendRgba)((0,Nt.parseRgba)(this.backgroundColor()),(0,Nt.parseRgba)(i)));this._highlightColorCache={theme:t,backgroundColor:e,resultColor:s}}return this._highlightColorCache.resultColor}_applyLightUpdateIfRequired(){
"visibleOnMouseOver"===(0,Be.actualCurrencyUnitVisibility)().value()&&this._undoModel.model().lightUpdate()}}function vn(e,t){return e.position-t.position}function Sn(e,t,i){const s=(e.position-t.position)/(e.time-t.time);return Math.sign(s)*Math.min(Math.abs(s),i)}!function(e){e[e.MaxStartDelay=50]="MaxStartDelay",e[e.EpsilonDistance=1]="EpsilonDistance"}(fn||(fn={}));class bn{constructor(e,t,i,s){this._position1=null,this._position2=null,this._position3=null,this._position4=null,this._animationStartPosition=null,this._durationMsecs=0,this._speedPxPerMsec=0,this._minSpeed=e,this._maxSpeed=t,this._dumpingCoeff=i,this._minMove=s}addPosition(e,t){if(null!==this._position1){if(this._position1.time===t)return void(this._position1.position=e);if(Math.abs(this._position1.position-e)<this._minMove)return}this._position4=this._position3,this._position3=this._position2,this._position2=this._position1,this._position1={time:t,position:e}}start(e,t){if(null===this._position1||null===this._position2)return;if(t-this._position1.time>50)return;let i=0;const s=Sn(this._position1,this._position2,this._maxSpeed),o=vn(this._position1,this._position2),n=[s],r=[o];if(i+=o,null!==this._position3){const e=Sn(this._position2,this._position3,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=vn(this._position2,this._position3);if(n.push(e),r.push(t),i+=t,null!==this._position4){const e=Sn(this._position3,this._position4,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=vn(this._position3,this._position4);n.push(e),r.push(t),i+=t}}}}let a=0;for(let e=0;e<n.length;++e)a+=r[e]/i*n[e];Math.abs(a)<this._minSpeed||(this._animationStartPosition={position:e,time:t},this._speedPxPerMsec=a,this._durationMsecs=function(e,t){const i=Math.log(t);return Math.log(1*i/-e)/i}(Math.abs(a),this._dumpingCoeff))}getStartPosition(){return(0,n.ensureNotNull)(this._animationStartPosition).position}getPosition(e){const t=(0,n.ensureNotNull)(this._animationStartPosition),i=e-t.time;return t.position+this._speedPxPerMsec*(Math.pow(this._dumpingCoeff,i)-1)/Math.log(this._dumpingCoeff)}finished(e){return null===this._animationStartPosition||this._progressDuration(e)===this._durationMsecs}_progressDuration(e){const t=e-(0,n.ensureNotNull)(this._animationStartPosition).time;return Math.min(t,this._durationMsecs)}}var wn=i(97995);const Cn=(0,ne.getLogger)("Chart.ChartUndoModel");var Tn;!function(e){e[e.MergeTimeout=1e3]="MergeTimeout"}(Tn||(Tn={}));const Pn=new dt.TranslatedString("scale price",a.t(null,void 0,i(94981)));class xn extends st.UndoCommand{constructor(e,t,i,s,o,n=!0){super(Pn,!1,n),this._newPriceScaleState=null,this._model=e,this._paneIndex=e.panes().indexOf(t),this._priceScaleId=i.id(),this._state=s,this._timestamp=o?performance.now():null}undo(){if(null!==this._newPriceScaleState)return void Cn.logDebug("PriceScaleChangeUndoCommand.undo: Command is already undone");const[e,t]=this._paneAndScale();this._newPriceScaleState=t.state(),this._model.restorePriceScaleState(e,t,this._state)}redo(){
if(null===this._newPriceScaleState)return void Cn.logDebug("PriceScaleChangeUndoCommand.redo: Command is not undone");const[e,t]=this._paneAndScale();this._model.restorePriceScaleState(e,t,this._newPriceScaleState),this._newPriceScaleState=null}canMerge(e){return e instanceof xn&&null!==this._timestamp&&null!==e._timestamp&&null===this._newPriceScaleState&&e._model===this._model&&e._paneIndex===this._paneIndex&&e._priceScaleId===this._priceScaleId&&Math.abs(e._timestamp-this._timestamp)<1e3}merge(e){this._timestamp=e._timestamp}_paneAndScale(){const e=this._model.panes()[this._paneIndex],t=(0,n.ensureNotNull)(e.getPriceScaleById(this._priceScaleId));return[e,t]}}var Mn,In=i(72104),An=i(67135);function Ln(e,t){0}function kn(e){Ln()}!function(e){e.Create="create",e.Paste="paste",e.Clone="clone"}(Mn||(Mn={}));var En=i(38780),Dn=i(94322);function Bn(e){return"startMoving"in e&&"move"in e&&"endMoving"in e&&"convertYCoordinateToPriceForMoving"in e}var Vn=i(2115);let Rn=null;function Nn(){return Rn}var On=i(64236),Fn=i(85552);i(76003);const Wn=parseInt(Fn["css-value-pane-controls-padding"]),Hn=(0,Rt.getHexColorByName)("color-cold-gray-700"),zn=(0,Rt.getHexColorByName)("color-cold-gray-400"),Un=new dt.TranslatedString("scroll",a.t(null,void 0,i(42070))),jn=a.t(null,void 0,i(66005));a.t(null,void 0,i(78972));function Gn(e,t,i){e.drawBackground&&e.drawBackground(t,i)}function qn(e,t,i){e.draw(t,i)}function $n(e,t){return e.paneViews(t)}function Kn(e,t){return e.topPaneViews?.(t)??[]}function Yn(e,t){return e.labelPaneViews(t)}function Zn(e,t){const i=e.strategyOrdersPaneView();return null===i?null:[i]}function Xn(e,t){return null===e||e.source!==t?null:e.hittest.data()}function Jn(e,t,i,s,o){const n=e.result?.hittest.target()??0;t.target()>n&&(e.result={hittest:t,source:i,renderer:s,isCustom:o})}const Qn={contextMenuEnabled:!0,contextMenu:In.defaultChartWidgetActionsOptions,priceScaleContextMenuEnabled:!0,legendWidgetEnabled:!0,controlsEnabled:!0,propertyPagesEnabled:!0,sourceSelectionEnabled:!0,countdownEnabled:!0},er=new Map([[Ut.AreaName.Text,"Text"],[Ut.AreaName.Style,"Style"]]),tr=!l.enabled("display_legend_on_all_charts");var ir;!function(e){e[e.MinScrollSpeed=.2]="MinScrollSpeed",e[e.MaxScrollSpeed=7]="MaxScrollSpeed",e[e.DumpingCoeff=.997]="DumpingCoeff",e[e.ScrollMinMove=15]="ScrollMinMove",e[e.SPenMaxDistance=5]="SPenMaxDistance",e[e.CollapsedHeight=33]="CollapsedHeight"}(ir||(ir={}));let sr=null;function or(e,t){return!(0,Ut.shouldDefaultActionBeExecuted)(e,t,"pressedMouseMoveHandler","touchMoveHandler")}var nr;!function(e){e[e.None=0]="None",e[e.DownWithoutMove=1]="DownWithoutMove",e[e.DownWithMove=2]="DownWithMove"}(nr||(nr={}));class rr{constructor(e,t,i,s){this._legendWidget=null,this._paneControls=null,this._isDestroyed=!1,this._trackCrosshairOnlyAfterLongTap=(0,lo.lastMouseOrTouchEventInfo)().isTouch,this._startTrackPoint=null,this._exitTrackingModeOnNextTry=!1,this._startMoveSourceParams=null,this._startChangeLineToolParams=null,this._preventSourceChange=!1,
this._preventScrollUntilNextMouseDownOrTouchStart=!1,this._clonningAtMoveLineTools=null,this._startCloningPoint=null,this._size=(0,Ft.size)({width:0,height:0}),this._themedTopColor=null,this._initCrossHairPosition=null,this._firstZoomPoint=null,this._editDialog=null,this._processing=!1,this._pressedMoveStage=0,this._touchMove=!1,this._startTouchPoint=null,this._isSelecting=!1,this._prevHoveredHittest=null,this._contextMenuX=0,this._contextMenuY=0,this._startScrollingPos=null,this._isScrolling=!1,this._scrollPriceScale=null,this._scrollXAnimation=null,this._prevPinchScale=1,this._pinching=!1,this._wasPinched=!1,this._longTap=!1,this._contextMenuOpenedOnLastTap=!1,this._paneControlsResizeObserver=null,this._lastClickedSource=null,this._customLegendWidgetsFactoryMap=new Map,this._prevMoveEventPosition=null,this._onMagnetStateChangedListener=this._onMagnetStateChanged.bind(this),this._onShiftKeyStateChangedListener=this._onShiftKeyStateChanged.bind(this),this._currentCursorClassName="",this._lastFinishedToolId=null,this._needResetMeasureLater=!1,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null,this._prevTooltipData=null,this._errorRenderer=null,this._highlightedPriceAxises=new wo.WatchedObject([]),this._visuallyCollapsed=new O.WatchedValue(!1),this._maximized=new O.WatchedValue(!1),this._endOfSeriesDataBanner=null,this._selectionBeforeMouseDown=new WeakSet,this._mouseTouchDownUpInfo=null,this._ignoringMouseMovement=!1,this._canvasConfiguredHandler=()=>this._state&&this._chartModel().lightUpdate(),this._updateVisuallyCollapsed=()=>{this._visuallyCollapsed.setValue(!this.state().maximized().value()&&this.state().collapsed().value())},this._updateMaximized=()=>{this._maximized.setValue(this.state().maximized().value())},this._chart=e,this._state=t,this._options=(0,tt.merge)((0,tt.clone)(Qn),i),this._paneWidgetsSharedState=s,this._state&&this._subscribeToState();const o={contextMenuEnabled:this._options.priceScaleContextMenuEnabled,pressedMouseMoveScale:this._options.handleScale.axisPressedMouseMove.price,mouseWheelScale:this._options.handleScale.mouseWheel,currencyConversionEnabled:this._options.currencyConversionEnabled,unitConversionEnabled:this._options.unitConversionEnabled,countdownEnabled:this._options.countdownEnabled,croppedTickMarks:this._options.croppedTickMarks};void 0!==this._options.priceScaleContextMenu&&(o.contextMenu=this._options.priceScaleContextMenu);const r=(e,t,i,s,n)=>new yn(this._chart,this,this._chartUndoModel(),i,t,e,o,s,n),a=e.properties().childs().scalesProperties,c=this._chartModel().rendererOptionsProvider(),h={backgroundBasedTheme:e.backgroundBasedTheme().spawnOwnership(),stubContextMenuProvider:()=>Promise.resolve([]),titlesProvider:()=>[],rendererOptionsProvider:c,getBackgroundTopColor:()=>this._chartModel().backgroundTopColor().value(),getBackgroundBottomColor:()=>this._chartModel().backgroundColor().value(),requestRepaint:()=>this._chartModel().lightUpdate()};this._rowElement=document.createElement("div"),this._rowElement.style.display="flex";const d={showLabels:!1}
;this._lhsPriceAxisesContainer=t.mode()===zi.PaneMode.Regular?new Vo(a,"left",r,h,d):new PaneWidgetSideArea(c,"left"),this._rhsPriceAxisesContainer=t.mode()===zi.PaneMode.Regular?new Vo(a,"right",r,h,d):new PaneWidgetSideArea(c,"right"),this._paneCell=document.createElement("div"),this._paneCell.classList.add("chart-markup-table","pane"),this._div=document.createElement("div"),this._div.classList.add("chart-gui-wrapper"),this._div.setAttribute("data-name","pane-widget-chart-gui-wrapper"),this._paneCell.appendChild(this._div),this._canvasBinding=(0,Kt.createBoundCanvas)(this._div,(0,Ft.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const u=this._canvasBinding.canvasElement;u.style.position="absolute",u.style.left="0",u.style.top="0",u.dataset.name="pane-canvas",this._topCanvasBinding=(0,Kt.createBoundCanvas)(this._div,(0,Ft.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const _=this._topCanvasBinding.canvasElement;_.style.position="absolute",_.style.left="0",_.style.top="0",_.dataset.name="pane-top-canvas",this._rowElement.appendChild(this._lhsPriceAxisesContainer.getElement()),this._rowElement.appendChild(this._paneCell),this._rowElement.appendChild(this._rhsPriceAxisesContainer.getElement()),u.setAttribute("aria-hidden","true");const p=this._chartModel().mainSeries();p.dataEvents().symbolResolved().subscribe(this,this._updateAccessibilityAttr),this._mainSeriesInterval=p.intervalObj().spawn(),this._mainSeriesInterval.subscribe(this._updateAccessibilityAttr.bind(this)),this._updateAccessibilityAttr(),this._options.legendWidgetEnabled&&(this._options.customLegendWidgetFactories&&(this._customLegendWidgetsFactoryMap=this._options.customLegendWidgetFactories),this._loadAndCreateLegendWidget()),this._state&&!this._chart.readOnly()&&this._options.controlsEnabled&&this._loadAndCreatePaneControlsWidget(this._state),(0,Dn.magnetEnabled)().subscribe(this._onMagnetStateChangedListener),(0,Vs.shiftPressed)().subscribe(this._onShiftKeyStateChangedListener),l.enabled("chart_drag_export")&&(_.draggable=this._chartModel().dragExportEnabled().value(),this._chartModel().dragExportEnabled().subscribe((e=>{_.draggable=e})),_.addEventListener("dragend",(e=>{this._ignoringMouseMovement=!1,this._chartModel().dragExportEnabled().value()&&(0,ee.emit)("dragend")})),_.addEventListener("dragstart",(async e=>{if(this._ignoringMouseMovement=!1,!this._chartModel().dragExportEnabled().value())return void e.preventDefault();e.stopPropagation();const t=this._chartUndoModel().model().hoveredSource(),i=Nn(),s={enableDragDrop:!1};if((0,ee.emit)("dragstart",{enableDragDrop:e=>s.enableDragDrop=e,preventDefault:()=>e.preventDefault(),keys:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,altKey:e.altKey,shiftKey:e.shiftKey},hoveredSourceId:t?.id()??null,exportData:e=>{const t=e=>s().convertPublicTimeToInternalTime(e),s=()=>(0,On.getChartWidgetApiTimeConverter)(p.interval(),(0,
n.ensureNotNull)(p.symbolInfo(),"main series symbol info"),this._chartModel());return void 0!==e?.from&&(e.from=t(e.from)),void 0!==e?.to&&(e.to=t(e.to)),i?.exportData(this._chartModel(),e)},setData:(t,i)=>{e.dataTransfer&&e.dataTransfer.setData(t,i)},setDragImage:(t,i,s)=>{e.dataTransfer&&e.dataTransfer.setDragImage(t,i,s)}}),!e.dataTransfer?.getData("text/plain")&&!e.dataTransfer?.getData("text/html"))return void e.preventDefault();this._isSelecting=!1;this._chartModel().crosshairSource().clearSelection(),this._paneWidgetsSharedState.clearDraggingSource(),this._ignoringMouseMovement=!0}))),this.setCursorForTool(),this._mouseEventHandler=new Wt.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{treatVertTouchDragAsPageScroll:!this._options.handleScroll.vertTouchDrag,treatHorzTouchDragAsPageScroll:!this._options.handleScroll.horzTouchDrag,shouldAllowTouchDrag:()=>this.trackingModeEnabled()}),this._paneCellMouseEventHandler=new Wt.MouseEventHandler(this._paneCell,{doubleTapEvent:this._paneDblClickOrTapEvent.bind(this),mouseDoubleClickEvent:this._paneDblClickOrTapEvent.bind(this)},{shouldAllowTouchDrag:()=>this.trackingModeEnabled(),treatVertTouchDragAsPageScroll:!this._options.handleScroll.vertTouchDrag,treatHorzTouchDragAsPageScroll:!this._options.handleScroll.horzTouchDrag}),this._prevHoveredHittest=null,this._highlightedPriceAxises.subscribe((e=>{this._highlightPriceAxisesByLabel(e.map((e=>e.axis)))})),this._prevPinchScale=0,this._isDestroyed=!1;const m=(0,ft.combine)((e=>{const t=this._chart.paneWidgetSeparators(this);return[t.separatorAbove?.selected()?.weakReference()??new O.WatchedValue(!1).ownership(),t.separatorBelow?.selected()?.weakReference()??new O.WatchedValue(!1).ownership()]}),this._chart.paneWidgetsWV().weakReference());this._anySeparatorSelected=(0,ft.accumulate)((e=>e.some(Boolean)),m.ownership())}destroy(){this._chart.onPaneWidgetDestroyed(this);this._chartModel().mainSeries().dataEvents().symbolResolved().unsubscribeAll(this),this._customLegendWidgetsFactoryMap.clear(),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._legendWidget&&(this._legendWidget.destroy(),this._legendWidget=null),null!==this._paneControlsResizeObserver&&this._paneControlsResizeObserver.disconnect(),null!==this._paneControls&&(this._paneControls.destroy(),this._paneControls=null),this._lhsPriceAxisesContainer.destroy(),this._rhsPriceAxisesContainer.destroy(),this.hasState()&&this._unsubscribeFromState(),(0,Dn.magnetEnabled)().unsubscribe(this._onMagnetStateChangedListener),(0,Vs.shiftPressed)().unsubscribe(this._onShiftKeyStateChangedListener),this._paneWidgetsSharedState.onPaneDestroyed(this),this._errorRenderer&&this._errorRenderer.then((e=>{e.destroy(),this._errorRenderer=null})),this._prevHoveredHittest=null,this._mouseEventHandler.destroy(),this._paneCellMouseEventHandler.destroy(),
this._rowElement.parentElement?.removeChild(this._rowElement),this._anySeparatorSelected.destroy(),this._mainSeriesInterval.destroy(),this._isDestroyed=!0}updateOptions(e){if((0,tt.merge)(this._options,e),!1===e.legendWidgetEnabled&&this._legendWidget&&(this._legendWidget.destroy(),this._legendWidget=null),e.legendWidgetEnabled&&!this._legendWidget&&(this._options.customLegendWidgetFactories&&(this._customLegendWidgetsFactoryMap=this._options.customLegendWidgetFactories),this._loadAndCreateLegendWidget()),!this._state)return;const t=this._state.mode(),i=this._chartModel().rendererOptionsProvider();if(t===zi.PaneMode.Regular&&!(this._lhsPriceAxisesContainer instanceof Vo)){this._lhsPriceAxisesContainer.destroy(),this._rhsPriceAxisesContainer.destroy();const e={showLabels:!1},t={contextMenuEnabled:this._options.priceScaleContextMenuEnabled,pressedMouseMoveScale:this._options.handleScale.axisPressedMouseMove.price,mouseWheelScale:this._options.handleScale.mouseWheel,currencyConversionEnabled:this._options.currencyConversionEnabled,unitConversionEnabled:this._options.unitConversionEnabled,countdownEnabled:this._options.countdownEnabled,croppedTickMarks:this._options.croppedTickMarks},s=(e,i,s,o,n)=>new yn(this._chart,this,this._chartUndoModel(),s,i,e,t,o,n),o=this._chart.properties().childs().scalesProperties,n=()=>this._chartModel().backgroundColor().value(),r=()=>this._chartModel().backgroundTopColor().value(),a={backgroundBasedTheme:this._chart.backgroundBasedTheme().spawnOwnership(),stubContextMenuProvider:()=>Promise.resolve([]),titlesProvider:()=>[],rendererOptionsProvider:i,getBackgroundTopColor:r,getBackgroundBottomColor:n,requestRepaint:()=>this._chartModel().lightUpdate()};this._lhsPriceAxisesContainer=new Vo(o,"left",s,a,e),this._rhsPriceAxisesContainer=new Vo(o,"right",s,a,e),this._rowElement.innerHTML="",this._rowElement.appendChild(this._lhsPriceAxisesContainer.getElement()),this._rowElement.appendChild(this._paneCell),this._rowElement.appendChild(this._rhsPriceAxisesContainer.getElement())}t!==zi.PaneMode.Widget||this._lhsPriceAxisesContainer instanceof PaneWidgetSideArea||(this._lhsPriceAxisesContainer.destroy(),this._rhsPriceAxisesContainer.destroy(),this._lhsPriceAxisesContainer=new PaneWidgetSideArea(i,"left"),this._rhsPriceAxisesContainer=new PaneWidgetSideArea(i,"right"),this._rowElement.innerHTML="",this._rowElement.appendChild(this._lhsPriceAxisesContainer.getElement()),this._rowElement.appendChild(this._paneCell),this._rowElement.appendChild(this._rhsPriceAxisesContainer.getElement()))}size(){return this._size}setSize(e){(0,Ft.equalSizes)(this._size,e)||(this._size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._paneCell.style.width=e.width+"px",this._paneCell.style.height=e.height+"px",this._div.style.width=e.width+"px",this._div.style.height=e.height+"px",this._rowElement.classList.toggle("js-hidden",0===e.height),null!==this._legendWidget&&this._legendWidget.updateWidgetModeBySize(e),
null!==this._paneControls&&this._paneControls.updateWidgetModeByWidth(e.width))}width(){return this._size.width}height(){return this._size.height}backgroundColor(){return this._chartModel().backgroundColor().value()}highlightedPriceAxises(){return this._highlightedPriceAxises}processDoubleClickOnSource(e,t,i){if((0,zs.isEditableTextLineTool)(e)){const t=e.textEditingActivationTime();null!==t&&performance.now()-t<500&&e.deactivateTextEditing()}(0,Po.isDataSource)(e)&&e.id()!==this._lastFinishedToolId&&this._showEditDialogForSource(e,t)}stretchFactor(){return this._state?this._state.stretchFactor():0}setStretchFactor(e){this.hasState()&&this.state().setStretchFactor(e)}setCursorForTool(e,t,i){if(t&&t.mod()&&e&&e!==this._chartModel().crosshairSource())return void this._setCursorClassName("pointer");if(void 0!==i){switch(i){case ei.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case ei.PaneCursorType.HorizontalResize:this._setCursorClassName("ew-resize");break;case ei.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case ei.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize");break;case ei.PaneCursorType.Default:this._setCursorClassName("default");break;case ei.PaneCursorType.Pointer:this._setCursorClassName("pointer");break;case ei.PaneCursorType.Grabbing:this._setCursorClassName("grabbing");break;case ei.PaneCursorType.Text:this._setCursorClassName("text");break;case ei.PaneCursorType.None:this._setCursorClassName("none")}return}const s=mt.tool.value();if((0,mt.toolIsCursor)(s)){if(null!==this._paneWidgetsSharedState.draggingSource()||this._isScrolling||this._chartUndoModel()&&this._chartUndoModel().model().sourcesBeingMoved().length)return void this._setCursorClassName("grabbing");if(e&&this._options.sourceSelectionEnabled)return void this._setCursorClassName("pointer")}let o="";switch(s){case"eraser":o="eraser";break;case"zoom":o="zoom-in"}if(!o)switch(mt.cursorTool.value()){case"arrow":o="default";break;case"dot":o="dot";break;case"demonstration":o="demonstration";break;case"performance":o="performance"}this._setCursorClassName(o)}showContextMenuForSelection(e,t,i){const s=this._chartUndoModel().selection();if(s.isEmpty())return;const o=s.dataSources().filter((e=>e.hasContextMenu()));this.showContextMenuForSources(o,e,void 0,t,i)}async showContextMenuForSources(e,t,i,s,o){if(!e.length||!this._state)return Promise.resolve(null);const{ActionsProvider:n}=await(0,Go.actionsProviderModule)();if(this._isDestroyed)return null;const r=e[0],a=(0,tt.merge)((0,tt.clone)(this._options.contextMenu),i||{}),l=new n(this._chart,a);if(r===this._chartUndoModel().crosshairSource())return r.handleContextMenuEvent(t),Promise.resolve(null);{const i=await l.contextMenuActionsForSources(e,this._state,t,s?.origin,o?.data()?.customActions);if(0===i.length)return Promise.resolve(null);{let e={menuName:""};return r instanceof Vn.Series?e={menuName:s?.origin??"ObjectTreeContextMenu",detail:{type:"series",id:r.instanceId()}}:(0,zs.isLineTool)(r)?e={
menuName:s?.origin??"ObjectTreeContextMenu",detail:{type:"shape",id:r?.id()??null}}:(0,Ws.isStudy)(r)&&(e={menuName:s?.origin??"ObjectTreeContextMenu",detail:{type:"study",id:r?.id()||null}}),Io.ContextMenuManager.createMenu(i,{takeFocus:!0,returnFocus:!0,isKeyboardEvent:a.isKeyboardEvent,statName:r.contextMenuStatName()},e).then((e=>(e.show(t),e)))}}}leftPriceAxisesContainer(){return this._lhsPriceAxisesContainer}rightPriceAxisesContainer(){return this._rhsPriceAxisesContainer}setPriceAxisSizes(e,t,i){this._priceAxisesContainer(e).setSizes(t,i)}state(){return(0,n.ensureNotNull)(this._state)}hasState(){return null!==this._state}setState(e){this._state!==e&&(this.hasState()&&(this._unsubscribeFromState(),this._paneControls?.destroy(),this._paneControls=null),this._state=e,this.hasState()&&(this.updateOptions(this._options),this._subscribeToState(),this._loadAndCreatePaneControlsWidget(this.state()),this.updatePriceAxisWidgetsStates(),this._updateAccessibilityAttr()))}getScreenshotData(e){const t=[],i=[];let s,o=[];const n=this.state(),r=n.mode()===zi.PaneMode.Widget?[]:n.sourcesByGroup().priceSources().slice().reverse(),a=this._chart.properties().childs().paneProperties.childs().legendProperties.childs();for(const c of r){const r=c.statusView();if((0,Ws.isStudy)(c)&&(a.showLegend.value()||e?.showCollapsedStudies)){const s=a.showStudyTitles.value(),o=s;if(c.properties().childs().visible.value()&&this._chartModel().paneForSource(c)===n&&r&&o){t.push(s?c.statusProvider(e?.status).text():"");const o=l.enabled("use_last_visible_bar_value_in_legend")?this._chartModel().timeScale().visibleBarsStrictRange()?.lastBar()??null:null,n=c.legendValuesProvider().getValues(o);i.push(n)}}else if(c===this._chartModel().mainSeries()&&r&&a.showSeriesTitle.value()){const t=c.statusProvider(e?.status||{}).getSplitTitle();s=Object.values(t).filter((e=>""!==e)).join(" · ");const i=l.enabled("use_last_visible_bar_value_in_legend")?this._chartModel().timeScale().visibleBarsStrictRange()?.lastBar()??null:null;o=c.legendValuesProvider().getValues(i)}}return{type:"pane",leftAxis:this._lhsPriceAxisesContainer.getScreenshotData(),rightAxis:this._rhsPriceAxisesContainer.getScreenshotData(),content:this._canvasBinding.canvasElement.toDataURL(),canvas:this._canvasBinding.canvasElement,contentWidth:this._size.width,contentHeight:this._size.height,studies:t,studiesValues:i,containsMainSeries:this.containsMainSeries(),mainSeriesText:s,mainSeriesValues:o}}updatePriceAxisWidgetsStates(){if(!this.hasState())return;const e=this._chartModel(),t=e.paneForSource(e.mainSeries());if(t)if(this._state?.mode()===zi.PaneMode.Regular){const i=e.priceScaleSlotsCount(),s=this.state(),o=s.visibleLeftPriceScales(),n=s.visibleRightPriceScales();this._lhsPriceAxisesContainer.setScales(o,i.left,t.leftPriceScales().length,i.left+i.right),this._rhsPriceAxisesContainer.setScales(n,i.right,t.rightPriceScales().length,i.left+i.right)}else this._state?.mode()===zi.PaneMode.Widget&&(this._lhsPriceAxisesContainer.setPane(this._state),
this._rhsPriceAxisesContainer.setPane(this._state))}updatePriceAxisWidgets(){this._lhsPriceAxisesContainer.update(),this._rhsPriceAxisesContainer.update()}update(){this.hasState()&&(this.updatePriceAxisWidgets(),null!==this._legendWidget&&this._legendWidget.update(),this.updateControls())}updateStatusWidget(e){this.hasState()&&null!==this._legendWidget&&(e.legendWidgetLayoutInvalidated()?this._legendWidget.updateLayout():this._legendWidget.update())}updateControls(){this.hasState()&&null!==this._paneControls&&this._paneControls.update()}updateThemedColors(e){this._themedTopColor=e.topColor,this._updateByThemedColors()}statusWidget(){return this._legendWidget}getElement(){return this._rowElement}canvasElement(){return this._canvasBinding.canvasElement}getRenderingInfo(){return(0,Kt.getBindingRenderingInfo)(this._canvasBinding)}hasCanvas(e){return this._canvasBinding.canvasElement===e||this._topCanvasBinding.canvasElement===e}pinchStartEvent(){return null===this._paneWidgetsSharedState.scrollingPane()&&null===this._paneWidgetsSharedState.pinchingPane()&&(this._onTouchEvent(),!!this._options.handleScale.pinch&&(this._chartModel().stopTimeScaleAnimation(),this._prevPinchScale=1,this._pinching=!0,this._wasPinched=!0,this._paneWidgetsSharedState.setPinchingPane(this),!0))}pinchEvent(e,t,i,s){if(null!==this._paneWidgetsSharedState.scrollingPane()||this._paneWidgetsSharedState.pinchingPane()!==this)return;if(this._onTouchEvent(),!this._options.handleScale.pinch)return;const o=10*(s-this._prevPinchScale);this._prevPinchScale=s,this._chartModel().zoomTime(e.x,o,!0),this._prevPinchScale=s}pinchEndEvent(){null===this._paneWidgetsSharedState.scrollingPane()&&this._paneWidgetsSharedState.pinchingPane()===this&&(this._onTouchEvent(),this._pinching=!1,this._paneWidgetsSharedState.setPinchingPane(null))}mouseClickEvent(e){this._onMouseEvent(),this._mouseClickOrTapEvent(e)}tapEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseClickOrTapEvent(e))}mouseDownEvent(e){this._onMouseEvent(),this.hasState()&&this._mouseDownOrTouchStartEvent(e,this._dataSourceAtPoint(e.localX,e.localY))}touchStartEvent(e){if(this._paneWidgetsSharedState.startTouch(this),this._preventTouchEventsExceptPinch())return;const t=!this._trackCrosshairOnlyAfterLongTap&&null!==sr&&sr.stateId===this.state().id()&&Math.abs(sr.x-e.localX)+Math.abs(sr.y-e.localY)<5;this._onTouchEvent(),this._chart.setActivePaneWidget(this);const i=this._dataSourceAtPoint(e.localX,e.localY);if(t){const t=this._chartModel().crosshairSource();null!==i&&i.source===t||t.selectPointMode().value()!==mt.SelectPointMode.None?this.startTrackingMode(new Vt.Point(e.localX,e.localY),new Vt.Point(e.localX,e.localY)):!this._chart.readOnly()&&null!==i&&(0,zs.isLineTool)(i.source)&&i.source.userEditEnabled()&&this._chartUndoModel().selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(i.source,i.hittest.data())}))}this._mouseDownOrTouchStartEvent(e,i),this._mouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._onMouseEvent(),this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){
this._paneWidgetsSharedState.endTouch(this),this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseOrTouchLeaveEvent(e),this._mouseUpOrTouchEndEvent(e))}mouseMoveEvent(e){this._onMouseEvent(),this._mouseOrTouchMoveEvent(e)}pressedMouseMoveEvent(e){this._onMouseEvent(),this._state?.model().chartFloatingTooltipVisible().value()?this._mouseOrTouchMoveEvent(e):this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._pressedMouseOrTouchMoveEvent(e))}mouseLeaveEvent(e){this._onMouseEvent(),this._updateHoveredSource(null,new To.EnvironmentState(e)),this._mouseOrTouchLeaveEvent(e)}mouseDoubleClickEvent(e){this._onMouseEvent(),this._mouseDoubleClickOrDoubleTapEvent(e)}wheelClickEvent(e){if(this._chart.readOnly())return;const t=this._dataSourceAtPoint(e.localX,e.localY);if(null===t||t.isCustom)return;if((t.hittest.target()||0)<=Ut.HitTarget.MovePointBackground)return;const i=new To.EnvironmentState(e),s=t.hittest.eraseMarker();if(i.mod()&&void 0!==s&&t.source.processErase)return void t.source.processErase(this._chartUndoModel(),s);const o=this._chartUndoModel();o.selection().isSelected(t.source)||o.selectionMacro((e=>{e.clearSelection();const i=(0,n.ensureNotNull)(t.source);e.addSourceToSelection(i,Xn(t,i))})),this._chart.removeSelectedSources()}doubleTapEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._mouseDoubleClickOrDoubleTapEvent(e))}longTapEvent(e){if(null===this._state||this._preventTouchEventsExceptPinch())return;if(this._onTouchEvent(),this._longTap=!0,null!==this._startTrackPoint||!this._trackingModeShouldBeActive())return;const t=this._chartModel().selection();if(!t.isEmpty()){const i=this._dataSourceAtPoint(e.localX,e.localY);if(null!==i&&t.isSelected(i.source))return}this.startTrackingMode(new Vt.Point(e.localX,e.localY),new Vt.Point(e.localX,e.localY),new To.EnvironmentState(e))}mouseEnterEvent(e){if(this._onMouseEvent(),!this.hasState())return;this._chart.setActivePaneWidget(this);const t=this._dataSourceAtPoint(e.localX,e.localY);this._updateHoveredSource(t,new To.EnvironmentState(e)),this.setCursorPosition(e.localX,e.localY,new To.EnvironmentState(e))}contextMenuEvent(e){this._onMouseEvent(),this._contextMenuEvent(e)}touchContextMenuEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._contextMenuEvent(e))}mouseDownOutsideEvent(e){this._processOutsideClick(null,e)}touchStartOutsideEvent(e){this._processOutsideClick(null,e)}cancelZoom(){this._chartModel().crosshairSource().clearSelection(),this._firstZoomPoint=null,this._preventCrossHairMove()&&this._clearCursorPosition()}startTrackingMode(e,t,i){this.state().mode()!==zi.PaneMode.Widget&&(this._startChangeLineToolParams=null,this._startMoveSourceParams=null,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null,this._chartUndoModel().selectionMacro((e=>e.clearSelection())),this._startTrackPoint=e,this._exitTrackingModeOnNextTry=!1,this.setCursorPosition(t.x,t.y,i),
this._initCrossHairPosition=this._chartModel().crosshairSource().currentPoint())}setDragToAnotherPaneCursor(){this._setCursorClassName("grabbing")}cloneLineTools(e,t){return this._chartUndoModel().cloneLineTools(e,t)}exitTrackingMode(){null!==this._state&&null!==this._startTrackPoint&&(this._exitTrackingModeOnNextTry=!0,this._tryExitTrackingMode())}trackingModeEnabled(){return null!==this._state&&null!==this._startTrackPoint}addCustomWidgetToLegend(e,t){this._options.legendWidgetEnabled&&(this._customLegendWidgetsFactoryMap.set(e,t),null!==this._legendWidget&&this._legendWidget.addCustomWidgetToLegend(e,t))}containsMainSeries(){return!!this.hasState()&&this.state().containsMainSeries()}paint(e,t){if(!this._chartUndoModel()||!this.hasState()||0===this._size.width||0===this._size.height)return;(0,Kt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),(0,Kt.tryApplySuggestedCanvasBitmapSize)(this._topCanvasBinding),this._state&&(e.priceScaleSideMaxLevel("left")>ao.InvalidationLevel.Cursor||e.priceScaleSideMaxLevel("right")>ao.InvalidationLevel.Cursor)&&(this._recalculatePriceScales((0,wi.viewportChangeEvent)(this.state())),null!==sr&&sr.stateId===this.state().id()&&this.setCursorPosition(sr.x,sr.y,sr.envState));const i=e.fullInvalidation();if(i>ao.InvalidationLevel.Cursor&&null!==sr&&sr.stateId===this.state().id()){const e=this._dataSourceAtPoint(sr.x,sr.y);this._updateHoveredSource(e,(0,Vs.globalEnvironmentState)())}if(this._lhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("left"),t),this._rhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("right"),t),i===ao.InvalidationLevel.None)return;const s=this._state&&(this._state.maximized().value()||!this._state.collapsed().value()||this._state.mode()===zi.PaneMode.Widget);if(i>ao.InvalidationLevel.Cursor){const e=(0,n.ensureNotNull)(this._canvasBinding.canvasElement.getContext("2d"));e.setTransform(1,0,0,1,0,0);const t=(0,Kt.getBindingRenderingInfo)(this._canvasBinding);this._makeSureIsUpdated(t),this._drawBackground(e,t),s&&this._drawSources(e,t)}if(null!==this._state){const e=(0,n.ensureNotNull)(this._topCanvasBinding.canvasElement.getContext("2d"));e.setTransform(1,0,0,1,0,0);const t=(0,Kt.getBindingRenderingInfo)(this._topCanvasBinding);e.clearRect(0,0,t.bitmapSize.width,t.bitmapSize.height),s&&this._drawTopViews(e,t),this._drawCrossHair(e,t),s&&this._drawActiveLineTools(e,t)}}cancelCreatingLineTool(){const e=this._chartUndoModel(),t=this._chartUndoModel().lineBeingCreated();if(t)if(t.pointsCount()<=0&&!(0,Lt.isLineDrawnWithPressedButton)(t.toolname)){const i=t.points();if(i.length>2){const s=i[i.length-2];e.continueCreatingLine(s),this._finishTool(t)}else e.cancelCreatingLine()}else e.cancelCreatingLine();null!==this._firstZoomPoint&&this.cancelZoom(),this._clearCursorPosition(),this.setCursorForTool()}async drawRightThere(e,t){this.hasState()&&(await(0,xo.ensureLineToolLoaded)(e),this._chartUndoModel().drawRightThere(e,this.state(),void 0,t))}cancelMeasuring(){this._chartUndoModel().crosshairSource().clearMeasure(),
(0,mt.resetToCursor)(),this.setCursorForTool()}async setErrorMessage(e){e&&!this._errorRenderer&&(this._errorRenderer=this._createErrorBlock()),(await this._errorRenderer)?.update({message:e?.message,icon:this._state?.containsMainSeries()||this._state?.maximized().value()?e?.icon:void 0,backgroundColor:`linear-gradient(${this._chartModel().backgroundTopColor().value()}, ${this._chartModel().backgroundColor().value()})`,textColor:this._chartModel().dark().value()?zn:Hn,solutionId:e?.solutionId,rawHtml:e?.rawHtml,buttons:this.containsMainSeries()?e?.buttons:void 0,maxWidth:e?.maxWidth,maxHeight:e?.maxHeight,zeroHeight:e?.zeroHeight})}collapsedHeight(){return Math.max(Math.ceil(this._paneControls?.bottomWithMargin()??0),33)}visuallyCollapsed(){return this._visuallyCollapsed.readonly()}maximized(){return this._maximized.readonly()}setCursorPosition(e,t,i){this._updateLastCrosshairPosition(e,t,i),this._chartModel().setAndSaveCurrentPosition(this._correctXCoord(e),this._correctYCoord(t),this.state(),i)}_tryExitTrackingMode(e){this._exitTrackingModeOnNextTry&&(this._startTrackPoint=null,e||this._clearCursorPosition())}_tryStartMeasure(e,t,i,s,o){return!(!(0,mt.toolIsMeasure)(mt.tool.value())||t.startMeasurePoint())&&(e.isTouch||this._preventCrossHairMove()||this.setCursorPosition(e.localX,e.localY,i),s=this._chartModel().magnet().align(s,o,this.state()),t.startMeasuring({price:s,index:o},this.state()),!0)}_tryFinishMeasure(e,t){if(t.startMeasurePoint()&&!t.endMeasurePoint()){let i=t.price;const s=t.index;return i=this._chartModel().magnet().align(i,s,this.state()),t.finishMeasure({price:i,index:s}),e.isTouch?(0,mt.resetToCursor)():this._needResetMeasureLater=!0,this._preventCrossHairMove()&&this._clearCursorPosition(),!0}return!1}_tryStartZoom(e,t,i,s){const o=this._chart.model().model().zoomEnabled();if("zoom"===mt.tool.value()&&o){const o=this._chartUndoModel(),n=o.timeScale().indexToCoordinate(i)-.5*o.timeScale().barSpacing();return this._firstZoomPoint={price:t,index:i,x:n,y:e.localY},this._preventCrossHairMove()||this.setCursorPosition(e.localX,e.localY,s),this._chartModel().crosshairSource().startSelection(this.state()),!0}return!1}_finishZoom(e){const t=this.state(),i=t.defaultPriceScale(),s=(0,n.ensureNotNull)(t.mainDataSource()).firstValue(),o=i.coordinateToPrice(e.localY,(0,n.ensureNotNull)(s)),r=this._chartUndoModel(),a=Math.round(r.timeScale().coordinateToIndex(e.localX)),l=(0,n.ensureNotNull)(this._firstZoomPoint);a!==l.index&&r.zoomToViewport(l.index,a,l.price,o,t),this._chartModel().crosshairSource().clearSelection(),this._firstZoomPoint=null,(0,mt.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition()}_tryFinishZoom(e){return null!==this._firstZoomPoint&&(this._finishZoom(e),!0)}_tryHandleEraserMouseDown(e,t){if((0,mt.toolIsEraser)(mt.tool.value())&&!e.isCustom&&(!(i=e.source)||!i.customization||!i.customization.disableErasing)){const i=this._chartUndoModel();if((0,zs.isLineTool)(e.source)||(0,Ws.isStudy)(e.source)){const s=e.hittest.eraseMarker()
;return t.mod()&&void 0!==s&&e.source.processErase?e.source.processErase(i,s):i.removeSource(e.source,!1),!0}}var i;return!1}_tryStartChangingLineTool(e,t,i,s){if(e.isTouch&&null!==this._startTrackPoint)return!1;const o=t.hittest;if((!e.isTouch||!this._preventSourceChange)&&o&&(0,zs.isLineTool)(t.source)&&o.target()===Ut.HitTarget.ChangePoint){const r=this._chartUndoModel(),a=(0,n.ensure)(this.state().mainDataSource()?.firstValue()),l=o.data()?.ownerSourceId,c=(0,n.ensureNotNull)(l?this._chartModel().dataSourceForId(l):t.source.ownerSource()),h=(0,n.ensureNotNull)(c.priceScale()).coordinateToPrice(e.localY,a);r.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(t.source,o.data())}));let d=h;t.source.priceScale()===r.mainSeries().priceScale()&&(d=r.model().magnet().align(h,s,this.state()));const u=o.data()?.nonDiscreteIndex;u&&(s=r.timeScale().coordinateToFloatIndex(e.localX));const _=o.data()?.pointIndex;return this._startChangeLineToolParams={source:t.source,ownerSource:c,startPoint:{index:s,price:d,nonDiscreteIndex:u},screenPoint:{x:e.localX,y:e.localY},pointIndex:_,envState:i},!0}return this._startChangeLineToolParams=null,!1}_tryStartCloning(e,t,i,s){if(i.mod()){const t=this._chartUndoModel().selection().dataSources().filter((e=>e.cloneable()));if(s&&s.cloneable()&&t.push(s),t.length>0)return this._clonningAtMoveLineTools=t.map((e=>e.id())),this._startCloningPoint=new Vt.Point(e.localX,e.localY),!0}return!1}_tryFinishClonning(e,t,i){const s=this._chartUndoModel(),o=this._chartModel();if(t.mod()&&this._clonningAtMoveLineTools){const r=new Vt.Point(e.localX,e.localY),a=(0,n.ensureNotNull)(this._startCloningPoint).subtract(r).length(),l=[];for(const e of this._clonningAtMoveLineTools){const t=o.dataSourceForId(e);null!==t&&l.push(t)}if(0===l.length)return!1;if(a>8){const o=this.cloneLineTools(l,!0).map((e=>(0,n.ensureNotNull)(s.model().dataSourceForId(e))));s.selectionMacro((e=>{e.clearSelection();let t=null;o.forEach((s=>{null===t&&(t=Xn(i,s)),e.addSourceToSelection(s,t)}))}));const r=new Vt.Point(e.localX,e.localY),a=(0,n.ensureNotNull)(o[0].priceScale()),c=(0,n.ensureNotNull)(this.state().mainDataSource()).firstValue(),h={index:s.timeScale().coordinateToIndex(e.localX),price:a.coordinateToPrice(e.localY,(0,n.ensureNotNull)(c))};s.startMovingSources(o,{logical:h,screen:r},null,t),this._clonningAtMoveLineTools=null,this._startCloningPoint=null}return!0}return!1}_mouseDownEventForLineTool(e,t,i,s){const o=mt.tool.value();if(!this.hasState()||(0,Lt.isLineToolDrawWithoutPoints)(o)||this.state().mode()===zi.PaneMode.Widget)return;const r=this._chartUndoModel();let a=!1,l=null;(0,mt.hideAllDrawings)().value()&&(0,Ss.toggleHideMode)(),(0,mt.lockDrawings)().setValue(!1),e.isTouch&&!e.stylus&&((0,Lt.isLineToolName)(o)&&!(0,Lt.isLineDrawnWithPressedButton)(o)||r.lineBeingCreated())&&this._initToolCreationModeParams(e);const c=r.lineBeingCreated();if(c&&!(0,Lt.isLineDrawnWithPressedButton)(c.toolname)){const o=(0,n.ensure)(c.ownerSource()?.firstValue());if(e.isTouch&&!e.stylus){if(!this._startTouchPoint){
this._startTouchPoint=new Vt.Point(e.pageX,e.pageY);const t=c.points(),i=t[t.length-1],s=r.timeScale().indexToCoordinate(i.index),a=(0,n.ensureNotNull)(c.priceScale()).priceToCoordinate(i.price,o);return void(this._initCrossHairPosition=new Vt.Point(s,a))}}else if(!e.isTouch){l=c;const h=r.model().paneBeingCreatedLineOn();if(h!==this._state&&null!==h){const i=this._externalPaneXCoord(h,e.localX),s=this._externalPaneYCoord(h,e.localY);a=r.continueCreatingLine({index:Math.round(r.timeScale().coordinateToIndex(i)),price:(0,n.ensure)(c.priceScale()?.coordinateToPrice(s,o))},t)}else{const e=r.model().magnet().align(s,i,this.state());a=r.continueCreatingLine({index:i,price:e},t)}}}else{const t=(0,Lt.isLineDrawnWithPressedButton)(o);if(!e.isTouch||e.stylus||t){const e=null===c||(0,zs.isBrushBasedLineTool)(c)&&c.hasOnlyOnePoint(),n={index:i,price:t&&!e?s:r.model().magnet().align(s,i,this.state())};l=r.createLineTool({pane:this.state(),point:n,linetool:o,actionSource:"Draw"}),this._mouseTouchDownUpInfo&&(this._mouseTouchDownUpInfo.toolCreation=!0),r.lineBeingCreated()||(a=!0)}}const h=this._dataSourceAtPoint(e.localX,e.localY);l&&r.selectionMacro((e=>{e.addSourceToSelection((0,n.ensureNotNull)(l),h?.hittest.data())})),a&&l&&(this._finishTool(l,h),e.preventDefault())}_handleSelectionMouseDownAndGetJustDeselectedSource(e,t,i){const s=this._chartUndoModel();let o=null;return(null===t||t.source.isSelectionEnabled())&&s.selectionMacro((s=>{!this._preventSourceChange&&null!==t&&(e.isTouch?t.hittest.target()>=Ut.HitTarget.MovePointBackground:t.hittest.target()>Ut.HitTarget.MovePointBackground)?(i.mod()||s.selection().isSelected(t.source)||s.clearSelection(),i.mod()&&s.selection().isSelected(t.source)?(o=t.source,s.removeSourceFromSelection(t.source)):s.addSourceToSelection(t.source,t.hittest.data()),s.selection().allSources().length>1&&(0,re.trackEvent)("GUI","Multiselect","Click Select")):i.mod()||(s.clearSelection(),this._clonningAtMoveLineTools=null,this._startCloningPoint=null)})),o}_processMouseMoveWhileZoom(e,t){this._preventCrossHairMove()||this.setCursorPosition(e.localX,e.localY,t)}_updateCommonTooltip(e,t){let i=null;if(null!==e&&null!==e.hittest){const t=e.hittest.data();t&&(i=t.tooltip||null)}if(null===this._prevTooltipData&&null===i)return;if(null===i||""===i.text)return this._prevTooltipData=null,void(0,En.hide)(t);if(this._prevTooltipData&&(0,Ot.default)(i,this._prevTooltipData))return;this._prevTooltipData=i;const s=(0,tt.clone)(i);if(void 0!==s.rect){const e=this._paneCell.getBoundingClientRect();s.rect.x+=e.left,s.rect.y+=e.top}(0,En.show)(s)}_setCursorPositionOnExternalPane(e,t,i,s){t=this._externalPaneXCoord(e,t),i=this._externalPaneYCoord(e,i);this._chart.paneByState(e).setCursorPosition(t,i,s)}_updateLastCrosshairPosition(e,t,i){const s=this.state().id();sr={x:e,y:t,envState:i,stateId:s}}_setCursorClassName(e){let t="";e&&(t="pane--cursor-"+e),this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._paneCell.classList.remove(this._currentCursorClassName),t&&this._paneCell.classList.add(t),
this._currentCursorClassName=t,this._paneCell.style.cursor)}_processMouseUpOrTouchEndHandler(e){const t=this._dataSourceAtPoint(e.localX,e.localY);if(null!==t){const i=this._sourceWasSelected(t);t.hittest.tryCallMouseUpOrTouchEndHandler(e,{sourceWasSelected:i})}}_crossHairShouldBeVisible(){const e=this._chartModel().crosshairSource();return(0,Lt.isLineToolName)(mt.tool.value())||(0,mt.toolIsMeasure)(mt.tool.value())||e.startMeasurePoint()&&!e.endMeasurePoint()||null!==this._firstZoomPoint||null!==this._chartModel().lineBeingEdited()||null!==this._chartModel().lineBeingCreated()}_clearCursorPosition(){sr=null,this._chartModel().clearCurrentPosition()}_dataSourceAtPoint(e,t){if(!this.hasState())return null;const i={result:null},s=this._chartUndoModel();if((0,Lt.isLineToolName)(mt.tool.value())||null!==s.lineBeingCreated())return i.result;if(this._currentChangingLineToolHitTest)return this._currentChangingLineToolHitTest;const o=new Set;if(this._currentMovingHitTest&&this._currentMovingHitTest.sourceAtPoint.hittest.data()){if(!this._currentMovingHitTest.cancelledContainer?.cancelled)return this._currentMovingHitTest.sourceAtPoint;o.add(this._currentMovingHitTest.sourceAtPoint.source.id())}if(this._currentMovingHitTest&&this._currentMovingHitTest.sourceAtPoint.hittest.data()&&!this._currentMovingHitTest.cancelledContainer?.cancelled)return this._currentMovingHitTest.sourceAtPoint;const n=this.state(),r=(0,Kt.getBindingRenderingInfo)(this._canvasBinding);this._makeSureIsUpdated(r);const a=Jn.bind(null,i),l=new Vt.Point(e,t);if(!n.maximized().value()&&n.collapsed().value()||(0,lo.lastMouseOrTouchEventInfo)().isTouch&&(mt.activePointSelectionMode.value()!==mt.SelectPointMode.None||null!==this._startTrackPoint))return this._hitTestSources(r,[s.crosshairSource()],l,a,!1,o),i.result;const c=n.sourcesByGroup(),h=s.selection(),d=h.dataSources().filter((e=>e.isMultiPaneEnabled()||s.paneForSource(e)===n));this._hitTestSources(r,d,l,a,!1,o),this._hitTestSources(r,h.customSources(),l,a,!0,o),h.allSources().forEach((e=>o.add(e.id()))),this._hitTestSources(r,[s.crosshairSource()],l,a,!1,o),this._hitTestSources(r,n.customSources(Co.CustomSourceLayer.Topmost),l,a,!0,o),this._hitTestSources(r,c.tradingSources(),l,a,!1,o),this._hitTestSources(r,n.customSources(Co.CustomSourceLayer.Foreground),l,a,!0,o);const u=c.hitTestSources();if(this._hitTestSources(r,u,l,a,!1,o),this.containsMainSeries()){const e=s.activeStrategySource().value();if(null!==e&&!o.has(e.id())){const t=e.strategyOrdersPaneView();if(null!==t){const s=t.renderer(r);if(null!==s){const t=s.hitTest(l,r);t&&Jn(i,t,e,s,!1)}}}}return null===i.result&&this._hitTestSources(r,n.customSources(Co.CustomSourceLayer.Background),l,a,!0,o),i.result}_sourceWasSelected(e){return!!e&&this._selectionBeforeMouseDown.has(e.source)}_hitTestSources(e,t,i,s,o,r){const a=(0,n.ensureNotNull)(this._state);for(let n=t.length-1;n>=0;--n){const l=t[n];if(r.has(l.id()))continue;const c=l.paneViews(a);if(null!==c&&0!==c.length)for(let t=c.length-1;t>=0;--t){const n=c[t].renderer(e);if(n&&n.hitTest){
const t=n.hitTest(i,e);null!==t&&s(t,l,n,o)}}}}_tryStartMovingLineTool(e,t,i,s){if(null===t.source||!t.source.movable()||null!==this._startTrackPoint)return!1;if(!this._preventSourceChange){const o=this._chartUndoModel(),r=(0,n.ensureNotNull)((0,n.ensureNotNull)(this._state).mainDataSource()).firstValue(),a=(0,n.ensureNotNull)(t.source.priceScale()),l=null===r?NaN:a.coordinateToPrice(e.localY,r);let c=(t.source.isSelectionEnabled()?o.selection().allSources():[t.source]).filter(Bn);const h=c.filter((e=>(0,zs.isLineTool)(e)&&!e.isSourceHidden()));c=h.length>0?h:c.includes(t.source)?[t.source]:[c[0]];const d=new Vt.Point(e.localX,e.localY),u={index:s,price:l},_=t.hittest.data()?.activeItem;return this._startMoveSourceParams={source:c,startPoint:{logical:u,screen:d},activeItem:void 0===_?null:_,envState:i},!0}return this._startMoveSourceParams=null,!1}_chartModel(){return this._chart.model().model()}_chartUndoModel(){return this._chart.model()}_externalPaneXCoord(e,t){t+=this._div.getBoundingClientRect().left+document.body.scrollLeft;const i=(0,n.ensureNotNull)(this._chart.paneByState(e)),s=i._div.getBoundingClientRect().left+document.body.scrollLeft;return i._correctXCoord(t-s)}_externalPaneYCoord(e,t){t+=this._div.getBoundingClientRect().top+document.body.scrollTop;const i=(0,n.ensureNotNull)(this._chart.paneByState(e)),s=i._div.getBoundingClientRect().top+document.body.scrollTop;return i._correctYCoord(t-s)}_correctXCoord(e){return Math.max(0,Math.min(e,this._size.width-1))}_correctYCoord(e){return Math.max(0,Math.min(e,this._size.height-1))}_processScroll(e){if(!this._chart.model().model().scrollEnabled())return;const t=performance.now();this._startScrollingPos||this._preventScroll()||(this._startScrollingPos={x:e.clientX,y:e.clientY,timestamp:t,localX:e.localX,localY:e.localY});const i=this._chartUndoModel();let s=this.state().defaultPriceScale();if(this._startScrollingPos&&!this._isScrolling&&(this._startScrollingPos.x!==e.clientX||this._startScrollingPos.y!==e.clientY))return i.beginUndoMacro(Un),null===this._scrollXAnimation&&this._options.useKineticScroll&&(this._scrollXAnimation=new bn(.2,7,.997,15),this._scrollXAnimation.addPosition(e.clientX,this._startScrollingPos.timestamp)),i.selection().isEmpty()||(s=i.selection().allSources()[0].priceScale()),null===s||s.isEmpty()||(this._scrollPriceScale=s,i.startScrollPrice(this.state(),s,e.localY)),i.startScrollTime(e.localX),this._isScrolling=!0,this.setCursorForTool(),void this._paneWidgetsSharedState.setScrollingPane(this);this._isScrolling&&(null!==this._scrollPriceScale&&i.scrollPriceTo(this.state(),this._scrollPriceScale,e.localY),i.scrollTimeTo(e.localX),null!==this._scrollXAnimation&&this._scrollXAnimation.addPosition(e.clientX,t))}_finishScroll(){const e=this._chartUndoModel();e.endScrollTime(),null!==this._scrollPriceScale&&e.endScrollPrice(this.state(),this._scrollPriceScale),e.endUndoMacro(),this._isScrolling=!1,this._startScrollingPos=null,this._scrollPriceScale=null,this.setCursorForTool(),this._paneWidgetsSharedState.setScrollingPane(null)}
_endScroll(e){if(!this._isScrolling)return!1;this._finishScroll();const t=this._scrollUndoCommandInStack(),i=performance.now();return null!==this._scrollXAnimation&&(this._scrollXAnimation.start(e.clientX,i),this._scrollXAnimation.finished(i)||(this._chartModel().stopTimeScaleAnimation(),this._chartModel().setTimeScaleAnimation(this._scrollXAnimation),this._scrollXAnimation=null)),t}_preventScroll(){return this._trackCrosshairOnlyAfterLongTap&&this._longTap||this._contextMenuOpenedOnLastTap||(0,Lt.isLineToolName)(mt.tool.value())||Boolean(this._chartUndoModel().lineBeingCreated())||null!==this._startTrackPoint||this._preventScrollUntilNextMouseDownOrTouchStart}_isSelectPointModeEnabled(){return this._chartUndoModel().crosshairSource().selectPointMode().value()!==mt.SelectPointMode.None}_preventCrossHairMove(){return!!this._trackCrosshairOnlyAfterLongTap&&(null===this._chart.trackingModePaneWidget()&&(!!this._contextMenuOpenedOnLastTap||!this._crossHairShouldBeVisible()&&null===this._startTrackPoint))}_finishTool(e,t=null){const i=this._chartUndoModel(),s=e.toolname;if(s===mt.tool.value()&&(0,mt.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition(),i.selectionMacro((i=>{i.addSourceToSelection(e,Xn(t,e))})),(0,zs.isEditableTextLineTool)(e)&&e.activateEditingOnCreation())e.activateTextEditingOn(this._div,!0);else if((0,Lt.isTextToolName)(s)){const t=i.createUndoCheckpoint();this._chart.showChartPropertiesForSource(e,Ns.TabNames.text,void 0,t)}this._lastFinishedToolId=e.id(),(0,ee.emit)("drawing_event",e.id(),"create"),kn()}_alignSourcesThatBeingMoved(e,t,i,s,o){const n=this._chartUndoModel(),r=2===o?NaN:n.timeScale().coordinateToIndex(t);n.model().sourcesBeingMoved().forEach((e=>{let a=r,l=e.convertYCoordinateToPriceForMoving(i,this.state().mainDataSource());if(null===l){if(1!==o)return;l=NaN}if((0,Ws.isStudy)(e)){const e=n.mainSeries(),t=e.bars().firstIndex(),i=e.bars().lastIndex();null!==t&&null!==i&&2!==o&&(a=Math.min(Math.max(r,t),i)),1!==o&&(l=this._chartModel().magnet().align(l,r,this.state()))}null!==this._currentMovingHitTest&&void 0!==this._currentMovingHitTest.sourceAtPoint.hittest.data()?.cursorType||this.setCursorForTool(),n.moveSources({screen:new Vt.Point(t,i),logical:{index:a,price:l}},s)}))}_resetMeasureIfRequired(){this._needResetMeasureLater&&((0,mt.resetToCursor)(),this._needResetMeasureLater=!1)}_makeSureIsUpdated(e){const t=this.state(),i=[...t.dataSources(),...t.customSources()];for(const s of i){const i=s.paneViews(t);if(null!==i)for(const t of i)t.makeSureIsUpdated?.(e)}}_drawBackground(e,t){const i=this._chartModel(),s=i.backgroundTopColor().value(),o=i.backgroundColor().value();if(this._state?.mode()===zi.PaneMode.Widget){const i=this._state?.model().panes().indexOf(this._state)??0,n=this._state?.model().mainPane(),r=i>(n?this._state?.model().panes().indexOf(n)??0:0)?o:s;(0,Kt.clearRect)(e,0,0,t.bitmapSize.width,t.bitmapSize.height,r)}else s===o?(0,Kt.clearRect)(e,0,0,t.bitmapSize.width,t.bitmapSize.height,o):(0,
$t.clearRectWithGradient)(e,0,0,t.bitmapSize.width,t.bitmapSize.height,s,o)}_drawWatermark(e,t){const i=this._chartModel().watermarkSource();if(null===i)return;if(!this.state().containsMainSeries())return;const s=i.paneViews();for(const i of s){e.save();const s=i.renderer(t);s&&s.draw(e,t),e.restore()}}_drawCrossHair(e,t){const i=this._chartUndoModel().crosshairSource();i.invalidateLockPosition(),i.visible||null===mt.crosshairLock.value()||i.updateAllViews((0,wi.sourceChangeEvent)(i.id())),this._drawSourceImpl(e,t,$n,qn,i)}_drawActiveLineTools(e,t){const i=this._chartModel(),s=[i.lineBeingCreated(),i.lineBeingEdited(),...i.sourcesBeingMoved(),i.customSourceBeingMoved()].filter((e=>!!e));for(const o of s){(i.paneForSource(o)===this.state()||(0,Po.isDataSource)(o)&&o.isMultiPaneEnabled())&&this._drawSourceImpl(e,t,$n,qn,o)}}_drawTopViews(e,t){for(const i of this.state().sourcesByGroup().all())i.topPaneViews&&this._drawSourceImpl(e,t,Kn,qn,i)}_drawSources(e,t){const i=this.state(),s=i.model(),o=i.sourcesByGroup(),n=o.tradingSources(),r=o.generalSources(),a=o.phantomSources(),l=i.customSources(Co.CustomSourceLayer.Background).slice(),c=i.customSources(Co.CustomSourceLayer.Foreground).slice(),h=i.customSources(Co.CustomSourceLayer.Topmost).slice(),d=s.activeStrategySource().value(),u=s.replayStudyStrategy().value();{const e=s.panes();for(let t=e.length-1;t>=0;t--)e[t].createDrawingsCaches()}this._drawSourceImpl(e,t,$n,qn,s.gridSource()),this._drawWatermark(e,t);for(const i of l)this._drawSourceImpl(e,t,$n,Gn,i);for(const i of r)this._drawSourceImpl(e,t,$n,Gn,i);for(const i of c)this._drawSourceImpl(e,t,$n,Gn,i);for(const i of a)this._drawSourceImpl(e,t,$n,Gn,i);const _=new Set;[s.lineBeingCreated(),s.lineBeingEdited(),...s.sourcesBeingMoved(),s.customSourceBeingMoved()].filter(tt.notNull).forEach((e=>_.add(e.id())));let p=s.hoveredSource();null!==p&&((0,Po.isDataSource)(p)&&!p.showOnTopOnHovering()||_.has(p.id())||(0,Po.isDataSource)(p)&&!r.includes(p)?p=null:_.add(p.id()));const m=s.selection().allSources().filter((e=>!((0,Po.isDataSource)(e)&&!r.includes(e))&&!_.has(e.id())));m.forEach((e=>_.add(e.id())));for(const i of l)this._drawSourceImpl(e,t,$n,qn,i,_);for(const i of r)this._drawSourceImpl(e,t,$n,qn,i,_);for(const i of c)this._drawSourceImpl(e,t,$n,qn,i,_);d&&this.containsMainSeries()&&this._drawSourceImpl(e,t,Zn,qn,d,_),u&&this._drawSourceImpl(e,t,Zn,qn,u,_);for(const i of n)this._drawSourceImpl(e,t,$n,Gn,i);for(const i of h)this._drawSourceImpl(e,t,$n,Gn,i);for(const i of r)this._drawSourceImpl(e,t,Yn,qn,i,_);for(const i of c)this._drawSourceImpl(e,t,Yn,qn,i,_);for(const i of n)this._drawSourceImpl(e,t,$n,qn,i,_);for(const i of h)this._drawSourceImpl(e,t,$n,qn,i,_);for(const i of m)this._drawSourceImpl(e,t,$n,qn,i),i===d&&this.containsMainSeries()&&this._drawSourceImpl(e,t,Zn,qn,d);for(const i of m)this._drawSourceImpl(e,t,Yn,qn,i);p&&(this._drawSourceImpl(e,t,$n,qn,p),p===d&&this.containsMainSeries()&&this._drawSourceImpl(e,t,Zn,qn,d),this._drawSourceImpl(e,t,Yn,qn,p))
;for(const i of a)this._drawSourceImpl(e,t,$n,qn,i,_);{const e=s.panes();for(let t=e.length-1;t>=0;t--)e[t].clearDrawingCaches()}}_drawSourceImpl(e,t,i,s,o,n){if(n&&n.has(o.id()))return;const r=i(o,this.state());if(r)for(const i of r){const o=i.renderer(t);o&&(e.save(),s(o,e,t),e.restore())}}_updateByThemedColors(){null!==this._legendWidget&&this._legendWidget.updateThemedColors(this._themedTopColor),null!==this._paneControls&&this._paneControls.updateThemedColors(this._themedTopColor)}_scrollUndoCommandInStack(){const e=this._chartUndoModel().undoHistory().undoStack();if(e.isEmpty())return!1;const t=e.head();if(!(t instanceof rt))return!1;if(t.isEmpty())return!1;return t.commands()[0]instanceof xn}_onStateDestroyed(){this.setState(null)}_onDataSourcesCollectionChanged(){this._startMoveSourceParams=null}_processMouseEnterLeaveMoveHandlers(e,t){if(null!==this._prevHoveredHittest&&(this._prevHoveredHittest.renderer!==e?.renderer||this._prevHoveredHittest.hittest.data()?.activeItem!==e.hittest.data()?.activeItem)){const e=this._sourceWasSelected(this._prevHoveredHittest);(0,Ut.tryCallHandler)(t,{sourceWasSelected:e},this._prevHoveredHittest.hittest.data()?.mouseLeaveHandler),this._prevHoveredHittest=null}if(!t.isTouch&&null!==e){const i=this._sourceWasSelected(e);this._prevHoveredHittest?.renderer!==e.renderer&&(e.hittest.tryCallMouseEnterHandler(t,{sourceWasSelected:i}),this._prevHoveredHittest=e),e.hittest.tryCallMouseMoveHandler(t,{sourceWasSelected:i})}}_startChangeOrMoveLineToolIfNeeded(){if(null!==this._startChangeLineToolParams){const e=this._startChangeLineToolParams;(0,re.trackEvent)("chart_alert","edit","start_change_line_tool_params"),this._chartUndoModel().startChangingLinetool(e.source,e.ownerSource,e.startPoint,e.pointIndex,e.envState)}if(null!==this._startMoveSourceParams){const e=this._startMoveSourceParams;(0,re.trackEvent)("chart_alert","edit","start_moving_sources"),this._chartUndoModel().startMovingSources(e.source,e.startPoint,e.activeItem,e.envState)}this._startMoveSourceParams=null,this._startChangeLineToolParams=null}_trackingModeShouldBeActive(){return!(!this._trackCrosshairOnlyAfterLongTap||this._contextMenuOpenedOnLastTap||this._crossHairShouldBeVisible())&&this._longTap}_processOutsideClick(e,t){let i=null;const s=this._chartModel();if(null!==e&&(i=e.isCustom?s.customSourceName(e.source):e.source.id()),null!==this._lastClickedSource&&this._lastClickedSource.id!==i){const e=this._lastClickedSource.id;let i=this._lastClickedSource.isCustom?s.customSourceForName(e):s.dataSourceForId(e);null!==i||this._lastClickedSource.isCustom||(i=s.dataSourceForId(e)),null!==i&&i.onClickOutside&&(i.onClickOutside((0,Kt.getBindingRenderingInfo)(this._canvasBinding),t),this._chartModel().updateSource(i))}this._lastClickedSource=null!==i?{id:i,isCustom:e?.isCustom??!1}:null}async showConfetti(e,t){0}_mouseClickOrTapEvent(e){if(!this.hasState())return;let t=null,i=null
;this._mouseTouchDownUpInfo&&this._mouseTouchDownUpInfo.toolCreation&&!this._mouseTouchDownUpInfo.mouseMove||(t=this._dataSourceAtPoint(e.localX,e.localY),i=t&&t.source);const s=this._chartUndoModel(),o=Boolean(t?.hittest.data()?.hideCrosshairLinesOnHover);this._processOutsideClick(t,e),s.model().setActivationChartFloatingTooltipHint(i),!this._isSelectPointModeEnabled()||o||e.isTouch&&this.trackingModeEnabled()&&!this._exitTrackingModeOnNextTry||s.crosshairSource().trySelectCurrentPoint();const r=this._sourceWasSelected(t);!(0,Lt.isLineToolName)(mt.tool.value())&&null!==t&&t.hittest.tryCallClickOrTapHandler(e,{sourceWasSelected:r})&&s.model().updateSource((0,n.ensureNotNull)(i)),!e.isTouch||this._isSelectPointModeEnabled()||t&&t.source===s.crosshairSource()||this._tryExitTrackingMode(),i&&(0,zs.isLineTool)(i)&&this._lastFinishedToolId!==i.id()&&(0,ee.emit)("drawing_event",i.id(),"click"),this._resetMeasureIfRequired(),this._mouseTouchDownUpInfo=null}_mouseDownOrTouchStartEvent(e,t){this._pressedMoveStage=1,this._preventScrollUntilNextMouseDownOrTouchStart=!1,this._selectionBeforeMouseDown=new Set(this._chartModel().selection().allSources()),e.isTouch&&(this._longTap=!1,this._exitTrackingModeOnNextTry=null!==this._startTrackPoint,this._paneWidgetsSharedState.clearDraggingSource()),this._contextMenuOpenedOnLastTap=!1,this._lastFinishedToolId=null;const i=this._chartModel();if(i.stopTimeScaleAnimation(),this._mouseTouchDownUpInfo={mouseMove:!1,toolCreation:Boolean(i.lineBeingCreated())},e.isTouch&&this._switchTrackingModeFromAnotherPaneIfNeeded(e),document.activeElement!==document.body&&document.activeElement!==document.documentElement)document.activeElement&&document.activeElement.blur?document.activeElement.blur():document.body.focus();else{const e=document.getSelection();null!==e&&e.removeAllRanges()}(0,ee.emit)("mouse_down",{clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,screenX:e.screenX,screenY:e.screenY}),this._updateCommonTooltip(null);const s=this._chartUndoModel(),o=new To.EnvironmentState(e);s.mainSeries().clearGotoDateResult();const r=this.state().defaultPriceScale();if(s.timeScale().isEmpty())return;const a=s.crosshairSource();if(!e.isTouch&&!(0,Lt.isLineDrawnWithPressedButton)(mt.tool.value())){const t=null!==s.lineBeingCreated()?s.model().paneBeingCreatedLineOn():null;null!==t&&t!==this._state?this._setCursorPositionOnExternalPane(t,e.localX,e.localY,o):this.setCursorPosition(e.localX,e.localY,o)}e.isTouch&&(0,Lt.isLineToolName)(mt.tool.value())&&((0,Lt.isLineDrawnWithPressedButton)(mt.tool.value())||null!==a.pane?(0,Lt.isLineDrawnWithPressedButton)(mt.tool.value())&&this._clearCursorPosition():this._chart.updateCrossHairPositionIfNeeded());const l=(0,n.ensureNotNull)(this.state().mainDataSource()).firstValue();let c=null==l?null:r.coordinateToPrice(e.localY,l),h=i.timeScale().coordinateToIndex(e.localX);if(a.startMeasurePoint()&&a.endMeasurePoint()&&a.clearMeasure(),o.shift()&&(0,mt.toolIsCursor)(mt.tool.value())){const e=s.selection().isEmpty()
;(null===t||e&&!t.hittest.data()?.hasOwnShortcutsBehaviourFor?.shiftKey)&&(mt.tool.setValue("measure"),(0,wn.trackDrawingToolSelected)("measure","Keyboard shortcut"),e||s.selectionMacro((e=>e.clearSelection())))}if((e.isTouch&&!e.stylus||null===c||!this._tryStartMeasure(e,a,o,c,h))&&(e.isTouch&&!e.stylus||!this._tryFinishMeasure(e,a))&&!(this._tryFinishZoom(e)||null!==c&&this._tryStartZoom(e,c,h,o))){if(e.isTouch&&(null!==this._startTrackPoint?(this._initCrossHairPosition=a.currentPoint(),this._startTrackPoint=new Vt.Point(e.localX,e.localY)):this._isSelectPointModeEnabled()&&null===this._chart.trackingModePaneWidget()&&this.startTrackingMode(new Vt.Point(e.localX,e.localY),new Vt.Point(e.localX,e.localY),new To.EnvironmentState(e))),e.isTouch&&(this._preventSourceChange=null===t||!s.selection().isSelected(t.source)),!this._isSelectPointModeEnabled()&&!this._isScrolling){if(e.isTouch&&!e.stylus&&((0,mt.toolIsMeasure)(mt.tool.value())||null!==a.measurePane().value()))return void this._initToolCreationModeParams(e);if(null!==c&&((0,Lt.isLineToolName)(mt.tool.value())||s.lineBeingCreated()))return o.shift()||s.selectionMacro((e=>e.clearSelection())),void this._mouseDownEventForLineTool(e,o,h,c)}if((0,mt.toolIsDemonstration)(mt.tool.value())&&o.altOnly()){e.isTouch&&!this.trackingModeEnabled()&&this.startTrackingMode(new Vt.Point(e.localX,e.localY),new Vt.Point(e.localX,e.localY),new To.EnvironmentState(e));const t=this._chartModel().crosshairSource().crosshairDemonstration();t.createHighlighter();const i=this._localCoordinatesToLineDataSourcePoint(a.originX(),a.originY(),(0,n.ensureNotNull)(this.state().mainDataSource()));i&&t.addHighlighterPosition(i)}else{if(null!==t){const i=this._sourceWasSelected(t);t.hittest.tryCallMouseDownOrTouchStartHandler(e,{sourceWasSelected:i})}if(!this._chart.readOnly()){const r=this._handleSelectionMouseDownAndGetJustDeselectedSource(e,t,o);if(null!==t&&!this._preventSourceChange){const i=t.hittest.data();if(t.isCustom){if(t.hittest.hasPressedMoveHandler(e))return s.model().setMovingCustomSource(t.source,i),this._preventScrollUntilNextMouseDownOrTouchStart=!0,this._currentMovingHitTest={sourceAtPoint:t,cancelledContainer:s.model().customSourceMovingHitTestData()??void 0},void s.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection((0,n.ensureNotNull)(t.source),(0,n.ensureNotNull)(i))}))}else if(i?.areaName===Ut.AreaName.SourceItemMove){const o=i?.activeItem;if(void 0!==o)return s.startCustomMoving(t.source,o,e),this._currentMovingHitTest={sourceAtPoint:t},void s.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection((0,n.ensureNotNull)(t.source),(0,n.ensureNotNull)(i))}))}}if(null!==t&&this._tryHandleEraserMouseDown(t,o))return;const a=null!==t&&(0,zs.isLineTool)(t.source)&&t.source.isLocked&&t.source.isLocked();if(!((0,mt.lockDrawings)().value()||a)&&null!==t&&!t.isCustom){if(!t.source.userEditEnabled())return;const s=t.hittest.data()?.snappingPrice,a=t.hittest.data()?.snappingIndex;let u=e.localY,_=e.localX
;const p=t.hittest.data()?.ownerSourceId,m=p?i.dataSourceForId(p):t.source.ownerSource();if(void 0!==s&&null!==l&&(u=(0,n.ensure)(m?.priceScale()).priceToCoordinate(s,l),c=s),void 0!==a&&(_=i.timeScale().indexToCoordinate(a),h=a),u===e.localY&&_===e.localX||(e={...e,localY:u,localX:_},this.setCursorPosition(e.localX,e.localY,o)),this._tryStartChangingLineTool(e,t,o,h))return void(this._currentChangingLineToolHitTest=t);if(this._currentChangingLineToolHitTest=null,(d=t.hittest.target())===Ut.HitTarget.MovePoint||d===Ut.HitTarget.MovePointBackground&&(0,lo.lastMouseOrTouchEventInfo)().isTouch){if(this._tryStartCloning(e,t,o,r))return;if(this._tryStartMovingLineTool(e,t,o,h))return void(this._currentMovingHitTest={sourceAtPoint:t});this._currentMovingHitTest=null}}if(null!==t&&(0,An.isPriceDataSource)(t.source)&&t.source.isDraggable()&&this._state?.hasDataSource(t.source)&&this._paneWidgetsSharedState.trySetDraggingSource(t.source,this))return}var d;null!==t&&t.hittest.target()===Ut.HitTarget.Regular||(this._processing=!0)}}}_mouseUpOrTouchEndEvent(e){if(!this.hasState())return;this._pressedMoveStage=0;const t=e.isTouch&&null!==this._startTrackPoint,i=e.isTouch&&this._wasPinched;e.isTouch&&(this._wasPinched=!1,this._longTap=!1),this._startMoveSourceParams=null,this._startChangeLineToolParams=null,this._currentChangingLineToolHitTest=null,this._currentMovingHitTest=null;const s=this._chartUndoModel(),o=s.model().customSourceMovingHitTestData();null!==o||s.customMoveBeingProcessed()||this._processMouseUpOrTouchEndHandler(e),this._isSelecting=!1;const r=s.model(),a=r.crosshairSource(),l=this._dataSourceAtPoint(e.localX,e.localY);if(a.selection()&&null===this._firstZoomPoint){const e=this.state().lineToolsForArea(a.selection(),(0,Kt.getBindingRenderingInfo)(this._canvasBinding));s.selectionMacro((t=>{let i=null;e.forEach((e=>{null===i&&(i=Xn(l,e)),t.addSourceToSelection(e,i)}))})),a.clearSelection(),(0,re.trackEvent)("GUI","Multiselect","Area Select")}(0,ee.emit)("mouse_up",{clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY,screenX:e.screenX,screenY:e.screenY});const c=e.isTouch&&this._touchMove;e.isTouch&&(this._touchMove=!1);const h=new To.EnvironmentState(e),d=mt.tool.value();if(e.isTouch&&((0,mt.toolIsMeasure)(d)||null!==a.measurePane().value())){if(!c&&!e.stylus&&null===a.measurePane().value()&&a.pane!==this._state)return void this.setCursorPosition(e.localX,e.localY);if(!c&&!e.stylus&&this._tryStartMeasure(e,a,h,a.price,a.index))return;if((!c||e.stylus)&&this._tryFinishMeasure(e,a))return}if(e.isTouch&&!c&&!(0,Lt.isLineDrawnWithPressedButton)(d)&&(0,Lt.isLineToolName)(d)&&!s.lineBeingCreated()){if(this._chart.justActivated())return;if(a.pane!==this._state)return void this.setCursorPosition(e.localX,e.localY,h);const t=a.currentPoint(),i=this.state().defaultPriceScale(),o=(0,n.ensure)(this.state().mainDataSource()?.firstValue()),r={index:Math.round(s.timeScale().coordinateToIndex(t.x)),price:i.coordinateToPrice(t.y,o)},c=(0,n.ensureNotNull)(s.createLineTool({pane:this.state(),point:r,linetool:d,
actionSource:"Draw"}));return this._mouseTouchDownUpInfo&&(this._mouseTouchDownUpInfo.toolCreation=!0),s.selectionMacro((e=>{e.addSourceToSelection(c)})),s.lineBeingCreated()||(this._finishTool(c,l),e.preventDefault()),void(this._startTouchPoint=null)}const u=s.lineBeingCreated();if(u&&!(0,Lt.isLineDrawnWithPressedButton)(u.toolname)&&e.isTouch&&(this._startTouchPoint||e.stylus)){if(this._startTouchPoint=null,!c||e.stylus){const t=(0,n.ensureNotNull)(u.lastPoint()),i=s.continueCreatingLine({index:t.index,price:t.price},new To.EnvironmentState(e));this._initCrossHairPosition=null,i&&(this._finishTool(u,l),e.preventDefault())}return}if(null!==this._firstZoomPoint&&this._firstZoomPoint.draggingMode)return void this._finishZoom(e);if(this._processing=!1,s.customMoveBeingProcessed())return void s.endCustomMoving();if(null!==o){if(o.beingMoved&&!o.cancelled){const t=this._sourceWasSelected(l);(0,Ut.tryCallHandler)(e,{sourceWasSelected:t},o.mouseUpHandler,o.touchEndHandler),this.setCursorForTool()}if(r.setMovingCustomSource(null,null),or(e,o))return}if(r.lineBeingEdited())return s.endChangingLinetool(!1),void(this._preventCrossHairMove()&&this._clearCursorPosition());if((0,Lt.isLineDrawnWithPressedButton)(d)&&!this._isSelectPointModeEnabled()){const t=s.lineBeingCreated();null!==t&&(kn(),t.finish(),"LineToolBrush"===t.toolname&&(0,ee.emit)("drawing_event",t.id(),"create"));const i=this.state().defaultPriceScale();if(i.isEmpty())return;if(!t)return;const o=(0,n.ensure)(t.ownerSource()?.firstValue()),r=i.coordinateToPrice(e.localY,o),a={index:Math.round(s.timeScale().coordinateToIndex(e.localX)),price:r};return void s.continueCreatingLine(a)}const _=r.crosshairSource().crosshairDemonstration();if(_.isThereUnfinishedHighlighter())return void _.finishHighlighter();if(r.sourcesBeingMoved().length)return s.endMovingSource(!1,!1),r.sourcesBeingMoved().filter(zs.isLineTool).forEach((e=>{this.setCursorForTool(e)})),void r.invalidate(ao.InvalidationMask.cursor());if(!this._chart.readOnly()){const t=e.localX>=0&&e.localX<this._size.width;if((!l||l.source!==a)&&t){const t=this._chartModel().mainSeries().syncModel();if(t){const i=this._chartModel().timeScale().points().roughTime(s.timeScale().coordinateToIndex(e.localX),((e,i)=>t.projectTime(e,i)));null!==i&&this._chart.chartWidgetCollection().syncScroll(1e3*i,this._chartModel())}}}const p=this._isScrolling,m=this._endScroll(e),g=this._paneWidgetsSharedState.draggingSource();if(null!==g){const t=e.target,i=this._chart.paneByCanvas(t);i&&i!==this&&i.state().mode()===zi.PaneMode.Regular&&(m&&s.undoHistory().undo(),s.mergeToPane(g,i.state()));if(this._chart.timeAxisByCanvas(t))if(r.isUnmergeAvailableForSource(g))m&&s.undoHistory().undo(),s.unmergeToNewBottomPane(g);else{const e=r.panes(),t=(0,n.ensureNotNull)(r.paneForSource(g)),i=e.indexOf(t);i!==e.length-1&&(m&&s.undoHistory().undo(),t.maximized().value()&&s.toggleMaximizedPane(t),s.movePane(i,e.length-1))}this._paneWidgetsSharedState.clearDraggingSource();const o=this._chart.getTimeScale();o&&o.restoreDefaultCursor()
;const a=this._chart.paneWidgets();for(let e=0;e<a.length;e++){const t=a[e];t===this&&l&&!l.isCustom?t.setCursorForTool(l.source||void 0):t.setCursorForTool(),t.leftPriceAxisesContainer().restoreDefaultCursor(),t.rightPriceAxisesContainer().restoreDefaultCursor()}}this._chart.readOnly()||t||h.mod()||p||i||null!==this._lastFinishedToolId||null!==l&&(l.hittest.target()>Ut.HitTarget.MovePointBackground||(0,lo.lastMouseOrTouchEventInfo)().isTouch)&&s.selectionMacro((e=>{e.clearSelection();const t=(0,n.ensureNotNull)(l.source);e.addSourceToSelection(t,Xn(l,t))})),e.isTouch&&(this._touchMove=!1)}_mouseOrTouchMoveEvent(e){if(!this.hasState())return;this._mouseTouchDownUpInfo&&(this._mouseTouchDownUpInfo.mouseMove=!0),this._resetMeasureIfRequired();const t=this._dataSourceAtPoint(e.localX,e.localY);this._processMouseEnterLeaveMoveHandlers(t,e);const i=this._chartUndoModel();if(!i)return;const s=e.localX,o=e.localY;this._prevMoveEventPosition=new Vt.Point(s,o);const n=new To.EnvironmentState(e);if(null===this._firstZoomPoint){if(this._updateHoveredSource(t,n,e),!e.isTouch&&i.lineBeingCreated()){const e=i.model().paneBeingCreatedLineOn();if(null!==e&&e!==this._state)return void this._setCursorPositionOnExternalPane(e,s,o,n)}e.isTouch||this.setCursorPosition(s,o,n)}else this._processMouseMoveWhileZoom(e,n)}_pressedMouseOrTouchMoveEvent(e){if(this._chartModel().dragExportEnabled().value()&&void 0!==e.buttons&&!Boolean(1&e.buttons))return;if(!this.hasState()||this._pinching||e.isTouch&&this._contextMenuOpenedOnLastTap)return;this._pressedMoveStage=2,this._mouseTouchDownUpInfo&&(this._mouseTouchDownUpInfo.mouseMove=!0),this._resetMeasureIfRequired(),this._startChangeOrMoveLineToolIfNeeded(),e.isTouch&&(this._touchMove=!0,this._preventSourceChange=!1);const t=new To.EnvironmentState(e),i=this._chartUndoModel(),s=i.crosshairSource(),o=e.localX,r=e.localY;if(this._prevMoveEventPosition=new Vt.Point(o,r),null!==this._firstZoomPoint)return this._processMouseMoveWhileZoom(e),void(this._firstZoomPoint.draggingMode=!0);const a=mt.tool.value();if(e.isTouch&&this._startTouchPoint&&(0,Lt.isLineToolName)(a)&&!(0,Lt.isLineDrawnWithPressedButton)(a)&&!i.lineBeingCreated()&&!this._isSelectPointModeEnabled())return void this._updateCrosshairPositionInToolCreationMode(e,this.state());const l=s.measurePane().value();if(e.isTouch&&(this._startTouchPoint||e.stylus)&&((0,mt.toolIsMeasure)(a)||null!==l))return void(e.stylus?this.setCursorPosition(e.localX,e.localY,new To.EnvironmentState(e)):this._updateCrosshairPositionInToolCreationMode(e,l||this.state()));const c=i.lineBeingCreated();if(e.isTouch&&!e.stylus&&c&&!(0,Lt.isLineDrawnWithPressedButton)(c.toolname)){if(this._startTouchPoint){const t=(0,n.ensureNotNull)(i.lineBeingCreated()),s=(0,n.ensureNotNull)(i.model().paneForSource(t));this._updateCrosshairPositionInToolCreationMode(e,s)}return}if(e.isTouch&&null!==this._startTrackPoint){this._exitTrackingModeOnNextTry=!1;const e=(0,n.ensureNotNull)(this._initCrossHairPosition),i=new Vt.Point(o,r).subtract(this._startTrackPoint),s=e.add(i)
;this.setCursorPosition(s.x,s.y,t)}else e.isTouch&&this._preventCrossHairMove()||this.setCursorPosition(o,r,t);const h=this._isSelectPointModeEnabled();if((0,Lt.isLineToolName)(a)&&!(0,Lt.isLineDrawnWithPressedButton)(a)&&!h&&!t.mod())return;if((0,Lt.isLineDrawnWithPressedButton)(a)&&!h){const t=i.lineBeingCreated();if(!t)return;const s=this._localCoordinatesToLineDataSourcePoint(e.localX,e.localY,(0,n.ensureNotNull)(t.ownerSource()));return void(s&&i.continueCreatingLine(s))}const d=i.crosshairSource().crosshairDemonstration();if(d.isThereUnfinishedHighlighter()){const e=this._localCoordinatesToLineDataSourcePoint(s.originX(),s.originY(),(0,n.ensureNotNull)(this.state().mainDataSource()));return void(e&&d.addHighlighterPosition(e))}if(null!==this._paneWidgetsSharedState.draggingSource()){const t=e.target,i=this._chart.paneByCanvas(t);i&&(i!==this?i.setDragToAnotherPaneCursor():i.setCursorForTool());const s=this._chart.timeAxisByCanvas(t);s&&s.setCursor("grabbing")}if(i.timeScale().isEmpty())return;const u=this._options.handleScroll;if((!u.pressedMouseMove||e.isTouch)&&(!u.horzTouchDrag&&!u.vertTouchDrag||!e.isTouch))return;if(this._chartModel().dragExportEnabled().value()&&this._ignoringMouseMovement)return;if(i.customMoveBeingProcessed())return void i.processCustomMove(e);const _=i.model().customSourceMovingHitTestData();if(null!==_&&(this._updateCommonTooltip(null,!0),_.cancelled||(i.model().processingCustomSourceMove(),(0,Ut.tryCallHandler)(e,{sourceWasSelected:this._selectionBeforeMouseDown.has(i.model().customSourceBeingMoved())},_.pressedMouseMoveHandler,_.touchMoveHandler)),or(e,_)))return;if(i.model().lineBeingEdited())return void this.setCursorPosition(o,r,t);if(i.model().sourcesBeingMoved().length)return void this._alignSourcesThatBeingMoved(i.model().sourcesBeingMoved(),e.localX,e.localY,t,i.model().lastHittestData()?.possibleMovingDirections);const p=this._dataSourceAtPoint(e.localX,e.localY);if(this._tryFinishClonning(e,new To.EnvironmentState(e),p))return;const m=(0,mt.toolIsMeasure)(a)||s.startMeasurePoint()&&s.endMeasurePoint();this._chart.readOnly()||!t.mod()||(0,Lt.isLineToolName)(a)||m||h?(this._processScroll(e),this._preventScroll()&&!this._preventCrossHairMove()&&null===this._startTrackPoint&&this.setCursorPosition(e.localX,e.localY,new To.EnvironmentState(e))):this._isSelecting||(s.startSelection(this.state()),this._isSelecting=!0)}_mouseOrTouchLeaveEvent(e){if(!this.hasState())return;const t=this._chartUndoModel();if(!t)return;const i=t.crosshairSource();e.isTouch||null!==i.measurePane().value()&&null===i.endMeasurePoint()||this._clearCursorPosition();if(this._chartModel().setHoveredSource(null,null),null!==this._prevHoveredHittest){const t=this._sourceWasSelected(this._prevHoveredHittest);(0,Ut.tryCallHandler)(e,{sourceWasSelected:t},this._prevHoveredHittest.hittest.data()?.mouseLeaveHandler),this._prevHoveredHittest=null}this._updateCommonTooltip(null),this._chart.setActivePaneWidget(null)}_mouseDoubleClickOrDoubleTapEvent(e){if(!this.hasState())return;const t=!this._chart.readOnly()&&!(0,
Lt.isLineToolName)(mt.tool.value())&&this._dataSourceAtPoint(e.localX,e.localY)||null,i=this._sourceWasSelected(t);if(null!==t&&t.isCustom)t.hittest.tryCallDblClickOrDblTapHandler(e,{sourceWasSelected:i});else if(null!==t&&(e.isTouch||t.hittest.target()>Ut.HitTarget.MovePointBackground))t.hittest.tryCallDblClickOrDblTapHandler(e,{sourceWasSelected:i})&&!(0,Ut.shouldDefaultActionBeExecuted)(e,(0,n.ensureNotNull)(t.hittest.data()),"doubleClickHandler","doubleTapHandler")||this.processDoubleClickOnSource(t.source,t.hittest?t.hittest:void 0);else if(!this._chart.readOnly()&&!(0,Lt.isLineToolName)(mt.tool.value())&&!this._chartUndoModel().lineBeingCreated()&&this._chartUndoModel().selection().isEmpty()){const t=this.state();new To.EnvironmentState(e).mod()&&!t.maximized().value()?(t.collapsed().value()||t.collapsingAvailable().value())&&this._chartUndoModel().toggleCollapsedPane(this.state()):this._chartUndoModel().toggleMaximizedPane(this.state())}}_contextMenuEvent(e){const t=this._chartUndoModel();if(t.crosshairSource().startMeasurePoint()&&!this._trackCrosshairOnlyAfterLongTap)return t.crosshairSource().clearMeasure(),void(0,mt.resetToCursor)(!0);if(this._pinching)return;if(null===this._firstZoomPoint||this._trackCrosshairOnlyAfterLongTap||this.cancelZoom(),!(0,mt.toolIsCursor)(mt.tool.value())||this._isSelectPointModeEnabled()){if(e.isTouch)return;return(0,mt.resetToCursor)(!0),this.setCursorForTool(),void(t.lineBeingCreated()&&t.cancelCreatingLine())}if(!this._options.contextMenuEnabled)return;const i=this._dataSourceAtPoint(e.localX,e.localY),s=i?i.source:null;if(e.isTouch&&null!==this._startTrackPoint){if(this._preventSourceChange)return;this._clearCursorPosition()}e.isTouch&&(this._contextMenuOpenedOnLastTap=!0,this._startTrackPoint=null),this._contextMenuX=e.localX,this._contextMenuY=e.localY;const o=i&&i.hittest?i.hittest.target():0,n=o>=Ut.HitTarget.Regular||o>=Ut.HitTarget.MovePointBackground&&e.isTouch;if(t.selectionMacro((t=>{null!==s&&n?t.selection().isSelected(s)||(t.clearSelection(),t.addSourceToSelection(s,Xn(i,s))):(this._options.contextMenu.general&&this._showContextMenu(e),t.clearSelection())})),null!==i&&n&&null!==s)if((0,Po.isDataSource)(s)&&s.hasContextMenu())s.isSelectionEnabled()?this.showContextMenuForSelection(e,void 0,i.hittest):this.showContextMenuForSources([s],e,void 0,void 0,i.hittest);else{const t=this._sourceWasSelected(i);i.hittest.tryCallContextMenuHandler(e,{sourceWasSelected:t})}}_onMouseEvent(){this._preventSourceChange=!1,this._startTrackPoint=null,this._trackCrosshairOnlyAfterLongTap=!1}_onTouchEvent(){this._trackCrosshairOnlyAfterLongTap=!0}_localCoordinatesToLineDataSourcePoint(e,t,i){const s=this.state().defaultPriceScale();if(s.isEmpty())return null;const o=new Vt.Point(e,t),r=(0,n.ensure)(i.firstValue());return o.price=s.coordinateToPrice(t,r),o.index=Math.round(this._chartUndoModel().timeScale().coordinateToIndex(e)),o}_switchTrackingModeFromAnotherPaneIfNeeded(e){const t=this._chart.trackingModePaneWidget();if(null!==t&&t!==this){
const i=this._chartModel().crosshairSource().currentPoint();t._exitTrackingModeOnNextTry=!0,t._tryExitTrackingMode(!0),this.startTrackingMode(new Vt.Point(e.localX,e.localY),new Vt.Point(i.x,e.localY),new To.EnvironmentState(e))}}async _showContextMenu(e){const t=e=>e instanceof zo.Separator,i=this._customActions(),s=(await this._initActions(e)).filter((e=>null!==e));i.remove.forEach((e=>{for(let t=0;t<s.length;t++){const i=s[t];if(i instanceof zo.Action&&i.getLabel()===e){s.splice(t,1);break}}}));const o=i.top.concat(s).concat(i.bottom);for(let e=o.length-1;e>0;e--)t(o[e])&&t(o[e-1])&&o.splice(e,1);o.length&&t(o[0])&&o.splice(0,1),o.length&&t(o[o.length-1])&&o.splice(o.length-1,1),Io.ContextMenuManager.showMenu(o,e,{statName:"ChartContextMenu"},{menuName:"ChartContextMenu"})}async _initActions(e){const t=this._chart.actions(),i=[];if(this._chart.model().model().resetScalesAvailable().value()&&(i.push(t.chartReset),i.push(new zo.Separator)),!this.state().isEmpty()&&l.enabled("datasource_copypaste")&&this.state().mode()===zi.PaneMode.Regular){const{createPasteAction:t,createActionCopyPrice:s}=await(0,Go.actionsProviderModule)(),o=s(this.state(),e.localY),n=t(this._chart,this.state());(o||n)&&(o&&i.push(o),n&&i.push(n),i.push(new zo.Separator))}i[i.length-1]instanceof zo.Separator||i.push(new zo.Separator),i.push(this._createLockTimeAxisAction(e)),i.push(new zo.Separator),i[i.length-1]instanceof zo.Separator||i.push(new zo.Separator),this._chart.applyIndicatorsToAllChartsAvailable()&&(i.push(t.applyStudiesToAllCharts),i.push(new zo.Separator));const s=t.paneRemoveAllDrawingTools.getState().disabled;s||i.push(t.paneRemoveAllDrawingTools);const o=t.paneRemoveAllStudies.getState().disabled;return o||i.push(t.paneRemoveAllStudies),s&&o||i.push(new zo.Separator),i.push(t.hideAllMarks),i.push(new zo.Separator),l.enabled("show_chart_property_page")&&i.push(t.chartProperties),i[i.length-1]instanceof zo.Separator&&i.pop(),i}_loadAndCreateLegendWidget(){Promise.all([i.e(3644),i.e(3439),i.e(1171),i.e(2537),i.e(8752),i.e(7780),i.e(2112),i.e(7691),i.e(7369),i.e(2227),i.e(2477),i.e(8093),i.e(5093)]).then(i.bind(i,6639)).then((e=>{if(this._isDestroyed||!this._options.legendWidgetEnabled||this._legendWidget)return;const t=e.LegendWidget,i=(0,ge.deepExtend)({},this._options.legendWidget);i.canShowSourceCode=!this._chart.onWidget()&&!ze.CheckMobile.any(),i.readOnlyMode=i.readOnlyMode||this._chart.readOnly(),i.statusesWidgets={sourceStatusesEnabled:this._options.sourceStatusesWidgetEnabled,sourceStatuses:this._options.sourceStatusesWidget||{},marketStatusEnabled:this._options.marketStatusWidgetEnabled,dataUpdateModeEnabled:this._options.chartWarningWidgetEnabled,dataUpdateMode:this._options.chartWarningWidget||{},dataProblemEnabled:this._options.dataProblemWidgetEnabled,pineSourceStatusEnabled:this._options.pineSourceStatusEnabled,alertStatusEnabled:this._options.alertStatusEnabled};const s=(0,
ft.combine)(((e,t)=>tr&&this._chart!==e&&!t),this._chart.chartWidgetCollection().activeChartWidget.weakReference(),this._chart.chartWidgetCollection().lock.crosshair.weakReference()),o=(0,ft.combine)(((e,t)=>null!==e?e===this._state:(0,mt.toolIsMeasure)(t)),this._chartModel().crosshairSource().measurePane().weakReference(),mt.tool.weakReference());this._legendWidget=new t(this._chartUndoModel(),this,this._chart.backgroundTopTheme().spawnOwnership(),s.ownership(),this._visuallyCollapsed.spawnOwnership(),o.ownership(),i,{showContextMenuForSelection:this.showContextMenuForSelection.bind(this),showContextMenuForSources:this.showContextMenuForSources.bind(this),showChartPropertiesForSource:this._chart.showChartPropertiesForSource.bind(this._chart),showGeneralChartProperties:this._chart.showGeneralChartProperties.bind(this._chart),showObjectsTreeDialog:this._chart.showObjectsTreeDialog.bind(this._chart),onLegendRowFocused:()=>{this._chart.chartWidgetCollection().activeChartWidget.setValue(this._chart)}}),this._div.prepend(this._legendWidget.getElement()),this._legendWidget.updateLayout(),this._legendWidget.updateWidgetModeBySize(this._size),this._legendWidget.updateThemedColors(this._themedTopColor);for(const e of Array.from(this._customLegendWidgetsFactoryMap.keys()))this._legendWidget.addCustomWidgetToLegend(e,(0,n.ensureDefined)(this._customLegendWidgetsFactoryMap.get(e)))}))}_loadAndCreatePaneControlsWidget(e){Promise.all([i.e(3644),i.e(3439),i.e(1171),i.e(2537),i.e(8752),i.e(7780),i.e(2112),i.e(7691),i.e(7369),i.e(2227),i.e(2477),i.e(8093),i.e(5093)]).then(i.bind(i,24028)).then((t=>{if(this._isDestroyed||this._state!==e)return;const i=t.PaneControlsWidget;this._paneControls=new i(this._chartUndoModel(),e,{backgroundThemeName:this._chart.backgroundTopTheme(),anySeparatorSelected:this._anySeparatorSelected.weakReference()},this._div),this._paneControls.updateWidgetModeByWidth(this._size.width),this._paneControls.updateThemedColors(this._themedTopColor),this._paneControlsResizeObserver=new ResizeObserver(this._handleRestrictLegendWidth.bind(this)),this._paneControlsResizeObserver.observe(this._paneControls.getElement()),this._state?.collapsed().value()&&this._chartModel().fullUpdate()}))}_handleRestrictLegendWidth(e){if(null===this._legendWidget||null===this._paneControls)return;const t=e[e.length-1].contentRect.width,i=0===t?0:t+2*Wn;this._legendWidget.addMargin(i)}_onMagnetStateChanged(){this._chart.isActive().value()&&(this._isSelectPointModeEnabled()||this._isToolActionActiveOnPane(!0))&&this._chartModel().crosshairSource().visible&&this._updateLineToolUsingMagnetOrShift()}_onShiftKeyStateChanged(){this._chart.isActive().value()&&this._isToolActionActiveOnPane(!1)&&this._chartModel().crosshairSource().visible&&this._updateLineToolUsingMagnetOrShift(To.EnvironmentState.create((0,Vs.shiftPressed)().value()))}_isToolActionActiveOnPane(e){const t=this._chartModel(),i=t.lineBeingCreated()||t.lineBeingEdited()||t.sourcesBeingMoved().length>0&&t.sourcesBeingMoved()[0];return i?t.paneForSource(i)===this._state:e&&(0,
Lt.isLineToolName)(mt.tool.value())&&t.crosshairSource().pane===this._state}_updateLineToolUsingMagnetOrShift(e){if(null===this._prevMoveEventPosition)return;const{x:t,y:i}=this._prevMoveEventPosition,s=this._chartModel().sourcesBeingMoved();s.length>0?(mt.isStudyEditingNow.value()&&this.setCursorPosition(t,i,e),this._alignSourcesThatBeingMoved(s,t,i,e)):this.setCursorPosition(t,i,e)}_showEditDialogForSource(e,t){if(this._options.propertyPagesEnabled&&e.userEditEnabled())if(e===this._chartUndoModel().mainSeries())this._chart.showGeneralChartProperties(Ns.TabNames.symbol);else if((0,zs.isLineTool)(e)||(0,Ws.isStudy)(e)){let i;const s=t?.data();if(null!=s){const e=s.areaName;void 0!==e&&(i=er.get(e))}this._chart.showChartPropertiesForSource(e,i).then((e=>{this._editDialog=e}))}}_initToolCreationModeParams(e){this._startTouchPoint=new Vt.Point(e.pageX,e.pageY),this._initCrossHairPosition=this._chartModel().crosshairSource().currentPoint()}_updateCrosshairPositionInToolCreationMode(e,t){if(t!==this._state){const i=this._chart.paneByState(t);return i._startTouchPoint=this._startTouchPoint,i._initCrossHairPosition=this._initCrossHairPosition,void i._updateCrosshairPositionInToolCreationMode(e,t)}const i=this._chartModel().crosshairSource();this._chart.justActivated()&&(this._initCrossHairPosition=i.currentPoint());const s=e.pageX,o=e.pageY,r=(0,n.ensureNotNull)(this._initCrossHairPosition),a=new Vt.Point(s,o).subtract((0,n.ensureNotNull)(this._startTouchPoint)),l=r.add(a);this.setCursorPosition(l.x,l.y,new To.EnvironmentState(e))}_priceAxisesContainer(e){return"left"===e?this._lhsPriceAxisesContainer:this._rhsPriceAxisesContainer}_recalculatePriceScales(e){const t=this.state();for(const i of t.leftPriceScales())t.recalculatePriceScale(i,e);for(const i of t.rightPriceScales())t.recalculatePriceScale(i,e);for(const i of t.sourcesByGroup().overlayPriceScaleSources())(0,zs.isLineTool)(i)||t.recalculatePriceScale(i.priceScale(),e)}_createLockTimeAxisAction(e){const t=0===mt.crosshairLock.value()?.type;return new zo.Action({actionId:"Chart.Crosshair.LockVerticalCursor",options:{label:jn,statName:"LockCursorInTime",checkable:!0,checked:t,onExecute:()=>this._toggleLockTimeAxis(e.localX,!t)}})}_toggleLockTimeAxis(e,t){if(t){const t=this._chartUndoModel().timeScale(),i=t.coordinateToIndex(e),s=t.points().roughTime(i);if(null!==s)return void mt.crosshairLock.setValue({type:0,time:s})}mt.crosshairLock.setValue(null)}_preventTouchEventsExceptPinch(){return this._paneWidgetsSharedState.hasTouchesOnOtherPanes(this)||null!==this._paneWidgetsSharedState.pinchingPane()}_updateHoveredSource(e,t,i){const s=this._chartUndoModel(),o=s.model();let n=!1;const r=e&&e.source,a=this._chart.readOnly();if(o.crosshairSource().isReplaySelection())this._setCursorClassName("none");else if(!(!a||e&&(0,zs.isLineTool)(e.source))||this._editDialog&&this._editDialog.visible().value())a&&(o.setHoveredSource(null,null),this.setCursorForTool());else{const l=mt.tool.value();let c=null;if(!this._processing&&((0,mt.toolIsCursor)(l)||(0,
mt.toolIsEraser)(l)&&!a||t.mod()||!s.lineBeingCreated())){const t=e?.hittest;n=Boolean(t?.data()?.hideCrosshairLinesOnHover),t&&t.target()>Ut.HitTarget.MovePointBackground?(c=r,!r?.isHoveredEnabled()||(0,mt.toolIsEraser)(l)&&r===s.mainSeries()?o.setHoveredSource(null,null):o.setHoveredSource(r,t.data(),0)):o.setHoveredSource(null,null)}a?this.setCursorForTool(c,t,ei.PaneCursorType.Default):this._options.sourceSelectionEnabled&&(this._isSelectPointModeEnabled()?this._setCursorClassName("pointer"):this.setCursorForTool(c,t,e?.hittest.data()?.cursorType));const h=o.customSourceBeingMoved(),d=null!==h?[h]:o.sourcesBeingMoved();if((!d.length||null!==e&&-1===d.indexOf(e.source))&&this._updateCommonTooltip(e),!a&&null!==e&&i&&e.hittest.hasPressedMoveHandler(i)){switch((e.hittest.data()||{}).cursorType){case ei.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case ei.PaneCursorType.HorizontalResize:this._setCursorClassName("we-resize");break;case ei.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case ei.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize")}}}this._preventCrossHairMove()&&this._clearCursorPosition(),1!==this._pressedMoveStage&&o.crosshairSource().setLinesShouldBeHidden(n)}async _createErrorBlock(){const e=new(await Ks());return this._div.insertBefore(e.container,this._topCanvasBinding.canvasElement.nextSibling),e}_customActions(){const e={top:[],bottom:[],remove:[]},t=this._chartUndoModel().timeScale(),i=this._state&&this._state.defaultPriceScale();if(!l.enabled("custom_items_in_context_menu"))return e;const s=t.isEmpty()?void 0:t.indexToUserTime(t.coordinateToIndex(this._contextMenuX));let o;if(i&&!i.isEmpty()){const e=(0,n.ensureNotNull)(this.state().mainDataSource()).firstValue();o=i.coordinateToPrice(this._contextMenuY,(0,n.ensureNotNull)(e))}return(0,ee.emit)("onContextMenu",{unixtime:null!=s?s.getTime()/1e3:void 0,price:o,callback:t=>{[...t].forEach((t=>{if(t.text)if(t.text.length>1&&"-"===t.text[0])e.remove.push(t.text.slice(1));else{let i;i="-"===t.text?new zo.Separator:new zo.Action({actionId:"Chart.ExternalActionId",options:{label:t.text,onExecute:t.click}}),t.position&&"top"===t.position?e.top.push(i):e.bottom.push(i)}}))}}),e}_highlightPriceAxisesByLabel(e){this._state?.mode()===zi.PaneMode.Regular&&(this._lhsPriceAxisesContainer.setHighlightedPriceAxises(e),this._rhsPriceAxisesContainer.setHighlightedPriceAxises(e))}_subscribeToState(){const e=this.state();e.onDestroyed().subscribe(this,this._onStateDestroyed,!0),e.dataSourcesCollectionChanged().subscribe(this,this._onDataSourcesCollectionChanged),e.maximized().subscribe(this._updateVisuallyCollapsed,{callWithLast:!0}),e.collapsed().subscribe(this._updateVisuallyCollapsed,{callWithLast:!0}),e.maximized().subscribe(this._updateMaximized,{callWithLast:!0})}_unsubscribeFromState(){const e=this.state();e.onDestroyed().unsubscribeAll(this),e.dataSourcesCollectionChanged().unsubscribeAll(this),e.maximized().unsubscribe(this._updateVisuallyCollapsed),
e.collapsed().unsubscribe(this._updateVisuallyCollapsed),e.maximized().unsubscribe(this._updateMaximized),this._maximized.setValue(!1)}_updateAccessibilityAttr(){if(this.hasState()&&this.state().isMainPane().value()){const e=this._chartModel().mainSeries(),t=e.symbol(),s=(0,ht.getTranslatedResolutionModel)(e.interval()).hint,o=a.t(null,{replace:{symbol:t,interval:s}},i(1136));this._topCanvasBinding.canvasElement.setAttribute("aria-label",o)}else this._topCanvasBinding.canvasElement.setAttribute("aria-hidden","true")}async _updateEndOfSeriesBanner(){0}_paneDblClickOrTapEvent(e){if(this._chart.readOnly())return;const t=this._dataSourceAtPoint(e.localX,e.localY);if(null!==t&&(0,zs.isEditableTextLineTool)(t.source)){const e=t.source.textEditingActivationTime();null!==e&&performance.now()-e<500&&this.processDoubleClickOnSource(t.source,t.hittest)}}}class ar{constructor(){this._draggingSource=null,this._activeTouchPanes=new Set,this._scrollingPane=null,this._pinchingPane=null}onPaneDestroyed(e){this._activeTouchPanes.delete(e),this._scrollingPane===e&&(this._scrollingPane=null),this._pinchingPane===e&&(this._pinchingPane=null)}startTouch(e){this._activeTouchPanes.add(e)}endTouch(e){this._activeTouchPanes.delete(e)}hasTouchesOnOtherPanes(e){return this._activeTouchPanes.size>1||1===this._activeTouchPanes.size&&!this._activeTouchPanes.has(e)}trySetDraggingSource(e,t){return!this.hasTouchesOnOtherPanes(t)&&((0,n.assert)(null===this._draggingSource||this._draggingSource===e),this._draggingSource=e,!0)}clearDraggingSource(){null!==this._draggingSource&&(this._draggingSource=null)}draggingSource(){return this._draggingSource}setScrollingPane(e){(0,n.assert)(null===e||null===this._scrollingPane||this._scrollingPane===e),this._scrollingPane=e}scrollingPane(){return this._scrollingPane}setPinchingPane(e){(0,n.assert)(null===e||null===this._pinchingPane||this._pinchingPane===e),this._pinchingPane=e}pinchingPane(){return this._pinchingPane}}var lr,cr=i(19679),hr=i(95772);i(20715);!function(e){e[e.BorderSize=1]="BorderSize",e[e.OffsetSize=5]="OffsetSize"}(lr||(lr={}));const dr={contextMenuEnabled:!0,timezoneMenuEnabled:!0,pressedMouseMoveScale:!0},ur=new dt.TranslatedString("change session",a.t(null,void 0,i(87041))),_r=a.t(null,void 0,i(94031));class pr{constructor(e,t,i,s,o){this._rendererOptions=null,this._onLabelHovered=new ae.Delegate,this._mousedown=!1,this._currentCursorClassName="invalid",this._options=(0,tt.merge)((0,tt.clone)(dr),t||{}),this.chart=e,this._properties=e.properties().childs().scalesProperties,this._element=document.createElement("div"),this._element.style.display="flex",this._backgroundBasedTheme=o;const n=e.model().model().rendererOptionsProvider(),r=()=>this.backgroundColor(),a=()=>{throw new Error("Time axis does not support real price scales")},l={titlesProvider:i,stubContextMenuProvider:async(e,t)=>{const i=await s(e,t),o=this.getContextMenuActions(!0);return 0===o.length?i:i.concat(new zo.Separator,o)},backgroundBasedTheme:o.spawnOwnership(),onActiveOrHoveredChart:(0,
ft.combine)(((e,t)=>e||t),this.chart.isActive().weakReference(),this.chart.isHovered().weakReference()).ownership(),rendererOptionsProvider:n,getBackgroundTopColor:r,getBackgroundBottomColor:r,requestRepaint:()=>{this.chart.model().model().invalidate(ao.InvalidationMask.timeScale(ao.InvalidationLevel.Light,!0))},showHorizontalBorder:!0};this._lhsStubContainer=new Vo(this._properties,"left",a,l,this._options.priceAxisLabelsOptions,this),this._lhsStubContainer.onLabelHovered().subscribe(this,((e,t)=>{this._onLabelHovered.fire(e,t)})),this._rhsStubContainer=new Vo(this._properties,"right",a,l,this._options.priceAxisLabelsOptions,this),this._rhsStubContainer.onLabelHovered().subscribe(this,((e,t)=>{this._onLabelHovered.fire(e,t)})),this._element.appendChild(this._lhsStubContainer.getElement()),this._cell=document.createElement("div"),this._element.appendChild(this._cell),this._cell.classList.add("chart-markup-table","time-axis"),this._cell.style.height="25px",this._dv=document.createElement("div"),this._dv.style.width="100%",this._dv.style.height="100%",this._dv.style.position="relative",this._dv.style.overflow="hidden",this._cell.appendChild(this._dv),this._canvasConfiguredHandler=()=>this.chart.model().model().lightUpdate(),this._canvasBinding=(0,Kt.createBoundCanvas)(this._dv,(0,Ft.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const c=this._canvasBinding.canvasElement;c.style.position="absolute",c.style.zIndex="1",c.style.left="0",c.style.top="0",this._topCanvasBinding=(0,Kt.createBoundCanvas)(this._dv,(0,Ft.size)({width:16,height:16})),this._topCanvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const h=this._topCanvasBinding.canvasElement;h.style.position="absolute",h.style.zIndex="2",h.style.left="0",h.style.top="0",this._dv.setAttribute("aria-hidden","true"),this._element.appendChild(this._rhsStubContainer.getElement()),this.restoreDefaultCursor(),this.update(),this._minVisibleSpan=cr.MINUTE_SPAN,this._mouseEventHandler=new Wt.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{treatVertTouchDragAsPageScroll:!0,treatHorzTouchDragAsPageScroll:!1}),this.size=(0,Ft.size)({width:0,height:0}),(0,mt.hideMarksOnBars)().subscribe(this,(()=>this.chart.model().model().lightUpdate()))}destroy(){this._mouseEventHandler.destroy(),this._topCanvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._topCanvasBinding.dispose(),this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._rhsStubContainer.onLabelHovered().unsubscribeAll(this),this._lhsStubContainer.onLabelHovered().unsubscribeAll(this),this._lhsStubContainer.destroy(),this._rhsStubContainer.destroy(),this.chart.properties().childs().paneProperties.childs().background.unsubscribeAll(this),this._backgroundBasedTheme.release(),(0,mt.hideMarksOnBars)().unsubscribeAll(this)}setCursor(e){let t="";"grabbing"!==e&&"ew-resize"!==e||(t="time-axis--cursor-"+e),
this._currentCursorClassName!==t&&(this._currentCursorClassName&&this._cell.classList.remove(this._currentCursorClassName),t&&this._cell.classList.add(t),this._currentCursorClassName=t,this._cell.style.cursor)}restoreDefaultCursor(){this.setCursor("")}getElement(){return this._element}optimalHeight(){const e=this.rendererOptions();return Math.ceil(e.borderSize+e.offsetSize+e.fontSize+e.paddingTop+e.paddingBottom+e.labelBottomOffset)}setSizes(e,t,i){this.size&&(0,Ft.equalSizes)(this.size,e)||(this.size=e,this._canvasBinding.resizeCanvasElement(e),this._topCanvasBinding.resizeCanvasElement(e),this._cell.style.width=e.width+"px",this._cell.style.height=e.height+"px"),this._lhsStubContainer.setSizes(e.height,t),this._rhsStubContainer.setSizes(e.height,i)}rendererOptions(){if(!this._rendererOptions||this._rendererOptions.fontSize!==this.fontSize()){const e=this.fontSize();this._rendererOptions={borderSize:1,offsetSize:5,fontSize:e,font:(0,si.makeFont)(e,m.CHART_FONT_FAMILY,""),widthCache:new Qt.TextWidthCache,paddingTop:3*e/12,paddingBottom:3*e/12,paddingHorizontal:9*e/12,labelBottomOffset:4*e/12}}return this._rendererOptions}backgroundColor(){return this.chart.model().model().backgroundColor().value()}lineColor(){const e=this._properties.childs().lineColor.value();if(0===(0,Nt.parseRgba)(e)[3]){const e=this.chart.model().model().lastPane();if(e&&e.collapsed().value())return this.chart.properties().childs().paneProperties.childs().separatorColor.value()}return e}textColor(){return this._properties.childs().textColor.value()}fontSize(){return this._properties.childs().fontSize.value()}baseFont(){return(0,si.makeFont)(this.fontSize(),m.CHART_FONT_FAMILY)}baseBoldFont(){return(0,si.makeFont)(this.fontSize(),m.CHART_FONT_FAMILY,"","bold")}hasCanvas(e){return this._canvasBinding.canvasElement===e||this._topCanvasBinding.canvasElement===e}onLabelHovered(){return this._onLabelHovered}getScreenshotData(){return{content:this._canvasBinding.canvasElement.toDataURL(),canvas:this._canvasBinding.canvasElement,contentWidth:this.size.width,contentHeight:this.size.height,lhsStub:this._lhsStubContainer.getScreenshotData(),rhsStub:this._rhsStubContainer.getScreenshotData()}}getContextMenuActions(e){const t=this.chart,i=t.actions(),s=[];if(e||(t.model().timeScale().resetAvailable().value()&&(s.push(i.timeScaleReset),s.push(new zo.Separator)),this._options.timezoneMenuEnabled&&s.push(i.applyTimeZone),s.push(i.sessionBreaks)),!t.model().mainSeries().isDWM()){const e=t.model()?.mainSeries().symbolInfo();if(e){const i=t.model().mainSeries().properties().childs().sessionId,o=(e.subsessions||[]).filter((e=>!e.private));if(o.length>1){const e=o.map((e=>new zo.Action({actionId:"Chart.SetSession",options:{label:(0,hr.translateSessionDescription)(e.description),checkable:!0,checked:i.value()===e.id,statName:"SetSession",onExecute:()=>{t.model().setProperty(i,e.id,ur)}}}))),n=new zo.Action({actionId:"Chart.SetSession",options:{label:_r,statName:"SetSession",subItems:e}});s.push(n)}}}
return!t.onWidget()&&l.enabled("show_chart_property_page")&&l.enabled("chart_property_page_scales")&&i.scalesProperties&&(s.length&&s.push(new zo.Separator),s.push(i.scalesProperties)),s}update(){if(!this.chart.hasModel())return;const e=this.chart.model().timeScale().marks();if(e){this._minVisibleSpan=cr.YEAR_SPAN;for(const t of e)this._minVisibleSpan=Math.min(t.span,this._minVisibleSpan)}}updatePriceAxisStubs(){const e=this.chart.model().model(),t=this.chart.hasMaximizedPane()?(0,n.ensureNotNull)(this.chart.maximizedPaneWidget()).state():e.paneForSource(e.mainSeries());if(!t)return;const i=e.priceScaleSlotsCount();this._lhsStubContainer.setScales([],i.left,t.leftPriceScales().length,i.left+i.right),this._rhsStubContainer.setScales([],i.right,t.rightPriceScales().length,i.left+i.right)}paint(e){if(e.level===ao.InvalidationLevel.None||0===this.size.width||0===this.size.height)return;(0,Kt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),(0,Kt.tryApplySuggestedCanvasBitmapSize)(this._topCanvasBinding);const t=(0,Kt.getContext2D)(this._topCanvasBinding.canvasElement);if(e.level>ao.InvalidationLevel.Cursor){const i=(0,Kt.getContext2D)(this._canvasBinding.canvasElement),s=(0,Kt.getBindingRenderingInfo)(this._canvasBinding);this.drawBackground(i,s),this.chart.hasModel()&&(this.drawBorder(i,s),this.drawTickMarks(i,s),this.drawBackLabels(i,s),this.drawCrossHairLabel(t,s)),this._lhsStubContainer.paintStubs(e),this._rhsStubContainer.paintStubs(e)}this.drawCrossHairLabel(t,(0,Kt.getBindingRenderingInfo)(this._topCanvasBinding))}drawBackground(e,t){if((0,Kt.clearRect)(e,0,0,t.bitmapSize.width,t.bitmapSize.height,this.backgroundColor()),!this.chart.hasModel())return;const i=this.chart.model();if(!i.timeScale().isEmpty()){const s=i.model().selection().lineDataSources().filter((e=>!e.isFixed())).reduce(((e,t)=>{const i=t.timeAxisPoints();return 0===i.length?e:e.concat(i)}),[]);s.length>0&&this._highlightBackground(e,s,t)}const s=i.model().crosshairSource();s.startMeasurePoint()&&this._highlightBackground(e,s.measurePoints(),t)}drawBorder(e,t){e.save(),e.fillStyle=this.lineColor();const i=Math.max(1,Math.floor(this.rendererOptions().borderSize*t.verticalPixelRatio)),s=t.bitmapSize.width;e.fillRect(0,0,s,i),e.restore()}drawTickMarks(e,t){const i=this.chart.model().timeScale().marks();if(!i||0===i.length)return;let s=i.reduce(((e,t)=>e.span>t.span?e:t),i[0]).span;s>30&&s<40&&(s=30),e.save(),e.strokeStyle=this.lineColor();const o=this.rendererOptions(),n=o.borderSize+o.offsetSize+o.paddingTop+o.fontSize/2;e.textAlign="center",e.textBaseline="middle",e.fillStyle=this.textColor(),(0,Kt.drawScaled)(e,t.horizontalPixelRatio,t.verticalPixelRatio,(()=>{e.font=this.baseFont();for(let t=0;t<i.length;t++){const o=i[t];o.span<s&&e.fillText(o.label,o.coord,n)}e.font=this.baseBoldFont();for(let t=0;t<i.length;t++){const o=i[t];o.span>=s&&e.fillText(o.label,o.coord,n)}})),e.restore()}drawBackLabels(e,t){e.save();const i=new Set,s=this.chart.model().model();let o=s.dataSources();const n=s.selection().allSources();for(const e of n)i.add(e)
;s.hoveredSource()&&i.add(s.hoveredSource());for(const e of s.sourcesBeingMoved())i.add(e);const r=s.customSourceBeingMoved();null!==r&&i.add(r);const a=s.lineBeingEdited()??s.lineBeingCreated();a&&i.add(a),i.add(this.chart.model().crosshairSource()),o=o.concat(s.customSources());const l=this.rendererOptions();for(let s=0;s<o.length;s++){const n=o[s];if(!i.has(n)&&n.timeAxisViews){const i=n.timeAxisViews();if(i)for(let s=0;s<i.length;s++)i[s].renderer().draw(e,t,l)}}e.restore()}drawCrossHairLabel(e,t){e.save(),e.clearRect(0,0,t.bitmapSize.width,t.bitmapSize.height);const i=this.chart.model().model(),s=[],o=i.lineBeingEdited()??i.lineBeingCreated();if(o&&o.timeAxisViews){const e=o.timeAxisViews();e&&e.length&&s.push(e)}const n=i.customSourceBeingMoved();this._addViewsOrMaxMin(null===n?[]:[n],s),this._addViewsOrMaxMin(i.sourcesBeingMoved(),s),this._addViewsOrMaxMin(i.selection().allSources(),s);const r=i.hoveredSource();if(r&&(0,Po.isDataSource)(r)&&!i.selection().isSelected(r)&&r.timeAxisViews){const e=r.timeAxisViews();e&&e.length&&s.push(e)}const a=i.crosshairSource(),l=a.timeAxisViews&&a.timeAxisViews();l&&l.length&&s.push(l);const c=this.rendererOptions();for(const i of s)for(const s of i)e.save(),s.renderer().draw(e,t,c),e.restore();e.restore()}mouseClickEvent(e){this.chart.model().model().setActivationChartFloatingTooltipHint(null)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._mouseOrTouchEnterEvent(e),this._mouseDownOrTouchStartEvent(e)}mouseDownOutsideEvent(){this._outsideMouseDownOrTouchStartEvent()}touchStartOutsideEvent(){this._outsideMouseDownOrTouchStartEvent()}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseUpOrTouchEndEvent(e),this._mouseOrTouchLeaveEvent(e)}contextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}touchContextMenuEvent(e){this._contextMenuOrTouchContextMenuEvent(e)}mouseEnterEvent(e){this._mouseOrTouchEnterEvent(e)}mouseLeaveEvent(e){this._mouseOrTouchLeaveEvent(e)}mouseDoubleClickEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}doubleTapEvent(e){this._mouseDoubleClickOrDoubleTapEvent(e)}_outsideMouseDownOrTouchStartEvent(){this._zoomAvailable()&&this._mousedown&&(this._mousedown=!1,this.chart.model().endScaleTime(),this.restoreDefaultCursor())}_highlightBackground(e,t,i){const s=this.chart.model().timeScale();let o=t[0].index,n=t[0].index;for(let e=1;e<t.length;e++)o=Math.min(o,t[e].index),n=Math.max(n,t[e].index);const{horizontalPixelRatio:r}=i,a=Math.floor(s.indexToCoordinate(o)*r),l=Math.ceil(s.indexToCoordinate(n)*r);(0,Kt.fillRect)(e,a,0,l-a,i.bitmapSize.height,this._properties.childs().axisHighlightColor.value())}_addViewsOrMaxMin(e,t){if(e.length<=1){for(const i of e)if(i.timeAxisViews){const e=i.timeAxisViews();e&&e.length&&t.push(e)}}else t.push(this._minMaxViews(e))}_minMaxViews(e){const t=[];let i=1/0,s=-1/0,o=null,n=null;for(const t of e)if(t.timeAxisViews){const e=t.timeAxisViews()
;if(e&&e.length)for(let t=0;t<e.length;++t){const r=e[t],a=r.coordinate();a>=s&&(s=a,n=r),a<=i&&(i=a,o=r)}}return n&&t.push(n),o&&t.push(o),t}_zoomAvailable(){const e=this.chart.model().model();return!e.timeScale().isEmpty()&&e.zoomEnabled()&&this._options.pressedMouseMoveScale&&!e.chartFloatingTooltipVisible().value()}_mouseDownOrTouchStartEvent(e){if(this._mousedown||!this._zoomAvailable())return;this._mousedown=!0;const t=this.chart.model();t.timeScale().isEmpty()||t.startScaleTime(e.localX)}_pressedMouseOrTouchMoveEvent(e){this._zoomAvailable()&&this.chart.model().scaleTimeTo(e.localX)}_mouseUpOrTouchEndEvent(e){this._zoomAvailable()&&(this._mousedown=!1,this.chart.model().endScaleTime(),this.restoreDefaultCursor())}_contextMenuOrTouchContextMenuEvent(e){this._options.contextMenuEnabled&&Io.ContextMenuManager.showMenu(this.getContextMenuActions(),e,{statName:"TimeScaleContextMenu"},{menuName:"TimeScaleContextMenu"})}_mouseOrTouchEnterEvent(e){this._zoomAvailable()&&this.setCursor("ew-resize")}_mouseOrTouchLeaveEvent(e){this.restoreDefaultCursor()}_mouseDoubleClickOrDoubleTapEvent(e){(0,re.trackEvent)("GUI","Double click time scale"),this.chart.model().resetTimeScale()}}var mr,gr,fr,yr,vr=i(85459),Sr=i.n(vr),br=i(76662),wr=i(10341),Cr=i(1395);function Tr(e,t){return"period-back"===e.type&&"period-back"===t.type?e.value===t.value:"time-range"===e.type&&"time-range"===t.type&&(e.from===t.from&&e.to===t.to)}function Pr(e,t){return!!Re.Interval.isEqual(e.res,t.res)&&Tr(e.val,t.val)}!function(e){e.extractErrorReason=function(e){return e.params[1]}}(mr||(mr={})),function(e){e.Default="default",e.FullSingleSession="full_single_session"}(gr||(gr={})),function(e){e.PeriodBack="period-back",e.TimeRange="time-range"}(fr||(fr={})),function(e){e.PeriodBack="period-back",e.TimeRange="time-range"}(yr||(yr={}));var xr=i(22961);const Mr={duration:250,easing:br.easingFunc.easeOutCubic};class Ir{constructor(e){this._onFinishCalled=!1,this._options={...Mr,...e},this._startTime=performance.now()}getStartPosition(){return this._options.from}getPosition(e){const t=this._calculateProgress(e);return 1===t?(this._options.onFinish&&!this._onFinishCalled&&(this._options.onFinish(!0),this._onFinishCalled=!0),this._options.to):(0,xr.lerp)(this._options.from,this._options.to,this._options.easing(t))}finished(e){return 1===this._calculateProgress(e)}onFinish(e){this._onFinishCalled||(this._options.onFinish?.(e),this._onFinishCalled=!0)}_calculateProgress(e){const t=e-this._startTime;return t>=this._options.duration?1:t/this._options.duration}}var Ar=i(92848),Lr=i(22455);function kr(e,t,i,s){let o=null;if(i.currencyConversionEnabled()&&(0,Lr.isActingAsSymbolSource)(e)){const n=i.availableCurrencies(),r=t.currency(n),a=e.currency();null!==r&&null!==r.selectedCurrency&&!r.allCurrenciesAreOriginal&&r.selectedCurrency!==a&&(s&&null===a||null!==a&&n.convertible(a))&&(o=r.selectedCurrency)}return o}const Er=new dt.TranslatedString("toggle collapsed pane state",a.t(null,void 0,i(46054)));class Dr extends st.UndoCommand{constructor(e,t){super(Er),
this._chartModel=e,this._paneIndex=t}redo(){this._chartModel.toggleCollapsedPane(this._paneIndex)}undo(){this._chartModel.toggleCollapsedPane(this._paneIndex)}}const Br=new dt.TranslatedString("toggle maximized pane state",a.t(null,void 0,i(63095)));class Vr extends st.UndoCommand{constructor(e,t){super(Br),this._model=e;const i=e.maximizedPane().value(),s=null===i?null:e.panes().indexOf(i);this._maximizedPaneIndex=t===i?null:e.panes().indexOf(t),this._prevMaximizedPaneIndex=s}redo(){this._setMaximizedPane(this._maximizedPaneIndex)}undo(){this._setMaximizedPane(this._prevMaximizedPaneIndex)}_setMaximizedPane(e){this._model.setMaximizedPane(null===e?null:this._model.panes()[e])}}const Rr=new dt.TranslatedString("move all scales to left",a.t(null,void 0,i(64077))),Nr=new dt.TranslatedString("move all scales to right",a.t(null,void 0,i(19013))),Or=(0,ne.getLogger)("Chart.MergeAllScales");class Fr extends st.UndoCommand{constructor(e,t,i,s,o,n){super(n),this._model=e,this._paneIndex=e.panes().indexOf(t),this._targetPosition=s,this._targetIndex=o,this._scaleId=i.id(),this._sourcePosition=t.priceScalePosition(i),"overlay"!==this._sourcePosition&&(this._sourceIndex=t.priceScaleIndex(i,this._sourcePosition))}redo(){const e=this._model.panes()[this._paneIndex],t=(0,n.ensureNotNull)(e.getPriceScaleById(this._scaleId));e.movePriceScale(t,this._targetPosition,this._targetIndex),this._model.fullUpdate()}undo(){const e=this._model.panes()[this._paneIndex],t=(0,n.ensureNotNull)(e.getPriceScaleById(this._scaleId));e.movePriceScale(t,this._sourcePosition,this._sourceIndex),this._model.fullUpdate()}}var Wr=i(13896);class Hr extends st.UndoCommand{constructor(e,t,i,s){super(s,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._createdIds=[],this._actionSourceWasSent=!1,this._model=e,this._withoutShift=i,this._origStates=t.map((e=>e.state(!0)));const o=e.lineToolsGroupModel();this._origGroups=t.map((e=>{const t=o.groupForLineTool(e);return t&&t.id}))}redo(){const e=this._model.lineToolsGroupModel();let t;this._actionSourceWasSent||(t="Clone",this._actionSourceWasSent=!0);const i=this._origStates.map(((i,s)=>{const o=(0,n.ensureNotNull)(this._model.dataSourceForId(i.id)),r=0===this._createdIds.length?void 0:(0,n.ensureDefined)(this._createdIds[s]),a=(0,zs.cloneLineTool)(this._model,o,!this._withoutShift,r,t);void 0!==i.sharingMode&&a.share(i.sharingMode);const l=(0,n.ensureNotNull)(o.priceScale());(0,n.ensureNotNull)(this._model.paneForSource(o)).addDataSource(a,l,!1);const c=this._origGroups[s];if(null!==c){const t=e.groupForId(c);t&&t.addLineTools([a])}return this._model.updateSource(a),a}));0===this._createdIds.length&&(this._createdIds=i.map((e=>e.id()))),this._model.selectionMacro((e=>{e.clearSelection(),i.forEach((t=>{e.addSourceToSelection(t)}))})),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){const e=this._model.lineToolsGroupModel();this._createdIds.forEach((t=>{const i=(0,n.ensureNotNull)(this._model.dataSourceForId(t)),s=e.groupForLineTool(i);null!==s&&s.excludeLineTool(i),this._model.removeSource(i)}))}newIds(){
return this._createdIds}}class zr extends st.UndoCommand{constructor(e,t,i,s=!0){super(t,i,s),this._invalidateViaSync=!1,this._chartModel=e}redo(){this._invalidateViaSync?this._chartModel.lineToolsSynchronizer().executeSynchronizationInLayoutAction((async()=>this._redo())):this._redo()}undo(){this._invalidateViaSync?this._chartModel.lineToolsSynchronizer().executeSynchronizationInLayoutAction((async()=>this._undo())):this._undo()}}var Ur=i(97217);function jr(e,t,i){let s=[];const o=e.children(t,!1,i);for(let t=0;t<o.length;t++)s=s.concat(jr(e,o[t],i));return s.push(t),s}function Gr(e,t,i){const s=new Set,o=t=>{e.children(t,!1,i).forEach((e=>{s.has(e)||(s.add(e),o(e))}))};return t.forEach(o),t.filter((e=>!s.has(e))).map((t=>jr(e,t,i))).reduce(((e,t)=>e.concat(t)),[])}function qr(e,t){return Gr(e,t,!0).reduce(((e,t)=>((0,Ur.isLineTool)(t)?e[1].push(t.id()):e[0].push(t.id()),e)),[[],[]])}function $r(e,t){qr(e,t).reverse().forEach((t=>{t.map((t=>e.dataSourceForId(t))).filter(tt.notNull).forEach((t=>{e.removeSource(t)}))}))}var Kr=i(29603);class Yr extends zr{constructor({chartModel:e,title:t,lineDataSourceIds:i}){super(e,t,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._excludeLineToolsFromGroupUndoCommands=[],this._undoState=[],this._lineDataSourceIds=i}_redo(){const e=this._lineDataSourceIds.map((e=>(0,n.ensureNotNull)(this._chartModel.dataSourceForId(e))));this._groupLineToolsByGroups(e).forEach(((e,t)=>{const i=new Kr.ExcludeLineToolsFromGroupUndoCommand(this._chartModel,t,e);i.redo(),this._excludeLineToolsFromGroupUndoCommands.push(i)})),e.forEach((e=>{this._undoState.push({state:e.state(!1),paneIndex:this._chartModel.panes().indexOf((0,n.ensureNotNull)(this._chartModel.paneForSource(e))),sharingMode:e.sharingMode().value()}),this._chartModel.removeSource(e)}))}_undo(){for(let e=this._undoState.shift();e;e=this._undoState.shift())this._chartModel.restoreSource(!1,e.paneIndex,null,e.state,null)?.share(e.sharingMode);this._excludeLineToolsFromGroupUndoCommands.forEach((e=>e.undo()))}_groupLineToolsByGroups(e){const t=this._chartModel.lineToolsGroupModel();return e.reduce(((e,i)=>{const s=t.groupForLineTool(i);if(null!==s){const t=e.get(s)||[];t.push(i),e.set(s,t)}return e}),new Map)}}var Zr=i(2258),Xr=i(42516);const Jr=(0,ne.getLogger)("Chart.RemoveSourcesUndoCommand"),Qr=new dt.TranslatedString("remove line data sources",a.t(null,void 0,i(38199)));class ea extends zr{constructor(e,t,i){super(e,i,void 0,(0,Xr.sourcesAffectState)(t)),this._removeLineDataSourcesUndoCommand=null,this._initialPriceScaleMode=null;const[s,o]=qr(e,t);this._sourceIds=s,this._lineDataSourceIds=o,this._sourceStates=[],this._paneIndexes=[],this._priceScalePositionIds=[],this._paneStates=[],this._restorePanes=[];const r=t[0];1===t.length&&(0,Ws.isStudy)(r)&&(this._initialPriceScaleMode=(0,n.ensureNotNull)(r.priceScale()).mode())}removedIds(){return[...this._sourceIds,...this._lineDataSourceIds]}_redo(){this._chartModel.panes().length;const e=this._sourceIds.map((e=>(0,n.ensureNotNull)(this._chartModel.dataSourceForId(e))))
;this._sourceStates=e.map((e=>{const t=e.state(!1);return null===t&&(0,Ws.isStudyStub)(e)?e.getDescriptor():t}));const t=e.map((e=>(0,n.ensureNotNull)(this._chartModel.paneForSource(e))));this._paneIndexes=t.map((e=>this._chartModel.panes().indexOf(e))),this._lineDataSourceIds.length>0&&(this._removeLineDataSourcesUndoCommand=new Yr({title:Qr,chartModel:this._chartModel,lineDataSourceIds:this._lineDataSourceIds}),this._removeLineDataSourcesUndoCommand.redo()),this._priceScalePositionIds=e.map(((e,i)=>{const s=e.priceScale();if(null===s)return null;const o=t[i].priceScalePosition(s);return{id:s.id(),position:o,priceScaleIndex:t[i].priceScaleIndex(s,o)}}));const i=new Set;e.forEach(((e,t)=>{i.add(this._paneIndexes[t])})),this._paneStates=e.map(((e,s)=>{const o=this._paneIndexes[s];return i.has(o)?t[s].state({includeSources:!1,withData:!0}):null})),this._restorePanes=e.map((e=>this._chartModel.removeSource(e)))}_undo(){const e=[];for(let t=this._sourceStates.length-1;t>=0;t--){const i=this._sourceStates[t];if(null!==i){let s=null;s=(0,Zr.isStudyStubDescriptor)(i)?this._chartModel.restoreStudyStub(i):this._chartModel.restoreSource(this._restorePanes[t],this._paneIndexes[t],this._paneStates[t],i,this._priceScalePositionIds[t]),s&&e.push(s)}}e.some(((t,i)=>t.id()!==this._sourceIds[e.length-i-1]))&&Jr.logError("Source was restored improperly - source ids does not match"),null!==this._initialPriceScaleMode&&(0,n.ensureNotNull)(e[0].priceScale()).setMode(this._initialPriceScaleMode),this._removeLineDataSourcesUndoCommand&&this._removeLineDataSourcesUndoCommand.undo()}}class ta extends st.UndoCommand{constructor(e,t,i,s=!0){super(i,s,(0,Xr.sourcesAffectState)(t)),this._newStates=[],this._model=e,this._savedStates=t.map((e=>e.state(!1)))}redo(){this._applyState(this._newStates)}undo(){0===this._newStates.length&&this.saveNewState(),this._applyState(this._savedStates)}saveNewState(){const e=this._savedStates.filter(tt.notNull).map((e=>(0,n.ensureNotNull)(this._model.dataSourceForId(e.id))));this._newStates=e.map((e=>e.state(!1)))}_applyState(e){for(const t of e)if(null!==t){const e=this._model.dataSourceForId(t.id);if(null!==e)if((0,Ws.isStudy)(e)){const i=t.state.inputs,s=e.properties().childs().inputs.childs();for(const e in i)s[e]&&s[e].setValue(i[e])}else{const i=e;this._model.restoreLineToolState(i,t,!0),i.synchronizeAlert(!0)}}}}class ia extends st.UndoCommand{constructor(e,t,i){super(i),this._chartModel=e,this._sourceId=t.id();const s=(0,n.ensureNotNull)(t.priceScale());this._initialPriceScaleId=s.id(),this._initialPriceScaleState=(0,n.ensureNotNull)(t.priceScale()).state();const o=(0,n.ensureNotNull)(e.paneForSource(t));this._initialPriceScalePosition=o.priceScalePosition(s),this._initialPriceScaleIndex=o.priceScaleIndex(s,this._initialPriceScalePosition),this._initialPaneIndex=e.panes().indexOf(o)}_newPriceScaleState(e){const t={...this._initialPriceScaleState};return delete t.m_isLockScale,delete t.id,delete t.m_topMargin,delete t.m_bottomMargin,delete t.hasCalculatedPriceRange,t}_originalPriceScaleState(){
return this._initialPriceScaleState}}class sa extends ia{constructor(e,t,i){super(e,t,i)}redo(){const e=(0,n.ensureNotNull)(this._chartModel.dataSourceForId(this._sourceId)),t=(0,n.ensureNotNull)(this._chartModel.paneForSource(e)),i=this._chartModel.children(e,!0,!0);t.bulkActionMacro((()=>{i.forEach((e=>this._chartModel.detachSource(e))),this._chartModel.detachSource(e)}));const s=this._chartModel.createPane(this.targetPaneIndex(e)),o=s.findSuitableScale(e);s.bulkActionMacro((()=>{s.addDataSource(e,o,!1),i.forEach((e=>s.addDataSource(e,o,!1)))}));const r=(0,n.ensureNotNull)(e.priceScale());r.restoreState(this._newPriceScaleState(s.isOverlay(e))),r.setHeight(s.height()),this._chartModel.fullUpdate(),this._chartModel.setShouldBeSavedEvenIfHidden(!0)}undo(){const e=(0,n.ensureNotNull)(this._chartModel.dataSourceForId(this._sourceId)),t=(0,n.ensureNotNull)(this._chartModel.paneForSource(e)),i=this._chartModel.children(e,!0,!0);t.bulkActionMacro((()=>{i.forEach((e=>this._chartModel.detachSource(e)));const t=this._chartModel.detachSource(e);(0,n.assert)(t,"Undo of detaching must remove pane")}));const s=this._chartModel.panes()[this._initialPaneIndex];let o=s.getPriceScaleById(this._initialPriceScaleId);null===o&&(o=s.createPriceScaleAtPosition(this._initialPriceScalePosition,this._initialPriceScaleIndex)),s.bulkActionMacro((()=>{s.addDataSource(e,o,!0),i.forEach((e=>s.addDataSource(e,o,!1)))}));const r=(0,n.ensureNotNull)(e.priceScale());r.restoreState(this._originalPriceScaleState()),r.setHeight(s.height()),this._chartModel.fullUpdate()}}class oa extends sa{constructor(e,t,i){super(e,t,i)}targetPaneIndex(e){const t=this._chartModel.panes();if(!t[this._initialPaneIndex].containsMainSeries()||e===this._chartModel.mainSeries())return this._initialPaneIndex+1;for(let e=this._initialPaneIndex+1;e<t.length;e++)if(t[e].mode()===zi.PaneMode.Regular)return e<t.length-1&&t[e].containsMainSeries()&&t[e+1].mode()===zi.PaneMode.Widget?e+1:e;return t.length}}class na extends sa{constructor(e,t,i){super(e,t,i)}targetPaneIndex(e){const t=this._chartModel.panes();if(!t[this._initialPaneIndex].containsMainSeries()||e===this._chartModel.mainSeries())return this._initialPaneIndex;for(let e=this._initialPaneIndex-1;e>=0;e--)if(t[e].mode()===zi.PaneMode.Regular)return e>0&&t[e].containsMainSeries()&&t[e-1].mode()===zi.PaneMode.Widget?e-1:e;return 0}}class ra extends sa{constructor(e,t,i){super(e,t,i)}targetPaneIndex(){return this._chartModel.panes().length}}class aa extends ia{constructor(e,t,i,s){super(e,t,i),this._restorePane=!1,this._keepZOrder=s??!1,this._initialZOrder=t.zorder()}redo(){const e=this._chartModel.panes().length,t=this._chartModel.panes()[this._targetPaneIndex()],i=(0,n.ensureNotNull)(this._chartModel.dataSourceForId(this._sourceId)),s=(0,n.ensureNotNull)(this._chartModel.paneForSource(i)),o=this._chartModel.children(i,!0,!0);s.bulkActionMacro((()=>{o.forEach((e=>this._chartModel.detachSource(e))),this._restorePane=this._chartModel.detachSource(i)}))
;const r="overlay"===this._initialPriceScalePosition?this._initialPriceScalePosition:void 0,a=t.findSuitableScale(i,void 0,r),l=0===a.dataSources().length;if(t.bulkActionMacro((()=>{t.addDataSource(i,a,this._keepZOrder),o.forEach((e=>t.addDataSource(e,a,this._keepZOrder)))})),i===this._chartModel.mainSeries()){const e=t.priceScalePosition(a);t.movePriceScale(a,e,0)}if(l){const e=(0,n.ensureNotNull)(i.priceScale());e.restoreState(this._newPriceScaleState(t.isOverlay(i))),e.setHeight(t.height())}this._chartModel.fullUpdate(),e!==this._chartModel.panes().length&&this._chartModel.setShouldBeSavedEvenIfHidden(!0)}undo(){let e;e=this._restorePane?this._chartModel.createPane(this._initialPaneIndex):this._chartModel.panes()[this._initialPaneIndex];const t=(0,n.ensureNotNull)(this._chartModel.dataSourceForId(this._sourceId)),i=(0,n.ensureNotNull)(this._chartModel.paneForSource(t)),s=this._chartModel.children(t,!0,!0);i.bulkActionMacro((()=>{s.forEach((e=>this._chartModel.detachSource(e))),this._chartModel.detachSource(t)}));let o=e.getPriceScaleById(this._initialPriceScaleId);null===o&&(o=e.createPriceScaleAtPosition(this._initialPriceScalePosition,this._initialPriceScaleIndex)),e.bulkActionMacro((()=>{t.setZorder(this._initialZOrder),e.addDataSource(t,o,!0),s.forEach((t=>e.addDataSource(t,o,!1)))}));const r=(0,n.ensureNotNull)(t.priceScale());r.restoreState(this._originalPriceScaleState()),r.setHeight(e.height()),this._chartModel.fullUpdate()}}class la extends aa{constructor(e,t,i){super(e,t,i)}_targetPaneIndex(){const e=this._chartModel.panes();for(let t=this._initialPaneIndex-1;t>=0;t--)if(e[t].mode()===zi.PaneMode.Regular)return t;throw new Error("No regular pane found above for merging")}}class ca extends aa{constructor(e,t,i){super(e,t,i)}_targetPaneIndex(){const e=this._chartModel.panes();for(let t=this._initialPaneIndex+1;t<e.length;t++)if(e[t].mode()===zi.PaneMode.Regular)return t;throw new Error("No regular pane found below for merging")}}class ha extends aa{constructor(e,t,i,s,o){super(e,t,s,o),this._targetPane=i}_targetPaneIndex(){return this._targetPane}}var da=i(56876);const ua=new dt.TranslatedString("create {tool}",a.t(null,void 0,i(12898)));class _a extends zr{constructor({model:e,pane:t,lineTool:i,ownerSource:s,drawOnAllChartsMode:o=0,id:n}){super(e,ua.format({tool:new dt.TranslatedString(i,da.lineToolsLocalizedNames[i])}),!1,!Wr.lineToolsDoNotAffectChartInvalidation),this._lineId=null,this._lineState=null,this._paneIndex=e.panes().indexOf(t),this._lineTool=i,this._ownerSourceId=s.id(),this._lineId=n??null,this._drawOnAllChartsMode=o}startCreatingLine(e,t,i,s,o,n){const r=this._chartModel.panes()[this._paneIndex],a=this._chartModel.dataSourceForId(this._ownerSourceId)||void 0,l=this._chartModel.createLineTool({pane:r,point:e,linetool:this._lineTool,properties:t,linkKey:i,sharingMode:s,ownerSource:a,id:this._lineId??void 0,fromExternalModel:o,actionSource:n});return this._lineId=l.id(),this._fromExternalModel=o,!this._chartModel.lineBeingCreated()}continueCreatingLine(e,t,i,s){(0,
n.assert)(this._lineId===this._chartModel.lineBeingCreated()?.id(),"Cannot continue not least created line");const o=this._chartModel.continueCreatingLine(e,t,i,s,this._fromExternalModel);return o&&this._chartModel.setShouldBeSavedEvenIfHidden(!0),o}line(){return null===this._lineId?null:this._chartModel.dataSourceForId(this._lineId)}drawOnAllCharts(){return 0!==this._drawOnAllChartsMode}_redo(){if(null===this._lineState)return;const e=this._chartModel.restoreSource(!1,this._paneIndex,null,(0,n.ensureNotNull)(this._lineState),null);null!==e&&(this._lineId=e.id(),this._lineState=null,e.share(this._drawOnAllChartsMode))}_undo(){const e=this.line();null!==e&&(this._lineState=e.state(!1),this._chartModel.removeSource(e),this._lineId=null)}}var pa=i(36313);const ma=new dt.TranslatedString("bring {title} to front",a.t(null,void 0,i(53159))),ga=new dt.TranslatedString("send {title} to back",a.t(null,void 0,i(5005))),fa=new dt.TranslatedString("insert {title} after {targetTitle}",a.t(null,void 0,i(56307))),ya=new dt.TranslatedString("insert {title} before {targetTitle}",a.t(null,void 0,i(46229))),va=new dt.TranslatedString("send {title} backward",a.t(null,void 0,i(40962))),Sa=new dt.TranslatedString("bring {title} forward",a.t(null,void 0,i(41966))),ba=new dt.TranslatedString("send group {title} backward",a.t(null,void 0,i(69546))),wa=new dt.TranslatedString("bring group {title} forward",a.t(null,void 0,i(1979)));function Ca(e){return new dt.TranslatedString(e.name(),e.title(pa.TitleDisplayTarget.StatusLine))}class Ta extends st.UndoCommand{constructor(e,t,i){super(i,void 0,(0,Xr.sourcesAffectState)(t)),this._sourcesByPanes=new Map,this._originalState=new Map,this._model=e,t.forEach((t=>{const i=(0,n.ensureNotNull)(e.paneForSource(t)),s=e.panes().indexOf(i),o=this._sourcesByPanes.get(s)||[];o.push(t.id()),this._sourcesByPanes.set(s,o)})),Array.from(this._sourcesByPanes.keys()).forEach((t=>{const i=e.panes()[t],s=new Map,o=new Set(i.sourcesByGroup().multipaneSources());i.sourcesByGroup().allIncludingHidden().filter((e=>!o.has(e))).forEach((e=>{s.set(e.id(),e.zorder())})),this._originalState.set(t,s)}))}undo(){this._originalState.forEach(((e,t)=>{const i=this._model.panes()[t],s=new Map;e.forEach(((e,t)=>{const o=(0,n.ensureNotNull)(i.dataSourceForId(t));s.set(o,e)})),i.setZOrders(s)}))}redo(){this._sourcesByPanes.forEach(((e,t)=>{const i=this._model.panes()[t],s=e.map((e=>(0,n.ensureNotNull)(i.dataSourceForId(e))));this._paneOperation(i,s)}))}}class Pa extends Ta{constructor(e,t){super(e,t,ma.format({title:Ca(t[0])}))}_paneOperation(e,t){e.bringToFront(t)}}class xa extends Ta{constructor(e,t){super(e,t,ga.format({title:Ca(t[0])}))}_paneOperation(e,t){e.sendToBack(t)}}class Ma extends Ta{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertAfter(t,this._targetSource)}}class Ia extends Ma{constructor(e,t,i){super(e,t,i,fa.format({title:Ca(t[0]),targetTitle:Ca(i)}))}}class Aa extends Ta{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertBefore(t,this._targetSource)}}
class La extends Aa{constructor(e,t,i){super(e,t,i,ya.format({title:Ca(t[0]),targetTitle:Ca(i)}))}}function ka(e,t){const i=t[0],s=e.sourcesByGroup().all().filter((e=>e.zorder()<i.zorder()));if(0===s.length)throw new Error("Cannot move backward source that alreadt on back");let o=s[s.length-1];if((0,zs.isLineTool)(o)){const t=e.model().lineToolsGroupModel().groupForLineTool(o);null!==t&&(o=t.lineTools()[0])}return o}class Ea extends Aa{constructor(e,t,i){super(e,i,ka(t,i),va.format({title:Ca(i[0])}))}}function Da(e,t){const i=t[t.length-1],s=e.sourcesByGroup().allExceptSpecialSources().filter((e=>e.zorder()>i.zorder()));if(0===s.length)throw new Error("Cannot bring forward source that alreadt on back");let o=s[0];if((0,zs.isLineTool)(o)){const t=e.model().lineToolsGroupModel().groupForLineTool(o);if(null!==t){const e=t.lineTools();o=e[e.length-1]}}return o}class Ba extends Ma{constructor(e,t,i){super(e,i,Da(t,i),Sa.format({title:Ca(i[0])}))}}function Va(e,t){return(0,n.ensureNotNull)(e.paneForSource(t.lineTools()[0]))}class Ra extends Aa{constructor(e,t){super(e,t.lineTools(),ka(Va(e,t),t.lineTools()),ba.format({title:t.name().value()}))}}class Na extends Ma{constructor(e,t){super(e,t.lineTools(),Da(Va(e,t),t.lineTools()),wa.format({title:t.name().value()}))}}const Oa=new dt.TranslatedString("rearrange panes",a.t(null,void 0,i(2618)));class Fa extends st.UndoCommand{constructor(e,t,i){if(super(Oa),this._chartModel=e,this._index=t,(0,tt.isNumber)(i))this._dstIndex=i;else{const s="up"===i?-1:1;this._dstIndex=t+s,e.panes()[this._dstIndex].mode()===zi.PaneMode.Widget&&(this._dstIndex=this._dstIndex+s)}}redo(){this._checkIndices()&&this._chartModel.movePane(this._index,this._dstIndex)}undo(){this._checkIndices()&&this._chartModel.movePane(this._dstIndex,this._index)}_checkIndices(){const e=this._chartModel.panes().length;return this._index>=0&&this._index<e&&this._dstIndex>=0&&this._dstIndex<e}}var Wa=i(76559);function Ha(e){return{val:e.value(),dependenValues:e.dependents?.().map(Ha)??[]}}function za(e){return(e.dependents?.()??[]).map(Ha)}function Ua(e,t){(e.dependents?.()??[]).forEach(((e,i)=>{e.setValue(t[i].val),(e.dependents?.()??[]).forEach((e=>Ua(e,t[i].dependenValues)))}))}function ja(e,t){return"string"==typeof t?(0,Wa.propertyByPath)(e,t):t}class Ga extends st.UndoCommand{constructor(e,t,i,s,o=!0){super(i,void 0,o);const n=e.pathToRoot();this._targetObj=(0,Wa.isRootPath)(n)?n:e,this._newValue=t,this._oldValue=e.value(),this._dependentValues=za(e),this._model=s}redo(e){(0,yi.allowSavingDefaults)(!0),ja(e.chartWidgetCollection,this._targetObj).setValue(this._newValue),(0,yi.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,wi.globalChangeEvent)()),this._model.lightUpdate()}undo(e){(0,yi.allowSavingDefaults)(!0);const t=ja(e.chartWidgetCollection,this._targetObj);t.setValue(this._oldValue),Ua(t,this._dependentValues),(0,yi.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,wi.globalChangeEvent)()),this._model.lightUpdate()}}class qa extends st.UndoCommand{constructor(e,t,i,s,o,n){super(s),
this._prevPriceAxisProps={},this._dependentValues=[],this._intervalChangeWasTracked=!1,this._property=e,this._mainSeries=i,this._value=t,this._model=o,this._chartWidget=n}redo(){const e=this._mainSeries,t=e.properties().childs();this._dependentValues=za(this._property),this._prevResolution=t.interval.value(),this._prevValue=this._property.value(),this._storePriceAxisProps(),(0,yi.allowSavingDefaults)(!0);const i=t.interval.value(),s=this._model.defaultResolutions(),o=(0,ht.getResolutionByChartStyle)(this._value,i,s);de.linking.interval.setValue(o),e.setChartStyleWithIntervalIfNeeded(this._value,o),(0,xt.setLastUsedStyle)(this._value,e.symbolInfo()),(0,xt.preparePriceAxisProperties)(t),(0,yi.allowSavingDefaults)(!1),this._invalidateModel(),this._chartWidget.screen.show(!0)}undo(){const e=this._mainSeries;(0,yi.allowSavingDefaults)(!0),e.setChartStyleWithIntervalIfNeeded(this._prevValue,this._prevResolution),this._restorePriceAxisProps(),de.linking.interval.setValue(this._prevResolution),Ua(this._property,this._dependentValues),(0,yi.allowSavingDefaults)(!1),this._invalidateModel(),this._chartWidget.screen.show(!0)}_storePriceAxisProps(){const e=this._mainSeries.priceScale();this._prevPriceAxisProps=e.mode()}_restorePriceAxisProps(){this._mainSeries.priceScale().setMode(this._prevPriceAxisProps)}_invalidateModel(){this._model&&(this._model.recalculateAllPanes((0,wi.sourceChangeEvent)(this._model.mainSeries().id())),this._model.lightUpdate())}}const $a=new dt.TranslatedString("change date range",a.t(null,void 0,i(16979)));class Ka extends st.UndoCommand{constructor(e,t){super($a),this._modelsData=[],this._rangeOptions=t,this._modelsData.push({model:e,prevResolution:e.mainSeries().properties().childs().interval.value(),barSpacing:e.timeScale().barSpacing(),rightOffset:e.timeScale().rightOffset(),rangeOptions:e.appliedTimeFrame().value()})}redo(){for(const e of this._modelsData){const t=e.model.mainSeries(),i=t.properties().childs().interval;Re.Interval.isEqual(this._rangeOptions.res,i.value())?t.loadDataTo(this._rangeOptions.val):(t.setDefaultTimeframe(this._rangeOptions.val),t.setSymbolParams({interval:this._rangeOptions.res}))}}undo(){for(const e of this._modelsData){const t=e.model.mainSeries(),i=t.properties().childs().interval;e.prevResolution!==i.value()?(null!==e.rangeOptions&&t.setDefaultTimeframe(e.rangeOptions.val),t.setSymbolParams({interval:e.prevResolution})):null!==e.rangeOptions&&t.loadDataTo(e.rangeOptions.val);const s=e.model.timeScale();s.setBarSpacing(e.barSpacing),s.setRightOffset(e.rightOffset)}}canMerge(e){return e instanceof Ka&&Pr(e._rangeOptions,this._rangeOptions)}merge(e){if(!(e instanceof Ka))throw new Error("Invalid command to merge");this._modelsData=this._modelsData.concat(e._modelsData)}}function Ya(e){return e.properties().visible.value()}function Za(e){return!Ya(e)}class Xa{constructor(e,t,i){this._instanceId=(0,fe.randomHashN)(6),this._onChanged=new ae.Delegate,this._lineToolsSet=new Set,this._lineTools=[...e],this._lineToolsSet=new Set(this._lineTools),this._name=new O.WatchedValue(t),
this.id=i||(0,fe.randomHashN)(6)}instanceId(){return this._instanceId}lineTools(){return this._lineTools}name(){return this._name}setName(e){this._doAndFireOnChange((()=>{this._name.setValue(e)}))}isActualSymbol(){return this._lineTools.length>0&&this._lineTools[0].isActualSymbol()&&this._lineTools[0].isActualCurrency()&&this._lineTools[0].isActualUnit()}symbol(){return this._lineTools[0].symbol()}currencyId(){return this._lineTools[0].properties().childs().currencyId.value()??null}unitId(){return this._lineTools[0].properties().childs().unitId.value()??null}sharingMode(){return this._lineTools[0].sharingMode()}share(e){this._lineTools.forEach((t=>t.share(e)))}containsLineTool(e){return this._lineToolsSet.has(e)}addLineTools(e){this._doAndFireOnChange((t=>{e.forEach((e=>this._lineToolsSet.add(e))),this._lineTools.push(...e),t.push(...e.map((e=>e.id())))}))}excludeLineTool(e){this._doAndFireOnChange((t=>{this._lineToolsSet.delete(e);const i=this._lineTools.indexOf(e);this._lineTools.splice(i,1),t.push(e.id())}))}excludeLineTools(e){this._doAndFireOnChange((t=>{const i=new Set(e);e.forEach((e=>this._lineToolsSet.delete(e))),this._lineTools=this._lineTools.filter((e=>!i.has(e))),t.push(...e.map((e=>e.id())))}))}state(){return{id:this.id,name:this._name.value(),tools:this._lineTools.map((e=>e.id()))}}visibility(){const e=this._lineTools.some(Ya),t=this._lineTools.some(Za);return e&&!t?"Visible":t&&!e?"Invisible":"Partial"}locked(){const e=this._lineTools.some((e=>e.properties().frozen.value())),t=this._lineTools.some((e=>!e.properties().frozen.value()));return e&&!t?"Locked":t&&!e?"Unlocked":"Partial"}isActualInterval(){const e=this._lineTools.some((e=>e.isActualInterval())),t=this._lineTools.some((e=>!e.isActualInterval()));return e&&!t?"IsActualInterval":t&&!e?"IsNotActualInterval":"Partial"}onChanged(){return this._onChanged}static fromState(e,t){const i=[];for(const s of t.tools){const t=e.dataSourceForId(s);null!==t&&i.push(t)}return i.length>0?new Xa(i,t.name,t.id):null}_doAndFireOnChange(e){const t=[],i=this.visibility(),s=this.locked(),o=this.isActualInterval();e(t),this._onChanged.fire({affectedLineTools:t,visibilityChanged:i!==this.visibility(),lockedChanged:s!==this.locked(),isActualIntervalChanged:o!==this.isActualInterval()})}}class Ja extends st.UndoCommand{constructor(e,t,i){super(i,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._model=e,this._groupId=t.id,this._groupName=t.name().value(),this._lineToolsIds=t.lineTools().map((e=>e.id()))}redo(){const e=(0,n.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId));this._model.lineToolsGroupModel().removeGroup(e)}undo(){const e=this._lineToolsIds.map((e=>this._model.dataSourceForId(e))),t=new Xa(e,this._groupName,this._groupId);this._model.lineToolsGroupModel().addGroup(t)}}const Qa=new dt.TranslatedString("create line tools group",a.t(null,void 0,i(46219)));class el extends st.UndoCommand{constructor(e,t){super(Qa,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._groupId=null,this._model=e,this._sourcesIds=t.map((e=>e.id()))
}redo(){const e=this._sourcesIds.map((e=>this._model.dataSourceForId(e))),t=null===this._groupId?void 0:this._groupId;this._groupId=this._model.lineToolsGroupModel().createGroup(e,this._title,t).id}undo(){const e=(0,n.ensureNotNull)(this._model.lineToolsGroupModel().groupForId((0,n.ensureNotNull)(this._groupId)));this._model.lineToolsGroupModel().removeGroup(e)}createdGroupId(){return this._groupId}}const tl=new dt.TranslatedString("add line tool(s) to group {group}",a.t(null,void 0,i(21162)));class il extends st.UndoCommand{constructor(e,t,i){super(tl.format({group:t.name().value()}),void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._model=e,this._groupId=t.id,this._lineToolsIds=i.map((e=>e.id()))}redo(){const e=(0,n.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId)),t=this._lineToolsIds.map((e=>this._model.dataSourceForId(e)));e.addLineTools(t)}undo(){const e=this._lineToolsIds.map((e=>this._model.dataSourceForId(e)));(0,n.ensureNotNull)(this._model.lineToolsGroupModel().groupForId(this._groupId)).excludeLineTools(e)}}class sl extends st.UndoCommand{constructor(e,t,i,s){super(s,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._chartModel=e,this._groupId=t.id,this._oldName=t.name().value(),this._newName=i}redo(){(0,n.ensureNotNull)(this._chartModel.lineToolsGroupModel().groupForId(this._groupId)).setName(this._newName)}undo(){(0,n.ensureNotNull)(this._chartModel.lineToolsGroupModel().groupForId(this._groupId)).setName(this._oldName)}}const ol=new dt.TranslatedString("create line tools group from selection",a.t(null,void 0,i(95394))),nl=new dt.TranslatedString("removing line tools group {name}",a.t(null,void 0,i(41430))),rl=new dt.TranslatedString("add line tool {lineTool} to group {name}",a.t(null,void 0,i(12570))),al=new dt.TranslatedString("make group {group} visible",a.t(null,void 0,i(45987))),ll=new dt.TranslatedString("make group {group} invisible",a.t(null,void 0,i(76709))),cl=new dt.TranslatedString("lock group {group}",a.t(null,void 0,i(20453))),hl=new dt.TranslatedString("unlock group {group}",a.t(null,void 0,i(74590))),dl=new dt.TranslatedString("rename group {group} to {newName}",a.t(null,void 0,i(80491)));class ul{constructor(e){this._environment=e}createGroupFromSelection(){const e=this._environment.model();(0,n.assert)(!e.selection().isEmpty(),"Cannot create group from empty selection");const t=(0,vi.sortSources)(e.selection().lineDataSources());(0,n.assert)(t.length===e.selection().allSources().length,"A group could contain line tools only");const i=t.length>1||null!==this._environment.model().lineToolsGroupModel().groupForLineTool(t[0]),s=t.reduce(((e,t)=>e.zorder()>t.zorder()?e:t),t[0]);let o=s;const r=e.lineToolsGroupModel().groupForLineTool(s);if(null!==r){const e=r.lineTools();o=e[e.length-1]}this._environment.beginUndoMacro(ol);const a=new Map,l=new Set;t.forEach((t=>{const i=this._groupForLineTool(t);if(null===i)return;const s=a.get(i)||[];s.push(t),a.set(i,s);const o=(0,n.ensureNotNull)(e.paneForSource(t));l.add(o)})),(0,
n.assert)(l.size<=1,"All selected sources should be on the same pane"),a.forEach(((t,i)=>{const s=new Kr.ExcludeLineToolsFromGroupUndoCommand(e,i,t);this._environment.pushUndoCommand(s)}));const c=new el(e,(0,vi.sortSources)(t));if(this._environment.pushUndoCommand(c),i){const i=new Ia(e,t,o);this._environment.pushUndoCommand(i)}this._environment.endUndoMacro();const h=(0,n.ensureNotNull)(c.createdGroupId());return(0,n.ensureNotNull)(e.lineToolsGroupModel().groupForId(h))}removeGroup(e){const t=this._environment.model(),i=e.lineTools();this._environment.beginUndoMacro(nl.format({name:e.name().value()}));const s=new Ja(t,e,null);this._environment.pushUndoCommand(s);const o=new ea(t,i,null);this._environment.pushUndoCommand(o);const r=t.mainSeries().symbol();i.forEach((e=>{null!==e.linkKey().value()&&(0,mt.removeLineTool)({withUndo:!0,model:t,symbol:r,sourceTitle:new dt.TranslatedString(e.name(),e.title(pa.TitleDisplayTarget.DataWindow)),lineToolState:e.state(!1),linkKey:(0,n.ensureNotNull)(e.linkKey().value())})})),this._environment.endUndoMacro()}groups(){return this._environment.model().lineToolsGroupModel().groups()}excludeLineToolFromGroup(e,t){const i=this._environment.model(),s=new Kr.ExcludeLineToolsFromGroupUndoCommand(i,e,[t]);this._environment.pushUndoCommand(s)}addLineToolToGroup(e,t){const i=this._environment.model(),s=i.lineToolsGroupModel().groupForLineTool(t);if(s===e)return;const o=rl.format({lineTool:new dt.TranslatedString(t.name(),t.title(pa.TitleDisplayTarget.StatusLine)),name:e.name().value()});this._environment.beginUndoMacro(o),null!==s&&this._environment.pushUndoCommand(new Kr.ExcludeLineToolsFromGroupUndoCommand(i,s,[t]));if(l.enabled("saveload_separate_drawings_storage")){const s=e.sharingMode().value();t.sharingMode().value()!==s&&this._environment.pushUndoCommand(new SetLineSharingModeUndoCommand(t,s,i,null))}this._environment.pushUndoCommand(new il(i,e,[t])),this._environment.endUndoMacro()}bringToFront(e){const t=this._environment.model(),i=new Pa(t,e.lineTools());this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendToBack(e){const t=this._environment.model(),i=new xa(t,e.lineTools());this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}bringForward(e){const t=this._environment.model(),i=new Na(t,e);this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendBackward(e){const t=this._environment.model(),i=new Ra(t,e);this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}insertAfter(e,t){const i=this._environment.model();let s;if(t instanceof Xa){const e=t.lineTools();s=e[e.length-1]}else s=t;const o=new Ia(i,e.lineTools(),s);this._environment.pushUndoCommand(o),this._environment.emitEvent("changeZOrder",[e.lineTools()])}insertBefore(e,t){const i=this._environment.model();let s;if(t instanceof Xa){s=t.lineTools()[0]}else s=t;const o=new La(i,e.lineTools(),s);this._environment.pushUndoCommand(o),
this._environment.emitEvent("changeZOrder",[e.lineTools()])}availableZOrderOperations(e){const t=this._environment.model(),i=e.lineTools(),s=i[0],o=i[i.length-1],r=(0,n.ensureNotNull)(t.paneForSource(i[0])).sourcesByGroup().allExceptSpecialSources(),a=r[0],l=r[r.length-1];return{bringForwardEnabled:o!==l,bringToFrontEnabled:o!==l,sendBackwardEnabled:s!==a,sendToBackEnabled:s!==a}}setGroupVisibility(e,t){const i=(t?al:ll).format({group:e.name().value()}),s=this._environment.model();this._environment.beginUndoMacro(i),e.lineTools().forEach((e=>{const i=e.properties().visible,o=new Ga(i,t,null,s,!Wr.lineToolsDoNotAffectChartInvalidation);this._environment.pushUndoCommand(o)})),this._environment.endUndoMacro()}setGroupLock(e,t){const i=(t?cl:hl).format({group:e.name().value()}),s=this._environment.model();this._environment.beginUndoMacro(i),e.lineTools().forEach((e=>{const i=e.properties().frozen,o=new Ga(i,t,null,s,!Wr.lineToolsDoNotAffectChartInvalidation);this._environment.pushUndoCommand(o)})),this._environment.endUndoMacro()}setGroupName(e,t){const i=this._environment.model(),s=dl.format({group:e.name().value(),newName:t}),o=new sl(i,e,t,s);this._environment.pushUndoCommand(o)}canBeGroupped(e){const t=this._environment.model();return new Set(e.map((e=>t.paneForSource(e)))).size<=1}_groupForLineTool(e){return this._environment.model().lineToolsGroupModel().groups().find((t=>t.containsLineTool(e)))||null}}var _l=i(61710);const pl=new dt.TranslatedString("apply study template {template}",a.t(null,void 0,i(69604)));function ml(e){for(const t of e.panes)for(const e of t.sources)if((0,wt.isMainSeriesState)(e))return e.id;return null}class gl extends st.UndoCommand{constructor(e,t,i){super(pl.format({template:i})),this._newSymbolParams={},this._model=e,this._templateContent=function(e,t){const i=(0,Qe.default)({},e),s=(0,n.ensureNotNull)(ml(i));for(const e of i.panes){e.mainSourceId===s&&(e.mainSourceId=t);for(const i of e.sources)if(i.id===s){i.id=t;const o=e=>{const i=e.indexOf(s);-1!==i&&e.splice(i,1,t)};if(e.leftAxisesState&&e.rightAxisesState?(e.leftAxisesState.forEach((e=>o(e.sources))),e.rightAxisesState.forEach((e=>o(e.sources)))):(o(e.leftAxisSources),o(e.rightAxisSources)),e.overlayPriceScales){const i=e.overlayPriceScales[s];i&&(delete e.overlayPriceScales[s],e.overlayPriceScales[t]=i)}}else i.ownerSource===s&&(i.ownerSource=t)}return i}(t,e.mainSeries().id()),this._initialState=e.studyTemplate(!0,!0,!0);const s=e.mainSeries();t.symbol&&(this._newSymbolParams={symbol:t.symbol,currency:t.currency??null,unit:t.unit??null}),t.interval&&(this._newSymbolParams.interval=t.interval,this._newSymbolParams.style=(0,xt.getChartStyleByResolution)(t.interval,s.style())),this._initialSymbolParams={symbol:s.symbol(),currency:s.currency(),unit:s.unit(),interval:s.interval(),style:s.style()},this._initialState=e.studyTemplate(),this._initialGroupsState=e.lineToolsGroupModel().state()}redo(){this._model.mainSeries().setSymbolParams(this._newSymbolParams);const e=this._merge(this._templateContent).filter(zs.isLineTool)
;this._model.lineToolsGroupModel().removeLineTools(e);const t=this._model.mainSeries().properties();(0,xt.preparePriceAxisProperties)(t),this._model.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.StudyCreation),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){this._model.mainSeries().setSymbolParams(this._initialSymbolParams),this._merge(this._initialState)}_merge(e){const t=e.version||0,i=this._model,s=i.mainSeries();(0,n.assert)(s.id()===ml(e)),s.priceScale().properties().childs().lockScale.setValue(!1);const o=i.panes(),r=[],a=s.properties().childs().tpoStyle.childs(),l=e.panes.reduce(((e,t)=>{const i=t.sources.find((e=>(0,wt.isMainSeriesState)(e)));if(i&&i.state&&18===i.state.style){const e=i.state.tpoStyle.summary.visible;return i.state.tpoStyle.summary.visible=!1,e}return e}),void 0)??false,c=s.properties().childs().volFootprintStyle.childs(),h=e.panes.reduce(((e,t)=>{const i=t.sources.find((e=>(0,wt.isMainSeriesState)(e)));if(i&&i.state&&17===i.state.style){const e=i.state.volFootprintStyle.showSummary;return i.state.volFootprintStyle.showSummary=!1,e}return e}),void 0)??false,d=s.style();18===d?a.summary.childs().visible.setValue(!1):17===d&&c.showSummary.setValue(!1);for(let e=o.length;e--;){const t=o[e],i=t.containsMainSeries(),s=t.dataSources();for(let e=s.length;e--;){const t=s[e];(!i||((0,Ws.isStudy)(t)||(0,Ws.isStudyStub)(t))&&t.isRemovedByStudyTemplates())&&r.push(t)}}i.resetDeferredStudies();const u=Gr(i,r,!0);for(let e=0;e<u.length;++e)i.removeSource(u[e]);const _=e.panes;for(let e=0;e<_.length;e++){let s=-1;const n=(0,tt.clone)(_[e]);n.sources.sort(((e,t)=>e.zorder-t.zorder));for(let e=0;e<n.sources.length;e++){const t=n.sources[e];if((0,wt.isMainSeriesState)(t)){delete t.state,s=e;break}}const r=s>-1,a=r?o[e]:i.createPane(e);r&&t<3&&(0,_l.reorderDataSourcesStateZOrder)(n.sources),a.restoreState({state:n,withData:!1,version:t}),null!==a.mainDataSource()||i.removePane(a)}return i.syncLollipopSources(),s.priceScale().setMode({autoScale:!0}),18===d?a.summary.childs().visible.setValue(l):17===d&&c.showSummary.setValue(h),i.startNotStartedStudies(),i.recalculateAllPanes((0,wi.globalChangeEvent)()),i.fullUpdate(),u}}const fl=(0,ne.getLogger)("Chart.ChartUndoModel");var yl;!function(e){e[e.PasteYCoordOffset=-40]="PasteYCoordOffset"}(yl||(yl={}));const vl=new dt.TranslatedString("paste drawing",a.t(null,void 0,i(62192)));class Sl extends st.UndoCommand{constructor(e,t,i,s,o){super(vl,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._needCopyToOtherCharts=!1,this._sourceState=null,this._actionSourceWasSent=!1,this._model=e,this._clipboardData=t,this._paneIndex=this._model.panes().indexOf(i||(0,n.ensureNotNull)(this._model.paneForSource(this._model.mainSeries()))),this._pasteWithData=!!s,this._keepZIndex=!!o}redo(){const e=this._model.panes()[this._paneIndex],t=(0,n.ensureNotNull)(e.clipboardLineToolOwnerSource(this._clipboardData.source.id)),i=t===this._model.mainSeries();let s;null===this._sourceState&&(this._sourceState=this._getSourceState(t,i)),
this._actionSourceWasSent||(s="Paste",this._actionSourceWasSent=!0);const o=(0,n.ensureNotNull)(e.restoreLineTool({state:this._sourceState,withData:this._pasteWithData,keepZOrder:this._keepZIndex,ownerSource:t,actionSource:s}));(0,n.ensureNotNull)(t.priceScale()).addDataSource(o),this._clipboardData.centeredOnChart&&o.centerPosition&&o.centerPosition(),o.restoreFixedPoint(),o.createServerPoints(),this._needCopyToOtherCharts=Boolean(i&&o.isSynchronizable()&&0!==o.sharingMode().value()),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){if(!this._sourceState)return void fl.logError("This command was never executed - nothing to undo");const e=this.source();this._clipboardData.centeredOnChart&&(this._clipboardData.centeredOnChart=!1,this._sourceState.points=e.normalizedPoints()),this._model.removeSource(e)}source(){return(0,n.ensureNotNull)(this._model.dataSourceForId((0,n.ensureNotNull)(this._sourceState).id))}needCopyToOtherCharts(){return this._needCopyToOtherCharts}_getSourceState(e,t){const i=(0,tt.clone)(this._clipboardData.source);delete i.state.symbol,t?(null!=i.linkKey||void 0!==i.sharingMode&&0!==i.sharingMode)&&(i.linkKey=(0,fe.randomHash)()):(i.linkKey=null,i.sharingMode=0);const s=(0,n.ensureNotNull)(e.priceScale()),o=this._model,{symbol:r,currencyId:a,unitId:l}=this._clipboardData.source.state,c=(0,n.ensureNotNull)(e.symbolSource());let h=!1;!c.symbolSameAsCurrent(r)||(null!==a?a!==(0,xt.symbolCurrency)(c.symbolInfo(),void 0,!0):c.isConvertedToOtherCurrency())||(null!==l?l!==(0,xt.symbolUnit)(c.symbolInfo(),this._model.unitConversionEnabled()):c.isConvertedToOtherUnit())||((0,Lr.isActingAsSymbolSource)(e)?h=!0:(0,Ws.isStudy)(e)&&(h=Boolean(e.metaInfo().is_price_study))),i.state.currencyId=o.currencyConversionEnabled()&&c.isConvertedToOtherCurrency()?c.currency():null,i.state.unitId=o.unitConversionEnabled()&&c.isConvertedToOtherUnit()?c.unit():null;const d=e=>{const t=e.x*o.timeScale().width(),i=e.y*s.height()-40;return new Vt.Point(t,i)},u=(0,n.ensureNotNull)(e.firstValue());if(this._model.id()===this._clipboardData.modelId||!h){for(let e=0;e<this._clipboardData.geometry.length;++e){const t=d(this._clipboardData.geometry[e]),n=o.timeScale().coordinateToIndex(t.x),r=o.timeScale().normalizeBarIndex(n);if(h){const t=s.priceToCoordinate(i.points[e].price,u)+-40;r.price=s.coordinateToPrice(t,u)}else r.price=s.coordinateToPrice(t.y,u);i.points[e]=r}i.state.interval=o.mainSeries().interval()}return i.id=(0,fe.randomHashN)(6),i}}class bl extends st.UndoCommand{constructor(e,t,i,s){super(s),this._newSourcesCurrencies=new Map,this._oldSourcesCurrencies=new Map,this._showFade=!1,this._chartModel=e;const o=e.mainSeries();for(const e of t.seriesLikeSources()){if(!e.isVisible()||!e.isActingAsSymbolSource().value())continue;const t=i||(0,xt.symbolOriginalCurrency)((0,n.ensureNotNull)(e.symbolInfo()));this._newSourcesCurrencies.set(e.id(),t),this._oldSourcesCurrencies.set(e.id(),e.currency()),this._showFade=this._showFade||e===o&&e.currency()!==t}}redo(){this._applyCurrencies(this._newSourcesCurrencies)}undo(){
this._applyCurrencies(this._oldSourcesCurrencies)}_applyCurrencies(e){e.forEach(((e,t)=>{(0,n.ensureNotNull)(this._chartModel.dataSourceForId(t)).setCurrency(e)})),this._chartModel.selectionMacro((e=>{e.clearSelection()})),this._showFade&&this._chartModel.undoModel().loadingScreen().show(!0)}}class wl extends st.UndoCommand{constructor(e,t,i,s){super(s),this._newSourcesUnits=new Map,this._oldSourcesUnits=new Map,this._showFade=!1,this._chartModel=e;const o=e.mainSeries();for(const e of t.seriesLikeSources()){if(!e.isVisible()||!e.isActingAsSymbolSource().value())continue;const t=i||(0,xt.symbolOriginalUnit)((0,n.ensureNotNull)(e.symbolInfo()),this._chartModel.unitConversionEnabled());this._newSourcesUnits.set(e.id(),t),this._oldSourcesUnits.set(e.id(),e.unit()),this._showFade=this._showFade||e===o&&e.unit()!==t}}redo(){this._applyUnits(this._newSourcesUnits)}undo(){this._applyUnits(this._oldSourcesUnits)}_applyUnits(e){e.forEach(((e,t)=>{(0,n.ensureNotNull)(this._chartModel.dataSourceForId(t)).setUnit(e)})),this._chartModel.selectionMacro((e=>{e.clearSelection()})),this._showFade&&this._chartModel.undoModel().loadingScreen().show(!0)}}class Cl extends ia{constructor(e,t,i,s){super(e,t,s),this._sourcePaneRemoved=!1,this._targetPaneIndex=e.panes().indexOf(i)}redo(){const e=this._chartModel.panes()[this._initialPaneIndex],t=this._chartModel.panes()[this._targetPaneIndex],i=e!==t,s=this._targetPriceScale(t),o=(0,n.ensureNotNull)(this._chartModel.dataSourceForId(this._sourceId)),r=this._chartModel.children(o,!0,!0);for(const e of r)i?(this._chartModel.detachSource(e),t.addDataSource(e,s,!1)):t.move(e,s);i?(this._sourcePaneRemoved=this._chartModel.detachSource(o),t.addDataSource(o,s,!1)):t.move(o,s);const a=t.priceScalePosition(s);t.movePriceScale(s,a,this._targetPriceScaleIndex(o)),this._chartModel.fullUpdate()}undo(){this._sourcePaneRemoved&&this._chartModel.createPane(this._initialPaneIndex);const e=this._chartModel.panes()[this._initialPaneIndex],t=e!==this._chartModel.panes()[this._targetPaneIndex],i=(0,n.ensureNotNull)(this._chartModel.dataSourceForId(this._sourceId));let s=e.getPriceScaleById(this._initialPriceScaleId);null===s&&(s=e.createPriceScaleAtPosition(this._initialPriceScalePosition,this._initialPriceScaleIndex));const o=this._chartModel.children(i,!0,!0);for(const i of o)t?(this._chartModel.detachSource(i),e.addDataSource(i,s,!1)):e.move(i,s);t?(this._chartModel.detachSource(i),e.addDataSource(i,s,!1)):e.move(i,s);const r=(0,n.ensureNotNull)(i.priceScale());r.restoreState(this._originalPriceScaleState()),r.setHeight(e.height()),this._chartModel.fullUpdate()}}class Tl extends Cl{constructor(e,t,i,s,o){super(e,t,i,o),this._targetPriceScalePosition=s}_targetPriceScale(e){const t=e.createPriceScaleAtPosition(this._targetPriceScalePosition);return t.restoreState(this._newPriceScaleState("overlay"===this._targetPriceScalePosition)),t.setHeight(e.height()),t}_targetPriceScaleIndex(e){return e===this._chartModel.mainSeries()?0:void 0}}class Pl extends Cl{constructor(e,t,i,s,o){super(e,t,i,o),
this._targetPriceScaleId=s.id()}_targetPriceScale(e){return(0,n.ensureNotNull)(e.getPriceScaleById(this._targetPriceScaleId))}_targetPriceScaleIndex(e){}}class xl extends st.UndoCommand{constructor(e,t,i,s){super(e),this._charts=new Map,this._firstRedo=!0,this._creationTime=performance.now(),this._linkingGroupIndex=s.linkingGroupIndex().value(),this._charts.set(s,{sourceId:t.id(),newSymbolParams:i,prevSymbolParams:t.symbolParams(),showFade:this._showFade(t,s),chartWidget:s})}redo(){this._firstRedo||(0,it.muteLinkingGroup)(this._linkingGroupIndex,!0),this._charts.forEach((e=>{const t=this._symbolSource(e).setSymbolParams(e.newSymbolParams);e.showFade&&e.chartWidget.screen.show(!0,t)})),this._firstRedo||(0,it.muteLinkingGroup)(this._linkingGroupIndex,!1),this._firstRedo=!1}undo(){(0,it.muteLinkingGroup)(this._linkingGroupIndex,!0),this._charts.forEach((e=>{const t=this._symbolSource(e).setSymbolParams(e.prevSymbolParams);e.showFade&&e.chartWidget.screen.show(!0,t)})),(0,it.muteLinkingGroup)(this._linkingGroupIndex,!1)}canMerge(e){if(!(e instanceof xl)||e._linkingGroupIndex!==this._linkingGroupIndex||!this._containsMainSeriesOnly()||!e._containsMainSeriesOnly()||e._creationTime-this._creationTime>500)return!1;for(const[t]of e._charts)if(this._charts.has(t))return!1;return!0}merge(e){if(e instanceof xl)for(const[t,i]of e._charts)this._charts.set(t,i)}_showFade(e,t){return e===t.model().mainSeries()}_symbolSource(e){return(0,n.ensureNotNull)(e.chartWidget.model().model().dataSourceForId(e.sourceId))}_containsMainSeriesOnly(){for(const[e,t]of this._charts)if(t.sourceId!==e.model().mainSeries().id())return!1;return!0}}const Ml=new dt.TranslatedString("change symbol",a.t(null,void 0,i(35400)));class Il extends xl{constructor(e,t,i){super(Ml,e,{symbol:t,currency:null,unit:null},i),this._symbol=t}canMerge(e){return e instanceof Il&&e._symbol===this._symbol&&super.canMerge(e)}}var Al=i(90054);const Ll=(0,ne.getLogger)("Chart.ChartUndoModel"),kl=new dt.TranslatedString("paste indicator",a.t(null,void 0,i(1064)));class El extends st.UndoCommand{constructor(e,t,i){super(kl),this._sourceState=null,this._model=e,this._clipboardData=t,this._paneId=i}redo(){if(!this._sourceState){const e=(0,Al.default)(this._clipboardData.source);e.id=(0,fe.randomHashN)(6),this._sourceState=e}let e,t;e=this._paneId?(0,n.ensureNotNull)(this._model.paneForId(this._paneId)):this._sourceState.metaInfo.is_price_study?(0,n.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())):this._model.createPane();const i=!e.mainDataSource();this._sourceState.zorder=e.newStudyZOrder();const s=(0,n.ensureNotNull)(e.restoreStudy(this._sourceState,!1));i||(t=this._sourceState.metaInfo.is_price_study?t=this._model.mainSeries().priceScale():this._paneId?e.findSuitableScale(s):e.defaultPriceScale(),t!==s.priceScale()&&e.move(s,t)),(0,Ws.isStudy)(s)&&s.start()}undo(){if(null===this._sourceState)return void Ll.logError("This command was never executed - nothing to undo");const e=(0,n.ensureNotNull)(this._model.dataSourceForId(this._sourceState.id))
;this._model.removeSource(e)}state(){return this._sourceState}}class Dl extends st.UndoCommand{constructor(e,t,i,s,o){super(null,!1),this._model=e,this._paneA=t,this._paneB=i,this._prevStretchA=s,this._currStretchA=o}redo(){const e=this._paneA.stretchFactor()+this._paneB.stretchFactor();this._paneA.setStretchFactor(this._currStretchA),this._paneB.setStretchFactor(e-this._currStretchA),this._model.fullUpdate()}undo(){const e=this._paneA.stretchFactor()+this._paneB.stretchFactor();this._paneA.setStretchFactor(this._prevStretchA),this._paneB.setStretchFactor(e-this._prevStretchA),this._model.fullUpdate()}}const Bl=new dt.TranslatedString("move",a.t(null,void 0,i(98277)));class Vl extends st.UndoCommand{constructor(e,t,i,s){super(Bl,!1),this._endEvent=null,this._model=e,this._sourceId=t.id(),this._itemIndex=i,this._startEvent=s}move(e){this._endEvent=e,this._move(e)}hasChanges(){return null!==this._endEvent}undo(){this._move(this._startEvent)}redo(){this._move((0,n.ensureNotNull)(this._endEvent))}_move(e){const t=(0,n.ensureNotNull)(this._model.dataSourceForId(this._sourceId));(0,n.assert)(void 0!==t.moveItem,'The method "moveItem" is not defined'),t.moveItem&&t.moveItem(new Vt.Point(e.localX,e.localY),this._itemIndex,new To.EnvironmentState(e))}}class Rl extends st.UndoCommand{constructor(e){const{chartModel:t,studyMetaInfo:i,inputs:s,props:o,addAsOverlay:n,parentSources:r,preferredPriceScale:a,allowChangeCurrency:l,allowChangeUnit:c,paneSize:h,targetZOrder:d,studyId:u,targetScaleMode:_,undoText:p}=e;super(p??null),this._paneState=null,this._studyInserResult=null,this._additionalStudiesInsertResults=[],this._chartModel=t,this._studyMetaInfo=i,this._props=o,this._addAsOverlay=n,this._parentIds=r.map((e=>e.id())),this._inputs=s,this._targetZOrder=d,this._preferredPriceScale=a,this._allowChangeCurrency=l,this._allowChangeUnit=c,this._paneSize=h,this._studyId=u??null,this._targetScaleMode=_??null}redo(){const e=this._parentIds.map((e=>this._chartModel.dataSourceForId(e)));this._studyInserResult=this._chartModel.insertStudyWithParams(this._studyMetaInfo,this._inputs,this._targetZOrder,this._props,this._addAsOverlay,e,this._preferredPriceScale,this._allowChangeCurrency,this._allowChangeUnit,this._paneSize,this._targetScaleMode??void 0,this._studyId??void 0),this._studyInserResult.study.then((e=>{if(this._studyId=e.id(),e.childStudyByRebind().subscribe(null,(()=>(0,re.trackEvent)("SOS","Apply SOS","Rebind SOS"))),this._chartModel.setShouldBeSavedEvenIfHidden(!0),null!==this._paneState){(0,n.ensureNotNull)(this._chartModel.paneForSource(e)).restoreState({state:this._paneState,withData:!1,version:this._chartModel.version()}),this._paneState=null}}))}undo(){const e=(0,n.ensureNotNull)(this._studyInserResult),t=e.entityId();let i=null,s=null;if(null!==t){i=(0,n.ensureNotNull)(this._chartModel.dataSourceForId(t));const o=e.originalScaleMode();null!==o&&i.priceScale()?.setMode(o),(0,Lr.isSymbolSource)(i)&&i.symbolResolved().unsubscribeAll(this),s=(0,n.ensureNotNull)(this._chartModel.paneForSource(i)).state()}else e.cancel()
;this._studyInserResult?.cancel();for(const e of this._additionalStudiesInsertResults){const t=e.entityId();null!==t?this._chartModel.removeSource((0,n.ensureNotNull)(this._chartModel.dataSourceForId(t))):e.cancel()}this._additionalStudiesInsertResults=[],null!==i&&this._chartModel.removeSource(i)&&(this._paneState=s)}insertedStudy(){return(0,n.ensureNotNull)(this._studyInserResult)}_createCopiesOfNewFundamentalForAllStocks(e){}_createCopiesOfExistingFundamentalsForNewStock(e){}}class Nl extends st.UndoCommand{constructor(e,t,i,s){super(i),this._newMode=e,this._priceScaleId=t.id(),this._model=s,this._oldMode=t.mode()}redo(){this._applyMode(this._newMode)}undo(){this._applyMode(this._oldMode)}_applyMode(e){const t=this._findPriceScaleById();null!==t&&((0,yi.allowSavingDefaults)(!0),t.setMode(e),(0,yi.allowSavingDefaults)(!1),this._model&&(this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),this._model.lightUpdate()))}_findPriceScaleById(){const e=this._model.panes();for(let t=0;t<e.length;t++){const i=e[t].getPriceScaleById(this._priceScaleId);if(null!==i)return i}return null}}var Ol=i(90484),Fl=i(11417),Wl=(i(88145),i(66142));const Hl=["color-sky-blue-400","color-banana-yellow-700","color-deep-blue-500","color-grapes-purple-a700","color-iguana-green-500","color-minty-green-a600","color-ripe-red-a200","color-berry-pink-200","color-tv-blue-a100","color-tan-orange-a200","color-sky-blue-a400","color-deep-blue-a100","color-grapes-purple-400","color-iguana-green-a700","color-minty-green-200","color-ripe-red-200","color-berry-pink-a200","color-ripe-red-500","color-grapes-purple-500","color-deep-blue-400","color-tv-blue-a200","color-sky-blue-500","color-iguana-green-400","color-minty-green-400","color-banana-yellow-600","color-tan-orange-500","color-berry-pink-400","color-ripe-red-300","color-grapes-purple-300","color-deep-blue-300","color-tv-blue-300","color-sky-blue-300","color-iguana-green-300","color-minty-green-300","color-banana-yellow-400","color-tan-orange-300","color-berry-pink-300","color-tan-orange-a700"],zl=["color-berry-pink-a700","color-grapes-purple-a700","color-deep-blue-a400","color-iguana-green-a700","color-ripe-red-a400","color-minty-green-a400","color-berry-pink-a200","color-tv-blue-a100","color-tan-orange-a200","color-sky-blue-a400","color-deep-blue-a200","color-grapes-purple-a100","color-iguana-green-a400","color-ripe-red-a100"];class Ul{constructor(e,t=Hl){this._userDefaultUsed=!1,this._calcColorOffset=e,this._colors=t}getColor(e,t=!1){const i=this._calcColorOffset();if(0===i&&(this._userDefaultUsed=!1),0===i&&!t)return this._userDefaultUsed=!0,e;const s=this._colors[(i-(this._userDefaultUsed?1:0))%this._colors.length],o=Rt.colorsPalette[s],n=(0,Ro.isHexColor)(e)?1:(0,Nt.parseRgba)(e)[3];return(0,Ro.generateColor)(o,(0,Ro.alphaToTransparency)(n))}}class jl{constructor(e,t){this._calcColorOffset=e,this._modelStartOffset=t}getColor(e){const t=this._calcColorOffset();if((0,Ro.isHexColor)(e)){const i=(0,Nt.parseRgb)(e);return(0,Nt.rgbToHexString)((0,Nt.shiftRgb)(i,t,this._modelStartOffset))}{
const i=(0,Nt.parseRgba)(e);return(0,Nt.rgbaToString)((0,Nt.shiftRgba)(i,t,this._modelStartOffset))}}}class Gl{constructor(e){this._rotators=new WeakMap,this._calcDefaultColorsOffset=e=>{const t=(0,Ws.useSameColorRotationComparator)(e);return this._chartModel.dataSources().filter((i=>(0,Ws.isStudy)(i)&&t(e,i.metaInfo()))).length},this._chartModel=e}getColorRotator(e){if(this._rotators.has(e)){const t=this._rotators.get(e);if(void 0!==t)return t}const t=this._createColorRotator(e);return this._rotators.set(e,t),t}_createColorRotator(e){const t=()=>this._calcDefaultColorsOffset(e);switch((0,Ws.studyColorRotationMode)(e)){case"sexyColors":return new Ul(t,zl);case"loop":return new Ul(t);case"shift":return new jl(t,this._chartModel.getStudyShiftColorStartOffset());case null:case"noRotations":return null}}}function ql(e){return(0,zs.isLineTool)(e)&&e.boundToSymbol()||!1}class $l{constructor(){this._items=[],this._set=new Set,this._dataSourcesCache=null,this._customSourcesCache=null,this._lineSourcesCache=null}isEmpty(){return 0===this._items.length}add(e){if(this._items.length>0&&!ql(this._items[0])&&this.clear(),ql(e)){const t=(0,Pt.lowerbound)(this._items,e,((e,t)=>e.zorder()<t.zorder()));this._items.splice(t,0,e)}else this.clear(),this._items=[e];this._set.add(e),this._invalidateCache()}canBeAddedToSelection(e){return 0===this._items.length||ql(this._items[0])&&ql(e)}isSelected(e){return this._set.has(e)}allSources(){return this._items.slice(0)}dataSources(){return null===this._dataSourcesCache&&(this._dataSourcesCache=this._items.filter(Po.isDataSource)),this._dataSourcesCache}lineDataSources(){return null===this._lineSourcesCache&&(this._lineSourcesCache=this._items.filter(zs.isLineTool)),this._lineSourcesCache}customSources(){return null===this._customSourcesCache&&(this._customSourcesCache=this._items.filter((e=>!(0,Po.isDataSource)(e)))),this._customSourcesCache}checkLineToolSelection(){this._items.forEach((e=>(0,zs.isLineTool)(e)&&e.calcIsActualSymbol())),this._items=this._items.filter((e=>!(0,zs.isLineTool)(e)||e.isActualSymbol())),this._invalidateCache()}remove(e){this._items=this._items.filter((t=>t!==e)),this._set.delete(e),this._invalidateCache()}clear(){this._items=[],this._set.clear(),this._invalidateCache()}_invalidateCache(){this._customSourcesCache=null,this._dataSourcesCache=null,this._lineSourcesCache=null}}var Kl,Yl,Zl=i(23502);!function(e){e[e.BorderSize=1]="BorderSize"}(Kl||(Kl={})),function(e){e[e.AdditionalInnerPadding=4]="AdditionalInnerPadding",e[e.HorzPadding=4]="HorzPadding",e[e.VertPadding=2.5]="VertPadding",e[e.LineSpacing=2]="LineSpacing"}(Yl||(Yl={}));class Xl{constructor(e){this._rendererOptions={borderSize:1,additionalPaddingInner:0,fontSize:NaN,font:"",color:"",paneBackgroundColor:"",paddingBottom:0,paddingInner:0,paddingOuter:0,paddingTop:0,lineSpacing:0},this._chartModel=e}options(){const e=this._rendererOptions,t=this._chartModel.properties().childs(),i=t.scalesProperties.childs().fontSize.value();return e.fontSize!==i&&(e.fontSize=i,e.font=(0,si.makeFont)(i,m.CHART_FONT_FAMILY,""),
e.paddingTop=i/12*2.5,e.paddingBottom=i/12*2.5,e.paddingInner=i/12*4,e.additionalPaddingInner=i/12*4,e.paddingOuter=i/12*4,e.lineSpacing=i/12*2),e.color=t.scalesProperties.childs().textColor.value(),e.paneBackgroundColor=t.paneProperties.childs().background.value(),this._rendererOptions}}var Jl=i(43229),Ql=i(57511);const ec=(0,yi.extractThemedColors)(ms.lightTheme.content.sessions,ms.darkTheme.content.sessions);const tc=["graphics","sessionHighlight.backgrounds.preMarket.visible","sessionHighlight.backgrounds.preMarket.available","sessionHighlight.backgrounds.postMarket.visible","sessionHighlight.backgrounds.postMarket.available","sessionHighlight.backgrounds.electronic.visible","sessionHighlight.backgrounds.electronic.available","sessionHighlight.vertLines.sessBreaks.available"];class ic extends yi.DefaultProperty{constructor(e){super({defaultName:"sessions",themedColors:ec,excludedDefaultsKeys:[...tc],excludedStateKeys:[...tc],excludedTemplateKeys:[...tc]}),this._symbolInfo=e,this._symbolInfo.subscribe((()=>this._updateGraphicsProps())),this.hasChild("graphics")||this.addProperty("graphics",{}),this.merge({sessionHighlight:{vertlines:{sessBreaks:{available:!0}},backgrounds:{preMarket:{visible:!0,available:!0},postMarket:{visible:!0,available:!0},electronic:{visible:!0,available:!0},outOfSession:{visible:!0,available:!0}}}}),this._updateGraphicsProps(),this.childs().sessionHighlight.subscribe(this,(()=>{this._updateGraphicsProps()}))}destroy(){this._symbolInfo.release(),super.destroy()}restoreState(e){const t=e.properties;!function(e){const t=e,i="graphics"in e?e.graphics.backgrounds:void 0;if(void 0!==i){const e=(0,n.ensureDefined)(i.outOfSession);e.color===Ql.sessionsPreferencesDefault.sessionHighlight.backgrounds.outOfSession.color||"postMarket"in i?(t.sessionHighlight=t.sessionHighlight??{},t.sessionHighlight.backgrounds=i):(t.sessionHighlight=t.sessionHighlight??{},t.sessionHighlight.backgrounds={...t.sessionHighlight?.backgrounds??{},postMarket:{color:e.color,transparency:e.transparency,visible:!0,available:!0},preMarket:{color:e.color,transparency:e.transparency,visible:!0,available:!0}})}const s="graphics"in e?e.graphics.vertlines:void 0;s&&(t.sessionHighlight??={},t.sessionHighlight.vertlines=s),(0,yi.cleanUpStateKeys)(t,tc)}(t),"graphics"in e.properties&&((0,Qe.default)(e.properties.sessionHighlight,e.properties.graphics),delete e.properties.graphics),this.mergeAndFire(t),this.removeDuplicateProperties()}loadThemeState(e){"graphics"in e&&((0,Qe.default)(e.sessionHighlight,e.graphics),delete e.graphics),this.mergeAndFire(e)}removeDuplicateProperties(){this.hasChild("properties")&&(this.removeProperty("properties"),(0,yi.allowSavingDefaults)(!0),this.fireChanged(),(0,yi.allowSavingDefaults)(!1))}_userSettings(){const e=super._userSettings();return e&&!e.sessionHighlight&&(e.sessionHighlight=e.graphics),delete e?.graphics,e}_updateGraphicsProps(){const e=this._symbolInfo.value();e&&(this.childs().graphics.mergeAndFire(this.childs().sessionHighlight.state()),function(e){
const t=e.subsessions?.filter((e=>!e.private)).map((e=>e.id))??[];return"futures"===e.type&&t.includes("regular")&&t.includes("us_regular")}(e)&&((0,n.ensureDefined)(this.childs().graphics.childs().backgrounds).childs().preMarket.mergeAndFire(this.childs().sessionHighlight.childs().backgrounds.childs().electronic.state()),(0,n.ensureDefined)(this.childs().graphics.childs().backgrounds).childs().postMarket.mergeAndFire(this.childs().sessionHighlight.childs().backgrounds.childs().electronic.state())))}}class sc extends Jl.AsyncResourceWrapper{constructor(e,t,i){super(e,(e=>e.destroy())),this._sessionsStateData=null,this._model=t,this._properties=i,t.mainSeries().dataEvents().symbolResolved().subscribe(this,this._updateVisibleOfPreAndPostMarketBackground),this._updateVisibleOfPreAndPostMarketBackground(),e.then((e=>{!this._destroyed&&this._sessionsStateData&&(e.restoreStateData(this._sessionsStateData),this._sessionsStateData=null)}))}destroy(){this._model.mainSeries().dataEvents().symbolResolved().unsubscribeAll(this),super.destroy()}properties(){return this._properties}applyOverrides(e){(0,h.applyPropertiesOverrides)(this._properties.childs().sessionHighlight,void 0,!1,e,"sessions");const t=this.get();t&&this._model.updateSource(t)}state(e){const t={properties:this._properties.state()};return e&&(t.data=this.get()?.stateData()??this._sessionsStateData??void 0),t}restoreState(e,t){if(e.oldState&&(e=function(e,t){const i={properties:{graphics:e.state.graphics}};return void 0!==e.data&&void 0!==e.metaInfo&&t&&(i.data={metaInfo:e.metaInfo,graphics:e.data.graphics}),i}(e,t)),this._properties.restoreState(e),this._updateVisibleOfPreAndPostMarketBackground(),this._sessionsStateData=null,void 0!==e.data&&t){const t=this.get();t?t.restoreStateData(e.data):this._sessionsStateData=e.data}}_updateVisibleOfPreAndPostMarketBackground(){const e=this._model.mainSeries().symbolInfo();if(e){const t=this._properties.childs().sessionHighlight.childs(),{preMarket:i,postMarket:s,electronic:o,outOfSession:n}=t.backgrounds.childs(),{sessBreaks:r}=t.vertlines.childs(),a=e.subsession_id,l=a&&(0,xt.isRegularSessionId)(a,e),c=(0,xt.symbolHasPreOrPostMarket)(e),h=!1;i.childs().available.setValue(c&&!l),s.childs().available.setValue(c&&!l),o.childs().available.setValue(h&&!l),n.childs().available.setValue((c||h)&&!l),r.childs().available.setValue(!0)}}}var oc=i(55114);const nc="symbolWatermark",rc={ticker:!1,interval:!1,description:!1,custom:!1,replay:!0,color:""},ac="rgba(80, 83, 94, 0.25)",lc=["rgba(80, 83, 94, 0.20)","rgba(80, 83, 94, 0.30)"];function cc(){const e=d.getJSON(nc)||{};return{...rc,...hc(e)}}function hc(e){const{color:t,visibility:i,...s}=e,o={...s};return void 0!==i&&(o.ticker=s.ticker??i,o.interval=s.interval??i,o.description=s.description??i,o.custom=s.custom??i),(0,et.default)(t)&&t!==ac&&(o.color=t),o}class dc extends Ps.Property{constructor(e,t){super(e),this._defaultColors=t}value(e){const t=super.value();return void 0===e||t&&t.length>0?t:this._getDefaultColor(e)}_getDefaultColor(e){const[t,i]=this._defaultColors
;return e===$s.StdTheme.Light?t:i}}const uc=(0,s.default)((()=>{const{color:e,...t}=cc(),i=new Ps.Property(t,(0,oc.createPropertySchema)(rc));return i.addChild("color",new dc(e,lc)),d.onSync.subscribe(null,(()=>i.mergeAndFire(cc()))),i.subscribe(null,(()=>d.setJSON(nc,i.state()))),i}));var _c=i(59332),pc=i(19e3),mc=i(75641),gc=i(88987);const fc=768;var yc,vc=i(20820);!function(e){e[e.LineOffset=4]="LineOffset",e[e.LinePadding=8]="LinePadding"}(yc||(yc={}));class Sc extends vc.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._widthCache=new Qt.TextWidthCache}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){if(!this._data)return;const{lines:t,color:i}=this._data,{context:s,mediaSize:{width:o,height:n}}=e;let r=0;const a=[],l=t.filter((e=>!!e.text)),c=l.length;for(let e=0;e<c;e++){const t=l[e],{font:i,lineHeight:n}=bc(t,0===e,o<fc),{width:c,paddingRight:h}=wc(t.icon,0===e,o<fc);s.font=i;const d=this._widthCache.measureText(s,t.text)+c+h+16,u=d>o?o/d:1;a.push(u),r+=n*u+4}let h=Math.max((n-r)/2,0);s.fillStyle=i;for(let e=0;e<c;e++){const t=l[e],i=a[e],{font:n,lineHeight:r,vertOffset:c}=bc(t,0===e,o<fc);try{s.save(),s.font=n,s.textBaseline="top",s.textAlign="left";const{icon:a,text:l}=t,{width:d,paddingRight:u,path:_}=wc(a,0===e,o<fc),p=this._widthCache.measureText(s,l)+d+u;if(s.translate((o-i*p)/2,h),s.scale(i,i),_){const e={x:0,y:(r-d)/2};try{s.translate(e.x,e.y),s.fill(_,"evenodd")}finally{s.translate(-e.x,-e.y)}}s.translate(d+u,0),s.fillText(l,0,c),h+=r*i+4}finally{s.restore()}}}}function bc(e,t,i){return"getFontMetrics"in e?e.getFontMetrics(t,i):e}function wc(e,t,i){return void 0===e?Cc:(0,gc.default)(e)?e(t,i):e}const Cc={width:0,paddingRight:0},Tc=new Path2D("M28 54C42.3594 54 54 42.3594 54 28C54 13.6406 42.3594 2 28 2C13.6406 2 2 13.6406 2 28C2 42.3594 13.6406 54 28 54ZM26 16V28V40L14 28L26 16ZM26 28L38 40V16L26 28Z"),Pc=Tc,xc=(0,$t.scalePath2D)(Tc,.785714286),Mc=(0,$t.scalePath2D)(Tc,.5),Ic="Sans-serif";function Ac(e,t){return e.value(t)}class Lc{constructor(e,t){this._renderer=new Sc,this._invalidated=!0,this._model=e,this._watermark=t}update(){this._invalidated=!0}renderer(){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){const{ticker:e,interval:t,description:i,custom:s,replay:o}=this._watermark.properties().state(),n=this._model.backgroundTheme().value(),r=this._model.mainSeries(),a=r.aliasSymbolInfo(),l=!1,c=this._model.watermarkContentProvider().value();if(!a||!(c?s:e||t||i||l))return void this._renderer.setData(null);if(c){const e=c({symbolInfo:a,interval:r.interval()}),t=e?.map((e=>({text:e.text,font:(0,si.makeFont)(e.fontSize,Ic),lineHeight:e.lineHeight,vertOffset:e.vertOffset})));return void this._renderer.setData({color:Ac(this._watermark.properties().childs().color,n),lines:t??[]})}let h=a.name;if(/QUANDL/.test(a.exchange)){const e=h.split(/\//);e.length&&(h=e[e.length-1])}const d={description:a.description,short_description:a.short_description,pro_name:a.pro_name,short_name:a.name,local_description:a.local_description,
language:a.language},u=[e?h:null,t?(0,mc.translatedIntervalString)(r.interval()):null].filter(tt.notNull),_=[{text:h?u.join(", "):""},{text:i&&(0,pc.getTranslatedSymbolDescription)(d)||""},{text:"",icon:kc}].filter((e=>e.text.length>0)).map((({text:e,icon:t})=>({text:e,icon:t,getFontMetrics:Ec})));this._renderer.setData({color:Ac(this._watermark.properties().childs().color,n),lines:_})}}const kc=(0,_c.default)((function(e,t){return t?e?{path:xc,width:44,paddingRight:12}:{path:Mc,width:28,paddingRight:8}:e?{path:Pc,width:56,paddingRight:16}:{path:Mc,width:28,paddingRight:12}}),((e,t)=>`${e}-${t}`));const Ec=(0,_c.default)((function(e,t){const[i,s,o]=Bc[t?e?2:3:e?0:1];return{font:(0,si.makeFont)(i,Ic),lineHeight:s,vertOffset:o}}),((e,t)=>`${e}-${t}`));var Dc;!function(e){e[e.FirstLine=0]="FirstLine",e[e.OtherLines=1]="OtherLines",e[e.FirstLineMobile=2]="FirstLineMobile",e[e.OtherLinesMobile=3]="OtherLinesMobile"}(Dc||(Dc={}));const Bc={0:[80,80,6],1:[36,44,8],2:[48,48,4],3:[28,36,6]},Vc="symbolWatermark";class Rc extends bi.DataSource{constructor(e){super(),this._updateSource=()=>{this._model.updateSource(this)},this._model=e,this._properties=uc(),(0,h.applyDefaultsOverrides)(this._properties,void 0,!1,Vc),this._properties.subscribe(this,this._updateSource),this._model.backgroundTheme().subscribe(this._updateSource),this._paneView=new Lc(e,this)}destroy(){this._model.backgroundTheme().unsubscribe(this._updateSource),this._properties.unsubscribe(this,this._updateSource),super.destroy()}model(){return this._model}name(){return"watermark"}properties(){return this._properties}restorePropertiesDefaults(){uc().mergeAndFire(rc)}applyOverrides(e){(0,h.applyPropertiesOverrides)(this._properties,void 0,!1,function(e){const{visibility:t,...i}=e,s={...i};return void 0!==t&&(s.ticker=t,s.interval=t,s.description=t,s.custom=t),s}(e),Vc)}paneViews(){return[this._paneView]}updateAllViews(e){super.updateAllViews(e),this._paneView.update()}contextMenuStatName(){return"WatermarkContextMenu"}}var Nc,Oc=i(38486),Fc=i(79603);!function(e){e[e.StepForChangeValue=.1]="StepForChangeValue",e[e.MinValue=1e-7]="MinValue",e[e.MaxValue=99999999]="MaxValue"}(Nc||(Nc={}));class Wc extends Fc.PropertyBase{constructor(e){super(),this._model=e}destroy(){this._listeners.destroy()}getStepChangeValue(){return.1}getMinValue(){return 1e-7}getMaxValue(){return 99999999}value(){return this._model.mainSeriesScaleRatio()}setValue(e,t){(e!==this.value()||t)&&(this._model.setMainSeriesScaleRatio(e),this.fireChanged())}setValueSilently(e){e!==this.value()&&this._model.setMainSeriesScaleRatio(e)}state(){return null}clone(){return new Wc(this._model)}storeStateIfUndefined(){return!0}weakReference(){return(0,Oc.weakReference)(this)}ownership(){return(0,Oc.ownership)(this)}}var Hc=i(18113),zc=i(28450);class Uc{constructor(e,t){this._map1=new Map,this._map2=new Map,this._getter1=e,this._getter2=t}add(e){const t=this._getter1(e),i=this._getter2(e);this._map1.set(t,e),this._map2.set(i,t)}getByKey1(e){return this._map1.get(e)??null}getByKey2(e){const t=this._map2.get(e)
;return void 0===t?null:this._map1.get(t)??null}removeByKey1(e){const t=this._map1.get(e);void 0!==t&&(this._map1.delete(e),this._map2.delete(this._getter2(t)))}removeByKey2(e){const t=this._map2.get(e);void 0!==t&&(this._map2.delete(e),this._map1.delete(t))}}var jc,Gc=i(27593),qc=i(6652);function $c(e,t,i){return i.hasDataSource(t)?Zc(t,i)===e:!!i.isMainPane().value()&&Zc(i.model().mainSeries(),i)===e}!function(e){e.Trading="trading",e.Drawing="drawing",e.DrawingForAllSymbols="drawingsForAllSymbols",e.Phantom="phantom",e.RestRowSources="restRowSources",e.LegendViewSources="legendViewSources",e.LeftPriceScale="leftPriceScale",e.RightPriceScale="rightPriceScale",e.OverlayPriceScale="overlayPriceScale",e.MultipaneSources="multipane",e.AllWithoutMultipane="allWithoutMultipane",e.AllWithoutMultipaneWithHidden="allWithoutMultipaneWithHidden",e.PlotSource="plotSource",e.ObjectTree="objectTree",e.HitTest="hitTest",e.General="general",e.Price="price",e.ExceptSpecial="exceptSpecial",e.AllSorted="allSorted",e.VisibleSorted="visibleSorted"}(jc||(jc={}));const Kc=new Map([["price",e=>(0,An.isPriceDataSource)(e)],["trading",e=>(0,zs.isTrading)(e)],["drawing",e=>(0,zs.isLineTool)(e)&&!(0,zs.isTrading)(e)&&!e.isPhantom()],["drawingsForAllSymbols",e=>(0,zs.isLineTool)(e)&&!(0,zs.isTrading)(e)&&!e.isPhantom()],["phantom",e=>(0,zs.isLineTool)(e)&&e.isPhantom()],["restRowSources",e=>!(0,zs.isLineTool)(e)&&!(0,zs.isTrading)(e)],["legendViewSources",(e,t)=>t.hasDataSource(e)&&((0,An.isPriceDataSource)(e)||(0,Us.isStudyLineTool)(e))],["leftPriceScale",$c.bind(null,"left")],["rightPriceScale",$c.bind(null,"right")],["overlayPriceScale",$c.bind(null,"overlay")],["multipane",(e,t)=>!t.hasDataSource(e)],["allWithoutMultipane",(e,t)=>t.hasDataSource(e)],["allWithoutMultipaneWithHidden",(e,t)=>t.hasDataSource(e)],["plotSource",(e,t)=>(0,qc.isSeries)(e)||(0,Ws.isStudy)(e)&&t.hasDataSource(e)&&!e.isSpeciallyZOrderedSource()],["objectTree",(e,t)=>{if((0,zs.isLineTool)(e)){const i=e.targetSignature().value();if(null!==i)return t.hasDataSourceWithSignature(i)}return t.hasDataSource(e)}]]),Yc=new Map([["price","visibleSorted"],["trading","visibleSorted"],["drawing","visibleSorted"],["drawingsForAllSymbols","allSorted"],["phantom","visibleSorted"],["restRowSources","visibleSorted"],["legendViewSources","visibleSorted"],["leftPriceScale","visibleSorted"],["rightPriceScale","visibleSorted"],["overlayPriceScale","visibleSorted"],["multipane","visibleSorted"],["allWithoutMultipane","visibleSorted"],["allWithoutMultipaneWithHidden","allSorted"],["plotSource","visibleSorted"],["objectTree","visibleSorted"]]);function Zc(e,t){const i=e.priceScale();return null===i?"overlay":t.priceScalePosition(i)}function Xc(e){let t=null;return{sources:e,hasSource:i=>(null===t&&(t=new Map(e.map((e=>[e.id(),e])))),t.has(i.id()))}}class Jc{constructor(e){this._groupedSources=new Map,this._sources=null,this._pane=e}clear(){this._groupedSources.clear(),this._sources=null}destroy(){this.clear()}all(){return this._groupedSources.has("visibleSorted")||this._sortSources(),(0,
n.ensureDefined)(this._groupedSources.get("visibleSorted")).sources}allIncludingHidden(){return this._groupedSources.has("allSorted")||this._sortSources(),(0,n.ensureDefined)(this._groupedSources.get("allSorted")).sources}allWithoutMultipane(){return this._getSourcesByGroupType("allWithoutMultipane")}allWithoutMultipaneWithHidden(){return this._getSourcesByGroupType("allWithoutMultipaneWithHidden")}objectTreeSources(){return this._getSourcesByGroupType("objectTree")}hasObjectTreeSource(e){return this._getGroupedSourcesByGroupType("objectTree").hasSource(e)}allExceptSpecialSources(){if(!this._groupedSources.has("exceptSpecial")){const e=this.allIncludingHidden().filter((e=>!e.isSpeciallyZOrderedSource()));this._groupedSources.set("exceptSpecial",Xc(e))}return(0,n.ensureDefined)(this._groupedSources.get("exceptSpecial")).sources}tradingSources(){return this._getSourcesByGroupType("trading")}priceSources(){return this._getSourcesByGroupType("price")}plotSources(){return this._getSourcesByGroupType("plotSource")}lineSources(){return this._getSourcesByGroupType("drawing")}hasLineSource(e){return this._getGroupedSourcesByGroupType("drawing").hasSource(e)}lineSourcesForAllSymbols(){return this._getSourcesByGroupType("drawingsForAllSymbols")}phantomSources(){return this._getSourcesByGroupType("phantom")}allExceptLineAndTradingSources(){return this._getSourcesByGroupType("restRowSources")}hitTestSources(){if(!this._groupedSources.has("hitTest")){const e=this.allExceptLineAndTradingSources().concat(this.lineSources());this._groupedSources.set("hitTest",Xc((0,vi.sortSources)(e,this._pane)))}return(0,n.ensureDefined)(this._groupedSources.get("hitTest")).sources}generalSources(){if(!this._groupedSources.has("general")){const e=this.allExceptLineAndTradingSources().concat(this.lineSources());this._groupedSources.set("general",Xc((0,vi.sortSources)(e,this._pane)))}return(0,n.ensureDefined)(this._groupedSources.get("general")).sources}leftPriceScalesSources(){return this._getSourcesByGroupType("leftPriceScale")}rightPriceScalesSources(){return this._getSourcesByGroupType("rightPriceScale")}overlayPriceScaleSources(){return this._getSourcesByGroupType("overlayPriceScale")}multipaneSources(){return this._getSourcesByGroupType("multipane")}legendViewSources(){return this._getSourcesByGroupType("legendViewSources")}_getSourcesByGroupType(e){return this._getGroupedSourcesByGroupType(e).sources}_getGroupedSourcesByGroupType(e){const t=(0,n.ensureDefined)(Yc.get(e));return this._groupedSources.has(t)?this._groupedSources.has(e)||this._groupSources(e):(this._sortSources(),this._groupSources(e)),(0,n.ensureDefined)(this._groupedSources.get(e))}_sortSources(){null===this._sources&&(this._sources=this._pane.dataSources());const e=this._pane.model().multiPaneSources(this._pane),t=(0,vi.sortSources)(this._sources.concat(e),this._pane),i=t.filter((e=>!(0,zs.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()&&e.isActualUnit()));this._groupedSources.set("allSorted",Xc(t)),this._groupedSources.set("visibleSorted",Xc(i))}_groupSources(e){
const t=(0,n.ensureDefined)(Yc.get(e)),i=Kc.get(e);if(void 0!==i){const s=(0,n.ensureDefined)(this._groupedSources.get(t)).sources.filter((e=>i(e,this._pane)));this._groupedSources.set(e,Xc(s))}}}var Qc=i(24062),eh=i(52945);function th(e,t,i){const s=(0,xt.symbolUnitConvertibleGroupsIfExist)(e,!0);if(null!==s)return s;const o=i.unitGroupById(t);return null===o?[]:[o]}function ih(e,t,i,s){let o=null;if(i.unitConversionEnabled()&&(0,Lr.isSymbolSource)(e)){const n=i.availableUnits(),r=t.unit(n),a=e.unit(),l=null===a?[]:th(e.symbolInfo(),a,n);null!==r&&null!==r.selectedUnit&&!r.allUnitsAreOriginal&&r.selectedUnit!==a&&(s&&null===a||null!==a&&n.convertible(a,l))&&(o=r.selectedUnit)}return o}var sh=i(60521);function oh(e,t,i){const s=e.div(t).toNumber();return Math.abs(Math.round(s)-s)<i}const nh=[2,5],rh=[5,2];class ah{constructor(e,t,i){if(this._base=e,this._integralDividers=t,(0,fo.isBaseDecimal)(e))this._fractionalDividers=[2,2.5,2];else{this._fractionalDividers=[];const e=i?nh:rh;for(let t=this._base;1!==t;){if(t%e[0]==0)this._fractionalDividers.push(e[0]),t/=e[0];else{if(t%e[1]!=0)throw new Error("unexpected base");this._fractionalDividers.push(e[1]),t/=e[1]}if(this._fractionalDividers.length>100)throw new Error("something wrong with base")}}}tickSpan(e,t,i){const s=0===this._base?0:1/this._base,o=Math.min(1e-14,(e-t)/1e3);let n=Math.pow(10,Math.max(0,Math.ceil((0,fo.log10)(e-t))));if(!isFinite(n))return 1e305;let r=0,a=this._integralDividers[0];for(;;){const e=(0,fo.greaterOrEqual)(n,s,o)&&n>s+o,t=(0,fo.greaterOrEqual)(n,i*a,o),l=(0,fo.greaterOrEqual)(n,1,o),c=new sh.Big(n).div(a),h=0===s||oh(c,s,o);if(!(e&&t&&l&&h))break;n=c.toNumber(),a=this._integralDividers[++r%this._integralDividers.length]}if(n<=s+o&&(n=s),n=Math.max(1,n),this._fractionalDividers.length>0&&(0,fo.equal)(n,1,o))for(r=0,a=this._fractionalDividers[0];;){const e=(0,fo.greaterOrEqual)(n,i*a,o)&&n>s+o,t=new sh.Big(n).div(a),l=0===s||oh(t,s,o);if(!e||!l)break;n=t.toNumber(),a=this._fractionalDividers[++r%this._fractionalDividers.length]}return n}}class lh{constructor(e,t,i,s){this._marks=null,this._priceScale=e,this._base=t,this._coordinateToLogicalFunc=i,this._logicalToCoordinateFunc=s}base(){return this._base}setBase(e){if(e<0)throw new Error("base < 0");this._base=e}tickSpan(e,t,i=0){if(e<t)throw new Error("high < low");const s=this._priceScale.height(),o=this._tickMarkHeight(),n=(e-t)*o/s,r=[new ah(this._base,[2,2.5,2],!0),new ah(this._base,[2,2,2.5],!0),new ah(this._base,[2.5,2,2],!0),new ah(this._base,[2,2.5,2],!1),new ah(this._base,[2,2,2.5],!1),new ah(this._base,[2.5,2,2],!1)].reduce(((s,o)=>{const r=o.tickSpan(e,t,n);return r>i?Math.min(r,s):s}),1/0);return r>0&&isFinite(r)?r:e-t}rebuildTickMarks(){this._marks=null}marks(){return null===this._marks&&(this._marks=this._rebuildTickMarksImpl()),this._marks}_fontHeight(){return this._priceScale.fontSize()}_tickMarkHeight(){return Math.ceil(2.5*this._fontHeight())}_rebuildTickMarksImpl(){const e=this._priceScale,t=[],i=e.mainSource();if(e.isEmpty()||!e.hasCalculatedPriceRange()||null===i)return t
;let s=i.firstValue();null===s&&(s=0);const o=e.height(),n=this._coordinateToLogicalFunc(o-1,s),r=this._coordinateToLogicalFunc(0,s),a=Math.max(n,r),l=Math.min(n,r);if(a===l)return t;let c=this.tickSpan(a,l),h=a%c;h+=h<0?c:0;const d=a>=l?1:-1;let u=null;const _=e.formatter();let p=NaN;for(let i=a-h;i>l;i-=c){i===p&&(c=this.tickSpan(a,l,c)),p=i;const o=this._logicalToCoordinateFunc(i,s);null!==u&&Math.abs(o-u)<this._tickMarkHeight()||(t.push({coord:o,label:_.format(i)}),u=o,e.isLog()&&(c=this.tickSpan(i*d,l)))}return t}}var ch=i(67563),hh=i(56265);const dh=l.enabled("hide_price_scale_if_all_sources_hidden"),uh=(0,hh.getPercentageFormatter)(),_h=new ch.PriceFormatter({priceScale:100,minMove:1}),ph={autoScale:!0,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,log:!1,logDisabled:!1,alignLabels:!0,isInverted:!1,indexedTo100:!1};class mh{constructor(e,t){this._marksCache=null,this._onMarksChanged=new ae.Delegate,this.m_dataSources=[],this._sourcesForAutoscale=null,this._sourcesThatAffectVisibility=[],this._hasSeries=!1,this._studiesCount=0,this._drawingCount=0,this._seriesLikeSources=[],this._priceDataSources=[],this._mainSource=null,this._lastSourceRemoved=new ae.Delegate,this._scaleSeriesOnly=!1,this._invalidatedForRange={isValid:!0,visibleBars:null},this._priceRange=null,this._hasCalculatedPriceRange=!1,this._logFormula=(0,eh.logFormulaForBase)(null),this.m_height=0,this._margins={top:0,bottom:0},this._correctedMarginsCache=null,this._topPixelMargin=0,this._bottomPixelMargin=0,this._internalHeightCache=null,this._internalHeightChanged=new ae.Delegate,this._priceRangeSnapshot=null,this._scrollStartPoint=null,this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null,this._recalculatePriceRangeOnce=!1,this._cachedOrderedSoruces=null,this._scaleStartPoint=null,this._twoPointsScaleStartPosition=null,this._maxPriceRange=null,this._minPriceRange=null,this._priceRangeChanged=new ae.Delegate,this._modeChanged=new ae.Delegate,this._sourcesToUpdateViews=null,this._markBuilder=new lh(this,100,this._coordinateToLogical.bind(this),this._logicalToCoordinate.bind(this)),this._formatter=null,this._resetScaleAvailable=new O.WatchedValue(!1),this._id="",this._isVisible=new O.WatchedValue(!0),t=Object.assign({},ph,t),this._properties=new Ps.Property(t),this._boundOnSourceIsActingAsSymbolSourceChanged=this._onSourceIsActingAsSymbolSourceChanged.bind(this),this._scalesProperties=e,this._properties.childs().isInverted.subscribe(this,this._onIsInvertedChanged),this._properties.subscribe(null,(()=>{const e=this.mainSource();if(e&&e.model()){const t=e.model().paneForSource(e);t&&e.model().updatePane(t)}})),this._scalesProperties.subscribe(this,(()=>{this._marksCache=null})),this._properties.childs().lockScale.subscribe(this,this._updateResetAvailableValue),this._properties.childs().autoScale.subscribe(this,this._updateResetAvailableValue),this._updateResetAvailableValue(),this.setId((0,fe.randomHash)())}id(){return this._id}setId(e){this._id=e}isLog(){return this._properties.childs().log.value()}
isPercentage(){return this._properties.childs().percentage.value()}isInverted(){return this._properties.childs().isInverted.value()}isIndexedTo100(){return this._properties.childs().indexedTo100.value()}isAutoScale(){return this._properties.childs().autoScale.value()&&!this.isLockScale()}isLockScale(){return this._properties.childs().lockScale.value()}isRegular(){return!this.isPercentage()&&!this.isLog()&&!this.isIndexedTo100()}isScaleSeriesOnly(){return this._scaleSeriesOnly}properties(){return this._properties}height(){return this.m_height}setHeight(e){this.m_height!==e&&(this.m_height=e,this._invalidateInternalHeightCache(),this._marksCache=null)}internalHeight(){if(this._internalHeightCache)return this._internalHeightCache;const e=this.height()-this.topPixelMargin()-this.bottomPixelMargin();return this._internalHeightCache=e,e}fontSize(){return this._scalesProperties.childs().fontSize.value()}priceRange(){return this._makeSureItIsValid(),this._priceRange}setPriceRange(e,t,i){if(!(e instanceof Qc.PriceRange))throw new TypeError("incorrect price range");const s=this._priceRange;if(!t&&Qc.PriceRange.compare(s,e))return;const o=null!==this._maxPriceRange&&this._maxPriceRange.containsStrictly(e),n=null!==this._minPriceRange&&e.containsStrictly(this._minPriceRange);this.isLockScale()&&!t&&(o||n)||(this._marksCache=null,this._priceRange=e,i||this._priceRangeChanged.fire(s,e),this.updateAllViews((0,wi.viewportChangeEvent)()))}setMinPriceRange(e){this._minPriceRange=e}setMaxPriceRange(e){this._maxPriceRange=e}recalculatePriceRangeOnce(){this._recalculatePriceRangeOnce=!0}priceRangeShouldBeRecalculatedOnce(){if(!this._recalculatePriceRangeOnce||this.isLockScale())return!1;const e=this.mainSource();return null!==e&&e.priceRangeReady()}priceRangeChanged(){return this._priceRangeChanged}mode(){const e=this._properties.childs();return{autoScale:e.autoScale.value(),lockScale:e.lockScale.value(),percentage:e.percentage.value(),indexedTo100:e.indexedTo100.value(),log:e.log.value()}}setMode(e){const t={},i=this.mode(),s=this._properties.state();let o=null;void 0!==e.autoScale&&e.autoScale!==s.autoScale&&(t.autoScale=e.autoScale,this._setAutoScaleValueWithDependentProperties(e.autoScale)),void 0!==e.lockScale&&e.lockScale!==s.lockScale&&(t.lockScale=e.lockScale,this._setLockScaleValueWithDependentProperties(e.lockScale)),void 0!==e.percentage&&e.percentage!==s.percentage&&(t.percentage=e.percentage,this._setPercentageValueWithDependentProperties(e.percentage),this._invalidatedForRange.isValid=!1),void 0!==e.indexedTo100&&e.indexedTo100!==s.indexedTo100&&(t.indexedTo100=e.indexedTo100,this._setIndexedTo100ValueWithDependentProperties(e.indexedTo100),this._invalidatedForRange.isValid=!1),void 0!==e.log&&e.log!==s.log&&(t.log=e.log,this._setLogValueWithDependentProperties(e.log));const n=this._properties.childs();s.log&&!n.log.value()&&(this._canConvertPriceRangeFromLog(this._priceRange)?(o=this._convertPriceRangeFromLog(this._priceRange),null!==o&&this.setPriceRange(o)):n.autoScale.setValue(!0)),
!s.log&&n.log.value()&&(o=this._convertPriceRangeToLog(this._priceRange),null!==o&&this.setPriceRange(o)),s.autoScale!==n.autoScale.value()&&n.autoScale.fireChanged(),s.autoScaleDisabled!==n.autoScaleDisabled.value()&&n.autoScaleDisabled.fireChanged(),s.lockScale!==n.lockScale.value()&&n.lockScale.fireChanged(),s.percentage!==n.percentage.value()&&(n.percentage.fireChanged(),this.updateFormatter()),s.indexedTo100!==n.indexedTo100.value()&&(n.indexedTo100.fireChanged(),this.updateFormatter()),s.percentageDisabled!==n.percentageDisabled.value()&&n.percentageDisabled.fireChanged(),s.log!==n.log.value()&&n.log.fireChanged(),s.logDisabled!==n.logDisabled.value()&&n.logDisabled.fireChanged(),void 0===t.log&&void 0===t.percentage&&void 0===t.lockScale&&void 0===t.autoScale&&void 0===t.indexedTo100||this._modeChanged.fire(i,this.mode())}modeChanged(){return this._modeChanged}isEmpty(){return this._makeSureItIsValid(),0===this.m_height||!this._priceRange||this._priceRange.isEmpty()}hasCalculatedPriceRange(){return this._hasCalculatedPriceRange}canDetachSource(e){return this.m_dataSources.some((t=>t!==e&&(0,An.isPriceDataSource)(t)&&!((0,Ws.isStudy)(t)&&t.isLinkedToSeries())))}updateAllViews(e){const t=this._getSourcesToUpdateViews();for(const i of t)i.updateAllViews(e)}logFormula(){return this._logFormula}state(){const e=this._properties.childs();return{id:this._id,m_priceRange:this.isAutoScale()?null:this.priceRange()?.serialize()||null,m_isAutoScale:this.isAutoScale(),m_isPercentage:e.percentage.value(),m_isIndexedTo100:e.indexedTo100.value(),m_isLog:e.log.value(),m_isLockScale:this.isLockScale(),m_isInverted:this.isInverted(),m_topMargin:this._margins.top,m_bottomMargin:this._margins.bottom,alignLabels:e.alignLabels.value(),logFormula:(0,tt.clone)(this._logFormula),hasCalculatedPriceRange:this._hasCalculatedPriceRange}}restoreState(e){let t=e.m_priceRange;if(void 0===t)throw new TypeError("invalid state");if(void 0===e.m_isAutoScale)throw new TypeError("invalid state");void 0!==e.id&&(this._id=e.id);const i={autoScale:e.m_isAutoScale};void 0!==e.m_isPercentage&&(i.percentage=e.m_isPercentage),void 0!==e.m_isIndexedTo100&&(i.indexedTo100=e.m_isIndexedTo100),void 0!==e.m_isLog&&(i.log=e.m_isLog),void 0!==e.m_isLockScale&&(i.lockScale=e.m_isLockScale),void 0!==e.m_isInverted&&this._properties.childs().isInverted.setValue(e.m_isInverted),this.setMode(i),this._hasCalculatedPriceRange=e.hasCalculatedPriceRange??null!==t,t?(t instanceof Qc.PriceRange||(t=new Qc.PriceRange(t)),this.setPriceRange(t,!0)):this.clearPriceRange(),e.logFormula&&(this._logFormula=e.logFormula),void 0!==e.m_topMargin&&(this._margins.top=e.m_topMargin),void 0!==e.m_bottomMargin&&(this._margins.bottom=e.m_bottomMargin),void 0!==e.alignLabels&&this._properties.childs().alignLabels.setValue(e.alignLabels),this._mainSource=null,this._scaleSeriesOnly=!1}priceToLogical(e){return this.isLog()&&e?(0,eh.toLog)(e,this._logFormula):e}logicalToPrice(e){return this.isLog()?(0,eh.fromLog)(e,this._logFormula):e}positionPercentToCoordinate(e){return this.height()*e}
priceToCoordinate(e,t){const i=this._priceToPercentOrIndexedTo100IfNeeded(e,t);return this._logicalToCoordinate(i)}coordinateToPrice(e,t){let i=this._coordinateToLogical(e);return this.isPercentage()?i=(0,eh.fromPercent)(i,t):this.isIndexedTo100()&&(i=(0,eh.fromIndexedTo100)(i,t)),i}mainSource(){if(null!==this._mainSource)return this._mainSource;let e;for(const t of this._priceDataSources){if((0,qc.isSeries)(t)){e=t;break}e||(e=t)}return this._mainSource=e||null,this._correctedMarginsCache=null,this._mainSource}priceToCoordinateFn(e){this._makeSureItIsValid();const t=this.bottomPixelMargin(),i=(0,n.ensureNotNull)(this.priceRange()),s=i.minValue(),o=i.maxValue(),r=this.internalHeight()-1,a=this.isInverted(),l=r/(o-s),c=this.m_height,h=e=>{const i=t+l*(e-s);return a?i:c-1-i};return this.isPercentage()?t=>h((0,eh.toPercent)(t,e)):this.isIndexedTo100()?t=>h((0,eh.toIndexedTo100)(t,e)):this.isLog()?e=>h((0,eh.toLog)(e,this._logFormula)):e=>h(e)}pricesArrayToCoordinates(e,t,i){this._makeSureItIsValid();const s=this.bottomPixelMargin(),o=(0,n.ensureNotNull)(this.priceRange()),r=o.minValue(),a=o.maxValue(),l=this.internalHeight()-1,c=this.isInverted(),h=l/(a-r);void 0===i&&(i=e.length);const d=this.isPercentage(),u=this.isIndexedTo100(),_=this.isLog(),p=this.m_height;let m,g;for(let o=0;o<i;o++)m=e[o],Number.isFinite(m)&&(d?m=(0,eh.toPercent)(m,t):u?m=(0,eh.toIndexedTo100)(m,t):_&&(m=(0,eh.toLog)(m,this._logFormula)),g=s+h*(m-r),e[o]=c?g:p-1-g)}pointsArrayToCoordinates(e,t,i){this._makeSureItIsValid();const s=(0,n.ensureNotNull)(this.priceRange()),o=this.bottomPixelMargin(),r=s.minValue(),a=s.maxValue(),l=this.internalHeight()-1,c=this.isInverted(),h=l/(a-r),d=e,u=i?.startItemIndex??0,_=i?.endItemIndex??d.length;if(this.isPercentage())for(let e=u;e<_;e++)d[e].y=(0,eh.toPercent)(d[e].y,t);if(this.isIndexedTo100())for(let e=u;e<_;e++)d[e].y=(0,eh.toIndexedTo100)(d[e].y,t);if(this.isLog())for(let e=u;e<_;e++)d[e].y=this.priceToLogical(d[e].y);for(let e=u;e<_;e++){const t=d[e].y;if(isNaN(t)||null==t)continue;const i=o+h*(t-r),s=c?i:this.m_height-1-i;d[e].y=s}}barPricesToCoordinates(e,t){this._makeSureItIsValid();const i=(0,n.ensureNotNull)(this.priceRange()),s=e,o=this.bottomPixelMargin(),r=i.minValue(),a=i.maxValue(),l=this.internalHeight()-1;let c=null;if(this.isPercentage()?c=eh.toPercent:this.isIndexedTo100()?c=eh.toIndexedTo100:this.isLog()&&(c=(e,t)=>e?(0,eh.toLog)(e,this._logFormula):e),0===s.length)return;const h="open"in s[0],d="close"in s[0];if(null!==c)for(let e=0;e<s.length;e++){if(!s[e])continue;const i=s[e];h&&(i.open=c(i.open,t)),i.high=c(i.high,t),i.low=c(i.low,t),d&&(i.close=c(i.close,t)),void 0!==i.additionalPrice&&(i.additionalPrice=c(i.additionalPrice,t))}const u=l/(a-r),_=this.isInverted();for(let e=0;e<s.length;e++){const t=s[e];if(!t)continue;if(h){const e=o+u*(t.open-r),i=_?e:this.m_height-1-e;t.open=i}const i=o+u*(t.high-r),n=_?i:this.m_height-1-i;t.high=n;const a=o+u*(t.low-r),l=_?a:this.m_height-1-a;if(t.low=l,d){const e=o+u*(t.close-r),i=_?e:this.m_height-1-e;t.close=i}if(void 0!==t.additionalPrice){
const e=o+u*(t.additionalPrice-r);t.additionalPrice=_?e:this.m_height-1-e}}}formatter(){return null===this._formatter&&this.updateFormatter(),(0,n.ensureNotNull)(this._formatter)}updateFormatter(){this._marksCache=null;const e=this.mainSource();let t=100;e&&(t=e.base()),this._formatter=null,this.isPercentage()?(this._formatter=uh,t=100):this.isIndexedTo100()?(this._formatter=_h,t=100):this._formatter=e?e.formatter():_h,this._markBuilder=new lh(this,t,this._coordinateToLogical.bind(this),this._logicalToCoordinate.bind(this)),this._markBuilder.rebuildTickMarks()}formatPrice(e,t,i){return this.isPercentage()?this.formatPricePercentage(e,t,i):this.isIndexedTo100()?this.formatPriceIndexedTo100(e,t,i):this.formatter().format(e,i)}formatPriceAbsolute(e,t){return this._mainSourceFormatter().format(e,t)}formatPricePercentage(e,t,i){return e=(0,eh.toPercent)(e,t),uh.format(e,i)}formatPriceIndexedTo100(e,t,i){const s=(0,eh.toIndexedTo100)(e,t);return this.formatter().format(s,i)}getFormattedValues(e,t,i,s){s??=this.formatPriceAbsolute(e);const o=this.formatPricePercentage(e,t,{signPositive:i}),n=this.formatPriceIndexedTo100(e,t);return{formattedPriceAbsolute:s,formattedPricePercentage:o,formattedPriceIndexedTo100:n,text:(0,eh.getCurrentModePriceText)(this,{formattedPriceAbsolute:s,formattedPricePercentage:o,formattedPriceIndexedTo100:n})}}resetScale(){this.setMode({autoScale:!0})}resetScaleAvailable(){return this._resetScaleAvailable.readonly()}dataSources(){return this.m_dataSources}seriesLikeSources(){return this._seriesLikeSources}addDataSource(e,t){this._addDataSourceImpl(e,t)}removeDataSource(e){const t=this.m_dataSources.indexOf(e);if((0,n.assert)(-1!==t,"Source is not attached to scale"),this.m_dataSources.splice(t,1),(0,An.isPriceDataSource)(e)){const t=this._priceDataSources.indexOf(e);if((0,n.assert)(-1!==t,"Source is not found"),this._priceDataSources.splice(t,1),(0,Lr.isSymbolSource)(e)){const t=this._seriesLikeSources.indexOf(e);(0,n.assert)(-1!==t,"Source is not found"),this._seriesLikeSources.splice(t,1),e.symbolResolved().unsubscribeAll(this),e.isActingAsSymbolSource().unsubscribe(this._boundOnSourceIsActingAsSymbolSourceChanged),(0,qc.isSeries)(e)&&(this._hasSeries=!1)}e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this)}this.mainSource()||this.setMode({autoScale:!0}),(0,Ws.isStudy)(e)&&(e.onIsActualIntervalChange().unsubscribe(this,this._dropScaleCache),e.onHibernationStateChange().unsubscribe(this,this._dropScaleCache),e.properties().childs().styles.unsubscribe(this,this._dropScaleCache),this._studiesCount--,0===this._studiesCount&&(0,mt.hideAllIndicators)().unsubscribe(this,this._dropScaleCache)),(0,zs.isLineTool)(e)&&(this._drawingCount--,0===this._drawingCount&&(0,mt.hideAllDrawings)().unsubscribe(this,this._dropScaleCache));const i=this._sourcesThatAffectVisibility.indexOf(e);-1!==i&&(this._sourcesThatAffectVisibility.splice(i,1),e.properties().childs().visible.unsubscribe(this,this._onSourceVisibilityChanged)),e===this._mainSource&&(this._correctedMarginsCache=null,
this._internalHeightCache=null,this._marksCache=null),this._mainSource=null,this._dropScaleCache(),this.updateFormatter(),this.invalidateSourcesCache(),this._updateIsVisible(),this._updateLogFormula(),0===this.m_dataSources.length&&this._lastSourceRemoved.fire()}replaceSource(e,t){const i=(0,An.isPriceDataSource)(e)?this._priceDataSources.indexOf(e):void 0;return this._addDataSourceImpl(t,void 0,-1===i?void 0:i),this.removeDataSource(e),-1!==i}currency(e){if(null!==this._currencyCache&&e.size()===this._currencyCache.availableCurrenciesCount)return this._currencyCache.value;let t;const i=new Set,s=new Set,o=new Set,r=new Map,a=new Set;let l,c=0===this._seriesLikeSources.length,h=!0,d=0,u=0;const _=this._seriesLikeSources.filter(Lr.isActingAsSymbolSource);for(const u of _){if(!u.isVisible())continue;const _=u.symbolInfo();if(null===_){t=null;break}const p=(0,xt.symbolOriginalCurrency)(_);if(null===p){t=null;break}r.set(p,(0,n.ensureNotNull)((0,xt.symbolOriginalCurrency)(_,!0)));const m=u.currency();if(null===m){t=null;break}r.set(m,(0,n.ensureNotNull)((0,xt.symbolCurrency)(_,!0)));const g=(0,xt.symbolBaseCurrency)(_);null!==g&&s.add(g),h=h&&p===m,o.add(m),i.add(p),void 0===l?l=m:null!==l&&l!==m&&(l=null),c||e.convertible(m)&&(0,xt.symbolCurrencyConvertible)(_)||(c=!0),d+=1,a.add((0,xt.proSymbol)(_,u.symbol()))}if(null!==t)for(const i of this._priceDataSources){if(_.includes(i))continue;const s=i;if(!s.isCurrencySource()||!s.isVisible()||s.isFailed())continue;const a=s.currency();if(null===a){t=null;break}o.add(a),u+=1;const h=(0,n.ensureNotNull)(s.symbolSource()),d=s.currencySourceSymbolInfo();if(null===d){t=null;break}if(c||e.convertible(a)&&(0,xt.symbolCurrencyConvertible)(d)||(c=!0),r.set(a,(0,n.ensureNotNull)((0,xt.symbolCurrency)(d,!0))),_.includes(h)||(c=!0),void 0===l)l=a;else if(null!==l&&l!==a){l=null;break}}return void 0===t&&(t=0===d&&0===u?null:{readOnly:c,selectedCurrency:l||null,currencies:o,originalCurrencies:i,baseCurrencies:s,symbolSourceCount:d,allCurrenciesAreOriginal:h,displayedValues:r,symbols:a}),this._currencyCache={value:t,availableCurrenciesCount:e.size()},t}unit(e){if(null!==this._unitCache&&e.size()===this._unitCache.availableUnitsCount)return this._unitCache.value;let t;const i=new Set,s=new Set,o=new Map,r=new Map,a=new Set;let l,c=0===this._seriesLikeSources.length?new Set:e.allGroups(),h=!0,d=0,u=0;const _=this._seriesLikeSources.filter(Lr.isActingAsSymbolSource);for(const n of _){if(!n.isVisible())continue;const u=n.symbolInfo();if(null===u){t=null;break}const _=(0,xt.symbolOriginalUnit)(u,n.model().unitConversionEnabled());if(null===_){t=null;break}o.set(_,e.name(_)),r.set(_,e.description(_));const p=n.unit();if(null===p){t=null;break}if(o.set(p,e.name(p)),r.set(p,e.description(p)),h=h&&_===p,s.add(p),i.add(_),void 0===l?l=p:null!==l&&l!==p&&(l=null),c.size>0){const t=th(u,p,e);c=(0,Pt.intersect)(c,new Set(t))}d+=1,a.add((0,xt.proSymbol)(u,n.symbol()))}if(null!==t)for(const i of this._priceDataSources){if(_.includes(i))continue;const a=i
;if(!a.isUnitSource()||!a.isVisible()||a.isFailed())continue;const h=a.unit();if(null===h){t=null;break}s.add(h),u+=1;const d=(0,n.ensureNotNull)(a.symbolSource()),p=d.symbolInfo();if(null===p){t=null;break}if(c.size>0){const t=th(p,h,e);c=(0,Pt.intersect)(c,new Set(t))}if(o.set(h,e.name(h)),r.set(h,e.description(h)),_.includes(d)||(c=new Set),void 0===l)l=h;else if(null!==l&&l!==h){l=null;break}}if(void 0===t)if(0===d&&0===u)t=null;else{t={availableGroups:c,selectedUnit:l||null,units:s,originalUnits:i,symbolSourceCount:d,allUnitsAreOriginal:h,names:o,descriptions:r,symbols:a}}return this._unitCache={value:t,availableUnitsCount:e.size()},t}measureUnitId(e){if(null!==this._measureUnitIdCache&&e.size()===this._measureUnitIdCache.availableUnitsCount)return this._measureUnitIdCache.value;let t,i;const s=new Map,o=new Map,n=new Set;let r=0;const a=this._seriesLikeSources.filter(Lr.isActingAsSymbolSource);for(const l of a){if(!l.isVisible())continue;const a=l.measureUnitId();if(null===a){t=null;break}n.add(a),s.set(a,e.name(a)),o.set(a,e.description(a)),void 0===i?i=a:null!==i&&i!==a&&(i=null),r+=1}return void 0===t&&(t=0===r?null:{selectedMeasureUnitId:i||null,measureUnitIds:n,names:s,descriptions:o,symbolSourceCount:r}),this._measureUnitIdCache={value:t,availableUnitsCount:e.size()},t}setMargins(e){if(!(0,tt.isNumber)(e.top)||!(0,tt.isNumber)(e.bottom))throw new TypeError("invalid margin");if(e.top<0||e.top>30||e.bottom<0||e.bottom>30)throw new RangeError("invalid margin");this._margins.top===e.top&&this._margins.bottom===e.bottom||(this._margins=e,this._correctedMarginsCache=null,this._invalidateInternalHeightCache(),this._marksCache=null)}topMargin(){return this._correctedMargins().top}bottomMargin(){return this._correctedMargins().bottom}invalidateMargins(){this._correctedMarginsCache=null}topPixelMargin(){return this.isInverted()?this.bottomMargin()*this.height()+this._bottomPixelMargin:this.topMargin()*this.height()+this._topPixelMargin}bottomPixelMargin(){return this.isInverted()?this.topMargin()*this.height()+this._topPixelMargin:this.bottomMargin()*this.height()+this._bottomPixelMargin}marks(){return this.isEmpty()?(this._marksCache=null,[]):(null===this._marksCache&&(this._markBuilder.rebuildTickMarks(),this._marksCache=this._markBuilder.marks(),this._onMarksChanged.fire()),this._marksCache)}onMarksChanged(){return this._onMarksChanged}priceRangeInPrice(){if(this.isEmpty())return null;const e=this.mainSource()?.firstValue()??null;if(null===e)return null;const t=this.height();return{from:this.coordinateToPrice(t-1,e),to:this.coordinateToPrice(0,e)}}setPriceRangeInPrice(e){if(this.isPercentage()||this.isIndexedTo100())return;const t=this.isInverted(),i=t?this.bottomMargin():this.topMargin(),s=t?this.topMargin():this.bottomMargin(),o=this.isLog();let n=o?(0,eh.toLog)(e.from,this._logFormula):e.from,r=o?(0,eh.toLog)(e.to,this._logFormula):e.to;const a=r-n;n+=s*a,r-=i*a,this.setMode({autoScale:!1}),this.setPriceRange(new Qc.PriceRange(n,r)),this._marksCache=null,this._onMarksChanged.fire()}hasMainSeries(){
return this._hasSeries}getStudies(){return this.dataSources().filter(Ws.isStudy)}lastSourceRemoved(){return this._lastSourceRemoved}sourcesForAutoscale(){return this._mainSource&&this._scaleSeriesOnly!==this._scalesProperties.childs().scaleSeriesOnly.value()&&(this._sourcesForAutoscale=null),this._sourcesForAutoscale||(this._sourcesForAutoscale=this._recalculateSourcesForAutoscale()),this._sourcesForAutoscale}recalculatePriceRange(e){this._invalidatedForRange={visibleBars:e,isValid:!1}}internalHeightChanged(){return this._internalHeightChanged}orderedSources(){if(this._cachedOrderedSoruces)return this._cachedOrderedSoruces;let e=this.m_dataSources.slice();return e=(0,vi.sortSources)(e),this._cachedOrderedSoruces=e,this._cachedOrderedSoruces}invalidateSourcesCache(){this._cachedOrderedSoruces=null,this._sourcesToUpdateViews=null}startScale(e){this.isEmpty()||this.isPercentage()||this.isIndexedTo100()||null!==this._scaleStartPoint||null!==this._priceRangeSnapshot||(this._scaleStartPoint=this.m_height-e,this._priceRangeSnapshot=this.priceRange()?.clone()??null)}scaleTo(e){if(this.isPercentage()||this.isIndexedTo100()||null===this._scaleStartPoint)return;this.setMode({autoScale:!1}),(e=this.m_height-e)<0&&(e=0);let t=(this._scaleStartPoint+.2*(this.m_height-1))/(e+.2*(this.m_height-1));const i=(0,n.ensureNotNull)(this._priceRangeSnapshot).clone();t=Math.max(t,.1),i.scaleAroundCenter(t),this.setPriceRange(i)}endScale(){this.isPercentage()||this.isIndexedTo100()||null!==this._scaleStartPoint&&(this._scaleStartPoint=null,this._priceRangeSnapshot=null)}startTwoPointsScale(e,t){if(this.isEmpty()||this.isPercentage()||this.isIndexedTo100()||null!==this._twoPointsScaleStartPosition)return;const i=Math.min(e,t),s=Math.max(e,t);this._twoPointsScaleStartPosition={topLogical:this._coordinateToLogical(i),bottomLogical:this._coordinateToLogical(s)}}twoPointsScale(e,t){if(this.isPercentage()||this.isIndexedTo100()||null===this._twoPointsScaleStartPosition)return;this.setMode({autoScale:!1});const i=Math.min(e,t),s=Math.max(e,t),{topLogical:o,bottomLogical:n}=this._twoPointsScaleStartPosition,r=this.bottomPixelMargin(),a=this.internalHeight()-1,l=(this._invertedCoordinate(i)-r)/a,c=(n-o)/((this._invertedCoordinate(s)-r)/a-l);if(!Number.isFinite(c))return;const h=o-c*l,d=h+c;this.setPriceRange(new Qc.PriceRange(this.priceToLogical(h),this.priceToLogical(d)))}endTwoPointsScale(){this._twoPointsScaleStartPosition=null}startScroll(e){this.isAutoScale()||null===this._scrollStartPoint&&null===this._priceRangeSnapshot&&(this.isEmpty()||(this._scrollStartPoint=e,this._priceRangeSnapshot=this.priceRange()?.clone()??null))}scrollTo(e){if(this.isAutoScale())return;if(null===this._scrollStartPoint||null===this._priceRangeSnapshot)return;const t=this.priceRange();if(null===t)return;let i=e-this._scrollStartPoint;this.isInverted()&&(i*=-1);const s=i*(t.length()/(this.internalHeight()-1)),o=this._priceRangeSnapshot.clone();o.shift(s),this.setPriceRange(o,!0),this._marksCache=null}endScroll(){
this.isAutoScale()||null!==this._scrollStartPoint&&(this._scrollStartPoint=null,this._priceRangeSnapshot=null)}clearPriceRange(){this._priceRange=null,this.recalculatePriceRangeOnce()}isVisible(){return this._isVisible}_addDataSourceImpl(e,t,i){if(t||-1===this.m_dataSources.indexOf(e)){if((0,An.isPriceDataSource)(e)){if(void 0===i?this._priceDataSources.push(e):this._priceDataSources.splice(i,0,e),e.currencyChanged().subscribe(this,(()=>this._currencyCache=null)),e.unitChanged().subscribe(this,(()=>this._unitCache=null)),(0,Lr.isSymbolSource)(e)&&(this._seriesLikeSources.push(e),e.symbolResolved().subscribe(this,(()=>{this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null,this._updateLogFormula()})),e.isActingAsSymbolSource().subscribe(this._boundOnSourceIsActingAsSymbolSourceChanged),(0,qc.isSeries)(e))){const t=e.properties();this._hasSeries||(t.childs().lockScale&&(this.setMode({lockScale:t.childs().lockScale.value()}),t.removeProperty("lockScale")),t.childs().pnfStyle.hasChild("lockScale")&&t.childs().pnfStyle.removeProperty("lockScale")),this._hasSeries=!0}e.isSpeciallyZOrderedSource()||(this._sourcesThatAffectVisibility.push(e),e.properties().childs().visible.subscribe(this,this._onSourceVisibilityChanged))}(0,Ws.isStudy)(e)&&(e.onIsActualIntervalChange().subscribe(this,this._dropScaleCache),e.onHibernationStateChange().subscribe(this,this._dropScaleCache),e.properties().childs().styles.subscribe(this,this._dropScaleCache),0===this._studiesCount&&(0,mt.hideAllIndicators)().subscribe(this,this._dropScaleCache),this._studiesCount++),(0,zs.isLineTool)(e)&&(0===this._drawingCount&&(0,mt.hideAllDrawings)().subscribe(this,this._dropScaleCache),this._drawingCount++),this.m_dataSources.push(e),this._mainSource=null,this.mainSource()===e&&(this._correctedMarginsCache=null,this._internalHeightCache=null,this._marksCache=null),this._dropScaleCache(),this.updateFormatter(),this._initScaleProperties(),this.invalidateSourcesCache(),this._updateIsVisible(),this._updateLogFormula()}}_recalculateSourcesForAutoscale(){this._mainSource&&(this._scaleSeriesOnly=this._scalesProperties.childs().scaleSeriesOnly.value());const e=this._scaleSeriesOnly&&this._hasSeries;return this.m_dataSources.filter((t=>!(!t.properties().visible.value()&&!(0,qc.isSeries)(t))&&(e?(0,qc.isSeries)(t):(0,Ws.isStudy)(t)?!t.isSourceHidden()&&t.isIncludedInAutoScale():t.isIncludedInAutoScale())))}_updateAutoScaleDisabledProperty(e){const t=this._properties.childs(),i=t.indexedTo100.value()||t.percentage.value()||t.lockScale.value();e?t.autoScaleDisabled.setValueSilently(i):t.autoScaleDisabled.setValue(i)}_setAutoScaleValueWithDependentProperties(e){const t=this._properties.childs();t.autoScale.setValueSilently(e),e&&(t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.logDisabled.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setLockScaleValueWithDependentProperties(e){const t=this._properties.childs();t.lockScale.setValueSilently(e),
e&&(t.autoScale.setValueSilently(!1),t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1),t.log.setValueSilently(!1)),t.percentageDisabled.setValueSilently(e),t.logDisabled.setValueSilently(e),this._updateAutoScaleDisabledProperty(!0)}_setPercentageValueWithDependentProperties(e){const t=this._properties.childs();t.percentage.setValueSilently(e),e&&(t.autoScale.setValueSilently(!0),t.log.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.indexedTo100.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setIndexedTo100ValueWithDependentProperties(e){const t=this._properties.childs();t.indexedTo100.setValueSilently(e),e&&(t.autoScale.setValueSilently(!0),t.log.setValueSilently(!1),t.lockScale.setValueSilently(!1),t.percentage.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_setLogValueWithDependentProperties(e){const t=this._properties.childs();t.log.setValueSilently(e),e&&(t.lockScale.setValueSilently(!1),t.percentage.setValueSilently(!1),t.indexedTo100.setValueSilently(!1)),this._updateAutoScaleDisabledProperty(!0)}_recalculatePriceRangeImpl(){const e=this._invalidatedForRange.visibleBars;if(null===e)return;let t=null;const i=this.sourcesForAutoscale(),s=this.isPercentage(),o=this.isIndexedTo100();let n=0,r=0;const a={targetPriceScale:this,scaleSeriesOnly:this._scaleSeriesOnly};for(const l of i){if(!l.properties().visible.value())continue;const i=l.firstValue();if(null===i||s&&0===i)continue;const c=e.firstBar(),h=e.lastBar(),d=l.autoScaleInfo(c,h,a);let u=d.range;u&&(s?u=(0,eh.toPercentRange)(u,i):o&&(u=(0,eh.toIndexedTo100Range)(u,i)),t=null===t?u:t.merge(u)),void 0!==d.topPixelMargin&&(n=Math.max(n,d.topPixelMargin)),void 0!==d.bottomPixelMargin&&(r=Math.max(r,d.bottomPixelMargin))}(Math.abs(n-this._topPixelMargin)>0||Math.abs(r-this._bottomPixelMargin)>0)&&(this._bottomPixelMargin=r,this._topPixelMargin=n,this._marksCache=null,this._invalidateInternalHeightCache()),t?(this._hasCalculatedPriceRange=!0,t.minValue()===t.maxValue()&&(t=new Qc.PriceRange(t.minValue()-.5,t.maxValue()+.5)),this.setPriceRange(t)):this._priceRange||this.setPriceRange(new Qc.PriceRange(-.5,.5)),this._invalidatedForRange.isValid=!0;const l=this.mainSource();null!==l&&this._recalculatePriceRangeOnce&&(this._recalculatePriceRangeOnce=!l.priceRangeReady())}_makeSureItIsValid(){this._invalidatedForRange.isValid||(this._invalidatedForRange.isValid=!0,this._recalculatePriceRangeImpl())}_invalidateInternalHeightCache(){this._internalHeightCache=null,this._internalHeightChanged.fire()}_coordinateToLogical(e){if(this._makeSureItIsValid(),this.isEmpty())return 0;const t=this._invertedCoordinate(e),i=(0,n.ensureNotNull)(this.priceRange()),s=i.minValue()+(i.maxValue()-i.minValue())*((t-this.bottomPixelMargin())/(this.internalHeight()-1));return this.logicalToPrice(s)}_logicalToCoordinate(e){if(this._makeSureItIsValid(),this.isEmpty())return 0;e=this.priceToLogical(e);const t=(0,
n.ensureNotNull)(this.priceRange()),i=this.bottomPixelMargin()+(this.internalHeight()-1)*(e-t.minValue())/(t.maxValue()-t.minValue());return this._invertedCoordinate(i)}_convertPriceRangeFromLog(e){if(null===e)return null;const t=(0,eh.fromLog)(e.minValue(),this._logFormula),i=(0,eh.fromLog)(e.maxValue(),this._logFormula);return new Qc.PriceRange(t,i)}_convertPriceRangeToLog(e){if(null===e)return null;const t=(0,eh.toLog)(e.minValue(),this._logFormula),i=(0,eh.toLog)(e.maxValue(),this._logFormula);return new Qc.PriceRange(t,i)}_canConvertPriceRangeFromLog(e){if(null===e)return!1;const t=(0,eh.fromLog)(e.minValue(),this._logFormula),i=(0,eh.fromLog)(e.maxValue(),this._logFormula);return isFinite(t)&&isFinite(i)}_onSourceVisibilityChanged(){this._dropScaleCache(),this._updateIsVisible()}_dropScaleCache(){this._sourcesForAutoscale=null,this._currencyCache=null,this._unitCache=null,this._measureUnitIdCache=null}_updateIsVisible(){if(!dh)return void this._isVisible.setValue(!0);const e=this._sourcesThatAffectVisibility.some((e=>e.isVisible()));this._isVisible.setValue(e)}_updateLogFormula(){const e=this.isLog()?this._convertPriceRangeFromLog(this.priceRange()):null,t=this.mainSource();if(null===t)this._logFormula=(0,eh.logFormulaForBase)(null);else{const e=t.base()||null,i=(0,eh.logFormulaForBase)(e);(0,eh.logFormulasAreSame)(i,this._logFormula)||(this._logFormula=i)}e&&this.setPriceRange(this._convertPriceRangeToLog(e))}_invertedCoordinate(e){return this.isInverted()?e:this.height()-1-e}_initScaleProperties(){const e=this.isLockScale(),t=this.properties().childs();e&&(t.percentage.setValue(!1),t.indexedTo100.setValue(!1),t.log.setValue(!1),t.autoScale.setValue(!1)),t.percentageDisabled.setValue(e),t.logDisabled.setValue(e),this._updateAutoScaleDisabledProperty(!1),t.percentage.value()&&(t.log.setValue(!1),t.indexedTo100.setValue(!1)),t.indexedTo100.value()&&(t.log.setValue(!1),t.percentage.setValue(!1))}_correctedMargins(){if(null===this._correctedMarginsCache){const e=this.mainSource();this._correctedMarginsCache=null!==e?e.correctScaleMargins(this._margins):this._margins}return this._correctedMarginsCache}_getSourcesToUpdateViews(){return this._sourcesToUpdateViews||(this._sourcesToUpdateViews=this.m_dataSources.filter((e=>!(0,zs.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()))),this._sourcesToUpdateViews}_mainSourceFormatter(){const e=this.mainSource();return e?.formatter()||_h}_priceToPercentOrIndexedTo100IfNeeded(e,t){return this.isPercentage()?(0,eh.toPercent)(e,t):this.isIndexedTo100()?(0,eh.toIndexedTo100)(e,t):e}_onSourceIsActingAsSymbolSourceChanged(){this._dropScaleCache()}_onIsInvertedChanged(){this._marksCache=null,this._markBuilder.rebuildTickMarks()}_updateResetAvailableValue(){this._resetScaleAvailable.setValue(!this.isLockScale()&&!this.isAutoScale())}}var gh=i(86252);const fh=[],yh=[];class vh{constructor(e){this._studies={},this._deferreds={},this._container=e,fh.push(e),yh.push(this)}add(e,t){this._deferreds[e]&&(this._deferreds[e].resolve(t),delete this._deferreds[e]),this._studies[e]=t}
get(e){return this._studies[e]?Promise.resolve(this._studies[e]):(this._deferreds[e]||(this._deferreds[e]=(0,me.createDeferredPromise)()),this._deferreds[e].promise)}delete(e){delete this._studies[e],delete this._deferreds[e]}reset(){const e=fh.indexOf(this._container);~e&&(fh.splice(e,1),yh.splice(e,1))}static instance(e){const t=fh.indexOf(e);return~t?yh[t]:new vh(e)}static ready(){for(const e of yh)if(Object.keys(e._deferreds).length>0)return!1;return!0}}var Sh=i(10544);var bh=i(81922),wh=i(54370),Ch=i(15219);function Th(e){e.wickUpColor=e.wickUpColor??e.wickColor,e.wickDownColor=e.wickDownColor??e.wickColor,delete e.wickColor}function Ph(e){e&&(e.colorType??=co.ColorType.Solid)}const xh=l.enabled("clear_price_scale_on_error_or_empty_bars"),Mh=(0,ne.getLogger)("Chart.Pane");var Ih;function Ah(e,t,i){e.setMargins({top:t,bottom:i})}!function(e){e[e.DefaultStretchFactor=1e3]="DefaultStretchFactor",e[e.LargePaneSizeRatio=1]="LargePaneSizeRatio",e[e.MediumPaneSizeRatio=.6]="MediumPaneSizeRatio",e[e.SmallPaneSizeRatio=.3]="SmallPaneSizeRatio",e[e.TinyPaneSizeRatio=.15]="TinyPaneSizeRatio"}(Ih||(Ih={}));const Lh="chart.pane";class kh{constructor(e,t,i,s,o){this.m_dataSources=[],this._sourceWatchedValuesSubscriptions=new Map,this.m_mainDataSource=null,this._cachedOrderedSources=new Jc(this),this._sourcesById=new Map,this._priceSourcesById=new Map,this._sourcePropertiesChanged=new ae.Delegate,this._sourcesZOrderChanged=new ae.Delegate,this._tagsChanged=new ae.Delegate,this._stretchFactor=1e3,this._isInInsertManyDataSourcesState=!1,this._lastLineDataSourceZOrder=null,this._rightPriceScales=[],this._leftPriceScales=[],this._lockedPriceScale=null,this._currentPriceScaleRatio=null,this._onPriceScalesChanged=new ae.Delegate,this._isRecalculatingScales=!1,this._priceDataSources=[],this._symbolSources=[],this._studySources=[],this._lollipopDataSources=[],this._symbolSourceResolved=new ae.Delegate,this._symbolSourceResolvingActive=new O.WatchedValue(!1),this._bulkActions={activeCounter:0},this._height=0,this._width=0,this._sizeChanged=new ae.Delegate,this._dataSourcesCollectionChanged=new ae.Delegate,this._dataSourcesZOrdersChanged=new ae.Delegate,this._symbolSourceCollectionChanged=new ae.Delegate,this._priceSourcesCollectionChanged=new ae.Delegate,this._isMainPane=new O.WatchedValue(!1),this._collapsed=new O.WatchedValue(!1),this._resetPriceScalesAvailable=new O.WatchedValue(!1),this._destroyed=new ae.Delegate,this._executionsPositionController=null,this._seriesDisplayError=null,this._onPriceScaleIsVisibleChanged=()=>{this._model.fullUpdate()},this._recalcSymbolSourceResolvingActive=()=>{for(const e of this._symbolSources)if(e.symbolResolvingActive().value())return void this._symbolSourceResolvingActive.setValue(!0);this._symbolSourceResolvingActive.setValue(!1)},this._onSymbolSourceCollectionChanged=()=>{0===this._bulkActions.activeCounter?this._symbolSourceCollectionChanged.fire():this._bulkActions.symbolSourceCollectionChanged=!0},this._onSeriesDisplayError=e=>{if(null!==e){
for(const e of this._leftPriceScales)e.clearPriceRange();for(const e of this._rightPriceScales)e.clearPriceRange()}},this._updateResetPriceScalesAvailableValue=()=>{const e=e=>e.resetScaleAvailable().value(),t=this._leftPriceScales.some(e)||this._rightPriceScales.some(e);this._resetPriceScalesAvailable.setValue(t)},this._priceScaleSelectionStrategy=(0,zc.createPriceScaleSelectionStrategy)(i.properties().childs().priceScaleSelectionStrategyName.value()),this._id=s??(0,fe.randomHashN)(6),this._mode=o??zi.PaneMode.Regular,this._timeScale=e,this.m_mainDataSource=null,this._properties=t,this._model=i,this._maximized=(0,ft.combine)((e=>e===this),i.maximizedPane().spawnOwnership()),this._collapsingAvailable=(0,ft.combine)(((e,t)=>t),this._isMainPane.weakReference(),i.paneCollapsingAvailable().weakReference()),i.properties().childs().priceScaleSelectionStrategyName.subscribe(null,(e=>{this._priceScaleSelectionStrategy=(0,zc.createPriceScaleSelectionStrategy)(e.value()),this._priceScaleSelectionStrategy.apply(this)})),this._timeScale.barSpacingChanged().subscribe(this,(()=>{this.m_mainDataSource===this._model.mainSeries()&&this._recalculatePriceScaleByScaleRatio(this.m_mainDataSource.priceScale())})),xh&&(this._seriesDisplayError=(0,xt.getSeriesDisplayErrorWV)(this._model.mainSeries()),this._seriesDisplayError.subscribe(this._onSeriesDisplayError)),i.onMultipaneSourcesCollectionChanged().subscribe(this,this._invalidateSourcesCache),i.panesCollectionChanged().subscribe(this,this._invalidateSourcesCache),t.childs().topMargin.subscribe(this,this._updateMargins),t.childs().bottomMargin.subscribe(this,this._updateMargins),this._lineToolsByLinkKey=new Uc((e=>e.linkKey().value()),(e=>e.id())),this._updateMargins()}destroy(){if(this._properties.childs().topMargin.unsubscribeAll(this),this._properties.childs().bottomMargin.unsubscribeAll(this),this._model.properties().childs().priceScaleSelectionStrategyName.unsubscribeAll(this),this._timeScale.barSpacingChanged().unsubscribeAll(this),this._leftPriceScales.concat(this._rightPriceScales).forEach((e=>{e.modeChanged().unsubscribeAll(this),e.priceRangeChanged().unsubscribeAll(this),e.internalHeightChanged().unsubscribeAll(this),e.isVisible().unsubscribe(this._onPriceScaleIsVisibleChanged),e.resetScaleAvailable().unsubscribe(this._updateResetPriceScalesAvailableValue)})),this._mode===zi.PaneMode.Regular)for(const e of this.m_dataSources)this.removeSourceFromPriceScale(e),e.destroy&&e.destroy();this._seriesDisplayError?.destroy(),this._model.onMultipaneSourcesCollectionChanged().unsubscribeAll(this),this._model.panesCollectionChanged().unsubscribeAll(this),this._maximized.destroy(),this._collapsingAvailable.destroy(),this._destroyed.fire()}id(){return this._id}mode(){return this._mode}bulkActionMacro(e){this.beginBulkAction(),e(),this.endBulkAction()}beginBulkAction(){this._bulkActions.activeCounter+=1}endBulkAction(){this._bulkActions.activeCounter-=1,this._processAfterBulkAction()}defaultPriceScale(){const e=this.m_mainDataSource?.priceScale()??null;if(null!==e)return e
;const t=this.properties().childs().axisProperties.state();return t.autoScale=!0,new mh(this._model.properties().childs().scalesProperties,t)}leftPriceScales(){return this._leftPriceScales}rightPriceScales(){return this._rightPriceScales}visibleLeftPriceScales(){const e=this._model.priceScaleSlotsCount(),t=this._leftPriceScales.filter((e=>e.isVisible().value())),i=this.mainDataSource()?.priceScale();if(t.length>e.left&&i?.isVisible().value()){const s=(0,Pt.moveToHead)(t,i);return s.splice(e.left),s}return t}visibleRightPriceScales(){const e=this._model.priceScaleSlotsCount(),t=this._rightPriceScales.filter((e=>e.isVisible().value())),i=this.mainDataSource()?.priceScale();if(t.length>e.right&&i?.isVisible().value()){const s=(0,Pt.moveToHead)(t,i);return s.splice(e.right),s}return t}clearSeries(e){const t=this._model.mainSeries();for(let i=this.m_dataSources.length-1;i>=0;i--)this.m_dataSources[i]===t&&this._removeSourceFromCollections(i,e)}sourcesByGroup(){return this._cachedOrderedSources}dataSourceForId(e){return this._sourcesById.get(e)||null}lineToolByLinkKey(e){return this._lineToolsByLinkKey.getByKey1(e)}changeSourceId(e,t){e===this._model.mainSeries()&&(0,Hc.getPersistentLogger)()?.addPersistentLogEntry(`changeSourceId for series from ${e.id()} to ${t}`,ne.LOGLEVEL.INFO,Lh),(0,n.assert)(this.hasDataSource(e));const i=e.id();e.setId(t),this._sourcesById.delete(i),this._sourcesById.set(t,e),(0,An.isPriceDataSource)(e)&&(this._priceSourcesById.delete(i),this._priceSourcesById.set(t,e))}movePriceScale(e,t,i){const s=this.priceScalePosition(e);if(s!==t)this.removePriceScale(e),this._placePriceScale(e,t,i),e.invalidateMargins(),this._invalidateSourcesCache();else if(void 0!==i&&"overlay"!==s){const t="left"===s?this._leftPriceScales:this._rightPriceScales,o=t.indexOf(e);t.splice(o,1),t.splice(i,0,e)}}mainDataSource(){return this.m_mainDataSource}isEmpty(){return null===this.m_mainDataSource}recalculatePriceScale(e,t){if(!e)return;let i=e.sourcesForAutoscale();if(e===this._model.mainSeries().priceScale()&&(i=[...i,...this._cachedOrderedSources.multipaneSources()]),(e.isAutoScale()||e.priceRangeShouldBeRecalculatedOnce()||null===e.priceRange())&&i.length>0&&!this.timeScale().isEmpty()){const i=e.priceRange(),s=this.timeScale().visibleBarsStrictRange();e.recalculatePriceRange(s),Qc.PriceRange.compare(i,e.priceRange())||e.updateAllViews(t)}}onSourceTagsChanged(){this._tagsChanged.fire()}insertDataSource(e,t,i,s){e.setZorder(i),t||(s=!1,t=this.findSuitableScale(e)),this._addSourceToCollections(e);let o=!1;e===this.model().mainSeries()?(this.m_mainDataSource=this.model().mainSeries(),o=!0):null===this.m_mainDataSource&&(0,An.isPriceDataSource)(e)&&(this.m_mainDataSource=e,o=!0),s||t.addDataSource(e,this._isInInsertManyDataSourcesState),e.setPriceScale(t),t.invalidateMargins(),e.onTagsChanged&&e.onTagsChanged().subscribe(this,this.onSourceTagsChanged),o&&this._mode===zi.PaneMode.Regular&&this._processMainSourceChange(),this._tagsChanged.fire(),(0,An.isPriceDataSource)(e)&&this.recalculatePriceScale(t,(0,
wi.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}addDataSource(e,t,i){let s=e.zorder();i||((0,zs.isLineTool)(e)&&!e.isSpeciallyZOrderedSource()?(s=null!==this._lastLineDataSourceZOrder?this._lastLineDataSourceZOrder+1:this.newLineToolZOrder(),this._isInInsertManyDataSourcesState&&(this._lastLineDataSourceZOrder=s)):(0,Ws.isStudy)(e)&&!e.isSpeciallyZOrderedSource()&&(s=this.newStudyZOrder())),this.insertDataSource(e,t,s)}removeDataSource(e,t=!1,i=!1,s=!1){let o=this.m_dataSources.indexOf(e);if(-1===o)return void Mh.logDebug("removeDataSource: invalid data source");this._removeSourceFromCollections(o,i),e!==this.m_mainDataSource||t||(this.m_mainDataSource=null);const n=e.priceScale();s||this.removeSourceFromPriceScale(e),e.onTagsChanged&&e.onTagsChanged().unsubscribe(this,this.onSourceTagsChanged),(0,An.isPriceDataSource)(e)&&!t&&this._processMainSourceChange(),(0,Ws.isStudy)(e)&&e.metaInfo().hasForceOverlayPlots()&&this._model.removeMultiPaneSource(e),this._tagsChanged.fire(),n&&(0,An.isPriceDataSource)(e)&&this.recalculatePriceScale(n,(0,wi.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}hasDataSource(e){return this._sourcesById.has(e.id())}hasDataSourceWithSignature(e){return this._priceDataSources.some((t=>t.signature().value()===e))}hasPriceDataSource(e){return this._priceSourcesById.has(e.id())}dataSources(){return this.m_dataSources}priceDataSources(){return this._priceDataSources}studySources(){return this._studySources}lollipopDataSources(){return this._lollipopDataSources}symbolSources(){return this._symbolSources}replaceSource(e,t,i){const s=this.m_mainDataSource===e,o=i?.replaceSource(e,t);this.removeDataSource(e,s,void 0,o),this.insertDataSource(t,i,e.zorder(),o),this._sourcesById.set(t.id(),t),(0,An.isPriceDataSource)(t)&&this._priceSourcesById.set(t.id(),t),s&&(this.m_mainDataSource=t,this._processMainSourceChange())}findSuitableScale(e,t,i){return this._priceScaleSelectionStrategy.findSuitableScale(this,e,t,i)}createNewPriceScaleIfPossible(){return this._priceScaleSelectionStrategy.createNewPriceScaleIfPossible(this)}canCreateNewPriceScale(){return this._priceScaleSelectionStrategy.canCreateNewPriceScale(this)}isOverlay(e){const t=e.priceScale();return null===t||"overlay"===this.priceScalePosition(t)}recalculate(e){this._leftPriceScales.forEach((t=>this.recalculatePriceScale(t,e))),this._rightPriceScales.forEach((t=>this.recalculatePriceScale(t,e)));for(const t of this.m_dataSources)this.isOverlay(t)&&!(0,zs.isLineTool)(t)&&this.recalculatePriceScale(t.priceScale(),e);this.updateAllViews(e),this._model.updatePane(this)}updateAllViews(e){const t=this._cachedOrderedSources.all();for(const i of t)i.updateAllViews(e);for(const t of this.model().customSources())t.updateViewsForPane(this,e)}updateLollipopViews(e){}priceScalePosition(e){return this._leftPriceScales.includes(e)?"left":this._rightPriceScales.includes(e)?"right":"overlay"}createPriceScaleAtPosition(e,t){const i=this.properties().childs().axisProperties.state();i.autoScale=!0
;const s=new mh(this.model().properties().childs().scalesProperties,i);return s.setHeight(this.height()),Ah(s,this._defaultTopMargin(),this._defaultBottomMargin()),this._placePriceScale(s,e,t),s}removePriceScale(e){e.modeChanged().unsubscribeAll(this),e.priceRangeChanged().unsubscribeAll(this),e.internalHeightChanged().unsubscribeAll(this),e.isVisible().unsubscribe(this._onPriceScaleIsVisibleChanged),e.resetScaleAvailable().unsubscribe(this._updateResetPriceScalesAvailableValue),e===this._lockedPriceScale&&(this._lockedPriceScale=null,this._currentPriceScaleRatio=null);const t=this._leftPriceScales.indexOf(e);-1!==t&&(this._leftPriceScales[t].invalidateMargins(),this._leftPriceScales.splice(t,1));const i=this._rightPriceScales.indexOf(e);if(-1!==i&&(this._rightPriceScales[i].invalidateMargins(),this._rightPriceScales.splice(i,1)),null===e.mainSource()){const t=e.dataSources().length;0!==t&&Mh.logError("Invalid priceScale state: empty mainSource but non-empty data sources="+t)}this._onPriceScalesChanged.fire(),this._updateResetPriceScalesAvailableValue()}priceScaleIndex(e,t){switch(t){case"left":return this.leftPriceScales().indexOf(e);case"right":return this.rightPriceScales().indexOf(e)}}move(e,t,i){const s=e.priceScale();this.removeSourceFromPriceScale(e),t.addDataSource(e),e.setPriceScale(t),t.invalidateMargins(),this._processMainSourceChange(),this._invalidateSourcesCache(),e.isIncludedInAutoScale()&&(null!==s&&this.recalculatePriceScale(s,(0,wi.sourceChangeEvent)(e.id())),this.recalculatePriceScale(t,(0,wi.sourceChangeEvent)(e.id()))),this._onPriceScalesChanged.fire()}setZOrders(e){e.forEach(((e,t)=>{t.setZorder(e)})),this._invalidateSourcesCache(),this._onDataSourcesZOrdersChanged(),0===this._bulkActions.activeCounter&&this._dataSourcesCollectionChanged.fire(),this.model().fullUpdate()}isMainPane(){return this._isMainPane.readonly()}isLast(){const e=this.model().panes();return e[e.length-1]===this}newStudyZOrder(){return(0,_l.newStudyZOrder)(this._priceDataSources)}newLineToolZOrder(e){return(0,_l.newLineToolZOrder)(this.m_dataSources,e)}model(){return this._model}containsMainSeries(){return this._sourcesById.has(this.model().mainSeries().id())}applyPriceScaleRatio(e,t){null!==this._lockedPriceScale&&this._lockedPriceScale!==e||this._currentPriceScaleRatio===t||!this.isMainPane().value()||null===this._lockedPriceScale&&e!==this.mainDataSource()?.priceScale()||(this._setNewPriceRangeByScaleRatio(e,t,this._mainSourceVisiblePriceRange(e),!0,!0),null!==this._lockedPriceScale?this._tryToApplyNewPriceScaleRatio():e.isLog()||this.model().mainSeriesScaleRatioPropertyOnChanged())}sendToBack(e){const t=this.sourcesByGroup().allExceptSpecialSources();this._batchReorder(e,t[0],_l.moveBeforeSource)}bringToFront(e){const t=this.sourcesByGroup().allExceptSpecialSources();this._batchReorder(e,t[t.length-1],_l.moveAfterSource)}sendBackward(e){const t=this.sourcesByGroup().allIncludingHidden(),i=t.indexOf(e[0]);if(0===i)this.bringToFront(e);else{const s=t[i-1];this.insertBefore(e,s)}}bringForward(e){
const t=this.sourcesByGroup().allExceptSpecialSources(),i=t.indexOf(e[e.length-1]);if(i===t.length-1)this.sendToBack(e);else{const s=t[i+1];this.insertAfter(e,s)}}insertAfter(e,t){this._batchReorder(e,t,_l.moveAfterSource)}insertBefore(e,t){this._batchReorder(e,t,_l.moveBeforeSource)}maximized(){return this._maximized}collapsed(){return this._collapsed}collapsingAvailable(){return this._collapsingAvailable}getPriceScaleById(e){const t=this.m_dataSources.find((t=>t.priceScale()?.id()===e));return void 0===t?null:t.priceScale()}priceScaleSelectionStrategy(){return this._priceScaleSelectionStrategy}setPriceScaleSelectionStrategy(e){this._priceScaleSelectionStrategy=e,e.apply(this)}findTargetPriceAxisViews(e,t,i,s){if((0,Po.isDataSource)(e)&&this.model().paneForSource(e)!==this)return[];const o=e.priceScale();if(t===o)return i;if(null===o)return[];if("overlay"===this.priceScalePosition(o))return t===this.defaultPriceScale()?i:[];const n=this.priceScalePosition(t);if(n!==this.priceScalePosition(o))return[];const r="left"===n?this.leftPriceScales():this.rightPriceScales();return r.indexOf(t)<r.indexOf(o)?s:[]}actionNoScaleIsEnabled(e){return!(!this.isOverlay(e)&&(0,An.isPriceDataSource)(e))||this._nonOverlayPricesSourcesCount()>1}properties(){return this._properties}setPriceAutoScale(e,t){e.setMode({autoScale:t}),this.timeScale().isEmpty()||this.recalculatePriceScale(e,(0,wi.viewportChangeEvent)())}state(e){const{withData:t,skipLineToolsFromOtherSymbols:i,wipeSensitiveData:s,skipLineTools:o,skipNonSharedLineTools:n,skipHiddenSources:r,includeSources:a,isStudyTemplate:l}=e??{},c={sources:[],mainSourceId:this.m_mainDataSource?.id(),stretchFactor:this._stretchFactor,leftAxisesState:[],rightAxisesState:[],overlayPriceScales:{},priceScaleRatio:this._currentPriceScaleRatio,isCollapsed:this._collapsed.value(),isMaximized:this._maximized.value(),mode:this._mode},h=new Map,d=new Map,u=e=>{if(h.has(e))return h.get(e);let t=!1;if((0,Ws.isStudy)(e))t=!(e.isVisible()||e.hasChildren()&&e.getAllChildren().some((e=>e.isVisible())));else if((0,zs.isLineTool)(e))if(e.isVisible()){const i=e.ownerSource();t=!!i&&u(i)}else t=!0;return h.set(e,t),t},_=e=>{if(d.has(e))return d.get(e);let a=null;const c=l&&!e.isSavedInStudyTemplates()||!e.state||(0,zs.isLineTool)(e)&&o||r&&u(e)||!e.isSavedInChart(Boolean(t))||!(a=e.state(t,s))||i&&(0,zs.isLineTool)(e)&&e.isActualSymbol&&!e.isActualSymbol()||n&&(0,zs.isLineTool)(e)&&0===e.sharingMode().value()||e.isPhantom()?null:a;return d.set(e,c),c};if(a){c.sources=[];for(let e=0;e<this.m_dataSources.length;e++){const t=_(this.m_dataSources[e]);null!==t&&c.sources.push(t)}}const p=e=>null!==d.get(e),m=e=>!o||!(0,zs.isLineTool)(e);c.leftAxisesState=this._leftPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(p).filter(m).map((e=>e.id()))}))),c.rightAxisesState=this._rightPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(p).filter(m).map((e=>e.id()))}))),c.overlayPriceScales={};for(const e of this.m_dataSources)if(this.isOverlay(e)&&e.isSavedInChart(Boolean(t))){
const t=e.priceScale();c.overlayPriceScales[e.id()]=t?.state()??null}return c}restoreState(e){const{state:t,withData:i,version:s,seriesId:o=this._model.mainSeries().id(),settingsMigration:r={},contentOverrides:a,restoreSilently:l,reason:c=0}=e;(0,Hc.getPersistentLogger)()?.addPersistentLogEntry(`Restoring pane with seriesId ${o}`,ne.LOGLEVEL.INFO,Lh),this._mode=t.mode??zi.PaneMode.Regular,t.stretchFactor&&(this._stretchFactor=t.stretchFactor);const d={};if(t.sources){const e=t.sources.filter((e=>!!e&&("MainSeries"===e.type||(!e.points?.some((e=>null===e.time_t||!isFinite(e.time_t)))||(Mh.logNormal("Dropped invalid "+e.type+". Reason: non-numeric point time"),!1))))),n=e.findIndex(wt.isMainSeriesState);-1!==n&&this.model().mainSeries().setObsoleteZOrder(e[n].zorder),s<3&&(0,_l.reorderDataSourcesStateZOrder)(e);const h=-1!==this.m_dataSources.indexOf(this._model.mainSeries());this.clearSeries(Boolean(l)),this.m_mainDataSource=null,h&&this._addSourceToCollections(this._model.mainSeries(),l),(()=>{const i=e.find((e=>e.id===t.mainSourceId));if(void 0===i)return void Mh.logWarn("There is no main source with id "+t.mainSourceId+", total sources="+e.length);if(!window.TradingView[i.type]||!(0,Lt.isLineToolName)(i.type))return void Mh.logNormal("The type of main source is not line tool - fix is unnecessary");let s=null;for(const t of e)if(!window.TradingView[i.type]||!(0,Lt.isLineToolName)(t.type)){if(null!==s)return void Mh.logWarn("Pane contains more than 1 possibly main sources - auto fix cannot be applied");s=t}if(null===s)return void Mh.logWarn("Pane contains only line tools - possible we need to remove this pane?");const o=t.mainSourceId;let n=0;t.mainSourceId=s.id,e.forEach((e=>{e.ownerSource===o&&(e.ownerSource=s?.id,n+=1)})),Mh.logNormal("Auto fix broken pane is applied, changed line tools="+n+", changed from="+o+" to="+s.id)})();for(const t of e)if("study_Sessions"===t.type){const e=t;e.oldState=!0,this.model().sessions().restoreState(e,i);break}for(const t of e)"study_Sessions"!==t.type&&(null===this._model.dataSourceForId(t.id)||"MainSeries"===t.type?(d[t.id]=t.ownerSource,(0,wt.isMainSeriesState)(t)?this._restoreMainSeries(t,i,h,r,a,l):(0,wt.isStudyState)(t)?this.restoreStudy(t,i,o,r,l,c):(0,wt.isLineToolState)(t)&&(t.state&&(t.state.zOrderVersion=2),this.restoreLineTool({state:t,withData:i,restoreSilently:l}))):Mh.logError("Duplicate id while restoring pane: "+t.type+","+t.id))}const u=new Set,_=(e,t)=>{e.priceScale()!==t&&(this.removeSourceFromPriceScale(e),e.setPriceScale(t),t.addDataSource(e))},p=(e,i,s)=>{if(u.has(e))return;u.add(e);const o=s.m_showSymbolLabels;void 0!==o&&e===this.model().mainSeries()&&this.model().properties().childs().scalesProperties.childs().showSymbolLabels.setValue(o),this._model.children(e,!0,!0).forEach((e=>{t.overlayPriceScales?.[e.id()]||p(e,i,s)})),_(e,i)},m=e=>{const t=(0,h.defaults)("chartproperties").paneProperties.axisProperties,i=new mh(this.model().properties().childs().scalesProperties,t);return i.restoreState(e.state),i.setHeight(this._height),e.sources.forEach((e=>{
const s=this.dataSourceForId(e);s&&p(s,i,t)})),0===i.dataSources().length?null:i},g=e=>e.map(m).filter((e=>null!==e));let f;if(t.leftAxisesState)f=g(t.leftAxisesState);else{const e=m({state:t.leftAxisState,sources:t.leftAxisSources});f=null!==e?[e]:[]}let y;if(this._leftPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._leftPriceScales=[],f.forEach((e=>this._placePriceScale(e,"left"))),t.rightAxisesState)y=g(t.rightAxisesState);else{const e=m({state:t.rightAxisState,sources:t.rightAxisSources});y=null!==e?[e]:[]}this._rightPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._rightPriceScales=[],y.forEach((e=>this._placePriceScale(e,"right"))),this._currentPriceScaleRatio=t.priceScaleRatio||t.leftPriceScaleRatio||t.rightPriceScaleRatio||null;const v=new Map;for(const e of this.m_dataSources){if(u.has(e))continue;let i;if(t.overlayPriceScales&&t.overlayPriceScales[e.id()]){let s=t.overlayPriceScales[e.id()];v.has(s?.id)?i=v.get(s?.id):(s=(0,n.ensure)(s),i=new mh(this._model.properties().childs().scalesProperties),i.setHeight(this._height),s.m_isAutoScale=!0,s.m_isLog=!1,s.m_isPercentage=!1,s.m_isLockScale=!1,i.restoreState(s),v.set(s.id,i))}else i=new mh(this._model.properties().childs().scalesProperties),i.setHeight(this._height);_(e,i)}for(const e of Object.keys(d)){const t=d[e],i=this.dataSourceForId(e);t&&i&&null===i.ownerSource()&&i.setOwnerSource(this.dataSourceForId(t))}if(t.mainSourceId&&!this.containsMainSeries()&&(this.m_mainDataSource=this.dataSourceForId(t.mainSourceId)),!this.m_mainDataSource)for(const e of this.m_dataSources)if((0,An.isPriceDataSource)(e)){this.m_mainDataSource=e;break}for(const e of this.m_dataSources)(0,zs.isLineTool)(e)?(e.ownerSource()||e.setOwnerSource(this.mainDataSource()),e.isFixed()&&e.restoreFixedPoint()):(0,Ws.isStudy)(e)&&!e.ownerSource()&&e.isLinkedToSeries()&&e.setOwnerSource(this.model().mainSeries());this._collapsed.setValue(t.isCollapsed??!1),t.isMaximized&&this._model.setMaximizedPane(this),this._updateMargins(),this._cachedOrderedSources.clear()}onPriceScalesChanged(){return this._onPriceScalesChanged}setPaneSize(e){let t;switch(e){case"large":t=1;break;case"medium":t=.6;break;case"small":t=.3;break;case"tiny":t=.15;break;default:throw new Error("Unknown size enum value: "+e)}this._stretchFactor=1e3*t}stretchFactor(){return this._stretchFactor}setStretchFactor(e){this._stretchFactor=e}customSources(e){return this.model().customSources(e)}createDrawingsCaches(){Gc.ExecutionsPositionController.recreateOrderedByBarsSourcesCache(this)}clearDrawingCaches(){Gc.ExecutionsPositionController.clearOrderedByBarsSourcesCache()}executionsPositionController(){return this._executionsPositionController||(this._executionsPositionController=new Gc.ExecutionsPositionController(this)),this._executionsPositionController}width(){return this._width}height(){return this._height}setHeight(e){if(this._height!==e&&(this._height=e,this._mode===zi.PaneMode.Regular)){this._leftPriceScales.forEach((t=>t.setHeight(e))),this._rightPriceScales.forEach((t=>t.setHeight(e)))
;for(let t=0;t<this.m_dataSources.length;t++){const i=this.m_dataSources[t];this.isOverlay(i)&&i.priceScale()&&(0,n.ensureNotNull)(i.priceScale()).setHeight(e)}this.updateAllViews((0,wi.viewportChangeEvent)()),this._sizeChanged.fire()}}setWidth(e){return this._width!==e&&(this._width=e,this.updateAllViews((0,wi.viewportChangeEvent)()),this._sizeChanged.fire(),!0)}onSizeChanged(){return this._sizeChanged}onTagsChanged(){return this._tagsChanged}onDestroyed(){return this._destroyed}dataSourcesCollectionChanged(){return this._dataSourcesCollectionChanged}dataSourcesZOrdersChanged(){return this._dataSourcesZOrdersChanged}symbolSourceCollectionChanged(){return this._symbolSourceCollectionChanged}priceSourcesCollectionChanged(){return this._priceSourcesCollectionChanged}symbolSourceResolved(){return this._symbolSourceResolved}symbolSourceResolvingActive(){return this._symbolSourceResolvingActive}sourcePropertiesChanged(){return this._sourcePropertiesChanged}sourceZOrderChanged(){return this._sourcesZOrderChanged}lineToolsForArea(e,t){const i=this.logicalRectToPixels(e);return[...this.m_dataSources,...this.model().multiPaneSources(this)].filter(zs.isLineTool).filter((e=>(e.paneViews(this)||[]).some((e=>{const s=e.renderer(t);return s&&s.doesIntersectWithBox&&s.doesIntersectWithBox(i,t)}))))}logicalRectToPixels(e){const t=this.defaultPriceScale(),i=this.timeScale(),s=(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainSource()).firstValue()),o=t.priceToCoordinate(e.p1.price,s),r=i.indexToCoordinate(e.p1.index),a=t.priceToCoordinate(e.p2.price,s),l=i.indexToCoordinate(e.p2.index),c=new Vt.Point(Math.min(r,l),Math.min(o,a)),h=new Vt.Point(Math.max(r,l),Math.max(o,a));return(0,Vt.box)(c,h)}timeScale(){return this._timeScale}restoreLineTool(e){const{withData:t,restoreSilently:i,actionSource:s,ownerSource:o}=e;let{keepZOrder:r,state:a}=e;if((0,Lt.isMtpPredictorToolName)(a.type))return Mh.logWarn(`No longer supported tool ${a.type} is skipped while restoring state`),null;const l=o??(a.ownerSource?this._model.dataSourceForId(a.ownerSource):null);delete a.state.lastUpdateTime,a.state.intervalsVisibilities=(0,bh.mergeIntervalVisibilitiesDefaults)(a.state.intervalsVisibilities),r=void 0===r||r,Sh.LineToolElliott.migrateState(a),function(e){"LineToolGannComplex"!==e.type||void 0!==e.version&&1!==e.version||(e.type="LineToolGannFixed")}(a),Array.isArray(a.positionPercents)&&(a.positionPercents=a.positionPercents[0]);const c=a.type,h=a.id,d=a.state,u=r?a.zorder:this.newLineToolZOrder();(0,n.assert)((0,Lt.isLineToolName)(c),"invalid data source type:"+c+" (expected to be a Line Tool)");let _,p,m=null;if((0,wt.isStudyLineToolState)(a)){m=this._model.isSnapshot()?new Ch.StudyVersioning([],[]):(0,os.studyMetaInfoRepository)().studyVersioning();const e=Ch.StudyVersioning.patchPointsBasedStudyState(a);a=e;const t=new ns.StudyMetaInfo(e.metaInfo);0;const i=m.updateMetaInfo(t)??t;p=(0,zs.createStudyLineToolProperties)(this._model.backgroundTheme().spawnOwnership(),c,t,i,d,m),_=(0,zs.createLineTool)(c,this._model,p,i,!0,void 0,s)}else p=(0,
zs.createLineToolProperties)(this._model.backgroundTheme().spawnOwnership(),c,!this._model.readOnly(),d),_=(0,zs.createLineTool)(c,this._model,p,null,!0,void 0,s);_.setId(h),_.linkKey().setValue(a.linkKey||null);a.alertId&&_.canHasAlert();let g=a.indexes??[];if(g=g.slice(0,a.points?.length??g.length),_.isFixed()?void 0!==a.positionPercents?_.restorePositionPercents(a.positionPercents):_.restorePositionPercents({x:.5,y:.5}):a.points&&_.restorePoints(a.points,g,t),(0,zs.isLineTool)(_)&&["LineToolBarsPattern","LineToolCallout","LineToolTrendAngle","LineToolGhostFeed","LineToolParallelChannel"].includes(_.toolname))_.restoreData?.(a);else if(t&&(0,wt.isStudyLineToolState)(a)&&_.restoreData){const e=a;m&&(e.graphics=Ch.StudyVersioning.patchPointsBasedStudyData(new ns.StudyMetaInfo(e.metaInfo),e.graphics)),_.restoreData?.(e)}const f=null==a.version?1:a.version,y=null==_.version?1:_.version;return f!==y&&_.migrateVersion?.(f,y,{pane:this,model:this._model,properties:p}),void 0!==u&&_.setZorder(u),o&&(0,zs.prepareLineToolPropertiesByOwnerSource)(p,o),_.setOwnerSource(l),_.isFixed()&&_.restoreFixedPoint(),void 0!==a.userEditEnabled&&_.setUserEditEnabled(a.userEditEnabled),void 0!==a.isSelectionEnabled&&_.setSelectionEnabled(a.isSelectionEnabled),this._addSourceToCollections(_,i),this._cachedOrderedSources.clear(),_}restoreStudy(e,t,s,o,n,r){if(t&&void 0===e.data&&void 0===e.nonSeriesData&&void 0===e.indexes)return Mh.logError("Cannot restore (skipping) study without data "+e.id+", "+e.metaInfo.id),null;const l=e.id,c=e.state,h=e.zorder;s=s??this._model.mainSeries().id();const d=(e.parentSources??(e.ownerSource?[e.ownerSource]:[])).filter((e=>e!==s)),u=new ns.StudyMetaInfo(e.metaInfo),_=e.metaInfoPatch?(0,Qe.default)((0,Al.default)(e.metaInfo),e.metaInfoPatch):e.metaInfo;let p=new ns.StudyMetaInfo(_);if(function(e){return"Script$TV_EARNINGS@tv-scripting"===e||"Script$TV_DIVIDENDS@tv-scripting"===e||"Script$TV_SPLITS@tv-scripting"===e||"ESD$TV_EARNINGS@tv-scripting"===e||"ESD$TV_DIVIDENDS@tv-scripting"===e||"ESD$TV_SPLITS@tv-scripting"===e||"Earnings@tv-basicstudies"===e||"Dividends@tv-basicstudies"===e||"Splits@tv-basicstudies"===e||"BarSetContinuousRollDates@tv-corestudies"===e}(p.id)&&!t)return Mh.logNormal("Skipping study "+p.id),null;let m=c;const g=new Zr.StudyStub(this._model,e,p.shortDescription??p.name);g.setId(l),g.setZorder(h);const f=vh.instance(this._model);f.get(l);let y=!1;const v=(i,s,o)=>{if(y&&this._model.dataSourceForId(l)!==g)return;g.setStatus({type:gh.StudyStatusType.Undefined});const n=async n=>{const a=(0,Zl.prepareStudyPropertiesForLoadChart)(p,i,m,o),c=i??p,h=s??u,d=!t&&c.isTVScript&&e.metaInfo.isTVScript&&c._serverMetaInfoVersion!==e.metaInfo._serverMetaInfoVersion,_=await(0,Ws.createStudy)(this._model,a,n,c,h,void 0,r,d);if(_.setId(l),_.setOwnFirstValue(e.ownFirstValue??null),e.customFields&&_.restoreStateCustomFields(e.customFields),t){const t=e,{data:i,nsData:s,indexes:o}=Ch.StudyVersioning.patchStudyData(p,t.data,t.nonSeriesData,t.indexes);_.restoreData(i,s,o)}this._model.replaceStudyStub(g,_),
f.add(l,_)};if(d.length>0){const e=d.map((e=>f.get(e)));Promise.all(e).then(n)}else n([])},S=(0,Al.default)(c);let b;if(t){const e=Ch.StudyVersioning.patchPropsStateAndMetaInfo(c,p,{oldShowStudyLastValueProperty:!o?.showStudyLastValueProperty}),t=Ch.StudyVersioning.patchPropsStateAndMetaInfo(S,u,{oldShowStudyLastValueProperty:!o?.showStudyLastValueProperty});b=[Promise.resolve(new ns.StudyMetaInfo(e.metaInfo)),Promise.resolve(new ns.StudyMetaInfo(t.metaInfo))]}else{const e=(0,os.studyMetaInfoRepository)().requestMetaInfo();b=[p,u].map(((i,s)=>e.then((()=>{const e=Ch.StudyVersioning.patchPropsStateAndMetaInfo(0===s?c:S,i,{oldShowStudyLastValueProperty:t&&!o?.showStudyLastValueProperty});return m=e.propsState,new ns.StudyMetaInfo(e.metaInfo)}))))}Promise.all(b).then((([e,t])=>{const s=this._model.isSnapshot()?new Ch.StudyVersioning([],[]):(0,os.studyMetaInfoRepository)().studyVersioning();if(this._model.isSnapshot())return void v(e,t,s);const o=[e,t].map(((e,t)=>s.updateMetaInfoAsync(e,1===t))).map((e=>e.sync?Promise.resolve(e.result):e.result));Promise.all(o).then((i=>v(i[0]??e,i[1]??t,s))).catch((e=>{"To use it, ask the author to publish the script."===e?g.setFailed(e,a.t(null,void 0,i(33599))):g.setFailed("error: "+e)}))})).catch((()=>g.setFailed(a.t(null,void 0,i(63183))))),g.setZorder(h);const w=e.metaInfo.linkedToSeries?this._model.mainSeries():d.length?this.dataSourceForId(d[0]):null;return g.setOwnerSource(w),this._addSourceToCollections(g,n),y=!0,this._processMainSourceChange(),this._cachedOrderedSources.clear(),g}clipboardLineToolOwnerSource(e){const t=this.dataSourceForId(e);if(null!==t){const e=t.ownerSource();if(null!==e&&null!==e.firstValue())return e}const i=this.mainDataSource();if(null!==i&&null!==i.firstValue())return i;for(const e of this.dataSources())if((0,An.isPriceDataSource)(e)&&null!==e.firstValue())return e;return null}realignLineTools(e){let t=!1;for(const i of this.m_dataSources)!(0,zs.isLineTool)(i)||void 0!==e&&i?.ownerSource()?.symbolSource()!==e&&(0,Lr.isActingAsSymbolSource)(e)||(i.realign(),i.updateAllViews((0,wi.sourceChangeEvent)(i.id())),t=!0);return t&&this._invalidateSourcesCache(),t}startScalePrice(e,t){e.startScale(t)}scalePriceTo(e,t){e.scaleTo(t),this.updateAllViews((0,wi.viewportChangeEvent)())}endScalePrice(e){e.endScale()}startScrollPrice(e,t){e.startScroll(t)}scrollPriceTo(e,t){e.scrollTo(t),this.updateAllViews((0,wi.viewportChangeEvent)())}endScrollPrice(e){e.endScroll()}resetPriceScale(e){const t=this.timeScale().visibleBarsStrictRange();e.resetScaleAvailable().value()&&e.resetScale(),e.recalculatePriceRange(t),this.updateAllViews((0,wi.viewportChangeEvent)())}resetPriceScalesAvailable(){return this._resetPriceScalesAvailable.readonly()}restorePriceScaleState(e,t){e.restoreState(t),this.updateAllViews((0,wi.viewportChangeEvent)())}beginInsertManyLineDataSources(){this._isInInsertManyDataSourcesState=!0,this._lastLineDataSourceZOrder=null}endInsertManyLineDataSources(){this._isInInsertManyDataSourcesState=!1,this._lastLineDataSourceZOrder=null}
removeSourceFromPriceScale(e){const t=e.priceScale();if(null!==t){const i=t.dataSources();i.indexOf(e)>=0&&t.removeDataSource(e),0===i.length&&this.removePriceScale(t)}}_invalidateSourcesCache(){this._cachedOrderedSources.clear(),this._leftPriceScales.forEach((e=>e.invalidateSourcesCache())),this._rightPriceScales.forEach((e=>e.invalidateSourcesCache()))}_processMainSourceChange(){let e=!1;if(null===this.m_mainDataSource)for(const t of this.m_dataSources)if((0,An.isPriceDataSource)(t)&&!this.isOverlay(t)&&(!(0,Ws.isStudy)(t)||!t.isLinkedToSeries())){this.m_mainDataSource=t,e=!0;break}if(this.m_mainDataSource&&e){let e=this.m_dataSources.filter(zs.isLineTool);e=(0,vi.sortSources)(e);for(const t of e)this.move(t,(0,n.ensureNotNull)(this.m_mainDataSource.priceScale()),!0)}else if(!this.m_mainDataSource||this.isOverlay(this.m_mainDataSource)&&0===this._nonOverlayPricesSourcesCount()){let e=null;if(this.m_dataSources.includes(this._model.mainSeries()))e=this._model.mainSeries();else for(const t of this.m_dataSources)if((0,An.isPriceDataSource)(t)&&this.isOverlay(t)&&t.showInObjectTree()){e=t;break}if(null!==e){const t=this.m_mainDataSource===e;this.m_mainDataSource=e;const i=this.createNewPriceScaleIfPossible();if(t&&e===this._model.mainSeries()){const t=(0,n.ensureNotNull)(e.priceScale());this._model.children(e,!0,!0).forEach((e=>{this.removeSourceFromPriceScale(e),i.addDataSource(e),e.setPriceScale(i)})),this.removePriceScale(t)}this.move(e,i,!0),this.recalculatePriceScale(e.priceScale(),(0,wi.globalChangeEvent)())}}}_addSourceToCollections(e,t){this.m_dataSources.push(e),this._sourcesById.set(e.id(),e),this._invalidateSourcesCache();const i=()=>{this._sourcePropertiesChanged.fire(e)};if(e.properties().subscribe(this,i),e.zOrderChanged().subscribe(this,(t=>this._sourcesZOrderChanged.fire(e,t))),(0,zs.isLineTool)(e)){e.normalizedPointsChanged().subscribe(this,i),e.fixedPointChanged().subscribe(this,i),e.onIsActualSymbolChange().subscribe(this,(()=>this._invalidateSourcesCache())),e.hasAlert().subscribe(i),e.sharingMode().subscribe(i);const t=()=>{this._lineToolsByLinkKey.removeByKey2(e.id()),this._lineToolsByLinkKey.add(e)};e.linkKey().subscribe(t),this._sourceWatchedValuesSubscriptions.set(e.id(),{linkKeyCallback:t,commonCallback:i}),this._lineToolsByLinkKey.add(e)}const s=(0,Lr.isSymbolSource)(e)?e:null;(0,An.isPriceDataSource)(e)&&(this._priceSourcesById.set(e.id(),e),e.currencyChanged().subscribe(this,(()=>this._invalidateSourcesCache())),e.unitChanged().subscribe(this,(()=>this._invalidateSourcesCache())),this._priceDataSources.push(e),(0,Ws.isStudy)(e)&&this._studySources.push(e),this._onPriceSourcesCollectionChanged(),null!==s&&(this._symbolSources.push(s),s.symbolResolved().subscribe(this,(()=>this._symbolSourceResolved.fire(e))),s.symbolResolvingActive().subscribe(this._recalcSymbolSourceResolvingActive),s.symbolHibernated().subscribe(this._onSymbolSourceCollectionChanged),this._recalcSymbolSourceResolvingActive(),this._onSymbolSourceCollectionChanged(),
s===this._model.mainSeries()&&this._isMainPane.setValue(!0))),e.isMultiPaneAvailable()&&this.model().addMultiPaneSource(e),t||0!==this._bulkActions.activeCounter||this._dataSourcesCollectionChanged.fire()}_removeSourceFromCollections(e,t){const i=this.m_dataSources[e],s=i.id();if(i.properties().unsubscribeAll(this),i.zOrderChanged().unsubscribeAll(this),this.m_dataSources.splice(e,1),this._sourcesById.delete(i.id()),(0,zs.isLineTool)(i)){if(i.normalizedPointsChanged().unsubscribeAll(this),i.fixedPointChanged().unsubscribeAll(this),i.onIsActualSymbolChange().unsubscribeAll(this),this._sourceWatchedValuesSubscriptions.has(s)){const e=this._sourceWatchedValuesSubscriptions.get(s);e&&(i.hasAlert().unsubscribe(e.commonCallback),i.linkKey().unsubscribe(e.linkKeyCallback)),this._sourceWatchedValuesSubscriptions.delete(s)}this._lineToolsByLinkKey.removeByKey2(i.id())}this._invalidateSourcesCache();const o=(0,Lr.isSymbolSource)(i)?i:null;(0,An.isPriceDataSource)(i)&&(this._priceSourcesById.delete(i.id()),i.currencyChanged().unsubscribeAll(this),i.unitChanged().unsubscribeAll(this),(0,Pt.removeItemFromArray)(this._priceDataSources,i),(0,Ws.isStudy)(i)&&(0,Pt.removeItemFromArray)(this._studySources,i),this._onPriceSourcesCollectionChanged(),null!==o&&((0,Pt.removeItemFromArray)(this._symbolSources,o),o.symbolResolved().unsubscribeAll(this),o.symbolResolvingActive().unsubscribe(this._recalcSymbolSourceResolvingActive),o.symbolHibernated().unsubscribe(this._onSymbolSourceCollectionChanged),this._recalcSymbolSourceResolvingActive(),this._onSymbolSourceCollectionChanged(),o===this._model.mainSeries()&&this._isMainPane.setValue(!1))),i.isMultiPaneAvailable()&&this.model().removeMultiPaneSource(i),t||0!==this._bulkActions.activeCounter||this._dataSourcesCollectionChanged.fire()}_recalculatePriceScaleByScaleRatio(e){this.isMainPane().value()&&e===this._lockedPriceScale&&(null!==this._currentPriceScaleRatio?this._applyOldScaleRatioToPriceScale():this._tryToApplyNewPriceScaleRatio())}_defaultBottomMargin(){return.01*this.properties().childs().bottomMargin.value()}_defaultTopMargin(){return.01*this.properties().childs().topMargin.value()}_updateMargins(){const e=this._defaultTopMargin(),t=this._defaultBottomMargin();for(const i of this._leftPriceScales)Ah(i,e,t);for(const i of this._rightPriceScales)Ah(i,e,t);for(const i of this.m_dataSources)if(this.isOverlay(i)){const s=i.priceScale();null!==s&&(Ah(s,e,t),this.recalculatePriceScale(s,(0,wi.viewportChangeEvent)()))}for(const e of this._leftPriceScales)this.recalculatePriceScale(e,(0,wi.viewportChangeEvent)());for(const e of this._rightPriceScales)this.recalculatePriceScale(e,(0,wi.viewportChangeEvent)());this.updateAllViews((0,wi.viewportChangeEvent)())}_batchReorder(e,t,i){i(this.sourcesByGroup().allExceptSpecialSources(),e,t),this._invalidateSourcesCache(),this._dataSourcesCollectionChanged.fire(),this._onDataSourcesZOrdersChanged(),this.model().fullUpdate()}_placePriceScale(e,t,i){if("overlay"===t)return void e.invalidateMargins()
;const s="left"===t?this._leftPriceScales:this._rightPriceScales,o=void 0===i?s.length:i;s.splice(o,0,e),e.modeChanged().subscribe(this,this._onPriceScaleModeChanged.bind(this,e)),e.internalHeightChanged().subscribe(this,this._recalculatePriceScaleByScaleRatio.bind(this,e)),e.priceRangeChanged().subscribe(this,this._recalculateTimeScaleByScaleRatio.bind(this,e)),e.priceRangeChanged().subscribe(this,this._onPriceScaleSetMinMaxPriceRange.bind(this,e)),e.isVisible().subscribe(this._onPriceScaleIsVisibleChanged),e.resetScaleAvailable().subscribe(this._updateResetPriceScalesAvailableValue),e.isLockScale()&&((0,n.assert)(null===this._lockedPriceScale),this._lockedPriceScale=e,this._currentPriceScaleRatio=null),e.invalidateMargins(),this._onPriceScalesChanged.fire(),this._updateResetPriceScalesAvailableValue()}_onPriceScaleModeChanged(e,t,i){if(i.lockScale&&(this._lockedPriceScale!==e&&null!==this._lockedPriceScale&&this._lockedPriceScale.setMode({lockScale:!1}),this._lockedPriceScale=e,this._currentPriceScaleRatio=(0,Wl.scaleRatio)(this.timeScale(),e)),t.lockScale&&!i.lockScale&&(this._lockedPriceScale=null,this._currentPriceScaleRatio=null),t.percentage===i.percentage&&t.indexedTo100===i.indexedTo100)return;const s=this.timeScale().visibleBarsStrictRange();null!==s&&(e.recalculatePriceRange(s),e.updateAllViews((0,wi.viewportChangeEvent)()))}_applyOldScaleRatioToPriceScale(){this._isRecalculatingScales||null===this._currentPriceScaleRatio||null===this._lockedPriceScale||(this._isRecalculatingScales=!0,this._setNewPriceRangeByScaleRatio(this._lockedPriceScale,this._currentPriceScaleRatio,this._mainSourceVisiblePriceRange(this._lockedPriceScale)),this._isRecalculatingScales=!1)}_setNewPriceRangeByScaleRatio(e,t,i,s,o){const n=(0,Wl.priceRangeByScaleRatio)(e,this.timeScale().barSpacing(),t);e.setPriceRange(null!==n?n:i,s,o)}_applyOldScaleRatioToTimeScale(){this._isRecalculatingScales||null===this._currentPriceScaleRatio||(this._isRecalculatingScales=!0,this._setNewBarSpacingByScaleRatio(),this._isRecalculatingScales=!1)}_tryToApplyNewPriceScaleRatio(){const e=(0,n.ensureNotNull)(this._lockedPriceScale),t=(0,Wl.scaleRatio)(this.timeScale(),e);this._currentPriceScaleRatio===t||e.isLog()||(this._currentPriceScaleRatio=t,this.model().mainSeriesScaleRatioPropertyOnChanged())}_recalculateTimeScaleByScaleRatio(e){e===this._lockedPriceScale&&(null!==this._currentPriceScaleRatio?this._applyOldScaleRatioToTimeScale():this._tryToApplyNewPriceScaleRatio())}_setNewBarSpacingByScaleRatio(){const e=this.timeScale().getValidBarSpacing((0,Wl.barSpacingByScaleRatio)((0,n.ensureNotNull)(this._lockedPriceScale),this._currentPriceScaleRatio));this.timeScale().isValidBarSpacing(e)&&this.timeScale().setBarSpacing(e)}_mainSourceVisiblePriceRange(e){const t=this.timeScale().visibleBarsStrictRange();return null!==t?(0,n.ensureNotNull)((0,n.ensureNotNull)(e.mainSource()).priceRange(t.firstBar(),t.lastBar(),{targetPriceScale:e,scaleSeriesOnly:e.isScaleSeriesOnly()})):new Qc.PriceRange(-.5,.5)}_setMinMaxPriceRange(){const e=(0,
n.ensureNotNull)(this._lockedPriceScale),t=(0,Wl.priceRangeByScaleRatio)(e,this.timeScale().maxBarSpacing(),this._currentPriceScaleRatio),i=(0,Wl.priceRangeByScaleRatio)(e,this.timeScale().minBarSpacing(),this._currentPriceScaleRatio);null!==t&&e.setMaxPriceRange(t),null!==i&&e.setMinPriceRange(i)}_onPriceScaleSetMinMaxPriceRange(e){e===this._lockedPriceScale&&this._setMinMaxPriceRange()}_onDataSourcesZOrdersChanged(){0===this._bulkActions.activeCounter?this._dataSourcesZOrdersChanged.fire():this._bulkActions.dataSourcesZOrdersChanged=!0}_onPriceSourcesCollectionChanged(){0===this._bulkActions.activeCounter?this._priceSourcesCollectionChanged.fire():this._bulkActions.priceSourcesCollectionChanged=!0}_nonOverlayPricesSourcesCount(){return this.m_dataSources.filter((e=>(!(0,Ws.isStudy)(e)||!e.isLinkedToSeries())&&((0,An.isPriceDataSource)(e)&&e.showInObjectTree()&&!this.isOverlay(e)))).length}_restoreMainSeries(e,t,i,s,o,r){const a=e.id,l=e.state;if(l&&o&&(l.style=o.style??l.style,l.interval=o.interval||l.interval,o.symbol&&o.symbol!==l.symbol&&(l.symbol=o.symbol,delete l.currencyId,delete l.unitId)),l&&["candleStyle","hollowCandleStyle","haStyle"].forEach((e=>{l[e]&&(l[e].wickUpColor=l[e].wickUpColor||l[e].wickColor,l[e].wickDownColor=l[e].wickDownColor||l[e].wickColor)})),l&&(l.statusViewStyle=l.statusViewStyle||{},!l.statusViewStyle.symbolTextSource)){const e=!!l.statusViewStyle.showSymbolAsDescription;l.statusViewStyle.symbolTextSource=e?"ticker":"description"}if(l){l.extendedHours?l.sessionId="extended":l.sessionId||(l.sessionId="regular"),delete l.extendedHours,(0,wh.allChartStyles)().includes(l.style)||(l.style=2);const e=l.lineStyle.styleType;let t;delete l.lineStyle.styleType,0===e&&(t=14,l.lineWithMarkersStyle=(0,tt.clone)(l.lineStyle)),1===e&&(t=15,l.steplineStyle=(0,tt.clone)(l.lineStyle)),void 0!==t&&2===l.style&&(l.style=t)}if(l)for(const e of["lineStyle","lineWithMarkersStyle","steplineStyle"])Ph(l[e]);if(!i){const e=this._model.mainSeries();(0,n.ensureNotNull)(this._model.mainPane()).removeDataSource(e,!1,r),this._addSourceToCollections(e,r)}const c=this.model().mainSeries(),h=c.properties().childs();this.m_mainDataSource=c;const d=l&&l.style?l.style:void 0;6===d&&"ATR"===h.pnfStyle.childs().inputs.childs().style.value()?h.pnfStyle.childs().inputs.childs().style.setValueSilently("Traditional"):4===d&&"ATR"===h.renkoStyle.childs().inputs.childs().style.value()&&h.renkoStyle.childs().inputs.childs().style.setValueSilently("Traditional"),l&&!l.hasOwnProperty("showSessions")&&(l.showSessions=!1),l&&void 0===l.settlementAsClose&&(l.settlementAsClose=!1),l&&t&&(l.showCountdown=!1),l&&(t&&!("showSeriesLastValueProperty"in s)&&"showLastValue"in l&&this._model.properties().childs().scalesProperties.childs().showSeriesLastValue.setValue(l.showLastValue),delete l.showLastValue),l&&this._restoreMainSeriesStudyInputs(e,c.styleStudyInfos());const u=c.sessionId();(0,Hc.getPersistentLogger)()?.addPersistentLogEntry(`Restore series. source.id: ${e.id} id: ${a}`,ne.LOGLEVEL.INFO,Lh),c.restoreState(e,t),
this.changeSourceId(c,a),(0,Hc.getPersistentLogger)()?.addPersistentLogEntry(`Series has been successfully restored. id: ${c.id()}`,ne.LOGLEVEL.INFO,Lh),c.sessionId()!==u&&h.sessionId.fireChanged()}async _restoreMainSeriesStudyInputs(e,t){await(0,os.studyMetaInfoRepository)().requestMetaInfo();const i=(0,os.studyMetaInfoRepository)().studyVersioning(),s={haStyle:(0,xt.chartStyleStudyId)(8,!0),renkoStyle:(0,xt.chartStyleStudyId)(4,!0),pbStyle:(0,xt.chartStyleStudyId)(7,!0),kagiStyle:(0,xt.chartStyleStudyId)(5,!0),pnfStyle:(0,xt.chartStyleStudyId)(6,!0),rangeStyle:(0,xt.chartStyleStudyId)(11,!0),volFootprintStyle:(0,xt.chartStyleStudyId)(17,!0),tpoStyle:(0,xt.chartStyleStudyId)(18,!0),svpStyle:(0,xt.chartStyleStudyId)(20,!0)},o={},r=(0,n.ensureDefined)(e.state);for(const[n]of Object.entries(bt.SYMBOL_STRING_DATA)){const a=`${bt.STYLE_SHORT_NAMES[n]}Style`,l=r[a]?.inputs;if(null==l)continue;const c=a in e?e[a].studyId:s[a],h=ns.StudyMetaInfo.parseIdString(c),d=t[a].studyId,u=ns.StudyMetaInfo.parseIdString(d),_=i.updateStudyInputs(h.id,h.version,u.version,l.inputs,null);o[a]={inputs:_}}this.model().mainSeries().properties().mergeAndFire(o)}_restoreSpecialSource(e,t,i){}_processAfterBulkAction(){const e=this._bulkActions;0===e.activeCounter&&(this._dataSourcesCollectionChanged.fire(),e.symbolSourceCollectionChanged&&(this._symbolSourceCollectionChanged.fire(),e.symbolSourceCollectionChanged=!1),e.priceSourcesCollectionChanged&&(this._priceSourcesCollectionChanged.fire(),e.priceSourcesCollectionChanged=!1),e.dataSourcesZOrdersChanged&&(this._dataSourcesZOrdersChanged.fire(),e.dataSourcesZOrdersChanged=!1))}}var Eh,Dh=i(28001);!function(e){e[e.Contains=0]="Contains",e[e.PlacedBefore=1]="PlacedBefore",e[e.PlacedAfter=2]="PlacedAfter"}(Eh||(Eh={}));class Bh{constructor(e,t){(0,n.assert)(e<=t,"The left value should be greater than or equal to the right value"),this._left=e,this._right=t}left(){return this._left}right(){return this._right}length(){return this._right-this._left+1}contains(e,t){return e<this._left-.5?!0===t&&1:e>this._right+.5?!0===t&&2:!0!==t||0}before(e){return e<this._left-.5}after(e){return e>this._right+.5}intersects(e){return!(this.after(e.left())||this.before(e.right()))}equals(e){return this._left===e.left()&&this._right===e.right()}static compare(e,t){return null===e||null===t?e===t:e.equals(t)}}const Vh=(0,ne.getLogger)("Chart.TimePoints");function Rh(e,t){return null===e||null===t?e===t:e.firstIndex===t.firstIndex&&e.lastIndex===t.lastIndex}var Nh;!function(e){e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Nearest=2]="Nearest"}(Nh||(Nh={}));class Oh{constructor(){this._zoffset=0,this._items=[],this._range=new yt.WatchedObject(null,Rh)}clear(){this._zoffset=0,this._items=[],this._range.setValue(null)}size(){return this._items.length}range(){return this._range.readonly()}merge(e,t,i){const s=this._mergeImpl(e,t,i);return this._updateFirstAndLastIndex(),s}addTail(e,t){for(let i=t?1:0;i<e.length;i++)this._items.push(e[i]);this._updateFirstAndLastIndex()}remove(e){const t=this._indexToOffset(e)
;if(null===t)return[];const i=this._items.splice(t),s=[];for(let t=0;t<i.length;t++)s.push({change:"remove",index:e+t,value:i[t]});return this._updateFirstAndLastIndex(),s}valueAt(e){const t=this._indexToOffset(e);return null!==t?this._items[t]:null}indexOf(e,t){if(this._items.length<1)return null;if(e>this._items[this._items.length-1])return t?this._validOffsetToIndex(this._items.length-1):null;for(let i=0;i<this._items.length;++i){if(e===this._items[i])return this._validOffsetToIndex(i);if(e<this._items[i])return t?this._validOffsetToIndex(i):null}return null}state(e){let t=0,i=this._items.length;return null!==e&&(t=this._indexToOffset(e.firstBar())??0,i=(this._indexToOffset(e.lastBar())??i-1)+1),{items:this._items.slice(t,i),zoffset:this._zoffset-t}}restoreState(e){null!==e&&(this._items=e.items,this._zoffset=e.zoffset,this._updateFirstAndLastIndex())}roughTime(e,t=null){e=Math.round(e);const i=this.valueAt(e);if(null!==i)return i;const s=this._items;if(!s.length||s.length<2)return null;const o=s.length-1,n=this._validOffsetToIndex(0),r=this._validOffsetToIndex(o),a=s[0],l=s[o],c=(l-a)/(r-n);if(e<n){return a-(n-e)*c}if(e>r){const i=e-r;if(i<500&&null!=t)return t(l,i);return l+i*c}return null}roughIndex(e,t=null,i=0){const s=this._items;if(!s.length||s.length<2)return null;const o=s.length-1,n=this._validOffsetToIndex(0),r=this._validOffsetToIndex(o),a=s[0],l=s[o];if(e>=a&&e<=l)return this._closestIndex(e,i);const c=(l-a)/(r-n);if(e<a){const t=a-e;return n-Math.round(t/c)}if(e>l){const i=e-l;let s=Math.trunc(i/c);if(s<500&&null!==t){const i=t(l,e);i.success&&(s=i.result)}return r+s}return null}closestIndexLeft(e){return this._closestIndex(e,0)}firstPoint(){return 0===this._items.length?null:this._items[0]}lastPoint(){return 0===this._items.length?null:this._items[this._items.length-1]}_closestIndex(e,t){const i=this._items;if(!i.length)return null;if(Number.isNaN(e))return null;const s=i.length-1;if(e>=i[s])return this._validOffsetToIndex(s);const o=(0,Pt.lowerbound)(this._items,e,((e,t)=>e<t));if(o<=s&&this._items[o]===e)return this._validOffsetToIndex(o);if(0===t)return 0===o?null:this._validOffsetToIndex(o-1);if(1===t)return o>s?null:this._validOffsetToIndex(o);const n=e-(this._items[o-1]??-1/0),r=(this._items[o]??1/0)-e;return this._validOffsetToIndex(n<r?o-1:o)}_mergeImpl(e,t,i){if(0===i.length)return Vh.logError("merge: 'values' does not contain any time points"),[];if(t>this._zoffset&&e+t>0)return Vh.logError("merge: when the first time point index is updated, we should fill the time points starting from the first one"),[];if(0===this._items.length)return this._items=i.slice(),this._zoffset=t,[{change:"rebuild",index:this._validOffsetToIndex(0)}];const s=e+this._zoffset;if(s<0){const o=Math.abs(s);if(i.length<o)return Vh.logError("merge: 'values' does not contain enough time points to fill in the new items. 'index': "+e.toString()+", previous 'zoffset': "+this._zoffset.toString()+", new 'zoffset': "+t.toString()+", 'values.length': "+i.length),[];this._items=new Array(o).concat(this._items),this._zoffset=t
;for(let s=0;s<i.length;++s)this._items[e+s+t]=i[s];return[{change:"rebuild",index:this._validOffsetToIndex(0)}]}const o=[];let n=s;for(;n<this._items.length&&n-s<i.length;++n)this._items[n]=i[n-s],o.push({change:"update",index:this._validOffsetToIndex(n),value:i[n-s]});const r=s+i.length;if(r>this._items.length){const e=r-this._items.length;for(let t=n;t<n+e;++t){const e=this._items.length;this._items.push(i[t-s]),o.push({change:"append",index:this._validOffsetToIndex(e),value:i[t-s]})}}else{for(let e=r;e<this._items.length;++e)o.push({change:"remove",index:this._validOffsetToIndex(e),value:this._items[e]});this._items.length=r}return this._zoffset=t,o}_updateFirstAndLastIndex(){const e=this._offsetToIndex(0),t=this._offsetToIndex(this._items.length-1);this._range.setValue(null===e||null===t?null:{firstIndex:e,lastIndex:t})}_validOffsetToIndex(e){return e-this._zoffset}_offsetToIndex(e){return 0<=e&&e<this.size()?this._validOffsetToIndex(e):null}_indexToOffset(e){const t=e+this._zoffset;return 0<=t&&t<this.size()?t:null}}var Fh=i(82284);const Wh=new Map([[0,.1],[11,.1],[1,.35],[9,.35],[12,.35],[8,.35]]);class Hh{constructor(e,t){this._styleSpecificRanges=new Map,this._logicalRange=e,this._defaultStyle=t}strictRange(e){if(null===this._logicalRange)return null;void 0===e&&(e=this._defaultStyle);let t=this._styleSpecificRanges.get(e);if(void 0===t){const i=(Wh.get(e)||0)/2;t=new Dh.BarsRange(Math.floor(this._logicalRange.left()+i),Math.ceil(this._logicalRange.right()-i)),this._styleSpecificRanges.set(e,t)}return t}logicalRange(){return this._logicalRange}isValid(){return null!==this._logicalRange}static invalid(){return new Hh(null,1)}}var zh=i(16659),Uh=i(82087),jh=i(20512);let Gh;var qh;!function(e){e[e.MarkPaddingFor14PxFont=5]="MarkPaddingFor14PxFont",e[e.MinMarkSizeFor14PxFont=50]="MinMarkSizeFor14PxFont",e[e.DefaultSkipItemsRatio=.5]="DefaultSkipItemsRatio",e[e.MaxDayAverageDeviationPercent=25]="MaxDayAverageDeviationPercent"}(qh||(qh={}));const $h=cr.YEAR_SPAN-1,Kh=cr.YEAR_SPAN-2,Yh=cr.DAY_SPAN-1,Zh=cr.HOUR_SPAN-1,Xh=cr.HOUR_SPAN-2,Jh=cr.HOUR_SPAN-3,Qh={[cr.MILLISECOND_SPAN]:1,[cr.HOUR_SPAN+2]:1,[cr.HOUR_SPAN+1]:1,[cr.SECOND_SPAN]:.9,[Kh]:.1,[cr.DAY_SPAN]:.85},ed={[cr.DAY_SPAN]:230};function td(e,t){switch(t){case"TimeWithMilliseconds":return new Uh.TimeFormatter(Uh.hourMinuteSecondMillisecFormat).format(e);case"TimeWithSeconds":case"Time":const s="TimeWithSeconds"===t?(0,jh.getHourMinuteSecondFormat)(we.timeHoursFormatProperty.value()):(0,jh.getHourMinuteFormat)(we.timeHoursFormatProperty.value());return new Uh.TimeFormatter(s).format(e);case"DayOfMonth":return e.getUTCDate().toString();case"Month":return(void 0===Gh&&(Gh=[a.t(null,void 0,i(62310)),a.t(null,void 0,i(2507)),a.t(null,void 0,i(92767)),a.t(null,void 0,i(27072)),a.t(null,{context:"short"},i(13132)),a.t(null,void 0,i(429)),a.t(null,void 0,i(53786)),a.t(null,void 0,i(46450)),a.t(null,void 0,i(6816)),a.t(null,void 0,i(12179)),a.t(null,void 0,i(26899)),a.t(null,void 0,i(32084))]),Gh)[e.getUTCMonth()];case"Year":return e.getUTCFullYear().toString()}}
const id=(0,_c.default)((e=>(0,si.parseFont)(e)?.size??12));function sd(e,t,i,s){const o=od(e,t),n=Math.max(e.width,s);return{left:o-n/2-i,right:o+n/2+i}}function od(e,t){return e.index*t}function nd(e,t){return t===e.length?null:e[t]}function rd(e,t,i,s,o){const n=sd(e,i,s,o),r=sd(t,i,s,o);return n.right>r.left}function ad(e){return new Date(1e3*e)}function ld(e){if(e.span>=cr.MONTH_SPAN&&e.span<cr.YEAR_SPAN){const t=(0,Ce.get_month)(ad(e.time));return t===Ce.JULY?$h:t===Ce.MARCH||t===Ce.MAY||t===Ce.SEPTEMBER||t===Ce.NOVEMBER?Kh:cr.MONTH_SPAN}if(e.span>=cr.MINUTE_SPAN&&e.span<cr.HOUR_SPAN){const t=(0,Ce.get_minutes)(ad(e.time));return t%30==0?Zh:t%15==0?Xh:t%5==0?Jh:cr.MINUTE_SPAN}if(e.span>=cr.HOUR_SPAN&&e.span<cr.DAY_SPAN){const t=(0,Ce.get_hours)(ad(e.time));return 0===t||12===t?Yh:e.span}return e.span>=cr.WEEK_SPAN&&e.span<cr.MONTH_SPAN?cr.DAY_SPAN:e.span}function cd(e,t){const i=function(e,t){return e===cr.MILLISECOND_SPAN&&t?"TimeWithMilliseconds":e<cr.MINUTE_SPAN&&t?"TimeWithSeconds":e<cr.DAY_SPAN&&t?"Time":e<cr.WEEK_SPAN||e<cr.MONTH_SPAN?"DayOfMonth":e<cr.YEAR_SPAN?"Month":"Year"}(e,t),s=new zh.CircularCacheBuffer(150);return e=>{let t=s.get(e.time);return void 0===t&&(t=function(e,t){return null!==_e.customFormatters.tickMarkFormatter?_e.customFormatters.tickMarkFormatter(e,t):td(e,t)}(ad(e.time),i),s.set(e.time,t)),t}}class hd{constructor(e,t,i){this._marksByIndex=new Map,this._marksByTime=new Map,this._marksBySpan=[],this._cache=null,this._labelsInvalidated=!0,this._widthsInvalidated=!0,this._skipIntraDayMarksSparseCache=null,this._changed=new ae.Delegate,this._formatterBySpan=new Map,this._textWidthCache=new Qt.TextWidthCache(1e4),this._timeVisible=e,this._sparseMarks=t,this._font=i;we.timeHoursFormatProperty.subscribe(this,(()=>{this._labelsInvalidated=!0,this._formatterBySpan.clear(),this._cache=null})),this._font.subscribe((()=>{this._textWidthCache.reset(),this._widthsInvalidated=!0,this._cache=null})),this._sparseMarks.subscribe((()=>{this._cache=null}))}destroy(){we.timeHoursFormatProperty.unsubscribeAll(this),this._timeVisible.release(),this._sparseMarks.release(),this._font.release()}reset(){this._resetImpl(),this._changed.fire()}indexToTime(e){const t=this._marksByIndex.get(e);return t?new Date(1e3*t.time):null}nearestIndex(e){let t=this.minIndex??0,i=this.maxIndex??0;for(;i-t>2;){if(1e3*(0,n.ensureDefined)(this._marksByIndex.get(t)).time===e)return t;if(1e3*(0,n.ensureDefined)(this._marksByIndex.get(i)).time===e)return i;const s=Math.round((t+i)/2);1e3*(0,n.ensureDefined)(this._marksByIndex.get(s)).time>e?i=s:t=s}return t}estimateLeft(e){const t=this._density();if(void 0===this.minIndex||!t)return 0;return(1e3*(0,n.ensureDefined)(this._marksByIndex.get(this.minIndex)).time-e)/t}merge(e,t){if(0===e.length)return;const i=e[0].index,s=e[e.length-1].index,o=i<=(this.minIndex??0)&&s>=(this.maxIndex??0);(t||o)&&this._resetImpl();const n=this._marksBySpan,r=new Set;if(this._marksByIndex.size>0)for(const t of e){const e=t.index,i=this._marksByIndex.get(e)
;i&&(i.index===e&&i.overriddenSpan===ld(t)&&i.time===t.time||this._removeTickmark(i));const s=this._marksByTime.get(t.time);s&&s.index!==e&&this._removeTickmark(s)}for(const t of e){const e=t.index;if(this._marksByIndex.has(e))continue;const i=ld(t),s=this._formatLabel(t),o={...t,label:s,overriddenSpan:i,width:(0,Kt.measureText)(s,this._font.value(),this._textWidthCache).width};this._marksByIndex.set(e,o),this._marksByTime.set(t.time,o);let a=n[i];void 0===a&&(a=[],n[i]=a);const l=0===a.length||a[a.length-1].time<t.time;a.push(o),l||r.add(i)}this.minIndex=Math.min(this.minIndex??1/0,i),this.maxIndex=Math.max(this.maxIndex??-1/0,s);for(let e=n.length;e--;)n[e]&&(n[e].length||delete n[e],r.has(e)&&n[e].sort(((e,t)=>e.time-t.time)));this._cache=null,this._skipIntraDayMarksSparseCache=null,this._changed.fire()}build(e){if(this._labelsInvalidated&&(this._marksByIndex.forEach((e=>{e.label=this._formatLabel(e)})),this._labelsInvalidated=!1),this._widthsInvalidated&&(this._marksByIndex.forEach((e=>{e.width=(0,Kt.measureText)(e.label,this._font.value(),this._textWidthCache).width})),this._widthsInvalidated=!1),this._cache?.barSpacing===e)return this._cache.marks;const t=id(this._font.value()),i=5/14*t,s=50/14*t;let o=[];for(let t=this._marksBySpan.length;t--;){if(!this._marksBySpan[t])continue;const r=this._marksBySpan[t];if(0===r.length)continue;const a=t<cr.DAY_SPAN&&this._sparseMarks.value()&&this._skipIntraDayMarksSparse(),l=o;o=[];let c=0,h=0;const d=r.length>2?ed[t]:void 0;let u=null,_=-1/0,p=null,m=0;for(;c<l.length||h<r.length;){const t=nd(l,c),a=nd(r,h);if(void 0!==d&&null!==a&&a!==u){if(null!==p){const t=null!==u&&u.index>p.index?u:p,i=od(a,e)-od(t,e);_=Math.max(_,i)}u=a}null!==t?null!==a?t.index<a.index?((0,n.assert)(null===p||!rd(p,t,e,i,s)),o.push(t),p=t,c++):(null!==p&&rd(p,a,e,i,s)||rd(a,t,e,i,s)?m++:(o.push(a),p=a),h++):((0,n.assert)(null===p||!rd(p,t,e,i,s)),o.push(t),p=t,c++):(null!==a&&(null!==p&&rd(p,a,e,i,s)?m++:(o.push(a),p=a)),h++)}if(this._sparseMarks.value()&&l.length>0&&m/r.length>(Qh[t]??.5)&&!a){o=l;break}if(void 0!==d&&Number.isFinite(_)&&_<=d)break}return this._cache={marks:o,barSpacing:e},o}marksBySpan(){const e={};for(let t=this._marksBySpan.length;t--;)if(this._marksBySpan[t]){const i=[];e[t]=i;for(const e of this._marksBySpan[t])i.push([e.index,e.time,e.overriddenSpan])}return e}state(e){let t=[];for(let e=this._marksBySpan.length;e--;)this._marksBySpan[e]&&(t=t.concat(this._marksBySpan[e]));if(null!==e){const i=e.firstBar(),s=e.lastBar();t=t.filter((e=>e.index>=i&&e.index<=s))}return{marks:t.map((e=>[e.span,e.time,e.index])),version:2}}restoreState(e){if(this._marksByIndex=new Map,this._marksByTime=new Map,this._marksBySpan=[],this.maxIndex=void 0,this.minIndex=void 0,e&&e.marks&&e.marks.length)if(2===e.version){const t=e.marks.map((e=>({span:e[0],time:e[1],index:e[2]})));this.merge(t)}else this.merge(e.marks)}removeTail(e){let t=-1/0;for(const i of this._marksByIndex.values())i.time>e?this._removeTickmark(i):t=Math.max(t,i.index);this.maxIndex=Number.isFinite(t)?t:void 0,
void 0===this.maxIndex&&(this.minIndex=void 0),this._skipIntraDayMarksSparseCache=null}addTail(e){if(void 0!==this.maxIndex)for(let t=0;t<e.length;t++)e[t].index=this.maxIndex+t+1;this.merge(e)}_resetImpl(){this._marksByIndex=new Map,this._marksByTime=new Map,this._marksBySpan=[],this.minIndex=void 0,this.maxIndex=void 0,this._cache=null,this._formatterBySpan.clear()}_removeTickmark(e){const t=e.index,i=e.time;if(this._marksByIndex.get(t)!==e)return;this._marksByIndex.delete(t),this._marksByTime.delete(i);const s=this._marksBySpan[e.overriddenSpan],o=(0,Pt.lowerbound)(s,e,((e,t)=>e.time<t.time));(0,n.assert)(o>=0&&o<s.length&&s[o].time===i,"Searched tickmark is not found"),s.splice(o,1),0===s.length&&delete this._marksBySpan[e.overriddenSpan]}_density(){if(void 0===this.minIndex||void 0===this.maxIndex)return 0;const e=this.maxIndex-this.minIndex;if(0===e)return 0;return 1e3*((0,n.ensureDefined)(this._marksByIndex.get(this.maxIndex)).time-(0,n.ensureDefined)(this._marksByIndex.get(this.minIndex)).time)/e}_formatLabel(e){const t=ld(e);let i=this._formatterBySpan.get(t);return void 0===i&&(i=cd(t,this._timeVisible.value()),this._formatterBySpan.set(t,i)),i(e)}_skipIntraDayMarksSparse(){if(null===this._skipIntraDayMarksSparseCache){const e=this._marksBySpan[cr.DAY_SPAN]??[];this._skipIntraDayMarksSparseCache=function(e){if(e.length<3)return 0;const t=[];let i=null;for(const s of e){if(null!==i){const e=Math.abs(s.index-i);t.push(e)}i=s.index}const s=t.reduce(((e,t)=>e+t),0)/t.length;return t.reduce(((e,t)=>e+Math.abs(t-s)))/t.length/s*100}(e)>=25}return this._skipIntraDayMarksSparseCache}}var dd=i(5471);class ud{constructor(){this._baseIndex=0}setBaseIndex(e){this._baseIndex=e}indexToTotalWeight(e){return e-this._baseIndex}totalWeightToIndex(e){return this._baseIndex+e}indexRangeToWeights(e,t,i){const s=e-this._baseIndex;return[{left:s-.5,center:s,right:s+.5,timePointIndex:e}]}state(e){return{type:"constant",state:{baseIndex:this._baseIndex}}}restoreState(e){this._baseIndex=e.state.baseIndex}needAdjustingOnDataRestoring(){return!1}}var _d=i(67455);const pd={preserveBarSpacing:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!0,minBarSpacing:.5},md=l.enabled("low_density_bars"),gd=md?1:2,fd=(0,ne.getLogger)("Chart.TimeScale");var yd;!function(e){e[e.DefaultRightOffset=10]="DefaultRightOffset",e[e.DefaultBarSpacing=6]="DefaultBarSpacing",e[e.UnplottableIndexCoord=-500]="UnplottableIndexCoord",e[e.DefaultRightOffsetPercentage=5]="DefaultRightOffsetPercentage",e[e.MaxIterationsForDynamicBarSpacingAdjust=20]="MaxIterationsForDynamicBarSpacingAdjust"}(yd||(yd={}));class vd{constructor(e,t){this._width=0,this._widthChanged=new ae.Delegate,this._rightOffset=10,this._rightOffsetChanged=new ae.Delegate,this._maxRightOffsetChanged=new ae.Delegate,this._defaultRightOffset=new O.WatchedValue(10),this._defaultRightOffsetPercentage=new O.WatchedValue(5),this._usePercentageRightOffset=new O.WatchedValue(!1),this._lastDefaultRightOffset=void 0,this._baseIndex=null,this._leftEdgeIndex=null,this._barSpacingChanged=new ae.Delegate,
this._barSpacing=6,this._snapshotBarSpacing=null,this._visibleBars=Hh.invalid(),this._visibleBarsInvalidated=!0,this._visibleBarsChanged=new ae.Delegate,this._logicalRangeChanged=new ae.Delegate,this._points=new Oh,this._onScroll=new ae.Delegate,this._resetDelegate=new ae.Delegate,this._scrollData=null,this._scaleStartPoint=null,this._commonTransitionStartState=null,this._requestingMoreData=!1,this._requestedTickmarksCount=0,this._endOfData=!1,this._lockBarsAndLogicalRangeEvents=!1,this._resetAvailable=new O.WatchedValue(!1),this._pointWeights=new ud,this._weightedPointsCache=[],this._throttleRequestMoreDataOnScroll=(0,o.default)(this._requestMoreData,300),this._options=(0,ge.deepExtend)({},pd,t),this._model=e,this._scalesProperties=e.properties().childs().scalesProperties,this._tickMarks=new hd((0,ft.combine)((e=>!e.isDWM()),e.mainSeries().intervalObj().weakReference()).ownership(),(0,ft.combine)(((e,t)=>!e.isTicks()&&!e.isSeconds()&&!(0,xt.isRangeBasedStyle)(t)),e.mainSeries().intervalObj().weakReference(),(0,ye.convertPropertyToWatchedValue)(e.mainSeries().properties().childs().style).ownership()).ownership(),(0,_d.createWVFromGetterAndSubscription)((()=>(0,si.makeFont)(this._scalesProperties.childs().fontSize.value(),m.CHART_FONT_FAMILY)),this._scalesProperties.childs().fontSize).ownership()),this._defaultRightOffset.subscribe((()=>{this._usePercentageRightOffset.setValue(!1),this._defaultRightOffsetOptionsUpdated()})),this._defaultRightOffsetPercentage.subscribe((e=>{if(e>=100||e<0){const t=Math.max(0,Math.min(e,99));this._defaultRightOffsetPercentage.setValue(t)}else this._usePercentageRightOffset.setValue(!0),this._defaultRightOffsetOptionsUpdated()})),this._usePercentageRightOffset.subscribe((()=>{this._defaultRightOffsetOptionsUpdated()})),this._options.preserveBarSpacing&&(this._barSpacing=this._scalesProperties.childs().barSpacing.value()||6),this._barSpacingChanged.subscribe(this,this._maxRightOffsetOnChanged),this._barSpacingChanged.subscribe(this,this._updateResetAvailableValue),this._rightOffsetChanged.subscribe(this,this._updateResetAvailableValue),this._widthChanged.subscribe(this,this._maxRightOffsetOnChanged),this._updateResetAvailableValue()}destroy(){this._barSpacingChanged.unsubscribeAll(this),this._barSpacingChanged.destroy(),this._widthChanged.unsubscribeAll(this),this._widthChanged.destroy(),this._tickMarks.destroy()}isEmpty(){return 0===this._width||!this.canNormalize()}canNormalize(){return this._points.size()>0}update(e,t,i,s,o){this._visibleBarsInvalidated=!0,i.length>0&&this._points.merge(e,t,i),this._tickMarks.merge(s,o),this.correctOffset()}addTail(e,t,i){this._tickMarks.removeTail(t);const s=e.params,o=(0,n.ensureDefined)(this._tickMarks.maxIndex)+(i?0:1);for(let e=0;e<s.marks.length;e++)s.marks[e].index=o+e;this._tickMarks.addTail(s.marks),this._points.addTail(s.changes,i);const r=this._rightOffset-s.changes.length;this._updateRightOffset(r)}state(e){const t={m_barSpacing:this.barSpacing(),m_rightOffset:this._defaultRightOffset.value(),
rightOffsetPercentage:this._defaultRightOffsetPercentage.value(),usePercentageRightOffset:this._usePercentageRightOffset.value()};if(e){t.m_rightOffset=Math.max(0,this._rightOffset);const e=this.visibleBarsStrictRange(),i=this.visibleExtendedDataRange(this._model.mainSeries().data(),0),s=e?e.unite(i):i;t.points=this._points.state(s),t.tickmarks=this._tickMarks.state(s),t.width=this._width,t.weights=this._pointWeights.state(s),t.baseIndex=this._baseIndex}return t}restoreState(e,t){if(void 0===e.m_barSpacing)return void fd.logDebug("restoreState: invalid state");if(void 0===e.m_rightOffset)return void fd.logDebug("restoreState: invalid state");e.weights&&(this._pointWeights=function(e){let t;switch(e.type){case"constant":return t=new ud,t.restoreState(e),t;case"computed":return t=new ComputedTimePointWeights,t.restoreState(e),t}throw new Error(`Unexpected time point weigths type ${e.type}`)}(e.weights));let i=e.m_barSpacing;this._snapshotBarSpacing=t?i:null;const s=e.m_rightOffset<0&&!t?this.rightOffsetDefaultValue():e.m_rightOffset,o=s<0?this.rightOffsetDefaultValue():Math.round(s);if(this._defaultRightOffset.setValue(o),void 0!==e.rightOffsetPercentage&&Number.isFinite(e.rightOffsetPercentage)&&this._defaultRightOffsetPercentage.setValue(e.rightOffsetPercentage),this._usePercentageRightOffset.setValue(Boolean(e.usePercentageRightOffset)),this._rightOffset=s,this._baseIndex=e.baseIndex??this._baseIndex,t&&(this._requestedTickmarksCount=1/0,this._endOfData=!0,this._points.restoreState(e.points||null),this._tickMarks.restoreState(e.tickmarks||null),e.width&&this._width>0&&(i*=this._width/e.width)),t&&this._pointWeights.needAdjustingOnDataRestoring()){this._tryToUpdateBarSpacing(this._barSpacing,i);const e=this._points.range().value();if(e){const t=e.firstIndex;let s=i,o=i,n=0;(()=>{n=this.indexToCoordinate(t),n<0?(o=i,s=i/10):(s=i,o=10*i)})();for(let e=0;e<20&&Math.abs(n)>2;e++){const e=(o+s)/2;this._tryToUpdateBarSpacing(this._barSpacing,e),n=this.indexToCoordinate(t),n<0?o=e:s=e}}}else this._tryToUpdateBarSpacing(this._barSpacing,i);this.correctOffset(),this._usePercentageRightOffset.value()&&(this._rightOffset=this.percentsToBarIndexLength(this._defaultRightOffsetPercentage.value())),this._rightOffsetChanged.fire(this._rightOffset)}marks(){if(this.isEmpty())return null;const e=this._barSpacing,t=5*((this._scalesProperties.childs().fontSize.value()||0)+4),i=Math.round(t/e),s=(0,n.ensureNotNull)(this.visibleBarsStrictRange()),o=Math.max(s.firstBar(),s.firstBar()-i),r=Math.max(s.lastBar(),s.lastBar()-i),a=this._tickMarks.build(e),l=[];for(const e of a)o<=e.index&&e.index<=r&&l.push({coord:this.indexToCoordinate(e.index),label:e.label,span:e.span,major:!1});return l}visibleBarsStrictRange(){return this._visibleBarsInvalidated&&(this._visibleBarsInvalidated=!1,this._updateVisibleBars()),this._visibleBars.strictRange()}visibleBarsStrictRangeChanged(){return this._visibleBarsChanged}visibleStrictDataRange(e){const t=this.visibleBarsStrictRange();if(null===t)return null
;const i=e.search(t.firstBar(),dd.PlotRowSearchMode.NearestRight),s=e.search(t.lastBar(),dd.PlotRowSearchMode.NearestLeft);return null===i||null===s?null:new Dh.BarsRange(i.index,s.index)}visibleExtendedDataRange(e,t){const i=this.visibleBarsStrictRange();if(null===i)return null;let s=1===t?null:e.search(i.firstBar()-1,dd.PlotRowSearchMode.NearestLeft),o=0===t?null:e.search(i.lastBar()+1,dd.PlotRowSearchMode.NearestRight);return null===s&&(s=e.search(i.firstBar(),dd.PlotRowSearchMode.NearestRight)),null===o&&(o=e.search(i.lastBar(),dd.PlotRowSearchMode.NearestLeft)),null===s||null===o?null:new Dh.BarsRange(s.index,o.index)}logicalRangeChanged(){return this._logicalRangeChanged}tickMarks(){return this._tickMarks}points(){return this._points}width(){return this._width}setWidth(e,t){if(!Number.isFinite(e)||e<=0)return void fd.logWarn(`setWidth: invalid argument: ${e}`);if(this._width===e)return;const i=this._usePercentageRightOffset.value()&&this._rightOffset>0?this.barIndexLengthToPercents(this._rightOffset):-1;if(this._visibleBarsInvalidated=!0,(t||this._options.lockVisibleTimeRangeOnResize)&&this._width){const t=this._barSpacing*e/this._width;this._tryToUpdateBarSpacing(this._barSpacing,t)}else this._width&&this.setBarSpacing(this._barSpacing);if(null!==this._leftEdgeIndex){if((0,n.ensureNotNull)(this.visibleBarsStrictRange()).firstBar()<=this._leftEdgeIndex){const t=this._width-e;this._rightOffset-=Math.round(t/this._barSpacing)+1}}this._width=e,this._widthChanged.fire(e);const s=this._rightOffset;i>0?this._rightOffset=this.percentsToBarIndexLength(i):this.correctOffset(),this._rightOffset!==s&&this._rightOffsetChanged.fire(this._rightOffset),this._requestMoreData()}setLeftEdgeFix(e){this._leftEdgeIndex=e;const t=this.visibleBarsStrictRange();if(null===t)return;const i=t.firstBar()-e;if(i<0){const e=this._rightOffset-i-1;this.scrollToOffsetAnimated(e,500)}}positionPercentToCoordinate(e){return this.width()*e}indexToCoordinate(e){if(this.isEmpty())return 0;const t=this.baseIndex(),i=this._pointWeights.indexToTotalWeight(t+this._rightOffset+.5)-this._pointWeights.indexToTotalWeight(e);return this._width-i*this._barSpacing}indexToUserTime(e){return this._tickMarks.indexToTime(e)}timePointToIndex(e,t){switch(t){case 0:return this._points.indexOf(e,!1);case 1:return this._points.closestIndexLeft(e);default:return this._points.indexOf(e,!0)}}indexToTimePoint(e){return this._points.valueAt(e)}timeToCoordinate(e){const t=this._points.closestIndexLeft(e);if(null===t)return null;const i=(0,n.ensureNotNull)(this._points.valueAt(t)),s=this.indexToCoordinate(t);if(s<=0||s>=this._width)return null;const o=this.barSpacing(),r=this.baseIndex();let a;a=0===r?this._model.mainSeries().intervalObj().value().inMilliseconds()/1e3:(0,n.ensureNotNull)(this._points.valueAt(r))-(0,n.ensureNotNull)(this._points.valueAt(r-1));const l=s+(e-i)/a*o+1;return l<=0||l>=this._width?null:l}barBorders(e){const t={timePointIndex:e,left:NaN,center:NaN,right:NaN};return this.fillBarBorders([t]),t}fillBarBorders(e,t,i){if(0===e.length)return
;let s=t?.startItemIndex??0;const o=(t?.endItemIndex??e.length)-1;if(!0===i&&(s=(0,Pt.upperbound)(e,Fh.UNPLOTTABLE_TIME_POINT_INDEX,((e,t)=>e<t.timePointIndex),s,o+1)),s>o)return;const r=this._pointWeights.indexToTotalWeight(this.baseIndex()+this._rightOffset+.5),a=this._pointWeights.indexRangeToWeights(e[s].timePointIndex,e[o].timePointIndex,this._weightedPointsCache);let l=0,c=a[l];const h=c,d=a[a.length-1];let u=NaN,_=NaN,p=NaN,m=!0;for(let t=s;t<=o;t+=1){const i=e[t];if(i.timePointIndex<h.timePointIndex)u=h.left-(h.timePointIndex-i.timePointIndex),_=u+.5,p=u+1;else if(i.timePointIndex>d.timePointIndex)p=d.right+(i.timePointIndex-d.timePointIndex),_=p-.5,u=p-1;else for(m&&(u=c.left,_=c.center,p=c.right,m=!1);c.timePointIndex<i.timePointIndex;)l+=1,(0,n.assert)(l<a.length,"Bar borders coordinates are not correct"),c=a[l],u=c.left,_=c.center,p=c.right;i.left=this._width-(r-u)*this._barSpacing,i.center=this._width-(r-_)*this._barSpacing,i.right=this._width-(r-p)*this._barSpacing}}timedValuesToCoordinates(e,t,i){const s=this._pointWeights.indexToTotalWeight(this.baseIndex()+this._rightOffset+.5),o=t?.startItemIndex??0;let n=o;const r=t?.endItemIndex??e.length;!0===i&&(n=(0,Pt.upperbound)(e,Fh.UNPLOTTABLE_TIME_POINT_INDEX,((e,t)=>e<t.x),o,r));for(let t=n;t<r;++t){const i=e[t],o=s-this._pointWeights.indexToTotalWeight(i.x);i.x=this._width-o*this._barSpacing}for(let t=o;t<n;++t)e[t].x=-500}rightOffsetForTimePoint(e){const t=this.timeToCoordinate(e);if(null===t)return null;const i=(t-this._baseIndexBarCenterCoordinate())/this._barSpacing;return this._pointWeights.totalWeightToIndex(i)}scrollToRealtime(e,t){let i=this.targetDefaultRightOffset();i<0&&(i=this.rightOffsetDefaultValue());const s=()=>{void 0!==t&&t(),this._requestMoreData()};if(e){const e=this.logicalRange(),t=this._model.mainSeries().bars().lastIndex();if(null===e||null===t)return;const i=this.indexToCoordinate(e.right()+.5),o=this.indexToCoordinate(t+this._defaultRightOffset.value()+.5);return this._model.stopTimeScaleAnimation(),void this._model.setTimeScaleAnimation(new Ir({from:0,to:i-o,duration:1e3,easing:br.easingFunc.easeInOutQuint,onFinish:s}))}this._visibleBarsInvalidated=!0,this._updateRightOffset(i),this._onScroll.fire(),s()}scrollToFirstBar(e=()=>{}){this._model.gotoTime(new Date("1800-01-01").getTime()).then(e),this._onScroll.fire()}scrollToOffsetAnimated(e,t){if(!isFinite(e))throw new RangeError("offset is required and must be finite number");const i=void 0===t?400:t;if(!isFinite(i)||i<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this._rightOffset,o=Date.now(),n=()=>{this._visibleBarsInvalidated=!0;const t=(Date.now()-o)/i;if(t>=1)return this._updateRightOffset(e),this._visibleBarsInvalidated=!0,this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),void this._model.lightUpdate();const r=s+(e-s)*t;this._updateRightOffset(r),this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),setTimeout(n,20)};n()}defaultRightOffset(){return this._defaultRightOffset}rightOffsetDefaultValue(){
return 10}defaultRightOffsetPercentage(){return this._defaultRightOffsetPercentage}usePercentageRightOffset(){return this._usePercentageRightOffset}barSpacing(){return this._barSpacing}barSpacingScaleRatio(){return null===this._snapshotBarSpacing?1:this._barSpacing/this._snapshotBarSpacing}setBarSpacing(e){if(!Number.isFinite(e))return void fd.logWarn(`setBarSpacing: invalid argument: ${e}`);e=this.getValidBarSpacing(e);const t=this._barSpacing>e;this._tryToUpdateBarSpacing(this._barSpacing,e)&&(this.correctOffset(),this._options.preserveBarSpacing&&((0,yi.allowSavingDefaults)(!0),this._scalesProperties.childs().barSpacing.setValue(this._barSpacing),(0,yi.allowSavingDefaults)(!1)),this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),this._model.lightUpdate(),t&&this.requestHistoryPointsIfNeeded())}barSpacingChanged(){return this._barSpacingChanged}getValidBarSpacing(e){return null==e&&(e=this.barSpacing()),e<this.minBarSpacing()?this.minBarSpacing():e>this.maxBarSpacing()?this.maxBarSpacing():e}isValidBarSpacing(e){return e>=this.minBarSpacing()&&e<=this.maxBarSpacing()}preserveBarSpacing(){return this._options.preserveBarSpacing}normalizeBarIndex(e){let t=0,i=0;const s=this.baseIndex(),o=(0,n.ensureNotNull)(this._points.range().value()).firstIndex;return e<o?(t=(0,n.ensureNotNull)(this._points.valueAt(o)),i=e-o):e>s?(t=(0,n.ensureNotNull)(this._points.valueAt(s)),i=e-s):(t=(0,n.ensureNotNull)(this._points.valueAt(e)),i=0),{time_t:t,offset:i}}denormalizeTimePoint(e){const t=this._points.indexOf(e.time_t,!1);if(null!==t)return t+e.offset}rightOffset(){return this._rightOffset}rightOffsetChanged(){return this._rightOffsetChanged}minRightOffset(){const e=this.points().range().value()?.firstIndex,t=this._baseIndex;if(void 0===e||null===t)return null;if(null!==this._leftEdgeIndex){const e=this.width()/this._barSpacing;return this._leftEdgeIndex-t+e-1}return e-t-1+gd}maxRightOffset(){return this.width()/this._barSpacing-gd}maxRightOffsetChanged(){return this._maxRightOffsetChanged}onReset(){return this._resetDelegate}baseIndex(){return this._baseIndex||0}zoom(e,t,i){if(!Number.isFinite(e)||!Number.isFinite(t))return void fd.logWarn(`zoom: invalid arguments: ${e}, ${t}, ${i}`);const s=this.rightOffset(),o=void 0!==i?!i:this._options.rightBarStaysOnScroll,n=o&&this.usePercentageRightOffset().value()&&s>=0,r=n?this.barIndexLengthToPercents(s):void 0,a=this.coordinateToIndex(e),l=this.barSpacing(),c=l+t*(l/10);this.setBarSpacing(c),o||(this.startScroll(this.indexToCoordinate(a)),this.scrollTo(e),this.endScroll()),n&&void 0!==r&&this.setRightOffset(this.percentsToBarIndexLength(r)),this._requestMoreData()}zoomToBarsRange(e,t){if(null!==this._leftEdgeIndex&&(e=Math.max(e,this._leftEdgeIndex)),t<e)return;const i=this.baseIndex(),s=this._rightOffset;this._rightOffset=t-i;const o=e-.5,n=t+.5,r=Math.max(this._pointWeights.indexToTotalWeight(n)-this._pointWeights.indexToTotalWeight(o),gd);this.setBarSpacing(this.width()/r),this._visibleBarsInvalidated=!0,this.correctOffset(),
this._rightOffset!==s&&this._rightOffsetChanged.fire(this._rightOffset),this._requestMoreData()}scrollToBar(e){null!==this._leftEdgeIndex&&(e=Math.max(e,this._leftEdgeIndex));const t=(0,n.ensureNotNull)(this.logicalRange()).length()+e-1;this._rightOffset=t-this.baseIndex(),this._visibleBarsInvalidated=!0,this.correctOffset(),this._rightOffsetChanged.fire(this._rightOffset),this._requestMoreData()}coordinateToIndex(e){return Math.round(this.coordinateToFloatIndex(e))}coordinateToFloatIndex(e){const t=(e-this._baseIndexBarCenterCoordinate())/this._barSpacing,i=this._pointWeights.totalWeightToIndex(t);return Math.round(1e6*i)/1e6}coordinateToVisibleIndex(e){let t=this.coordinateToIndex(e);const i=this.visibleBarsStrictRange();return null===i||i.contains(t)||(t=Math.min(Math.max(i.firstBar(),t),i.lastBar())),t}canZoomIn(){return this.barSpacing()<this.maxBarSpacing()}canZoomOut(){return this.barSpacing()>this._options.minBarSpacing}minBarSpacing(){return this._options.minBarSpacing}maxBarSpacing(){const e=this.width();return md?e:e/gd}minVisibleBarCount(){return gd}resetRightOffset(){this.setRightOffset(this.targetDefaultRightOffset())}reset(){this._visibleBarsInvalidated=!0,this._points.clear(),this._scrollData=null,this._scaleStartPoint=null,this._clearCommonTransitionsStartState(),this._tickMarks.reset(),this._leftEdgeIndex=null,this._resetDelegate.fire(),this.disconnect()}resetAvailable(){return this._resetAvailable.readonly()}disconnect(){this._requestingMoreData=!1,this._requestedTickmarksCount=0,this._endOfData=!1}setBaseIndex(e){if(!Number.isFinite(e))return void fd.logDebug(`setBaseIndex: invalid argument: ${e}`);const t=this._baseIndex!==e;this._visibleBarsInvalidated=!0,this._baseIndex=e,this._pointWeights.setBaseIndex(this._baseIndex),this.correctOffset(),t&&(this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),this._model.lightUpdate())}resetBaseIndex(){this._visibleBarsInvalidated=!0,this._baseIndex=null}setRightOffset(e){Number.isFinite(e)?(this._visibleBarsInvalidated=!0,this._updateRightOffset(e)):fd.logWarn(`setRightOffset: invalid argument: ${e}`)}correctBarSpacing(){this.isEmpty()||this.points().size()<this.width()/this.barSpacing()&&(this.setRightOffset(this.targetDefaultRightOffset()),this.setBarSpacing(this.width()/(this.points().size()+this.rightOffset())))}setTimePointWeights(e){this._weightedPointsCache=[],this._pointWeights=e??new ud,this._pointWeights.setBaseIndex(this.baseIndex()),this._visibleBarsInvalidated=!0}correctOffset(){const e=this.maxRightOffset();this._rightOffset>e&&(this._rightOffset=e,this._visibleBarsInvalidated=!0);const t=this.minRightOffset();null!==t&&this._rightOffset<t&&(this._rightOffset=t,this._visibleBarsInvalidated=!0)}logicalRange(){return this._visibleBarsInvalidated&&(this._visibleBarsInvalidated=!1,this._updateVisibleBars()),this._visibleBars.logicalRange()}restoreDefault(){this._visibleBarsInvalidated=!0,this._lockBarsAndLogicalRangeEvents=!0;const e=this._visibleBars;this.setBarSpacing(6),this.resetRightOffset(),this._lockBarsAndLogicalRangeEvents=!1,
this._fireVisibleBarsChangedIfRequired(e,this._visibleBars),this._requestMoreData()}startScale(e){this._scrollData&&this.endScroll(),null===this._scaleStartPoint&&null===this._commonTransitionStartState&&(this.isEmpty()||(this._scaleStartPoint=e,this._saveCommonTransitionsStartState()))}scaleTo(e){if(null===this._commonTransitionStartState)return;const t=(0,fo.clamp)(this._width-e,0,this._width),i=(0,fo.clamp)(this._width-(0,n.ensureNotNull)(this._scaleStartPoint),0,this._width);if(0===t||0===i)return;const s=this.barIndexLengthToPercents(this.rightOffset());this.setBarSpacing(this._commonTransitionStartState.barSpacing*t/i),this.usePercentageRightOffset().value()&&this.rightOffset()>=0&&this.setRightOffset(this.percentsToBarIndexLength(s))}endScale(){null!==this._scaleStartPoint&&(this._scaleStartPoint=null,this._clearCommonTransitionsStartState(),this._requestMoreData())}startScroll(e){null===this._scrollData&&null===this._commonTransitionStartState&&(this.isEmpty()||(this._scrollData={startCoordinate:e,startRightEdgeLogical:this.baseIndex()+this._rightOffset+.5,startBaseIndex:this.baseIndex()},this._saveCommonTransitionsStartState()))}scrollTo(e){if(this._visibleBarsInvalidated=!0,null===this._scrollData)return;const{startCoordinate:t,startRightEdgeLogical:i,startBaseIndex:s}=this._scrollData,o=e-t,n=i+(this.baseIndex()-s),r=this.indexToCoordinate(n),a=this.coordinateToFloatIndex(r-o)-.5-this.baseIndex();this._updateRightOffset(a),this._onScroll.fire()}endScroll(){null!==this._scrollData&&(this._scrollData=null,this._clearCommonTransitionsStartState(),this._throttleRequestMoreDataOnScroll())}isBeingScrolled(){return null!==this._scrollData}isBeingScaled(){return null!==this._scaleStartPoint}onScroll(){return this._onScroll}invalidateVisibleBars(){this._visibleBarsInvalidated=!0}onTimeScaleCompleted(e){if(this._requestingMoreData=!1,this._endOfData=e,l.enabled("fix_left_edge")&&this._endOfData){const e=this._points.range().value()?.firstIndex;void 0!==e&&this.setLeftEdgeFix(e)}this._requestMoreData()}requestMoreHistoryPoints(e){this._requestHistoryPoints(e)}targetDefaultRightOffset(){return this.usePercentageRightOffset().value()?this.percentsToBarIndexLength(this._defaultRightOffsetPercentage.value()):this._defaultRightOffset.value()}percentsToBarIndexLength(e){return.01*e*this._width/this._barSpacing}barIndexLengthToPercents(e){return 100*e*this._barSpacing/this._width}requestHistoryPointsIfNeeded(){if(this.isEmpty())return;if(this._endOfData)return void fd.logNormal("Skipping loading more data due end of data state");const e=this.visibleBarsStrictRange();if(null===e)return;const t=(0,n.ensureNotNull)(this._points.range().value()).firstIndex-e.firstBar();t<=0||this._requestHistoryPoints(t)}_requestMoreData(){this._requestFutureTickmarksIfNeeded(),this.requestHistoryPointsIfNeeded()}_requestFutureTickmarksIfNeeded(){if(this.isEmpty()||!this._model.chartApi().isConnected().value())return;const e=this.visibleBarsStrictRange();if(null===e)return;const t=e.lastBar()-(0,
n.ensureNotNull)(this._points.range().value()).lastIndex;if(t<=this._requestedTickmarksCount)return;const i=t-this._requestedTickmarksCount;this._requestedTickmarksCount=t,this._model.chartApi().requestMoreTickmarks((0,n.ensureNotNull)(this._model.mainSeries().seriesSource().instanceId()),i)}_requestHistoryPoints(e){this._model.chartApi().isConnected().value()&&(this._requestingMoreData?fd.logNormal("Skipping loading more data due active loading"):(this._requestingMoreData=!0,this._model.chartApi().requestMoreData(e)))}_updateVisibleBars(){const e=this._visibleBars;if(this.isEmpty())return void(this._visibleBars.isValid()&&(this._visibleBars=Hh.invalid(),this._visibleBarsChanged.fire(null,e.strictRange()),this._logicalRangeChanged.fire(null,e.logicalRange())));const t=this.width()/this.barSpacing(),i=this.baseIndex(),s=i+this._rightOffset,o=s+.5,n=this._pointWeights.indexToTotalWeight(o)-t,r=Math.min(o-1,this._pointWeights.totalWeightToIndex(n))+.5;Number.isFinite(r)&&Number.isFinite(s)?(this._visibleBars=new Hh(new Bh(r,s),this._model.mainSeries().style()),this._lockBarsAndLogicalRangeEvents||this._fireVisibleBarsChangedIfRequired(e,this._visibleBars)):fd.logWarn(`updateVisibleBars error: baseIndex: ${i}, barSpacing: ${this._barSpacing}, rightOffset: ${this._rightOffset}`)}_fireVisibleBarsChangedIfRequired(e,t){Dh.BarsRange.compare(e.strictRange(),t.strictRange())||this._visibleBarsChanged.fire(t.strictRange(),e.strictRange()),Bh.compare(e.logicalRange(),t.logicalRange())||this._logicalRangeChanged.fire(t.logicalRange(),e.logicalRange())}_baseIndexBarCenterCoordinate(){const e=this.baseIndex()+this._rightOffset+.5,t=this._pointWeights.indexToTotalWeight(e);return this._width-t*this._barSpacing}_tryToUpdateBarSpacing(e,t){return e!==t&&(this._visibleBarsInvalidated=!0,this._barSpacing=t,this._barSpacingChanged.fire(t),!0)}_saveCommonTransitionsStartState(){this._commonTransitionStartState={barSpacing:this.barSpacing(),rightOffset:this.rightOffset()}}_clearCommonTransitionsStartState(){this._commonTransitionStartState=null}_maxRightOffsetOnChanged(){this._maxRightOffsetChanged.fire(this.maxRightOffset())}_updateRightOffset(e){const t=this._rightOffset;this._rightOffset=e,this.correctOffset(),this._rightOffset!==t&&this._rightOffsetChanged.fire(this._rightOffset),this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),this._model.lightUpdate()}_defaultRightOffsetOptionsUpdated(){const e=this.rightOffset();if(l.enabled("lock_visible_range_when_adjusting_percentage_right_margin")&&e>=0){const e=this._defaultRightOffsetPercentage.value(),t=this._usePercentageRightOffset.value()&&this._rightOffset>=0?Math.round(this.barIndexLengthToPercents(this._rightOffset)):-1;if(this._lastDefaultRightOffset!==e&&t===this._lastDefaultRightOffset){const t=this._barSpacing*(100-e)/(100-this._lastDefaultRightOffset);this._tryToUpdateBarSpacing(this._barSpacing,t)}}this.setRightOffset(this.targetDefaultRightOffset()),this._updateResetAvailableValue(),this._lastDefaultRightOffset=this._defaultRightOffsetPercentage.value()}
_updateResetAvailableValue(){this._resetAvailable.setValue(6!==this.barSpacing()||this.rightOffset()!==this.targetDefaultRightOffset())}}var Sd=i(86957),bd=i(60336);class wd{constructor(e){this._onChanged=new ae.Delegate,this._groups=[],this._groups=e||[],this._groups.forEach((e=>{e.onChanged().subscribe(null,(t=>this._onChanged.fire(e.id,t)))}))}groups(){return this._groups.filter((e=>e.isActualSymbol()))}groupsForAllSymbols(){return this._groups}createGroup(e,t,i){t=t||this._generateNextName();const s=new Xa(e,t,i);this._groups.push(s),s.onChanged().subscribe(null,(e=>this._onChanged.fire(s.id,e)));const o={visibilityChanged:!1,lockedChanged:!1,isActualIntervalChanged:!1,affectedLineTools:e.map((e=>e.id()))};return this._onChanged.fire(s.id,o),s}addGroup(e){this._groups.push(e),e.onChanged().subscribe(null,(t=>this._onChanged.fire(e.id,t))),this._onChanged.fire(e.id)}removeGroup(e){const t=this._groups.findIndex((t=>t.id===e.id));this._groups.splice(t,1),this._onChanged.fire(e.id)}groupForId(e){return this._groups.find((t=>t.id===e))||null}groupForLineTool(e){return this._groups.find((t=>t.containsLineTool(e)))||null}removeLineTools(e){const t=new Set;this._groups.forEach((i=>{const s=e.filter(i.containsLineTool.bind(i));s.length&&(i.excludeLineTools(s),t.add(i.id))}));return this._groups.filter((e=>0===e.lineTools().length)).forEach((e=>this.removeGroup(e))),Array.from(t)}state(e){return{groups:(e?this._groups.filter((e=>e.isActualSymbol())):this._groups).map((e=>e.state()))}}onChanged(){return this._onChanged}fireChangedAll(){this._groups.forEach((e=>{this._onChanged.fire(e.id)}))}static fromState(e,t){const i=[];for(const s of t.groups){const t=Xa.fromState(e,s);null!==t&&i.push(t)}return new wd(i)}_generateNextName(){const e=new Set(this.groups().map((e=>e.name().value())));for(let t=1;;t++){const i=`Group ${t}`,s=`Group_${t}`;if(!e.has(i)&&!e.has(s))return i}}}var Cd=i(47312),Td=i(51101);function Pd(e){return Boolean(e.session.timezone)&&Boolean(e.session.spec)}class xd{constructor(e,t){var i,s;this._sourceTargetBarBuilder=null,this._cache=new Map,this._source=e,this._target=t,this._sourceSession=Cd.SessionInfo.fromState(e.session),this._targetSession=Cd.SessionInfo.fromState(t.session),this._isResolutionTheSame=Re.Interval.isEqual(e.resolution,t.resolution)||Re.Interval.isTicks(e.resolution)&&Re.Interval.isTicks(t.resolution),this._isSessionTheSame=(i=e.session,s=t.session,i.timezone===s.timezone&&i.spec===s.spec&&i.holidays===s.holidays&&i.corrections===s.corrections)}sourceTimeToTargetTime(e){if(this._isSessionTheSame&&this._isResolutionTheSame)return e;if(!Pd(this._source)||!Pd(this._target))return e;let t=this._cache.get(e);if(void 0===t){const i=1e3*e,s=this._sourceTargetBuilder();s.moveTo(i);const o=s.indexOfBar(i);t=s.startOfBar(Math.max(0,o))/1e3,this._cache.set(e,t)}return t}_sourceTargetBuilder(){return null===this._sourceTargetBarBuilder&&(this._sourceTargetBarBuilder=(0,Td.newBarBuilder)(this._target.resolution,this._targetSession,this._sourceSession)),this._sourceTargetBarBuilder}}
var Md=i(40153),Id=i(69555),Ad=i(66786),Ld=i(30693);class kd extends Ld.PriceLineAxisView{constructor(e,t){super(),this._model=e,this._source=t}_value(){const e=this._model.mainSeries(),t=e.priceScale(),i=e.firstValue();if(null===i)return{noData:!0};const s=this._source.price(),o=this._source.currentSession();if(null===s||"pre_market"!==o&&"post_market"!==o)return{noData:!0};const n=t.priceToCoordinate(s,i);return{noData:!1,floatCoordinate:n,coordinate:n,color:"",formattedPricePercentage:"",formattedPriceAbsolute:"",formattedPriceIndexedTo100:"",text:"",index:0}}_priceLineColor(e){const t=this._source.properties().childs();return"pre_market"===this._source.currentSession()?t.preMarketColor.value():t.postMarketColor.value()}_lineWidth(){return this._source.properties().childs().lineWidth.value()}_lineStyle(){return this._source.properties().childs().lineStyle.value()}_isVisible(){if(!this._source.canBeVisibleOnSymbolAndInterval()||!this._model.properties().childs().scalesProperties.childs().showPrePostMarketPriceLabel.value())return!1;const e=this._source.price(),t=this._source.currentSession();return null!==e&&("pre_market"===t||"post_market"===t)}}var Ed=i(36281);class Dd extends Ed.PriceAxisView{constructor(e,t){super(),this._model=e,this._source=t}_updateRendererData(e,t,s){if(e.visible=!1,t.visible=!1,!this._model.properties().childs().scalesProperties.childs().showPrePostMarketPriceLabel.value())return;const o=this._model.mainSeries(),n=o.priceScale(),r=o.firstValue();if(null===r)return;if(!this._source.canBeVisibleOnSymbolAndInterval())return;const l=this._source.price(),c=this._source.currentSession();if(null==l||"pre_market"!==c&&"post_market"!==c)return;const h=this._source.properties().childs(),d="pre_market"===c?(0,Ro.resetTransparency)(h.preMarketColor.value()):(0,Ro.resetTransparency)(h.postMarketColor.value());e.visible=!0,t.visible=!0,e.text=n.formatPriceAbsolute(l),t.text="pre_market"===c?a.t(null,{context:"market_status"},i(93866)):a.t(null,{context:"market_status"},i(35359)),s.coordinate=n.priceToCoordinate(l,r),s.background=d,s.textColor=this.generateTextColor(d)}}var Bd=i(40738);class Vd extends Bd.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._source=t;const s={doubleClickHandler:i,doubleTapHandler:i};this._lineRenderer.setHitTest(new Ut.HitTestResult(Ut.HitTarget.Regular,s))}_updateImpl(){const e=this._lineRendererData;e.visible=!1;const t=this._model.mainSeries(),i=this._source.properties().childs();if(!i.visible.value()||!t.isVisible())return;const s=t.priceScale(),o=t.firstValue();if(null===o)return;if(!this._source.canBeVisibleOnSymbolAndInterval())return;const n=this._source.price(),r=this._source.currentSession();null===n||"pre_market"!==r&&"post_market"!==r||(e.visible=!0,e.y=s.priceToCoordinate(n,o),e.linestyle=i.lineStyle.value(),e.linewidth=i.lineWidth.value(),e.color="pre_market"===r?i.preMarketColor.value():i.postMarketColor.value())}}qt.LINESTYLE_DOTTED,Rt.colorsPalette["color-tv-blue-500"];class Rd extends Ad.CustomSourceBase{constructor(e,t,i){super(e,t),
this._extraHoursPrice=null,this._currentSession="holiday",this._quotesProvider=t.mainSeries().quotesProvider(),this._prePostMarketLinePaneView=new Vd(t,this,i),this._prePostPriceAxisView=new Dd(t,this),this._prePostLabelPaneView=new Id.PanePriceAxisView(this._prePostPriceAxisView,t.mainSeries(),t),this._prePostPriceLineAxisView=new kd(t,this),this._quotesProvider.quotesUpdate().subscribe(this,this._updateQuotes),this._updateQuotes()}destroy(){this._quotesProvider.quotesUpdate().unsubscribeAll(this)}paneViews(e){return this._areViewsAvailableForPane(e)?[this._prePostMarketLinePaneView]:[]}labelPaneViews(e){return this._areViewsAvailableForPane(e)?[this._prePostLabelPaneView]:[]}priceAxisViews(e,t){return this._areViewsAvailableForPane(e)?e.findTargetPriceAxisViews(this,t,[this._prePostPriceAxisView],[this._prePostPriceLineAxisView]):[]}priceScale(){return this._model.mainSeries().priceScale()}updateAllViews(e){this._prePostMarketLinePaneView.update(e),this._prePostPriceAxisView.update(e),this._prePostPriceLineAxisView.update(e),this._prePostLabelPaneView.update(e)}price(){return this._extraHoursPrice}currentSession(){return this._currentSession}canBeVisibleOnSymbolAndInterval(){return this._model.mainSeries().isPrePostMarketPricesAvailableProperty().value()}properties(){return this._model.mainSeries().properties().childs().prePostMarket}_updateQuotes(){const e=this._quotesProvider.quotes();null===e?this._extraHoursPrice=null:(this._extraHoursPrice=e.rtc,void 0!==e.current_session&&(this._currentSession=e.current_session));const t=this._model.mainSeries().properties().childs().prePostMarket.childs().visible.value(),i=this._model.properties().childs().scalesProperties.childs().showPrePostMarketPriceLabel.value();this.canBeVisibleOnSymbolAndInterval()&&(t||i)&&(this.updateAllViews((0,wi.sourceChangeEvent)(this.id())),this._model.updateSource(this))}_areViewsAvailableForPane(e){return!this._model.isInReplay().value()&&!this._model.isSnapshot()&&this._model.paneForSource(this._model.mainSeries())===e}}var Nd=i(67225);function Od(e,t){return e.code<t.code?-1:e.code>t.code?1:0}class Fd{constructor(e){this._convertibleItems=e,this._idsToItems=new Map;for(const t of e)this._idsToItems.set(t.id,t)}convertible(e){return void 0!==this._idsToItems.get(e)}item(e){return this._idsToItems.get(e)??null}size(){return this._convertibleItems.length}filterConvertible(e,t){const i=this._convertibleItems.filter(function(e,t){return i=>!e.has(i.id)&&t(i.id)}(e,t));return i.sort(Od),i}getItems(){return this._convertibleItems.map((e=>e.id))}}class Wd{constructor(e){this._allGroups=new Set,this._idToName=new Map,this._idToDescription=new Map,this._groupedUnitIds=new Map,this._groupedUnits=new Map,this._groupById=new Map,this._size=0,this._units=e;for(const t in e)if(e.hasOwnProperty(t)){this._allGroups.add(t),this._groupedUnitIds.set(t,new Set(e[t].map((e=>e.id)))),this._groupedUnits.set(t,e[t]);for(const i of e[t])this._size++,this._idToName.set(i.id,i.name),this._idToDescription.set(i.id,i.description),this._groupById.set(i.id,t)}}
unitsChanged(e){return this._units!==e}size(){return this._size}name(e){return this._idToName.get(e)||e}description(e){return this._idToDescription.get(e)||e}unitGroupById(e){return this._groupById.get(e)||null}allGroups(){return new Set(this._allGroups)}unitsByGroups(e){const t=[];return e.forEach((e=>{const i=this._groupedUnits.get(e);void 0!==i&&t.push({name:e,units:i})})),t}convertible(e,t){for(const i of t){const t=this._groupedUnitIds.get(i);if(void 0!==t&&t.has(e))return!0}return!1}}var Hd=i(50335);class zd{constructor(e){this._source=null,this._sourcePane=null,this._currentToolSupportsPhantomMode=!1,this._model=e}destroy(){this._source=null,this._sourcePane=null}source(){return this._source}onToolChanged(){this._removeSource(),this._currentToolSupportsPhantomMode=(0,Lt.isLineToolName)(mt.tool.value())&&(0,zs.supportsPhantomMode)(mt.tool.value())}onCursorPositionUpdated(){if(!this._currentToolSupportsPhantomMode)return;const e=this._model.crosshairSource();if(this._sourcePane!==e.pane&&this._removeSource(),null===e.pane||!(0,Hd.isNumber)(e.index)||!(0,Hd.isNumber)(e.price))return void this._removeSource();const t={index:e.index,price:e.price};null!==this._source?this._source.setPoint(0,t):(this._source=this._model.createLineTool({pane:e.pane,point:t,linetool:mt.tool.value()}),this._sourcePane=e.pane)}_removeSource(){null!==this._source&&(this._model.removeSource(this._source),this._source=null,this._sourcePane=null)}}var Ud=i(7024),jd=i(4359);const Gd=(e,t)=>!0,qd=(e,t)=>!t.isPlotForceOverlay(e.id),$d=(e,t)=>t.isPlotForceOverlay(e.id);function Kd(e,t){const i=e.priceScale(),s=e.firstValue();if(null===i||null===s)return;const o=e.bars().valueAt(t);if(null===o)return;let r;if(null!==e.priceSource())r=[e.barFunction()(o)];else switch(e.style()){case 12:r=[(0,n.ensure)(o[2]),(0,n.ensure)(o[3])];break;case 16:case 21:r=[(0,n.ensure)(o[2]),(0,n.ensure)(o[4]),(0,n.ensure)(o[3])];break;default:r=[(0,n.ensure)(o[1]),(0,n.ensure)(o[2]),(0,n.ensure)(o[3]),(0,n.ensure)(o[4])]}return r.map((e=>({y:i.priceToCoordinate(e,s),price:e})))}var Yd;!function(e){e[e.MagnetTolerance=50]="MagnetTolerance"}(Yd||(Yd={}));class Zd{constructor(){this._lastValue=null}align(e,t,i){this._lastValue=null;let s=e;if(!(0,Dn.magnetEnabled)().value())return s;const o=i.mainDataSource();if(null===o)return s;const r=o.priceScale();if(!r||r.isEmpty())return s;const a=o.model().mainSeries(),l=(0,Dn.magnetSnapsToIndicators)().value();if(!l&&o!==a)return s;const c=(0,n.ensure)(o.firstValue()),h=r.priceToCoordinate(e,c),d=i.containsMainSeries()?function(e,t){return Kd(e,t)}(a,t)??[]:[];if(l){i.model().allStudies(!0).filter((e=>e.isVisible())).forEach((e=>{const s=function(e,t,i){const s=e.model(),o=s.paneForSource(e),n=s.mainPane(),r=s.mainSeries();if((0,Ws.isOverlayStudy)(e))return i===o?Kd(e,t):void 0;const a=e.metaInfo();if(!a)return;const l=e.data().valueAt(t);if(null===l)return;const c=a.hasForceOverlayPlots();if(!(i===o||c&&i===n))return;const h=e.priceScale(),d=r.priceScale(),u=e.firstValue(),_=r.firstValue();if(!h||!d||null===u||null===_)return
;let p,m,g;o===n?(p=Gd,m=d,g=_):i===o?(p=qd,m=h,g=u):(p=$d,m=d,g=_);const f=a.plots,y=f.filter((t=>!(0,jd.isPlotWithTechnicalValues)(t)&&e.isPlotVisibleAt(t.id,1)&&p(t,a))),v=[];for(const e of y){const t=l[f.indexOf(e)+1];if(null!=t){const i=a.isPlotForceOverlay(e.id),s=(i?d:h).priceToCoordinate(t,i?_:u);v.push({y:s,price:m.coordinateToPrice(s,g)})}}return v}(e,t,i);s&&d.push(...s)}))}if(0===d.length)return s;d.sort(((e,t)=>Math.abs(e.y-h)-Math.abs(t.y-h)));const u=d[0];return((0,Dn.magnetMode)().value()===Ud.MagnetMode.StrongMagnet||Math.abs(u.y-h)<50)&&(s=u.price,this._lastValue=s),s}lastValue(){return this._lastValue}resetLastValue(){this._lastValue=null}}class Xd{constructor(e){this._appliedTimeFrame=new yt.WatchedObject(null),this._appliedTimeFrameInfo=null,this._appliedTimeFrameChangedBound=this._appliedTimeFrameChanged.bind(this),this._model=e,e.mainSeries().dataEvents().seriesTimeFrame().subscribe(this,this._onSeriesTimeFrame),this._appliedTimeFrame.subscribe(this._appliedTimeFrameChangedBound)}destroy(){this._appliedTimeFrame.unsubscribe(this._appliedTimeFrameChangedBound),this._model.timeScale().logicalRangeChanged().unsubscribeAll(this),this._model.mainSeries().dataEvents().seriesTimeFrame().unsubscribeAll(this)}appliedTimeFrame(){return this._appliedTimeFrame}_appliedTimeFrameChanged(){this._model.timeScale().logicalRangeChanged().unsubscribe(this,this._invalidateAppliedTimeFrame)}_onSeriesTimeFrame(e,t,i,s){if(s){const e=this._model.timeScale();this._appliedTimeFrameInfo={logicalRange:e.logicalRange(),baseIndex:e.baseIndex()},e.logicalRangeChanged().subscribe(this,this._invalidateAppliedTimeFrame)}}_invalidateAppliedTimeFrame(){if(null===this._appliedTimeFrameInfo)return;const e=this._model.timeScale(),t=e.logicalRange(),i=e.baseIndex(),s=this._appliedTimeFrameInfo.logicalRange,o=this._appliedTimeFrameInfo.baseIndex;(null===t||null===s||Math.abs(i-t.left()-(o-s.left()))>=.01||Math.abs(i-t.right()-(o-s.right()))>=.01)&&this._appliedTimeFrame.setValue(null)}}var Jd=i(32955),Qd=i(10307);class eu extends Qd.BitmapCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null}setData(e){this._data=e}hitTest(e){return null}_drawImpl(e){if(null===this._data)return;const{context:t,verticalPixelRatio:i,horizontalPixelRatio:s,bitmapSize:o}=e,n=Math.max(1,Math.floor(s));t.lineWidth=n;const r=Math.ceil(o.height*i),a=Math.ceil(o.width*s);if(t.lineCap="butt",this._data.vertLinesVisible){t.strokeStyle=this._data.vertLinesColor,(0,$t.setLineStyle)(t,this._data.vertLineStyle);for(const e of this._data.timeMarks){const i=Math.round(e.coord*s);(0,$t.drawVerticalLine)(t,i,0,r)}}if(this._data.horzLinesVisible){t.strokeStyle=this._data.horzLinesColor,(0,$t.setLineStyle)(t,this._data.horzLineStyle);for(const e of this._data.priceMarks){const s=Math.round(e.coord*i);(0,$t.drawHorizontalLine)(t,s,0,a)}}}}class tu{constructor(e){this._renderer=new eu,this._pane=e}update(){}renderer(){const e=this._pane.defaultPriceScale(),t=this._pane.model().timeScale();if(e.isEmpty()||t.isEmpty())return null
;const i=this._pane.model().properties().childs().paneProperties.childs(),s=t.marks(),o=i.gridLinesMode.value(),n={horzLinesVisible:"both"===o||"horz"===o,vertLinesVisible:"both"===o||"vert"===o,horzLinesColor:i.horzGridProperties.childs().color.value(),vertLinesColor:i.vertGridProperties.childs().color.value(),horzLineStyle:i.horzGridProperties.childs().style.value(),vertLineStyle:i.vertGridProperties.childs().style.value(),priceMarks:e.marks(),timeMarks:null!==s?s:[]};return this._renderer.setData(n),this._renderer}}class iu extends bi.DataSource{constructor(e){super(),this._model=e}id(){return"grid"}paneViews(e){return e.mode()===zi.PaneMode.Regular?[new tu(e)]:null}name(){return"Grid"}model(){return this._model}contextMenuStatName(){return"GridContextMenu"}}class su extends Ed.PriceAxisView{constructor(e,t,i,s){super(),this._source=e,this._pane=t,this._priceScale=i,this._priceProvider=s,this._properties=e.model().properties().childs().scalesProperties}setHitTestData(e){this._hitTestData=e}setXCoord(e){this._xCoord=e}additionalPadding(e){return 0}_updateRendererData(e,t,i){if(e.visible=!1,t.visible=!1,this._pane.model().chartFloatingTooltipVisible().value())return;const s=this._priceScale,o=s.mainSource(),n=null!==o?o.firstValue():null;if(!this._isVisible()||s.isEmpty()||null===n)return;const r=this._currentPrice(s);if(null===r)return;i.background=(0,Ro.resetTransparency)(this._bgColor()),i.textColor=this.generateTextColor(i.background);const a=this.additionalPadding(s.fontSize());i.additionalPaddingTop=a,i.additionalPaddingBottom=a,i.coordinate=s.priceToCoordinate(r,n),e.text=s.formatPrice(r,n),e.visible=!0,t.visible=!0,t.hitTestData=this._hitTestData,t.xCoord=this._xCoord}_currentPrice(e){return this._priceProvider(e)}}class ou extends su{additionalPadding(e){return 2/12*e}_isVisible(){const e=this._source.lockedPane();return this._properties.childs().showPriceScaleCrosshairLabel.value()&&(this._source.visible||null!==e)&&(e??this._source.pane)===this._pane}_currentPrice(e){const t=mt.crosshairLock.value();return null!==t&&1===t.type?this._pane===this._source.lockedPane()?t.price:null:super._currentPrice(e)}_bgColor(){const e=this._properties.childs();return this._source.model().dark().value()?e.crosshairLabelBgColorDark.value():e.crosshairLabelBgColorLight.value()}_updateRendererData(e,t,i){const s=t.visible;super._updateRendererData(e,t,i),this._source.isHovered()?t.backgroung=this._source.model().dark().value()?Rt.colorsPalette["color-cold-gray-600"]:Rt.colorsPalette["color-cold-gray-650"]:t.backgroung=void 0,s||(t.visible=s)}}class nu extends su{_isVisible(){return null!==this._source.measurePane().value()}_bgColor(){return this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}}var ru,au,lu=i(33718);function cu(e){const t=e.priceScale();return null===t?0:t.isPercentage()||t.isIndexedTo100()?2:1}!function(e){e[e.NotDefined=0]="NotDefined",e[e.Regular=1]="Regular",e[e.Unregular=2]="Unregular"}(ru||(ru={}));class hu extends Id.PanePriceAxisView{constructor(e,t,i,s,o){super(e,t,s),
this._crossHairMenuCachedState=null,this._hasActions=!1,this._gaOrigin="CH menu",this._crosshairPriceAxisView=e,e.setPaneRendererLabelIcon(0),this._crosshair=t,this._scale=i,this._options=o,this._updateGaOrigin()}_updateImpl(e){const t=this._crosshair.y,i=this._chartModel.properties().childs().scalesProperties.childs().fontSize.value(),s=this._chartModel.timeScale().width(),o=this._crosshair.model().priceAxisRendererOptions(),n=i+2*this._crosshairPriceAxisView.additionalPadding(i)+o.paddingTop+o.paddingBottom,r=n,a=t-n/2,c=this._crosshair.pane,h=this._mainDataSourceOnPane(),d=h&&h.symbolSource(),u=!!d&&(d.isConvertedToOtherCurrency()||d.isConvertedToOtherUnit());if(this._updateGaOrigin(),null!==h){const e=cu(h),t=h.idForAlert(),i=this._chartModel.isInReplay().value(),s=this._crossHairMenuCachedState,o=l.enabled("chart_crosshair_menu");null!==s&&s.id===t&&s.priceScale===e&&s.isCurrencyOrUnitConverted===u&&s.isInReplay===i&&s.isMenuEnabled===o||(this._updateTooltipAndActionsAvailability(h,e,u),this._crossHairMenuCachedState={id:t,priceScale:e,isCurrencyOrUnitConverted:u,isInReplay:i,isMenuEnabled:o})}const _=null!==h&&(0,Lr.isActingAsSymbolSource)(h)?h.symbol():null,p=null!==c&&(c.maximized().value()||!c.collapsed().value())&&(Boolean(_)||!1);this._crosshairPriceAxisView.setPaneLabelVisible(p);const m=this._position();if(null!==m){const e=0,t=s-r,i=Boolean(lu.showPlusButtonOnCursor.value()),o=i?this._crosshair.x:void 0,l=void 0!==o?o-r/2:"left"===m?e:t,c=void 0!==o?o+r/2:"left"===m?e+r:t+r,h=(0,Vt.box)(new Vt.Point(l,a),new Vt.Point(c,a+n));this._data={itemBox:h,clickHandler:this._handleClick.bind(this,m,i,h)},this._crosshairPriceAxisView.setHitTestData(this._data),this._crosshairPriceAxisView.setXCoord(o)}super._updateImpl(e)}_priceScale(){return this._scale}_updateGaOrigin(){this._gaOrigin=Boolean(lu.showPlusButtonOnCursor.value())?"CH menu cursor":"CH menu"}_updateTooltipAndActionsAvailability(e,t,i){this._hasActions=!1;if(!(1===t))return;this._chartModel.isInReplay().value();this._hasActions=!1}_handleClick(e,t,i,s,o){(0,re.trackEvent)(this._gaOrigin,"click");const n=this._mainDataSourceOnPane(),r=null!==n&&(0,Lr.isActingAsSymbolSource)(n)?n.symbol():null,a={pageX:o.pageX,pageY:o.pageY,clientX:o.clientX,clientY:o.clientY,screenX:o.screenX,screenY:o.screenY,price:this._crosshair.price,symbol:r};ee.emit("onPlusClick",a)}async _getMenuItems(e){return Promise.resolve([])}_createAlertMenuItems(e){return Promise.resolve([])}_getAddAlertActionOptions(e,t,i){return{dataSource:e,y:t,disabled:i,analyticsOpt:{method:"crosshair_menu",source:"chart",actionSource:"crosshair_menu",gaOrigin:this._gaOrigin}}}_createTradingMenuItems(){return Promise.resolve([])}async _createAddHorizontalLineMenuItem(){return[]}async _getActionAddHorizontalLine(e){return null}_getValue(e,t){const i=e.priceScale(),s=e.firstValue();if(null===i||null===s)return null;return i.isPercentage()||i.isIndexedTo100()?null:i.coordinateToPrice(t,s)}_showContextMenu(e,t,i,s,o){const r="left"===o;setTimeout((()=>{
const o=s.clientX-s.localX,a=s.clientY-s.localY,l=i.min.x+o,c=i.max.x+o,h=i.min.y+a,d=c-l,u=i.max.y+a-h,_=t?mt.crosshairLock.value():void 0;if(void 0!==_){const e=(0,n.ensureNotNull)(this._chartModel.timeScale().points().roughTime(this._crosshair.index));mt.crosshairLock.setValue({type:1,price:this._crosshair.price,time:e,modelId:this._chartModel.id(),paneId:(0,n.ensureNotNull)(this._crosshair.pane).id()})}Io.ContextMenuManager.showMenu(e,{clientX:s.clientX,clientY:s.clientY,box:{x:l,w:d,y:h,h:u},attachToXBy:t?"auto":r?"left":"right",attachToYBy:"auto-strict",marginX:t?0:-d},void 0,{menuName:"CrosshairMenuView"},(()=>{void 0!==_&&mt.crosshairLock.setValue(_)}))}))}_mainDataSourceOnPane(){const e=this._crosshair.pane;return null!==e?e.mainDataSource():null}}class du extends Qd.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return void 0===this._data.clickHandler?null:new Ut.HitTestResult(Ut.HitTarget.Custom,{clickHandler:this._data.clickHandler,tapHandler:this._data.clickHandler})}_drawImpl(e){const t=this._data.vertLinesVisible,i=this._data.horzLinesVisible;if(!t&&!i)return;const{context:s,horizontalPixelRatio:o,verticalPixelRatio:n,bitmapSize:r}=e;s.lineWidth=Math.max(1,Math.floor(this._data.lineWidth*o)),s.strokeStyle=this._data.color,s.fillStyle=this._data.color,s.lineCap="butt",(0,$t.setLineStyle)(s,this._data.lineStyle);const a=Math.round(this._data.x*o),l=Math.round(this._data.y*n),c=Math.ceil(r.width*o),h=Math.ceil(r.height*n);t&&a>=0&&(0,$t.drawVerticalLine)(s,a,0,h),i&&l>=0&&(0,$t.drawHorizontalLine)(s,l,0,c),this._data.drawCenter&&(s.beginPath(),s.arc(a,l,Math.round(3*o),0,2*Math.PI,!0),s.fillStyle=this._data.color,s.fill()),this._data.scissors&&function(e,t,i){const{context:s,bitmapSize:o,horizontalPixelRatio:n,verticalPixelRatio:r}=e,a=24*n,l=Math.round(t-a/2);let c=Math.round(i-a/2);if(c<0)c=0;else{const e=o.height-a;c>e&&(c=e)}s.translate(l,c),s.scale(n,r),s.fillStyle="#0f0f0f",s.fill(uu),s.strokeStyle="#fff",s.lineWidth=1,s.stroke(uu)}(e,a,l)}}!function(e){e.Path="m15.68 3.72-3.82 5.52-3.83-5.52-.28-.42-.42.3a2.84 2.84 0 0 0-.68 3.92l3.27 4.73-1.16 1.68a3.34 3.34 0 0 0-4.26 3.22 3.34 3.34 0 0 0 3.32 3.35 3.34 3.34 0 0 0 3.08-4.6l1-1.44 1.13 1.62a3.34 3.34 0 0 0 3.15 4.42c1.84 0 3.32-1.5 3.32-3.35a3.34 3.34 0 0 0-4.42-3.17l-1.23-1.78 3.22-4.65a2.86 2.86 0 0 0-.69-3.96l-.41-.29-.29.42ZM7.82 16.27c.47 0 .86.39.86.88 0 .48-.39.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.4-.88.86-.88Zm8.36 0c.47 0 .86.39.86.88 0 .48-.4.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.39-.88.86-.88Z",e[e.Size=24]="Size",e.FillColor="#0f0f0f",e.StrokeColor="#fff",e[e.StrokeWidth=1]="StrokeWidth"}(au||(au={}))
;const uu=new Path2D("m15.68 3.72-3.82 5.52-3.83-5.52-.28-.42-.42.3a2.84 2.84 0 0 0-.68 3.92l3.27 4.73-1.16 1.68a3.34 3.34 0 0 0-4.26 3.22 3.34 3.34 0 0 0 3.32 3.35 3.34 3.34 0 0 0 3.08-4.6l1-1.44 1.13 1.62a3.34 3.34 0 0 0 3.15 4.42c1.84 0 3.32-1.5 3.32-3.35a3.34 3.34 0 0 0-4.42-3.17l-1.23-1.78 3.22-4.65a2.86 2.86 0 0 0-.69-3.96l-.41-.29-.29.42ZM7.82 16.27c.47 0 .86.39.86.88 0 .48-.39.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.4-.88.86-.88Zm8.36 0c.47 0 .86.39.86.88 0 .48-.4.87-.86.87a.87.87 0 0 1-.86-.87c0-.5.39-.88.86-.88Z");const _u=Rt.colorsPalette["color-tv-blue-500"];class pu{constructor(e,t){this._rendererData={},this._renderer=new du(this._rendererData),this._source=e,this._pane=t}update(){}renderer(){const e=this._source.selectPointMode().value()!==mt.SelectPointMode.None,t=this._source.lockedPane(),i=(this._source.visible||null!==t)&&(this._source.areLinesVisible||e)&&!this._source.linesShouldBeHidden(),s=this._rendererData;if(!i||null===this._pane)return null;const o=this._source.paneForPointSelect(),r=this._source.isReplaySelection(),a=t??this._source.pane,l=this._pane===a,c=r||(null!==o?a===o&&this._pane===o:l);if(s.scissors=!1,e&&(r||this._source.isOnHoveredChartWidget())&&c){const e=(0,n.ensureNotNull)(this._source.pointToSelect());s.color=this._source.lineColor()||_u,r?(s.lineWidth=2,s.scissors=l):s.lineWidth=1,s.lineStyle=qt.LINESTYLE_SOLID,s.horzLinesVisible=!0,s.vertLinesVisible=!0,s.drawCenter=!1,"time"===e?s.horzLinesVisible=!1:"price"===e&&(s.vertLinesVisible=!1)}else{const e=this._source.properties(),t=mt.tool.value(),i=(0,lo.lastMouseOrTouchEventInfo)(),o=i.isTouch&&!i.stylus&&((0,Lt.isLineToolName)(t)||(0,mt.toolIsMeasure)(t));let n;n=o?_u:e.childs().color.value();const r=e.childs().transparency.value();!o&&r>0&&(n=(0,Ro.generateColor)(n,r)),s.color=n,s.horzLinesVisible=!this._pane.model().chartFloatingTooltipVisible().value()&&this._pane===a&&(this._pane.maximized().value()||!this._pane.collapsed().value()),s.vertLinesVisible=!0,s.lineWidth=e.childs().width.value(),s.lineStyle=e.childs().style.value(),s.drawCenter=o&&this._pane===a}return s.x=this._source.lockedX()??this._source.x,s.y=this._source.lockedY()??this._source.y,this._renderer}}var mu=i(86228);const gu={backgroundColor:(0,Ro.generateColor)(Rt.colorsPalette["color-tv-blue-500"],70),borderColor:(0,Ro.generateColor)(Rt.colorsPalette["color-tv-blue-500"],20)};class fu{constructor(e){this._renderer=new mu.RectangleRenderer,this._rectangle=null,this._crosshair=e}update(){const e=this._crosshair.selection();null!==e&&null!==this._crosshair.pane?this._rectangle=this._crosshair.pane.logicalRectToPixels(e):this._rectangle=null}renderer(){if(!this._rectangle)return null;const e={backcolor:gu.backgroundColor,color:gu.borderColor,fillBackground:!0,linewidth:1,points:[this._rectangle.min,this._rectangle.max],extendLeft:!1,extendRight:!1};return this._renderer.setData(e),this._renderer}}var yu=i(24640),vu=i(50605),Su=i(18185),bu=i(80819),wu=i(4753),Cu=i(25672);const Tu=a.t(null,void 0,i(41643)),Pu=a.t(null,{context:"study"},i(24261)),xu=(0,
hh.getPercentageFormatter)(),Mu=new Su.TimeSpanFormatter,Iu=(0,hh.getVolumeFormatter)(),Au=(0,Rt.getHexColorByName)("color-tv-blue-500"),Lu=(0,Rt.getHexColorByName)("color-ripe-red-400"),ku={bgColorPositive:(0,Ro.generateColor)(Au,80),bgColorNegative:(0,Ro.generateColor)(Lu,80),colorPositive:(0,Rt.getHexColorByName)("color-tv-blue-600"),colorNegative:(0,Rt.getHexColorByName)("color-ripe-red-400"),labelBgColorPositive:Au,labelBgColorNegative:Lu};var Eu;!function(e){e[e.MinArrowDistance=50]="MinArrowDistance"}(Eu||(Eu={}));class Du{constructor(e,t){this._horzTrenRenderer=new bu.TrendLineRenderer,this._vertTrenRenderer=new bu.TrendLineRenderer,this._bgRenderer=new mu.RectangleRenderer,this._labelRenderer=new wu.TextRenderer,this._p1=null,this._p2=null,this._source=e,this._pane=t}update(e){const[t,i]=this._source.measurePoints();if(void 0===i)return this._p1=null,void(this._p2=null);const s=(0,n.ensureNotNull)(this._source.measurePane().value()),o=t.price,r=i.price,a=i.index-t.index,l=(0,yu.forceLTRStr)(""+a),c=(0,n.ensureNotNull)(s.mainDataSource()),h=c.firstValue();if(null===h)return this._p1=null,void(this._p2=null);const d=this._source.model().timeScale().indexToCoordinate(t.index),u=this._source.model().timeScale().indexToCoordinate(i.index),_=s.defaultPriceScale().priceToCoordinate(o,h),p=s.defaultPriceScale().priceToCoordinate(r,h);this._p1=new Vt.Point(d,_),this._p2=new Vt.Point(u,p);const g=this._source.model().timeScale().indexToUserTime(t.index),f=this._source.model().timeScale().indexToUserTime(i.index);let y=null;null!==g&&null!==f&&(y=(f.valueOf()-g.valueOf())/1e3);const v=r-o,S=100*v/Math.abs(o),b=this._pane.model().mainSeries().symbolInfo(),w=b&&(0,hh.getPipFormatter)(b),C=(0,n.ensureNotNull)(c.formatter()),T=(C.formatChange?.(r,o)??C.format(v))+" ("+xu.format(Math.round(100*S)/100)+") "+(w?w.format(v):""),P=null!==y?Mu.format(y):null,x=null!==P?", "+(0,yu.startWithLTR)(P):"";let M=(0,yu.forceLTRStr)(T)+"\n"+Tu.format({count:l})+x;const I=this._source.measureVolume();Number.isNaN(I)||(M+=`\n${Pu} ${Iu.format(I)}`);const A=r<o?ku.bgColorNegative:ku.bgColorPositive,L=r<o?ku.colorNegative:ku.colorPositive,k=r<o?ku.labelBgColorNegative:ku.labelBgColorPositive,E={points:[this._p1,this._p2],linewidth:0,fillBackground:!0,color:A,backcolor:A,extendLeft:!1,extendRight:!1};this._bgRenderer.setData(E);const D=this._p1.add(this._p2).scaled(.5);{const e=Math.round(D.y),t=new Vt.Point(this._p1.x,e),i=new Vt.Point(this._p2.x,e),s={points:[t,i],color:L,linewidth:1,linestyle:qt.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:Cu.LineEnd.Normal,rightend:Math.abs(t.x-i.x)>=50?Cu.LineEnd.Arrow:Cu.LineEnd.Normal};this._horzTrenRenderer.setData(s)}{const e=Math.round(D.x),t=new Vt.Point(e,this._p1.y),i=new Vt.Point(e,this._p2.y),s={points:[t,i],color:L,linewidth:1,linestyle:qt.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:Cu.LineEnd.Normal,rightend:Math.abs(t.y-i.y)>=50?Cu.LineEnd.Arrow:Cu.LineEnd.Normal};this._vertTrenRenderer.setData(s)}const B={x:0,y:10
},V=.5*(this._p1.x+this._p2.x),R=this._p2.y,N=new Vt.Point(V,R),O={points:[N],text:M,color:"#FFFFFF",horzAlign:vu.HorizontalAlign.Center,vertAlign:vu.VerticalAlign.Middle,font:m.CHART_FONT_FAMILY,offsetX:B.x,offsetY:B.y,bold:!1,italic:!1,fontsize:12,lineSpacing:8,backgroundColor:k,backgroundTransparency:10,boxPaddingVert:9,boxPaddingHorz:9,backgroundRoundRect:4};this._labelRenderer.setData(O);const F=this._labelRenderer.measure(),W=(0,wu.calculateLabelPosition)(F,this._p1,this._p2,B,this._pane.height());this._labelRenderer.setPoints([W])}renderer(){if(null===this._p1||null===this._p2)return null;const e=new jt.CompositeRenderer;return e.append(this._bgRenderer),e.append(this._horzTrenRenderer),e.append(this._vertTrenRenderer),e.append(this._labelRenderer),e}}var Bu,Vu=i(99875);!function(e){e[e.Light=0]="Light",e[e.Dark=1]="Dark"}(Bu||(Bu={}));class Ru extends vc.MediaCoordinatesPaneRenderer{constructor(e){super(),this._svgMap=new Map,this._data=e,this._svgMap.set(e.theme,this._createSvgRenderer(e.theme))}hitTest(){return null}setData(e){this._svgMap.has(e.theme)||this._svgMap.set(e.theme,this._createSvgRenderer(e.theme)),this._data=e}_drawImpl(e){const{context:t,mediaSize:i}=e,{theme:s,x:o}=this._data,n=this._svgMap.get(s);if(!n)return;const r=n.viewBox(),{width:a,height:l}=r,c=a/2;o+c<0||o-c>i.width||(t.translate(o-c,i.height-l),n.render(t,{targetViewBox:r}))}_createSvgRenderer(e){const t=1===e?Vu.replace("backgroundColor",(0,Rt.getHexColorByName)("color-cold-gray-900")).replace("lineColor",(0,Rt.getHexColorByName)("color-cold-gray-450")):Vu.replace("backgroundColor",(0,Rt.getHexColorByName)("color-white")).replace("lineColor",(0,Rt.getHexColorByName)("color-cold-gray-550"));return(0,Mo.svgRenderer)(t)}}class Nu{constructor(e){this._source=e,this._renderer=new Ru(this._getRenderData(0))}update(){}renderer(){const e=this._source.visible&&this._source.areLinesVisible,t=this._source.lockedX(),i=0===mt.crosshairLock.value()?.type;return e&&i&&null!==t?(this._renderer.setData(this._getRenderData(t+1)),this._renderer):null}_getRenderData(e){return{x:e,theme:this._source.model().dark().value()?1:0}}}var Ou=i(40137),Fu=i(53660);class Wu extends Ou.DataWindowView{constructor(e){super(),this._invalidated=!0,this._dateItem=new Ou.DataWindowItem("",a.t(null,void 0,i(22677)),""),this._timeItem=new Ou.DataWindowItem("",a.t(null,void 0,i(12806)),""),this._model=e,this._items.push(this._dateItem),this._items.push(this._timeItem)}update(){this._invalidated=!0}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}_updateImpl(){const e=this._model.mainSeries().isDWM();if(this._timeItem.setVisible(!e),this._timeItem.setValue(Fu.notAvailable),this._dateItem.setValue(Fu.notAvailable),this._model.timeScale().isEmpty())return;let t=this._model.crosshairSource().appliedIndex();if(!(0,Hd.isNumber)(t)){const e=this._model.mainSeries().data().last();if(null===e)return;t=e.index}const i=this._model.timeScale().indexToUserTime(t);null!==i&&(this._dateItem.setValue(this._model.dateFormatter().format(i)),
e||this._timeItem.setValue(this._model.timeFormatter().format(i)))}}var Hu=i(23752);const zu=Rt.colorsPalette["color-tv-blue-500"],Uu=a.t(null,{context:"Replay"},i(53310));class ju extends Hu.TimeAxisView{constructor(e,t,i,s=!1){super(e),this._indexProvider=i,this._highlighted=s,this._source=t,this._properties=e.properties().childs().scalesProperties}_getText(e){if(this._source.isReplaySelection()){const t=this._model.timeScale().indexToUserTime(e);return null!==t?`${Uu}: ${this._model.dateTimeFormatter().format(t)}`:""}return super._getText(e)}_getBgColor(){if(this._source.isReplaySelection())return zu;const e=this._properties.childs();return this._highlighted?e.axisLineToolLabelBackgroundColorCommon.value():this._model.dark().value()?e.crosshairLabelBgColorDark.value():e.crosshairLabelBgColorLight.value()}_getIndex(){return this._model.crosshairSource().visible||null!==this._source.lockedPane()?this._indexProvider():null}_isVisible(){return this._properties.childs().showTimeScaleCrosshairLabel.value()}}var Gu,qu=i(19233),$u=i(39697),Ku=i(49156);!function(e){e[e.LineWidth=36]="LineWidth",e[e.CircleBorderWidth=1]="CircleBorderWidth",e[e.AnimationDuration=4e3]="AnimationDuration"}(Gu||(Gu={}));const Yu=(0,Ro.applyAlpha)(Ku.colors.colorRipeRed500,.25),Zu=(0,Ro.applyAlpha)(Ku.colors.colorRipeRed500,.03);class Xu{constructor(e){this._invalidated=!0,this._circleRenderer=new $u.CircleRenderer,this._source=e}update(e){this._invalidated=!0}renderer(e){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._circleRenderer}_updateImpl(){const e=this._source.originX(),t=this._source.originY();Number.isFinite(e)&&Number.isFinite(t)?this._circleRenderer.setData({center:(0,Vt.point)(e,t),radius:18,lineWidth:1,color:Zu,backColor:Yu,disableInteractions:!0}):this._circleRenderer.setData(null)}}class Ju{constructor(e){this._activeHighlighter=null,this._highlighters=new Map,this._toolsFactory=null,this._throttleUpdateHighlighters=(0,o.default)((()=>{const e=(0,wi.sourceChangeEvent)(this._crosshair.id());let t=!1;const i=Array.from(this._highlighters.keys());for(const s of i){const i=[];for(const t of(0,n.ensureDefined)(this._highlighters.get(s)))t.animationProgress()<1?(t.updateAllViews(e),i.push(t)):t.destroy?.();i.length>0?(this._highlighters.set(s,i),t=!0):this._highlighters.delete(s)}t&&this._crosshair.model().updateSource(this._crosshair)}),20,{leading:!0}),this._crosshair=e,this._view=new Xu(e),this._currentTool=mt.tool.spawn(),this._currentTool.subscribe((e=>{(0,mt.toolIsDemonstration)(e)&&null===this._toolsFactory&&(this._toolsFactory=new Jl.AsyncResourceWrapper((async()=>{const e=await i.e(360).then(i.bind(i,76196));return(t,i,s,o)=>new e.LineToolDemonstrationHighlighter(t,i,s,o)})()))}),{callWithLast:!0})}destroy(){for(const[,e]of this._highlighters)for(const t of e)t.destroy?.();this._currentTool.destroy()}update(e){this._view.update(e);for(const[,t]of this._highlighters)for(const i of t)i.updateAllViews(e)}paneViews(e){const t=[];e===this._crosshair.pane&&(0,
mt.toolIsDemonstration)(mt.cursorTool.value())&&t.push(this._view);for(const i of this._highlighters.get(e)??[]){const s=i.paneViews(e);s&&t.push(...s)}return this._highlighters.size>0&&this._throttleUpdateHighlighters(),t}createHighlighter(){const e=this._toolsFactory?.get();if(!e)return;this._activeHighlighter=e(this._crosshair.model(),Yu,36,4e3);const t=(0,n.ensureNotNull)(this._crosshair.pane),i=(0,n.ensureNotNull)(t.mainDataSource());(0,zs.prepareLineToolPropertiesByOwnerSource)(this._activeHighlighter.properties(),i),this._activeHighlighter.setOwnerSource(i);const s=this._highlighters.get(t)??[];s.push(this._activeHighlighter),this._highlighters.set(t,s)}addHighlighterPosition(e){this._activeHighlighter?.addPoint(e),this.update((0,wi.sourceChangeEvent)(this._crosshair.id()))}isThereUnfinishedHighlighter(){return null!==this._activeHighlighter}finishHighlighter(){this._activeHighlighter?.finish(),this._activeHighlighter=null,this._throttleUpdateHighlighters()}}const Qu={menuEnabled:!1,menuForMainSourceOnly:!1,disableTradingMenuActions:!1,disableDrawHorizLineMenuAction:!1};let e_=0;const t_=(0,ne.getLogger)("Chart.Crosshair");class i_ extends bi.DataSource{constructor(e,t,i){super(),this.pane=null,this.price=NaN,this.index=NaN,this.visible=!0,this.areLinesVisible=!0,this.x=NaN,this.y=NaN,this._lockData=null,this._crosshairDemonstration=new Ju(this),this._measurePane=new O.WatchedValue(null),this._measurePaneViewCache=new WeakMap,this._startMeasurePoint=null,this._endMeasurePoint=null,this._lastValidMeasurePoint=null,this._normalizedMeasurePoints=null,this._linesShouldBeHidden=!1,this._isOnHoveredChartWidget=!1,this._crossHairSelectPointMode=new O.WatchedValue(mt.SelectPointMode.None),this._selectionPane=null,this._selectionView=new fu(this),this._selectionStartPoint=null,this._timeLockPaneView=null,this._crosshairPaneViewCache=new WeakMap,this._pointSelectionPaneViewCache=new WeakMap,this._priceAxisViews=new Map,this._panePriceAxisViews=new Map,this._startMeasurePriceAxisViews=new Map,this._endMeasurePriceAxisViews=new Map,this._originX=NaN,this._originY=NaN,this._subscribed=!1,this._movedDelegate=new ae.Delegate,this._pointSelectedDelegate=new ae.Delegate,this._requestedPoint=null,this._paneForRequestedPoint=null,this._selectLineColor=null,this._volumeCalculator=null,this._selectFromAllChartsIfOutOfData=null,this._currentMeasurePointsetAndSymbolId=null,this._model=e,this._options=Object.assign({},Qu,i||{}),this._dataWindowView=new Wu(e),this.setSelectionEnabled(!1);const s=e=>t=>t===(0,n.ensureNotNull)(this._measurePane.value()).defaultPriceScale()?e():null;this._currentPosPriceProvider=e=>{const t=(0,n.ensureNotNull)(this.pane);if(e===t.defaultPriceScale())return this.price;const i=(0,n.ensureNotNull)(t.defaultPriceScale().mainSource()).firstValue();if(null===i)return null;const s=t.defaultPriceScale().priceToCoordinate(this.price,i),o=(0,n.ensureNotNull)(e.mainSource()).firstValue();return null===o?null:e.coordinateToPrice(s,o)},this._startMeasurePriceProvider=s((()=>(0,
n.ensureNotNull)(this._startMeasurePoint).price)),this._endMeasurePriceProvider=s((()=>(0,n.ensureNotNull)(this._lastMeasurePoint()).price)),this._properties=t;this._timeAxisView=new ju(e,this,(()=>this.appliedIndex()),!1),this._startMeasureTimeAxisView=new ju(e,this,(()=>(0,n.ensureNotNull)(this._startMeasurePoint).index),!0),this._endMeasureTimeAxisView=new ju(e,this,(()=>(0,n.ensureNotNull)(this._lastMeasurePoint()).index),!0),this._cursorTool=mt.cursorTool.spawn(),e.readOnly()||this._cursorTool.subscribe((e=>this.areLinesVisible="arrow"!==e),{callWithLast:!0}),this._crosshairLock=mt.crosshairLock.spawn(),this._showPlusButtonOnCursor=lu.showPlusButtonOnCursor.spawn();const o=()=>{this.updateAllViews((0,wi.sourceChangeEvent)(this.id())),this._model.lightUpdate()};this._crosshairLock.subscribe(o),this._showPlusButtonOnCursor.subscribe(o)}destroy(){null!==this._volumeCalculator&&this._volumeCalculator.destroy(),this._measurePane.setValue(null),this._crosshairLock.destroy(),this._showPlusButtonOnCursor.destroy(),this._cursorTool.destroy(),this._removeMeasurePointset(),this._crosshairDemonstration.destroy(),super.destroy()}name(){return"Crosshair"}moved(){return this._movedDelegate}originX(){return this._originX}originY(){return this._originY}saveOriginCoords(e,t){this._originX=e,this._originY=t}clearOriginCoords(){this._originX=NaN,this._originY=NaN}currentPoint(){return new Vt.Point(this.x,this.y)}model(){return this._model}appliedIndex(){return this._getLockData().index??this.index}lockedX(){return this._getLockData().xCoord??null}lockedY(){return this._getLockData().yCoord??null}lockedPane(){const e=mt.crosshairLock.value();return null===e||1!==e.type?null:this._model.id()===e.modelId?this._model.paneForId(e.paneId):this._model.mainPane()}invalidateLockPosition(){this._lockData=null}startMeasurePoint(){return this._startMeasurePoint||null}endMeasurePoint(){return this._endMeasurePoint||null}measureVolume(){if(null===this._volumeCalculator)return NaN;const[e,t]=this.measurePoints();return void 0===t?NaN:this._volumeCalculator.volume(e.index,t.index)}measurePane(){return this._measurePane.readonly()}crosshairDemonstration(){return this._crosshairDemonstration}startMeasuring(e,t){this._startMeasurePoint=e,this._measurePane.setValue(t),t.containsMainSeries()&&((0,n.assert)(null===this._volumeCalculator),this._volumeCalculator=new qu.SeriesTimeRangeVolumeCalculator(this.model().mainSeries())),this._model.updatePane(t)}finishMeasure(e){this._endMeasurePoint=e,this._createMeasurePointset((0,n.ensureNotNull)(this._startMeasurePoint),this._endMeasurePoint)}clearMeasure(){this._removeMeasurePointset(),this._measurePane.setValue(null),delete this._startMeasurePoint,delete this._endMeasurePoint,delete this._lastValidMeasurePoint,this._model.lightUpdate(),null!==this._volumeCalculator&&(this._volumeCalculator.destroy(),this._volumeCalculator=null)}measurePoints(){const e=[(0,n.ensureNotNull)(this._startMeasurePoint)],t=this._lastMeasurePoint();return null!==t&&e.push(t),e}startSelection(e){
this._selectionStartPoint=this.currentLogicalPoint(),this._selectionPane=e}clearSelection(){this._selectionStartPoint=null,this._selectionPane=null}selection(){return this._selectionStartPoint?{p1:this._selectionStartPoint,p2:this.currentLogicalPoint()}:null}currentLogicalPoint(){return{index:this.appliedIndex(),price:this.price}}selectPointMode(){return this._crossHairSelectPointMode}lineColor(){return this._selectLineColor}cancelRequestSelectPoint(){this._crossHairSelectPointMode.value()!==mt.SelectPointMode.None&&this._setSelectPointModeState(mt.SelectPointMode.None),this._selectFromAllChartsIfOutOfData=null}requestSelectPoint(e){(0,n.assert)(this._crossHairSelectPointMode.value()===mt.SelectPointMode.None,"Point already requested");const{pointType:t,pane:i,lineColor:s=null,selectFromAllChartsIfOutOfData:o,selectPointMode:r=mt.SelectPointMode.Study}=e;i&&((0,n.assert)(-1!==this._model.panes().indexOf(i),"Chartmodel doesn't contains specified pane"),this._paneForRequestedPoint=i,this._model.panesCollectionChanged().subscribe(this,this._paneCollectionChanged)),this._selectLineColor=s,this._requestedPoint=t,this._selectFromAllChartsIfOutOfData=o??null,this._setSelectPointModeState(r)}onPointSelected(){return this._pointSelectedDelegate}trySelectCurrentPoint(){const e=this.pane;if(!e)return;const t=(0,n.ensureNotNull)(this._requestedPoint);let i=null;if(!this._model.mainSeries().bars().search(this.index,dd.PlotRowSearchMode.Exact)&&"price"!==t&&(this._selectFromAllChartsIfOutOfData&&(i=Math.min(...Array.from(mt.barTimesUnderCursor.values()))??null),null===i))return;if(this._paneForRequestedPoint&&this._paneForRequestedPoint!==e)return;let s,o=i;if("price"===t||null!==i||(o=this._model.timeScale().indexToTimePoint(this.index),null!==o)){if("time"!==t){const t=e.mainDataSource();if(null===t)return;const i=t.firstValue(),o=t.priceScale();if(null===i||null===o)return;s=o.coordinateToPrice(this.y,i)}this._setSelectPointModeState(mt.SelectPointMode.None),this._pointSelectedDelegate.fire({time:o??void 0,price:s},e)}}isOnHoveredChartWidget(){return this._isOnHoveredChartWidget}setOnHoveredChartWidget(e){this._isOnHoveredChartWidget=e}isReplaySelection(){return!1}clearPosition(){this.visible=!1,this.index=NaN,this.price=NaN,this.x=NaN,this.y=NaN,this.pane=null,this.clearOriginCoords(),this._updateVisibilityDependentPaneViews()}setPosition(e,t,i){this._subscribed||(this._model.mainSeries().onRestarted().subscribe(this,this.clearMeasure),this._subscribed=!0),this.visible=!0;const s=this._model.id(),o=this._model.mainSeries().bars().search(this.index,dd.PlotRowSearchMode.NearestRight);return o&&mt.barTimesUnderCursor.set(s,o.value[0]),this._tryToUpdateViews(e,t,i)}setLinesShouldBeHidden(e){this._linesShouldBeHidden=e}linesShouldBeHidden(){return this._linesShouldBeHidden}handleContextMenuEvent(e){this._crossHairSelectPointMode.value()!==mt.SelectPointMode.None&&this._setSelectPointModeState(mt.SelectPointMode.None)}properties(){return this._properties}priceAxisViews(e,t){
const i=null===this._requestedPoint||"time"!==this._requestedPoint||!this._isOnHoveredChartWidget,s=[];return(this.lockedPane()??this.pane)===e&&i&&s.push(this._createPriceAxisViewOnDemand(this._priceAxisViews,this._panePriceAxisViews,e,t,this._currentPosPriceProvider,ou,!0)[0]),this._startMeasurePoint&&s.push(this._createPriceAxisViewOnDemand(this._startMeasurePriceAxisViews,null,e,t,this._startMeasurePriceProvider,nu)[0]),this._lastMeasurePoint()&&s.push(this._createPriceAxisViewOnDemand(this._endMeasurePriceAxisViews,null,e,t,this._endMeasurePriceProvider,nu)[0]),s}timeAxisViews(){const e=[],t=null===this._requestedPoint||"price"!==this._requestedPoint||!this._isOnHoveredChartWidget;return this._linesShouldBeHidden||!this.visible&&null===mt.crosshairLock.value()||!t||e.push(this._timeAxisView),this._startMeasurePoint&&e.push(this._startMeasureTimeAxisView),this._lastMeasurePoint()&&e.push(this._endMeasureTimeAxisView),e}paneViews(e){if(void 0===e||e.mode()!==zi.PaneMode.Regular)return null;const t=[];if(this.isReplaySelection()){let i=this._pointSelectionPaneViewCache.get(e);i||(i=new CrosshairPointSelectionPaneView(this,e,this._model),this._pointSelectionPaneViewCache.set(e,i)),t.push(i)}let i=this._crosshairPaneViewCache.get(e);if(i||(i=new pu(this,e),this._crosshairPaneViewCache.set(e,i)),t.push(i),e===this._selectionPane&&t.push(this._selectionView),e===this._measurePane.value()){let i=this._measurePaneViewCache.get(e);i||(i=new Du(this,e),this._measurePaneViewCache.set(e,i)),i.update((0,wi.sourceChangeEvent)(this.id())),t.push(i)}if((lu.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value())&&1!==mt.crosshairLock.value()?.type){const i=e===this.pane,s=!ze.CheckMobile.any()||window.screen.width>=320,o=mt.tool.value(),n=(0,Lt.isLineToolName)(o),r=null!==this._model.lineBeingEdited()||null!==this._model.lineBeingCreated()||this._model.sourcesBeingMoved().length>0||null!==this._model.customSourceBeingMoved()||(0,mt.toolIsMeasure)(o);if(i&&this._isOnHoveredChartWidget&&this._crossHairSelectPointMode.value()===mt.SelectPointMode.None&&s&&!n&&!r){const i=e.mainDataSource();if(null!==i){const s=i.priceScale();if(null!==s){const i=this._createPriceAxisViewOnDemand(this._priceAxisViews,this._panePriceAxisViews,e,s,this._currentPosPriceProvider,ou,!0)[1];null!==i&&t.push(i)}}}}return 0===mt.crosshairLock.value()?.type&&(null===this._timeLockPaneView&&(this._timeLockPaneView=new Nu(this)),t.push(this._timeLockPaneView)),t.push(...this._crosshairDemonstration.paneViews(e)),t}dataWindowView(){return this._dataWindowView}updateAllViews(e){this._priceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._panePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._startMeasurePoint&&(this._startMeasurePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._startMeasureTimeAxisView.update(e)),this._lastMeasurePoint()&&(this._endMeasurePriceAxisViews.forEach((t=>{t.forEach((t=>t.update(e)))})),this._endMeasureTimeAxisView.update(e)),this._timeAxisView.update(e),this._selectionView.update(),
this._dataWindowView.update(),this._crosshairDemonstration.update(e),this._updateVisibilityDependentPaneViews()}isMenuEnabled(){return!0}isHoveredEnabled(){return lu.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value()}isHovered(){return this._model.hoveredSource()===this}pointToSelect(){return this._requestedPoint}paneForPointSelect(){return this._paneForRequestedPoint}contextMenuStatName(){return"CrossHairContextMenu"}restart(){this._currentMeasurePointsetAndSymbolId=null,this._normalizedMeasurePoints&&this._createMeasurePointsetWithNormalizedPoints(this._normalizedMeasurePoints)}_lastMeasurePoint(){return this._endMeasurePoint?this._endMeasurePoint:(null!==this.pane&&this._measurePane.value()===this.pane&&(this._lastValidMeasurePoint={price:this._model.magnet().align(this.price,this.index,this.pane),index:this.index}),this._lastValidMeasurePoint||null)}_createPriceAxisViewOnDemand(e,t,i,s,o,r,a=!1){let l=e.get(i),c=null!==t?t.get(i):void 0;void 0===l&&(l=new Map,e.set(i,l),this.isMenuEnabled()&&null!==t&&(c=new Map,t.set(i,c)),a&&i.onDestroyed().subscribe(this,(()=>this._onPaneDestroyed(i))));let h=l.get(s);if(void 0===h){if(h=new r(this,i,s,o),l.set(s,h),void 0!==c){const e=new hu(h,this,s,this._model,this._options);c.set(s,e)}a&&s.lastSourceRemoved().subscribe(this,(()=>this._onPriceScaleCleared(s)))}let d=null;return void 0!==c&&(d=(0,n.ensureDefined)(c.get(s))),[h,d]}_onPaneDestroyed(e){e.onDestroyed().unsubscribeAll(this),this._priceAxisViews.delete(e),this._panePriceAxisViews.delete(e),this._startMeasurePriceAxisViews.delete(e),this._endMeasurePriceAxisViews.delete(e)}_onPriceScaleCleared(e){e.lastSourceRemoved().unsubscribeAll(this),this._priceAxisViews.forEach((t=>t.delete(e))),this._panePriceAxisViews.forEach((t=>t.delete(e))),this._startMeasurePriceAxisViews.forEach((t=>t.delete(e))),this._endMeasurePriceAxisViews.forEach((t=>t.delete(e)))}_tryToUpdateViews(e,t,i){return!!this._tryToUpdateData(e,t,i)&&(this.updateAllViews((0,wi.sourceChangeEvent)(this.id())),this._movedDelegate.fire({index:this.index,price:this.price}),!0)}_tryToUpdateData(e,t,i){const s=this.x,o=this.y,r=this.price,a=this.index,l=this.pane,c=this._priceScaleByPane(i);if(this.index=e,this.x=isNaN(e)?NaN:this._model.timeScale().indexToCoordinate(e),null!==c&&null!==i){this.pane=i,this.price=t;const e=(0,n.ensureNotNull)(i.mainDataSource()).firstValue();this.y=null===e?NaN:c.priceToCoordinate(t,e)}else this.pane=null,this.price=NaN,this.y=NaN;return s!==this.x||o!==this.y||a!==this.index||r!==this.price||l!==this.pane}_priceScaleByPane(e){return e&&!e.defaultPriceScale().isEmpty()?e.defaultPriceScale():null}_setSelectPointModeState(e){e===mt.SelectPointMode.None&&(this._requestedPoint=null,this._selectLineColor=null,this._paneForRequestedPoint&&(this._paneForRequestedPoint=null,this._model.panesCollectionChanged().unsubscribe(this,this._paneCollectionChanged))),mt.activePointSelectionMode.setValue(e),this._crossHairSelectPointMode.setValue(e),this._model.lightUpdate()}_paneCollectionChanged(e){
const t=this._paneForRequestedPoint;null!==t&&-1===e.indexOf(t)&&this.cancelRequestSelectPoint()}_updateVisibilityDependentPaneViews(){for(const e of this.model().panes())this._pointSelectionPaneViewCache.get(e)?.update()}_getLockData(){if(null===this._lockData){const e=mt.crosshairLock.value();if(null===e)this._lockData={};else{const t=this._model.timeScale(),i=t.points().roughIndex(e.time)??void 0,s=void 0===i?void 0:t.indexToCoordinate(i);switch(e.type){case 0:this._lockData={index:i,xCoord:s};break;case 1:{let t;const o=this.lockedPane();if(null!==o){const i=o.mainDataSource();if(null!==i){const s=i.firstValue(),o=i.priceScale();null!==o&&null!==s&&(t=o.priceToCoordinate(e.price,s))}}this._lockData={index:i,xCoord:s,yCoord:t}}}}}return this._lockData}_createMeasurePointsetWithNormalizedPoints(e){const t=this._model.mainSeries().seriesSource().symbolInstanceId();if(null===t)return;this._removeMeasurePointset(),++e_,this._currentMeasurePointsetAndSymbolId={measurePointsetId:e_,symbolId:t},this._normalizedMeasurePoints=e;const i=(0,Ai.getServerInterval)(this._model.mainSeries().interval());this._model.chartApi().createPointset(this._currentMeasurePointsetIdWithPrefix(),"turnaround",this._currentMeasurePointsetAndSymbolId.symbolId,i,e,this._onPointsetResponse.bind(this))}_createMeasurePointset(e,t){const i=this._normalizePoint(e),s=this._normalizePoint(t),o=[[i.time_t,i.offset],[s.time_t,s.offset]];this._createMeasurePointsetWithNormalizedPoints(o)}_removeMeasurePointset(){null!==this._currentMeasurePointsetAndSymbolId&&this._model.chartApi().isConnected().value()&&this._model.chartApi().removePointset(this._currentMeasurePointsetIdWithPrefix()),this._currentMeasurePointsetAndSymbolId=null,this._normalizedMeasurePoints=null}_currentMeasurePointsetIdWithPrefix(){return"pointsetMeasure_"+(0,n.ensureNotNull)(this._currentMeasurePointsetAndSymbolId).measurePointsetId}_normalizePoint(e){return{...this._model.timeScale().normalizeBarIndex(e.index),price:e.price}}_onPointsetResponse(e){if("pointset_error"===e.method)return void t_.logError(`Error getting pointset: ${e.params[0]} ${e.params[1]}`);if(e.params.customId!==this._currentMeasurePointsetIdWithPrefix())return;if(null===this._startMeasurePoint||null===this._endMeasurePoint)return;const t=e.params.plots;if(2!==t.length)return;const i=t[0].value[0],s=t[1].value[0];this._startMeasurePoint.index=i,this._endMeasurePoint.index=s,this.updateAllViews((0,wi.sourceChangeEvent)(this.id())),this._model.updateSource(this)}}var s_=i(45720),o_=i(22033),n_=i(97902);const r_=(0,ne.getLogger)("Chart.ApplyPreferencesToAllCharts"),a_={color:"",style:0},l_={autoScale:!1,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,log:!1,logDisabled:!1,alignLabels:!1,isInverted:!1,indexedTo100:!1},c_={backgroundType:co.ColorType.Solid,background:"",backgroundGradientStartColor:"",backgroundGradientEndColor:"",topMargin:0,bottomMargin:0,gridLinesMode:"both",horzGridProperties:(0,ge.deepExtend)({},a_),vertGridProperties:(0,ge.deepExtend)({},a_),crossHairProperties:(0,
ge.deepExtend)({},{color:"",style:0,transparency:0,width:0}),legendProperties:(0,ge.deepExtend)({},{showStudyArguments:!1,showStudyTitles:!1,showStudyValues:!1,showSeriesTitle:!1,showSeriesOHLC:!1,showLegend:!1,showLastDayChange:!1,showBarChange:!0,showVolume:!1,showPriceSource:!1,showBackground:!0,backgroundTransparency:0,showLogo:!0,showTradingButtons:!0,showTradingButtonsMobile:!0,showSeriesLegendCloseOnMobile:!0,barChangeUpColor:"",barChangeDownColor:"",useBarChangeCustomColors:!1}),axisProperties:(0,ge.deepExtend)({},l_),separatorColor:""},h_={lineColor:"",textColor:"",fontSize:0,scaleSeriesOnly:!1,showSeriesLastValue:!1,seriesLastValueMode:n_.PriceAxisLastValueMode.LastValueAccordingToScale,showSeriesPrevCloseValue:!1,showStudyLastValue:!1,showSymbolLabels:!1,showStudyPlotLabels:!1,showBidAskLabels:!1,showPrePostMarketPriceLabel:!0,showFundamentalLastValue:!1,showFundamentalNameLabel:!1,showPriceScaleCrosshairLabel:!0,showTimeScaleCrosshairLabel:!0},d_={...h_},u_={visible:!1,futureOnly:!1,breaks:(0,ge.deepExtend)({},{color:"",visible:!1,style:0,width:0})},__={style:0,minTick:"",showPriceLine:!1,priceLineWidth:0,priceLineColor:"",baseLineColor:"",showPrevClosePriceLine:!1,showCountdown:!0,prevClosePriceLineWidth:0,sessionId:"regular",prevClosePriceLineColor:"",esdShowDividends:!1,esdShowSplits:!1,esdShowEarnings:!1,esdShowBreaks:!1,showContinuousContractSwitches:!1,showContinuousContractSwitchesBreaks:!1,showFuturesContractExpiration:!1,showLastNews:!1,dividendsAdjustment:!1,backAdjustment:!1,settlementAsClose:!0,statusViewStyle:(0,ge.deepExtend)({},{fontSize:16,showExchange:!0,showInterval:!0,symbolTextSource:"description"}),priceAxisProperties:(0,ge.deepExtend)({},l_),highLowAvgPrice:(0,ge.deepExtend)({},{highLowPriceLinesVisible:!1,highLowPriceLabelsVisible:!1,averageClosePriceLabelVisible:!1,averageClosePriceLineVisible:!1,highLowPriceLinesColor:"",highLowPriceLinesWidth:0,averagePriceLineColor:"",averagePriceLineWidth:0}),candleStyle:(0,ge.deepExtend)({},o_.candleStylePreferencesDefault),hollowCandleStyle:(0,ge.deepExtend)({},o_.hollowCandlePreferencesStyleDefault),barStyle:(0,ge.deepExtend)({},o_.barStylePreferencesDefault),lineStyle:(0,ge.deepExtend)({},o_.lineStyleDefault),lineWithMarkersStyle:(0,ge.deepExtend)({},o_.lineStyleDefault),steplineStyle:(0,ge.deepExtend)({},o_.lineStyleDefault),areaStyle:(0,ge.deepExtend)({},o_.areaStylePreferencesDefault),hlcAreaStyle:(0,ge.deepExtend)({},o_.hlcAreaStylePreferencesDefault),baselineStyle:(0,ge.deepExtend)({},o_.baselineStylePreferencesDefault),hiloStyle:(0,ge.deepExtend)({},o_.hiloStylePreferencesDefault),haStyle:(0,ge.deepExtend)({},o_.haStylePreferencesDefault),renkoStyle:(0,ge.deepExtend)({},o_.renkoStylePreferencesDefault),pbStyle:(0,ge.deepExtend)({},o_.pbStylePreferencesDefault),kagiStyle:(0,ge.deepExtend)({},o_.kagiStylePreferencesDefault),pnfStyle:(0,ge.deepExtend)({},o_.pnfStylePreferencesDefault),rangeStyle:(0,ge.deepExtend)({},o_.rangeStylePreferencesDefault),columnStyle:(0,ge.deepExtend)({},o_.columnStylePreferencesDefault),hlcBarsStyle:(0,
ge.deepExtend)({},o_.hlcBarsStylePreferencesDefault)},p_={priceScaleSelectionStrategyName:"auto",timeScale:(0,ge.deepExtend)({},{defaultRightOffset:0,defaultRightOffsetPercentage:5,usePercentageRightOffset:!1}),mainSeries:(0,ge.deepExtend)({},__),sessions:(0,ge.deepExtend)({},Ql.sessionsPreferencesDefault),paneProperties:(0,ge.deepExtend)({},c_),chartEventsSourceProperties:(0,ge.deepExtend)({},u_),tradingProperties:(0,ge.deepExtend)({},Co.tradingPreferencesDefault)},m_={timezone:"",inactivityGaps:!1,scalesProperties:(0,ge.deepExtend)({},d_),...p_},g_={scalesProperties:(0,ge.deepExtend)({},h_),...p_};function f_(e,t,i,s,o=!0){if(void 0===t[e])return r_.logDebug(`We haven't had this property ${s}.${e} yet, please, remove it from whiteList`),null;if((0,tt.isObject)(i[e])){const n=Object.keys(i[e]);let r="";return n.map((n=>({[n]:f_(n,t[e],i[e],`${s}.${e}`,o)}))).reduce(((e,t)=>(r=Object.keys(t)[0],e[r]=t[r],e)),{})}return o?t[e].value():t[e]}var y_,v_=i(37293);!function(e){e.StudyCannotBeChild="cannot_be_child",e.StubWasRemoved="stub_was_removed",e.CannotGetMetainfo="cannot_get_metainfo",e.CannotCompilePub="cannot_compile_pub",e.Cancelled="cancelled",e.Unknown="unknown"}(y_||(y_={}));const S_=(0,ne.getLogger)("Chart.Studies.StudyInserter"),b_=/^PUB;.*/;class w_{constructor(e,t){this._parentSources=[],this._propsState=void 0,this._preferredPriceScale=void 0,this._allowChangeCurrency=!1,this._allowChangeUnit=!1,this._paneSize=void 0,this._forceOverlay=!1,this._inserterImpl=t,this._studyDescriptor=e}setParentSources(e){this._parentSources=e}setPaneSize(e){this._paneSize=e}setPreferredPriceScale(e){this._preferredPriceScale=e}setAllowChangeCurrency(e){this._allowChangeCurrency=e}setAllowChangeUnit(e){this._allowChangeUnit=e}setForceOverlay(e){this._forceOverlay=e}setPropertiesState(e){this._propsState=e}setTargetPriceScaleMode(e){this._targetPriceScaleMode=e}async insert(e,t,i){let s=null;var o;i||(s=void 0!==(o=this._inserterImpl).createStub&&void 0!==o.removeStub?this._inserterImpl.createStub():null);const n=(e,t)=>{if(i){const s=(0,et.default)(e)?{error:e}:{error:e.message,editorError:e};i.setStatus({type:gh.StudyStatusType.Error,errorDescription:s}),t&&i.setMetaInfo(t),this._inserterImpl.storeFailedStub(i)}};let r,a,l=!0;try{r=await(0,os.studyMetaInfoRepository)().findById(this._studyDescriptor)}catch(e){S_.logWarn(`Cannot get study ${JSON.stringify(this._studyDescriptor)}`);const t=this._studyDescriptor.pineId;b_.test(t);return n("Error: cannot compile script"),Promise.reject(y_.CannotGetMetainfo)}finally{null!==s&&(l=this._inserterImpl.removeStub(s))}if(!l)return Promise.reject(y_.StubWasRemoved);if(void 0!==t&&t.cancelled)return Promise.reject(y_.Cancelled);if(!this._canApplyStudyToParent(r))return n("Error: cannot be child"),Promise.reject(y_.StudyCannotBeChild);const c={...r.defaults.inputs};let d={};if(void 0!==e){const t=ns.StudyMetaInfo.getStudyPropertyRootName(r),i=(0,tt.clone)((0,h.defaults)(t));(0,tt.merge)(c,i.inputs);const s=await e(c,r.inputs,r);d=s.inputs,this._parentSources=s.parentSources??[]}
if(void 0!==t&&t.cancelled)return Promise.reject(y_.Cancelled);const u=this._insertStudy(r,d,i);if(null===u)return n("Error: unknown error"),Promise.reject(y_.Unknown);await u.startPromise;const _=await u.study;return a?Promise.reject(a):_}_insertStudy(e,t,i){return this._inserterImpl.createStudy(e,t,null,i,this._propsState,this._forceOverlay,this._parentSources,this._preferredPriceScale,this._allowChangeCurrency,this._allowChangeUnit,this._paneSize,this._targetPriceScaleMode)}_canApplyStudyToParent(e){return 0===this._parentSources.length||ns.StudyMetaInfo.canBeChild(e)}}class C_{constructor(e){this._priceSourceNamesById=new Map,e.forEach((e=>this._priceSourceNamesById.set(e.id,e.name)))}name(e){return this._priceSourceNamesById.get(e)??null}priceSourcesChanged(e){return e.length!==this._priceSourceNamesById.size}}var T_=i(2072);class P_{constructor(){this._widgets=null,this._provider=new T_.WatchedValue(null),this._watermarkProperties=uc();const e=(0,n.ensureDefined)(this._watermarkProperties.child("color"));this._colorWatchedValue=(0,ye.convertPropertyToWatchedValue)(e);const t=(0,n.ensureDefined)(this._watermarkProperties.child("ticker"));this._tickerVisibilityWatchedValue=(0,ye.convertPropertyToWatchedValue)(t);const i=(0,n.ensureDefined)(this._watermarkProperties.child("interval"));this._intervalVisibilityWatchedValue=(0,ye.convertPropertyToWatchedValue)(i);const s=(0,n.ensureDefined)(this._watermarkProperties.child("description"));this._descriptionVisibilityWatchedValue=(0,ye.convertPropertyToWatchedValue)(s);const o=(0,n.ensureDefined)(this._watermarkProperties.child("custom"));this._customVisibilityWatchedValue=(0,ye.convertPropertyToWatchedValue)(o);let r=!1;const a=()=>{r=!0,this._visibilityWatchedValue.setValue(this._tickerVisibilityWatchedValue.value()||this._intervalVisibilityWatchedValue.value()||this._descriptionVisibilityWatchedValue.value()),r=!1};this._visibilityWatchedValue=new T_.WatchedValue(!1),a(),this._tickerVisibilityWatchedValue.subscribe(a),this._intervalVisibilityWatchedValue.subscribe(a),this._descriptionVisibilityWatchedValue.subscribe(a),this._visibilityWatchedValue.subscribe((e=>{r||(this._tickerVisibilityWatchedValue.setValue(e),this._intervalVisibilityWatchedValue.setValue(e),this._descriptionVisibilityWatchedValue.setValue(e))}))}setWidgetCollection(e){this._widgets=e}setContentProvider(e){this._provider.setValue(e),this._widgets&&this._widgets.getAll().forEach((e=>{e.model().model().lightUpdate()}))}provider(){return this._provider}ready(){return null!==this._widgets}destroy(){this._colorWatchedValue.destroy(),this._visibilityWatchedValue.destroy(),this._tickerVisibilityWatchedValue.destroy(),this._intervalVisibilityWatchedValue.destroy(),this._descriptionVisibilityWatchedValue.destroy()}visibility(){return this._visibilityWatchedValue}tickerVisibility(){return this._tickerVisibilityWatchedValue}intervalVisibility(){return this._intervalVisibilityWatchedValue}descriptionVisibility(){return this._descriptionVisibilityWatchedValue}customVisibility(){
return this._customVisibilityWatchedValue}color(){return this._colorWatchedValue}static getInstance(){return null===this._instance&&(this._instance=new P_),this._instance}}P_._instance=null;var x_=i(19136);class M_ extends Ad.CustomSourceBase{constructor(e,t){super(e,t),this._studySource=null,this._metaInfo=null,this._destroyed=!1,this._isStarted=!1,this._session="session",this._requestAndProcessMetaInfo(),t.timeScale().onReset().subscribe(this,this._clearData)}start(){this._isStarted=!0,null!==this._studySource&&this._studySource.start()}restart(){this._clearData(),l.enabled("stop_study_on_restart")&&this.stop(),this.start()}isStarted(){return this._isStarted}stop(){this._isStarted=!1,null!==this._studySource&&this._studySource.stop()}isHoveredEnabled(){return!1}updateAllViews(e){}destroy(){this._destroyed=!0,null!==this._studySource&&(this._studySource.dataCleared().unsubscribeAll(this),this._studySource.dataUpdated().unsubscribeAll(this),this._studySource.destroy(),this._studySource=null),this._model.timeScale().onReset().unsubscribeAll(this)}series(){return this._model.mainSeries()}priceScale(){return this.series().priceScale()}valueAt(){return null}metaInfo(){return(0,n.ensureNotNull)(this._metaInfo)}setSession(e){this._session=e||"session",null!==this._studySource&&this._studySource.setInputs({display_session:e})}async _requestAndProcessMetaInfo(){if(this._model.isSnapshot())return;const e=await(0,os.studyMetaInfoRepository)().findById({type:"java",studyId:"InactivityGaps@tv-basicstudies"});this._destroyed||(this._setMetaInfo(e),null!==this._metaInfo&&(this._studySource=new x_.StudyDataSource(this._model.chartApi(),this._model.mainSeries().seriesSource(),"inactivitygaps_",this._metaInfo),this._studySource.dataCleared().subscribe(this,this.updateAllViews.bind(this,(0,wi.sourceChangeEvent)(this.id()))),this._studySource.dataUpdated().subscribe(this,this.updateAllViews.bind(this,(0,wi.sourceChangeEvent)(this.id()))),this._studySource.setInputs({display_session:this._session})))}_setMetaInfo(e){this._metaInfo=e}_clearData(){this._studySource?.clearData()}}const I_=new dt.TranslatedString("remove deselected empty line tools",a.t(null,void 0,i(27171))),A_=l.enabled("auto_enable_symbol_labels"),L_=l.enabled("saveload_separate_drawings_storage"),k_=(0,ne.getLogger)("Chart.ChartModel");function E_(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}function D_(e){const t=(0,wi.crosshairMoveEvent)();for(let i=e.length;i--;){const s=e[i].dataSources();for(let e=s.length;e--;)s[e].dataWindowView()?.update(t),s[e].chartFloatingTooltipView?.()?.update(t);const o=e[i].priceDataSources();for(let e=o.length;e--;)o[e].legendView()?.update(t)}}const B_={isSnapshot:!1,readOnly:!1,watermarkEnabled:!0,shiftVisibleRangeOnNewBar:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,countdownEnabled:!0,lastPriceAnimationEnabled:!0,onWidget:!1,hideIdeas:!1};var V_;!function(e){e[e.MnPaneHeight=30]="MnPaneHeight",e[e.RecalcVisibleRangeStudiesTimeout=2e3]="RecalcVisibleRangeStudiesTimeout",
e[e.RecalcVisibleRangeStudiesLargeTimeout=5e3]="RecalcVisibleRangeStudiesLargeTimeout",e[e.RecalcVisibleRangeStudiesTimeoutLibrary=500]="RecalcVisibleRangeStudiesTimeoutLibrary",e[e.RecalcColorStudiesTimeout=250]="RecalcColorStudiesTimeout"}(V_||(V_={}));const R_={throttle:o.default,debounce:Ol.default},N_=new Map([[Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction,{timeout:500,adapter:"debounce"}],[Co.RecalcVisibleRangeStudiesReason.DataUpdate,{timeout:500,adapter:"throttle"}],[Co.RecalcVisibleRangeStudiesReason.SeriesRestart,{timeout:500,adapter:"debounce"}],[Co.RecalcVisibleRangeStudiesReason.SeriesCompleted,{timeout:500,adapter:"debounce"}],[Co.RecalcVisibleRangeStudiesReason.StudyCreation,{timeout:500,adapter:"debounce"}]]),O_=Array.from(N_.values());function F_(e){return e.reduce(((e,t)=>{if(!(0,zs.isLineTool)(t)||!t.isSynchronizable())return e;const i=t.linkKey().value();return i?(e[0].add(i),e[1].add(t.toolname),e):e}),[new Set,new Set])}function W_(e){return e.sourcesByGroup().allWithoutMultipane()}function H_(e){return e.sourcesByGroup().allWithoutMultipaneWithHidden()}class z_{constructor(e,t,i,s,o,n,r,a,c,d,u,_){this._onRearrangePanes=new ae.Delegate,this._lineToolsGroupModel=new wd,this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,this._lineBeingEdited=null,this._customSourceBeingMovedHitTestData=null,this._customSourceBeingMoved=null,this._dataSourceCollectionChanged=new ae.Delegate,this._sourceProperitesChanged=new ae.Delegate,this._sourceZOrderChanged=new ae.Delegate,this._symbolSourceResolved=new ae.Delegate,this._symbolSourceResolvingActive=new O.WatchedValue(!1),this._adjustForDividendsAvailability=new O.WatchedValue(0),this._adjustForDividendsEnabled=new O.WatchedValue(!1),this._inactivityGapsWatchedValue=null,this._allowedAdjustment=new O.WatchedValue("none"),this._currentTool=mt.tool.spawn(),this._linesBeingCreated=[],this._lineCancelled=new ae.Delegate,this._phantomSourceContainer=new zd(this),this._destroyed=!1,this._restoringState=!1,this._isSettingsExternalPosition=!1,this._isTimeScrolling=!1,this._magnet=new Zd,this._scrollingState=null,this._modelIntervals=[],this._rendererOptionsProvider=new Xl(this),this._studyInserted=new ae.Delegate,this._cachedStudiesMaxOffset=0,this._replayStatus=new O.WatchedValue(0),this._panes=[],this._maximizedPane=new O.WatchedValue(null),this._tagsChanged=new ae.Delegate,this._strategySources=[],this._strategySourcesChange=new ae.Delegate,this._activeStrategySource=new O.WatchedValue(null),this._symbolIntervalChanged=new ae.Delegate,this._paneCollapsingAvailable=new O.WatchedValue(!1),this._panesCollectionChanged=new ae.Delegate,this._scrollEnabled=l.enabled("chart_scroll"),this._zoomEnabled=l.enabled("chart_zoom"),this._lollipopSourcesWatcher=null,this._alertsWatcher=null,this._hoveredSource=null,this._hoveredSourceChanged=new ae.Delegate,this._lastHoveredHittestData=null,this._hoveredSourceOrigin=null,this._lastSelectedHittestData=null,this._topmostCustomSources=[],this._fgCustomSources=[],this._bgCustomSources=[],this._allCustomSources=[],
this._customSourcesMap=new Map,this._dragExportEnabled=new O.WatchedValue(!1),this._multiPaneSources=[],this._showLegendProperty=new Ps.Property,this._id=(0,fe.guid)(),this._chartSaveTime=null,this._availableCurrenciesList=null,this._availableCurrencies=new Fd([]),this._availablePriceSources=new C_([]),this._availableUnitsObject=null,this._availableUnits=new Wd({}),this._availablePriceSourcesBySymbol=new Map,this._shouldBeSavedEvenIfHidden=!1,this._watchedThemeSpawn=k.watchedTheme.spawn(),this._backgroundColorAtYPercentFromTop=new Nd.GradientColorCache,this._studiesWV=new yt.WatchedObject([],Pt.compareTwoCollectionsByIds),this._studiesExcludeInternalWV=new yt.WatchedObject([],Pt.compareTwoCollectionsByIds),this._resetScalesAvailable=new O.WatchedValue(!1),this._recalcVRStudiesParams={reasons:new Set},this._recalcColorStudiesParams={},this._replayStudyStrategy=new O.WatchedValue(null),this._studyColorRotatorFactory=new Gl(this),this._mainSeriesScaleRatioProperty=new Wc(this),this._recalcVisibleRangeStudiesImplDebouncedByAdapter=new Map(Object.keys(R_).map((e=>[e,new Map(O_.filter((t=>t.adapter===e)).map((e=>[e.timeout,R_[e.adapter](this._recalcVisibleRangeStudiesImpl.bind(this,this._recalcVRStudiesParams),e.timeout)])))]))),this._recalcColorStudiesImplDebounced=(0,Ol.default)(this._recalcColorStudiesImpl.bind(this,this._recalcColorStudiesParams),250),this._width=0,this._resetScales=new ae.Delegate,this._chartThemeLoaded=new ae.Delegate,this._selection=new $l,this._selectedSourceChanged=new ae.Delegate,this._symbolSourceCollectionChanged=new ae.Delegate,this._gridSource=new iu(this),this._visibleRangeStudiesInputs=new yt.WatchedObject(null),this._syncPointCache=new Map,this._lastAppliedGotoTimeRange=null,this._lastGotoTimeRange=null,this._alertsCollection=new O.WatchedValue(null),this._lollipopSourcesWatcherLoader=null,this._sessions=null,this._onMultipaneSourcesCollectionChanged=new ae.Delegate,this._replayStudyStrategyInputs=null,this._studyShiftColorStartOffset=void 0,this._chartFloatingTooltipVisible=new O.WatchedValue(!1),this._activationChartFloatingTooltipHint=new O.WatchedValue(!1),this._lineToolsSyncBlock=0,this._clearSelection=()=>{this._lastSelectedHittestData=null,this._selection.clear()},this._removeSourceFromSelection=e=>{this._selection.remove(e)},this._addSourceToSelection=(e,t)=>{const i=this._selection.isSelected(e);i&&this._lastSelectedHittestData===t||e&&!e.isSelectionEnabled()||(this._lastSelectedHittestData=t||null,i||this._selection.add(e))},this._recalcSymbolResolvingActive=()=>{for(const e of this._panes)if(e.symbolSourceResolvingActive().value())return void this._symbolSourceResolvingActive.setValue(!0);this._symbolSourceResolvingActive.setValue(!1)},this._recalcAdjustForDividendsAvailability=()=>{if(this._symbolSourceResolvingActive.value())return;const e=this.mainSeries();switch(e.symbolInfo()?.allowed_adjustment??"none"){case"dividends":return void this._adjustForDividendsAvailability.setValue(2);case"splits":return void this._adjustForDividendsAvailability.setValue(1);case"any":
return void this._adjustForDividendsAvailability.setValue(3)}for(const t of this.symbolSources().filter(Lr.isActingAsSymbolSource)){if(t.symbolHibernated().value()||t===e)continue;if("any"===(t.symbolInfo()?.allowed_adjustment??"none"))return void this._adjustForDividendsAvailability.setValue(3)}this._adjustForDividendsAvailability.setValue(0)},this._recalcAllowedAdjustment=()=>{const e=this.mainSeries(),t=e.symbolInfo()?.allowed_adjustment??"none";if("dividends"===t||"splits"===t)return void this._allowedAdjustment.setValue(t);let i="none";for(const e of this.symbolSources().filter(Lr.isActingAsSymbolSource)){if(e.symbolHibernated().value())continue;const t=e.symbolInfo()?.allowed_adjustment??"none";if("any"===t)return void this._allowedAdjustment.setValue("any");"splits"===t&&"dividends"!==i&&(i="splits"),"dividends"===t&&(i="dividends")}this._allowedAdjustment.setValue(i)},this._recalcAdjustForDividendsEnabled=()=>{switch(this._adjustForDividendsAvailability.value()){case 2:return void this._adjustForDividendsEnabled.setValue(!0);case 0:case 1:return void this._adjustForDividendsEnabled.setValue(!1)}this._adjustForDividendsEnabled.setValue(this.mainSeries().properties().childs().dividendsAdjustment.value())},this._recalcPaneCollapsingAvailable=e=>{let t=this._panes.filter((e=>!e.collapsed().value())).length;0===t&&e&&this._panes.length>0&&(this._panes[0].collapsed().setValue(!1),t=1),this._paneCollapsingAvailable.setValue(t>1)},this._updateResetScalesAvailableValue=()=>{const e=this._timeScale.resetAvailable().value()||this._panes.some((e=>e.resetPriceScalesAvailable().value()));this._resetScalesAvailable.setValue(e)},this._onDrawingsVisibilityChanged=e=>{const t=!e.value();for(const e of this.dataSources()){const i=(0,zs.isLineTool)(e)&&e.properties().visible.value();t&&i?(0,ee.emit)("drawing_event",e.id(),"show"):!t&&i&&(0,ee.emit)("drawing_event",e.id(),"hide")}this.selectionMacro((e=>e.clearSelection()))},this._onIndicatorsVisibilityChanged=()=>{this.allStudies().some((e=>e.canBeHiddenByGlobalFlag()&&e.properties().childs().visible.value()&&this.selection().isSelected(e)))?this.selectionMacro((e=>e.clearSelection())):this.lightUpdate()},this._chartSession=e,this._invalidateHandler=t,this._undoModel=n,this._properties=i,this._options=(0,tt.merge)((0,tt.clone)(B_),a),this._hibernateWV=c,this._linkingGroupIndex=d,this._isAutoSaveEnabled=u,this._readOnly=this._options.readOnly,this._isSnapshot=this._options.isSnapshot,this._symbolAliasService=_,this._symbolAliasService?.onAliasChanged().subscribe(this,(()=>this.lightUpdate())),this.onWidget()||Md.withWeekdayProperty.subscribe(this,(()=>this._updateDateTimeFormatter())),this._chartSaveTime=(new Date).valueOf(),this._backgroundColor=new O.WatchedValue(this._getBackgroundColor()),this._backgroundTopColor=new O.WatchedValue(this._getBackgroundColor(!0)),this._properties.childs().paneProperties.childs().background.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundType.subscribe(this,this._updateBackgroundColor),
this._properties.childs().paneProperties.childs().backgroundGradientStartColor.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().backgroundGradientEndColor.subscribe(this,this._updateBackgroundColor),this._properties.childs().paneProperties.childs().legendProperties.childs().showLegend.subscribe(this,this._updateShowLegendProperty),this._properties.childs().scalesProperties.subscribe(this,this.fullUpdate),this._backgroundColor.subscribe(this.recalcColorStudies.bind(this,!1)),this._backgroundTopColor.subscribe(this.recalcColorStudies.bind(this,!1)),this._backgroundCounterColor=new O.WatchedValue(this._getBackgroundCounterColor()),this._backgroundColor.subscribe((()=>this._backgroundCounterColor.setValue(this._getBackgroundCounterColor()))),this._backgroundTheme=(0,ft.combine)((e=>"white"===e?$s.StdTheme.Dark:$s.StdTheme.Light),this._backgroundCounterColor.weakReference()),this._isDark=(0,ft.combine)((e=>e===$s.StdTheme.Dark),this._backgroundTheme.weakReference()),this._watchedThemeSpawn.subscribe(this._updateBackgroundColor.bind(this)),this._symbolSourceResolvingActive.subscribe((()=>{this._recalcAdjustForDividendsAvailability(),this._recalcAllowedAdjustment()})),(0,mt.init)();const p=this._readOnly?new Ps.Property((0,tt.merge)((0,tt.clone)(ms.lightTheme.content.chartProperties.paneProperties.crossHairProperties),(0,h.defaults)("chartproperties.paneProperties.crossHairProperties"))):this._properties.childs().paneProperties.childs().crossHairProperties;this._crossHairSource=new i_(this,p,this._options.crossHair),this._crossHairSelectPointMode=this._crossHairSource.selectPointMode().spawn(),this._crossHairSelectPointMode.subscribe((e=>{if(e!==mt.SelectPointMode.None&&this.lineBeingCreated()){const e=mt.tool.value();this.cancelCreatingLine(),mt.tool.setValue(e)}})),this._tagsChanged=new ae.Delegate;const m={countdownEnabled:this._options.countdownEnabled,lastPriceAnimationEnabled:this._options.lastPriceAnimationEnabled};this._mainSeries=new Vn.Series(this,s,m,o),this._timeScale=new vd(this,this._options.timeScale),this._timeScale.resetAvailable().subscribe(this._updateResetScalesAvailableValue),this._appliedTimeFrame=new Xd(this),this._mainSeries.onStyleChanged().subscribe(this._timeScale,this._timeScale.invalidateVisibleBars);const g=()=>this.fullUpdate();this._mainSeries.properties().childs().showCountdown.subscribe(this,(()=>{this._mainSeries.updateAllViews((0,wi.sourceChangeEvent)(this._mainSeries.id())),g()})),(0,Be.currencyUnitVisibilityProperty)().subscribe(this,g),(0,$o.autoLogButtonsVisibilityProperty)().subscribe(this,g),this._timeScale.visibleBarsStrictRangeChanged().subscribe(this._mainSeries,this._mainSeries.clearHighLowPriceCache),this._timeScale.visibleBarsStrictRangeChanged().subscribe(this._mainSeries,this._mainSeries.clearAveragePriceCache),this.createPane(void 0,{axisProperties:s.childs().priceAxisProperties.state(["autoScale"])}),this._adjustForDividendsAvailability.subscribe(this._recalcAdjustForDividendsEnabled),
this.mainSeries().properties().childs().dividendsAdjustment.subscribe(this,this._recalcAdjustForDividendsEnabled),this._recalcAdjustForDividendsEnabled(),this._boundUpdateStudiesMaxOffset=this._updateStudiesMaxOffset.bind(this),this.mainSeries().dataEvents().seriesTimeFrame().subscribe(this,((e,t,i,s)=>{if(null!==this._lastAppliedGotoTimeRange&&null!==i&&s&&Tr(this._lastAppliedGotoTimeRange.range,i)){const e=this.appliedTimeFrame().value();null!==e&&!this._lastAppliedGotoTimeRange.actual&&Tr(this._lastAppliedGotoTimeRange.range,e.val)&&this.appliedTimeFrame().setValue(null),this._lastAppliedGotoTimeRange=null}})),this.mainSeries().dataEvents().completed().subscribe(this,(e=>{null===this._lastAppliedGotoTimeRange&&null!==this._lastGotoTimeRange&&this.gotoTimeRange(this._lastGotoTimeRange.from,this._lastGotoTimeRange.to,this._lastGotoTimeRange)}));const f=this._panes[0];f.setStretchFactor(2*f.stretchFactor()),this._properties.subscribe(this,this.lightUpdate),this._properties.childs().timezone.subscribe(null,(()=>{this._chartSession&&this._chartSession.isConnected().value()&&this._chartSession.switchTimezone(this.timezone())})),f.addDataSource(this._mainSeries,f.findSuitableScale(this._mainSeries),!1),this._barsMarksSources=r(this);for(const e of this._barsMarksSources)e.setOwnerSource(this._mainSeries),f.addDataSource(e,this._mainSeries.priceScale(),!0);if(this._mainSeries.symbolResolved().subscribe(this,this._clearAvailablePriceSources),this._mainSeries.onSymbolIntervalChanged().subscribe(this,this._onSymbolIntervalChanged),this._createLollipopSourcesWatcher(),this._watermarkSource=this._options.watermarkEnabled?new Rc(this):null,this._timezoneExceptExchange=(0,ft.combine)(((e,t)=>"exchange"!==e?e:t),(0,_d.createWVFromProperty)(this._properties.childs().timezone).ownership(),(0,_d.createWVFromGetterAndSubscription)((()=>this.mainSeries().symbolInfo()?.timezone??null),this.mainSeries().symbolResolved()).ownership()),this._updateDateTimeFormatter(),this._mainSeries.dataEvents().completed().subscribe(this,(()=>{this._scrollingState&&this.gotoTime(void 0,{targetPointAlignment:this._scrollingState.targetPointAlignment,autoscaleAfterScroll:this._scrollingState.autoscaleAfterScroll})})),this._mainSeries.onIntervalChanged().subscribe(this,(()=>{this._recalcVRStudiesParams.oldStartVisibleIndex=NaN,this._recalcVRStudiesParams.oldEndVisibleIndex=NaN})),!this._readOnly){this._mainSeries.properties().addChild("priceAxisProperties",this._mainSeries.priceScale().properties());const e=this._properties.childs().paneProperties.childs().legendProperties.childs();e.showStudyTitles.subscribe(this,(t=>{t.value()||e.showStudyArguments.setValue(!1)}))}this._mainSeries.properties().childs().interval.subscribe(this,this._updateDateTimeFormatter),this._mainSeries.onTimeFrameApplied().subscribe(this,(e=>{const t=e?{res:this._mainSeries.interval(),val:e}:null;this.appliedTimeFrame().setValue(t)})),this._maximizedPane.subscribe((()=>n.model().fullUpdate())),this._dataSourceCollectionChanged.subscribe(this,this._updateShowLegendProperty),(0,
mt.hideAllDrawings)().subscribe(this,this._onDrawingsVisibilityChanged),(0,mt.hideAllIndicators)().subscribe(this,this._onIndicatorsVisibilityChanged),be.dateFormatProperty.subscribe(this,this._updateDateTimeFormatter),we.timeHoursFormatProperty.subscribe(this,this._updateDateTimeFormatter),this._currentTool.subscribe((e=>{(0,Lt.isLineToolName)(e)&&this.selectionMacro((e=>{e.clearSelection()})),!(0,xo.isLineToolLoaded)(e)&&(0,xo.isAsyncGenericLineToolName)(e)?(0,xo.loadLineTool)(e).then((()=>this._phantomSourceContainer.onToolChanged())):this._phantomSourceContainer.onToolChanged()})),this._initialiseInactivityGaps(),this._signatureSources=this._studiesExcludeInternalWV.spawn();const y=(0,ft.combine)((e=>e.map((e=>e.signature().weakReference()))),this._signatureSources.weakReference());this._sourcesSignatures=(0,ft.accumulate)((e=>e.filter(tt.notNull)),y.ownership())}destroy(){this.clearIntervals(),this.resetDeferredStudies(),this._symbolAliasService?.onAliasChanged().unsubscribeAll(this),this.allStudies().forEach((e=>this.removeSource(e))),be.dateFormatProperty.unsubscribe(this,this._updateDateTimeFormatter),we.timeHoursFormatProperty.unsubscribe(this,this._updateDateTimeFormatter),(0,mt.hideAllIndicators)().unsubscribe(this,this._onIndicatorsVisibilityChanged),(0,mt.hideAllDrawings)().unsubscribe(this,this._onDrawingsVisibilityChanged),this._dataSourceCollectionChanged.unsubscribeAll(this),this._phantomSourceContainer.destroy(),this._hoveredSourceChanged.destroy(),null!==this._watermarkSource&&(this._watermarkSource.destroy(),this._watermarkSource=null),Array.from(this._customSourcesMap.keys()).forEach(this._removeCustomSource,this),(0,n.assert)(0===this._topmostCustomSources.length),(0,n.assert)(0===this._fgCustomSources.length),(0,n.assert)(0===this._bgCustomSources.length),(0,n.assert)(0===this._allCustomSources.length),(0,n.assert)(0===this._customSourcesMap.size),this._panes.forEach((e=>e.destroy())),this._panes.length=0,this._sessions=null,null!==this._lollipopSourcesWatcher&&(this._lollipopSourcesWatcher.destroy(),this._lollipopSourcesWatcher=null),null!==this._alertsWatcher&&this._alertsWatcher.destroy(),this.onWidget()||Md.withWeekdayProperty.unsubscribeAll(this),this._properties.childs().paneProperties.childs().legendProperties.childs().showLegend.unsubscribeAll(this),this._properties.childs().paneProperties.childs().background.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundType.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundGradientEndColor.unsubscribeAll(this),this._properties.childs().paneProperties.childs().backgroundGradientStartColor.unsubscribeAll(this),this._watchedThemeSpawn.destroy(),this._lastHoveredHittestData=null,this._lastSelectedHittestData=null,(0,Be.currencyUnitVisibilityProperty)().unsubscribeAll(this),(0,$o.autoLogButtonsVisibilityProperty)().unsubscribeAll(this),this._mainSeries.properties().childs().interval.unsubscribe(this,this._updateDateTimeFormatter),
this._mainSeries.properties().childs().showCountdown.unsubscribeAll(this),this._crossHairSelectPointMode.destroy(),this._mainSeries.onIntervalChanged().unsubscribeAll(this),this._mainSeries.onTimeFrameApplied().unsubscribeAll(this),this._mainSeries.symbolResolved().unsubscribe(this,this._clearAvailablePriceSources),this._mainSeries.onSymbolIntervalChanged().unsubscribe(this,this._onSymbolIntervalChanged),this._mainSeries.onStyleChanged().unsubscribe(this._timeScale,this._timeScale.invalidateVisibleBars),this._timeScale.visibleBarsStrictRangeChanged().unsubscribe(this._mainSeries,this._mainSeries.clearHighLowPriceCache),this._timeScale.visibleBarsStrictRangeChanged().unsubscribe(this._mainSeries,this._mainSeries.clearAveragePriceCache),this._timeScale.barSpacingChanged().unsubscribeAll(this),this._timeScale.onScroll().unsubscribeAll(this),this._timeScale.destroy(),this._timezoneExceptExchange.destroy(),this._lollipopSourcesWatcherLoader?.destroy(),this._appliedTimeFrame.destroy(),this._crossHairSource.destroy(),this._currentTool.destroy(),this._signatureSources.destroy(),this._sourcesSignatures.destroy(),this._destroyed=!0}restart(){this._chartSession.switchTimezone(this.timezone()),this._timeScale.reset(),this._mainSeries.restart();for(const e of this.dataSources())e.restart&&e!==this._mainSeries&&e.restart();this._sessions?.get()?.restart()}version(){return 3}collapsed(){return this._hibernateWV}visibleRangeStudiesInputs(){return this._visibleRangeStudiesInputs.readonly()}chartSaveTime(){return this._chartSaveTime}setChartSaveTime(e){this._chartSaveTime=e}startNotStartedStudies(){if(!this._mainSeries.isStarted())throw new Error("Cannot start studies: main series is not started");for(const e of this.dataSources())(0,Ws.isStudy)(e)&&!e.isStarted()&&e.restart?.()}undoModel(){return this._undoModel}onData(e){switch(e.method){case"timescale_update":{const t=e.params;this._updateTimeScale({index:t.index,zoffset:t.zoffset,values:t.changes,indexDiffs:t.index_diff,baseIndex:t.baseIndex,marks:t.marks,clearFlag:t.clear,clearTickMarks:t.clearTickMarks});break}case"timescale_completed":{const t=Boolean(e.params[0]);this._timeScale.onTimeScaleCompleted(t);break}}}addStrategySource(e,t){1!==t&&-1===this._strategySources.indexOf(e)&&(this._strategySources.push(e),this._strategySourcesChange.fire(t),this.setActiveStrategySource(e))}removeStrategySource(e,t){if(1===t)return;const i=this._strategySources.indexOf(e);if(-1!==i){if(this._strategySources.splice(i,1)[0]===this._activeStrategySource.value()&&this.unsetActiveStrategySource(),this._strategySources.length>0){const e=this._strategySources[this._strategySources.length-1];this.setActiveStrategySource(e)}this._strategySourcesChange.fire(t)}}setActiveStrategySource(e){-1!==this._strategySources.indexOf(e)&&this._activeStrategySource.setValue(e)}unsetActiveStrategySource(){this._activeStrategySource.setValue(null)}activeStrategySource(){return this._activeStrategySource.readonly()}strategySources(){return this._strategySources}strategySourcesChange(){
return this._strategySourcesChange}replayStudyStrategy(){return this._replayStudyStrategy}setReplayStudyStrategy(e){this._replayStudyStrategy.setValue(e)}async replayStudyStrategyProperties(){if(null===this._replayStudyStrategyInputs){const e=await getReplayStrategyMetaInfo();if(null!==this._replayStudyStrategyInputs)return this._replayStudyStrategyInputs;this._replayStudyStrategyInputs=new yi.DefaultProperty({defaultName:"replayStudyStrategyInputs",factoryDefaultsSupplier:()=>(0,tt.clone)(e.defaults.inputs)})}return this._replayStudyStrategyInputs}clearReplayStudyStrategyProperties(){this._replayStudyStrategyInputs=null}setScrollEnabled(e){this._scrollEnabled=e}scrollEnabled(){return this._scrollEnabled}setZoomEnabled(e){this._zoomEnabled=e}zoomEnabled(){return this._zoomEnabled}dragExportEnabled(){return this._dragExportEnabled}async setDragExportEnabled(e){l.enabled("charting_library_export_chart_data")?(await async function(){if(null===Rn){const e=await Promise.all([i.e(2578),i.e(9498)]).then(i.bind(i,99207));Rn=e}}(),this._dragExportEnabled.setValue(e)):console.error("feature is not enabled")}zoomToViewport(e,t,i,s,o){this.setTimeViewport(e,t);let n=Math.min(i,s),r=Math.max(i,s);const a=o.defaultPriceScale();a.isPercentage()||a.setMode({autoScale:!1}),a.isLog()&&(n=a.priceToLogical(n),r=a.priceToLogical(r)),a.setPriceRange(new Qc.PriceRange(n,r)),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),this.invalidate(this._paneInvalidationMask(o,ao.InvalidationLevel.Light))}setTimeViewport(e,t){const i=this.appliedTimeFrame().value();null!==this._lastAppliedGotoTimeRange&&null!==i&&Tr(this._lastAppliedGotoTimeRange.range,i.val)&&!this._lastAppliedGotoTimeRange.actual||(this.timeScale().zoomToBarsRange(e,t),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction),this.lightUpdate())}onTagsChanged(){return this._tagsChanged}canZoomIn(){return this._timeScale.canZoomIn()&&this._zoomEnabled}canZoomOut(){return this._timeScale.canZoomOut()&&this._zoomEnabled}onPaneTagsChanged(){this._tagsChanged.fire()}panesCollectionChanged(){return this._panesCollectionChanged}dataSourceCollectionChanged(){return this._dataSourceCollectionChanged}symbolSourceCollectionChanged(){return this._symbolSourceCollectionChanged}symbolSourceResolved(){return this._symbolSourceResolved}symbolSourceResolvingActive(){return this._symbolSourceResolvingActive}adjustForDividendsAvailability(){return this._adjustForDividendsAvailability}adjustForDividendsEnabled(){return this._adjustForDividendsEnabled}allowedAdjustment(){return this._allowedAdjustment}paneCollapsingAvailable(){return this._paneCollapsingAvailable}sourcePropertiesChanged(){return this._sourceProperitesChanged}sourceZOrderChanged(){return this._sourceZOrderChanged}zoomTime(e,t,i){if(!this._zoomEnabled)return;const s=this.timeScale();if(s.isEmpty()||0===t)return;const o=s.width();e=Math.max(1,Math.min(e,o-2)),s.zoom(e,t,i),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),
this.lightUpdate(),this.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction)}lineBeingEdited(){return this._lineBeingEdited?.lineDataSource??null}linePointBeingEdited(){return this._lineBeingEdited?.pointIndex??null}linePointBeingChanged(){return this._lineBeingEdited?.startChangingPoint??null}activeItemBeingMoved(){return this._activeItemBeingMoved}mainSeries(){return this._mainSeries}updateAllPaneViews(e){for(const t of this._panes)t.updateAllViews(e);this._watermarkSource?.updateAllViews(e)}dataSources(){const e=[this.crosshairSource()];for(const t of this._panes)for(const i of t.dataSources())e.push(i);return e}priceDataSources(){const e=[];for(const t of this._panes)for(const i of t.priceDataSources())e.push(i);return e}symbolSources(){const e=[];for(const t of this._panes)for(const i of t.symbolSources())e.push(i);return e}orderedDataSources(e){let t=[this._crossHairSource];for(let i=0;i<this._panes.length;i++){let s=this._panes[i].sourcesByGroup().all();e&&(s=s.slice().reverse()),t=t.concat(s)}return t}lineToolByLinkKey(e){for(const t of this._panes){const i=t.lineToolByLinkKey(e);if(i)return i}return null}timeScale(){return this._timeScale}selection(){return this._selection}selectionMacro(e,t=!1){const i=this.selection().allSources();e({removeSourceFromSelection:this._removeSourceFromSelection,addSourceToSelection:this._addSourceToSelection,clearSelection:this._clearSelection,selection:this.selection.bind(this)});const s=(0,Pt.subtract)(i,this.selection().allSources()),o=(0,Pt.subtract)(this.selection().allSources(),i);o.concat(i).forEach((e=>e.updateAllViews((0,wi.selectionChangeEvent)())));let n=[];if(s.forEach((e=>{(0,zs.isLineTool)(e)&&!t&&((0,zs.isEditableTextLineTool)(e)&&e.deactivateTextEditing(),e.shouldBeRemovedOnDeselect()&&n.push(e))})),1===o.length){const[e]=o;(0,zs.isLineTool)(e)&&e.hasAlert().value()&&0===e.alertStatus().value()&&e.synchronizeAlert().catch((()=>{}))}n=n.filter((e=>null!==this.dataSourceForId(e.id()))),n.length>0&&this._undoModel.removeSources(n,!1,I_),this.lightUpdate(),(s.length>0||o.length>0)&&this._selectedSourceChanged.fire()}onSelectedSourceChanged(){return this._selectedSourceChanged}checkLineToolSelection(){const e=this.selection().allSources();this._selection.checkLineToolSelection(),e.length!==this.selection().allSources().length&&this._selectedSourceChanged.fire()}lineToolsGroupModel(){return this._lineToolsGroupModel}restoreLineToolsGroups(e){this._lineToolsGroupModel=wd.fromState(this,e)}realignLineTools(e){for(const t of this._panes)(void 0===e||t.hasDataSource(e))&&t.realignLineTools(e)&&this._dataSourceCollectionChanged.fire(t)}copyToOtherCharts(e,t){const i=this.mainSeries(),s=i.syncModel(),o=this.timeScale();if(s)for(const r of e){if(!r.isSynchronizable())continue;const e=r.linkKey().value()||(0,fe.randomHash)();r.linkKey().setValue(e);const a=r.state(!1),l=r.normalizedPoints(),c=r.normalizedPointsForCreating(),h=r.properties().interval.value(),d=i.interval(),u=e=>{if(Re.Interval.isEqual(h,d))return e.map((e=>{const t=(0,
n.ensureNotNull)(o.timePointToIndex(e.time_t))+e.offset;return{price:e.price,timeStamp:(0,n.ensureNotNull)(this.externalTimeStamp(t))}}));{const t=s.createNewModelWithResolution(h);return e.map((e=>({price:e.price,timeStamp:0===e.offset?e.time_t:t.projectTime(e.time_t,e.offset)})))}},_=u(l),p=u(c),m={...a,id:r.id(),linkKey:e,points:_,pointsForCreating:p,linetool:r.toolname,model:this,symbol:i.symbol(),withUndo:t,zOrder:r.zorder(),finalState:{points:l,interval:h},pointPositionPercents:r.isFixed()?r.calcPositionPercents():void 0,sharingMode:r.sharingMode().value()};(0,mt.copyLineTool)(m)}}isSnapshot(){return this._isSnapshot}onWidget(){return this._options.onWidget}hideIdeas(){return this._options.hideIdeas}updateSource(e){const t=this._invalidationMaskForSource(e);null!==t&&this.invalidate(t)}updateSourcePriceScale(e){const t=this._invalidationMaskForSourcePriceScale(e);null!==t&&this.invalidate(t)}updatePane(e){this.invalidate(this._paneInvalidationMask(e))}updateTimeScaleBaseIndex(e){const t=this.mainSeries().bars(),i=(t.firstIndex()??1/0)<(e?.index??-1/0),s=this._timeScale.baseIndex();if(t.isEmpty()||this._updateBaseIndex((0,n.ensureNotNull)(t.lastIndex()),!!(e&&e.index>0)),i&&!this._timeScale.isBeingScrolled()&&!this._timeScale.isBeingScaled()){const e=this._timeScale.baseIndex()-s,t=this._timeScale.rightOffset();t-this.studyAwareDefaultRightOffset()>e&&this._timeScale.setRightOffset(t-e)}}setInterval(e,t){const i=setInterval(e,t);return this._modelIntervals.push(i),i}clearInterval(e){clearInterval(e);const t=this._modelIntervals.indexOf(e);t>-1&&this._modelIntervals.splice(t,1)}clearIntervals(){for(let e=0;e<this._modelIntervals.length;e++)clearInterval(this._modelIntervals[e]);this._modelIntervals=[]}createStudyInserter(e){return new w_(e,{createStudy:(e,t,i,s,o,n,r,a,l,c,h,d,u)=>this.insertStudyWithParams(e,t,i,o,n,r,a,l,c,h,d,u),storeFailedStub:e=>{}})}insertStudyWithParams(e,t,i,s,o,r,a,l,c,h,u,_){let p=null;if(!o&&void 0!==e.groupingKey){const t=this.findNonOverlayStudyWithGroupingKey(e.groupingKey);null!==t&&(p=t.pane)}null===p&&(o||e.is_price_study?p=(0,n.ensureNotNull)(this.paneForSource(r?.[0]??this._mainSeries)):(p=this.createPane(),void 0!==h&&p.setPaneSize(h))),"Compare@tv-basicstudies"===e.id&&this._mainSeries.priceScale().setMode({log:!1,percentage:!0});const m=(0,tt.merge)((0,Al.default)(s??{}),{inputs:t,parentSources:[]});let g=!1,f=null,y=null;const v=r??[],S=(0,Zl.prepareStudyProperties)(e,m,p,(0,os.studyMetaInfoRepository)().studyVersioning(),v),b=(0,Ws.createStudy)(this,S,v,new ns.StudyMetaInfo(e.state(),e.useVersionFromMetaInfo),new ns.StudyMetaInfo(e.state(),e.useVersionFromMetaInfo),_,void 0),w=(0,me.createDeferredPromise)();return b.then((e=>{if(g)return e.stop(),void e.destroy?.();f=e.id();const t=p.findSuitableScale(e,r?.[0]??this.mainSeries(),a);if(y=t.mode(),t===this.mainSeries().priceScale()&&(0,Lr.isSymbolSource)(e)){const i=l?kr(e,t,this,!0):null,s=c?ih(e,t,this,!0):null;null===i&&null===s||e.setSymbolParams({currency:i||void 0,unit:s||void 0})}if((0,Lr.isSymbolSource)(e)&&(0,
n.ensureNotNull)(p).hasDataSource(this.mainSeries())&&A_&&!d.getBool("enable_symbol_labels_on_inserting_compare_once",!1)&&((0,yi.allowSavingDefaults)(!0),this.properties().childs().scalesProperties.childs().showSymbolLabels.setValue(!0),(0,yi.allowSavingDefaults)(!1),d.setValue("enable_symbol_labels_on_inserting_compare_once",!0)),w.resolve(e.start()),i&&p.id()===i.paneId)p.insertDataSource(e,t,i.zorder);else{p.addDataSource(e,t,!1);null!==e.preferredZOrder()&&p.insertAfter([e],this.mainSeries())}void 0!==u&&t.setMode(u),e.isLinkedToSeries()&&e.setOwnerSource(this.mainSeries()),this.recalculatePane(p,(0,wi.sourceChangeEvent)(e.id())),this.fullUpdate(),this._invalidateBarColorerCaches(),this._recalcVisibleRangeStudiesImpl({studies:[e],reasons:new Set([Co.RecalcVisibleRangeStudiesReason.StudyCreation])}),this._recalcColorStudiesImpl({studies:[e],force:!0}),this._studyInserted.fire(e),e.maxOffset().subscribe(this._boundUpdateStudiesMaxOffset,{callWithLast:!0})})),{study:b,startPromise:w.promise,cancel:()=>g=!0,entityId:()=>f,originalScaleMode:()=>y}}replaceStudyStub(e,t){const i=this.paneForSource(e);if(null===i)return!1;const s=e.priceScale(),o=e.zorder(),n=e.ownerSource();return this.paneForSource(e)===i?i.replaceSource(e,t,s):(i.insertDataSource(t,s,o),this.removeSource(e)),t.setOwnerSource(n),this.dataSources().forEach((i=>{i.ownerSource()===e&&i.setOwnerSource(t)})),this._invalidateBarColorerCaches(),t.start(),this.recalculatePane(i,(0,wi.sourceChangeEvent)(t.id())),this.fullUpdate(),!0}insertStudyStub(e,t,i,s){const o=void 0!==t,r=new Zr.StudyStub(this,i??null,e,t,s??null);let a;if(t||!o){a=(0,n.ensureNotNull)(this.mainPane());const e=!0===t?this.mainSeries().priceScale():a.createPriceScaleAtPosition("overlay");a.addDataSource(r,e,!1)}else a=this.createPane(),a.addDataSource(r,null,!1);return r.setZorder(a.newStudyZOrder()),this.recalculatePane(a,(0,wi.sourceChangeEvent)(r.id())),this.fullUpdate(),r}removeStudyStub(e){const t=this.dataSourceForId(e);return null===t?(k_.logNormal("StudyStub id="+e+" is not found in chart model"),!1):(this.removeSource(t),!0)}restoreStudyStub(e){const t=this.insertStudyStub(e.title,e.isOverlay,e.descriptor);return this.paneForSource(t)?.changeSourceId(t,e.id),t.setStatus(e.status),t}bulkActionMacro(e){const t=this._panes;t.forEach((e=>e.beginBulkAction())),e(),t.forEach((e=>e.endBulkAction()))}allLineTools(){return this._getAllSources(zs.isLineTool)}allLineToolsIncludingHidden(){return this._getAllSources(zs.isLineTool,H_)}setHoveredSource(e,t=null,i){const s=this._hoveredSource!==e;this._hoveredSourceOrigin=i??null,!s&&(0,Ut.hitTestResultDataAreEqual)(this._lastHoveredHittestData,t)||(this._lastHoveredHittestData=t,this._hoveredSource&&(this._hoveredSource.updateAllViews((0,wi.hoverChangeEvent)()),this.updateSource(this._hoveredSource)),this._hoveredSource=e,this._hoveredSource&&(this._hoveredSource.updateAllViews((0,wi.hoverChangeEvent)()),this.updateSource(this._hoveredSource)),s&&this._hoveredSourceChanged.fire(e))}properties(){return this._properties}chartApi(){
return this._chartSession}disconnect(){this._sessions?.get()?.stop();for(const e of this.dataSources())e.disconnect&&e.disconnect();this._timeScale.disconnect()}crosshairSource(){return this._crossHairSource}gridSource(){return this._gridSource}publishedChartsTimelineSource(){return null}hoveredSource(){return this._hoveredSource}hoveredSourceOrigin(){return this._hoveredSourceOrigin}hoveredSourceChanged(){return this._hoveredSourceChanged}lastHittestData(){return this._lastHoveredHittestData}lastSelectedHittestData(){return this._lastSelectedHittestData}lightUpdate(){this.invalidate(ao.InvalidationMask.light())}fullUpdate(){this.invalidate(ao.InvalidationMask.full())}async syncTimeWithModel(e,t,i){const s=this.mainSeries().syncModel();if(null===s)return;const o=1e3*this.createSyncPoint(e,s.syncSourceTarget()).sourceTimeToTargetTime(t/1e3),r=(0,Ce.get_timezone)((0,n.ensureNotNull)(this.timezoneExceptExchange().value()));let a=(0,Ce.utc_to_cal)(r,o);return this.mainSeries().isDWM()&&(a=s.getSession().spec.correctTradingDay(a),(0,Ce.set_hms)(a,0,0,0,0,(0,Ce.get_timezone)("Etc/UTC"))),this._gotoTimeImpl(a.getTime(),{targetPointAlignment:"center",alignIfTargetPointIsVisible:!1,autoscaleAfterScroll:!1,...i}).catch((()=>{}))}gotoTime(e,t){return this._gotoTimeImpl(e,{targetPointAlignment:"center",alignIfTargetPointIsVisible:!0,autoscaleAfterScroll:!0,...t}).catch((()=>{}))}recalculatePane(e,t){e?.recalculate(t)}recalculateAllPanes(e){this._panes.forEach((t=>t.recalculate(e))),this.updateAllPaneViews(e),this.crosshairSource().updateAllViews(e)}async gotoTimeRange(e,t,i){const s=this.timeScale(),o=s.tickMarks(),r=this.mainSeries();if(i||this._lastGotoTimeRange?.deferred.reject(),void 0===o.minIndex)return void(i||(this._lastGotoTimeRange={from:e,to:t,deferred:(0,me.createDeferredPromise)()}));let a=e,l=t;if(null!==r.symbolInfo()){const i=(0,n.ensureNotNull)(this.timezoneExceptExchange().value()),s=(0,Ce.get_timezone)(i),o=(0,Ce.utc_to_cal)(s,e),c=(0,Ce.utc_to_cal)(s,t);if(r.isDWM()){const e=(0,Ce.get_timezone)("Etc/UTC");(0,Ce.set_hms)(o,0,0,0,0,e),(0,Ce.set_hms)(c,0,0,0,0,e)}a=o.getTime(),l=c.getTime()}const c=(0,n.ensureDefined)(o.maxIndex),h=(0,n.ensureDefined)(o.minIndex);if(!(a>=(0,n.ensureNotNull)(o.indexToTime(h)).valueOf()||r.endOfData()||i)){const s={type:"time-range",from:e/1e3,to:t/1e3};return null===this._lastAppliedGotoTimeRange&&(this._lastAppliedGotoTimeRange={range:s,actual:!0},r.loadDataTo(s)),i||(i=this._lastGotoTimeRange={from:e,to:t,deferred:(0,me.createDeferredPromise)()}),i.deferred.promise}{const e=(e,t)=>e<t,t=e=>(0,n.ensureNotNull)(o.indexToTime(e)).valueOf(),d=(0,Pt.lowerboundExt)(t,a,e,o.nearestIndex(a),c);let u=a===l?d:(0,Pt.lowerboundExt)(t,l,e,o.nearestIndex(l),c);this._lastGotoTimeRange=null,null!==this._lastAppliedGotoTimeRange&&(this._lastAppliedGotoTimeRange.actual=!1);const _=s.baseIndex();if(d+Math.max(u-d+1,s.minVisibleBarCount())>_){const e=s.targetDefaultRightOffset();u-_<e&&(u=_+e)}const p=d===u&&d===h&&r.endOfData()?d-1:d;s.zoomToBarsRange(p,u),this.updateAllPaneViews((0,
wi.viewportChangeEvent)()),this.lightUpdate(),i?.deferred.resolve()}}paneForSource(e){if(e===this._mainSeries.activeStudyBinding())return this.mainPane();if(!(0,Po.isDataSource)(e))return Array.from(this._customSourcesMap.values()).includes(e)?this.paneForSource(this.mainSeries()):null;for(let t=this._panes.length-1;t>=0;t--)if(this._panes[t].hasDataSource(e))return this._panes[t];return e instanceof xi?this.paneForSource(this.mainSeries()):null}mainPane(){return this._panes.find((e=>e.isMainPane().value()))??null}lastPane(){return this._panes[this._panes.length-1]}removeSource(e,t){this.selectionMacro((t=>t.removeSourceFromSelection(e)),!0),this._hoveredSource===e&&(this._hoveredSource=null,this._lastHoveredHittestData=null),this._sourcesBeingMoved.includes(e)&&(this._sourcesBeingMoved=this._sourcesBeingMoved.filter((t=>t!==e)),this._sourcesBeingMoved.length||(this._activeItemBeingMoved=null)),e===this._lineBeingEdited?.lineDataSource&&(this._lineBeingEdited=null,mt.isToolEditingNow.setValue(!1)),e===this.lineBeingCreated()&&(this._linesBeingCreated.shift(),0===this._linesBeingCreated.length&&mt.isToolCreatingNow.setValue(!1)),!t&&e.stop&&e.stop();const i=this.detachSource(e),s=this.mainSeries().priceScale();return(0,Ws.isStudy)(e)&&(0,Lr.isActingAsSymbolSource)(e)&&e.priceScale()===s&&s.isPercentage()&&1===s.seriesLikeSources().filter(Lr.isActingAsSymbolSource).length&&s.setMode({percentage:!1}),this.fullUpdate(),this._invalidateBarColorerCaches(),(0,Ws.isStudy)(e)&&((0,ee.emit)("study_event",e.id(),"remove"),e.isChildStudy()&&e.parentSources().forEach((t=>t.unsetChild(e))),e.maxOffset().unsubscribe(this._boundUpdateStudiesMaxOffset)),!t&&e.destroy&&e.destroy(),(0,zs.isLineTool)(e)&&(e.removeAlert(),(0,ee.emit)("drawing_event",e.id(),"remove")),i}mainSeriesScaleRatio(){return(0,Wl.scaleRatio)(this._timeScale,this.mainSeries().priceScale())}setMainSeriesScaleRatio(e){(0,n.ensureNotNull)(this.paneForSource(this._mainSeries)).applyPriceScaleRatio(this._mainSeries.priceScale(),e)}timezone(){return this._properties.childs().timezone.value()}timezoneExceptExchange(){return this._timezoneExceptExchange}allStudies(e){const t=e?e=>(0,Ws.isStudy)(e)&&!0:Ws.isStudy;return this._getAllSources(t)}studiesWV(e){return e?this._studiesExcludeInternalWV.readonly():this._studiesWV.readonly()}signatureSources(){return this._signatureSources}sourcesSignatures(){return this._sourcesSignatures}listUserStudies(e){const t=[];for(const i of this._panes)for(const s of i.priceDataSources())if(!(0,Ws.isFundamentalStudy)(s)&&(0,Ws.isStudy)(s)&&s.showInObjectTree()){const{id:i,shortDescription:o}=s.metaInfo();if(e.dontCountVolume&&"Volume@tv-basicstudies"===i||e.dontCountCompare&&"Compare@tv-basicstudies"===i||e.dontCountOverlay&&"Overlay@tv-basicstudies"===i)continue;t.push(o)}return t}findNonOverlayStudyWithGroupingKey(e,t){const i=void 0!==t?[t]:this._panes;for(const t of i){const i=t.dataSources().find((i=>(0,Ws.isStudy)(i)&&i.metaInfo().groupingKey===e&&!t.isOverlay(i)));if(void 0!==i)return{pane:t,study:i}}return null}canMovePaneUp(e){
if(0===e)return!1;const t=this._panes[e],i=this._panes[e-1];return t.mode()===zi.PaneMode.Widget?i.containsMainSeries():i.mode()!==zi.PaneMode.Widget||!t.containsMainSeries()||1!==e}movePaneUp(e){this.movePane(e,e-1)}canMovePaneDown(e){if(e===this._panes.length-1)return!1;const t=this._panes[e],i=this._panes[e+1];return t.mode()===zi.PaneMode.Widget?i.containsMainSeries():i.mode()!==zi.PaneMode.Widget||!t.containsMainSeries()||e!==this._panes.length-2}movePaneDown(e){this.movePane(e,e+1)}movePane(e,t){const i=this._panes[e];this._panes.splice(e,1),this._panes.splice(t,0,i),this._panesCollectionChanged.fire(this._panes),this._onRearrangePanes.fire(),this._invalidateBarColorerCaches(),this.invalidate(ao.InvalidationMask.panesOrder())}toggleCollapsedPane(e){const t=this._panes[e];t.collapsed().setValue(!t.collapsed().value()),this.fullUpdate()}sendToBack(e){this._sendTo(e,((e,t)=>e.sendToBack(t)))}bringToFront(e){this._sendTo(e,((e,t)=>e.bringToFront(t)))}backgroundColor(){return this._backgroundColor}backgroundTopColor(){return this._backgroundTopColor}backgroundColorAtYPercentFromTop(e){const t=this.backgroundColor().value(),i=this.backgroundTopColor().value();return this._backgroundColorAtYPercentFromTop.gradientColor(i,t,e)}backgroundCounterColor(){return this._backgroundCounterColor.readonly()}dark(){return this._isDark}backgroundTheme(){return this._backgroundTheme}readOnly(){return this._readOnly}defaultResolutions(){return this.chartApi().defaultResolutions()}availableCurrencies(){const e=this._getAvailableCurrencies();return e.length!==this._availableCurrencies.size()&&(this._availableCurrencies=new Fd(e)),this._availableCurrencies}currencyConversionEnabled(){return this._options.currencyConversionEnabled}availableUnits(){const e=this._getAvailableUnits();return this._availableUnits.unitsChanged(e)&&(this._availableUnits=new Wd(e)),this._availableUnits}unitConversionEnabled(){return this._options.unitConversionEnabled}availablePriceSources(e){const t=this._getAvailablePriceSources(e);return null!==t&&this._availablePriceSources.priceSourcesChanged(t)&&(this._availablePriceSources=new C_(t)),this._availablePriceSources}resetDeferredStudies(){vh.instance(this).reset()}waitForStudy(e){const t=this.dataSourceForId(e);return t&&(0,Ws.isStudy)(t)?Promise.resolve(t):vh.instance(this).get(e)}resetWaitForStudy(e){vh.instance(this).delete(e)}isJustClonedChart(){return this._undoModel.isJustClonedChart()}studyTemplate(e,t,i){const s={panes:[],version:this.version()};for(const e of this.panes())s.panes.push(e.state({includeSources:!0,isStudyTemplate:!0}));const o=this.mainSeries();return e&&(s.symbol=o.symbol(),this.currencyConversionEnabled()&&i&&(s.currency=o.currency()),this.unitConversionEnabled()&&i&&(s.unit=o.unit())),t&&(s.interval=o.interval()),s}dataSourceForId(e){for(const t of this._panes){const i=t.dataSourceForId(e);if(i)return i}return null}getStudyById(e){const t=this.dataSourceForId(e);return null!==t&&(0,Ws.isStudy)(t)?t:null}getLineToolById(e){const t=this.dataSourceForId(e);return null!==t&&(0,
zs.isLineTool)(t)?t:null}restoreLineToolState(e,t,i){t.positionPercents?e.restorePositionPercents(t.positionPercents):(e.clearFixedPoint(),e.restorePoints(t.points,t.indexes||[])),t.state.intervalsVisibilities=(0,bh.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities),e.linkKey().setValue(t.linkKey||null),e.properties().mergeAndFire(t.state),e.restoreData&&e.restoreData(t),e.createServerPoints(),e.setZorder(t.zorder??e.zorder()),this.fullUpdate();const s=e.linkKey().value();null!==s&&i&&!this._lineToolsSyncBlock&&(0,mt.restoreLineToolState)({model:this,linkKey:s,state:t})}restoreFactoryDefaults(e){e.restoreFactoryDefaults(),this.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction)}preferences(){return function(e,t,i=m_){const s={timezone:"",priceScaleSelectionStrategyName:"auto",inactivityGaps:!1,timeScale:{defaultRightOffset:e.timeScale().defaultRightOffset().value(),defaultRightOffsetPercentage:e.timeScale().defaultRightOffsetPercentage().value(),usePercentageRightOffset:e.timeScale().usePercentageRightOffset().value()},mainSeries:{},sessions:{},paneProperties:{},scalesProperties:{},chartEventsSourceProperties:{},tradingProperties:{}},o=["timeScale","mainSeries","sessions"],n=i.mainSeries,r=Object.keys(i),a=Object.keys(n),l=t.properties(),c=e.sessions().properties(),h=e.properties(),d=i.sessions,u=Object.keys(d);return a.forEach((e=>{s.mainSeries[e]=f_(e,l,n,"mainSeries")})),u.forEach((e=>{s.sessions[e]=f_(e,c,d,"sessions")})),r.forEach((e=>{o.includes(e)||(s[e]=f_(e,h,i,"preferences"))})),s}(this,this.mainSeries())}applyPreferences(e){for(const[t,i]of Object.entries(e)){const e=this._properties.child(t);void 0!==i&&void 0!==e&&e.mergeAndFire(i)}if(void 0!==e.timeScale){const t=e.timeScale;this._timeScale.defaultRightOffset().setValue(t.defaultRightOffset),this._timeScale.defaultRightOffsetPercentage().setValue(t.defaultRightOffsetPercentage),this._timeScale.usePercentageRightOffset().setValue(t.usePercentageRightOffset)}this._properties.saveDefaults(),this._mainSeries.applyPreferences(e.mainSeries),this.sessions().restoreState({properties:e.sessions},!1),this.recalculateAllPanes((0,wi.globalChangeEvent)()),this.fullUpdate()}restoreTheme(e,t,i){e.mainSourceProperties.hollowCandleStyle||(e.mainSourceProperties.hollowCandleStyle=e.mainSourceProperties.candleStyle),this._undoModel.chartLoadTheme(e,t,i)}updateScales(){this.mainSeries().properties().childs().priceAxisProperties.fireChanged()}onResetScales(){return this._resetScales}startMovingSources(e,t,i,s,o,r){this._sourcesBeingMoved=e,this._activeItemBeingMoved=i;let a=!1;if(this._sourcesBeingMoved.forEach((e=>{!a&&(0,Ws.isStudy)(e)&&(a=!0);const l=(0,n.ensureNotNull)(this.paneForSource(e)),c=(0,zs.isLineTool)(e),h=c&&e.linkKey().value();if(!1!==h&&null!==h&&s.has(h)&&c&&e.isFixed()){const t=(0,n.ensureDefined)(s.get(h)),a={screen:this._percentPositionToPoint(t,l)};e.startMoving(a,i,o,r)}else e.startMoving(t,i,o,r);const d=this._paneInvalidationMask(l,ao.InvalidationLevel.Light);this.invalidate(d)})),!r){
const[s,r]=F_(e);if(s.size&&t.logical){const a=this.externalTimeStamp(t.logical.index),l={linkKeys:[...s],toolNames:[...r],model:this,symbol:this.mainSeries().symbol(),point:{price:t.logical.price,timeStamp:a},activeItem:null!==i?i:void 0,envState:o,pointPositionPercents:new Map};e.forEach((e=>{if((0,zs.isLineTool)(e)){const i=e.linkKey().value();if(i&&e.isSynchronizable()&&e.isFixed()){const s=(0,n.ensureNotNull)(this.paneForSource(e));l.pointPositionPercents.set(i,this._pointToPercentPosition((0,n.ensureDefined)(t.screen),s))}}})),(0,mt.startMovingLineTool)(l)}}mt.isToolMovingNow.setValue(!0),a&&mt.isStudyEditingNow.setValue(!0)}moveSources(e,t,i,s){if(this._sourcesBeingMoved.filter((e=>!e.isLocked||!e.isLocked())).forEach((o=>{const r=(0,zs.isLineTool)(o)?o.linkKey().value():null;if(null!==r&&t.has(r)){const e=(0,n.ensureNotNull)(this.paneForSource(o)),a=(0,n.ensureDefined)(t.get(r)),l={screen:this._percentPositionToPoint(a,e)};o.move(l,this._activeItemBeingMoved,i,s)}else o.move(e,this._activeItemBeingMoved,i,s)})),this.lightUpdate(),!s&&e.logical&&!this._lineToolsSyncBlock){const[t,s]=F_(this._sourcesBeingMoved),o=this.externalTimeStamp(e.logical.index),r={linkKeys:[...t],toolNames:[...s],model:this,point:{price:e.logical.price,timeStamp:o},envState:i,pointPositionPercents:new Map};this._sourcesBeingMoved.filter(zs.isLineTool).forEach((t=>{if(t.linkKey().value()&&t.isSynchronizable()&&t.isFixed()){const i=(0,n.ensureNotNull)(this.paneForSource(t));r.pointPositionPercents.set(t.linkKey().value(),this._pointToPercentPosition((0,n.ensureDefined)(e.screen),i))}})),(0,mt.moveLineTool)(r)}}endMovingSources(e,t,i){const s=this._sourcesBeingMoved.map((s=>{const o=(0,n.ensureNotNull)(this.paneForSource(s)),r=s.endMoving(e,t,i),a=this._paneInvalidationMask(o,ao.InvalidationLevel.Light);return a.invalidateAll(ao.InvalidationLevel.Light),this.invalidate(a),r}));if(!t&&!this._lineToolsSyncBlock){const[e,t]=F_(this._sourcesBeingMoved),i=this._sourcesBeingMoved.filter(zs.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey)).map((e=>{const t={points:e.normalizedPoints(),interval:this.mainSeries().interval()};return e.isFixed()&&(t.pointPositionPercents=e.calcPositionPercents()),t}));e.size&&(0,mt.finishMovingLineTool)({linkKeys:[...e],toolNames:[...t],model:this,finalStates:i,changes:s})}this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,mt.isToolMovingNow.setValue(!1),mt.isStudyEditingNow.setValue(!1)}sourcesBeingMoved(){return this._sourcesBeingMoved}setMovingCustomSource(e,t){this._customSourceBeingMoved=e,this._customSourceBeingMovedHitTestData=null!==t?{beingMoved:!1,cancelled:!1,...t}:null}processingCustomSourceMove(){null!==this._customSourceBeingMovedHitTestData&&(this._customSourceBeingMovedHitTestData.beingMoved=!0)}customSourceMovingHitTestData(){return this._customSourceBeingMovedHitTestData}customSourceBeingMoved(){return null!==this._customSourceBeingMovedHitTestData&&this._customSourceBeingMovedHitTestData.beingMoved?this._customSourceBeingMoved:null}lineToolsSynchronizer(){
return this._lineToolsSynchronizer}setLineToolsSynchronizer(e){this._lineToolsSynchronizer=e}width(){return this._width}setWidth(e,t){(this._panes.reduce(((t,i)=>i.setWidth(e)||t),!1)||this._width!==e)&&(this._width=e,this._timeScale.setWidth(e,t),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction))}setPaneHeight(e,t){e.setHeight(t),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),this.lightUpdate()}resetScalesAvailable(){return this._resetScalesAvailable.readonly()}maximizedPane(){return this._maximizedPane.readonly()}setMaximizedPane(e){(0,n.assert)(null===e||this._panes.includes(e),"The pane is not part of this chart"),this._maximizedPane.setValue(e)}panes(){return this._panes}paneForId(e){return this._panes.find((t=>t.id()===e))||null}createPane(e,t,i,s){this._restoringState||this._maximizedPane.setValue(null);const o=this._properties.childs().paneProperties;t&&o.merge(t);const n=new kh(this._timeScale,o,this,i,s??zi.PaneMode.Regular);return void 0!==e?this._panes.splice(e,0,n):this._panes.push(n),n.onTagsChanged().subscribe(this,(()=>this.onPaneTagsChanged())),n.dataSourcesCollectionChanged().subscribe(this,(()=>this._dataSourceCollectionChanged.fire(n))),n.dataSourcesZOrdersChanged().subscribe(this,(()=>this._invalidateBarColorerCaches())),n.symbolSourceCollectionChanged().subscribe(this,(()=>this._onSymbolSourceCollectionChanged(n))),n.priceSourcesCollectionChanged().subscribe(this,(()=>this._onPriceSourcesCollectionChanged(n))),n.sourcePropertiesChanged().subscribe(this,(e=>this._sourceProperitesChanged.fire(n,e))),n.sourceZOrderChanged().subscribe(this,(e=>this._sourceZOrderChanged.fire(n,e))),n.symbolSourceResolved().subscribe(this,(e=>this._symbolSourceResolved.fire(n,e))),n.symbolSourceResolvingActive().subscribe(this._recalcSymbolResolvingActive),n.collapsed().subscribe(this._recalcPaneCollapsingAvailable),n.resetPriceScalesAvailable().subscribe(this._updateResetScalesAvailableValue,{callWithLast:!0}),this._recalcPaneCollapsingAvailable(),this._panesCollectionChanged.fire(this._panes),this._invalidateBarColorerCaches(),this.invalidate(ao.InvalidationMask.panesOrder()),n}removePane(e){e===this._maximizedPane.value()&&this._maximizedPane.setValue(null),e.destroy();const t=this._panes.indexOf(e);-1!==t&&(this._panes.splice(t,1),e.dataSourcesCollectionChanged().unsubscribeAll(this),e.dataSourcesZOrdersChanged().unsubscribeAll(this),e.symbolSourceCollectionChanged().unsubscribeAll(this),e.priceSourcesCollectionChanged().unsubscribeAll(this),e.sourcePropertiesChanged().unsubscribeAll(this),e.onTagsChanged().unsubscribeAll(this),e.symbolSourceResolved().unsubscribeAll(this),e.symbolSourceResolvingActive().unsubscribe(this._recalcSymbolResolvingActive),e.collapsed().unsubscribe(this._recalcPaneCollapsingAvailable),e.resetPriceScalesAvailable().unsubscribe(this._updateResetScalesAvailableValue),this._recalcPaneCollapsingAvailable(!0)),this._updateResetScalesAvailableValue()
;this.crosshairSource().pane===e&&this.clearCurrentPosition(),this._panesCollectionChanged.fire(this._panes),this._invalidateBarColorerCaches(),this.invalidate(ao.InvalidationMask.panesOrder())}changePanesHeight(e,t){if(this._panes.length<2)return;(0,n.assert)(e>=0&&e<this._panes.length,"Invalid pane index");const i=this._panes[e],s=this._panes.reduce(((e,t)=>e+t.stretchFactor()),0),o=this._panes.reduce(((e,t)=>e+t.height()),0),r=o-30*(this._panes.length-1);t=Math.min(r,Math.max(30,t));const a=s/o,l=i.height();i.setStretchFactor(t*a);let c=t-l,h=this._panes.length-1;for(const e of this._panes)if(e!==i){const t=Math.min(r,Math.max(30,e.height()-c/h));c-=e.height()-t,h-=1;const i=t*a;e.setStretchFactor(i)}this.fullUpdate()}clearCurrentPosition(){const e=this.crosshairSource();e.clearPosition(),(0,n.ensureNotNull)(e.dataWindowView()).update((0,wi.sourceChangeEvent)(e.id())),D_(this._panes),this.invalidate(ao.InvalidationMask.cursor()),this._undoModel.syncCrosshair(null),this._phantomSourceContainer.onCursorPositionUpdated()}getTpoSummaryPane(){throw new Error("Not implemented")}getVolumeFootprintSummaryPane(){throw new Error("Not implemented")}setAndSaveCurrentPosition(e,t,i,s){this.crosshairSource().saveOriginCoords(e,t),this.setCurrentPosition(e,t,i,s)}setCurrentPosition(e,t,i,s){let o=NaN;const r=this._timeScale.coordinateToVisibleIndex(e),a=(this._lineBeingEdited??this._linesBeingCreated[0])?.ownerSource.priceScale()??i.defaultPriceScale();let l=null;!a.isEmpty()&&Number.isFinite(t)&&(l=(0,n.ensureNotNull)(i.mainDataSource()).firstValue(),null!==l&&(o=a.coordinateToPrice(t,l)));const c=this._crossHairSelectPointMode.value()!==mt.SelectPointMode.None,h=mt.tool.value(),d=this.mainSeries(),u=this.crosshairSource(),_=u.index,p=u.price,m=c||mt.isStudyEditingNow.value();let g=!1;const f=(0,Dn.magnetSnapsToIndicators)().value();if(a===this._mainSeries.priceScale()||f)if((0,Lt.isLineDrawnWithPressedButton)(h)){const e=this.lineBeingCreated();g=null===e||(0,zs.isBrushBasedLineTool)(e)&&e.hasOnlyOnePoint()}else{g=Boolean(this.lineBeingCreated()||this._lineBeingEdited||(0,Lt.isLineToolName)(h)||(0,mt.toolIsMeasure)(h))||m}!this._isSettingsExternalPosition&&g?(o=this._magnet.align(o,r,i),null!==l&&this._setCorrectedPositionToCrosshair(r,o,i)):this._magnet.resetLastValue();let y=null;if(isNaN(o)||(y=i),this._isTimeScrolling){if(!this._isSettingsExternalPosition&&c){const e=d.bars().firstIndex(),t=d.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(r,e),t);s!==r&&this._setCorrectedPositionToCrosshair(s,o,i)}}else u.setPosition(u.index,o,y);return}u.setOnHoveredChartWidget(!0),u.setPosition(r,o,y),(0,n.ensureNotNull)(u.dataWindowView()).update((0,wi.sourceChangeEvent)(u.id())),D_(this._panes);const v=d.syncModel(),S=this.lineBeingCreated();if(this.crosshairSource().startMeasurePoint()||S?this.lightUpdate():this.invalidate(ao.InvalidationMask.cursor()),S){const e=S.linkKey().value();if(!this._isSettingsExternalPosition){const t=S.setLastPoint({index:r,price:o},s);if(S.updateAllViews((0,
wi.sourceChangeEvent)(S.id())),t.price===o&&t.index===r||this._setCorrectedPositionToCrosshair(t.index,t.price,i),v&&e&&!this._lineToolsSyncBlock){const i=this._timeScale.points().roughTime(t.index,v.projectTime.bind(v));(0,mt.setLineToolLastPoint)({model:this,linkKey:e,point:{timeStamp:(0,n.ensureNotNull)(i),price:t.price}})}}}if(!this._isSettingsExternalPosition&&null!==this._lineBeingEdited&&null!==this._lineBeingEdited.pointIndex){const e={index:r,price:o},{lineDataSource:t,pointIndex:n,startChangingPoint:a}=this._lineBeingEdited;if(a?.nonDiscreteIndex){const t=this.crosshairSource().originX();Number.isFinite(t)&&(e.index=this._timeScale.coordinateToFloatIndex(t))}this.changeLinePoint(e,s);const l=t.alignCrossHairToAnchor(n)?t.getPoint(n):e;null!==l&&this._setCorrectedPositionToCrosshair(l.index,l.price,i)}if(!this._isSettingsExternalPosition&&1===this._sourcesBeingMoved.length){const e=this._sourcesBeingMoved[0];if(e.alignCrossHairToMovePoint?.()){const t=e.currentMovingPoint?.();t&&t.logical&&this._setCorrectedPositionToCrosshair(t.logical.index,t.logical.price,i)}}if(!this._isSettingsExternalPosition&&m){const e=d.bars().firstIndex(),t=d.bars().lastIndex();if(null!==e&&null!==t){const s=Math.min(Math.max(r,e),t);s!==r&&this._setCorrectedPositionToCrosshair(s,o,i)}}(_!==r||p!==o)&&this._syncCrosshair(s)}setExternalPosition(e,t){let i;const s=this.crosshairSource();if(s.setOnHoveredChartWidget(!1),null!==e&&(0,tt.isNumber)(e.timeStamp)){const t=this.mainSeries().syncModel();if(t){const s=this.createSyncPoint(e.syncSourceTarget,t.syncSourceTarget()).sourceTimeToTargetTime(e.timeStamp);i=this._timeScale.points().roughIndex(s,t.distance.bind(t),1)}}if(null!==e&&null!=i&&Number.isFinite(i)){this._isSettingsExternalPosition=!0;const o=(0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),r=this._timeScale.indexToCoordinate(i),a=(0,n.ensureNotNull)(o.mainDataSource()).firstValue();if(null!==a){let i=NaN;void 0!==e.price&&Number.isFinite(e.price)&&(i=this.mainSeries().priceScale().priceToCoordinate(e.price,a)),s.clearOriginCoords(),this.setCurrentPosition(r,i,o,t)}return s.setOnHoveredChartWidget(!1),void(this._isSettingsExternalPosition=!1)}s.clearPosition(),(0,n.ensureNotNull)(s.dataWindowView()).update((0,wi.sourceChangeEvent)(s.id())),D_(this._panes),this.invalidate(ao.InvalidationMask.cursor())}startScaleTime(e){this._timeScale.startScale(e)}scaleTimeTo(e){this._timeScale.scaleTo(e),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),this.lightUpdate()}endScaleTime(){this._timeScale.endScale(),this.lightUpdate(),this.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction)}resetTimeScale(){this._timeScale.restoreDefault(),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction),this.lightUpdate(),this._resetScales.fire()}startScalePrice(e,t,i){e.startScalePrice(t,i)}scalePriceTo(e,t,i){e.scalePriceTo(t,i),
this.mainSeries().priceScale().isLockScale()?this.lightUpdate():this.invalidate(this._paneInvalidationMask(e,ao.InvalidationLevel.Light))}endScalePrice(e,t){e.endScalePrice(t),this.invalidate(this._paneInvalidationMask(e,ao.InvalidationLevel.Light))}startTwoPointsScalePrice(e,t,i,s){t.startTwoPointsScale(i,s)}twoPointsScalePriceTo(e,t,i,s){t.twoPointsScale(i,s),t.updateAllViews((0,wi.viewportChangeEvent)()),this.invalidate(this._paneInvalidationMask(e))}endTwoPointsScalePrice(e,t){t.endTwoPointsScale(),this.invalidate(this._paneInvalidationMask(e))}resetPriceScale(e,t){e.resetPriceScale(t),this.invalidate(this._paneInvalidationMask(e,ao.InvalidationLevel.Light))}restorePriceScaleState(e,t,i){e.restorePriceScaleState(t,i),this.invalidate(this._paneInvalidationMask(e,ao.InvalidationLevel.Light))}detachSource(e){const t=this.paneForSource(e);return!!t&&(t.removeDataSource(e),t.isEmpty()?(this.lineBeingCreated()&&t===this.paneBeingCreatedLineOn()&&this.cancelCreatingLine(),this.removePane(t),!0):(this.fullUpdate(),!1))}restoreSource(e,t,i,s,o){const n=e?this.createPane(t):this.panes()[t],r=(0,wt.isStudyState)(s),a=r?n.restoreStudy(s):(0,wt.isLineToolState)(s)?n.restoreLineTool({state:s}):null;if(!a)return null;let l=null;if(o?(l=n.getPriceScaleById(o.id),l||(l=n.createPriceScaleAtPosition(o.position,o.priceScaleIndex),l.setId(o.id))):l=a.ownerSource()?.priceScale()??l,l&&(a.setPriceScale(l),l.addDataSource(a)),!e&&i&&i.overlayPriceScales){const e=this.dataSources().filter((e=>void 0!==i.overlayPriceScales[e.id()]));e.forEach((e=>n.removeSourceFromPriceScale(e)));const t=new Map;e.forEach((e=>{const s=i.overlayPriceScales[e.id()];if(!s)return;let o;t.has(s.id)?o=t.get(s.id):(o=n.createPriceScaleAtPosition("overlay"),o.restoreState(s),t.set(s.id,o)),e.setPriceScale(o),o.addDataSource(e)}))}return e&&i&&n.restoreState({state:i,withData:!1,version:this.version()}),r&&(this.recalculateAllPanes((0,wi.sourceChangeEvent)(a.id())),this._invalidateBarColorerCaches(),this.fullUpdate()),a}children(e,t,i){return this.dataSources().filter((s=>(0,Ws.isStudy)(s)?!t&&s.parentSources().includes(e):!((0,zs.isLineTool)(s)&&i&&s.supportsTargetSignature()&&null!==s.targetSignature())&&s.ownerSource()===e))}onRearrangePanes(){return this._onRearrangePanes}studyInserted(){return this._studyInserted}finishLineTool(e){const t=e.linkKey().value();(0,mt.drawOnAllCharts)().value()&&null!==t&&e.isSynchronizable()&&!this._lineToolsSyncBlock&&(0,mt.finishLineTool)({linkKey:t,model:this})}startChangingLinetool(e,t,i,s,o,r){this._lineBeingEdited={lineDataSource:e,ownerSource:t,startChangingPoint:i??null,pointIndex:s??null},e.startChanging(s,i,r),mt.isToolEditingNow.setValue(!0);const a=(0,n.ensureNotNull)(this.paneForSource(e));e.startDragPoint&&void 0!==s&&void 0!==i&&e.startDragPoint(s,i),r||void 0===s||void 0===i||e.setPoint(s,i,o,r),e.updateAllViews((0,wi.sourceChangeEvent)(e.id()));const l=this._paneInvalidationMask(a,ao.InvalidationLevel.Light);this.invalidate(l);const c=e.linkKey().value()
;if(c&&e.isSynchronizable()&&void 0!==s&&void 0!==i&&!this._lineToolsSyncBlock){const t=(0,n.ensureNotNull)(this.externalTimeStamp(i.index));(0,mt.startChangingLineTool)({linkKey:c,model:this,symbol:this.mainSeries().symbol(),point:{price:i.price,timeStamp:t},positionPercents:e.positionPercents(),pointIndex:s,envState:o||null})}}createLineTool(e){const{point:t,linetool:i,linkKey:s=null,sharingMode:o=0,id:r,fromExternalModel:a,actionSource:l,pane:c}=e;let{properties:h,ownerSource:d}=e;d=(0,n.ensureDefined)(d||(0,n.ensureNotNull)(c.mainDataSource()));let u=c;if((0,n.assert)((0,Lt.isLineToolName)(i),`Cannot create unknown line tool: ${i}`),h){const e={...v_.intervalsVisibilitiesDefaults},t=h.childs().intervalsVisibilities.state();(0,tt.merge)(e,t??{});const s=h.state();s.intervalsVisibilities=e,h=(0,zs.createLineToolProperties)(this.backgroundTheme().spawnOwnership(),i,!this.readOnly(),s)}const _=(0,zs.createLineTool)(i,this,h,null,void 0,r,l);if("LineToolExecution"!==i){let e;switch(i){case"LineToolIcon":e=_.properties().childs().icon.value().toString(16).toUpperCase();break;case"LineToolEmoji":e=_.properties().childs().emoji.value();break;case"LineToolSticker":e=_.properties().childs().sticker.value()}(0,re.trackEvent)("drawings","Study_Drawing_"+i,e)}(0,Us.isStudyLineTool)(_)&&(0,re.trackEvent)("studies",`Study_${_.metaInfo().id}`,_.metaInfo().description);const p=!_.linkKey().value()&&!s;h||(0,zs.prepareLineToolPropertiesByOwnerSource)(_.properties(),d),_.setOwnerSource(d);const m=d.priceScale();if(_.setPriceScale(m),L_&&d===this.mainSeries()&&_.share(o),u.addDataSource(_,m,!1),null!==_.preferredZOrder()&&u.insertAfter([_],this.mainSeries()),(0,mt.drawOnAllCharts)().value()){const e=_.isSynchronizable()?s||(0,fe.randomHash)():null;_.linkKey().setValue(e)}else _.linkKey().setValue(s);let g;if(p&&_.enableCurrentIntervalVisibility(),_.isFixed()){const e=(0,n.ensureNotNull)((0,n.ensureNotNull)(c.mainDataSource()).firstValue()),i=this._timeScale.indexToCoordinate(t.index),s=(0,n.ensureNotNull)(m).priceToCoordinate(t.price,e);g=_.addFixedPoint(new Vt.Point(i,s))}else g=_.addPoint(t);return g||(this._linesBeingCreated.unshift({lineDataSource:_,fromExternal:!!a,ownerSource:d,pane:c}),mt.isToolCreatingNow.setValue(!0)),this.fullUpdate(),_}endChangingLinetool(e,t){const i=(0,n.ensureNotNull)(this._lineBeingEdited).lineDataSource,s=i.endChanging(!1,e,t);this._lineBeingEdited=null,mt.isToolEditingNow.setValue(!1),this.lightUpdate();const o={points:i.normalizedPoints(),interval:this.mainSeries().interval()},r=i.linkKey().value();null===r||!i.isSynchronizable()||t||this._lineToolsSyncBlock||(0,mt.finishChangingLineTool)({model:this,linkKey:r,symbol:this.mainSeries().symbol(),finalState:o,changes:s})}continueCreatingLine(e,t,i,s,o){const r=(0,n.ensureNotNull)(this.lineBeingCreated()),a=r.addPoint(e,t,i,o);r.updateAllViews((0,wi.sourceChangeEvent)(r.id()));const l=new ao.InvalidationMask(ao.InvalidationLevel.Light);return a&&(this._linesBeingCreated.shift(),0===this._linesBeingCreated.length&&mt.isToolCreatingNow.setValue(!1)),
this.invalidate(l),a}cancelCreatingLine(){const e=this.lineBeingCreated();e&&(this.removeSource(e),this._linesBeingCreated.shift(),this._lineCancelled.fire(),0===this._linesBeingCreated.length&&mt.isToolCreatingNow.setValue(!1),(0,mt.drawOnAllCharts)().value()&&e.isSynchronizable()&&!this._lineToolsSyncBlock&&(0,mt.cancelLineTool)({model:this}))}lineBeingCreated(){return this._linesBeingCreated[0]?.lineDataSource??null}lineBeingCreateFromExternal(){return this._linesBeingCreated[0]?.fromExternal??!1}paneBeingCreatedLineOn(){return this._linesBeingCreated[0]?.pane??null}lineCancelled(){return this._lineCancelled}isPhantomLine(e){return this._phantomSourceContainer.source()===e}alignTo45Degrees(e,t,i){const[s,o]=i,n={...o};e.snapPoint45Degree(s,n),this.startChangingLinetool(e,t,o,o.pointIndex),this.changeLinePoint(n,To.EnvironmentState.create(!0)),this.endChangingLinetool(!1)}changeLinePoint(e,t,i){const s=(0,n.ensureNotNull)(this._lineBeingEdited),o=s.lineDataSource,r=(0,n.ensureNotNull)(s.pointIndex);let a=e.price,l=e.index;if(o.setPoint(r,e,t,i),!i){const t=o.alignCrossHairToAnchor(r)?o.getPoint(r):e;null!==t&&(l=t.index,a=t.price)}o.updateAllViews((0,wi.sourceChangeEvent)(o.id())),this.lightUpdate();const c=o.linkKey().value();if(!i&&null!==c&&o.isSynchronizable()&&!this._lineToolsSyncBlock){const e=(0,n.ensureNotNull)(s.startChangingPoint),i={indexesChanged:l!==e.index,pricesChanged:a!==e.price},h=o.getChangePointForSync(r);if(null!==h){const e=this.externalTimeStamp(l);null!==e&&(a=h.price,(0,mt.changeLineTool)({linkKey:c,model:this,symbol:this.mainSeries().symbol(),point:{price:a,timeStamp:e},positionPercents:o.positionPercents(),envState:t,changes:i}))}}}changeLinePoints(e,t,i){const s=e.points(),o=e.linkKey().value();!i&&o&&e.isSynchronizable()&&!this._lineToolsSyncBlock&&t.forEach(((t,i)=>{const r=s[i],a=r.price!==t.price,l=r.index!==t.index;if(e.getChangePointForSync(i)){const i=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,mt.changeLineTool)({linkKey:o,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:i},positionPercents:e.positionPercents(),changes:{pricesChanged:a,indexesChanged:l}})}})),e.setPoints(t),e.updateAllViews((0,wi.sourceChangeEvent)(e.id())),this.lightUpdate()}startScrollTime(e){this._timeScale.startScroll(e),this._isTimeScrolling=!0,this.mainSeries().clearGotoDateResult()}scrollTimeTo(e){this._timeScale.scrollTo(e),this.recalculateAllPanes((0,wi.viewportChangeEvent)()),this.lightUpdate()}endScrollTime(){this._timeScale.endScroll(),this.lightUpdate(),this.recalcVisibleRangeStudies(Co.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction),this._isTimeScrolling=!1}startScrollPrice(e,t,i){e.startScrollPrice(t,i)}scrollPriceTo(e,t,i){e.scrollPriceTo(t,i),this.invalidate(this._paneInvalidationMask(e,ao.InvalidationLevel.Light))}endScrollPrice(e,t){e.endScrollPrice(t),this.invalidate(this._paneInvalidationMask(e,ao.InvalidationLevel.Light))}addCustomSource(e,t,i=Co.CustomSourceLayer.Foreground){
this._customSourcesMap.has(e)&&k_.logWarn(`Attempt to add the same custom source multiple time "${e}"`),k_.logNormal(`Adding custom source "${e}"`);const s=t(e,this);switch(i){case Co.CustomSourceLayer.Background:this._bgCustomSources.push(s);break;case Co.CustomSourceLayer.Foreground:this._fgCustomSources.push(s);break;case Co.CustomSourceLayer.Topmost:this._topmostCustomSources.push(s);break;default:throw new Error(`Unknown custom sources layer ${i}`)}this._allCustomSources.push(s),this._customSourcesMap.set(e,s),this.lightUpdate()}removeCustomSource(e){this._removeCustomSource(e),this.lightUpdate()}hasCustomSource(e){return this._customSourcesMap.has(e)}customSourceForName(e){return this._customSourcesMap.get(e)||null}customSourceName(e){let t=null;return this._customSourcesMap.forEach(((i,s)=>{i===e&&(t=s)})),t}customSources(e){switch(e){case Co.CustomSourceLayer.Background:return this._bgCustomSources;case Co.CustomSourceLayer.Foreground:return this._fgCustomSources;case Co.CustomSourceLayer.Topmost:return this._topmostCustomSources;default:return this._allCustomSources}}addMultiPaneSource(e){this._multiPaneSources.push(e),this._onMultipaneSourcesCollectionChanged.fire(),this.lightUpdate()}removeMultiPaneSource(e){const t=this._multiPaneSources.indexOf(e);-1===t?k_.logWarn("Attempt to remove multi-pane source which does not exist in the model"):(this._onMultipaneSourcesCollectionChanged.fire(),this._multiPaneSources.splice(t,1)),this.lightUpdate()}multiPaneSources(e){return this._multiPaneSources.filter((t=>!e.hasDataSource(t)))}onMultipaneSourcesCollectionChanged(){return this._onMultipaneSourcesCollectionChanged}rendererOptionsProvider(){return this._rendererOptionsProvider}magnet(){return this._magnet}priceAxisRendererOptions(){return this._rendererOptionsProvider.options()}priceScaleSlotsCount(){let e=0,t=0;this._panes.forEach((i=>{e=Math.max(i.leftPriceScales().length,e),t=Math.max(i.rightPriceScales().length,t)}));const i=e+t;if(ze.CheckMobile.any()){const e=(0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),t=e.priceScalePosition(this.mainSeries().priceScale());return("overlay"===t?e.rightPriceScales().length>0:"right"===t)?{left:0,right:1,totallySlots:i}:{left:1,right:0,totallySlots:i}}return{left:e,right:t,totallySlots:i}}dateTimeFormatter(){return this._dateTimeFormatter}dateFormatter(){return this._dateFormatter}timeFormatter(){return this._timeFormatter}isUnmergeAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return(0,n.ensureNotNull)(this.paneForSource(e)).dataSources().filter(this._unmergeAvailable,this).length>1}isMergeDownAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;const t=this.paneForSource(e),i=this.panes().filter((e=>e.mode()===zi.PaneMode.Regular));return t!==i[i.length-1]}isMergeUpAvailableForSource(e){if(!this._unmergeAvailable(e))return!1;return this.paneForSource(e)!==this.panes().filter((e=>e.mode()===zi.PaneMode.Regular))[0]}isPriceScaleVisible(e){const t=e.mainSource();if(!t)return!1;const i=(0,
n.ensureNotNull)(this.paneForSource(t)),s=i.priceScalePosition(e);if("overlay"===s)return!0;const o=i.priceScaleIndex(e,s),r=this.priceScaleSlotsCount()[s];return void 0!==o&&o<r}getStudyShiftColorStartOffset(){return this._studyShiftColorStartOffset}setStudyShiftColorStartOffset(e){this._studyShiftColorStartOffset=e}sessions(){return(0,n.ensureNotNull)(this._sessions)}createSessions(e){if(null===this._sessions){const t=function(e){const t=new ic(e);return(0,h.applyDefaultsOverrides)(t.childs().sessionHighlight,void 0,!1,"sessions"),t.removeDuplicateProperties(),t}(this.mainSeries().symbolInfoWV().weakReference());this._sessions=new sc((async()=>{const s=await Promise.all([i.e(8736),i.e(6025),i.e(9378),i.e(1485),i.e(5456),i.e(7539)]).then(i.bind(i,52973));return this.addCustomSource("sessions",((i,o)=>{const n=new s.Sessions(i,o,t,e);return n.start(),n}),Co.CustomSourceLayer.Background),this.customSourceForName("sessions")})(),this,t)}}createPrePostMarket(e){this.addCustomSource("prePostMarket",((t,i)=>new Rd(t,i,e)))}createInactivityGaps(){this.addCustomSource("inactivityGaps",((e,t)=>new M_(e,t)))}inactivityGaps(){if(!l.enabled("inactivity_gaps"))throw new Error("inactivity_gaps featureset is not enabled");return(0,n.ensureNotNull)(this._inactivityGapsWatchedValue)}setInactivityGapsSession(e){(0,n.ensureNotNull)(this.customSourceForName("inactivityGaps")).setSession(e||"session")}watermarkSource(){return this._watermarkSource}watermarkContentProvider(){return P_.getInstance().provider()}studiesColorRotatorFactory(){return this._studyColorRotatorFactory}replayStatus(){return this._replayStatus}setReplayStatus(e){this._replayStatus.setValue(e)}isInReplay(){return this._mainSeries.isInReplay()}getSymbolString(){return this._mainSeries.getSymbolString()}interval(){return this._mainSeries.interval()}onInReplayStateChanged(){return new ae.Delegate}switchToReplay(e,t){0}switchToRealtime(){0}canChangeResolution(e){return this._mainSeries.canChangeResolution(e)}canChangeSymbol(e){return this._mainSeries.canChangeSymbol(e)}onReplayModified(){return(0,n.assert)(!1,"Replay not implemented"),this._mainSeries.onReplayModified()}mainSeriesScaleRatioProperty(){return this._mainSeriesScaleRatioProperty}mainSeriesScaleRatioPropertyOnChanged(){this._mainSeriesScaleRatioProperty.fireChanged()}getThemeNameIfStdTheme(){const e=this.sessions().properties(),t=this.properties(),i=this.mainSeries().properties();return e.allThemePropertiesAreDefault($s.StdTheme.Light)&&t.allThemePropertiesAreDefault($s.StdTheme.Light)&&i.allThemePropertiesAreDefault($s.StdTheme.Light)?$s.StdTheme.Light:e.allThemePropertiesAreDefault($s.StdTheme.Dark)&&t.allThemePropertiesAreDefault($s.StdTheme.Dark)&&i.allThemePropertiesAreDefault($s.StdTheme.Dark)?$s.StdTheme.Dark:null}theme(){return{chartProperties:this.properties().themeState(),sessions:this.sessions().properties().themeState(),mainSourceProperties:this.mainSeries().properties().themeState(),version:this.version()}}template(){return{chartProperties:this.properties().template(),
sessions:this.sessions().properties().template(),mainSourceProperties:this.mainSeries().properties().template(),version:this.version()}}onChartThemeLoaded(){return this._chartThemeLoaded}chartThemeLoaded(){this._chartThemeLoaded.fire()}async colorStudiesPropertiesReady(){this._recalcColorStudiesImpl(this._recalcVRStudiesParams);const e=this.allStudies(!0).filter((e=>e.metaInfo().inputs.filter(Ts.isStudyInputDependsOnChartColors).length>0));await Promise.all(e.map((e=>e.propertiesPatched())))}state(e){const{withData:t,skipLineToolsFromOtherSymbols:i,skipLineTools:s}=e,o=this.publishedChartsTimelineSource(),n=this.properties().childs(),r=n.tradingProperties.state(),a={panes:this._panes.map((t=>t.state({...e,includeSources:!0}))),timeScale:this._timeScale.state(t),chartProperties:{paneProperties:n.paneProperties.state(["horzGridProperties.style","vertGridProperties.style"]),scalesProperties:n.scalesProperties.state(),publishedChartsTimelineProperties:o?o.state(t):void 0,chartEventsSourceProperties:n.chartEventsSourceProperties?.state(),tradingProperties:r,priceScaleSelectionStrategyName:n.priceScaleSelectionStrategyName.value(),inactivityGaps:n.inactivityGaps.value()},sessions:this.sessions().state(t),version:this.version(),timezone:this.timezone(),shouldBeSavedEvenIfHidden:this._shouldBeSavedEvenIfHidden,linkingGroup:this._linkingGroupIndex.value()};return s||(a.lineToolsGroups=this.lineToolsGroupModel().state(i)),a}isInRestoreState(){return this._restoringState}restoreState(e,t,i){vh.instance(this).reset();const s={};if(!e.panes)return void k_.logDebug("ChartModel.restoreState: invalid state");if(!Array.isArray(e.panes))return void k_.logDebug("ChartModel.restoreState: invalid state");if(e.panes.length<1)return void k_.logDebug("ChartModel.restoreState: invalid state");this._restoringState=!0;for(const e of this._barsMarksSources)this.detachSource(e);if(this._shouldBeSavedEvenIfHidden=e.shouldBeSavedEvenIfHidden??!0,e.chartProperties&&!e.chartProperties.timezone&&(e.chartProperties.timezone=e.timezone),e.chartProperties){const i=(0,h.factoryDefaults)("chartproperties").scalesProperties;(0,tt.merge)(i,e.chartProperties.scalesProperties),!("showLastValue"in i)||"showSeriesLastValue"in i||"showStudyLastValue"in i||(i.showSeriesLastValueProperty=i.showLastValue,i.showStudyLastValueProperty=i.showLastValue),"showSeriesLastValue"in i&&(s.showSeriesLastValueProperty=!0),"showStudyLastValue"in i&&(s.showStudyLastValueProperty=!0),(!this.isSnapshot()&&!this.readOnly()&&"showCurrency"in i||"showUnit"in i)&&((0,Be.migrateShowCurrencyAndShowUnitProperties)(i.showCurrency,i.showUnit),delete i.showCurrency,delete i.showUnit);{const{paneProperties:t}=e.chartProperties;t.vertGridProperties=t.vertGridProperties||(0,tt.clone)(t.gridProperties),t.horzGridProperties=t.horzGridProperties||(0,tt.clone)(t.gridProperties),"backgroundType"in t||(t.backgroundType=co.ColorType.Solid),"separatorColor"in t||(t.separatorColor=(0,L.getThemedColor)("color-chart-page-bg")),this._properties.childs().paneProperties.mergeAndFire(t)}
this._properties.childs().scalesProperties.mergeAndFire(i),e.chartProperties.timezone&&this._properties.childs().timezone.setValue(e.chartProperties.timezone),e.chartProperties.chartEventsSourceProperties&&this._properties.hasChild("chartEventsSourceProperties")&&this._properties.childs().chartEventsSourceProperties.mergeAndFire(e.chartProperties.chartEventsSourceProperties),e.chartProperties.tradingProperties&&this._properties.hasChild("tradingProperties")&&(void 0===e.chartProperties.tradingProperties.horizontalAlignment&&(e.chartProperties.tradingProperties.horizontalAlignment=(o=e.chartProperties.tradingProperties.lineLength)<=40?Co.TradedGroupHorizontalAlignment.Right:o>=60?Co.TradedGroupHorizontalAlignment.Left:Co.TradedGroupHorizontalAlignment.Center),this._properties.childs().tradingProperties.mergeAndFire(e.chartProperties.tradingProperties)),this._timeScale.restoreState(e.timeScale,t),this._updateDateTimeFormatter()}var o;if(e.timeScale&&this._timeScale.restoreState(e.timeScale,t),!this.readOnly()){const t=this._getExceedingChildStudies(e.panes);if(t.length){for(let i=e.panes.length-1;i>=0;--i){const s=e.panes[i];for(let e=s.sources.length-1;e>=0;--e){const i=s.sources[e];~t.indexOf(i)&&s.sources.splice(e,1)}s.sources.length||s.mode!==zi.PaneMode.Regular||e.panes.splice(i,1)}0}}const r=e.version||0,a=e.panes;let l="_seriesId",c=1;for(const e of a){const t=e.sources.find((e=>"MainSeries"===e.type));if(t){l=t.id,t.state&&(c=t.state.style);break}}const d=!0,u=a[0];this.panes()[0].restoreState({state:u,withData:t,version:r,seriesId:l,settingsMigration:s,contentOverrides:i,restoreSilently:d,reason:2,targetSeriesStyle:c}),this.panes()[0].mainDataSource()||this.removePane(this.panes()[0]);let _=1;for(let o=1;o<e.panes.length;o++){const n=e.panes[o];if(0===n.sources.length&&(n.mode??zi.PaneMode.Regular)===zi.PaneMode.Regular){k_.logWarn("Empty pane detected - restoring is skipped. idx="+o+", state="+JSON.stringify(n));continue}const a=this.panes()[_]||this.createPane();a.restoreState({state:n,withData:t,version:r,seriesId:l,settingsMigration:s,contentOverrides:i,restoreSilently:d,reason:2,targetSeriesStyle:c}),a.mainDataSource()||a.mode()!==zi.PaneMode.Regular?_+=1:this.removePane(a)}u.isCollapsed&&this._panes[0].collapsed().setValue(!0),this._invalidateBarColorerCaches();const p=this.dataSources();let m=0;for(let e=0;e<p.length;e++){const t=p[e];(0,zs.isLineTool)(t)&&(m++,t.calcIsActualSymbol())}this.updateTimeScaleBaseIndex(),this.recalculateAllPanes((0,wi.globalChangeEvent)()),this.fullUpdate(),this.syncLollipopSources();const g=(0,n.ensureNotNull)(this.mainPane());for(const e of this._barsMarksSources)this.detachSource(e),g.addDataSource(e,this._mainSeries.priceScale(),!0);let f=Fl.TVLocalStorage.getItem("linetools_limit")||1e3;return window.is_authenticated&&window.user&&window.user.settings&&(f=window.user.settings.linetools_limit||f),e.sessions&&this.sessions().restoreState(e.sessions,t),e.lineToolsGroups&&(this._lineToolsGroupModel=wd.fromState(this,e.lineToolsGroups)),m>f&&m%100==0?{
lines_limit_exceeded:!0,line_tools_count:m}:(this.panes().forEach((e=>this._dataSourceCollectionChanged.fire(e))),this._lineToolsGroupModel.fireChangedAll(),this._linkingGroupIndex.setValue(e.linkingGroup??null),this._restoringState=!1,{})}shouldBeSavedEvenIfHidden(){return this._shouldBeSavedEvenIfHidden}setShouldBeSavedEvenIfHidden(e){this._shouldBeSavedEvenIfHidden=e}externalTimeStamp(e){const t=this.mainSeries().syncModel();return this.timeScale().points().roughTime(e,t&&t.projectTime.bind(t))}syncLollipopSources(){this._lollipopSourcesWatcherLoader?.callFunction((()=>{null!==this._lollipopSourcesWatcher&&this._lollipopSourcesWatcher.syncSources()}))}restoreChartEvents(e){this._lollipopSourcesWatcherLoader?.callFunction((()=>{null!==this._lollipopSourcesWatcher&&this._options.chartEventsEnabled&&this._lollipopSourcesWatcher.restoreChartEvents(e)}))}recalcVisibleRangeStudies(e){if(this._recalcVRStudiesParams.reasons.add(e),this._mainSeries.isStarted()&&this._mainSeries.isCompleted()){const t=(0,n.ensureDefined)(N_.get(e)).adapter,i=Math.min(...Array.from(this._recalcVRStudiesParams.reasons).map((e=>(0,n.ensureDefined)(N_.get(e)))).filter((e=>e.adapter===t)).map((e=>e.timeout)));(0,n.ensureDefined)(this._recalcVisibleRangeStudiesImplDebouncedByAdapter.get(t)?.get(i))()}else this._recalcVisibleRangeStudiesImpl(this._recalcVRStudiesParams)}recalcColorStudies(e){this._recalcColorStudiesParams.force=this._recalcColorStudiesParams.force||Boolean(e),this._recalcColorStudiesImplDebounced()}recalcStudyBasedLineTools(){this.dataSources().forEach((e=>{(0,Us.isStudyLineTool)(e)&&e.recalcStudyIfNeeded()}))}alertsWatcher(){return this._alertsWatcher}alertsCollection(){return this._alertsCollection.readonly()}showLegend(){return this._showLegendProperty}id(){return this._id}selectPointMode(){return this._crossHairSelectPointMode}cancelRequestSelectPoint(){this._crossHairSource.cancelRequestSelectPoint()}requestSelectPoint(e){return this._crossHairSource.requestSelectPoint(e)}onPointSelected(){return this._crossHairSource.onPointSelected()}recalculatePriceRangeOnce(){const e=this.mainSeries();for(const t of this._panes)for(const i of t.priceDataSources())i.symbolSource()===e&&i.disablePriceRangeReady()}invalidate(e){this._invalidateHandler?.(e)}appliedTimeFrame(){return this._appliedTimeFrame.appliedTimeFrame()}barsMarksSources(){return this._barsMarksSources}createSyncPoint(e,t){return(0,s_.getDefault2Lazy)(this._syncPointCache,e.uniqueId,t.uniqueId,(()=>new xd(e,t)))}isAutoSaveEnabled(){return this._isAutoSaveEnabled}linkingGroupIndex(){return this._linkingGroupIndex}studyAwareDefaultRightOffset(){return this._timeScale.usePercentageRightOffset().value()?this._timeScale.percentsToBarIndexLength(this.studyAwareDefaultRightOffsetPercentage()):Math.max(this._timeScale.defaultRightOffset().value(),this._cachedStudiesMaxOffset)}studyAwareDefaultRightOffsetPercentage(){
return this._timeScale.usePercentageRightOffset().value()?Math.max(this._timeScale.defaultRightOffsetPercentage().value(),this._timeScale.barIndexLengthToPercents(this._cachedStudiesMaxOffset)):this._timeScale.barIndexLengthToPercents(this.studyAwareDefaultRightOffset())}clearAllStudies(){this.dataSources().forEach((e=>e.clearData?.()))}setTimeScaleAnimation(e,t){const i=ao.InvalidationMask.light(),s=this._timeScale;i.setTimeScaleAnimation(e,t??s.width()-s.indexToCoordinate(s.baseIndex())),this.invalidate(i)}stopTimeScaleAnimation(){this._timeScale.endScroll();const e=ao.InvalidationMask.light();e.stopTimeScaleAnimation(),this.invalidate(e)}lollipopSourcesOptions(){const e=this._options;return{chartEventsEnabled:!this._options.isSnapshot&&this._options.chartEventsEnabled,esdEnabled:e.esdEnabled,newsNotificationsEnabled:e.newsNotificationsEnabled,continuousContractSwitchesEnabled:e.continuousContractSwitchesEnabled,futuresContractExpirationEnabled:e.futuresContractExpirationEnabled,latestUpdatesEnabled:e.latestUpdatesEnabled}}onSymbolIntervalChanged(){return this._symbolIntervalChanged}setPriceAutoScale(e,t,i){e.setPriceAutoScale(t,i),this.invalidate(this._paneInvalidationMask(e,ao.InvalidationLevel.Light))}calculateDefaultTags(){return this.dataSources().reduce(((e,t)=>(t.tags&&e.push(...t.tags()),e)),[])}setActivationChartFloatingTooltipHint(e){this.isSnapshot()||null!==e&&e!==this.mainSeries()&&(!(0,Ws.isStudy)(e)||(0,Ws.isESDStudy)(e))||this._activationChartFloatingTooltipHint.setValue(!0)}activationChartFloatingTooltipHint(){return this._activationChartFloatingTooltipHint.readonly()}setChartFloatingTooltipVisible(e){this._chartFloatingTooltipVisible.setValue(e),this._crossHairSource.updateAllViews((0,wi.crosshairMoveEvent)()),this.lightUpdate()}chartFloatingTooltipVisible(){return this._chartFloatingTooltipVisible.readonly()}async withoutLineToolsSyncAction(e){try{this._lineToolsSyncBlock++,await e()}finally{this._lineToolsSyncBlock--}}symbolAliasService(){return this._symbolAliasService}_initAlertsList(){throw new Error("Not implemented")}_updateStudiesMaxOffset(){const e=Math.max(...this.allStudies().map((e=>e.maxOffset().value())));this._cachedStudiesMaxOffset=e;const t=this._timeScale.rightOffset();if(t<0)return;if(e<=t)return;const i=this._timeScale.logicalRange();i?this._timeScale.zoomToBarsRange(i.left(),this._timeScale.baseIndex()+Math.max(this._timeScale.rightOffset(),e)):this._timeScale.setRightOffset(Math.max(t,e))}_updateBaseIndex(e,t){const i=this._timeScale,s=i.baseIndex(),o=i.logicalRange();if(null!==o&&t){const t=o.contains(s),n=e-s,r=t?null:i.rightOffset()-n;if(!this._options.shiftVisibleRangeOnNewBar&&t){const e=i.width()/i.barSpacing(),t=e/(e+n),s=Math.max(i.minBarSpacing(),i.barSpacing()*t);i.setBarSpacing(s)}null!==r&&i.setRightOffset(r)}i.setBaseIndex(e)}async _createLollipopSourcesWatcher(){}_updateDateTimeFormatter(){const e=be.dateFormatProperty.value(),t=this.onWidget()?void 0:Md.withWeekdayProperty.value();if(this._dateFormatter=new bd.DateFormatter(e,t),
this.mainSeries().isDWM())this._dateTimeFormatter=new bd.DateFormatter(e,t),this._timeFormatter=new Uh.TimeFormatter((0,jh.getHourMinuteFormat)(we.timeHoursFormatProperty.value()));else{const i=Re.Interval.parse(this.mainSeries().interval()),s=(0,jh.getTimeFormatForInterval)(i,we.timeHoursFormatProperty.value());this._dateTimeFormatter=new Sd.DateTimeFormatter({dateFormat:e,withWeekday:t,timeFormat:s,dateTimeSeparator:"   "}),this._timeFormatter=new Uh.TimeFormatter(s)}}_invalidationMaskForSource(e,t=ao.InvalidationLevel.Light){if(e===this.crosshairSource())return ao.InvalidationMask.cursor();if(this._watermarkSource===e)return this._paneInvalidationMask((0,n.ensureNotNull)(this.paneForSource(this.mainSeries())),t);if(-1!==this._allCustomSources.indexOf(e)){const e=new ao.InvalidationMask;return e.invalidateAll(t),e}if(!(0,Po.isDataSource)(e))return null;if(e.isMultiPaneEnabled())return new ao.InvalidationMask(t);const i=this.paneForSource(e);return null!==i?this._paneInvalidationMask(i,t):null}_paneInvalidationMask(e,t=ao.InvalidationLevel.Light){const i=new ao.InvalidationMask,s=this._panes.indexOf(e);return i.invalidateAllPane(s,t),i}_invalidationMaskForSourcePriceScale(e,t=ao.InvalidationLevel.Light){if(!(0,Po.isDataSource)(e))return new ao.InvalidationMask(t);const i=this.paneForSource(e);if(null===i)return null;let s=e.priceScale();if(null===s)return null;const o=this._panes.indexOf(i);let n=i.priceScalePosition(s);if("overlay"===n){const e=this._panes[o].defaultPriceScale();s=e,n=i.priceScalePosition(e)}const r=i.priceScaleIndex(s,n);if(void 0===r)return null;const a=new ao.InvalidationMask;return a.invalidatePriceScale(o,n,r,t),a}_removeCustomSource(e){const t=this._customSourcesMap.get(e);if(void 0===t)return void k_.logWarn(`Attempt to remove custom source which does not exist in the model - "${e}"`);k_.logNormal(`Removing custom source "${e}"`),this.selectionMacro((e=>{e.removeSourceFromSelection(t)})),this._hoveredSource===t&&this.setHoveredSource(null),this._customSourceBeingMoved===t&&this.setMovingCustomSource(null,null);const i=E_(this._bgCustomSources,t),s=E_(this._fgCustomSources,t),o=E_(this._topmostCustomSources,t),r=E_(this._allCustomSources,t);(0,n.assert)(i||s||o,"Source should be presented in one of the layers"),(0,n.assert)(r,"Source should be presented in the array"),this._customSourcesMap.delete(e),t.destroy()}_updateShowLegendProperty(){const e=this._properties.childs().paneProperties.childs().legendProperties.childs().showLegend,t=this._showLegendProperty;if(e.value())t.setValue(!0);else{for(const e of this._panes){let i=0;for(const s of e.priceDataSources())if(null!==s.statusView()&&(i++,i>=2))return void t.setValue(!1)}t.setValue(!0)}}_pointToPercentPosition(e,t){return{x:e.x/this._timeScale.width(),y:e.y/(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).priceScale()).height()}}_percentPositionToPoint(e,t){const i=e.x*this._timeScale.width(),s=e.y*(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).priceScale()).height();return new Vt.Point(i,s)}
_recalcVisibleRangeStudiesImpl(e){if(!this._mainSeries.isStarted()||!this._mainSeries.isCompleted())return void this._visibleRangeStudiesInputs.setValue(null);if(this.timeScale().isEmpty())return;const t=this.timeScale().visibleBarsStrictRange();if(null===t)return;const i=this._mainSeries.bars(),s=i.search(t.firstBar(),dd.PlotRowSearchMode.NearestRight),o=i.search(t.lastBar(),dd.PlotRowSearchMode.NearestLeft),n=i.lastIndex(),r=s?s.index:void 0,a=o?o.index:void 0,l=r===e.oldStartVisibleIndex,c=a===e.oldEndVisibleIndex,h=[Co.RecalcVisibleRangeStudiesReason.SeriesRestart,Co.RecalcVisibleRangeStudiesReason.SeriesCompleted,Co.RecalcVisibleRangeStudiesReason.StudyCreation].some((t=>e.reasons.has(t)));l&&c&&!h||(e.reasons.clear(),e.oldStartVisibleIndex=void 0!==r?r:NaN,e.oldEndVisibleIndex=void 0!==a?a:NaN,this._visibleRangeStudiesInputs.setValue({firstVisibleBarTime:1e3*(s?.value[0]??0),lastVisibleBarTime:1e3*(o?.value[0]??0),subscribeRealtime:o?.index===n}))}_recalcColorStudiesImpl(e){const t=this.backgroundColorAtYPercentFromTop(.5),i=this.dark().value()?Rt.colorsPalette["color-cold-gray-200"]:Rt.colorsPalette["color-cold-gray-900"],s=t===e.oldBgColor,o=i===e.oldFgColor;if(s&&o&&!e.force)return;e.force=!1,e.oldBgColor=t,e.oldFgColor=i;const n=e.studies??this.priceDataSources();e.studies=void 0;for(const e of n)if((0,Ws.isStudy)(e)){const s=e.metaInfo().inputs.filter(Ts.isStudyInputDependsOnChartColors),o=e.properties().childs().inputs;s.forEach((e=>{const s=e.id===Ts.ChartColorDependentStudyInputNames.FgColor?i:t;o.childs()[e.id].setValueSilently(s)})),s.length>0&&o.fireChanged()}}_getAllSources(e,t=W_){const i=[];for(const s of this._panes){const o=t(s);for(const t of o)e(t)&&i.push(t)}return i}_invalidateBarColorerCaches(){this.mainSeries().invalidateBarColorerCache()}_addAlertLabelToChart(e){throw new Error("Not implemented")}_removeAlertLabelFromChart(e){throw new Error("Not implemented")}_removeAllAlertLabelsFromChart(){throw new Error("Not implemented")}_updateTimeScale(e){const{index:t,zoffset:i,values:s,indexDiffs:o,baseIndex:n,marks:r,clearFlag:a,clearTickMarks:l}=e;if(a){this._timeScale.reset();for(const e of this.dataSources())e.clearData?.()}if(o.length>0)for(const e of this.dataSources())e.moveData?.(o);const c=this._timeScale.indexToTimePoint(this._timeScale.baseIndex()),h=this._timeScale.canNormalize();this._timeScale.update(t,i,s,r,l||!1);const d=this._timeScale.points().range().value();let u="ChartModel.prototype._updateTimeScale("+t+","+i+","+s.length+","+o.length+","+r.length+","+a+")";if(u+="TimeScale: {first:"+(d?.firstIndex??null)+",last:"+(d?.lastIndex??null)+"}",null===n){this._timeScale.resetBaseIndex();const e=this._timeScale.rightOffset();e<0?this._timeScale.setRightOffset(this.studyAwareDefaultRightOffset()):this._timeScale.setRightOffset(Math.max(e,this._cachedStudiesMaxOffset))}else if(void 0!==n){const e=this._timeScale.indexToTimePoint(n),t=null!==c&&null!==e&&e>c;this._updateBaseIndex(n,t)}if(k_.logDebug(u),!h&&h!==this._timeScale.canNormalize())for(const e of this.dataSources())!(0,
zs.isLineTool)(e)||e.isFixed()||e.isSourceHidden()||e.processHibernate();for(const e of this.dataSources())e.updateAllViews({type:"data-source-change",sourceId:e.id(),clearData:!0});this.recalculateAllPanes((0,wi.globalChangeEvent)()),this.lightUpdate()}_getAvailableCurrencies(){return!this.currencyConversionEnabled()||this.isSnapshot()?[]:(0,tt.isArray)(this._availableCurrenciesList)?this._availableCurrenciesList:(null!==this._availableCurrenciesList||(this._availableCurrenciesList=this.chartApi().availableCurrencies(),this._availableCurrenciesList.then((e=>{this._destroyed||(this._availableCurrenciesList=e,this.fullUpdate())})).catch((e=>{k_.logWarn(`An error occurred while getting currencies config: ${e}`)}))),[])}_getAvailableUnits(){return!this.unitConversionEnabled()||this.isSnapshot()?{}:this._availableUnitsObject instanceof Promise||null===this._availableUnitsObject?(null!==this._availableUnitsObject||(this._availableUnitsObject=this.chartApi().availableUnits(),this._availableUnitsObject.then((e=>{this._destroyed||(this._availableUnitsObject=e,this.fullUpdate())})).catch((e=>{k_.logWarn(`An error occurred while getting units config: ${e}`)}))),{}):this._availableUnitsObject}_getAvailablePriceSources(e){const t=this._availablePriceSourcesBySymbol.get(e);if(Array.isArray(t))return t;if((0,tt.isPromise)(t))return[];const i=this.chartApi().availablePriceSources(e);return this._availablePriceSourcesBySymbol.set(e,i),i.then((t=>{this._destroyed||(this._availablePriceSourcesBySymbol.set(e,t),this.fullUpdate())})).catch((e=>{k_.logWarn(`An error occurred while getting price sources config: ${e}`)})),[]}_clearAvailablePriceSources(){this._availablePriceSourcesBySymbol.clear()}_onSymbolIntervalChanged(){this._symbolIntervalChanged.fire()}_getBackgroundColor(e){const t=this._properties.childs().paneProperties.childs();if(t.backgroundType.value()===co.ColorType.Gradient){const i=t.backgroundGradientStartColor.value(),s=t.backgroundGradientEndColor.value();return e?i:s}return t.background.value()}_getBackgroundCounterColor(){const e=this.backgroundColor().value();return"black"===(0,Nt.rgbToBlackWhiteString)((0,Nt.parseRgb)(e),150)?"white":"black"}_updateBackgroundColor(){this._backgroundColor.setValue(this._getBackgroundColor()),this._backgroundTopColor.setValue(this._getBackgroundColor(!0))}_syncCrosshair(e){if(!this._isSettingsExternalPosition){const t=this._undoModel.mainSeries(),i=t.syncModel(),s=this._undoModel.crosshairSource(),o=s.pane;if(null!==i&&null!==o){const n={timeStamp:this._timeScale.points().roughTime(s.index,i.projectTime.bind(i)),syncSourceTarget:i.syncSourceTarget()};o.mainDataSource()===t&&(n.price=s.price,n.symbol=t.symbol()),this._undoModel.syncCrosshair(n,e)}this._phantomSourceContainer.onCursorPositionUpdated()}}_gotoTimeImpl(e,t){const i=this.timeScale(),s=this.mainSeries();let o;if(void 0!==e){if(this._scrollingState&&this._scrollingState.deferred.reject(),o=(0,me.createDeferredPromise)(),!s.isDWM()){const t=s.symbolInfo();if(null!==t){const i=(0,
n.ensureNotNull)(this.timezoneExceptExchange().value()),o=(0,Ce.cal_to_utc)((0,Ce.get_timezone)(i),new Date(e)),r=(0,Jd.createTimeToBarTimeAligner)(s.interval(),t)(o);e=(0,Ce.utc_to_cal)((0,Ce.get_timezone)(i),r).getTime()}}this._scrollingState={targetDate:e,deferred:o,targetPointAlignment:t.targetPointAlignment,autoscaleAfterScroll:t.autoscaleAfterScroll}}else{if(!this._scrollingState)return k_.logError("scrollTo called without an argument"),Promise.reject();e=this._scrollingState.targetDate,o=this._scrollingState.deferred}if(void 0===i.tickMarks().minIndex)return o.resolve(void 0),o.promise;this.stopTimeScaleAnimation();let r=((e,o)=>{if((e=>(0,n.ensureNotNull)(i.tickMarks().indexToTime((0,n.ensureDefined)(i.tickMarks().minIndex))).valueOf()-e)(o)<0){let r=i.tickMarks().nearestIndex(o);const a=s.bars().lastIndex();if(null===a)return"no_data";r=Math.min(r,a);let l=(0,n.ensureNotNull)(i.tickMarks().indexToTime(r)).valueOf();for(;l<o&&r<a;)r++,l=(0,n.ensureNotNull)(i.tickMarks().indexToTime(r)).valueOf();if((0,n.ensureNotNull)(i.visibleBarsStrictRange()).contains(r)&&!t.alignIfTargetPointIsVisible)return"in_visible_range";if("none"!==e){const t=i.width();if("left"===e)i.scrollToBar(r);else{const e=i.indexToCoordinate(r),s=i.coordinateToFloatIndex(e-t/2);i.scrollToBar(s)}}return{timestamp:(0,n.ensureNotNull)(i.indexToTimePoint(r))}}return"no_data"})(this._scrollingState.targetPointAlignment,this._scrollingState.targetDate);if("no_data"===r){const t=(0,n.ensureDefined)(i.tickMarks().minIndex),o=(0,n.ensureNotNull)(i.visibleBarsStrictRange()),a=o.lastBar()-o.firstBar();if(s.requestMoreDataAvailable()){const t=i.tickMarks().estimateLeft(e);i.requestMoreHistoryPoints(Math.ceil(t+a/2))}else i.zoomToBarsRange(t-a/2,t+a/2),r={timestamp:(0,n.ensureNotNull)(i.indexToTimePoint(t)),eod:!0}}if("no_data"!==r&&"in_visible_range"!==r){if(this._scrollingState.autoscaleAfterScroll){const e=(0,n.ensureNotNull)(i.visibleBarsStrictRange());for(const t of this.panes()){for(const i of t.leftPriceScales())i.recalculatePriceRange(e);for(const i of t.rightPriceScales())i.recalculatePriceRange(e)}}this.fullUpdate(),this._scrollingState=null,o.resolve(r)}return"in_visible_range"===r&&(o.reject("already visible"),this._scrollingState=null),o.promise}_setCorrectedPositionToCrosshair(e,t,i){this.crosshairSource().setPosition(e,t,i)}_onSymbolSourceCollectionChanged(e){this._clearAvailablePriceSources(),this._recalcAdjustForDividendsAvailability(),this._recalcAllowedAdjustment(),this._symbolSourceCollectionChanged.fire(e)}_onPriceSourcesCollectionChanged(e){this._panes.some((e=>e.hasDataSource(this._mainSeries)))&&(this._studiesWV.setValue(this.allStudies()),this._studiesExcludeInternalWV.setValue(this.allStudies(!0)))}_unmergeAvailable(e){return e===this._mainSeries||(0,Ws.isStudy)(e)&&!e.isLinkedToSeries()&&e.showInObjectTree()}_getExceedingChildStudies(e){let t=[];for(let i=0;i<e.length;++i)t=t.concat(e[i].sources||[]);let i=0;const s=[],o={};let n=0,r=1e6;for(;t.length&&--r;){const e=t[n]
;(e.ownerSource&&o[e.ownerSource]||!e.ownerSource)&&(o[e.id]=e,t.splice(t.indexOf(e),1),e.ownerSource&&(0,wt.isStudyState)(e)&&e.state&&e.state.isChildStudy&&++i>1&&s.push(e)),n=(n+1)%t.length}return s}_sendTo(e,t){const i=new Map;e.forEach((e=>{const t=this.paneForSource(e);if(!t)return;const s=this._panes.indexOf(t);i.has(s)||i.set(s,[]),i.get(s)?.push(e)}));for(const[e,s]of i.entries())t(this._panes[e],s);this.fullUpdate()}_initialiseInactivityGaps(){if(!l.enabled("inactivity_gaps"))return;this.createInactivityGaps();const e=async e=>{const t=this.customSourceForName("inactivityGaps");e?t.start():t.stop()};if(null===this._inactivityGapsWatchedValue){const t=this.properties().childs().inactivityGaps;this._inactivityGapsWatchedValue=(0,ye.convertPropertyToWatchedValue)(t),this._inactivityGapsWatchedValue.subscribe((t=>{e(t)})),e(t.value())}}_getWidgetPane(e,t){throw new Error("Not implemented")}}var U_=i(14715);class j_ extends st.UndoCommand{constructor(e,t,i,s){super(s,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._model=i,this._id=e.id(),this._targetSharingMode=t,this._originSharingMode=e.sharingMode().value()}redo(){const e=this._model.dataSourceForId(this._id);e&&(e.share(this._targetSharingMode),0!==this._targetSharingMode&&0===this._originSharingMode&&(e.linkKey().setValue((0,fe.randomHash)()),this._model.copyToOtherCharts([e],!1)))}undo(){const e=this._model.dataSourceForId(this._id);e&&(e.share(this._originSharingMode),0===this._originSharingMode&&((0,mt.removeLineTool)({withUndo:!1,model:this._model,symbol:e.symbol(),linkKey:(0,n.ensureNotNull)(e.linkKey().value()),sourceTitle:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e),lineToolState:e.state(!1),unlink:!0}),e.linkKey().setValue(null)))}}const G_=new dt.TranslatedString("zoom",a.t(null,void 0,i(91084)));class q_ extends st.UndoCommand{constructor(e,t,i,s,o,n){super(G_),this._barSpacing=null,this._rightBarsOffset=null,this._leftBarsOffset=null,this._priceMode=null,this._model=e,this._startBar=t,this._endBar=i,this._startPrice=s,this._endPrice=o,this._pane=n}redo(){const e=(0,n.ensureNotNull)(this._model.timeScale().visibleBarsStrictRange());this._leftBarsOffset=e.firstBar()-this._startBar,this._rightBarsOffset=e.lastBar()-this._endBar,this._barSpacing=this._model.timeScale().barSpacing(),this._priceMode=this._pane.defaultPriceScale().mode(),this._model.zoomToViewport(this._startBar,this._endBar,this._startPrice,this._endPrice,this._pane)}undo(){const e=this._model.timeScale(),t=this._pane.defaultPriceScale(),i=(0,n.ensureNotNull)(e.visibleBarsStrictRange());e.setBarSpacing((0,n.ensureNotNull)(this._barSpacing)),e.zoomToBarsRange(i.firstBar()+(0,n.ensureNotNull)(this._leftBarsOffset),i.lastBar()+(0,n.ensureNotNull)(this._rightBarsOffset)),t.setMode((0,n.ensureNotNull)(this._priceMode)),t.recalculatePriceRange((0,n.ensureNotNull)(e.visibleBarsStrictRange())),this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),this._model.lightUpdate()}}const $_=(0,
ne.getLogger)("Chart.ChartUndoModel"),K_=new dt.TranslatedString("zoom",a.t(null,void 0,i(91084)));class Y_ extends st.UndoCommand{constructor(e,t,i){super(K_),this._baseCmd=e,this._zoomStack=t,this._inOut=i}undo(e){if(this._inOut){if(this._baseCmd!==this._zoomStack.head())return void $_.logDebug("zoom stack inconsistency");this._baseCmd.undo(e),this._zoomStack.pop()}else this._baseCmd.redo(e),this._zoomStack.push(this._baseCmd)}redo(e){if(this._inOut)this._baseCmd.redo(e),this._zoomStack.push(this._baseCmd);else{if(this._baseCmd!==this._zoomStack.head())return void $_.logDebug("zoom stack inconsistency");this._baseCmd.undo(e),this._zoomStack.pop()}}}const Z_=new dt.TranslatedString("stop syncing drawing",a.t(null,void 0,i(3350)));class X_ extends st.UndoCommand{constructor(e,t){super(Z_,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._model=e,this._sourceId=t.id(),this._linkKey=t.linkKey().value()}redo(){(0,n.ensureNotNull)(this._model.dataSourceForId(this._sourceId)).linkKey().setValue(null)}undo(){(0,n.ensureNotNull)(this._model.dataSourceForId(this._sourceId)).linkKey().setValue(this._linkKey)}}const J_=new dt.TranslatedString("restore defaults",a.t(null,void 0,i(85815)));class Q_ extends st.UndoCommand{constructor(e,t,i=J_,s=!0){super(i,void 0,s),this._chartModel=e;const o=t.pathToRoot();this._targetObj=(0,Wa.isRootPath)(o)?o:t,this._state=t.state()}redo({chartWidgetCollection:e}){this._chartModel.restoreFactoryDefaults(this._getProperty(e))}undo({chartWidgetCollection:e}){this._getProperty(e).mergeAndFire(this._state),this._chartModel.mainSeries().onChartStyleChanged()}_getProperty(e){const t=this._targetObj;return"string"==typeof t?(0,Wa.propertyByPath)(e,t):t}}class ep extends Q_{constructor(e,t,i,s){super(e,t,i,s??!Wr.lineToolsDoNotAffectChartInvalidation)}redo(e){this._getProperty(e.chartWidgetCollection).child("intervalsVisibilities")?.mergeAndFire(v_.intervalsVisibilitiesDefaults),super.redo(e)}}const tp=new dt.TranslatedString("restore study defaults",a.t(null,void 0,i(96881)));class ip extends ep{constructor(e,t,i=tp){super(e,t.properties(),i,!0),this._studyId=t.id()}redo(e){super.redo(e),this._chartModel.recalcColorStudies(!0),this._patchProperties()}undo(e){super.undo(e),this._chartModel.recalcColorStudies(!0),this._patchProperties()}_patchProperties(){0}}function sp(e,t){return(0,yi.extractState)(e,t.map((e=>e.path)))}const op=new dt.TranslatedString("apply chart theme",a.t(null,void 0,i(68231)));class np extends st.UndoCommand{constructor(e,t,i){super(op),this._model=e,t.sessions&&(this._newSessionProps=i?t.sessions:sp(t.sessions,(0,yi.extractThemedColors)(ms.lightTheme.content.sessions,ms.darkTheme.content.sessions))),Th(t.mainSourceProperties.candleStyle),Th(t.mainSourceProperties.hollowCandleStyle),Th(t.mainSourceProperties.haStyle);const s=t;s.chartProperties=s.chartProperties??{paneProperties:{},scalesProperties:void 0};const o=s.chartProperties.paneProperties.gridProperties;s.chartProperties.paneProperties.vertGridProperties=s.chartProperties.paneProperties.vertGridProperties??o,
s.chartProperties.paneProperties.horzGridProperties=s.chartProperties.paneProperties.horzGridProperties??o;const n=this._model.properties().state().paneProperties.legendProperties;delete n.backgroundTransparency;const r=s.chartProperties.paneProperties;i&&(r.legendProperties={...r.legendProperties,...n});const a=(0,Al.default)((0,h.factoryDefaults)("chartproperties"));if(delete a.timezone,i){const e=a.paneProperties;e&&(delete e.topMargin,delete e.bottomMargin)}const l=(0,ge.deepExtend)({},a,t.chartProperties);this._newChartProps=i?l:sp(l,(0,yi.extractThemedColors)(ms.lightTheme.content.chartProperties,ms.darkTheme.content.chartProperties)),e.timeScale().preserveBarSpacing()&&"barSpacing"in this._newChartProps.scalesProperties&&delete this._newChartProps.scalesProperties.barSpacing,Ph(t.mainSourceProperties.lineStyle),Ph(t.mainSourceProperties.lineWithMarkersStyle),Ph(t.mainSourceProperties.steplineStyle);const c=(0,h.factoryDefaults)("chartproperties.mainSeriesProperties"),d=(0,ge.deepExtend)({},c,t.mainSourceProperties);i&&(delete d.visible,delete d.symbol,delete d.shortName,delete d.timeframe,delete d.interval,delete d.currencyId,delete d.unitId,delete d.sessionId,delete d.esdBreaksStyle),this._newSeriesProps=i?d:sp(d,(0,yi.extractThemedColors)(ms.lightTheme.content.mainSourceProperties,ms.darkTheme.content.mainSourceProperties)),this._oldChartProps=i?e.properties().state():e.properties().themeState(),this._oldSeriesProps=i?e.mainSeries().properties().state():e.mainSeries().properties().themeState(),this._oldSessionProps=i?this._model.sessions().properties().state():this._model.sessions().properties().themeState()}undo(){this._merge(this._oldChartProps,this._oldSeriesProps,this._oldSessionProps),this._model.mainSeries().onChartStyleChanged(),this._model.updateScales(),this._model.chartThemeLoaded()}redo(){this._merge(this._newChartProps,this._newSeriesProps,this._newSessionProps),this._model.mainSeries().onChartStyleChanged(),this._model.updateScales(),this._model.chartThemeLoaded()}_merge(e,t,i){const s=this._model;(0,yi.allowSavingDefaults)(!0);const o=s.properties(),n=s.mainSeries().properties(),r=s.sessions().properties();o.applyDefaultThemedProperties(k.watchedTheme.value()),o.mergeAndFire(e),o.saveDefaults(),"priceAxisProperties"in t&&s.mainSeries().priceScale().setMode({autoScale:t.priceAxisProperties?.autoScale,percentage:t.priceAxisProperties?.percentage,log:t.priceAxisProperties?.log,lockScale:t.priceAxisProperties?.lockScale}),n.applyDefaultThemedProperties(k.watchedTheme.value()),n.mergeAndFire(t),n.saveDefaults(),s.mainSeries().createPaneView(),s.mainSeries().invalidateBarStylesCache(),s.recalculateAllPanes((0,wi.globalChangeEvent)()),i&&(r.applyDefaultThemedProperties(k.watchedTheme.value()),r.loadThemeState(i),r.saveDefaults()),s.fullUpdate(),(0,yi.allowSavingDefaults)(!1)}}const rp=new dt.TranslatedString("change resolution",a.t(null,void 0,i(32829)));class ap extends xl{constructor(e,t,i){super(rp,e,function(e,t){let i;const s=(0,xt.isRangeStyle)(e.style()),o=Re.Interval.isRange(t)
;return!s&&o?i=11:s&&!o&&(i=(0,xt.getLastUsedStyle)()),{interval:t,style:i}}(e,t),i),this._resolution=t}canMerge(e){return e instanceof ap&&e._resolution===this._resolution&&super.canMerge(e)}_showFade(e,t){return!0}}class lp extends lt{constructor(){super(...arguments),this._firstRedo=!0}redo(){this._firstRedo||(0,it.muteLinkingGroup)(this._newValue,!0),(0,it.muteLinkingGroup)(this._oldValue,!0),super.redo(),this._firstRedo||(0,it.muteLinkingGroup)(this._newValue,!1),(0,it.muteLinkingGroup)(this._oldValue,!1),this._firstRedo=!1}undo(){(0,it.muteLinkingGroup)(this._newValue,!0),(0,it.muteLinkingGroup)(this._oldValue,!0),super.undo(),(0,it.muteLinkingGroup)(this._newValue,!1),(0,it.muteLinkingGroup)(this._oldValue,!1)}}var cp=i(91111);class hp extends st.UndoCommand{constructor(e,t,i){super(i),this._chartModel=e,this._stubDescriptor=(0,n.ensureNotNull)(t.getDescriptor())}redo(){this._chartModel.dataSourceForId(this._stubDescriptor.id)||this._chartModel.restoreStudyStub(this._stubDescriptor)}undo(){this._chartModel.removeStudyStub(this._stubDescriptor.id)}}class dp extends st.UndoCommand{constructor(e,t,i){super(i,void 0,!Wr.lineToolsDoNotAffectChartInvalidation),this._source=e,this._newState=t,this._oldState=e.properties().state()}redo(){this._source.applyTemplate(this._newState)}undo(){this._source.applyTemplate(this._oldState)}}var up=i(87911),_p=i(49470);const pp=new dt.TranslatedString("apply all chart properties",a.t(null,void 0,i(99551)));class mp extends st.UndoCommand{constructor(e){super(pp),this._trading=null,this._oldNoConfirmEnabled=null,this._oldShowOnlyRejectionNotifications=null,this._oldShowPricesWithZeroVolume=null,this._oldShowPricesWithSpread=null,this._oldOrderExecutedSoundEnabled=null,this._prevWatermarkPreferences=null,this._prevAlertLabelsPreferences=null,this._prevAlertNotificationsPreferences=null,this._model=e,this._trading=(0,_p.tradingService)(),null!==this._trading&&(this._oldNoConfirmEnabled=this._trading.noConfirmEnabled.value(),this._oldShowOnlyRejectionNotifications=this._trading.showOnlyRejectionNotifications.value(),this._oldShowPricesWithZeroVolume=this._trading.showPricesWith().zeroVolume.value(),this._oldShowPricesWithSpread=this._trading.showPricesWith().spread.value(),this._oldOrderExecutedSoundEnabled=this._trading.orderExecutedSoundParams.enabled.value()),this._defaultsPreferences=function(e,t,i=g_,s=!0){const o={timeScale:{defaultRightOffset:e.timeScale().rightOffsetDefaultValue(),defaultRightOffsetPercentage:e.timeScale().defaultRightOffsetPercentage().value(),usePercentageRightOffset:e.timeScale().usePercentageRightOffset().value()},mainSeries:{},sessions:{},paneProperties:{},scalesProperties:{},chartEventsSourceProperties:{},tradingProperties:{},priceScaleSelectionStrategyName:"auto"},n=["timeScale","mainSeries","sessions"],r=i.mainSeries,a=Object.keys(i),l=Object.keys(r),c=i.sessions,h=Object.keys(c),d=e.mainSeries().properties().factoryDefaults(),u=e.properties().factoryDefaults(),_=e.sessions().properties().factoryDefaults();return l.forEach((e=>{
s&&"style"===e||(o.mainSeries[e]=f_(e,d,r,"mainSeries",!1))})),a.forEach((e=>{n.includes(e)||(o[e]=f_(e,u,i,"preferences",!1))})),h.forEach((e=>{o.sessions[e]=f_(e,_,c,"sessions",!1)})),o}(this._model,this._model.mainSeries()),this._oldPreferences=e.preferences(),this._prevDateFormat=be.dateFormatProperty.value(),this._model.onWidget()||(this._prevWithWeekday=Md.withWeekdayProperty.value()),this._prevTimeHoursFormat=we.timeHoursFormatProperty.value(),this._prevAddPlusButton=lu.addPlusButtonProperty.value(),this._prevShowOpenMarkerStatus=up.showMarketOpenStatusProperty.value(),this._prevCurrencyUnitVisibility=(0,Be.currencyUnitVisibilityProperty)().value(),this._prevAutoLogButtonsVisibility=(0,$o.autoLogButtonsVisibilityProperty)().value(),this._prevNavigationButtonsVisibility=(0,ve.property)().value(),this._prevPaneButtonsVisibility=(0,Se.property)().value();const t=this._model.watermarkSource();null!==t&&(this._prevWatermarkPreferences=t.properties().state())}redo(){null!==this._trading&&(this._trading.noConfirmEnabled.setValue(!1),this._trading.showOnlyRejectionNotifications.setValue(!1),this._trading.showPricesWith().zeroVolume.setValue(!0),this._trading.showPricesWith().spread.setValue(!0),this._trading.orderExecutedSoundParams.enabled.setValue(!1),this._trading.orderExecutedSoundParams.volume.setValue(.5)),this._model.applyPreferences(this._defaultsPreferences),this._model.updateScales(),(0,be.restoreDateFormatSettingsValue)(),(0,we.restoreTimeHoursFormatSettingsValue)(),(0,lu.restoreAddPlusButtonSettingsValue)(),(0,up.restoreShowMarketOpenStatusProperty)(),(0,Be.restoreCurrencyUnitVisibilitySettingsValue)(),(0,$o.restoreAutoLogButtonsVisibilitySettingsValue)(),(0,ve.restoreNavigationButtonsVisibilitySettingsValue)(),(0,Se.restorePaneButtonsVisibilitySettingsValue)();const e=this._model.watermarkSource();null!==e&&e.restorePropertiesDefaults()}undo(){null!==this._trading&&(this._trading.noConfirmEnabled.setValue((0,n.ensureNotNull)(this._oldNoConfirmEnabled)),this._trading.showOnlyRejectionNotifications.setValue((0,n.ensureNotNull)(this._oldShowOnlyRejectionNotifications)),this._trading.showPricesWith().zeroVolume.setValue((0,n.ensureNotNull)(this._oldShowPricesWithZeroVolume)),this._trading.showPricesWith().spread.setValue((0,n.ensureNotNull)(this._oldShowPricesWithSpread)),this._trading.orderExecutedSoundParams.enabled.setValue((0,n.ensureNotNull)(this._oldOrderExecutedSoundEnabled))),this._model.applyPreferences(this._oldPreferences),this._model.updateScales(),be.dateFormatProperty.setValue(this._prevDateFormat),we.timeHoursFormatProperty.setValue(this._prevTimeHoursFormat),up.showMarketOpenStatusProperty.setValue(this._prevShowOpenMarkerStatus),lu.addPlusButtonProperty.setValue(this._prevAddPlusButton),(0,Be.currencyUnitVisibilityProperty)().setValue(this._prevCurrencyUnitVisibility),(0,$o.autoLogButtonsVisibilityProperty)().setValue(this._prevAutoLogButtonsVisibility),(0,ve.property)().setValue(this._prevNavigationButtonsVisibility),(0,Se.property)().setValue(this._prevPaneButtonsVisibility),
this._model.onWidget()||Md.withWeekdayProperty.setValue(this._prevWithWeekday);const e=this._model.watermarkSource();null!==e&&null!==this._prevWatermarkPreferences&&e.properties().mergeAndFire(this._prevWatermarkPreferences)}}class gp extends st.UndoCommand{constructor(e,t,i,s){super(i),this._property=e,this._newValue=t,this._model=s,this._priceScale=this._model.mainSeries().priceScale(),this._oldValue=this._property.value(),this._oldMode=this._priceScale.mode()}redo(){this._oldValue=this._property.value(),this._oldMode=this._priceScale.mode(),(0,yi.allowSavingDefaults)(!0),this._priceScale.setMode({autoScale:!1,percentage:!1,log:!1}),this._property.setValue(this._newValue),(0,yi.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),this._model.lightUpdate()}undo(){(0,yi.allowSavingDefaults)(!0),this._property.setValue(this._oldValue),this._priceScale.setMode(this._oldMode),(0,yi.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,wi.viewportChangeEvent)()),this._model.lightUpdate()}}class fp{constructor(e){this._leftScales=e.leftPriceScales().map((e=>e.id())),this._rightScales=e.rightPriceScales().map((e=>e.id()))}restorePane(e){this._leftScales.reverse().map((t=>(0,n.ensureNotNull)(e.getPriceScaleById(t)))).forEach((t=>e.movePriceScale(t,"left"))),this._rightScales.reverse().map((t=>(0,n.ensureNotNull)(e.getPriceScaleById(t)))).forEach((t=>e.movePriceScale(t,"right")))}}class yp extends st.UndoCommand{constructor(e,t,i){super(i),this._chartModel=e,this._targetStrategy=(0,zc.createPriceScaleSelectionStrategy)(t),this._initialState=e.panes().map((e=>new fp(e)))}redo(){this._chartModel.panes().forEach((e=>e.setPriceScaleSelectionStrategy(this._targetStrategy))),this._chartModel.fullUpdate()}undo(){const e=this._chartModel.panes();for(let t=0;t<e.length;t++)this._initialState[t].restorePane(e[t]);this._chartModel.fullUpdate()}}
const vp=new dt.TranslatedString("send {title} backward",a.t(null,void 0,i(40962))),Sp=new dt.TranslatedString("bring {title} forward",a.t(null,void 0,i(41966))),bp=new dt.TranslatedString("insert {title} after {target}",a.t(null,void 0,i(32960))),wp=new dt.TranslatedString("insert {title} before {target}",a.t(null,void 0,i(57106))),Cp=new dt.TranslatedString("cut {title}",a.t(null,void 0,i(11500))),Tp=new dt.TranslatedString("cut sources",a.t(null,void 0,i(94227))),Pp=new dt.TranslatedString("remove {title}",a.t(null,void 0,i(94543))),xp=new dt.TranslatedString("remove drawings group",a.t(null,void 0,i(1193))),Mp=new dt.TranslatedString("move scale",a.t(null,void 0,i(44854))),Ip=new dt.TranslatedString("stop syncing line tool(s)",a.t(null,void 0,i(49183))),Ap=new dt.TranslatedString("move drawing(s)",a.t(null,void 0,i(52510))),Lp=new dt.TranslatedString("load default drawing template",a.t(null,void 0,i(43364))),kp=new dt.TranslatedString("apply factory defaults to selected sources",a.t(null,void 0,i(27851))),Ep=new dt.TranslatedString("change currency",a.t(null,void 0,i(32302))),Dp=new dt.TranslatedString("change unit",a.t(null,void 0,i(85975))),Bp=new dt.TranslatedString("clone line tools",a.t(null,void 0,i(32943))),Vp=new dt.TranslatedString("merge up",a.t(null,void 0,i(52458))),Rp=new dt.TranslatedString("merge down",a.t(null,void 0,i(78055))),Np=new dt.TranslatedString("merge to pane",a.t(null,void 0,i(41866))),Op=new dt.TranslatedString("unmerge up",a.t(null,void 0,i(79443))),Fp=new dt.TranslatedString("unmerge down",a.t(null,void 0,i(46453))),Wp=new dt.TranslatedString("unmerge to new bottom pane",a.t(null,void 0,i(81576))),Hp=new dt.TranslatedString("move {title} to new right scale",a.t(null,void 0,i(77482))),zp=new dt.TranslatedString("move {title} to new left scale",a.t(null,void 0,i(58228))),Up=new dt.TranslatedString("make {title} no scale (Full screen)",a.t(null,void 0,i(10625))),jp=new dt.TranslatedString("reset scales",a.t(null,void 0,i(3323))),Gp=new dt.TranslatedString("create {tool}",a.t(null,void 0,i(12898))),qp=new dt.TranslatedString("paste {title}",a.t(null,void 0,i(57010))),$p=new dt.TranslatedString("insert {title}",a.t(null,void 0,i(48818))),Kp=new dt.TranslatedString("remove pane",a.t(null,void 0,i(93333))),Yp=new dt.TranslatedString("invert scale",a.t(null,void 0,i(6830))),Zp=new dt.TranslatedString("toggle auto scale",a.t(null,void 0,i(42240))),Xp=new dt.TranslatedString("toggle lock scale",a.t(null,void 0,i(49695))),Jp=new dt.TranslatedString("toggle regular scale",a.t(null,void 0,i(80688))),Qp=new dt.TranslatedString("toggle indexed to 100 scale",a.t(null,void 0,i(24736))),em=new dt.TranslatedString("toggle percentage scale",a.t(null,void 0,i(98994))),tm=new dt.TranslatedString("toggle log scale",a.t(null,void 0,i(49403))),im=new dt.TranslatedString("move left",a.t(null,void 0,i(79209))),sm=new dt.TranslatedString("move right",a.t(null,void 0,i(60114))),om=new dt.TranslatedString("align to 45 degrees",a.t(null,void 0,i(4128))),nm=new dt.TranslatedString("set price scale selection strategy to {title}",a.t(null,void 0,i(82241))),rm=new dt.TranslatedString("remove all indicators",a.t(null,void 0,i(60806))),am=new dt.TranslatedString("remove drawings",a.t(null,void 0,i(30538))),lm=new dt.TranslatedString("remove all indicators and drawing tools",a.t(null,void 0,i(29096))),cm=new dt.TranslatedString("turn line tools sharing off",a.t(null,void 0,i(8040))),hm=new dt.TranslatedString("share line tools in layout",a.t(null,void 0,i(90221))),dm=new dt.TranslatedString("share line tools globally",a.t(null,void 0,i(63934))),um=new dt.TranslatedString("change linking group",a.t(null,void 0,i(88849))),_m=(new dt.TranslatedString("apply drawing template",a.t(null,void 0,i(89720))),
(0,ne.getLogger)("Chart.ChartUndoModel"));var pm;function mm(e,t){return{bringForwardEnabled:e.bringForwardEnabled||t.bringForwardEnabled,bringToFrontEnabled:e.bringToFrontEnabled||t.bringToFrontEnabled,sendBackwardEnabled:e.sendBackwardEnabled||t.sendBackwardEnabled,sendToBackEnabled:e.sendToBackEnabled||t.sendToBackEnabled}}!function(e){e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.Left=2]="Left",e[e.Right=3]="Right"}(pm||(pm={}));const gm=(0,l.enabled)("saveload_separate_drawings_storage");function fm(){return gm?(0,mt.drawOnAllCharts)().value()?1===(0,mt.drawOnAllChartsMode)().value()?1:2:0:(0,mt.drawOnAllCharts)().value()?1:0}function ym(e,t){(0,wr.showTooManyStudiesNotice)(t.limitValue)}class vm extends(Sr()){constructor(e,t,i,s,o,n,r,a,l,c,h,d){super(),this._createLineCommands=[],this._scalePriceInfo=null,this._currentSourceMoveCommand=null,this._currentLineChangeCommand=null,this._currentCustomMoveCommand=null,this._zoomStack=new nt,this._initialPriceScrollState=null,this._initialPriceScrollPos=null,this._chartWidget=n,this.m_model=new z_(e,t,i,s,o,this,a,l,c,h,d,n.chartWidgetCollection().symbolAliasService()),this._undoHistory=r,this._lineToolsGroupController=new ul({model:this._model.bind(this),pushUndoCommand:this._pushUndoCommand.bind(this),beginUndoMacro:e=>{this._undoHistory.beginUndoMacro(e)},endUndoMacro:this._undoHistory.endUndoMacro.bind(this._undoHistory),emitEvent:this.emitEvent.bind(this)})}id(){return this._model().id()}undoHistory(){return this._undoHistory}setWatchedValue(e,t,i){this._undoHistory.setWatchedValue(e,t,i)}lineToolsGroupController(){return this._lineToolsGroupController}mergeAllScales(e){!function(e,t){e.beginUndoMacro("left"===t?Rr:Nr),e.model().panes().forEach((i=>{const s="left"===t?i.visibleRightPriceScales():i.visibleLeftPriceScales(),o=("left"===t?i.visibleLeftPriceScales():i.visibleRightPriceScales()).concat(s),n="overlay"===i.priceScalePosition(i.defaultPriceScale())?o[0]:i.defaultPriceScale();e.movePriceScale(i,n,t,0),o.forEach((t=>{if(t===n)return;let s=t.mainSource();for(;null!==s;){e.moveToScale(s,i,n,null,!0);const o=t.mainSource();if(o===s){Or.logError("Loop detected while trying to merge scales");break}s=o}}))})),e.endUndoMacro(),e.model().fullUpdate()}(this,e)}movePriceScale(e,t,i,s){const o=new Fr(this._model(),e,t,i,s,Mp);this._pushUndoCommand(o)}createLineTool({pane:e,point:t,linetool:i,properties:s,linkKey:o,ownerSource:r,synchronizationMode:a=Cr.CreateLineToolSyncMode.Default,sharingMode:l=fm(),id:c,actionSource:h}){const d=cp.lineToolsStudyIds[i];if((0,n.assert)(!(0,Lt.isStudyLineToolName)(d)||!!d),d){const e=this.canCreateStudy({id:d});if(!e.success)return ym(this.model(),e),(0,Lt.isStudyLineToolName)(mt.tool.value())&&(0,mt.resetToCursor)(),null}const u=Gp.format({tool:new dt.TranslatedString(i,da.lineToolsLocalizedNames[i])});this.beginUndoMacro(u);const _=a!==Cr.CreateLineToolSyncMode.ForceOff,p=new _a({model:this._model(),pane:e,lineTool:i,ownerSource:r||(0,n.ensureNotNull)(e.mainDataSource()),drawOnAllChartsMode:l,id:c
}),m=p.startCreatingLine(t,s,o||null,l,a===Cr.CreateLineToolSyncMode.ForceOff,h),g=(0,n.ensureNotNull)(p.line());this._createLineCommands.unshift(p);let f=null;if(m&&(_&&this.finishLineTool(g),this._pushUndoCommand(p),this._createLineCommands.shift(),f={points:g.normalizedPoints(),interval:this.mainSeries().interval()}),(void 0===o&&a===Cr.CreateLineToolSyncMode.Default&&(0,mt.drawOnAllCharts)().value()||a===Cr.CreateLineToolSyncMode.ForceOn)&&g.isSynchronizable()){const e=(0,n.ensureNotNull)(this.model().externalTimeStamp(t.index)),s={point:{price:t.price,timeStamp:e},linetool:i,properties:g.properties(),symbol:this.mainSeries().symbol(),model:this.model(),linkKey:(0,n.ensureNotNull)(g.linkKey().value()),finalState:f,id:g.id(),sharingMode:g.sharingMode().value()};g.isFixed()&&(s.pointPositionPercents=g.calcPositionPercents()),(0,mt.createLineTool)(s)}return this.endUndoMacro(),g}continueCreatingLine(e,t,i,s){const o=(0,n.ensureDefined)(this._createLineCommands[0]);this.beginUndoMacro(o.text());const r=(0,n.ensureNotNull)(this._model().lineBeingCreated()),a=o.continueCreatingLine(e,t,i,s);let l=null;if(a&&(this.finishLineTool(r),this._pushUndoCommand(o),this._createLineCommands.shift(),l={points:r.normalizedPoints(),interval:this.mainSeries().interval()}),o.drawOnAllCharts()&&r.isSynchronizable()){const i=(0,n.ensureNotNull)(this._model().externalTimeStamp(e.index));(0,mt.continueLineTool)({point:{price:e.price,timeStamp:i},envState:t,finalState:l,model:this._model()})}return this.endUndoMacro(),a}continueExternalLine(e,t,i){const s=(0,n.ensureDefined)(this._createLineCommands[0]),o=s.continueCreatingLine(e,t,i);return o&&(this._pushUndoCommand(s),this._createLineCommands.shift()),o}finishLineTool(e){this._model().finishLineTool(e)}cancelCreatingLine(){this.m_model.cancelCreatingLine()}lineBeingCreated(){return this.m_model.lineBeingCreated()}pasteImageAsLineTool(e,t,i,s){const o=this._model().timeScale(),r=o.width(),a=i.height(),l=i.defaultPriceScale(),c=(0,n.ensureNotNull)((0,n.ensureNotNull)(l.mainSource()).firstValue()),h={price:l.coordinateToPrice(a/2,c),index:o.coordinateToIndex(r/2)},d=(0,zs.createLineToolProperties)(i.model().backgroundTheme().spawnOwnership(),"LineToolImage",!i.model().readOnly());void 0!==s&&d.childs().transparency.setValue(s);const u=(0,n.ensureNotNull)(l.mainSource());(0,zs.prepareLineToolPropertiesByOwnerSource)(d,u);const _=this.createLineTool({pane:i,point:h,linetool:"LineToolImage",properties:d,actionSource:"Paste"});return _&&(_.setBlobImageUrl(t),this.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(_,null)})),e.then((e=>{_.properties().childs().url.setValue(e)})).catch((e=>{const t=_.linkKey().value(),i=this.model();null!==t&&(0,mt.removeLineTool)({withUndo:!1,model:i,linkKey:t,symbol:_.symbol(),sourceTitle:new dt.TranslatedString(_.name(),_.translatedType()),lineToolState:_.state(!1)}),i.removeSource(_)}))),_}loadRange(e){const t=this._model(),i=t.appliedTimeFrame().value();return(null===i||!Pr(i,e))&&(this._pushUndoCommand(new Ka(t,e)),(0,
ee.emit)("timeframe_interval",e),!0)}mainSeries(){return this.m_model.mainSeries()}model(){return this.m_model}allUndoModels(){return this._chartWidget.chartWidgetCollection().chartModels().value()}publishedChartsTimelineSource(){return this.m_model.publishedChartsTimelineSource()}unlinkLines(e){const t=this.model();this.beginUndoMacro(Ip);for(const i of e)null!==i.linkKey().value()&&(0,mt.removeLineTool)({withUndo:!0,model:this.model(),symbol:i.symbol(),linkKey:(0,n.ensureNotNull)(i.linkKey().value()),sourceTitle:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,i),lineToolState:i.state(!1),unlink:!0}),this._pushUndoCommand(new X_(t,i));this.endUndoMacro()}zoomFromViewport(){const e=new Y_((0,n.ensureDefined)(this._zoomStack.head()),this._zoomStack,!1);this._pushUndoCommand(e)}zoomToViewport(e,t,i,s,o){const n=new q_(this.m_model,e,t,i,s,o),r=new Y_(n,this._zoomStack,!0);this._pushUndoCommand(r)}zoomStack(){return this._zoomStack}timeScale(){return this.m_model.timeScale()}selection(){return this.m_model.selection()}selectionMacro(e,t){return this.m_model.selectionMacro(e,t)}onSelectedSourceChanged(){return this.m_model.onSelectedSourceChanged()}onTagsChanged(){return this.m_model.onTagsChanged()}lineCancelled(){return this.m_model.lineCancelled()}hoveredSource(){return this.m_model.hoveredSource()}crosshairSource(){return this.m_model.crosshairSource()}activeStrategySource(){return this.m_model.activeStrategySource()}setProperty(e,t,i,s){if(e&&e.value()!==t){this.beginUndoMacro(i);const o=new Ga(e,t,i,this.m_model,!s);this._pushUndoCommand(o),this.endUndoMacro(),this.emitEvent("setProperty")}}setProperties(e,t,i,s=!0){this.beginUndoMacro(i),this.m_model.selectionMacro((()=>{for(let o=0;o<e.length;o++)this.setProperty(e[o],t[o],i,!s)})),this.endUndoMacro()}beginUndoMacro(e){return this._undoHistory.beginUndoMacro(e)}endUndoMacro(){this._undoHistory.endUndoMacro()}invertPriceScale(e){const t=e.properties().childs().isInverted;this.setProperty(t,!t.value(),Yp)}togglePriceScaleAutoScaleMode(e){const t={autoScale:!e.isAutoScale()};this.setPriceScaleMode(t,e,Zp)}togglePriceScaleLockScaleMode(e){const t={lockScale:!e.isLockScale()};this.setPriceScaleMode(t,e,Xp)}togglePriceScalePercentageScaleMode(e){const t={percentage:!e.isPercentage()};this.setPriceScaleMode(t,e,em)}togglePriceScaleIndexedTo100ScaleMode(e){const t={indexedTo100:!e.isIndexedTo100()};this.setPriceScaleMode(t,e,Qp)}togglePriceScaleLogScaleMode(e){const t={log:!e.isLog()};this.setPriceScaleMode(t,e,tm)}setPriceScaleRegularScaleMode(e){this.setPriceScaleMode({log:!1,percentage:!1,indexedTo100:!1},e,Jp)}withMacro(e,t){const i=this.beginUndoMacro(e);try{t()}finally{this.endUndoMacro()}return i}dataSources(){return this.m_model.dataSources()}orderedDataSources(e){return this.m_model.orderedDataSources(e)}barsMarksSources(){return this.m_model.barsMarksSources()}removeAllDrawingTools(e){this.beginUndoMacro(am),this._removeAllDrawingToolsImpl(e),this.endUndoMacro()}removeAllStudiesAndDrawingTools(e){this.beginUndoMacro(lm),
this._removeAllDrawingToolsImpl(e),this._removeAllStudiesImpl(),this.endUndoMacro()}removeAllStudies(){this.beginUndoMacro(rm),this._removeAllStudiesImpl(),this.endUndoMacro()}scrollChartByBar(e){if(!this.m_model.scrollEnabled())return;const t=e*this.m_model.timeScale().barSpacing();this.startScrollTime(0),this.scrollTimeTo(t),this.endScrollTime()}canZoomIn(){return this.model().canZoomIn()}canZoomOut(){return this.model().canZoomOut()}zoomOut(){const e=this.timeScale().width();this.canZoomOut()&&(0,xr.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(0),this.scaleTimeTo(e),this.endScaleTime()}})}zoomIn(){const e=this.timeScale().width();this.canZoomIn()&&(0,xr.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(e),this.scaleTimeTo(0),this.endScaleTime()}})}scrollChart(e){this.m_model.scrollEnabled()&&(this.startScrollTime(0),this.scrollTimeTo(e),this.endScrollTime())}startMovingSources(e,t,i,s){e.filter((e=>e.doesMovingAffectsUndo())).length&&(this._currentSourceMoveCommand=new ta(this.model(),e,Ap,!1)),this.model().startMovingSources(e,t,i,new Map,s)}moveSources(e,t){this.model().moveSources(e,new Map,t)}endMovingSource(e,t){this.model().endMovingSources(e,void 0,t),null!==this._currentSourceMoveCommand&&(this._currentSourceMoveCommand.saveNewState(),this._pushUndoCommand(this._currentSourceMoveCommand)),this._currentSourceMoveCommand=null}startChangingLinetool(e,t,i,s,o,n){this._currentLineChangeCommand=new ta(this.model(),[e],e.changePointUndoText(s),!1),this.model().startChangingLinetool(e,t,i,s,o,n)}changeLinePoint(e,t){this.model().changeLinePoint(e,t)}alignToolTo45Degrees(e,t){const i=e.alignTo45DegreesPoints();i&&(this._pushUndoCommand(new ta(this.model(),[e],om,!1)),this.model().alignTo45Degrees(e,t,i))}endChangingLinetool(e){this.model().endChangingLinetool(e),null!==this._currentLineChangeCommand&&(this._currentLineChangeCommand.saveNewState(),this._pushUndoCommand(this._currentLineChangeCommand)),this._currentLineChangeCommand=null}setChartStyleProperty(e,t,i){if(e.value()!==t){const s=void 0,o=()=>{this.beginUndoMacro(i);const s=new qa(e,t,this.mainSeries(),i,this.model(),this._chartWidget);this._pushUndoCommand(s),this.emitEvent("setChartStyleProperty"),e.value(),this.endUndoMacro()};s?runOrGoPro(o,s.feature,{feature:s.featureName}):o()}}setPriceAutoScale(e,t,i){this._pushUndoCommand(new xn(this.m_model,e,t,t.state())),this.m_model.setPriceAutoScale(e,t,i)}setPriceScaleMode(e,t,i){if(!(0,Ot.default)(t.mode(),e)){const s=new Nl(e,t,i,this.m_model);this._pushUndoCommand(s)}}setPriceScaleSelectionStrategy(e){const t=this.m_model.properties().childs();if(t.priceScaleSelectionStrategyName.value()===e)return;(0,re.trackEvent)("Chart","Change PriceScale Selection Strategy");const i=nm.format({title:e});this.beginUndoMacro(i),this.setProperty(t.priceScaleSelectionStrategyName,e,i);const s=new yp(this.m_model,e,i);this._pushUndoCommand(s),this.endUndoMacro()}setScaleRatioProperty(e,t,i){if(e.value()!==t){const s=new gp(e,t,i,this.m_model);this._pushUndoCommand(s)}}createUndoCheckpoint(){
return this._undoHistory.createUndoCheckpoint()}undoToCheckpoint(e){this._undoHistory.undoToCheckpoint(e)}restorePropertiesForSource(e){(0,zs.isLineTool)(e)?this._restoreLineToolFactoryDefaults(e):this._restoreStudyFactoryDefaults(e)}restoreLineToolsFactoryDefaults(e){1===e.length?this._restoreLineToolFactoryDefaults(e[0]):(this.beginUndoMacro(kp),e.forEach((e=>this._restoreLineToolFactoryDefaults(e))),this.endUndoMacro())}restorePreferences(){const e=new mp(this.model());this._pushUndoCommand(e)}restoreState(e,t,i){return this.m_model.restoreState(e,t,i)}async clipboardCopy(e,t=this.selection().dataSources()){if(!(0,l.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;for(const e of i)if((0,Ws.isStudy)(e)&&e.isChildStudy())throw new Error("Can not copy child study");const s=(0,Ar.clipboardDataForSources)(this._model().id(),i);return null!==s?e.write({app:JSON.stringify(s),text:s.title}):void 0}async clipboardCut(e,t=this.selection().dataSources()){if(!(0,l.enabled)("datasource_copypaste"))return;const i=t.filter((e=>e.copiable()));if(0===i.length)return;await this.clipboardCopy(e,i);const s=i.filter((e=>e.isUserDeletable()));if(0===s.length)return;const o=(1===s.length?Cp:Tp).format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,s[0])});this.beginUndoMacro(o),this.m_model.selectionMacro((()=>this.removeSources(s,!1,o)),!0),this.endUndoMacro()}async clipboardPaste(e,t){let i=null;if((0,l.enabled)("datasource_copypaste")&&(i=i||await e.read(),i.app)){const e=JSON.parse(i.app);if(null!==await this.pasteSourceFromClip(t,e))return}await this._processSpecialLineToolsContents(e,i,t)}applyStudyTemplate(e,t){const i=new gl(this._model(),e,t);this.beginUndoMacro(i.text());const s=this.m_model.panes().reduce(((e,t)=>e.concat(t.sourcesByGroup().allWithoutMultipaneWithHidden().filter(zs.isLineTool).filter((e=>e.ownerSource()!==this.m_model.mainSeries()&&(!e.supportsTargetSignature()||null===e.targetSignature()))))),[]);this.removeSources(s,!1,null),this._pushUndoCommand(i),this.endUndoMacro(),(0,ee.emit)("load_study_template")}createStudyInserter(e,t,i={}){const{stubTitle:s,isOverlay:o}=i,n={createStudy:(e,t,i,s,o,n,r,a,l,c,h,d)=>{if(!this.checkIfFeatureAvailable(e,r))return _m.logNormal("Cannot insert study "+e.id),null;(0,re.trackEvent)("studies","Study_"+e.id,e.description),"Compare@tv-basicstudies"===e.id&&(0,re.trackEvent)("compare","symbol:"+t.symbol),s&&this.m_model.removeSource(s);const u=this._insertStudy(e,t,o,n,r,a,l,c,h,null,d);return u.study.then((e=>(0,ee.emit)("study_event",e.id(),"create"))),u},storeFailedStub:e=>{this._storeFailedStub(e)}};void 0!==s&&(n.createStub=()=>this.m_model.insertStudyStub(s,o).id(),n.removeStub=e=>this.m_model.removeStudyStub(e));const r=new w_(e,n);return r.setParentSources(t),r}applyLineToolTemplate(e,t,i){this.beginUndoMacro(i),this.saveLineToolState(e,i);const s=new dp(e,t,i);this._pushUndoCommand(s),this.saveLineToolState(e,i),this.endUndoMacro(),this.model().updateSource(e)}applyLineToolsTemplate(e){
throw new Error("Not implemented")}replayStatus(){return this.m_model.replayStatus()}setReplayStatus(e){return this.m_model.setReplayStatus(e)}isInReplay(){return this.m_model.isInReplay()}getSymbolString(){return this.m_model.getSymbolString()}interval(){return this.m_model.interval()}onInReplayStateChanged(){return this.m_model.onInReplayStateChanged()}switchToReplay(e,t){0}switchToRealtime(){0}canChangeResolution(e){return this.model().canChangeResolution(e)}canChangeSymbol(e){return this.model().canChangeSymbol(e)}onReplayModified(){return this.model().onReplayModified()}startCustomMoving(e,t,i){this._currentCustomMoveCommand=new Vl(this.model(),e,t,i)}customMoveBeingProcessed(){return null!==this._currentCustomMoveCommand}processCustomMove(e){(0,n.ensureNotNull)(this._currentCustomMoveCommand).move(e)}endCustomMoving(){null!==this._currentCustomMoveCommand&&this._currentCustomMoveCommand.hasChanges()&&(this._pushUndoCommand(this._currentCustomMoveCommand),this._currentCustomMoveCommand=null)}state(e){return this.m_model.state(e)}panes(){return this.m_model.panes()}cloneLineTools(e,t){for(let t=0;t<Math.min(5,e.length);++t)e[t],Ln();this.beginUndoMacro(Bp);const i=new Hr(this._model(),e,t,Bp);this._pushUndoCommand(i);const s=i.newIds().map((e=>(0,n.ensureNotNull)(this.model().dataSourceForId(e)))).filter((e=>0!==e.sharingMode().value()));return s.length&&this._model().copyToOtherCharts(s,!0),this.endUndoMacro(),this.emitEvent("cloneLineTools"),i.newIds()}removeSource(e,t,i){this.lineBeingCreated()!==e?this.removeSources([e],t,Pp.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e)}),i):this.cancelCreatingLine()}removeSelectedSources(){const e=this._model().selection().dataSources();if(!e.length)return;const t=(e.length>1?xp:Pp).format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e[0])});this.removeSources(e,!1,t)}removeSources(e,t,i,s){s||(e=e.filter((e=>e.isUserDeletable())));const o=this._model(),r=o.lineToolsGroupModel();this.beginUndoMacro(i),o.selectionMacro((s=>{const a=new Map;e.forEach((e=>{if((0,zs.isLineTool)(e)){const t=r.groupForLineTool(e);if(null!==t){const i=a.get(t)||[];i.push(e),a.set(t,i)}null!==e.linkKey().value()&&(0,mt.removeLineTool)({withUndo:!0,model:this.model(),linkKey:(0,n.ensureNotNull)(e.linkKey().value()),symbol:this.model().mainSeries().symbol(),lineToolState:e.state(!1),sourceTitle:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e)})}}));const l=new ea(o,e,i),c=l.removedIds();this._pushUndoCommand(l),!t&&c.length>0&&(1===c.length?this.emitEvent("removeSource",[c[0]]):this.emitEvent("removeSources",[c]))}),!0),this.endUndoMacro()}async scrollToLineTool(e){const t=this.timeScale().logicalRange();if(null===t)return;const i=e.points().map((e=>e.index)),s=this.timeScale().points().range().value();if(null===s)return;let o=s.firstIndex;const r=s.lastIndex,a=t.length()/2;if(0===i.length||i.some((e=>t.contains(e))))return;const l=()=>{
const t=e.points().map((e=>e.index)),i=t.filter((e=>e<=r)).reduce(((e,t)=>null===e?t:Math.max(e,t)),null);return null!==i?i:t.reduce(((e,t)=>Math.min(e,t)))};let c=l();if(o-a>c){const t=e.points().map((e=>e.time)).filter(tt.notUndefined).map((e=>1e3*e));if(0===t.length)return;const i=t.reduce(((e,t)=>Math.min(e,t)),t[0]);await this.model().gotoTime(i),c=l();if((0,n.ensureNotNull)(this.timeScale().logicalRange()).contains(c))return;o=(0,n.ensureNotNull)(this.timeScale().points().range().value()).firstIndex}o-a>c&&this.mainSeries().setGotoDateResult({timestamp:(0,n.ensureNotNull)(this.timeScale().points().valueAt(o)),eod:!0});const h=this.timeScale().width()/2,d=this.timeScale().indexToCoordinate(c);this.model().stopTimeScaleAnimation(),this.model().setTimeScaleAnimation(new Ir({from:0,to:h-d,duration:br.dur,easing:br.easingFunc.easeInOutCubic}))}mergeSourceUp(e){const t=new la(this._model(),e,Vp);this._mergeUnmergeSource(e,t)}mergeSourceDown(e){const t=new ca(this._model(),e,Rp);this._mergeUnmergeSource(e,t)}mergeToPane(e,t,i){const s=this._model().panes().indexOf(t),o=new ha(this._model(),e,s,Np,i);this._mergeUnmergeSource(e,o)}unmergeSourceUp(e){const t=new na(this._model(),e,Op);this._withKeepWidgetPanePositionGuard((()=>this._mergeUnmergeSource(e,t)),t.text())}unmergeSourceDown(e){const t=new oa(this._model(),e,Fp);this._withKeepWidgetPanePositionGuard((()=>this._mergeUnmergeSource(e,t)),t.text())}unmergeToNewBottomPane(e){const t=new ra(this._model(),e,Wp);this._mergeUnmergeSource(e,t)}moveLeft(){this.beginUndoMacro(im),(0,xr.doAnimate)({to:this.m_model.timeScale().width()/5,onStep:e=>{this.startScrollTime(e),this.scrollTimeTo(0),this.endScrollTime()},onComplete:()=>{this.endUndoMacro()}})}moveRight(){this.beginUndoMacro(sm),(0,xr.doAnimate)({to:this.m_model.timeScale().width()/5,onStep:e=>{this.startScrollTime(0),this.scrollTimeTo(e),this.endScrollTime()},onComplete:()=>{this.endUndoMacro()}})}availableZOrderOperations(e){const t=this._model().lineToolsGroupModel(),i=e.filter(zs.isLineTool),s=i.map((e=>t.groupForLineTool(e)));(0,n.assert)(new Set(s).size<=1,"Cannot move line tools from different group");const o=0===s.length?null:s[0];let r={bringForwardEnabled:!1,bringToFrontEnabled:!1,sendBackwardEnabled:!1,sendToBackEnabled:!1};const a=new Set(i);for(const t of(0,vi.sortSources)(e)){if((0,zs.isLineTool)(t)&&null!==o){const e=(0,vi.sortSources)(o.lineTools().filter((e=>!a.has(e)||e===t)));r=mm(r,{bringForwardEnabled:t!==e[e.length-1],bringToFrontEnabled:t!==e[e.length-1],sendBackwardEnabled:t!==e[0],sendToBackEnabled:t!==e[0]});continue}const e=(0,n.ensureNotNull)(this._model().paneForSource(t)).sourcesByGroup().allExceptSpecialSources();if(0===e.length)continue;const i=t.zorder(),s=e[0].zorder(),l=e[e.length-1].zorder();r=mm(r,{bringForwardEnabled:i!==l,bringToFrontEnabled:i!==l,sendBackwardEnabled:i!==s,sendToBackEnabled:i!==s})}return r}sendToBack(e){if(!this.availableZOrderOperations(e).sendToBackEnabled)throw new Error("Send to back operation is unavailable");let t=null;const i=e[0];if((0,
zs.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new La(this.model(),(0,vi.sortSources)(e),i[0])}}null===t&&(t=new xa(this.model(),(0,vi.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}bringToFront(e){if(!this.availableZOrderOperations(e).bringToFrontEnabled)throw new Error("Bring to front operation is unavailable");let t=null;const i=e[0];if((0,zs.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new Ia(this.model(),(0,vi.sortSources)(e),i[i.length-1])}}null===t&&(t=new Pa(this.model(),(0,vi.sortSources)(e))),this._pushUndoCommand(t),this.emitEvent("changeZOrder",[e])}sendBackward(e){if(!this.availableZOrderOperations(e).sendBackwardEnabled)throw new Error("Send backward operation is unavailable");const t=vp.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,vi.sortSources)(e),((e,t)=>new Ea(this.model(),e,t)))}bringForward(e){if(!this.availableZOrderOperations(e).bringForwardEnabled)throw new Error("Bring forward operation is unavailable");const t=Sp.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,vi.sortSources)(e),((e,t)=>new Ba(this.model(),e,t)))}insertAfter(e,t){e=(0,vi.sortSources)(e);const i=bp.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e[0]),target:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new Ia(this.model(),e,t)))}insertBefore(e,t){e=(0,vi.sortSources)(e);const i=wp.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e[0]),target:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new La(this.model(),e,t)))}detachToRight(e,t){(0,re.trackEvent)("Chart","Move to new right scale");const i=Hp.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e)}),s=new Tl(this.model(),e,t,"right",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachToLeft(e,t){(0,re.trackEvent)("Chart","Move to new left scale");const i=zp.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e)}),s=new Tl(this.model(),e,t,"left",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachNoScale(e,t){(0,re.trackEvent)("Chart","Make source no scale");const i=Up.format({title:(0,bi.getTranslatedStringForSource)(pa.TitleDisplayTarget.StatusLine,e)}),s=new Tl(this.model(),e,t,"overlay",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}moveToScale(e,t,i,s,o){(0,re.trackEvent)("Chart","Move source to target scale"),this.beginUndoMacro(s);const n=new Pl(this.model(),e,t,i,s),r=o?null:kr(e,i,this._model()),a=o?null:ih(e,i,this._model());this._pushUndoCommand(n),null!==r&&this.setPriceScaleCurrency(i,r),null!==a&&this.setPriceScaleUnit(i,a),
this.endUndoMacro(),this.emitEvent("moveSource",[e])}setLinkingGroupIndex(e){const t=this.model().linkingGroupIndex();this._undoHistory.beginUndoMacro(um),this._pushUndoCommand(new lp(t,t.value(),e,um)),this._model().setShouldBeSavedEvenIfHidden(!0),this._undoHistory.endUndoMacro()}startScrollPrice(e,t,i){t.isAutoScale()||(this._initialPriceScrollState=t.state(),this._initialPriceScrollPos=i,this._model().startScrollPrice(e,t,i))}scrollPriceTo(e,t,i){t.isAutoScale()||(this._initialPriceScrollState&&this._initialPriceScrollPos&&Math.abs(this._initialPriceScrollPos-i)>20&&(this._pushUndoCommand(new xn(this.m_model,e,t,this._initialPriceScrollState,void 0,!1)),this._initialPriceScrollState=null,this._initialPriceScrollPos=null),this._model().scrollPriceTo(e,t,i))}endScrollPrice(e,t){t.isAutoScale()||(this._initialPriceScrollState=null,this._initialPriceScrollPos=null,this._model().endScrollPrice(e,t))}startScrollTime(e){this.model().startScrollTime(e)}scrollTimeTo(e){this.model().scrollTimeTo(e)}endScrollTime(){this.model().endScrollTime()}startScaleTime(e){this.model().startScaleTime(e)}scaleTimeTo(e){this.model().scaleTimeTo(e)}endScaleTime(){this.model().endScaleTime()}resetTimeScale(){this.model().resetTimeScale()}startScalePrice(e,t,i,s){this._scalePriceInfo={priceScaleState:t.state(),tryMergeConsecutiveScales:s},this.model().startScalePrice(e,t,i)}scalePriceTo(e,t,i){this.model().scalePriceTo(e,t,i)}endScalePrice(e,t){this.model().endScalePrice(e,t);const i=(0,n.ensureNotNull)(this._scalePriceInfo);(0,Ot.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new xn(this.model(),e,t,i.priceScaleState,i.tryMergeConsecutiveScales)),this._scalePriceInfo=null}startTwoPointsScalePrice(e,t,i,s,o){this._scalePriceInfo={priceScaleState:t.state(),tryMergeConsecutiveScales:o},this.model().startTwoPointsScalePrice(e,t,i,s)}twoPointsScalePriceTo(e,t,i,s){this.model().twoPointsScalePriceTo(e,t,i,s)}endTwoPointsScalePrice(e,t){this.model().endTwoPointsScalePrice(e,t);const i=(0,n.ensureNotNull)(this._scalePriceInfo);(0,Ot.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new xn(this.model(),e,t,i.priceScaleState,i.tryMergeConsecutiveScales)),this._scalePriceInfo=null}resetPriceScale(e,t){const i=t.state();this.model().resetPriceScale(e,t),(0,Ot.default)(i,t.state())||this._pushUndoCommand(new xn(this.m_model,e,t,i))}rearrangePanes(e,t){const i=this.m_model.panes()[e],s=new Fa(this._model(),e,t);i.mode()===zi.PaneMode.Widget?this._pushUndoCommand(s):this._withKeepWidgetPanePositionGuard((()=>this._pushUndoCommand(s)),s.text())}movePane(e,t){const i=this.m_model.panes()[e],s=new Fa(this._model(),e,t);i.mode()===zi.PaneMode.Widget?this._pushUndoCommand(s):this._withKeepWidgetPanePositionGuard((()=>this._pushUndoCommand(s)),s.text())}toggleCollapsedPane(e){const t=this.panes().findIndex((t=>t===e));t<0||this._pushUndoCommand(new Dr(this._model(),t))}toggleMaximizedPane(e){this._pushUndoCommand(new Vr(this._model(),e))}readOnly(){return this.m_model.readOnly()}checkIfFeatureAvailable(e,t){
const i=t.length>0,s=this.canCreateStudy({id:e.id,child:i,fundamental:!1});return!!s.success||(ym(this.model(),s),!1)}async pasteSourceFromClip(e,t,i){const s=t;if(!s||0===s.sources.length)return null;const o=e||(0,n.ensureNotNull)(this.model().paneForSource(this.mainSeries()));if(!s.sources.some((e=>"drawing"!==e.type||null!==o.clipboardLineToolOwnerSource(e.source.id))))return null;const r=Array.from(new Set(s.sources.filter(Ar.isLineToolClipboardData).map((e=>e.source.type))));await Promise.all(r.map((e=>(0,zs.initLineTool)(e)))),this.beginUndoMacro(qp.format({title:s.title}));let a=0;const l=[],c=[];for(const t of s.sources)if("drawing"===t.type&&null!==o.clipboardLineToolOwnerSource(t.source.id)){const e=await this.pasteLineTool(o,t);a<5&&(Ln(),a+=1),c.push(e),l.push(e)}else"study"===t.type&&t.source&&t.source.metaInfo&&this.checkIfFeatureAvailable(new ns.StudyMetaInfo(t.source.metaInfo),[])&&l.push(this.pasteStudy(t,i?e:void 0));return c.length&&this.selectionMacro((e=>{e.clearSelection(),c.forEach((t=>{e.addSourceToSelection(t,null)}))})),this.endUndoMacro(),l}async pasteLineTool(e,t,i,s){await(0,xo.ensureLineToolLoaded)(t.source.type),t.source.state.intervalsVisibilities=(0,bh.mergeIntervalVisibilitiesDefaults)(t.source.state.intervalsVisibilities),(0,bh.makeIntervalsVisibilitiesVisibleAtInterval)(t.source.state.intervalsVisibilities,this.model().mainSeries().intervalObj().value());const o=new Sl(this.model(),t,e,i,s);this._pushUndoCommand(o);const n=o.source();return o.needCopyToOtherCharts()&&this._model().copyToOtherCharts([n],!0),this.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(n,null)})),n}pasteStudy(e,t){const i=new El(this.model(),e,t?.id());this._pushUndoCommand(i);const s=(0,n.ensureNotNull)(i.state()).id;return(0,ee.emit)("study_event",s,"paste_study"),(0,n.ensureNotNull)(this._model().dataSourceForId(s))}removePane(e){const t=this.m_model.panes()[e].dataSources().slice();this.removeSources(t,!1,Kp)}createPane(e){return this.m_model.createPane(e)}setPriceScaleCurrency(e,t){const i=new bl(this.m_model,e,t,Ep);this._pushUndoCommand(i)}setPriceScaleUnit(e,t){const i=new wl(this.m_model,e,t,Dp);this._pushUndoCommand(i)}setSymbol(e,t){e.symbolSameAsResolved(t)||this._pushUndoCommand(new Il(e,t,this._chartWidget))}setResolution(e,t){Re.Interval.isEqual(e.interval(),t)||this._pushUndoCommand(new ap(e,t,this._chartWidget))}syncCrosshair(e,t){this._chartWidget.chartWidgetCollection().syncCrosshair(e,this._chartWidget.id(),t)}loadingScreen(){return this._chartWidget.screen}chartLoadTheme(e,t,i){const s=new np(this.model(),e,t);i?s.redo():this._pushUndoCommand(s)}isJustClonedChart(){return this._chartWidget.isJustClonedChart()}isMultipleLayout(){return this._chartWidget.isMultipleLayout()}addPaneStretchFactorUndoCommand(e,t,i,s){const o=new Dl(this.model(),e,t,i,s);this._pushUndoCommand(o)}applyPreferences(e){throw new Error("Not implemented")}paneForSource(e){return this.m_model.paneForSource(e)}destroy(){this.m_model.destroy()}moveSelectedToolsLeft(){return this._moveSelectedTools(2)}
moveSelectedToolsUp(){return this._moveSelectedTools(0)}moveSelectedToolsRight(){return this._moveSelectedTools(3)}moveSelectedToolsDown(){return this._moveSelectedTools(1)}insertStudyWithoutCheck(e,t,i,s){return this._insertStudy(e,t,{},!1,[],void 0,void 0,void 0,void 0,i??null,void 0,s)}saveLineToolState(e,t){this._pushUndoCommand(new ta(this.m_model,[e],t))}resetScales(){this._model().stopTimeScaleAnimation(),this.beginUndoMacro(jp),this.resetTimeScale();for(const e of this.m_model.panes()){for(const t of e.leftPriceScales())this.resetPriceScale(e,t);for(const t of e.rightPriceScales())this.resetPriceScale(e,t)}this.endUndoMacro(),this.m_model.recalculateAllPanes((0,wi.viewportChangeEvent)())}shareLineTools(e,t){if(!gm)return;const i=0===t?cm:1===t?hm:dm;this.withMacro(i,(()=>{0===t&&this.unlinkLines(e),e.forEach((i=>{const s=this.model().lineToolsGroupModel().groupForLineTool(i);if(s){s.lineTools().every((t=>e.includes(t)))||this.lineToolsGroupController().excludeLineToolFromGroup(s,i)}this._pushUndoCommand(new j_(i,t,this.model(),null))}))}))}canCreateStudy(e,t){return this.model().chartApi().canCreateStudy(e,t)}chartWidgetCollectionLock(){return this._chartWidget.chartWidgetCollection().lock}onSymbolIntervalChanged(){return this.m_model.onSymbolIntervalChanged()}paneBeingCreatedLineOn(){return this.m_model.paneBeingCreatedLineOn()}invalidate(e){this.m_model.invalidate(e)}setWidth(e){this.m_model.setWidth(e)}setPaneHeight(e,t){this.m_model.setPaneHeight(e,t)}dataSourceForId(e){return this.m_model.dataSourceForId(e)}lineBeingEdited(){return this.m_model.lineBeingEdited()}sourcesBeingMoved(){return this.m_model.sourcesBeingMoved()}gridSource(){return this.m_model.gridSource()}watermarkSource(){return this.m_model.watermarkSource()}mainSeriesScaleRatioProperty(){return this.m_model.mainSeriesScaleRatioProperty()}setHoveredSource(e,t){this.m_model.setHoveredSource(e,t)}setCurrentPosition(e,t,i,s){this.m_model.setCurrentPosition(e,t,i,s)}setAndSaveCurrentPosition(e,t,i,s){this.m_model.setAndSaveCurrentPosition(e,t,i,s)}version(){return this.m_model.version()}restart(){this.m_model.restart()}disconnect(){this.m_model.disconnect()}calculateDefaultTags(){return this.m_model.calculateDefaultTags()}drawRightThere(e,t,i,s){if((0,Lt.isLineToolName)(e)){if(void 0===i){const e=this.crosshairSource(),s=this.model().magnet().align(e.price,e.index,t);i={index:e.index,price:s}}const o=this.createLineTool({point:i,linetool:e,pane:t,actionSource:s});o&&this.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(o)}))}}unloadDataSources(){const e=this.model(),t=e.dataSources().filter((e=>!!(0,Ws.isStudy)(e)||(0,zs.isLineTool)(e)||(0,Ws.isStudyStub)(e)));$r(e,t)}_model(){return this.m_model}_pushUndoCommand(e){this._undoHistory.pushUndoCommand(e)}_mergeUnmergeSource(e,t){this.beginUndoMacro(t.text());const i=(0,n.ensureNotNull)(this._model().paneForSource(e)),s=new Set(i.sourcesByGroup().lineSources().filter((t=>t.ownerSource()===e)));this._model().lineToolsGroupModel().groups().filter((e=>{
const t=e.lineTools().some((e=>s.has(e))),i=e.lineTools().some((e=>!s.has(e)));return t&&i})).forEach((e=>{this._pushUndoCommand(new Kr.ExcludeLineToolsFromGroupUndoCommand(this._model(),e,e.lineTools()))})),this._pushUndoCommand(t),this.endUndoMacro()}_insertStudy(e,t,i,s,o,n,r,a,l,c,h,d){const u=$p.format({title:e.description}),_=new Rl({chartModel:this.model(),studyMetaInfo:e,inputs:t,props:i,addAsOverlay:s,parentSources:o,preferredPriceScale:n,allowChangeCurrency:r,allowChangeUnit:a,paneSize:l,targetZOrder:c??null,targetScaleMode:h,studyId:d,undoText:u});return this._pushUndoCommand(_),_.insertedStudy()}_storeFailedStub(e){const t=$p.format({title:e.title()});this.beginUndoMacro(t);const i=new hp(this.model(),e,t);this._pushUndoCommand(i),this.endUndoMacro()}async _processSpecialLineToolsContents(e,t,i){if(t=t||await e.read(),(window.user.id||(0,l.enabled)("image_drawingtool"))&&t.files){const e=Array.from(t.files).find(U_.blobImageFilter);if(e){const t=URL.createObjectURL(e),s=(0,U_.uploadImage)(e);return void 0===i&&(i=(0,n.ensureNotNull)(this._model().paneForSource(this.mainSeries()))),await(0,xo.ensureLineToolLoaded)("LineToolImage"),this.pasteImageAsLineTool(s,t,i),void await s}}}_insertAfterOrBefore(e,t,i,s){const o=(0,n.ensureNotNull)(this._model().paneForSource(i));if(t.some((e=>(0,zs.isLineTool)(e)&&this._model().paneForSource(e)!==o)))throw new Error("Cannot insert line tool after target on another pane");this.beginUndoMacro(e),t.forEach((e=>{(0,n.ensureNotNull)(this.model().paneForSource(e))!==o&&this.mergeToPane(e,o)}));const r=s();this._withKeepWidgetPanePositionGuard((()=>this._pushUndoCommand(r)),r.text()),this.emitEvent("changeZOrder",[t]),this.endUndoMacro()}_sendBackOrBringForward(e,t,i){const s=new Map;t.forEach((e=>{const t=(0,n.ensureNotNull)(this._model().paneForSource(e)),i=s.get(t)||[];i.push(e),s.set(t,i)})),this.beginUndoMacro(e),s.forEach(((e,t)=>{this._pushUndoCommand(i(t,e))})),this.endUndoMacro(),this.emitEvent("changeZOrder",[t])}_moveSelectedTools(e){const t=this.model().selection().lineDataSources().filter((e=>!e.isSourceHidden()));if(0===t.length)return!1;if((0,mt.lockDrawings)().value())return!0;const i=this.timeScale().visibleBarsStrictRange();if(null===i)return!1;const s=function(e){const t=new Map;for(const i of e){const e=i.ownerSource();if(null===e)continue;let s=t.get(e);if(void 0===s){const o=e.priceScale(),n=e.priceStep(),r=e.firstValue();if(null===o||null===n||null===r)continue;if(null===o.priceRange())continue;s={sources:[],priceScale:o,priceStep:n,startPrice:i.points()[0].price,firstValue:r},t.set(e,s)}s.sources.push(i)}return t}(t);if(0===s.size)return!1;this.beginUndoMacro(Ap);const o=i.firstBar(),n=this.timeScale().indexToCoordinate(o),r=o+(3===e?1:2===e?-1:0),a=this.timeScale().indexToCoordinate(r);return mt.isDirectionalMovementActive.setValue(!0),s.forEach((t=>{const{startPrice:i,priceStep:s,priceScale:l,firstValue:c}=t,h=i+(0===e?s:1===e?-s:0),d=l.priceToCoordinate(i,c),u=l.priceToCoordinate(h,c),_={logical:{index:o,price:i},screen:new Vt.Point(n,d)},p={
logical:{index:r,price:h},screen:new Vt.Point(a,u)};this.startMovingSources(t.sources,_,null),this.moveSources(p),this.endMovingSource(!1,!0)})),mt.isDirectionalMovementActive.setValue(!1),this.endUndoMacro(),!0}_restoreStudyFactoryDefaults(e){const t=new ip(this.m_model,e);this._pushUndoCommand(t)}_restoreLineToolFactoryDefaults(e){this.beginUndoMacro(Lp),this.saveLineToolState(e,Lp);const t=new ep(this.m_model,e.properties(),Lp);this._pushUndoCommand(t),this.saveLineToolState(e,Lp),this.endUndoMacro(),this.model().updateSource(e)}_removeAllDrawingToolsImpl(e,t){this.selectionMacro((()=>{this.lineBeingCreated()&&this.cancelCreatingLine();this.dataSources().filter(zs.isLineTool).filter((e=>e.isActualSymbol()&&e.isUserDeletable())).filter((e=>!t||t===e.toolname)).filter((t=>e||!t.isLocked?.())).forEach((e=>this.removeSource(e,!1)))}),!0)}_removeAllStudiesImpl(){const e=this.dataSources(),t=e.filter(Ws.isStudy).filter((e=>!e.isChildStudy()&&e.removeByRemoveAllStudies())),i=e.filter(Ws.isStudyStub);t.concat(i).forEach((e=>this.removeSource(e,!1)))}_withKeepWidgetPanePositionGuard(e,t){const i=this.m_model.panes().findIndex((e=>e.mode()===zi.PaneMode.Widget)),s=this.m_model.panes().findIndex((e=>e.containsMainSeries()));if(-1===i||-1===s)return void e();const o=i>s;this.beginUndoMacro(t),e();const n=this.m_model.panes().findIndex((e=>e.mode()===zi.PaneMode.Widget)),r=this.m_model.panes().findIndex((e=>e.containsMainSeries()));if(r!==s){const e=o?r+1:r;this.movePane(n,e>n?e-1:e)}this.endUndoMacro()}}class Sm{constructor(){this._ariaElement=null,this._nextAnnouncementTime=Date.now().valueOf(),this._latestDescription="",this._timeoutId=null,this._locale="en"}createElement(e){this._ariaElement=kt(e)}setLocale(e){this._locale=e}async updateChartDescription(e,t,i,s){if("en"!==this._locale)return;let o=`Price ${e.formatter().format(t)}`;if(i){o+=` as of ${Et(i/1e3,s)}`}this._setChartDescription(o)}static getInstance(){return null===this._instance&&(this._instance=new Sm),this._instance}_setChartDescription(e){if(this._latestDescription=e,null!==this._timeoutId)return;const t=Date.now().valueOf();t<this._nextAnnouncementTime?this._timeoutId=setTimeout((()=>{this._timeoutId=null,this._applyChartDescription()}),this._nextAnnouncementTime-t):this._applyChartDescription()}_applyChartDescription(){if(!this._ariaElement)return;this._ariaElement.textContent=this._latestDescription;const e=Date.now().valueOf();this._nextAnnouncementTime=e+2e3}}Sm._instance=null;var bm=i(81360);const wm=a.t(null,void 0,i(47773));class Cm{constructor(e){this._lastResolvedSymbol=null,this._chart=e,this._chart.withModel(this,this._connectToModel)}_getPopupContent(){const e=this._getProSymbol(),t=new URL("https://www.tradingview.com/chart/");t.searchParams.append("symbol",e),t.searchParams.append("utm_source","www.tradingview.com"),t.searchParams.append("utm_medium","widget"),t.searchParams.append("utm_campaign","chart"),t.searchParams.append("utm_term",e);return wm.format({linkStart:`<a target="_blank" href="${t.toString()}">`,linkEnd:"</a>"})}
_onPopupClosed(){const e=this._chart.defaultSymbol(),t=this._getSymbol();let i;i=this._lastResolvedSymbol?this._lastResolvedSymbol:e!==t?e:"AAPL",this._chart.setSymbol(i)}_getProSymbol(){return this._chart.model().mainSeries().proSymbol()}_getSymbol(){return this._chart.model().mainSeries().actualSymbol()}_connectToModel(){const e=this._chart.model().mainSeries();e.dataEvents().symbolResolved().subscribe(this,this._onSymbolResolved),e.dataEvents().symbolGroupNotPermitted().subscribe(this,this._onSymbolGroupNotPermitted),e.dataEvents().symbolNotPermitted().subscribe(this,this.show)}_onSymbolResolved(){this._lastResolvedSymbol=this._getSymbol()}_onSymbolGroupNotPermitted(){this.show()}}class Tm extends Cm{show(){(0,j.showWarning)({title:"Unavailable",html:this._getPopupContent(),onClose:()=>this._onPopupClosed()})}}const Pm=(0,ne.getLogger)("ChartApi.AbstractSession");var xm;!function(e){e[e.Disconnected=0]="Disconnected",e[e.Registered=1]="Registered",e[e.Connected=2]="Connected"}(xm||(xm={}));class Mm{constructor(e,t,i){this._isConnected=new O.WatchedValue(!1),this._state=0,this._isConnectForbidden=!1,this._sessionId="",this._sessionIdChanged=new ae.Delegate,this._chartApi=e,this._sessionPrefix=t,this._shouldReconnectAfterCriticalError=i}destroy(){this._logNormal("Destroying session"),this._isConnected.unsubscribe(),this.disconnect(),this._sessionIdChanged.destroy(),delete this._chartApi,this._logNormal("Session has been destroyed")}isConnected(){return this._isConnected}sessionId(){return this._sessionId}onSessionIdChanged(){return this._sessionIdChanged}connect(){0===this._state&&((0,n.assert)(!this._isConnectForbidden,"Cannot call connect because it is forbidden at this moment"),this._setSessionId(`${this._sessionPrefix}_${(0,fe.randomHash)()}`),this._logNormal("Connecting session - wait until transport stay connected"),this._state=1,this._chartApi.createSession(this._sessionId,this))}disconnect(){0!==this._state&&((0,n.assert)(""!==this._sessionId,"sessionId must not be invalid"),this._logNormal("Disconnecting session..."),this._forbidConnectWhile((()=>{this._chartApi.connected()&&this._sendRemoveSession(),this._processDestroyingOnServer()})))}onMessage(e){switch(e.method){case"connected":return void this._onChartApiConnected();case"disconnected":return void this._onChartApiDisconnected();case"critical_error":const t=String(e.params[0]),i=String(e.params[1]);return void this._onCriticalError(t,i)}this._onMessage(e)}serverTime(){return this._chartApi.serverTime()}_getChartApi(){return this._chartApi}_generateLogMessage(e){return`[${this._sessionId}] ${e}`}_onCriticalError(e,t){this._logError(`Critical error. Reason=${e}, info=${t}.`),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this._shouldReconnectAfterCriticalError?(this._logNormal("Reconnecting after critical error..."),this.connect()):this._logNormal("Reconnecting after critical error skipped")}_onChartApiConnected(){(0,n.assert)(1===this._state,"Session is not registered"),
this._logNormal("Transport is connected. Creating session on the server"),this._sendCreateSession(),this._state=2,this._isConnected.setValue(!0)}_onChartApiDisconnected(){this._logNormal("Transport is disconnected. Reconnecting..."),this._forbidConnectWhile((()=>{this._processDestroyingOnServer()})),this.connect()}_setSessionId(e){const t=this._sessionId;this._logNormal(`Changing sessionId: old=${t}, new=${e}`),this._sessionId=e,this._sessionIdChanged.fire(e,t)}_logNormal(e){Pm.logNormal(this._generateLogMessage(e))}_logError(e){Pm.logError(this._generateLogMessage(e))}_processDestroyingOnServer(){this._state=0,this._isConnected.setValue(!1),this._chartApi.removeSession(this._sessionId),this._setSessionId("")}_forbidConnectWhile(e){this._isConnectForbidden=!0,e(),this._isConnectForbidden=!1}}class Im extends Mm{constructor(e,t=!1){super(e,"cs",!1),this._sessionDisabled=!1,this._handler=null,this._criticalError=new ae.Delegate,this._symbolResolveMap=new Map,this._lastSymbolResolveInfoMap=new Map,this._disableStatistics=t}destroy(){this._criticalError.destroy(),this._handler=null,this._symbolResolveMap.clear(),super.destroy()}switchTimezone(e){return this._getChartApi().switchTimezone(this.sessionId(),e)}defaultResolutions(){return this._getChartApi().defaultResolutions()}availableCurrencies(){return this._getChartApi().availableCurrencies()}availableUnits(){return this._getChartApi().availableUnits()}availablePriceSources(e){return this._getChartApi().availablePriceSources(e)}resolveSymbol(e,t,i){if(this._symbolResolveMap.has(t)){const[e,s]=this._symbolResolveMap.get(t);return Array.isArray(s)?s.push(i):s.then(i),e}{const s=[i];return this._getChartApi().resolveSymbol(this.sessionId(),e,t,(i=>{if("symbol_error"===i.method)this._symbolResolveMap.delete(t);else{this._symbolResolveMap.set(t,[e,Promise.resolve(i)]);const[,s]=i.params,o={pro_name:s.pro_name,ticker:s.ticker};this._lastSymbolResolveInfoMap.set(t,o),o.pro_name&&this._lastSymbolResolveInfoMap.set(o.pro_name,o),s.full_name&&this._lastSymbolResolveInfoMap.set(s.full_name,o),o.ticker&&this._lastSymbolResolveInfoMap.set(o.ticker,o)}s.forEach((e=>e(i)))})),this._symbolResolveMap.set(t,[e,s]),e}}requestFirstBarTime(e,t,i){return this._getChartApi().requestFirstBarTime(this.sessionId(),e,t,i)}lastSymbolResolveInfo(e){return this._lastSymbolResolveInfoMap.get(e)??null}createSeries(e,t,i,s,o,n,r){return this._getChartApi().createSeries(this.sessionId(),e,t,i,s,o,n,r)}modifySeries(e,t,i,s,o,n,r){return this._getChartApi().modifySeries(this.sessionId(),e,t,i,s,o,n,r)}removeSeries(e){return!!this.isConnected().value()&&this._getChartApi().removeSeries(this.sessionId(),e)}requestMoreData(e,t,i){return"number"==typeof e?this._getChartApi().requestMoreData(this.sessionId(),e):this._getChartApi().requestMoreData(this.sessionId(),e,t,i)}requestMoreTickmarks(e,t,i){return this._getChartApi().requestMoreTickmarks(this.sessionId(),e,t,i)}setFutureTickmarksMode(e){return this._getChartApi().setFutureTickmarksMode(this.sessionId(),e)}canCreateStudy(e,t){
return this._getChartApi().canCreateStudy(this.sessionId(),e,t)}getStudyCounter(){return this._getChartApi().getStudyCounter(this.sessionId())}getFundamentalCounter(){return this._getChartApi().getFundamentalCounter(this.sessionId())}createStudy(e,t,i,s,o,n,r){return this._getChartApi().createStudy(this.sessionId(),e,t,i,s,o,n,r)}modifyStudy(e,t,i,s,o){return this._getChartApi().modifyStudy(this.sessionId(),e,t,i,s,o)}notifyStudy(e,t,i){return this._getChartApi().notifyStudy(this.sessionId(),e,t,i)}removeStudy(e){return this._getChartApi().removeStudy(this.sessionId(),e)}createPointset(e,t,i,s,o,n){return this._getChartApi().createPointset(this.sessionId(),e,t,i,s,o,n)}modifyPointset(e,t,i,s){return this._getChartApi().modifyPointset(this.sessionId(),e,t,i,s)}removePointset(e){return this._getChartApi().removePointset(this.sessionId(),e)}setVisibleTimeRange(e,t,i,s,o,n,r){this._getChartApi().setVisibleTimeRange(this.sessionId(),e,t,i,s,!0,o,n,void 0,r)}criticalError(){return this._criticalError}connect(e=null){null!==e&&(this._handler=e),this._symbolResolveMap.clear(),super.connect()}setHandler(e){this._handler=e}connected(){return this.isConnected().value()&&!this._sessionDisabled}disable(){this._sessionDisabled=!0}chartApi(){return this._getChartApi()}_sendCreateSession(){Object.keys(this).forEach((e=>{/^(s|st|symbol_)\d+$/.test(e)&&delete this[e]})),this._getChartApi().chartCreateSession(this.sessionId(),this._disableStatistics)}_sendRemoveSession(){this._getChartApi().chartDeleteSession(this.sessionId())}_onMessage(e){this._handler&&this._handler(e)}_onCriticalError(e,t){this._criticalError.fire(e,t),super._onCriticalError(e,t)}}var Am=i(2433);const Lm=(0,yi.extractThemedColors)(ms.lightTheme.content.mainSourceProperties,ms.darkTheme.content.mainSourceProperties),km="chartproperties.mainSeriesProperties",Em=(0,s.default)((()=>{const e=(0,oc.createPropertySchema)((0,Qe.default)((0,h.factoryDefaults)(km),Am.light.content.mainSourceProperties),7);return(0,Qe.default)(e,{subschema:{priceAxisProperties:{subschema:{lockScale:{saveFlags:6},percentage:{saveFlags:6},percentageDisabled:{saveFlags:6},indexedTo100:{saveFlags:6},log:{saveFlags:6},logDisabled:{saveFlags:6},isInverted:{saveFlags:6},autoScaleDisabled:{saveFlags:6}}},visible:{type:oc.DataTypes.BOOLEAN,saveFlags:2},symbol:{type:oc.DataTypes.STRING,saveFlags:2},shortName:{type:oc.DataTypes.STRING,saveFlags:2},timeframe:{type:oc.DataTypes.STRING,saveFlags:2},interval:{type:oc.DataTypes.STRING,saveFlags:2},currencyId:{type:oc.DataTypes.STRING,saveFlags:2},unitId:{type:oc.DataTypes.STRING,saveFlags:2},style:{type:oc.DataTypes.NUMBER,saveFlags:6},sessionId:{type:oc.DataTypes.STRING,saveFlags:2}}}),e}));class Dm extends yi.DefaultProperty{constructor(){super({defaultName:km,themedColors:Lm,schema:Em()})}}let Bm=null;var Vm=i(89880),Rm=i(29242),Nm=i(84526),Om=i(92572);function Fm(e){
const t=e.model().dataSources(),s=t.filter(Ur.isLineTool).filter((e=>e.isActualSymbol()&&e.isUserDeletable())).length,o=t.filter(Ws.isStudy).filter((e=>e.removeByRemoveAllStudies())).length,n=a.t(null,{plural:"{amount} drawings",count:s,replace:{amount:s.toString()}},i(22299)),r=a.t(null,{plural:"{amount} indicators",count:o,replace:{amount:o.toString()}},i(68984));return{drawings:{label:a.t(null,{replace:{drawings:n}},i(86285)),disabled:0===s},studies:{label:a.t(null,{replace:{indicators:r}},i(87797)),disabled:0===o},all:{label:a.t(null,{replace:{drawings:n,indicators:r}},i(87796)),disabled:0===s&&0===o}}}var Wm=i(59613);function Hm(e){const t=e.options(),s={label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(2569))),statName:"ChangeInterval",onExecute:()=>(0,Wm.showChangeIntervalDialogAsync)({initVal:de.linking.interval.value(),selectOnInit:!0})};return!(0,l.enabled)("show_interval_dialog_on_key_press")||t.readOnly||t.hideSymbolSearch||(s.shortcutHint=",",s.hotkeyGroup=e.hotkeys(),s.hotkeyHash=188),new zo.Action({actionId:"Chart.Dialogs.ShowChangeInterval",options:s})}class zm extends zo.Action{constructor(e,t=new O.WatchedValue(!1)){super({...e,options:{...e.options,checkable:!0,checked:t.value(),onExecute:()=>{this._wv.setValue(!this._wv.value())}}}),this._updateChecked=e=>{this.update({checked:e})},t.subscribe(this._updateChecked),this._wv=t}destroy(){this._wv.unsubscribe(this._updateChecked),super.destroy()}}const Um=(0,l.enabled)("show_average_close_price_line_and_label"),jm=new dt.TranslatedString("scale price chart only",Vm.t(null,void 0,i(63796))),Gm=new dt.TranslatedString("stay in drawing mode",Vm.t(null,void 0,i(4114))),qm=new dt.TranslatedString("hide marks on bars",Vm.t(null,void 0,i(62249))),$m=new dt.TranslatedString("change symbol last value visibility",Vm.t(null,void 0,i(67453))),Km=(new dt.TranslatedString("change symbol previous close value visibility",Vm.t(null,void 0,i(4729))),new dt.TranslatedString("change previous close price line visibility",Vm.t(null,void 0,i(58419))),new dt.TranslatedString("change symbol labels visibility",Vm.t(null,void 0,i(73357)))),Ym=new dt.TranslatedString("change indicators value labels visibility",Vm.t(null,void 0,i(64729))),Zm=new dt.TranslatedString("change indicators name labels visibility",Vm.t(null,void 0,i(24893))),Xm=(new dt.TranslatedString("change bid and ask labels visibility",Vm.t(null,void 0,i(69362))),new dt.TranslatedString("change bid and ask lines visibility",Vm.t(null,void 0,i(52919))),new dt.TranslatedString("change pre/post market price label visibility",Vm.t(null,void 0,i(30870))),new dt.TranslatedString("change pre/post market price line visibility",Vm.t(null,void 0,i(11718))),
new dt.TranslatedString("change high and low price labels visibility",Vm.t(null,void 0,i(24226)))),Jm=new dt.TranslatedString("change high and low price lines visibility",Vm.t(null,void 0,i(80692))),Qm=new dt.TranslatedString("change average close price label visibility",Vm.t(null,void 0,i(76852))),eg=new dt.TranslatedString("change average close price line visibility",Vm.t(null,void 0,i(1022))),tg=new dt.TranslatedString("change countdown to bar close visibility",Vm.t(null,void 0,i(39383))),ig=new dt.TranslatedString("change plus button visibility",Vm.t(null,void 0,i(96379))),sg=new dt.TranslatedString("change session breaks visibility",Vm.t(null,void 0,i(38413))),og=new dt.TranslatedString("change price line visibility",Vm.t(null,void 0,i(8662))),ng=new dt.TranslatedString("change timezone",Vm.t(null,void 0,i(20137)));function rg(e){const t=e.hotkeys(),s=e.model(),o=e.options(),n=e.properties(),r=new zo.Action({actionId:"Chart.Series.PriceScale.ToggleInvertPriceScale",options:{label:Vm.t(null,void 0,i(37189)),statName:"Invert Scale",checkable:!0,onExecute:()=>s.invertPriceScale(s.mainSeries().priceScale()),hotkeyGroup:t,hotkeyHash:B.Modifiers.Alt+73}}),c=new zo.Action({actionId:"Chart.Series.PriceScale.ToggleAutoScale",options:{label:Vm.t(null,void 0,i(24157)),checkable:!0,onExecute:e=>{const t=s.mainSeries().priceScale();s.togglePriceScaleAutoScaleMode(t),e.update({checked:t.isAutoScale()})}}}),h=new zo.Action({actionId:"Chart.Scales.ToggleLockPriceToBarRatio",options:{label:Vm.t(null,void 0,i(14017)),checkable:!0,statName:"ToggleLockScale",onExecute:()=>s.togglePriceScaleLockScaleMode(s.mainSeries().priceScale())}}),d=new zo.Action({actionId:"Chart.Series.PriceScale.ToggleRegular",options:{label:Vm.t(null,{context:"scale_menu"},i(55300)),checkable:!0,statName:"ToggleRegularScale",onExecute:e=>{const t=s.mainSeries().priceScale();s.setPriceScaleRegularScaleMode(t),e.update({checked:t.isRegular()})}}}),u=new zo.Action({actionId:"Chart.Series.PriceScale.TogglePercentage",options:{label:Vm.t(null,void 0,i(6919)),checkable:!0,statName:"TogglePercantage",onExecute:()=>s.togglePriceScalePercentageScaleMode(s.mainSeries().priceScale()),hotkeyGroup:t,hotkeyHash:B.Modifiers.Alt+80}}),_=new zo.Action({actionId:"Chart.Series.PriceScale.ToggleIndexedTo100",options:{label:Vm.t(null,void 0,i(89999)),checkable:!0,statName:"ToggleIndexedTo100",onExecute:()=>s.togglePriceScaleIndexedTo100ScaleMode(s.mainSeries().priceScale())}}),p=new zo.Action({actionId:"Chart.Series.PriceScale.ToggleLogarithmic",options:{label:Vm.t(null,void 0,i(16170)),statName:"ToggleLogScale",checkable:!0,onExecute:()=>s.togglePriceScaleLogScaleMode(s.mainSeries().priceScale()),hotkeyGroup:t,hotkeyHash:B.Modifiers.Alt+76}}),m=new zo.Action({actionId:"Chart.ChangeTimeZone",options:{label:Vm.t(null,void 0,i(20909)),statName:"TimeZone",onDestroy:()=>e.properties().childs().timezone.unsubscribeAll(m)}}),g=e.properties().childs().timezone,f=()=>{const t=[],i=Pe.availableTimezones,s=e=>e.id===g.value();i.forEach((i=>{const o=new zo.Action({
actionId:"Chart.ChangeTimeZone",options:{label:i.title,checkable:!0,checked:s(i),statName:"SetTimeZone",onExecute:()=>{e.model().setProperty(g,i.id,ng)}}});t.push(o)})),m.update({subItems:t})};f(),g.subscribe(m,f);const y=new Ko.ActionWithStandardIcon({actionId:"Chart.TimeScale.Reset",options:{label:Vm.t(null,void 0,i(54170)),iconId:"Chart.Reset",statName:"ResetScale",onExecute:()=>s.resetTimeScale(),hotkeyGroup:e.hotkeys(),hotkeyHash:B.Modifiers.Mod+B.Modifiers.Alt+81}}),v=new zo.Action({actionId:"Chart.Dialogs.ShowInsertIndicators",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(87829))),statName:"InsertIndicator",onExecute:()=>e.showIndicators(),...o.indicatorsDialogShortcutEnabled?{hotkeyGroup:t,hotkeyHash:191}:void 0}}),S=new zo.Action({actionId:"Chart.Dialogs.ShowCompareOrAddSymbol",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(53942))),statName:"CompareOrAddSymbol",onExecute:()=>e.toggleCompareOrAdd()}}),b=new Ko.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowGeneralSettings",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(32514))),iconId:"Settings",statName:"ChartProperties",onExecute:()=>e.showGeneralChartProperties()}}),w=new Ko.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowGeneralSettings.SymbolTab",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(32514))),iconId:"Settings",statName:"MainSeriesProperties",onExecute:()=>e.showGeneralChartProperties(Ns.TabNames.symbol)}}),C=new Ko.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowGeneralSettings.ScalesTab",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(93907))),iconId:"Settings",statName:"ScalesProperties",onExecute:()=>e.showGeneralChartProperties(Ns.TabNames.scales)}}),T=new zo.Action({actionId:"Chart.SelectedObject.ToggleLocked",options:{label:Vm.t(null,void 0,i(79777)),statName:"ToggleLockSelectedObject",onExecute:()=>e.toggleLockSelectedObject()}}),P=new Ko.ActionWithStandardIcon({actionId:"Chart.SelectedObject.Hide",options:{label:Vm.t(null,void 0,i(27298)),iconId:"Chart.Hide",statName:"HideSelectedObject",onExecute:()=>e.hideSelectedObject()}}),x=new jo({actionId:"Chart.PriceScale.ToggleAutoScaleSeriesOnly",options:{label:Vm.t(null,void 0,i(43758)),checkable:!0,statName:"ScalePriceChartOnly"}},{property:n.childs().scalesProperties.childs().scaleSeriesOnly,undoModel:s,undoText:jm}),M=new zm({actionId:"Chart.DrawingToolbar.ToggleVisibility",options:{label:Vm.t(null,void 0,i(93864)),statName:"ToggleDrawingToolbar"}},o.isDrawingToolbarVisible),I=new jo({actionId:"",options:{label:Vm.t(null,void 0,i(99901)),checkable:!0,statName:"ToggleStayInDrawingMode"}},{property:mt.properties().childs().stayInDrawingMode,undoModel:s,undoText:Gm}),A=new jo({actionId:"Chart.Marks.ToggleVisibility",options:{label:Vm.t(null,void 0,i(28345)),checkable:!0,statName:"ToggleHideMarksOnBars"}},{property:mt.hideMarksOnBars(),undoModel:s,undoText:qm,callback:e=>mt.hideMarksOnBars().setValue(e.isChecked())}),L=new jo({actionId:"Chart.PriceScale.Labels.ToggleSeriesLastValueVisibility",options:{label:Vm.t(null,void 0,i(10127)),
checkable:!0,checked:!1,statName:"ToggleSymbolLastValue"}},{property:n.childs().scalesProperties.childs().showSeriesLastValue,undoModel:s,undoText:$m}),k=new jo({actionId:"Chart.PriceScale.Labels.ToggleSymbolNameLabelsVisibility",options:{label:Vm.t(null,void 0,i(32390)),checkable:!0,checked:!1,statName:"ToggleSymbolLabels"}},{property:n.childs().scalesProperties.childs().showSymbolLabels,undoModel:s,undoText:Km}),E=(0,_d.combineProperty)(((e,t)=>e||!1),n.childs().scalesProperties.childs().showStudyLastValue.weakReference(),n.childs().scalesProperties.childs().showFundamentalLastValue.weakReference()),D=new jo({actionId:"Chart.PriceScale.Labels.ToggleIndicatorsValueLabelsVisibility",options:{label:Vm.t(null,void 0,i(46850)),checkable:!0,checked:!1,statName:"ToggleStudiesAndFundamentalsPriceLabels",onDestroy:()=>{E.destroy()}}},{property:E,undoModel:s,undoText:null,callback:()=>{const e=!E.value();s.beginUndoMacro(Ym),s.setProperty(n.childs().scalesProperties.childs().showStudyLastValue,e,null),s.endUndoMacro()}}),V=(0,_d.combineProperty)(((e,t)=>e||!1),n.childs().scalesProperties.childs().showStudyPlotLabels.weakReference(),n.childs().scalesProperties.childs().showFundamentalNameLabel.weakReference()),R=new jo({actionId:"Chart.PriceScale.Labels.ToggleIndicatorsNameLabelsVisibility",options:{label:Vm.t(null,void 0,i(54418)),checkable:!0,checked:!1,statName:"ToggleStudiesAndFundamentalsNameLabels",onDestroy:()=>{V.destroy()}}},{property:V,undoModel:s,undoText:null,callback:()=>{const e=!V.value();s.beginUndoMacro(Zm),s.setProperty(n.childs().scalesProperties.childs().showStudyPlotLabels,e,null),s.endUndoMacro()}}),N=s.mainSeries().properties().childs().highLowAvgPrice.childs(),O=new jo({actionId:"Chart.PriceScale.Labels.ToggleHighLowPriceLabelsVisibility",options:{label:Vm.t(null,void 0,i(99479)),checkable:!0,checked:!1,statName:"ToggleHighLowPriceLabels"}},{property:N.highLowPriceLabelsVisible,undoModel:s,undoText:Xm}),F=new jo({actionId:"Chart.Lines.ToggleHighLowLinesVisibility",options:{label:Vm.t(null,void 0,i(33766)),checkable:!0,checked:!1,statName:"ToggleHighLowPriceLine"}},{property:N.highLowPriceLinesVisible,undoModel:s,undoText:Jm}),W=new jo({actionId:"Chart.PriceScale.ToggleCountdownToBarCloseVisibility",options:{label:Vm.t(null,void 0,i(83140)),checkable:!0,checked:!1,statName:"ToggleCountdown"}},{property:s.mainSeries().properties().childs().showCountdown,undoModel:s,undoText:tg}),H=new jo({actionId:"Chart.PriceScale.ToggleAddOrderPlusButtonVisibility",options:{label:Vm.t(null,void 0,i(71566)),checkable:!0,checked:lu.addPlusButtonProperty.value(),statName:"ToggleAddOrderPlusButton"}},{property:lu.addPlusButtonProperty,undoModel:s,undoText:ig}),z=new Ko.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowSymbolInfo",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(75594))),iconId:"Chart.SymbolInfo",checkable:!1,statName:"SymbolInfo",onExecute:()=>{{const t=e.model().model(),i=t.mainSeries().symbolInfo();if(i){const e=t.availableUnits(),s=t.unitConversionEnabled();(0,Nm.showSymbolInfoDialog)({
symbolInfo:i,showUnit:s,unitDescription:t=>t?e.description(t):"",dateFormatter:t.dateFormatter()})}}}}}),U=new zo.Action({actionId:"Chart.PriceScale.MergeAllScalesToLeft",options:{label:Vm.t(null,void 0,i(62329)),statName:"MergeAllScalesToLeft",onExecute:()=>s.mergeAllScales("left")}}),j=new zo.Action({actionId:"Chart.PriceScale.MergeAllScalesToRight",options:{label:Vm.t(null,void 0,i(55813)),statName:"MergeAllScalesToRight",onExecute:()=>s.mergeAllScales("right")}}),G=new zo.Action({actionId:"Chart.PriceScale.MoveToLeft",options:{label:Vm.t(null,void 0,i(26493)),statName:"MoveScaleToLeft",onExecute:()=>s.mergeAllScales("left")}}),q=new zo.Action({actionId:"Chart.PriceScale.MoveToRight",options:{label:Vm.t(null,void 0,i(40789)),statName:"MoveScaleToRight",onExecute:()=>s.mergeAllScales("right")}}),$=new Ko.ActionWithStandardIcon({actionId:"Chart.Scales.Reset",options:{label:Vm.t(null,void 0,i(75246)),iconId:"Chart.Reset",statName:"ResetChart",onExecute:()=>e.GUIResetScales(),hotkeyGroup:t,hotkeyHash:B.Modifiers.Alt+82}}),K=e.model().model().sessions().properties().childs().sessionHighlight.childs().vertlines.childs().sessBreaks.childs().visible,Y=(0,_d.createWVFromProperty)(e.model().mainSeries().isDWMProperty()),Z=new zo.Action({actionId:"Chart.SessionBreaks.ToggleVisibility",options:{label:Vm.t(null,void 0,i(66707)),checkable:!0,checked:K.value(),statName:"ToggleSessionBreaks",disabled:Y.value(),onExecute:()=>{K&&s.setProperty(K,!K.value(),sg)},onDestroy:()=>Y.destroy()}});Y.subscribe((()=>Z.update({disabled:Y.value()})));const X=new jo({actionId:"Chart.Lines.ToggleSeriesPriceLineVisibility",options:{label:Vm.t(null,void 0,i(72926)),checkable:!0,statName:"TogglePriceLine"}},{property:s.mainSeries().properties().childs().showPriceLine,undoModel:s,undoText:og}),J=new zo.Action({actionId:"Chart.Undo",options:{label:Vm.t(null,void 0,i(14804)),onExecute:()=>{(0,re.trackEvent)("GUI","Undo"),s.undoHistory().undo()},onDestroy:()=>{e.model().undoHistory().undoStack().onChange().unsubscribeAll(J)},disabled:!0,hotkeyGroup:t,hotkeyHash:B.Modifiers.Mod+90,isRepeatAccepted:!0}});e.model().undoHistory().undoStack().onChange().subscribe(J,(()=>J.update({disabled:e.model().undoHistory().undoStack().isEmpty()})));const Q=new zo.Action({actionId:"Chart.Redo",options:{label:Vm.t(null,void 0,i(48236)),onExecute:()=>{(0,re.trackEvent)("GUI","Redo"),e.model().undoHistory().redo()},onDestroy:()=>{e.model().undoHistory().redoStack().onChange().unsubscribeAll(Q)},disabled:!0,hotkeyGroup:t,hotkeyHash:B.Modifiers.Mod+89,isRepeatAccepted:!0}});e.model().undoHistory().redoStack().onChange().subscribe(Q,(()=>Q.update({disabled:e.model().undoHistory().redoStack().isEmpty()})));const ee={invertSeriesScale:r,autoSeriesScale:c,lockSeriesScale:h,regularSeriesScale:d,percentSeriesScale:u,indexedTo100SeriesScale:_,logSeriesScale:p,applyTimeZone:m,symbolSearch:new zo.Action({actionId:"Chart.Dialogs.ShowChangeSymbol",options:{label:(0,Rm.appendEllipsis)(a.t(null,void 0,i(85124))),statName:"ChangeSymbol",onExecute:()=>{(0,vs.showDialog)({defaultValue:"",
trackResultsOptions:{trackResults:!1,emptySearchType:"empty_result__supercharts"},enableOptionsChain:l.enabled("symbol_search_option_chain_selector")})}}}),changeInterval:Hm(e),timeScaleReset:y,insertIndicator:v,compareOrAdd:S,chartProperties:b,mainSeriesPropertiesAction:w,scalesProperties:C,lineToggleLock:T,seriesHide:P,studyHide:P,lineHide:P,scaleSeriesOnly:x,drawingToolbarAction:M,stayInDrawingModeAction:I,hideAllMarks:A,showSeriesLastValue:L,showSymbolLabelsAction:k,showStudyLastValue:D,showStudyPlotNamesAction:R,showHighLowPriceLabels:O,showHighLowPriceLines:F,showCountdown:W,addPlusButton:H,showSymbolInfoDialog:z,mergeLeftScalesAction:U,mergeRightScalesAction:j,moveScaleToLeft:G,moveScaleToRight:q,chartReset:$,sessionBreaks:Z,showPriceLine:X,undo:J,redo:Q};if(o.goToDateEnabled&&(ee.gotoDate=new zo.Action({actionId:"Chart.Dialogs.ShowGoToDate",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(54280))),statName:"GoToDate",onExecute:()=>(0,Om.showGoToDateDialog)(e.chartWidgetCollection().activeChartWidget.value()),hotkeyGroup:t,hotkeyHash:B.Modifiers.Alt+71}})),(0,l.enabled)("show_object_tree")&&(ee.paneObjectTree=new zo.Action({actionId:"Chart.ObjectTree.Show",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(51221))),statName:"ObjectsTree",onExecute:()=>e.showObjectsTreePanelOrDialog()}})),(0,l.enabled)("property_pages")&&(ee.format=new Ko.ActionWithStandardIcon({actionId:"Chart.SelectedObject.ShowSettingsDialog",options:{label:(0,Rm.appendEllipsis)(Vm.t(null,void 0,i(32514))),iconId:"Settings",statName:"EditSelectedObject",onExecute:()=>e.showSelectedSourcesProperties()}})),Um&&(ee.showAverageClosePriceLabel=new jo({actionId:"Chart.PriceScale.Labels.ToggleAveragePriceLabelVisibility",options:{label:Vm.t(null,void 0,i(21841)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLabel"}},{property:N.averageClosePriceLabelVisible,undoModel:s,undoText:Qm}),ee.showAverageClosePriceLine=new jo({actionId:"Chart.Lines.ToggleAverageLineVisibility",options:{label:Vm.t(null,void 0,i(16138)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLine"}},{property:N.averageClosePriceLineVisible,undoModel:s,undoText:eg})),!e.readOnly()){const s=function(e){const t=Fm(e),i=new zo.Action({actionId:"Chart.RemoveAllLineTools",options:{label:t.drawings.label,disabled:t.drawings.disabled,statName:"RemoveAllDrawingTools",onExecute:()=>e.removeAllDrawingTools(),onDestroy:()=>e.model().model().dataSourceCollectionChanged().unsubscribeAll(e)}}),s=new zo.Action({actionId:"Chart.RemoveAllIndicators",options:{label:t.studies.label,disabled:t.studies.disabled,statName:"RemoveAllIndicators",onExecute:()=>e.removeAllStudies()}}),o=new zo.Action({actionId:"Chart.RemoveAllIndicatorsAndLineTools",options:{label:t.all.label,disabled:t.all.disabled,statName:"RemoveAllIndicatorsAndDrawingTools",onExecute:()=>e.removeAllStudiesDrawingTools()}});return e.model().model().dataSourceCollectionChanged().subscribe(e,(()=>{const{studies:t,drawings:n,all:r}=Fm(e);s.update({disabled:t.disabled,label:t.label}),i.update({
disabled:n.disabled,label:n.label}),o.update({disabled:r.disabled,label:r.label})})),{drawings:i,studies:s,all:o}}(e);ee.paneRemoveAllStudies=s.studies,ee.paneRemoveAllDrawingTools=s.drawings,ee.paneRemoveAllStudiesDrawingTools=s.all,ee.applyStudiesToAllCharts=new zo.Action({actionId:"Chart.ApplyIndicatorsToAllCharts",options:{label:Vm.t(null,void 0,i(22437)),statName:"ApplyIndicatorsToAllCharts",onExecute:()=>e.chartWidgetCollection().applyIndicatorsToAllCharts(e)}}),ee.studyRemove=ee.lineRemove=new Ko.ActionWithStandardIcon({actionId:"Chart.SelectedObject.Remove",options:{label:Vm.t(null,void 0,i(67410)),iconId:"Chart.RemoveSelectedObject",statName:"RemoveSelectedObject",onExecute:()=>{(e.chartWidgetCollection().activeChartWidget.value()??e).removeSelectedSources()},hotkeyGroup:t,hotkeyHash:B.isMacKeyboard?8:46}})}return ee}var ag,lg=i(19334),cg=i(16708),hg=i(57340);!function(e){e[e.ShowDelay=400]="ShowDelay",e[e.WindowWidthLimit=767]="WindowWidthLimit"}(ag||(ag={}));class dg extends Error{constructor(){super("Cannot show floating tooltip")}}class ug{constructor(e,t){this._floatingTooltip=void 0,this._cursorPosition=new yt.WatchedObject(null),this._destroyController=new AbortController,this._chartWidget=e,this._maximizedChartWidget=t.spawn(),this._visible=(0,ft.combine)((e=>!!e),e.activePaneWidget().weakReference())}destroy(){this._cursorPosition.destroy(),this._visible.destroy(),this._maximizedChartWidget.destroy(),this._destroyController.abort()}async mouseDownEvent(e){const{target:t,button:i}=e;if(0===i&&window.innerWidth>767&&t instanceof HTMLCanvasElement&&this._chartWidget.paneWidgets().some((e=>e.hasCanvas(t)))){const t=(0,Vt.point)(e.pageX,e.pageY);try{await this._awaitBeforeShow()}catch{return}const i=new AbortController,r=()=>i.abort();window.addEventListener("mouseup",r,{once:!0}),this._destroyController.signal.addEventListener("abort",r,{once:!0}),s=this._maximizedChartWidget,o=e=>{null!==e&&e!==this._chartWidget&&r()},(n=i.signal).aborted||(s.subscribe(o),n.addEventListener("abort",(()=>s.unsubscribe(o)),{once:!0}));try{await this._show(t,i.signal)}catch(t){if(t instanceof dg)return void r();throw e}}var s,o,n}mouseMoveEvent(e){return!!(this._floatingTooltip&&1&e.buttons)&&(this._cursorPosition.setValue((0,Vt.point)(e.pageX,e.pageY)),!0)}async _awaitBeforeShow(){const e=new AbortController,t=()=>e.abort();this._destroyController.signal.addEventListener("abort",t,{once:!0}),window.addEventListener("mouseup",t),window.addEventListener("mousemove",t);try{await(0,J.delay)(e.signal,400)}finally{this._destroyController.signal.removeEventListener("abort",t),window.removeEventListener("mouseup",t),window.removeEventListener("mousemove",t)}}async _show(e,t){const[{createChartFloatingTooltip:s},{createViewState:o}]=await Promise.all([Promise.all([i.e(6729),i.e(7691),i.e(9646),i.e(2227),i.e(8093),i.e(2962)]).then(i.bind(i,64624)),Promise.all([i.e(6729),i.e(7691),i.e(9646),i.e(2227),i.e(8093),i.e(2962)]).then(i.bind(i,10978))]);if(!t.aborted){if(!this._canShowTooltip())throw new dg
;t.addEventListener("abort",(()=>this._destroyFloatingTooltip()),{once:!0});try{this._chartWidget.model().model().setChartFloatingTooltipVisible(!0),this._floatingTooltip=s(o(this._chartWidget,this._cursorPosition,this._visible.weakReference()),this._chartWidget.model().model().dark().weakReference()),this._cursorPosition.setValue(e),d.setValue("hint.chartFloatingTooltipActivationHint",!1,{forceFlush:!0})}catch{throw new dg}}}_destroyFloatingTooltip(){this._cursorPosition.setValue(null),this._floatingTooltip&&(this._floatingTooltip.destroy(),this._floatingTooltip=void 0),this._chartWidget.model().model().setChartFloatingTooltipVisible(!1)}_canShowTooltip(){const e=this._chartWidget.model().model(),t=mt.tool.value();if(null!==e.lineBeingEdited()||null!==e.lineBeingCreated()||e.sourcesBeingMoved().length>0||null!==e.customSourceBeingMoved()||(0,mt.toolIsMeasure)(t)||(0,mt.toolIsEraser)(t)||e.crosshairSource().crosshairDemonstration().isThereUnfinishedHighlighter())return!1;const i=e.hoveredSource();return!!(null===i||(0,Ws.isStudy)(i)||(0,Po.isDataSource)(i)&&(0,qc.isSeries)(i))}}let _g=!1;function pg(e,t){!_g&&window.innerWidth>767&&l.enabled("popup_hints")&&d.getBool("hint.chartFloatingTooltipActivationHint",!0)&&(_g=!0,Promise.all([i.e(8535),i.e(1171),i.e(6195),i.e(3476),i.e(2227),i.e(5572)]).then(i.bind(i,18299)).then((i=>{t.signal.aborted||i.showActivationHint(e,t)})))}i(3980);var mg=i(8811);const gg=(0,ne.getLogger)("ChartWidget",{color:"#606"}),fg=l.enabled("chart_content_overrides_by_defaults"),yg=l.enabled("long_press_floating_tooltip"),vg=new dt.TranslatedString("hide {title}",a.t(null,void 0,i(13017))),Sg=new dt.TranslatedString("unlock {title}",a.t(null,void 0,i(12525))),bg=new dt.TranslatedString("lock {title}",a.t(null,void 0,i(76104))),wg=new dt.TranslatedString("change session",a.t(null,void 0,i(87041)));const Cg={addToWatchlistEnabled:!0,showFinancialsEnabled:!1,sourceSelectionEnabled:!0,propertyPagesEnabled:!0,paneContextMenuEnabled:!0,priceScaleContextMenuEnabled:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,goToDateEnabled:!1,marketStatusWidgetEnabled:!0,chartWarningWidgetEnabled:!0,dataProblemWidgetEnabled:!0,paneControlsEnabled:!0,isSymbolAvailable:e=>Promise.resolve(!0),legendWidgetEnabled:!0,chartEventsEnabled:!0,newsNotificationsEnabled:!0,esdEnabled:!1,latestUpdatesEnabled:!1,continuousContractSwitchesEnabled:!1,futuresContractExpirationEnabled:!1,croppedTickMarks:!0,countdownEnabled:!0,lastPriceAnimationEnabled:!0,useKineticScroll:ze.CheckMobile.any(),indicatorsDialogShortcutEnabled:!0,handleScale:{mouseWheel:!0,pinch:!0,axisPressedMouseMove:{time:!0,price:!0}},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0}},Tg=(0,yi.extractThemedColors)(ms.lightTheme.content.chartProperties,ms.darkTheme.content.chartProperties);var Pg;function xg(e,t,i,s=0){const o=t.mainSeries().syncModel(),n=e.mainSeries().syncModel();let r=i;if(null!==o&&null!==n){const t=e.createSyncPoint(o.syncSourceTarget(),n.syncSourceTarget());0!==s&&(i=o.projectTime(i,s)),
r=t.sourceTimeToTargetTime(i)}return e.timeScale().points().roughIndex(r,n&&n.distance.bind(n))}!function(e){e[e.ShowTimeAxisMinChartHeight=61]="ShowTimeAxisMinChartHeight",e[e.ShowPriceAxisMinChartWidth=102]="ShowPriceAxisMinChartWidth"}(Pg||(Pg={}));const Mg=new Set(["Volume@tv-basicstudies","Compare@tv-basicstudies","Overlay@tv-basicstudies","Dividends@tv-basicstudies","Earnings@tv-basicstudies","Splits@tv-basicstudies","BarSetContinuousRollDates@tv-corestudies","Sessions@tv-basicstudies","InactivityGaps@tv-basicstudies","VbPSessionsRough@tv-volumebyprice","AnchoredVWAP@tv-basicstudies","RegressionTrend@tv-basicstudies","VbPAnchored@tv-basicstudies","VbPFixed@tv-basicstudies","VbPFixed@tv-volumebyprice","LongShortPosition@tv-basicstudies"]),Ig=(0,s.default)((()=>{window.ChartApiInstance.setIsNonCountedStudyFn((e=>Mg.has(e)))}));var Ag;!function(e){e.Canceled="canceled",e.Limits="limits"}(Ag||(Ag={}));class Lg extends Error{constructor(e){super(`CreateStudyError: ${e}`),this.reason=e}}Lg.Reasons=Ag;class kg{constructor(e,t){this._activePaneWidget=new O.WatchedValue(null),this._model=null,this._mainDiv=null,this._parent=null,this._elTooltipDiv=null,this._paneWidgets=new O.WatchedValue([]),this._timeAxisWidget=null,this._paneSeparators=[],this._controlBarNavigation=null,this._lineToolsSynchronizer=null,this._lineToolsSynchronizerHasChanges=null,this._modelCreated=new ae.Delegate,this._isDestroyed=!1,this._customLegendWidgetsFactoryMap=new Map,this._backgroundTopTheme=new O.WatchedValue("light"),this._backgroundBasedTheme=new O.WatchedValue("light"),this._backgroundBottomTheme=new O.WatchedValue("light"),this._backgroundTopColorSpawn=null,this._backgroundBottomColorSpawn=null,this._lhsAxesWidth=0,this._rhsAxesWidth=0,this._lhsPriceAxisWidthChanged=new ae.Delegate,this._rhsPriceAxisWidthChanged=new ae.Delegate,this._hotkeysListener=null,this._mouseWheelHelper=null,this._onWheelBound=null,this._justActivated=!1,this._inited=!1,this._containsData=!1,this._initialLoading=!1,this._onWidget=!1,this._widgetCustomer=void 0,this._defInterval=null,this._defStyle=null,this._defTimeframe=null,this._removeMaximizeHotkey=null,this._invalidationMask=null,this._drawPlanned=!1,this._drawRafId=0,this._inLoadingState=!1,this._timingsMeter=null,this._tagsChanged=new ae.Delegate,this._redraw=new ae.Delegate,this._isVisible=new O.WatchedValue(!0),this._collapsed=new O.WatchedValue(!1),this._dataWindowWidget=null,this._resizeHandler=null,this._spinner=null,this._symbolWV=new O.WatchedValue,this._resolutionWV=new O.WatchedValue,this._actions=null,this._updateThemedColorBound=this._updateThemedColor.bind(this),this._disconnected=new ae.Delegate,this._reconnectBailout=new ae.Delegate,this._connected=new ae.Delegate,this._chartWidgetInitialized=new ae.Delegate,this._aboutToBeDestroyed=new ae.Delegate,this._saveChartService=null,this._objectTreeDialogController=null,this._chartPaintedPromise=null,this._noExchangeSubscrptionWarning=null,this._paneWidgetsSharedState=new ar,this._onZoom=new ae.Delegate,this._onScroll=new ae.Delegate,
this._availableScreen=null,this._widgetSymbolChangeRestrictions=null,this._hoveredPriceAxes=new Set,this._anyAxisHovered=new O.WatchedValue(!1),this._linkingGroupIndex=new O.WatchedValue(null),this._isHovered=new O.WatchedValue(!1),this._activeHint=null,this._eventHintDeferredPromise=null,this._warningHintDeferredPromise=null,this._setSymbolIntervalContentOverrides={},this._ariaPriceDescription=null,this._definitionsViewModel=null,this._barsButton=null,this._chartFloatingTooltipController=null,this._tooltipPopupHintDestroySignal=null,this._updateScalesActions=()=>{const e=this.actions(),t=this.model().mainSeries(),i=t.priceScale(),s=t.properties(),o=i.isLockScale(),n=6===s.childs().style.value();e.percentSeriesScale.update({disabled:o||n,checked:i.isPercentage()}),e.logSeriesScale.update({disabled:o||n,checked:i.isLog()}),e.regularSeriesScale.update({disabled:o||n,checked:i.isRegular()}),e.indexedTo100SeriesScale.update({disabled:o||n,checked:i.isIndexedTo100()}),e.invertSeriesScale.update({checked:i.isInverted()}),e.lockSeriesScale.update({checked:i.isLockScale()}),e.autoSeriesScale.update({checked:i.isAutoScale(),disabled:i.properties().childs().autoScaleDisabled.value()})},this._onChartFloatingTooltipEnabledChanged=()=>{hg.chartFloatingTooltipEnabledWV.value()?this._chartFloatingTooltipController=new ug(this,this._chartWidgetCollection.maximizedChartWidget()):(this._chartFloatingTooltipController?.destroy(),this._chartFloatingTooltipController=null)},this._invalidationHandler=e=>{if(!(e instanceof ao.InvalidationMask))throw new Error("Invalid mask");null!==this._invalidationMask?this._invalidationMask.merge(e):this._invalidationMask=e,this._drawPlanned||(this._drawPlanned=!0,this._options.visible.when((()=>{const e=!document.hidden,t=this.screen&&this.screen.isShown();null!==this._timingsMeter&&e&&!t&&this._timingsMeter.startWaitingDraw();const i=(0,n.ensureNotNull)((0,n.ensureNotNull)(this._parent).ownerDocument.defaultView);this._drawRafId=i.requestAnimationFrame(this._invalidationRAFCallback.bind(this))})))},this._onChartSessionIsConnectedChanged=e=>{e?this._onConnection():this._onDisconnect()},this._subscribeToBanInfo=e=>{e?this._spinner?.stop():this._spinner?.spin()},this._id=t,this._options=(0,tt.merge)((0,tt.clone)(Cg),e),this._chartWidgetCollection=this._options.chartWidgetCollection,this._isActive=new O.WatchedValue(!!this._options.isActive),this._options.customLegendWidgetFactories&&(this._customLegendWidgetsFactoryMap=this._options.customLegendWidgetFactories),this._subscribeToDrawingState(),this.withModel(this,(()=>{const e=this.model().model();e.backgroundTopColor().subscribe(this._updateThemedColorBound),e.backgroundColor().subscribe(this._updateThemedColorBound),hg.chartFloatingTooltipEnabledWV.subscribe(this._onChartFloatingTooltipEnabledChanged,{callWithLast:!0})}));const i=(0,mg.createWVFromGetterAndSubscription)((()=>this.hasModel()?this.model().model():null),this._modelCreated),s=(0,
ft.combine)((e=>[e?e.mainSeries().symbolInfoWV().weakReference():new O.WatchedValue(null).ownership()]),i.ownership());this._symbolInfoWV=(0,ft.accumulate)((e=>e[0]),s.ownership()).ownership(),this._errorRenderer=new oo(this),this._scrollHelper=new Rs(this),this._objectTreeDialogController=ws.getInstance(),this._properties=new yi.DefaultProperty({defaultName:"chartproperties",useUserPreferences:this._options.useUserChartPreferences,excludedDefaultsKeys:["scalesProperties.axisHighlightColor","scalesProperties.axisLineToolLabelBackgroundColorActive","scalesProperties.axisLineToolLabelBackgroundColorCommon","scalesProperties.showPriceScaleCrosshairLabel","scalesProperties.showTimeScaleCrosshairLabel","scalesProperties.crosshairLabelBgColorLight","scalesProperties.crosshairLabelBgColorDark","alertsProperties","mainSeriesProperties"],excludedTemplateKeys:["timezone","tradingProperties","mainSeriesProperties","chartEventsSourceProperties","priceScaleSelectionStrategyName","paneProperties.horzGridProperties.style","paneProperties.vertGridProperties.style","paneProperties.topMargin","paneProperties.bottomMargin","volumePaneSize","alertsProperties"],excludedStateKeys:["alertsProperties","mainSeriesProperties"],themedColors:Tg}),this._mainSeriesProperties=new Dm,this._startSpinner(this._options.container.value()),this._chartSession=new Im(window.ChartApiInstance),Ig(),this._isMultipleLayout=(0,ft.combine)((e=>(0,ut.isMultipleLayout)(e)),this._chartWidgetCollection.layout.weakReference()),this._properties.childs().scalesProperties.childs().scaleSeriesOnly.subscribe(null,(()=>{const e=this.model().model();e.recalculateAllPanes((0,wi.viewportChangeEvent)()),e.invalidate(ao.InvalidationMask.full())})),this._hotkeys=D.createGroup({desc:"Chart actions",isDisabled:()=>!this.isActive().value()}),this._ariaPriceDescription=Sm.getInstance(),this.withModel(this,(()=>{this.model().crosshairSource().moved().subscribe(this,this._updateAriaPriceDescription)})),this._compareDialog=this._chartWidgetCollection.getCompareDialogRenderer(),this._options.timeScaleWidget&&(this._options.timeScaleWidget.pressedMouseMoveScale=this._options.handleScale.axisPressedMouseMove.time);const o=this._options.onCmeWidget;o&&gg.logWarn("[ChartWidget] 'onCmeWidget' option is depricated");const r=this._options.widgetCustomer,a=this._options.timezone;let l=this._options.defSymbol??"",c=Re.Interval.isValid(this._options.defInterval)?this._options.defInterval:null;const d=this._options.defStyle;let u=(0,xt.isValidStyle)(d)?d:null;const _=this._options.defSessionId,p=void 0!==this._options.defTimeframe?"string"==typeof this._options.defTimeframe?{value:this._options.defTimeframe.toUpperCase(),type:"period-back"}:{...this._options.defTimeframe,type:"time-range"}:null;this._content=this._options.content,this._initialLoading=this._options.initialLoading,this._containsData=!!this._options.containsData,this._onWidget=!!this._options.onWidget,this._compareSymbols=this._options.compareSymbols,this._defSymbol=l,this._defInterval=c,this._defTimeframe=p,this._defStyle=u,
this._onWidget&&(o?this._widgetCustomer="cme":r&&(this._widgetCustomer=r)),this._compareDialog=this._chartWidgetCollection.getCompareDialogRenderer();const m=this._contentSeriesProperties();m&&(l=m.symbol,c=m.interval),void 0===this._options.useUserChartPreferences&&(this._options.useUserChartPreferences=!0);const g="chartproperties.mainSeriesProperties",f=this._options.useUserChartPreferences?(0,h.defaults)(g):(0,h.factoryDefaults)(g),y=this._mainSeriesProperties,v=c||f.interval||"D";null!==u&&(0,xt.isValidStyle)(u)||(u=(0,xt.isValidStyle)(f.style)?f.style:(0,xt.getDefaultStyle)(Re.Interval.isRange(v))),y.merge({visible:!0,symbol:l||window.DEFAULT_SYMBOL,shortName:"",timeframe:"",interval:v,currencyId:null,unitId:null,style:u,sessionId:_}),this._symbolWV.setValue(l),this._resolutionWV.setValue(v),this._containsData&&this._mainSeriesProperties.merge({showCountdown:!1}),a&&(0,Pe.timezoneIsAvailable)(a)&&this._properties.childs().timezone.setValue(a),this._options.container.subscribe((e=>{this._setElement(e)}),{callWithLast:!0});const S=()=>{this.resize()};this._options.width.subscribe(S),this._options.height.subscribe(S),this._options.visible.subscribe(this._updateTimingsMeterState.bind(this))}refreshMarks(){this.model().barsMarksSources().forEach((e=>e.refreshData()))}clearMarks(e){this.model().barsMarksSources().forEach((t=>t.clearMarks(e)))}setTimezone(e){const t=e;t&&(0,Pe.timezoneIsAvailable)(t)?this.properties().childs().timezone.setValue(t):console.warn("Incorrect timezone: "+JSON.stringify(t))}getTimezone(){return this.properties().childs().timezone.value()}destroy(){hg.chartFloatingTooltipEnabledWV.unsubscribe(this._onChartFloatingTooltipEnabledChanged),this._chartFloatingTooltipController?.destroy(),this._tooltipPopupHintDestroySignal?.abort(),this._chartSession.disconnect(),this._unsetActions(),this._hotkeys?.destroy(),this._lineToolsSynchronizer?.destroy(),this._noExchangeSubscrptionWarning?.destroy(),window.loginStateChange.unsubscribe(this,this._handleLoginStateChanged),null!==this._model&&(this._model.model().backgroundTopColor().unsubscribe(this._updateThemedColorBound),this._model.model().backgroundColor().unsubscribe(this._updateThemedColorBound),this._model.model().crosshairSource().moved().unsubscribe(this,this._updateAriaPriceDescription),this._model.destroy()),this._ariaPriceDescription=null,this._customLegendWidgetsFactoryMap.clear(),this._scrollHelper.destroy(),this._errorRenderer.destroy(),this._chartSession.criticalError().unsubscribe(this,this._onChartSessionCriticalError),this._chartSession.isConnected().unsubscribe(this._onChartSessionIsConnectedChanged),this._chartSession.destroy(),this._persistentLogSwitcher?.destroy(),this._isDestroyed=!0,this._aboutToBeDestroyed.fire(),this._removeMaximizeHotkey?.(),this._removeMaximizeHotkey=null,0!==this._drawRafId&&this._parent?.ownerDocument.defaultView?.cancelAnimationFrame(this._drawRafId),this._backgroundTopColorSpawn?.destroy(),this._backgroundBottomColorSpawn?.destroy(),this._timingsMeter?.stopCollect(),this._timingsMeter=null
;const e=this._paneWidgets.value();for(let t=0;t<e.length;t++)e[t].destroy();this._paneWidgets.setValue([]);for(let e=0;e<this._paneSeparators.length;e++)this._paneSeparators[e].destroy();this._paneSeparators.length=0,this._hotkeysListener?.destroy(),this._barsButton?.destroy(),this._controlBarNavigation?.destroy(),this._controlBarNavigation=null,this._mainDiv&&(this._onWheelBound&&this._mainDiv.removeEventListener("wheel",this._onWheelBound),this._mainDiv.remove()),this._timeAxisWidget?.destroy(),this._timeAxisWidget=null,this._definitionsViewModel?.destroy(),this._isMultipleLayout.destroy(),mt.createdLineTool.unsubscribeAll(this),mt.continuedLineTool.unsubscribeAll(this),mt.cancelledLineTool.unsubscribeAll(this),mt.beenSetLineToolLastPoint.unsubscribeAll(this),mt.startedMovingLineTool.unsubscribeAll(this),mt.movedLineTool.unsubscribeAll(this),mt.finishedMovingLineTool.unsubscribeAll(this),mt.startedChangingLineTool.unsubscribeAll(this),mt.changedLineTool.unsubscribeAll(this),mt.finishedChangingLineTool.unsubscribeAll(this),mt.removedLineTool.unsubscribeAll(this),mt.finishedLineTool.unsubscribeAll(this),mt.changedLineStyle.unsubscribeAll(this),mt.restoredLineToolState.unsubscribeAll(this),mt.restoredLineTool.unsubscribeAll(this),mt.copiedLineTool.unsubscribeAll(this)}title(){return a.t(null,void 0,i(39950))}emulateCriticalError(){this._chartSession.removeSeries("-1")}chartSession(){return this._chartSession}onDisconnected(){return this._disconnected}onReconnectBailout(){return this._reconnectBailout}onConnected(){return this._connected}chartWidgetInitialized(){return this._chartWidgetInitialized}setBarsButton(e){this._barsButton=e}setVisibleTimeRange(e,t,i,s,o){{const r=this.model().mainSeries().seriesSource();this._chartSession.setVisibleTimeRange((0,n.ensureNotNull)(r.instanceId()),r.turnaround(),e,t,i,s,o)}}chartWidgetCollection(){return this._chartWidgetCollection}isInitialized(){return this._inited}lineToolsSynchronizer(){return this._lineToolsSynchronizer}actions(){return null===this._actions?this._setActions():this._actions}defaultSymbol(){return this._defSymbol}requestFullscreen(){this.getResizerDetacher().requestFullscreen()}exitFullscreen(){this.getResizerDetacher().exitFullscreen()}inFullscreen(){return this.getResizerDetacher().fullscreen.value()}modelCreated(){return this._modelCreated}containsStudyByPredicate(e){return!!this._model&&this._model.dataSources().some((t=>!!(0,Ws.isStudy)(t)&&e(t.metaInfo())))}model(){return(0,n.ensureNotNull)(this._model)}id(){return this._id}layoutId(){return this._chartWidgetCollection.metaInfo.uid.value()}properties(){return this._properties}mainSeriesProperties(){return this._mainSeriesProperties}readOnly(){return Boolean(this._options.readOnly)}isActive(){return this._isActive.readonly()}isHovered(){return this._isHovered.readonly()}crossHairSyncEnabled(){return this._chartWidgetCollection.lock.crosshair.value()}isVisible(){return this._isVisible.value()}setVisible(e){this._isVisible.setValue(e)}visible(){return this._isVisible.readonly()}isCollapsed(){
return this._collapsed.value()}setCollapsed(e){this._collapsed.setValue(e)}collapsed(){return this._collapsed.readonly()}isJustClonedChart(){return!!(this._options||{}).justCloned}removeAllDrawingTools(){!!this.model().model().allLineTools().find((e=>e.isLocked?.()))?(0,cg.confirmRemovingLockedLineTools)(cg.DeleteLockedLineToolReason.RemoveAll).then((e=>{this.model().removeAllDrawingTools(e)})):this.model().removeAllDrawingTools(!0)}removeAllStudies(){this.model().removeAllStudies()}removeAllStudiesDrawingTools(){!!this.model().model().allLineTools().find((e=>e.isLocked?.()))?(0,cg.confirmRemovingLockedLineTools)(cg.DeleteLockedLineToolReason.RemoveAll).then((e=>{this.model().removeAllStudiesAndDrawingTools(e)})):this.model().removeAllStudiesAndDrawingTools(!0)}removeSelectedSources(){this.removeDataSources(this.model().selection().dataSources())}removeDataSources(e){const t=this.model(),i=e.filter((e=>e!==t.mainSeries()&&e!==t.lineBeingCreated()&&e.isUserDeletable()));if(0===i.length)return;let s=null;(0,Ws.isStudy)(i[0])&&((0,n.assert)(1===i.length,"Cannot remove several studies (no multi select for studies)"),s=i[0]);i.find((e=>e.hasAlert().value()));const o=!!i.find((e=>(0,zs.isLineTool)(e)&&e.isLocked?.()));if(s&&s.hasChildren()){const e=s.getAllChildren().map((e=>e.name(!0)));(0,fs.showDeleteStudyTreeConfirm)(e,(()=>{t.removeSelectedSources()}))}else o?(0,cg.showDeleteLockedLineToolsConfirm)(cg.DeleteLockedLineToolReason.RemoveSelected,(e=>{e||t.selectionMacro((e=>{i.filter((e=>(0,zs.isLineTool)(e)&&e.isLocked?.())).forEach((t=>{e.removeSourceFromSelection(t)}))})),t.removeSelectedSources()})):t.removeSelectedSources()}getSymbol(e){if(!this._model)return this._setSymbolIntervalContentOverrides.symbol||window.DEFAULT_SYMBOL;if(!e)return this._symbolWV.value();const t=this._model.mainSeries().properties().childs();return t.shortName&&t.shortName.value()?t.shortName?.value()??"":t.symbol?.value()??""}setSymbol(e){this._model?(this._symbolWV.setValue(e),this._model.setSymbol(this._model.mainSeries(),e)):(this._mainSeriesProperties.merge({symbol:e}),this._symbolWV.setValue(e),this._setSymbolIntervalContentOverrides.symbol=e)}setResolution(e){this._model?(this._resolutionWV.setValue(e),this._model.setResolution(this._model.mainSeries(),e)):(this._mainSeriesProperties.merge({interval:e}),this._resolutionWV.setValue(e),this._setSymbolIntervalContentOverrides.interval=e)}getResolution(){return this._resolutionWV.value()}symbolWV(){return this._symbolWV.readonly()}symbolInfoWV(){return this._symbolInfoWV}resolutionWV(){return this._resolutionWV.readonly()}loadRange(e){if(this._model){this.screen.show();this._model.loadRange(e)||this.screen.hide()}}async showGeneralChartProperties(e,t){if(!l.enabled("show_chart_property_page"))return Promise.resolve(null);const s=await this._showChartProperties(this.model().mainSeries(),e,{doNotCloseOnBgClick:!0,onResetToDefault:async()=>{this.model().restorePreferences()
;const[e,t]=await Promise.all([Promise.resolve().then(i.bind(i,22489)),Promise.resolve().then(i.bind(i,71843))]),s=e.getCurrentTheme().name;t.loadTheme(this.chartWidgetCollection(),{themeName:s,standardTheme:!0})},shouldReturnFocus:t?.shouldReturnFocus});if(null===s)return null;const o=()=>{s.hide(),this._chartWidgetCollection.activeChartWidget.unsubscribe(o)};return this._chartWidgetCollection.activeChartWidget.subscribe(o),s}showChartPropertiesForSource(e,t,i,s){return l.enabled("property_pages")&&e.userEditEnabled()?e===this.model().model().mainSeries()?this.showGeneralChartProperties(t):((i=i||{}).onResetToDefault=()=>{((0,zs.isLineTool)(e)||(0,Ws.isStudy)(e))&&this.model().restorePropertiesForSource.bind(this._model,e)},this._showChartProperties(e,t,i,s)):Promise.resolve(null)}toggleCompareOrAdd(){this._compareDialog.visible().value()?this._compareDialog.hide():this._compareDialog.show()}tags(){return this._model?this._model.calculateDefaultTags():[]}options(){return this._options}ownerDocument(){return(0,n.ensureNotNull)(this._parent).ownerDocument}async showChartPropertiesForSources(e){if(!l.enabled("property_pages"))return Promise.resolve(null);const{sources:t,title:s,tabName:o,renamable:r}=e,c=(0,n.ensureNotNull)(this._model),h=Ds(t.map((e=>e.properties().childs()))),d=Ds(t.map((e=>e.properties().childs().intervalsVisibilities))),[{createPropertyPage:u},{getSelectionStylePropertiesDefinitions:_},{getSelectionIntervalsVisibilitiesPropertiesDefinition:p},{getSelectionCoordinatesPropertyDefinition:m}]=await Promise.all([Promise.all([i.e(3198),i.e(5410),i.e(2745),i.e(8823),i.e(8537)]).then(i.bind(i,60567)),Promise.all([i.e(3198),i.e(5410),i.e(2745),i.e(8823),i.e(8537)]).then(i.bind(i,6255)),Promise.all([i.e(3198),i.e(5410),i.e(2745),i.e(8823),i.e(8537)]).then(i.bind(i,73863)),Promise.all([i.e(3198),i.e(5410),i.e(2745),i.e(8823),i.e(8537)]).then(i.bind(i,97578))]);return async function(e){const{SourcesPropertiesEditorRenderer:t}=await Promise.all([i.e(4752),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(6032),i.e(3672),i.e(2537),i.e(3359),i.e(8894),i.e(5743),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(1979),i.e(4495),i.e(9487),i.e(445),i.e(846),i.e(9323),i.e(8220),i.e(3329),i.e(9970),i.e(6052),i.e(9590),i.e(4678),i.e(159),i.e(9965),i.e(9742),i.e(6043),i.e(4059),i.e(1488),i.e(903),i.e(4633),i.e(2227),i.e(4931),i.e(9418),i.e(4426),i.e(9026),i.e(769),i.e(9928),i.e(8604),i.e(5893),i.e(624),i.e(6780)]).then(i.bind(i,66512)),s=new t(e);return null!==Ms&&(Ms.hide(),Ms=s),s.show(),s}({sources:t,propertyPages:[u(_(h,c),"style",a.t(null,void 0,i(92516))),u({definitions:[m(t,c)]},"displacement",a.t(null,void 0,i(70132))),u(p(d,c),"visibility",a.t(null,void 0,i(40091)))],undoModel:c,title:s,activeTabId:o,renamable:r})}getPriceAxisWidthChangedByName(e){return"left"===e?this._lhsPriceAxisWidthChanged:this._rhsPriceAxisWidthChanged}getPriceAxisMaxWidthByName(e){return"left"===e?this._lhsAxesWidth:this._rhsAxesWidth}timeAxisHeight(){
return null!==this._timeAxisWidget?this._timeAxisWidget.size.height:0}withModel(e,t){null!==this._model?t.call(e):this.modelCreated().subscribe(e,t,!0)}hasModel(){return null!==this._model}onRedraw(){return this._redraw}copyLineToOtherCharts(){const e=(0,n.ensureNotNull)(this._model),t=e.selection().lineDataSources().filter((e=>e.isSynchronizable()));e.model().copyToOtherCharts(t,!0)}toggleLockSelectedObject(){const e=this.model();e.selection().lineDataSources().forEach((t=>{const i=t.properties().frozen.value();e.setProperty(t.properties().frozen,!i,(i?Sg:bg).format({title:new dt.TranslatedString(t.name(),t.title(pa.TitleDisplayTarget.StatusLine))}),Wr.lineToolsDoNotAffectChartInvalidation)}))}hideDataSources(e){if(e.length){const t=e.map((e=>e.properties().visible)),i=e.map((()=>!1));this.model().setProperties(t,i,vg.format({title:new dt.TranslatedString(e[0].name(),e[0].title(pa.TitleDisplayTarget.StatusLine))}))}}hideSelectedObject(){this.hideDataSources(this.model().selection().dataSources().filter((e=>!0)))}unlinkSelectedLine(){const e=(0,n.ensureNotNull)(this._model),t=e.selection().lineDataSources();e.unlinkLines(t)}paneWidgetsWV(){return this._paneWidgets}paneWidgets(){return this._paneWidgets.value()}paneWidgetSeparators(e){const t=this.paneWidgets().indexOf(e),i={};return this._paneSeparators.forEach((e=>{e.topPaneIndex()===t&&(i.separatorBelow=e),e.bottomPaneIndex()===t&&(i.separatorAbove=e)})),i}activePaneWidget(){return this._activePaneWidget.readonly()}paneByState(e){return this._paneWidgets.value().find((t=>t.hasState()&&t.state()===e))??null}paneByCanvas(e){return this._paneWidgets.value().find((t=>t.hasCanvas(e)))??null}timeAxisByCanvas(e){return this._timeAxisWidget?.hasCanvas(e)?this._timeAxisWidget:null}selectPointMode(){return(0,n.ensureNotNull)(this._model).model().selectPointMode()}cancelRequestSelectPoint(){const e=(0,n.ensureNotNull)(this._model).model();e.cancelRequestSelectPoint(),e.setReplayStatus(e.isInReplay().value()?3:0),e.clearCurrentPosition()}requestSelectPoint(e,t){const i=(0,n.ensureNotNull)(this._model);return e.selectPointMode===mt.SelectPointMode.Replay&&i.model().setReplayStatus(1),new Promise(((s,o)=>{const n=()=>!!this.isVisible()||(o("Chartwidget must be visible"),this.cancelRequestSelectPoint(),!1);if(!n())return;(0,mt.resetToCursor)(!0),i.lineBeingCreated()&&i.cancelCreatingLine();let r=!1;const a={};i.model().onPointSelected().subscribe(a,((e,t)=>{r=!0,this._isVisible.unsubscribe(n),this._hideHint(),s({point:e,pane:t})}),!0),i.model().requestSelectPoint(e),this.startTrackingMode(),void 0!==t&&this._showEventHint(t),this._isVisible.subscribe(n),this.selectPointMode().subscribe((()=>{setTimeout((()=>{r||(this.selectPointMode().value()===mt.SelectPointMode.None&&this._hideHint(),i.model().onPointSelected().unsubscribeAll(a),this._isVisible.unsubscribe(n),o("cancelled"))}))}),{once:!0})}))}showReplayOrderConfirmationDialog(){return this.model().isInReplay().value(),Promise.resolve()}showSourceProperties(e,t){e===this.model().mainSeries()&&(t=Ns.TabNames.symbol),
this.showChartPropertiesForSource(e,t)}onScroll(){return this._onScroll}onZoom(){return this._onZoom}onTagsChanged(){return this._tagsChanged}onWidget(){return this._onWidget}containsVolume(){return this.model().dataSources().some((e=>(0,Ws.isStudy)(e)&&"Volume"===e.metaInfo().shortId))}containsStudy(e){return this.containsStudyByPredicate((t=>t.id===e||t.fullId===e))}isSmall(){return this._width()<550||this._height()<300}onCmeWidget(){return"cme"===this._widgetCustomer}widgetCustomer(){return this._widgetCustomer}compareSymbols(){return this._compareSymbols}images(e){window.TradingView.printing=!0;const t=this.model().selection().allSources();this.model().selectionMacro((e=>e.clearSelection())),this.model().model().recalculateAllPanes((0,wi.globalChangeEvent)());const i=(t,i)=>{t.paint(i,ao.InvalidationMask.timeScale(ao.InvalidationLevel.Light,!0).invalidationForTimeScale());const s={showCollapsedStudies:Boolean(e?.showCollapsedStudies),status:e?.status};return t.getScreenshotData(s)},s=[],o=this.maximizedPaneWidget();if(null!==o){const e=this._paneWidgets.value().indexOf(o);s.push(i(o,ao.InvalidationMask.light().invalidationForPane(e)))}else{const e=this._paneWidgets.value();e.forEach(((t,o)=>{s.push(i(t,ao.InvalidationMask.light().invalidationForPane(o))),o<e.length-1&&s.push(this._paneSeparators[o].image())}))}let n;this._timeAxisWidget&&(this._timeAxisWidget.paint(ao.InvalidationMask.timeScale(ao.InvalidationLevel.Light,!0).invalidationForTimeScale()),n=this._timeAxisWidget.getScreenshotData()),window.TradingView.printing=!1,this.model().selectionMacro((e=>{t.forEach((t=>{e.addSourceToSelection(t)}))})),this.model().model().recalculateAllPanes((0,wi.globalChangeEvent)()),this.model().model().lightUpdate();const r=this.mainSeriesQuotesAndMetainfo();return{panes:s,timeAxis:n,colors:{text:this.properties().childs().scalesProperties.childs().textColor.value(),bg:this.properties().childs().paneProperties.childs().background.value(),scales:this.properties().childs().scalesProperties.childs().lineColor.value()},meta:r.meta,ohlc:r.ohlc,quotes:r.quotes}}insertStudy(e,t,i,s,o){return this._insertStudyOrReplaceStub(e,t,void 0,i,s,o)}replaceStubByStudy(e,t,i,s,o,n){return e.updateDescriptor(t),this._insertStudyOrReplaceStub(t,i,e,s,o,n)}addOverlayStudy(e,t,i){const s=this.model();return this._options&&this._options.isSymbolAvailable?this._options.isSymbolAvailable(e).then((async o=>{if(!o)return null;await(0,os.studyMetaInfoRepository)().requestMetaInfo();const n=s.createStudyInserter({type:"java",studyId:"Overlay@tv-basicstudies"},[]),r={allowExtendTimeScale:i};if(l.enabled("use_overrides_for_overlay")){const e=(0,h.factoryDefaults)("study_Overlay@tv-basicstudies.style");r.style=e}return n.setPropertiesState(r),n.setForceOverlay(t),n.insert((()=>Promise.resolve({inputs:{symbol:e},parentSources:[]})))})):Promise.resolve(null)}addCompareStudy(e){const t=this.model();return this._options&&this._options.isSymbolAvailable?this._options.isSymbolAvailable(e).then((async i=>i?(await(0,
os.studyMetaInfoRepository)().requestMetaInfo(),t.createStudyInserter({type:"java",studyId:"Compare@tv-basicstudies"},[]).insert((()=>Promise.resolve({inputs:{symbol:e},parentSources:[]})))):null)):Promise.resolve(null)}showIndicators(e,t){if(window.studyMarket)return window.studyMarket.visible().value()?void window.studyMarket.hide():(window.studyMarket.show(e,t),window.studyMarket)}setSaveChartService(e){this._saveChartService=e,null!==this._lineToolsSynchronizer&&this._lineToolsSynchronizer.setSaveChartService(e)}getSaveChartService(){return this._saveChartService}mainSeriesQuotesAndMetainfo(){let e,t,i;const s=this._model&&this._model.mainSeries();if(s){const o=e=>null==e?"":s.formatter().format(e,{signNegative:!0,useRtlFormat:!1}),n=e=>null==e?"":e+"";e={resolution:s.interval(),symbol:s.symbol(),values:s.legendValuesProvider().getValues(null)};const r=s.symbolInfo();r&&(e.symbol=r.full_name,e.description=r.description,e.exchange=r.exchange);const a=s.bars().last();null!==a&&(t=a.value.slice(1,5).map(o));const l=s.quotes();l&&(i={change:o(l.change),changePercent:n(l.change_percent),last:o(l.last_price)})}return{meta:e,ohlc:t,quotes:i}}isMultipleLayout(){return this._isMultipleLayout}updateCrossHairPositionIfNeeded(){if(this._model){const e=(0,lo.lastMouseOrTouchEventInfo)();if(e.isTouch){const t=this.maximizedPaneWidget()||this._paneWidgets.value()[0];if(t.hasState()&&(!e.stylus&&(this._isLineToolModeExceptBrush()||(0,mt.toolIsMeasure)(mt.tool.value()))||this.selectPointMode().value()!==mt.SelectPointMode.None)){const e=.5*this._model.model().timeScale().width(),i=.5*t.state().defaultPriceScale().height();t.setCursorPosition(e,i)}const i=this._model.model().crosshairSource();i.updateAllViews((0,wi.sourceChangeEvent)(i.id()))}}}trackingModePaneWidget(){if(!(0,lo.lastMouseOrTouchEventInfo)().isTouch)return null;for(const e of this.paneWidgets())if(e.trackingModeEnabled())return e;return null}startTrackingMode(){if((0,lo.lastMouseOrTouchEventInfo)().isTouch){this.exitTrackingMode(),this.updateCrossHairPositionIfNeeded();const e=this.maximizedPaneWidget()||this._paneWidgets.value()[0],t=this.model().model().crosshairSource().currentPoint();e.startTrackingMode(t,t)}}exitTrackingMode(){(0,lo.lastMouseOrTouchEventInfo)().isTouch&&this.paneWidgets().some((e=>e.trackingModeEnabled()))&&(this.paneWidgets().forEach((e=>e.exitTrackingMode())),this.model().model().clearCurrentPosition())}onToolChanged(){const e=this.model().model();e.lineBeingCreated()&&!e.lineBeingCreateFromExternal()&&this._cancelCreatingLine(),this.selectPointMode().value()!==mt.SelectPointMode.None&&this.cancelRequestSelectPoint(),this.exitTrackingMode()}setInLoadingState(e){this._inLoadingState=e}paint(e){const t=e??ao.InvalidationMask.full();t.validationActions().forEach((e=>e()));const i=this.maximizedPaneWidget();this._paneWidgets.value().forEach(((e,s)=>{null!==i&&i!==e||e.paint(t.invalidationForPane(s),t.invalidationForTimeScale())})),this._timeAxisWidget&&this._timeAxisWidget.paint(t.invalidationForTimeScale()),this._redraw.fire()}GUIResetScales(){
(0,re.trackEvent)("GUI","Reset Scales"),null!==this._model&&this._model.resetScales()}applyOverrides(e){const t={};for(const[i,s]of Object.entries(e))i.startsWith("mainSeriesProperties.priceAxisProperties")||(t[i]=s);if((0,h.applyPropertiesOverrides)(this.properties(),void 0,!1,t,void 0),l.enabled("use_localstorage_for_settings")&&this.properties().saveDefaults(),this._model){(0,h.applyPropertiesOverrides)(this._model.model().properties(),void 0,!1,t),(0,h.applyPropertiesOverrides)(this._model.mainSeries().properties(),void 0,!1,t,"mainSeriesProperties"),this._model.model().sessions().applyOverrides(t);const e=this._model.model().watermarkSource();null!==e&&e.applyOverrides(t),l.enabled("use_localstorage_for_settings")&&(this._model.model().properties().saveDefaults(),this._model.mainSeries().properties().saveDefaults())}}showFundamentals(e){this.showIndicators(e?[e]:void 0,"financials")}maximizedPaneWidget(){return this._paneWidgets.value().find((e=>e.maximized().value()))??null}hasMaximizedPane(){return null!==this.maximizedPaneWidget()}setActive(e){(0,lo.lastMouseOrTouchEventInfo)().isTouch&&(e&&this.selectPointMode().value()!==mt.SelectPointMode.None?this.startTrackingMode():this.exitTrackingMode());for(const e of this._paneWidgets.value())e.update();e||this.model().selectionMacro((e=>{e.clearSelection()})),this._isActive.setValue(e)}justActivated(){return this._justActivated}setActivePaneWidget(e){this._activePaneWidget.setValue(e)}onPaneWidgetDestroyed(e){this._activePaneWidget.value()===e&&this._activePaneWidget.setValue(null)}getResizerDetacher(){return this._options}toggleFullscreen(){const e=this.getResizerDetacher();e.fullscreenable.value()&&(e.fullscreen.value()?e.exitFullscreen():e.requestFullscreen())}async generalPropertiesDefinitions(){return await(0,os.studyMetaInfoRepository)().findAllJavaStudies(),this._getChartPropertyDefinitionsViewModel().then((e=>e.propertyPages()))}propertiesDefinitionsForSource(e){return(0,zs.isLineTool)(e)||(0,Ws.isStudy)(e)||(0,Us.isStudyLineTool)(e)?e.getPropertyDefinitionsViewModel().then((e=>null===e?null:e.propertyPages())).catch((e=>(gg.logWarn(e),null))):Promise.resolve(null)}backgroundTopTheme(){return this._backgroundTopTheme.readonly()}backgroundBasedTheme(){return this._backgroundBasedTheme.readonly()}backgroundBottomTheme(){return this._backgroundBottomTheme.readonly()}state(e){if(this._model){const t=this._model.state(e);return t.chartId=this.id(),t}return this._content}lineToolsAndGroupsDTO(){return(0,n.ensureNotNull)(this._lineToolsSynchronizer).prepareDTO()}applyLineToolUpdateNotification(e,t){return(0,n.ensureNotNull)(this._lineToolsSynchronizer).applyLineToolUpdateNotification(e,t)}reloadAllLineTools(){(0,n.ensureNotNull)(this._lineToolsSynchronizer).reloadAllLineTools()}startApplyingLineToolUpdateNotification(){this._lineToolsSynchronizer?.startApplyingLineToolUpdateNotification()}endApplyingLineToolUpdateNotification(){this._lineToolsSynchronizer?.endApplyingLineToolUpdateNotification()}applyAlertIdByExternalSource(e,t){
this._lineToolsSynchronizer?.applyAlertIdByExternalSource(e,t)}deleteAlertByExternalSource(e,t){this._lineToolsSynchronizer?.deleteAlertByExternalSource(e)}shouldBeSavedEvenIfHidden(){return this._model?this.model().model().shouldBeSavedEvenIfHidden():!!this._options.content.shouldBeSavedEvenIfHidden}getTimeScale(){return this._timeAxisWidget}showObjectsTreePanelOrDialog(){let e=!1;const t=window.widgetbar;if(t&&t.isVisible()){const i=(0,n.ensureNotNull)(t.setPage("object_tree"));(0,n.ensureNotNull)(i.widget("object_tree"));0,e="object_tree"===i.name}e||this.showObjectsTreeDialog()}showObjectsTreeDialog(){this._objectTreeDialogController?.show()}addCustomWidgetToLegend(e,t){this._customLegendWidgetsFactoryMap.set(e,t);for(const i of this.paneWidgets())i.addCustomWidgetToLegend(e,t)}applyIndicatorsToAllChartsAvailable(){if(!this.chartWidgetCollection().applyIndicatorsToAllChartsAvailable())return!1;for(const e of this.model().model().panes()){if(e.sourcesByGroup().all().some((e=>(0,Ws.isStudy)(e)&&!0)))return!0}return!1}widget(){return(0,n.ensureNotNull)(this._mainDiv)}addCompareAsOverlay(e,t,i){const s=this.model();return(0,n.ensureDefined)(this._options.isSymbolAvailable)(e).then((async o=>{if(!o)return null;await(0,os.studyMetaInfoRepository)().requestMetaInfo();const n=s.createStudyInserter({type:"java",studyId:"Overlay@tv-basicstudies"},[]);return n.setForceOverlay(!0),n.setPreferredPriceScale("as-series"),!0!==i&&n.setTargetPriceScaleMode({percentage:!0}),void 0!==t&&n.setPropertiesState({allowExtendTimeScale:t}),n.insert((async()=>({inputs:{symbol:e},parentSources:[]})))}))}scrollHelper(){return this._scrollHelper}resize(){const e=this._height()+"px",t=this._width()+"px",i=(0,n.ensureNotNull)(this._mainDiv);i.style.height=e,i.style.width=t,this._elMainTable.style.height=e,this._elMainTable.style.width=t,this._resizeHandler&&this._mainDiv&&this._resizeHandler()}chartPainted(){return this._drawPlanned?(null===this._chartPaintedPromise&&(this._chartPaintedPromise=(0,me.createDeferredPromise)()),this._chartPaintedPromise.promise):Promise.resolve()}setDataWindowWidget(e){this._dataWindowWidget=e}removeDataWindowWidget(){this._dataWindowWidget=null}showSelectedSourcesProperties(e){const t=(0,n.ensureNotNull)(this._model).selection().dataSources();if(1===t.length)this.showSourceProperties(t[0],e);else{const i=t.filter(zs.isLineTool);i.length>0&&this.showChartPropertiesForSources({sources:i,tabName:e})}}setTimingsMeter(e){this._timingsMeter=e,this._updateTimingsMeterState()}onAboutToBeDestroyed(){return this._aboutToBeDestroyed}executeActionById(e){if("takeScreenshot"===e)return console.warn('Action "takeScreenshot" is deprecated. Use method "takeScreenshot" instead'),void this._chartWidgetCollection.takeScreenshot();const t=this.actions()[e];t?t.execute():console.warn("Unknown action id: "+e)}getCheckableActionState(e){const t=this.actions()[e];if(t){if(t.isCheckable())return t.isChecked();console.warn("Action "+e+" has no state")}else console.warn("Unknown action id: "+e);return null}connect(){
this._chartSession.isConnected().subscribe(this._onChartSessionIsConnectedChanged),this._chartSession.criticalError().subscribe(this,this._onChartSessionCriticalError),this._chartSession.connect(this._onData.bind(this))}finishInitWithoutConnect(){this._chartSession.disable(),this._init(),this._chartWidgetInitialized.fire()}reconnect(){this._chartSession.disconnect(),this._chartSession.connect()}update(){if(this.hasModel()){for(const e of this._paneWidgets.value())e.update();this._timeAxisWidget&&this._timeAxisWidget.update()}}setPriceAxisHovered(e,t){t?this._hoveredPriceAxes.add(e):this._hoveredPriceAxes.delete(e),this._anyAxisHovered.setValue(this._hoveredPriceAxes.size>0)}anyPriceAxisHovered(){return this._anyAxisHovered.readonly()}linkingGroupIndex(){return this._linkingGroupIndex}offsetInDocument(e){const t=this.paneByState(e);if(!t)return{left:NaN,top:NaN};const i=t.getElement().getBoundingClientRect();return{left:Math.round(i.left+document.body.scrollLeft),top:Math.round(i.top+document.body.scrollTop)}}showHint(e,...t){if(0===e)this._showEventHint(...t);else if(1===e)throw new Error("Warning hint not implemented")}hotkeys(){return this._hotkeys}onAboutToLoadContent(){this._lineToolsSynchronizer?.destroy(),this._lineToolsSynchronizer=null,this._chartSession.disconnect()}async loadContent(e,t){this.screen.show();const i=this.model();i.model().setMaximizedPane(null),i.model().selectionMacro((e=>e.clearSelection()));const s=i.mainSeries();i.model().isInReplay().value()&&i.model().switchToRealtime();let o,r;i.crosshairSource().clearMeasure(),i.unloadDataSources(),this._chartSession.connect(this._onData.bind(this)),this._activePaneWidget.setValue(null),s.purgeSymbolInfo(),e.loading=!0,this._id=(0,n.ensureDefined)(e.chartId),await(0,zs.ensureAllLineToolsLoadedForLayout)([e]),this._content=e,this._setSymbolIntervalContentOverrides={},this._initialLoading=t;const a=this._contentSeriesProperties();if(a&&(o=a,r=e.chartProperties.priceScaleSelectionStrategyName),!o)throw Error("An error occurred while determining main series on the chart");const l=s.style();this._mainSeriesProperties.mergeAndFire({visible:!0,symbol:o.symbol,timeframe:"",interval:o.interval||"D",style:o.style}),void 0!==r&&this._properties.childs().priceScaleSelectionStrategyName.setValue(r),l!==s.style()&&s.onChartStyleChanged(),this._init(),i.undoHistory().clearStack(),this._chartWidgetInitialized.fire()}resetDrawingState(){(0,mt.resetToCursor)(!0);const e=(0,n.ensureNotNull)(this._model?.crosshairSource().pane??null);(0,n.ensureNotNull)(this.paneByState(e)).cancelCreatingLineTool(),this._model?.selectionMacro((e=>{e.clearSelection()}))}_clearSelectionHotkey(){return{desc:"Cancel selection",hotkey:27,handler:()=>{if(this.selectPointMode().value()!==mt.SelectPointMode.None)return this.selectPointMode().value()===mt.SelectPointMode.Replay&&this._chartWidgetCollection.getAll().forEach((e=>{e!==this&&e.selectPointMode().value()===mt.SelectPointMode.Replay&&e.cancelRequestSelectPoint()})),void this.cancelRequestSelectPoint();if(this._model){
const e=this._model.selection().lineDataSources();1===e.length&&(0,zs.isEditableTextLineTool)(e[0])&&e[0].textEditingJustFinished()||this._model.selectionMacro((e=>{this._cancelCreatingLine(),e.clearSelection()}))}const e=this._model?.model().customSourceMovingHitTestData();e&&e.cancelMoveHandler&&e.cancelMoveHandler()&&(e.cancelled=!0,this._model?.model().setMovingCustomSource(null,null),this._model?.model().lightUpdate())},isDisabled:()=>{const e=this._model;if(!e)return!0;const t=0===e.selection().allSources().length,i=null===e.crosshairSource().measurePane().value(),s=this.selectPointMode().value()===mt.SelectPointMode.None;return t&&i&&s}}}async _insertStudyOrReplaceStub(e,t,i,s,o,n){try{return t.length&&await new Promise(((e,t)=>{(0,Is.runOrSignIn)(e,{source:"study on study",onUnmountEvent:()=>t(new Lg(Ag.Canceled))})})),n?.(),"java"===e.type&&await(0,os.studyMetaInfoRepository)().requestMetaInfo(),await this._insertOrReplaceStubByStudyImpl(e,t,i,s,o)}catch(e){return i&&e instanceof Lg&&this.model().model().removeSource(i,!0),null}}_insertOrReplaceStubByStudyImpl(e,t,i,s,o){const r=(0,n.ensureNotNull)(this._model).createStudyInserter(e,t,s);r.setForceOverlay("java"===e.type&&"Volume@tv-basicstudies"===e.studyId&&l.enabled("volume_force_overlay"));const a=r.insert(((e,i,s)=>new Promise(((n,r)=>{this.selectPointMode().value()!==mt.SelectPointMode.None&&this.cancelRequestSelectPoint(),o?n(o(e,i,s)):(0,Ws.isSymbolicStudy)(s)?((0,re.trackEvent)("GUI","Confirmation dialogs","Symbol confirmation dialog"),xs(this,e,s,n,(()=>r(new Lg(Lg.Reasons.Canceled))),"symbol")):(0,Ws.hasConfirmInputs)(i)?((0,re.trackEvent)("GUI","Confirmation dialogs","Inputs confirmation dialog"),xs(this,e,s,n,(()=>r(new Lg(Lg.Reasons.Canceled))))):n({inputs:{},parentSources:t})}))),void 0,i);return a.then((()=>{(0,mt.hideAllIndicators)().value()&&(0,Ss.toggleHideMode)()})).catch((e=>{})),a}async _showChartProperties(e,t,i,s){if(!this._model)return null;t&&((0,d.setValue)("properties_dialog.active_tab.chart",t),i.tabName=t);const o=await qs(e,this._model,i,this._options.chartWidgetCollection,s);return o?.visible().value()?o:null}_createLineToolsSynchronizerIfNeeded(){if(l.enabled("saveload_separate_drawings_storage")){this._lineToolsSynchronizer?.destroy(),this._lineToolsSynchronizerHasChanges??=new O.WatchedValue(!1),this._lineToolsSynchronizerHasChanges.setValue(!1);const e={readOnlyMode:this.readOnly(),migrateSyncedLineTools:this===this._options.chartWidgetCollection.getAll()[0]},t={layoutId:this.layoutId(),chartId:this._id,clientId:this._chartWidgetCollection.clientId},i=function(){if(!Bm)throw new Error("LineToolsSynchronizer Class not loaded");return Bm}();this._lineToolsSynchronizer=new i(t,this.model().model(),e,this._lineToolsSynchronizerHasChanges),null!==this._saveChartService&&this._lineToolsSynchronizer.setSaveChartService(this._saveChartService),this._lineToolsSynchronizer.invalidateAll(!0),this._model?.model().setLineToolsSynchronizer(this._lineToolsSynchronizer)}}_updateThemedColor(){
const e=this.model().model(),t=e.backgroundColorAtYPercentFromTop(.5);let i=e.backgroundTopColor().value(),s=e.backgroundColor().value();const o=(0,gs.isColorDark)(t),n=(0,gs.isColorDark)(i),r=(0,gs.isColorDark)(s);this.widget().classList.toggle("chart-widget--themed-dark",o),this.widget().classList.toggle("chart-widget--themed-light",!o),this.widget().classList.toggle("chart-widget__top--themed-dark",n),this.widget().classList.toggle("chart-widget__top--themed-light",!n),this.widget().classList.toggle("chart-widget__bottom--themed-dark",r),this.widget().classList.toggle("chart-widget__bottom--themed-light",!r),this._backgroundTopTheme.setValue(n?"dark":"light"),this._backgroundBasedTheme.setValue(o?"dark":"light"),this._backgroundBottomTheme.setValue(r?"dark":"light"),i===s&&(0,L.isStdThemedDefaultValue)("chartProperties.paneProperties.background",i,this._backgroundBasedTheme.value())&&(i=null,s=null);for(const e of this._paneWidgets.value())e.updateThemedColors({topColor:i,bottomColor:s})}_isLineToolModeExceptBrush(){const e=mt.tool.value();return(0,Lt.isLineToolName)(e)&&!(0,Lt.isLineDrawnWithPressedButton)(e)&&this.selectPointMode().value()===mt.SelectPointMode.None}_cancelCreatingLine(){const e=(0,n.ensureNotNull)(this._model).model(),t=e.lineBeingCreated();if(null!==t){const i=(0,n.ensureNotNull)(e.paneForSource(t));(0,n.ensureNotNull)(this.paneByState(i)).cancelCreatingLineTool(),t.toolname===mt.tool.value()&&(0,mt.resetToCursor)()}const i=e.crosshairSource().measurePane().value();if(null!==i){(0,n.ensureNotNull)(this.paneByState(i)).cancelMeasuring()}}_adjustSize(e){let t=0;const i=null===this._model?null:this._model.model().priceScaleSlotsCount(),s=new Uint32Array(null===i?0:i.left),o=new Uint32Array(null===i?0:i.right),n={value:0},r={value:0},a=(0,ro.getCanvasDevicePixelRatio)(document.body),l=(e,t)=>e+t,c=(e,t,i)=>{Array.isArray(i)?i.forEach(((t,i)=>{e[i]=Math.max(e[i],t)})):t.value=Math.max(t.value,i)},h=(e,t,i)=>{if(i.value>t){const s=i.value/t;let o=0;for(let t=0;t<e.length;t++)e[t]=Math.ceil(e[t]*s),o+=e[t];return o}return t},d=this._width(),u=this._height(),_=this._paneSeparators.length,p=this.hasMaximizedPane()?0:vo.height()*_,m=null!==this._timeAxisWidget?this._timeAxisWidget.optimalHeight():0;let g=u-m>=61?m:0;g%2&&(g+=1);const f=this._paneWidgets.value(),y=Math.max(1,Math.floor((u-p-g)/f.length));let v=0,S=null;const b=this.maximizedPaneWidget();for(const e of f)if(!b||b===e){e.leftPriceAxisesContainer().updateCurrencyLabels();const i=e.leftPriceAxisesContainer().optimalWidths();e.rightPriceAxisesContainer().updateCurrencyLabels();const a=e.rightPriceAxisesContainer().optimalWidths();c(s,n,i),c(o,r,a),b!==e&&e.state().collapsed().value()?v+=Math.min(y,e.collapsedHeight()):(t+=e.stretchFactor(),S=e)}let w=s.reduce(l,0);0===w&&0!==s.length&&0!==n.value&&(s[0]=w=n.value);let C=o.reduce(l,0);0===C&&0!==o.length&&0!==r.value&&(o[0]=C=r.value),w=h(s,w,n),C=h(o,C,r);let T=Math.max(d-w-C,0);if(T<=102){w=0,C=0,T=d;for(let e=0;e<s.length;e++)s[e]=0;for(let e=0;e<o.length;e++)o[e]=0}
for(const e of this._paneSeparators)e.adjustSize();const P=p+v+g,x=u<P?0:u-P,M=x/t;let I=0,A=!1;const L=this._model?.model();this._paneWidgets.value().forEach(((e,t)=>{void 0!==L&&e.setState(L.panes()[t]);let i=0;if(this.hasMaximizedPane())i=this.maximizedPaneWidget()===e?x:0;else if(e.state().collapsed().value())i=Math.min(y,e.collapsedHeight());else{const t=e===S?Math.ceil((x-I)*a)/a:Math.round(e.stretchFactor()*M*a)/a;i=Math.max(t,2),I+=i}e.setPriceAxisSizes("left",i,s),e.setPriceAxisSizes("right",i,o),A=A||i!==e.height(),e.setSize((0,Ft.size)({width:T,height:i})),L&&e.state()&&L.setPaneHeight(e.state(),i)})),null!==this._timeAxisWidget&&this._timeAxisWidget.setSizes((0,Ft.size)({width:T,height:g}),s,o),L&&L.setWidth(T,e),this._controlBarNavigation&&this._controlBarNavigation.updatePosition(),this._lhsAxesWidth!==w&&(this._lhsAxesWidth=w,this._lhsPriceAxisWidthChanged.fire(w)),this._rhsAxesWidth!==C&&(this._rhsAxesWidth=C,this._rhsPriceAxisWidthChanged.fire(C)),A&&ee.emit("panes_height_changed")}_makePaneWidgetsAndSeparators(){const e=this.model().model().panes(),t=e.length,i=this._paneWidgets.value().length,s=this._paneWidgets.value().slice();for(let e=t;e<i;e++){(0,n.ensureDefined)(s.pop()).destroy();const e=this._paneSeparators.pop();e&&e.destroy()}const o=this._options.containsData;for(let n=0;n<t;n++){const t=n>=i,r={contextMenuEnabled:this._options.paneContextMenuEnabled,currencyConversionEnabled:this._options.currencyConversionEnabled,unitConversionEnabled:this._options.unitConversionEnabled,handleScale:this._options.handleScale,handleScroll:this._options.handleScroll,priceScaleContextMenuEnabled:this._options.priceScaleContextMenuEnabled,legendWidgetEnabled:this._options.legendWidgetEnabled&&e[n].mode()===zi.PaneMode.Regular,sourceStatusesWidgetEnabled:!o,sourceStatusesWidget:this._options.sourceStatusesWidget,marketStatusWidgetEnabled:this._options.marketStatusWidgetEnabled&&!o,chartWarningWidgetEnabled:this._options.chartWarningWidgetEnabled&&!o,chartWarningWidget:this._options.chartWarningWidget,dataProblemWidgetEnabled:this._options.dataProblemWidgetEnabled&&!o,legendWidget:this._options.legendWidget,propertyPagesEnabled:this._options.propertyPagesEnabled,sourceSelectionEnabled:this._options.sourceSelectionEnabled,controlsEnabled:this._options.paneControlsEnabled,croppedTickMarks:this._options.croppedTickMarks,countdownEnabled:this._options.countdownEnabled,customLegendWidgetFactories:new Map(this._customLegendWidgetsFactoryMap),useKineticScroll:this._options.useKineticScroll,pineSourceStatusEnabled:!this.readOnly(),alertStatusEnabled:!1};if(void 0!==this._options.paneContextMenu&&(r.contextMenu=this._options.paneContextMenu),void 0!==this._options.priceScaleContextMenu&&(r.priceScaleContextMenu=this._options.priceScaleContextMenu),t){const t=new rr(this,e[n],r,this._paneWidgetsSharedState);if(s.push(t),n>0){const e=new vo(this,n-1,n);this._paneSeparators.push(e),
this._timeAxisWidget?this._elMainTable.insertBefore(e.getElement(),this._timeAxisWidget.getElement()):this._elMainTable.appendChild(e.getElement())}this._timeAxisWidget?this._elMainTable.insertBefore(t.getElement(),this._timeAxisWidget.getElement()):this._elMainTable.appendChild(t.getElement())}else{s[n].updateOptions(r)}}const r=this.maximizedPaneWidget();for(const e of this._paneSeparators)r?e.hide():e.show();for(let i=0;i<t;i++){const t=e[i],o=s[i];o.hasState()&&o.state()===t?o.updatePriceAxisWidgetsStates():o.setState(t)}for(let e=t;e--;)s[e].updateControls();this._paneWidgets.setValue([...s]),this._errorRenderer.updatePaneWidgets(),this._updateThemedColor()}_width(){return this._options.width.value()}_height(){return this._options.height.value()}_update(e,t){const i=e?e.fullInvalidation():ao.InvalidationLevel.Full,s=!!e&&e.isVisibleTimeRangeLockedOnResize();if(null!==this._timingsMeter&&this._timingsMeter.startDraw(i),i===ao.InvalidationLevel.Full&&(this._model?this._updateGui(s):this._adjustSize(s)),i>ao.InvalidationLevel.Cursor&&(this._timeAxisWidget?.update(),this._paneWidgets.value().forEach((e=>{e.updatePriceAxisWidgets()})),this._applyTimeScaleInvalidations(e,t),this._invalidationMask?.fullInvalidation()===ao.InvalidationLevel.Full&&(this._invalidationMask.merge(e),this._adjustSize(this._invalidationMask.isVisibleTimeRangeLockedOnResize()),this._applyTimeScaleInvalidations(this._invalidationMask,t),e=this._invalidationMask,this._invalidationMask=null)),this.paint(e),this._dataWindowWidget){const t=e.maxPaneInvalidation();t===ao.InvalidationLevel.Full?this._dataWindowWidget.fullUpdate():t>ao.InvalidationLevel.None&&this._dataWindowWidget.update()}this._paneWidgets.value().forEach(((t,i)=>{t.updateStatusWidget(e.invalidationForPane(i))})),null!==this._timingsMeter&&this._timingsMeter.stopDraw(),e&&e.panesOrderInvalidated()&&ee.emit("panes_order_changed")}_initMaximizeHotkey(e){const t=e=>!e.defaultPrevented&&(0,B.modifiersFromEvent)(e)===B.Modifiers.Alt&&!(0,mt.toolIsDemonstration)(mt.tool.value()),i=e=>{t(e)&&e.stopPropagation()},s=e=>{t(e)&&(e.preventDefault(),e.stopPropagation(),this.toggleFullscreen())};return e.addEventListener("mousedown",i,!0),e.addEventListener("click",s,!0),()=>{e.removeEventListener("mousedown",i,!0),e.removeEventListener("click",s,!0)}}_onMousewheel(e){if(!this.model().model().zoomEnabled()||null===this._mouseWheelHelper)return;if(null===this._model)return;if(this.model().timeScale().isEmpty())return;const t=this._mouseWheelHelper.processWheel(e),i=t.deltaX,s=-t.deltaY;if(0!==i&&this._options.handleScroll.mouseWheel||0!==s&&this._options.handleScale.mouseWheel){if(e.cancelable&&e.preventDefault(),0!==s&&this._options.handleScale.mouseWheel){const t=Math.sign(s)*Math.min(1,Math.abs(s)),i=(0,n.ensureNotNull)(this._mainDiv).getBoundingClientRect(),o=e.clientX-this._lhsAxesWidth-i.left;if(!Number.isFinite(o)||!Number.isFinite(t))return void gg.logWarn("Incorrect mouse wheel processing: scrollPosition: "+o+", zoomScale: "+t);const r=new To.EnvironmentState(e).mod()
;this.model().model().zoomTime(o,t,!!r||void 0),this._onZoom.fire(r)}0!==i&&this._options.handleScroll.mouseWheel&&this.model().scrollChart(-80*i)}}_beginRequestActive(){const e=this._chartWidgetCollection.activeChartWidget.value()!==this;if(this._chartWidgetCollection.activeChartWidget.setValue(this),e){this._chartWidgetCollection.ariaDescribeChart(this._chartWidgetCollection.activeChartWidget.value());const e=(0,lo.lastMouseOrTouchEventInfo)();e.isTouch&&!e.stylus&&this._isLineToolModeExceptBrush()&&this.updateCrossHairPositionIfNeeded(),this._justActivated=!0}}_endRequestActive(){this._justActivated&&setTimeout((()=>this._justActivated=!1),0)}_requestActive(){this._beginRequestActive(),this._endRequestActive()}_createSessions(e){{const t=this.showGeneralChartProperties.bind(this,Ns.TabNames.timezoneSessions);return void e.createSessions(t)}}_createPrePostMarket(e){0}_createVolumeIfNeeded(){const e=l.enabled("create_volume_indicator_by_default")&&this._options.addVolume,t=!this._content,i=l.enabled("create_volume_indicator_by_default_once"),s=this._content&&!this._content.loading;if(e&&(t||s&&!i)){const e=()=>{setTimeout((async()=>{const e=this.model().model(),t=e.mainSeries().symbolInfo();if(!t)return;const i=(0,xt.hasVolume)(t);if(!this.containsVolume()&&i){const t=(0,h.factoryDefaults)("chartproperties.volumePaneSize");await(0,os.studyMetaInfoRepository)().requestMetaInfo();const i=e.createStudyInserter({type:"java",studyId:"Volume@tv-basicstudies"});i.setForceOverlay(l.enabled("volume_force_overlay")),i.setPaneSize(t),l.enabled("hide_volume_ma")&&i.setPropertiesState({styles:{vol_ma:{display:0}}}),i.insert()}else if(!i&&this.containsVolume()){const t=this.model().dataSources().filter((e=>(0,Ws.isStudy)(e)&&"Volume"===e.metaInfo().shortId))[0];e.removeSource(t)}}))};this.model().mainSeries().dataEvents().symbolResolved().subscribe(this,e,i)}}onModelTagsChanged(){this._tagsChanged.fire()}_initBackgroundColor(){null===this._backgroundTopColorSpawn&&(this._backgroundTopColorSpawn=this.model().model().backgroundTopColor().spawn(),this._backgroundTopColorSpawn.subscribe(this._onBackgroundColorChanged.bind(this))),null===this._backgroundBottomColorSpawn&&(this._backgroundBottomColorSpawn=this.model().model().backgroundColor().spawn(),this._backgroundBottomColorSpawn.subscribe(this._onBackgroundColorChanged.bind(this)))}_updateGui(e){this._model&&(this._makeTimeAxisWidget(),this._makePaneWidgetsAndSeparators(),this._elMainTable.style.userSelect="none",this._adjustSize(e))}_onChartStyleChanged(){(0,re.trackEvent)("Chart",`Chart Style ${this.model().mainSeries().getStyleShortName().toUpperCase()}`)}_addPerfMark(e){(0,lg.addPerfMark)(`ChartWidget.${this._id}.${e}`)}_setElement(e){if(!e)return;if(this._mainDiv){this._mainDiv.remove();const e=document.createRange();e.selectNodeContents((0,n.ensureNotNull)(this._parent)),e.deleteContents()}this._controlBarNavigation&&(this._controlBarNavigation.destroy(),this._controlBarNavigation=null),null!==this._removeMaximizeHotkey&&this._removeMaximizeHotkey(),
this._removeMaximizeHotkey=this._initMaximizeHotkey(e);const t=e.ownerDocument,s=t.createElement("div");s.classList.add("chart-container-border"),e.insertBefore(s,e.firstChild),this._parent=s;const o=t.createElement("div");if(o.classList.add("chart-widget"),this._mainDiv=o,this._elTooltipDiv=t.createElement("div"),this._elTooltipDiv.className="tooltip-wrapper",this._mainDiv.appendChild(this._elTooltipDiv),this._elMainTable=t.createElement("div"),this._elMainTable.className="chart-markup-table",this._mainDiv.appendChild(this._elMainTable),o.setAttribute("role","region"),o.setAttribute("aria-label",a.t(null,{replace:{index:this.id()}},i(56275))),this._hotkeysListener&&this._hotkeysListener.destroy(),this._errorRenderer.setContainer(this._parent),this._hotkeysListener=new Vs.ChartHotkeysListener(this,this._mainDiv),(this._options.controlBarEnabled||l.enabled("control_bar"))&&this._createControlBar(),this._options.handleScale.mouseWheel||this._options.handleScroll.mouseWheel){this._mouseWheelHelper=new mo;const e=this._onMousewheel.bind(this);this._onWheelBound=e,this._mainDiv.addEventListener("wheel",e,{passive:!1})}this._mainDiv.addEventListener("mouseenter",(()=>this._isHovered.setValue(!0))),this._mainDiv.addEventListener("mouseleave",(()=>this._isHovered.setValue(!1))),this.resize(),this._justActivated=!1,yg&&(o.addEventListener("mousedown",(e=>this._chartFloatingTooltipController?.mouseDownEvent(e))),o.addEventListener("mousemove",(e=>this._chartFloatingTooltipController?.mouseMoveEvent(e))),this.withModel(this,(()=>{this.model().model().activationChartFloatingTooltipHint().subscribe((e=>{e&&(this._tooltipPopupHintDestroySignal?.abort(),this._tooltipPopupHintDestroySignal=new AbortController,pg(o,this._tooltipPopupHintDestroySignal))}))}))),this.withModel(this,(()=>{s.appendChild(o),o.addEventListener("mousedown",this._beginRequestActive.bind(this)),o.addEventListener("mouseup",this._endRequestActive.bind(this)),o.addEventListener("touchstart",this._beginRequestActive.bind(this)),o.addEventListener("touchmove",this._endRequestActive.bind(this)),o.addEventListener("touchend",this._endRequestActive.bind(this)),o.addEventListener("click",this._requestActive.bind(this))})),this._inited&&(null!==this._timeAxisWidget&&(this._timeAxisWidget.destroy(),this._timeAxisWidget=null),this._paneWidgets.value().forEach((e=>{e.destroy()})),this._paneWidgets.setValue([]),this._paneSeparators.forEach((e=>{e.destroy()})),this._paneSeparators.length=0,this._update(ao.InvalidationMask.full(),performance.now()))}_init(){this.hasModel()&&this.model().mainSeries().clearData(),this._initColors(),this._makeDefaultGui();this._makeDefaultModel(),(()=>{this._checkObsoleteTimezone(),this._chartSession&&this._chartSession.connected()&&this.model().model().restart(),this._content&&(this._initColors(),this._updateGui(),this.update()),this._resizeHandler=()=>{this._invalidationHandler(ao.InvalidationMask.full())},this._resizeHandler(),(0,n.ensureNotNull)(this._parent).appendChild((0,n.ensureNotNull)(this._mainDiv)),
this._spinner&&(this._spinner.stop(),this._spinner=null),this._activateSymbolSearchHotkeys(),this.model().timeScale().onScroll().subscribe(this,(()=>this._onScroll.fire())),this._inited=!0})()}_makeDefaultModel(){let e;if(this._content&&this._content.timeScale.points){const t=this._content.timeScale.points.items[0];e={startDate:t}}const t=()=>{const t={readOnly:this.readOnly(),isSnapshot:!!this._containsData,...ys(this._options,["timeScale","crossHair","chartEventsEnabled","newsNotificationsEnabled","esdEnabled","latestUpdatesEnabled","continuousContractSwitchesEnabled","futuresContractExpirationEnabled","countdownEnabled","lastPriceAnimationEnabled","currencyConversionEnabled","unitConversionEnabled","watermarkEnabled","shiftVisibleRangeOnNewBar","hideIdeas","onWidget"])},i=function(e,t,i,s,o,n,r,a,l,c,h,d){const u=new vm(e,t,i,s,o,n,r,a,l,c,h,d);return u.model().fullUpdate(),u}(this._chartSession,this._invalidationHandler,this._properties,this._mainSeriesProperties,e,this,this._options.undoHistory,this._options.barsMarksContainersFactory,t,this._collapsed,this._linkingGroupIndex,this._saveChartService?.autoSaveEnabled()??new O.WatchedValue(!0));return this._createSessions(i.model()),i};l.enabled("lean_chart_load")?this._model=this._model||t():this._model=t(),this._model.model().setChartSaveTime(1e3*this._chartWidgetCollection.metaInfo.lastModified.value()),this._createVolumeIfNeeded();if(this._content){let e=this._setSymbolIntervalContentOverrides;fg&&this._initialLoading&&(e={...e,symbol:this._defSymbol,interval:this._defInterval??void 0,style:this._defStyle??void 0},this._defInterval&&Re.Interval.isRange(this._defInterval)&&(e.style=11)),this._applySavedModelState(this._containsData,e),this._setSymbolIntervalContentOverrides={},fg&&this._defSymbol&&this.model().model().recalculatePriceRangeOnce()}this._setActions(),this._createLineToolsSynchronizerIfNeeded(),(()=>{const e=(0,n.ensureNotNull)(this._model);e.onTagsChanged().subscribe(this,(()=>this.onModelTagsChanged())),this._initBackgroundColor(),this._updateGui(),this._modelCreated.fire(e),this._tagsChanged.fire(),l.enabled("determine_first_data_request_size_using_visible_range")&&this._setFirstRequestNumbarsUsingTimeframeAndInterval(e);const t=e.mainSeries(),i=t.properties().childs();this._defTimeframe&&t.setDefaultTimeframe(this._defTimeframe),t.dataEvents().symbolNotPermitted().subscribe(null,(e=>t.setSymbolParams({symbol:e}))),this._symbolWV.setValue(i.symbol.value()),i.symbol.subscribe(this,(e=>this._symbolWV.setValue(e.value()))),this._resolutionWV.setValue(i.interval.value()),i.interval.subscribe(this,(e=>this._resolutionWV.setValue(e.value()))),i.style.unsubscribe(this,this._onChartStyleChanged),i.style.subscribe(this,this._onChartStyleChanged),t.dataEvents().completed().subscribe(this,(()=>this._addPerfMark("SeriesCompleted")),!0),t.dataEvents().barReceived().subscribe(this,(()=>this._addPerfMark("SeriesFirstDataReceived")),!0);this._options;t.dataEvents().chartTypeNotPermitted().subscribe(null,(()=>{t.setSymbolParams({interval:"D"})})),
t.dataEvents().intradaySpreadNotPermitted().subscribe(null,(()=>{t.setSymbolParams({interval:"D"})})),t.dataEvents().customIntervalNotPermitted().subscribe(null,(i=>{const s=e.model().defaultResolutions(),o=s.find((e=>(0,ht.compareResolutions)(e,i)>=0))??s[s.length-1];t.setSymbolParams({interval:o})})),t.dataEvents().intradayExchangeNotPermitted().subscribe(null,(()=>{t.setSymbolParams({interval:"D"})})),t.requestingStyleIsNotSupported.subscribe(null,(()=>{const i=t.interval(),s=e.model().defaultResolutions(),o=(0,xt.getLastUsedSingleValueBasedStyle)(),n=(0,ht.getResolutionByChartStyle)(o,i,s);t.setChartStyleWithIntervalIfNeeded(o,n)})),t.requestingStyleSupportRecovered.subscribe(null,(i=>{const s=t.interval(),o=e.model().defaultResolutions(),n=(0,ht.getResolutionByChartStyle)(i,s,o);t.setChartStyleWithIntervalIfNeeded(i,n)}))})()}_applySavedModelState(e,t){this._adjustSize();const i=(0,n.ensureNotNull)(this._model),s=(i.restoreState(this._content,e,t),i.mainSeries().properties().childs());this._symbolWV.setValue(s.symbol.value()),this._resolutionWV.setValue(s.interval.value())}_addHotkeys(){if(this._hotkeys.add({desc:"Maximize",hotkey:B.Modifiers.Alt+13,handler:()=>this.toggleFullscreen(),isDisabled:()=>!this.getResizerDetacher().fullscreenable.value()}),this._hotkeys.add(this._clearSelectionHotkey()),this._options.indicatorsDialogShortcutEnabled&&this._hotkeys.add({desc:"Show insert indicator dialog",hotkey:111,handler:()=>this.showIndicators()}),!this.readOnly()){this._hotkeys.add({desc:"Remove selected source",hotkey:B.isMacKeyboard?46:8,handler:()=>this.removeSelectedSources()}),this._hotkeys.add({desc:"Switch between sessions",hotkey:B.Modifiers.Shift+B.Modifiers.Alt+69,handler:()=>this._switchSubSession()});{const e=async(e,t)=>{const i=this._activePaneWidget.value();i&&("drawRightThere"===t.action?await i.drawRightThere(e,"Hotkey"):(mt.tool.setValue(e),(0,wn.trackDrawingToolSelected)(e,"Keyboard shortcut")))},t=(t,i)=>()=>e(t,i);Object.entries(bm.lineToolsSelectHotkeys).map((([e,i])=>({desc:i.description,hotkey:i.hash,handler:t(e,i)}))).forEach((e=>this._hotkeys.add(e)))}}this._hotkeys.add({desc:"Hide all drawing tools",hotkey:B.Modifiers.Mod+B.Modifiers.Alt+72,handler:()=>(0,Ss.toggleHideMode)()}),this.withModel(null,(()=>{const e=()=>this._hotkeys.promote();this.model().onSelectedSourceChanged().subscribe(null,e),this.model().crosshairSource().measurePane().subscribe((t=>{null!==t&&e()}))}))}_switchSubSession(){if(!this.hasModel())return;const e=this.model().mainSeries();if(!Re.Interval.parse(e.interval()).isIntraday())return;const t=e.symbolInfo();if(null===t)return;const i=t.subsessions?.filter((e=>!e.private))??[];if(0===i.length)return;const s=(i.findIndex((t=>t.id===e.properties().childs().sessionId.value()))+1)%i.length;this.model().setProperty(e.properties().childs().sessionId,i[s].id,wg)}_startSpinner(e){this._spinner||e&&(this._spinner=(new ks).spin(e))}_handleLoginStateChanged(){0}_checkObsoleteTimezone(){const e=this.properties().childs().timezone.value();(0,
Pe.timezoneIsAvailable)(e)||this.properties().childs().timezone.setValue({UTC:"Etc/UTC",EST:"America/New_York",CST:"America/Chicago",PST:"America/Los_Angeles"}[e]||"exchange")}_initColors(){const e=this.properties().childs(),t=e.scalesProperties.childs();t.lineColor.subscribe(this,this._updateAndPaint),t.textColor.subscribe(this,this._updateAndPaint),e.paneProperties.childs().separatorColor.subscribe(this,this._setPaneSeparatorLineColor)}_setPaneSeparatorLineColor(){this._paneSeparators.forEach((e=>e.update())),this._updateAndPaint()}_updateAndPaint(){this.update(),this.paint()}_makeDefaultGui(){this._makeLoadingScreen(),((0,r.getChartingLibraryGlobalContext)().configurationData.is_tradingview_data||this.onWidget())&&this._makeAvailableOnTVPopup(),this.hasModel()&&(this._makeTimeAxisWidget(),this._makePaneWidgetsAndSeparators(),this._updateScalesActions()),this._adjustSize(),(0,Kt.disableSelection)(this._elMainTable),this._updateAndPaint()}_makeLoadingScreen(){if(l.enabled("lean_chart_load")){if(this.screen)return;this.screen=new _o(this,(0,n.ensureNotNull)(this._parent))}else this.screen?.destroy(),this.screen=new _o(this,(0,n.ensureNotNull)(this._mainDiv))}_makeAvailableOnTVPopup(){this._availableScreen||(this._availableScreen=new Tm(this))}_initialiseWidgetSymbolChangeRestrictions(){}_activateSymbolSearchHotkeys(){this.readOnly()||this._options.hideSymbolSearch||(0,vs.activateKeyPressHandler)()}_makeTimeAxisWidget(){if(this._timeAxisWidget)return void this._timeAxisWidget.updatePriceAxisStubs();const e=this.model();this._timeAxisWidget=new pr(this,this._options.timeScaleWidget,this._titlesProvider.bind(this),this._menuItemsProvider.bind(this),this._backgroundBasedTheme.spawnOwnership()),this._elMainTable.appendChild(this._timeAxisWidget.getElement()),this._timeAxisWidget.updatePriceAxisStubs(),this._timeAxisWidget.onLabelHovered().subscribe(this,((t,i)=>{const s=this.maximizedPaneWidget(),o=s?s.state():e.paneForSource(e.mainSeries()),r=(0,n.ensureNotNull)(this.paneByState((0,n.ensureNotNull)(o))).highlightedPriceAxises(),a=r.value().slice(),l=a.findIndex((e=>e.owner===t.owner&&e.axis?.label===t.axis?.label));i||-1===l?i&&-1===l&&a.push({owner:t.owner,axis:t.axis}):a.splice(l,1),r.setValue(a),this.model().model().lightUpdate()}))}_updateAriaPriceDescription(e){if(this._ariaPriceDescription&&l.enabled("aria_crosshair_price_description")){const t=this.model().mainSeries().nearestData(e.index,dd.PlotRowSearchMode.Exact);if(!t)return;const i=t.value[4];if(!(0,tt.isNumber)(i))return;const s=this.model().timeScale().indexToUserTime(t.index),o=Re.Interval.parse(this.model().mainSeries().interval());this._ariaPriceDescription.updateChartDescription(this.model().mainSeries(),i,s?.getTime()??null,o.isIntraday())}}_titlesProvider(e,t){const i=this.model(),s=this.maximizedPaneWidget(),o=(0,n.ensureNotNull)(s?s.state():i.paneForSource(i.mainSeries())),r="right"===e?o.rightPriceScales():o.leftPriceScales();if(r.length<t+1)return[];let a=r[t].orderedSources().filter((e=>e===i.mainSeries()||(0,Ws.isStudy)(e)));return a.reverse(),
a=(0,Pt.moveToHead)(a,i.mainSeries()),a.map((e=>e.title(pa.TitleDisplayTarget.StatusLine,!0,void 0,!1)))}async _menuItemsProvider(e,t){const i=this.model(),s=this.maximizedPaneWidget(),o=(0,n.ensureNotNull)(s?s.state():i.paneForSource(i.mainSeries())),r="right"===e?o.visibleRightPriceScales():o.visibleLeftPriceScales();if(r.length<t+1)return[];const a=r[t],l=i.model().panes().indexOf(o),c=this._paneWidgets.value()[l],h="right"===e?c.rightPriceAxisesContainer():c.leftPriceAxisesContainer(),d=(0,n.ensureNotNull)(h).findAxisWidgetForScale(a);return await(d?.getContextMenuActions())??[]}_invalidationRAFCallback(e){if(this._drawPlanned=!1,this._drawRafId=0,!this._inLoadingState){if(this._invalidationMask){const t=this._invalidationMask;this._invalidationMask=null,this._update(t,e);for(const i of t.invalidationForTimeScale().animations)if(0===i.type&&!i.value.finished(e)){this.model().model().setTimeScaleAnimation(i.value,i.rightOffsetPx);break}}null!==this._chartPaintedPromise&&(this._chartPaintedPromise.resolve(),this._chartPaintedPromise=null)}}_applyTimeScaleInvalidations(e,t){for(const i of e.invalidationForTimeScale().animations)this._applyTimeScaleInvalidation(i,t)}_applyTimeScaleInvalidation(e,t){if(!this.hasModel())return;const i=this.model().model(),s=i.timeScale();if(0===e.type){const o=e.value.getStartPosition()-e.value.getPosition(t),n=e.rightOffsetPx+o,r=s.width()-n,a=s.indexToCoordinate(s.baseIndex());i.startScrollTime(a),i.scrollTimeTo(r),i.endScrollTime(),s.requestHistoryPointsIfNeeded(),e.value.finished(t)&&e.value.onFinish?.(!0)}}_onChartSessionCriticalError(e,t){this._disconnected.fire(!0)}_onData(e){if("reconnect_bailout"===e.method)this._reconnectBailout.fire();else this.model().model().onData(e)}_onConnection(){this.hasModel()?(this.model().model().restart(),this.model().model().fullUpdate(),this._connected.fire()):this._requestMetadataAndProcessModel()}_onDisconnect(){this.hasModel()&&this.model().model().disconnect(),this._model&&this._model.model().fullUpdate(),this._disconnected.fire()}async _requestMetadataAndProcessModel(){await this._requestMetadata(),this._inited||(await(0,zs.initAllLineToolsFromContent)(this._content),this._init(),this._chartWidgetInitialized.fire())}async _requestMetadata(){this._addPerfMark("RequestMetadataStart"),await(0,os.studyMetaInfoRepository)().requestMetaInfo(),this._addPerfMark("RequestMetadataEnd")}async _createControlBar(){const e=await Promise.all([i.e(3644),i.e(3439),i.e(1171),i.e(2537),i.e(8752),i.e(7780),i.e(2112),i.e(7691),i.e(7369),i.e(2227),i.e(2477),i.e(8093),i.e(5093)]).then(i.bind(i,30854));this._controlBarNavigation=new e.ControlBarNavigation(this,(0,n.ensureNotNull)(this._mainDiv),this._options.controlBar),this._model&&this._adjustSize()}_subscribeToDrawingState(){if(this.readOnly())return;(0,mt.init)();const e=(e,t)=>{const i=this._model;if(null===i)return;const s=i.model();e.model!==s&&(this._lineToolsSynchronizer&&l.enabled("cl_revert_separate_loading_logic")?this._lineToolsSynchronizer.executeSynchronizationInLayoutAction((()=>t(s,i))):t(s,i))}
;mt.createdLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=(0,n.ensureNotNull)(e.paneForSource(e.mainSeries()));let o,r=null;if(void 0===t.pointPositionPercents){if(r=xg(e,t.model,t.point.timeStamp),null===r)return;o=t.point.price}else{const i=t.pointPositionPercents.x*e.timeScale().width(),s=e.mainSeries().priceScale(),n=t.pointPositionPercents.y*s.height(),a=e.mainSeries().firstValue();if(null===a)return;r=e.timeScale().coordinateToIndex(i),o=s.coordinateToPrice(n,a)}const a={index:(0,n.ensureNotNull)(r),price:o},l=i.createLineTool({pane:s,point:a,linetool:t.linetool,properties:t.properties,linkKey:t.linkKey,ownerSource:e.mainSeries(),synchronizationMode:Cr.CreateLineToolSyncMode.ForceOff,id:t.id,sharingMode:t.sharingMode});null!==l&&!Boolean(this.model().lineBeingCreated())&&t.finalState&&l.restoreExternalPoints(t.finalState,{indexesChanged:!0,pricesChanged:!0})}))})),mt.continuedLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=xg(e,t.model,t.point.timeStamp);if(null===s)return;const o={index:s,price:t.point.price},n=e.lineBeingCreated();if(null===n)return;i.continueExternalLine(o,t.envState??void 0,!!t.finalState)&&t.finalState&&n.restoreExternalPoints(t.finalState,{indexesChanged:!0,pricesChanged:!0})}))})),mt.cancelledLineTool.subscribe(this,(t=>{e(t,(async(e,t)=>{e.cancelCreatingLine()}))})),mt.beenSetLineToolLastPoint.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.lineBeingCreated();if(null===s||s.linkKey().value()!==t.linkKey)return;const o=xg(e,t.model,t.point.timeStamp);if(null===o)return;const n={index:o,price:t.point.price};s.setLastPoint(n),s.updateAllViews((0,wi.sourceChangeEvent)(s.id())),e.lightUpdate()}))})),mt.startedMovingLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=t.linkKeys.map((t=>e.lineToolByLinkKey(t))).filter(tt.notNull);if(s.length){const i=xg(e,t.model,t.point.timeStamp);if(null===i)return;const o={index:i,price:t.point.price},n=t.activeItem??null,r=s[0].pointToScreenPoint(o);r&&e.startMovingSources(s,{logical:o,screen:r},n,t.pointPositionPercents,null===t.envState?void 0:t.envState,!0)}}))})),mt.movedLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.sourcesBeingMoved().filter(zs.isLineTool).filter((e=>(e=>t.linkKeys.some((t=>e.linkKey().value()===t)))(e)));if(!s.length)return;const o=xg(e,t.model,t.point.timeStamp);if(null===o)return;const n={index:o,price:t.point.price},r=s[0].pointToScreenPoint(n);r&&e.moveSources({logical:n,screen:r},t.pointPositionPercents,t.envState??void 0,!0)}))})),mt.finishedMovingLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.sourcesBeingMoved().filter(zs.isLineTool);if(0===s.length)return;s.forEach((i=>{const s=(e=>{for(let i=0;i<t.linkKeys.length;i++)if(t.linkKeys[i]===e.linkKey().value())return{state:t.finalStates[i],changes:t.changes[i]};return null})(i);e.endMovingSources(null!==s,!0),null!==s&&(i.restoreExternalPoints(s.state,s.changes),s.state.pointPositionPercents&&i.restorePositionPercents(s.state.pointPositionPercents))}))}))})),mt.startedChangingLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{
const s=e.lineToolByLinkKey(t.linkKey);if(null!==s){let i=null;if(t.positionPercents){const o=e.timeScale().positionPercentToCoordinate(t.positionPercents.x),r=(0,n.ensureNotNull)(s.priceScale()).positionPercentToCoordinate(t.positionPercents.y);if(i=s.screenPointToPoint((0,Vt.point)(o,r),!0),!i)return}else{const o=s.getPoint(t.pointIndex),n=o?o.index:xg(e,t.model,t.point.timeStamp);if(null===n)return;i={index:n,price:t.point.price}}s.isActualSymbol()&&s.isActualCurrency()&&s.isActualUnit()&&e.startChangingLinetool(s,(0,n.ensureNotNull)(s.ownerSource()),i,t.pointIndex,t.envState??void 0,!0)}}))})),mt.changedLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.lineBeingEdited();if(null===s||s.linkKey().value()!==t.linkKey)return;let o=null;if(t.positionPercents){const i=e.timeScale().positionPercentToCoordinate(t.positionPercents.x),r=(0,n.ensureNotNull)(s.priceScale()).positionPercentToCoordinate(t.positionPercents.y);if(o=s.screenPointToPoint((0,Vt.point)(i,r),!0),!o)return}else{let i=null;if(i=t.changes.indexesChanged?xg(e,t.model,t.point.timeStamp):(0,n.ensureNotNull)(e.linePointBeingChanged()).index,null===i)return;o={index:i,price:t.point.price}}s.isActualSymbol()&&s.isActualCurrency()&&s.isActualUnit()&&e.changeLinePoint(o,void 0,!0)}))})),mt.finishedChangingLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.lineToolByLinkKey(t.linkKey);null!==s&&s.isActualSymbol()&&s.isActualCurrency()&&s.isActualUnit()&&null!==e.lineBeingEdited()&&e.endChangingLinetool(!!t.finalState,!0),null!==s&&t.finalState&&(t.finalState.pointPositionPercents?s.restorePositionPercents(t.finalState.pointPositionPercents):s.restoreExternalPoints(t.finalState,t.changes))}))})),mt.removedLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const{withUndo:s,unlink:o,linkKey:n}=t,r=e.lineToolByLinkKey(n);null!==r&&(o&&r.detachAlert(),s?i.removeSource(r,!1):(e.lineToolsGroupModel().removeLineTools([r]),e.removeSource(r)))}))})),mt.finishedLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.lineToolByLinkKey(t.linkKey);null!==s&&(0,Lt.isLineToolFinishRequiredWhenCreatedByApi)(s.toolname)&&s.finish()}))})),mt.changedLineStyle.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.lineToolByLinkKey(t.linkKey);if(null!==s){const{zOrder:e,...i}=t.state;void 0!==e&&s.setZorder(e),(0,ps.default)(i)||(s.restoreExternalState(i),s.propertiesChanged(!0)),t.alertId&&s.syncAlert(t.alertId)}}))})),mt.restoredLineToolState.subscribe(this,(t=>{e(t,(async(e,i)=>{const s=e.lineToolByLinkKey(t.linkKey);if(null!==s){const i={...t.state};i.indexes=t.state.points.map((i=>({index:xg(e,t.model,i.time_t),price:i.price}))),e.restoreLineToolState(s,i,!1)}}))})),mt.restoredLineTool.subscribe(this,(t=>{e(t,(async(e,i)=>{e.restoreSource(t.state.restorePane,t.state.paneIndex,t.state.paneState,t.state.sourceState,null)}))})),mt.copiedLineTool.subscribe(this,(async t=>{e(t,(async(e,i)=>{const s=(0,n.ensureNotNull)(e.paneForSource(e.mainSeries()));let o;const r={...t.state,intervalsVisibilities:(0,bh.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities)},a=(0,
zs.createLineToolProperties)(e.backgroundTheme().spawnOwnership(),t.linetool,!e.readOnly(),r),l=e.dataSourceForId(t.id);if(l){if(!(0,zs.isLineTool)(l))return void gg.logError(`Error sync creating line tool. Object with id ${t.id} is already in use and it is not a line tool`);if(l.toolname!==t.linetool)return void gg.logError(`Error sync creating line tool. Object with id ${t.id} is already in use and its type differs: ${l.toolname} and ${t.linetool}`)}if(l&&(l.linkKey().setValue(t.linkKey),l.share(t.sharingMode)),t.pointPositionPercents){const e={index:0,price:0};if(o=l??i.createLineTool({pane:s,point:e,linetool:t.linetool,properties:a,linkKey:t.linkKey,synchronizationMode:Cr.CreateLineToolSyncMode.ForceOff,id:t.id}),null===o)return;o.restorePositionPercents((0,n.ensureDefined)(t.pointPositionPercents))}else{const r=i=>({index:(0,n.ensureNotNull)(xg(e,t.model,i.timeStamp)),price:i.price}),c=t.points.map(r),h=t.pointsForCreating.map(r),d=c[0];if(l)o=l;else if(t.withUndo)o=i.createLineTool({pane:s,point:d,linetool:t.linetool,properties:a,linkKey:t.linkKey,sharingMode:t.sharingMode,synchronizationMode:Cr.CreateLineToolSyncMode.ForceOff,id:t.id});else{const e=new _a({model:i.model(),pane:s,lineTool:t.linetool,ownerSource:(0,n.ensureNotNull)(s.mainDataSource()),drawOnAllChartsMode:t.sharingMode,id:t.id});e.redo(),e.startCreatingLine(d,a,t.linkKey||null,t.sharingMode,!0),o=(0,n.ensureNotNull)(e.line())}if(null===o)return;const u=(e,s)=>{t.withUndo?i.continueCreatingLine(e,new To.EnvironmentState(void 0,!0),s,!0):i.model().continueCreatingLine(e,new To.EnvironmentState(void 0,!0),s,!0)},_=(0,Lt.isLineToolFinishRequiredWhenCreatedByApi)(t.linetool);if(e.lineBeingCreated())if(h.length>1)for(let e=1;e<h.length;e++)u(h[e],e<h.length-1&&!_),e===h.length-1&&_&&(o.finish(),u(h[e],!0));else _&&(o.finish(),u(h[0],!0))}o.properties().interval.setValue(t.state.interval),o.restoreExternalState(t.state),o.restoreData&&o.restoreData(t),o.setZorder(t.zOrder),o.propertiesChanged(!0),t.finalState&&(o.calcIsActualSymbol(),o.restoreExternalPoints(t.finalState,{pricesChanged:!0,indexesChanged:!0})),t.alertId&&o.syncAlert(t.alertId)}))}))}_setFirstRequestNumbarsUsingTimeframeAndInterval(e){const t=function(e){const t=e.numberExtraBars??0,i=e.barSpacing||6,s=Math.ceil(e.width/i)+t;if(e.timeFrame){if(!e.interval)return{barCount:s};const i=Re.Interval.parse(e.interval);if("string"==typeof e.timeFrame){if("ALL"===e.timeFrame)return{barCount:s};let o=e.timeFrame;"YTD"===e.timeFrame&&(o=`${Math.floor(((new Date).valueOf()-new Date((new Date).getFullYear(),0,0).valueOf())/1e3/60/60/24)}D`);const n=Re.Interval.parse(o),r=Date.now().valueOf(),a=r-n.inMilliseconds();return{barCount:(0,Td.getPeriodsBetweenDates)(e.symbolInfo?.session??"24x7",e.symbolInfo?.session_holidays??"",e.symbolInfo?.corrections??"",i.letter(),i.multiplier(),a,r)+t,message:`based on period of ${o}`,shouldAdjustBarSpacing:!0}}if("time-range"===e.timeFrame.type)return{barCount:(0,
Td.getPeriodsBetweenDates)(e.symbolInfo?.session??"24x7",e.symbolInfo?.session_holidays??"",e.symbolInfo?.corrections??"",i.letter(),i.multiplier(),1e3*e.timeFrame.from,1e3*e.timeFrame.to)+t,message:`based on time range: ${e.timeFrame.from} ... ${e.timeFrame.to}`,shouldAdjustBarSpacing:!0}}return{barCount:s}}({width:e.timeScale().width(),barSpacing:e.timeScale().barSpacing(),timeFrame:this.options().defTimeframe,interval:this.options().defInterval});if(l.enabled("charting_library_debug_mode")&&console.log(`${(new Date).toISOString()} Setting initial data request count to ${t.barCount} bars${t.message?` (${t.message})`:""}`),e.mainSeries().seriesSource().setInitialRequestOptions({count:t.barCount}),t.shouldAdjustBarSpacing&&"number"==typeof t.barCount&&t.barCount>0){const i=Math.ceil(e.timeScale().width()/t.barCount);e.timeScale().setBarSpacing(i)}}_createEventHint(){if(null===this._eventHintDeferredPromise){const e=(0,me.createDeferredPromise)();this._eventHintDeferredPromise=e,Promise.all([i.e(6195),i.e(628),i.e(2227),i.e(6166)]).then(i.bind(i,91759)).then((t=>{e.resolve(new t.ChartEventHintRenderer(this._chartWidgetCollection.getContainer()))}))}return this._eventHintDeferredPromise.promise}async _createWarningHint(){return null}_showEventHint(e){l.enabled("popup_hints")&&(null!==this._activeHint&&0===this._activeHint.type?this._activeHint.show(e):(this._hideHint(),this._createEventHint().then((t=>{this._activeHint=t,void 0!==e&&this._activeHint.show(e)}))))}_showWarningHint(e){0}_hideHint(){null!==this._activeHint&&this._activeHint.hide()}_checkIsTradedGroupSelected(){const e=this.model(),t=e.model();return e.selection().customSources().some((e=>t.customSourceName(e)?.startsWith(tradedGroupPlaceOrderPrefix)||t.customSourceName(e)?.startsWith(tradedGroupEditOrderPrefix)))}_setActions(){return this._unsetActions(),this._addHotkeys(),this._actions=rg(this),this.withModel(null,(()=>{const e=this.model().mainSeries(),t=e.properties();t.childs().priceAxisProperties.subscribe(this,this._updateScalesActions),e.priceScaleAboutToBeChanged().subscribe(this,(()=>{t.childs().priceAxisProperties.unsubscribeAll(this)})),e.priceScaleChanged().subscribe(this,(()=>{t.childs().priceAxisProperties.subscribe(this,this._updateScalesActions),this._updateScalesActions()}))})),this._updateScalesActions(),this._actions}_unsetActions(){this._actions&&(Object.values(this._actions).forEach((e=>{e.destroy()})),this._actions=null)}_updateTimingsMeterState(){const e=this._options.visible.value();null!==this._timingsMeter&&(e?this._timingsMeter.startCollect():this._timingsMeter.stopCollect())}_onBackgroundColorChanged(){this._paneWidgets.value().forEach((e=>{e.setCursorForTool()})),this.update(),this.model().model().fullUpdate()}_contentSeriesProperties(){if(this._content)for(let e=this._content.panes.length;e-- >0;){const t=this._content.panes[e].sources;for(let e=t.length;e-- >0;){const i=t[e];if((0,wt.isMainSeriesState)(i))return i.state??null}}return null}async _getChartPropertyDefinitionsViewModel(){if(null===this._definitionsViewModel){
const e=await Promise.all([i.e(5418),i.e(5410),i.e(7903),i.e(3596)]).then(i.bind(i,19350));if(this._isDestroyed)throw new Error("Chart widget already destroyed");await new Promise((e=>this.withModel(null,e))),null===this._definitionsViewModel&&(this._definitionsViewModel=new e.ChartPropertyDefinitionsViewModel(this.model(),this.properties(),this._options))}return this._definitionsViewModel}}var Eg=i(26743),Dg=i(1866);const Bg=!l.enabled("widget_logo")||!1;var Vg;function Rg(e,t=null,i=null){let s={};if("number"==typeof e)return{relativePositions:{[e]:{l:t,t:i}},nextElementLeft:e,nextElementTop:e};const[o,...n]=e;if("v"===o){let e=null;for(const o of n){const n=Rg(o,t,i);s={...s,...n.relativePositions},i=n.nextElementTop,e=n.nextElementLeft}t=e}if("h"===o){let e=null;for(const o of n){const n=Rg(o,t,i);s={...s,...n.relativePositions},t=n.nextElementLeft,e=n.nextElementTop}i=e}return{relativePositions:s,nextElementTop:i,nextElementLeft:t}}!function(e){e[e.LegendTopMargin=10]="LegendTopMargin",e[e.LegendLeftMargin=8]="LegendLeftMargin",e[e.LegendLineSpacingCoeff=1.4]="LegendLineSpacingCoeff",e[e.LegendItemSpacingCoeff=1.4]="LegendItemSpacingCoeff",e[e.LegendTextFontSize=12]="LegendTextFontSize",e[e.Padding=10]="Padding",e[e.ChartsSpacing=5]="ChartsSpacing",e[e.FooterHeight=60]="FooterHeight",e[e.LogoHeight=28]="LogoHeight",e[e.LogoWidth=162]="LogoWidth"}(Vg||(Vg={}));const Ng=function(e){const t={};for(const i of Object.keys(e)){const s=Rg(e[i]).relativePositions;t[i]=s}return t}(Eg);function Og(e,t,i,s){let o=Math.round(10*s),n=Math.round(10*s);const r=i[e];if(null!==r.l){const e=Og(r.l,t,i,s);o=e.x+e.width+Math.round(5*s)}if(null!==r.t){const e=Og(r.t,t,i,s);n=e.y+e.height+Math.round(5*s)}const a=t[e];return{x:o,y:n,width:a.width,height:a.height}}function Fg(e,t,i){const s=(new DOMParser).parseFromString(Dg,"image/svg+xml");s?.firstElementChild?.setAttribute("color",i);const o=URL.createObjectURL(new Blob([(new XMLSerializer).serializeToString(s)],{type:"image/svg+xml"}));return new Promise((i=>{const s=new Image;s.width=e,s.height=t,s.onload=()=>{i({image:s,width:e,height:t})},s.src=o}))}function Wg(e,t,i,s){return(0,Kt.drawScaled)(e,s,s,(()=>{e.fillText(i,t.x/s,t.y/s)})),e.measureText(i).width*s}function Hg(e,t,i,s,o,n){const r=o.map((e=>e.text)).join("");let a=i.x;const l=function(e,t,i,s){if(e.measureText(t).width*s<=i)return{text:t,elided:!1};const o=e.measureText("...").width*s,n=[];for(let e=0;e<t.length;++e)n.push(e);const r=(0,Pt.upperbound)(n,i,((n,r)=>e.measureText(t.slice(0,r+1)).width*s+o>i));return{text:(t=t.slice(0,r)).trim(),elided:!0}}(e,r,s-a,t);if(l.elided&&!n)return null;const c=[];let h=0;for(const e of o){if(h+e.text.length>l.text.length)break;c.push(e.text),h+=e.text.length}const d=c.join("").trim().length;h=0;for(const s of o){if(h+s.text.length>d)break;s.color&&(e.save(),e.fillStyle=s.color),a+=Wg(e,new Vt.Point(a,i.y),s.text,t),s.color&&e.restore(),h+=s.text.length}return l.elided&&(a+=Wg(e,new Vt.Point(a,i.y),"...",t)),a}function zg(e){return e.map((e=>({...e,title:""})))}function Ug(e,t){
const i=[{text:e.trim()}];for(const e of t)e.visible&&(""!==i[i.length-1].text&&i.push({text:"  "}),e.title&&i.push({text:e.title}),i.push({text:e.value,color:e.color}));return i}class jg{constructor(e,t){this._logoTextColor=null,this._snapshotData=e,t=t||{},this._options={backgroundColor:L.themes[e.theme].getThemedColor("color-bg-primary"),borderColor:L.themes[e.theme].getThemedColor("color-border"),font:m.CHART_FONT_FAMILY,fontSize:12,legendMode:"vertical",hideResolution:!1,hideStudiesFromLegend:!1,showHeaderPublishedBy:!1,showHeaderMainSymbol:!1,...t};const i=Ng[e.layout],s=e.charts.map((e=>function(e){const t=e.panes[0],i=t.canvas.width+t.leftAxis.canvas.width+t.rightAxis.canvas.width;let s=0;for(const t of e.panes)s+=t.canvas.height;return void 0!==e.timeAxis&&0!==e.timeAxis.contentHeight&&(s+=e.timeAxis.canvas.height),(0,Ft.size)({width:i,height:s})}(e)));if(this._pixelRatio=e.hidpiRatio,this._chartsGeometry=e.charts.map(((e,t)=>Og(t,s,i,this._pixelRatio))),!Bg){let i=e.theme;void 0!==t.backgroundColor&&(i="black"===(0,Nt.rgbToBlackWhiteString)((0,Nt.parseRgb)(t.backgroundColor),150)?$s.StdTheme.Dark:$s.StdTheme.Light),this._logoTextColor=L.themes[i].getThemedColor("color-text-primary")}this._headerDefaultTextColor=L.themes[e.theme].getThemedColor("color-text-primary")}async getImage(){const e=this._pixelRatio;let t=0,i=0,s=0;const o=this._headerItems();if(o.length>0){s=Math.ceil(1.4*this._options.fontSize*e)*o.length}i+=s;let n=0,r=0;for(const e of this._chartsGeometry)n=Math.max(n,e.x+e.width),r=Math.max(r,e.y+e.height);const a=i;t+=n,i+=r,t+=Math.round(10*e);const l=Bg?Math.round(10*e):Math.round(60*e),c=i;i+=l;const h=(0,Kt.createDisconnectedCanvas)(document,(0,Ft.size)({width:t,height:i}),1),d=(0,Kt.getContext2D)(h);d.font=(0,si.makeFont)(this._options.fontSize,this._options.font),d.textBaseline="top",d.fillStyle=this._options.backgroundColor,d.fillRect(0,0,t,i),o.length>0&&this._drawHeader(d,o,t,new Vt.Point(Math.round(10*e),Math.round(10*e)));for(let e=0;e<this._snapshotData.charts.length;++e){const t=this._snapshotData.charts[e],i=this._chartsGeometry[e];this._drawChart(t,i,d,new Vt.Point(0,a))}if(null!==this._logoTextColor){const t=await Fg(Math.round(162*e),Math.round(28*e),this._logoTextColor);d.drawImage(t.image,Math.round(10*e),c+Math.round(l/2-t.height/2),t.width,t.height)}return h}_drawChart(e,t,i,s){i.save(),i.translate(t.x+s.x,t.y+s.y);let o=0;for(const t of e.panes){let s=0;const n=t.leftAxis.canvas.width+Math.round(8*this._pixelRatio),r=o,a=o+Math.round(10*this._pixelRatio);t.leftAxis.contentWidth>0&&t.leftAxis.contentHeight>0&&(i.drawImage(t.leftAxis.canvas,s,o),s+=t.leftAxis.canvas.width),i.drawImage(t.canvas,s,o),s+=t.canvas.width,t.rightAxis.contentWidth>0&&t.rightAxis.contentHeight>0&&i.drawImage(t.rightAxis.canvas,s,o),"pane"===t.type&&(i.fillStyle=e.colors.text,this._drawLegend(t,i,new Vt.Point(n,a),r)),o+=t.canvas.height}if(void 0!==e.timeAxis&&0!==e.timeAxis.contentHeight){let t=0
;e.timeAxis.lhsStub.contentWidth>0&&e.timeAxis.lhsStub.contentHeight>0&&(i.drawImage(e.timeAxis.lhsStub.canvas,t,o),t+=e.timeAxis.lhsStub.canvas.width),i.drawImage(e.timeAxis.canvas,t,o),t+=e.timeAxis.canvas.width,e.timeAxis.rhsStub.contentWidth>0&&e.timeAxis.rhsStub.contentHeight>0&&i.drawImage(e.timeAxis.rhsStub.canvas,t,o)}i.strokeStyle=this._options.borderColor,i.strokeRect(0,0,t.width,t.height),i.restore()}_headerItems(){const e=[];if(this._options.showHeaderPublishedBy&&this._snapshotData.publishedBy)for(const t of this._snapshotData.publishedBy)e.push([{text:t}]);if(this._options.showHeaderMainSymbol){const t=this._snapshotData.charts[0],i=`${t.meta?.symbol}, ${t.meta?.resolution}`;e.push(Ug(i,t.meta?.values??[]))}return e}_drawHeader(e,t,i,s){e.save(),e.fillStyle=this._headerDefaultTextColor;const o=Math.ceil(1.4*this._options.fontSize*this._pixelRatio);t.forEach(((t,n)=>{Hg(e,this._pixelRatio,new Vt.Point(s.x,s.y+o*n),i,t,!0)})),e.restore()}_drawLegend(e,t,i,s){let o=!0;const r=Math.ceil(1.4*this._options.fontSize*this._pixelRatio);let a=i.x,l=i.y;if(e.mainSeriesText&&l+r<s+e.canvas.height){const i=Hg(t,this._pixelRatio,new Vt.Point(a,l),e.contentWidth*this._pixelRatio,Ug(e.mainSeriesText,e.mainSeriesValues),!0);"horizontal"!==this._options.legendMode?l+=r:(a=(0,n.ensureNotNull)(i)+1.4*this._options.fontSize*this._pixelRatio,o=!1)}for(let n=0;n<e.studies.length;++n)if(l+r<s+e.canvas.height){const s=e.studies[n],c=e.studiesValues[n];let h=null;for(;null===h;)h=Hg(t,this._pixelRatio,new Vt.Point(a,l),e.contentWidth*this._pixelRatio,this._options.hideStudiesFromLegend?[]:Ug(s,zg(c)),o),"horizontal"!==this._options.legendMode?l+=r:null===h?(o=!0,a=i.x,l+=r):(a=h+1.4*this._options.fontSize*this._pixelRatio,o=!1)}}}var Gg=i(58043),qg=i(69600);function $g(e){return`chart-widget-collection-border-${e}`}const Kg=new dt.TranslatedString("resize layout",Vm.t(null,void 0,i(47418))),Yg=new dt.TranslatedString("reset layout sizes",Vm.t(null,void 0,i(85366)));var Zg;function Xg(e,t){return e.selected===t.selected&&e.withShift===t.withShift}!function(e){e[e.EDGE=0]="EDGE",e[e.BORDER=0]="BORDER",e[e.PADDING=2]="PADDING"}(Zg||(Zg={}));class Jg{constructor(e){this._selected=new yt.WatchedObject({selected:!1,withShift:!1},Xg),this._onShiftPressed=e=>{const t=this._state.currentLayoutResizeAction.value();t&&this._applyMouseMove(t.delta,e)},this._state=e.state,this._splitterElement=e.splitterElement,this._splitter=e.splitter,this._computeContentBox=e.computeContentBox,(0,Vs.shiftPressed)().subscribe(this._onShiftPressed),this._selected.subscribe((e=>{if(e.selected){const t=$g(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(t)).forEach((e=>e.classList.remove(qg.hovered)));(e.withShift?Array.from(this._state.parent.getElementsByClassName(t)):[this._splitterElement]).forEach((e=>e.classList.add(qg.hovered)))}else{const e=$g(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(e)).forEach((e=>e.classList.remove(qg.hovered)))}}))}destroy(){(0,
Vs.shiftPressed)().unsubscribe(this._onShiftPressed)}mouseDownEvent(e){this._mouseDownOrTouchStartEvent(e)}touchStartEvent(e){this._selected.value().selected&&this._mouseDownOrTouchStartEvent(e)}pressedMouseMoveEvent(e){this._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._selected.value().selected&&this._pressedMouseOrTouchMoveEvent(e)}mouseUpEvent(e){this._mouseUpOrTouchEndEvent(e)}touchEndEvent(e){this._mouseUpOrTouchEndEvent(e)}mouseEnterEvent(e){this._selected.setValue({selected:!0,withShift:e.shiftKey})}mouseLeaveEvent(){this._selected.setValue({selected:!1,withShift:!1})}mouseDoubleClickEvent(e){this._resetLayoutSizes()}doubleTapEvent(){this._resetLayoutSizes()}tapEvent(e){this._selected.setValue({selected:!this._selected.value().selected,withShift:e.shiftKey})}touchStartOutsideEvent(e){this._selected.setValue({selected:!1,withShift:!1})}_mouseDownOrTouchStartEvent(e){const t=new Vt.Point(e.localX+this._splitterElement.offsetLeft,e.localY+this._splitterElement.offsetTop),i=(0,Gg.deepCopy)(this._state.sizingState.value());this._state.currentLayoutResizeAction.setValue({point:t,splitter:this._splitter,initialState:i,alignedState:this._state.layoutTemplate.value().syncSublayoutsBySplitter(this._splitter,(0,Gg.deepCopy)(i)),shiftState:e.shiftKey,delta:0}),this._selected.setValue({selected:!0,withShift:e.shiftKey})}_pressedMouseOrTouchMoveEvent(e){const t=this._state.currentLayoutResizeAction.value();if(!t)return;t.shiftState!==e.shiftKey&&(this._selected.setValue({selected:!0,withShift:e.shiftKey}),t.shiftState=e.shiftKey);const i=new Vt.Point(e.localX+this._splitterElement.offsetLeft,e.localY+this._splitterElement.offsetTop);t.delta="v"===t.splitter.orientation?i.y-t.point.y:i.x-t.point.x,this._applyMouseMove(t.delta,e.shiftKey)}_mouseUpOrTouchEndEvent(e){const t=this._state.currentLayoutResizeAction.value();if(t&&(this._splitterElement.classList.remove(qg["i-active"]),this._state.currentLayoutResizeAction.setValue(null),t.currentState)){this._state.undoHistory.beginUndoMacro(Kg),this._state.undoHistory.pushUndoCommand(new lt(this._state.sizingState,t.initialState,t.currentState,Kg));const e=this._state.layoutTemplate.value().layoutType;this._state.undoHistory.pushUndoCommand(new at((t=>t?this._state.allLayoutSizesState.set(e,t):this._state.allLayoutSizesState.delete(e)),this._state.allLayoutSizesState.get(this._state.layoutTemplate.value().layoutType),this._state.sizingState.value(),Yg)),this._state.undoHistory.endUndoMacro(),this._state.layoutSizesChanged.setValue(!0)}}_applyMouseMove(e,t){const i=(0,n.ensureNotNull)(this._state.currentLayoutResizeAction.value()),s=t?i.alignedState:i.initialState,o=this._state.options.padding??2,r=this._computeContentBox();i.currentState=this._state.layoutTemplate.value().resizeApplier(r,o,e,i.splitter,(0,Gg.deepCopy)(s),t),this._state.sizingState.setValue(i.currentState)}_resetLayoutSizes(e){const t=(0,
_s.layoutInitialSizingState)(this._state.layoutTemplate.value().expression),i=this._state.layoutTemplate.value().layoutType,s=e=>e?this._state.allLayoutSizesState.set(i,e):this._state.allLayoutSizesState.delete(i);if(e)return this._state.sizingState.setValue(t),void s(t);this._state.undoHistory.beginUndoMacro(Yg),this._state.undoHistory.pushUndoCommand(new lt(this._state.sizingState,this._state.sizingState.value(),t,Yg)),this._state.undoHistory.pushUndoCommand(new at(s,this._state.allLayoutSizesState.get(this._state.layoutTemplate.value().layoutType),t,Yg)),this._state.undoHistory.endUndoMacro()}}const Qg=(0,ne.getLogger)("Chart.ChartWidgetCollection"),ef=(a.t(null,void 0,i(98226)),a.t(null,void 0,i(70079)),a.t(null,void 0,i(94656)),a.t(null,void 0,i(92101)),a.t(null,void 0,i(85902)),a.t(null,void 0,i(32482)),new dt.TranslatedString("change series style",a.t(null,void 0,i(49965)))),tf=new dt.TranslatedString("sync time",a.t(null,void 0,i(91677))),sf=new dt.TranslatedString("symbol lock",a.t(null,void 0,i(53278))),of=new dt.TranslatedString("interval lock",a.t(null,void 0,i(56558))),nf=new dt.TranslatedString("date range lock",a.t(null,void 0,i(58850))),rf=new dt.TranslatedString("track time",a.t(null,void 0,i(46807))),af=new dt.TranslatedString("set layout sizes",a.t(null,void 0,i(46302))),lf=new dt.TranslatedString("reset layout sizes",a.t(null,void 0,i(85366))),cf=function(e,t){const i=t.model().model().studyTemplate();e.undoHistory.beginUndoMacro(rs);for(let s=0;s<e.chartWidgetsDefs.length;s++){const o=e.chartWidgetsDefs[s].chartWidget;o!==t&&(o.hasModel()&&o.model().applyStudyTemplate(i,""))}e.undoHistory.endUndoMacro()},hf=async function(e,t,i,s,o){e.undoHistory.beginUndoMacro(o);for(let r=0;r<e.chartWidgetsDefs.length;r++){const a=e.chartWidgetsDefs[r].chartWidget;if(a!==t&&a&&a.hasModel()){const t=a.model();if(!ls(i,t))continue;let r;if(s.isOnMainPane)r=(0,n.ensureNotNull)(t.model().paneForSource(a.model().model().mainSeries()));else{const i=new Ui(t.model(),s.paneIndex);e.undoHistory.pushUndoCommand(i);const o=(0,n.ensureDefined)(i.createdPaneId());r=(0,n.ensureDefined)(t.model().panes().find((e=>e.id()===o)))}const l=await t.pasteSourceFromClip(r,i,!0);if(l&&1===l.length){const e=l[0];if(s.asCompare){const i=(0,n.ensureNotNull)(t.mainSeries().priceScale());t.moveToScale(e,(0,n.ensureDefined)(r),i,o),t.setPriceScaleMode({percentage:!0},i,null)}}t.model().lightUpdate()}}e.undoHistory.endUndoMacro()},df=async function(e,t,i,s){const o=e.map((e=>e.chartWidget)).filter((e=>e.hasModel())).filter((e=>e.id()===t||0!==s));try{o.forEach((e=>e.startApplyingLineToolUpdateNotification()));for(const e of o)await e.model().model().withoutLineToolsSyncAction((()=>e.applyLineToolUpdateNotification(i,s)))}finally{o.forEach((e=>e.endApplyingLineToolUpdateNotification()))}},uf=function(e){return new es({copyRequested:(t,i)=>{e.activeChartWidget.value().model().clipboardCopy(t,i)},cutRequested:(t,i)=>{e.activeChartWidget.value().model().clipboardCut(t,i)},pasteRequested:(t,i)=>{if(i?.mode()===zi.PaneMode.Widget)return
;(i?i.model().undoModel():e.activeChartWidget.value().model()).clipboardPaste(t,i)}})},_f=function(e){const t={};return e.chartWidgetsDefs.map((e=>e.chartWidget)).forEach((e=>t[e.id()]=function(e){const t={};if(!e.hasModel()){const i=e.options().content;if(!i)return t;const s=(0,n.ensureNotNull)(i.panes.reduce(((e,t)=>e??t.sources.find((e=>"MainSeries"===e.type))??null),null));return t.resolution=s.state?.interval,t.symbol=s.state?.symbol,t.short_name=s.state?.shortName,t}const i=e.model().mainSeries(),s=i.properties().childs(),o=i.symbolInfo();t.resolution=s.interval.value(),t.symbol_type=null!==o&&o.type||"",t.exchange=null!==o&&o.exchange||"",t.listed_exchange=null!==o&&o.listed_exchange||"";const r=o?.legs??[];if(null!==o&&i.isSpread()){const e=r[0];let i=o.base_name[0];i=i.split(":")[1],t.symbol=e,t.short_name=i,t.expression=o.full_name}else t.symbol=null!==o&&o.ticker||s.symbol.value(),t.short_name=s.shortName.value();const a=o?.base_name??[];return t.legs=r.map(((e,t)=>({symbol:e,pro_symbol:a[t]}))),t}(e))),t},pf=function(e,t,i){const s=e.chartWidgetsDefs.slice(0,e.layoutTemplate.value().count).map(((t,i,s)=>({def:t,metrics:e.layoutTemplate.value().sizer({top:0,left:0,width:256,height:256},i,s.length,0)}))).sort(((e,t)=>e.metrics.top-t.metrics.top||e.metrics.left-t.metrics.left)).map((e=>e.def));if(s.length<2)return null;let o=s.indexOf(t);return-1===o?null:(o=(o+(i?s.length-1:1))%s.length,s[o])},mf=function(e){let t=1;for(;e(""+t);)t++;return""+t},gf=async function(e,t,i){const{theme:s,onlyActiveChart:o,restoreNonThemeDefaults:n,themeName:r,standardTheme:a,syncState:l=!0,noUndo:c}=i,h=(0,L.getCurrentTheme)().name;let d;o?d=[e.activeChartWidget.value()]:(await Promise.all(e.savedChartWidgetOptions.map(((e,t)=>t)).map((t=>new Promise((i=>{const s=function(e,t,i){return e.addNewChartWidget(t,i)}(e,t,i);e.hideChart(s)}))))),d=e.chartWidgetsDefs.map((e=>e.chartWidget))),c?(a&&new is(h,r,l).redo(),d.forEach((e=>{e.model().model().restoreTheme(s,n,c)}))):(e.undoHistory.beginUndoMacro(as),a&&e.undoHistory.pushUndoCommand(new is(h,r,l)),d.forEach((e=>{e.model().model().restoreTheme(s,n)})),e.undoHistory.endUndoMacro()),await Promise.all(d.map((e=>e.model().model().colorStudiesPropertiesReady())))},ff=function(e,t,i,s){let o=0;const n=(0,ss.createWVFromGetterAndSubscriptions)((()=>++o),[i,s]);return(0,ft.combine)(((t,i)=>e()[ds[t]]??null),t.weakReference(),n.ownership())},yf=function(e){ns.StudyMetaInfo.mergeDefaultsOverrides(e),(0,os.studyMetaInfoRepository)().isReady()&&ns.StudyMetaInfo.overrideDefaults((0,os.studyMetaInfoRepository)().getInternalMetaInfoArray())};const vf=new Map,Sf=new Map;var bf;function wf(e){return e.value()?1:0}function Cf(e){return Promise.all(e.map((e=>{const t=e.model().mainSeries();return t.symbolResolvingActive().value()?vt(t.dataEvents().symbolResolved()).promise:t.symbolInfo()})))}!function(e){e[e.EDGE=0]="EDGE",e[e.BORDER=0]="BORDER",e[e.PADDING=2]="PADDING"}(bf||(bf={}));const Tf={saveChartEnabled:!0,takeScreenshotEnabled:!0,publishedChartsEnabled:!0};class Pf{constructor(e){
this.activeChartStyle=new O.WatchedValue,this.activeChartWidget=new O.WatchedValue,this.onAboutToBeDestroyed=new ae.Delegate,this.clientId=(0,fe.randomHash)(),this._destroyed=!1,this._chartWidgetsDefs=[],this._activeIndex=0,this._globalDetachable=new O.WatchedValue,this._layoutTemplate=new O.WatchedValue,this._layoutType="s",this._layoutWV=new O.WatchedValue(this._layoutType),this._currentLayoutResizeAction=new O.WatchedValue(null),this._inlineChartsCount=new O.WatchedValue,this._selectedSources=new O.WatchedValue([]),this._lineToolsSynchronizerHasChanges=new O.WatchedValue(!1),this._viewMode=new O.WatchedValue(void 0),this._allLayoutSizesState=new Map,this._splitters=new O.WatchedValue([]),this._savedChartWidgetOptions=[],this._flags={isConfirmationAboutReplayLocked:!1,loadingChart:!1,setTimeFrameActive:!1,setChartStyleActive:!1,setNewResolution:!1},this._loadingContent=!1,this._initialLoading=!1,this._isPhoneSize=new O.WatchedValue(!1),this._sizingState=new O.WatchedValue,this._layoutSizesChangedWV=new O.WatchedValue(!1),this._symbolLock=new O.WatchedValue(!1),this._internalSymbolLock=new O.WatchedValue(this._symbolLock.value()),this._intervalLock=new O.WatchedValue(!1),this._internalIntervalLock=new O.WatchedValue(this._intervalLock.value()),this._trackTimeLock=new O.WatchedValue(!1),this._combinedTrackTimeLock=this._createCombineTrackTimeLock(),this._internalTrackTimeLock=new O.WatchedValue(this._combinedTrackTimeLock.value()),this._dateRangeLock=new O.WatchedValue(!1),this._internalDateRangeLock=new O.WatchedValue(this._dateRangeLock.value()),this._crosshairLock=new O.WatchedValue(d.getBool("chart.syncCrosshair",!0)),this._activeChartCanBeMoved=new O.WatchedValue(!1),this._symbolLockSpawn=this._symbolLock.spawn(),this._intervalLockSpawn=this._intervalLock.spawn(),this._dateRangeLockSpawn=this._dateRangeLock.spawn(),this._trackTimeLockSpawn=this._trackTimeLock.spawn(),this._crosshairLockSpawn=this._crosshairLock.spawn(),this._hotkeys=(0,D.createGroup)({desc:"Layout"}),this._saveChartService=null,this._chartStorageNotification=null,this._newsNotifier=null,this._crossHairSyncBroadcast=null,this._crossHairSyncEnabledSubscriptionId=null,this._maximizedChartDef=new O.WatchedValue(null),this._maximizedChart=new O.WatchedValue(null),this._chartWidgetCreatedDelegate=new ae.Delegate,this._onZoom=new ae.Delegate,this._onScroll=new ae.Delegate,this._bottomToolbar=new O.WatchedValue(null),this._bottomToolbarWidget=null,this._bottomToolbarDestroyer=null,this._linkingGroupsCharts=new Map,this._chartModels=new yt.WatchedObject([],Pt.compareTwoCollectionsByIds),this._customLegendWidgetsFactoriesMap=new Map,this._customSources=new Map,this._replayContainer=null,this._prevMaximizedChartDef=null,this._phoneStates=[],this._chartsSwappedDelegate=new ae.Delegate,this._saveKeysPressedDelegate=new ae.Delegate,this._subscribedChartWidget=null,this._lineToolsSplitAdjuster=null,this._tool=mt.tool.spawn(),this._activeChartInterval=new yt.WatchedObject(Re.Interval.parse("")),this._hasChanges=new O.WatchedValue(!1),this._hasChangesSpawn=null,
this._pendingSetSymbolCancellationToken={cancelled:!0},this._symbolAliasService=null,this._onResizeActionChanged=e=>{this._dateRangeLock.value()&&null===e&&this._syncChartsDateRangesWithActiveChartRange()},this._recalcHasChanges=()=>{this._lineToolsSynchronizerHasChanges.setValue(this._chartWidgetsDefs.some((e=>{const t=e.chartWidget.lineToolsSynchronizer();return null!==t&&t.hasChanges().value()})))},this._handlePhoneSize=(e,t)=>{0},this._handlePhoneForceFullscreen=()=>{if(!window.is_authenticated)return;const e=(0,l.enabled)("app_phone");!(0,l.enabled)("app_tablet")&&(e||this._isPhoneSize.value())?this._viewMode.value()===CollectionViewMode.ForceFullscreen&&(this._prevMaximizedChartDef=this._maximizedChartDef.value(),this.activeChartWidget.value().requestFullscreen()):this._prevMaximizedChartDef||(this._setMaximized(null),this._updateViewMode())},this._updateActiveChartCanBeMoved=()=>{},this._updateLinkingGroupCharts=()=>{const e=new Map;for(const t of this._chartWidgetsDefs){const i=null;let s=e.get(i);void 0===s&&(s=[],e.set(i,s)),s.push(t.chartWidget)}for(const t of(0,Pt.join)(new Set(this._linkingGroupsCharts.keys()),new Set(e.keys())))this._getLinkingGroupCharts(t).setValue(e.get(t)??[])},this._updateLayout=()=>{let e;const t=this._layoutTemplate.value(),i=this._maximizedChartDef.value();if(e=i?[i]:this._chartWidgetsDefs.slice(0,t.count).filter((e=>!e.hiddenInLayout.value())),e.forEach(((t,i)=>this._updateLayoutPartial(t,i,e.length))),!this._maximizedChartDef.value()){const{padding:e=2,border:i=0}=this._options,s=this._computeContentBox(),o=t.splitters(s,e+i,this._sizingState.value());this._clearSplitters(o.length);const n=this._splitters.value(),r=o.map(((e,t)=>{const i=t<n.length?n[t].splitterElement:document.createElement("div");let s,o;t<n.length?(s=n[t].mouseListener,o=n[t].mouseHandler):(s=new Jg({state:this._stateImpl(),splitterElement:i,splitter:e,computeContentBox:this._computeContentBox.bind(this)}),o=new Wt.MouseEventHandler(i,s));const r=e.metrics,a=i.classList.contains(qg.hovered),l=i.classList.contains(qg["i-active"]);return i.className="",i.classList.add(qg.chartsSplitter),i.classList.add(`chart-widget-collection-border-${e.className}`),a&&i.classList.add(qg.hovered),l&&i.classList.add(qg["i-active"]),i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.width=r.width+"px",i.style.height=r.height+"px",i.setAttribute("aria-hidden","true"),"v"===e.orientation?i.style.cursor="ns-resize":i.style.cursor="ew-resize",this._parent.insertBefore(i,this._bottomToolbar.value()),{splitter:e,splitterElement:i,mouseHandler:o,mouseListener:s}}));this._splitters.setValue(r)}},this.undoHistory=function(e){const t=[],i=new nt,s=new nt,o={chartWidgetCollection:e},r=new ae.Delegate;function a(e){if(t.length>0)t[t.length-1].addCommand(e);else{s.clear();const t=i.head(),o=t&&t.text().originalText();t&&t.canMerge(e)?t.merge(e):i.push(e);const n=e.text().originalText();""!==n&&n!==o&&ct.logNormal("DO: "+n)}e.executeOnPush()&&e.redo(o),t.length||r.fire(l())}function l(){
const e=i.head(),t=s.head(),o=void 0===e?void 0:e.text(),n=void 0===t?void 0:t.text();return{enableUndo:!i.isEmpty(),undoCommandCount:i.size(),undoText:void 0!==o?o.translatedText():o,enableRedo:!s.isEmpty(),redoCommandCount:s.size(),redoText:void 0!==n?n.translatedText():n,originalUndoText:void 0!==o?o.originalText():void 0,originalRedoText:void 0!==n?n.originalText():void 0}}return{beginUndoMacro:function(e){const i=new rt(e);return t.push(i),i},clearStack:function(){i.clear(),s.clear(),r.fire(l())},createUndoCheckpoint:function(){return{lastActualCommand:i.isEmpty()?null:i.head()}},endUndoMacro:function(){const e=(0,n.ensureDefined)(t.pop());e.isEmpty()||a(e)},pushUndoCommand:a,redo:function(){if(s.isEmpty())return!1;const e=s.pop();return!!e&&(e.redo(o),i.push(e),ct.logNormal("REDO: "+e.text().originalText()),r.fire(l()),!0)},redoStack:function(){return s},setWatchedValue:function(e,t,i,s){const o=e.value();if(o!==t){const n=new lt(e,o,t,i,!s);a(n),n.redo()}},undo:function(){if(i.isEmpty())return!1;const e=i.pop();return!!e&&(e.undo(o),s.push(e),ct.logNormal("UNDO: "+e.text().originalText()),r.fire(l()),!0)},undoStack:function(){return i},undoToCheckpoint:function(e){for(;!i.isEmpty()&&e.lastActualCommand!==i.head();)i.pop().undo(o);s.clear(),r.fire(l())},state:l,onChange:function(){return r}}}(this),this._options=(0,Qe.default)({},Tf,e),this._readOnly=this._options.readOnly||!1;this._readOnly&&e.content;this._symbolAliasService=null,this.layout=this._layoutWV.readonly(),this.selectedSources=this._selectedSources.readonly(),this.inlineChartsCount=this._inlineChartsCount.readonly(),this.lineToolsSynchronizerHasChanges=this._lineToolsSynchronizerHasChanges.readonly(),this.viewMode=this._viewMode.readonly(),this.lock={symbol:this._symbolLockSpawn,interval:this._intervalLockSpawn,dateRange:this._dateRangeLockSpawn,crosshair:this._crosshairLockSpawn,trackTime:this._trackTimeLockSpawn},this._symbolLock.subscribe((e=>this._handleSymbolLockChange(e))),this._internalSymbolLock.subscribe((e=>this._handleInternalSymbolLockChange(e))),this._intervalLock.subscribe((e=>this._handleIntervalLockChange(e))),this._internalIntervalLock.subscribe((e=>this._handleInternalIntervalLockChange(e))),this._trackTimeLock.subscribe((e=>this._handleTrackTimeLockChange(e))),this._internalTrackTimeLock.subscribe((e=>this._handleInternalTrackTimeLockChange(e))),this._dateRangeLock.subscribe((e=>this._handleDateRangeLockChange(e))),this._internalDateRangeLock.subscribe((e=>this._handleInternalDateRangeLockChange(e))),this._currentLayoutResizeAction.subscribe(this._onResizeActionChanged),this._crosshairLock.subscribe((e=>{d.setValue("chart.syncCrosshair",e);for(let e=0;e<this._chartWidgetsDefs.length;++e){const t=this._chartWidgetsDefs[e].chartWidget;t.hasModel()&&t.model().model().lightUpdate()}})),this._widthWV=this._options.resizerBridge.width,this._heightWV=this._options.resizerBridge.height,this._maximizedChartDef.subscribe((e=>{this._maximizedChart.setValue(null===e?null:e.chartWidget),e&&this.activeChartWidget.setValue((0,
n.ensureNotNull)(e.chartWidget))})),this._maximizedChartDef.subscribe((e=>{this._chartWidgetsDefs.forEach((t=>{t.fullscreen.setValue(t===e)}))}),{callWithLast:!0}),this._maximizedChartDef.subscribe((()=>{this._updateChartsVisibility(),this._updateLayout(),ee.emit("layout_changed")})),this._widgetOptions=this._options.widgetOptions||{},this.onWidget=!!this._widgetOptions.onWidget;const t=this._options.metaInfo||{};this.metaInfo={id:new O.WatchedValue(t.id||null),name:new O.WatchedValue(t.name),description:new O.WatchedValue(t.description),username:new O.WatchedValue(t.username),uid:new O.WatchedValue(t.uid),lastModified:new O.WatchedValue(t.lastModified),isPrivate:new O.WatchedValue(t.isPrivate)};this.undoHistory.onChange().subscribe(null,(e=>{ee.emit("undo_redo_state_changed",e)})),this._parent=this._options.resizerBridge.container.value(),this._parent.classList.add("unselectable"),this._parent.addEventListener("contextmenu",St.preventDefaultForContextMenu),this._options.seriesControlBarEnabled&&this._createSeriesControlWidget(),this._chartPropertiesDialogRenderer=new Ct(this),this._compareDialogRenderer=new Tt(this),this._sizingState.subscribe((()=>this._updateLayout())),this._widthWV.subscribe(this._updateLayout),this._heightWV.subscribe(this._updateLayout),this._activeLinkingGroupWV=this._getActiveLinkingGroupWV(),this._allLinkingGroupsWV=this._getAllLinkingGroupsWV(),this.activeChartWidget.subscribe((e=>{if(!e)return;let t=NaN;for(let i=this._chartWidgetsDefs.length;i--;)if(this._chartWidgetsDefs[i].chartWidget===e){t=i;break}if(!isFinite(t))throw new Error("Cannot make detached ChartWidget active");if(this._activeIndex!==t){this._maximizedChartDef.value()&&(this._isDetached(this._chartWidgetsDefs[t])||this._maximizedChartDef.setValue(this._chartWidgetsDefs[t])),this._activeIndex=t,this._updateActivityView();for(let t=this._chartWidgetsDefs.length;t--;)this._chartWidgetsDefs[t].chartWidget!==e&&this._chartWidgetsDefs[t].chartWidget.setActive(!1);this._updateCrossHairPositionIfNeeded(),e.setActive(!0),mt.activePointSelectionMode.setValue(e.selectPointMode().value())}this._updateActiveChartCanBeMoved(),this._updateActiveChartInterval(),this._subscribeToProperties(e)}),{callWithLast:!0}),this._readOnly||(this._hotkeys.add({desc:"Switch active chart",hotkey:(0,l.enabled)("accessible_keyboard_shortcuts")?D.Modifiers.Shift+39:9,handler:()=>this.switchChart(!1)}),this._hotkeys.add({desc:"Switch active chart",hotkey:(0,l.enabled)("accessible_keyboard_shortcuts")?D.Modifiers.Shift+37:gt.Modifiers.Shift+9,handler:()=>this.switchChart(!0)})),this._hotkeys.add({desc:"Fullscreen mode",hotkey:D.Modifiers.Shift+70,isDisabled:(0,l.enabled)("widget")||!this.fullscreenable().value(),handler:()=>{this.fullscreen().value()?this.exitFullscreen():this.startFullscreen()}}),this._options.takeScreenshotEnabled&&(this._hotkeys.add({desc:"Screenshot server",hotkey:D.Modifiers.Alt+83,handler:this.takeServerScreenshot.bind(this)}),(0,He.isOnMobileAppPage)("any")||(this._hotkeys.add({desc:"Download client screenshot",
hotkey:D.Modifiers.Mod+D.Modifiers.Alt+83,handler:cs.bind(this,this)}),this._hotkeys.add({desc:"Copy client screenshot",hotkey:D.Modifiers.Mod+D.Modifiers.Shift+83,handler:hs.bind(this,this)}))),this._options.saveChartEnabled&&this._hotkeys.add({desc:"Save Chart Layout",hotkey:D.Modifiers.Mod+83,handler:()=>this._saveKeysPressedDelegate.fire()}),this._clipboardHandler=uf(this._stateImpl()),this.clipboard=this._clipboardHandler,this._options.globalEvents&&this._clipboardHandler.listen(),this._leftBottomChartWidget=ff(this.getAll.bind(this),this._layoutWV.readonly(),this._chartsSwappedDelegate,this._chartWidgetCreatedDelegate),this._layoutWV.subscribe((e=>this._layoutType=e)),this._layoutWV.subscribe((()=>this._updateActivityView())),this._inlineChartsCount.subscribe(this._updateActiveChartCanBeMoved),this._inlineChartsCount.subscribe((e=>{this._chartWidgetsDefs.forEach(((t,i)=>{t.collapsed.setValue(i>=e)}))})),this._inlineChartsCount.subscribe((e=>{this._bottomToolbar.value()?.classList.toggle("multiple-layout",e>1)})),this.loadContent(this._options.content,!0).then((e=>{this._readOnly&&(this._layoutWV.writeLock=!0),e.contentMigrated&&ee.emit("chart_migrated")})),window.addEventListener("resize",this._updateLayout);let i=0;const s=()=>{--i,0===i&&ee.emitOnce("onChartReady")};this._chartWidgetsDefs.forEach((e=>{if(!e)return;i++;const t=e.chartWidget;t.withModel(null,(()=>{this._options.metaInfo&&t.model().model().setChartSaveTime(1e3*this._options.metaInfo.lastModified);const e=t.model().mainSeries();if(e.bars().size()>0||e.isFailed())s();else{const t=e.dataEvents(),i=()=>{s(),t.barReceived().unsubscribe(null,i),t.completed().unsubscribe(null,i),t.error().unsubscribe(null,i),t.unsupportedResolutionRequested().unsubscribe(null,i)};t.barReceived().subscribe(null,i),t.completed().subscribe(null,i),t.error().subscribe(null,i),t.unsupportedResolutionRequested().subscribe(null,i)}}))})),this._allInitialModelsCreated().then(Cf).then((()=>{window.saver&&window.is_authenticated&&this._options.widgetOptions.justCloned&&window.saver.saveChartSilently()})).catch(Qg.logError.bind(Qg))}destroy(){if(this.onAboutToBeDestroyed.fire(),this.setActive(!1),this._bottomToolbarDestroyer?.(),this._bottomToolbarDestroyer=null,this._symbolLockSpawn.destroy(),this._intervalLockSpawn.destroy(),this._trackTimeLockSpawn.destroy(),this._dateRangeLockSpawn.destroy(),this._combinedTrackTimeLock.destroy(),this._crosshairLockSpawn.destroy(),this._currentLayoutResizeAction.unsubscribe(this._onResizeActionChanged),this._chartWidgetsDefs.forEach((e=>e.destroy())),this._options.resizerBridge.remove(),this._clearSplitters(),window.removeEventListener("resize",this._updateLayout),this._tool.destroy(),this._parent.remove(),this._customSources.clear(),this._customLegendWidgetsFactoriesMap.clear(),this._hotkeys.destroy(),this._chartStorageNotification&&this._chartStorageNotification.destroy(),this._clipboardHandler&&this._clipboardHandler.destroy(),this._newsNotifier&&this._newsNotifier.destroy(),this._activeLinkingGroupWV.destroy(),
this._allLinkingGroupsWV.destroy(),window.TVD&&null!==this._crossHairSyncEnabledSubscriptionId){const e=window.TVD.crosshairSyncEnabled;e&&e.unsubscribe(this._crossHairSyncEnabledSubscriptionId),this._destroyBroadcastChannel()}this._hasChangesSpawn?.destroy(),this._leftBottomChartWidget.destroy(),this._destroyed=!0}innerState(){return this._stateImpl()}getAll(){return this._chartWidgetsDefs.map((e=>e.chartWidget))}maximizedChartWidget(){return this._maximizedChart.readonly()}leftBottomChartWidget(){return this._leftBottomChartWidget}activeLinkingGroup(){return this._activeLinkingGroupWV}allLinkingGroups(){return this._allLinkingGroupsWV}linkingGroupsCharts(e){return this._getLinkingGroupCharts(e).readonly()}async setLayout(e){(e=this._checkProFeature(e))in ut.layouts||(e="s"),ee.emit("layout_about_to_be_changed",e),this._clearSplitters();const t=ut.layouts[e];this._layoutTemplate.setValue(t);const{count:i,layoutType:s,expression:o}=t,r=this._allLayoutSizesState.get(s)??(0,_s.layoutInitialSizingState)(o);this._allLayoutSizesState.set(s,r),this._sizingState.setValue(r);for(let e=0;e<i||e<this._chartWidgetsDefs.length;e++){let t=this._chartWidgetsDefs[e];if(e<i){if(t){if(this._loadingContent){const e=this._savedChartWidgetOptions.shift();e&&await(0,n.ensureNotNull)(t.chartWidget).loadContent(e.content,this._initialLoading)}}else t=this._addNewChartWidget(e);t.container.value().classList.toggle("multiple",i>1)}}this._updateChartsVisibility(),this._sizingState.setValue(r),this._layoutWV.setValue(e),this._recalculateMaximizedChartDef(),this._updateInlineChartsCount(),this._updateLayout(),this._updateWatchedValue(),this._checkAllPendingModelsAlreadyCreated(),this._inlineChartsCount.value()<1&&i>0&&this._chartWidgetsDefs[i-1].rdState.bridge().attach()}setChartStyleToWidget(e,t){return us.call(this,e,t)}state(e){const{withData:t,skipLineToolsFromOtherSymbols:i,wipeSensitiveData:s,skipLineTools:o,skipHiddenSources:n,addOnlyActiveChart:r}=e;let a=r?this.getAll().indexOf(this.activeChartWidget.value()):0;const l=r?a+1:this._chartsCountToSave(),c=[];const h=new Set;for(;a<l;a++){const e=this._chartWidgetsDefs[a];if(e?.chartWidget.hasModel()){const t=e.chartWidget.model().model().mainSeries().symbolInfo();t&&h.add(t.pro_name)}const r=this._getStateForChartImpl(a,t,i,s,o,n);if(r){let e=r;0,c.push(e)}}const d=r?void 0:Array.from(this._allLayoutSizesState.entries()).reduce(((e,[t,i])=>(e[t]=i,e)),{});return{name:this.metaInfo.name.value(),layout:r?"s":this._layoutType,charts:c,symbolLock:wf(this._symbolLock),intervalLock:wf(this._intervalLock),trackTimeLock:wf(this._trackTimeLock),dateRangeLock:wf(this._dateRangeLock),crosshairLock:wf(this._crosshairLock),layoutsSizes:d,studyMetaInfoMap:undefined,symbolAliasServiceState:this._symbolAliasService?.state(Array.from(h))}}applyLineToolUpdateNotification(e,t,i){df.call(this,this._chartWidgetsDefs,e,t,i)}readOnly(){return this._readOnly}onZoom(){return this._onZoom}onScroll(){return this._onScroll}resizerBridge(){return this._options.resizerBridge}setSymbol(e,t,i){
return this._setSymbolImpl(e,t,i)}setSymbolAll(e){const t=this._chartWidgetsDefs.map((e=>e.chartWidget));return this._setSymbolImpl(e,void 0,void 0,t)}async setResolution(e,t,i){const s=this._flags;return!(s.loadingChart||s.setTimeFrameActive||s.setNewResolution||s.setChartStyleActive)&&(this._applyResolution(e,t,i),!0)}setTimeFrame(e){this._flags.loadingChart||this._flags.setTimeFrameActive||(this._flags.setTimeFrameActive=!0,this._intervalLock.value()?this._chartWidgetsDefs.forEach((t=>{t.chartWidget.loadRange(e)})):this.activeChartWidget.value().loadRange(e),this._flags.setTimeFrameActive=!1)}setChartStyle(e,t){this._flags.setChartStyleActive=!0;const i=e.model(),s=i.mainSeries().properties().childs().style;i.setChartStyleProperty(s,t,ef),this._flags.setChartStyleActive=!1}async setChartLayoutWithUndo(e){return e=this._checkProFeature(e),this.layout.value()!==e&&(this.undoHistory.pushUndoCommand(new pt(this,e)),!0)}images(e){const t=Math.max(1,window.devicePixelRatio||1),i=this.getAll();let s;const o=this.maximizedChartWidget().value();if(e&&e.onlyActiveChart||o)return{layout:"s",hidpiRatio:t,theme:(0,L.getCurrentTheme)().name,charts:[this.activeChartWidget.value().images(e)],publishedBy:s};const n=[],r=ut.layouts[this.layout.value()].count,a={showCollapsedStudies:(e=e||{}).showCollapsedStudies,status:e.status};for(let e=0;e<i.length&&e<r;e++)n.push(i[e].images(a));return{layout:this.layout.value(),hidpiRatio:t,theme:(0,L.getCurrentTheme)().name,charts:n,publishedBy:s}}clientSnapshot(e={}){const t={hideResolution:Boolean(e.hideResolution)};return async function(e,t){return new jg(e,t).getImage()}(this.images({showCollapsedStudies:!0,status:t}),e)}tags(){let e=[];for(let t=0;t<this._chartWidgetsDefs.length&&t<this._layoutTemplate.value().count;t++)e=e.concat(this._chartWidgetsDefs[t].chartWidget.tags());return e=Array.from(new Set(e)),e=e.map((e=>e.toLowerCase().replace(/\W+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""))),e}syncCrosshair(e,t,i){if(this._setExternalPosition(e,t,i)){const t=this._crossHairSyncBroadcast;if(t){const s={type:"crosshair",payload:{point:e,envState:i,sourceUniqueId:t.uniqueId}};t.channel.postMessage(s)}}}syncScroll(e,t){if(!this._combinedTrackTimeLock.value()||this._dateRangeLock.value())return;const i=this._layoutTemplate.value().count;this.undoHistory.beginUndoMacro(tf),this._chartWidgetsDefs.slice(0,i).filter((e=>e.chartWidget.hasModel()&&e.chartWidget.model().model()!==t)).forEach((t=>{const i=t.chartWidget.model().model(),s=i.mainSeries().syncModel();s&&i.syncTimeWithModel(s.syncSourceTarget(),e)})),this.undoHistory.endUndoMacro(),ee.emit("sync_time",e)}clearChartMetaInfo(){this.metaInfo.id.setValue(null),this.metaInfo.uid.setValue(""),this.metaInfo.name.setValue("")}async takeScreenshot(){if(void 0===this._options.snapshotUrl||0===this._options.snapshotUrl?.length)return console.warn("To use this feature, please specify the snapshot_url option in the widget constructor."),"";const e={snapshotUrl:this._options.snapshotUrl};const t=await At(this,e)
;return ee.emit("onScreenshotReady",t),t}async takeServerScreenshot(){if(void 0===this._options.snapshotUrl||0===this._options.snapshotUrl?.length)return console.warn("To use this feature, please specify the snapshot_url option in the widget constructor."),"";const e={snapshotUrl:this._options.snapshotUrl};const t=(0,He.isOnMobileAppPage)("any"),i=t?At:It,s=await i(this,e);return ee.emit("onScreenshotReady",s),t||ee.emit("onServerScreenshotCopiedToClipboard"),s}async loadLayoutState(e){this.metaInfo.id.setValue(e.id),this.metaInfo.uid.setValue(e.uid),this.metaInfo.name.setValue(e.name),this.metaInfo.description.setValue(e.description),this.metaInfo.username.setValue(e.username),this.metaInfo.lastModified.setValue(e.lastModified),this.metaInfo.isPrivate.setValue(e.isPrivate);const t=await this.loadContent(e.chartWidgetCollectionState);this.unloadUnusedCharts(),this.undoHistory.clearStack(),ee.emit("layout_loaded"),t.contentMigrated&&ee.emit("chart_migrated")}saveLayoutState(){return new Promise(((e,t)=>{this._saveChartService?.saveChartOrShowTitleDialog((()=>{}),e,t)}))}async loadContent(e,t){Qg.logNormal("Loading layout content"),this.getAll().forEach((e=>e.onAboutToLoadContent())),this._loadingContent=!0,this._initialLoading=Boolean(t),this._savedChartWidgetOptions.splice(0),(0,mt.init)();let i=!1,s=this._layoutType;if(e){const t=function(e){return"charts"in e}(e)?e:{layout:"s",charts:[e],name:""};if(t.layoutsSizes)for(const e of Object.keys(t.layoutsSizes))this._allLayoutSizesState.set(e,t.layoutsSizes[e]);const i=new Set;if(t.charts.forEach((e=>{e.chartId&&i.add(e.chartId)})),t.charts.forEach((e=>{if(!e.chartId){const t=mf((e=>i.has(e)));i.add(t),e.chartId=t}})),s=t.layout,!(0,ut.isSupportedLayout)(s)){const e=(0,ut.tryGuessingTheMostSuitableLayout)(s);Qg.logError(`Loading unsupported layout ${s}. Force migration to ${e}`),s=e}for(const e of t.charts){if("studyMetaInfoMap"in t){const i=t;e.panes.forEach((e=>{e.sources.forEach((e=>{"metaInfo"in e&&(0,et.default)(e.metaInfo)&&(e.metaInfo=(0,tt.clone)((0,n.ensureDefined)(i.studyMetaInfoMap)[e.metaInfo]))}))}))}this._savedChartWidgetOptions.push({content:e})}void 0!==t.symbolLock&&this._symbolLock.setValue(Boolean(t.symbolLock)),void 0!==t.intervalLock&&this._intervalLock.setValue(Boolean(t.intervalLock)),void 0!==t.trackTimeLock&&this._trackTimeLock.setValue(Boolean(t.trackTimeLock)),void 0!==t.dateRangeLock&&this._dateRangeLock.setValue(Boolean(t.dateRangeLock)),void 0!==t.crosshairLock&&this._crosshairLock.setValue(Boolean(t.crosshairLock))}return this._maximizedChartDef.setValue(null),await this.setLayout(s||"s"),this._tool.subscribe(this._onToolChanged.bind(this)),this._tool.subscribe(this._updateCrossHairPositionIfNeeded.bind(this)),this._loadingContent=!1,this._initialLoading=!1,{contentMigrated:i}}applyOverrides(e){for(let t=0;t<this._chartWidgetsDefs.length;t++)this._chartWidgetsDefs[t].chartWidget.applyOverrides(e)}applyStudiesOverrides(e){yf(e)}switchChart(e){this.ariaDescribeChart(this.activeChartWidget.value())}startFullscreen(){
this._options.resizerBridge.requestFullscreen()}exitFullscreen(){this._options.resizerBridge.exitFullscreen()}fullscreenable(){return this._options.resizerBridge.fullscreenable}fullscreen(){return this.resizerBridge().fullscreen}chartWidgetCreated(){return this._chartWidgetCreatedDelegate}saveKeysPressed(){return this._saveKeysPressedDelegate}getContainer(){return this._parent}applyTheme(e){return gf(this._stateImpl(),this,e)}applyIndicatorsToAllCharts(e){cf(this._stateImpl(),e)}applyIndicatorsToAllChartsAvailable(){return!this._readOnly&&this._actualLayoutCount()>1}async applyIndicatorToAllCharts(e,t,i,s){await hf(this._stateImpl(),e,t,i,s)}setActive(e){if(0!==this._chartWidgetsDefs.length){for(let e=this._chartWidgetsDefs.length;e--;)this._chartWidgetsDefs[e].chartWidget.setActive(!1);this._chartWidgetsDefs[this._activeIndex].chartWidget.setActive(e)}}revertToInline(){this._setMaximized(null);for(let e=0;e<this._chartWidgetsDefs.length;e++)this._chartWidgetsDefs[e].rdState.bridge().attach()}activeChartInterval(){return this._activeChartInterval.readonly()}hasChanges(){return this._hasChanges.readonly()}chartMarketStatuses(){return this._chartWidgetsDefs.map((e=>"-"))}chartSeriesStatuses(){return this._chartWidgetsDefs.map((e=>{const t=e.chartWidget.hasModel()?e.chartWidget.model().mainSeries().status():null;return(null===t?"":bt.SERIES_STATUS_TEXT[t])+" ("+t+")"}))}applyPreferencesToAllCharts(e){0}addCustomSource(e,t,i){(0,n.assert)(!this._customSources.has(e),"Cannot create the same custom source multiple times"),this._customSources.set(e,{factory:t,layer:i});for(let s=0;s<this._chartWidgetsDefs.length;++s){const o=this._chartWidgetsDefs[s].chartWidget;o.hasModel()&&o.model().model().addCustomSource(e,t,i)}}removeCustomSource(e){(0,n.assert)(this._customSources.has(e),"Cannot remove not created custom source"),this._customSources.delete(e);for(let t=0;t<this._chartWidgetsDefs.length;++t){const i=this._chartWidgetsDefs[t].chartWidget;i.hasModel()&&i.model().model().removeCustomSource(e)}}addCustomWidgetToLegend(e,t){(0,n.assert)(!this._customLegendWidgetsFactoriesMap.has(e),"Cannot create the same custom widget in legend multiple times"),this._customLegendWidgetsFactoriesMap.set(e,t);for(let i=0;i<this._chartWidgetsDefs.length;++i)this._chartWidgetsDefs[i].chartWidget.addCustomWidgetToLegend(e,t)}addReplayWidget(e){(0,n.assert)(null===this._replayContainer,"Cannot create replay container multiple times"),this._replayContainer=document.createElement("div"),this._replayContainer.style.position="absolute",this._replayContainer.style.minHeight="49px",this._replayContainer.style.overflow="hidden",this._replayContainer.style.left="0px",this._replayContainer.style.right="0px";const t=this._bottomToolbar.value()?.offsetHeight??0;this._replayContainer.style.bottom=`${t}px`,this._replayContainer.setAttribute("data-is-chart-toolbar-component","true"),this._parent.prepend(this._replayContainer);e(this._replayContainer,(()=>this._updateLayout())),this._updateLayout()}destroyReplayWidget(){(0,
n.assert)(null!==this._replayContainer,"Cannot remove replay container, container is not created"),this._replayContainer.remove(),this._replayContainer=null,this._updateLayout()}setViewMode(e){this._viewMode.setValue(e)}moveActiveChartWithUndo(e){}activeChartCanBeMoved(){return this._activeChartCanBeMoved.readonly()}generalPropertiesDefinitions(){return this.activeChartWidget.value().generalPropertiesDefinitions()}reconnectChartApi(e){reconnectChartApiHelper(e)}setBroker(e){0}setSaveChartService(e){this._saveChartService=e,this._hasChangesSpawn?.destroy(),this._hasChangesSpawn=e.hasChangesWV().spawn(),this._hasChangesSpawn.subscribe((e=>this._hasChanges.setValue(e)),{callWithLast:!0});for(let t=0;t<this._chartWidgetsDefs.length;++t){this._chartWidgetsDefs[t].chartWidget.setSaveChartService(e)}}getCompareDialogRenderer(){return this._compareDialogRenderer}getChartPropertiesDialogRenderer(){return this._chartPropertiesDialogRenderer}chartsSymbols(){return _f(this._stateImpl())}resetLayoutSizes(e){const t=this._layoutTemplate.value().layoutType,i=this._layoutTemplate.value().expression,s=(0,_s.layoutInitialSizingState)(i),o=e=>e?this._allLayoutSizesState.set(t,e):this._allLayoutSizesState.delete(t);if(e)return this._sizingState.setValue(s),void o(s);this.undoHistory.beginUndoMacro(lf),this.undoHistory.pushUndoCommand(new lt(this._sizingState,this._sizingState.value(),s,lf)),this.undoHistory.pushUndoCommand(new at(o,this._allLayoutSizesState.get(t),s,lf)),this.undoHistory.endUndoMacro()}setLayoutSizes(e,t,i=af){}unloadUnusedCharts(){const e=this._chartWidgetsDefs.splice(ut.layouts[this._layoutType].count);for(const t of e)t.destroy();this._updateLinkingGroupCharts()}layoutSizesChanged(){return this._layoutSizesChangedWV.readonly()}ariaDescribeChart(e){{const t=this.getAll().indexOf(e);Dt.getInstance().updateChartDescription(e,t,this._layoutType)}}chartModels(){return this._chartModels.readonly()}symbolAliasService(){return this._symbolAliasService}subscribeChartStorageNotification(e){this._chartStorageNotification?.subscribeOnChanges(e)}unsubscribeChartStorageNotification(e){this._chartStorageNotification?.unsubscribeOnChanges(e)}_stateImpl(){return{undoHistory:this.undoHistory,chartWidgetsDefs:this._chartWidgetsDefs,actualLayoutCount:this._actualLayoutCount.bind(this),savedChartWidgetOptions:this._savedChartWidgetOptions,activeChartWidget:this.activeChartWidget,options:this._options,parent:this._parent,setChartStorageNotificationSubscription:e=>{this._chartStorageNotification=e},maximizedChartDef:this._maximizedChartDef,setMaximized:this._setMaximized.bind(this),layoutTemplate:this._layoutTemplate,widthWV:this._widthWV,heightWV:this._heightWV,checkProFeature:this._checkProFeature.bind(this),lineToolsSynchronizerHasChanges:this._lineToolsSynchronizerHasChanges,recalcHasChanges:this._recalcHasChanges.bind(this),onZoom:this._onZoom,onScroll:this._onScroll,layoutType:this._layoutType,layoutWV:this._layoutWV,isPhoneSize:this._isPhoneSize,viewMode:this._viewMode,updateViewMode:this._updateViewMode.bind(this),
loadingContent:this._loadingContent,initialLoading:this._initialLoading,inlineChartsCount:this._inlineChartsCount,updateWatchedValue:this._updateWatchedValue.bind(this),checkAllPendingModelsAlreadyCreated:this._checkAllPendingModelsAlreadyCreated.bind(this),readOnly:this._readOnly,symbolLock:this._symbolLock,internalSymbolLock:this._internalSymbolLock,intervalLock:this._intervalLock,internalIntervalLock:this._internalIntervalLock,dateRangeLock:this._dateRangeLock,internalDateRangeLock:this._internalDateRangeLock,trackTimeLock:this._trackTimeLock,internalTrackTimeLock:this._internalTrackTimeLock,crosshairLock:this._crosshairLock,customLegendWidgetsFactoriesMap:this._customLegendWidgetsFactoriesMap,globalDetachable:this._globalDetachable,saveChartService:this._saveChartService,customSources:this._customSources,updateActivityView:this._updateActivityView.bind(this),sizingState:this._sizingState,currentLayoutResizeAction:this._currentLayoutResizeAction,allLayoutSizesState:this._allLayoutSizesState,splitters:this._splitters,widgetOptions:this._widgetOptions,bottomToolbar:this._bottomToolbar,replayContainer:this._replayContainer,layoutSizesChanged:this._layoutSizesChangedWV,flags:this._flags,chartModels:this._chartModels,hideChart:this._hideChart.bind(this),addNewChartWidget:this._addNewChartWidget.bind(this)}}_handleInternalSymbolLockChange(e){this._symbolLock.setValue(e)}_handleSymbolLockChange(e){if(e!==this._internalSymbolLock.value())if(this._loadingContent)this._internalSymbolLock.setValue(e);else{if(this.undoHistory.beginUndoMacro(sf),e){const e=this.activeChartWidget.value();this._chartWidgetsDefs.map((e=>e.chartWidget));this._linkingGroupsCharts.forEach(((t,i)=>{const s=(e.linkingGroupIndex().value(),e);if(void 0!==s){(0,it.muteLinkingGroup)(i,!0);for(const e of t.value())e!==s&&e.symbolWV().value()!==s.symbolWV().value()&&(e.setSymbol(s.symbolWV().value()),this._dateRangeLock.value()&&this._subscribeToCompletedEventForDateRangeSync(e,!0));(0,it.muteLinkingGroup)(i,!1)}}))}this.undoHistory.setWatchedValue(this._internalSymbolLock,e,sf),this.undoHistory.endUndoMacro()}}_handleInternalIntervalLockChange(e){this._intervalLock.setValue(e)}_handleIntervalLockChange(e){if(e!==this._internalIntervalLock.value())if(this._loadingContent)this._internalIntervalLock.setValue(e);else{if(this.undoHistory.beginUndoMacro(of),e&&e){const e=this.activeChartWidget.value();this._chartWidgetsDefs.map((e=>e.chartWidget));this._linkingGroupsCharts.forEach(((t,i)=>{const s=(e.linkingGroupIndex().value(),e);if(void 0!==s){(0,it.muteLinkingGroup)(i,!0);for(const e of t.value())e!==s&&e.resolutionWV().value()!==s.resolutionWV().value()&&(e.setResolution(s.resolutionWV().value()),this._dateRangeLock.value()&&this._subscribeToCompletedEventForDateRangeSync(e,!0));(0,it.muteLinkingGroup)(i,!1)}}))}this.undoHistory.setWatchedValue(this._internalIntervalLock,e,of),this.undoHistory.endUndoMacro()}}_handleInternalDateRangeLockChange(e){const t=this.activeChartWidget.value();if(t&&t.hasModel()){const i=t.model()
;e?(this._subscribeToEventsForDateRangeSync(i),this._syncChartsDateRangesWithActiveChartRange(t)):this._unsubscribeFromEventsForDateRangeSync(i)}this._dateRangeLock.setValue(e)}_handleDateRangeLockChange(e){this._loadingContent?this._internalDateRangeLock.setValue(e):this.undoHistory.setWatchedValue(this._internalDateRangeLock,e,nf)}_handleInternalTrackTimeLockChange(e){this._trackTimeLock.setValue(e)}_handleTrackTimeLockChange(e){this._loadingContent?this._internalTrackTimeLock.setValue(e):this.undoHistory.setWatchedValue(this._internalTrackTimeLock,e,rf)}_subscribeToEventsForDateRangeSync(e){e.timeScale().visibleBarsStrictRangeChanged().subscribe(this._getSubscriptionObjectForChartModel(e),(()=>{this._activeChartLogicalRangeChanged()}))}_unsubscribeFromEventsForDateRangeSync(e){e.timeScale().visibleBarsStrictRangeChanged().unsubscribeAll(this._getSubscriptionObjectForChartModel(e)),vf.forEach((e=>{const t=e.cw,i=e.callback;t.model().mainSeries().dataEvents().completed().unsubscribe(null,i)})),vf.clear()}_activeChartLogicalRangeChanged(){this._syncChartsDateRangesWithActiveChartRange()}_getSubscriptionObjectForChartModel(e){const t=Sf.get(e.id())??{};return Sf.set(e.id(),t),t}_setExternalPosition(e,t,i){const s=this._actualLayoutCount();return this._chartWidgetsDefs.slice(0,s).filter((e=>e.rdState.bridge().visible.value())).map((e=>e.chartWidget)).filter((e=>e.id()!==t&&(!!e.hasModel()&&this._crosshairLock.value()))).forEach((t=>t.model().model().setExternalPosition(e,i))),!0}_createBroadcastChannel(){const e=new BroadcastChannel("ChartWidgetsCollection");return e.onmessage=e=>{const t=e.data;if(this._crossHairSyncBroadcast&&"crosshair"===t.type)this._crossHairSyncBroadcast.uniqueId!==t.payload.sourceUniqueId&&this._setExternalPosition(t.payload.point,null,t.payload.envState)},{channel:e,uniqueId:(0,fe.randomHashN)(6)}}_destroyBroadcastChannel(){this._crossHairSyncBroadcast?.channel.close()}async _createChartWidgetCollectionNewsNotifier(){return null}async _createSeriesControlWidget(){const e="0px",t=document.createElement("div");this._bottomToolbar.setValue(t),t.style.left=e,t.style.right=e,t.style.bottom=e,t.classList.add("chart-toolbar","chart-controls-bar"),t.setAttribute("data-is-chart-toolbar-component","true"),this._parent.appendChild(t);const{BottomToolbarRenderer:s}=await Promise.all([i.e(91),i.e(8185),i.e(1681),i.e(5563),i.e(3439),i.e(8933),i.e(6032),i.e(3672),i.e(3359),i.e(4587),i.e(7780),i.e(7827),i.e(844),i.e(1667),i.e(9836),i.e(5834),i.e(2227),i.e(3179),i.e(6193),i.e(7260)]).then(i.bind(i,12062));if(this._destroyed)return;const o=this._options.resizerBridge,r=[o.container.spawn(),o.width.spawn(),o.height.spawn()],a=o.container.value(),l=new ae.Delegate,c=()=>{l.fire()};r.forEach((e=>{e.subscribe(c)}));this._bottomToolbarWidget=new s((0,n.ensureNotNull)(this._bottomToolbar.value()),l,(()=>{const e=a.getBoundingClientRect(),t=this._computeContentBox();return t.top=e.top+t.top,t.left=e.left+t.left,t}),this,window.ChartApiInstance,this._widgetOptions,this._options.seriesControlBar),
this._bottomToolbarDestroyer=()=>{null!==this._bottomToolbarWidget&&(this._bottomToolbarWidget.destroy(),this._bottomToolbarWidget=null,this._bottomToolbar.setValue(null)),r.forEach((e=>{e.destroy()})),l.destroy()}}_checkProFeature(e){return e}_allInitialModelsCreated(){return this._chartWidgetsDefs.every((e=>e.chartWidget.hasModel()))?Promise.resolve(this._chartWidgetsDefs.map((e=>e.chartWidget))):Promise.all(this._chartWidgetsDefs.map((e=>e.chartWidget.hasModel()||vt(e.chartWidget.modelCreated()).promise))).then((()=>this._allInitialModelsCreated()))}_actualLayoutCount(){return ut.layouts[this._layoutType].count}_setMaximized(e){this._maximizedChartDef.value()!==e&&this._maximizedChartDef.setValue(e)}_updateViewMode(){"s"===this._layoutType||this._maximizedChartDef.value()?this._viewMode.setValue(CollectionViewMode.ForceFullscreen):this._viewMode.setValue(CollectionViewMode.Multichart)}_updateWatchedValue(){const e=Math.min(this._layoutTemplate.value().count,this._chartWidgetsDefs.length)-1;if(e<0)return void this.activeChartWidget.deleteValue();const t=Math.min(Math.max(0,this._activeIndex),e);this.activeChartWidget.setValue(this._chartWidgetsDefs[t].chartWidget)}_checkAllPendingModelsAlreadyCreated(){this._chartWidgetsDefs.every((e=>e.chartWidget.hasModel()))&&(this._updateWatchedValue(),ee.emit("layout_changed"))}_updateActivityView(){for(let e=this._chartWidgetsDefs.length;e--;){const t=e===this._activeIndex;this._chartWidgetsDefs[e].container.value().classList.toggle("active",t),this._chartWidgetsDefs[e].container.value().classList.toggle("inactive",!t)}}_isDetached(e){return e.rdState.owner.value()!==e}_getVisuallyAdjacentDef(e,t){return pf(this._stateImpl(),e,t)}_swapCharts(e,t){}_subscribeToProperties(e){if(this._subscribedChartWidget!==e){if(this._subscribedChartWidget&&(this._subscribedChartWidget.modelCreated().unsubscribe(null,this._onmodel),this._subscribedChartWidget.hasModel())){const e=this._subscribedChartWidget.model();this._dateRangeLock.value()&&this._unsubscribeFromEventsForDateRangeSync(e);e.mainSeries().properties().childs().style.unsubscribe(this,this._onstyle);e.model().onSelectedSourceChanged().unsubscribe(this,this._onselectedsource),this._subscribedChartWidget=null}e&&(this._subscribedChartWidget=e,e.hasModel()?this._onmodel(e.model()):e.modelCreated().subscribe(this,this._onmodel))}}_onmodel(e){const t=e.mainSeries().properties().childs();t.style.subscribe(this,this._onstyle),this._onstyle(t.style);e.model().onSelectedSourceChanged().subscribe(this,this._onselectedsource),this._dateRangeLock.value()&&(this._subscribeToEventsForDateRangeSync(e),this._syncChartsDateRangesWithActiveChartRange()),this._onselectedsource()}_onstyle(e){this.activeChartStyle.setValue(e.value())}_onselectedsource(){const e=(0,n.ensureNotNull)(this._subscribedChartWidget).model();this._selectedSources.setValue(e.selection().allSources().slice())}_onToolChanged(){this._chartWidgetsDefs.forEach((e=>{e.chartWidget.onToolChanged()}))}_updateCrossHairPositionIfNeeded(){const e=this.activeChartWidget.value()
;this._chartWidgetsDefs.forEach((t=>{t.chartWidget!==e&&this._crosshairLock.value()&&t.chartWidget.updateCrossHairPositionIfNeeded()})),e&&e.updateCrossHairPositionIfNeeded()}async _setSymbolImpl(e,t,i,s){const o=i??this.activeChartWidget.value();void 0===t&&(t=o.linkingGroupIndex().value()),s=s??(this._symbolLock.value()?this._chartWidgetsDefs.map((e=>e.chartWidget)):[o]),this._pendingSetSymbolCancellationToken.cancelled=!0;this._pendingSetSymbolCancellationToken={cancelled:!1};return(()=>{for(const t of s)(t.hasModel()?t.model().mainSeries().symbolSameAsResolved(e):t.symbolWV().value()===e)||t.setSymbol(e)})(),!0}_alreadyHasId(e){return this._chartWidgetsDefs.some((t=>t.chartWidget?.id()===e))}_getCopiedChartStateAsWidgetContent(){const e=this.activeChartWidget.value();if(e){const t=e.state({skipNonSharedLineTools:(0,l.enabled)("saveload_separate_drawings_storage")});return t.chartId=mf((e=>this._alreadyHasId(e))),t.shouldBeSavedEvenIfHidden=!1,t.panes.forEach((e=>{e.sources.forEach((e=>{(0,wt.isLineToolState)(e)&&!e.linkKey&&(e.alertId=void 0)}))})),{content:t}}}_onIdeaClickedHandler(e){0}_barsMarksContainersFactory(e){const t=[];{const i=new Hi(e);t.push(i);const s=new Li(e);t.push(s)}return t}_getLinkingGroupCharts(e){e=null;let t=this._linkingGroupsCharts.get(e);return void 0===t&&(t=new yt.WatchedObject([],Pt.compareTwoCollectionsByIds),this._linkingGroupsCharts.set(e,t)),t}_getActiveLinkingGroupWV(){return new O.WatchedValue(null).spawn()}_getAllLinkingGroupsWV(){const e=new yt.WatchedObject(this._getAllLinkingGroups()),t=()=>{e.setValue(this._getAllLinkingGroups())};this._chartWidgetsDefs.forEach((e=>e.chartWidget.linkingGroupIndex().subscribe(t)));const i=e=>{e.linkingGroupIndex().subscribe(t),t()};return this._chartWidgetCreatedDelegate.subscribe(null,i),e.spawn((()=>{this._chartWidgetsDefs.forEach((e=>e.chartWidget.linkingGroupIndex().unsubscribe(t))),this._chartWidgetCreatedDelegate.unsubscribe(null,i)}))}_getAllLinkingGroups(){return[null]}_computeContentBox(){const{border:e=0,edge:t=0}=this._options,i=t+e,s=this._bottomToolbar.value()?.offsetHeight??0,o=this._replayContainer?.offsetHeight??0;return{width:this._widthWV.value()-2*i,height:this._heightWV.value()-s-o-i,top:0,left:i}}_updateLayoutPartial(e,t,i,s=this._layoutTemplate.value()){const o=this._computeContentBox(),{padding:n=2,border:r=0}=this._options,a=s.sizer(o,t,i,n+r,this._sizingState.value());a.width=Math.max(Math.round(a.width),0),a.height=Math.max(Math.round(a.height),0),a.top=Math.round(a.top),a.left=Math.round(a.left),e.metrics=a;const l=e.container.value();if(l){l.style.width=a.width+"px",l.style.height=a.height+"px",l.style.top=a.top+"px",l.style.left=a.left+"px";const e=1===i;false;const t=Math.round(o.width),s=0===a.top&&0===a.left,n=0===a.top&&a.left+a.width===t,r=0===a.top&&a.width===t;l.classList.toggle("top-left-chart",!e&&!r&&s),l.classList.toggle("top-right-chart",!e&&!r&&n),l.classList.toggle("top-full-width-chart",e||r)}e.width.setValue(a.width),e.height.setValue(a.height)}_setInitialSizes(e){let t=0,i=0
;const s=this._layoutTemplate.value();for(let o=0;o<s.count;o++){this._chartWidgetsDefs[o]===e&&(i=t),t++}this._updateLayoutPartial(e,i,t,s)}_createChartWidget(e){let t={chartWidgetCollection:this,isActive:0===this._chartWidgetsDefs.length,barsMarksContainersFactory:e=>this._barsMarksContainersFactory(e),undoHistory:this.undoHistory,readOnly:this._readOnly,initialLoading:this._initialLoading,...e??{}};void 0!==this._customLegendWidgetsFactoriesMap&&(t.customLegendWidgetFactories=new Map(this._customLegendWidgetsFactoriesMap));const i=document.createElement("div");i.classList.add("chart-container"),i.style.position="absolute",i.style.overflow="hidden",this._parent.insertBefore(i,this._bottomToolbar.value()),ze.isEdge&&(i.style.touchAction="none",i.style.msTouchAction="none"),t.className&&i.classList.add(t.className);const s={alive:new O.WatchedValue(!0),container:new O.WatchedValue(i),width:new O.WatchedValue,height:new O.WatchedValue,collapsed:new O.WatchedValue(!1),hiddenInLayout:new O.WatchedValue(!1),visible:new O.WatchedValue,rdState:new Ne,requestFullscreen:()=>{this._globalDetachable.value()&&(this._setMaximized(s),this.activeChartWidget.setValue((0,n.ensureNotNull)(s.chartWidget)))},exitFullscreen:()=>{this.activeChartWidget.value()===s.chartWidget&&this._setMaximized(null)},detachable:this._globalDetachable,fullscreenable:this._globalDetachable,fullscreen:new O.WatchedValue(!1),chartWidget:null};s.rdState.pushOwner(s);const o=()=>{s.chartWidget.isActive()&&this._updateActiveChartCanBeMoved()};s.rdState.owner.subscribe(o),this._chartWidgetsDefs.push(s);const r=()=>{(0,n.ensureNotNull)(s.chartWidget).setVisible(!s.hiddenInLayout.value()),l()},a=e=>{(0,n.ensureNotNull)(s.chartWidget).setCollapsed(e)},l=()=>{s.visible.setValue(!s.hiddenInLayout.value()&&this._options.resizerBridge.visible.value())};s.hiddenInLayout.subscribe(r),s.collapsed.subscribe(a),this._options.resizerBridge.visible.subscribe(l),l(),this._setInitialSizes(s),t={...t,...s.rdState.bridge()};const c=t.content?(0,n.ensureDefined)(t.content.chartId):mf((e=>this._alreadyHasId(e))),h=s.chartWidget=new kg(t,c);this._saveChartService&&h.setSaveChartService(this._saveChartService),t.containsData?h.finishInitWithoutConnect():h.connect();const d=()=>{s.chartWidget.isActive()&&this._updateActiveChartInterval()},u=()=>{this._checkForLineToolsSplitsAdjustment(s.chartWidget)};h.withModel(null,(()=>{const e=h.model().model();this._customSources.forEach(((t,i)=>{e.addCustomSource(i,t.factory,t.layer)})),e.mainSeries().intervalObj().subscribe(d,{callWithLast:!0})})),this._updateWatchedValue(),this._updateActivityView();const _=t?.content?.linkingGroup??null;h.linkingGroupIndex().setValue(_),h.linkingGroupIndex().subscribe(this._updateLinkingGroupCharts);const p=this._getLinkingGroupCharts(_).value();return p.length>0&&(this._symbolLock.value()&&h.setSymbol(p[0].symbolWV().value()),this._intervalLock.value()&&h.setResolution(p[0].resolutionWV().value())),this._updateLinkingGroupCharts(),h.onZoom().subscribe(this,(e=>this._onZoom.fire(e))),
h.onScroll().subscribe(this,(()=>this._onScroll.fire())),h.withModel(null,(()=>{h.lineToolsSynchronizer()?.hasChanges().subscribe(this._recalcHasChanges,{callWithLast:!0})})),s.destroy=()=>{if(s.rdState.owner.unsubscribe(o),s.hiddenInLayout.unsubscribe(r),s.collapsed.unsubscribe(a),this._options.resizerBridge.visible.unsubscribe(l),h.linkingGroupIndex().unsubscribe(this._updateLinkingGroupCharts),h.onZoom().unsubscribeAll(this),h.onScroll().unsubscribeAll(this),h.lineToolsSynchronizer()?.hasChanges().unsubscribe(this._recalcHasChanges),s.timingsMeter?.destroy(),s.rdState.destroy(),h.destroy(),h.hasModel()){const e=h.model().mainSeries();e.intervalObj().unsubscribe(d),e.lastSplits().unsubscribe(u)}},this._chartWidgetCreatedDelegate.fire(h),s}_addNewChartWidget(e,t){let i,s=this._savedChartWidgetOptions.shift();if(void 0!==s){const e=this.activeChartWidget.value();e&&e.lineToolsSynchronizer()&&(i=e.lineToolsAndGroupsDTO())}else s=this._getCopiedChartStateAsWidgetContent();const o={...this._widgetOptions,...s,...0===e||this._symbolLock.value()?void 0:{defSymbol:null}},n=this._createChartWidget(o),{chartWidget:r}=n;return r.modelCreated().subscribe(null,(()=>{t?t():this._checkAllPendingModelsAlreadyCreated(),this._dateRangeLock.value()&&r===this.activeChartWidget.value()&&this._subscribeToCompletedEventForDateRangeSync(r,!0);const e=r.lineToolsSynchronizer();void 0!==i&&e&&[...i.entries()].map((([t,i])=>{0!==t&&e.applyDTO(i,t).then((()=>{e.invalidateAll(!0)}))}));let s=!1;const o=()=>{const e=this._chartWidgetsDefs.filter((e=>(e.chartWidget!==r||!s)&&e.chartWidget.hasModel())).map((e=>e.chartWidget.model()));this._chartModels.setValue(e)};o(),r.onAboutToBeDestroyed().subscribe(null,(()=>{s=!0,o()}))}),!0),n}_subscribeToCompletedEventForDateRangeSync(e,t){const i=e.id();if(vf.has(i))return;const s=()=>{vf.has(i)&&(vf.delete(i),this._syncChartsDateRangesWithActiveChartRange(t?e:void 0))};e.model().mainSeries().dataEvents().completed().subscribe(null,s,!0),vf.set(i,{cw:e,callback:s})}_syncChartsDateRangesWithActiveChartRange(e){if(!this._dateRangeLock.value()||null!==this._currentLayoutResizeAction.value())return;const t=this.activeChartWidget.value(),i=t.model().mainSeries();if(!(0,xt.isTimeBasedStyle)(i.style()))return;const s=t.model().timeScale(),o=s.visibleBarsStrictRange();if(null===o)return;const r=(0,n.ensureNotNull)(s.points().range().value());let a=s.indexToTimePoint(o.firstBar());null===a&&i.endOfData()&&(a=s.indexToTimePoint(r.firstIndex));let l=s.indexToTimePoint(o.lastBar());if(null===l&&(l=s.indexToTimePoint(r.lastIndex)),null===a||null===l)return void this._subscribeToCompletedEventForDateRangeSync(t,!1);vf.delete(t.id());let c=1e3*a,h=1e3*l;if(i.isDWM()){const e=new Date(c),t=new Date(h);(0,Ce.set_hms)(e,0,0,0,0),(0,Ce.set_hms)(t,0,0,0,0),c=e.getTime(),h=t.getTime()}for(let i=0;i<this._chartWidgetsDefs.length;i++){const s=this._chartWidgetsDefs[i].chartWidget;s.hasModel()&&s!==t&&(void 0===e||s===e)&&(0,
xt.isTimeBasedStyle)(s.model().mainSeries().style())&&setTimeout(this._chartWidgetGotoTimeRange.bind(null,s,c,h))}}_chartWidgetGotoTimeRange(e,t,i){e.model().model().gotoTimeRange(t,i).catch((()=>{})),ee.emit("sync_date_range",t,i)}_hideChart(e){e.hiddenInLayout.setValue(!0);const t=e.container.value();t.parentNode&&t.parentNode.removeChild(t)}_updateChartsVisibility(){const{count:e}=this._layoutTemplate.value(),t=this._maximizedChartDef.value();this._chartWidgetsDefs.forEach(((i,s)=>{(t?t===i:s<e)?(this._parent.insertBefore(i.container.value(),this._bottomToolbar.value()),i.hiddenInLayout.setValue(!1)):this._hideChart(i)}))}_updateInlineChartsCount(){const{count:e}=this._layoutTemplate.value();this._inlineChartsCount.setValue(e),this._globalDetachable.setValue(e>1)}_getStateForChartImpl(e,t,i,s,o,n){if(e<this._chartWidgetsDefs.length){const r=this._chartWidgetsDefs[e].chartWidget;return e<this._actualLayoutCount()||r.shouldBeSavedEvenIfHidden()?r.state({withData:t,skipLineToolsFromOtherSymbols:i,wipeSensitiveData:s,skipLineTools:o,skipHiddenSources:n}):null}const r=this._savedChartWidgetOptions[e-this._chartWidgetsDefs.length].content;return o?(a=r,{...a,panes:(l=a.panes,l.map((e=>{return{...e,sources:(t=e.sources,t.filter((e=>!(0,Lt.isLineToolName)(e.type))))};var t})))}):r;var a,l}_chartsCountToSave(){return this._actualLayoutCount()}_updateActiveChartInterval(){const e=this.activeChartWidget.value();e?.hasModel()&&this._activeChartInterval.setValue(e.model().mainSeries().intervalObj().value())}_createCombineTrackTimeLock(){return(0,ft.combine)(((e,t)=>e||t),this._trackTimeLock.weakReference(),this._someOfWidgetsAreInSelectingReplayPointMode(this._layoutWV,this._chartWidgetsDefs).ownership())}_someOfWidgetsAreInSelectingReplayPointMode(e,t){return new O.WatchedValue(!1).spawn()}_getChartWidgetsForIntervalLock(){return(this._intervalLock.value()?this._chartWidgetsDefs.map((e=>e.chartWidget)):[this.activeChartWidget.value()]).filter((e=>e.hasModel()))}_applyResolution(e,t,i=this.activeChartWidget.value()){const s=this._flags;if((0,ht.setLastUsedResolution)(e),s.setNewResolution=!0,void 0===t&&(t=i.linkingGroupIndex().value()),this._intervalLock.value())for(const t of this._chartWidgetsDefs){const i=t.chartWidget;i.resolutionWV().value()!==e&&i.setResolution(e)}else i.setResolution(e);s.setNewResolution=!1}async _checkForLineToolsSplitsAdjustment(e){1}_clearSplitters(e=0){const t=this._splitters.value();t.splice(e).forEach((e=>{e.splitterElement.remove(),e.mouseListener.destroy(),e.mouseHandler.destroy()})),this._splitters.setValue([...t])}_recalculateMaximizedChartDef(){this._maximizedChartDef.setValue(null)}_validateLayoutSizes(e){}_validateLayoutSizesState(e,t){}_validateLayoutSizesStateRecursive(e,t,i,s){}}var xf=i(69455)
;const Mf=["LineToolTrendLine","LineToolRay","LineToolInfoLine","LineToolExtended","LineToolRegressionTrend","LineToolRotatedRectangle","LineToolParallelChannel","LineToolFlatBottom","LineToolDisjointAngle","LineToolPitchfork","LineToolSchiffPitchfork","LineToolSchiffPitchfork2","LineToolInsidePitchfork","LineToolVertLine","LineToolCrossLine","LineToolHorzLine","LineToolHorzRay","LineToolTrendAngle"];function If(e,t=!1,s=!1){if(!l.enabled("popup_hints"))return()=>{};const o=e.getContainer();let r=null,c=null;return mt.tool.subscribe(h),mt.createdLineTool.subscribe(null,u),mt.finishedLineTool.subscribe(null,_),e.layoutSizesChanged().subscribe(p),t||ze.CheckMobile.any()||!g("hint.startFocusedZoom")||(c=function(e,t){let i=!1;const s=o=>{o?(i&&t(o),e.onZoom().unsubscribe(null,s)):i||(t(o),i=!0)};return e.onZoom().subscribe(null,s),()=>e.onZoom().unsubscribe(null,s)}(e,(function(e){if(!g("hint.startFocusedZoom"))return;if(e)r&&(c=null,f("hint.startFocusedZoom"));else{m(a.t(null,void 0,i(81712)).format({key:(0,gt.humanReadableModifiers)(gt.Modifiers.Mod,!1)}),"hint.startFocusedZoom")}}))),()=>{mt.tool.unsubscribe(h),mt.createdLineTool.unsubscribe(null,u),mt.finishedLineTool.unsubscribe(null,_),e.layoutSizesChanged().unsubscribe(p),c?.()};function h(){const e=mt.tool.value(),t=ze.CheckMobile.any();if(!t&&(0,mt.toolIsDemonstration)(e)&&g("hint.demonstrationCursorSelected")){return void m(a.t(null,void 0,i(87133)).format({key:(0,gt.humanReadableModifiers)(gt.Modifiers.Alt,!1)}),"hint.demonstrationCursorSelected")}if(s&&t&&(o=e,Mf.includes(o)))return void async function(){0}();var o;if("LineToolTextAbsolute"===e&&g("hint.anchoredTextWillBeRemoved"))return void m(a.t(null,void 0,i(77705)),"hint.anchoredTextWillBeRemoved");if(!g("hint.touchPainting"))return;const n=(0,Lt.isLineToolDrawWithoutPoints)(e);!(0,Lt.isStudyLineToolName)(e)||"LineToolRegressionTrend"===e||n||t?(0,Lt.isLineToolName)(e)&&!(0,Lt.isLineDrawnWithPressedButton)(e)&&!n&&t?m(a.t(null,void 0,i(60663)),"hint.touchPainting"):r&&r.hide():m(a.t(null,void 0,i(14985)),"hint.touchPainting")}function u(){const e=mt.tool.value();"LineToolPath"===e&&g("hint.finishBuildPathByDblClick")?m(a.t(null,void 0,i(75296)),"hint.finishBuildPathByDblClick"):"LineToolPolyline"===e&&g("hint.finishBuildPolylineByDblClick")&&m(a.t(null,void 0,i(17409)),"hint.finishBuildPolylineByDblClick")}function _(){if(r){const e=mt.tool.value();"LineToolPath"===e?f("hint.finishBuildPathByDblClick"):"LineToolPolyline"===e&&f("hint.finishBuildPolylineByDblClick")}}function p(){if(!g("hint.startResizingChartInLayout"))return;m(ze.CheckMobile.any()?a.t(null,void 0,i(36539)):a.t(null,void 0,i(9430)),"hint.startResizingChartInLayout")}function m(e,t){if(r)r.show(e,f.bind(null,t));else{const s=mt.tool.value();Promise.all([i.e(6195),i.e(628),i.e(2227),i.e(6166)]).then(i.bind(i,91759)).then((i=>{r=new i.ChartEventHintRenderer(o),s===mt.tool.value()&&r.show(e,f.bind(null,t))}))}}function g(e){return!Boolean(d.getBool(e))}function f(e){d.setValue(e,!0,{forceFlush:!0}),(0,n.ensureNotNull)(r).destroy(),
null!==c&&c(),r=null}}class Af{constructor(e,t,i){this.handler=e,this.customId=t,this.singleShot=i}}function Lf(e,t){return`${e}__${t}`}function kf(e){for(const t of Object.keys(e)){const i=e[t];if((0,tt.isObject)(i))throw new Error(`Study with non-simple inputs cannot be created: ${t}=${JSON.stringify(i)}`)}return e}class Ef{constructor(e,t,i,s){this.sessionid="",this._chartApiMessagerProvider=e,this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._metadataRequestNextNumber=1,this._studyMetaInfoCache=i,this.studiesAccessController=s,this._connected=!1,this._enabled=!1,this._studyEngine=t,this._callbacks={},this._serverTimeOffset=0,this._studyEngine.on("configuration_received",(()=>{this._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",((...e)=>{const t=e[0];if(!Array.isArray(t?.value)||t.value.length<6)return;const i={time:t.value[0]/1e3,open:t.value[1],high:t.value[2],low:t.value[3],close:t.value[4],volume:t.value[5]};this._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={},this._studySpecs=new Map,this._isNonCountedStudy=()=>!0,this.defaultResolutions=this.defaultResolutions.bind(this)}destroy(){this._studyEngine.destroy(),this._studyEngine=null}purgeCache(){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache()}resetCache(){this._studyEngine.resetCache()}defaultResolutions(){return this._studyEngine.supportedResolutions()||["1","3","5","15","30","45","60","120","180","240","1D","1W","1M"]}availableCurrencies(){const e=this._studyEngine.supportedCurrencies().map((e=>"string"==typeof e?{id:e,code:e}:e));return Promise.resolve(e)}availableUnits(){return Promise.resolve(this._studyEngine.supportedUnits())}async availablePriceSources(e){return await this._studyEngine.supportedPriceSources(e)??[]}supportedSymbolsTypes(){return this._studyEngine.supportedSymbolsTypes()??[]}symbolsGrouping(){const e={};for(const[t,i]of Object.entries(this._studyEngine.symbolsGrouping()))e[t]=i instanceof RegExp?i:new RegExp(i);return e}start(){this._enabled=!0,this._fireEvent("start_enabled")}unsubscribe(e,t){const i=this._callbacks[e];i&&i.splice(i.indexOf(t),1)}on(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this}chartCreateSession(e,t){return this._studyEngine.chartCreateSession(e),!1}chartDeleteSession(e){return this._studyEngine.chartDeleteSession(e),!1}createSession(e,t){this._chartApiMessagerProvider.createChartApiMessager(e,this),this._sessions[e]=t,this._notificationHandlers[e]={},this.connected()&&t.onMessage({method:"connected",params:[]})}removeSession(e){delete this._sessions[e],delete this._notificationHandlers[e],this._studyEngine.stopSources(e)}connected(){return this._connected}connect(){this._enabled?this.connected()||(this._connected=!0,this.sessionid="dummy session id",this._notifySessions({method:"connected",params:[]})):this.on("start_enabled",(()=>{this.connect()}))}disconnect(){this._connected=!1,this._notifySessions({method:"disconnected",params:[]}),this.purgeCache(),this.studyCounter=0
}switchTimezone(e,t){return this._studyEngine.switchTimezone(e,t),!1}receiveLocalResponse(e){this._dispatchNotification(e),this._fireEvent("message_"+e.method,void 0,!0)}getMarks(e,t,i,s,o){const n=s;this._studyEngine.getMarks(e,t,i,n,o)}getTimescaleMarks(e,t,i,s,o){const n=s;this._studyEngine.getTimescaleMarks(e,t,i,n,o)}resolveSymbol(e,t,i,s){return this._notificationHandlers[e][t]=new Af(s,t),this._studyEngine.resolveSymbol(e,t,i),!1}requestFirstBarTime(e,t,i,s){throw new Error("Method not implemented.")}createSeries(e,t,i,s,o,n,r,a){this._notificationHandlers[e][t]=new Af((o=>{"series_completed"===o.method&&null!==r&&(this._applyTimeFrame(e,s,t,i,r),r=null),a(o)}),t);const l={countBack:n||300};return null!==r&&"time-range"===r.type&&(l.to=1e3*r.to,l.from=1e3*r.from),this._studyEngine.createSeries(e,t,i,s,o,l),!1}removeSeries(e,t){return delete this._notificationHandlers[e][t],this._studyEngine.removeSeries(e,t),!1}setVisibleTimeRange(e,t,i,s,o,r,a,l,c,h){let d=s,u=!0!==(a=a||{}).applyDefaultRightMargin&&void 0===a.percentRightMargin&&void 0!==o?o:null;const _=(0,Jd.createDwmAligner)((0,n.ensureNotNull)(this._studyEngine.getSeriesInterval(e,t)),(0,n.ensureNotNull)(this._studyEngine.getSeriesSymbolInfo(e,t)));null!==_&&(d=_.timeToSessionStart(1e3*d)/1e3,null!==u&&(u=_.timeToSessionStart(1e3*u)/1e3));const p=()=>{const s=this._studyEngine.sessionTimeScale(e);if(null===s)return void(h&&h(new Error("Session time scale is not available")));const o=s.indexOfTime(1e3*d);let _;if(null===u)_=s.lastSessionBarIndex();else{const e=s.indexOfTime(1e3*u);_=e&&e.index}if(null===o||null===_)return void(h&&h(new Error("Bars are not available")));let p=o.index;if(o.timeMs<1e3*d&&(p+=1),!1===r){const e=(0,n.ensureNotNull)(s.firstSessionBarIndex());p<e&&(p=e)}p>_?h&&h(new Error("Invalid visible range")):(this._chartApiMessagerProvider.getChartApiMessager(e).onSeriesTimeframeUpdate(t,i,p,_,a,c),l&&setTimeout(l,0))};if(this._studyEngine.isTimeScaleExtendedTo(e,1e3*s))return void p();const m=this._chartApiMessagerProvider.getChartApiMessager(e).beforeSeriesCompleted,g=this._chartApiMessagerProvider.getChartApiMessager(e).seriesError;function f(e,s){e===t&&s===i&&(m.unsubscribe(null,f),g.unsubscribe(null,y),p())}function y(e,s){e===t&&s===i&&m.unsubscribe(null,f)}void 0!==this._setVisibleRangeTimeout[e]&&clearTimeout(this._setVisibleRangeTimeout[e]),this._setVisibleRangeTimeout[e]=window.setTimeout((()=>{delete this._setVisibleRangeTimeout[e],m.subscribe(null,f,!0),g.subscribe(null,y,!0),this._studyEngine.ensureExtendedTo(t,e,1e3*s)}),0)}modifySeries(e,t,i,s,o,n,r,a){return this._notificationHandlers[e][t]=new Af((o=>{"series_completed"===o.method&&null!==r&&(this._applyTimeFrame(e,s,t,i,r),r=null),a(o)}),t),this._studyEngine.modifySeries(e,t,s,o,i,n),!1}requestMoreData(e,t,i,s){const o="number"==typeof t?t:i;return this._studyEngine.extendSeriesRange(e,o),!1}allStudiesMetadata(){return this._studyMetaInfoCache.studiesMetadata()}requestMetadata(){return new Promise((e=>{const t=this.studiesAccessController.getEnabledTools();e({
method:"studies_metadata",params:["metadata_"+this._metadataRequestNextNumber++,{errors:[],hash:"",metainfo:t,migrations:[]}]})}))}setIsNonCountedStudyFn(e){this._isNonCountedStudy=e}canCreateStudy(e,t,i){return this._isNonCountedStudy(t.id)||this.studyCounter<210?{success:!0}:{success:!1,reason:"general",limitValue:210}}getStudyCounter(e){return this.studyCounter}getFundamentalCounter(e){return 0}createStudy(e,t,i,s,o,n,r,a){if(!this.canCreateStudy(e,a).success){const e=new Error("Exceeded the limit of studies");throw e.cause="TooManyStudies",e}return this._notificationHandlers[e][t]=new Af(r,t),this._studySpecs.set(Lf(e,t),a),this._studyEngine.createStudy(e,t,s,i,o,kf(n)),this._isNonCountedStudy(a.id)||this.studyCounter++,!0}removeStudy(e,t){if(this._notificationHandlers[e][t]){delete this._notificationHandlers[e][t];const i=Lf(e,t),s=(0,n.ensureDefined)(this._studySpecs.get(i));this._studySpecs.delete(i),this._studyEngine.removeStudy(e,t),this._isNonCountedStudy(s.id)||this.studyCounter--}return!1}modifyStudy(e,t,i,s,o,n){return this._notificationHandlers[e][t]=new Af(o,t),this._studyEngine.modifyStudy(e,t,i,kf(s)),!1}notifyStudy(e,t,i,s){throw new Error("Method not implemented.")}createPointset(e,t,i,s,o,n,r){return this._notificationHandlers[e][t]=new Af(r,t),this._studyEngine.createPointset(e,t,s,o,n),!1}modifyPointset(e,t,i,s,o){throw new Error("Method not implemented.")}removePointset(e,t){return this._notificationHandlers[e][t]=null,this._studyEngine.removePointset(e,t),!1}requestMoreTickmarks(e,t,i,s){return this._studyEngine.requestMoreTickmarks(e,i),!1}setFutureTickmarksMode(e,t){throw new Error("Method not implemented.")}serverTime(){return this._studyEngine.serverTime()}quoteCreateSession(e){return this._studyEngine.quoteCreateSession(e),!1}quoteDeleteSession(e){return this._studyEngine.quoteDeleteSession(e),!1}quoteAddSymbols(e,t){return-1!==t.indexOf(void 0)&&(console.warn("Got undefined in quoteAddSymbols"),t=t.filter((e=>!!e))),this._studyEngine.quoteAddSymbols(e,t),!1}quoteRemoveSymbols(e,t){return this._studyEngine.quoteRemoveSymbols(e,t),!1}quoteFastSymbols(e,t){return this._studyEngine.quoteFastSymbols(e,t),!1}quoteSetFields(e,t){return this._studyEngine.quoteSetFields(e,t),!1}quoteHibernateAll(e){return this._studyEngine.quoteHibernateAll(e),!1}searchSymbols(e,t,i,s,o){this._studyEngine.searchSymbols(e,t,i,s,o)}searchSymbolsPaginated(e,t){this._studyEngine.searchSymbolsPaginated(e,t)}depthCreateSession(e){this._studyEngine.depthCreateSession(e)}depthDeleteSession(e){this._studyEngine.depthDeleteSession(e)}depthSetSymbol(e,t){this._studyEngine.depthSetSymbol(e,t)}depthClearSymbol(e){}depthSetScale(e,t){}_applyTimeFrame(e,t,i,s,o){let r,a,l={},c=!0;if("period-back"===o.type){const t=this._studyEngine.getSeriesLastBarTime(e,i);if(null===t)return;a=t/1e3;const s=Re.Interval.parse(o.value),h=(0,n.ensureNotNull)(this._studyEngine.getSeriesSymbolInfo(e,i));r=(0,Td.alignPeriodsBackForVisibleRange)(h.session,h.session_holidays,h.corrections,s.letter(),s.multiplier(),1,t)/1e3;const d=(0,
Jd.createDwmAligner)((0,n.ensureNotNull)(this._studyEngine.getSeriesInterval(e,i)),h);null!==d&&(a=d.timeToExchangeTradingDay(1e3*a)/1e3,r=d.timeToExchangeTradingDay(1e3*r)/1e3),l={applyDefaultRightMargin:!0},c=this._studyEngine.hasStudyWithExtendedTimeScale(e)}else r=o.from,a=o.to;this.setVisibleTimeRange(e,i,s,r,a,c,l,void 0,o,void 0)}_fireEvent(e,t,i){if(this._callbacks.hasOwnProperty(e)){const s=this._callbacks[e].slice(0);i||(this._callbacks[e]=[]);for(let e=0;e<s.length;++e)s[e](t)}}_notifySessions(e){for(const t in this._sessions)if(this._sessions.hasOwnProperty(t)){const i=this._sessions[t];"function"==typeof i.onMessage&&i.onMessage(e)}}_dispatchNotification(e){const t=e.params.shift();if(this._notificationHandlers[t])switch(e.method){case"timescale_update":const i=e.params[0],s=e.params[1];s.clear=0===s.changes.length&&0===s.marks.length,this._sessions[t].onMessage({method:"timescale_update",params:s});for(const e in i)if(i.hasOwnProperty(e)){const s={method:"data_update",params:{customId:e,plots:i[e].series,nonseries:i[e].nonseries,turnaround:i[e].turnaround}};this._invokeNotificationHandler(t,e,s)}break;case"tickmark_update":this._sessions[t].onMessage({method:"timescale_update",params:e.params[0]});break;case"data_update":for(const i in e.params[0])if(e.params[0].hasOwnProperty(i)){const s=e.params[0][i],o={method:"data_update",params:{customId:i,plots:s.series?s.series:s.plots,nonseries:s.nonseries,turnaround:s.turnaround}};this._invokeNotificationHandler(t,i,o)}break;case"index_update":for(const i in e.params[0])if(e.params[0].hasOwnProperty(i)){const s={method:"index_update",params:e.params[0][i]};this._invokeNotificationHandler(t,i,s)}break;case"critical_error":this._sessions[t].onMessage({method:"critical_error",params:e.params});break;case"timescale_completed":case"quote_symbol_data":case"quote_list_fields":case"depth_symbol_error":case"depth_symbol_success":case"dd":case"dpu":case"depth_bar_last_value":this._sessions[t].onMessage({method:e.method,params:e.params});break;case"clear_data":for(const i in e.params[0])e.params[0].hasOwnProperty(i)&&this._invokeNotificationHandler(t,i,{method:"clear_data",params:e.params[0][i]});break;default:const o=e.params[0];this._invokeNotificationHandler(t,o,e)}}_invokeNotificationHandler(e,t,i){if(void 0===t)return;const s=this._notificationHandlers[e][t];void 0!==s&&void 0!==s?.handler&&s.handler(i)}}class Df{constructor(e,t){this._studiesAccess=e,this._studyMetaInfoCache=t}getEnabledTools(){return this._studyMetaInfoCache.studiesMetadata().filter((e=>this.isToolEnabled(e.description)||e.is_hidden_study))}isToolEnabled(e){const t=this._findTool(e);return"black"===this._studiesAccess.type?!(t&&!t.grayed):!!t}isToolGrayed(e){const t=this._findTool(e);return!(!t||!t.grayed)}_findTool(e){let t=null;for(let i=0;i<this._studiesAccess.tools.length;++i){const s=this._studiesAccess.tools[i];if(s.name===e||s===e){t=s;break}}return t}}var Bf=i(52499),Vf=(i(68659),i(71843));class Rf{constructor(e){this._toolbarThemeChanged=new ae.Delegate,this._onWatchedThemeChanged=e=>{
this._toolbarThemeChanged.fire(e)},this._opts=e,k.watchedTheme.subscribe(this._onWatchedThemeChanged)}destroy(){k.watchedTheme.unsubscribe(this._onWatchedThemeChanged)}isStdTheme(){const e=this._opts.chartWidgetCollection.getAll().every((e=>null!==e.model().model().getThemeNameIfStdTheme()));return Promise.resolve(e)}async setStdTheme(e,t=!0,i){await(0,Vf.loadTheme)(this._opts.chartWidgetCollection,{themeName:e,standardTheme:!0,syncState:t,noUndo:i})}setStdThemeForLayout(e,t=!0){(0,k.setTheme)(e),t&&(0,L.syncTheme)()}getCurrentThemeName(){return(0,L.getCurrentTheme)().name}toolbarThemeChanged(){return this._toolbarThemeChanged}}function Nf(e){return e in Of}const Of={cursor:{name:"cursor",onlySelectable:!0},dot:{name:"dot",onlySelectable:!0},arrow_cursor:{name:"arrow",onlySelectable:!0},eraser:{name:"eraser",onlySelectable:!0},measure:{name:"measure",onlySelectable:!0},zoom:{name:"zoom",onlySelectable:!0},brush:{name:"LineToolBrush"},highlighter:{name:"LineToolHighlighter"},text:{name:"LineToolText"},anchored_text:{name:"LineToolTextAbsolute",isAnchored:!0},note:{name:"LineToolNote"},text_note:{name:"LineToolTextNote"},anchored_note:{name:"LineToolNoteAbsolute",isAnchored:!0},signpost:{name:"LineToolSignpost"},callout:{name:"LineToolCallout"},balloon:{name:"LineToolBalloon"},comment:{name:"LineToolComment"},arrow_up:{name:"LineToolArrowMarkUp"},arrow_down:{name:"LineToolArrowMarkDown"},arrow_left:{name:"LineToolArrowMarkLeft"},arrow_right:{name:"LineToolArrowMarkRight"},price_label:{name:"LineToolPriceLabel"},price_note:{name:"LineToolPriceNote"},arrow_marker:{name:"LineToolArrowMarker"},flag:{name:"LineToolFlagMark"},image:{name:"LineToolImage"},table:{name:"LineToolTable"},vertical_line:{name:"LineToolVertLine"},horizontal_line:{name:"LineToolHorzLine"},cross_line:{name:"LineToolCrossLine"},horizontal_ray:{name:"LineToolHorzRay"},trend_line:{name:"LineToolTrendLine"},info_line:{name:"LineToolInfoLine"},trend_angle:{name:"LineToolTrendAngle"},arrow:{name:"LineToolArrow"},ray:{name:"LineToolRay"},extended:{name:"LineToolExtended"},parallel_channel:{name:"LineToolParallelChannel"},disjoint_angle:{name:"LineToolDisjointAngle"},flat_bottom:{name:"LineToolFlatBottom"},anchored_vwap:{name:"LineToolAnchoredVWAP"},pitchfork:{name:"LineToolPitchfork"},schiff_pitchfork_modified:{name:"LineToolSchiffPitchfork"},schiff_pitchfork:{name:"LineToolSchiffPitchfork2"},inside_pitchfork:{name:"LineToolInsidePitchfork"},pitchfan:{name:"LineToolPitchfan"},gannbox:{name:"LineToolGannSquare"},gannbox_square:{name:"LineToolGannComplex"},gannbox_fixed:{name:"LineToolGannFixed"},gannbox_fan:{name:"LineToolGannFan"},fib_retracement:{name:"LineToolFibRetracement"},fib_trend_ext:{name:"LineToolTrendBasedFibExtension"},fib_speed_resist_fan:{name:"LineToolFibSpeedResistanceFan"},fib_timezone:{name:"LineToolFibTimeZone"},fib_trend_time:{name:"LineToolTrendBasedFibTime"},fib_circles:{name:"LineToolFibCircles"},fib_spiral:{name:"LineToolFibSpiral"},fib_speed_resist_arcs:{name:"LineToolFibSpeedResistanceArcs"},fib_wedge:{name:"LineToolFibWedge"},
fib_channel:{name:"LineToolFibChannel"},xabcd_pattern:{name:"LineTool5PointsPattern"},cypher_pattern:{name:"LineToolCypherPattern"},abcd_pattern:{name:"LineToolABCD"},triangle_pattern:{name:"LineToolTrianglePattern"},"3divers_pattern":{name:"LineToolThreeDrivers"},head_and_shoulders:{name:"LineToolHeadAndShoulders"},elliott_impulse_wave:{name:"LineToolElliottImpulse"},elliott_triangle_wave:{name:"LineToolElliottTriangle"},elliott_triple_combo:{name:"LineToolElliottTripleCombo"},elliott_correction:{name:"LineToolElliottCorrection"},elliott_double_combo:{name:"LineToolElliottDoubleCombo"},cyclic_lines:{name:"LineToolCircleLines"},time_cycles:{name:"LineToolTimeCycles"},sine_line:{name:"LineToolSineLine"},long_position:{name:"LineToolRiskRewardLong"},short_position:{name:"LineToolRiskRewardShort"},forecast:{name:"LineToolPrediction"},date_range:{name:"LineToolDateRange"},price_range:{name:"LineToolPriceRange"},date_and_price_range:{name:"LineToolDateAndPriceRange"},bars_pattern:{name:"LineToolBarsPattern"},ghost_feed:{name:"LineToolGhostFeed"},projection:{name:"LineToolProjection"},rectangle:{name:"LineToolRectangle"},rotated_rectangle:{name:"LineToolRotatedRectangle"},circle:{name:"LineToolCircle"},ellipse:{name:"LineToolEllipse"},triangle:{name:"LineToolTriangle"},polyline:{name:"LineToolPolyline"},path:{name:"LineToolPath"},curve:{name:"LineToolBezierQuadro"},double_curve:{name:"LineToolBezierCubic"},arc:{name:"LineToolArc"},icon:{name:"LineToolIcon"},emoji:{name:"LineToolEmoji"},sticker:{name:"LineToolSticker"},regression_trend:{name:"LineToolRegressionTrend"},fixed_range_volume_profile:{name:"LineToolFixedRangeVolumeProfile"}};const Ff=new ae.Delegate;var Wf=i(44862),Hf=i(51829);function zf(e,t,i){if(i.isDays())return t;if(e.moveTo(1e3*t),i.isIntraday()){const i=e.indexOfBar(1e3*t);if(i<0)throw new Error(`${t} is out of the instrument session `);return e.endOfBar(i)/1e3}return e.startOfBar(Hf.SessionStage.LASTBAR_SESSION)/1e3}class Uf{constructor(e){this._timeScale=e}coordinateToTime(e){const t=this._timeScale.coordinateToIndex(e);return this._timeScale.indexToTimePoint(t)}barSpacingChanged(){return this._timeScale.barSpacingChanged()}rightOffsetChanged(){return this._timeScale.rightOffsetChanged()}setRightOffset(e){this._timeScale.setRightOffset(e)}setBarSpacing(e){this._timeScale.setBarSpacing(e)}barSpacing(){return this._timeScale.barSpacing()}rightOffset(){return this._timeScale.rightOffset()}width(){return this._timeScale.width()}defaultRightOffset(){return this._timeScale.defaultRightOffset().spawn()}defaultRightOffsetPercentage(){return this._timeScale.defaultRightOffsetPercentage().spawn()}usePercentageRightOffset(){return this._timeScale.usePercentageRightOffset().spawn()}isEmpty(){return this._timeScale.isEmpty()}scrollToFirstBar(e){this._timeScale.scrollToFirstBar(e)}scrollToRealtime(e){this._timeScale.scrollToRealtime(!1,e)}pointsCount(){return this._timeScale.points().size()}leftVisibleBarUTCTime(){const e=this._timeScale.visibleBarsStrictRange()?.firstBar()??null
;return null===e?null:this._timeScale.indexToTimePoint(e)}}const jf=new dt.TranslatedString("change timezone",a.t(null,void 0,i(20137)));class Gf{constructor(e){this._onTimezoneChanged=new ae.Delegate,this._chartWidget=e,this._timezoneProperty=e.properties().childs().timezone,this._timezoneProperty.subscribe(this,(e=>{this._onTimezoneChanged.fire(e.value())})),e.onAboutToBeDestroyed().subscribe(this,(()=>{this._timezoneProperty.unsubscribeAll(this)}),!0)}availableTimezones(){return Pe.availableTimezones}getTimezone(){const e=this._timezoneProperty.value();return(0,n.ensureDefined)(this.availableTimezones().find((t=>t.id===e)))}setTimezone(e,t){(0,n.assert)((0,Pe.timezoneIsAvailable)(e),`Incorrect timezone: ${e}`),t?.disableUndo?this._timezoneProperty.setValue(e):this._chartWidget.model().setProperty(this._timezoneProperty,e,jf)}onTimezoneChanged(){return this._onTimezoneChanged}}class qf{constructor(e,t){this._chartUndoModel=e,this._chartModel=e.model(),this._priceScale=t}getMode(){const e=this._priceScale.properties().childs();return e.percentage.value()?2:e.indexedTo100.value()?3:e.log.value()?1:0}setMode(e){this._priceScale.setMode({percentage:2===e,log:1===e,indexedTo100:3===e})}isInverted(){return this._priceScale.isInverted()}setInverted(e){this._priceScale.properties().childs().isInverted.setValue(e)}isLocked(){return this._priceScale.isLockScale()}setLocked(e){this._priceScale.setMode({lockScale:e})}isAutoScale(){return this._priceScale.isAutoScale()}setAutoScale(e){this._priceScale.setMode({autoScale:e})}getVisiblePriceRange(){return this._priceScale.priceRangeInPrice()}setVisiblePriceRange(e){this._priceScale.setPriceRangeInPrice(e),this._chartModel.lightUpdate()}hasMainSeries(){return this._priceScale.hasMainSeries()}getStudies(){return this._priceScale.getStudies().map((e=>e.id()))}currency(){const e=this._chartModel.availableCurrencies(),t=this._priceScale.currency(e);return null===t?null:{readOnly:t.readOnly,selectedCurrency:t.selectedCurrency,originalCurrencies:Array.from(t.originalCurrencies),currencies:e.getItems().filter((e=>!t.baseCurrencies.has(e))),symbols:Array.from(t.symbols)}}setCurrency(e){const t=this.currency()?.currencies;t&&e&&!t.includes(e)?console.warn("The provided currency is not supported by your datafeed!"):this._chartUndoModel.setPriceScaleCurrency(this._priceScale,e)}unit(){const e=this._chartModel.availableUnits(),t=this._priceScale.unit(e);return null===t?null:{readOnly:0===t.availableGroups.size,selectedUnit:t.selectedUnit,originalUnits:Array.from(t.originalUnits),availableGroups:Array.from(t.availableGroups),symbols:Array.from(t.symbols)}}setUnit(e){!e||this._chartModel.availableUnits().unitGroupById(e)?this._chartUndoModel.setPriceScaleUnit(this._priceScale,e):console.warn("The provided unit is not supported by your datafeed!")}coordinateToPrice(e){const t=this._priceScale.mainSource()?.firstValue();return null==t?null:this._priceScale.coordinateToPrice(e,t)}measureUnitId(){const e=this._priceScale.measureUnitId(this._chartModel.availableUnits());return null===e?null:{
selectedMeasureUnitId:e.selectedMeasureUnitId}}}function $f(e){return{id:e.id(),name:(t=e.toolname,Object.keys(Of).find((e=>Of[e].name===t))||null)};var t}function Kf(e){return{id:e.id(),name:e.metaInfo().description}}const Yf=new dt.TranslatedString("change pane height",a.t(null,void 0,i(14691)));class Zf extends st.UndoCommand{constructor(e,t,i){super(Yf),this._model=e,this._paneIndex=t,this._paneHeight=i,this._prevStretchFactors=this._model.panes().map((e=>e.stretchFactor()))}redo(){this._model.changePanesHeight(this._paneIndex,this._paneHeight)}undo(){const e=this._model.panes();for(let t=0;t<e.length;++t)e[t].setStretchFactor((0,n.ensureDefined)(this._prevStretchFactors[t]));this._model.fullUpdate()}}class Xf{constructor(e,t){this._priceScales=new WeakMap,this._pane=e,this._chartWidget=t}hasMainSeries(){return this._pane.containsMainSeries()}getLeftPriceScales(){return this._pane.leftPriceScales().map(this._getPriceScaleApi,this)}getRightPriceScales(){return this._pane.rightPriceScales().map(this._getPriceScaleApi,this)}getMainSourcePriceScale(){const e=this._pane.mainDataSource();if(null===e)return null;const t=e.priceScale();return null===t||this._pane.isOverlay(e)?null:this._getPriceScaleApi(t)}getPriceScaleById(e){const t=this._pane.getPriceScaleById(e);return null===t?null:this._getPriceScaleApi(t)}setMaximized(e){this._pane.maximized().value()!==e&&this._chartWidget.model().toggleMaximizedPane(this._pane)}isMaximized(){return this._pane.maximized().value()}legendLoaded(){const e=this._chartWidget.paneByState(this._pane);return Boolean(e&&e.statusWidget())}getAllEntities(){const e=this._pane.model();return this._pane.sourcesByGroup().allIncludingHidden().filter((e=>!e.isSpeciallyZOrderedSource())).map((t=>function(e,t){return t===e.mainSeries()?function(e){return{id:e.id(),name:"Main Series"}}(e.mainSeries()):(0,Ws.isStudy)(t)?Kf(t):(0,zs.isLineTool)(t)?$f(t):null}(e,t))).filter(tt.notNull).filter((e=>null!==e.name))}getHeight(){return this._pane.height()}setHeight(e){const t=this._chartWidget.model().model(),i=t.panes();(0,n.assert)(i.length>1,"Unable to change pane's height if there is only one pane");const s=i.indexOf(this._pane);(0,n.assert)(-1!==s,"Invalid pane index");const o=new Zf(t,s,e);this._chartWidget.model().undoHistory().pushUndoCommand(o)}moveTo(e){const t=this.paneIndex();t!==e&&((0,n.assert)(e>=0&&e<this._chartWidget.paneWidgets().length,"Invalid pane index"),this._chartWidget.model().movePane(t,e))}paneIndex(){return this._chartWidget.model().model().panes().indexOf(this._pane)}collapse(){if(1===this._chartWidget.model().panes().length)throw new Error("Cannot collapse a single pane!");if(this._pane.collapsed().value())throw new Error("Cannot collapse current pane!");this._chartWidget.model().toggleCollapsedPane(this._pane)}restore(){if(1===this._chartWidget.paneWidgets().length)throw new Error("Cannot restore a single pane!");if(!this._pane.collapsed().value())throw new Error("Cannot restore current pane!");this._chartWidget.model().toggleCollapsedPane(this._pane)}isCollapsed(){
return this._pane.collapsed().value()}_getPriceScaleApi(e){let t=this._priceScales.get(e);return void 0===t&&(t=new qf(this._chartWidget.model(),e),this._priceScales.set(e,t)),t}}var Jf=i(3618);function Qf(e){return void 0===e.inputs?[]:e.inputs.map((e=>({...e,id:e.id,localizedName:void 0!==e.name?(0,Jf.getTranslatedInputTitle)(e.name):""})))}function ey(e){const t={};if(e.defaults){const i=(0,Al.default)(e.defaults);t.defaults=i}return void 0!==e.plots&&(t.plots=(0,Al.default)(e.plots)),void 0!==e.styles&&(t.styles=(0,Al.default)(e.styles)),void 0!==e.bands&&(t.bands=(0,Al.default)(e.bands)),void 0!==e.filledAreas&&(t.filledAreas=(0,Al.default)(e.filledAreas)),void 0!==e.palettes&&(t.palettes=(0,Al.default)(e.palettes)),t}var ty=i(82130);class iy{constructor(e,t){this._onStudyCompleted=new ae.Delegate,this._onStudyError=new ae.Delegate,this._isStudyDestroyed=!1,this._study=e,this._chartWidget=t,this._undoModel=this._chartWidget.model(),this._model=this._undoModel.model(),this._study.onAboutToBeDestroyed().subscribe(this,(()=>{this._study.onStatusChanged().unsubscribeAll(this),this._study.onAboutToBeDestroyed().unsubscribeAll(this),this._isStudyDestroyed=!0})),this._study.onStatusChanged().subscribe(this,(e=>{switch(e.type){case gh.StudyStatusType.Completed:this._onStudyCompleted.fire();break;case gh.StudyStatusType.Error:this._onStudyError.fire()}}))}isUserEditEnabled(){return this._study.userEditEnabled()}setUserEditEnabled(e){this._study.setUserEditEnabled(e)}getInputsInfo(){return Qf(this._study.metaInfo())}getInputValues(){const e=this._study.inputs({symbolsForChartApi:!1,asObject:!0});return Object.keys(e).map((t=>{const i=e[t];return{id:t,value:(0,tt.isObject)(i)?i.v:i}}))}getStyleInfo(){return ey(this._study.metaInfo())}getStyleValues(){const{styles:e,bands:t,filledAreas:i,palettes:s,graphics:o,ohlcPlots:n,filledAreasStyle:r}=this._study.properties().state();return{styles:e,bands:t,filledAreas:i,palettes:s,graphics:o,ohlcPlots:n,filledAreasStyle:r}}setInputValues(e){const t=this.getInputValues();for(const i of e){void 0!==t.find((e=>e.id===i.id))?this._study.properties().childs().inputs.childs()[i.id].setValue(i.value):console.warn(`There is no such input: "${i.id}"`)}}mergeUp(){this._model.isMergeUpAvailableForSource(this._study)&&new la(this._model,this._study,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._study)&&new ca(this._model,this._study,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._study)&&new na(this._model,this._study,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._study)&&new oa(this._model,this._study,null).redo()}paneIndex(){return this._model.panes().indexOf(this._model.paneForSource(this._study))}onDataLoaded(){return this._onStudyCompleted}onStudyError(){return this._onStudyError}mergeUpWithUndo(){this._model.isMergeUpAvailableForSource(this._study)&&this._undoModel.mergeSourceUp(this._study)}mergeDownWithUndo(){this._model.isMergeDownAvailableForSource(this._study)&&this._undoModel.mergeSourceDown(this._study)}
unmergeUpWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceUp(this._study)}unmergeDownWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceDown(this._study)}priceScale(){return new qf(this._undoModel,(0,n.ensureNotNull)(this._study.priceScale()))}symbolSource(){const e=(0,n.ensureNotNull)(this._study.symbolSource());return{symbol:e.symbol(),currencyId:e.currency(),unitId:e.unit()}}currency(){return this._study.currency()}changePriceScale(e){const t=(0,n.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())),i=(0,n.ensureNotNull)(this._model.paneForSource(this._study));switch(e){case"no-scale":(0,n.assert)(i.actionNoScaleIsEnabled(this._study),"Unable to leave a pane without any non-overlay price scale"),new Tl(this._model,this._study,i,"overlay",null).redo();break;case"as-series":(0,n.assert)(i===t,"Study should be on the main pane"),new Pl(this._model,this._study,i,this._model.mainSeries().priceScale(),null).redo();break;case"new-left":new Tl(this._model,this._study,i,"left",null).redo();break;case"new-right":new Tl(this._model,this._study,i,"right",null).redo();break;default:const s=this._model.dataSourceForId(e);if(null===s)throw new Error(`There is no study with entityId='${e}'`);const o=i===this._model.paneForSource(s);(0,n.assert)(o,"Both studies should be on the same pane");const r=(0,n.ensureNotNull)(s.priceScale()),a=kr(this._study,r,this._model),l=ih(this._study,r,this._model);new Pl(this._model,this._study,i,r,null).redo(),null!==a&&new bl(this._model,r,a,null).redo(),null!==l&&new wl(this._model,r,l,null).redo()}}isVisible(){return this._study.properties().childs().visible.value()}setVisible(e){this._study.properties().childs().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._study])}sendToBack(){this._model.sendToBack([this._study])}applyOverrides(e){(0,Wf.applyOverridesToStudy)(this._study,e)}hasPlots(){return this._study.metaInfo().plots.length>0}dataLength(){if(this._study.status().type!==gh.StudyStatusType.Completed)return 0;return this._study.metaInfo().plots.length>0?this._study.data().size():this._model.mainSeries().bars().size()}isLoading(){const e=this._study.status();return e.type===gh.StudyStatusType.Undefined||e.type===gh.StudyStatusType.Loading}hasError(){return this._study.status().type===gh.StudyStatusType.Error}hasPendingUnresolvedSymbols(){return this._study.hasPendingUnresolvedSymbols()}anyGraphicsReady(){return!(0,ty.isStudyGraphicsEmpty)(this._study.graphics())}graphicsViewsReady(){return this._study.graphicsViewsReady()}properties(){return this._study.properties()}setProperties(e){this._study.properties().mergeAndFire(e)}async applyToEntireLayout(){const{ActionsProvider:e}=await(0,Go.actionsProviderModule)();if(this._isStudyDestroyed)return;const t=new e(this._chartWidget),i=(await t.contextMenuActionsForSources([this._study],(0,n.ensureNotNull)(this._chartWidget.model().paneForSource(this._study)))).find((e=>"applyStudyToEntireLayout"===e.id));i&&i.execute()}status(){
return{...this._study.status()}}title(){return this._study.title(pa.TitleDisplayTarget.StatusLine)}symbolsResolved(){return this._study.symbolsResolved()}study(){return this._study}}const sy=new Map([["LineToolBezierQuadro",3],["LineToolBezierCubic",4]]);function oy(e){const t=sy.get(e.toolname);if(void 0!==t)return t;const i=e.pointsCount();return-1===i?e.points().length:i}function ny(e){return"LineToolRiskRewardLong"===e||"LineToolRiskRewardShort"===e}const ry=["alwaysShowStats","entryPrice","inputs.first bar time","inputs.last bar time","interval","linesWidths","points","snapTo45Degrees","stopPrice","symbol","symbolStateVersion","currencyId","unitId","targetPrice","zOrderVersion"];class ay{constructor(e,t,i){this._source=e,this._undoModel=t,this._model=t.model(),this._pointsConverter=i}isSelectionEnabled(){return this._source.isSelectionEnabled()}setSelectionEnabled(e){this._source.setSelectionEnabled(e)}isSavingEnabled(){return this._source.isSavedInChart()}setSavingEnabled(e){this._source.setSavingInChartEnabled(e)}isShowInObjectsTreeEnabled(){return this._source.showInObjectTree()}setShowInObjectsTreeEnabled(e){this._source.setShowInObjectsTreeEnabled(e)}isUserEditEnabled(){return this._source.userEditEnabled()}setUserEditEnabled(e){this._source.setUserEditEnabled(e)}bringToFront(){this._model.bringToFront([this._source])}sendToBack(){this._model.sendToBack([this._source])}getProperties(e,t){return this._source.properties().state(ry,e,t)}setProperties(e,t){(0,yi.allowSavingDefaults)(!!t),this._source.properties().mergeAndFire(e),(0,yi.allowSavingDefaults)(!1)}getPoints(){let e=this._source.points();const t=oy(this._source);return e.length>t&&((0,n.assert)(ny(this._source.toolname)),e=e.slice(0,t)),this._pointsConverter.dataSourcePointsToPriced(e)}setPoints(e){if(this._source.isFixed())return;const t=oy(this._source);if(t!==e.length)throw new Error(`Wrong points count. Required: ${t}, provided: ${e.length}`);const i=this._pointsConverter.apiPointsToDataSource(e);this._model.startChangingLinetool(this._source,(0,n.ensureNotNull)(this._source.ownerSource())),this._model.changeLinePoints(this._source,i),this._model.endChangingLinetool(!0),this._source.createServerPoints()}getAnchoredPosition(){return this._source.positionPercents()}setAnchoredPosition(e){const t=this._source.fixedPoint(),i=this._source.linkKey().value(),s=void 0===t?null:this._source.screenPointToPoint(t);if(!this._source.isFixed()||void 0===t||null===i||null===s)return;const o={logical:s,screen:t},n=new Map;n.set(i,e),this._model.startMovingSources([this._source],o,null,new Map),this._model.moveSources(o,n),this._model.endMovingSources(!0)}ownerSourceId(){return(0,n.ensureNotNull)(this._source.ownerSource()).id()}changePoint(e,t){if(this._source.isFixed())return;const i=this._pointsConverter.apiPointsToDataSource([e])[0];this._model.startChangingLinetool(this._source,(0,n.ensureNotNull)(this._source.ownerSource()),{...i},t),this._model.changeLinePoint({...i}),this._model.endChangingLinetool(!1),this._source.createServerPoints()}isHidden(){
return this._source.isSourceHidden()}getRawPoints(){return this._source.points()}getNormalizedPoints(){return this._source.normalizedPoints()}setRawPoint(e,t){this._model.startChangingLinetool(this._source,(0,n.ensureNotNull)(this._source.ownerSource()),{...t},e),this._model.changeLinePoint({...t}),this._model.endChangingLinetool(!1)}move(e,t){this._model.startMovingSources([this._source],{logical:e,screen:(0,n.ensureNotNull)(this._source.pointToScreenPoint(e))},null,new Map),this._model.moveSources({logical:t,screen:(0,n.ensureNotNull)(this._source.pointToScreenPoint(t))},new Map),this._model.endMovingSources(!1)}dataAndViewsReady(){return this._source.dataAndViewsReady()}zorder(){return this._source.zorder()}symbol(){return this._source.properties().symbol.value()}currency(){return this._source.properties().currencyId.value()}unit(){return this._source.properties().unitId.value()}share(e){this._undoModel.shareLineTools([this._source],e)}setVisible(e,t=!1){this._undoModel.setProperty(this._source.properties().visible,e,null,t)}sharingMode(){return this._source.sharingMode().value()}lineDataSource(){return this._source}template(){return this._source.template()}}class ly{constructor(e,t){this._series=e,this._undoModel=t,this._model=t.model()}isUserEditEnabled(){return this._series.userEditEnabled()}setUserEditEnabled(e){this._series.setUserEditEnabled(e)}mergeUp(){this._model.isMergeUpAvailableForSource(this._series)&&new la(this._model,this._series,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._series)&&new ca(this._model,this._series,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._series)&&new na(this._model,this._series,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._series)&&new oa(this._model,this._series,null).redo()}mergeUpWithUndo(){this._model.isMergeUpAvailableForSource(this._series)&&this._undoModel.mergeSourceUp(this._series)}mergeDownWithUndo(){this._model.isMergeDownAvailableForSource(this._series)&&this._undoModel.mergeSourceDown(this._series)}unmergeUpWithUndo(){this._model.isUnmergeAvailableForSource(this._series)&&this._undoModel.unmergeSourceUp(this._series)}unmergeDownWithUndo(){this._model.isUnmergeAvailableForSource(this._series)&&this._undoModel.unmergeSourceDown(this._series)}detachToRight(){new Tl(this._model,this._series,this._pane(),"right",null).redo()}detachToLeft(){new Tl(this._model,this._series,this._pane(),"left",null).redo()}detachNoScale(){new Tl(this._model,this._series,this._pane(),"overlay",null).redo()}changePriceScale(e){const t=(0,n.ensureNotNull)(this._model.paneForSource(this._series));switch(e){case"new-left":new Tl(this._model,this._series,t,"left",null).redo();break;case"new-right":new Tl(this._model,this._series,t,"right",null).redo();break;case"no-scale":(0,n.assert)(t.actionNoScaleIsEnabled(this._series),"Unable to leave a pane without any non-overlay price scale"),new Tl(this._model,this._series,t,"overlay",null).redo();break;default:const i=this._model.dataSourceForId(e)
;if(null===i)throw new Error(`There is no study with entityId='${e}'`);const s=this._model.paneForSource(i)===t;(0,n.assert)(s,"Study should be on the main pane");const o=(0,n.ensureNotNull)(i.priceScale());new Pl(this._model,this._series,t,o,null).redo()}}isVisible(){return this._series.properties().childs().visible.value()}setVisible(e){this._series.properties().childs().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._series])}sendToBack(){this._model.sendToBack([this._series])}entityId(){return this._series.id()}chartStyleProperties(e,t){return t?this._series.properties().childs()[cy(e)].state():this._series.properties().childs()[cy(e)].state(["inputs","inputsInfo"])}setChartStyleProperties(e,t){this._series.properties().childs()[cy(e)].mergeAndFire(t)}barsCount(){return this._series.bars().size()}endOfData(){return this._series.endOfData()}symbolSource(){return{symbol:this._series.symbol(),currencyId:this._series.currency(),unitId:this._series.unit()}}series(){return this._series}isLoading(){return this._series.isLoading()}isInReplay(){return this._series.isInReplay()}data(){return this._series.data()}priceScale(){return new qf(this._undoModel,this._series.priceScale())}seriesErrorMessage(){return this._series.seriesErrorMessage()}compositeStatusVW(){return this._series.compositeStatusVW()}properties(){return this._series.properties()}_pane(){return(0,n.ensureNotNull)(this._model.paneForSource(this._series))}}function cy(e){switch(e){case 0:return"barStyle";case 1:return"candleStyle";case 2:return"lineStyle";case 14:return"lineWithMarkersStyle";case 15:return"steplineStyle";case 3:return"areaStyle";case 16:return"hlcAreaStyle";case 4:return"renkoStyle";case 5:return"kagiStyle";case 6:return"pnfStyle";case 7:return"pbStyle";case 8:return"haStyle";case 9:return"hollowCandleStyle";case 10:return"baselineStyle";case 11:return"rangeStyle";case 12:return"hiloStyle";case 13:return"columnStyle";case 17:return"volFootprintStyle";case 18:return"tpoStyle";case 19:return"volCandlesStyle";case 20:return"svpStyle";case 21:return"hlcBarsStyle";default:(0,n.ensureNever)(e)}throw new Error(`unsupported chart style: ${e}`)}var hy=i(32112);function dy(e,t){const{symbolChanged:i,currencyChanged:s,unitChanged:o,styleChangeRequiresRestart:n}=e.compareSymbolParams(t);return!(i||s||o||n)}function uy(e,t){e.isLoading()&&!e.isFailed()||t(e.isFailed());const i=e.seriesSource().symbolInstanceId(),s=e.dataEvents(),o=e.symbolParams(),n=()=>{s.completed().unsubscribe(null,r),(dy(e,o)||e.seriesSource().symbolInstanceId()===i)&&t(!1)},r=()=>{s.error().unsubscribe(null,n),(dy(e,o)||e.seriesSource().symbolInstanceId()===i)&&t(!0)};s.completed().subscribe(null,n,!0),s.error().subscribe(null,r,!0)}class _y{constructor(e,t){this._controller=e,this._model=t}createGroupFromSelection(){return this._controller.createGroupFromSelection().id}removeGroup(e){const t=(0,n.ensureDefined)(this._groupById(e));this._controller.removeGroup(t)}groups(){return this._controller.groups().map((e=>e.id))}shapesInGroup(e){const t=(0,
n.ensureDefined)(this._groupById(e));return(0,vi.sortSources)(t.lineTools()).map((e=>e.id()))}excludeShapeFromGroup(e,t){const i=(0,n.ensureDefined)(this._groupById(e)),s=(0,n.ensureNotNull)(this._model.dataSourceForId(t));(0,n.assert)((0,zs.isLineTool)(s),"Passed shapeId is not a line tool"),this._controller.excludeLineToolFromGroup(i,s)}addShapeToGroup(e,t){const i=(0,n.ensureDefined)(this._groupById(e)),s=(0,n.ensureNotNull)(this._model.dataSourceForId(t));(0,n.assert)((0,zs.isLineTool)(s),"Passed shapeId is not a line tool"),this._controller.addLineToolToGroup(i,s)}availableZOrderOperations(e){const t=(0,n.ensureDefined)(this._groupById(e));return this._controller.availableZOrderOperations(t)}bringToFront(e){const t=(0,n.ensureDefined)(this._groupById(e));this._controller.bringToFront(t)}bringForward(e){const t=(0,n.ensureDefined)(this._groupById(e));this._controller.bringForward(t)}sendBackward(e){const t=(0,n.ensureDefined)(this._groupById(e));this._controller.sendBackward(t)}sendToBack(e){const t=(0,n.ensureDefined)(this._groupById(e));this._controller.sendToBack(t)}insertAfter(e,t){const i=(0,n.ensureDefined)(this._groupById(e)),s=(0,n.ensureNotNull)(this._groupById(t)||this._model.dataSourceForId(t));this._controller.insertAfter(i,s)}insertBefore(e,t){const i=(0,n.ensureDefined)(this._groupById(e)),s=(0,n.ensureNotNull)(this._groupById(t)||this._model.dataSourceForId(t));this._controller.insertBefore(i,s)}groupVisibility(e){return(0,n.ensureDefined)(this._groupById(e)).visibility()}setGroupVisibility(e,t){const i=(0,n.ensureDefined)(this._groupById(e));this._controller.setGroupVisibility(i,t)}groupLock(e){return(0,n.ensureDefined)(this._groupById(e)).locked()}setGroupLock(e,t){const i=(0,n.ensureDefined)(this._groupById(e));this._controller.setGroupLock(i,t)}getGroupName(e){return(0,n.ensureDefined)(this._groupById(e)).name().value()}setGroupName(e,t){const i=(0,n.ensureDefined)(this._groupById(e));this._controller.setGroupName(i,t)}canBeGroupped(e){const t=e.map((e=>(0,n.ensureNotNull)(this._model.dataSourceForId(e))));return!t.some((e=>!(0,zs.isLineTool)(e)))&&this._controller.canBeGroupped(t)}_groupById(e){return this._controller.groups().find((t=>t.id===e))}}var py=i(18041);const my=new dt.TranslatedString("change price to bar ratio",a.t(null,void 0,i(2509))),gy=new dt.TranslatedString("toggle lock scale",a.t(null,void 0,i(49695)));function fy(e,t){return t.map((t=>(0,n.ensureNotNull)(e.dataSourceForId(t))))}class yy{constructor(e,t){this._visibleBarsChanged=new ae.Delegate,this._crosshairMoved=new ae.Delegate,this._dataSourceHovered=new ae.Delegate,this._ranges=null,this._zoomUndoStackIsNotEmpty=null,this._panes=new WeakMap,this._studies=new WeakMap,this._lineDataSources=new WeakMap,this._selectionApi=null,this._lollipopSourcesApi=null,this._prevVisibleRange=null,this._prevHoveredSourceId=null,this._onSymbolChangedDelegate=new ae.Delegate,this._chartWidget=e,this._activateChart=t,this._timezoneApi=new Gf(e),this._chartWidget.withModel(this,(()=>{
this._chartWidget.model().crosshairSource().moved().subscribe(this,this._onCrosshairMoved),this._chartWidget.model().model().hoveredSourceChanged().subscribe(this,this._onHoveredSourceChanged),this._chartWidget.model().timeScale().logicalRangeChanged().subscribe(this,this._onLogicalRangeChanged),this._chartWidget.model().mainSeries().dataEvents().symbolResolved().subscribe(this,this._onSymbolChanged)})),this._widgetLinkingGroupIndex=e.linkingGroupIndex().spawn(),this._widgetLinkingGroupIndex.subscribe((e=>this._apiLinkingGroupIndex.setValue(e))),this._apiLinkingGroupIndex=new O.WatchedValue(this._widgetLinkingGroupIndex.value()),this._apiLinkingGroupIndex.subscribe((e=>{this._widgetLinkingGroupIndex.value()!==e&&(this._chartWidget.hasModel()?this._chartWidget.model().setLinkingGroupIndex(e):this._widgetLinkingGroupIndex.setValue(e))})),this._chartWidget.onAboutToBeDestroyed().subscribe(this,this._destroy,!0)}setActive(){this._activateChart()}getPriceToBarRatio(){return this._chartWidget.model().model().mainSeriesScaleRatioProperty().value()}setPriceToBarRatio(e,t){const i=this._chartWidget.model(),s=i.model(),o=s.mainSeriesScaleRatioProperty();t?.disableUndo?new gp(o,e,null,s).redo():i.setScaleRatioProperty(o,e,my)}isPriceToBarRatioLocked(){return this._chartWidget.model().model().mainSeries().priceScale().isLockScale()}setPriceToBarRatioLocked(e,t){const i=this._chartWidget.model(),s=i.model(),o=s.mainSeries().priceScale();t?.disableUndo?new Nl({lockScale:e},o,null,s).redo():i.setPriceScaleMode({lockScale:e},o,gy)}id(){return this._chartWidget.id()}onDataLoaded(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().completed())}onSymbolChanged(){return this._makeSubscriptionFromDelegate(this._onSymbolChangedDelegate)}onIntervalChanged(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().onIntervalChanged())}onVisibleRangeChanged(){return this._makeSubscriptionFromDelegate(this._visibleBarsChanged)}onChartTypeChanged(){const e=this._chartWidget.model().mainSeries().onStyleChanged();return this._makeSubscriptionFromDelegate(e)}onSeriesTimeframe(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().seriesTimeFrame())}onSeriesError(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().seriesError())}dataReady(e){const t=!this._chartWidget.hasModel()||!this._chartWidget.model().mainSeries()||this._chartWidget.model().mainSeries().data().isEmpty();return e&&(t?this.onDataLoaded().subscribe(null,e,!0):e()),!t}whenChartReady(e){this._chartWidget.withModel(this,e)}crossHairMoved(){return this._makeSubscriptionFromDelegate(this._crosshairMoved)}onHoveredSourceChanged(){return this._makeSubscriptionFromDelegate(this._dataSourceHovered)}setVisibleRange(e,t){return new Promise(((i,s)=>{const o=e=>{clearTimeout(n),s(e)},n=setTimeout((()=>o(new Error("Rejected by timeout"))),t?.rejectByTimeout??1e4);this._chartWidget.setVisibleTimeRange(e.from,e.to,t,(()=>{clearTimeout(n),i()
}),o)}))}async setSymbol(e,t){(0,tt.isFunction)(t)&&(t={dataReady:t});const{dataReady:i,doNotActivateChart:s,initiatorName:o="chart api"}=t||{};if(e===this.symbol()||this._chartWidget.hasModel()&&this._chartWidget.model().mainSeries().symbolSameAsResolved(e))return i?.(),!0;s||this._activateChart();const n=this._chartWidget.chartWidgetCollection(),r=await n.setSymbol(e,void 0,this._chartWidget);return r&&uy(this._chartWidget.model().mainSeries(),(e=>{!e&&i&&i()})),r}async setResolution(e,t){(0,tt.isFunction)(t)&&(t={dataReady:t});const{dataReady:i,doNotActivateChart:s,initiatorName:o="Chart api"}=t||{},n=Re.Interval.normalize(e);if(null===n||n===this.resolution())return i?.(),!0;s||this._activateChart();const r=await this._chartWidget.chartWidgetCollection().setResolution(n,void 0,this._chartWidget);return r&&uy(this._chartWidget.model().mainSeries(),(e=>{!e&&i&&i()})),r}async setChartType(e,t){if(this._chartWidget.model().mainSeries().properties().childs().style.value()===e)return t?.(),!0;const i=this._chartWidget.chartWidgetCollection().setChartStyleToWidget(e,this._chartWidget);return uy(this._chartWidget.model().mainSeries(),(e=>{!e&&t&&t()})),i}resetData(){this._chartWidget.model().mainSeries().rerequestData()}executeActionById(e){this._chartWidget.executeActionById(e)}getCheckableActionState(e){return this._chartWidget.getCheckableActionState(e)}refreshMarks(){this._chartWidget.refreshMarks()}clearMarks(e){this._chartWidget.clearMarks(e)}getBarsMarksSources(){return this._chartWidget.model().barsMarksSources()}getAllShapes(){return this._chartWidget.model().model().allLineTools().map($f).filter((e=>null!==e.name))}getAllStudies(){return this._chartWidget.model().model().allStudies(!0).map(Kf)}getStudyTemplateSnapshot(e,t,i){return(0,py.getStudyTemplateSaveData)(e,this._chartWidget.model().model(),t,i)}getStudyTemplateDescString(){const e=(0,py.getStudyTemplateMetaInfo)(this._chartWidget.model().model());return(0,py.getStudyTemplateDescString)(e.indicators)}async applyStudyTemplateByRecord(e){if(!e)return;const{name:t,id:i,is_default:s}=e,o=e=>this._chartWidget.model().applyStudyTemplate(JSON.parse(e.content),t);s?await z.backend.getStandardStudyTemplateById(i,o):await z.backend.getStudyTemplateById(i).then(o)}chartTemplate(){return this._chartWidget.model().model().template()}applyChartTempalte(e){this._chartWidget.chartWidgetCollection().applyTheme(e)}getAllPanesHeight(){const e=this._chartWidget.model().model().panes();if(this._chartWidget.hasMaximizedPane()){let t=0,i=0;e.forEach((e=>{t+=e.height(),i+=e.stretchFactor()}));const s=i/t;return e.map((e=>Math.round(e.stretchFactor()/s*100)/100))}return e.map((e=>e.height()))}setAllPanesHeight(e){const t=this._chartWidget.model().model(),i=t.panes();(0,n.assert)(i.length===e.length,"There`s a mismatch between the number of heights you provided and the number of panes.");const s=i.reduce(((e,t)=>e+t.stretchFactor()),0)/e.reduce(((e,t)=>e+t));e.forEach(((e,t)=>{const o=e*s;i[t].setStretchFactor(o)})),t.fullUpdate()}maximizeChart(){
this._chartWidget.requestFullscreen()}isMaximized(){return this._chartWidget.inFullscreen()}restoreChart(){this._chartWidget.exitFullscreen()}restoreChartPreferences(){this._chartWidget.model().restorePreferences()}availableZOrderOperations(e){const t=fy(this._chartWidget.model().model(),e);return this._chartWidget.model().availableZOrderOperations(t)}sendToBack(e){const t=fy(this._chartWidget.model().model(),e);this._chartWidget.model().sendToBack(t)}bringToFront(e){const t=fy(this._chartWidget.model().model(),e);this._chartWidget.model().bringToFront(t)}bringForward(e){const t=fy(this._chartWidget.model().model(),e);this._chartWidget.model().bringForward(t)}sendBackward(e){const t=fy(this._chartWidget.model().model(),e);this._chartWidget.model().sendBackward(t)}insertAfter(e,t){const i=this._chartWidget.model().model(),s=fy(i,e),o=(0,n.ensureNotNull)(i.dataSourceForId(t));this._chartWidget.model().insertAfter(s,o)}insertBefore(e,t){const i=this._chartWidget.model().model(),s=fy(i,e),o=(0,n.ensureNotNull)(i.dataSourceForId(t));this._chartWidget.model().insertBefore(s,o)}sessions(){return this._chartWidget.model().model().sessions()?.get()??null}chartModel(){return this._chartWidget.model().model()}chartUndoModel(){return this._chartWidget.model()}chartWidget(){return this._chartWidget}getTimeScaleLogicalRange(){return this._chartWidget.model().timeScale().logicalRange()}setEntityVisibility(e,t){console.warn("`setEntityVisibility` is deprecated. Use shape/study API instead");const i=this._chartWidget.model().model().dataSourceForId(e);if(!i)return;const s=i.properties();s&&s.visible&&s.visible.setValue(t)}async createStudy(e,t,i,s,o,n){if("function"==typeof o)return console.warn('"createStudy" does not take "callback" parameter anymore'),Promise.resolve(null);if(n=n||{},"string"!=typeof e)return this._createStudy(e);e=e.toLowerCase();const r=await(0,os.studyMetaInfoRepository)().findAllJavaStudies(),a=ns.StudyMetaInfo.findStudyMetaInfoByDescription(r,e);if(n.checkLimit){const e=this._chartWidget.model().canCreateStudy({id:a.id});if(!e.success)return(0,wr.showTooManyStudiesNotice)(e.limitValue),Promise.resolve(null)}const l=(n.disableUndo?this._chartWidget.model().model():this._chartWidget.model()).createStudyInserter({type:"java",studyId:a.id},[]);if(l.setForceOverlay(!!t),n.priceScale&&l.setPreferredPriceScale(function(e){switch(e){case"no-scale":return"overlay";case"as-series":return"as-series";case"new-left":return"left";case"new-right":return"right";default:throw new Error(`The pricescale "${e}" is invalid, the only valid options are "no-scale", "as-series", "new-left" and "new-right".`)}}(n.priceScale)),n.allowChangeCurrency&&l.setAllowChangeCurrency(!0),n.allowChangeUnit&&l.setAllowChangeUnit(!0),Array.isArray(s)){console.warn("Passing study inputs as an ordered array is now deprecated. Please use an object where keys correspond to the inputs of your study instead.");const e={};for(let t=0;t<a.inputs.length;++t)e[a.inputs[t].id]=s[t];s=e}return l.insert((()=>Promise.resolve({inputs:s||{},parentSources:[]
}))).then((e=>(o&&(0,Wf.applyOverridesToStudy)(e,o),i&&e.setUserEditEnabled(!1),e.id())))}waitForStudyCreated(e){return this._chartWidget.model().model().waitForStudy(e)}compileFailedStudies(){return this._chartWidget.model().model().studiesWV().value().filter((e=>e.isPine()&&e.hasCompileError()))}getStudyById(e){const t=this._chartWidget.model().model().getStudyById(e);if(null===t)throw new Error("There is no such study");return this._getStudyApi(t)}getSeries(){const e=this._chartWidget.model(),t=e.mainSeries();return new ly(t,e)}createShape(e,t){return this._createMultipointShape(this._convertUserPointsToDataSource([e]),t)}async createMultipointShape(e,t){return this._createMultipointShape(this._convertUserPointsToDataSource(e),t)}getShapeById(e){const t=this._chartWidget.model().model().getLineToolById(e);if(null===t)throw new Error("There is no such shape");return this._getLineDataSourceApi(t)}removeEntity(e,t){const i=this._chartWidget.model().model().dataSourceForId(e);i?t&&t.disableUndo?$r(this._chartWidget.model().model(),[i]):this._chartWidget.model().removeSource(i,!0,!0):console.warn(`Can't find a source with id: ${e}`)}removeEntityWithUndo(e){const t=this._chartWidget.model().model().dataSourceForId(e);t&&this._chartWidget.model().removeSource(t,!1)}removeAllShapes(){this._chartWidget.removeAllDrawingTools()}removeAllStudies(){this._chartWidget.removeAllStudies()}selection(){return null===this._selectionApi&&(this._selectionApi=new hy.SelectionApi(this._chartWidget.model().model())),this._selectionApi}showPropertiesDialog(e){const t=this._chartWidget.model().model().dataSourceForId(e);if(null===t)throw new Error(`Study or shape ${e} does not exist`);this._chartWidget.showChartPropertiesForSource(t)}createStudyTemplate(e){return this._chartWidget.model().model().studyTemplate(e.saveSymbol,e.saveInterval)}applyStudyTemplate(e){this._chartWidget.model().applyStudyTemplate(e,""+1e3*Math.random())}drawOnAllCharts(e){(0,mt.drawOnAllCharts)().setValue(e)}createOrderLine(){throw new Error("createOrderLine is only available on Trading Platform")}createPositionLine(){throw new Error("createPositionLine is only available on Trading Platform")}createExecutionShape(){throw new Error("createExecutionShape is only available on Trading Platform")}symbol(){return this._chartWidget.symbolWV().value()}symbolExt(){const e=this._chartWidget.model().mainSeries().symbolInfo();if(null===e)return null;const t=((e,t)=>{const i={};return t.forEach((t=>{void 0!==e[t]&&(i[t]=e[t])})),i
})(e,["name","base_name","ticker","description","long_description","type","session","session_display","session_holidays","corrections","exchange","exchange","listed_exchange","timezone","format","pricescale","minmov","fractional","minmove2","variable_tick_size","has_intraday","supported_resolutions","intraday_multipliers","has_seconds","has_ticks","seconds_multipliers","has_daily","daily_multipliers","has_weekly_and_monthly","weekly_multipliers","monthly_multipliers","has_empty_bars","visible_plots_set","volume_precision","data_status","delay","expired","expiration_date","sector","industry","currency_code","original_currency_code","unit_id","original_unit_id","unit_conversion_types","subsession_id","subsessions","price_source_id","price_sources","logo_urls","exchange_logo","pro_name","library_custom_fields"]);return t.pro_name=e.pro_name,t}resolution(){return this._chartWidget.model().mainSeries().interval()}marketStatus(){return this._chartWidget.model().mainSeries().marketStatusModel().currentSession().spawn()}getVisibleRange(){const e={from:0,to:0},t=this._chartWidget.model().timeScale(),i=t.visibleBarsStrictRange();if(null===i)return e;const s=i.firstBar(),o=i.lastBar(),r=this._convertIndexToPublicTime(o);if(null===r)return e;const a=Math.max((0,n.ensureNotNull)(t.points().range().value()).firstIndex,s);return e.from=(0,n.ensureNotNull)(this._convertIndexToPublicTime(a)),e.to=r,e}getVisibleBarsRange(){const e=this._chartWidget.model().timeScale();if(null===e.visibleBarsStrictRange())return null;let t=this.chartModel().mainSeries().data();for(const e of this.chartModel().dataSources())if((0,An.isPriceDataSource)(e)&&e.isVisible()){const i=e.barsProvider().bars(),s=i.last(),o=t.last();null!==s&&null!==o&&s.index>o.index&&(t=i)}const i=e.visibleStrictDataRange(t);if(null===i)return null;const s=this._convertIndexToPublicTime(i.firstBar()),o=this._convertIndexToPublicTime(i.lastBar());return null===s||null===o?null:{from:s,to:o}}getVisiblePriceRange(){if(console.warn("`getVisiblePriceRange` is deprecated. Use Price Scale API instead"),!this._chartWidget.model().mainSeries())return null;return this._chartWidget.model().mainSeries().priceScale().priceRangeInPrice()}scrollPosition(){return console.warn("`scrollPosition` is deprecated. Use rightOffset from Time Scale API instead"),this._chartWidget.model().timeScale().rightOffset()}defaultScrollPosition(){return console.warn("`defaultScrollPosition` is deprecated. Use defaultRightOffset from Time Scale API instead"),this._chartWidget.model().timeScale().defaultRightOffset().value()}priceFormatter(){return this._chartWidget.model().mainSeries().priceScale().formatter()}chartType(){return this._chartWidget.model().mainSeries().properties().childs().style.value()}setTimezone(e){this._chartWidget.setTimezone(e)}getTimezone(){return this._chartWidget.getTimezone()}getTimezoneApi(){return this._timezoneApi}getPanes(){return this._chartWidget.model().model().panes().map((e=>this._getPaneApi(e)))}exportData(e){
if(!l.enabled("charting_library_export_chart_data"))return Promise.reject("Data export is not supported");const t={...e};return void 0!==t.from&&(t.from=this._convertTimeFromPublic(t.from)),void 0!==t.to&&(t.to=this._convertTimeFromPublic(t.to)),Promise.all([i.e(2578),i.e(9498)]).then(i.bind(i,99207)).then((e=>e.exportData(this._chartWidget.model().model(),t)))}setDragExportEnabled(e){l.enabled("chart_drag_export")?this._chartWidget.model().model().setDragExportEnabled(e):console.error("feature is not enabled")}canZoomOut(){return!this._chartWidget.model().zoomStack().isEmpty()}canZoomOutWV(){if(!this._zoomUndoStackIsNotEmpty){const e=new O.WatchedValue(!1);this._zoomUndoStackIsNotEmpty=e.spawn(),this._chartWidget.withModel(this,(()=>{const t=this._chartWidget.model().zoomStack();t.onChange().subscribe(this,(()=>e.setValue(!t.isEmpty())))}))}return this._zoomUndoStackIsNotEmpty.readonly()}zoomOut(){this.canZoomOut()&&this._chartWidget.model().zoomFromViewport()}setZoomEnabled(e){this._chartWidget.model().model().setZoomEnabled(e)}setScrollEnabled(e){this._chartWidget.model().model().setScrollEnabled(e)}shapesGroupController(){return new _y(this._chartWidget.model().lineToolsGroupController(),this._chartWidget.model().model())}isSelectBarRequested(){return this._chartWidget.selectPointMode().value()!==mt.SelectPointMode.None}requestSelectBar(){return this.isSelectBarRequested()?Promise.reject("already requested"):new Promise(((e,t)=>{this._chartWidget.requestSelectPoint({pointType:"time"}).then((t=>{e(this._convertTimeToPublic((0,n.ensureDefined)(t.point.time)))})).catch((()=>{t("cancelled")}))}))}cancelSelectBar(){this.isSelectBarRequested()&&this._chartWidget.cancelRequestSelectPoint()}barTimeToEndOfPeriod(e){const t=this._prepareEndOfPeriodArgs();return zf(t.barBuilder,e,t.intervalObj)}endOfPeriodToBarTime(e){const t=this._prepareEndOfPeriodArgs();return function(e,t,i){if(i.isDays())return t;const s=1e3*t-1;if(e.moveTo(s),i.isIntraday()){const i=e.indexOfBar(s);if(i<0)throw new Error(`${t} is out of the instrument session `);return e.startOfBar(i)/1e3}return e.startOfBar(0)/1e3}(t.barBuilder,e,t.intervalObj)}createAnchoredShape(e,t){const i=()=>new Error(`Cannot create "${t.shape}" shape`),s=t.shape;if(Nf(s)&&!0!==Of[s].isAnchored)throw console.warn(`${s} is not an anchored shape. It can be created using createShape or createMultipointShape`),i();const o=this._chartWidget.model().model(),n=o.mainSeries();if(o.timeScale().isEmpty())throw i();const r=void 0!==t.ownerStudyId?o.dataSourceForId(t.ownerStudyId):n,a=this._convertPositionPercentToDataSource(e,r);if(null===a)throw i();return this._createMultipointShape([a],t)}properties(){return this._chartWidget.properties()}setBarSpacing(e){this._chartWidget.model().timeScale().setBarSpacing(e)}scrollChartByBar(e){this._chartWidget.model().scrollChartByBar(e)}mergeAllScales(e){this._chartWidget.model().mergeAllScales(e)}chartPainted(){return this._chartWidget.chartPainted()}applyOverrides(e){this._chartWidget.applyOverrides(e)}addOverlayStudy(e,t,i){
return this._chartWidget.addOverlayStudy(e,t,i)}lineToolsSynchronizer(){return this._chartWidget.lineToolsSynchronizer()}cloneLineTool(e){const t=this._chartWidget.model(),i=t.model().dataSourceForId(e);return t.cloneLineTools([i],!1)[0]}shareLineTools(e,t){const i=this._chartWidget.model(),s=e.map((e=>i.model().dataSourceForId(e)));i.shareLineTools(s,t)}getLollipopSourcesApi(){throw new Error("getLollipopSourcesApi is not supported")}clickAtLatestUpdatesLollipop(){throw new Error("clickAtLatestUpdatesLollipop is not supported")}linkingGroupIndex(){return this._apiLinkingGroupIndex.spawn()}loadingScreenActive(){return this._chartWidget.screen.isShown()}symbolResolvingActive(){for(const e of this._chartWidget.model().model().symbolSources())if(e.symbolResolvingActive().value())return!0;return!1}hasModel(){return this._chartWidget.hasModel()}disableAllUtilitySources(){0}chartProto(){return kg.prototype}ranges(){throw new Error("not implemented")}getTimeScale(){return new Uf(this._chartWidget.model().timeScale())}async loadChartTemplate(e){await(0,Vf.loadTheme)(this._chartWidget.chartWidgetCollection(),{themeName:e,standardTheme:!1,noUndo:!1,onlyActiveChart:!0})}setTimeFrame(e){this.setActive(),this._chartWidget.loadRange(e)}async syncTime(e){if(this._chartWidget.hasModel()){const t=this._chartWidget.model().model(),i=t.mainSeries().syncModel();if(i)return t.syncTimeWithModel(i.syncSourceTarget(),e)}}syncDateRange(e,t){this._chartWidget.hasModel()&&this._chartWidget.model().model().gotoTimeRange(e,t)}getLineToolsState(e=1,t,i){this._canUseLineToolsSynchronizer("getLineToolsState");const s=i??!0,o=(0,n.ensureNotNull)(this.lineToolsSynchronizer()).getDTO(e,t,s);return delete o.clientId,o}async applyLineToolsState(e){this._canUseLineToolsSynchronizer("applyLineToolsState"),await(0,n.ensureNotNull)(this.lineToolsSynchronizer()).applyDTO(e)}reloadLineToolsFromServer(){this._canUseLineToolsSynchronizer("reloadLineToolsFromServer"),(0,n.ensureNotNull)(this.lineToolsSynchronizer()).reloadAllLineTools()}studyMetaIntoRepository(){return(0,os.studyMetaInfoRepository)()}replayStatus(){return this._chartWidget.model().model().replayStatus()}replayStudyStrategyProperties(){return this._chartWidget.model().model().replayStudyStrategyProperties()}insertStudyWithoutCheck(e,t,i,s,o){return this._chartWidget.model().insertStudyWithoutCheck(new ns.StudyMetaInfo(e,o),t,i,s)}copyEntityToClipboard(e){const t=this._chartWidget.model().model().dataSourceForId(e);t&&this._chartWidget.chartWidgetCollection().clipboard.uiRequestCopy([t])}pasteFromClipboard(){this._chartWidget.chartWidgetCollection().clipboard.uiRequestPaste()}inactivityGaps(){return this._chartWidget.model().model().inactivityGaps()}setInactivityGapsSession(e){this._chartWidget.model().model().setInactivityGapsSession(e)}_destroy(){this._zoomUndoStackIsNotEmpty?.destroy(),this._chartWidget.hasModel()&&(this._chartWidget.model().crosshairSource().moved().unsubscribeAll(this),this._chartWidget.model().timeScale().logicalRangeChanged().unsubscribe(this,this._onLogicalRangeChanged),
this._chartWidget.model().zoomStack().onChange().unsubscribeAll(this)),this._chartWidget.modelCreated().unsubscribeAll(this),this._widgetLinkingGroupIndex.destroy()}async _createTradingPrimitive(e){const t=this._chartWidget.model(),i=t.model(),s=(0,n.ensureNotNull)(i.paneForSource(i.mainSeries()));await(0,xo.ensureLineToolLoaded)(e);const o={pane:s,point:(()=>{const e=(0,n.ensureNotNull)(t.mainSeries().bars().last());return{index:e.index,price:e.value[4],interval:i.mainSeries().interval()}})(),linetool:e,actionSource:"API"};return i.createLineTool(o).adapter()}_createStudy(e){return Promise.reject("Pine Script® and java studies are not supported")}_convertTimeToPublic(e){return this._getTimeConverter().convertInternalTimeToPublicTime(e)}_convertIndexToPublicTime(e){return null===this._chartWidget.model().mainSeries().symbolInfo()?null:this._getTimeConverter().convertTimePointIndexToPublicTime(e)}_convertPositionPercentToDataSource(e,t){const i=this._chartWidget.model().timeScale(),s=t.priceScale(),o=t.firstValue();if(null==o||!isFinite(o)||null===s)return null;const n=i.coordinateToIndex(e.x*i.width());return{price:s.coordinateToPrice(e.y*s.height(),o),index:n}}_convertUserPointsToDataSource(e){const t=this._chartWidget.model().model(),i=t.mainSeries(),s=t.timeScale().points(),o=i.data();if(t.timeScale().isEmpty())return null;const r=e.map((e=>e.time||0)),a=this._alignPoints(r),l=(e,t,r)=>{const a=s.closestIndexLeft(e)||0,l={index:a,price:NaN},c=(0,n.ensureNotNull)(s.valueAt(a)),h=(0,n.ensureNotNull)(s.range().value());if(e>c&&a===h.lastIndex){const t=(0,n.ensureNotNull)(i.syncModel()).distance(c,e);t.success&&(l.index=l.index+t.result)}else if(e<c&&a===h.firstIndex){const t=(0,n.ensureNotNull)(i.syncModel()).distance(e,c);t.success&&(l.index=l.index-t.result)}if((0,tt.isNumber)(t))l.price=t;else{let e=r?["open","high","low","close"].indexOf(r)+1:1;e<=0&&(e=1),l.price=(0,n.ensure)((0,n.ensureNotNull)(o.valueAt(a))[e])}return l},c=[];for(let t=0;t<e.length;t++){const i=e[t];c.push(l(a[t],i.price,i.channel))}return c}async _createMultipointShape(e,t){const i=()=>new Error(`Cannot create "${s.shape}" shape`),s=Object.assign({},{filled:!0},t),o=Of[s.shape]||Of.flag;const r=this._chartWidget.model().model(),a=r.mainSeries();if(r.timeScale().isEmpty())throw i();const l=void 0!==s.ownerStudyId?r.dataSourceForId(s.ownerStudyId)??a:a,c=r.paneForSource(l);if(null===e||null===c)throw i();if(o.onlySelectable)throw new Error(`Cannot create "${s.shape}" shape`);if("LineToolIcon"===o.name){const e=s;if(e.icon=e.icon||e.overrides&&e.overrides.icon,!s.hasOwnProperty("icon"))throw new Error("icon must be specified in options");e.overrides=e.overrides||{},e.overrides.icon=e.icon}await(0,xo.ensureLineToolLoaded)(o.name);const h=(0,zs.createLineToolProperties)(r.backgroundTheme().spawnOwnership(),o.name,!r.readOnly());if((0,zs.prepareLineToolPropertiesByOwnerSource)(h,l),s.overrides)for(const e in s.overrides)h.hasChild(e)?(0,
n.ensureDefined)(h.child(e)).mergeAndFire(s.overrides[e]):ny(o.name)&&-1!==["profitLevel","stopLevel"].indexOf(e)&&h.addProperty(e,s.overrides[e]);let d;void 0!==h.hasChild("text")&&s.text&&(0,n.ensureDefined)(h.child("text")).setValue(s.text),h.hasChild("filled")&&s.filled&&(0,n.ensureDefined)(h.child("filled")).setValue(!0),d=s.disableUndo?this._chartWidget.model().model():this._chartWidget.model();const u=d.createLineTool({pane:c,point:e[0],linetool:o.name,properties:h,ownerSource:l,actionSource:"API"});if(null===u)throw h.destroy(),i();if(u.properties()!==h&&h.destroy(),ny(o.name)){if(e.length>2)throw new Error(`Wrong points count for ${s.shape}. Required 1 or 2`);2===e.length&&(u.startChanging(1,e[1]),u.setPoint(1,e[1]),u.endChanging(!0,!1))}else{const t=u.pointsCount();if(t!==e.length&&-1!==t)throw new Error(`Wrong points count for ${s.shape}. Required ${t}`);const i=new To.EnvironmentState(void 0,!0),n=(0,Lt.isLineDrawnWithPressedButton)(o.name);for(let t=1;t<e.length&&this._chartWidget.model().lineBeingCreated();t++)u.setLastPoint(e[t]),d.continueCreatingLine(e[t],i,t<e.length-1||n);(0,Lt.isLineToolFinishRequiredWhenCreatedByApi)(o.name)&&(u.finish(),d.finishLineTool(u),d.continueCreatingLine(e[e.length-1],i,!1))}if(s.lock&&u.setUserEditEnabled(!1),s.disableSelection&&u.setSelectionEnabled(!1),s.disableSave&&(void 0===u.customization&&(u.customization={}),u.customization.disableSave=!0),s.hasOwnProperty("showInObjectsTree")&&(void 0===u.customization&&(u.customization={}),u.customization.showInObjectsTree=s.showInObjectsTree),s.zOrder){const e=this._chartWidget.model().availableZOrderOperations([u]);"top"===s.zOrder&&e.bringToFrontEnabled?d.bringToFront([u]):"bottom"===s.zOrder&&e.sendToBackEnabled&&d.sendToBack([u])}return u.id()}_convertTimeFromPublic(e){return this._getTimeConverter().convertPublicTimeToInternalTime(e)}_getTimeConverter(){const e=this._chartWidget.model().mainSeries();return(0,On.getChartWidgetApiTimeConverter)(e.interval(),(0,n.ensureNotNull)(e.symbolInfo(),"main series symbol info"),this._chartWidget.model().model())}_onHoveredSourceChanged(e){const t=null!==e&&(0,An.isPriceDataSource)(e)?e.id():null,i=this._prevHoveredSourceId;this._prevHoveredSourceId=t,t!==i&&this._dataSourceHovered.fire(t)}_onCrosshairMoved(e){const t=this.chartModel().crosshairSource().pane;if(null===t)return;const i=this._chartWidget.offsetInDocument(t),s=this.chartModel().timeScale(),o=t.mainDataSource()?.priceScale(),n=s.indexToUserTime(e.index),r=this._convertIndexToPublicTime(e.index),a=s.indexToCoordinate(e.index),l=o?.priceToCoordinate(e.price,t.mainDataSource()?.firstValue()||0);if(void 0===a||void 0===l||null===n||null===r)return;const c={price:e.price,time:r,userTime:n.getTime()/1e3,entityValues:{},offsetX:a+i.left,offsetY:l+i.top},h=this.chartModel().priceDataSources(),d=(0,wi.sourceChangeEvent)(this._chartWidget.model().crosshairSource().id());for(let e=0;e<h.length;e++){const t=h[e],i=t.dataWindowView();if(null===i)continue;i.update(d)
;const s=t===this.chartModel().hoveredSource(),o=i.items().filter((e=>e.visible()&&0!==e.title().length)).map((e=>({title:e.title(),value:e.value()})));c.entityValues[t.id()]={isHovered:s,values:o,title:i.header()}}this._crosshairMoved.fire(c)}_makeSubscriptionFromDelegate(e){return{subscribe:e.subscribe.bind(e),unsubscribe:e.unsubscribe.bind(e),unsubscribeAll:e.unsubscribeAll.bind(e)}}_prepareEndOfPeriodArgs(){const e=this._chartWidget.model().model(),t=e.timezone(),i=(0,n.ensureNotNull)(e.mainSeries().symbolInfo()),s=e.mainSeries().interval(),o=new Cd.SessionInfo(t,i.session,i.session_holidays,i.corrections);return{barBuilder:(0,Td.newBarBuilder)(s,o,o),intervalObj:Re.Interval.parse(s)}}_getPaneApi(e){let t=this._panes.get(e);return void 0===t&&(t=new Xf(e,this._chartWidget),this._panes.set(e,t)),t}_getStudyApi(e){let t=this._studies.get(e);return void 0===t&&(t=new iy(e,this._chartWidget),this._studies.set(e,t)),t}_getLineDataSourceApi(e){let t=this._lineDataSources.get(e);return void 0===t&&(t=new ay(e,this._chartWidget.model(),{apiPointsToDataSource:this._convertUserPointsToDataSource.bind(this),dataSourcePointsToPriced:e=>{const t=(0,n.ensureNotNull)(this._chartWidget.model().mainSeries().syncModel()),i=this._chartWidget.model().timeScale();return e.map((e=>{const s=i.normalizeBarIndex(e.index);return{price:e.price,time:this._convertTimeToPublic(t.projectTime(s.time_t,s.offset))}}))}}),this._lineDataSources.set(e,t)),t}_alignPoints(e){const t=this._chartWidget.model().model(),i=t.mainSeries(),s=i.interval(),o=i.symbolInfo();if(t.timeScale().isEmpty()||!Re.Interval.isDWM(s)||null===o)return e;const n=(0,Jd.createDwmAligner)(s,o);return null===n?e:e.map((e=>n.timeToSessionStart(1e3*e)/1e3))}_onLogicalRangeChanged(){const e=this._chartWidget.model().mainSeries(),t=e.data().isEmpty();if(null!==this._chartWidget.model().timeScale().visibleBarsStrictRange()&&t)return void e.dataEvents().completed().subscribe(this,this._onLogicalRangeChanged,!0);const i=this.getVisibleRange();null!==this._prevVisibleRange&&(0,tt.deepEquals)(this._prevVisibleRange,i)[0]||(this._prevVisibleRange=i,this._visibleBarsChanged.fire(i))}_canUseLineToolsSynchronizer(e){if(!l.enabled("saveload_separate_drawings_storage"))throw new Error(`${e} can only be used when 'saveload_separate_drawings_storage' featureset is enabled`)}_onSymbolChanged(e){var t;this._onSymbolChangedDelegate.fire({name:(t=e).name,base_name:t.base_name,ticker:t.ticker,description:t.description,long_description:t.long_description,type:t.type,session:t.session,session_display:t.session_display,session_holidays:t.session_holidays,corrections:t.corrections,exchange:t.exchange,listed_exchange:t.listed_exchange,timezone:t.timezone,format:t.format,pricescale:t.pricescale,minmov:t.minmov,fractional:t.fractional,minmove2:t.minmove2,variable_tick_size:t.variable_tick_size,has_intraday:t.has_intraday,supported_resolutions:t.supported_resolutions,intraday_multipliers:t.intraday_multipliers,has_seconds:t.has_seconds,has_ticks:t["is-tickbars-available"],
seconds_multipliers:t.seconds_multipliers,build_seconds_from_ticks:t.build_seconds_from_ticks,has_daily:t.has_daily,daily_multipliers:t.daily_multipliers,has_weekly_and_monthly:t.has_weekly_and_monthly,weekly_multipliers:t.weekly_multipliers,monthly_multipliers:t.monthly_multipliers,has_empty_bars:t.has_empty_bars,visible_plots_set:t.visible_plots_set,volume_precision:t.volume_precision,data_status:t.data_status,delay:t.delay,expired:t.expired,expiration_date:t.expiration_date,sector:t.sector,industry:t.industry,currency_code:t.currency_code,original_currency_code:t.original_currency_code,unit_id:t.unit_id,original_unit_id:t.original_unit_id,unit_conversion_types:t.unit_conversion_types,subsession_id:t.subsession_id,subsessions:t.subsessions,price_source_id:t.price_source_id,price_sources:t.source2?[t.source2]:[],logo_urls:t.library_custom_fields?.logo_urls,exchange_logo:t.library_custom_fields?.exchange_logo,library_custom_fields:t.library_custom_fields})}}var vy=i(52092);class Sy{loginRequired(){throw new Error("Not implemented")}onGoProDialog(e,t){throw new Error("Not implemented")}}function by(){throw new Error("not implemented")}function wy(e){const t=new O.WatchedValue(e.value()),i=t=>{(0,yi.allowSavingDefaults)(!0),e.setValue(t),(0,yi.allowSavingDefaults)(!1)};return t.subscribe(i),e.subscribe(t,(()=>{t.setValue(e.value())})),t.spawn((()=>{e.unsubscribeAll(t),t.unsubscribe(i)}))}class Cy extends Sy{constructor(e){super(),this.linking=de.linking,this._lockDrawingsWatchedValue=null,this._hideDrawingsWatchedValue=null,this._hideIndicatorsWatchedValue=null,this._studyTemplatesDrawer=null,this._fontIconsSettingsDrawer=null,this._favoriteDrawingsToolbar=null,this._webview=null,this._activeChartWidgetWV=new O.WatchedValue(null),this._activeChartRangeState=new Bf.WatchedObject({ranges:[]}),this._themesApi=null,this._newsApiDeferredPromise=null,this._newsApiRejectionReason=null,this._watchlistApiDeferredPromise=null,this._watchlistApiRejectionReason=null,this._widgetbarApiDeferredPromise=null,this._widgetbarApiRejectionReason=null,this._isDestroyed=!1,this._widgebarApi=null,this._chartWidgets=new WeakMap,this._layoutSettingsDrawer=null,this._magnetEnabledWV=null,this._magnetModeWV=null,this._magnetSnapsToIndicatorsWV=null,this._drawOnAllCharts=(0,ye.convertPropertyToWatchedValue)((0,mt.drawOnAllCharts)()),this._replayApi=null,this._pineEditorApi=null,this._backtestingStrategyApi=null,this._supportTicketData=null,this._activeChartWidgetChangedDelegate=new ae.Delegate,this._alerts=null,this._activateChart=e=>{this.setActiveChart(this._chartIndex(e))};const{chartApiInstance:t,chartWidgetCollection:i,studyMarket:s,saveChartService:o,loadChartService:n,sharingChartService:r=null,webview:a=null,favoriteServices:l,alertsServices:c,supportTicketData:h=null}=e;this._chartApiInstance=t,this._chartWidgetCollection=i,this._studyMarket=s,this._saveChartService=o,this._sharingChartService=r,this._loadChartService=n,this._favoriteServices=l,this._intervalsService=null,this._alertsWidgetDialog=null,this._detailsDialogController=null,
this._supportedChartStylesSpawn=de.linking.supportedChartStyles.spawn(),this._chartWidgetCollection.onAboutToBeDestroyed.subscribe(null,(()=>this.destroy()),!0),this._webview=a,this._alertService=null,this._supportTicketData=h;const d=i.lock;this._symbolSync=d.symbol.spawn(),this._intervalSync=d.interval.spawn(),this._dateRangeSync=d.dateRange.spawn(),this._crosshairSync=d.crosshair.spawn(),this._timeSync=d.trackTime.spawn(),this._chartWidgetCollection.activeChartWidget.subscribe((()=>this._onActiveChartChanged()),{callWithLast:!0}),ee.subscribe("toggle_currency_menu_inner",((...e)=>{this._toggleUnitConversionMenu("toggle_currency_menu",...e)}),this),ee.subscribe("toggle_unit_menu_inner",((...e)=>{this._toggleUnitConversionMenu("toggle_unit_menu",...e)}),this)}destroy(){this._supportedChartStylesSpawn.destroy(),this._intervalsService?.destroy(),this._themesApi?.destroy(),this._widgebarApi?.destroy(),this._widgetbarApiRejectionReason="This ITradingViewApi instance has been destroyed",this._symbolSync.destroy(),this._intervalSync.destroy(),this._dateRangeSync.destroy(),this._crosshairSync.destroy(),this._timeSync.destroy(),this._drawOnAllCharts.destroy(),this._pineEditorApi?.destroy(),this._isDestroyed=!0,this._magnetEnabledWV?.destroy(),this._magnetModeWV?.destroy(),this._magnetSnapsToIndicatorsWV?.destroy(),ee.unsubscribeAll("toggle_currency_menu_inner",this),ee.unsubscribeAll("toggle_unit_menu_inner",this)}themes(){return null===this._themesApi&&(this._themesApi=new Rf({chartWidgetCollection:this._chartWidgetCollection})),this._themesApi}dialogs(){return{Indicators:this._studyMarket,Compare:this._chartWidgetCollection.getCompareDialogRenderer(),ObjectsTree:null,ChartProperties:this._chartWidgetCollection.getChartPropertiesDialogRenderer(),ChartLayoutSaveAs:this._saveChartService?.getSaveAsController()??null,ChartLayoutRename:this._saveChartService?.getRenameController()??null,ChartLayoutCreate:this._saveChartService?.getCreateController()??null,ChartLayoutLoad:this._loadChartService,Alerts:this._alertsWidgetDialog,Details:this._detailsDialogController,FinancialsCharts:null,Technicals:null,Forecast:null}}subscribe(e,t){ee.subscribe(e,t,void 0)}unsubscribe(e,t){ee.unsubscribe(e,t,void 0)}onActiveChartChanged(){return this._activeChartWidgetChangedDelegate}webview(){return by(),this._webview}connect(){by()}disconnect(){by()}onConnectionStatusChanged(e){by()}isConnected(){by()}supportTicketData(){return this._supportTicketData}setPublishChartOptions(e){by()}publishChart(e){by()}studyTemplatesDrawerApi(){by()}fontIconsSettingsDrawer(){by()}intervalsService(){by()}alertService(){by()}async alerts(){by()}supportedChartTypes(){return this._supportedChartStylesSpawn}setBrokerName(e){this._chartWidgetCollection.setBroker(e)}getDrawOnAllCharts(){return(0,mt.drawOnAllCharts)().value()}drawOnAllCharts(e){return(0,mt.drawOnAllCharts)().setValue(e)}drawOnAllChartsEnabled(){return this._drawOnAllCharts}getDrawOnAllChartsMode(){return(0,mt.drawOnAllChartsMode)().value()}drawOnAllChartsMode(e){(0,mt.drawOnAllChartsMode)().setValue(e)
}currencies(){return this._chartApiInstance?.availableCurrencies()??Promise.reject()}units(){return this._chartApiInstance?.availableUnits()??Promise.reject()}disableTrackingEvents(){(0,re.disableTrackingEvents)()}getSaveChartService(){return this._saveChartService}symbolSync(){return this._symbolSync}intervalSync(){return this._intervalSync}dateRangeSync(){return this._dateRangeSync}crosshairSync(){return this._crosshairSync}timeSync(){return this._timeSync}setSymbolSearchUI(e){by()}chart(e=0){if(e<0||e>=this.chartsCount())throw Error("Incorrect index: "+e);return this._getChartWidgetApi(this._chartWidgetCollection.getAll()[e])}*charts(){for(let e=0;e<this.chartsCount();e++)yield this.chart(e)}activeChart(){return this._getChartWidgetApi(this._activeChartWidget())}activeChartRangesState(){return this._activeChartRangeState}setActiveChart(e){if(e>=0&&e<this.chartsCount()){const t=this._chartWidgetCollection.getAll()[e];t&&(this._activeChartWidget().inFullscreen()?t.requestFullscreen():this._chartWidgetCollection.activeChartWidget.setValue(t))}}async replayApi(){by()}async backtestingStrategyApi(){if(by(),null===this._chartApiInstance)throw new Error("backtesting api isn't available");if(null===this._backtestingStrategyApi){await Promise.all(this._chartWidgetCollection.getAll().map(waitForModel));const{facade:e}=await getBacktestingStrategyFacadeInstance(this._chartWidgetCollection);this._backtestingStrategyApi=e}return this._backtestingStrategyApi}pineEditorApi(){by()}activeChartIndex(){return this._chartIndex(this._activeChartWidget())}chartsCount(){return ut.layouts[this.layout()].count}layout(){return this._chartWidgetCollection.layout.value()}layoutName(){return this._chartWidgetCollection.metaInfo.name.value()}layoutNameWatchedValue(){return this._chartWidgetCollection.metaInfo.name.readonly()}async layoutSettingsDrawer(){by()}setLayout(e,t){t?.withUndo?this._chartWidgetCollection.setChartLayoutWithUndo(e):this._chartWidgetCollection.setLayout(e)}resetLayoutSizes(e){throw new Error("Unsupported. This API is only applicable to the Trading Edition of the library")}setLayoutSizes(e,t){throw new Error("Unsupported. This API is only applicable to the Trading Edition of the library")}unloadUnusedCharts(){throw new Error("Unsupported. This API is only applicable to the Trading Edition of the library")}moveActiveChart(e){this._chartWidgetCollection.moveActiveChartWithUndo(e)}async openPublicationViewPopup(e){0}async closePublicationViewPopup(){0}undoRedoState(){return this._chartWidgetCollection.undoHistory.state()}clearUndoHistory(){return this._chartWidgetCollection.undoHistory.clearStack()}undo(){this._chartWidgetCollection.undoHistory.undo()}redo(){this._chartWidgetCollection.undoHistory.redo()}async selectLineTool(e,t,i){if(!Nf(e))return;const s=Of[e].name;if("icon"===e){const e=t?.icon;void 0!==e&&mt.iconTool.setValue(e)}if(await(0,zs.initLineTool)(s),"emoji"===e){const e=t?.emoji;void 0!==e&&mt.emojiTool.setValue(e)}if("sticker"===e){const e=t?.sticker;void 0!==e&&mt.stickerTool.setValue(e)}mt.tool.setValue(s),
(0,wn.trackDrawingToolSelected)(s,i)}favoriteDrawingsToolbar(){return i.e(5551).then(i.bind(i,46973)).then((e=>(this._favoriteDrawingsToolbar||(this._favoriteDrawingsToolbar=new e.FavoriteDrawingsApi),this._favoriteDrawingsToolbar)))}sharingChart(){return this._sharingChartService}watchlist(){by()}setWatchlistApiPromise(e){by()}news(){by()}setNewsApiPromise(e){by()}widgetbar(){by()}setWidgetbarApiPromise(e){by()}getChartStorage(){return getChartStorage()}setDebugMode(e){l.setEnabled("charting_library_debug_mode",e)}setFeatureEnabled(e,t){"chart_crosshair_menu"!==e?l.setEnabled(e,t):lu.addPlusButtonProperty.setValue(t)}magnetEnabled(){return null===this._magnetEnabledWV&&(this._magnetEnabledWV=wy((0,mt.properties)().childs().magnet)),this._magnetEnabledWV}magnetMode(){return null===this._magnetModeWV&&(this._magnetModeWV=wy((0,mt.properties)().childs().magnetMode)),this._magnetModeWV}magnetSnapsToIndicators(){return null===this._magnetSnapsToIndicatorsWV&&(this._magnetSnapsToIndicatorsWV=wy((0,mt.properties)().childs().magnetSnapsToIndicators)),this._magnetSnapsToIndicatorsWV}flushBufferedData(){Ff.fire()}chartWidgetCollectionState(e){return this._chartWidgetCollection.state(e)}chartWidgetCollectionSeriesStatuses(){return this._chartWidgetCollection.chartSeriesStatuses()}watermark(){{const e=P_.getInstance();if(!e.ready())throw new Error("Watermark API is not initialised yet.");return e}}setContextMenuOptions(e){Cy.setContextMenuOptions(e)}changeSymbol(e,t,i,s="API"){de.linking.setIntervalAndLogInitiator((0,n.ensureNotNull)(Re.Interval.normalize(t)),s),de.linking.setSymbolAndLogInitiator(e,s),i&&this.activeChart().onDataLoaded().subscribe(null,i,!0)}closePopupsAndDialogs(){Io.ContextMenuManager.hideAll(),ee.emit(vy.CLOSE_POPUPS_AND_DIALOGS_COMMAND)}startFullscreen(){return this._chartWidgetCollection.startFullscreen()}exitFullscreen(){return this._chartWidgetCollection.exitFullscreen()}getFavoriteChartStylesService(){by()}getFavoriteIntervalsService(){by()}getFavoriteCurrencyUnitConversionApi(){by()}getIntervals(){let e=[];const t=(0,ht.getCustomResolutions)();return null!==this._chartApiInstance&&(e=this._chartApiInstance.defaultResolutions()),(0,ht.mergeResolutions)(e,t)}getLinetoolsFavoritesStore(){by()}getSavedCharts(e){z.backend.getCharts().then(e)}getStudiesList(){return(0,n.ensureNotNull)(this._chartApiInstance).allStudiesMetadata().filter((e=>!e.is_hidden_study)).map((e=>e.description))}getStudyInputs(e){return Qf(ns.StudyMetaInfo.findStudyMetaInfoByDescription((0,n.ensureNotNull)(this._chartApiInstance).allStudiesMetadata(),e))}getStudyStyles(e){return ey(ns.StudyMetaInfo.findStudyMetaInfoByDescription((0,n.ensureNotNull)(this._chartApiInstance).allStudiesMetadata(),e))}getSymbolInterval(e){const t={symbol:this.linking.proSymbol.value(),interval:this.linking.interval.value()};return e?.(t),t}hasChartChanges(){return this._chartWidgetCollection.hasChanges()}async loadChart(e){{this._chartApiInstance?.disconnect(),e.extendedData&&(this._chartWidgetCollection.metaInfo.id.setValue(e.extendedData.uid),
this._chartWidgetCollection.metaInfo.uid.setValue(e.extendedData.uid),this._chartWidgetCollection.metaInfo.name.setValue(e.extendedData.name));const t=await this._chartWidgetCollection.loadContent(e.json);this._chartWidgetCollection.unloadUnusedCharts(),this._chartApiInstance?.connect(),de.linking.setSymbolAndLogInitiator(this.activeChart().symbol(),"API"),ee.emit("chart_loaded"),t.contentMigrated&&ee.emit("chart_migrated")}}async loadChartFromServer(e){await(this._loadChartService?.loadChart(e,!1))}async loadLayoutFromServerByLayoutId(e,t,i){await(this._loadChartService?.loadChartByUrl(e,!!t,i))}layoutId(){return this._chartWidgetCollection.metaInfo.uid.value()}async createNewLayout(e){by()}lockAllDrawingTools(){return null===this._lockDrawingsWatchedValue&&(this._lockDrawingsWatchedValue=new O.WatchedValue((0,mt.lockDrawings)().value()),this._lockDrawingsWatchedValue.subscribe((e=>{(0,mt.lockDrawings)().setValue(e)})),(0,mt.lockDrawings)().subscribe(this,(()=>{(0,n.ensureNotNull)(this._lockDrawingsWatchedValue).setValue((0,mt.lockDrawings)().value())}))),this._lockDrawingsWatchedValue}hideAllDrawingTools(){return null===this._hideDrawingsWatchedValue&&(this._hideDrawingsWatchedValue=new O.WatchedValue((0,mt.hideAllDrawings)().value()),this._hideDrawingsWatchedValue.subscribe((e=>{(0,mt.hideAllDrawings)().setValue(e)})),(0,mt.hideAllDrawings)().subscribe(this,(()=>{(0,n.ensureNotNull)(this._hideDrawingsWatchedValue).setValue((0,mt.hideAllDrawings)().value())}))),this._hideDrawingsWatchedValue}hideAllIndicators(){return null===this._hideIndicatorsWatchedValue&&(this._hideIndicatorsWatchedValue=new O.WatchedValue((0,mt.hideAllIndicators)().value()),this._hideIndicatorsWatchedValue.subscribe((e=>{(0,mt.hideAllIndicators)().setValue(e)})),(0,mt.hideAllIndicators)().subscribe(this,(()=>{(0,n.ensureNotNull)(this._hideIndicatorsWatchedValue).setValue((0,mt.hideAllIndicators)().value())}))),this._hideIndicatorsWatchedValue}logs(){return{getLogHistory:ne.getLogHistory,enable:window.lon,disable:window.loff}}mainSeriesPriceFormatter(){return this._chartWidgetCollection.activeChartWidget.value().model().mainSeries().priceScale().formatter()}onContextMenu(e){ee.subscribe("onContextMenu",(t=>{t.callback(e(t.unixtime,t.price))}),void 0)}onGrayedObjectClicked(e){ee.subscribe("onGrayedObjectClicked",e,void 0)}removeChartFromServer(e,t){z.backend.removeChart(e).then(t)}saveChart(e,t){if(!this._saveChartService)return;const i=this._saveChartService.saveToJSON(t);return e&&e(JSON.parse(i.content))}saveChartToServer(e,t,i){this._saveChartService&&this._saveChartService.saveChartSilently(e,t,i)}selectedLineTool(){const e=Object.keys(Of),t=mt.tool.value();for(let i=0;i<e.length;++i)if(Of[e[i]].name===t)return e[i];throw new Error("Unknown tool")}autosave(){if(!this._saveChartService)throw new Error("Saving service is not available");return this._saveChartService.autoSaveEnabled()}setForceFullscreenMode(){by()}setMultichartMode(){by()}setDateRangeLinkingEnabled(e){this._chartWidgetCollection.lock.dateRange.setValue(e)}
studyMetaIntoRepository(){return(0,os.studyMetaInfoRepository)()}deferredStudiesReady(){return vh.ready()}hasPendingStudiesModuleLoading(){return(0,Ws.hasPendingStudiesModuleLoading)()}hasPendingLineToolsModuleLoading(){return hasPendingLineToolsModuleLoading()}shouldBeSaved(){return!this._chartWidgetCollection.readOnly()&&(this._saveChartService?.hasChanges()||!1)}setIntervalLinkingEnabled(e){this._chartWidgetCollection.lock.interval.setValue(e)}setTimeFrame(e){this._chartWidgetCollection.setTimeFrame(e)}showConfirmDialog(e){let t=e.callback;const i=e=>{t&&(t(e),t=null)};(0,j.showConfirm)({title:e.title,text:e.body||"",onClose:()=>{i(!1)},onConfirm:e=>{i(!0),e.dialogClose()}})}showLoadChartDialog(){this._loadChartService?.showLoadDialog()}persistentLogger(){return null}showNoticeDialog(e){(0,j.showWarning)({title:e.title,text:e.body||"",onClose:e.callback})}showSupportDialog(){by()}showSaveAsChartDialog(){const e=this._saveChartService;e&&window.runOrSignIn((()=>{e.saveChartAs()}),{source:"Save as chart dialogue"})}showRenameChartDialog(){by()}saveChartOrShowTitleDialog(e,t,i){by()}showCreateAlertDialog(){by()}createGoProDialog(e){by()}setUserInfo(e){by()}openMobileChartPicker(){by()}closeMobileChartPicker(){by()}takeClientScreenshot(e){return this._chartWidgetCollection.clientSnapshot(e)}takeScreenshot(){return this._chartWidgetCollection.takeScreenshot()}trading(){by()}waitTrading(){by()}viewMode(){by()}viewModeWatchedValue(){by()}async dummyBrokerController(){return Promise.reject("Not implemented")}pineLibApi(){return by(),{saveNew,saveNext,requestBuiltinScripts}}resetCache(){(0,r.getChartingLibraryGlobalContext)().ChartApiInstance.resetCache()}getSymbolAliasService(){throw new Error("not supported")}static setContextMenuOptions(e){void 0!==e.items_processor&&Io.ContextMenuManager.setCustomItemsProcessor(e.items_processor),void 0!==e.renderer_factory&&Io.ContextMenuManager.setCustomRendererFactory(e.renderer_factory)}_getChartWidgetApi(e){let t=this._chartWidgets.get(e);return void 0===t&&(t=new yy(e,this._activateChart.bind(null,e)),this._chartWidgets.set(e,t)),t}_chartIndex(e){return this._chartWidgetCollection.getAll().indexOf(e)}_activeChartWidget(){return this._chartWidgetCollection.activeChartWidget.value()}_toggleUnitConversionMenu(e,t,i,s,o){if(t)return void ee.emit(e,t,-1,-1,"");const r=this._chartWidgetCollection.getAll(),a=r.findIndex((e=>e.model().model().id()===i));if(-1===a)return;const l=(0,n.ensureDefined)(r[a]).paneWidgets().findIndex((e=>e.state().id()===s));-1!==l&&ee.emit(e,t,a,l,o)}_onBeforeActiveChartChanged(){0}_onActiveChartChanged(){this._onBeforeActiveChartChanged(),this._activeChartWidgetWV.setValue(this.activeChart()),this._activeChartWidgetChangedDelegate.fire(),this._onAfterActiveChartChanged()}_onAfterActiveChartChanged(){this._updateActiveChartRangeState()}_updateActiveChartRangeState(){0}}i(4783),i(45);var Ty=i(78136),Py=i(19979);const xy={ar_AE:"ar",de_DE:"de",en:"www",es:"es",ca_ES:"es",fa_IR:"www",fr:"fr",he_IL:"il",id:"id",in:"in",it:"it",ja:"jp",kr:"kr",ms_MY:"my",pl:"pl",
br:"br",ru:"ru",sv_SE:"se",th_TH:"th",tr:"tr",uk:"uk",vi_VN:"vn",zh_CN:"cn",zh_TW:"tw"};function My(e){return xy[e]||"www"}var Iy=i(33065),Ay=i(70893),Ly=i(50946);i(59449);const ky={customBrandingTradingViewText:Rt.colorsPalette["color-brand"],customBrandingText:Rt.colorsPalette["color-cold-gray-850"],background:Rt.colorsPalette["color-cold-gray-900"],shadow:Rt.colorsPalette["color-cold-gray-700"],text:Rt.colorsPalette["color-white"],staticTextBackground:(0,Ro.generateColor)(Rt.colorsPalette["color-cold-gray-800"],20),logo:Rt.colorsPalette["color-white"],platformBgColor:Rt.colorsPalette["color-cold-gray-900"],platformFgColor:Rt.colorsPalette["color-cold-gray-200"]},Ey={customBrandingTradingViewText:Rt.colorsPalette["color-brand"],customBrandingText:Rt.colorsPalette["color-cold-gray-850"],background:Rt.colorsPalette["color-white"],shadow:Rt.colorsPalette["color-cold-gray-150"],text:Rt.colorsPalette["color-cold-gray-900"],staticTextBackground:(0,Ro.generateColor)(Rt.colorsPalette["color-white"],20),logo:Rt.colorsPalette["color-cold-gray-900"],platformBgColor:Rt.colorsPalette["color-white"],platformFgColor:Rt.colorsPalette["color-cold-gray-900"]};const Dy=new Map([["logo-old-style",Ly],["tradingview-old-style",Ay]]),By=l.enabled("adaptive_logo"),Vy=l.enabled("small_no_display"),Ry=l.enabled("38914"),Ny="site_branding",Oy="widget_branding",Fy="widget_referral_branding",Wy="widget_custom_branding",Hy="widget_custom_no_powered_branding",zy="fundamental_branding",Uy="fundamental_custom_branding",jy="fundamental_custom_no_powered_branding",Gy="library_branding",qy="library_custom_branding",$y="library_custom_no_powered_branding",Ky=navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("edge"),Yy=window.urlParams||{},Zy=window.initData||{};Yy.no_referral_id&&enable(Yy.referral_id||"","aggressive");const Xy=a.t(null,void 0,i(98856)),Jy=Ry?a.t(null,void 0,i(44676)):a.t(null,void 0,i(92800));a.t(null,void 0,i(46768)),a.t(null,void 0,i(83470)),a.t(null,void 0,i(3140));var Qy;!function(e){e[e.OldFontAdditionalVerticalOffset=0]="OldFontAdditionalVerticalOffset",e[e.NewFontAdditionalVerticalOffset=.1]="NewFontAdditionalVerticalOffset",e[e.StrokeWidth=4]="StrokeWidth",e[e.StaticLogoHorizontalTextOffset=5]="StaticLogoHorizontalTextOffset",e[e.TextWidthCompensation=2]="TextWidthCompensation",e[e.AdaptiveWidthToHideText=500]="AdaptiveWidthToHideText",e[e.WidthToHideLogoIfSmallNoDisplayEnabled=480]="WidthToHideLogoIfSmallNoDisplayEnabled",e[e.TextAdditionalCropWidth=11]="TextAdditionalCropWidth",e[e.BadgeLogoMargin=-11]="BadgeLogoMargin",e[e.BadgeTextMargin=-8]="BadgeTextMargin",e[e.TextAnimatedAlphaStart=.3]="TextAnimatedAlphaStart",e[e.TextAnimatedAlphaEnd=1]="TextAnimatedAlphaEnd",e[e.AnimationDuration=200]="AnimationDuration"}(Qy||(Qy={}));(0,ze.onWidget)();class ev extends Ad.CustomSourceBase{constructor(e,t,i){super(e,t),this._canvasWidth=0,this._paneHeight=0,this._left=13,this._bottom=36,this._layout=Ny,this._needToShow=!0,this._showBranding=!1,this._customLogoSrc="",
this._customLogoLink="",this._tradingviewLogoLinkToPath="",this._cubicBezier=new br.CubicBezier(.4,.01,.22,1),this._openAnimation=null,this._closeAnimation=null,this._powBy=null,this._custom=null,this._destroyed=!1,this._mainSeries=this._model.mainSeries(),this._visible=i,this._showForPro=!t.onWidget();const s=()=>this._model.updateSource(this);this._visible.subscribe(s),this._dark=t.dark().spawn(),this._dark.subscribe(s),this._checkLayout(),this._layout!==Wy&&this._layout!==Uy||(this._left=8,this._bottom=5);const o=()=>{this._needToShow?this._showBranding=!0:this._showBranding=!1};this._resizeHandlerDelayed=(0,Ol.default)(o,200),o(),window.addEventListener("resize",this._resizeHandlerDelayed),this._model.isSnapshot()?this._init():(this._mainSeries.dataEvents().symbolResolved().subscribe(this,this._init),null!==this._mainSeries.symbolInfo()&&this._init()),this._renderer={draw:this.draw.bind(this),hitTest:this.hitTest.bind(this)},t.onWidget()||window.loginStateChange.subscribe(this,this._init)}destroy(){window.removeEventListener("resize",this._resizeHandlerDelayed),this._mainSeries.dataEvents().symbolResolved().unsubscribeAll(this),this._powBy&&this._powBy.destroy(),this._model.onWidget()||window.loginStateChange.unsubscribeAll(this),this._visible.release(),this._dark.destroy(),this._destroyed=!0}paneViews(e){if(window.TradingView.printing&&this._layout!==Hy&&this._layout!==jy)return[];if(!this._visible.value())return[];if(this._layout===Ny&&!this._showForPro&&window.user&&window.user.is_pro)return[];const t=this._model.mainPane();if(!t)return[];const i=l.enabled("move_logo_to_main_pane");let s=!1;if(e.maximized().value())s=!0;else if(i)s=t.collapsed().value()?e===this._model.panes().find((e=>!e.collapsed().value())):e.isMainPane().value();else if(this._model.lastPane().collapsed().value()){const t=this._model.panes();for(let i=t.length-1;i>=0;--i){const o=t[i];if(!o.collapsed().value()){s=o===e;break}}}else s=e.isLast();return s?[{renderer:this.renderer.bind(this)}]:[]}labelPaneViews(e){return[]}priceAxisViews(e,t){return[]}updateAllViews(){}updateViewsForPane(e){}priceScale(){return null}renderer(e){return this._paneHeight=e.mediaSize.height,this._canvasWidth=e.mediaSize.width,this._renderer}hasContextMenu(){return!1}onClickOutside(){this._hasAnimation()&&this._startCloseAnimation()}hitTest(e){if(!this._showBranding||l.enabled("logo_without_link"))return null;if(this._powBy&&this._layout!==Hy&&this._layout!==jy&&(this._powBy.hitTest(e)||this._custom&&this._custom.hitTest(e))){const e=!0;return new Ut.HitTestResult(Ut.HitTarget.Custom,{hideCrosshairLinesOnHover:!0,cursorType:e?ei.PaneCursorType.Pointer:ei.PaneCursorType.Default,clickHandler:()=>{this._openLink()},tapHandler:()=>{this._hasAnimation()?this._toggleOpenAnimatedOrOpenLink():this._openLink()},mouseEnterHandler:()=>{this._hasAnimation()&&this._startOpenAnimation()},mouseLeaveHandler:()=>{this._hasAnimation()&&this._startCloseAnimation()},mouseDownHandler:()=>{0},mouseUpHandler:()=>{0}})}return null}tvUrl(){const e="https://"+function(e){
return My(e)+".tradingview.com"}((Zy.querySettings?.locale??Zy.currentLocaleInfo?.language)||"en");let t=new URL(e);if(this._customLogoLink)return this._customLogoLink;if(this._layout===Gy||this._layout===qy){let e;switch(!0){case l.enabled("charting_library"):e="library";break;case l.enabled("trading_terminal"):e="trading-terminal"}this._tradingviewLogoLinkToPath&&(t.pathname=this._tradingviewLogoLinkToPath),t.searchParams.append("utm_source",window.location.origin),t.searchParams.append("utm_medium","library"),e&&t.searchParams.append("utm_campaign",e)}return t.toString()}draw(e,t){if(!this._showBranding)return;let i=0;Yy.utm=!0,(0,Kt.drawScaled)(e,t.horizontalPixelRatio,t.verticalPixelRatio,(()=>{if(this._powBy&&this._powBy.show){i=this._powBy.height,e.save();const s=new Vt.Point(this._left,this._paneHeight-this._bottom-i);this._powBy.draw(s,e,t,this._canvasWidth),e.restore()}if(this._custom&&this._custom.show){e.save();const s=new Vt.Point(this._left,this._paneHeight-this._bottom-i-this._custom.height);this._custom.draw(s,e,t),e.restore()}}))}_init(){this._checkLayout();const e=this._mainSeries.symbolInfo();this._powBy&&this._powBy.destroy(),this._powBy=new rv(this._layout,e?.name||"",this._model,(()=>this._model.fullUpdate())),this._custom=new av(this._layout,this._customLogoSrc,(()=>this._model.fullUpdate())),this._openAnimation=null,this._closeAnimation=null,this._model.lightUpdate()}_checkLayout(){if(l.enabled("widget"))0;else{{const e=JSON.parse(Yy.logo)||{};e.image?(this._customLogoSrc=e.image,this._customLogoLink=e.link,this._needToShow=l.enabled("widget_logo"),l.enabled("link_to_tradingview")?this._layout=qy:this._layout=$y):(e.tradingviewLogoLinkToPath&&(this._tradingviewLogoLinkToPath=e.tradingviewLogoLinkToPath.replace(/^\//,"")),this._layout=Gy,this._needToShow=l.enabled("widget_logo"))}}}_startOpenAnimation(){if(null!==this._openAnimation)return;null!==this._closeAnimation&&(this._closeAnimation.stop(),this._closeAnimation=null);const e=(0,n.ensureNotNull)(this._powBy).animationStep();this._openAnimation=(0,xr.doAnimate)({from:e,to:1,duration:200*(1-e),easing:this._cubicBezier.easingFunc,onStep:this._animatedDrawStep.bind(this)})}_startCloseAnimation(){if(null!==this._closeAnimation)return;null!==this._openAnimation&&(this._openAnimation.stop(),this._openAnimation=null);const e=(0,n.ensureNotNull)(this._powBy).animationStep();this._closeAnimation=(0,xr.doAnimate)({from:e,to:0,duration:200*e,easing:this._cubicBezier.easingFunc,onStep:this._animatedDrawStep.bind(this)})}_animatedDrawStep(e,t){(0,n.ensureNotNull)(this._powBy).animatedDrawStep(t),this._model.lightUpdate()}_hasAnimation(){return null!==this._powBy&&this._powBy.hasAnimation()}_openGoPro(){0}_openLink(){if((0,ze.isSymphonyEmbed)())return!1;if(this._layout===Ny)return this._model.isSnapshot()||this._openGoPro(),!1;l.enabled("widget");return(0,n.ensureNotNull)(window.open(this.tvUrl(),"_blank")).opener=null,!0}_toggleOpenAnimatedOrOpenLink(){
null!==this._openAnimation&&this._openAnimation.completed()?this._openLink()||this._startCloseAnimation():this._startOpenAnimation()}}function tv(e){return!Vy||e>480}function iv(e){return!By||e>500}let sv={},ov={};class nv{constructor(){this._topLeftPoint=null,this._hitTestHeight=null}hitTest(e){const t=this._getHitTestBox();if(t)return(0,Gt.pointInBox)(e,t)}_getHitTestBox(){const e=this._topLeftPoint;if(e){const{x:t,y:i}=e;return(0,Vt.box)(e,new Vt.Point(t+this.width,i+(this._hitTestHeight??this.height)))}}}class rv extends nv{constructor(e,t,i,s){super(),this.show=!0,this.hovered=!1,this.active=!1,this._needDisplayImage=!1,this._textAnimatedAlpha=1,this._textAnimatedAlphaStart=1,this._textAdditionalCropWidth=0,this._textAnimatedAlphaEnd=1,this._badgeData={logoMargin:0,textMargin:0,width:0},this._invertTextCropDirection=!1,this._font=`px ${m.CHART_FONT_FAMILY}`,this._txt="TradingView",this._maximizedAnimationTextWidth=0,this._logoWidth=0,this._textWidthCache=new Qt.TextWidthCache,this._pixelRatio={horizontalPixelRatio:NaN,verticalPixelRatio:NaN},this._model=i,this._layout=e,this._symbol=t,this._showTradeWithLogo=!1,this._showAnimatedBranding=l.enabled("show_animated_logo")||e===Oy,this._alwaysMaximized=l.enabled("logo_always_maximized")||this._model.isSnapshot()&&!ze.CheckMobile.any()||!1,this._fontSize=this._showAnimatedBranding||this._layout===Fy?11:14,this._showAnimatedBranding||this._layout!==Wy&&this._layout!==Uy||(this._fontSize=12),this._sizeConstants=(this._model.isSnapshot(),{brandCircleSize:32,textAsImageWidthCompensation:0,leftOffset:0,bottomOffset:-23,logoLeftOffset:1,logoTextOffset:6}),this.width=this._minimizedAnimationWidth(),this._animatedWidth=this.width,this.height=this._fontSize+2,this._requestRepaint=s,this._init(),this._checkFontLoaded(),this._recalculateMetrics()}destroy(){this._model.properties().childs().paneProperties.childs().background.unsubscribeAll(this),this._model.onChartThemeLoaded().unsubscribeAll(this)}hasAnimation(){return this._showAnimatedBranding&&!this._alwaysMaximized}animationStep(){const e=this._minimizedAnimationWidth(),t=this._maximizedAnimationWidth();return(this._animatedWidth-e)/(t-e)}animatedDrawStep(e){const t=this._minimizedAnimationWidth(),i=this._maximizedAnimationWidth();this._animatedWidth=t+e*(i-t),this._textAnimatedAlpha=this._textAnimatedAlphaStart+e*(this._textAnimatedAlphaEnd-this._textAnimatedAlphaStart)}draw(e,t,i,s){const{brandCircleSize:o,logoLeftOffset:n,leftOffset:r,bottomOffset:a}=this._sizeConstants;this._needDisplayImage&&tv(s)&&(e=new Vt.Point(e.x+r,e.y-a)),this._topLeftPoint=e,t.translate(e.x,e.y);const{horizontalPixelRatio:l,verticalPixelRatio:c}=i;(0,Iy.equalPixelRatios)(i,this._pixelRatio)||(this._textWidthCache.reset(),this._pixelRatio={horizontalPixelRatio:l,verticalPixelRatio:c});const h=this._colors;if(this._showAnimatedBranding){if(this._needDisplayImage){const e=this._getLogoImage(h.logo);this.width=this._animatedWidth,this._drawLogo(t,e,this._animatedWidth,this._animatedWidth,this._animatedWidth>this._sizeConstants.brandCircleSize)}
}else if(this._layout===Wy||this._layout===Uy){t.font=this._fontSize+this._font;const e=t.measureText(this._txt).width+2;this.width=e+t.measureText("TradingView").width+2,t.save(),t.globalAlpha=.7,t.fillStyle=this._colors.customBrandingText,t.fillText(this._txt,0,12),t.fillStyle=this._colors.customBrandingTradingViewText,t.fillText("TradingView",e,12),t.restore()}else if(tv(s))if(this._needDisplayImage){const e=this._getLogoImage(h.logo);t.save(),this._drawBgCircle(t,o/2);const{width:i,height:r}=e.logoImage.viewBox(),a=new Vt.Point(Math.round((o-i)/2)-1+n,Math.floor((o-r)/2)+1);this._drawLogoImage(t,a,e.logoImage);const l=iv(s);l&&(t.translate(o+5,Math.round(this._fontSize*("px EuclidCircular"===this._font?.1:0))),this._drawTextStroke(t),this._drawTextFill(t)),t.restore(),this.width=o,l&&(this.width+=this._maximizedAnimationTextWidth)}else{const e=iv(s);e&&(t.save(),t.translate(Ky?-.5:0,-.5),this._drawTextStroke(t),this._drawTextFill(t),t.restore()),e&&(this.width=this._maximizedAnimationTextWidth)}else this.width=0}showTradeWithLogo(e){this._showTradeWithLogo=e}_minimizedAnimationWidth(){return this._sizeConstants.brandCircleSize+this._badgeData.logoMargin+this._badgeData.width}_maximizedAnimationWidth(){return this._sizeConstants.brandCircleSize+this._sizeConstants.logoTextOffset+this._maximizedAnimationTextWidth+this._badgeData.width+this._badgeData.textMargin}_drawTradeWithLogo(e,t,i){0}_drawLogo(e,t,i,s,o){const{brandCircleSize:n,logoLeftOffset:r,logoTextOffset:a}=this._sizeConstants;e.save(),this._drawFillRectWithRoundedCorner(e,-.5,0,i,n,n/2);const{logoImage:l,textImage:c,proBadgeImage:h}=t,{width:d,height:u}=l.viewBox(),_=new Vt.Point(Math.round((n-d)/2)-1+r,Math.floor((n-u)/2)+1);if(o){const t=new Vt.Point(_.x+d+a,_.y),i=e.globalAlpha;e.globalAlpha*=this._textAnimatedAlpha;const o=s-this._sizeConstants.brandCircleSize-a-this._badgeData.logoMargin-this._badgeData.width;this._drawImageCropWidth(e,t,c,o),e.globalAlpha=i}if(h){const{width:t,height:i}=h.viewBox();h.render(e,{targetViewBox:{x:_.x+this.width-t,y:Math.floor((n-i)/2)+1,width:t,height:i}})}this._drawLogoImage(e,_,l),e.restore()}_init(){ov={},sv={},this._checkLayout(),this.show&&(this._updateColors(),this._updateHeight(),this._model.properties().childs().paneProperties.childs().background.subscribe(this,this._updateColors),this._model.onChartThemeLoaded().subscribe(this,this._updateColors))}_updateHeight(){this._needDisplayImage?this.height=this._sizeConstants.brandCircleSize:this.height=this._fontSize+2}_checkFontLoaded(){if(!this._showAnimatedBranding&&document.fonts&&document.fonts.check&&document.fonts.load){document.fonts.check(`${this._fontSize}px EuclidCircular`)?this._font="px EuclidCircular":document.fonts.load(`${this._fontSize}px EuclidCircular`,this._txt).then((()=>{this._font="px EuclidCircular",this._recalculateMetrics(),this._requestRepaint()}))}}_recalculateMetrics(){const e=(0,Kt.createDisconnectedCanvas)(document,(0,Ft.size)({width:0,height:0})),t=(0,Kt.getPrescaledContext2D)(e);t.font=this._fontSize+this._font
;const i=this._needDisplayImage?this._getLogoImage(this._colors.logo):null;let s=i?i.textImage.viewBox().width+this._sizeConstants.textAsImageWidthCompensation:Math.ceil(t.measureText(this._txt).width)+2+8;s%2==0&&(s+=1),this._maximizedAnimationTextWidth=s,this._textWidthCache.reset(),this._logoWidth=i?.logoImage.viewBox().width??0,this._animatedWidth=this._alwaysMaximized?this._maximizedAnimationWidth():this._minimizedAnimationWidth()}_updateColors(){this._colors=this._model.dark().value()?ky:Ey}_getLogoImage(e){return function(e,t,i,s,o){const r=ov,a=[t,i,o&&"tradeWith"].filter(Boolean).join("-"),l=r[a];if(void 0!==l)return l;const[c,h,d]=function(e,t,i){return i?["logo-trade-with","tradingview-trade-with"]:["logo-old-style","tradingview-old-style",void 0]}(0,0,o),u=e=>e.replace(/fill="#[\da-f]{6}"/gi,`fill="${i}"`),_={logoImage:e(u((0,n.ensureDefined)(Dy.get(c)))),textImage:e(u((0,n.ensureDefined)(Dy.get(h)))),proBadgeImage:d?e(u((0,n.ensureDefined)(Dy.get(d)))):void 0};return r[a]=_,_}(Mo.svgRenderer,this._model.dark().value()?"dark":"light",e,0,this._showTradeWithLogo)}_checkLayout(){switch(this._layout){case Oy:case Fy:case Wy:case zy:case Uy:case qy:case Gy:case Ny:this.show=!0;break;case Hy:case jy:case $y:this.show=!1}switch(this._layout){case Gy:this._needDisplayImage=!0,this._txt=Xy;break;case qy:this._txt=Jy}}_drawTextStroke(e){e.save(),e.textBaseline="middle",e.textAlign="start",e.font=this._fontSize+this._font,e.strokeStyle=this._colors.staticTextBackground,e.lineWidth=4,e.lineJoin="round",e.strokeText(this._txt,0,this._sizeConstants.brandCircleSize/2+this._textWidthCache.yMidCorrection(e,this._txt)),e.restore()}_drawTextFill(e){e.save(),e.textBaseline="middle",e.textAlign="start",e.font=this._fontSize+this._font,e.fillStyle=this._colors.text,e.fillText(this._txt,0,this._sizeConstants.brandCircleSize/2+this._textWidthCache.yMidCorrection(e,this._txt)),e.restore()}_drawImageCropWidth(e,t,i,s){e.save();const{logoMargin:o,textMargin:n}=this._badgeData;e.beginPath();const{width:r,height:a}=i.viewBox();e.rect(t.x-this._textAdditionalCropWidth,t.y,s+this._textAdditionalCropWidth,a),e.clip(),i.render(e,{targetViewBox:{x:t.x-(this._invertTextCropDirection?r-s-o+n:0),y:t.y,width:r,height:a}}),e.restore()}_drawBgCircle(e,t){const i=2*Math.PI;e.save(),e.beginPath(),e.fillStyle=this._colors.shadow,e.arc(t,t,t+1,0,i),e.fill(),e.closePath(),e.restore(),e.save(),e.beginPath(),e.fillStyle=this._colors.background,e.arc(t,t,t,0,i,!1),e.fill(),e.closePath(),e.restore()}_drawFillRectWithRoundedCorner(e,t,i,s,o,n,r){e.save(),(0,$t.drawRoundRect)(e,t-1,i-1,s+2,o+2,n),e.fillStyle=this._backgroundShadowFillStyle(),e.fill(),e.closePath(),e.restore(),e.save(),(0,$t.drawRoundRect)(e,t,i,s,o,r??n),e.fillStyle=this._backgroundFillStyle(),e.fill(),e.closePath(),e.restore()}_tradeWithLogoBackgroundColor(){return""}_backgroundShadowFillStyle(){return this._colors.shadow}_backgroundFillStyle(){return this._colors.background}_drawLogoImage(e,t,i){const{width:s,height:o}=i.viewBox();i.render(e,{targetViewBox:{x:t.x,y:t.y,width:s,height:o
}})}}class av extends nv{constructor(e,t,i){super(),this.show=!1,this.width=0,this.height=0,this._ready=!1,this._layout=e,this._src=t,this._onReadyCallback=i,this._checkLayout();const s=new Image;this._img=s,this.show&&(s.addEventListener("load",(()=>{this.width=Math.round(s.width),this.height=Math.round(s.height),this._ready=!0,this._onReadyCallback&&this._onReadyCallback()})),s.crossOrigin="anonymous",s.src=this._src)}draw(e,t,i){this._topLeftPoint=e,this._ready&&(t.translate(e.x,e.y),t.drawImage(this._img,-.5,-.5,this.width,this.height))}_checkLayout(){switch(this._layout){case Wy:case Hy:case Uy:case jy:case qy:case $y:this.show=!0;break;case Ny:case Oy:case Fy:case zy:case Gy:this.show=!1}}}var lv=i(55279),cv=i(48961);class hv{constructor(e,t){this._headerToolbar=e,this._dropdownId=t}applyOptions(e){this._headerToolbar.updateDropdown(this._dropdownId,e)}remove(){this._headerToolbar.removeDropdown(this._dropdownId)}}var dv=i(68028);class uv{constructor(e){this._symbolModel=e}getVisible(){return this._symbolModel.visible().value()}setVisible(e){return this._symbolModel.visible().setValue(e),this}getIcon(){return this._symbolModel.icon().value()}setIcon(e){return this._symbolModel.icon().setValue(e),this}getColor(){return this._symbolModel.color().value()}setColor(e){return this._symbolModel.color().setValue(e),this}getTooltip(){return this._symbolModel.tooltip().value()}setTooltip(e){return this._symbolModel.tooltip().setValue(e),this}getDropDownContent(){return this._symbolModel.tooltipContent().value()}setDropDownContent(e){return this._symbolModel.tooltipContent().setValue(e),this}}class _v{symbol(e){return new uv(this._model().getSymbolCustomStatus(e))}hideAll(){this._model().hideAll()}static getInstance(){return null===this._instance&&(this._instance=new _v),this._instance}_model(){return dv.CustomStatusModel.getInstance()}}_v._instance=null;var pv=i(22692),mv=i(15754);var gv=i(23745),fv=i(10980),yv=i(43222);class vv{constructor(e,t){this._server=e,this._session=t,this.beforeSeriesCompleted=new ae.Delegate,this.seriesError=new ae.Delegate}onSymbolResolved(e,t){this._server.receiveLocalResponse({method:"symbol_resolved",params:[this._session,e,t]})}onSymbolError(e,t){this._server.receiveLocalResponse({method:"symbol_error",params:[this._session,e,t]})}onStudyError(e,t,i){this._server.receiveLocalResponse({method:"study_error",params:[this._session,e,t,i]})}onSeriesLoading(e,t){this._server.receiveLocalResponse({method:"series_loading",params:[this._session,e,t]})}onSeriesCompleted(e,t,i){this.beforeSeriesCompleted.fire(e,t),this._server.receiveLocalResponse({method:"series_completed",params:[this._session,e,i,t]})}onSeriesError(e,t,i){this._server.receiveLocalResponse({method:"series_error",params:[this._session,e,t,i]}),this.seriesError.fire(e,t)}onStudyCompleted(e,t){this._server.receiveLocalResponse({method:"study_completed",params:[this._session,e,t]})}onStudyLoading(e,t){this._server.receiveLocalResponse({method:"study_loading",params:[this._session,e,t]})}onTickmarksUpdated(e,t){const i={
method:"tickmark_update",params:[this._session,{index:e,zoffset:0,changes:[],marks:t,index_diff:[]}]};this._server.receiveLocalResponse(i)}onTimescaleUpdate(e,t){const i={method:"timescale_update",params:[this._session,this._prepareDataUpdateObjects(t),{index:e.pointsIndex,zoffset:0,changes:e.points,marks:e.marks,index_diff:e.indexChange,baseIndex:e.baseIndex,clearTickMarks:e.clearTickMarks}]};this._server.receiveLocalResponse(i)}onTimescaleCompleted(e){this._server.receiveLocalResponse({method:"timescale_completed",params:[this._session,e]})}onSeriesTimeframeUpdate(e,t,i,s,o,n){const r={method:"series_timeframe",params:[this._session,e,t,i,s,n||null,!0,o]};this._server.receiveLocalResponse(r)}onPointsetDataUpdate(e,t,i){this.onDataUpdate(e,t,i,null)}onDataUpdate(e,t,i,s){const o={method:"data_update",params:[this._session,this._prepareDataUpdateObjects([{objId:e,turnaround:t,data:i,nonSeriesData:s}])]};this._server.receiveLocalResponse(o)}onQuotesData(e){this._server.receiveLocalResponse({method:"quote_symbol_data",params:e})}onDepthData(e){this._server.receiveLocalResponse({method:"dd",params:e})}onDepthUpdate(e){this._server.receiveLocalResponse({method:"dpu",params:e})}onClearData(e){this._server.receiveLocalResponse({method:"clear_data",params:[this._session,e]})}_prepareDataUpdateObjects(e){const t={};return e.forEach((e=>{t[e.objId]={series:e.data,turnaround:e.turnaround},e.nonSeriesData&&(e.nonSeriesData.data?t[e.objId].nonseries={d:JSON.stringify(e.nonSeriesData.data),indexes:e.nonSeriesData.indexes}:t[e.objId].nonseries={d:"",indexes:[]})})),t}}class Sv{constructor(){this._instances=new Map}createChartApiMessager(e,t){const i=new vv(t,e);return this._instances.set(e,i),i}getChartApiMessager(e){return(0,n.ensureDefined)(this._instances.get(e),`ChartapiMessager instance for session ${e}`)}}const bv={blue:"#2962ff",gray:"#787B86",green:"#4CAF50",olive:"#808000",teal:"#00897B",new:(e,t)=>(0,Ro.applyTransparency)(e,t)},wv={hline:{style_dashed:qt.LINESTYLE_DASHED,style_dotted:qt.LINESTYLE_DOTTED,style_solid:qt.LINESTYLE_SOLID}},Cv={line:"line"};class Tv{get(e){return NaN}set(e){}indexOf(e){return NaN}adopt(e,t,i){return NaN}}var Pv=i(60911);class xv{constructor(e,t){this.color=bv,this.linestyle=wv,this.plotstyle=Cv,this.barstate={isLast:()=>this._ctx.symbol.isLastBar},this.input={bool:()=>{const e=this._inputCallback(this._inputIndex++);return(0,n.assert)("boolean"==typeof e,"Study input value should be a boolean"),e},int:()=>{const e=this._inputCallback(this._inputIndex++);return(0,n.assert)("number"==typeof e,"Study input value should be a number"),e},source:()=>{const e=this._inputCallback(this._inputIndex++);return(0,n.assert)((e=>{switch(e){case"open":case"high":case"low":case"close":case"hl2":case"hlc3":case"ohlc4":return!0;default:return!1}})(e),"Study input value should be a series source"),this._ctx.new_var(Py.Std[e](this._ctx))},string:()=>{const e=this._inputCallback(this._inputIndex++);return(0,n.assert)("string"==typeof e,"Study input value should be a string"),e},symbol:()=>{
const e=this._inputCallback(this._inputIndex++);return(0,n.assert)("string"==typeof e,"Study input value should be a symbol string"),e}},this.request={security:(e,t)=>{const i=this._symbolIndexByTickerId.get(e);this._addedTickerIds.has(e)||this._ctx.new_sym(e,Py.Std.period(this._ctx)),(0,n.assert)(void 0!==i,`Unknown tickerId ${e}`);const s=this._ctx.new_unlimited_var(Py.Std.time(this._ctx));this._ctx.select_sym(i);const o=this._ctx.new_unlimited_var(Py.Std.time(this._ctx)),r=t?.expression?.()??this.close();return this._ctx.select_sym(0),this._ctx.new_var(r.adopt(o,s,0))}},this.runtime={error:e=>{Py.Std.error(e)}},this.math={max:(e,...t)=>{const i=e=>(0,Hd.isNumber)(e)?e:e.get(0),s=Math.max(i(e),...t.map(i));return(0,Hd.isNumber)(e)?s:this._ctx.new_var(s)},min:(e,...t)=>{const i=e=>(0,Hd.isNumber)(e)?e:e.get(0),s=Math.min(i(e),...t.map(i));return(0,Hd.isNumber)(e)?s:this._ctx.new_var(s)},negative:e=>(0,Hd.isNumber)(e)?-e:this._ctx.new_var(-e.get(0))},this.ta={change:e=>this._ctx.new_var(Py.Std.change(e)),correlation:(e,t,i)=>this._ctx.new_var(Py.Std.correlation(e,t,i,this._ctx)),cum:e=>this._ctx.new_var(Py.Std.cum(e.get(0),this._ctx)),ema:(e,t)=>this._ctx.new_var(Py.Std.ema(e,t,this._ctx)),rma:(e,t)=>this._ctx.new_var(Py.Std.rma(e,t,this._ctx)),sma:(e,t)=>this._ctx.new_var(Py.Std.sma(e,t,this._ctx)),vwap:(e,t,i)=>{const[s,o,n]=Py.Std.vwapBands(e,t,i,this._ctx);return[this._ctx.new_var(s),this._ctx.new_var(o),this._ctx.new_var(n)]},wma:(e,t)=>this._ctx.new_var(Py.Std.wma(e,t,this._ctx))},this.ticker={modify:(e,t)=>{let i;if((0,Pv.isEncodedExtendedSymbol)(e))i=e;else{const s={symbol:e,session:t};i=(0,Pv.encodeExtendedSymbolOrGetSimpleSymbolString)(s)}return this._symbolIndexByTickerId.has(i)||this._symbolIndexByTickerId.set(i,++this._symbolIndex),i}},this.timeframe={change:e=>{if(isNaN(Py.Std.time(this._ctx)))return!1;const t=(0,Td.newBarBuilder)(e,this._ctx.symbol.session,null);t.moveTo(Py.Std.time(this._ctx));return 0===t.startOfBar(0)-Py.Std.time(this._ctx)},isDWM:()=>this._ctx.symbol.isdwm()},this._addedTickerIds=new Set,this._symbolIndexByTickerId=new Map,this._returnValues=[],this._ctx=e,this._inputCallback=t,this._inputIndex=0,this._symbolIndex=0}open(){return this._ctx.new_var(Py.Std.open(this._ctx))}high(){return this._ctx.new_var(Py.Std.high(this._ctx))}low(){return this._ctx.new_var(Py.Std.low(this._ctx))}close(){return this._ctx.new_var(Py.Std.close(this._ctx))}volume(){return this._ctx.new_var(Py.Std.volume(this._ctx))}year(){return Py.Std.year(this._ctx)}na(e){return!!Py.Std.na(e)}series(e){return this._ctx.new_var(e)}fill(e,t,i){}hline(e,t){return{id:""}}indicator(e){}plot(e,t){const i="number"==typeof e?e:e.get(0),s=void 0===t?.offset?i:{offset:t.offset,value:i};return this._returnValues.push(s),{id:""}}getReturnValues(){return this._returnValues}setMinimumAdditionalDepth(e){this._ctx.setMinimumAdditionalDepth(e)}}var Mv=i(18330);const Iv=e=>{switch(e){case"data_window":return Ts.InputDisplayFlags.DataWindow;case"none":return Ts.InputDisplayFlags.None;default:return Ts.InputDisplayFlags.All}},Av=e=>{
switch(e){case"data_window":return 2;case"none":return 0;default:return 15}};class Lv{constructor(){this.color=bv,this.linestyle=wv,this.plotstyle=Cv,this.barstate={isLast:()=>!1},this.input={bool:(e,t,i)=>(this._input({confirm:i?.confirm,defval:e,display:Iv(i?.display),group:i?.group,inline:i?.inline,id:this._getNextInputId(),name:t,type:"bool"}),e),int:(e,t,i)=>(this._input({confirm:i?.confirm,defval:e,display:Iv(i?.display),group:i?.group,id:this._getNextInputId(),inline:i?.inline,name:t,type:"integer"}),e),source:(e,t,i)=>(this._input({confirm:i?.confirm,defval:e,display:Iv(i?.display),group:i?.group,id:this._getNextInputId(),inline:i?.inline,name:t,type:"source"}),new Tv),string:(e,t,i)=>(this._input({confirm:i?.confirm,defval:e,display:Iv(i?.display),group:i?.group,id:this._getNextInputId(),inline:i?.inline,name:t,options:i?.options,type:"text"}),e),symbol:(e,t,i)=>(this._input({confirm:i?.confirm,defval:e,display:Iv(i?.display),group:i?.group,id:this._getNextInputId(),inline:i?.inline,name:t,type:"symbol"}),e)},this.math={max:e=>(0,Hd.isNumber)(e)?0:new Tv,min:e=>(0,Hd.isNumber)(e)?0:new Tv,negative:e=>(0,Hd.isNumber)(e)?0:new Tv},this.ta={change:e=>new Tv,correlation:(e,t,i)=>new Tv,cum:e=>new Tv,ema:()=>new Tv,rma:()=>new Tv,sma:()=>new Tv,vwap:()=>[new Tv,new Tv,new Tv],wma:()=>new Tv},this.request={security:e=>(this._tickers.push(e),new Tv)},this.runtime={error:e=>{throw new Error(e)}},this.ticker={modify:()=>""},this.timeframe={change:()=>!1,isDWM:()=>!1},this._bands=[],this._defaults={},this._filledAreas=[],this._format={type:"inherit"},this._inputs=[],this._overlay=!1,this._plots=[],this._shortTitle="",this._styles={},this._tickers=[],this._title="",this._version=1}getStudyName(){return this._title}getStudyMetainfo(){var e,t;return{_metainfoVersion:53,bands:this._bands,defaults:this._defaults,description:this._title,filledAreas:this._filledAreas,format:this._format,id:(e=this._title,t=this._version,`${e}@tv-basicstudies-${t}`),inputs:this._inputs,is_price_study:this._overlay,palettes:{},plots:this._plots,shortDescription:this._shortTitle,styles:this._styles}}getTickers(){return this._tickers}open(){return new Tv}high(){return new Tv}low(){return new Tv}close(){return new Tv}volume(){return new Tv}year(){return 0}na(e){return!1}series(e){return new Tv}fill(e,t,i){const s=this._getNextFillId(),o=this._plots.some((t=>t.id===e.id)),n=this._plots.some((e=>e.id===t.id)),r=this._bands.some((t=>t.id===e.id)),a=this._bands.some((e=>e.id===t.id)),l=o&&n;l||r&&a||this.runtime.error(`Could not find pair of plots or pair of hlines with ids ${e.id} ${t.id}`);const c=l?"plot_plot":"hline_hline";this._filledAreas.push({fillgaps:!1,id:s,isHidden:!1,objAId:e.id,objBId:t.id,title:i?.title??(l?"Plots Background":"Hlines Background"),type:c}),void 0===this._defaults.filledAreasStyle&&(this._defaults.filledAreasStyle={}),this._defaults.filledAreasStyle[s]=(e=>{if((e=>void 0===e?.color)(e))return{bottomColor:e?.bottomColor,fillType:"gradient",topColor:e?.topColor,visible:"all"===e?.display};return{fillType:void 0,
color:e?.color??"TODO",visible:"all"===e?.display}})(i)}hline(e,t){const i=this._getNextBandId();this._bands.push({id:i,isHidden:!1,name:t?.title??"Level"}),void 0===this._defaults.bands&&(this._defaults.bands=[]);const s={color:t?.color??"#808080",linestyle:t?.linestyle??wv.hline.style_dashed,linewidth:t?.linewidth??1,value:e,visible:"none"!==t?.display,name:""};return this._defaults.bands.push(s),{id:i}}indicator(e){void 0!==e.title&&(this._title=e.title),void 0!==e.shortTitle&&(this._shortTitle=e.shortTitle),void 0!==e.format&&(this._format={type:e.format,precision:e.precision}),void 0!==e.version&&(this._version=e.version),this._overlay=!!e.overlay}plot(e,t){const i=this._getNextPlotId();return this._plots.push({type:t?.style??"line",id:i}),void 0===this._defaults.styles&&(this._defaults.styles={}),this._defaults.styles[i]=(e=>{switch(e?.style){case void 0:case"line":return{color:e?.color??"#0496FF",display:Av(e?.display),linestyle:Mv.LineStyle.Solid,linewidth:e?.linewidth??1,plottype:jd.LineStudyPlotStyle.Line,trackPrice:!1,transparency:0};default:throw new Error("")}})(t),this._styles[i]={isHidden:!1,joinPoints:!1,title:t?.title??"Plot"},{id:i}}setMinimumAdditionalDepth(e){}_input(e){this._inputs.push(e),void 0===this._defaults.inputs&&(this._defaults.inputs={}),this._defaults.inputs[e.id]=(0,n.ensureDefined)(e.defval,"study input default value")}_getNextInputId(){return`in_${this._inputs.length}`}_getNextPlotId(){return`plot_${this._plots.length}`}_getNextBandId(){return`hline_${this._bands.length}`}_getNextFillId(){return`fill_${this._filledAreas.length}`}}var kv=i(4659);class Ev{build(e){const t=new Lv;return e(t),{name:t.getStudyName(),metainfo:t.getStudyMetainfo(),constructor:class{main(t,i,s){try{const s=new xv(t,i);e(s);const o=s.getReturnValues();return 0===o.length?null:o}catch(e){Py.Std.error(this._getErrorMessage(e))}}_getErrorMessage(e){if(e instanceof kv.StudyError)throw e;return(e instanceof Error?e.message:null==e?"Unknown error":e.toString()).replace(/:/g,"")}}}}}const Dv={palettes:{},inputs:[],plots:[{id:"open",type:"line"},{id:"high",type:"line"},{id:"low",type:"line"},{id:"close",type:"line"},{id:"volume",type:"line"}],graphics:{},_metainfoVersion:48,description:"Unnamed Study",format:{type:"inherit"},is_hidden_study:!0,is_price_study:!1,shortDescription:"Unnamed Study",description_localized:"Unnamed Study",id:"BarSetHeikenAshi@tv-prostudies",shortId:"BarSetHeikenAshi",packageId:"tv-basicstudies",version:13,fullId:"BarSetHeikenAshi@tv-basicstudies-13",productId:"tv-basicstudies",name:"BarSetHeikenAshi@tv-basicstudies",defaults:{},linkedToSeries:!1};class Bv{constructor(){this._metainfoCache=[]}studiesMetadata(){return 0===this._metainfoCache.length&&(this._metainfoCache=(0,r.getChartingLibraryGlobalContext)().JSServer.studyLibrary.map((e=>new ns.StudyMetaInfo(e.metainfo))),this._metainfoCache.push(new ns.StudyMetaInfo(Dv))),this._metainfoCache}}var Vv=i(78966),Rv=i.n(Vv);class Nv{createMarketStatusWatcher(e,t,i,s){return new(Rv())(e,t,i,s)}}class Ov{constructor(e){this._studyLibrary=e}
findStudyObject(e){e.endsWith("!")&&(e=e.slice(0,-1));const t=e.split("@")[0],i=this._studyLibrary.filter((i=>i.metainfo.id===e||i.metainfo.shortDescription===t));if(0===i.length)return null;return i[0]}}var Fv,Wv=i(63193),Hv=i(56052),zv=i(82433),Uv=i(47132),jv=i(16329);class Gv{constructor(e,t){this.info=e,this.bars=t||[],this.isBarClosed=!0,this.firstLoadedTimeMs=0!==this.bars.length?this.bars[0].time:1/0,this._emptyBarCount=0,this._lastBarIsEmpty=!1}symbolinfo(){return this.info}isLastBarClosed(){return this.isBarClosed}setLastBarClosed(e){this.isBarClosed=e}bar(e){const t=this.bars[e];if(void 0===t)throw new Error(`BarSet has no value at index ${e}`);return t}count(){return this.bars.length}emptyBarCount(){return this._emptyBarCount}add(e,t,i){void 0===i&&(i=!1);const s=e,o=this.bars,n=o.length,r=s.time,a=0===n?NaN:o[n-1].time;0===n||a<r?(o.push(s),i&&(this._emptyBarCount+=1,this._lastBarIsEmpty=!0)):a===r?(i!==this._lastBarIsEmpty&&(this._emptyBarCount+=i?1:-1,this._lastBarIsEmpty=i),o[n-1]=s):console.error("time order violation, prev: "+new Date(a).toUTCString()+", cur: "+new Date(r).toUTCString()),this.isBarClosed=!!t}}function qv(e,t){return e.ticker+(e.currency_code?"_#_"+e.currency_code:"")+(e.unit_id?"_#_"+e.unit_id:"")+(e.subsession_id?"_#_"+e.subsession_id:"")+"_#_"+t}function $v(e){return new Date(e).toISOString()}!function(e){e.ThreadKeySeparator="_#_"}(Fv||(Fv={})),function(e){e[e.MaxEmptyResponsesInARow=50]="MaxEmptyResponsesInARow",e[e.ResetCacheTimePeriod=1e4]="ResetCacheTimePeriod"}(Fv||(Fv={}));class Kv{constructor(e,t,i,s,o,n){this._cache={bars:[]},this._nextSubscriptionId=0,this._pendingSubscribers=[],this._subscribers=[],this._requesting=!1,this._leftDate=null,this._nextTime=null,this._realtimeOn=!1,this._endOfData=!1,this._resetCacheTimeout=null,this._errorMessage=null,this._destroyed=!1,this._emptyResponsesCount=0,this._firstDataRequest=!0,this._datafeed=e,this._symbolInfo=t,this._interval=Re.Interval.parse(i),this._resolution=this._interval.value(),this._dwmAligner=o,this._serverTimeOffsetGetter=s,this._resetCacheTimePeriod=void 0===n?1e4:n,this._sessionSpec=new jv.SessionsSpec(t.timezone,t.session,t.session_holidays,t.corrections),this._updateDatesFromExpirationDate()}destroy(){0!==this._subscribers.length&&this._logWarning("Destroying with not-empty state"),this._clearResetCacheTimeout(),this._unsubscribeRealtime(),this._purgeCache(),delete this._datafeed,this._destroyed=!0}addSubscription(e,t,i){const s=this._getNextSubscriptionId();this._pendingSubscribers.push({key:s,range:e,onHistoryCallback:t,onErrorCallback:i}),Re.Interval.isDWM(this._resolution)&&void 0!==e.to&&null!==this._dwmAligner&&e.to%864e5&&this._logWarning(`Internal error: invalid date for DWM resolution ${$v(e.to)}, expected time without a time part`),this._clearResetCacheTimeout();return setTimeout((()=>{this._destroyed||this._processPendingSubscribers()}),0),s}removeSubscription(e){const t=this._pendingSubscribers.find((t=>t.key===e));if(t)return void this._pendingSubscribers.splice(this._pendingSubscribers.indexOf(t),1)
;const i=this._subscribers.find((t=>t.key===e));if(i)return this._subscribers.splice(this._subscribers.indexOf(i),1),void(this._subscribers.length||(this._resetCacheTimeout=window.setTimeout((()=>{this._resetCacheTimeout=null,this._purgeCache(),this._unsubscribeRealtime()}),this._resetCacheTimePeriod)));this._logWarning("Unknown subscription symbol={0}, resolution={1}, key={2}".format(this._symbolInfo.name,this._resolution,e))}resetCache(){this._unsubscribeRealtime();const e=this._leftDate;this._purgeCache(),null===e||l.enabled("request_only_visible_range_on_reset")||this._ensureRequestedTo({to:e,countBack:0})}_logMessage(e,t){(l.enabled("charting_library_debug_mode")||t)&&console.log(`${this._logMessagePrefix()}${e}`)}_logWarning(e){console.warn(`${this._logMessagePrefix()}${e}`)}_logError(e){console.error(`${this._logMessagePrefix()}${e}`)}_logMessagePrefix(){const e=this._symbolInfo.currency_code,t=this._symbolInfo.unit_id;return`${(new Date).toISOString()} FEED [${this._symbolInfo.name}|${this._resolution}${e?"|"+e:""}${t?"|"+t:""}]: `}_clearResetCacheTimeout(){null!==this._resetCacheTimeout&&(clearTimeout(this._resetCacheTimeout),this._resetCacheTimeout=null)}_purgeCache(){this._logMessage("Reset cache"),this._cache={bars:[]},this._errorMessage=null,this._leftDate=null,this._endOfData=!1,this._firstDataRequest=!0,this._updateDatesFromExpirationDate()}_updateDatesFromExpirationDate(){void 0!==this._symbolInfo.expiration_date&&(this._nextTime=1e3*this._symbolInfo.expiration_date,this._leftDate=1e3*(this._symbolInfo.expiration_date+1))}_dealignTime(e){return null===this._dwmAligner?e:this._dwmAligner.timeToExchangeTradingDay(e)}_normalizeRange(e){const t=void 0!==e.to?e.to:this._dealignTime(this._now());if(0===this._cache.bars.length||void 0!==e.to&&t<=(0,n.ensureNotNull)(this._leftDate))return{countBack:e.countBack,to:t};const i=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(t):t,s=(0,Pt.lowerbound)(this._cache.bars,i,((e,t)=>e.time<t));return e.countBack<s?{countBack:0,to:0!==e.countBack&&s<=this._cache.bars.length?this._dealignTime(this._cache.bars[s-e.countBack].time):t}:{countBack:e.countBack-s,to:this._dealignTime(this._cache.bars[0].time)}}_processPendingSubscribers(){const e=this._pendingSubscribers;if(!e.length)return;if(this._requesting)return void this._logMessage("Processing is skipped due active request");if(this._logMessage(`Processing pending subscribers, count=${e.length}`),this._errorMessage){const t=this._errorMessage;return this._logMessage(`Return error: ${t}`),this._pendingSubscribers=[],void e.forEach((e=>{e.onErrorCallback(t)}))}let t=this._normalizeRange(e[0].range);for(const i of e.map((e=>this._normalizeRange(e.range))))(i.to<t.to||i.to===t.to&&i.countBack>t.countBack)&&(t=i);this._logMessage(`Leftmost subscriber requires ${t.countBack} bars prior ${$v(t.to)}`);!(null===this._leftDate||t.to<this._leftDate&&(null===this._nextTime||t.to<this._nextTime)||0!==t.countBack)||this._endOfData?(this._pendingSubscribers=[],e.forEach((e=>{const t=this._moveSubscriberToRealtime(e)
;this._returnHistoryDataToSubscriber(e,t)})),this._subscribeRealtimeIfNeeded()):this._ensureRequestedTo(t)}_moveSubscriberToRealtime(e){const t={key:e.key,onHistoryCallback:e.onHistoryCallback,barset:null};return this._subscribers.push(t),t}_isSymbolExpired(){return this._symbolInfo.expired||void 0!==this._symbolInfo.expiration_date}_subscribeRealtimeIfNeeded(){!this._subscribers.length||this._realtimeOn||this._isSymbolExpired()||this._subscribeRealtime()}_subscribeRealtime(){if(this._symbolInfo.expired||this._realtimeOn)return;this._realtimeOn=!0,this._datafeed.subscribeBars(this._symbolInfo,this._resolution,(e=>{null!==this._dwmAligner&&(e.time=this._dwmAligner.timeToSessionStart(e.time)),this._putToCacheNewBar(e),this._subscribers.forEach((t=>{const i=t.barset;if(null===i)throw new Error("subscriber.barset is null");i.add(e),t.onHistoryCallback(i)}))}),qv(this._symbolInfo,this._resolution),this.resetCache.bind(this)),this._logMessage("Subscribed to realtime")}_unsubscribeRealtime(){!this._isSymbolExpired()&&this._realtimeOn&&(this._datafeed.unsubscribeBars(qv(this._symbolInfo,this._resolution)),this._logMessage("Unsubscribed from realtime"),this._realtimeOn=!1)}_returnHistoryDataToSubscriber(e,t){const i=this._normalizeRange(e.range),s=this._createBarsetForRange(i);s.count()>0?this._logMessage("Bars to return for request {0}: total {1} bars in [{2} ... {3}] ".format(e.key,s.count(),$v(s.bars[0].time),$v(s.bars[s.count()-1].time))):this._logMessage("Request {0}. Nothing to return.".format(e.key)),t.barset=s,this._endOfData&&null!==this._leftDate&&i.to<=this._leftDate&&(s.endOfData=!0),e.onHistoryCallback(s)}_createBarsetForRange(e){const t=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(e.to):e.to,i=(0,Pt.lowerbound)(this._cache.bars,t,((e,t)=>e.time<t)),s=new Gv(this._symbolInfo,this._cache.bars.slice(Math.max(0,i-e.countBack)));return 0!==s.bars.length?s.firstLoadedTimeMs=this._dealignTime(s.bars[0].time):0!==this._cache.bars.length?s.firstLoadedTimeMs=this._dealignTime(this._cache.bars[this._cache.bars.length-1].time):s.firstLoadedTimeMs=this._dealignTime((0,n.ensureNotNull)(this._leftDate)),s}_ensureRequestedTo(e){let t;if(this._requesting&&this._logMessage("Internal error: trying to call getBars while the previous request is active",!0),null!==this._leftDate)t=this._leftDate;else{const e=this._now();if(null===this._dwmAligner)t=e;else{let i=this._sessionSpec.alignToNearestSessionStart(new Date(e),1).getTime();if(i<e){const e=this._sessionSpec.alignToNearestSessionEnd(new Date(i),1).getTime();i=this._sessionSpec.alignToNearestSessionStart(new Date(e+1e3),1).getTime()}t=this._dealignTime(i)}}const i=(0,Td.alignPeriodsBackForDataRequest)(this._symbolInfo.session,this._symbolInfo.session_holidays,this._symbolInfo.corrections,this._interval.letter(),this._interval.multiplier(),e.countBack,Math.min(e.to,t,this._nextTime??1/0));let s=e.countBack;if(e.to<t){s+=(0,
Td.getPeriodsBetweenDates)(this._symbolInfo.session,this._symbolInfo.session_holidays,this._symbolInfo.corrections,this._interval.letter(),this._interval.multiplier(),e.to,t)}if(null!==this._leftDate&&this._leftDate<i)return void this._processPendingSubscribers();const o=this._firstDataRequest||(this._isSymbolExpired()?0===this._cache.bars.length:null===this._leftDate);this._firstDataRequest=!1,this._requesting=!0,this._nextTime=null,this._leftDate=i;const n=`[${$v(i)} ... ${$v(t)}, ${s} bars]`;this._logMessage(`Requesting data: ${n}`);let r=!1;const a=i/1e3,l=t/1e3;this._datafeed.getBars(this._symbolInfo,this._resolution,{from:this._interval.isTicks()?a:Math.floor(a),to:this._interval.isTicks()?l:Math.floor(l),countBack:s,firstDataRequest:o},((e,t)=>{if(!this._destroyed)if(r)this._logMessage("getBars callback is already called before",!0);else{if(r=!0,e.length>0){const t=` [${$v(e[0].time)} ... ${$v(e[e.length-1].time)}]`;this._logMessage(`Receiving bars: total ${e.length} bars in ${t}, requested range: ${n}`)}else this._logMessage(`Receiving bars: barset is empty, requested range: ${n}`);this._requesting=!1,this._processBars(e,t)}}),(e=>{this._destroyed||(r?this._logMessage("getBars callback is already called before",!0):(r=!0,this._requesting=!1,this._errorMessage=e||null,this._processPendingSubscribers()))}))}_processBars(e,t){this._checkBars(e),this._alignBarsTime(e),e.length>0?(this._emptyResponsesCount=0,this._processFullBarset(e,t)):(this._emptyResponsesCount+=1,this._processEmptyBarset(t)),this._processPendingSubscribers()}_processEmptyBarset(e){e&&e.nextTime?(this._logMessage("Next time received: `{0}`".format($v(1e3*e.nextTime))),this._nextTime=1e3*e.nextTime):e&&e.noData?this._setEndOfData():this._logMessage("nextTime or noData should present in metainfo when empty barset is returned"),50===this._emptyResponsesCount&&(this._logMessage("EOD detected due 50 empty responses in a row"),this._setEndOfData())}_setEndOfData(){this._logMessage("EOD received"),this._endOfData=!0,this._cache.bars.length&&(this._leftDate=this._dealignTime(this._cache.bars[0].time))}_processFullBarset(e,t){this._putToCache(e)?null!==this._leftDate&&0!==this._cache.bars.length&&(this._interval.isTicks()?this._leftDate=this._dealignTime(this._cache.bars[0].time):this._leftDate=Math.min(this._leftDate,this._dealignTime(this._cache.bars[0].time))):this._logMessage("Incremental update failed. Starting full update. Returned data should be in the requested range.",!0),t&&t.nextTime?this._logWarning("nextTime should be set when there is no data in the requested period only"):t&&t.noData&&this._setEndOfData()}_getNextSubscriptionId(){return this._nextSubscriptionId++}_checkBars(e,t=!1){if(l.enabled("charting_library_debug_mode"))for(let i=1;i<e.length;i++){if(e[i].time<=e[i-1].time){let s=`Wrong bars time: time ${e[i].time} of bar ${i} should be more than time ${e[i-1].time} of bar ${i-1}`;t&&null!==this._dwmAligner&&(s+="\nCheck that you provide DWM bars without time part, i.e. 00:00 GMT"),this._logError(s)}
const s=this._getExpectedBarPropertyNames();s.some((t=>"number"!=typeof e[i][t]||!isFinite(e[i][t])))&&this._logError(`Wrong bars values: all ${s.join(", ")} properties should be numbers`)}}_getExpectedBarPropertyNames(){switch(this._symbolInfo.visible_plots_set){case"c":return["close","time"];case"hlc":return["high","low","close","time"];default:return["high","low","open","close","time"]}}_putToCache(e){if(0===e.length)return!0;if(this._cache.bars.length===e.length&&this._cache.bars[0].time===e[0].time&&this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time)return this._logMessage("Time range of received data is the same as cached one. Skip the update."),!0;if(0!==this._cache.bars.length&&e[e.length-1].time===this._cache.bars[0].time&&this._cache.bars.splice(0,1),0!==this._cache.bars.length&&e[e.length-1].time>=this._cache.bars[0].time){const t=this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time;if(this._cache.bars=[],!t)return this._leftDate=null,!1;this._logMessage("Received history up to now instead of incremental update. Return exactly what is requested.")}return this._cache.bars=[...e,...this._cache.bars],this._checkBars(this._cache.bars,!0),!0}_putToCacheNewBar(e){const t=this._cache.bars.length,i=e.time,s=0===t?NaN:this._cache.bars[t-1].time;0===t||s<i?this._cache.bars.push(e):s===i?(this._interval.isTicks()&&this._logMessage("Received update for the last tick bar"),this._cache.bars[t-1]=e):this._logError(`putToCacheNewBar: time violation, previous bar time: ${$v(s)} should be less or equal to new time: ${$v(i)}`)}_alignBarsTime(e){if(this._dwmAligner)for(const t of e)t.time=this._dwmAligner.timeToSessionStart(t.time)}_now(){return Date.now()+1e3*this._serverTimeOffsetGetter()+6e4}}class Yv{constructor(e,t,i){this._threads={},this._datafeed=e,this._serverTimeOffsetGetter=t,this._resetCacheTimePeriod=i}destroy(){this._forEachThread(((e,t)=>t.destroy())),this._threads={},delete this._datafeed}purgeCache(){this._forEachThread(((e,t)=>t.destroy())),this._threads={}}resetCache(){this._forEachThread(((e,t)=>t.resetCache()))}subscribe(e,t,i,s,o){const n=qv(e,t);this._threads[n]||(this._threads[n]=this._createThread(e,t));return n+'"'+this._threads[n].addSubscription(i,s,o)}unsubscribe(e){const t=e.split('"');if(2!==t.length)return void this._logWarning("Wrong guid format");const i=t[0],s=parseInt(t[1]);this._threads.hasOwnProperty(i)?this._threads[i].removeSubscription(s):this._logWarning("Data thread doesnt exist: "+e)}_createThread(e,t){return new Kv(this._datafeed,e,t,this._serverTimeOffsetGetter,(0,Jd.createDwmAligner)(t,e),this._resetCacheTimePeriod)}_forEachThread(e){Object.keys(this._threads).forEach((t=>e(t,this._threads[t])))}_logWarning(e){console.warn(`${(new Date).toISOString()} FEED: ${e}`)}}class Zv{constructor(){this._listeners=[]}listenersCount(){return this._listeners.reduce(((e,t)=>e+(t?1:0)),0)}addListener(e,t){this._listeners.push({dataListener:e,onErrorCallback:t}),this._barset&&e(this._barset),this._errorMsg&&t(this._errorMsg)}removeListener(e){
const t=this._listeners.filter((t=>t&&t.dataListener===e));if(0===t.length)return;const i=this._listeners.indexOf(t[0]);delete this._listeners[i]}onError(e){this._errorMsg=e||"unspecified error";const t=this._listeners,i=t.length;for(let s=0;s<i;s++){const i=t[s];i&&i.onErrorCallback&&i.onErrorCallback(e)}}fire(e,t){t||(this._barset=e);const i=this._listeners,s=i.length;for(let t=0;t<s;t++){const s=i[t];s&&s.dataListener(e)}}}var Xv=i(30342);class Jv{constructor(e,t,i,s,o,n,r){this.periodBase="",this._shouldAlignDwmBarsToMainSeries=l.enabled("align_dwm_bars_to_main_series"),this._canExtendTimeScale=l.enabled("secondary_series_extend_time_scale");const a=(0,Pv.decodeExtendedSymbol)(e),c="string"==typeof a.symbol?a:a.symbol;if((0,Pv.isStudySymbol)(c))throw new Error(`Unexpected nested study symbol: ${e}`);const h="string"==typeof a.symbol?a.symbol:a.symbol.symbol;this.ticker=h,this.currencyCode=i||c["currency-id"],this.unitId=s||c["unit-id"],this.subsessionId=r||c.session;const d=c["currency-id"]!==this.currencyCode||c["unit-id"]!==this.unitId;c["currency-id"]=this.currencyCode,c["unit-id"]=this.unitId,d&&(e=(0,Pv.encodeExtendedSymbolOrGetSimpleSymbolString)(a)),this.tickerid=e;const u=Re.Interval.parse(t);this.resolution=u.letter(),this.interval=u.multiplier(),this.period=u.value(),this.index=-1,this.time=NaN,this.open=NaN,this.high=NaN,this.low=NaN,this.close=NaN,this.volume=NaN,this.updatetime=NaN,this.minTick=NaN,this.isNewBar=!1,this.isBarClosed=!1,this.isFirstBar=!1,this.isLastBar=!1,this.session=new Cd.SessionInfo("Etc/UTC","24x7"),this.regularSubsession=null,this.preMarketSubsession=null,this.postMarketSubsession=null,this.script=o,this.projectionTime=NaN,this.isBarUpdate=!1,this.isAdditionalDepthAllowed=!(0,Pv.isStudySymbol)(a)||a.type.includes("BarSetHeikenAshi"),n&&this.set_symbolinfo(n)}set_symbolinfo(e){if(e||console.error("WARN: symbolinfo isn't defined for "+this.tickerid),this.info=e,this.minTick=e.minmov/e.pricescale,this.currencyCode=e.currency_code,this.unitId=e.unit_id,this.subsessionId=e.subsession_id,this.timezone=(0,Ce.get_timezone)(e.timezone),this.utcTimezone=(0,Ce.get_timezone)("Etc/UTC"),this.session.init(e.timezone,e.session,e.session_holidays,e.corrections),void 0!==e.subsessions){const t=e.subsessions.find((e=>e.id===Xv.SubsessionId.Regular)),i=e.subsessions.find((e=>e.id===Xv.SubsessionId.PreMarket)),s=e.subsessions.find((e=>e.id===Xv.SubsessionId.PostMarket));void 0!==t&&(this.regularSubsession=new jv.SessionsSpec(e.timezone,t.session,e.session_holidays,t["session-correction"])),void 0!==i&&(this.preMarketSubsession=new jv.SessionsSpec(e.timezone,i.session,e.session_holidays,i["session-correction"])),void 0!==s&&(this.postMarketSubsession=new jv.SessionsSpec(e.timezone,s.session,e.session_holidays,s["session-correction"]))}}isdwm(){return""!==this.resolution&&"S"!==this.resolution&&"T"!==this.resolution}enable_dwm_aligning(e,t){this.dwm_aligner=(0,Td.newBarBuilder)(this.period,e,t)}bartime(){const e=this.time;if(!this.isdwm()||isNaN(e))return e;const t=(0,
n.ensureDefined)(this.timezone,"symbol instrument timezone");let i=(0,Ce.utc_to_cal)(t,e);return i=this.session.spec.correctTradingDay(i),(0,Ce.cal_to_utc)(t,i)}lastbar(e,t){if(isNaN(e.time))return;let i=e.time;if(this.dwm_aligner){const e=(0,Ce.get_cal_from_unix_timestamp_ms)(this.dwm_aligner.sessionSrc().timezone,i);!this._shouldAlignDwmBarsToMainSeries||this.dwm_aligner.sessionTgt().spec.includesDay(e)?(this.dwm_aligner.moveTo(i),i=this.dwm_aligner.startOfBar(0)):this._canExtendTimeScale&&this.utcTimezone&&((0,Ce.set_hms)(e,0,0,0,0,this.utcTimezone),i=(0,Ce.cal_to_utc)(this.utcTimezone,e))}const s=this.time!==i;s&&this.index>=0&&!this.isBarClosed&&(this.isNewBar=!1,this.isBarClosed=!0,this.script.calc(this)),this.time=i,this.open=e.open,this.high=e.high,this.low=e.low,this.close=e.close,this.volume=(0,Hd.isNumber)(e.volume)&&e.volume>=0?e.volume:NaN,this.updatetime=e.updatetime||NaN,this.isNewBar=s,this.isBarClosed=!!e.isBarClosed,this.isLastBar=!!e.isLastBar,this.projectionTime=e.projectionTime||NaN,this.isBarUpdate=!!t,this.isNewBar&&(this.index++,this.isFirstBar=0===this.index),this.script.calc(this)}}class Qv{constructor(e){this.mindepth=0,this.original=NaN,this.modified=!1,this._hist=null,this._histPos=0,this.symbol=e}valueOf(){return this.get(0)}get(e=0){return isNaN(e)&&(e=0),e=e||0,this._hist?e>=this._hist.length?(console.error("not enough depth: "+this),NaN):this._get(e):(this.mindepth=Py.Std.max(this.mindepth,e),NaN)}set(e){this._hist&&(this._hist[this._histPos]=e,this.modified=!0)}prepare(e){e===this.symbol&&(e.isNewBar?(this.original=this.get(0),!this.modified&&this._hist||this.add_hist()):this.set(this.original),this.modified=!1)}add_hist(){if(!this._hist){let e=Py.Std.na(this.mindepth)?Py.Std.max_series_default_size:Py.Std.max(this.mindepth+1,1);e=Math.round(e);const t=new Array(e);for(let i=0;i<e;i++)t[i]=NaN;this._hist=t,this._histPos=-1}this._histPos=Math.min(this._histPos+1,this._hist.length),this._histPos===this._hist.length&&(this._histPos=this._hist.length-1,this._hist.shift(),this._hist.push(NaN)),this._hist[this._histPos]=this.original}reset_hist(){null!==this._hist&&(this._hist=null,this.add_hist())}adopt(e,t,i){this._hist||(this.mindepth=NaN);const s=e.symbol.isBarUpdate?(()=>{const i=t.indexOf(e.get());return-1===i?0:i})():0,o=t.get(s);let n=e.indexOf(o);if(0!==i){const i=t.get(s+1);if(!Py.Std.na(i)){n=n===e.indexOf(i)?-1:n}}return n<0?NaN:this._get(n)}indexOf(e){if(!this._hist)return this.mindepth=NaN,-1;if(Py.Std.na(e))return-1;const t=this._hist.length,i=this.symbol.index+1,s=Math.min(t,i),o=(0,Pt.upperbound_int)(this._hist,e,0,s);return 0===o?-1:s-o}_get(e){if(null===this._hist)return NaN;let t=this._histPos-e;return t<0&&(t+=this._hist.length),this._hist[t]}}class eS extends Qv{add_hist(){if(this._hist||(this._hist=new Float64Array(2e3),this._histPos=-1),this._histPos=this._histPos+1,this._histPos===this._hist.length){const e=new Float64Array(2*this._hist.length);e.set(this._hist),this._hist=e}this._hist[this._histPos]=this.original}}class tS{constructor(e){
this.minimumAdditionalDepth=null,this.targetAnchor=null,this._vars=[],this._varsIndex=0,this._ctx=[],this._ctxIndex=0,this.symbol=e}new_sym(e,t,i,s,o){return this.symbol.script.add_sym(e,t,i,s,o,void 0)}select_sym(e){const t=this.symbol.script.get_sym(e);null==t&&Py.Std.error(`Attempted to select symbol at index ${e} but there is no such symbol`),this.symbol=t}is_main_symbol(e){return void 0!==e&&e===this.symbol.script.get_sym(0)}new_var(e){const t=this._vars;t.length<=this._varsIndex&&t.push(new Qv(this.symbol));const i=t[this._varsIndex++];return arguments.length>0&&void 0!==e&&i.set(e),i}new_unlimited_var(e){const t=this._vars;t.length<=this._varsIndex&&t.push(new eS(this.symbol));const i=t[this._varsIndex++];return arguments.length>0&&i.set(e),i}new_ctx(){return this._ctx.length<=this._ctxIndex&&this._ctx.push(new tS(this.symbol)),this._ctx[this._ctxIndex++]}prepare(e){this._ctxIndex=0,this._varsIndex=0;for(let t=0;t<this._vars.length;t++)this._vars[t].prepare(e);for(let t=0;t<this._ctx.length;t++)this._ctx[t].prepare(e)}maxAdditionalDepth(){if(null!==this.minimumAdditionalDepth)return this.minimumAdditionalDepth;let e=0;for(let t=0;t<this._vars.length;t++){const i=this._vars[t].mindepth;!isNaN(i)&&i>e&&(e=i)}return e}stop(){this.symbol=null,this._vars=null}setMinimumAdditionalDepth(e){this.minimumAdditionalDepth=e}setTargetAnchor(e){this.targetAnchor=e}}function iS(e){return!Array.isArray(e)&&"composite"!==e.type&&"non_series_bars"!==e.type&&!!e.nonseries}class sS{constructor(e,t,i,s,o,n,r,a,l,c,h){this._body=n,this._symbols=[],this._runner=o,this._inputCallback=a,this._out=r,this._nonseriesOut=l,this._ctx=new tS(this.add_sym(e,t,i,s,h,c)),this.init()}calc(e){const t=this._ctx,i=this._body;t.prepare(e);const s=i.main(t,this._inputCallback,e);var o;if(null!=s)if(null===(o=s)||Array.isArray(o)||"composite"!==o.type)this._processResult(s);else for(let e=0;e<s.data.length;++e)this._processResult(s.data[e])}init(){const e=this._ctx,t=this._body;t.init&&t.init(e,this._inputCallback),t.main(e,this._inputCallback)}add_sym(e,t,i,s,o,n){const r=this._runner.add_sym(e,t,i,s,this,o,n);return this._symbols.push(r),r.isdwm()&&this._symbols.length>1&&this._runner.host.enableDwmAligning&&r.enable_dwm_aligning(this._symbols[0].session,r.session),r}maxAdditionalDepth(){return this._symbols[0].isAdditionalDepthAllowed?this._ctx.maxAdditionalDepth():0}targetAnchor(){return this._ctx.targetAnchor}stop(){this._symbols=null,this._ctx?.stop(),this._ctx=null}get_sym(e){return this._symbols[e]}_processResult(e){const t=this._ctx;var i;this._out&&e&&(!isNaN(t.symbol.time)||iS(e))&&(iS(e)?(i=e,Array.isArray(i)||"projection"!==i.type||(e.projectionTime=t.symbol.time),this._nonseriesOut(t.symbol,e)):!function(e){return!Array.isArray(e)&&("non_series_bars"===e.type||"projection"===e.type)}(e)?this._out(t.symbol,e):e.bars.forEach((e=>{this._out(t.symbol,e)})))}}class oS{constructor(e){this._nonseriesUpdate=null,this._script=null,this._symbols=[],this._barsets=[],this._subscription=[],this.host=e,this._isRecalculated=!1,this.isStarted=!1,
this.start()}add_sym(e,t,i,s,o,n,r){const a=new Jv(e,t,i,s,o,r,n);return this._symbols.push(a),a}get_sym(e){return this._symbols[e]}out(e,t){if(this._nonseriesUpdate){const i=Object.assign({},this._nonseriesUpdate);t.splice(0,0,e.time),i.lastBar=t,this.host.nonseriesOut(e,i)}else this.host.out(e,t)}start(){this.isStarted=!0;const e=this.host,t=new sS(e.tickerid,e.period,e.currencyCode,e.unitId,this,e.body,this.out.bind(this),e.input,e.nonseriesOut,e.symbolInfo,e.subsessionId);this._script=t;const i=[],s=this._symbols;let o=null;const r=this._script.targetAnchor();let a=0;if(null!==r&&"number"==typeof e.dataRange.to){const t=(0,Ce.get_timezone)(e.symbolInfo.timezone);if(!t)return;const i=(0,Ce.utc_to_cal)(t,e.dataRange.to);if("Week"===r){const e=(i.getDay()+6)%7;i.setDate(i.getDate()-e)}else if("Month"===r)i.setDate(1);else if("Quarter"===r){const e=3*Math.floor(i.getMonth()/3);i.setMonth(e),i.setDate(1)}else if("Year"===r)i.setMonth(0),i.setDate(1);else if("Decade"===r){const e=10*Math.floor(i.getFullYear()/10);i.setFullYear(e),i.setMonth(0),i.setDate(1)}else if("Session"===r){const t=Cd.SessionInfo.create(e.symbolInfo.timezone,e.symbolInfo.session,e.symbolInfo.session_holidays,e.symbolInfo.corrections);o=(0,Td.alignExchangeTimeToSessionStartAndReturnUTC)(t.spec,i)}if("Session"!==r&&(i.setHours(0,0,0,0),o=(0,Ce.cal_to_utc)(t,i)),null!==o){const t=e.symbolInfo,i=Re.Interval.parse(e.period);a=(0,Td.getPeriodsBetweenDates)(t.session,t.session_holidays,t.corrections,i.letter(),i.multiplier(),o,e.dataRange.to),e.dataRange.from=o}}const l=Object.assign({},e.dataRange,{countBack:Math.max((e.dataRange.countBack??0)+this._script.maxAdditionalDepth(),a)}),c=s[0],h=(t,s,o)=>{i.push(e.datafeed.subscribe(t.tickerid,t.currencyCode,t.unitId,t.period,o,e.onErrorCallback,e.symbolInfo,e.sessionId,s,e.forceAlignBars,t.subsessionId))},d=(t,i)=>{"series"===(i.nonseries?"nonseries":"series")?this.update(t,i):i.lastBar?(this._nonseriesUpdate=i,i.lastBar.isLastBar=!0,"projection"===i.type&&(i.lastBar.projectionTime=i.lastBar.time),this._symbols[0].lastbar(i.lastBar),this._nonseriesUpdate=null):e.nonseriesOut(s[0],i)},u=()=>l;h(c,u,(e=>{!e.nonseries&&Number.isFinite(e.firstLoadedTimeMs)&&(e=>{function i(i,s){let r=(0,Jd.createTimeToBarTimeAligner)(i,s)(e);const a=(0,Jd.createDwmAligner)(i,s);null!==a&&(r=a.timeToExchangeTradingDay(r));let l=0;if(null!==o){const e=Re.Interval.parse(i);l=(0,Td.getPeriodsBetweenDates)(s.session,s.session_holidays,s.corrections,e.letter(),e.multiplier(),o,r)}return{to:o??r,countBack:Math.max((0,n.ensureNotNull)(t,"script runner script").maxAdditionalDepth(),Math.ceil(1.05*l))}}for(let e=1;e<s.length;e++){const t=s[e],o=t.period;Re.Interval.isEqual(o,c.period)||h(t,i.bind(null,o),d.bind(null,e))}})(e.firstLoadedTimeMs),d(0,e)}));for(let e=1;e<s.length;e++){const t=s[e];Re.Interval.isEqual(t.period,c.period)&&h(t,u,d.bind(null,e))}this._subscription=i}stop(){const e=this._subscription;if(e||this._script){if(null!==e)for(let t=0;t<e?.length;t++)this.host.datafeed.unsubscribe(e[t]);this._subscription=null,
this._script?.stop(),this._script=null,this._symbols=null,this.isStarted=!1}else console.warn("Recurring script engine stop happened.")}update(e,t){if(!t)return void console.error("Unexpected barset = null");const i=this._symbols[e];if(this._isRecalculated){const e=t.bar(t.count()-1);e.isBarClosed=t.isLastBarClosed(),e.isLastBar=!0,i.lastbar(e,!0)}else this._barsets[e]||(this._barsets[e]=t,i.set_symbolinfo(t.symbolinfo()),this.recalc())}recalc(){const e=this._symbols;for(let t=0;t<e.length;t++)if(!this._barsets[t])return;try{for(let t=e.length-1;t>=0;t--){const i=e[t],s=this._barsets[t],o=s.count();for(let e=0;e<o;e++){const t=s.bar(e);t.isLastBar=e===o-1,t.isBarClosed=!t.isLastBar||s.isLastBarClosed(),i.lastbar(t)}}this._isRecalculated=!0;const t=this._barsets.every((e=>e.endOfData));t&&this.host.setNoMoreData(),this.host.recalc(this,{endOfData:t,firstLoadedTimeMs:this._barsets[0].firstLoadedTimeMs,emptyBarCount:this._barsets[0].emptyBarCount()})}catch(e){if(!(e instanceof kv.StudyError))throw e;this.host.onErrorCallback(e.message,e.title)}}}class nS{constructor(e){this.runner=new oS(e)}stop(){this.runner.stop()}isStarted(){return this.runner.isStarted}}class rS{constructor(e,t,i,s,o,n,r,a,l,c,h){this.listeners=t,this._isRecalculated=!1,this._symbolInfo=a,this.engine=new nS({datafeed:e,tickerid:i,currencyCode:s,unitId:o,subsessionId:h,period:n,body:r,sessionId:c,symbolInfo:a,dataRange:l,forceAlignBars:!1,enableDwmAligning:!1,input:()=>{throw new Error("BarBuildItem scripts should not need to access any input values")},recalc:(e,t)=>{this._recalc(t)},out:(e,t)=>{this._out(e,t)},nonseriesOut:(e,t)=>{this._nonseriesOut(e,t)},setNoMoreData:()=>{this._barset&&(this._barset.endOfData=!0)},onErrorCallback:e=>{this.listeners.onError(e)}})}stop(){this.engine?this.engine.stop():console.error("Internal library error 0x1")}_recalc(e){this._isRecalculated&&console.error("recalc called twice!"),this._barset||(this._barset=new Gv(this._symbolInfo)),e&&(this._barset.firstLoadedTimeMs=e.firstLoadedTimeMs,this._barset.endOfData=e.endOfData),this.listeners.fire(this._barset),this._isRecalculated=!0}_nonseriesOut(e,t){const i=Object.assign({},t);i.nonseries=!0,i.data=t.bars,delete i.bars,i.barsetSize=this._barset?this._barset.count():0,i.lastBar=this._barset&&this._barset.count()>0?this._barset.bar(this._barset.count()-1):null,this.listeners.fire(i,!0)}_out(e,t){const i=t[0];if(isNaN(i))return;const s={time:i,open:t[1],high:t[2],low:t[3],close:t[4],volume:t[5],updatetime:t[6]},o=t[7];this._barset||(this._barset=new Gv((0,n.ensureDefined)(e.info,"bar builder item output symbol info")));const r=t[8],a=t[9];if(r instanceof Array&&a)for(let e=0;e<r.length;e++){const t=r[e],i={time:t,open:a,high:a,low:a,close:a,volume:0,updatetime:t};this._barset.add(i,!0,!0),this._isRecalculated&&this.listeners.fire(this._barset)}this._barset.add(s,o),this._barset.isBarClosed=!!o,this._isRecalculated&&this.listeners.fire(this._barset)}}class aS{main(e){
const t=e.new_var(Py.Std.open(e)),i=e.new_var(Py.Std.close(e)),s=t.get(1),o=i.get(1),n=Py.Std.ohlc4(e),r=Py.Std.na(t.get(1))?(Py.Std.open(e)+Py.Std.close(e))/2:(s+o)/2;t.set(r),i.set(n);const a=Py.Std.max(Py.Std.high(e),Py.Std.max(r,n)),l=Py.Std.min(Py.Std.low(e),Py.Std.min(r,n)),c=Py.Std.volume(e),h=e.symbol;return[h.time,r,a,l,n,c,h.updatetime,h.isBarClosed,void 0,void 0]}}var lS=i(4622);class cS{constructor(e,t,i,s,o,n,r,a){this.listeners=e,this._host=n,this._host.resolve(t,i,(e=>{o&&e.regular_session&&(e.session=e.regular_session),this._subs=this._host.subscribe(e,s,a,(e=>{this.listeners.fire(e)}),(e=>{this.listeners.onError(e)}))}),(e=>{this.listeners.onError(e)}))}stop(){this._subs&&this._host.unsubscribe(this._subs)}}var hS=i(99955);class dS{constructor(e,t){this._period=e,this._generateEmptyBars=!!t}init(e){this._bb=(0,Td.newBarBuilder)(this._period,e.symbol.session,null),this._bbEmptyBars=this._generateEmptyBars?(0,Td.newBarBuilder)(this._period,e.symbol.session,null):void 0,e.setMinimumAdditionalDepth(0)}main(e){const t=(0,n.ensureDefined)(this._bb,"bar builder study bar builder"),i=e.symbol.time,s=t.alignTime(i),o=e.new_var(s),r=Py.Std.na(s),a=o.get(1),l=Py.Std.na(a)?1:Py.Std.neq(s,a),c=e.new_var(),h=e.new_var(),d=e.new_var(),u=e.new_var(),_=c.get(1),p=h.get(1),m=d.get(1),g=u.get(1),f=r?NaN:l?Py.Std.open(e):_,y=r?NaN:l?Py.Std.high(e):Py.Std.max(Py.Std.high(e),p),v=r?NaN:l?Py.Std.low(e):Py.Std.min(Py.Std.low(e),m),S=r?NaN:Py.Std.close(e),b=r?NaN:l?Py.Std.volume(e):Py.Std.volume(e)+g,w=r?NaN:i,C=e.symbol.isBarClosed&&t.isLastBar(0,i),T=this._generateEmptyBars&&l?this._extrapolate(a,s):void 0,P=e.new_var(Py.Std.close(e)).get(1),x=T instanceof Array?P:NaN;return c.set(f),h.set(y),d.set(v),u.set(b),[s,f,y,v,S,b,w,C,T,x]}_extrapolate(e,t){return isNaN(e)||isNaN(t)?void 0:(0,hS.extrapolateBarsFrontToTime)((0,n.ensureDefined)(this._bbEmptyBars,"bar builder study empty bar builder"),e,t,Number.MAX_SAFE_INTEGER,!0).times}}const uS=e=>{console.error(e),Py.Std.error(e)},_S=Re.Interval.parse("1M").inMilliseconds(0);class pS{constructor(e){this._host=e,this._cache={}}subscribe(e,t,i,s,o,n,r,a,l,c,h){const d=l(r),u=((e,t,i,s,o,n,r,a,l)=>n+e+s+(t||"")+(i||"")+(l||"")+(o.has_empty_bars?"_":"")+"_"+r.countBack+"_"+r.to+"_"+Boolean(a))(e,t,i,s,r,a,d,c,h);let _=this._getCache(u);return _||(_=this._createItem(e,t,i,s,r,d,a,c,h),this._putCache(u,_)),_.listeners.addListener(o,n),{key:u,listener:o}}unsubscribe(e){const t=this._getCache(e.key);t&&t.listeners.removeListener(e.listener)}removeUnused(){const e=[],t=e=>!!this._cache[e];for(const i in this._cache)if(t(i)){0===(0,n.ensureNotNull)(this._cache[i],`datafeed cache item ${i}`).listeners.listenersCount()&&e.push(i)}if(0!==e.length){for(let t=0;t<e.length;t++){const i=e[t],s=(0,n.ensureNotNull)(this._cache[i],`unused datafeed cache item ${i}`);this._cache[i]=null,s.stop()}this.removeUnused()}}_getCache(e){return this._cache[e]}_putCache(e,t){this._cache[e]=t}_rebuildFrom(e,t){const i=(0,lS.findSuitableResolutionToBuildFrom)(e,t);if(i.error)throw uS(i.errorMessage),
new Error(i.errorMessage);return i.resolution}_createItem(e,t,i,s,o,n,r,a,l){const c=new Zv,h=(0,Pv.decodeExtendedSymbol)(e),d="string"!=typeof h.symbol?h.symbol:h;t=d["currency-id"]||t,i=d["unit-id"]||i;const u=d.symbol,_=d.session&&d.session!==Xv.SubsessionId.Extended;if((l=d.session||l)===Xv.SubsessionId.Regular&&(l=void 0),"type"in h){const e=Object.assign({},o);return o.has_empty_bars&&(e.has_empty_bars=!1),new rS(this,c,u,t,i,s,function(e){if(0===e.type.indexOf("BarSetHeikenAshi@tv-basicstudies-"))return new aS;const t=`unknown builder type: ${e.type}`;throw console.error(t),new Error(t)}(h),e,n,r,l)}a&&!(0,Jd.isAlignmentEnabled)()&&uS("Internal error: rebuilding is requested but it is disabled."),!a&&o.has_empty_bars&&uS('Misconfiguration error: attempt to request data for symbol with "has_empty_bars" flag, but "disable_resolution_rebuild" featureset is enabled');const p=this._rebuildFrom(s,o);if(!Re.Interval.isTicks(s)&&(!Re.Interval.isEqual(s,p)||a)){(0,Jd.isAlignmentEnabled)()||uS('Misconfiguration error: remove "disable_resolution_rebuild" featureset or provide '+s+" data by yourself");const a=o.has_empty_bars,h=Object.assign({},o);o.has_empty_bars&&(h.has_empty_bars=!1);const d=Math.ceil((m=Re.Interval.parse(s),g=Re.Interval.parse(p),m.kind()===g.kind()?m.multiplier()/g.multiplier():(m.isMonths()?m.multiplier()*_S:m.inMilliseconds())/(g.isMonths()?g.multiplier()*_S:g.inMilliseconds())));return n=Object.assign({},n,{countBack:n.countBack*d}),new rS(this,c,e,t,i,p,new dS(s,a),h,n,r,l)}var m,g;return new cS(c,u,{currency:t,unit:i,session:l},s,!!_,this._host,o,n)}}function mS(e,t,i){return(0,tt.isArray)(e)?function(e,t,i){return e.map((e=>{const s=mS(e,t,i),o=t(s);return void 0!==o?o:s}))}(e,t,i):(0,tt.isObject)(e)&&((0,tt.isHashObject)(e)||i&&i.visitInstances)?function(e,t,i){const s={};return Object.keys(e).forEach((o=>{const n=mS(e[o],t,i),r=t(n);s[o]=void 0!==r?r:n})),s}(e,t,i):e}function gS(e,t,i){const s=mS(e,t,i),o=t(s);return void 0!==o?o:s}var fS,yS=i(92211);function vS(e,t){return e.length>t}!function(e){e[e.DefaultExtrapolateLimit=2e5]="DefaultExtrapolateLimit",e[e.ExtendedExtrapolateLimit=45e4]="ExtendedExtrapolateLimit"}(fS||(fS={}));class SS{constructor(e,t,i){this._firstRealBarTimeMs=null,this._historyBarsCache=[],this._projectionFirstIndex=1/0,this._barsTimes=[],this._minFutureBarsCount=0,this._lastRealBarTimeMs=null,this._futureBarsCache=[],this._symbolInfo=e,this._interval=Re.Interval.parse(t),this._extrapolateLimit=i??(l.enabled("extended_extrapolation_limit")?45e4:2e5),this._session=new Cd.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),this._barBuilder=(0,Td.newBarBuilder)(t,this._session,null)}destroy(){this.clear()}interval(){return this._interval}barBuilder(){return this._barBuilder}symbolInfo(){return this._symbolInfo}clear(){this._firstRealBarTimeMs=null,this._historyBarsCache=[],this._barsTimes=[],this._lastRealBarTimeMs=null,this._futureBarsCache=[],this._minFutureBarsCount=0,this._projectionFirstIndex=1/0}firstFutureBarIndex(){return this._barsTimes.length}
futureBars(){return this._futureBarsCache}replaceBarsTimesTail(e,t=e.length){if(0===e.length)return;if(0===this._barsTimes.length)return void this.setBarsTimes(e,t);const i=e[0],s=this._barsTimes[this._barsTimes.length-1],o=i>s?this._barsTimes.length:(0,Pt.lowerbound_int)(this._barsTimes,i);0!==o?(this._barsTimes.splice(o,this._barsTimes.length,...e),this._projectionFirstIndex=t===e.length?this._barsTimes.length:this._barsTimes.indexOf(e[t]),(0,n.assert)(-1!==this._projectionFirstIndex,"something went wrong"),s!==e[e.length-1]&&this._setLastRealBarTime(e[e.length-1])):this.setBarsTimes(e,t)}setBarsTimes(e,t=e.length){const i=this._barsTimes;if(this._barsTimes=e.slice(),this._projectionFirstIndex=0===this._barsTimes.length?1/0:t,0===e.length)return this._historyBarsCache=[],this._futureBarsCache=[],this._firstRealBarTimeMs=null,void(this._lastRealBarTimeMs=null);0!==i.length&&i[i.length-1]===e[e.length-1]||this._setLastRealBarTime(e[e.length-1]),0!==i.length&&i[0]===e[0]||(this._historyBarsCache=[],this._firstRealBarTimeMs=e[0])}extrapolateTimeWithOffsetToTime(e,t){if(0===t)return{timeMs:e,exact:!0};0===this._barsTimes.length&&(t<0?null===this._firstRealBarTimeMs?this._firstRealBarTimeMs=e:(this._extendHistoryCacheToTimeFromRight(Math.min(e,null!==this._lastRealBarTimeMs?this._lastRealBarTimeMs:1/0)),this._ensureExtrapolatedToHistoryTime(e)):null===this._lastRealBarTimeMs?this._lastRealBarTimeMs=e:(this._extendFutureCacheToTimeFromLeft(Math.max(e,null!==this._firstRealBarTimeMs?this._firstRealBarTimeMs:1/0)),this.ensureExtrapolatedToFutureTime(e)));const i=this.indexOfTime(e);if(null===i)return null;const s=this.timeOfBarIndex(i.index+t,0);return null===s?null:((i.index<0||this._projectionFirstIndex<=i.index)&&(s.exact=!1),s)}indexOfTime(e){if(null!==this._firstRealBarTimeMs&&e<this._firstRealBarTimeMs){this._ensureExtrapolatedToHistoryTime(e);let t=(0,Pt.lowerbound_int)(this._historyBarsCache,e);if(0!==this._historyBarsCache.length&&0===t&&e<this._historyBarsCache[0])return null;t!==this._historyBarsCache.length&&this._historyBarsCache[t]===e||(t-=1);return{index:t-this._historyBarsCache.length,timeMs:this._historyBarsCache[t]}}if(null!==this._lastRealBarTimeMs&&e>this._lastRealBarTimeMs){this.ensureExtrapolatedToFutureTime(e);let t=(0,Pt.lowerbound_int)(this._futureBarsCache,e);if(0!==this._futureBarsCache.length&&t===this._futureBarsCache.length&&e>this._futureBarsCache[this._futureBarsCache.length-1])return null;this._futureBarsCache[t]!==e&&(t-=1);const i=Math.max(1,this._barsTimes.length)+t;return{index:i,timeMs:i===this._barsTimes.length-1?(0,n.ensureNotNull)(this._lastRealBarTimeMs):this._futureBarsCache[t]}}if(0===this._barsTimes.length){if(null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs<=e||null!==this._lastRealBarTimeMs&&e<=this._lastRealBarTimeMs){const e=this.timeOfBarIndex(0,0);return null===e?null:{index:0,timeMs:e.timeMs}}return null}let t=(0,Pt.lowerbound_int)(this._barsTimes,e);return this._barsTimes[t]!==e&&(t-=1),{index:t,timeMs:this._barsTimes[t]}}setMinFutureBarsCount(e){
this._minFutureBarsCount=e,0!==this._barsTimes.length&&this._ensureExtrapolatedToFutureBar(e)}ensureExtrapolatedToFutureTime(e){null!==this._lastRealBarTimeMs&&this._lastRealBarTimeMs>=e||vS(this._futureBarsCache,this._extrapolateLimit)||0!==this._futureBarsCache.length&&this._futureBarsCache[this._futureBarsCache.length-1]>=e||(l.enabled("disable_resolution_rebuild")&&(this._interval.isDays()||this._interval.isWeeks())&&this._barsTimes.length>=2?this._extendFutureCacheFromRight(((t,i)=>{const s=this._futureBarsCache.length>0?this._futureBarsCache[this._futureBarsCache.length-1]:t;return this._calculateBarPattern(s,e,null)})):this._extendFutureCacheFromRight(((t,i)=>(0,hS.extrapolateBarsFrontToTime)(this._barBuilder,t,e,this._extrapolateLimit,!0).times)),this._futureBarsCache[this._futureBarsCache.length-1]<e&&this._ensureExtrapolatedToFutureBar(this._futureBarsCache.length+1))}timeOfBarIndex(e,t=0){const i=this._timeOfBarIndex(e);if(null===i){this._ensureExtrapolatedToFutureBar(Math.max(0,0===this._barsTimes.length?0:this._barsTimes.length-1)+t+1);const i=this._timeOfBarIndex(e+t);null!==i&&this.ensureExtrapolatedToFutureTime(i.timeMs)}return i}_setLastRealBarTime(e){const t=this._futureBarsCache.length,i=(0,Pt.upperbound_int)(this._futureBarsCache,e);0===i?this._extendFutureCacheToTimeFromLeft(e):(this._lastRealBarTimeMs=e,this._futureBarsCache=this._futureBarsCache.slice(i)),this._ensureExtrapolatedToFutureBar(Math.max(t,this._minFutureBarsCount))}_timeOfBarIndex(e){if(e<0){const t=Math.abs(e);this._ensureExtrapolatedToHistoryBar(t);const i=this._historyBarsCache.length-t;return i<0?null:{timeMs:this._historyBarsCache[i],exact:!1}}if(0===e&&0===this._barsTimes.length)return{timeMs:(0,n.ensureNotNull)(this._firstRealBarTimeMs??this._lastRealBarTimeMs),exact:!1};if(e>=this._barsTimes.length){const t=e-Math.max(1,this._barsTimes.length);return this._ensureExtrapolatedToFutureBar(t+1),t>=this._futureBarsCache.length?null:{timeMs:this._futureBarsCache[t],exact:!1}}return{timeMs:this._barsTimes[e],exact:e<this._projectionFirstIndex}}_calculateBarPattern(e,t,i){const s=this.interval(),o=s.multiplier(),n=s.isDWM(),r=[];let a,l=e;a=s.isSeconds()?1e3:s.isMinutes()?6e4:s.isDays()?864e5:s.isWeeks()?6048e5:s.isMonths()?2592e6:864e5;let c=0;for(;(null===i||c<i)&&(null===t||l<t);){const e=l+o*a;let t=e;if(n){this._barBuilder.moveTo(e);const i=new Date(e),s=this._session.spec,o=s?.correctTradingDay(i);o&&(t=o.getTime())}else{this._barBuilder.moveTo(e);const i=this._barBuilder.indexOfBar(e);t=this._barBuilder.startOfBar(i)}if(r.includes(t)){const e=l+o*a;if(r.includes(e))break;r.push(e),l=e}else r.push(t),l=t;if(r.length>this._extrapolateLimit)break;c++}return r}_extendFutureCacheFromRight(e){const t=0!==this._futureBarsCache.length?this._futureBarsCache[this._futureBarsCache.length-1]:this._lastRealBarTimeMs;if(null===t)return!1;const i=e(t,this._futureBarsCache.length)||[];return 0!==i.length&&(this._futureBarsCache=this._futureBarsCache.concat(i),!0)}_extendHistoryCacheFromLeft(e){
const t=0!==this._historyBarsCache.length?this._historyBarsCache[0]:this._firstRealBarTimeMs;if(null===t)return;const i=e(t,this._historyBarsCache.length);this._historyBarsCache=i.concat(this._historyBarsCache)}_extendFutureCacheToTimeFromLeft(e){if(null!==this._lastRealBarTimeMs&&this._lastRealBarTimeMs<=e)return;if((0,n.assert)(0===this._barsTimes.length||e===this._barsTimes[this._barsTimes.length-1],"invalid argument"),this._lastRealBarTimeMs=e,0===this._futureBarsCache.length)return;const t=(0,hS.extrapolateBarsFrontToTime)(this._barBuilder,e,this._futureBarsCache[0]-1,this._extrapolateLimit,!0).times;this._futureBarsCache=t.concat(this._futureBarsCache)}_extendHistoryCacheToTimeFromRight(e){if(null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs>=e)return;if((0,n.assert)(0===this._barsTimes.length,"bars should be empty"),this._firstRealBarTimeMs=e,0===this._historyBarsCache.length)return;const t=(0,hS.extrapolateBarsFrontToTime)(this._barBuilder,this._historyBarsCache[this._historyBarsCache.length-1],e-1,this._extrapolateLimit,!0).times;this._historyBarsCache=this._historyBarsCache.concat(t)}_ensureExtrapolatedToFutureBar(e){return!(this._futureBarsCache.length>=e||vS(this._futureBarsCache,this._extrapolateLimit))&&(l.enabled("disable_resolution_rebuild")&&(this._interval.isDays()||this._interval.isWeeks())&&this._barsTimes.length>=2?this._extendFutureCacheFromRight(((t,i)=>{const s=this._futureBarsCache.length>0?this._futureBarsCache[this._futureBarsCache.length-1]:t,o=e-i;return this._calculateBarPattern(s,null,o)})):this._extendFutureCacheFromRight(((t,i)=>(0,hS.extrapolateBarsFrontByCount)(this._barBuilder,t,e-i,!0).times)))}_ensureExtrapolatedToHistoryBar(e){this._historyBarsCache.length>=e||vS(this._historyBarsCache,this._extrapolateLimit)||this._extendHistoryCacheFromLeft(((t,i)=>(0,hS.extrapolateBarsFrontByCount)(this._barBuilder,t,-(e-i),!0).times.reverse()))}_ensureExtrapolatedToHistoryTime(e){null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs<=e||vS(this._historyBarsCache,this._extrapolateLimit)||0!==this._historyBarsCache.length&&this._historyBarsCache[0]<=e||(this._extendHistoryCacheFromLeft(((t,i)=>{const s=(0,hS.extrapolateBarsFrontToTime)(this._barBuilder,t-1,e-1,this._extrapolateLimit,!0).times;return s[s.length-1]===t?s.slice(0,-1):s})),(0===this._historyBarsCache.length||this._historyBarsCache[0]>e)&&this._ensureExtrapolatedToHistoryBar(this._historyBarsCache.length+1))}}function bS(e){return 60*e*60*1e3}function wS(e){return 60*e*1e3}const CS=[{divisor:1,weight:18},{divisor:(TS=1,1e3*TS),weight:19},{divisor:wS(1),weight:20},{divisor:wS(5),weight:21},{divisor:wS(30),weight:22},{divisor:bS(1),weight:30},{divisor:bS(3),weight:31},{divisor:bS(6),weight:32},{divisor:bS(12),weight:33}];var TS,PS;function xS(e,t){if(null!==t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;const i=t.getTime(),s=e.getTime()
;for(let e=CS.length-1;e>=0;--e)if(Math.floor(i/CS[e].divisor)!==Math.floor(s/CS[e].divisor))return CS[e].weight}return 18}function MS(e,t,i=0){if(0===e.length)return[];let s=i,o=i;const n=[];for(;s<e.length;)o>=t.length?(n.push({old:s,new:Fh.INVALID_TIME_POINT_INDEX}),s++):e[s].timeMs===t[o].timeMs?(s!==o&&n.push({old:s,new:o}),s++,o++):e[s].timeMs<t[o].timeMs?(n.push({old:s,new:Fh.INVALID_TIME_POINT_INDEX}),s++):o++;return n.sort(((e,t)=>{if(e.new===t.new&&e.new===Fh.INVALID_TIME_POINT_INDEX)return e.old-t.old;if(e.new===Fh.INVALID_TIME_POINT_INDEX)return-1;if(t.new===Fh.INVALID_TIME_POINT_INDEX)return 1;const i=e.old-e.new,s=t.old-t.new;return i>0?s>0?e.old-t.old:-1:s<0?t.new-e.new:1}))}function IS(e,t){return{span:e.markWeight,time:e.displayTime,index:t}}!function(e){e[e.FutureTickMarksLimit=1e3]="FutureTickMarksLimit"}(PS||(PS={}));class AS{constructor(){this._completed=!0,this._mainSymbolExtrapolator=null,this._pointDataByTimePoint=new Map,this._instanceIds=new Set,this._displayTimezone=null,this._minFutureBarsCount=0,this._sortedTimePoints=[],this._needRebuildEndOfPeriod=l.enabled("end_of_period_timescale_marks"),this._shouldAlignDwmBarsToMainSeries=l.enabled("align_dwm_bars_to_main_series")}destroy(){this.clearTimeScale()}setCompleted(e){this._completed=e}isCompleted(){return this._completed}clearTimeScale(){return this._pointDataByTimePoint.clear(),this._instanceIds.clear(),this._sortedTimePoints=[],{baseIndex:null,pointsIndex:0,indexChange:[],marks:[],points:[],clearTickMarks:!0}}indexOfTime(e){if(0===this._sortedTimePoints.length)return null===this._mainSymbolExtrapolator?null:this._mainSymbolExtrapolator.indexOfTime(e);if(e<this._sortedTimePoints[0].timeMs){if(null===this._mainSymbolExtrapolator)return null;const t=this._mainSymbolExtrapolator.indexOfTime(e),i=this._mainSymbolExtrapolator.indexOfTime(this._sortedTimePoints[0].timeMs);if(null===t||null===i)return null;let s=t.index-i.index;return i.timeMs!==this._sortedTimePoints[0].timeMs&&(s-=1),{index:s,timeMs:t.timeMs}}if(e>this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs){if(null===this._mainSymbolExtrapolator)return null;const t=this._mainSymbolExtrapolator.indexOfTime(e),i=this._mainSymbolExtrapolator.indexOfTime(this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs);if(null===t||null===i)return null;const s=t.index-i.index-1;return{index:this._sortedTimePoints.length+s,timeMs:t.timeMs}}let t=(0,Pt.lowerbound)(this._sortedTimePoints,e,((e,t)=>e.timeMs<t));return this._sortedTimePoints[t].timeMs!==e&&(t-=1),{index:t,timeMs:this._sortedTimePoints[t].timeMs}}setMainSymbolExtrapolator(e){this._mainSymbolExtrapolator=e,this._updateFutureBars(),this._fillPointsData(this._sortedTimePoints,0)}setMinFutureBarsCount(e){this._minFutureBarsCount=e,this._updateFutureBars()}minFutureBarsCount(){return this._minFutureBarsCount}firstFutureBarIndex(){return this._sortedTimePoints.length}firstSessionBarIndex(){return 0===this._sortedTimePoints.length?null:0}lastSessionBarIndex(){
return 0===this._sortedTimePoints.length?null:this._sortedTimePoints.length-1}tickMarks(e=0){const t=this.firstFutureBarIndex();(0,n.assert)(e<=t,"tickmarks cannot be filtered in the future");const i=this._futureBars().map(((e,t)=>({timeMs:e,markWeight:0,displayTime:NaN})));this._fillPointsData(i,0,0!==this._sortedTimePoints.length?this._sortedTimePoints[this._sortedTimePoints.length-1].displayTime:null);const s=[];for(let t=e;t<this._sortedTimePoints.length;++t)s.push(IS(this._sortedTimePoints[t],t));const o=i.map(((e,i)=>IS(e,i+t)));return s.concat(o)}setTimezone(e){this._displayTimezone="exchange"===e?null:(0,Ce.get_timezone)(e),this._fillPointsData(this._sortedTimePoints,0)}fillIndexesInRows(e){if(0===e.length)return;let t=-1,i=(0,Pt.lowerbound)(this._sortedTimePoints,Math.round(1e3*e[0].value[0]),((e,t)=>e.timeMs<t));for(const s of e){const e=Math.round(1e3*s.value[0]);for(;i<this._sortedTimePoints.length&&this._sortedTimePoints[i].timeMs<e;)i+=1;i!==this._sortedTimePoints.length&&this._sortedTimePoints[i].timeMs===e||(i-=1),(0,n.assert)(i!==t,"data must have unique times"),t=i,s.index=i}(0,n.assert)(i<this._sortedTimePoints.length,"data must be within a data range")}convertTimesToIndexes(e,t=!1){if(0===e.length)return[];let i=-1,s=(0,Pt.lowerbound)(this._sortedTimePoints,e[0],((e,t)=>e.timeMs<t));return e.map(((e,o,r)=>{for(;s<this._sortedTimePoints.length&&this._sortedTimePoints[s].timeMs<e;)s+=1;if(0===s&&e<this._sortedTimePoints[0].timeMs)return Fh.INVALID_TIME_POINT_INDEX;if(s>=this._sortedTimePoints.length){const t=this.indexOfTime(e);if(null===t)return Fh.INVALID_TIME_POINT_INDEX;s=t.timeMs!==e?t.index+1:t.index}return(!t||o>0&&e<=r[o-1])&&(0,n.assert)(s>i,"data must have unique sorted times"),i=s,s}))}firstSeriesBarTime(){return 0===this._sortedTimePoints.length?null:this._sortedTimePoints[0].timeMs}replaceStudyBarsTimesTail(e,t){return this._replaceInstanceBarsTimesTail(e,t)}replaceBarsTimesTail(e,t){return this._replaceInstanceBarsTimesTail(e,t)}setSeriesBarsTimes(e,t){return this._setBarsTimes(e,t)}setStudyBarsTimes(e,t,i){return this._setBarsTimes(e,t,i)}_setBarsTimes(e,t,i){const s=0!==this._pointDataByTimePoint.size;if(this._instanceIds.has(e))for(const t of this._sortedTimePoints)t.pointData.instances.delete(e);0===t.length?this._instanceIds.delete(e):this._instanceIds.add(e),this._addBarsTimesToInstance(e,t,!1),s&&this._cleanupPointsData(this._sortedTimePoints);const o=[];this._pointDataByTimePoint.forEach(((e,t)=>{o.push({markWeight:0,timeMs:t,displayTime:NaN,pointData:e})})),o.sort(((e,t)=>e.timeMs-t.timeMs));const n=this._updateTimeScalePoints(o);return this._applyTimeScaleChanges(n,i||!1)}_replaceInstanceBarsTimesTail(e,t){if(0===t.length)return null;if(!this._instanceIds.has(e))return this._setBarsTimes(e,t);const i=[],s=(0,Pt.lowerbound)(this._sortedTimePoints,t[0],((e,t)=>e.timeMs<t));for(let t=s;t<this._sortedTimePoints.length;++t){const s=this._sortedTimePoints[t];s.pointData.instances.delete(e)&&0===s.pointData.instances.size&&i.push(s)}const o=this._addBarsTimesToInstance(e,t,!0)
;this._cleanupPointsData(i);const n=o.map((e=>({timeMs:e.timeMs,pointData:e.pointData,markWeight:0,displayTime:NaN})));for(let e=s;e<this._sortedTimePoints.length;++e){const t=this._sortedTimePoints[e];0!==t.pointData.instances.size&&n.push(t)}n.sort(((e,t)=>e.timeMs-t.timeMs));const r=this._updateTimeScalePointsTail(n);return this._applyTimeScaleChanges(r,!1)}_updateFutureBars(){if(0===this._minFutureBarsCount||null===this._mainSymbolExtrapolator)return;if(0!==this._sortedTimePoints.length){const e=this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs;this._mainSymbolExtrapolator.ensureExtrapolatedToFutureTime(e)}const e=this._futureBarsFirstPointIndex();this._mainSymbolExtrapolator.setMinFutureBarsCount(e+this._minFutureBarsCount)}_addBarsTimesToInstance(e,t,i){const s=i?[]:null;for(const i of t){const t=this._pointDataByTimePoint.get(i);if(void 0===t){const t=new Set;t.add(e);const o={index:0,instances:t};this._pointDataByTimePoint.set(i,o),null!==s&&s.push({timeMs:i,pointData:o})}else t.instances.add(e)}return s}_futureBarsFirstPointIndex(){if(null===this._mainSymbolExtrapolator||0===this._sortedTimePoints.length)return 0;const e=this._mainSymbolExtrapolator.futureBars();return(0,Pt.upperbound_int)(e,this._sortedTimePoints[this._sortedTimePoints.length-1].timeMs)}_futureBars(){return null===this._mainSymbolExtrapolator?[]:this._mainSymbolExtrapolator.futureBars().slice(this._futureBarsFirstPointIndex(),this._futureBarsFirstPointIndex()+1e3)}_cleanupPointsData(e){for(const t of e)0===t.pointData.instances.size&&this._pointDataByTimePoint.delete(t.timeMs)}_updateTimeScalePoints(e){let t=-1;for(let i=0;i<this._sortedTimePoints.length&&i<e.length;++i){const s=this._sortedTimePoints[i],o=e[i];if(s.timeMs!==o.timeMs){t=i;break}o.markWeight=s.markWeight,o.displayTime=s.displayTime}if(t=LS(t,this._sortedTimePoints.length,e.length),-1===t)return null;for(let i=t;i<e.length;++i){e[i].pointData.index=i}this._fillPointsData(e,t);const i=MS(this._sortedTimePoints,e,t);return this._sortedTimePoints=e,this._updateFutureBars(),{pointsIndex:t,indexChange:i}}_updateTimeScalePointsTail(e){if(0===e.length)return null;const t=(0,Pt.lowerbound)(this._sortedTimePoints,e[0].timeMs,((e,t)=>e.timeMs<t));let i=-1;for(let s=0;s<e.length;++s){const o=e[s],n=t+s;if(o.pointData.index=n,n>=this._sortedTimePoints.length)continue;this._sortedTimePoints[n].timeMs!==o.timeMs&&-1===i&&(i=n)}const s=t+e.length;if(i=LS(i,this._sortedTimePoints.length,s),-1===i)return null;this._fillPointsData(e,0,0===t||0===this._sortedTimePoints.length?null:this._sortedTimePoints[t-1].displayTime);const o=MS(this._sortedTimePoints.slice(t),e).map((e=>({old:e.old+t,new:e.new===Fh.INVALID_TIME_POINT_INDEX?e.new:e.new+t})));{const i=this._sortedTimePoints;let o=0;for(;t+o<i.length&&o<e.length;)i[t+o]=e[o],o+=1;for(;o<e.length;++o)i.push(e[o]);i.length=s}return this._updateFutureBars(),{pointsIndex:i,indexChange:o}}_getBaseIndex(){return 0===this._sortedTimePoints.length?null:this._sortedTimePoints.length-1}_fillPointsData(e,t,i=null){
this._fillDiplayTimeForPoints(e,t),function(e,t=0,i=null){let s=0===t||0===e.length?i:e[t-1].displayTime,o=null!==s?new Date(1e3*s):null,n=0;for(let i=t;i<e.length;++i){const t=e[i],r=new Date(1e3*t.displayTime);t.markWeight=xS(r,o),n+=t.displayTime-(s||t.displayTime),o=r,s=t.displayTime}if(0===t&&e.length>1&&null===i){const t=Math.ceil(n/(e.length-1)),i=new Date(1e3*(e[0].displayTime-t));e[0].markWeight=xS(new Date(1e3*e[0].displayTime),i)}}(e,t,i)}_applyTimeScaleChanges(e,t){if(null===e)return t?(this._fillPointsData(this._sortedTimePoints,0),{points:[],pointsIndex:0,baseIndex:this._getBaseIndex(),indexChange:[],marks:this.tickMarks(0),clearTickMarks:!0}):null;let i=e.pointsIndex;if(0!==i&&t&&(this._fillPointsData(this._sortedTimePoints,0),i=0),0===this._sortedTimePoints.length)return{baseIndex:null,pointsIndex:0,indexChange:[],marks:[],points:[],clearTickMarks:!0};const s=[];for(let t=e.pointsIndex;t<this._sortedTimePoints.length;++t)s.push(this._sortedTimePoints[t].timeMs/1e3);return{...e,points:s,baseIndex:this._getBaseIndex(),marks:this.tickMarks(i),clearTickMarks:t}}_fillDiplayTimeForPoints(e,t=0){if(null===this._mainSymbolExtrapolator)return;const i=this._mainSymbolExtrapolator.interval(),s=this._mainSymbolExtrapolator.barBuilder(),o=this._mainSymbolExtrapolator.symbolInfo(),n=null===this._displayTimezone?(0,Ce.get_timezone)(o.timezone):this._displayTimezone,r=1===this._instanceIds.size,a=i.isDWM(),l=a?(0,Jd.createDwmAligner)(i.value(),{timezone:o.timezone,corrections:r?o.corrections:void 0,session_holidays:r?o.session_holidays:void 0,session:r?o.session:"24x7"}):null,c=!a;for(let o=t;o<e.length;++o){let t=e[o].timeMs/1e3;this._needRebuildEndOfPeriod&&(t=zf(s,t,i)),null===l||this._shouldAlignDwmBarsToMainSeries||(t=Math.floor(l.timeToExchangeTradingDay(1e3*t)/1e3)),c&&(t=Math.floor((0,Ce.utc_to_cal_ts)(n,1e3*t)/1e3)),e[o].displayTime=t}}}function LS(e,t,i){return-1===e&&t!==i&&(e=i<t?Math.max(0,i-1):t),e}const kS=new Map([["horizlines",e=>[e.startIndex,e.endIndex]],["hhists",e=>[e.firstBarTime,e.firstBarTime]],["vertlines",e=>[e.index]],["polygons",e=>e.points.map((e=>e.index))],["horizlines",e=>[e.startIndex,e.endIndex]],["hhists",e=>[e.firstBarTime,e.firstBarTime]],["vertlines",e=>[e.index]],["polygons",e=>e.points.map((e=>e.index))],["backgrounds",e=>[e.start,e.stop]]]),ES=new Map([["horizlines",(e,t)=>{const i=e;i.startIndex=t.get(i.startIndex),i.endIndex=t.get(i.endIndex)}],["hhists",(e,t)=>{const i=e;i.firstBarTime=t.get(i.firstBarTime),i.lastBarTime=t.get(i.lastBarTime)}],["vertlines",(e,t)=>{const i=e;i.index=t.get(i.index)}],["polygons",(e,t)=>{const i=e;for(const e of i.points)e.index=t.get(e.index)}],["backgrounds",(e,t)=>{const i=e;i.start=t.get(i.start),i.stop=t.get(i.stop)}]]);class DS{main(e){return[Py.Std.open(e),Py.Std.high(e),Py.Std.low(e),Py.Std.close(e),Py.Std.volume(e),Py.Std.updatetime(e),void 0,void 0,void 0,void 0]}}const BS=(0,ne.getLogger)("ChartApi.PointsetsManager");class VS{constructor(){this._pointsetsDataBySymbol=new Map}destroy(){this._pointsetsDataBySymbol.clear()}
createPointset(e,t,i,s,o){let n=this._pointsetsDataBySymbol.get(t);void 0===n&&(n=new Map,this._pointsetsDataBySymbol.set(t,n));const r=[];for(const t of s){const[s,n,a]=t;if("number"!=typeof s||Number.isNaN(s)){BS.logWarn(`Pointset time is invalid: id=${e}, ${s} of type ${typeof s}`);continue}const l=o(a||i);r.push({point:t,extrapolation:l.extrapolateTimeWithOffsetToTime(1e3*s,n)})}s.length===r.length&&n.set(e,{resolution:i,points:r})}removePointset(e){const t=[];this._pointsetsDataBySymbol.forEach(((i,s)=>{i.delete(e),0===i.size&&t.push(s)}));for(const e of t)this._pointsetsDataBySymbol.delete(e)}invalidatePointsetsForSymbol(e,t){const i=this._pointsetsDataBySymbol.get(e);void 0!==i&&i.forEach(((e,i)=>{if(Re.Interval.isEqual(e.resolution,t))for(const t of e.points)null!==t.extrapolation&&t.extrapolation.exact&&(t.extrapolation.exact=!1)}))}getUpdatesForSymbol(e,t,i,s){const o=new Map,n=this._pointsetsDataBySymbol.get(e);return void 0!==n&&n.forEach(((e,n)=>{const r=this._refreshPointsetData(e,t,i,s);null!==r&&o.set(n,r)})),o}_refreshPointsetData(e,t,i,s){if(Re.Interval.isEqual(e.resolution,t))for(let s=0;s<e.points.length;++s){const o=e.points[s];if(null!==o.extrapolation&&o.extrapolation.exact)continue;const[n,r,a]=o.point,l=i(a||t);o.extrapolation=l.extrapolateTimeWithOffsetToTime(1e3*n,r)}const o=[];for(let i=0;i<e.points.length;++i){const n=e.points[i];if(null===n.extrapolation)return null;const r=s.indexOfTime(n.extrapolation.timeMs);if(null===r)return BS.logWarn(`Cannot get index of time: time=${n.extrapolation.timeMs}, ${e.resolution} -> ${t}`),null;o.push({index:i,value:[r.index,r.timeMs/1e3]})}return o}}const RS=-5e6,NS="pre_post_market_sessions",OS=l.enabled(NS),FS=l.enabled("pay_attention_to_ticker_not_symbol");class WS{constructor(e,t,i,s){this._chartApiMessagerProvider=t,this._marketStatusWatcherProvider=i,this._studyLibrary=s,this._studiesCache={},this._objectsDataCache={},this._studiesNonSeriesTimes={},this._barsCoefficientsCache={},this._externalDatafeed=e,(0,gc.default)(e.getVolumeProfileResolutionForPeriod)&&(0,Uv.overwriteVolumeProfileResolutionForPeriodGetter)(((t,i,s,o)=>(0,n.ensure)(e.getVolumeProfileResolutionForPeriod)(t,i,s,o))),this._marketStatusWatchers={},this._resolveRequests={},this._resolvePromisesBySymbolId=new Map,this._symbolIdToSymbolRequestString=new Map,this._callbacks={},this._serverTimeOffset=0,this._logMessage("Datafeed settings received: {0}".format(JSON.stringify(window.configurationData))),this._datafeedConfiguration=function(e){const t=(0,tt.merge)({},e),i=t.supported_resolutions;if(!i||0===i.length)return t.supported_resolutions=void 0,t;const s=[];for(let e=0;e<i.length;e++){const t=i[e];if(-1!==s.indexOf(t))throw new Error("Duplicating resolution `"+t+"`");Re.Interval.parse(t).isRange()||s.push(t)}return t.supported_resolutions=s,t}(window.configurationData),this._fireEvent("configuration_received"),this._externalDatafeed.getServerTime&&this._externalDatafeed.getServerTime((e=>{this._serverTimeOffset=e-(new Date).valueOf()/1e3})),
this._invalidatedPointsetSessions=new Set,this._refreshPointsetsTimerId=null,this._pointsetsManagers={},this._quotesInfo={},this._depthInfo={},this._endOfData={},this._computeStudyCounter=0,this._symbolExtrapolators={},this._timeScales={},this._cachedDatafeed=new Yv(e,this.serverTimeOffset.bind(this),this._datafeedConfiguration.reset_cache_timeout);const o=(e,t,i)=>{const s=new Cd.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),o=(0,Td.newBarBuilder)(t,s,s);return e=>{if(e&&e.count()){const t=1e3*this.getCurrentUTCTime();o.moveTo(t),o.indexOfBar(t)>=0&&e.setLastBarClosed(!1)}i(e)}};this._pineDatafeed=new pS({resolve:(e,t,i,s)=>{this._resolveSymbolByName(e,t,(e=>i(JS(e))),s)},subscribe:(e,t,i,s,n)=>this._cachedDatafeed.subscribe(e,t,i,o(e,t,s),(e=>n(e??"Unknown datafeed error"))),unsubscribe:e=>this._cachedDatafeed.unsubscribe(e)})}destroy(){for(const e of Object.keys(this._quotesInfo))this._stopQuotesSubscription(e);this._cachedDatafeed.destroy(),this._externalDatafeed=null;for(const e of Object.keys(this._pointsetsManagers))this._pointsetsManagers[e].destroy();this._quotesInfo={},this._pointsetsManagers={}}purgeCache(){this._endOfData={},this._resolveRequests={},this._objectsDataCache={},this._studiesNonSeriesTimes={},this._studiesCache={},this._resolvePromisesBySymbolId.clear(),this._symbolIdToSymbolRequestString.clear(),Object.keys(this._pointsetsManagers).forEach((e=>{this._pointsetsManagers[e].destroy()})),this._pointsetsManagers={},Object.keys(this._timeScales).forEach((e=>{this._timeScales[e].destroy()})),this._timeScales={},Object.keys(this._symbolExtrapolators).forEach((e=>{this._symbolExtrapolators[e].destroy()})),this._symbolExtrapolators={}}purgeDataCache(){this._cachedDatafeed.purgeCache()}resetCache(){this._cachedDatafeed.resetCache()}serverTimeOffset(){return this._serverTimeOffset}getCurrentUTCTime(){return(new Date).valueOf()/1e3+this._serverTimeOffset}serverTime(){return 1e3*this.getCurrentUTCTime()}switchTimezone(e,t){this._timeScales[e].setTimezone(t);const i=this._timeScales[e].tickMarks();null!==i&&this._chartApiMessagerProvider.getChartApiMessager(e).onTickmarksUpdated(0,i)}on(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this}supportedResolutions(){return this._datafeedConfiguration.supported_resolutions}supportedCurrencies(){return this._datafeedConfiguration.currency_codes||[]}supportedUnits(){return this._datafeedConfiguration.units||{}}supportedPriceSources(e){return new Promise(((t,i)=>{this._resolveSymbolImpl(e,(e=>{t(JS(e).price_sources)}),(e=>{i(e)}))}))}supportedSymbolsTypes(){return this._datafeedConfiguration.symbols_types||[]}symbolsGrouping(){return this._datafeedConfiguration.symbols_grouping||{futures:/$a/}}getMarks(e,t,i,s,o){const r={red:6,green:5,blue:4,yellow:3};this._externalDatafeed.getMarks&&this._datafeedConfiguration.supports_marks&&(this._logMessage("Requesting bars marks: symbol {0}, resolution {1}, range [{2} ... {3}]".format((0,
n.ensure)(e.full_name),o,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString())),this._externalDatafeed.getMarks(JS(e),t,i,(t=>{const i=t.map((e=>(e.time=Number(e.time),e)));this._logMessage("Received bars marks: symbol {0}, resolution {1}, marks {2}".format((0,n.ensure)(e.full_name),o,JSON.stringify(i)));const a=(0,Jd.createDwmAligner)(o,e),c=l.enabled("two_character_bar_marks_labels"),h=i.map((e=>{const t=e;return t.tickmark=null!==a?a.timeToSessionStart(1e3*e.time)/1e3:e.time,t.direction=(0,et.default)(e.color)?r[e.color]:r.red,t.onClicked=()=>{ee.emit("onMarkClick",e.id)},t.label=e.label?c?e.label.slice(0,2):e.label[0]:"",t}));s(h)}),o))}getTimescaleMarks(e,t,i,s,o){this._externalDatafeed.getTimescaleMarks&&this._datafeedConfiguration.supports_timescale_marks&&(this._logMessage("Requesting timescale marks: symbol {0}, resolution {1}, range [{2} ... {3}]".format((0,n.ensure)(e.full_name),o,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString())),this._externalDatafeed.getTimescaleMarks(JS(e),t,i,(t=>{this._logMessage("Received timescale marks: symbol {0}, resolution {1}, marks {2}".format((0,n.ensure)(e.full_name),o,JSON.stringify(t)));const i=(0,Jd.createDwmAligner)(o,e),r=t.map((e=>{const t=e;return t.tickmark=null!==i?i.timeToSessionStart(1e3*e.time)/1e3:e.time,t}));s(r)}),o))}getSeriesLastBarTime(e,t){const i=this._getSeriesData(e,t);return null===i||0===i.length?null:i[i.length-1].timeMs}getSeriesInterval(e,t){const i=this._studiesCache[e][t];return i?i.resolution:null}onSessionSeriesError(e){this.stopSources(e);const t=this._mainSeriesRecord(e);null!==t&&(t.error=!0),this._applyTimeScaleUpdate(e,this._timeScales[e].clearTimeScale())}stopSources(e){for(const t of this._getStudiesCacheSessionKeys(e)){const i=this._studiesCache[e][t];i&&"series"===i.type&&this._stopSourcesTree(e,t)}}getSeriesSymbolInfo(e,t){const i=this._studiesCache[e][t];return i?i.symbolInfo:null}modifySeries(e,t,i,s,o,r){const a=this._mainSeriesRecord(e);if(null===a||a.guid!==t){if(null!==a&&a.error)return this._studiesCache[e][t].symbolId=i,this._studiesCache[e][t].resolution=s,void(this._studiesCache[e][t].turnaround=o);this._stopSourcesTree(e,t),this.createSeries(e,t,o,i,s,{countBack:0},!0);for(const i of this._getStudiesCacheSessionKeys(e)){const s=this._studiesCache[e][i];if(s&&"study"===s.type&&s.parentId===t){this._studiesNonSeriesTimes[e][i]=null;const t=this._studiesCache[e][s.parentId];this._createStudy(t.symbolId,t.resolution,s.studyObject,e,i,s.turnaround,s.parentId,(0,n.ensure)(s.inputs))}}}else this._modifyMainSeries(e,i,s,o,r)}createStudy(e,t,i,s,o,n){const r=this._studiesCache[e][i],a=this._studyLibrary.findStudyObject(o);if(null===a)return $S("Study does not exist: "+o),void this._chartApiMessagerProvider.getChartApiMessager(e).onStudyError(t,s,"unknown study name");const l=new a.constructor;this._studiesCache[e]=this._studiesCache[e]||{},this._studiesCache[e][t]={studyObject:l,guid:t,type:"study",inputs:n,metainfo:a.metainfo,turnaround:s,parentId:i},this._studiesNonSeriesTimes[e][t]=null,
this._createStudy(r.symbolId,r.resolution,l,e,t,s,i,n)}modifyStudy(e,t,i,s){const o=this._studiesCache[e][t];if(!o)throw Error("This should never happen");const n=this._studiesCache[e][o.parentId];o.inputs=s,o.turnaround=i,o.engine&&(o.engine.stop(),this._pineDatafeed.removeUnused()),this._studiesNonSeriesTimes[e][t]=null,this._createStudy(n.symbolId,n.resolution,o.studyObject,e,t,i,o.parentId,s)}sessionTimeScale(e){return this._timeScales[e]||null}isTimeScaleExtendedTo(e,t){const i=(0,n.ensure)(this._mainSeriesRecord(e));if(Re.Interval.isDWM(i.resolution)&&null!=i.symbolInfo){const e=(0,Jd.createDwmAligner)(i.resolution,i.symbolInfo);null!==e&&(t=e.timeToSessionStart(t))}const s=this._timeScales[e].indexOfTime(t);return null!==s&&s.index>=0}ensureExtendedTo(e,t,i){if(!this._studiesCache[t][e])throw Error("This should never happen");setTimeout((()=>{this._recreateSourcesForDataRange(t,{to:i})}),0)}extendSeriesRange(e,t){let i=this._timeScales[e].firstSeriesBarTime();if(null===i)return void this._logMessage("Nothing to extend - there is no points on time scale");const s=(0,n.ensure)(this._mainSeriesRecord(e));if(Re.Interval.isDWM(s.resolution)&&null!=s.symbolInfo){const e=(0,Jd.createDwmAligner)(s.resolution,s.symbolInfo);null!==e&&(i=e.timeToExchangeTradingDay(i))}const o=(0,n.ensure)(this._symbolIdToSymbolRequestString.get(US(e,s.symbolId))),r=this._barsCoefficients(o,s.resolution),a=r.barsCoefficient||1;if(!r.barsCoefficient){const i=this._getSeriesData(e,s.guid);null!==i&&(r.expectedBarsCount=i.length+t)}setTimeout((()=>{this._recreateSourcesForDataRange(e,{to:i,countBack:(t+2)*a})}),0)}seriesTurnaround(e,t){return this._studiesCache[e]&&this._studiesCache[e][t]&&this._studiesCache[e][t].turnaround}createSeries(e,t,i,s,o,r,a){this._setEndOfData(e,t,i,!1);const c=new DS;this._studiesCache[e]=this._studiesCache[e]||{};const h=this._getSeriesData(e,t),d=this._studiesCache[e][t],u=this._seriesCount(e),_=this._mainSeriesRecord(e),p=function(e){let{dataRange:t}=e;const{oldStudyRecord:i,resolution:s,symbolId:o,seriesCount:r,oldData:a,mainSeriesRecord:l,timeScales:c,session:h}=e;if(!i||Re.Interval.isEqual(i.resolution,s)&&i.symbolId===o)void 0!==t.countBack&&null!==a&&0!==a.length&&(t.to=a[0].timeMs),i&&null!=i.firstLoadedTimeMs?t.to=void 0!==t.to?Math.min(i.firstLoadedTimeMs,t.to):i.firstLoadedTimeMs:i||0===r||null!==l&&(null!=l.firstLoadedTimeMs?(t.to=l.firstLoadedTimeMs,t.countBack=0):t=Object.assign({},l.dataRange));else if(1===r)t=Object.assign({},i.initialDatarange);else{const e=c[h].firstSeriesBarTime();(void 0===t.to||null!==e&&e<t.to)&&(t.to=(0,n.ensureNotNull)(e),t.countBack=0)}void 0===t.countBack&&(t.countBack=0);void 0===t.to&&0===t.countBack&&(t.countBack=100);return t}({dataRange:r,oldStudyRecord:d,resolution:o,symbolId:s,seriesCount:u,oldData:h,mainSeriesRecord:_,timeScales:this._timeScales,session:e});if(this._studiesCache[e][t]={symbolId:s,resolution:o,studyObject:c,guid:t,type:"series",turnaround:i,dataRange:p,initialDatarange:d&&d.initialDatarange||Object.assign({},p),firstLoadedTimeMs:null,
symbolInfo:null,isMain:d&&d.isMain||0===u,completed:!1},null!==_&&_.guid!==t&&_.error)return;this._updateMainTsBuilder(e),this._updateTimeScaleState(e),this._chartApiMessagerProvider.getChartApiMessager(e).onSeriesLoading(t,i);const m=(s,n,r)=>{const a=[];if(void 0!==r){const e=(r.data||[]).reduce(((e,t)=>Math.max(e,t[0]||0)),-1);if(null!=r.projectionTime)for(let t=0;t<=e;++t)a.push(r.projectionTime+t)}let l=null,c=null;const h=s?this._getSymbolExtrapolator(e,s,o):null;if(void 0!==n){const i=n.map((e=>e.timeMs)).concat(a);null!==h&&h.replaceBarsTimesTail(i,n.length),c=this._timeScales[e].replaceBarsTimesTail(t,i),l=n}else{const i=this._getSeriesData(e,t)||[],s=i.map((e=>e.timeMs)).concat(a);null!==h&&h.setBarsTimes(s,i.length),c=this._timeScales[e].setSeriesBarsTimes(t,s),l=i}if(this._applyTimeScaleUpdate(e,c),0===l.length&&void 0===r)return;this._timeScales[e].fillIndexesInRows(l);const d=void 0!==r?this._prepareSeriesNonSeriesData(e,t,r):null;this._chartApiMessagerProvider.getChartApiMessager(e).onDataUpdate(t,i,l,d)},g=s=>{const o=this._studiesCache[e][t];o.completed=!0,this._chartApiMessagerProvider.getChartApiMessager(e).onSeriesError(t,i,s),l.enabled("clear_bars_on_series_error")&&(o.isMain?this.onSessionSeriesError(e):this._clearSeriesData(e,t))};this._computeStudy(e,c,s,o,t,[],p,jS(e,t),(function(){return-1/0}),{onDataReadyCallback:(r,l,c,h)=>{const d=this._studiesCache[e][t];if(!d)throw Error("This should never happen");if(d.symbolInfo=c,d.firstLoadedTimeMs=h.firstLoadedTimeMs,d.completed=!0,this._updateMainTsBuilder(e),a&&this._pointsetsManagers[e].invalidatePointsetsForSymbol(c.full_name,o),0!==r.length){const i=(0,n.ensure)(this._symbolIdToSymbolRequestString.get(US(e,s))),a=this._barsCoefficients(i,o);a.expectedBarsCount&&a.barsCount&&(a.barsCoefficient=Math.min(Math.max(a.barsCoefficient||1,Math.floor(a.expectedBarsCount/(r.length-a.barsCount)+.5)),100)),a.barsCount=r.length,this._clearSeriesData(e,t)}else!h.endOfData&&d.isMain&&setTimeout((()=>{this._studiesCache[e]&&this._recreateSourcesForDataRange(e,{countBack:10})}),0);m(c),h.endOfData&&(this._logMessage("Series has no more data on server: {0}".format(c.full_name)),this._setEndOfData(e,t,i)),0===r.length&&this._clearSeriesData(e,t),this._chartApiMessagerProvider.getChartApiMessager(e).onSeriesCompleted(t,i,c.data_status),this._updateTimeScaleState(e)},onRealtimeCallback:(s,n,r,a,l)=>{m(l,s),this._timeScales[e].fillIndexesInRows(s);const c=s[s.length-1];if(n){if(!this._studiesCache[e][t])throw Error("This should never happen");this._logMessage("New bar arrived: symbol {0}, resolution {1}, bar {2}".format(l.full_name,o,JSON.stringify(c)))}else this._logMessage("Last bar update: symbol {0}, resolution {1}, bar {2}".format(l.full_name,o,JSON.stringify(c))),this._chartApiMessagerProvider.getChartApiMessager(e).onDataUpdate(t,i,s,null);this._fireEvent("realtime_tick",s[s.length-1],!0)},onSymbolErrorCallback:e=>{this._logMessage("Series symbol resolve error: "+e),g(e||"resolve error")},onErrorCallback:e=>{this._logMessage("Series error: "+e),g(e)},
onNonSeriesDataUpdate:(s,o)=>{if("projection"!==s.type)throw new Error("unexpected non-series data type for series "+s.type);const r=this._getSeriesData(e,t);if(null!==r)m((0,n.ensure)(o.info),0===r.length?void 0:[r[r.length-1]],s);else{const o=this._prepareSeriesNonSeriesData(e,t,s);this._chartApiMessagerProvider.getChartApiMessager(e).onDataUpdate(t,i,[],o)}}})}removeStudy(e,t){if(this._studiesCache[e]&&this._studiesCache[e][t]&&this._studiesCache[e][t].engine&&(this._studiesCache[e][t].engine.stop(),this._pineDatafeed.removeUnused()),this._studyCanExtendTimeScale(e,t)){this._timeScales[e].setCompleted(!1);const i=this._timeScales[e].setStudyBarsTimes(t,[],!0);this._applyTimeScaleUpdate(e,i),this._updateTimeScaleState(e)}delete this._studiesCache[e][t],delete this._studiesNonSeriesTimes[e][t]}removeSeries(e,t){this._stopSourcesTree(e,t),delete this._studiesCache[e][t],this._updateMainTsBuilder(e),this._timeScales[e].isCompleted()&&this._timeScales[e].setCompleted(!1);const i=this._timeScales[e].setSeriesBarsTimes(t,[]);this._applyTimeScaleUpdate(e,i),this._updateTimeScaleState(e)}requestMoreTickmarks(e,t){const i=this._timeScales[e];i.setMinFutureBarsCount(i.minFutureBarsCount()+t);const s=i.firstFutureBarIndex(),o=i.tickMarks(s);this._chartApiMessagerProvider.getChartApiMessager(e).onTickmarksUpdated(s,o)}chartCreateSession(e){this._pointsetsManagers[e]=new VS,this._timeScales[e]=new AS,this._studiesNonSeriesTimes[e]={}}chartDeleteSession(e){this._pointsetsManagers[e].destroy(),delete this._pointsetsManagers[e],this._timeScales[e].destroy(),delete this._timeScales[e],delete this._studiesNonSeriesTimes[e]}removePointset(e,t){this._pointsetsManagers[e].removePointset(t)}async createPointset(e,t,i,s,o){const n=this._resolvePromisesBySymbolId.get(US(e,i));if(void 0===n)return;let r;try{r=(await n).symbolInfo}catch(e){return}this._pointsetsManagers[e].createPointset(t,r.full_name,s,o,((t=s)=>this._getSymbolExtrapolator(e,r,t))),null===this._refreshPointsetsTimerId&&(this._refreshPointsetsTimerId=window.setTimeout((()=>{this._refreshPointsetsTimerId=null,this._refreshPointsets(this._invalidatedPointsetSessions),this._invalidatedPointsetSessions.clear()}),0)),this._invalidatedPointsetSessions.add(e)}searchSymbols(e,t,i,s,o){this._logMessage(`Symbol search requested: search string \`${e}\`, exchange: \`${t}\`, type \`${i}\``);this._externalDatafeed.searchSymbols(e,t,i,(e=>{this._logMessage(`Symbol search response: ${JSON.stringify(e)}`),e.forEach((e=>{XS(e.logo_urls,e.exchange_logo,e)})),s(e)}),o)}searchSymbolsPaginated(e,t){if(void 0===this._externalDatafeed.searchSymbolsPaginated)return void this.searchSymbols(e.userInput??"",e.exchange??"",e.symbolType??"",(e=>t(e,0)),e.searchSource??"symbolSearch");this._logMessage(`Symbol search requested: search string \`${e.userInput}\`, exchange: \`${e.exchange}\`, type \`${e.symbolType}\`, start \`${e.start}\``);this._externalDatafeed.searchSymbolsPaginated?.(e,((e,i)=>{this._logMessage(`Symbol search response: ${JSON.stringify(e)}`),e.forEach((e=>{
XS(e.logo_urls,e.exchange_logo,e)})),t(e,i)}))}resolveSymbol(e,t,i){this._symbolIdToSymbolRequestString.set(US(e,t),i),this._resolvePromisesBySymbolId.set(US(e,t),new Promise(((s,o)=>{this._resolveSymbolImpl(i,(o=>{this._chartApiMessagerProvider.getChartApiMessager(e).onSymbolResolved(t,o),s({symbolInfo:o,requestedSymbol:i})}),(i=>{this._chartApiMessagerProvider.getChartApiMessager(e).onSymbolError(t,i),o(i)}))})))}quoteCreateSession(e){this._quotesInfo[e]={symbols:[],fastSymbols:[],listenerGUID:void 0}}quoteDeleteSession(e){this._stopQuotesSubscription(e),delete this._quotesInfo[e]}quoteSetFields(e,t){}quoteAddSymbols(e,t){this._quotesInfo[e].symbols=this._filteredSymbols(this._quotesInfo[e].symbols.concat(t)),this._restartQuotesSubscription(e)}quoteRemoveSymbols(e,t){this._quotesInfo[e].symbols=this._quotesInfo[e].symbols.filter((e=>t.indexOf(e)<0)),this._restartQuotesSubscription(e)}quoteFastSymbols(e,t){this._quotesInfo[e].fastSymbols=this._filteredSymbols(t),this._restartQuotesSubscription(e)}quoteHibernateAll(e){}depthCreateSession(e){this._depthInfo[e]={symbol:null,listenerGUID:void 0}}depthDeleteSession(e){this._depthInfo[e].symbol=null,this._stopDepthSubscription(e),delete this._depthInfo[e]}depthSetSymbol(e,t){this._depthInfo[e].symbol=t,this._restartDepthSubscription(e)}hasStudyWithExtendedTimeScale(e){for(const t of this._getStudiesCacheSessionKeys(e)){if("study"===this._studiesCache[e][t].type&&this._studyCanExtendTimeScale(e,t))return!0}return!1}_stopDepthSubscription(e){this._depthInfo[e].listenerGUID&&(this._externalDatafeed.unsubscribeDepth?.(this._depthInfo[e].listenerGUID),this._depthInfo[e].listenerGUID=void 0)}_restartDepthSubscription(e){this._stopDepthSubscription(e),this._startDepthSubscription(e)}_startDepthSubscription(e){const t=this._depthInfo[e].symbol;if(!t)return;const i=e=>e.map((e=>({p:e.price,v:e.volume}))),s=e=>({s:t,bids:i(e.bids),asks:i(e.asks)}),o=t=>{t.snapshot?this._chartApiMessagerProvider.getChartApiMessager(e).onDepthData([e,s(t)]):this._chartApiMessagerProvider.getChartApiMessager(e).onDepthUpdate([e,s(t)])};this._externalDatafeed.subscribeDepth&&(this._depthInfo[e].listenerGUID=this._externalDatafeed.subscribeDepth(t,(t=>{this._depthInfo[e]&&o(t)})))}_restartQuotesSubscription(e){this._stopQuotesSubscription(e),this._startQuotesSubscription(e)}async _startQuotesSubscription(e){const t={},i={},s=(t,i)=>{const s="ok"===t.s,o=this._marketStatusWatchers[e][t.n],n={...t,symbolname:t.n,status:t.s,values:{...t.v,change:s?t.v.ch:void 0,last_price:s?t.v.lp:void 0,change_percent:s?t.v.chp:void 0,current_session:s?t.v.cs:o&&o.marketStatus(),pricescale:i.pricescale,minmov:i.minmov,minmove2:i.minmove2||0,fractional:i.fractional||!1}};XS(i.logo_urls,i.exchange_logo,n.values),(o&&s?t.v.cs:void 0)&&o.stop(),this._chartApiMessagerProvider.getChartApiMessager(e).onQuotesData([e,n])},o=n=>{n.forEach((r=>{const a=r.n;if(i[a]?.size>0){const t=[...i[a]].map((e=>({...r,n:e})));if(l.enabled("charting_library_debug_mode")){
const t=void 0!==this._quotesInfo[e].listenerGUID?`with listenerGUID ${this._quotesInfo[e].listenerGUID}`:"";this._logMessage(`QUOTES Data for symbol ${a} ${t}: ${JSON.stringify(n)}`)}setTimeout((()=>o(t)),0)}if(void 0!==t[r.n]&&null!==t[r.n])s(r,t[r.n]);else if(l.enabled("charting_library_debug_mode")){const t=void 0!==this._quotesInfo[e].listenerGUID?`with listenerGUID ${this._quotesInfo[e].listenerGUID}`:"";this._logMessage(`QUOTES Data for unexpected symbol ${a} ${t}: ${JSON.stringify(n)}`)}}))},r=async e=>{try{const[s,o]=KS(e),r=await new Promise(((e,t)=>{this._resolveSymbolByName(s,o,e,t)})),a=(0,n.ensure)(r.ticker);return t[a]=t[e]=JS(r),a===e?a:(void 0===i[a]&&(i[a]=new Set),a!==e&&i[a].add(e),a)}catch{return null}},a=async e=>[...new Set((await Promise.all([...new Set(e)].map(r))).filter((e=>null!==e)))];if(this._externalDatafeed.getQuotes&&!l.enabled("charting_library")){const[t,i]=await Promise.all([a(this._quotesInfo[e].symbols),a(this._quotesInfo[e].fastSymbols)]),s={};if(l.enabled("charting_library_debug_mode")){const e=WS.debugGetQuotesRequestId++;this._logMessage(`QUOTES Requesting data for symbols ${JSON.stringify(t)} with request ID ${e}`);for(const i of t){const t=1e4;s[i]=window.setTimeout((()=>{this._logMessage(`QUOTES Timeout after waiting ${t/1e3} seconds for data symbol ${i} with request ID ${e}`)}),t)}}this._externalDatafeed.getQuotes(t,(n=>{if(l.enabled("charting_library_debug_mode"))for(const e of n)void 0!==s[e.n]&&clearTimeout(s[e.n]),delete s[e.n];this._quotesInfo[e]&&0!==this._quotesInfo[e].symbols.length&&(o(n),this._quotesInfo[e].listenerGUID=e,l.enabled("charting_library_debug_mode")&&this._logMessage(`QUOTES Subscribing listenerGUID ${this._quotesInfo[e].listenerGUID} to data for symbols ${JSON.stringify(t)} and fast symbols ${JSON.stringify(i)}`),this._externalDatafeed.subscribeQuotes(t,i,o,this._quotesInfo[e].listenerGUID))}),(e=>{this._logMessage(`QUOTES Error getting data for symbols ${JSON.stringify(t)}: ${e}`)}))}else!this._externalDatafeed.getQuotes&&l.enabled("trading_terminal")&&setTimeout((()=>{o(this._quotesInfo[e].symbols.map((e=>({n:e,s:"ok",v:{}}))))}));this._createMarketStatusWatchers(e,this._quotesInfo[e].symbols)}_createMarketStatusWatchers(e,t){void 0===this._marketStatusWatchers[e]&&(this._marketStatusWatchers[e]={});for(let i=0;i<t.length;i+=1){const s=t[i];if(void 0===this._marketStatusWatchers[e][s]){const[t,i]=KS(s);this._marketStatusWatchers[e][s]=this._marketStatusWatcherProvider.createMarketStatusWatcher(((o,n,r,a)=>this._resolveSymbolByName(t,i,r,(o=>{$S(`Error resolving for market status watcher ${qS(t,i.currency,i.unit,i.session)}:\n${o}`),this.quoteRemoveSymbols(e,[s]),a(o)}))),e,s,this._chartApiMessagerProvider)}}}_filteredSymbols(e){const t=[];return e.forEach((e=>{e instanceof Object||t.indexOf(e)<0&&t.push(e)})),t}_refreshPointsets(e){e.forEach((e=>{const t=this._studiesCache[e];if(null==t)return;let i=null;for(const e of Object.keys(t)){const s=t[e];if("series"===s.type){i=s;break}}if(null===i||null==i.symbolInfo)return;const s=i.symbolInfo
;this._pointsetsManagers[e].getUpdatesForSymbol(i.symbolInfo.full_name,i.resolution,((t=i.resolution)=>this._getSymbolExtrapolator(e,s,t)),this._timeScales[e]).forEach(((t,i)=>{this._chartApiMessagerProvider.getChartApiMessager(e).onPointsetDataUpdate(i,null,t)}))}))}_recreateSourcesForDataRange(e,t){const i=[];for(const s of this._getStudiesCacheSessionKeys(e)){const o=this._studiesCache[e][s];if(o&&"series"===o.type&&!this._isEndOfData(e,s,o.turnaround)&&(this._stopSourcesTree(e,s),i.push(s)),o&&"study"===o.type&&this._studyCanExtendTimeScale(e,s)&&!this._isEndOfData(e,s,o.turnaround)){const i=this._studiesCache[e][(0,n.ensure)(o.parentId)];o.dataRange=t,this._createStudy(i.symbolId,i.resolution,o.studyObject,e,s,o.turnaround,(0,n.ensure)(o.parentId),(0,n.ensure)(o.inputs))}}i.forEach((i=>{this._startSourcesTree(e,i,Object.assign({},t))}));for(const t of this._getStudiesCacheSessionKeys(e)){const i=this._studiesCache[e][t];"series"===i.type&&this._isEndOfData(e,t,i.turnaround)&&this._chartApiMessagerProvider.getChartApiMessager(e).onSeriesCompleted(t,i.turnaround,(0,n.ensure)(i.engine).runner.host.symbolInfo.data_status)}this._updateTimeScaleState(e)}_startSourcesTree(e,t,i){const s=this._studiesCache[e][t];this.createSeries(e,t,s.turnaround,s.symbolId,s.resolution,i,!0);for(const i of this._getStudiesCacheSessionKeys(e)){const o=this._studiesCache[e][i];o&&"study"===o.type&&o.parentId===t&&this._createStudy(s.symbolId,s.resolution,o.studyObject,e,i,o.turnaround,o.parentId,(0,n.ensure)(o.inputs))}}_clearSeriesData(e,t){const i={};i[t]={turnaround:this._studiesCache[e][t].turnaround};for(const s of this._getStudiesCacheSessionKeys(e)){const o=this._studiesCache[e][s];"study"===o.type&&this._studyCanExtendTimeScale(e,s)||("study"!==o.type||o.parentId!==t||this._studyCanExtendTimeScale(e,s)||(i[s]={turnaround:o.turnaround}))}this._chartApiMessagerProvider.getChartApiMessager(e).onClearData(i)}_prepareSeriesNonSeriesData(e,t,i){const s=i.data[i.data.length-1],o=this._getSeriesData(e,t),r=null===o?[]:i.data;return{data:{data:{reversalAmount:i.reversalAmount,boxSize:i.boxSize,price:s?s[4]:i.price,bars:r.map(((e,t)=>({time:t,open:e[1],high:e[2],low:e[3],close:e[4],volume:e[5],factor:e[6],additionalPrice:e[6]})))}},indexes:this._timeScales[e].convertTimesToIndexes(r.map((e=>{const t=e[0]||0;return t<0?(0,n.ensure)(o)[(0,n.ensure)(o).length+t].timeMs:i.projectionTime+t})))}}_seriesCount(e){let t=0;for(const i of this._getStudiesCacheSessionKeys(e)){"series"===this._studiesCache[e][i].type&&(t+=1)}return t}_modifyMainSeries(e,t,i,s,o){this.stopSources(e);const r=this._mainSeriesRecord(e);let a=!1;for(const n of this._getStudiesCacheSessionKeys(e)){const c=this._studiesCache[e][n];if(c&&"series"===c.type)if((0,Wv.default)(r)||c.guid!==r.guid)this.createSeries(e,c.guid,c.turnaround,c.symbolId,i,{countBack:0},!0);else{a=r.symbolId!==t||r.resolution!==i;const n=ZS(o),c={countBack:n||0};l.enabled("request_only_visible_range_on_reset")&&n&&(delete this._objectsDataCache[jS(e,r.guid)],delete this._studiesCache[e][r.guid]),
this.createSeries(e,r.guid,s,t,i,c,!0)}}for(const t of this._getStudiesCacheSessionKeys(e)){const i=this._studiesCache[e][t];if(i&&"study"===i.type){this._studiesNonSeriesTimes[e][t]=null;const s=this._studiesCache[e][(0,n.ensure)(i.parentId)];this._createStudy(s.symbolId,s.resolution,i.studyObject,e,t,i.turnaround,i.parentId,(0,n.ensure)(i.inputs))}}a&&this._applyTimeScaleUpdate(e,this._timeScales[e].clearTimeScale())}_mainSeriesRecord(e){let t=null,i=null;for(const s of this._getStudiesCacheSessionKeys(e)){const o=this._studiesCache[e][s];if("series"===o.type&&(null===t&&(t=o),o.isMain)){i=o;break}}return null===i&&(i=t),null!==i&&(i.isMain=!0),i}_stopSourcesTree(e,t){for(const i of this._getStudiesCacheSessionKeys(e)){const s=this._studiesCache[e][i];s&&(("series"===s.type&&i===t||"study"===s.type&&s.parentId===t)&&(s.engine&&s.engine.isStarted()&&s.engine.stop(),s.activeResolve=-1))}this._pineDatafeed.removeUnused()}_getSeriesData(e,t){return this._objectsDataCache[jS(e,t)]||null}_resolveSymbolImpl(e,t,i){var s;(0,Pv.isEncodedExtendedSymbol)(e)||(s="Expect to get symbol encoded string, but got the following instead: "+e,console.error(`${(new Date).toISOString()} ${s}`));const[o,n]=KS(e);this._resolveSymbolByName(o,n,t,i)}_getSymbolExtrapolator(e,t,i){const s=(0,n.ensure)(Re.Interval.normalize(i)),o=function(e,t,i){const s=void 0!==t.subsession_id?","+t.subsession_id:"";return e+","+t.full_name+","+i+s}(e,t,s);let r=this._symbolExtrapolators[o];return void 0===r&&(r=new SS(t,s),this._symbolExtrapolators[o]=r),r}_barsCoefficients(e,t){const i=(0,Pv.decodeExtendedSymbol)(e);if(!("type"in i)||void 0===i.type)return{};const s=e+t;return this._barsCoefficientsCache[s]||(this._barsCoefficientsCache[s]={}),this._barsCoefficientsCache[s]}_studyCanExtendTimeScale(e,t){const i=this._studiesCache[e][t]?.metainfo;return void 0!==i&&(l.enabled("studies_extend_time_scale")&&i.canExtendTimeScale||l.enabled("secondary_series_extend_time_scale")&&"Overlay@tv-basicstudies-1"===i.id||l.enabled("inactivity_gaps")&&"InactivityGaps@tv-basicstudies-1"===i.id)}_stopQuotesSubscription(e){this._quotesInfo[e].listenerGUID&&(l.enabled("charting_library_debug_mode")&&this._logMessage(`QUOTES Unsubscribe listenerGUID=${this._quotesInfo[e].listenerGUID}`),this._externalDatafeed.unsubscribeQuotes(this._quotesInfo[e].listenerGUID),this._quotesInfo[e].listenerGUID=void 0),this._removeMarketStatusWatchers(e)}_removeMarketStatusWatchers(e){Object.keys(this._marketStatusWatchers[e]||{}).forEach((t=>{this._marketStatusWatchers[e][t].stop()})),this._marketStatusWatchers[e]={}}_logMessage(e){l.enabled("charting_library_debug_mode")&&console.log(`${(new Date).toISOString()} ${e}`)}_resolveSymbolByName(e,t,i,s){let o;const n=t&&t.currency,r=t&&t.unit,a=t&&t.session,l=GS(e,n,r,a);(0,Wv.default)(this._resolveRequests[l])?(o=this._resolveSymbolInternal(e,n||void 0,r||void 0,a||void 0),this._resolveRequests[l]=o,o.then((t=>{this._resolveRequests[GS(e,t.currency_id,t.unit_id,t.subsession_id)]=o,this._resolveRequests[GS((0,
yS.extractSymbolNameFromSymbolInfo)(t,null),t.currency_id,t.unit_id,t.subsession_id)]=o,this._resolveRequests[GS((0,yS.extractSymbolNameFromSymbolInfo)(t,null),n,r,a)]=o})).catch((()=>{}))):o=this._resolveRequests[l],o.then(i).catch(s)}_resolveSymbolInternal(e,t,i,s){return new Promise(((o,n)=>{const r=qS(e,t,i,s);this._logMessage("Symbol resolve requested: `{0}` ".format(r));let a=!0;this._externalDatafeed.resolveSymbol(e,(e=>{a&&$S("`resolveSymbol` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),this._logMessage("Symbol resolved: `{0}`, SymbolInfo in server response {1}".format(r,JSON.stringify(e)));const t=function(e,t){if(e.ticker||(e.ticker=e.symbol||e.name),e.full_name=t.shouldUseTickerNotSymbol?e.ticker:`${e.exchange}:${e.name}`,e.pro_name=e.full_name,e.base_name||(e.base_name=[e.name]),e.legs||(e.legs=[e.name]),e.exchange||(e.exchange=e["exchange-listed"]),e.data_status||(e.data_status="streaming"),!e.session&&e["session-regular"]&&(e.session=e["session-regular"]),!e.minmov&&e.minmovement&&(e.minmov=e.minmovement),e.currency_code&&(e.currency_id=e.currency_code),e.original_currency_code&&(e.original_currency_id=e.original_currency_code),e.holidays&&(e.session_holidays=e.holidays),void 0!==e.has_no_volume&&(e.visible_plots_set=e.has_no_volume?"ohlc":"ohlcv"),void 0===e.visible_plots_set&&(e.visible_plots_set="ohlcv"),e.supported_resolutions){const t=[];for(const i of e.supported_resolutions){const e=Re.Interval.parse(i);e.isValid()&&!e.isRange()&&t.push(e.value())}e.supported_resolutions=t}if(e.price_sources||(e.price_sources=[]),e["is-tickbars-available"]=!!e.has_ticks,delete e.has_ticks,!0===t.shouldUseSubsessions&&Array.isArray(e.subsessions))for(let t=0;t<e.subsessions.length;t++){const i=e.subsessions[t];switch(i.id){case Xv.SubsessionId.Regular:case Xv.SubsessionId.Extended:i.private=!1;break;case Xv.SubsessionId.PreMarket:case Xv.SubsessionId.PostMarket:i.private=!0}}return e.build_seconds_from_ticks=!1,e}(e,{shouldUseSubsessions:OS,shouldUseTickerNotSymbol:FS});!function(e){const t=e.ticker??e.name??("symbol"in e?e.symbol:void 0)??"unknown symbol";function i(e){$S(`SymbolInfo validation for ${t}: `+e)}"string"==typeof e.ticker&&0!==e.ticker.length||!FS||i('ticker must be a non-empty string when the "pay_attention_to_ticker_not_symbol" featureset is enabled');void 0!==e.exchange&&0!==e.exchange.length||i("exchange must be provided to the symbol information");e.has_empty_bars&&!(0,Jd.isAlignmentEnabled)()&&i('both has_empty_bars field and featureset "disable_resolution_rebuild" are enabled and may cause data issues (see #3329)');(void 0===e.minmov||e.minmov<=0)&&i("minmov must be positive");(void 0===e.pricescale||e.pricescale<=0)&&i("pricescale must be positive");void 0!==e.name&&0!==e.name.length||i("name must be non-empty string");void 0!==e.session&&0!==e.session.length||i("session must be non-empty string");"holidays"in e&&i("field holidays is deprecated, use session_holidays instead")
;"has_no_volume"in e&&i("field has_no_volume is deprecated, use visible_plots_set instead");void 0===e.timezone||0===e.timezone.length?i("timezone must be non-empty string"):"exchange"!==e.timezone&&(0,Pe.timezoneIsAvailable)(e.timezone)||"UTC"!==e.timezone&&i('unsupported timezone "{0}"'.format(e.timezone));if(void 0!==e.intraday_multipliers){const t=e.intraday_multipliers;if(Array.isArray(t))for(let e=0;e<t.length;++e)"string"!=typeof t[e]&&i('intraday_multipliers[{0}] = "{1}" must be string (now: {2})'.format(e+1,t[e],typeof t[e]));else i("intraday_multipliers must be array")}(e.supported_resolutions||[]).filter((e=>!Re.Interval.isValid(e))).forEach((e=>{i("supported_resolutions field contains invalid value: "+e)})),OS||(void 0!==e.subsessions&&i(`Symbol info contains subsessions but the ${NS} feature is not enabled, so the subsessions will be ignored`),void 0!==e.subsession_id&&i(`Symbol info contains a subsession ID but the ${NS} feature is not enabled, so the subsession ID will be ignored`));!0===e.build_seconds_from_ticks&&i("build_seconds_from_ticks is true but building seconds from ticks is only available in Trading Platform.")}(t),this._logMessage("Symbol info after post-processing: `{0}`, SymbolInfo {1}".format(r,JSON.stringify(t))),o(t)}),(e=>{this._logMessage("Symbol resolve failed: `{0}`, reason: `{1}`".format(r,e)),n(e)}),{currencyCode:t,unitId:i,session:s}),a=!1}))}_fireEvent(e,t,i){if(this._callbacks.hasOwnProperty(e)){const s=this._callbacks[e];for(let e=0;e<s.length;++e)s[e](t);i||(this._callbacks[e]=[])}}async _computeStudy(e,t,i,s,o,n,r,a,c,h){let d=!0;const u=[];null!==a&&(this._objectsDataCache[a]=null),this._timeScales[e].setCompleted(!1);const _=this._computeStudyCounter++;function p(e,t){if(e<c())return RS;if(0===t)return 0;const i=u[t-1].index;return i===RS?0:i+1}const m=new Map;let g=!1;const f=(i,c)=>{const _=Re.Interval.parse(s);if((0,Hv.default)(i.supported_resolutions)&&i.supported_resolutions.length>0&&(0,lS.findSuitableResolutionToBuildFrom)(s,i).error)h.onSymbolErrorCallback(`unsupported resolution: ${i.ticker}, ${s}`);else{if(Re.Interval.isDWM(s)&&void 0!==r.to){const e=(0,Jd.createDwmAligner)(s,i);null!==e&&(r.to=e.timeToExchangeTradingDay(r.to))}if(r.from&&r.to){const e=(0,Td.getPeriodsBetweenDates)(i.session,i.session_holidays,i.corrections,_.letter(),_.multiplier(),r.from,r.to);r.countBack=Math.max(e,r.countBack)}try{const _=new nS({datafeed:this._pineDatafeed,unitId:i.unit_id,currencyCode:i.currency_code,tickerid:c,symbolInfo:JS(i),period:s,body:t,sessionId:e,onErrorCallback:h.onErrorCallback,dataRange:r,subsessionId:i.subsession_id,forceAlignBars:!l.enabled("disable_sameinterval_aligning")&&(0,Jd.isAlignmentEnabled)(),enableDwmAligning:l.enabled("align_dwm_bars_to_main_series")||!this._studyCanExtendTimeScale(e,o),input:e=>n[e],out:(e,t)=>{!function(e,t,i){let s=e.time;const o="number"==typeof t?[t]:t;if(o[0]&&"object"==typeof o[0]&&"timeMs"in o[0]){const e=o[0];o.splice(0,1),s=void 0===e.timeMs||isNaN(s)?s:e.timeMs}for(let e=0;e<o.length;++e){let t=o[e]
;t&&"object"==typeof t&&!Array.isArray(t)&&(m.set(e,t.offset),t=t.value),"number"==typeof t&&isNaN(t)&&(t=void 0),o[e]=t}const n=u.length-1,r=n<0||s>u[n].timeMs;r?u.push({index:p(s,u.length),value:[s/1e3].concat(o),timeMs:s}):(u[n].index=p(s,n),u[n].value=[s/1e3].concat(o),u[n].timeMs=s),d||h.onRealtimeCallback([u[u.length-1]],r,u.length,m,i)}(e,t,i)},nonseriesOut:(e,t)=>{h.onNonSeriesDataUpdate(t,e)},setNoMoreData:()=>{g=!0},recalc:(e,s)=>{d=!1,u.endOfData=g,u.emptyBarCount=s.emptyBarCount,(!("error"in t)||(0,Wv.default)(t.error)||(0,gc.default)(t.error)&&null===t.error())&&(null!==a&&(this._objectsDataCache[a]=u),h.onDataReadyCallback(u,m,i,s))}});if(!this._studiesCache[e]||!this._studiesCache[e][o])throw Error("This should never happen");this._studiesCache[e][o].engine=_}catch(e){if(!((0,zv.default)(e)&&"studyError"in e&&e.studyError))throw e;h.onErrorCallback(zS(e,"unknown study error"))}}},y=()=>this._studiesCache[e]&&this._studiesCache[e][o]&&this._studiesCache[e][o].activeResolve===_;this._studiesCache[e][o].activeResolve=_;const v=this._resolvePromisesBySymbolId.get(US(e,i));if(void 0===v)throw new Error("This should never happen");let S,b;try{const e=await v;S=e.symbolInfo,b=e.requestedSymbol}catch(e){return void(y()&&h.onSymbolErrorCallback(zS(e,"unknown symbol error")))}y()&&f(S,b)}_getDataRangeForStudy(e,t){const i=this._studiesCache[e][t],s={...this._seriesDataRange(e,i.parentId)},o=this._studiesCache[e][i.parentId];return this._studyCanExtendTimeScale(e,t)&&o?.completed?void 0!==i.dataRange?i.dataRange:(i.firstLoadedTimeMs&&(s.to=i.firstLoadedTimeMs),s):s}_seriesDataRange(e,t){const i=this._studiesCache[e][t];return null!==i.firstLoadedTimeMs?{to:i.firstLoadedTimeMs,countBack:0}:i.dataRange}_createStudy(e,t,i,s,o,r,a,l){this._studiesCache[s][o].completed=!1;const c=(e=>{if(Array.isArray(e))return e;const t=[],i=this._studiesCache[s][o].metainfo.inputs;if((0,Hv.default)(i))for(let s=0;s<i.length;s++)t[s]=e[i[s].id];return t})(l);this._chartApiMessagerProvider.getChartApiMessager(s).onStudyLoading(o,r);const h=(e,t,i)=>{const n=this._studiesCache[s][o];if(n.completed=!0,e.length>0&&(n.firstLoadedTimeMs=e[0].timeMs),e=YS(e),this._setEndOfData(s,o,r,!this._studyCanExtendTimeScale(s,o)||e.endOfData),this._studyCanExtendTimeScale(s,o)){const t=e.map((e=>e.timeMs)),i=this._timeScales[s].setStudyBarsTimes(o,t);this._applyTimeScaleUpdate(s,i)}this._timeScales[s].fillIndexesInRows(e),this._chartApiMessagerProvider.getChartApiMessager(s).onDataUpdate(o,r,e,t),this._chartApiMessagerProvider.getChartApiMessager(s).onStudyCompleted(o,r),this._updateTimeScaleState(s)},d=e=>{if(0===e.size)return{};const t={},i=this._studiesCache[s][o].metainfo;return e.forEach(((e,s)=>{t[(0,n.ensure)(i.plots)[s].id]=e})),{data:{offsets:t},indexes:[]}};let u=null,_=!1;this._computeStudy(s,i,e,t,o,c,this._getDataRangeForStudy(s,o),null,(()=>{if(this._studyCanExtendTimeScale(s,o))return-1/0;if(null===u){const e=this._getSeriesData(s,a)?.[0];if(void 0===e)return 1/0;u=e.timeMs}return u}),{onDataReadyCallback:(e,t,i)=>{
_&&0===e.length||h(e,d(t))},onRealtimeCallback:(e,t,i,n,a)=>{const l=YS(e);if(this._studyCanExtendTimeScale(s,o)){const e=l.map((e=>e.timeMs)),t=this._timeScales[s].replaceStudyBarsTimesTail(o,e);this._applyTimeScaleUpdate(s,t)}this._timeScales[s].fillIndexesInRows(l),this._chartApiMessagerProvider.getChartApiMessager(s).onDataUpdate(o,r,l,d(n)),this._updateTimeScaleState(s)},onSymbolErrorCallback:()=>{this._studiesCache[s][o].completed=!0,this._chartApiMessagerProvider.getChartApiMessager(s).onStudyError(o,r,"error in series")},onErrorCallback:(e,t)=>{this._studiesCache[s][o].completed=!0;let i=e;t&&(i={error:e,title:t}),this._chartApiMessagerProvider.getChartApiMessager(s).onStudyError(o,r,i),this._updateTimeScaleState(s)},onNonSeriesDataUpdate:(e,t)=>{switch(_=!0,e.type){case"projection":break;case"study_gap":const t=this._timeScales[s].replaceStudyBarsTimesTail(o,e.times);this._applyTimeScaleUpdate(s,t);break;case"study_graphics":{const t={data:{graphicsCmds:e.data?.graphicsCmds,isUpdate:e.data?.isUpdate},indexes:[]},i=function(e){const t=e.data&&e.data.graphicsCmds&&e.data.graphicsCmds.create;if(!t)return[];const i=new Map,s=new Set;kS.forEach(((e,o)=>{const n=t[o];if(n)for(const t of n)for(const o of t.data){const t=e(o);for(const e of t)i.set(e,-1),s.add(e)}}));const o=Array.from(s).sort(((e,t)=>e-t));return o.forEach(((e,t)=>i.set(e,t))),ES.forEach(((e,s)=>{const o=t[s];if(o)for(const t of o)for(const s of t.data)e(s,i)})),o}(t);this._studiesNonSeriesTimes[s][o]=i,t.indexes=this._timeScales[s].convertTimesToIndexes(i),h([],t);break}case"non_series_data":{const t={data:e.data,indexes:[]},i=t?.data?.data?.pivots,n=void 0!==i;let r=function(e){const t={};gS(e,(e=>{(0,zv.default)(e)&&Object.keys(e).forEach((i=>{i.endsWith("__t")&&(t[e[i]]=!0)}))}),{visitInstances:!0});const i=Object.keys(t).map(Number).sort(((e,t)=>e-t));return i.forEach(((e,i)=>{t[e]=i})),Object.assign(e,gS(e,(e=>((0,zv.default)(e)&&Object.keys(e).forEach((i=>{i.endsWith("__t")&&(e[i.slice(0,-3)]=t[e[i]])})),e)),{visitInstances:!0})),i}(t),a=this._timeScales[s].convertTimesToIndexes(r,n);if(n){const e=new Set,t=[],s=[];let o=0;for(let n=a.length-1;n>=0;n--){const l=a[n];e.has(l)||l===Fh.INVALID_TIME_POINT_INDEX?(i.splice(n,1),o++):(t.unshift(r[n]),s.unshift(l),e.add(l))}o>0&&i.forEach(((e,t)=>{e.startIndex=t,e.endIndex=t+1})),r=t,a=s}this._studiesNonSeriesTimes[s][o]=r,t.indexes=a,h([],t);break}default:$S("unsupported non-series data type for study "+e.type)}}})}_isEndOfData(e,t,i){const s=e+"!"+t+"@"+i;return Boolean(this._endOfData[s])}_setEndOfData(e,t,i,s){const o=e+"!"+t+"@"+i;this._endOfData[o]=!1!==s}_applyTimeScaleUpdate(e,t){if(null===t)return;const i=[];for(const t of this._getStudiesCacheSessionKeys(e)){const s=this._studiesCache[e][t];if(s&&"study"===s.type){const o=this._studiesNonSeriesTimes[e][t];if(o){const n={indexes:this._timeScales[e].convertTimesToIndexes(o),data:{indexes_replace:!0}};i.push({objId:t,turnaround:s.turnaround,data:[],nonSeriesData:n})}}}
this._chartApiMessagerProvider.getChartApiMessager(e).onTimescaleUpdate(t,i),Promise.resolve().then((()=>{const t=this._mainSeriesRecord(e);if(null!==t&&null!=t.symbolInfo){const i=t.symbolInfo,s=(s=t.resolution)=>this._getSymbolExtrapolator(e,i,s);this._pointsetsManagers[e].getUpdatesForSymbol(t.symbolInfo.full_name,t.resolution,s,this._timeScales[e]).forEach(((t,i)=>{this._chartApiMessagerProvider.getChartApiMessager(e).onPointsetDataUpdate(i,null,t)}))}}))}_updateMainTsBuilder(e){const t=this._mainSeriesRecord(e);if(null!==t&&null!=t.symbolInfo){const i=this._getSymbolExtrapolator(e,t.symbolInfo,t.resolution);this._timeScales[e].setMainSymbolExtrapolator(i)}}_updateTimeScaleState(e){if(!this._studiesCache[e])return;let t=!0,i=!0;for(const s of this._getStudiesCacheSessionKeys(e)){const o=this._studiesCache[e][s];"InactivityGaps@tv-basicstudies-1"!==o?.metainfo?.id&&(i=i&&this._isEndOfData(e,s,o.turnaround),t=t&&o.completed)}this._timeScales[e].isCompleted()!==t&&(this._timeScales[e].setCompleted(t),t&&this._chartApiMessagerProvider.getChartApiMessager(e).onTimescaleCompleted(i))}_getStudiesCacheSessionKeys(e){return void 0!==this._studiesCache[e]?Object.keys(this._studiesCache[e]):[]}}WS.debugGetQuotesRequestId=1;const HS=WS;function zS(e,t){return"string"==typeof e?e:(0,zv.default)(e)&&e&&"message"in e&&(0,et.default)(e.message)?e.message:t}function US(e,t){return e+"_"+t}function jS(e,t){return e+"_"+t}function GS(e,t,i,s){return e+(t?"_#_"+t:"")+(i?"_#_"+i:"")+(s?"_#_"+s:"")}function qS(e,t,i,s){return[e,t,i,s].filter((e=>(0,et.default)(e)&&e.length>0)).join("|")}function $S(e){console.warn(`${(new Date).toISOString()} ${e}`)}function KS(e){const t=(0,Pv.decodeExtendedSymbol)(e),i="string"==typeof t.symbol?t:t.symbol;return[i.symbol,{currency:"currency-id"in i&&i["currency-id"],unit:"unit-id"in i&&i["unit-id"],session:"session"in i?i.session===Xv.SubsessionId.Regular?void 0:i.session:void 0}]}function YS(e){const t=e.findIndex((e=>e.index!==RS));return-1===t?[]:0===t?e:e.slice(t)}function ZS(e){if(null===e||"number"==typeof e)return e;if("object"==typeof e&&Array.isArray(e)){switch(e[0]){case"bar_count":return e[2];case"from_to":return e.length>=3?e[2]??null:null}}return null}function XS(e,t,i){if(i.logoid=void 0,i["base-currency-logoid"]=void 0,i["currency-logoid"]=void 0,e){if("string"==typeof e)return void $S("`logo_urls` should be an array of urls, not a string.");const[t,s]=e;s?(i["base-currency-logoid"]=t,i["currency-logoid"]=s):i.logoid=t}t&&(i.provider_id=t,i.country=void 0)}function JS(e){return e.timezone=e.timezone,e}(0,A.setClasses)();const QS=(0,r.getChartingLibraryGlobalContext)(),eb=(0,r.getChartingLibraryOwner)(),tb=new class{constructor(e,t){this._updateDocumentHeight=e=>{"visual"===this._viewportType&&this._window.document.documentElement.style.setProperty("height",`${e}px`,"important")},this._window=e,this._fullscreenApi=new Oe(e.document),this._viewportType=ze.CheckMobile.iOS()&&!(0,He.isOnMobileAppPage)("any")&&this._window.visualViewport?"visual":"quirks",
"visual"===this._viewportType?this._viewport=(0,n.ensure)(this._window.visualViewport):this._viewport=this._window;const i=this._layoutSizeSensor=this._window.document.createElement("div");i.id="layout-size-sensor",i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.right="0",i.style.bottom="0",i.style.pointerEvents="none",i.style.visibility="hidden",this._initFullscreen()}allocate(){this.free();const e=this._window.document,t=e.createElement("div");t.classList.add("js-rootresizer__contents"),t.style.position="relative",t.style.width="100%",t.style.height="100%",e.body.insertAdjacentElement("afterbegin",t),e.body.insertAdjacentElement("afterbegin",this._layoutSizeSensor),this._visibilityApi=new Fe(this._window.document);const i={alive:new O.WatchedValue(!0),fullscreenable:new O.WatchedValue(!0),container:new O.WatchedValue(t),width:new O.WatchedValue,height:new O.WatchedValue,availWidth:new O.WatchedValue,availHeight:new O.WatchedValue,visible:this._visibilityApi.isVisible,fullscreen:this._fullscreenApi.isFullscreen,remove:()=>{i.alive.setValue(!1)},attach:()=>{i.alive.setValue(!1),this._window.close()},requestFullscreen:()=>{this._requestFullscreen()},exitFullscreen:()=>{this._exitFullscreen()}};return i.alive.subscribe((e=>{e||i!==this._area||this.free()})),this._area=i,this._resizeHandler=()=>{const e=this._width(i)||800,t=this._height(i)||600;i.availHeight.setValue(t),i.availWidth.setValue(e),i.height.setValue(t),i.width.setValue(e)},this._area.height.subscribe(this._updateDocumentHeight,{callWithLast:!0}),this._resizeHandler(),this._viewport.addEventListener("resize",this._resizeHandler),new Ne(i).bridge()}free(){if(this._resizeHandler&&(this._viewport.removeEventListener("resize",this._resizeHandler),this._resizeHandler=void 0),this._visibilityApi&&(this._visibilityApi.destroy(),this._visibilityApi=void 0),this._area){const e=this._area;this._area=void 0,e.height.unsubscribe(this._updateDocumentHeight),e.alive.setValue(!1);const t=e.container.value(),i=t?.parentElement;i&&(i.removeChild(t),i.removeChild(this._layoutSizeSensor))}}_height(e){if("visual"===this._viewportType)return this._layoutSizeSensor.clientHeight;return e.container.value().clientHeight}_width(e){return e.container.value().clientWidth}_requestFullscreen(){this._fullscreenApi.enter()}_exitFullscreen(){this._fullscreenApi.exit()}_initFullscreen(){this._fullscreenApi.isFullscreen.subscribe((e=>{this._resizeHandler&&this._resizeHandler()}))}}(window),ib=new class{constructor(e){this._processVisibility=e=>{const t=e.container.value();return this.affectsLayout(e.name)?(t&&t.classList.toggle("js-hidden",!1),!0):(t&&t.classList.toggle("js-hidden",!0),!1)},this._setWidth=(e,t,i)=>{let s=i;this._fullscreenArea!==e.name&&(e.availWidth.setValue(i),e.canNegotiate.width&&(s=Ue(i,e.negotiations.width))),t||(s=0);const o=e.container.value();return o&&t&&(o.style.width=s+"px"),e.width.setValue(s),s},this._setHeight=(e,t,i)=>{let s=i;this._fullscreenArea!==e.name&&(e.availHeight.setValue(i),e.canNegotiate.height&&(s=Ue(i,e.negotiations.height))),
t||(s=0);const o=e.container.value();return o&&t&&(o.style.height=s+"px"),e.height.setValue(s),s};const t=e.container.value();if(!t)throw new Error("bridge.container.value() must be an element");this._container=t,this._availableAreas=["left","tradingpanel","right","top","bottom","center","topleft","extratop"],this._areas={},this._bridge=e,this._width=e.width,this._height=e.height,this._width.subscribe((()=>this.recalculate())),this._height.subscribe((()=>this.recalculate())),this._bridge.visible.subscribe((()=>this._updateVisibility())),this._bridge.fullscreen.subscribe((()=>this._onParentFullscreenChange())),this.recalculate()}allocate(e){const t=e&&e.areaName;if(-1===this._availableAreas.indexOf(t))throw new Error("unknown options.areaName");this.free(t);const i=this._createDOM(t),s={name:t,canNegotiate:{width:"left"===t||"right"===t||"tradingpanel"===t||"topleft"===t,height:"top"===t||"bottom"===t||"topleft"===t||"extratop"===t},negotiations:{width:[],height:[]},remove:()=>{for(const e in this._areas)this._areas[e]===s&&this.free(e)},negotiateWidth:e=>{if(!s.canNegotiate.width)return;const t=je(e);Ge(s.negotiations.width,t)||(s.negotiations.width=t,this.recalculate())},negotiateHeight:e=>{if(!s.canNegotiate.height)return;const t=je(e);Ge(s.negotiations.height,t)||(s.negotiations.height=t,this.recalculate())},requestFullscreen:()=>{this._fullscreenArea||("right"!==t&&"center"!==t||(this._fullscreenArea=t),"center"===t&&this._bridge.requestFullscreen(),this._updateFullscreen())},exitFullscreen:()=>{t===this._fullscreenArea&&(this._fullscreenArea=void 0,"center"===t&&this._bridge.exitFullscreen(),this._updateFullscreen())},width:new O.WatchedValue,height:new O.WatchedValue,availWidth:new O.WatchedValue,availHeight:new O.WatchedValue,alive:new O.WatchedValue(!0),container:new O.WatchedValue(i),visible:new O.WatchedValue(!0),fullscreen:new O.WatchedValue(!1),fullscreenable:new O.WatchedValue("right"===t||"center"===t),rdState:new Ne};return s.rdState.pushOwner(s),this._areas[t]=s,s.rdState.owner.subscribe((e=>{const i=s.container.value();if(e!==s)i&&(i.innerHTML="",i.parentElement&&i.parentElement.removeChild(i));else{let e=null;for(let i=this._availableAreas.indexOf(t);i--;){const t=this._availableAreas[i];if(this.affectsLayout(t)){e=this._areas[t].container.value();break}}i&&(e&&i.parentElement?i.insertAdjacentElement("afterend",e):this._container.appendChild(i))}this.recalculate()}),{callWithLast:!0}),s.rdState.bridge()}free(e){const t=this._areas[e];if(!t)return;this._areas[e]=void 0;const i=t.container.value();i&&i.parentElement&&i.parentElement.removeChild(i),t.alive.setValue(!1)}recalculate(){const e={};this._recalcSingleRunToken=e;const t=this._areas.topleft,i=this._areas.left,s=this._areas.tradingpanel,o=this._areas.right,n=this._areas.top,r=this._areas.bottom,a=this._areas.center,l=this._areas.extratop,c=this._width.value(),h=this._height.value();let d=0,u=0,_=0,p=0,m=0,g=0,f=0,y=0;if(e===this._recalcSingleRunToken&&l){const e=this._processVisibility(l);y=this._setHeight(l,e,h),this._setWidth(l,e,c)}
if(e===this._recalcSingleRunToken&&t){const e=this._processVisibility(t);f=this._setHeight(t,e,h),g=this._setWidth(t,e,c);const i=t.container.value();e&&i&&(i.style.top=y+"px")}let v=0;if(e===this._recalcSingleRunToken&&n){const e=this._processVisibility(n),t=n.container.value();e&&t&&(t.style.left=g+"px",t.style.top=y+"px");const i=c-g;this._setWidth(n,e,i),d=this._setHeight(n,e,h),d&&(v=1)}if(e===this._recalcSingleRunToken&&i){const e=this._processVisibility(i),t=Math.max(f,d);_=this._setWidth(i,e,c),_&&(_+=4),_&&1===v&&(v=4);const s=i.container.value();e&&s&&(s.style.top=t+y+v+"px"),this._setHeight(i,e,h-t-y)}if(e===this._recalcSingleRunToken&&s){const e=this._processVisibility(s);let t=c-_;qe||(t-=300),m=this._setWidth(s,e,t),m&&1===v&&(v=4),this._setHeight(s,e,h-y-d-v)}if(e===this._recalcSingleRunToken&&o){const e=this._processVisibility(o);let t=c-_-m;qe||(t-=300),p=this._setWidth(o,e,t),p&&1===v&&(v=4),this._setHeight(o,e,h-y-d-v);const i=o.container.value();e&&i&&(i.style.top=d+y+v+"px")}const S=m+p;let b=0,w=c-_-m-p-(S?4:0);const C=Boolean(m||!S);if(!p&&m&&(w+=4),e===this._recalcSingleRunToken&&r){const e=this._processVisibility(r),t=r.container.value();e&&t&&(t.style.left=_+"px",t.classList.toggle("no-border-top-left-radius",!_),t.classList.toggle("no-border-top-right-radius",C)),this._setWidth(r,e,w);const i=h-y;b=Math.min(300,i-0),u=this._setHeight(r,e,i)+4}const T=Boolean(d&&(_||S));if(this._container.classList.toggle("layout-with-border-radius",T),e===this._recalcSingleRunToken&&a){const e=this._processVisibility(a),t=a.container.value();e&&t&&(t.style.left=_+"px",t.style.top=d+y+v+"px",t.classList.toggle("no-border-bottom-left-radius",!u||!_),t.classList.toggle("no-border-bottom-right-radius",C||!u),t.classList.toggle("no-border-top-left-radius",Boolean(!_&&S)),t.classList.toggle("no-border-top-right-radius",C)),this._setWidth(a,e,w);const i=h-d-u-y-v;this._setHeight(a,e,Math.max(i,b))}if(e===this._recalcSingleRunToken&&s&&this.affectsLayout("tradingpanel")){const e=s.container.value();e&&(e.style.right=m&&p?`${p+4}px`:`${p}px`,e.style.top=y+d+v+"px",e.style.borderTopRightRadius=T&&p?"4px":"0px")}e===this._recalcSingleRunToken&&this._updateVisibility()}affectsLayout(e){const t=this._areas[e];if(!t)return!1;if(t.rdState.owner.value()!==t)return!1;if(this._fullscreenArea&&this._fullscreenArea!==e)return Ye(e);if(this._width.value()<=567||this._height.value()<=445&&!Ke){if(!["center","top","left","topleft","extratop"].includes(e))return!1}return!0}_updateVisibility(){const e=this._bridge.visible.value();for(let t=0;t<this._availableAreas.length;t++){const i=this._availableAreas[t],s=this._areas[i];s&&(e&&this.affectsLayout(i)?s.visible.setValue(!0):s.visible.setValue(!1))}}_onParentFullscreenChange(){this._bridge.fullscreen.value()||(this._fullscreenArea=void 0,this._updateFullscreen())}_updateFullscreen(){const e=void 0!==this._fullscreenArea;for(let t=0;t<this._availableAreas.length;t++){const i=this._availableAreas[t],s=this._areas[i];if(!s)continue;if(i===this._fullscreenArea){
s.fullscreen.setValue(!0);continue}s.fullscreen.setValue(!1);const o=s.container.value();o&&o.classList.toggle("js-hidden",e&&!Ye(i))}this._updateVisibility(),this.recalculate()}_createDOM(e){const t=document.createElement("div");return t.classList.add("layout__area--"+e),t.style.position="absolute","tradingpanel"===e&&(t.style.borderTopRightRadius="4px"),"bottom"===e?t.style.bottom="0":t.style.top="0","right"===e||"tradingpanel"===e?t.style.right="0":t.style.left="0",t}}(tb.allocate()),sb=(eb.brokerFactory,Boolean(!1)),ob=QS.urlParams;QS.DEFAULT_SYMBOL=ob.symbol??"";const nb=new AbortController,rb=eb.getCustomIndicators,ab=(0,me.createDeferredPromise)(),lb=(0,me.createDeferredPromise)(),cb=(0,me.createDeferredPromise)(),hb=l.enabled("left_toolbar"),db=l.enabled("library_custom_color_themes"),ub=JSON.parse(ob.widgetbar),_b=l.enabled("right_toolbar")&&(ub.watchlist||ub.details||ub.news||ub.datawindow||l.enabled("dom_widget")||l.enabled("order_panel")||l.enabled("show_object_tree")||l.enabled("bugreport_button")),pb=l.enabled("header_widget")?ib.allocate({areaName:"top"}):null,mb=hb?ib.allocate({areaName:"left"}):null,gb=ib.allocate({areaName:"center"}),fb=(_b&&ib.allocate({areaName:"right"}),null);if(void 0!==eb.contextMenu&&Cy.setContextMenuOptions(eb.contextMenu),Promise.all([ab.promise,lb.promise,cb.promise]).then((()=>{QS.ChartApiInstance.start()})),"function"==typeof rb){const e=rb({Std:Py.Std});e&&e.then?e.then((e=>{if(!Array.isArray(e))return console.warn("custom_indicators_getter should be a function that returns a Promise object which result is an array of custom indicators"),void ab.resolve();const t=QS.JSServer;for(const i of e)if("function"==typeof i){const e=(new Ev).build(i);t.studyLibrary.push.call(t.studyLibrary,e)}else t.studyLibrary.push.call(t.studyLibrary,i);ab.resolve(),console.log("{0} custom indicators loaded.".format(e.length))})).catch((e=>{console.warn("Error loading custom indicators "+e),ab.resolve()})):(console.warn("custom_indicators_getter should be a function that returns a Promise object"),ab.resolve())}else ab.resolve();QS.widgetReady=e=>{ee.subscribe("onChartReady",e,null)};const yb=ob.theme?.toLowerCase()??$s.StdTheme.Light;var vb;function Sb(e){QS.__defaultsOverrides=QS.__defaultsOverrides||{},(0,ge.deepExtend)(QS.__defaultsOverrides,e),void 0!==TradingView.defaultProperties&&void 0!==TradingView.defaultProperties.chartproperties&&((0,h.applyDefaultsOverrides)(TradingView.defaultProperties.chartproperties),(0,h.applyDefaultOverridesToLinetools)())}vb=yb,L.themes[vb]&&(0,k.setTheme)(vb),async function(e){if(!db||void 0===e)return;try{const{overrideStandardThemes:t}=await i.e(2413).then(i.bind(i,79736));t(e)}catch(e){console.error("Error applying custom themes",e)}}(eb.customThemes).then(cb.resolve).catch(cb.resolve),QS.applyStudiesOverrides=e=>{e&&(QS.chartWidgetCollection?QS.chartWidgetCollection.applyStudiesOverrides?.(e):ns.StudyMetaInfo.mergeDefaultsOverrides(e))},QS.applyOverrides=e=>{Sb(e),QS.chartWidgetCollection&&QS.chartWidgetCollection.applyOverrides(e)},
QS.doWhenApiIsReady=e=>{QS.tradingViewApi?e():lb.promise.then(e)},QS.applyTradingCustomization=e=>{if(e.order)for(const t in e.order)TradingView.defaultProperties.linetoolorder[t]=e.order[t];if(e.position)for(const t in e.position)TradingView.defaultProperties.linetoolposition[t]=e.position[t];return null===fb?Promise.resolve():fb.then((t=>{function i(e){const t={};for(const i of Object.keys(e??{})){const s=i.split(".");let o=t;for(const e of s.slice(0,s.length-1))o.hasOwnProperty(e)||(o[e]={}),o=o[e];o[s[s.length-1]]=e[i]}return t}if(null===t)return;const s=i(e.brokerOrder),o=i(e.brokerPosition);t?.overrideTradedGroupStyles({order:{lightTheme:s,darkTheme:s},position:{lightTheme:o,darkTheme:o}})}))},QS.changeTheme=(e,t)=>{const i=L.themes[e.toLowerCase()];return i?QS.tradingViewApi.themes().setStdTheme(i.name,!0,t&&t.disableUndo):Promise.resolve()},QS.getTheme=()=>QS.tradingViewApi.themes().getCurrentThemeName(),QS.customThemes=async()=>{if(!db)return Promise.reject(new Error("The library_custom_color_themes feature must be enabled to use the custom themes API"));return new((await i.e(2413).then(i.bind(i,82753))).CustomThemesApi)},QS.is_authenticated=!1;JSON.parse(QS.urlParams.brokerConfig);a.t(null,void 0,i(94566)),a.t(null,void 0,i(92800)),a.t(null,void 0,i(44676));let bb=null;const wb=(0,me.createDeferredPromise)();let Cb;const Tb=()=>{if(l.setEnabled("charting_library_export_chart_data",!QS.configurationData.is_tradingview_data),l.setEnabled("charting_library_debug_mode","true"===ob.debug||l.enabled("charting_library_debug_mode")),l.setEnabled("chart_property_page_trading",!1),l.enabled("remove_library_container_border")){const e=document.querySelector("#library-container");null!==e&&(e.style.border="0px",e.style.padding="1px")}l.enabled("no_min_chart_width")&&(document.body.style.minWidth="0px"),null!=ob.studiesOverrides&&ns.StudyMetaInfo.mergeDefaultsOverrides(JSON.parse(ob.studiesOverrides)),(0,n.assert)(void 0===TradingView.defaultProperties,"Default properties are inited before applying overrides"),Sb(JSON.parse(ob.overrides));const e=ob.numeric_formatting?JSON.parse(ob.numeric_formatting):void 0;e&&("string"==typeof e.decimal_sign&&(ue.formatterOptionsLibraryOverrides.decimalSign=e.decimal_sign[0]),"string"==typeof e.grouping_separator&&(ue.formatterOptionsLibraryOverrides.groupingSeparator=e.grouping_separator[0]));const t=new Sv,s=new Nv,c=new Bv,h=ob.studiesAccess&&JSON.parse(ob.studiesAccess)||{type:"black",tools:[]},d=new Df(h,c),u=new Ov((0,r.getChartingLibraryGlobalContext)().JSServer.studyLibrary),_=new HS(eb.datafeed,t,s,u);QS.ChartApiInstance=new Ef(t,_,c,d);const p=eb.customFormatters;p&&(p.timeFormatter&&(_e.customFormatters.timeFormatter=p.timeFormatter),p.dateFormatter&&(_e.customFormatters.dateFormatter=p.dateFormatter),p.tickMarkFormatter&&(_e.customFormatters.tickMarkFormatter=p.tickMarkFormatter),p.priceFormatterFactory&&(_e.customFormatters.priceFormatterFactory=p.priceFormatterFactory),p.studyFormatterFactory&&(_e.customFormatters.studyFormatterFactory=p.studyFormatterFactory)),
eb.customTimezones&&De.instance().addTimezones(eb.customTimezones);const m=ob.chartContent?JSON.parse(ob.chartContent).json:void 0,g=ob.chartContentExtendedData?JSON.parse(ob.chartContentExtendedData):m?m.extendedData:void 0,f=ob.interval||"D",v=function(e){const t=/(\d+)(\w+)/;return e.map((e=>{const s=(0,n.ensureNotNull)(t.exec(e.text)),o=s[2].toLowerCase(),r=parseInt(s[1]),l="y"===o?12*r+"M":r+o,c=Re.Interval.parse(l.toUpperCase()),h=Re.Interval.parse(e.resolution);return{text:e.title||{y:a.t(null,{plural:"{count}y",count:r,context:"short_N_year"},i(46766)),m:a.t(null,{plural:"{count}m",count:r,context:"short_N_month"},i(58590)),d:a.t(null,{plural:"{count}d",count:r,context:"short_N_day"},i(47801))}[o]||`${r}${o}`,description:e.description||"",value:{value:c.value(),type:"period-back"},targetResolution:h.value(),requiresIntraday:c.isIntraday()}}))}(JSON.parse(ob.timeFrames)),S={resizerBridge:gb,padding:l.enabled("border_around_the_chart")?2:0,content:m,widgetOptions:{addToWatchlistEnabled:!1,hideIdeas:!0,addVolume:(0,n.ensureDefined)(QS.ChartApiInstance.studiesAccessController).isToolEnabled("Volume"),muteSessionErrors:!0,timezone:ob.timezone,defSymbol:ob.symbol??"",defInterval:m?"":f,compareSymbols:ob.compareSymbols&&JSON.parse(ob.compareSymbols),defTimeframe:(b=eb.timeframe,b?"string"==typeof b?b:{...b,type:"time-range"}:b),paneContextMenuEnabled:l.enabled("pane_context_menu"),paneContextMenu:{mainSeriesTrade:sb},priceScaleContextMenuEnabled:l.enabled("scales_context_menu"),currencyConversionEnabled:l.enabled("pricescale_currency"),unitConversionEnabled:l.enabled("pricescale_unit"),legendWidgetEnabled:l.enabled("legend_widget"),legendWidget:{contextMenu:{settings:l.enabled("show_chart_property_page"),showOpenMarketStatus:l.enabled("display_market_status")}},sourceStatusesWidget:{errorSolution:!1},marketStatusWidgetEnabled:l.enabled("display_market_status"),chartWarningWidget:{subscriptionFullInfo:!1},timeScaleWidget:{contextMenuEnabled:l.enabled("scales_context_menu"),timezoneMenuEnabled:l.enabled("timezone_menu"),priceAxisLabelsOptions:{showLabels:l.enabled("main_series_scale_menu")}},timeScale:{preserveBarSpacing:!1,lockVisibleTimeRangeOnResize:l.enabled("lock_visible_time_range_on_resize"),rightBarStaysOnScroll:l.enabled("right_bar_stays_on_scroll"),minBarSpacing:ob.time_scale&&JSON.parse(ob.time_scale).min_bar_spacing},goToDateEnabled:l.enabled("go_to_date"),crossHair:{menuEnabled:l.enabled("chart_crosshair_menu")},handleScale:{mouseWheel:l.enabled("mouse_wheel_scale"),pinch:l.enabled("pinch_scale"),axisPressedMouseMove:{time:l.enabled("axis_pressed_mouse_move_scale"),price:l.enabled("axis_pressed_mouse_move_scale")}},handleScroll:{mouseWheel:l.enabled("mouse_wheel_scroll"),pressedMouseMove:l.enabled("pressed_mouse_move_scroll"),horzTouchDrag:l.enabled("horz_touch_drag_scroll"),vertTouchDrag:l.enabled("vert_touch_drag_scroll")},shiftVisibleRangeOnNewBar:l.enabled("shift_visible_range_on_new_bar"),croppedTickMarks:l.enabled("cropped_tick_marks"),countdownEnabled:l.enabled("countdown"),
indicatorsDialogShortcutEnabled:l.enabled("insert_indicator_dialog_shortcut")},seriesControlBarEnabled:l.enabled("timeframes_toolbar"),seriesControlBar:{timeFramesWidgetEnabled:!0,timeFramesWidget:{goToDateEnabled:l.enabled("go_to_date"),availableTimeFrames:(e,t)=>{if(!e)return[];if(t!==bt.STATUS_DELAYED&&t!==bt.STATUS_DELAYED_STREAMING&&t!==bt.STATUS_EOD&&t!==bt.STATUS_READY)return[];return v.filter((t=>!(t.requiresIntraday&&!e.has_intraday)&&!(e.supported_resolutions&&!e.supported_resolutions.includes(t.targetResolution))))}},timeWidgetEnabled:!0,timeWidget:{timezoneMenuEnabled:l.enabled("timezone_menu")},adjustForDividendsButtonEnabled:!1,sessionIdButtonEnabled:l.enabled("pre_post_market_sessions"),backAdjustmentButtonEnabled:!1,settlementAsCloseButtonEnabled:!1,percentageScaleButtonEnabled:!0,logScaleButtonEnabled:!0,autoScaleButtonEnabled:!0,layoutFullscreenButtonEnabled:!0,mobileChangeLayoutEnabled:!1},globalEvents:!0,snapshotUrl:ob.snapshotUrl,mobileForceChartMaximizeEnabled:!1,saveChartEnabled:l.enabled("save_shortcut")};var b;hb&&((0,xf.createFavoriteDrawingToolbar)(),S.widgetOptions.isDrawingToolbarVisible=P.isDrawingToolbarVisible),g&&(S.metaInfo={id:g.uid,name:g.name,description:g.description,uid:g.uid,username:""}),eb.additionalSymbolInfoFields&&(0,lv.setAdditionalSymbolInfoFields)(eb.additionalSymbolInfoFields);const w=eb.symbolSearchComplete;w&&(0,cv.setSymbolSearchCompleteOverrideFunction)(w);const C=QS.chartWidgetCollection=new Pf(S);let x=!1;C.onAboutToBeDestroyed.subscribe(null,(()=>{x=!0}),!0),function(e){e.addCustomSource("branding",((t,i)=>{const s=(0,ft.combine)(((e,t)=>{const s=e??t;return null!==s&&s.hasModel()&&s.model().model()===i}),e.maximizedChartWidget().weakReference(),e.leftBottomChartWidget().weakReference());return new ev(t,i,s.ownership())}),Co.CustomSourceLayer.Topmost)}(C),QS.studyMarket=new pe(C),Je.registerService(Xe.CHART_WIDGET_COLLECTION_SERVICE,C),C.activeChartWidget.subscribe((e=>{ee.emit("activeChartChanged",C.getAll().indexOf(e))})),QS.saver=new N.ChartSaver(C);const A=new I.ChartChangesWatcher(C,QS.saver,ee),k=new Z(C,QS.saver,A);C.setSaveChartService(k);const E=new oe(C);QS.chartWidget=C.activeChartWidget.value(),QS.pro=new TradingView.Pro;const B=function(e){if(!pb)return null;const t=JSON.parse(ob.favorites);t.intervals=t.intervals.map((e=>{let t=""+e;return t.match(/1[DWMYdwmy]/)&&(t=t.slice(1)),t})),l.enabled("study_templates")&&(Cb=new he({chartWidgetCollection:e.chartWidgetCollection}));let s;const o=ob.header_widget_buttons_mode;"fullsize"===o&&(s=["full"]);"compact"===o&&(s=["small"]);const n=(0,gv.shouldShowQuickSearchOnLib)()?function(e){const t=t=>Promise.all([i.e(9520),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(6032),i.e(3672),i.e(3359),i.e(3425),i.e(1697),i.e(4587),i.e(7833),i.e(8752),i.e(8260),i.e(1979),i.e(7780),i.e(445),i.e(846),i.e(1667),i.e(3290),i.e(6870),i.e(2227),i.e(4931),i.e(9418),i.e(4426),i.e(9026),i.e(1890),i.e(1727),i.e(9754)]).then(i.bind(i,11065)).then((i=>{const s=new(0,
i.GlobalSearchDialogRenderer)(e);return null!==Ve&&Ve.hide(),s.show(t),Ve=s,s}));return(0,D.createGroup)({desc:"GlobalSearch"}).add({desc:"Open",hotkey:D.Modifiers.Mod+75,handler:()=>t()}),t}(e.loadChartService):void 0;return new T(new y,{chartSaver:QS.saver,chartApiInstance:QS.ChartApiInstance,chartWidgetCollection:e.chartWidgetCollection,defaultFavoriteStyles:t.chartTypes,defaultFavoriteIntervals:t.intervals,resizerBridge:pb,studyMarket:QS.studyMarket,studyTemplates:Cb,allowedModes:s,saveChartService:e.saveChartService,loadChartService:e.loadChartService,chartChangesWatcher:e.chartChangesWatcher,onClick:Ab,snapshotUrl:e.snapshotUrl,openGlobalSearch:n})}({chartWidgetCollection:C,saveChartService:k,chartChangesWatcher:A,loadChartService:E,snapshotUrl:ob.snapshotUrl});null!==B?B.load().then((e=>{bb=e.getComponent(),wb.resolve()})):(wb.promise.catch((()=>{})),wb.reject("header widget is not loaded"));const V=function(e){if(mb){const t=ob.toolbarbg&&/^[0-9a-f]+$/i.test(ob.toolbarbg)?String(ob.toolbarbg):void 0;if(t){const e=document.createElement("style");e.textContent="body,.chart-controls-bar,#footer-chart-panel{background-color:#"+t+" !important}",document.head.appendChild(e)}return new M({bgColor:t,chartWidgetCollection:e,drawingsAccess:ob.drawingsAccess?JSON.parse(ob.drawingsAccess):void 0,resizerBridge:mb,onClick:Ab})}return null}(C),R=null;QS.tradingViewApi=new Cy({chartWidgetCollection:C,chartApiInstance:QS.ChartApiInstance,saveChartService:k,loadChartService:E,studyMarket:null});if(de.linking.bindToChartWidgetCollection(C),isNaN(ob.studyCountLimit)||(TradingView.STUDY_COUNT_LIMIT=Math.max(2,+(0,n.ensureDefined)(ob.studyCountLimit))),!isNaN(ob.ssreqdelay)){const e=Math.max(0,+(0,n.ensureDefined)(ob.ssreqdelay));(0,Ty.setSearchRequestDelay)(e)}QS.ChartApiInstance.connect(),(async()=>{const{LineToolPropertiesWidget:e}=await Promise.all([i.e(7617),i.e(8185),i.e(1681),i.e(3439),i.e(8933),i.e(6032),i.e(3672),i.e(2537),i.e(3359),i.e(3425),i.e(8260),i.e(1979),i.e(7780),i.e(7827),i.e(8220),i.e(9590),i.e(1667),i.e(9836),i.e(3290),i.e(6178),i.e(7777),i.e(2227),i.e(3179),i.e(1890),i.e(6193),i.e(6376),i.e(2306)]).then(i.bind(i,36699));x||(QS.lineToolPropertiesToolbar=new e(C))})();const O=document.querySelector(".tv-content");null!==O&&O.addEventListener("contextmenu",(e=>{e.target instanceof Element&&"input"!==e.target.tagName.toLowerCase()&&"textarea"!==e.target.tagName.toLowerCase()&&e.preventDefault()})),lb.resolve(),C.undoHistory.undoStack().onChange().subscribe(null,(0,o.default)((e=>{e?.affectsState()&&ee.emit("onAutoSaveNeeded")}),1e3*(Number(ob.autoSaveDelay)||5),{leading:!1,trailing:!0}));let F=!1;function W(){V&&V.load(nb.signal),R&&R.load(nb.signal).then((e=>{QS.footerWidget=e.getComponent()}))}QS.chartWidget.withModel(null,(()=>{QS.ChartApiInstance.on("realtime_tick",(e=>{ee.emit("onTick",e)}));if(!L.savedThemeName()&&yb){const e=L.getStdTheme(yb);e&&e.content&&void 0===m&&C.applyTheme({theme:e.content,onlyActiveChart:!1,restoreNonThemeDefaults:!1,themeName:yb,standardTheme:!0,syncState:!0,noUndo:!0
}).then((()=>QS.applyOverrides(QS.__defaultsOverrides)))}if(l.enabled("charting_library_debug_mode")&&ee.subscribeToAll(((...e)=>{console.log(`${(new Date).toISOString()} Event "${e[0]}", arguments: ${JSON.stringify(e.slice(1))}`)})),F)return;F=!0,If(C),function(e,t){const s=a.t(null,void 0,i(37367)).format({emoji:"👍"}),o=a.t(null,void 0,i(69804)).format({emoji:"👍"}),r=a.t(null,void 0,i(6655)).format({emoji:"👍"});ee.on("onServerScreenshotCopiedToClipboard",(()=>h(s)),null),ee.on("onClientScreenshotCopiedToClipboard",(()=>h(o)),null),ee.on("onServerScreenshotEmbedCodeCopiedToClipboard",(()=>h(r)),null);let l=null;const c=e.getContainer();function h(e){l?l.show(e):Promise.all([i.e(5371),i.e(2307),i.e(2227),i.e(92)]).then(i.bind(i,1524)).then((i=>{l||(l=new i.ChartScreenshotHintRenderer((0,n.ensureNotNull)(c),{bottomPadding:t.seriesControlBarEnabled}),l.show(e))}))}}(C,{seriesControlBarEnabled:l.enabled("timeframes_toolbar")});P_.getInstance().setWidgetCollection(QS.chartWidgetCollection)})),C.getAll().some((e=>e.isInitialized()))?W():function(e,t){const i=e.getAll(),s=()=>{t(),i.forEach((e=>{e.chartWidgetInitialized().unsubscribe(null,s)}))};i.forEach((e=>{e.chartWidgetInitialized().subscribe(null,s,!0)}))}(C,W),ee.subscribe("chart_load_requested",(e=>{QS.tradingViewApi.loadChart({json:JSON.parse(e.content),extendedData:e})}),null)};window.addEventListener("unload",(()=>{nb.abort(),QS.widgetbar&&(QS.widgetbar.destroy(),QS.widgetbar=null),QS.chartWidgetCollection&&(QS.chartWidgetCollection.destroy(),QS.chartWidgetCollection=null),QS.ChartApiInstance&&QS.ChartApiInstance.disconnect(),(0,Ze.destroyQuoteSessions)(),QS.ChartApiInstance&&(QS.ChartApiInstance.destroy(),QS.ChartApiInstance=null)})),l.enabled("saveload_storage_customization")&&(eb.saveLoadAdapter?E.setCustomAdapter(eb.saveLoadAdapter):QS.urlParams.chartsStorageUrl&&QS.urlParams.clientId?E.initialize(QS.urlParams.clientId,QS.urlParams.userId,QS.urlParams.chartsStorageUrl,QS.urlParams.chartsStorageVer||"1.0"):(l.setEnabled("saveload_storage_customization",!1),l.setEnabled("header_saveload",!1))),void 0!==eb.imageStorageAdapter&&l.enabled("image_drawingtool")&&(0,fv.setImageStorageAdapter)(eb.imageStorageAdapter);const Pb=(0,me.createDeferredPromise)();function xb(){Pb.resolve()}eb.loadLastChart&&l.enabled("saveload_storage_customization")?E.getCharts().then((e=>{if(0===e.length)return void xb();const t=e.sort(((e,t)=>t.modified_iso-e.modified_iso))[0];E.getChartContent(t).then((e=>{const t=e,i=JSON.parse(t.content);i.extendedData=e,ob.chartContent=JSON.stringify({json:i}),xb()})).catch(xb)})).catch(xb):xb();const Mb=async function(){if(l.enabled("saveload_separate_drawings_storage")){const e=await i.e(7129).then(i.bind(i,67387));return Bm=e.LineToolsSynchronizer,!0}return!1}(),Ib=(0,me.createDeferredPromise)();function Ab(){const e=TradingView.bottomWidgetBar;e&&e.turnOffMaximize()}Promise.all([Ib.promise,Pb.promise,QS.loadedCustomCss,Mb,cb.promise]).then((()=>{const e=document.querySelector(".loading-indicator");if(e&&(e.style.display="none"),
setTimeout(Tb,0),l.enabled("14851")&&Math.random()<=.02){t=window,i=document,s="script",o="ga",t.GoogleAnalyticsObject=o,t[o]=t[o]||function(){(t[o].q=t[o].q||[]).push(arguments)},t[o].l=Number(new Date),r=i.createElement(s),a=i.getElementsByTagName(s)[0],r.async=1,r.src="//www.google-analytics.com/analytics.js",a.parentNode.insertBefore(r,a);const e=(0,n.ensureNotNull)(document.URL.match(new RegExp("(:?.*://)([^/]+)/.*")))[2];QS.ga("create","UA-112911840-1","auto"),QS.ga("set","anonymizeIp",!0),QS.ga("set",{hostname:e,page:e,referrer:e}),QS.ga("send","pageview")}var t,i,s,o,r,a})),(()=>{let e=!0;eb.datafeed.onReady((t=>{e&&console.warn("`onReady` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),QS.configurationData=t,Ib.resolve()})),e=!1})(),QS.createShortcutAction=(()=>{const e=D.createGroup({desc:"API",order:yv.ACTION_API_GROUP_ORDER});return(t,i)=>{var s;e.add({hotkey:(s=t,"number"==typeof s?s:"string"==typeof s?R(s.split("+")):Array.isArray(s)?R(s):0),handler:i})}})(),QS.initializationFinished=()=>{QS.chartWidgetCollection.undoHistory.clearStack()},QS.headerReady=()=>wb.promise,function e(t=0,i=10){const s={received:!1};QS.dispatchEvent(new CustomEvent("innerWindowLoad",{detail:s})),!s.received&&t<i&&setTimeout((()=>{e(t+1,i)}),10*Math.pow(2,t))}(),QS.createButton=e=>{if(null===bb)throw new Error("Cannot create button: header widget is not ready or is not loaded - use `headerReady` to wait until header is ready");(e=e||{}).align=e.align||"left",e.useTradingViewStyle=e.useTradingViewStyle||!1;const t=(0,fe.randomHash)();return bb.addButton(t,e)??t},QS.removeButton=e=>{if(null===bb)throw new Error("Cannot remove button: header widget is not ready or is not loaded - use `headerReady` to wait until header is ready");return bb.removeButton(e)},QS.createDropdown=e=>{if(void 0===e)throw new Error("Cannot create dropdown without any parameters. Please refer to the documentation");void 0===e.align&&(e.align="left");const t=(0,fe.randomHash)();return bb?(bb.addDropdown(t,e),Promise.resolve(new hv(bb,t))):wb.promise.then((()=>((0,n.ensureNotNull)(bb).addDropdown(t,e),new hv((0,n.ensureNotNull)(bb),t))))},QS.getAllFeatures=()=>{const e=l.getAllFeatures();return Object.keys(e).forEach((t=>{isNaN(parseFloat(t))||delete e[t]})),e},QS.getNavigationButtonsVisibility=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)((0,ve.property)()))),QS.getPaneButtonsVisibility=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)((0,Se.property)()))),QS.getDateFormat=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)(be.dateFormatProperty))),QS.getTimeHoursFormat=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)(we.timeHoursFormatProperty))),QS.getCurrencyAndUnitVisibility=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)((0,Be.currencyUnitVisibilityProperty)()))),QS.customSymbolStatus=()=>_v.getInstance();QS.urlParams.debugBroker,new Set(["connectionStatus"]);const Lb=ob.locale||"en",kb=Dt.getInstance();kb.createElement(document),kb.setLocale(Lb),
QS.customChartDescriptionFunction&&kb.setCustomProvider(QS.customChartDescriptionFunction);const Eb=Sm.getInstance();Eb.createElement(document),Eb.setLocale(Lb),function(){const e=l.enabled("accessible_keyboard_shortcuts")?(0,B.humanReadableHash)(9):`${(0,B.humanReadableModifiers)(B.Modifiers.Alt,!1)} + ${(0,B.humanReadableHash)(90)}`,t=`${(0,B.humanReadableModifiers)(B.Modifiers.Mod,!1)} + ${(0,B.humanReadableHash)(75)}`,s=a.t(null,void 0,i(7697)),o=[a.t(null,{replace:{shortcut:e}},i(85166)),a.t(null,{replace:{shortcut:t}},i(57959)),a.t(null,void 0,i(36332)),a.t(null,void 0,i(9687)),a.t(null,void 0,i(40490)),a.t(null,void 0,i(27884))],n=document.createElement("p");n.innerText=s;const r=document.createElement("ul");o.forEach((e=>{const t=document.createElement("li");t.innerText=e,r.appendChild(t)}));const c=document.createElement("div");c.setAttribute("role","contentinfo"),c.setAttribute("aria-hidden","false"),c.style.fontSize="0",c.appendChild(n),c.appendChild(r),document.body.insertBefore(c,document.body.firstChild)}(),window.addEventListener("keydown",(e=>{const t=(0,B.hashFromEvent)(e);9!==t&&t!==D.Modifiers.Shift+9||(0,pv.updateTabIndexes)()})),new zo.Action({actionId:"UnknownAction",options:{label:"",onExecute:()=>{(0,pv.updateTabIndexes)();const[e]=Array.from(document.querySelectorAll('button:not([disabled]):not([aria-disabled]):not([tabindex="-1"]), input:not([disabled]):not([aria-disabled]):not([tabindex="-1"]), [tabindex]:not([disabled]):not([aria-disabled]):not([tabindex="-1"])')).filter((0,mv.createScopedVisibleElementFilter)(document.documentElement)).sort(pv.navigationOrderComparator);void 0!==e&&e.focus()},hotkeyHash:l.enabled("accessible_keyboard_shortcuts")?9:D.Modifiers.Alt+90,hotkeyGroup:(0,D.createGroup)({desc:"Global shortcuts"})}})},52959:(e,t,i)=>{"use strict";function s(){return window}function o(){const e=s();return e.parent[e.urlParams.uid]}i.d(t,{getChartingLibraryGlobalContext:()=>s,getChartingLibraryOwner:()=>o})},29063:(e,t,i)=>{"use strict";i.r(t);var s=i(21097),o=i(51768),n=i(76422),r=i(38780);function a(e,t=!1){"loading"!==document.readyState?t?setTimeout((()=>e()),1):e():document.addEventListener("DOMContentLoaded",(()=>e()))}new Promise((e=>{a(e)}));function l(e,t="x"){let i=!1;return"x"!==t&&"both"!==t||(i=i||e.offsetWidth<e.scrollWidth),"y"!==t&&"both"!==t||(i=i||e.offsetHeight<e.scrollHeight),i}function c(e,t="x"){for(const i of Array.from(e.children))if(i instanceof HTMLElement&&(l(i,t)||c(i,t)))return!0;return!1}function h(e){let t="x";return e.matches(".apply-overflow-tooltip--direction_both")?t="both":e.matches(".apply-overflow-tooltip--direction_y")&&(t="y"),t}function d(e){const t=e.getAttribute("data-overflow-tooltip-html");if(t)return{type:"html",data:t};const i=e.getAttribute("data-overflow-tooltip-text");if(i)return{type:"text",data:i};if(e.matches?.(".apply-overflow-tooltip--allow-text")){return{type:"text",data:e.textContent||""}}const s=Array.from(e.childNodes).reduce(((e,t)=>(t.nodeType===Node.TEXT_NODE&&e.push(t.textContent||""),e)),[]).join("").trim();return s?{
type:"text",data:s}:{type:"none"}}function u(e,t){let i=!1;const s=e.children;for(let e=0;e<s.length;e++){const o=s[e];if(o instanceof HTMLElement&&l(o,t)){i=!0;break}}return i}function _(e){const t=e.target;if(t instanceof HTMLElement&&(t.matches(".apply-overflow-tooltip-focus")||t.querySelector(".apply-overflow-tooltip-focus"))){const e=t.matches(".apply-overflow-tooltip")?t:t.querySelector(".apply-overflow-tooltip"),i=h(e);if(e.matches(".apply-overflow-tooltip--check-children-recursively")){if(!c(e,i))return}else if(e.matches(".apply-overflow-tooltip--check-children")){if(!u(e,i))return}else if(!l(e,i))return;(0,r.showOnElement)(t,{content:d(e)});const s=()=>{(0,r.hide)(),t.removeEventListener("blur",s),t.removeEventListener("active-descendant-blur",s)};t.addEventListener("blur",s),t.addEventListener("active-descendant-blur",s)}}a((()=>{document.addEventListener("mouseenter",(e=>{const t=e.target;if(t instanceof HTMLElement&&t.matches(".apply-overflow-tooltip")){const e=h(t);if(t.matches(".apply-overflow-tooltip--check-children-recursively")){if(!c(t,e))return}else if(t.matches(".apply-overflow-tooltip--check-children")){if(!u(t,e))return}else if(!l(t,e))return;(0,r.showOnElement)(t,{content:d(t)});const i=()=>{(0,r.hide)(),["mouseleave","mousedown"].forEach((e=>t.removeEventListener(e,i)))};["mouseleave","mousedown"].forEach((e=>t.addEventListener(e,i)))}}),!0),document.addEventListener("focus",_,!0),document.addEventListener("active-descendant-focus",_,!0)}));var p=i(48096),m=i(11417);var g=i(39527);function f(e){return()=>{e()}}var y=i(3343),v=i(34811),S=i(15754);const b=(e=document.documentElement,t)=>document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>t=>{if(1!==t.nodeType)return NodeFilter.FILTER_SKIP;const i=t;return(0,S.isInertRoot)(i)?NodeFilter.FILTER_REJECT:(0,S.isVisibilityVisible)(i)&&i.matches(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP})(t));const w=(e=document.documentElement)=>b(e,S.FOCUSABLE_SELECTOR);const C=`[${v.FOCUS_TRAP_DATA_ATTRIBUTE}="true"]`;class T{constructor(){this._handleMouseDown=()=>{this._forwardTab=void 0},this._handleKeyDown=e=>{this._forwardTab=void 0,[9,y.Modifiers.Shift+9].includes((0,y.hashFromEvent)(e))&&(this._forwardTab=!e.shiftKey)},this._handleFocus=e=>{const t=e.target;if(void 0===this._forwardTab||!(t instanceof HTMLElement))return;const i=this._findDeepestFocusTrapElement(document.documentElement);if(!(i instanceof HTMLElement)||!i||i.contains(t))return;e.preventDefault(),e.stopPropagation(),t.blur();const s=i.compareDocumentPosition(t);if(s&Node.DOCUMENT_POSITION_PRECEDING||s&Node.DOCUMENT_POSITION_FOLLOWING){const e=this._forwardTab?x(i):x(i,!0);e instanceof HTMLElement&&e.focus()}},document.documentElement.addEventListener("focus",this._handleFocus,{capture:!0}),document.documentElement.addEventListener("keydown",this._handleKeyDown,{capture:!0}),document.documentElement.addEventListener("mousedown",this._handleMouseDown,{capture:!0})}destroy(){document.documentElement.removeEventListener("focus",this._handleFocus,{capture:!0}),
document.documentElement.removeEventListener("keydown",this._handleKeyDown,{capture:!0}),document.documentElement.removeEventListener("mousedown",this._handleMouseDown,{capture:!0})}_findDeepestFocusTrapElement(e){const t=e.querySelectorAll(C);let i=null,s=-1;return t.forEach((t=>{const o=this._calculateParentCount(t,e);o>s&&(s=o,i=t)})),i}_calculateParentCount(e,t){let i=0,s=e.parentElement;for(;s&&s!==t;)"true"===s.getAttribute(v.FOCUS_TRAP_DATA_ATTRIBUTE)&&i++,s=s.parentElement;return i}}const P=f((()=>new T));function x(e,t){return t?function(e){return function(e){for(e.currentNode=e.root;null!==e.lastChild(););return e.currentNode===e.root?null:e.currentNode}(w(e))}(e):function(e){return t=w(e),t.currentNode=t.root,t.nextNode();var t}(e)}const M=f((()=>{P()}));var I=i(99247);let A;function L(e){window.TVSettings&&window.TVSettings.sync(window.user.settings),window.is_authenticated?(e||(initOfferLoginStateChangeButton(),onGoPro()&&window.location.reload()),!1===window.user.profile_data_filled&&((0,o.trackEvent)("Conversion","First login"),delete window.user.profile_data_filled)):availableOffersWrapper.runOrUpdate((e=>{Object.keys(e).forEach((t=>{const i=t;e[i].available_for_anons||delete e[i]})),window.user={username:"Guest",following:"0",followers:"0",ignore_list:[],available_offers:e},m.TVLocalStorage.removeItem("trial_availiable")}))}A=window.loginStateChange?window.loginStateChange:window.loginStateChange=new p.Delegate,A.subscribe(null,L),s.TVXWindowEvents.on("loginStateChange",(e=>{const t=JSON.parse(e);window.user=t.user,window.is_authenticated=!!t.is_authenticated,A.fire()})),s.TVXWindowEvents.on("signOut",(()=>{!function(){if(window.initData.lfs){const e=document.getElementsByClassName("js-admin-warning")[0];document.body.removeChild(e)}let e=!0;[/^\/chart\//,/^\/share-your-love\//,/^\/pine\//].forEach((t=>{t.test(window.location.pathname)&&(e=!1)})),e&&window.location.reload()}()})),(()=>{const e="user-obj-changed",t={};window.crossTabSyncUserAttr=t=>{const i={};t instanceof Array?t.forEach((e=>{i[e]=window.user[e]})):i[t]=window.user[t],s.TVXWindowEvents.emit(e,JSON.stringify(i))},s.TVXWindowEvents.on(e,(e=>{const i=JSON.parse(e);let s;for(s in i)if(i.hasOwnProperty(s)){window.user[s]=i[s];(t[s]||[]).forEach((e=>{e.fire(i[s])}))}}))})(),window.TradingView.changeLoginState=e=>{window.is_authenticated=!!e,s.TVXWindowEvents.emit("loginStateChange",JSON.stringify({is_authenticated:window.is_authenticated,user:window.user})),window.is_authenticated&&n.emit("GLOBAL_EVENT_SIGN_IN_SUCCESS"),A.fire()},window.loginUser=function(e){window.user=(0,g.deepExtend)({},e),window.TradingView.changeLoginState(!0)},window.loginRequiredDelegate=new p.Delegate,window.runOrSignIn=(e,t)=>{t||(t={}),e()},window.onLoginStateChange=L,window.TradingView.setTrialAvailiable=e=>{m.TVLocalStorage.setItem("trial_availiable",e?"1":"0")},window.TradingView.notificationsChanged=new p.Delegate,M(),(0,I.initMouseClickAutoBlurHandler)()},43229:(e,t,i)=>{"use strict";i.d(t,{AsyncResourceWrapper:()=>s});class s{constructor(e,t){
this._destroyed=!1,this._callbacks=[],this._resource={pendingResource:e},this._destroyFn=t,e.then((e=>{if(this._destroyed)this._destroyFn?.(e);else{this._resource.resource=e;for(const t of this._callbacks)t(e)}})).finally((()=>{this._callbacks=[]}))}destroy(){this._resource.resource&&this._destroyFn?.(this._resource.resource),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}}},52859:(e,t,i)=>{"use strict";i.r(t),i.d(t,{alphaToTransparency:()=>r,applyAlpha:()=>n,applyTransparency:()=>l,colorFromBackground:()=>u,colorToInteger:()=>g,generateColor:()=>o,getLuminance:()=>h,gradientColorAtPercent:()=>_,isHexColor:()=>d,resetTransparency:()=>c,rgbaFromInteger:()=>p,rgbaToInteger:()=>m,transparencyToAlpha:()=>a});var s=i(24377);function o(e,t,i){if(t=t||0,!d(e))return i?(0,s.rgbaToString)((0,s.rgba)((0,s.parseRgb)(e),(0,s.normalizeAlphaComponent)(a(t)))):e;const[o,n,r]=(0,s.parseRgb)(e),l=(0,s.normalizeAlphaComponent)(a(t));return(0,s.rgbaToString)([o,n,r,l])}function n(e,t,i){const o=(0,s.tryParseRgba)(e);if(null===o)throw new Error(`Invalid color: ${e}`);const[n,r,a,l]=o,c=(0,s.normalizeAlphaComponent)(t*(i?l:1));return(0,s.rgbaToString)((0,s.rgba)([n,r,a],c))}function r(e){return 100*(1-e)}function a(e){if(e<0||e>100)throw new Error("invalid transparency");return 1-e/100}function l(e,t){if("transparent"===e)return e;const i=(0,s.parseRgba)(e),o=i[3];return(0,s.rgbaToString)((0,s.rgba)(i[0],i[1],i[2],a(t)*o))}function c(e){return"transparent"===e?e:d(e)?e.slice(0,7):(0,s.rgbaToString)((0,s.rgba)((0,s.parseRgb)(e),(0,s.normalizeAlphaComponent)(1)))}function h(e){const t=(0,s.parseRgb)(e).map((e=>(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)));return Number((.2126*t[0]+.7152*t[1]+.0722*t[2]).toFixed(3))}function d(e){return 0===e.indexOf("#")}function u(e){return"black"===(0,s.rgbToBlackWhiteString)((0,s.parseRgb)(e),150)?"#ffffff":"#000000"}function _(e,t,i){const[o,n,r,a]=(0,s.parseRgba)(e),[l,c,h,d]=(0,s.parseRgba)(t),u=(0,s.rgba)(Math.round(o+i*(l-o)),Math.round(n+i*(c-n)),Math.round(r+i*(h-r)),a+i*(d-a));return(0,s.rgbaToString)(u)}function p(e){const t=(e=Math.round(e))%256;e-=t;const i=(e/=256)%256;e-=i;const s=(e/=256)%256;e-=s;return`rgba(${t},${i},${s},${(e/=256)/255})`}function m(e){const t=Math.round(255*e[3]);return e[0]+256*e[1]+65536*e[2]+16777216*t}function g(e){const t=(0,s.tryParseRgba)(e);return null===t?0:m(t)}},29970:(e,t,i)=>{"use strict";i.d(t,{colorsAreCloseEnough:()=>h,isColorDark:()=>_});var s,o=i(81251),n=i(24377);function r(e){return e<0&&(e+=2*Math.PI),e}function a(e,t){
const[i,s,o]=e,[n,a,l]=t,c=(Math.sqrt(s**2+o**2)+Math.sqrt(a**2+l**2))/2,h=.5*(1-Math.sqrt(Math.pow(c,7)/(Math.pow(c,7)+6103515625))),d=(1+h)*s,u=(1+h)*a,_=Math.sqrt(d*d+o*o),p=Math.sqrt(u*u+l*l),m=0===o&&0===d?0:r(Math.atan2(o,d)),g=0===l&&0===u?0:r(Math.atan2(l,u)),f=n-i,y=p-_;let v;const S=_*p;0===S?v=0:(v=g-m,v<-Math.PI?v+=2*Math.PI:v>Math.PI&&(v-=2*Math.PI));const b=2*Math.sqrt(S)*Math.sin(v/2),w=(i+n)/2,C=(_+p)/2;let T;const P=m+g;T=_*p==0?P:Math.abs(m-g)<=Math.PI?P/2:P<2*Math.PI?(P+2*Math.PI)/2:(P-2*Math.PI)/2;const x=1-.17*Math.cos(T-Math.PI/6)+.24*Math.cos(2*T)+.32*Math.cos(3*T+Math.PI/30)-.2*Math.cos(4*T-Math.PI/180*63),M=Math.PI/6*Math.exp(-Math.pow((T-Math.PI/180*275)/(Math.PI/180*25),2)),I=2*Math.sqrt(Math.pow(C,7)/(Math.pow(C,7)+6103515625)),A=1+.015*Math.pow(w-50,2)/Math.sqrt(20+Math.pow(w-50,2)),L=1+.045*C,k=1+.015*C*x,E=-Math.sin(2*M)*I;return Math.sqrt(Math.pow(f/(1*A),2)+Math.pow(y/(1*L),2)+Math.pow(b/(1*k),2)+E*(y/(1*L))*(b/(1*k)))}!function(e){e[e.Pow25In7=6103515625]="Pow25In7",e[e.LWeight=1]="LWeight",e[e.CWeight=1]="CWeight",e[e.HWeight=1]="HWeight"}(s||(s={}));const l=[127,127,127];function c(e){const t=e[3],i=e.slice(0,3);for(let e=0;e<3;e++)i[e]=Math.round(i[e]*t+l[e]*(1-t));return i}function h(e,t){return a(g(p(c((0,n.parseRgba)(e)))),g(p(c((0,n.parseRgba)(t)))))<3}const d=(0,o.default)((()=>g(p([0,0,0])))),u=(0,o.default)((()=>g(p([255,255,255]))));function _(e){const t=g(p(c((0,n.parseRgba)(e))));return a(t,d())<a(t,u())}function p(e){const[t,i,s]=e,o=t/255,n=i/255,r=s/255,a=100*(o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92),l=100*(n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92),c=100*(r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92);return[.4124*a+.3576*l+.1805*c,.2126*a+.7152*l+.0722*c,.0193*a+.1192*l+.9505*c]}var m;function g(e){const[t,i,s]=e,o=t/95.047,n=i/100,r=s/108.883,a=o>.008856?Math.pow(o,1/3):7.787*o+16/116,l=n>.008856?Math.pow(n,1/3):7.787*n+16/116;return[116*l-16,500*(a-l),200*(l-(r>.008856?Math.pow(r,1/3):7.787*r+16/116))]}!function(e){e[e.X=95.047]="X",e[e.Y=100]="Y",e[e.Z=108.883]="Z"}(m||(m={}))},22961:(e,t,i)=>{"use strict";function s(e,t,i){return e*(1-i)+t*i}i.d(t,{doAnimate:()=>r,lerp:()=>s});const o={from:0,duration:250,easing:i(76662).easingFunc.easeOutCubic};class n{constructor(e){this._doing=!0,this._completed=!1,this._options={...o,...e};const t=performance.now();window.requestAnimationFrame((e=>{this._animation(t,this._options.from,e)}))}stop(){this._doing=!1}completed(){return this._completed}_animation(e,t,i){if(!this._doing)return void this._finishAnimation();const o=(i=!i||i<1e12?performance.now():i)-e,n=o>=this._options.duration||t===this._options.to,r=s(this._options.from,this._options.to,this._options.easing(o/this._options.duration)),a=n?this._options.to:r,l=a-t;this._options.onStep(l,a),n?this._finishAnimation():window.requestAnimationFrame((t=>{this._animation(e,a,t)}))}_finishAnimation(){this._options.onComplete&&this._options.onComplete(),this._completed=!0}}function r(e){return new n(e)}},32925:(e,t,i)=>{"use strict";i.d(t,{fetch:()=>o})
;var s=i(9343);new class{constructor(e,t){this._test=e[t]={}}provide(e,t){this._test[e]=t}}(window,"qaGlobals"),(0,s.getLogger)("Fetch");function o(e,t,i={}){return window.fetch(e,t)}},67225:(e,t,i)=>{"use strict";i.d(t,{GradientColorCache:()=>o});var s=i(52859);class o{constructor(){this._color1="",this._color2="",this._colors=new Map}gradientColor(e,t,i){if(t===e)return t;i=Math.max(0,Math.min(100,Math.round(100*i))),this._color1===e&&this._color2===t||(this._colors.clear(),this._color1=e,this._color2=t);let o=this._colors.get(i);return void 0===o&&(o=(0,s.gradientColorAtPercent)(e,t,i/100),this._colors.set(i,o)),o}}},49251:(e,t,i)=>{"use strict";function s(e,t,i,s){return`${s?s+" ":""}${i?i+" ":""}${e}px ${t}`}i.d(t,{makeFont:()=>s,parseFont:()=>n});const o=/(bold )?(italic )?(\d+)(px|pt) (.*)$/;function n(e){const t=o.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])}}},18113:(e,t,i)=>{"use strict";i.d(t,{getPersistentLogger:()=>o});let s=null;function o(){return s}},24640:(e,t,i)=>{"use strict";i.r(t),i.d(t,{detectAutoDirection:()=>b,forceLTRStr:()=>u,forceLTRStrSsr:()=>_,forceRTLStr:()=>m,getLTRScrollLeft:()=>g,getLTRScrollLeftOffset:()=>f,isRtl:()=>o,startWithLTR:()=>d,stripLTRMarks:()=>h,stripLTRStrSsr:()=>p});var s=i(64531);const o=()=>"rtl"===window.document.dir,n="‎",r="‪",a="‫",l="‬",c=new RegExp(n+"|"+r+"|"+a+"|"+l,"g");function h(e){return""!==e&&o()&&null!=e?e.replace(c,""):e}function d(e){return""!==e&&o()&&null!=e?n+e:e}function u(e){return""!==e&&o()&&null!=e?r+e+l:e}function _(e){return r+e+l}function p(e){return e.startsWith(r)&&e.endsWith(l)?e.slice(1,-1):e}function m(e){return""!==e&&o()&&null!=e?a+e+l:e}function g(e){return(0,s.getNormalizedScrollLeft)(e,"rtl")}function f(e,t){const i=(0,s.detectScrollType)();if("indeterminate"===i)return 0;switch(i){case"negative":t=e.clientWidth-e.scrollWidth+t;break;case"reverse":t=e.scrollWidth-e.clientWidth-t}return t}var y;!function(e){e.LTR="ltr",e.RTL="rtl",e.UNKNOWN=""}(y||(y={}));const v=/[^\u0000-\u0040\u005B-\u0060\u007B-\u00BF\u00D7\u00F7\u02B9-\u02FF\u2000-\u200E\u2010-\u2029\u202C\u202F-\u2BFF]/,S=/[\u0590-\u07FF\u200F\u202B\u202E\uFB1D-\uFDFD\uFE70-\uFEFC]/;function b(e){const t=v.exec(e);return t?S.test(t[0])?"rtl":"ltr":""}},76662:(e,t,i)=>{"use strict";i.d(t,{CubicBezier:()=>s.CubicBezier,dur:()=>s.dur,easingFunc:()=>s.easingFunc});var s=i(74991)},59672:(e,t,i)=>{"use strict";function s(){return Promise.all([i.e(6342),i.e(8185),i.e(2202),i.e(8894),i.e(5743),i.e(6954),i.e(2227),i.e(2077)]).then(i.bind(i,3014))}i.d(t,{loadChangeIntervalDialog:()=>s})},59613:(e,t,i)=>{"use strict";i.d(t,{showChangeIntervalDialogAsync:()=>n});var s=i(59672);let o=null;function n(e){const t=o=(0,s.loadChangeIntervalDialog)().then((i=>{t===o&&i.showChangeIntervalDialog(e)}));return t}},92572:(e,t,i)=>{"use strict";function s(e){
return Promise.all([i.e(7629),i.e(8185),i.e(1681),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3439),i.e(1171),i.e(8933),i.e(2537),i.e(8894),i.e(5743),i.e(9487),i.e(3329),i.e(4678),i.e(4059),i.e(861),i.e(2227),i.e(9418),i.e(3179),i.e(4426),i.e(9928),i.e(8604),i.e(1859)]).then(i.bind(i,62256)).then((t=>t.showGoToDateDialog(e)))}i.d(t,{showGoToDateDialog:()=>s})},70347:(e,t,i)=>{"use strict";i.d(t,{runOrSigninWithFeature:()=>s});const s=(e,t)=>{e()};window.TradingView.runOrSigninWithFeature=s},16708:(e,t,i)=>{"use strict";i.d(t,{DeleteLockedLineToolReason:()=>s,confirmRemovingLockedLineTools:()=>d,showDeleteLockedLineToolsConfirm:()=>h});var s,o=i(11542),n=i(3615),r=i(5734),a=i(89947);!function(e){e[e.RemoveSelected=0]="RemoveSelected",e[e.RemoveAll=1]="RemoveAll"}(s||(s={}));const l=o.t(null,void 0,i(41019)),c=o.t(null,void 0,i(41019));async function h(e,t){if(r.doNotShowDeleteLockedLineConfirmProperty.value())return void t(a.deleteLockedLineToolsProperty.value());const{getContent:h}=await Promise.all([i.e(7328),i.e(3425),i.e(6052),i.e(1065),i.e(4598)]).then(i.bind(i,30627));(0,n.showConfirm)({title:o.t(null,void 0,i(71692)),content:h(e===s.RemoveSelected?l:c),id:`${r.doNotShowDeleteLockedLineKey}-confirm`,mainButtonText:o.t(null,void 0,i(93123)),mainButtonIntent:"danger",cancelButtonText:o.t(null,void 0,i(99024)),onConfirm:({dialogClose:e})=>{r.doNotShowDeleteLockedLineConfirmProperty.value()&&a.deleteLockedLineToolsProperty.setValue(!0),t(!0),e()},onCancel:({dialogClose:e})=>{r.doNotShowDeleteLockedLineConfirmProperty.value()&&a.deleteLockedLineToolsProperty.setValue(!1),t(!1),e()}})}function d(e){return new Promise((t=>{h(e,t)}))}},31237:(e,t,i)=>{"use strict";i.d(t,{showDeleteStudyTreeConfirm:()=>r});var s=i(11542),o=i(3615);const n=5;function r(e,t){let r,a="";if(e.length>n){const t=e.length-n+1;r=e.slice(0,n-1),a=s.t(null,{plural:"and {nameCount} more indicators.",count:t},i(31550)).format({nameCount:t.toString()})}else r=e;const l='<ul style="padding-left:20px">'+r.map((e=>`<li>${e}</li>`)).join("")+"</ul>"+a,c=s.t(null,void 0,i(4995))+l;(0,o.showConfirm)({title:s.t(null,void 0,i(97767)),html:c,mainButtonText:s.t(null,void 0,i(67410)),mainButtonIntent:"danger",cancelButtonText:s.t(null,void 0,i(4543)),onConfirm:({dialogClose:e})=>{t(),e()}})}},10341:(e,t,i)=>{"use strict";i.d(t,{showTooManyStudiesNotice:()=>n});var s=i(11542),o=i(3615);function n(e){(0,o.showWarning)({title:s.t(null,void 0,i(66719)),text:s.t(null,{replace:{number:`${e}`}},i(86146))})}},55279:(e,t,i)=>{"use strict";i.d(t,{getAdditionalSymbolInfoFields:()=>n,setAdditionalSymbolInfoFields:()=>o});let s=[];function o(e){s=e}function n(){return s}},84526:(e,t,i)=>{"use strict";function s(e){Promise.all([i.e(8622),i.e(8185),i.e(5371),i.e(2202),i.e(5563),i.e(2647),i.e(3359),i.e(445),i.e(2112),i.e(9036),i.e(2227),i.e(9418),i.e(2477),i.e(9374)]).then(i.bind(i,46069)).then((({SymbolInfoDialogImpl:t})=>{t.getInstance().show(e)}))}i.d(t,{showSymbolInfoDialog:()=>s})},12362:(e,t,i)=>{"use strict";i.d(t,{ChartSaverBase:()=>d})
;var s=i(50279),o=i(50151),n=(i(11542),i(14411)),r=i(23024),a=i(48096),l=i(37103),c=i(81593);function h(e,t){e.content=JSON.stringify(t)}new WeakMap;new TextEncoder;class d{constructor(e){this._prevChartState=null,this._chartSavedDelegate=new a.Delegate,this._chartAboutToBeSavedDelegate=new a.Delegate,this._chartSizeLimitExceededDelegate=new a.Delegate,this._isSaveInProcess=!1,this._savingToken=null,this._chartWidgetCollection=e}async saveChartLineTools(e,t,s,o){if(l.enabled("saveload_separate_drawings_storage")){const n=await(0,r.getChartStorage)(),a=this.layoutId(),l=i=>n.saveLineToolsAndGroups(i,e,t,s,o);if(!a){this._chartSavedDelegate.subscribe(null,(e=>{if(e){const e=this._chartWidgetCollection.metaInfo.uid.value();l(e)}}),!0);const{SavingLineToolsLibraryError:e}=await i.e(5565).then(i.bind(i,98653));throw new e("Layout ID not yet created.",!0)}return l(a)}return Promise.reject("Line tools storage is not supported")}layoutId(){return this._chartWidgetCollection.metaInfo.uid.value()}saveChartSilently(e,t,i){const s=i||{};this._isSaveInProcess=!0,this._chartAboutToBeSavedDelegate.fire(),this._saveChart((e=>{const t=e&&l.enabled("saveload_separate_drawings_storage"),i=this._getChartWidgetCollectionState(!1,void 0,void 0,void 0,t),o=this._getCommonSavingInfo(!1);return h(o,i),s.chartName&&(o.name=s.chartName),o.name&&0!==o.name.length||!s.defaultChartName||(o.name=s.defaultChartName),s.autoSave&&(o.autoSave=!0),o}),((t,i)=>{(0,o.assert)(!this._chartWidgetCollection.readOnly(),"Trying to save layout in read-only mode"),i&&this.layoutId()===t.uid&&this._chartWidgetCollection.metaInfo.name.setValue(i.name??""),this._prevChartState=i,this._chartSavedDelegate.fire(!0),this._isSaveInProcess=!1,e&&e({uid:t.uid,data:i}),this._prevChartState&&delete this._prevChartState.savingToken}),(e=>{this._chartSavedDelegate.fire(!1),this._isSaveInProcess=!1,t&&t(e)}),s)}saveToJSON(e){const t=e&&!1===e.includeDrawings||void 0,i=this._getCommonSavingInfo(!1);return h(i,this._getChartWidgetCollectionState(!1,!0,t,void 0,t)),i}isSaveInProcess(){return this._isSaveInProcess}_getChartWidgetCollectionState(e,t,i,s,o){let n=!1;return e?n=!0:(t=!0,s=!1),this._chartWidgetCollection.state({withData:!!e,skipLineToolsFromOtherSymbols:!!i,wipeSensitiveData:!!s,skipLineTools:o,skipHiddenSources:n,addOnlyActiveChart:!t})}_getCommonSavingInfo(e){const t=this._chartWidgetCollection,i=this._chartWidgetCollection.chartsSymbols()[t.activeChartWidget.value().id()],s={...(o=i,{...o,legs:JSON.stringify(o.legs??[])})};var o;const n=t.metaInfo,r=n.id.value();return null!==r&&(s.id=r),s.name=n.name.value()||"",s.description=n.description.value()||"",s.is_realtime=s.is_realtime=e?"0":"1",s}async _saveLineToolsToStorage(){if(l.enabled("saveload_separate_drawings_storage")){this.layoutId();0;const[e,t]=this._chartWidgetCollection.getAll().reduce(((e,t)=>{const i=t.lineToolsSynchronizer();if(i){e[0]||=i.hasUnsavedMigrationsFromChartState();const t=i.flushPendingSavings();t&&e[1].push(t)}return e}),[!1,[]]);return t.length&&await Promise.all(t),t.length>0&&e}return!1
}_invalidateAllLineTools(){this._chartWidgetCollection.getAll().forEach((e=>e.lineToolsSynchronizer()?.invalidateAll()))}_saveChartImpl(e,t,i,s,o,n){let r;r=s=>{t.uid||t.uid!==this.layoutId()||(t.id=s.result,t.uid=`${s.result}`,this._chartWidgetCollection.metaInfo.id.setValue(t.id),this._chartWidgetCollection.metaInfo.uid.setValue(t.uid)),i(t,e)},e.name?c.backend.saveChart(e.name,e.short_name,e.resolution,e,t).then(r).catch((async e=>{const t=e instanceof Response?e:void 0,i=e instanceof Error?e:void 0;this._savingToken=null;const o=s.bind(null,{status:t?.status,message:t?.statusText??i?.message??"Unknown error"});o()})):s({status:-1,message:"Saving chart with empty name is not allowed"})}async _saveChart(e,t,o,r){const a=this._chartWidgetCollection.metaInfo,c={name:a.name.value(),description:a.description.value(),uid:a.uid.value(),id:a.id.value(),lastModified:a.lastModified.value(),username:a.username.value(),isPrivate:a.isPrivate.value()};let h=r.changes??n.changedAll;l.enabled("saveload_separate_drawings_storage")&&this._invalidateAllLineTools();let d=!0;if(2&h||l.enabled("saveload_separate_drawings_storage"))try{await this._saveLineToolsToStorage()&&(h|=1)}catch(e){h|=1;const{SavingLineToolsLibraryError:t}=await i.e(5565).then(i.bind(i,98653));e instanceof t&&e.safe||(d=!1)}if(1&h){const i=e(d);if((0,s.default)(this._prevChartState,i)&&null!==c.id)return this._chartSavedDelegate.fire(!0),void t(c,i);0;const n=(e,i)=>(d||this._chartWidgetCollection.getAll().forEach((e=>e.lineToolsSynchronizer()?.markAsValidatedBecauseOfSavingToContent())),t(e,i));return this._saveChartImpl(i,c,n,o,r,e)}this._chartSavedDelegate.fire(!0),t(c,e(d))}}},71846:(e,t,i)=>{"use strict";var s=i(12362).ChartSaverBase;i.i18next(null,void 0,i(49947));t.ChartSaver=class extends s{constructor(e){super(e)}chartSizeLimitExceeded(){return this._chartSizeLimitExceededDelegate}chartAboutToBeSaved(){return this._chartAboutToBeSavedDelegate}chartSaved(){return this._chartSavedDelegate}publishChart(e){}publishScript(e,t,i){}isScriptNameValid(e){return""!==e.trim()&&e.length<=64}isScriptDescriptionValid(e){return""!==e.trim()&&e.length<=7e4}isScriptDescribersValid(e,t){return this.isScriptNameValid(e)&&this.isScriptDescriptionValid(t)}openInNewTab(e,t,i){e.publishInProgress=!0,i||this.isScriptDescribersValid(t.name,t.description)&&undefined(new Promise((function(t){e.setPopupUrl=t})))}onPublish(e,t){}}},19e3:(e,t,i)=>{"use strict";i.d(t,{getTranslatedSymbolDescription:()=>s});i(11542);function s(e){return e.description||""}},29242:(e,t,i)=>{"use strict";function s(e){return e+"…"}i.d(t,{appendEllipsis:()=>s})},58043:(e,t,i)=>{"use strict";function s(e){let t;if("object"!=typeof e||null==e||"number"==typeof e.nodeType)t=e;else if(e instanceof Date)t=new Date(e.valueOf());else if(Array.isArray(e)){t=[];let i=0;const o=e.length;for(;i<o;i++)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=s(e[i]))}else{t={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=s(e[i]))}return t}i.d(t,{deepCopy:()=>s})},39527:(e,t,i)=>{"use strict"
;function s(e,...t){return e&&"object"==typeof e?(0===t.length||t.forEach((t=>{null!=t&&"object"==typeof t&&Object.keys(t).forEach((i=>{const n=e[i],r=t[i];if(r===e)return;const a=Array.isArray(r);if(r&&(o(r)||a)){let t;t=a?n&&Array.isArray(n)?n:[]:n&&o(n)?n:{},e[i]=s(t,r)}else void 0!==r&&(e[i]=r)}))})),e):e}function o(e){if(!e||"[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);if(!t)return!0;const i=Object.hasOwnProperty.toString,s=t.hasOwnProperty("constructor")&&t.constructor;return"function"==typeof s&&i.call(s)===i.call(Object)}i.d(t,{deepExtend:()=>s})},88723:(e,t,i)=>{"use strict";function s(){let e,t;return{promise:new Promise(((i,s)=>{e=i,t=s})),reject:t,resolve:e}}i.d(t,{createDeferredPromise:()=>s})},39058:(e,t,i)=>{"use strict";function s(e){if(void 0===e)return"";if(e instanceof Error){let t=e.message;return e.stack&&(t+=" "+e.stack),t}return"string"==typeof e?e.toString():JSON.stringify(e)}i.d(t,{errorToString:()=>s})},4168:(e,t,i)=>{"use strict";i.r(t),i.d(t,{guid:()=>s.guid,randomHash:()=>s.randomHash,randomHashN:()=>s.randomHashN});var s=i(4226)},50470:(e,t,i)=>{"use strict";i.d(t,{parseHtml:()=>n,parseHtmlElement:()=>r});const s=new WeakMap;var o;function n(e,t){let i,o;return i=null==t?document.documentElement:9===t.nodeType?t.documentElement:t,s&&(o=s.get(i)),o||(o=i.ownerDocument.createRange(),o.selectNodeContents(i),s&&s.set(i,o)),o.createContextualFragment(e)}function r(e,t){const i=n(e,t),s=i.firstElementChild;return null!==s&&i.removeChild(s),s}!function(e){e[e.Element=1]="Element",e[e.Document=9]="Document"}(o||(o={}))},26867:(e,t,i)=>{"use strict";function s(e){e.preventDefault()}i.d(t,{preventDefault:()=>s,preventDefaultForContextMenu:()=>n});const o=["input:not([type])",'input[type="text"]','input[type="email"]','input[type="password"]','input[type="search"]','input[type="number"]','input[type="url"]',"textarea","a[href]",'*[contenteditable="true"]',"[data-allow-context-menu]"];function n(e){const t=e.target;t&&!t.closest(o.join(", "))&&e.preventDefault()}},53470:(e,t,i)=>{"use strict";function s(e){return e.reduce((function(e,t,i){return~e.indexOf(t)||e.push(t),e}),[])}i.r(t),i.d(t,{uniq:()=>s})},34369:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28" fill="currentColor"><path fill-rule="evenodd" d="M18 14a4 4 0 1 1-8 0 4 4 0 0 1 8 0Zm-1 0a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/><path fill-rule="evenodd" d="M8.5 5h11l5 9-5 9h-11l-5-9 5-9Zm-3.86 9L9.1 6h9.82l4.45 8-4.45 8H9.1l-4.45-8Z"/></svg>'},93544:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><path fill="currentColor" d="M18 7h5v1h-2.01l-1.33 14.64a1.5 1.5 0 0 1-1.5 1.36H9.84a1.5 1.5 0 0 1-1.49-1.36L7.01 8H5V7h5V6c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v1Zm-6-2a1 1 0 0 0-1 1v1h6V6a1 1 0 0 0-1-1h-4ZM8.02 8l1.32 14.54a.5.5 0 0 0 .5.46h8.33a.5.5 0 0 0 .5-.46L19.99 8H8.02Z"/></svg>'},53573:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28" fill="none"><path fill="currentColor" fill-rule="evenodd" d="m17.13 9.74 7.37.9-5.44 5.06L20.4 23 14 19.38 7.6 23l1.34-7.3-5.44-5.06 7.37-.9L14 3l3.13 6.74Zm5.11 1.63-4.26 3.97 1.04 5.74L14 18.24l-5.02 2.84 1.04-5.74-4.26-3.97 5.79-.7L14 5.37l2.45 5.3 5.8.7Z"/></svg>'},34487:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28" fill="none"><path fill="currentColor" d="M14 3c6.075 0 11 4.925 11 11s-4.925 11-11 11S3 20.076 3 14 7.925 3 14 3m0 1C8.477 4 4 8.477 4 14s4.477 10 10 10 10-4.477 10-10S19.524 4 14 4m1 16h-1v-7h-2v-1h3zM14 8a1 1 0 1 1 0 2 1 1 0 0 1 0-2"/></svg>'},11890:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28" fill="none"><path fill="currentColor" d="M25 17.225 14 24 3 17.357l.508-.867L14 22.873l10.498-6.51zM14 5c.171 0 .344.04.498.128l9.985 5.753a1 1 0 0 1-.016 1.741l-9.983 5.522a1 1 0 0 1-.968-.001l-9.984-5.545a1 1 0 0 1-.012-1.742l9.98-5.728A1 1 0 0 1 13.999 5m-9.982 6.724L14 17.269l9.982-5.522L14 5.994z"/></svg>'},5845:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><path fill="currentColor" d="M6 5h1v18H6V5ZM16 14V9h1v5h5v1h-5v5h-1v-5h-5v-1h5Z"/></svg>'},94839:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><path fill="currentColor" d="M23 6v1H5V6h18ZM14 16v-5h1v5h5v1h-5v5h-1v-5H9v-1h5Z"/></svg>'},29453:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><path fill="currentColor" d="M17.5 7A3 3 0 0 1 15 9.96V14h5v1h-5v7.98a6.97 6.97 0 0 0 3.57-1.32A4.5 4.5 0 0 0 20.5 18h1a5.5 5.5 0 0 1-2.32 4.46A7.98 7.98 0 0 1 14.5 24c-1.6 0-3.33-.53-4.68-1.54A5.5 5.5 0 0 1 7.5 18h1c0 1.56.78 2.8 1.93 3.66A6.97 6.97 0 0 0 14 22.98V15H9v-1h5V9.96A3 3 0 1 1 17.5 7Zm-3 2a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"/></svg>'},50946:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 19" width="22" height="19"><path fill="#ffffff" d="M9 4H0v4h5v7h4V4Zm8 11h-5l4.5-11h5L17 15Zm-5-7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z"/></svg>'},70893:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="28 0 136 19" width="136" height="19"><path fill="#ffffff" d="M28.52 9.03c0 2.84 2.3 5.14 5.14 5.14a5.12 5.12 0 0 0 4.59-2.65l-1.77-.98a3.14 3.14 0 0 1-5.92-1.51 3.14 3.14 0 0 1 5.92-1.51l1.77-.98a5.12 5.12 0 0 0-4.6-2.65 5.13 5.13 0 0 0-5.13 5.14ZM39.05 14h1.91v-3.42c0-1.34.68-1.98 1.56-1.98.8 0 1.23.61 1.23 1.62V14h1.92V9.9c0-1.82-1.01-3.05-2.7-3.05-.91 0-1.64.39-2 .95V3.5h-1.92V14Zm7.51-3.5c0 1.99 1.43 3.65 3.29 3.65.96 0 1.7-.49 2.01-.93V14h1.92V7h-1.92v.78a2.5 2.5 0 0 0-2.01-.93c-1.86 0-3.3 1.66-3.3 3.65Zm5.46 0c0 1.1-.72 1.9-1.77 1.9s-1.76-.8-1.76-1.9c0-1.1.71-1.9 1.76-1.9s1.77.8 1.77 1.9Zm3.21 3.5h1.91v-3.35c0-1.14.6-1.86 1.52-1.86.3 0 .57.06.86.16V7a2.2 2.2 0 0 0-.64-.08c-.78 0-1.5.51-1.74 1.2V7h-1.91v7Zm9.71-.07v-1.7a2.2 2.2 0 0 1-.79.13c-.82 0-1.19-.33-1.19-1.19V8.68h1.98V7h-1.98V5.05h-1.92V7h-1.41v1.68h1.41v2.87c0 1.7 1.2 2.53 2.68 2.53a4 4 0 0 0 1.22-.15Zm5.63-.71c.32.44 1.06.93 2.03.93 1.86 0 3.29-1.66 3.29-3.65s-1.43-3.65-3.3-3.65c-.96 0-1.7.49-2.02.93V3.5h-1.92V14h1.92v-.78Zm3.37-2.72c0 1.1-.71 1.9-1.76 1.9s-1.77-.8-1.77-1.9c0-1.1.72-1.9 1.77-1.9s1.76.8 1.76 1.9Zm5.39 6.43L83.73 7H81.6l-1.86 4.54L77.87 7h-2.1l2.94 6.6-1.47 3.33h2.09ZM88.27 14h2.05V6h2.67V4.05h-7.36v1.93h2.64V14Zm4.44 0h1.92v-3.35c0-1.14.6-1.86 1.51-1.86.31 0 .58.06.87.16V7a2.2 2.2 0 0 0-.64-.08c-.79 0-1.5.51-1.74 1.2V7h-1.92v7Zm4.41-3.5c0 1.99 1.43 3.65 3.3 3.65.96 0 1.7-.49 2.01-.93V14h1.92V7h-1.92v.78a2.5 2.5 0 0 0-2.02-.93c-1.86 0-3.29 1.66-3.29 3.65Zm5.46 0c0 1.1-.71 1.9-1.76 1.9s-1.76-.8-1.76-1.9c0-1.1.71-1.9 1.76-1.9s1.76.8 1.76 1.9Zm2.76 0c0 1.99 1.43 3.65 3.3 3.65.96 0 1.7-.49 2.01-.93V14h1.92V3.5h-1.92v4.28a2.5 2.5 0 0 0-2.02-.93c-1.86 0-3.29 1.66-3.29 3.65Zm5.46 0c0 1.1-.71 1.9-1.76 1.9s-1.76-.8-1.76-1.9c0-1.1.71-1.9 1.76-1.9s1.76.8 1.76 1.9Zm5.4-5.87c0-.67-.55-1.21-1.23-1.21-.66 0-1.22.54-1.22 1.21a1.23 1.23 0 0 0 2.45 0ZM114 14h1.92V7H114v7Zm3.35 0h1.92v-3.42c0-1.34.67-1.98 1.56-1.98.8 0 1.23.61 1.23 1.62V14h1.91V9.9c0-1.82-1-3.05-2.7-3.05-.9 0-1.63.39-2 .95V7h-1.92v7Zm14.77-.55V7h-1.92v.78a2.48 2.48 0 0 0-2.03-.93c-1.82 0-3.3 1.56-3.3 3.54 0 1.96 1.48 3.53 3.3 3.53.9 0 1.67-.41 2.03-.93v.48c0 1.12-.74 1.92-1.88 1.92-.77 0-1.56-.28-2.18-.87l-1.05 1.43c.8.75 2.06 1.12 3.26 1.12 2.14 0 3.77-1.08 3.77-3.62Zm-5.32-3.06c0-1.08.81-1.8 1.78-1.8.96 0 1.77.72 1.77 1.8 0 1.06-.8 1.79-1.77 1.79s-1.78-.73-1.78-1.8Zm9.1 3.61h1.8l4.12-9.94h-2.25l-2.77 6.9-2.81-6.9h-2.2l4.1 9.94Zm8.63-9.37c0-.67-.55-1.21-1.24-1.21-.65 0-1.21.54-1.21 1.21a1.23 1.23 0 0 0 2.45 0ZM142.34 14h1.92V7h-1.92v7Zm2.89-3.5c0 2.21 1.63 3.65 3.71 3.65 1.47 0 2.6-.63 3.25-1.56l-1.43-1.07c-.3.48-.93.88-1.8.88-.93 0-1.75-.51-1.86-1.45h5.23c.03-.3.03-.5.03-.66 0-2.27-1.61-3.44-3.44-3.44a3.58 3.58 0 0 0-3.69 3.65Zm3.63-2.07c.71 0 1.41.39 1.58 1.22h-3.27c.18-.86.98-1.22 1.69-1.22ZM159.27 14h1.9l2.31-7h-2.06l-1.31 4.48L158.68 7h-1.47l-1.42 4.48L154.46 7h-2.04l2.32 7h1.9l1.31-3.99 1.32 3.99Z"/></svg>'},1457:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path d="M13.111 18.5H10.5a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1h11a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1h-8.389z"/><path d="M18.5 20v1.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1H8"/></g></svg>'},55824:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 7 5" width="7" height="5" fill="none"><path stroke="currentColor" stroke-width="1.2" d="M1 1.5l2.5 2 2.5-2"/></svg>'},99875:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 18 18" width="18" height="18"><path fill="backgroundColor" d="M5 7V6a4 4 0 1 1 8 0v1a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9c0-1.1.9-2 2-2Z"/><path fill="lineColor" fill-rule="evenodd" d="M9 3a3 3 0 0 0-3 3v1h6V6a3 3 0 0 0-3-3ZM5 6v1a2 2 0 0 0-2 2v5c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2V6a4 4 0 0 0-8 0Zm0 2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1H5Zm4 2a1 1 0 0 0-1 1v1a1 1 0 1 0 2 0v-1a1 1 0 0 0-1-1Z"/></svg>'},2872:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><g fill="none" fill-rule="evenodd" stroke="currentColor" transform="translate(6 3)"><rect width="15" height="12" rx="2" x=".5" y="8.5"/><path stroke-linecap="round" stroke-width="2" d="M8 15v2"/><path d="M11.5 4a3.5 3.5 0 0 0-7 0v4.5"/></g></svg>'},7983:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 13" width="15" height="13"><path fill="currentColor" fill-rule="evenodd" d="M4.1 1 1.14 6.5 4.1 12h6.8l2.96-5.5L10.9 1H4.1ZM15 6.5 11.5 0h-8L0 6.5 3.5 13h8L15 6.5ZM7.5 8a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/></svg>'},39267:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path d="M6.5 15A8.5 8.5 0 1 0 15 6.5H8.5"/><path d="M12 10L8.5 6.5 12 3"/></g></svg>'},16911:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><g fill="none" fill-rule="evenodd" stroke="currentColor" transform="translate(3 6)"><path d="M.964 8C3 4 6.679.5 11 .5 15.32.5 19 4 21.036 8 19 12 15.32 15.5 11 15.5 6.679 15.5 3 12 .964 8z"/><circle cx="11" cy="8" r="3.5"/></g></svg>'},6862:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path stroke-linecap="square" d="M11.5 21.5v-7m3 7v-5m3 5v-3m-9 3v-5"/><path d="M5.5 22v-3"/><path stroke-linecap="square" d="M5.5 13.5l4.297-4.297a2.406 2.406 0 0 1 3.406 0l2.594 2.594c.94.94 2.463.943 3.406 0L23.5 7.5M22.5 12.5v6m-3-3h6"/></g></svg>'},54190:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><path fill="none" fill-rule="evenodd" stroke="currentColor" stroke-linecap="square" d="M6.145 11.968L14 5.5l7.855 6.468a.3.3 0 0 1-.191.532H6.336a.3.3 0 0 1-.19-.532zm0 4.064L14 22.5l7.855-6.468a.3.3 0 0 0-.191-.532H6.336a.3.3 0 0 0-.19.532z"/></svg>'},25191:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><g fill="none" fill-rule="evenodd" transform="translate(4 5)"><path fill="currentColor" d="M3 1h1v13.5H3z"/><circle stroke="currentColor" cx="3.5" cy="16.5" r="2"/><path fill="currentColor" d="M5.5 16H18v1H5.5z"/><path stroke="currentColor" d="M0 4L3.5.5 7 4m8 9l3.5 3.5L15 20"/></g></svg>'},93379:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><g fill="currentColor" fill-rule="nonzero"><path d="M4 15h8.5v-1h-8.5zM16.5 15h8.5v-1h-8.5z"/><path d="M14.5 16c.828 0 1.5-.672 1.5-1.5s-.672-1.5-1.5-1.5-1.5.672-1.5 1.5.672 1.5 1.5 1.5zm0 1c-1.381 0-2.5-1.119-2.5-2.5s1.119-2.5 2.5-2.5 2.5 1.119 2.5 2.5-1.119 2.5-2.5 2.5z"/></g></svg>'},84959:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><path fill="currentColor" d="M18.15 7.02A9.05 9.05 0 0014 6c-3.45 0-6.08 2-7.8 3.92a18.18 18.18 0 00-2.64 3.84v.02h-.01L4 14l-.45-.21-.1.21.1.21L4 14l-.45.21.01.03a5.85 5.85 0 00.16.32c.11.2.28.51.5.87a18.18 18.18 0 002.4 3.12l.71-.71A17.18 17.18 0 014.56 14a10.05 10.05 0 01.52-.91c.41-.69 1.04-1.6 1.85-2.5C8.58 8.75 10.95 7 14 7a8 8 0 013.4.77l.75-.75zm-3.11 3.12a4 4 0 00-4.9 4.9l.86-.87V14a3 3 0 013.17-3l.87-.86zm1.96 3.7l.86-.88a4 4 0 01-4.9 4.9l.87-.86A3 3 0 0017 13.83zm-6.4 6.4A8 8 0 0014 21c3.05 0 5.42-1.76 7.07-3.58A17.18 17.18 0 0023.44 14a9.47 9.47 0 00-.52-.91 17.18 17.18 0 00-2.25-2.93l.7-.7a18.18 18.18 0 013.06 4.3l.02.02L24 14l.45.21-.01.03a7.03 7.03 0 01-.16.32c-.11.2-.28.51-.5.87-.44.72-1.1 1.69-1.97 2.65C20.08 20.01 17.45 22 14 22c-1.55 0-2.94-.4-4.15-1.02l.75-.75zM24 14l.45-.21.1.21-.1.21L24 14zM22.2 6.5L6.5 22.2l-.7-.7L21.5 5.8l.7.7z"/></svg>'},97874:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28"><g fill="none" fill-rule="evenodd" stroke="currentColor" transform="translate(6 4)"><rect width="15" height="12" rx="2" x=".5" y="7.5"/><path stroke-linecap="round" stroke-width="2" d="M8 14v2"/><path d="M11.5 7.5V4a3.5 3.5 0 0 0-7 0v3.5"/></g></svg>'},1866:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 162 28" width="162" height="28"><path fill="currentColor" d="M130.37 7.21c0 .99-.83 1.78-1.87 1.78-1 0-1.84-.8-1.84-1.78s.85-1.77 1.84-1.77c1.04 0 1.87.8 1.87 1.77M130 21h-3V10h3zM84.54 9.02c1.04 0 1.87-.8 1.87-1.77 0-.99-.83-1.78-1.87-1.78-1 0-1.84.8-1.84 1.78s.85 1.77 1.84 1.77M83 21h3V10h-3zM46 21h-3V9h-4V6h11v3h-4zM53 21l-3 .02V10h3v1.88c.36-1 1.34-1.75 2.53-1.75h.03c.3 0 .6 0 .94.1v2.84a4 4 0 0 0-1.31-.2c-1.38 0-2.19 1-2.19 2.7zM91 21h-3V10.01l3-.01v1q.85-1.22 2.9-1.21c2.57 0 4.1 1.8 4.1 4.45V21h-3v-6c0-1.47-.56-2.66-1.77-2.66-1.36 0-2.23.93-2.23 2.89zM120 21l6-15h-3.5l-4 10.5L114 6h-3.5l6.5 15zM156.45 21h-2.93l-2.02-6.25-2 6.25h-2.93L143 10h3.14l2.05 7.04 2.17-7.04h2.26l2.2 7.04 2.02-7.04H160zM61.92 21.24c1.52 0 2.57-.77 3.08-1.47V21h3V10h-3v1.23a3.8 3.8 0 0 0-3.08-1.47c-2.93 0-5.17 2.64-5.17 5.74s2.24 5.74 5.17 5.74m.64-2.75c-1.68 0-2.78-1.25-2.78-2.99s1.1-3 2.78-3 2.77 1.26 2.77 3-1.1 3-2.77 3M78 19.77c-.5.7-1.56 1.47-3.08 1.47-2.93 0-5.17-2.64-5.17-5.74s2.24-5.74 5.17-5.74c1.52 0 2.57.77 3.08 1.47V6h3v15h-3zm-5.22-4.27c0 1.74 1.1 3 2.78 3s2.77-1.26 2.77-3-1.1-3-2.77-3c-1.68 0-2.78 1.26-2.78 3M105.23 25.82c3.36 0 5.77-1.72 5.77-5.68V10h-3v1.23a3.6 3.6 0 0 0-3.06-1.47c-2.88 0-5.2 2.46-5.2 5.56 0 3.08 2.32 5.68 5.2 5.68a3.8 3.8 0 0 0 3.06-1.58v.74c0 1.76-1.04 3.02-2.82 3.02a4.8 4.8 0 0 1-3.43-1.37l-1.65 2.25c1.25 1.2 3.21 1.76 5.13 1.76m.35-7.68a2.75 2.75 0 0 1-2.8-2.82c0-1.69 1.28-2.81 2.8-2.81s2.8 1.12 2.8 2.81a2.75 2.75 0 0 1-2.8 2.82M142.78 18.72a6 6 0 0 1-5.1 2.47c-3.28 0-5.83-2.27-5.83-5.74a5.6 5.6 0 0 1 5.78-5.75c2.89 0 5.42 1.83 5.42 5.42v.16c0 .25 0 .6-.05.97h-8.23c.18 1.47 1.48 2.19 2.93 2.19 1.39 0 2.33-.62 2.84-1.39zm-5.23-6.53c-1.13 0-2.38.57-2.67 1.91h5.15c-.26-1.32-1.36-1.91-2.48-1.91M14 6H2v6h6v9h6zm12 15h-7l6-15h7zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6"/></svg>'},95779:(e,t,i)=>{"use strict";i.d(t,{disable:()=>h,enable:()=>c,enabled:()=>a,getAllFeatures:()=>d,setEnabled:()=>l})
;const s=JSON.parse('{"14851":{},"custom_items_in_context_menu":{},"countdown":{},"symbol_search_parser_mixin":{},"pay_attention_to_ticker_not_symbol":{},"graying_disabled_tools_enabled":{},"update_study_formatter_on_symbol_resolve":{},"constraint_dialogs_movement":{},"phone_verification":{},"show_trading_notifications_history":{},"show_interval_dialog_on_key_press":{},"header_interval_dialog_button":{"subsets":["show_interval_dialog_on_key_press"]},"header_fullscreen_button":{},"header_symbol_search":{},"symbol_search_hot_key":{},"header_resolutions":{"subsets":["header_interval_dialog_button"]},"header_chart_type":{},"header_settings":{},"header_indicators":{},"header_compare":{},"header_undo_redo":{},"header_quick_search":{},"header_screenshot":{},"header_saveload":{},"study_on_study":{},"scales_date_format":{},"scales_time_hours_format":{},"header_widget":{"subsets":["header_widget_dom_node","header_symbol_search","header_resolutions","header_chart_type","header_settings","header_indicators","header_compare","header_undo_redo","header_quick_search","header_fullscreen_button","compare_symbol","header_screenshot"]},"legend_widget":{},"compare_symbol":{"subsets":["header_compare"]},"property_pages":{"subsets":["show_chart_property_page","chart_property_page"]},"show_chart_property_page":{},"chart_property_page":{"subsets":["chart_property_page_scales","chart_property_page_trading","chart_property_page_right_margin_editor"]},"left_toolbar":{},"right_toolbar":{},"hide_left_toolbar_by_default":{},"control_bar":{},"widget_logo":{},"timeframes_toolbar":{},"edit_buttons_in_legend":{"subsets":["show_hide_button_in_legend","format_button_in_legend","study_buttons_in_legend","delete_button_in_legend","legend_inplace_edit"]},"show_hide_button_in_legend":{},"object_tree_legend_mode":{},"format_button_in_legend":{},"study_buttons_in_legend":{},"delete_button_in_legend":{},"legend_inplace_edit":{},"broker_button":{},"buy_sell_buttons":{"subsets":["broker_button"]},"pane_context_menu":{},"scales_context_menu":{},"legend_context_menu":{},"context_menus":{"subsets":["pane_context_menu","scales_context_menu","legend_context_menu","objects_tree_context_menu"]},"items_favoriting":{},"save_chart_properties_to_local_storage":{},"use_localstorage_for_settings":{"subsets":["items_favoriting","save_chart_properties_to_local_storage"]},"handle_scale":{"subsets":["mouse_wheel_scale","pinch_scale","axis_pressed_mouse_move_scale"]},"handle_scroll":{"subsets":["mouse_wheel_scroll","pressed_mouse_move_scroll","horz_touch_drag_scroll","vert_touch_drag_scroll"]},"plain_studymarket":{},"disable_resolution_rebuild":{},"border_around_the_chart":{},"charting_library_debug_mode":{},"saveload_requires_authentication":{},"saveload_storage_customization":{},"volume_force_overlay":{},"create_volume_indicator_by_default":{},"create_volume_indicator_by_default_once":{},"saved_charts_count_restriction":{},"lean_chart_load":{},"stop_study_on_restart":{},"star_some_intervals_by_default":{},"move_logo_to_main_pane":{},"show_animated_logo":{},"link_to_tradingview":{},"logo_without_link":{},"logo_always_maximized":{},"right_bar_stays_on_scroll":{},"chart_content_overrides_by_defaults":{},"snapshot_trading_drawings":{},"allow_supported_resolutions_set_only":{},"widgetbar_tabs":{"subsets":["right_toolbar"]},"show_object_tree":{"subsets":["right_toolbar"]},"dom_widget":{"subsets":["right_toolbar"]},"collapsible_header":{},"study_templates":{},"side_toolbar_in_fullscreen_mode":{},"header_in_fullscreen_mode":{},"remove_library_container_border":{},"whotrades_auth_only":{},"support_multicharts":{},"display_market_status":{},"display_data_mode":{},"datasource_copypaste":{},"drawing_templates":{"subsets":["linetoolpropertieswidget_template_button"]},"expand_symbolsearch_items":{},"symbol_search_three_columns_exchanges":{},"symbol_search_flags":{},"symbol_search_limited_exchanges":{},"bugreport_button":{"subsets":["right_toolbar"]},"footer_publish_idea_button":{},"text_notes":{},"show_source_code":{},"symbol_info":{},"no_bars_status":{},"clear_bars_on_series_error":{},"hide_loading_screen_on_series_error":{},"seconds_resolution":{},"dont_show_boolean_study_arguments":{},"hide_last_na_study_output":{},"price_scale_always_last_bar_value":{},"study_dialog_fundamentals_economy_addons":{},"uppercase_instrument_names":{},"trading_notifications":{},"chart_crosshair_menu":{},"japanese_chart_styles":{},"hide_series_legend_item":{},"hide_study_overlay_legend_item":{},"hide_study_compare_legend_item":{},"linetoolpropertieswidget_template_button":{},"use_overrides_for_overlay":{},"timezone_menu":{},"main_series_scale_menu":{},"show_login_dialog":{},"remove_img_from_rss":{},"bars_marks":{},"chart_scroll":{},"chart_zoom":{},"source_selection_markers":{},"low_density_bars":{},"end_of_period_timescale_marks":{},"open_account_manager":{},"show_order_panel_on_start":{},"order_panel":{"subsets":["order_panel_close_button","order_panel_undock","right_toolbar","order_info"]},"multiple_watchlists":{},"watchlist_import_export":{},"study_overlay_compare_legend_option":{},"mobile_app_action_open_details_webview":{},"custom_resolutions":{},"referral_program_for_widget_owners":{},"mobile_trading":{},"real_brokers":{},"no_min_chart_width":{},"lock_visible_time_range_on_resize":{},"pricescale_currency":{},"cropped_tick_marks":{},"trading_account_manager":{},"disable_sameinterval_aligning":{},"display_legend_on_all_charts":{},"chart_style_hilo":{},"chart_style_hilo_last_price":{},"pricescale_unit":{},"show_spread_operators":{},"hide_exponentiation_spread_operator":{},"hide_reciprocal_spread_operator":{},"compare_symbol_search_spread_operators":{},"studies_symbol_search_spread_operators":{},"hide_resolution_in_legend":{},"hide_unresolved_symbols_in_legend":{},"fix_left_edge":{},"study_symbol_ticker_description":{},"two_character_bar_marks_labels":{},"tick_resolution":{},"secondary_series_extend_time_scale":{},"hide_volume_ma":{},"small_no_display":{},"charting_library_single_symbol_request":{},"use_ticker_on_symbol_info_update":{},"show_zoom_and_move_buttons_on_touch":{},"hide_main_series_symbol_from_indicator_legend":{},"chart_hide_close_position_button":{},"chart_hide_close_order_button":{},"hide_price_scale_global_last_bar_value":{"subsets":["use_last_visible_bar_value_in_legend"]},"keep_object_tree_widget_in_right_toolbar":{},"show_average_close_price_line_and_label":{},"hide_image_invalid_symbol":{},"hide_object_tree_and_price_scale_exchange_label":{},"confirm_overwrite_if_chart_layout_with_name_exists":{},"determine_first_data_request_size_using_visible_range":{},"use_na_string_for_not_available_values":{},"show_last_price_and_change_only_in_series_legend":{},"legend_last_day_change":{},"iframe_loading_compatibility_mode":{},"show_percent_option_for_right_margin":{},"watchlist_context_menu":{},"accessible_keyboard_shortcuts":{},"advanced_emoji_in_titles":{},"app_phone":{},"app_tablet":{},"mobile_app_hide_replay_toolbar":{},"symbol_search_option_chain_selector":{},"tv_production":{"subsets":["advanced_emoji_in_titles","auto_enable_symbol_labels","symbol_search_parser_mixin","header_fullscreen_button","header_widget","dont_show_boolean_study_arguments","left_toolbar","right_toolbar","buy_sell_buttons","control_bar","symbol_search_hot_key","context_menus","edit_buttons_in_legend","object_tree_legend_mode","uppercase_instrument_names","use_localstorage_for_settings","saveload_requires_authentication","volume_force_overlay","saved_charts_count_restriction","create_volume_indicator_by_default","create_volume_indicator_by_default_once","charts_auto_save","save_old_chart_before_save_as","chart_content_overrides_by_defaults","alerts","header_saveload","header_layouttoggle","datasource_copypaste","show_saved_watchlists","watchlists_from_to_file","add_to_watchlist","property_pages","support_multicharts","display_market_status","display_data_mode","show_chart_warn_message","support_manage_drawings","widgetbar_tabs","study_templates","collapsible_header","drawing_templates","footer_publish_idea_button","text_notes","show_source_code","symbol_info","linetoolpropertieswidget_template_button","trading_notifications","symbol_search_three_columns_exchanges","symbol_search_flags","symbol_search_limited_exchanges","phone_verification","custom_resolutions","compare_symbol","study_on_study","japanese_chart_styles","show_login_dialog","dom_widget","bars_marks","chart_scroll","chart_zoom","show_trading_notifications_history","source_selection_markers","study_dialog_fundamentals_economy_addons","multiple_watchlists","marked_symbols","order_panel","pricescale_currency","show_animated_logo","pricescale_currency","show_object_tree","watchlist_import_export","scales_date_format","scales_time_hours_format","popup_hints","show_right_widgets_panel_by_default","compare_recent_symbols_enabled","chart_style_hilo_last_price","symbol_search_option_chain_selector"]},"widget":{"subsets":["auto_enable_symbol_labels","symbol_search_parser_mixin","uppercase_instrument_names","left_toolbar","right_toolbar","control_bar","symbol_search_hot_key","context_menus","edit_buttons_in_legend","object_tree_legend_mode","use_localstorage_for_settings","saveload_requires_authentication","volume_force_overlay","create_volume_indicator_by_default","create_volume_indicator_by_default_once","dont_show_boolean_study_arguments","header_widget_dom_node","header_symbol_search","header_resolutions","header_chart_type","header_compare","header_indicators","star_some_intervals_by_default","display_market_status","display_data_mode","show_chart_warn_message","symbol_info","linetoolpropertieswidget_template_button","symbol_search_three_columns_exchanges","symbol_search_flags","symbol_search_limited_exchanges","widgetbar_tabs","compare_symbol","show_login_dialog","plain_studymarket","japanese_chart_styles","bars_marks","chart_scroll","chart_zoom","source_selection_markers","property_pages","show_right_widgets_panel_by_default","chart_style_hilo_last_price"]},"bovespa_widget":{"subsets":["widget","header_settings","linetoolpropertieswidget_template_button","compare_recent_symbols_enabled"]},"charting_library_base":{"subsets":["14851","allow_supported_resolutions_set_only","auto_enable_symbol_labels","border_around_the_chart","collapsible_header","constraint_dialogs_movement","context_menus","control_bar","create_volume_indicator_by_default","custom_items_in_context_menu","datasource_copypaste","uppercase_instrument_names","display_market_status","edit_buttons_in_legend","object_tree_legend_mode","graying_disabled_tools_enabled","header_widget","legend_widget","header_saveload","dont_show_boolean_study_arguments","lean_chart_load","left_toolbar","right_toolbar","link_to_tradingview","pay_attention_to_ticker_not_symbol","plain_studymarket","refresh_saved_charts_list_on_dialog_show","right_bar_stays_on_scroll","saveload_storage_customization","stop_study_on_restart","timeframes_toolbar","symbol_search_hot_key","update_study_formatter_on_symbol_resolve","update_timeframes_set_on_symbol_resolve","use_localstorage_for_settings","volume_force_overlay","widget_logo","countdown","use_overrides_for_overlay","trading_notifications","compare_symbol","symbol_info","timezone_menu","main_series_scale_menu","create_volume_indicator_by_default_once","bars_marks","chart_scroll","chart_zoom","source_selection_markers","property_pages","go_to_date","adaptive_logo","show_animated_logo","handle_scale","handle_scroll","shift_visible_range_on_new_bar","chart_content_overrides_by_defaults","cropped_tick_marks","scales_date_format","scales_time_hours_format","popup_hints","save_shortcut","show_right_widgets_panel_by_default","show_object_tree","insert_indicator_dialog_shortcut","compare_recent_symbols_enabled","hide_main_series_symbol_from_indicator_legend","chart_style_hilo","request_only_visible_range_on_reset","clear_price_scale_on_error_or_empty_bars","show_symbol_logo_in_legend","show_symbol_logo_for_compare_studies","library_custom_color_themes","long_press_floating_tooltip"]},"charting_library":{"subsets":["charting_library_base"]},"static_charts_service":{"subsets":["charting_library","disable_resolution_rebuild"]},"trading_terminal":{"subsets":["charting_library_base","support_multicharts","header_layouttoggle","japanese_chart_styles","chart_property_page_trading","add_to_watchlist","open_account_manager","show_dom_first_time","order_panel","buy_sell_buttons","multiple_watchlists","show_trading_notifications_history","always_pass_called_order_to_modify","show_object_tree","watchlist_import_export","drawing_templates","trading_account_manager","chart_crosshair_menu","compare_recent_symbols_enabled","watchlist_context_menu","show_symbol_logo_in_account_manager","watchlist_sections","prefer_quote_short_name","enable_dom_data_for_untradable_symbols","prefer_symbol_name_over_fullname","watchlist_cross_tab_sync"]}}'),o=new Map,n=new Map,r=new Set
;function a(e){const t=o.get(e);if(void 0!==t)return t;const i=n.get(e);return!!i&&i.some(a)}function l(e,t){o.set(String(e),Boolean(t))}function c(e){l(e,!0)}function h(e){l(e,!1)}function d(){const e=Object.create(null);for(const t of r)e[t]=a(t);return e}!function(){for(const[e,t]of Object.entries(s))if(r.add(e),"subsets"in t)for(const i of t.subsets){r.add(i);let t=n.get(i);void 0===t&&(t=[],n.set(i,t)),t.push(e)}}()},9343:(e,t,i)=>{"use strict";var s;i.r(t),i.d(t,{LOGLEVEL:()=>s,getLogHistory:()=>v,getLogLevel:()=>_,getLogger:()=>b,getRawLogHistory:()=>f,isHighRateEnabled:()=>p,loggingOff:()=>C,loggingOn:()=>w,serializeLogHistoryEntry:()=>y,setHighRateStatus:()=>g,setLogLevel:()=>m}),function(e){e[e.ERROR=1]="ERROR",e[e.WARNING=2]="WARNING",e[e.INFO=3]="INFO",e[e.NORMAL=4]="NORMAL",e[e.DEBUG=5]="DEBUG"}(s||(s={}));let o=0;const n=1e3,r=[];let a=null,l=null,c=null,h=null,d=s.WARNING,u=!1;function _(){return d}function p(){return u}function m(e){e=Math.max(s.ERROR,Math.min(s.DEBUG,e)),d=e}function g(e){u=e}function f(e,t){let i=r.reduce(((e,t)=>e.concat(t)),[]);return i.sort(((e,t)=>e.id-t.id)),void 0!==t&&(i=i.filter((e=>e.subSystemId===t))),"number"==typeof e&&(i=i.slice(-e)),i}function y(e){return new Date(e.timestamp).toISOString()+":"+e.subSystemId+":"+e.message.replace(/"/g,"'")}const v=(e,t)=>function(e,t){let i,s=0,o=0;for(i=e.length-1;i>=1&&(s+=8*(1+encodeURIComponent(e[i]).length),!(i-1>0&&(o=8*(1+encodeURIComponent(e[i-1]).length),s+o>t)));i--);return e.slice(i)}(f(e,t).map(y),75497472);function S(e,t,i,r){if(t===l&&r.id===c)return;const u=new Date;if(e<=s.NORMAL&&function(e,t,i,s,r){"function"==typeof structuredClone&&(t=structuredClone(t)),t=t.slice(0,n);const a={id:o,message:t,subSystemId:s,timestamp:Number(e)};o+=1,i.push(a),void 0!==r&&i.length>r&&i.splice(0,1)}(u,t,i,r.id,r.maxCount),e<=d&&(!r.highRate||p())&&(!a||r.id.match(a))){const i=u.toISOString()+":"+r.id+":"+t;switch(e){case s.DEBUG:console.debug(i);break;case s.INFO:case s.NORMAL:r.color?console.log("%c"+i,"color: "+r.color):console.log(i);break;case s.WARNING:console.warn(i);break;case s.ERROR:console.error(i)}l=t,c=r.id,null!==h&&clearTimeout(h),h=setTimeout((()=>{l=null,c=null,h=null}),1e3)}}function b(e,t={}){const i=[];r.push(i);const o=Object.assign(t,{id:e});function n(e){return t=>S(e,String(t),i,o)}return{logDebug:n(s.DEBUG),logError:n(s.ERROR),logInfo:n(s.INFO),logNormal:n(s.NORMAL),logWarn:n(s.WARNING)}}const w=(e,t)=>{m(s.DEBUG),u=Boolean(e),a=t||null},C=()=>{m(s.INFO)}},10892:(e,t,i)=>{"use strict";i.d(t,{Interval:()=>h,ResolutionKind:()=>n,SpecialResolutionKind:()=>r,isHour:()=>u});const s=/^(\d*)([TSHDWMR])$/,o=/^(\d+)$/;var n,r;!function(e){e.Ticks="ticks",e.Seconds="seconds",e.Minutes="minutes",e.Days="days",e.Weeks="weeks",e.Months="months",e.Range="range",e.Invalid="invalid"}(n||(n={})),function(e){e.Hours="hours"}(r||(r={}));const a={};a[n.Ticks]=1e3,a[n.Seconds]=1e3,a[n.Minutes]=60*a[n.Seconds],a[n.Days]=1440*a[n.Minutes],a[n.Weeks]=7*a[n.Days];const l={T:n.Ticks,S:n.Seconds,D:n.Days,W:n.Weeks,M:n.Months,R:n.Range
},c=new Set([n.Ticks,n.Seconds,n.Minutes]);class h{constructor(e,t){this._kind=n.Invalid,this._multiplier=0,e!==n.Invalid&&t>0&&(this._kind=e,this._multiplier=t)}kind(){return this._kind}guiKind(){return this.isMinuteHours()?r.Hours:this._kind}multiplier(){return this._multiplier}isValid(){return this.kind()!==n.Invalid&&this.multiplier()>0}isDWM(){return this.isValid()&&!this.isRange()&&!this.isIntraday()&&!this.isTicks()}isIntraday(){const e=c.has(this.kind());return this.isValid()&&e}isSeconds(){return this.kind()===n.Seconds}isMinutes(){return this.kind()===n.Minutes}isMinuteHours(){return this.kind()===n.Minutes&&u(this.multiplier())}isDays(){return this.kind()===n.Days}isWeeks(){return this.kind()===n.Weeks}isMonths(){return this.kind()===n.Months}isRange(){return this.kind()===n.Range}isTicks(){return this.kind()===n.Ticks}is1Tick(){return this.isTicks()&&1===this.multiplier()}isTimeBased(){return!this.isRange()}letter(){return this.isValid()&&this.kind()!==n.Minutes?this.kind()[0].toUpperCase():""}value(){return this.isValid()?this.kind()===n.Minutes?this.multiplier()+"":this.multiplier()+this.letter():""}isEqualTo(e){if(!(e instanceof h))throw new Error("Argument is not an Interval");return!(!this.isValid()||!e.isValid())&&(this.kind()===e.kind()&&this.multiplier()===e.multiplier())}inMilliseconds(e=Date.now()){if(!this.isValid()||this.isRange())return NaN;if(this.isMonths()){const t=new Date(e);t.setUTCMonth(t.getUTCMonth()+(this.multiplier()||1));return+t-e}const t=this.multiplier();return a[this.kind()]*t}static isEqual(e,t){return e===t||h.parse(e).isEqualTo(h.parse(t))}static parseExt(e){e=(e+"").toUpperCase().split(",")[0];let t=s.exec(e);return null!==t?"H"===t[2]?{interval:new h(n.Minutes,60*d(t[1])),guiResolutionKind:r.Hours}:{interval:new h(l[t[2]],d(t[1])),guiResolutionKind:l[t[2]]}:(t=o.exec(e),null!==t?{interval:new h(n.Minutes,d(t[1])),guiResolutionKind:n.Minutes}:{interval:new h(n.Invalid,0),guiResolutionKind:n.Invalid})}static parse(e){return h.parseExt(e).interval}static kind(e){return h.parse(e).kind()}static isValid(e){return h.parse(e).isValid()}static isDWM(e){return h.parse(e).isDWM()}static isIntraday(e){return h.parse(e).isIntraday()}static isSeconds(e){return h.parse(e).isSeconds()}static isMinutes(e){return h.parse(e).isMinutes()}static isMinuteHours(e){return h.parse(e).isMinuteHours()}static isDays(e){return h.parse(e).isDays()}static isWeeks(e){return h.parse(e).isWeeks()}static isMonths(e){return h.parse(e).isMonths()}static isRange(e){return h.parse(e).isRange()}static isTicks(e){return h.parse(e).isTicks()}static isTimeBased(e){return h.parse(e).isTimeBased()}static normalize(e){const t=h.parse(e);return t.isValid()?t.value():null}}function d(e){return 0===e.length?1:parseInt(e,10)}function u(e){return e>=60&&!(e%60)}},75774:(e,t,i)=>{"use strict";i.d(t,{isAndroid:()=>p,isAnyMobile:()=>v,isBlackBerry:()=>m,isChrome:()=>a,isEdge:()=>c,isFF:()=>l,isIOS:()=>g,isIPad:()=>y,isLinux:()=>_,isMac:()=>d,isOperaMini:()=>f,isSafari:()=>h,isWindows:()=>u,mobiletouch:()=>n,touch:()=>r})
;const s="undefined"!=typeof window&&"undefined"!=typeof navigator,o=s&&"ontouchstart"in window,n=s&&o&&"onorientationchange"in window,r=s&&(o||!!navigator.maxTouchPoints),a=s&&window.chrome&&window.chrome.runtime,l=s&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,c=s&&/\sEdge\/\d\d\b/.test(navigator.userAgent),h=s&&Boolean(navigator.vendor)&&navigator.vendor.indexOf("Apple")>-1&&-1===navigator.userAgent.indexOf("CriOS")&&-1===navigator.userAgent.indexOf("FxiOS"),d=s&&/mac/i.test(navigator.platform),u=s&&/Win32|Win64/i.test(navigator.platform),_=s&&/Linux/i.test(navigator.platform),p=s&&/Android/i.test(navigator.userAgent),m=s&&/BlackBerry/i.test(navigator.userAgent),g=s&&/iPhone|iPad|iPod/.test(navigator.platform),f=s&&/Opera Mini/i.test(navigator.userAgent),y=s&&("MacIntel"===navigator.platform&&navigator.maxTouchPoints>1||/iPad/.test(navigator.platform)),v=p||m||g||f},26743:e=>{"use strict";e.exports=JSON.parse('{"4":["v",["h",0,2],["h",1,3]],"6":["v",["h",0,2,4],["h",1,3,5]],"8":["v",["h",0,2,4,6],["h",1,3,5,7]],"s":0,"2h":["h",0,1],"2v":["v",0,1],"3h":["h",0,1,2],"3v":["v",0,1,2],"3s":["h",0,["v",1,2]],"3r":["h",["v",0,1],2],"2-1":["v",["h",0,2],1],"1-2":["v",0,["h",1,2]],"4v":["v",0,1,2,3],"4h":["h",0,1,2,3],"4s":["h",0,["v",1,2,3]],"4s-l":["h",["v",1,2,3],0],"1-3":["v",0,["h",1,2,3]],"3-1":["v",["h",0,1,2],3],"2-2-l":["h",0,1,["v",2,3]],"2-2-r":["h",["v",0,1],2,3],"2-2":["v",["h",0,1],["v",2,3]],"1-4":["v",0,["h",1,2,3,4]],"5h":["h",0,1,2,3,4],"5v":["v",0,1,2,3,4],"5s":["h",0,["v",1,2,3,4]],"5s-l":["h",["v",1,2,3,4],0],"2-3":["v",["h",0,1],["h",2,3,4]],"3-2":["v",["h",0,1,2],["h",3,4]],"4-1":["v",["h",0,1,2,3],4],"2-3-l":["h",0,1,["v",2,3,4]],"2-3-r":["h",["v",0,1,2],3,4],"6h":["h",0,1,2,3,4,5],"6v":["v",0,1,2,3,4,5],"6c":["v",["h",0,1],["h",2,3],["h",4,5]],"2-4":["v",["h",0,1],["h",2,3,4,5]],"4-2":["v",["h",0,1,2,3],["h",4,5]],"4-3":["v",["h",0,1,2,3],["h",4,5,6]],"7h":["h",0,1,2,3,4,5,6],"7s":["h",0,["v",1,2,3,4,5,6]],"8c":["v",["h",0,1],["h",2,3],["h",4,5],["h",6,7]],"8h":["h",0,1,2,3,4,5,6,7],"8v":["v",0,1,2,3,4,5,6,7],"9s":["v",["h",0,1,2],["h",3,4,5],["h",6,7,8]],"5-4":["v",["h",0,1,2,3,4],["h",5,6,7,8]],"9h":["h",0,1,2,3,4,5,6,7,8],"9v":["v",0,1,2,3,4,5,6,7,8],"10c5":["v",["h",0,2,4,6,8],["h",1,3,5,7,9]],"10h":["h",0,1,2,3,4,5,6,7,8,9],"10v":["v",0,1,2,3,4,5,6,7,8,9],"12c6":["v",["h",0,2,4,6,8,10],["h",1,3,5,7,9,11]],"12c4":["v",["h",0,4,8],["h",1,5,9],["h",2,6,10],["h",3,7,11]],"12h":["h",0,1,2,3,4,5,6,7,8,9,10,11],"14c7":["v",["h",0,2,4,6,8,10,12],["h",1,3,5,7,9,11,13]],"16c8":["v",["h",0,2,4,6,8,10,12,14],["h",1,3,5,7,9,11,13,15]],"16c4":["v",["h",0,4,8,12],["h",1,5,9,13],["h",2,6,10,14],["h",3,7,11,15]]}')},30714:e=>{"use strict"
;e.exports=JSON.parse('{"color-white":"#ffffff","color-black":"#000000","color-transparent":"#00000000","color-cold-gray-50":"#F9F9F9","color-cold-gray-100":"#F2F2F2","color-cold-gray-150":"#EBEBEB","color-cold-gray-200":"#DBDBDB","color-cold-gray-250":"#C9C9C9","color-cold-gray-300":"#B8B8B8","color-cold-gray-350":"#A8A8A8","color-cold-gray-400":"#9C9C9C","color-cold-gray-450":"#8C8C8C","color-cold-gray-500":"#808080","color-cold-gray-550":"#707070","color-cold-gray-600":"#636363","color-cold-gray-650":"#575757","color-cold-gray-700":"#4A4A4A","color-cold-gray-750":"#3D3D3D","color-cold-gray-800":"#2E2E2E","color-cold-gray-850":"#1F1F1F","color-cold-gray-900":"#0F0F0F","color-cold-gray-950":"#000000","color-ripe-red-50":"#FFEBEC","color-ripe-red-100":"#FCCBCD","color-ripe-red-200":"#FAA1A4","color-ripe-red-300":"#F77C80","color-ripe-red-400":"#F7525F","color-ripe-red-500":"#F23645","color-ripe-red-600":"#CC2F3C","color-ripe-red-700":"#B22833","color-ripe-red-800":"#991F29","color-ripe-red-900":"#801922","color-ripe-red-a100":"#FF8080","color-ripe-red-a200":"#FF5252","color-ripe-red-a400":"#FF3333","color-ripe-red-a600":"#CC2929","color-ripe-red-a700":"#802028","color-ripe-red-a800":"#4D191D","color-ripe-red-a900":"#331F20","color-tan-orange-50":"#FFF3E0","color-tan-orange-100":"#FFE0B2","color-tan-orange-200":"#FFCC80","color-tan-orange-300":"#ffb74d","color-tan-orange-400":"#FFA726","color-tan-orange-500":"#FF9800","color-tan-orange-600":"#FB8C00","color-tan-orange-700":"#F57C00","color-tan-orange-800":"#EF6C00","color-tan-orange-900":"#e65100","color-tan-orange-a100":"#FFD180","color-tan-orange-a200":"#ffab40","color-tan-orange-a400":"#FF9100","color-tan-orange-a500":"#E57E17","color-tan-orange-a600":"#CC7014","color-tan-orange-a700":"#8C541C","color-tan-orange-a800":"#593A1B","color-tan-orange-a900":"#33261A","color-iguana-green-50":"#E8F5E9","color-iguana-green-100":"#C8E6C9","color-iguana-green-200":"#A5D6A7","color-iguana-green-300":"#81c784","color-iguana-green-400":"#66BB6A","color-iguana-green-500":"#4caf50","color-iguana-green-600":"#43a047","color-iguana-green-700":"#388e3c","color-iguana-green-800":"#2E7D32","color-iguana-green-900":"#1B5E20","color-iguana-green-a100":"#B9F6CA","color-iguana-green-a200":"#69F0AE","color-iguana-green-a400":"#00E676","color-iguana-green-a700":"#00c853","color-banana-yellow-50":"#FFFDE7","color-banana-yellow-100":"#FFF9C4","color-banana-yellow-200":"#FFF59D","color-banana-yellow-300":"#FFF176","color-banana-yellow-400":"#ffee58","color-banana-yellow-500":"#ffeb3b","color-banana-yellow-600":"#fdd835","color-banana-yellow-700":"#fbc02d","color-banana-yellow-800":"#f9a825","color-banana-yellow-900":"#F57F17","color-banana-yellow-a100":"#FFFF8D","color-banana-yellow-a200":"#FFFF00","color-banana-yellow-a400":"#ffea00","color-banana-yellow-a700":"#EEDA01","color-tv-blue-50":"#E3EFFD","color-tv-blue-100":"#BBD9FB","color-tv-blue-200":"#90BFF9","color-tv-blue-300":"#5B9CF6","color-tv-blue-400":"#3179F5","color-tv-blue-500":"#2962FF","color-tv-blue-600":"#1E53E5","color-tv-blue-700":"#1848CC","color-tv-blue-800":"#143EB2","color-tv-blue-900":"#0C3299","color-tv-blue-a100":"#82b1ff","color-tv-blue-a200":"#448aff","color-tv-blue-a400":"#2979ff","color-tv-blue-a600":"#2962FF","color-tv-blue-a700":"#143A87","color-tv-blue-a800":"#142E61","color-tv-blue-a900":"#132042","color-deep-blue-50":"#EDE7F6","color-deep-blue-100":"#D1C4E9","color-deep-blue-200":"#B39DDB","color-deep-blue-300":"#9575cd","color-deep-blue-400":"#7e57c2","color-deep-blue-500":"#673ab7","color-deep-blue-600":"#5E35B1","color-deep-blue-700":"#512da8","color-deep-blue-800":"#4527A0","color-deep-blue-900":"#311B92","color-deep-blue-a100":"#b388ff","color-deep-blue-a200":"#7C4DFF","color-deep-blue-a400":"#651FFF","color-deep-blue-a700":"#6200EA","color-minty-green-50":"#DAF2EE","color-minty-green-100":"#ACE5DC","color-minty-green-200":"#70CCBD","color-minty-green-300":"#42BDA8","color-minty-green-400":"#22AB94","color-minty-green-500":"#089981","color-minty-green-600":"#06806B","color-minty-green-700":"#056656","color-minty-green-800":"#004D40","color-minty-green-900":"#00332A","color-minty-green-a100":"#A7FFF0","color-minty-green-a200":"#45E5CB","color-minty-green-a400":"#2BD9BC","color-minty-green-a600":"#24B29B","color-minty-green-a700":"#1B7667","color-minty-green-a800":"#10443B","color-minty-green-a900":"#082621","color-grapes-purple-50":"#F3E5F5","color-grapes-purple-100":"#E1BEE7","color-grapes-purple-200":"#CE93D8","color-grapes-purple-300":"#ba68c8","color-grapes-purple-400":"#ab47bc","color-grapes-purple-500":"#9c27b0","color-grapes-purple-600":"#8e24aa","color-grapes-purple-700":"#7b1fa2","color-grapes-purple-800":"#6A1B9A","color-grapes-purple-900":"#4A148C","color-grapes-purple-a100":"#EA80FC","color-grapes-purple-a200":"#E040FB","color-grapes-purple-a400":"#D500F9","color-grapes-purple-a700":"#aa00ff","color-berry-pink-50":"#FCE4EC","color-berry-pink-100":"#F8BBD0","color-berry-pink-200":"#f48fb1","color-berry-pink-300":"#f06292","color-berry-pink-400":"#ec407a","color-berry-pink-500":"#e91e63","color-berry-pink-600":"#D81B60","color-berry-pink-700":"#C2185B","color-berry-pink-800":"#AD1457","color-berry-pink-900":"#880E4F","color-berry-pink-a100":"#ff80ab","color-berry-pink-a200":"#ff4081","color-berry-pink-a400":"#f50057","color-berry-pink-a700":"#c51162","color-sky-blue-50":"#E0F7FA","color-sky-blue-100":"#B2EBF2","color-sky-blue-200":"#80DEEA","color-sky-blue-300":"#4dd0e1","color-sky-blue-400":"#26c6da","color-sky-blue-500":"#00bcd4","color-sky-blue-600":"#00acc1","color-sky-blue-700":"#0097A7","color-sky-blue-800":"#00838F","color-sky-blue-900":"#006064","color-sky-blue-a100":"#84FFFF","color-sky-blue-a200":"#18FFFF","color-sky-blue-a400":"#00e5ff","color-sky-blue-a700":"#00B8D4","color-forest-green-50":"#DAF2E6","color-forest-green-100":"#ACE5C9","color-forest-green-200":"#70CC9E","color-forest-green-300":"#42BD7F","color-forest-green-400":"#22AB67","color-forest-green-500":"#089950","color-forest-green-600":"#068043","color-forest-green-700":"#056636","color-forest-green-800":"#004D27","color-forest-green-900":"#1A3326","color-facebook":"#1877F2","color-deep-facebook":"#1564CA","color-twitter":"#1DA1F2","color-deep-twitter":"#188CD3","color-youtube":"#FF0000","color-linkedin":"#007BB5","color-seeking-alpha-brand":"#ff7200"}')
}},e=>{e.O(0,[938,481,8971],(()=>{return t=37150,e(e.s=t);var t}));e.O()}]);