Files
riwa-ionic/public/charting_library/bundles/library.6ef314468a2a940f40f4.js
2026-01-14 21:55:53 +07:00

864 lines
2.5 MiB
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[1297],{20041:e=>{e.exports={}},17192:e=>{e.exports={}},69681:e=>{e.exports={}},73052:e=>{e.exports={}},15216:e=>{e.exports={"tv-spinner__container-rotate":"tv-spinner__container-rotate-aLqboHuu"}},10048: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"}},20350:e=>{e.exports={screen:"screen-otjoFNF2",fade:"fade-otjoFNF2",screenfade:"screenfade-otjoFNF2"}},26572:e=>{e.exports={}},98714: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"}},82815:e=>{e.exports={}},60070:e=>{e.exports={}},99647:e=>{e.exports={"css-value-chart-controls-bar-height-with-border":"39px","css-value-chart-controls-bar-border":"1px"}},43882:e=>{e.exports={}},95047:e=>{e.exports={}},25043:e=>{e.exports={}},91751: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"}},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})},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(91679),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}},7029:(e,t,i)=>{"use strict";i.d(t,{t:()=>s});const s=i.i18next},19625:(e,t,i)=>{"use strict";i.d(t,{colorsPalette:()=>d,getHexColorByName:()=>u});var s=i(23420),o=i(579),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}}},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:()=>$,show:()=>G,showOnElement:()=>U});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="")}"interactive"===document.readyState?_():document.addEventListener("DOMContentLoaded",_);var m=i(49481),g=i(63273),f=(i(21251),i(14729)),y=i(9859),v=i(49483);const S={default:"",white:"theme-white",chart:"theme-chart","round-shadow":"theme-round-shadow"},b=Object.keys(S);var w,C=i(94194),P=i(61814),T=i(91751);function x(e){const t=function(e){const t=e.hasAttribute("data-tooltip")?e.getAttribute("data-tooltip"):e.getAttribute("title");return t&&((0,C.setTooltipData)(e,"text",t),e.removeAttribute("title")),(0,C.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)(B).cloneNode(!0),i=N(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)(R).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)(V).cloneNode(!0),r=(0,P.hotKeyDeserialize)(e.hotkey),a=r.keys.map((e=>`<span class="${T["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="${T["common-tooltip__plus-sign"]}">+</span>`),i.classList.add(T["common-tooltip__body--with-hotkey"]),t&&n.classList.add(T["common-tooltip__hotkey-block--divider"]),i.appendChild(n)}return t.addEventListener("contextmenu",f.preventDefault),t}function M(e,t){const i=t.rect;if(!i)return;!function(e,t){const i=b.includes(t)?S[t]:"";e.classList.remove(...b.map((e=>S[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=N(e),o=e.querySelector(`.${T["common-tooltip__button-container"]}`);s.classList.toggle(T["common-tooltip__body--width_wide"],Boolean(t.wide)),s.classList.toggle(T["common-tooltip__body--no-padding"],Boolean(t.noPadding)),s.classList.toggle(T["common-tooltip__body--width_narrow"],Boolean(t.narrow)),s.classList.toggle(T["common-tooltip__body--no-buttons"],!0),s.style.left=L(0),s.style.width=L(s.clientWidth+(Boolean(t.noPadding)?0:2));const n=document.body.clientWidth,r=v.CheckMobile.iOS()||v.CheckMobile.Android()||(0,v.supportTouch)()&&(0,v.isMac)()?window.innerHeight:document.body.clientHeight,a=t.vertical,l=t.extendMargin||a&&i.w<20||!a&&i.h<20;e.classList.toggle(T["common-tooltip--farther"],l),e.classList.toggle(T["common-tooltip--vertical"],a),e.classList.toggle(T["common-tooltip--horizontal"],!a);const c=function(e){return e.querySelector(`.${T["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,y.clamp)(i.y+i.h/2,u,_)-h/2,m=p+h;e.style.left=L(i.x+i.w),e.style.top=L(p),p<a?s.style.top=o.style.top=L(a-p):m>l&&(s.style.top=o.style.top=L(l-m));const{right:f}=(e.querySelector(":last-child")||s).getBoundingClientRect(),v=f+10>n;e.classList.toggle(T["common-tooltip--direction_reversed"],v),e.classList.toggle(T["common-tooltip--direction_normal"],!v);let S=v?"after":"before";(0,g.isRtl)()?(S=t.otr?"after":S,S=t.otl?"before":S):(S=t.otr?"before":S,S=t.otl?"after":S),c.classList.toggle(T["common-tooltip__ear-holder--before"],"before"===S),c.classList.toggle(T["common-tooltip__ear-holder--after"],"after"===S),"after"===S&&(e.style.left="auto",e.style.right=L(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=L(u);const _=d<a;e.classList.toggle(T["common-tooltip--direction_reversed"],_),e.classList.toggle(T["common-tooltip--direction_normal"],!_);const p=function(e,t,i,s){if(e.above)return O(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 O(i,s)?"above":"below"}(t,r,h,i);"above"===p?e.style.bottom=L(r-i.y):e.style.top=L(i.y+i.h),c.classList.add("above"===p?T["common-tooltip__ear-holder--above"]:T["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=L(u+g),e.style.width=L(s.clientWidth+o.clientWidth),g=_?Math.max(0,g):Math.min(0,g),o.style.left=L(-g),s.style.left=L(-g)}}function A(e){e.classList.toggle(T["common-tooltip--hidden"],!0)}function L(e){return`${Math.floor(e)}px`}!function(e){e[e.ViewportPadding=10]="ViewportPadding"}(w||(w={}));const k=`\n\t<div id="common-tooltip-wrapper" class="${T["common-tooltip"]}">\n\t\t<div class="${T["common-tooltip__ear-holder"]}" >\n\t\t\t<div class="${T["common-tooltip__body"]} js-tooltip-body"></div>\n\t\t</div>\n\t\t<div class="${T["common-tooltip__button-container"]}"></div>\n\t</div>\n`,D=`\n\t<div class="${T["common-tooltip__hotkey-block"]}"></div>\n`,E=`\n\t<div class="${T["common-tooltip__hotkey-text"]}"></div>\n`,B=(0,m.parseHtmlElement)(k),V=(0,m.parseHtmlElement)(D),R=(0,m.parseHtmlElement)(E);function N(e){return e.querySelector(`.${T["common-tooltip__body"]}`)}function O(e,t){return 10+e<t.y}let F=!1,W=null,H=null;s.mobiletouch||(document.addEventListener("mouseover",j,!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;j(e,!0)}),{capture:!0}),document.addEventListener("active-descendant-focus",(function(e){e.target instanceof HTMLElement&&j(e,!0)}),{capture:!0}));const z=new MutationObserver((()=>{if(W&&W.options.target){let e;e="isConnected"in W.options.target?W.options.target.isConnected:document.body.contains(W.options.target),e||$()}})),U=(e,t={})=>{const{content:i,...s}=Z(t),o=x(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=Z(e),i=I(t);var s;if(W={options:t,element:i},s=i,p(),u&&u.appendChild(s),c(),!F)return A(i),void h((()=>K(i)),function(e){return"number"!=typeof e.tooltipDelay||isNaN(e.tooltipDelay)?500:e.tooltipDelay}(t));const{tooltipDebounce:o}=e;"number"!=typeof o||isNaN(o)?K(i):h((()=>K(i)),o)};function j(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||Y(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=()=>U(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)),H&&(H.destroy(),H=null),$(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===H&&(H=(0,n.createGroup)({desc:"Tooltip"}),H.add({desc:"Hide",hotkey:27,handler:o}));break}}}function q(){p(),F=!1,W=null}const $=(e,t)=>{if(c(),(0,o.ensureNotNull)(z).disconnect(),!W)return;if(!e&&!F)return;const{element:i,options:s}=W,n=()=>{i.removeEventListener("mouseleave",n),A(i),e?q():l=setTimeout((()=>{q()}),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 K(e){const{options:t}=(0,o.ensureNotNull)(W);if(M(e,t),function(e){e.classList.toggle(T["common-tooltip--hidden"],!1)}(e),(0,o.ensureNotNull)(z).observe(document,{childList:!0,subtree:!0}),F=!0,t.forceHideOnMove){const e=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("touchmove",e),$()};document.addEventListener("mousemove",e),document.addEventListener("touchmove",e)}}function Y(e){return e&&(e.nodeType===Node.ELEMENT_NODE?e:null)}function Z(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()}}},23024:(e,t,i)=>{"use strict";i.d(t,{getChartStorage:()=>n});var s=i(64289);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,11777));o=new e}return null===o&&(o=new ChartStorageHttp),o}},38881:(e,t,i)=>{"use strict";i.d(t,{ChunkLoader:()=>o});var s=i(14051);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";i.d(t,{preventDefault:()=>o,preventScrollByWheelClick:()=>r,wrapHandlerWithPreventEvent:()=>n});var s=i(49483);function o(e){e.cancelable&&e.preventDefault()}function n(e){return t=>{o(t),e(t)}}function r(e){s.isChrome&&e.addEventListener("mousedown",(e=>{if(1===e.button)return e.preventDefault(),!1}))}},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(52033);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}},82992:(e,t,i)=>{"use strict";i.d(t,{linking:()=>m});var s=i(90484),o=i(50151),n=i(64147),r=(i(56570),i(85049)),a=i(68805),l=i(9343),c=i(42989),h=i(69109);const d=(0,l.getLogger)("Linking");var u,_;!function(e){e[e.NotBound=0]="NotBound",e[e.BoundToWidget=1]="BoundToWidget",e[e.BoundToModel=2]="BoundToModel"}(u||(u={})),function(e){e[e.Symbol=0]="Symbol",e[e.Resolution=1]="Resolution"}(_||(_={}));class p{constructor(e,t,i){this.watchedSymbol=new n.WatchedValue,this.seriesShortSymbol=new n.WatchedValue,this.proSymbol=new n.WatchedValue,this.ensuredProSymbol=new n.WatchedValue,this.watchedInterval=new n.WatchedValue,this.watchedIntraday=new n.WatchedValue,this.watchedSeconds=new n.WatchedValue,this.watchedTicks=new n.WatchedValue,this.watchedDataFrequencyResolution=new n.WatchedValue,this.watchedRange=new n.WatchedValue,this.watchedSupportedResolutions=new n.WatchedValue,this.watchedSupportedChartStyles=new n.WatchedValue,this.symbolNamesList=new n.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.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()}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=r.Interval.normalize(e);t&&this._needApplyInterval(t)&&!this._muted&&this._setGroupInterval(t)}_updateIntervalByProperty(e,t){
const i=this._intervalLock(),s=r.Interval.normalize(t);i&&s&&this._needApplyInterval(s)&&!this._muted&&this._setGroupInterval(s),(i||e===this._boundChartWidget)&&this.watchedInterval.setValue(s??t)}_sendSnowplowAnalytics(){if(!window.user.do_not_track)throw new Error("unsupported")}_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,c.allChartStyles)();((0,a.isCloseBasedSymbol)(e)||this._mainSeries().intervalObj().is1Tick())&&(i=i.filter((e=>(0,a.isSingleValueBasedStyle)(e)))),"hlc"===e.visible_plots_set&&(i=i.filter((e=>(0,a.isHLCBasedStyle)(e)||(0,a.isSingleValueBasedStyle)(e)))),this.watchedSupportedChartStyles.setValue(i),this.watchedIntraday.setValue(!!e.has_intraday),this.watchedSeconds.setValue(!!e.has_seconds),this.watchedTicks.setValue(!(0,a.isCloseBasedSymbol)(e)&&!!e["is-tickbars-available"]),this.watchedRange.setValue(!(0,a.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();r.Interval.isEqual(t,e)||this.watchedInterval.setValue(t)}})),this.mute(!1)}_needApplyInterval(e){return this._chartsForLock(1).some((t=>!r.Interval.isEqual(t.resolutionWV().value(),e)))}}const m=new class{constructor(){this._watchedSymbol=new n.WatchedValue,this._seriesShortSymbol=new n.WatchedValue,this._proSymbol=new n.WatchedValue,this._ensuredProSymbol=new n.WatchedValue,this._watchedInterval=new n.WatchedValue,this._watchedIntraday=new n.WatchedValue,this._watchedSeconds=new n.WatchedValue,this._watchedTicks=new n.WatchedValue,this._watchedDataFrequencyResolution=new n.WatchedValue,this._watchedRange=new n.WatchedValue,this._watchedSupportedResolutions=new n.WatchedValue,this._watchedSupportedChartStyles=new n.WatchedValue([]),this._symbolNamesList=new n.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 n.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._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,h.setMuteLinkingGroup)(((e,t)=>{this._linkingGroup(e).mute(t)}))}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){(this.symbol.value()!==e||i)&&(d.logInfo(`Change linking symbol to ${e}, initiator: ${t}`),this.symbol.setValue(e,i))}_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 d.logError(e),new Error(e)}this._preventFeedBySymbol||this._loadSearchCharts(e)}}_loadSearchCharts(e){if(!this._searchCharts){const e="No search charts defined";throw d.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={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 p(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:m})},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(92184);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}},56840:(e,t,i)=>{
"use strict";e=i.nmd(e),i(49483);i(84906).fetch;var s=i(66800).regExpEscape,o=i(21097).TVXWindowEvents,n=i(11417).TVLocalStorage,r=i(52033).Delegate,a=i(56570),l=["s.tradingview.com","betacdn.tradingview.com"],c=a.enabled("use_localstorage_for_settings"),h=window.TVSettings=function(){var e=!1,t=null;function i(){return!t&&c}try{e=!TradingView.onWidget()&&parent&&parent!==window&&!!parent.IS_DEMO_PAGE}catch(e){}if(e){var d={"widgetbar.layout-settings":{widgets:{},settings:{minimized:!0}},notShowMainWizard:!0},u=function(e,t,i){var s=d[e];return s??t},_=function(){};return{loaded:!1,loadedModel:!1,getValue:u,getJSON:u,getBool:u,getFloat:u,getInt:u,setValue:_,setJSON:_,remove:_,keys:function(){return Object.keys(d)},keysMask:function(){return[]},sync:_,onSync:{subscribe:function(){}}}}window.environment;var p,m=TradingView.onWidget()?"tradingview-widget":"tradingview",g=m+".",f={},y=[/^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/];function v(e){return g+e}function S(e){return e.substring(g.length)}function b(e,t){var i=f[e];return i??t}function w(e,t,i){i=i||{};var s=""+t;return f[e]!==s&&(f[e]=s,P(e,i)),i.forceFlush&&!p&&(p=setTimeout((function(){p=void 0,T()}),10)),h}function C(e,t){return t=t||{},null!=f[e]&&(delete f[e],P(e)),t.forceFlush&&T(),h}function P(e,s){if(t)null==f[e]?t.removeValue(e):t.setValue(e,f[e]);else if(i())try{null==f[e]?n.removeItem(v(e)):n.setItem(v(e),f[e])}catch(e){}else 0;!0!==s?.skipCrossWindowEvent&&o.emit("settings",JSON.stringify({key:e,value:f[e]}))}function T(e){}function x(){return Object.keys(f)}function I(e){for(var t=0;t<y.length;++t)if(y[t].exec(e))return!0;return!1}function M(e){return e.substring(0,g.length)===g}function A(e){f={};const t=0===Object.keys(e).length;t||function(e){Object.keys(e).forEach((function(t){f[t]=e[t]+""}))}(e),function(e){for(var t=n.length;t--;){var i=n.key(t);i&&M(i)&&(e&&w(S(i),n.getItem(i)),n.removeItem(i))}}(t)}y.push(/^savedwatch\..+/),o.on("settings",(function(e){var t=JSON.parse(e);null==t.value?delete f[t.key]:f[t.key]=t.value}));var L=new r;return{loaded:!1,loadedModel:!1,getValue:b,getJSON:function(e,t){var i=b(e,void 0);if(null==i)return t;try{return JSON.parse(i)}catch(i){return C(e),t}},getBool:function(e,t){var i=b(e);return null==i?t:!(!i||"false"===i||0==+i)},getFloat:function(e,t,i){var s=b(e,void 0);if(null==s)return t;var o=parseFloat(s);if(!isFinite(o))throw new TypeError('"'+s+'" is not float (key: "'+e+'")');return o},getInt:function(e,t,i){var s=b(e,void 0);if(null==s)return t;var o=parseInt(s,10)
;if(!isFinite(o))throw new TypeError('"'+s+'" is not int (key: "'+e+'")');return o},setValue:w,setJSON:function(e,t,i){return w(e,JSON.stringify(t),i),h},remove:C,keys:x,keysMask:function(e,t){for(var i=x(),o=[],n=(e=new RegExp("^"+s(e).replace(/\\\*\\\*/gi,".+").replace(/\\\*/gi,"[^.]+")+"$","gi"),i.length-1);n>=0;n--)e.test(i[n])&&o.push(i[n]),e.lastIndex=0;return o},sync:function(e){null!==e?(t?A(t.initialSettings||{}):i()?(function(){if(TradingView.onWidget()&&l.includes(window.location.host))for(var e="tradingview.",t=n.length;t--;){var i=n.key(t);if(0===i.indexOf(e)){var s=i.replace(e,m+".");n.setItem(s,n.getItem(i)),n.removeItem(i)}}}(),function(){f={};for(var e=!a.enabled("save_chart_properties_to_local_storage"),t=n.length;t--;){var i=n.key(t);if(i&&M(i)){var s=i.substring(g.length);e&&!I(s)||(f[s]=n.getItem(i))}}}()):A(e||{}),L.fire()):!0},onSync:L,setSettingsAdapter:function(e){t=e}}}();e&&e.exports&&(e.exports=h)},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 Boolean(e.typespecs?.includes("yield"))}function r(e){return e?.includes("discontinued")??!1}i.d(t,{hasCryptoTypespec:()=>s,isBond:()=>o,isSymbolDelisted:()=>r,isYield:()=>n})},49156:(e,t,i)=>{"use strict";i.d(t,{colors:()=>a});var s=i(19625),o=i(19063);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"),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),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),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),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(46088);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,colorMintyGreen500Alpha20:w,colorMintyGreen500Alpha28:C,colorMintyGreen500Alpha50:P,colorRipeRed200:T,colorRipeRed400:x,colorRipeRed500:I,colorRipeRed600:M,colorRipeRedA700:A,colorRipeRed500Alpha5:L,colorRipeRed500Alpha28:k,colorRipeRed500Alpha50:D,colorRipeRed500Alpha20:E,colorDeepBlueA700:B,colorBerryPink500:V,colorBerryPink400Alpha50:R,colorBerryPink400Alpha75:N,colorIguanaGreenA700:O,colorSkyBlue400Alpha5:F,colorSkyBlue400Alpha50:W,colorSkyBlue400Alpha75:H,colorSkyBlue500:z,colorDeepBlueA400:U,colorTvBlue200:G,colorTvBlue400:j,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:x},prePostMarket:{preMarketColor:X,postMarketColor:q},candleStyle:{borderColor:"#378658",upColor:y,wickColor:"#737375",wickUpColor:y,wickDownColor:I,downColor:I,borderUpColor:y,borderDownColor:I},volCandlesStyle:{borderColor:"#378658",upColor:y,wickColor:"#737375",wickUpColor:y,wickDownColor:I,downColor:I,borderUpColor:y,borderDownColor:I},haStyle:{borderColor:"#378658",upColor:y,wickColor:"#737375",wickUpColor:y,wickDownColor:I,downColor:I,borderUpColor:y,borderDownColor:I},hlcAreaStyle:{highLineColor:y,lowLineColor:I,closeLineColor:h,highCloseFillColor:w,closeLowFillColor:E},hollowCandleStyle:{upColor:y,downColor:I,borderColor:"#378658",borderUpColor:y,borderDownColor:I,wickColor:"#737375",wickUpColor:y,wickDownColor:I},barStyle:{downColor:I,upColor:y},pnfStyle:{downColor:I,upColor:y,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae"},baselineStyle:{baselineColor:h,topFillColor1:C,topFillColor2:b,bottomFillColor1:L,bottomFillColor2:k,topLineColor:y,bottomLineColor:I},areaStyle:{transparency:100,color1:$,color2:q,linecolor:q},hiloStyle:{color:q,borderColor:q,labelColor:q},columnStyle:{upColor:P,downColor:D},renkoStyle:{upColor:y,downColor:I,borderUpColor:y,borderDownColor:I,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae",wickUpColor:y,wickDownColor:I},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:I,upColor:y,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae"},pbStyle:{upColor:y,downColor:I,borderUpColor:y,borderDownColor:I,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",borderUpColorProjection:"#a9dcc3",borderDownColorProjection:"#f5a6ae"},rangeStyle:{upColor:y,downColor:I,upColorProjection:"#a9dcc3",downColorProjection:"#f5a6ae",candlesUpColor:y,candlesDownColor:I,candlesBorderUpColor:y,candlesBorderDownColor:I,candlesWickUpColor:y,candlesWickDownColor:I},tpoStyle:J,volFootprintStyle:Q,svpStyle:ee,hlcBarsStyle:{color:q}}}}},24317:(e,t,i)=>{"use strict";i.r(t),i.d(t,{darkTheme:()=>le,getStdChartTheme:()=>ue,getStdThemeNames:()=>de,lightTheme:()=>ae,overrideStdTheme:()=>ce,restoreStdThemes:()=>he,translateThemeName:()=>_e});var s=i(11542),o=i(37265),n=i(2433),r=i(46088),a=i(49156)
;const{colorWhite:l,colorColdGray100Alpha0:c,colorColdGray100Alpha6:h,colorColdGray200:d,colorColdGray300:u,colorColdGray400:_,colorColdGray450:p,colorColdGray600:m,colorColdGray800:g,colorColdGray900:f,colorDeepBlueA200:y,colorGrapesPurpleA400:v,colorGrapesPurpleA200Alpha15:S,colorMintyGreen400:b,colorMintyGreen500:w,colorMintyGreen600:C,colorMintyGreen800:P,colorMintyGreen500Alpha5:T,colorMintyGreen500Alpha20:x,colorMintyGreen500Alpha28:I,colorMintyGreen500Alpha50:M,colorMintyGreenA900:A,colorRipeRed400:L,colorRipeRed500:k,colorRipeRed600:D,colorRipeRed800:E,colorRipeRed500Alpha5:B,colorRipeRed500Alpha20:V,colorRipeRed500Alpha28:R,colorRipeRed500Alpha50:N,colorRipeRedA900:O,colorBerryPink400Alpha50:F,colorBerryPink400Alpha75:W,colorBerryPink500:H,colorIguanaGreenA700:z,colorSkyBlue400Alpha5:U,colorSkyBlue400Alpha50:G,colorSkyBlue400Alpha75:j,colorSkyBlue500:q,colorDeepBlueA400:$,colorTvBlue400:K,colorTvBlue500:Y,colorTvBlue500Alpha28:Z,colorTvBlue600:X,colorTvBlue800:J,colorTvBlueA800:Q,colorTanOrange500:ee,colorTanOrange600:te}=a.colors,ie={},se={},oe={},ne={content:{chartProperties:{scalesProperties:{textColor:u,lineColor:c,backgroundColor:l},paneProperties:{vertGridProperties:{color:h},horzGridProperties:{color:h},crossHairProperties:{color:_},background:f,backgroundGradientStartColor:"#1C1C1C",backgroundGradientEndColor:f,backgroundType:"gradient",separatorColor:g}},sessions:{sessionHighlight:{backgrounds:{outOfSession:{color:Y,transparency:92},preMarket:{color:ee,transparency:92},postMarket:{color:Y,transparency:92},electronic:{color:Y,transparency:92}},vertlines:{sessBreaks:{color:"#4985e7"}}}},mainSourceProperties:{baseLineColor:m,prevClosePriceLineColor:"#555555",priceLineColor:"",highLowAvgPrice:{highLowPriceLinesColor:"",averagePriceLineColor:""},bidAsk:{bidLineColor:Y,askLineColor:L},prePostMarket:{preMarketColor:te,postMarketColor:Y},candleStyle:{borderColor:"#378658",upColor:w,wickColor:"#737375",wickUpColor:w,wickDownColor:k,downColor:k,borderUpColor:w,borderDownColor:k},volCandlesStyle:{borderColor:"#378658",upColor:w,wickColor:"#737375",wickUpColor:w,wickDownColor:k,downColor:k,borderUpColor:w,borderDownColor:k},haStyle:{borderColor:"#378658",upColor:w,wickColor:"#737375",wickUpColor:w,wickDownColor:k,downColor:k,borderUpColor:w,borderDownColor:k},hlcAreaStyle:{highLineColor:w,lowLineColor:k,closeLineColor:p,highCloseFillColor:x,closeLowFillColor:V},hollowCandleStyle:{upColor:w,downColor:k,borderColor:"#378658",borderUpColor:w,borderDownColor:k,wickColor:"#737375",wickUpColor:w,wickDownColor:k},barStyle:{downColor:k,upColor:w},pnfStyle:{downColor:k,upColor:w,upColorProjection:"#336854",downColorProjection:"#7f323f"},baselineStyle:{baselineColor:p,topFillColor1:I,topFillColor2:T,bottomFillColor1:B,bottomFillColor2:R,topLineColor:w,bottomLineColor:k},areaStyle:{transparency:100,color1:Z,color2:Y,linecolor:Y},hiloStyle:{color:Y,borderColor:Y,labelColor:Y},columnStyle:{upColor:M,downColor:N},renkoStyle:{upColor:w,downColor:k,borderUpColor:w,borderDownColor:k,upColorProjection:"#336854",
downColorProjection:"#7f323f",borderUpColorProjection:"#336854",borderDownColorProjection:"#7f323f",wickUpColor:w,wickDownColor:k},lineStyle:{colorType:r.ColorType.Gradient,color:Y,gradientStartColor:v,gradientEndColor:"#00BCE5"},lineWithMarkersStyle:{colorType:r.ColorType.Gradient,color:Y,gradientStartColor:v,gradientEndColor:"#00BCE5"},steplineStyle:{colorType:r.ColorType.Gradient,color:Y,gradientStartColor:v,gradientEndColor:"#00BCE5"},kagiStyle:{downColor:k,upColor:w,upColorProjection:"#336854",downColorProjection:"#7f323f"},pbStyle:{upColor:w,downColor:k,borderUpColor:w,borderDownColor:k,upColorProjection:"#336854",downColorProjection:"#7f323f",borderUpColorProjection:"#336854",borderDownColorProjection:"#7f323f"},rangeStyle:{upColor:w,downColor:k,upColorProjection:"#336854",downColorProjection:"#7f323f",candlesUpColor:w,candlesDownColor:k,candlesBorderUpColor:w,candlesBorderDownColor:k,candlesWickUpColor:w,candlesWickDownColor:k},tpoStyle:ie,volFootprintStyle:se,svpStyle:oe,hlcBarsStyle:{color:Y}}}};var re=i(24633);let ae=(0,o.clone)(n.light),le=(0,o.clone)(ne);function ce(e,t){switch(e){case re.StdTheme.Light:ae=(0,o.merge)((0,o.clone)(ae),t);break;case re.StdTheme.Dark:le=(0,o.merge)((0,o.clone)(le),t)}}function he(){ae=(0,o.clone)(n.light),le=(0,o.clone)(ne)}function de(){return[re.StdTheme.Light,re.StdTheme.Dark]}function ue(e){return(0,o.clone)(e===re.StdTheme.Light?ae:e===re.StdTheme.Dark?le:void 0)}function _e(e){return{[re.StdTheme.Light]:s.t(null,{context:"colorThemeName"},i(96870)),[re.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={}))},85662:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DEFAULT_THEME:()=>c,getCurrentTheme:()=>g,getStdTheme:()=>T,getStdThemeNames:()=>C,getStdThemedValue:()=>x,getTheme:()=>b,getThemeNames:()=>w,getThemedColor:()=>f,isPublicTheme:()=>m,isStdThemeName:()=>P,isStdThemedDefaultValue:()=>I,isThemeExist:()=>L,removeTheme:()=>A,restoreTheme:()=>y,saveTheme:()=>M,savedThemeName:()=>v,syncTheme:()=>S,themes:()=>p,translateStdThemeName:()=>k});var s=i(24377),o=i(56840);function n(){return(0,o.getValue)("current_theme.name")||null}const r=i(64289);var a=i(24317),l=i(45345);const c="light";var h=i(24633),d=i(11542),u=i(20913),_=i(19625);const p={[h.StdTheme.Light]:{name:h.StdTheme.Light,label:()=>d.t(null,{context:"colorThemeName"},i(96870)),order:2,getThemedColor:e=>(0,_.getHexColorByName)(e)},[h.StdTheme.Dark]:{name:h.StdTheme.Dark,label:()=>d.t(null,{context:"colorThemeName"},i(85119)),order:1,getThemedColor:e=>{const t=u[e]||e;return(0,_.getHexColorByName)(t)}}};function m(e){return!e.isPrivate}function g(){return p[l.watchedTheme.value()]||p[c]}function f(e){return g().getThemedColor(e)}function y(){(0,l.setTheme)(n()||c)}function v(){return n()}function S(){var e;e=g().name,(0,o.setValue)("current_theme.name",e,{forceFlush:!0})}function b(e){return r.loadTheme(e)}function w(){return r.loadThemes()}function C(){return a.getStdThemeNames()}function P(e){
return C().includes(e)}function T(e){return a.getStdChartTheme(e)||{content:void 0}}function x(e,t){const i=t||g().name,s=a.getStdChartTheme(i),o=0!==e.length&&e.split(".");return s&&s.content&&o?o.reduce(((e,t)=>e[t]),s.content):null}function I(e,t,i){const o=x(e,i);return null!==o&&(0,s.areEqualRgba)((0,s.parseRgba)(o),(0,s.parseRgba)(String(t)))}function M(e,t){return r.saveTheme(e,t)}function A(e){return r.removeTheme(e)}function L(e){return r.isThemeExist(e)}function k(e){return a.translateThemeName(e)}},45345:(e,t,i)=>{"use strict";i.d(t,{setTheme:()=>r,watchedTheme:()=>n});var s,o=i(64147);!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)}(e,window)}))},51768:(e,t,i)=>{"use strict";i.d(t,{disableTrackingEvents:()=>a,trackEvent:()=>r});var s=i(76422);i(56570);(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.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(21251);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={}))},58473:(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(79652),l=i(56570),c=i(86235),h=i(86001),d=i(50340),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(1303),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(5826),i.e(4600),i.e(2564),i.e(6445),i.e(3799),i.e(5480),i.e(6489),i.e(9766),i.e(5375),i.e(601),i.e(4876),i.e(4137),i.e(2371),i.e(2227),i.e(4931),i.e(2544),i.e(769),i.e(4411),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(1303),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(5826),i.e(4600),i.e(2564),i.e(6445),i.e(3799),i.e(5480),i.e(6489),i.e(9766),i.e(5375),i.e(601),i.e(4876),i.e(4137),i.e(2371),i.e(2227),i.e(4931),i.e(2544),i.e(769),i.e(4411),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(1303),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(5826),i.e(4600),i.e(2564),i.e(6445),i.e(3799),i.e(5480),i.e(6489),i.e(9766),i.e(5375),i.e(601),i.e(4876),i.e(4137),i.e(2371),i.e(2227),i.e(4931),i.e(2544),i.e(769),i.e(4411),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(52033);!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(56840),r=i(79320),a=i(928),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)}))}},25812:(e,t,i)=>{"use strict";var s;i.d(t,{ToolboxType:()=>s}),function(e){e[e.Delete=0]="Delete"
}(s||(s={}))},59064:(e,t,i)=>{"use strict";i.d(t,{globalCloseDelegate:()=>s,globalCloseMenu:()=>o});const s=new(i(52033).Delegate);function o(){s.fire()}},61223:e=>{e.exports={"css-value-header-toolbar-height":"38px"}},63844:e=>{e.exports={chartsSplitter:"chartsSplitter-L0xapso5",hovered:"hovered-L0xapso5"}},45982:e=>{e.exports={"css-value-pane-controls-padding-left":"1px","css-value-pane-controls-padding-right":"4px"}},56479:e=>{e.exports={paneSeparator:"paneSeparator-uqBaC1Ki",handle:"handle-uqBaC1Ki",mobile:"mobile-uqBaC1Ki",hovered:"hovered-uqBaC1Ki",selected:"selected-uqBaC1Ki",active:"active-uqBaC1Ki"}},79437:(e,t,i)=>{"use strict";var s=i(37265).declareClassAsPureInterface;function o(){}TradingView.WEB_SOCKET_WAS_CONNECTED=!1,o.prototype.defaultResolutions=function(){},o.prototype.availableCurrencies=function(){},o.prototype.availableUnits=function(){},o.prototype.supportedSymbolsTypes=function(){},o.prototype.symbolsGrouping=function(){},o.prototype.quoteCreateSession=function(e){},o.prototype.quoteDeleteSession=function(e){},o.prototype.quoteSetFields=function(e,t){},o.prototype.quoteAddSymbols=function(e,t){},o.prototype.quoteRemoveSymbols=function(e,t){},o.prototype.quoteFastSymbols=function(e,t){},o.prototype.depthCreateSession=function(e,t,i){},o.prototype.depthDeleteSession=function(e){},o.prototype.depthSetSymbol=function(e,t){},o.prototype.depthClearSymbol=function(e){},o.prototype.depthSetScale=function(e,t){},o.prototype.chartCreateSession=function(e,t){},o.prototype.chartDeleteSession=function(e){},o.prototype.createSession=function(e,t){},o.prototype.removeSession=function(e){},o.prototype.connected=function(){},o.prototype.connect=function(){},o.prototype.disconnect=function(){},o.prototype.switchTimezone=function(e,t){},o.prototype.resolveSymbol=function(e,t,i,s){},o.prototype.createSeries=function(e,t,i,s,o,n,r,a){},o.prototype.removeSeries=function(e,t,i){},o.prototype.modifySeries=function(e,t,i,s,o,n,r){},o.prototype.requestMoreData=function(e,t,i,s){},o.prototype.requestMetadata=function(e){},o.prototype.canCreateStudy=function(e,t,i){},o.prototype.createStudy=function(e,t,i,s,o,n,r,a){},o.prototype.getStudyCounter=function(e){},o.prototype.getFundamentalCounter=function(e){},o.prototype.removeStudy=function(e,t){},o.prototype.modifyStudy=function(e,t,i,s,o){},o.prototype.createPointset=function(e,t,i,s,o,n,r){},o.prototype.modifyPointset=function(e,t,i,s,o){},o.prototype.removePointset=function(e,t,i){},o.prototype.requestMoreTickmarks=function(e,t,i,s){},o.prototype.requestFirstBarTime=function(e,t,i,s){},o.prototype._sendRequest=function(e,t){},o.prototype._onMessage=function(e){},o.prototype._dispatchNotification=function(e){},o.prototype._invokeNotificationHandler=function(e,t,i){},o.prototype._notifySessions=function(e){},o.prototype.unpack=function(e){},o.prototype.searchSymbols=function(e,t,i,s,o,n,r,a,l,c){},o.prototype.getMarks=function(e,t,i,s,o){},o.prototype.getTimescaleMarks=function(e,t,i,s,o){},s(o,"ChartApiInterface"),e.exports.ChartApiInterface=o},64289:(e,t,i)=>{
"use strict";i.r(t),i.d(t,{favorStandardStudyTemplate:()=>D,favorStudyTemplate:()=>k,getChartContent:()=>C,getCharts:()=>S,getChartsCount:()=>v,getCustomAdapter:()=>g,getDrawingTemplates:()=>R,getStandardStudyTemplateById:()=>E,getStorageURL:()=>p,getStudyTemplateById:()=>I,getStudyTemplatesList:()=>A,initialize:()=>f,invalidateStudyTemplatesList:()=>L,isThemeExist:()=>G,loadDrawingTemplate:()=>N,loadLayout:()=>P,loadTheme:()=>W,loadThemes:()=>H,openLayoutLink:()=>T,removeChart:()=>b,removeDrawingTemplate:()=>O,removeStudyTemplate:()=>x,removeTheme:()=>U,renameStudyTemplate:()=>B,replaceStudyTemplate:()=>V,saveChart:()=>w,saveDrawingTemplate:()=>F,saveStudyTemplate:()=>M,saveTheme:()=>z,setCustomAdapter:()=>m,updateUser:()=>y});var s=i(9343),o=i(14712),n=i(56840);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 P(e){try{return{chartWidgetCollectionState:await C(e),description:e.name,id:e.id,lastModified:e.modified_iso,name:e.name,uid:e.url,username:""}}catch(e){throw r.logWarn("Error loading chart"),e}}function T(e,t){throw new Error("Opening layout link is not supported")}async function x(e){try{const t=j().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 I(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 M(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=j().indexOf(e.name);return{id:e.name,is_default:!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=j();q(t?[...s,e]:s.filter((t=>t!==e))),i?.(null)}function D(e,t,i){k(e,t,i)}function E(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 G(e){return W(e).then((e=>Boolean(e.content)))}function j(){return n.getJSON("StudyTemplates.quicks",[])}function q(e){n.setJSON("StudyTemplates.quicks",e)}},51243:(e,t,i)=>{"use strict";var s=i(50151).ensureNotNull,o=i(50151).ensureDefined,n=i(9343).getLogger("Chart.ChartApiLocal"),r=i(14381),a=i(85049).Interval,l=i(84954).JSStudyEngineTypescript,c=i(6058),h=i(79437).ChartApiInterface,d=i(18278).HandlerInfo,u=i(37265).requireFullInterfaceImplementation,_=i(82783).TIMEFRAMETYPE,p=i(53388).createDwmAligner;TradingView.STUDY_COUNT_LIMIT=210;function m(e,t){return`${e}__${t}`}JSServer.ChartApi=function(e){this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._metadataRequestNextNumber=1,this._connected=!1,this._enabled=!1,this._studyEngine=new l(e),this._callbacks={},this._serverTimeOffset=0;var t=this;this._studyEngine.on("configuration_received",(function(){t._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",(function(e){var i={time:e.value[0]/1e3,open:e.value[1],high:e.value[2],low:e.value[3],close:e.value[4],volume:e.value[5]};t._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={},this._studySpecs=new Map,this._isNonCountedStudy=()=>!0,this.defaultResolutions=this.defaultResolutions.bind(this)},JSServer.ChartApi.prototype.destroy=function(){this._studyEngine.destroy(),this._studyEngine=null},JSServer.ChartApi.prototype.purgeCache=function(e){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache()},JSServer.ChartApi.prototype.resetCache=function(){this._studyEngine.resetCache()},JSServer.ChartApi.prototype.defaultResolutions=function(){return this._studyEngine.supportedResolutions()||["1","3","5","15","30","45","60","120","180","240","1D","1W","1M"]},JSServer.ChartApi.prototype.availableCurrencies=function(){var e=this._studyEngine.supportedCurrencies().map((function(e){return"string"==typeof e?{id:e,code:e}:e}));return Promise.resolve(e)},JSServer.ChartApi.prototype.availableUnits=function(){return Promise.resolve(this._studyEngine.supportedUnits())},JSServer.ChartApi.prototype.availablePriceSources=function(e){return this._studyEngine.supportedPriceSources(e)},JSServer.ChartApi.prototype.supportedSymbolsTypes=function(){return this._studyEngine.supportedSymbolsTypes()},JSServer.ChartApi.prototype.symbolsGrouping=function(){return this._studyEngine.symbolsGrouping()},JSServer.ChartApi.prototype.start=function(){this._enabled=!0,
this._fireEvent("start_enabled")},JSServer.ChartApi.prototype.unsubscribe=function(e,t){var i=this._callbacks[e];i&&i.splice(i.indexOf(t),1)},JSServer.ChartApi.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},JSServer.ChartApi.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){var s=this._callbacks[e].slice(0);i||(this._callbacks[e]=[]);for(var o=0;o<s.length;++o)s[o](t)}},JSServer.ChartApi.prototype.chartCreateSession=function(e,t){this._studyEngine.chartCreateSession(e)},JSServer.ChartApi.prototype.chartDeleteSession=function(e){this._studyEngine.chartDeleteSession(e)},JSServer.ChartApi.prototype.createSession=function(e,t){TradingView.ChartapiMessagerInstances[e]=new c(this,e),this._sessions[e]=t,this._notificationHandlers[e]={},this.connected()&&t.onMessage({method:"connected",params:[]})},JSServer.ChartApi.prototype.removeSession=function(e){delete this._sessions[e],delete this._notificationHandlers[e],this._studyEngine.stopSources(e)},JSServer.ChartApi.prototype.connected=function(){return this._connected},JSServer.ChartApi.prototype.connect=function(){if(this._enabled)this.connected()||(this._connected=!0,this.sessionid="dummy session id",this._notifySessions({method:"connected",params:[]}));else{var e=this;this.on("start_enabled",(function(){e.connect()}))}},JSServer.ChartApi.prototype.disconnect=function(){this._connected=!1,this._notifySessions({method:"disconnected",params:[]}),this.purgeCache(),this.studyCounter=0},JSServer.ChartApi.prototype.switchTimezone=function(e,t){this._studyEngine.switchTimezone(e,t)},JSServer.ChartApi.prototype.receiveLocalResponse=function(e){this._dispatchNotification(e),this._fireEvent("message_"+e.method,void 0,!0)},JSServer.ChartApi.prototype.getMarks=function(e,t,i,s,o){this._studyEngine.getMarks(e,t,i,s,o)},JSServer.ChartApi.prototype.getTimescaleMarks=function(e,t,i,s,o){this._studyEngine.getTimescaleMarks(e,t,i,s,o)},JSServer.ChartApi.prototype.resolveSymbol=function(e,t,i,s){this._notificationHandlers[e][t]=new d(s,t),this._studyEngine.resolveSymbol(e,t,i)},JSServer.ChartApi.prototype.createSeries=function(e,t,i,s,o,n,r,a){var l=this;this._notificationHandlers[e][t]=new d((function(o){"series_completed"===o.method&&null!==r&&(l._applyTimeFrame(e,s,t,i,r),r=null),a(o)}),t);const c={countBack:n||300};null!==r&&r.type===_.TimeRange&&(c.to=1e3*r.to,c.from=1e3*r.from),this._studyEngine.createSeries(e,t,i,s,o,c)},JSServer.ChartApi.prototype.removeSeries=function(e,t){delete this._notificationHandlers[e][t],this._studyEngine.removeSeries(e,t)},JSServer.ChartApi.prototype.setVisibleTimeRange=function(e,t,i,o,n,r,a,l,c,h){var d=o,u=!0!==(a=a||{}).applyDefaultRightMargin&&void 0===a.percentRightMargin&&void 0!==n?n:null,_=p(this._studyEngine.getSeriesInterval(e,t),this._studyEngine.getSeriesSymbolInfo(e,t));null!==_&&(d=_.timeToSessionStart(1e3*d)/1e3,null!==u&&(u=_.timeToSessionStart(1e3*u)/1e3));var m=this;function g(){var o=m._studyEngine.sessionTimeScale(e);if(null!==o){
var n,_=o.indexOfTime(1e3*d);if(null===u)n=o.lastSessionBarIndex();else{var p=o.indexOfTime(1e3*u);n=p&&p.index}if(null!==_&&null!==n){var g=_.index;if(_.timeMs<1e3*d&&(g+=1),!1===r){const e=s(o.firstSessionBarIndex());g<e&&(g=e)}g>n?h&&h(new Error("Invalid visible range")):(TradingView.ChartapiMessagerInstances[e].onSeriesTimeframeUpdate(t,i,g,n,a,c),l&&setTimeout(l,0))}else h&&h(new Error("Bars are not available"))}else h&&h(new Error("Session time scale is not available"))}if(this._studyEngine.isTimeScaleExtendedTo(e,1e3*o))g();else{var f=TradingView.ChartapiMessagerInstances[e].beforeSeriesCompleted,y=TradingView.ChartapiMessagerInstances[e].seriesError;void 0!==this._setVisibleRangeTimeout[e]&&clearTimeout(this._setVisibleRangeTimeout[e]),this._setVisibleRangeTimeout[e]=setTimeout(function(){delete this._setVisibleRangeTimeout[e],f.subscribe(null,v,!0),y.subscribe(null,S,!0),this._studyEngine.ensureExtendedTo(t,e,1e3*o)}.bind(this),0)}function v(e,s){e===t&&s===i&&(f.unsubscribe(null,v),y.unsubscribe(null,S),g())}function S(e,s){e===t&&s===i&&f.unsubscribe(null,v)}},JSServer.ChartApi.prototype._applyTimeFrame=function(e,t,i,s,o){var n,l,c={},h=!0;if(o.type===_.PeriodBack){var d=this._studyEngine.getSeriesLastBarTime(e,i);if(null===d)return;l=d/1e3;var u=a.parse(o.value),m=this._studyEngine.getSeriesSymbolInfo(e,i);n=r.alignPeriodsBackForVisibleRange(m.session,m.session_holidays,m.corrections,u.letter(),u.multiplier(),1,d)/1e3;var g=p(this._studyEngine.getSeriesInterval(e,i),m);null!==g&&(l=g.timeToExchangeTradingDay(1e3*l)/1e3,n=g.timeToExchangeTradingDay(1e3*n)/1e3),c={applyDefaultRightMargin:!0},h=this._studyEngine.hasStudyWithExtendedTimeScale(e)}else n=o.from,l=o.to;this.setVisibleTimeRange(e,i,s,n,l,h,c,void 0,o)},JSServer.ChartApi.prototype.modifySeries=function(e,t,i,s,o,n,r,a){var l=this;this._notificationHandlers[e][t]=new d((function(o){"series_completed"===o.method&&null!==r&&(l._applyTimeFrame(e,s,t,i,r),r=null),a(o)}),t),this._studyEngine.modifySeries(e,t,s,o,i,n)},JSServer.ChartApi.prototype.requestMoreData=function(e,t){this._studyEngine.extendSeriesRange(e,t)},JSServer.ChartApi.prototype.setStudiesAccessController=function(e){this.studiesAccessController=e},JSServer.ChartApi.prototype.allStudiesMetadata=function(){return this._studyEngine.studiesMetadata()},JSServer.ChartApi.prototype.requestMetadata=function(){return new Promise(((e,t)=>{const i=this.studiesAccessController.getEnabledTools();e({method:"studies_metadata",params:[this._makeNextRequestId(),{errors:[],hash:"",metainfo:i,migrations:[]}]})}))},JSServer.ChartApi.prototype._makeNextRequestId=function(){return"metadata_"+this._metadataRequestNextNumber++},JSServer.ChartApi.prototype.setIsNonCountedStudyFn=function(e){this._isNonCountedStudy=e},JSServer.ChartApi.prototype.canCreateStudy=function(e,t,i){return this._isNonCountedStudy(t.id)||this.studyCounter<TradingView.STUDY_COUNT_LIMIT?{success:!0}:{success:!1,reason:"general",limitValue:TradingView.STUDY_COUNT_LIMIT}},JSServer.ChartApi.prototype.getStudyCounter=function(e){
return this.studyCounter},JSServer.ChartApi.prototype.getFundamentalCounter=function(e){return 0},JSServer.ChartApi.prototype.createStudy=function(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 d(r,t),this._studySpecs.set(m(e,t),a),this._studyEngine.createStudy(e,t,s,i,o,n),this._isNonCountedStudy(a.id)||this.studyCounter++,!0},JSServer.ChartApi.prototype.removeStudy=function(e,t){if(this._notificationHandlers[e][t]){delete this._notificationHandlers[e][t];const i=m(e,t),s=o(this._studySpecs.get(i));this._studySpecs.delete(i),this._studyEngine.removeStudy(e,t),this._isNonCountedStudy(s.id)||this.studyCounter--}},JSServer.ChartApi.prototype.modifyStudy=function(e,t,i,s,o){this._notificationHandlers[e][t]=new d(o,t),this._studyEngine.modifyStudy(e,t,i,s)},JSServer.ChartApi.prototype.notifyStudy=function(){throw Error("This call is not implemented")},JSServer.ChartApi.prototype.createPointset=function(e,t,i,s,o,n,r){this._notificationHandlers[e][t]=new d(r,t),this._studyEngine.createPointset(e,t,s,o,n)},JSServer.ChartApi.prototype.modifyPointset=function(e,t,i,s,o){throw Error("This call is not implemented")},JSServer.ChartApi.prototype.removePointset=function(e,t,i){this._notificationHandlers[e][t]=null,this._studyEngine.removePointset(e,t)},JSServer.ChartApi.prototype.requestMoreTickmarks=function(e,t,i){this._studyEngine.requestMoreTickmarks(e,i)},JSServer.ChartApi.prototype.requestFirstBarTime=function(e,t,i,s){this._notificationHandlers[e][t]=new d(s,t)},JSServer.ChartApi.prototype._invokeHandler=function(e,t){e&&e(t)},JSServer.ChartApi.prototype._sendRequest=function(e,t){throw Error("This method is not implemented")},JSServer.ChartApi.prototype._onMessage=function(e){throw Error("This method is not implemented")},JSServer.ChartApi.prototype._dispatchNotification=function(e){var t=e.params.shift();if(this._notificationHandlers[t])switch(e.method){case"timescale_update":var i=e.params[0],s=e.params[1];for(var o in s.clear=0===s.changes.length&&0===s.marks.length,this._sessions[t].onMessage({method:"timescale_update",params:s}),i){var r={method:"data_update",params:{customId:o,plots:i[o].series,nonseries:i[o].nonseries,turnaround:i[o].turnaround}};this._invokeNotificationHandler(t,o,r)}break;case"tickmark_update":this._sessions[t].onMessage({method:"timescale_update",params:e.params[0]});break;case"data_update":for(var o in e.params[0]){var a=e.params[0][o];r={method:"data_update",params:{customId:o,plots:a.series?a.series:a.plots,nonseries:a.nonseries,turnaround:a.turnaround}};this._invokeNotificationHandler(t,o,r)}break;case"index_update":for(var o in e.params[0]){r={method:"index_update",params:e.params[0][o]};this._invokeNotificationHandler(t,o,r)}break;case"critical_error":n.logNormal(new Date+" critical_error session:"+this.sessionid+" reason:"+e.params[0]),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(var l in e.params[0])this._invokeNotificationHandler(t,l,{method:"clear_data",params:e.params[0][l]});break;default:var c=e.params[0];this._invokeNotificationHandler(t,c,e)}},JSServer.ChartApi.prototype._invokeNotificationHandler=function(e,t,i){if(void 0!==t){var s=this._notificationHandlers[e][t];void 0!==s&&s&&this._invokeHandler(s.handler,i)}},JSServer.ChartApi.prototype.searchSymbols=function(e,t,i,s,o){this._studyEngine.searchSymbols(e,t,i,s,o)},JSServer.ChartApi.prototype._notifySessions=function(e){for(var t in this._sessions){if(!this._sessions.hasOwnProperty(t))return;var i=this._sessions[t];"function"==typeof i.onMessage&&i.onMessage(e)}},JSServer.ChartApi.prototype.unpack=function(e){throw Error("This method is not implemented")},JSServer.ChartApi.prototype.quoteCreateSession=function(e){return this._studyEngine.quoteCreateSession(e)},JSServer.ChartApi.prototype.quoteDeleteSession=function(e){return this._studyEngine.quoteDeleteSession(e)},JSServer.ChartApi.prototype.quoteSetFields=function(e,t){return this._studyEngine.quoteSetFields(e,t)},JSServer.ChartApi.prototype.quoteAddSymbols=function(e,t){return-1!==t.indexOf(void 0)&&(console.warn("Got undefined in quoteAddSymbols"),t=t.filter((function(e){return!!e}))),this._studyEngine.quoteAddSymbols(e,t)},JSServer.ChartApi.prototype.quoteRemoveSymbols=function(e,t){return this._studyEngine.quoteRemoveSymbols(e,t)},JSServer.ChartApi.prototype.quoteFastSymbols=function(e,t){return this._studyEngine.quoteFastSymbols(e,t)},JSServer.ChartApi.prototype.quoteHibernateAll=function(e){return this._studyEngine.quoteHibernateAll(e)},JSServer.ChartApi.prototype.depthCreateSession=function(e){return this._studyEngine.depthCreateSession(e)},JSServer.ChartApi.prototype.depthDeleteSession=function(e){return this._studyEngine.depthDeleteSession(e)},JSServer.ChartApi.prototype.depthSetSymbol=function(e,t){return this._studyEngine.depthSetSymbol(e,t)},JSServer.ChartApi.prototype.depthClearSymbol=function(e){},JSServer.ChartApi.prototype.depthSetScale=function(e,t){},JSServer.ChartApi.prototype.createStudiesAccessController=function(e,t,i){return new this.StudiesAccessController(this._studyEngine,e&&JSON.parse(e)||{type:"black",tools:[]})},JSServer.ChartApi.prototype.StudiesAccessController=function(e,t){this._studyEngine=e,this._studiesAccess=t},JSServer.ChartApi.prototype.StudiesAccessController.prototype._findTool=function(e){for(var t=null,i=0;i<this._studiesAccess.tools.length;++i){var s=this._studiesAccess.tools[i];if(s.name===e||s===e){t=s;break}}return t},JSServer.ChartApi.prototype.StudiesAccessController.prototype.getEnabledTools=function(){return this._studyEngine.studiesMetadata().filter((function(e){return this.isToolEnabled(e.description)||e.is_hidden_study}),this)},
JSServer.ChartApi.prototype.StudiesAccessController.prototype.isToolEnabled=function(e){var t=this._findTool(e);return"black"===this._studiesAccess.type?!t||t.grayed:!!t},JSServer.ChartApi.prototype.StudiesAccessController.prototype.isToolGrayed=function(e){var t=this._findTool(e);return t&&t.grayed},JSServer.ChartApi.prototype.serverTimeOffset=function(){return this._studyEngine.serverTimeOffset()},JSServer.ChartApi.prototype.serverTime=function(){return this._studyEngine.serverTime()},JSServer.ChartApi.prototype.disconnectCount=function(){return 0},u(JSServer.ChartApi,"JSServer.ChartApi",h,"ChartApiInterface"),e.exports=JSServer.ChartApi},6058:(e,t,i)=>{"use strict";var s=i(52033).Delegate,o=function(e,t){this._server=e,this._session=t,this.beforeSeriesCompleted=new s,this.seriesError=new s};o.prototype.onSymbolResolved=function(e,t){this._server.receiveLocalResponse({method:"symbol_resolved",params:[this._session,e,t]})},o.prototype.onSymbolError=function(e,t){this._server.receiveLocalResponse({method:"symbol_error",params:[this._session,e,t]})},o.prototype.onStudyError=function(e,t,i){this._server.receiveLocalResponse({method:"study_error",params:[this._session,e,t,i]})},o.prototype.onSeriesLoading=function(e,t){this._server.receiveLocalResponse({method:"series_loading",params:[this._session,e,t]})},o.prototype.onSeriesCompleted=function(e,t,i){this.beforeSeriesCompleted.fire(e,t),this._server.receiveLocalResponse({method:"series_completed",params:[this._session,e,i,t]})},o.prototype.onSeriesError=function(e,t,i){this._server.receiveLocalResponse({method:"series_error",params:[this._session,e,t,i]}),this.seriesError.fire(e,t)},o.prototype.onStudyCompleted=function(e,t){this._server.receiveLocalResponse({method:"study_completed",params:[this._session,e,t]})},o.prototype.onStudyLoading=function(e,t){this._server.receiveLocalResponse({method:"study_loading",params:[this._session,e,t]})},o.prototype.onTickmarksUpdated=function(e,t){var i={method:"tickmark_update",params:[this._session,{index:e,zoffset:0,changes:[],marks:t,index_diff:[]}]};this._server.receiveLocalResponse(i)},o.prototype.onTimescaleUpdate=function(e,t){var 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}]};this._server.receiveLocalResponse(i)},o.prototype.onTimescaleCompleted=function(e){this._server.receiveLocalResponse({method:"timescale_completed",params:[this._session,e]})},o.prototype.onSeriesTimeframeUpdate=function(e,t,i,s,o,n){var r={method:"series_timeframe",params:[this._session,e,t,i,s,n||null,!0,o]};this._server.receiveLocalResponse(r)},o.prototype.onPointsetDataUpdate=function(e,t,i){this.onDataUpdate(e,t,i,null)},o.prototype._prepareDataUpdateObjects=function(e){var t={};return e.forEach((function(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},o.prototype.onDataUpdate=function(e,t,i,s){var o={method:"data_update",params:[this._session,this._prepareDataUpdateObjects([{objId:e,turnaround:t,data:i,nonSeriesData:s}])]};this._server.receiveLocalResponse(o)},o.prototype.onQuotesData=function(e){this._server.receiveLocalResponse({method:"quote_symbol_data",params:e})},o.prototype.onDepthData=function(e){this._server.receiveLocalResponse({method:"dd",params:e})},o.prototype.onDepthUpdate=function(e){this._server.receiveLocalResponse({method:"dpu",params:e})},o.prototype.onClearData=function(e){this._server.receiveLocalResponse({method:"clear_data",params:[this._session,e]})},TradingView.ChartapiMessagerInstances=[],e.exports=o},9447:(e,t,i)=>{"use strict";i.d(t,{barTimeToEndOfPeriod:()=>o,endOfPeriodToBarTime:()=>n});var s=i(83910);function o(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(s.SessionStage.LASTBAR_SESSION)/1e3}function n(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 t=e.startOfBar(0)/1e3}},9001:(e,t,i)=>{"use strict";var s=i(56570);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)}},2060:(e,t,i)=>{"use strict";var s,o=i(14381),n={};e.exports=function(e,t,i){var r,a,l,c,h={},d=n[i]||"out_of_session",u=!1,_=i,p=t,m=null,g=null;function f(){var e={};e.symbolname=_,e.status="ok",e.values={},e.values.current_session=d,n[_]=d,TradingView.ChartapiMessagerInstances[p].onQuotesData([p].concat([e]))}function y(){if(r)if(c)d="out_of_session";else{var e=(new Date).getTime(),t=o.isTradingNow(e,r)?"market":"out_of_session";a&&o.isTradingNow(e,a)?t="pre_market":l&&o.isTradingNow(e,l)&&(t="post_market"),t!==d&&(d=t)}}return e(i,null,(function(e){u||function(e){r=new o.SessionInfo(e.timezone,e.session_display??e.session,e.session_holidays,e.corrections),c=e.expired,e.subsession_id&&e.subsessions?e.subsessions.forEach((t=>{switch(t.id){case"regular":r=new o.SessionInfo(e.timezone,t["session-display"]??t.session,e.session_holidays,t["session-correction"]||e["session-correction"]||e.corrections);break;case"premarket":a=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":
l=new o.SessionInfo(e.timezone,t["session-display"]??t.session,e.session_holidays,t["session-correction"]||e["session-postmarket-correction"]||e.corrections)}})):(a=void 0,l=void 0);const t=60-new Date(Date.now()).getSeconds();s&&s?.ticker===e.ticker||(s={ticker:e.ticker,timer:t},clearTimeout(s.timeout)),g=setTimeout((()=>{m=setInterval((()=>{y(),f()}),6e4),y(),f()}),1e3*s.timer),s&&void 0!==s?.timeout||(s.timeout=g),y(),f()}(e)}),(function(){})),h.stop=function(){u=!0,m&&clearInterval(m),g&&clearInterval(g)},h.marketStatus=function(){return d},h}},39692:(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})},67153:(e,t,i)=>{"use strict";i.d(t,{findSuitableResolutionToBuildFrom:()=>r});var s=i(85049);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:n(t.value())}}function n(e){return`Misconfiguration error: it is trying to request ${e} but we cannot build it from lower resolution`}function r(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:"Misconfiguration error: it is trying to request a resolution but symbol does not support it"};if(i.isDWM())return{error:!0,errorMessage:n(i.value())};if(i.isMinutes()&&!t.has_intraday)return{error:!0,errorMessage:"Misconfiguration error: it is trying to request intraday resolution but symbol does not support it"};if(i.isSeconds()&&!t.has_seconds)return{error:!0,errorMessage:"Misconfiguration error: it is trying to request seconds resolution but symbol does not support it"};const r=t.seconds_multipliers??["1"],a=0===r.length,l=a||r.every((e=>parseInt(e,10)>i.multiplier())),c=t.build_seconds_from_ticks&&(a||l)&&t["is-tickbars-available"];if(i.isSeconds()&&c)return{error:!1,resolution:"1T"};if(i.isTicks())return t["is-tickbars-available"]?{error:!1,resolution:e}:{error:!0,errorMessage:"unsupported_resolution"};const h=i.isSeconds()?t.seconds_multipliers:t.intraday_multipliers;return void 0===h?{error:!1,resolution:i.value()}:o(h,i)}},23863:(e,t,i)=>{"use strict";const s=i(56570),o=i(19625).getHexColorByName;var n=i(73772).Std;i(42924);var r=i(69146).pivotPointsStandardStudyItem,a=i(24018).volumeProfileVisibleRangeStudyItem,l=i(92245).volumeProfileFixedRangeVbPStudyItem,c=i(92245).volumeProfileFixedRangeBSStudyItem,h=i(68563).spreadStudyItem,d=i(15497).ratioStudyItem,u=i(65498).regressionTrendStudyItem,_=i(46367).anchoredVWAPStudyItem
;const p=o("color-ripe-red-400"),m=o("color-minty-green-400"),g=s.enabled("secondary_series_extend_time_scale");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),n.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),o=n[t(0)](this._context),r=this._context.new_unlimited_var(o);return this._context.select_sym(0),[r.adopt(s,i,0)]}}},{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:"boolean",isHidden:!0}],id:"Overlay@tv-basicstudies-1",format:{type:"price",precision:4},canExtendTimeScale:!0},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(0),n.period(this._context))},this.main=function(e,t){this._context=e;var i=!g||!0!==t(1),s=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var o=this._context.new_unlimited_var(this._context.symbol.time),r=this._context.new_unlimited_var(n.open(this._context)),a=this._context.new_unlimited_var(n.high(this._context)),l=this._context.new_unlimited_var(n.low(this._context)),c=this._context.new_unlimited_var(n.close(this._context));return i?(this._context.select_sym(0),[r.adopt(o,s,1),a.adopt(o,s,1),l.adopt(o,s,1),c.adopt(o,s,1)]):[r.get(0),a.get(0),l.get(0),c.get(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:p,width:1,style:0},1:{
color:m,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),n.period(this._context))},this.f_0=function(e,t){return n.gt(e,t)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=n.volume(this._context),s=n.open(this._context),o=n.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(n.volume(this._context)),_=this._context.new_var(n.open(this._context)),p=this._context.new_var(n.close(this._context));i=u.adopt(d,r,1),s=_.adopt(d,r,1),o=p.adopt(d,r,1),this._context.select_sym(0)}var m=this._context.new_var(i),g=n[h.toLowerCase()](m,c,this._context),f=this._context.new_var(g),y=this._context.new_var(o);return[i,y.get(1)&&this._input(4)?this.f_0(y.get(1),o):this.f_0(s,o),g,n[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),o=i/100,r=Math.ceil(s/2);return[n.zigzag(o,r,this._context),n.zigzagbars(o,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 n.selectSessionBreaks(t,this._times).map(e)},this._getPreAndPostMarketBackgroundsData=function(e){const i=n.selectPreAndPostMarketTimes(e,this._times);return{preMarket:i.preMarket.map(t),postMarket:i.postMarket.map(t)}},this.main=function(e,t){if(n.isdwm(e))return null;var i=n.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 o=this._getVerticalLineData(e),r=this._getPreAndPostMarketBackgroundsData(e);return 0===o.length&&0===r.preMarket.length&&0===r.postMarket?null:{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{vertlines:[{styleId:"sessBreaks",data:o}],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),[o,r]=n.supertrend(s,i,e),a=e.new_var(r).get(1);return[o,-1===r?0:1,-1===r&&a!==r?1:NaN,1===r&&a!==r?1:NaN]}}},{name:"IntradayInactivityGaps",metainfo:{historyCalculationMayChange:!0,_metainfoVersion:52,description:"Intraday Inactivity Gaps",id:"IntradayInactivityGaps@tv-basicstudies-1",is_hidden_study:!0,is_price_study:!0,name:"IntradayInactivityGaps@tv-basicstudies",inputs:[{id:"display_session",name:"Gap Display Session",defval:"session",type:"text",display:0}],palettes:{},plots:[],defaults:{linkedToSeries:!0,inputs:{display_session:"session"}},shortDescription:"Intraday Inactivity Gaps",format:{type:"inherit"},canExtendTimeScale:!0},constructor:function(){this.init=function(e){this._context=e,this._range={from:null,to:null},this._lastRange=null},this.main=function(e,t){if(!n.isintraday(e))return null;const i=t(0);this._context=e;const s=e.symbol,o=n.time(e);return"number"==typeof o&&isFinite(o)&&(null===this._range.from&&(this._range.from=o),this._range.to=o),!s.isLastBar||this._lastRange&&this._lastRange.from===this._range.from&&this._lastRange.to===this._range.to?null:(this._lastRange={...this._range},{nonseries:!0,type:"study_gap",displaySession:i,...this._range})}}},r,a,l,c,h,d,u,_])},73772:(e,t,i)=>{"use strict";i.d(t,{Std:()=>h});var s=i(14381),o=i(2740);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 s=null,n=null,r=e[0],a=(0,o.utc_to_cal)(this._timezone,r);this._isInPreMarketSession(a)&&(n=r),this._isInPostMarketSession(a)&&(s=r);for(let l=1;l<e.length;l++){const c=e[l],h=(0,o.utc_to_cal)(this._timezone,c);null!==s&&this._isInPostMarketSession(a)&&!this._isInPostMarketSession(h)&&(i.push({start:s,stop:r}),s=null),null===n&&this._isInPreMarketSession(h)&&(n=c),null===s&&this._isInPostMarketSession(h)&&(s=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!==s&&i.push({start:s,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(83910),a=i(1452);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,o.YEAR,t),h.month=(e,t)=>h.timepart(e.symbol,o.MONTH,t),h.weekofyear=(e,t)=>h.timepart(e.symbol,o.WEEK_OF_YEAR,t),h.dayofmonth=(e,t)=>h.timepart(e.symbol,o.DAY_OF_MONTH,t),h.dayofweek=(e,t)=>h.timepart(e.symbol,o.DAY_OF_WEEK,t),h.hour=(e,t)=>h.timepart(e.symbol,o.HOUR_OF_DAY,t),h.minute=(e,t)=>h.timepart(e.symbol,o.MINUTE,t),h.second=(e,t)=>h.timepart(e.symbol,o.SECOND,t),h.add_days_considering_dst=(e,t,i)=>(0,o.add_days_considering_dst)((0,o.get_timezone)(e),t,i),h.add_years_considering_dst=(e,t,i)=>(0,o.add_years_considering_dst)((0,o.get_timezone)(e),t,i),h.selectSessionBreaks=(e,t)=>{if(h.isdwm(e)||void 0===e.symbol.session.timezone)return[];const i=(0,s.newBarBuilder)(e.symbol.period,e.symbol.session,null),o=[],n=t.length;if(i.moveTo(t[n-1]),1===n&&i.startOfBar(0)===t[0])o.push(t[0]);else{for(let e=n-2;e>=0;--e){const s=t[e];if(s>=i.startOfBar(0))continue;i.moveTo(s);const n=t[e+1];o.push(n)}o.reverse()}return o},
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 s=(0,o.utc_to_cal)(e.session.timezone,i||e.bartime());return(0,o.get_part)(s,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(),P=_.get(1);2===h.n(s)&&(h.greater(C,P)?(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 T=m+g*(f-m);return 1===o.get()?h.greater(T,u.get())&&(y=!0,o.set(-1),T=Math.max(d.get(),r.get()),r.set(u.get()),n.set(e)):h.less(T,d.get())&&(y=!0,o.set(1),T=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()?(T=Math.min(T,v),h.n(s)>2&&(T=Math.min(T,S))):(T=Math.max(T,b),h.n(s)>2&&(T=Math.max(T,w))),p.set(T),T},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,s.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,s.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())}}},
46367:(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(73772);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()}}}},69146:(e,t,i)=>{"use strict";i.d(t,{pivotPointsStandardStudyItem:()=>_});var s,o,n=i(85049),r=i(67153),a=i(73772);!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 l{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 c{constructor(){this.pivots=[]}}function h(e,t){e.setUTCMonth(e.getUTCMonth()+t)}function d(e,t){if(a.Std.ismonthly(e)){let i=new Date(t);return i.getUTCDay()<function(e,t){return new Date(t,e,0).getDate()}(i.getUTCMonth(),i.getUTCFullYear())?(h(i,a.Std.interval(e)),i=a.Std.add_days_considering_dst("Etc/UTC",i,1-i.getUTCDay())):(i=a.Std.add_days_considering_dst("Etc/UTC",i,1),h(i,a.Std.interval(e))),i.valueOf()}return t+n.Interval.parse(e.symbol.resolution).inMilliseconds(t)}function u(e,t){let i;switch(t){case"Auto":i=function(e){const t=n.Interval.parse(e.interval+e.resolution);switch(t.kind()){case n.ResolutionKind.Weeks:case n.ResolutionKind.Months:return"12M";case n.ResolutionKind.Days:return"1M";case n.ResolutionKind.Minutes:return t.multiplier()>=1&&t.multiplier()<=15?"1D":"1W";case n.ResolutionKind.Seconds:case n.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),l="M"===e.resolution&&("Daily"===t||"Weekly"===t||"Monthly"===t);return(s||o||l||e.info&&(0,r.findSuitableResolutionToBuildFrom)(i,e.info).error)&&a.Std.error("You cannot see this pivot timeframe on this resolution"),i}const _={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._secondaryRes="1D",this._firstMainSeriesBarTime=NaN}init(e,t){this._isValidResolution=!1;const i=t(0),s=t(1),o=t(2),r=t(3);this._data=new c,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=r,this._pivTimeFrame=o;const l=t(4);if(""===l)this._secondaryRes=u(e.symbol,this._pivTimeFrame),e.new_sym(e.symbol.tickerid,this._secondaryRes);else{const t=e.new_sym(l,a.Std.period(e)),i=n.Interval.parse(u(t,o));t.resolution=i.letter(),t.interval=i.multiplier(),t.period=i.value()}this._isValidResolution=!0}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(a.Std.open(e)),o=e.new_var(a.Std.high(e)),n=e.new_var(a.Std.low(e)),r=e.new_var(a.Std.close(e)),c=e.new_var(a.Std.time(e)),h=this._data,u=s.get(0),_=c.get(0),p=s.get(1),m=o.get(1),g=n.get(1),f=r.get(1),y=e.symbol.isLastBar;if(0!==h.pivots.length&&e.symbol.isNewBar){const e=h.pivots[h.pivots.length-1];e.endIndex__t!==_&&(e.endIndex__t=_)}if(0===e.symbol.index||!e.symbol.isNewBar)return e.select_sym(0),null;const v=function(e,t,i,s,o,n,r,c){const h=new l;let d=NaN;const u=i-s;switch(c){case 0:d=(i+s+o)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+(i-s),h.s2=d-(i-s),h.r3=2*d+(i-2*s),h.s3=2*d-(2*i-s),h.r4=3*d+(i-3*s),h.s4=3*d-(3*i-s),h.r5=4*d+(i-4*s),h.s5=4*d-(4*i-s);break
;case 1:d=(i+s+o)/3,h.p=d,h.r1=d+.382*u,h.s1=d-.382*u,h.r2=d+.618*u,h.s2=d-.618*u,h.r3=d+u,h.s3=d-u;break;case 2:d=(i+s+2*e)/4,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+u,h.s2=d-u,h.r3=i+2*(d-s),h.s3=s-2*(i-d),h.r4=h.r3+u,h.s4=h.s3-u;break;case 3:d=(i+s+o)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+u,h.s2=d-u,h.r3=d+2*u,h.s3=d-2*u,h.r4=d+3*u,h.s4=d-3*u;break;case 4:let n=NaN;n=a.Std.equal(t,o)?i+s+2*o:a.Std.greater(o,t)?2*i+s+o:2*s+i+o,d=n/4,h.p=d,h.r1=n/2-s,h.s1=n/2-i;break;case 5:d=(i+s+o)/3,h.p=d,h.r1=o+1.1*u/12,h.s1=o-1.1*u/12,h.r2=o+1.1*u/6,h.s2=o-1.1*u/6,h.r3=o+1.1*u/4,h.s3=o-1.1*u/4,h.r4=o+1.1*u/2,h.s4=o-1.1*u/2;break;case 6:d=(i+s+o)/3,h.p=d,h.r1=2*d-s,h.s1=2*d-i,h.r2=d+(i-s),h.s2=d-(i-s),h.r3=d-h.s1+h.r2,h.s3=2*d-(2*i-s);break;default:throw new Error("Unknown kind")}return h.startIndex__t=n,h.endIndex__t=r,h}(u,p,m,g,f,_,d(e,_),this._kindPP);return e.select_sym(0),this._showHistoricalPivots||(h.pivots=[]),h.pivots.push(v),h.pivots.length>this._historicalPivotsToKeep&&h.pivots.shift(),y?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)}}}},15497:(e,t,i)=>{"use strict";i.d(t,{ratioStudyItem:()=>n});var s=i(62473);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}},65498:(e,t,i)=>{"use strict";i.d(t,{regressionTrendStudyItem:()=>n});var s=i(73772);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}}}},62473:(e,t,i)=>{"use strict";i.d(t,{SpreadRatioBase:()=>l,spreadRatioDefaults:()=>c,spreadRatioFilledAreas:()=>p,spreadRatioInputs:()=>h,spreadRatioPalettes:()=>_,spreadRatioPlots:()=>d,spreadRatioStyles:()=>u});var s=i(19625),o=i(94113),n=i(73772),r=i(19063);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=e.symbol.time,s=n.Std[this._source](e);e.select_sym(1);const o=n.Std[this._source](e),r=e.new_unlimited_var(o),a=e.new_unlimited_var(e.symbol.time);if(e.select_sym(0),isNaN(i))return null;let l=a.indexOf(i);-1!==l&&a.get(l)!==i&&(l=-1);const c=l<0?NaN:r.get(l),h=this._doCalculation(this._scaleFactor1,s,this._scaleFactor2,c);return[h,0,n.Std.ge(h,0),n.Std.lt(h,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}]},68563:(e,t,i)=>{"use strict";i.d(t,{spreadStudyItem:()=>n});var s=i(62473);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}},56209:(e,t,i)=>{"use strict";i.d(t,{VbPCheckHaveVolumeExpr:()=>o});var s=i(73772);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)}}},43789:(e,t,i)=>{"use strict";i.d(t,{VolumeByPriceExpr:()=>g});var s=i(50151),o=i(9859),n=i(85049),r=i(41978);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(61923),d=i(73772);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)}}},7370:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileBase:()=>p,maxHHistItems:()=>u,numOfSubHists:()=>_});var s,o=i(56570),n=i(85049);!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(73772),d=i(39692);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)}}},92245:(e,t,i)=>{"use strict";i.d(t,{volumeProfileFixedRangeBSStudyItem:()=>w,volumeProfileFixedRangeVbPStudyItem:()=>b});var s=i(50151),o=i(7370),n=i(94113),r=i(9233),a=i(85049),l=i(40878),c=i(45382),h=i(32569),d=i(61923),u=i(62628),_=i(56209),p=i(85904),m=i(43789);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(11694),y=i(73772);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})},11694:(e,t,i)=>{"use strict";i.d(t,{VolumeProfileOutputSeries:()=>n});var s=i(50151),o=i(29981);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.")}}},24018:(e,t,i)=>{"use strict";i.d(t,{volumeProfileVisibleRangeStudyItem:()=>y});var s=i(50151),o=i(7370),n=i(9233),r=i(85049),a=i(40878),l=i(43789),c=i(61923);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(45382),u=i(32569),_=i(62628),p=i(56209),m=i(11694),g=i(73772);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"}}}}},1452:(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}}},32569:(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")}}},40878:(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)}}},
61923:(e,t,i)=>{"use strict";i.d(t,{GraphicsList:()=>n});var s=i(41978),o=i(67908);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()}}},41978:(e,t,i)=>{"use strict";i.d(t,{GraphicsObj:()=>l});var s=i(73772);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()}}},67908:(e,t,i)=>{"use strict";function s(e){return Boolean(e.isNaN)}i.d(t,{isNaNable:()=>s})},62628:(e,t,i)=>{"use strict";i.d(t,{JStudyDataUpdate:()=>p});var s=i(32569);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(37265),l=i(67908);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}:{}}}},45382:(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)}}}},42924:(e,t,i)=>{"use strict";const s=i(19625).getHexColorByName,o=i(73772).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:"BB",metainfo:{_metainfoVersion:23,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{plot_0:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:35,visible:!0,color:"#FF0000"},plot_1:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:35,visible:!0,color:"#0000FF"},plot_2:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:35,visible:!0,color:"#0000FF"}},precision:4,filledAreasStyle:{fill_0:{color:"#000080",transparency:90,visible:!0}},inputs:{in_0:20,in_1:2}},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:"in_0",name:"length",defval:20,type:"integer",min:1,max:1e12},{id:"in_1",name:"mult",defval:2,type:"float",min:.001,max:50}],id:"BB@tv-basicstudies-1"},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.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);return[a,this.f_1(a,h),this.f_2(a,h)]}}},{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}},inputs:{in_0:20,in_1:2,symbol:"",offset:0}},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:"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);if(""!==n){this._context.select_sym(1);var c=this._context.new_var(o.time(this._context));s=this._context.new_var(o.close(this._context)).adopt(c,i,1),this._context.select_sym(0)}var h=this._context.new_var(s),d=o.sma(h,r,this._context),u=this._context.new_var(s),_=o.stdev(u,r,this._context),p=this.f_0(a,_);return[{value:d,offset:l},{value:this.f_1(d,p),offset:l},{value:this.f_2(d,p),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:"sym",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.round(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),P=o.sma(C,w,this._context),T=n,x=this._context.new_var(u),I=o.roc(x,T),M=c,A=this._context.new_var(I),L=o.sma(A,M,this._context),k=r,D=this._context.new_var(u),E=o.roc(D,k),B=h,V=this._context.new_var(E),R=o.sma(V,B,this._context),N=this.f_0(y,P,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(2)?(a=o.ema(c,this._input(1),this._context),l=o.ema(c,this._input(2),this._context)):"Weighted"===this._input(2)?(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)},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)),o.na(r.get(0))?(e.symbol.isLastBar&&o.error("To calculate the VWAP indicator, more data is needed. Zoom out or scroll left to load more historical data.","VWAP is waiting for more data"),[NaN]):[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"}]}}}}}}]},91007:(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={}))},84954:(e,t,i)=>{"use strict";i.d(t,{JSStudyEngineTypescript:()=>Ve});var s,o=i(56570),n=i(63193),r=i(56052),a=i(82433),l=i(83873),c=i(88987),h=i(39692),d=i(50151),u=i(85049),_=i(29981),p=i(14381),m=i(53388),g=i(17326);i(21251);class f{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 y(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="_#_"}(s||(s={})),function(e){e[e.MaxEmptyResponsesInARow=50]="MaxEmptyResponsesInARow",e[e.ResetCacheTimePeriod=1e4]="ResetCacheTimePeriod"}(s||(s={}));class S{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=u.Interval.parse(i),this._resolution=this._interval.value(),this._dwmAligner=o,this._serverTimeOffsetGetter=s,this._resetCacheTimePeriod=void 0===n?1e4:n,this._sessionSpec=new g.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}),u.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=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||o.enabled("request_only_visible_range_on_reset")||this._ensureRequestedTo({to:e,countBack:0})}_logMessage(e,t){(o.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,d.ensureNotNull)(this._leftDate))return{countBack:e.countBack,to:t};const i=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(t):t,s=(0,_.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)}))}),y(this._symbolInfo,this._resolution),this.resetCache.bind(this)),this._logMessage("Subscribed to realtime")}_unsubscribeRealtime(){!this._isSymbolExpired()&&this._realtimeOn&&(this._datafeed.unsubscribeBars(y(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,_.lowerbound)(this._cache.bars,t,((e,t)=>e.time<t)),s=new f(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,d.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,p.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,p.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._logMessage("EOD received"),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._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._logWarning("noData should be set when there is no data in the requested period and earlier only")}_getNextSubscriptionId(){return this._nextSubscriptionId++}_checkBars(e,t=!1){if(o.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 b{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=y(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 S(this._datafeed,e,t,this._serverTimeOffsetGetter,(0,m.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 w{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 C=i(73698),P=i(2740),T=i(42217),x=i(91007),I=i(50335);const M=o.enabled("align_dwm_bars_to_main_series");class A{constructor(e,t,i,s,o,n,r){this.periodBase="";const a=(0,C.decodeExtendedSymbol)(e),l="string"==typeof a.symbol?a:a.symbol;if((0,C.isStudySymbol)(l))throw new Error(`Unexpected nested study symbol: ${e}`);const c="string"==typeof a.symbol?a.symbol:a.symbol.symbol;this.ticker=c,this.currencyCode=i||l["currency-id"],this.unitId=s||l["unit-id"],this.subsessionId=r||l.session;const h=l["currency-id"]!==this.currencyCode||l["unit-id"]!==this.unitId;l["currency-id"]=this.currencyCode,l["unit-id"]=this.unitId,h&&(e=(0,C.encodeExtendedSymbolOrGetSimpleSymbolString)(a)),this.tickerid=e;const d=u.Interval.parse(t);this.resolution=d.letter(),this.interval=d.multiplier(),this.period=d.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 T.SessionInfo("Etc/UTC","24x7"),this.regularSubsession=null,this.preMarketSubsession=null,this.postMarketSubsession=null,this.script=o,this.projectionTime=NaN,this.isAdditionalDepthAllowed=!(0,C.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,P.get_timezone)(e.timezone),
this.session.init(e.timezone,e.session,e.session_holidays,e.corrections),void 0!==e.subsessions){const t=e.subsessions.find((e=>e.id===x.SubsessionId.Regular)),i=e.subsessions.find((e=>e.id===x.SubsessionId.PreMarket)),s=e.subsessions.find((e=>e.id===x.SubsessionId.PostMarket));void 0!==t&&(this.regularSubsession=new g.SessionsSpec(e.timezone,t.session,e.session_holidays,t["session-correction"])),void 0!==i&&(this.preMarketSubsession=new g.SessionsSpec(e.timezone,i.session,e.session_holidays,i["session-correction"])),void 0!==s&&(this.postMarketSubsession=new g.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,p.newBarBuilder)(this.period,e,t)}bartime(){const e=this.time;if(!this.isdwm()||isNaN(e))return e;const t=(0,d.ensureDefined)(this.timezone,"symbol instrument timezone");let i=(0,P.utc_to_cal)(t,e);return i=this.session.spec.correctTradingDay(i),(0,P.cal_to_utc)(t,i)}lastbar(e){if(isNaN(e.time))return;let t=e.time;if(this.dwm_aligner){const e=(0,P.get_cal_from_unix_timestamp_ms)(this.dwm_aligner.sessionSrc().timezone,t);(!M||this.dwm_aligner.sessionTgt().spec.includesDay(e))&&(this.dwm_aligner.moveTo(t),t=this.dwm_aligner.startOfBar(0))}const i=this.time!==t;i&&this.index>=0&&!this.isBarClosed&&(this.isNewBar=!1,this.isBarClosed=!0,this.script.calc(this)),this.time=t,this.open=e.open,this.high=e.high,this.low=e.low,this.close=e.close,this.volume=(0,I.isNumber)(e.volume)&&e.volume>=0?e.volume:NaN,this.updatetime=e.updatetime||NaN,this.isNewBar=i,this.isBarClosed=!!e.isBarClosed,this.isLastBar=!!e.isLastBar,this.projectionTime=e.projectionTime||NaN,this.isNewBar&&(this.index++,this.isFirstBar=0===this.index),this.script.calc(this)}}var L=i(73772);class k{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=L.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=L.Std.na(this.mindepth)?L.Std.max_series_default_size:L.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(){this._hist=null,this.add_hist()}adopt(e,t,i){this._hist||(this.mindepth=NaN);const s=t.get();let o=e.indexOf(s);if(0!==i){const i=t.get(1);if(!L.Std.na(i)){o=o===e.indexOf(i)?-1:o}}return o<0?NaN:this._get(o)}indexOf(e){
if(!this._hist)return this.mindepth=NaN,-1;if(L.Std.na(e))return-1;const t=this._hist.length,i=this.symbol.index+1,s=Math.min(t,i),o=(0,_.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 D extends k{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 E{constructor(e){this.minimumAdditionalDepth=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)}select_sym(e){const t=this.symbol.script.get_sym(e);null==t&&L.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 k(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 D(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 E(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}}function B(e){return!Array.isArray(e)&&"composite"!==e.type&&"non_series_bars"!==e.type&&!!e.nonseries}class V{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 E(this.add_sym(e,t,i,s,c,h)),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}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)||B(e))&&(B(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)})))}}var R=i(1452);class N{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 A(e,t,i,s,o,n,r);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 V(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,o=Object.assign({},e.dataRange,{countBack:e.dataRange.countBack??0+this._script.maxAdditionalDepth()}),n=s[0],r=(t,s,o)=>{i.push(N.feed.subscribe(t.tickerid,t.currencyCode,t.unitId,t.period,o,e.onErrorCallback,e.symbolInfo,e.sessionId,s,e.forceAlignBars,t.subsessionId))},a=(t,i)=>{"series"===(i.nonseries?"nonseries":"series")?this.update(t,i):i.lastBar?(this._nonseriesUpdate=i,i.lastBar.isLastBar=!0,this._symbols[0].lastbar(i.lastBar),this._nonseriesUpdate=null):e.nonseriesOut(s[0],i)},l=()=>o;r(n,l,(e=>{!e.nonseries&&Number.isFinite(e.firstLoadedTimeMs)&&(e=>{function i(i,s){let o=(0,m.createTimeToBarTimeAligner)(i,s)(e);const n=(0,m.createDwmAligner)(i,s);return null!==n&&(o=n.timeToExchangeTradingDay(o)),{to:o,countBack:(0,d.ensureNotNull)(t,"script runner script").maxAdditionalDepth()}}for(let e=1;e<s.length;e++){const t=s[e],o=t.period;u.Interval.isEqual(o,n.period)||r(t,i.bind(null,o),a.bind(null,e))}})(e.firstLoadedTimeMs),a(0,e)}));for(let e=1;e<s.length;e++){const t=s[e];u.Interval.isEqual(t.period,n.period)&&r(t,l,a.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++)N.feed.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)}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 R.StudyError))throw e;this.host.onErrorCallback(e.message,e.title)}}}N.feed={subscribe(){throw console.error("must be initialized with setupFeed"),new Error("must be initialized with setupFeed")},unsubscribe(){throw console.error("must be initialized with setupFeed"),new Error("must be initialized with setupFeed")}};class O{constructor(e){this.runner=new N(e)}stop(){this.runner.stop()}isStarted(){return this.runner.isStarted}}class F{constructor(e,t,i,s,o,n,r,a,l,c){this.listeners=e,this._isRecalculated=!1,this._symbolInfo=r,this.engine=new O({tickerid:t,currencyCode:i,unitId:s,subsessionId:c,period:o,body:n,sessionId:l,symbolInfo:r,dataRange:a,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 f(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 f((0,d.ensureDefined)(e.info,"bar builder item output symbol info")));const n=t[8],r=t[9];if(n instanceof Array&&r)for(let e=0;e<n.length;e++){const t=n[e],i={time:t,open:r,high:r,low:r,close:r,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 W{main(e){const t=e.new_var(L.Std.open(e)),i=e.new_var(L.Std.close(e)),s=t.get(1),o=i.get(1),n=L.Std.ohlc4(e),r=L.Std.na(t.get(1))?(L.Std.open(e)+L.Std.close(e))/2:(s+o)/2;t.set(r),i.set(n);const a=L.Std.max(L.Std.high(e),L.Std.max(r,n)),l=L.Std.min(L.Std.low(e),L.Std.min(r,n)),c=L.Std.volume(e),h=e.symbol;return[h.time,r,a,l,n,c,h.updatetime,h.isBarClosed,void 0,void 0]}}var H=i(67153);class z{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 U=i(40644);class G{constructor(e,t){this._period=e,this._generateEmptyBars=!!t}init(e){this._bb=(0,p.newBarBuilder)(this._period,e.symbol.session,null),this._bbEmptyBars=this._generateEmptyBars?(0,p.newBarBuilder)(this._period,e.symbol.session,null):void 0,e.setMinimumAdditionalDepth(0)}main(e){const t=(0,d.ensureDefined)(this._bb,"bar builder study bar builder"),i=e.symbol.time,s=t.alignTime(i),o=e.new_var(s),n=L.Std.na(s),r=o.get(1),a=L.Std.na(r)?1:L.Std.neq(s,r),l=e.new_var(),c=e.new_var(),h=e.new_var(),u=e.new_var(),_=l.get(1),p=c.get(1),m=h.get(1),g=u.get(1),f=n?NaN:a?L.Std.open(e):_,y=n?NaN:a?L.Std.high(e):L.Std.max(L.Std.high(e),p),v=n?NaN:a?L.Std.low(e):L.Std.min(L.Std.low(e),m),S=n?NaN:L.Std.close(e),b=n?NaN:a?L.Std.volume(e):L.Std.volume(e)+g,w=n?NaN:i,C=e.symbol.isBarClosed&&t.isLastBar(0,i),P=this._generateEmptyBars&&a?this._extrapolate(r,s):void 0,T=e.new_var(L.Std.close(e)).get(1),x=P instanceof Array?T:NaN;return l.set(f),c.set(y),h.set(v),u.set(b),[s,f,y,v,S,b,w,C,P,x]}_extrapolate(e,t){return isNaN(e)||isNaN(t)?void 0:(0,U.extrapolateBarsFrontToTime)((0,d.ensureDefined)(this._bbEmptyBars,"bar builder study empty bar builder"),e,t,Number.MAX_SAFE_INTEGER,!0).times}}const j=e=>{var t;Y.instance=new Y(e),t=Y.instance,N.feed=t},q=()=>{Y.instance.removeUnused()},$=e=>{console.error(e),L.Std.error(e)},K=u.Interval.parse("1M").inMilliseconds(0);class Y{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,d.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,d.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,H.findSuitableResolutionToBuildFrom)(e,t);if(i.error)throw $(i.errorMessage),new Error(i.errorMessage);return i.resolution}_createItem(e,t,i,s,o,n,r,a,l){const c=new w,h=(0,C.decodeExtendedSymbol)(e),d="string"!=typeof h.symbol?h.symbol:h;t=d["currency-id"]||t,i=d["unit-id"]||i;const _=d.symbol,p=d.session&&d.session!==x.SubsessionId.Extended;if((l=d.session||l)===x.SubsessionId.Regular&&(l=void 0),"type"in h){const e=Object.assign({},o);return o.has_empty_bars&&(e.has_empty_bars=!1),new F(c,_,t,i,s,function(e){if(0===e.type.indexOf("BarSetHeikenAshi@tv-basicstudies-"))return new W;const t=`unknown builder type: ${e.type}`;throw console.error(t),new Error(t)}(h),e,n,r,l)}a&&!(0,
m.isAlignmentEnabled)()&&$("Internal error: rebuilding is requested but it is disabled."),!a&&o.has_empty_bars&&$('Misconfiguration error: attempt to request data for symbol with "has_empty_bars" flag, but "disable_resolution_rebuild" featureset is enabled');const g=this._rebuildFrom(s,o);if(!u.Interval.isTicks(s)&&(!u.Interval.isEqual(s,g)||a)){(0,m.isAlignmentEnabled)()||$('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((f=u.Interval.parse(s),y=u.Interval.parse(g),f.kind()===y.kind()?f.multiplier()/y.multiplier():(f.isMonths()?f.multiplier()*K:f.inMilliseconds())/(y.isMonths()?y.multiplier()*K:y.inMilliseconds())));return n=Object.assign({},n,{countBack:n.countBack*d}),new F(c,e,t,i,g,new G(s,a),h,n,r,l)}var f,y;return new z(c,_,{currency:t,unit:i,session:l},s,!!p,this._host,o,n)}}var Z=i(37265);function X(e,t,i){return(0,Z.isArray)(e)?function(e,t,i){return e.map((e=>{const s=X(e,t,i),o=t(s);return void 0!==o?o:s}))}(e,t,i):(0,Z.isObject)(e)&&((0,Z.isHashObject)(e)||i&&i.visitInstances)?function(e,t,i){const s={};return Object.keys(e).forEach((o=>{const n=X(e[o],t,i),r=t(n);s[o]=void 0!==r?r:n})),s}(e,t,i):e}function J(e,t,i){const s=X(e,t,i),o=t(s);return void 0!==o?o:s}var Q=i(97085),ee=i(68805);var te,ie=i(63950);function se(e,t){return e.length>t}!function(e){e[e.DefaultExtrapolateLimit=2e5]="DefaultExtrapolateLimit"}(te||(te={}));class oe{constructor(e,t,i=2e5){this._firstRealBarTimeMs=null,this._historyBarsCache=[],this._projectionFirstIndex=1/0,this._barsTimes=[],this._minFutureBarsCount=0,this._lastRealBarTimeMs=null,this._futureBarsCache=[],this._symbolInfo=e,this._interval=u.Interval.parse(t),this._extrapolateLimit=i,this._session=new p.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),this._barBuilder=(0,p.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,_.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,d.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,_.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,_.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,d.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,_.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||se(this._futureBarsCache,this._extrapolateLimit)||0!==this._futureBarsCache.length&&this._futureBarsCache[this._futureBarsCache.length-1]>=e||(o.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,
U.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,_.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,d.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,d.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,U.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,d.assert)(0===this._barsTimes.length,"bars should be empty"),this._firstRealBarTimeMs=e,0===this._historyBarsCache.length)return;const t=(0,U.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||se(this._futureBarsCache,this._extrapolateLimit))&&(o.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,U.extrapolateBarsFrontByCount)(this._barBuilder,t,e-i,!0).times)))}_ensureExtrapolatedToHistoryBar(e){this._historyBarsCache.length>=e||se(this._historyBarsCache,this._extrapolateLimit)||this._extendHistoryCacheFromLeft(((t,i)=>(0,U.extrapolateBarsFrontByCount)(this._barBuilder,t,-(e-i),!0).times.reverse()))}_ensureExtrapolatedToHistoryTime(e){null!==this._firstRealBarTimeMs&&this._firstRealBarTimeMs<=e||se(this._historyBarsCache,this._extrapolateLimit)||0!==this._historyBarsCache.length&&this._historyBarsCache[0]<=e||(this._extendHistoryCacheFromLeft(((t,i)=>{const s=(0,U.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))}}var ne=i(2060),re=i.n(ne),ae=i(76422),le=i(50503),ce=i(9447);function he(e){return 60*e*60*1e3}function de(e){return 60*e*1e3}const ue=[{divisor:1,weight:18},{divisor:(_e=1,1e3*_e),weight:19},{divisor:de(1),weight:20},{divisor:de(5),weight:21},{divisor:de(30),weight:22},{divisor:he(1),weight:30},{divisor:he(3),weight:31},{divisor:he(6),weight:32},{divisor:he(12),weight:33}];var _e,pe;function me(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=ue.length-1;e>=0;--e)if(Math.floor(i/ue[e].divisor)!==Math.floor(s/ue[e].divisor))return ue[e].weight}return 18}function ge(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:le.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:le.INVALID_TIME_POINT_INDEX}),s++):o++;return n.sort(((e,t)=>{if(e.new===t.new&&e.new===le.INVALID_TIME_POINT_INDEX)return e.old-t.old;if(e.new===le.INVALID_TIME_POINT_INDEX)return-1;if(t.new===le.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 fe(e,t){return{
span:e.markWeight,time:e.displayTime,index:t}}!function(e){e[e.FutureTickMarksLimit=1e3]="FutureTickMarksLimit"}(pe||(pe={}));const ye=o.enabled("end_of_period_timescale_marks"),ve=o.enabled("align_dwm_bars_to_main_series");class Se{constructor(){this._completed=!0,this._mainSymbolExtrapolator=null,this._pointDataByTimePoint=new Map,this._instanceIds=new Set,this._displayTimezone=null,this._minFutureBarsCount=0,this._sortedTimePoints=[]}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,_.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,d.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(fe(this._sortedTimePoints[t],t));const o=i.map(((e,i)=>fe(e,i+t)));return s.concat(o)}setTimezone(e){this._displayTimezone="exchange"===e?null:(0,P.get_timezone)(e),this._fillPointsData(this._sortedTimePoints,0)}fillIndexesInRows(e){if(0===e.length)return;let t=-1,i=(0,_.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,d.assert)(i!==t,"data must have unique times"),t=i,s.index=i}(0,d.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,_.lowerbound)(this._sortedTimePoints,e[0],((e,t)=>e.timeMs<t));return e.map(((e,o,n)=>{for(;s<this._sortedTimePoints.length&&this._sortedTimePoints[s].timeMs<e;)s+=1;if(0===s&&e<this._sortedTimePoints[0].timeMs)return le.INVALID_TIME_POINT_INDEX;if(s>=this._sortedTimePoints.length){const t=this.indexOfTime(e);if(null===t)return le.INVALID_TIME_POINT_INDEX;s=t.timeMs!==e?t.index+1:t.index}return(!t||o>0&&e<=n[o-1])&&(0,d.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,_.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,_.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=be(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=ge(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,_.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=be(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=ge(this._sortedTimePoints.slice(t),e).map((e=>({old:e.old+t,new:e.new===le.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=me(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=me(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,P.get_timezone)(o.timezone):this._displayTimezone,r=1===this._instanceIds.size,a=i.isDWM(),l=a?(0,m.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;ye&&(t=(0,ce.barTimeToEndOfPeriod)(s,t,i)),null===l||ve||(t=Math.floor(l.timeToExchangeTradingDay(1e3*t)/1e3)),c&&(t=Math.floor((0,P.utc_to_cal_ts)(n,1e3*t)/1e3)),e[o].displayTime=t}}}function be(e,t,i){return-1===e&&t!==i&&(e=i<t?Math.max(0,i-1):t),e}const we=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]]]),Ce=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 Pe{main(e){return[L.Std.open(e),L.Std.high(e),L.Std.low(e),L.Std.close(e),L.Std.volume(e),L.Std.updatetime(e),void 0,void 0,void 0,void 0]}}const Te=(0,i(9343).getLogger)("ChartApi.PointsetsManager");class xe{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)){Te.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(u.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(u.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 Te.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}}var Ie=i(68159);const Me={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},Ae=-5e6,Le=()=>(0,d.ensure)(window.TradingView),ke=()=>(0,d.ensure)(window.JSServer.studyLibrary),De="pre_post_market_sessions",Ee=o.enabled(De),Be=o.enabled("pay_attention_to_ticker_not_symbol");class Ve{constructor(e){this._studiesCache={},this._objectsDataCache={},this._studiesNonSeriesTimes={},this._metainfoCache=[],this._barsCoefficientsCache={},this._externalDatafeed=e,(0,c.default)(e.getVolumeProfileResolutionForPeriod)&&(0,h.overwriteVolumeProfileResolutionForPeriodGetter)(((t,i,s,o)=>(0,d.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=this._adoptConfigurationData(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 b(e,this.serverTimeOffset.bind(this),this._datafeedConfiguration.reset_cache_timeout);const t=(e,t,i)=>{const s=new p.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),o=(0,p.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)}};j({resolve:(e,t,i,s)=>{this._resolveSymbolByName(e,t,(e=>i(qe(e))),s)},subscribe:(e,i,s,o,n)=>this._cachedDatafeed.subscribe(e,i,s,t(e,i,o),(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&&Le().ChartapiMessagerInstances[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(qe(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,n){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,d.ensure)(e.full_name),n,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString())),this._externalDatafeed.getMarks(qe(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,d.ensure)(e.full_name),n,JSON.stringify(i)));const a=(0,m.createDwmAligner)(n,e),c=o.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,l.default)(e.color)?r[e.color]:r.red,t.onClicked=()=>{ae.emit("onMarkClick",e.id)},t.label=e.label?c?e.label.slice(0,2):e.label[0]:"",t}));s(h)}),n))}
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,d.ensure)(e.full_name),o,new Date(1e3*t).toUTCString(),new Date(1e3*i).toUTCString())),this._externalDatafeed.getTimescaleMarks(qe(e),t,i,(t=>{this._logMessage("Received timescale marks: symbol {0}, resolution {1}, marks {2}".format((0,d.ensure)(e.full_name),o,JSON.stringify(t)));const i=(0,m.createDwmAligner)(o,e),n=t.map((e=>{const t=e;return t.tickmark=null!==i?i.timeToSessionStart(1e3*e.time)/1e3:e.time,t}));s(n)}),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,n){const r=this._mainSeriesRecord(e);if(null===r||r.guid!==t){if(null!==r&&r.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,d.ensure)(s.inputs))}}}else this._modifyMainSeries(e,i,s,o,n)}createStudy(e,t,i,s,o,n){const r=this._studiesCache[e][i],a=this._findStudyObject(o);if(null===a)return He("Study does not exist: "+o),void Le().ChartapiMessagerInstances[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(),q()),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,d.ensure)(this._mainSeriesRecord(e));if(u.Interval.isDWM(i.resolution)&&null!=i.symbolInfo){const e=(0,m.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,d.ensure)(this._mainSeriesRecord(e));if(u.Interval.isDWM(s.resolution)&&null!=s.symbolInfo){const e=(0,m.createDwmAligner)(s.resolution,s.symbolInfo);null!==e&&(i=e.timeToExchangeTradingDay(i))}const o=(0,d.ensure)(this._symbolIdToSymbolRequestString.get(Ne(e,s.symbolId))),n=this._barsCoefficients(o,s.resolution),r=n.barsCoefficient||1;if(!n.barsCoefficient){const i=this._getSeriesData(e,s.guid);null!==i&&(n.expectedBarsCount=i.length+t)}setTimeout((()=>{this._recreateSourcesForDataRange(e,{to:i,countBack:(t+2)*r})}),0)}seriesTurnaround(e,t){return this._studiesCache[e]&&this._studiesCache[e][t]&&this._studiesCache[e][t].turnaround}createSeries(e,t,i,s,n,r,a){this._setEndOfData(e,t,i,!1);const l=new Pe;this._studiesCache[e]=this._studiesCache[e]||{};const c=this._getSeriesData(e,t),h=this._studiesCache[e][t],_=this._seriesCount(e),p=this._mainSeriesRecord(e),m=function(e){let{dataRange:t}=e;const{oldStudyRecord:i,resolution:s,symbolId:o,seriesCount:n,oldData:r,mainSeriesRecord:a,timeScales:l,session:c}=e;if(!i||u.Interval.isEqual(i.resolution,s)&&i.symbolId===o)void 0!==t.countBack&&null!==r&&0!==r.length&&(t.to=r[0].timeMs),i&&null!=i.firstLoadedTimeMs?t.to=void 0!==t.to?Math.min(i.firstLoadedTimeMs,t.to):i.firstLoadedTimeMs:i||0===n||null!==a&&(null!=a.firstLoadedTimeMs?(t.to=a.firstLoadedTimeMs,t.countBack=0):t=Object.assign({},a.dataRange));else if(1===n)t=Object.assign({},i.initialDatarange);else{const e=l[c].firstSeriesBarTime();(void 0===t.to||null!==e&&e<t.to)&&(t.to=(0,d.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:h,resolution:n,symbolId:s,seriesCount:_,oldData:c,mainSeriesRecord:p,timeScales:this._timeScales,session:e});if(this._studiesCache[e][t]={symbolId:s,resolution:n,studyObject:l,guid:t,type:"series",turnaround:i,dataRange:m,initialDatarange:h&&h.initialDatarange||Object.assign({},m),firstLoadedTimeMs:null,symbolInfo:null,isMain:h&&h.isMain||0===_,completed:!1},null!==p&&p.guid!==t&&p.error)return;this._updateMainTsBuilder(e),this._updateTimeScaleState(e),Le().ChartapiMessagerInstances[e].onSeriesLoading(t,i);const g=(s,o,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,n):null;if(void 0!==o){const i=o.map((e=>e.timeMs)).concat(a);null!==h&&h.replaceBarsTimesTail(i,o.length),c=this._timeScales[e].replaceBarsTimesTail(t,i),l=o}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;Le().ChartapiMessagerInstances[e].onDataUpdate(t,i,l,d)},f=s=>{const n=this._studiesCache[e][t];n.completed=!0,Le().ChartapiMessagerInstances[e].onSeriesError(t,i,s),o.enabled("clear_bars_on_series_error")&&(n.isMain?this.onSessionSeriesError(e):this._clearSeriesData(e,t))};this._computeStudy(e,l,s,n,t,[],m,Oe(e,t),(function(){return-1/0}),{onDataReadyCallback:(o,r,l,c)=>{const h=this._studiesCache[e][t];if(!h)throw Error("This should never happen");if(h.symbolInfo=l,h.firstLoadedTimeMs=c.firstLoadedTimeMs,h.completed=!0,this._updateMainTsBuilder(e),a&&this._pointsetsManagers[e].invalidatePointsetsForSymbol(l.full_name,n),0!==o.length){const i=(0,d.ensure)(this._symbolIdToSymbolRequestString.get(Ne(e,s))),r=this._barsCoefficients(i,n);r.expectedBarsCount&&r.barsCount&&(r.barsCoefficient=Math.min(Math.max(r.barsCoefficient||1,Math.floor(r.expectedBarsCount/(o.length-r.barsCount)+.5)),100)),r.barsCount=o.length,this._clearSeriesData(e,t)}else!c.endOfData&&h.isMain&&setTimeout((()=>{this._studiesCache[e]&&this._recreateSourcesForDataRange(e,{countBack:10})}),0);g(l),c.endOfData&&(this._logMessage("Series has no more data on server: {0}".format(l.full_name)),this._setEndOfData(e,t,i)),0===o.length&&this._clearSeriesData(e,t),Le().ChartapiMessagerInstances[e].onSeriesCompleted(t,i,l.data_status),this._updateTimeScaleState(e)},onRealtimeCallback:(s,o,r,a,l)=>{g(l,s),this._timeScales[e].fillIndexesInRows(s);const c=s[s.length-1];if(o){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,n,JSON.stringify(c)))}else this._logMessage("Last bar update: symbol {0}, resolution {1}, bar {2}".format(l.full_name,n,JSON.stringify(c))),Le().ChartapiMessagerInstances[e].onDataUpdate(t,i,s,null);this._fireEvent("realtime_tick",s[s.length-1],!0)},onSymbolErrorCallback:e=>{this._logMessage("Series symbol resolve error: "+e),f(e||"resolve error")},onErrorCallback:e=>{this._logMessage("Series error: "+e),f(e)},onNonSeriesDataUpdate:(s,o)=>{if("projection"!==s.type)throw new Error("unexpected non-series data type for series "+s.type);const n=this._getSeriesData(e,t);if(null!==n)g((0,d.ensure)(o.info),0===n.length?void 0:[n[n.length-1]],s);else{const o=this._prepareSeriesNonSeriesData(e,t,s);Le().ChartapiMessagerInstances[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(),q()),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);Le().ChartapiMessagerInstances[e].onTickmarksUpdated(s,o)}chartCreateSession(e){this._pointsetsManagers[e]=new xe,this._timeScales[e]=new Se,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(Ne(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=setTimeout((()=>{this._refreshPointsetsTimerId=null,this._refreshPointsets(this._invalidatedPointsetSessions),this._invalidatedPointsetSessions.clear()}),0)),this._invalidatedPointsetSessions.add(e)}studiesMetadata(){return 0===this._metainfoCache.length&&(this._metainfoCache=ke().map((e=>new Ie.StudyMetaInfo(e.metainfo))),this._metainfoCache.push(new Ie.StudyMetaInfo(Me))),this._metainfoCache}searchSymbols(e,t,i,s,o){this._logMessage("Symbol search requested: search string `{0}`, exchange: `{1}`, type `{2}`".format(e,t,i));this._externalDatafeed.searchSymbols(e,t,i,(e=>{this._logMessage("Symbol search response: {0}".format(JSON.stringify(e))),e.forEach((e=>{je(e.logo_urls,e.exchange_logo,e)})),s(e)}),o)}resolveSymbol(e,t,i){this._symbolIdToSymbolRequestString.set(Ne(e,t),i),this._resolvePromisesBySymbolId.set(Ne(e,t),new Promise(((s,o)=>{this._resolveSymbolImpl(i,(o=>{Le().ChartapiMessagerInstances[e].onSymbolResolved(t,o),s({symbolInfo:o,requestedSymbol:i})}),(i=>{Le().ChartapiMessagerInstances[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)});this._externalDatafeed.subscribeDepth&&(this._depthInfo[e].listenerGUID=this._externalDatafeed.subscribeDepth(t,(t=>{var i;this._depthInfo[e]&&((i=t).snapshot?Le().ChartapiMessagerInstances[e].onDepthData([e,s(i)]):Le().ChartapiMessagerInstances[e].onDepthUpdate([e,s(i)]))})))}_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}};je(i.logo_urls,i.exchange_logo,n.values),(o&&s?t.v.cs:void 0)&&o.stop(),Le().ChartapiMessagerInstances[e].onQuotesData([e,n])},n=r=>{r.forEach((a=>{const l=a.n;if(i[l]?.size>0){const t=[...i[l]].map((e=>({...a,n:e})));if(o.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 ${l} ${t}: ${JSON.stringify(r)}`)}setTimeout((()=>n(t)),0)}if(void 0!==t[a.n]&&null!==t[a.n])s(a,t[a.n]);else if(o.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 ${l} ${t}: ${JSON.stringify(r)}`)}}))},r=async e=>{try{const[s,o]=ze(e),n=await new Promise(((e,t)=>{this._resolveSymbolByName(s,o,e,t)})),r=(0,d.ensure)(n.ticker);return t[r]=t[e]=qe(n),r===e?r:(void 0===i[r]&&(i[r]=new Set),r!==e&&i[r].add(e),r)}catch{return null}},a=async e=>[...new Set((await Promise.all([...new Set(e)].map(r))).filter((e=>null!==e)))];if(this._externalDatafeed.getQuotes&&!o.enabled("charting_library")){const[t,i]=await Promise.all([a(this._quotesInfo[e].symbols),a(this._quotesInfo[e].fastSymbols)]),s={};if(o.enabled("charting_library_debug_mode")){const e=Ve.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]=setTimeout((()=>{this._logMessage(`QUOTES Timeout after waiting ${t/1e3} seconds for data symbol ${i} with request ID ${e}`)}),t)}}this._externalDatafeed.getQuotes(t,(r=>{
if(o.enabled("charting_library_debug_mode"))for(const e of r)void 0!==s[e.n]&&clearTimeout(s[e.n]),delete s[e.n];this._quotesInfo[e]&&0!==this._quotesInfo[e].symbols.length&&(n(r),this._quotesInfo[e].listenerGUID=e,o.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,n,this._quotesInfo[e].listenerGUID))}),(e=>{this._logMessage(`QUOTES Error getting data for symbols ${JSON.stringify(t)}: ${e}`)}))}else!this._externalDatafeed.getQuotes&&o.enabled("trading_terminal")&&setTimeout((()=>{n(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]=ze(s);this._marketStatusWatchers[e][s]=new(re())(((o,n,r,a)=>this._resolveSymbolByName(t,i,r,(o=>{He(`Error resolving for market status watcher ${We(t,i.currency,i.unit,i.session)}:\n${o}`),this.quoteRemoveSymbols(e,[s]),a(o)}))),e,s)}}}_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)=>{Le().ChartapiMessagerInstances[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,d.ensure)(o.parentId)];o.dataRange=t,this._createStudy(i.symbolId,i.resolution,o.studyObject,e,s,o.turnaround,(0,d.ensure)(o.parentId),(0,d.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)&&Le().ChartapiMessagerInstances[e].onSeriesCompleted(t,i.turnaround,(0,d.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,
d.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}))}Le().ChartapiMessagerInstances[e].onClearData(i)}_prepareSeriesNonSeriesData(e,t,i){const s=i.data[i.data.length-1],o=this._getSeriesData(e,t),n=null===o?[]:i.data;return{data:{data:{reversalAmount:i.reversalAmount,boxSize:i.boxSize,price:s?s[4]:i.price,bars:n.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(n.map((e=>{const t=e[0]||0;return t<0?(0,d.ensure)(o)[(0,d.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,r){this.stopSources(e);const a=this._mainSeriesRecord(e);let l=!1;for(const c of this._getStudiesCacheSessionKeys(e)){const h=this._studiesCache[e][c];if(h&&"series"===h.type)if((0,n.default)(a)||h.guid!==a.guid)this.createSeries(e,h.guid,h.turnaround,h.symbolId,i,{countBack:0},!0);else{l=a.symbolId!==t||a.resolution!==i;const n=Ge(r),c={countBack:n||0};o.enabled("request_only_visible_range_on_reset")&&n&&(delete this._objectsDataCache[Oe(e,a.guid)],delete this._studiesCache[e][a.guid]),this.createSeries(e,a.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,d.ensure)(i.parentId)];this._createStudy(s.symbolId,s.resolution,i.studyObject,e,t,i.turnaround,i.parentId,(0,d.ensure)(i.inputs))}}l&&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))}q()}_getSeriesData(e,t){return this._objectsDataCache[Oe(e,t)]||null}_findStudyObject(e){e.endsWith("!")&&(e=e.slice(0,-1));const t=e.split("@")[0],i=ke().filter((i=>i.metainfo.id===e||i.metainfo.shortDescription===t));if(0===i.length)return null;return i[0]}_resolveSymbolImpl(e,t,i){var s;(0,C.isEncodedExtendedSymbol)(e)||(s="Expect to get symbol encoded string, but got the following instead: "+e,console.error(`${(new Date).toISOString()} ${s}`));const[o,n]=ze(e);this._resolveSymbolByName(o,n,t,i)}_getSymbolExtrapolator(e,t,i){const s=(0,d.ensure)(u.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 n=this._symbolExtrapolators[o];return void 0===n&&(n=new oe(t,s),this._symbolExtrapolators[o]=n),n}_barsCoefficients(e,t){const i=(0,C.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&&(o.enabled("studies_extend_time_scale")&&i.canExtendTimeScale||o.enabled("secondary_series_extend_time_scale")&&"Overlay@tv-basicstudies-1"===i.id||o.enabled("intraday_inactivity_gaps")&&"IntradayInactivityGaps@tv-basicstudies-1"===i.id)}_stopQuotesSubscription(e){this._quotesInfo[e].listenerGUID&&(o.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){o.enabled("charting_library_debug_mode")&&console.log(`${(new Date).toISOString()} ${e}`)}_adoptConfigurationData(e){const t=(0,Q.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+"`");s.push(t)}return t.supported_resolutions=s,t}_resolveSymbolByName(e,t,i,s){let o;const r=t&&t.currency,a=t&&t.unit,l=t&&t.session,c=Fe(e,r,a,l);(0,n.default)(this._resolveRequests[c])?(o=this._resolveSymbolInternal(e,r||void 0,a||void 0,l||void 0),this._resolveRequests[c]=o,o.then((t=>{this._resolveRequests[Fe(e,t.currency_id,t.unit_id,t.subsession_id)]=o,this._resolveRequests[Fe((0,ee.extractSymbolNameFromSymbolInfo)(t,null),t.currency_id,t.unit_id,t.subsession_id)]=o,this._resolveRequests[Fe((0,ee.extractSymbolNameFromSymbolInfo)(t,null),r,a,l)]=o})).catch((()=>{}))):o=this._resolveRequests[c],o.then(i).catch(s)}_resolveSymbolInternal(e,t,i,s){return new Promise(((o,n)=>{const r=We(e,t,i,s);this._logMessage("Symbol resolve requested: `{0}` ".format(r));let a=!0;this._externalDatafeed.resolveSymbol(e,(e=>{a&&He("`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)for(let t=0;t<e.supported_resolutions.length;t++){const i=u.Interval.parse(e.supported_resolutions[t]);i.isValid()&&(e.supported_resolutions[t]=i.value())}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 x.SubsessionId.Regular:case x.SubsessionId.Extended:i.private=!1;break;case x.SubsessionId.PreMarket:case x.SubsessionId.PostMarket:i.private=!0}}return e.build_seconds_from_ticks=!1,e}(e,{shouldUseSubsessions:Ee,shouldUseTickerNotSymbol:Be});!function(e){const t=e.ticker??e.name??("symbol"in e?e.symbol:void 0)??"unknown symbol";function i(e){He(`SymbolInfo validation for ${t}: `+e)}"string"==typeof e.ticker&&0!==e.ticker.length||!Be||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,m.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,ie.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=>!u.Interval.isValid(e))).forEach((e=>{i("supported_resolutions field contains invalid value: "+e)})),Ee||(void 0!==e.subsessions&&i(`Symbol info contains subsessions but the ${De} feature is not enabled, so the subsessions will be ignored`),void 0!==e.subsession_id&&i(`Symbol info contains a subsession ID but the ${De} 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,l,h,d,_,g,f){let y=!0;const v=[];null!==_&&(this._objectsDataCache[_]=null),this._timeScales[e].setCompleted(!1);const S=this._computeStudyCounter++;function b(e,t){if(e<g())return Ae;if(0===t)return 0;const i=v[t-1].index;return i===Ae?0:i+1}const w=new Map;let C=!1;const P=(i,g)=>{const S=u.Interval.parse(s);if((0,r.default)(i.supported_resolutions)&&i.supported_resolutions.length>0&&(0,H.findSuitableResolutionToBuildFrom)(s,i).error)f.onSymbolErrorCallback(`unsupported resolution: ${i.ticker}, ${s}`);else{if(u.Interval.isDWM(s)&&void 0!==d.to){const e=(0,m.createDwmAligner)(s,i);null!==e&&(d.to=e.timeToExchangeTradingDay(d.to))}if(d.from&&d.to){const e=(0,p.getPeriodsBetweenDates)(i.session,i.session_holidays,i.corrections,S.letter(),S.multiplier(),d.from,d.to);d.countBack=Math.max(e,d.countBack)}try{const r=new O({unitId:i.unit_id,currencyCode:i.currency_code,tickerid:g,symbolInfo:qe(i),period:s,body:t,sessionId:e,onErrorCallback:f.onErrorCallback,dataRange:d,subsessionId:i.subsession_id,forceAlignBars:!o.enabled("disable_sameinterval_aligning")&&(0,m.isAlignmentEnabled)(),enableDwmAligning:o.enabled("align_dwm_bars_to_main_series")||!this._studyCanExtendTimeScale(e,l),input:e=>h[e],out:(e,t)=>{!function(e,t,i){const s=e.time,o="number"==typeof t?[t]:t;for(let e=0;e<o.length;++e){let t=o[e];t&&"object"==typeof t&&!Array.isArray(t)&&(w.set(e,t.offset),t=t.value),"number"==typeof t&&isNaN(t)&&(t=void 0),o[e]=t}const n=v.length-1,r=n<0||s>v[n].timeMs;r?v.push({index:b(s,v.length),value:[s/1e3].concat(o),timeMs:s}):(v[n].index=b(s,n),v[n].value=[s/1e3].concat(o),v[n].timeMs=s),y||f.onRealtimeCallback([v[v.length-1]],r,v.length,w,i)}(e,t,i)},nonseriesOut:(e,t)=>{f.onNonSeriesDataUpdate(t,e)},setNoMoreData:()=>{C=!0},recalc:(e,s)=>{y=!1,v.endOfData=C,v.emptyBarCount=s.emptyBarCount,(!("error"in t)||(0,n.default)(t.error)||(0,c.default)(t.error)&&null===t.error())&&(null!==_&&(this._objectsDataCache[_]=v),f.onDataReadyCallback(v,w,i,s))}});if(!this._studiesCache[e]||!this._studiesCache[e][l])throw Error("This should never happen");this._studiesCache[e][l].engine=r}catch(e){if(!((0,a.default)(e)&&"studyError"in e&&e.studyError))throw e;f.onErrorCallback(Re(e,"unknown study error"))}}},T=()=>this._studiesCache[e]&&this._studiesCache[e][l]&&this._studiesCache[e][l].activeResolve===S;this._studiesCache[e][l].activeResolve=S;const x=this._resolvePromisesBySymbolId.get(Ne(e,i));if(void 0===x)throw new Error("This should never happen");let I,M;try{const e=await x
;I=e.symbolInfo,M=e.requestedSymbol}catch(e){return void(T()&&f.onSymbolErrorCallback(Re(e,"unknown symbol error")))}T()&&P(I,M)}_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,n,l,c){this._studiesCache[s][o].completed=!1;const h=(e=>{if(Array.isArray(e))return e;const t=[],i=this._studiesCache[s][o].metainfo.inputs;if((0,r.default)(i))for(let s=0;s<i.length;s++)t[s]=e[i[s].id];return t})(c);Le().ChartapiMessagerInstances[s].onStudyLoading(o,n);const u=(e,t,i)=>{const r=this._studiesCache[s][o];if(r.completed=!0,e.length>0&&(r.firstLoadedTimeMs=e[0].timeMs),e=Ue(e),this._setEndOfData(s,o,n,!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),Le().ChartapiMessagerInstances[s].onDataUpdate(o,n,e,t),Le().ChartapiMessagerInstances[s].onStudyCompleted(o,n),this._updateTimeScaleState(s)},_=e=>{if(0===e.size)return{};const t={},i=this._studiesCache[s][o].metainfo;return e.forEach(((e,s)=>{t[(0,d.ensure)(i.plots)[s].id]=e})),{data:{offsets:t}}};let m=null,g=!1;this._computeStudy(s,i,e,t,o,h,this._getDataRangeForStudy(s,o),null,(()=>{if(this._studyCanExtendTimeScale(s,o))return-1/0;if(null===m){const e=this._getSeriesData(s,l)?.[0];if(void 0===e)return 1/0;m=e.timeMs}return m}),{onDataReadyCallback:(e,t,i)=>{g&&0===e.length||u(e,_(t))},onRealtimeCallback:(e,t,i,r,a)=>{const l=Ue(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),Le().ChartapiMessagerInstances[s].onDataUpdate(o,n,l,_(r)),this._updateTimeScaleState(s)},onSymbolErrorCallback:()=>{this._studiesCache[s][o].completed=!0,Le().ChartapiMessagerInstances[s].onStudyError(o,n,"error in series")},onErrorCallback:(e,t)=>{if(this._studiesCache[s][o].completed=!0,t){const i={error:e,title:t};Le().ChartapiMessagerInstances[s].onStudyError(o,n,i)}else Le().ChartapiMessagerInstances[s].onStudyError(o,n,e)},onNonSeriesDataUpdate:(e,i)=>{switch(g=!0,e.type){case"projection":break;case"study_gap":const n=e.displaySession||"session",r="session"===n?i.info?.session:n,l=new p.SessionInfo(i.info?.timezone||i.session.timezone.name(),r||"24x7",i.info?.session_holidays||"",i.info?.corrections||""),c=(0,p.newBarBuilder)(t,l,null),h=(0,U.extrapolateBarsFrontToTime)(c,e.from,e.to,1/0,!0),d=this._timeScales[s].replaceStudyBarsTimesTail(o,h.times);this._applyTimeScaleUpdate(s,d);break;case"study_graphics":{const t={type:"study_graphics",data:e.data,indexes:[],nonseries:!0
},i=function(e){const t=e.data&&e.data.graphicsCmds&&e.data.graphicsCmds.create;if(!t)return[];const i=new Map,s=new Set;we.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))),Ce.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),u([],t);break}case"non_series_data":{const t={type:"non_series_data",data:e.data,nonseries:!0,indexes:[]},i=t?.data?.data?.pivots,n=void 0!==i;let r=function(e){const t={};J(e,(e=>{(0,a.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,J(e,(e=>((0,a.default)(e)&&Object.keys(e).forEach((i=>{i.endsWith("__t")&&(e[i.slice(0,-3)]=t[e[i]])})),e)),{visitInstances:!0})),i}(t),l=this._timeScales[s].convertTimesToIndexes(r,n);if(n){const e=new Set,t=[],s=[];let o=0;for(let n=l.length-1;n>=0;n--){const a=l[n];e.has(a)||a===le.INVALID_TIME_POINT_INDEX?(i.splice(n,1),o++):(t.unshift(r[n]),s.unshift(a),e.add(a))}o>0&&i.forEach(((e,t)=>{e.startIndex=t,e.endIndex=t+1})),r=t,l=s}this._studiesNonSeriesTimes[s][o]=r,t.indexes=l,u([],t);break}default:He("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})}}}Le().ChartapiMessagerInstances[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)=>{Le().ChartapiMessagerInstances[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];"IntradayInactivityGaps@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&&Le().ChartapiMessagerInstances[e].onTimescaleCompleted(i))}_getStudiesCacheSessionKeys(e){
return void 0!==this._studiesCache[e]?Object.keys(this._studiesCache[e]):[]}}Ve.debugGetQuotesRequestId=1;function Re(e,t){return"string"==typeof e?e:(0,a.default)(e)&&e&&"message"in e&&(0,l.default)(e.message)?e.message:t}function Ne(e,t){return e+"_"+t}function Oe(e,t){return e+"_"+t}function Fe(e,t,i,s){return e+(t?"_#_"+t:"")+(i?"_#_"+i:"")+(s?"_#_"+s:"")}function We(e,t,i,s){return[e,t,i,s].filter((e=>(0,l.default)(e)&&e.length>0)).join("|")}function He(e){console.warn(`${(new Date).toISOString()} ${e}`)}function ze(e){const t=(0,C.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===x.SubsessionId.Regular?void 0:i.session:void 0}]}function Ue(e){const t=e.findIndex((e=>e.index!==Ae));return-1===t?[]:0===t?e:e.slice(t)}function Ge(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 je(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 He("`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 qe(e){return e.timezone=e.timezone,e}},39076:(e,t,i)=>{"use strict";i.d(t,{backend:()=>s});const s=i(64289)},18278:(e,t,i)=>{"use strict";i.d(t,{HandlerInfo:()=>s});class s{constructor(e,t,i){this.handler=e,this.customId=t,this.singleShot=i}}},82783:(e,t,i)=>{"use strict";var s,o,n,r;function a(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)}i.d(t,{TIMEFRAMETYPE:()=>r,areEqualTimeFrames:()=>a}),function(e){e.extractErrorReason=function(e){return e.params[1]}}(s||(s={})),function(e){e.Default="default",e.FullSingleSession="full_single_session"}(o||(o={})),function(e){e.PeriodBack="period-back",e.TimeRange="time-range"}(n||(n={})),function(e){e.PeriodBack="period-back",e.TimeRange="time-range"}(r||(r={}))},80437:()=>{"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[]}},92883:(e,t,i)=>{"use strict";i.d(t,{getNewPeveCloseMode:()=>o});let s=!1;function o(){return s}},97126:(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._fields=[...e.fields]}update(e,t,i){const o=(0,s.ensureDefined)(e.symbolname);if(this._cache.has(o)||this._cache.set(o,{symbolname:o,status:e.status,values:{}}),"error"===e.status)return;const n=(0,
s.ensureDefined)(this._cache.get(o));n.status=e.status;for(const s of this._fields)t.has(s)&&(i||void 0!==e.values[s])&&(n.values[s]=e.values[s])}get(e){return this._cache.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","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","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","dividend_payout_ratio_ttm","dividends_yield_current","dividend_ex_date_upcoming","dividend_amount_upcoming","dividend_amount_recent","dividend_ex_date_recent","dividend_amount_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"]),r=new o({
fields:n})},42003:(e,t,i)=>{"use strict";i.d(t,{destroyQuoteSessions:()=>r,getQuoteSessionInstance:()=>n});var s=i(32783);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]}}},64364:(e,t,i)=>{"use strict";i.d(t,{QuoteSession:()=>o});var s=i(92184);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)}}window.TradingView.QuoteSession=o},32783:(e,t,i)=>{"use strict";e=i.nmd(e);var s=i(20057).default,o=i(90484).default,n=i(725).PriceFormatter;const{uniq:r}=i(97144);var a=i(92184);const{normalizeUpdateMode:l}=i(89512);var c=i(31054).deepExtend;const{QUOTE_FIELDS_CACHE:h,QUOTE_FIELDS:d}=i(97126);var u,_=i(52033).Delegate,p=i(92883).getNewPeveCloseMode;function m(e,t){this.options=Object.assign({throttleTimeout:125},t),this._connected=!1,this._symbol_data={},this._subscriptions={},this.onConnect=new _,this.onDisconnect=new _,this._quoteApi=new u(window.ChartApiInstance),this._type=e||"full",this._delayUpdateFastSymbols=o(this._updateFastSymbols,250),this._throttledSymbolData={},this._formatterValuesCache={},this._waitingForFormatters={},this._snapshotValuesCache={},this._waitingForSnapshot={},this.connect()}u=i(64364).QuoteSession,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"]),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.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];p()&&(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},TradingView.QuoteSessionMultiplexer=m,e&&e.exports&&(e.exports=m)},45687:(e,t,i)=>{"use strict";i.d(t,{getServerInterval:()=>o});var s=i(85049);function o(e){return s.Interval.isRange(e)?"1":e}},89512:(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})},63812:(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}}},29981:(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])}}},2740:(e,t,i)=>{"use strict";i.d(t,{DAY_OF_MONTH:()=>S,DAY_OF_WEEK:()=>w,DECEMBER:()=>g,FIRST_DAY_OF_WEEK:()=>_,FRIDAY:()=>d,HOUR_OF_DAY:()=>C,JANUARY:()=>m,LAST_DAY_OF_WEEK:()=>p,MINUTE:()=>P,MONDAY:()=>a,MONTH:()=>y,SATURDAY:()=>u,SECOND:()=>T,SUNDAY:()=>r,THURSDAY:()=>h,TUESDAY:()=>l,WEDNESDAY:()=>c,WEEK_OF_YEAR:()=>v,YEAR:()=>f,add_date:()=>H,add_days_considering_dst:()=>F,add_minutes:()=>z,add_years_considering_dst:()=>W,cal_to_utc:()=>ie,clone:()=>G,days_per_year:()=>q,get_cal:()=>Q,get_cal_from_unix_timestamp_ms:()=>ee,get_cal_utc:()=>te,get_day_of_month:()=>E,get_day_of_week:()=>B,get_day_of_year:()=>V,get_minutes_from_midnight:()=>R,get_minutes_with_hours:()=>N,get_month:()=>L,get_part:()=>K,get_timezone:()=>se,get_year:()=>A,is_leap_year:()=>$,minutesPerDay:()=>x,minutesPerWeek:()=>I,setCustomTimezones:()=>ne,set_hms:()=>O,set_seconds:()=>U,time_seconds:()=>Y,time_seconds_diff:()=>Z,utc_to_cal:()=>X,utc_to_cal_ts:()=>J});var s=i(23998);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&&oe&&(t=oe.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=re(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=re(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=11,f=1,y=2,v=3,S=5,b=6,w=7,C=11,P=12,T=13,x=1440,I=10080,M=864e5;function A(e){return e.getUTCFullYear()}function L(e){return e.getUTCMonth()}function k(e){return e.getUTCHours()}function D(e){return e.getUTCMinutes()}function E(e){return e.getUTCDate()}function B(e){return e.getUTCDay()+1}function V(e){const t=e.getUTCMonth();let i=o[t];return t>m+1&&$(e.getUTCFullYear())&&(i+=1),i+e.getUTCDate()}function R(e){return 60*k(e)+D(e)}function N(e){return R(e)}function O(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 F(e,t,i){const s=e.offset_utc(t.getTime()),o=G(t);H(o,i);const n=e.offset_utc(o.getTime());return o.setTime(o.getTime()+s-n),o}function W(e,t,i){let s=t;for(let t=Math.abs(i);t>0;t--)s=F(e,s,j(s)*Math.sign(i));return s}function H(e,t){e.setTime(e.getTime()+t*M)
}function z(e,t){e.setTime(e.getTime()+60*t*1e3)}function U(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);O(e,r,a,n-3600*r-60*a,0),H(e,o)}function G(e){return new Date(e.getTime())}function j(e){return q(e.getUTCFullYear())}function q(e){return $(e)?366:365}function $(e){return e%4==0&&(e%100!=0||e%400==0)}function K(e,t){switch(t){case f:return A(e);case y:return L(e);case S:return E(e);case v:return function(e){const t=new Date(Date.UTC(e.getUTCFullYear(),0,1)).getUTCDay(),i=0===t?1:8-t,s=V(e)-i;return Math.ceil(s/7)+1}(e);case w:return B(e);case C:return k(e);case P:return D(e);case b:return V(e);case T:return function(e){return e.getUTCSeconds()}(e);default:return e.getTime()}}function Y(e){return 1e3*e}function Z(e,t){return le(e)-le(t)}function X(e,t){return new Date(J(e,t))}function J(e,t){return t+e.offset_utc(t)}function Q(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 ee(e,t){return new Date(t+e.offset_utc(t))}function te(e,t,i,s=0,o=0,n=0){return new Date(Date.UTC(e,t,i,s,o,n))}function ie(e,t,i){let s=t.getTime();i&&(s+=e.correction_loc(s));return s-e.offset_loc(s)}function se(e){return new n(e)}let oe;function ne(e){oe=e}function re(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=ae((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=ae((s+o)/2)}}function ae(e){return 0|e}function le(e){return e<0?ae(e/1e3)-(e%1e3!=0?1:0):ae(e/1e3)}},51056:(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},5201:(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}}},88960:(e,t,i)=>{"use strict";i.d(t,{accumulate:()=>a,combine:()=>r,combineWithFilteredUpdate:()=>n});var s=i(64147);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=()=>{t(...i.map((e=>e.value())))&&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){const o=(t,i)=>{const s=t.map((e=>e.value()));return e(s,i)},n=new s.WatchedValue(o(t.value(),i?.value())),r=t.spawn();let a=[];const l=i?.spawn()??new s.WatchedValue(void 0),c=()=>{n.setValue(o(a,l.value()))},h=e=>{a.forEach((e=>e.destroy())),a=e.map((e=>e.spawn())),a.forEach((e=>{e.subscribe(c)})),c()};h(r.value()),r.subscribe(h),l.subscribe(c);return n.readonly().spawn((()=>{a.forEach((e=>e.destroy())),r.destroy(),l.destroy(),t.release()}))}},63950:(e,t,i)=>{"use strict";i.d(t,{availableTimezones:()=>l,timezoneIsAvailable:()=>u,timezoneIsSupported:()=>_,timezoneTitle:()=>p,updateAvailableTimezones:()=>d});var s=i(82112),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/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(426))},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}},52033:(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)}`)}}}}},30699:(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={}))},82236:(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))],["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))]])},19938:(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}},34776:(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})},9859:(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)}i.d(t,{ceiledEven:()=>d,clamp:()=>s,equal:()=>a,greaterOrEqual:()=>r,isBaseDecimal:()=>n,log10:()=>l,max:()=>h,sign:()=>o,toInt:()=>u})},82112:(e,t,i)=>{"use strict";i.d(t,{parseTzOffset:()=>o});var s=i(2740);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}}},97085:(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,deepEquals:()=>l,isFunction:()=>a,isNumber:()=>s,isObject:()=>r,merge:()=>n})},13665: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 P(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 T(e){return 1!==(e=P(e)).length?null:e[0]}function x(e,t){return(e=P(e)).some((function(e){return t.includes((e||"").toUpperCase())}))}function I(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=T(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:T,getExchanges:P,isExchange:function(e,t){return!!(e=T(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)})),I(t)},normalize:function(e){if("string"!=typeof e)throw new TypeError("expression must be a string");return I(C(w(b(e))))}}}();e.exports=i},45126:(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)}}},23998: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,-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,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-7200,-10800,-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,1245452400,1262303999,1925013600],offset:[21700,21200,23400,19800,23400,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,-2229292800,-1046649600,-1038700800,-873244800,-794188800,-496195200,-489283200,259372800,275184e3,1925020800],offset:[-57360,29040,28800,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,-1343091600,-1234828800,-1220317200,-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,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,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,-1667437200,-1647734400,-1635814800,-1616198400,-1604365200,-1584662400,-1572742800,-155304e4,-1541206800,-1521504e3,-1442451600,-1426809600,-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,-922665600,-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,212547600,228268800,243997200,260323200,276051600,291772800,307504800,323222400,338954400,354675600,370404e3,386125200,401853600,417578400,433303200,449024400,465357600,481078800,496807200,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,0,3600,0,3600,0,3600,0,3600,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,-1667437200,-1647734400,-1635814800,-1616198400,-1604365200,-1584662400,-1572742800,-155304e4,-1541206800,-1521504e3,-1442451600,-1426809600,-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,-922665600,-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,228268800,243997200,260323200,276051600,291772800,307504800,323222400,338954400,354675600,370404e3,386125200,401853600,417578400,433303200,449024400,465357600,481078800,496807200,512528400,528256800,543978e3,559706400,575427600,591156e3,606877200,622605600,638326800,65466e4,670381200,686109600,701830800,717559200,733280400,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,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,0,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600,0,-3600]}}},1640:(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)},64147:(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])}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 super.readonly()}release(){this._weakReference||super.release()}}},91676:(e,t,i)=>{"use strict";i.d(t,{WatchedObject:()=>r});var s=i(64147),o=i(37265);function n(e,t){return(0,o.deepEquals)(e,t)[0]}class r extends s.WatchedValue{constructor(e,t=n){super(e),this._comparator=t}setValue(e,t){(t||!1===this._comparator(this.value(),e))&&super.setValue(e,t)}}},7047:(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))},19291:(e,t,i)=>{"use strict";i.d(t,{mapKeyCodeToDirection:()=>h,navigationOrderComparator:()=>r,queryFocusableElements:()=>l,queryTabbableElements:()=>a,updateTabIndexes:()=>c});var s,o=i(63273),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={}))},27235:(e,t,i)=>{"use strict";i.d(t,{TOOLBAR_WIDTH_COLLAPSED:()=>o,TOOLBAR_WIDTH_EXPANDED:()=>s});const s=52,o=5},6307:(e,t,i)=>{"use strict";i.d(t,{isDrawingToolbarVisible:()=>l});var s=i(56840),o=i(56570),n=i(64147);const r=!o.enabled("hide_left_toolbar_by_default"),a=s.getBool("ChartDrawingToolbarWidget.visible",r),l=new n.WatchedValue(a)},72894:(e,t,i)=>{"use strict";i.d(t,{HEADER_TOOLBAR_HEIGHT_COLLAPSED:()=>n,HEADER_TOOLBAR_HEIGHT_EXPANDED:()=>o});var s=i(61223);const o=parseInt(s["css-value-header-toolbar-height"]),n=3},27514:(e,t,i)=>{"use strict";i.d(t,{shouldShowQuickSearchOnLib:()=>r});var s=i(49483),o=i(84015),n=i(56570);function r(){return!s.CheckMobile.any()&&!(0,o.isOnMobileAppPage)("any")&&!n.enabled("widget")&&n.enabled("header_quick_search")}},81199:(e,t,i)=>{"use strict";i.d(t,{ActionWithStandardIcon:()=>n});var s=i(29023),o=i(67375);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)}}},29023:(e,t,i)=>{"use strict";i.d(t,{Action:()=>c,Separator:()=>h});var s,o=i(50151),n=i(68335),r=i(92184),a=i(52033);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}}},67375:(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(37924),h=i(77067),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.AlertAdd="Alert.Add",e.AlertEdit="Alert.Edit",e.AlertRestart="Alert.Restart",e.AlertStop="Alert.Stop",e.AlertEventsExport="Alert.EventsExport",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.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]])},56657:(e,t,i)=>{"use strict";i.d(t,{ActionsProvider:()=>st,createActionCopyPrice:()=>Je,createActionToggleVisibilityDataSources:()=>tt,createChangeIntervalsVisibilitiesAction:()=>Xe,createLinesAction:()=>Qe,createPasteAction:()=>Ye,createSyncDrawingActions:()=>et,createVisualOrderAction:()=>Ze,defaultContextMenuOptions:()=>Ke});var s=i(50151),o=i(9343),n=(i(60521),i(37265)),r=i(11542),a=i(56570),l=i(29023),c=i(96152),h=i(19466),d=i(79036),u=(i(26023),i(25149)),_=i(28388),p=i(68335),m=(i(25812),i(85604)),g=i(80387),f=i(86920),y=i(32755),v=i(60074),S=i(34585),b=i(45126),w=(i(928),i(85049)),C=i(85719),P=i(10892),T=i(56616),x=i(65383),I=i(12988),M=i(300),A=i(81199);i(77336);(0,o.getLogger)("Chart.ActionsProvider");const L=new b.TranslatedString("change visibility",r.t(null,void 0,i(1924))),k=new b.TranslatedString("pin to scale {label}",r.t(null,void 0,i(81566))),D=new b.TranslatedString("pin to right scale",r.t(null,void 0,i(7495))),E=new b.TranslatedString("pin to left scale",r.t(null,void 0,i(78690))),B=(new b.TranslatedString("change earnings visibility",r.t(null,void 0,i(6819))),
new b.TranslatedString("change dividends visibility",r.t(null,void 0,i(53929))),new b.TranslatedString("change splits visibility",r.t(null,void 0,i(47474))),new b.TranslatedString("change continuous contract switch visibility",r.t(null,void 0,i(18867))),new b.TranslatedString("change futures contract expiration visibility",r.t(null,void 0,i(85532))),new b.TranslatedString("change latest news and Minds visibility",r.t(null,void 0,i(50243))),new b.TranslatedString("show all ideas",r.t(null,void 0,i(13336)))),V=new b.TranslatedString("show ideas of followed users",r.t(null,void 0,i(91395))),R=new b.TranslatedString("show my ideas only",r.t(null,void 0,i(57460))),N=(new b.TranslatedString("change events visibility on chart",r.t(null,void 0,i(6119))),new b.TranslatedString("add this symbol to entire layout",r.t(null,void 0,i(79290)))),O=new b.TranslatedString("add this indicator to entire layout",r.t(null,void 0,i(96677))),F=(new b.TranslatedString("add this strategy to entire layout",r.t(null,void 0,i(58156))),new b.TranslatedString("add this financial metric to entire layout",r.t(null,void 0,i(67608))),new b.TranslatedString("apply drawing template",r.t(null,void 0,i(89720))),new b.TranslatedString("lock objects",r.t(null,void 0,i(18942)))),W=new b.TranslatedString("unlock objects",r.t(null,void 0,i(23230))),H=new b.TranslatedString("anchor objects",r.t(null,void 0,i(63869))),z=new b.TranslatedString("unanchor objects",r.t(null,void 0,i(99234))),U=new b.TranslatedString("change visibility at current interval and above",r.t(null,void 0,i(45800))),G=new b.TranslatedString("change visibility at current interval and below",r.t(null,void 0,i(75645))),j=new b.TranslatedString("change visibility at current interval",r.t(null,void 0,i(84331))),q=new b.TranslatedString("change visibility at all intervals",r.t(null,void 0,i(57916))),$=(r.t(null,void 0,i(66823)),(0,S.appendEllipsis)(r.t(null,void 0,i(264))),r.t(null,void 0,i(98334))),K=r.t(null,void 0,i(27298)),Y=r.t(null,void 0,i(3564)),Z=r.t(null,void 0,i(94559)),X=r.t(null,void 0,i(2165)),J=r.t(null,void 0,i(16986)),Q=r.t(null,void 0,i(12645)),ee=r.t(null,void 0,i(44579)),te=r.t(null,void 0,i(29436)),ie=r.t(null,void 0,i(81054)),se=r.t(null,void 0,i(32538)),oe=r.t(null,void 0,i(72046)),ne=r.t(null,void 0,i(90095)),re=r.t(null,void 0,i(14115)),ae=r.t(null,void 0,i(33110)),le=r.t(null,void 0,i(28280)),ce=r.t(null,void 0,i(76150)),he=r.t(null,void 0,i(94210)),de=r.t(null,void 0,i(60035)),ue=r.t(null,void 0,i(10761)),_e=r.t(null,void 0,i(11254)),pe=r.t(null,void 0,i(35049)),me=r.t(null,void 0,i(19271)),ge=r.t(null,void 0,i(15512)),fe=r.t(null,void 0,i(46545)),ye=r.t(null,void 0,i(52160)),ve=r.t(null,void 0,i(17293)),Se=r.t(null,void 0,i(21973)),be=r.t(null,void 0,i(55481)),we=r.t(null,void 0,i(71179)),Ce=r.t(null,void 0,i(4077)),Pe=r.t(null,void 0,i(54853)),Te=r.t(null,void 0,i(20177)),xe=r.t(null,void 0,i(494)),Ie=r.t(null,void 0,i(60668)),Me=r.t(null,void 0,i(58026)),Ae=r.t(null,void 0,i(56982)),Le=((0,S.appendEllipsis)(r.t(null,void 0,i(35088))),(0,
S.appendEllipsis)(r.t(null,void 0,i(2439))),(0,S.appendEllipsis)(r.t(null,void 0,i(32514)))),ke=(r.t(null,void 0,i(78358)),(0,S.appendEllipsis)(r.t(null,void 0,i(76266))),r.t(null,void 0,i(49680))),De=r.t(null,void 0,i(12537)),Ee=(r.t(null,void 0,i(93553)),r.t(null,void 0,i(74975))),Be=r.t(null,void 0,i(99894)),Ve=r.t(null,void 0,i(51077)),Re=r.t(null,void 0,i(24185)),Ne=(r.t(null,void 0,i(37113)),r.t(null,void 0,i(29449)),r.t(null,void 0,i(50849)),r.t(null,void 0,i(33158)),r.t(null,void 0,i(81465)),r.t(null,void 0,i(62986)),r.t(null,void 0,i(55418))),Oe=r.t(null,void 0,i(10261)),Fe=r.t(null,void 0,i(44020)),We=((0,S.appendEllipsis)(r.t(null,void 0,i(32514))),r.t(null,void 0,i(97878)),r.t(null,void 0,i(39010))),He=r.t(null,void 0,i(26090)),ze=(r.t(null,void 0,i(95754)),r.t(null,void 0,i(35679)),r.t(null,void 0,i(9140)),r.t(null,void 0,i(46607)),r.t(null,void 0,i(39079)),(0,S.appendEllipsis)(r.t(null,void 0,i(75594)))),Ue=(0,S.appendEllipsis)(r.t(null,void 0,i(88853))),Ge=r.t(null,void 0,i(35140)),je=r.t(null,void 0,i(63553)),qe=r.t(null,void 0,i(92957)),$e=r.t(null,void 0,i(58764)),Ke=(r.t(null,void 0,i(10996)),r.t(null,void 0,i(3061)),{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});function Ye(e,t){return!t.isEmpty()&&a.enabled("datasource_copypaste")?new A.ActionWithStandardIcon({actionId:"Chart.Clipboard.PasteSource",options:{label:Ge.trim(),shortcutHint:(0,p.humanReadableHash)(p.Modifiers.Mod+86),statName:"Paste",onExecute:()=>e.chartWidgetCollection().clipboard.uiRequestPaste(t)}}):null}function Ze(e,t){const i=e.model(),s=i.availableZOrderOperations(t),o=[new A.ActionWithStandardIcon({actionId:"Chart.Source.VisualOrder.BringToFront",options:{label:ve,statName:"BringToFront",disabled:!s.bringToFrontEnabled,onExecute:()=>i.bringToFront(t)}}),new A.ActionWithStandardIcon({actionId:"Chart.Source.VisualOrder.SendToBack",options:{label:Se,statName:"SendToBack",disabled:!s.sendToBackEnabled,onExecute:()=>i.sendToBack(t)}}),new A.ActionWithStandardIcon({actionId:"Chart.Source.VisualOrder.BringForward",options:{label:be,statName:"BringForward",disabled:!s.bringForwardEnabled,onExecute:()=>i.bringForward(t)}}),new A.ActionWithStandardIcon({actionId:"Chart.Source.VisualOrder.SendBackward",options:{label:we,statName:"SendBackward",disabled:!s.sendBackwardEnabled,onExecute:()=>i.sendBackward(t)}})];return new A.ActionWithStandardIcon({actionId:"Chart.Source.VisualOrder",options:{label:Ce,iconId:"Chart.VisualOrder",statName:"VisualOrder",subItems:o}})}function Xe(e,t){const i=e.model(),s=(e,s)=>{const o=w.Interval.parse(i.mainSeries().interval()),n=(0,P.getIntervalsVisibilitiesForMode)(o,e),r=[],a=[];t.forEach((e=>{const t=e.properties().intervalsVisibilities.childs();r.push(t.ticks),a.push(n.ticks),r.push(t.seconds),a.push(n.seconds),r.push(t.secondsFrom),a.push(n.secondsFrom),r.push(t.secondsTo),a.push(n.secondsTo),r.push(t.minutes),a.push(n.minutes),r.push(t.minutesFrom),
a.push(n.minutesFrom),r.push(t.minutesTo),a.push(n.minutesTo),r.push(t.hours),a.push(n.hours),r.push(t.hoursFrom),a.push(n.hoursFrom),r.push(t.hoursTo),a.push(n.hoursTo),r.push(t.days),a.push(n.days),r.push(t.daysFrom),a.push(n.daysFrom),r.push(t.daysTo),a.push(n.daysTo),r.push(t.weeks),a.push(n.weeks),r.push(t.weeksFrom),a.push(n.weeksFrom),r.push(t.weeksTo),a.push(n.weeksTo),r.push(t.months),a.push(n.months),r.push(t.monthsFrom),a.push(n.monthsFrom),r.push(t.monthsTo),a.push(n.monthsTo),r.push(t.ranges),a.push(n.ranges)})),i.setProperties(r,a,s,(0,M.sourcesAffectState)(t))},o=[new A.ActionWithStandardIcon({actionId:"Chart.Source.IntervalsVisibility.CurrentAndAbove",options:{label:Te,statName:"currentAndAboveIntervals",onExecute:()=>s(3,U)}}),new A.ActionWithStandardIcon({actionId:"Chart.Source.IntervalsVisibility.CurrentAndBelow",options:{label:xe,statName:"currentAndBelowIntervals",onExecute:()=>s(2,G)}}),new A.ActionWithStandardIcon({actionId:"Chart.Source.IntervalsVisibility.Current",options:{label:Ie,statName:"currentInterval",onExecute:()=>s(1,j)}}),new A.ActionWithStandardIcon({actionId:"Chart.Source.IntervalsVisibility.All",options:{label:Me,statName:"allIntervals",onExecute:()=>s(0,q)}})];return new A.ActionWithStandardIcon({actionId:"Chart.Source.IntervalsVisibility",options:{label:Pe,statName:"IntervalsVisibility",subItems:o}})}function Je(e,t){const i=e.defaultPriceScale(),s=void 0!==t?i.coordinateToPrice(t,e.mainDataSource()?.firstValue()??0):e.model().mainSeries().lastValueData(4,!0,!0).price,o=e.mainDataSource()?.formatter();if(void 0===s||!o)return null;const n=o.format(s),r=o.format(s,{ignoreLocaleNumberFormat:!0});return new A.ActionWithStandardIcon({actionId:"Chart.Clipboard.CopyPrice",options:{label:`${je} ${n}`,statName:"CopyPrice",onExecute:()=>(0,T.getClipboard)().writeText(r)}})}function Qe(e){const t=e.actions(),i=[t.showPriceLine];return i.push(t.showHighLowPriceLines),a.enabled("show_average_close_price_line_and_label")&&i.push(t.showAverageClosePriceLine),new A.ActionWithStandardIcon({actionId:"Chart.Lines",options:{label:Ae,statName:"Lines",subItems:i}})}function et(e,t){return[]}function tt(e,t){const i=t[0].properties().visible.value(),s=i?K:$,o=i?"Chart.Hide":"Chart.ShowObject",n=i?"Chart.SelectedObject.Hide":"Chart.SelectedObject.Show";return new A.ActionWithStandardIcon({actionId:n,options:{checkable:!0,statName:"ToggleVisibilitySelectedObject",label:s,iconId:o,onExecute:()=>{const s=e.model();s.withMacro(L,(()=>{t.forEach((e=>{s.setProperty(e.properties().visible,!i,L,C.lineToolsDoNotAffectChartInvalidation&&(0,y.isLineTool)(e))}))}))}}})}var it;!function(e){e.Copy="Copy"}(it||(it={}));class st{constructor(e,t){this._chartWidget=e,this._options=(0,n.merge)((0,n.clone)(Ke),t||{})}async contextMenuActionsForSources(e,t,i,o,n){const r=e[0],a=this._options,c=[];if(r===this._chartWidget.model().mainSeries()&&a.mainSeries)c.push(...await this._contextMenuActionsForSeries(r,i));else if((0,d.isStudy)(r)&&a.studies)c.push(...await this._contextMenuActionsForStudy(r,(0,
s.ensureDefined)(t),i));else if((0,y.isLineTool)(r)&&a.lineTools){const t=e.filter(y.isLineTool);c.push(...await this._contextMenuActionsForLineTool(t))}else 0;return c.length&&n?.length&&c.push(new l.Separator),c.push(...n??[]),c}async actionForLineTools(e,t){switch(t){case"Chart.SelectedObject.ToggleAnchored":return this._createActionToggleAnchorLineTools(e);case"Chart.SelectedObject.InsertRowTable":{if(1!==e.length)return null;const t=e[0];return((await(t.additionalActions?.(this._chartWidget.model())))?.actions??[]).filter((e=>"action"===e.type&&"Chart.SelectedObject.InsertRowTable"===e.getState().actionId))[0]??null}case"Chart.SelectedObject.InsertColumnTable":{if(1!==e.length)return null;const t=e[0];return((await(t.additionalActions?.(this._chartWidget.model())))?.actions??[]).filter((e=>"action"===e.type&&"Chart.SelectedObject.InsertColumnTable"===e.getState().actionId))[0]??null}}throw new Error(`Unsupported actionId: ${t}`)}_isReadOnly(){return this._chartWidget.readOnly()}_createActionScale(e){const t=(0,s.ensureNotNull)(e.priceScale()),i=this._chartWidget.model().model(),o=(0,s.ensureNotNull)(i.paneForSource(e)),n=o.priceScalePosition(t),r=("left"===n?o.leftPriceScales():o.rightPriceScales()).indexOf(t),a=i.priceScaleSlotsCount().totallySlots<2?"dontneedname":"needname",l="overlay"===n?"":(0,c.getPriceAxisNameInfo)(n,r).label,h=ce.format({label:l}),d={"left-needname":h,"left-dontneedname":de,"right-needname":h,"right-dontneedname":ue,"overlay-needname":he,"overlay-dontneedname":he}[n+"-"+a];return new A.ActionWithStandardIcon({actionId:"Chart.Source.ChangePriceScale",options:{label:d,iconId:"Chart.PriceScale",subItems:this._createActionScaleItems(e)}})}_createActionResetInputPoints(e){const t=e.metaInfo(),s=t.inputs.filter(x.isTimeOrPriceNotHiddenInput);return 0===s.length?null:new A.ActionWithStandardIcon({actionId:"Chart.Source.ResetInputPoints",options:{label:Ue,onExecute:async()=>{let o;try{const n=e.properties().childs().inputs.state();for(const e of Object.keys(n))s.find((t=>t.id===e))||delete n[e];const r=new I.Property({inputs:n}),a=await Promise.all([i.e(9003),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(9481),i.e(4600),i.e(2564),i.e(6445),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(5323),i.e(1072),i.e(9325),i.e(116),i.e(8985),i.e(8222),i.e(4106),i.e(7444),i.e(2440),i.e(9296),i.e(625),i.e(5083),i.e(9255),i.e(7935),i.e(422),i.e(1531),i.e(6316),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(9928),i.e(7223),i.e(9443),i.e(3030)]).then(i.bind(i,73339));o=(await a.selectInputValuesOnChart(this._chartWidget,s,r,t.shortDescription,t.inputs)).customSourceId,e.properties().mergeAndFire(r.state())}finally{void 0!==o&&this._chartWidget.model().model().removeCustomSource(o)}}}})}_createActionLayoutChartsSync(){return new LayoutChartsSyncContextMenuAction(this._chartWidget.linkingGroupIndex().readonly(),(e=>this._chartWidget.model().setLinkingGroupIndex(e)))}_createActionScaleDetach(e,t,i,o){const n=this._chartWidget.model().model(),r=(0,s.ensureNotNull)(n.paneForSource(e))
;if(!r.canCreateNewPriceScale())return null;const a=(0,s.ensureNotNull)(e.priceScale()),l=a.canDetachSource(e),h=r.priceScalePosition(a),d=l||h!==t;if(!d)return null;const u=n.priceScaleSlotsCount(),_={left:{labelled:te,sided:ae},right:{labelled:te,sided:le}},p="left"===t?r.leftPriceScales().length:r.rightPriceScales().length,m=u[t]>p?"labelled":"sided",g=(0,c.getPriceAxisNameInfo)(t,p).label,f=_[t][m].format({label:g});return new A.ActionWithStandardIcon({actionId:"Chart.Source.ChangePriceScale",options:{checkable:!1,disabled:!d,label:f,statName:o,payload:e,onExecute:i}})}_onDetachLeft(e){const t=e.getPayload(),i=this._chartWidget.model().model(),o=(0,s.ensureNotNull)(i.paneForSource(t));this._chartWidget.model().detachToLeft(t,o)}_onDetachRight(e){const t=e.getPayload(),i=this._chartWidget.model().model(),o=(0,s.ensureNotNull)(i.paneForSource(t));this._chartWidget.model().detachToRight(t,o)}_createActionScaleDetachLeft(e){return this._createActionScaleDetach(e,"left",this._onDetachLeft.bind(this),"ToggleScaleLeft")}_createActionScaleDetachRight(e){return this._createActionScaleDetach(e,"right",this._onDetachRight.bind(this),"ToggleScaleRight")}_onMoveToScale(e){const t=e.getPayload();if(t.datasource.priceScale()===t.priceScale)return;const i=this._chartWidget.model().model(),o=(0,s.ensureNotNull)(i.paneForSource(t.datasource));this._chartWidget.model().moveToScale(t.datasource,o,t.priceScale,t.undoText)}_createMoveToScaleAction(e,t,i,s){const o=e.priceScale()===t;return new A.ActionWithStandardIcon({actionId:"Chart.Source.MoveToOtherScale",options:{checkable:!0,checked:o,label:i,statName:"ToggleScale",payload:{datasource:e,priceScale:t,undoText:s},onExecute:this._onMoveToScale.bind(this)}})}_onNoScale(e){const t=e.getPayload().datasource,i=this._chartWidget.model().model(),o=(0,s.ensureNotNull)(i.paneForSource(t));o.isOverlay(t)||this._chartWidget.model().detachNoScale(t,o)}_createActionNoScale(e){const t=this._chartWidget.model().model(),i=(0,s.ensureNotNull)(t.paneForSource(e)),o=i.actionNoScaleIsEnabled(e);return new A.ActionWithStandardIcon({actionId:"Chart.Source.MoveToNoScale",options:{checkable:!0,checked:i.isOverlay(e),label:_e,disabled:!o,statName:"ToggleNoScale",payload:{datasource:e},onExecute:this._onNoScale.bind(this)}})}_createActionScaleItems(e){const t=[],i=this._chartWidget.model().model(),o=(0,s.ensureNotNull)(i.paneForSource(e)),n=i.priceScaleSlotsCount().totallySlots>1,r=o.rightPriceScales(),a=o.leftPriceScales(),h=this._createActionScaleDetachRight(e),d=this._createActionScaleDetachLeft(e),u=r.length+a.length+(null===h?0:1)+(null===d?0:1)>2,_={right:{hidden:{checked:{labelled:Y,sided:Z},unchecked:{labelled:X,sided:J}},visible:{checked:{labelled:Q,sided:ee},unchecked:{labelled:te,sided:ie}}},left:{hidden:{checked:{labelled:Y,sided:se},unchecked:{labelled:X,sided:oe}},visible:{checked:{labelled:Q,sided:ne},unchecked:{labelled:te,sided:re}}}},p={right:D,left:E},m={left:o.visibleLeftPriceScales(),right:o.visibleRightPriceScales()},g=(t,i)=>{
const s=("right"===i?r:a)[t],o=m[i].includes(s)?"visible":"hidden",l=e.priceScale()===s?"checked":"unchecked",h=n?"labelled":"sided",d=_[i],u=(0,c.getPriceAxisNameInfo)(i,t).label;return{actionText:d[o][l][h].format({label:u}),undoText:n?k.format({label:u}):p[i]}};t.push(...r.map(((t,i)=>{const s=g(i,"right");return this._createMoveToScaleAction(e,t,s.actionText,s.undoText)}))),null!==h&&t.push(h);u&&(r.length>0||null!==h)&&t.push(new l.Separator);t.push(...a.map(((t,i)=>{const s=g(i,"left");return this._createMoveToScaleAction(e,t,s.actionText,s.undoText)}))),null!==d&&t.push(d);u&&(a.length>0||null!==d)&&t.push(new l.Separator);return t.push(this._createActionNoScale(e)),t}_createActionMergeUp(e){const t=this._chartWidget.model();return t.model().isMergeUpAvailableForSource(e)?new A.ActionWithStandardIcon({actionId:"Chart.Source.MergeUp",options:{label:me,statName:"MergeUp",onExecute:()=>t.mergeSourceUp(e)}}):null}_createActionUnmergeUp(e){const t=this._chartWidget.model();return t.model().isUnmergeAvailableForSource(e)?new A.ActionWithStandardIcon({actionId:"Chart.Source.UnmergeUp",options:{label:ge,statName:"UnmergeUp",onExecute:()=>t.unmergeSourceUp(e)}}):null}_createActionMergeDown(e){const t=this._chartWidget.model();return t.model().isMergeDownAvailableForSource(e)?new A.ActionWithStandardIcon({actionId:"Chart.Source.MergeDown",options:{label:fe,statName:"MergeDown",onExecute:()=>t.mergeSourceDown(e)}}):null}_createActionUnmergeDown(e){const t=this._chartWidget.model();return t.model().isUnmergeAvailableForSource(e)?new A.ActionWithStandardIcon({actionId:"Chart.Source.UnmergeDown",options:{label:ye,statName:"UnmergeDown",onExecute:()=>t.unmergeSourceDown(e)}}):null}_mergeContentMenuItems(e){return[this._createActionMergeUp(e),this._createActionUnmergeUp(e),this._createActionMergeDown(e),this._createActionUnmergeDown(e)].filter(n.notNull)}_createActionMove(e){const t=this._mergeContentMenuItems(e);return t.length>0?new A.ActionWithStandardIcon({actionId:"Chart.Source.MoveToPane",options:{label:pe,iconId:"Chart.Move",subItems:t}}):null}async _createDetailsMetricsAction(e){return null}async _contextMenuActionsForSeries(e,t){const i=[],o=this._chartWidget.model().model(),n=(0,s.ensureNotNull)(o.paneForSource(e)),r=this._chartWidget.actions(),c=t&&"localY"in t?t.localY:void 0;if(this._isReadOnly())i.push(tt(this._chartWidget,[e])),i.push(new l.Separator),i.push(this._createActionScale(e));else{0,i.length>0&&!(i[i.length-1]instanceof l.Separator)&&i.push(new l.Separator),a.enabled("symbol_info")&&i.push(r.showSymbolInfoDialog);const t=await this._createDetailsMetricsAction(e);if(t&&i.push(t),i.length>0&&!(i[i.length-1]instanceof l.Separator)&&i.push(new l.Separator),!n.isEmpty()&&a.enabled("datasource_copypaste")){const e=Je(n,c),t=Ye(this._chartWidget,n);(e||t)&&(e&&i.push(e),t&&i.push(t),i.push(new l.Separator))}i.push(Ze(this._chartWidget,[e]));const s=this._createActionMove(e);null!==s&&i.push(s),i.push(this._createActionScale(e)),i.push(tt(this._chartWidget,[e])),i.push(new l.Separator)
;Boolean(window.widgetbar?.widget("watchlist"))&&r.addToWatchlist&&(r.addToWatchlist.prepare(),i.push(r.addToWatchlist)),a.enabled("text_notes")&&i.push(r.addToTextNotes),i[i.length-1]instanceof l.Separator||i.push(new l.Separator),a.enabled("show_chart_property_page")&&!this._chartWidget.onWidget()&&i.push(r.mainSeriesPropertiesAction),i[i.length-1]instanceof l.Separator&&i.pop()}return i}_createActionAddChildStudy(e){throw new Error("unsupported")}_createActionAddFundamentals(e){return null}_createActionShowSymbolInfoDialog(e,t){const i=this._chartWidget.model().model();return new A.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowSymbolInfo",options:{label:ze,iconId:"Chart.SymbolInfo",checkable:!1,statName:"SymbolInfo",onExecute:()=>{const s={symbolInfo:e.symbolInfo(),unitDescription:e=>e?t.description(e):"",dateFormatter:i.dateFormatter()};(0,g.showSymbolInfoDialog)(s)}}})}_createActionShowProperties(e){return new A.ActionWithStandardIcon({actionId:"Chart.Indicator.ShowSettingsDialog",options:{label:Le,iconId:"Settings",statName:"EditSelectedObject",onExecute:()=>this._chartWidget.showSourceProperties(e)}})}async _contextMenuActionsForStudy(e,t,i){const s=t!==this._chartWidget.model().paneForSource(e),o=this._chartWidget.actions(),n=(i&&"localY"in i&&i.localY,[]);if(!e.userEditEnabled())return n;if(this._chartWidget.readOnly())n.push(tt(this._chartWidget,[e])),n.push(new l.Separator),(0,u.isNonSeriesStudy)(e)||n.push(this._createActionScale(e));else{0,a.enabled("study_on_study")&&e.canHaveChildren()&&n.push(this._createActionAddChildStudy(e));const t=this._createApplyToEntireLayoutCommand(e);null!==t&&n.push(t);const i=this._createAddIndicatorToFavoritesCommand(e);if(i&&n.push(i),n.length>0&&!(n[n.length-1]instanceof l.Separator)&&n.push(new l.Separator),a.enabled("symbol_info")&&(0,d.isCompareOrOverlayStudy)(e)&&null!==e.symbolInfo()&&(n.push(this._createActionShowSymbolInfoDialog(e,this._chartWidget.model().model().availableUnits())),n.push(new l.Separator)),s||n.push(Ze(this._chartWidget,[e])),n.push(Xe(this._chartWidget,[e])),!(0,u.isNonSeriesStudy)(e)&&!s){const t=this._createActionMove(e);null!==t&&n.push(t),n.push(this._createActionScale(e))}n.push(new l.Separator);const r=e.metaInfo();if(e.copiable()){const t=new A.ActionWithStandardIcon({actionId:"Chart.Clipboard.CopySource",options:{label:ke,shortcutHint:(0,p.humanReadableHash)(p.Modifiers.Mod+67),statName:"Copy",onExecute:()=>{this._chartWidget.chartWidgetCollection().clipboard.uiRequestCopy([e])}}});n.push(t)}n.push(tt(this._chartWidget,[e])),n.push(o.studyRemove);const c=this._options.objectTree&&o.paneObjectTree,h=!1;(c||h)&&(n.push(new l.Separator),c&&n.push(o.paneObjectTree),h&&n.push(this._chartWidget.actions().showDataWindow)),n.push(new l.Separator),a.enabled("property_pages")&&new _.MetaInfoHelper(r).hasUserEditableOptions()&&n.push(this._createActionShowProperties(e)),n[n.length-1]instanceof l.Separator&&n.pop()}return n}_createLineToolTemplateAction(e){return null}_createActionToggleLockLineTools(e){
const t=e[0].properties().frozen.value(),i=t?Be:Ve;return new A.ActionWithStandardIcon({actionId:"Chart.SelectedObject.ToggleLocked",options:{label:i,statName:"ToggleLockSelectedObject",checkable:!0,iconId:t?"Chart.UnlockObject":"Chart.LockObject",onExecute:()=>{if(1===e.length)this._chartWidget.toggleLockSelectedObject();else{const i=t?W:F,s=this._chartWidget.model();s.withMacro(i,(()=>{e.forEach((e=>{s.setProperty(e.properties().frozen,!t,i,C.lineToolsDoNotAffectChartInvalidation)}))}))}}}})}_createActionToggleAnchorLineTools(e){const t=e.filter((e=>e.anchorable()));if(0===t.length)return null;const i=t[0].properties().anchored.value();return new A.ActionWithStandardIcon({actionId:"Chart.SelectedObject.ToggleAnchored",options:{label:Re,statName:"ToggleAnchoredSelectedObject",checkable:!0,checked:i,onExecute:()=>{const e=i?z:H,s=this._chartWidget.model();s.withMacro(e,(()=>{t.forEach((t=>{s.setProperty(t.properties().childs().anchored,!i,e,C.lineToolsDoNotAffectChartInvalidation)}))}))}}})}async _contextMenuActionsForLineTool(e){const t=[],i=this._chartWidget.actions(),s=(this._chartWidget.model().model(),()=>{t.push(Ze(this._chartWidget,e))}),o=()=>{t.push(Xe(this._chartWidget,e))},n=()=>{const i=e.filter((e=>e.cloneable()));if(i.length>0){const e=new A.ActionWithStandardIcon({actionId:"Chart.LineTool.Clone",options:{label:De,iconId:"Chart.Clone",shortcutHint:(0,p.humanReadableModifiers)(p.Modifiers.Mod)+"Drag",statName:"Clone",onExecute:()=>this._chartWidget.model().cloneLineTools(i,!1)},id:"Clone"});t.push(e)}return!!i.length},r=()=>{const i=e.filter((e=>e.copiable()));if(i.length>0){const e=new l.Action({actionId:"Chart.Clipboard.CopyLineTools",options:{label:ke,shortcutHint:(0,p.humanReadableHash)(p.Modifiers.Mod+67),statName:"Copy",onExecute:()=>this._chartWidget.chartWidgetCollection().clipboard.uiRequestCopy(i)},id:"Copy"});t.push(e)}return!!i.length},c=()=>{const e=(this._chartWidget,[]);return t.push(...e),e.length>0},d=e=>{const i=new A.ActionWithStandardIcon({actionId:"Chart.ScrollToLineTool",options:{label:Ee.format({lineToolName:e.title(h.TitleDisplayTarget.StatusLine)}),statName:"GoToLineTool",checkable:!1,onExecute:async()=>this._chartWidget.model().scrollToLineTool(e)}});t.push(i)},u=e=>{const t=this._chartWidget.model().model().lineToolsGroupModel(),i=e.map((e=>t.groupForLineTool(e)));return new Set(i).size<=1};if(1===e.length){const h=e[0];let u={actions:[],placement:"CustomAction"};if(h.additionalActions&&(u=await h.additionalActions(this._chartWidget.model())),u.actions.length>0&&"BeforeAll"===u.placement&&(t.push(...u.actions),t.push(new l.Separator)),this._chartWidget.readOnly())t.push(tt(this._chartWidget,[h]));else if(h.userEditEnabled()){0,s(),o(),this._options.objectTree&&i.paneObjectTree&&t.push(i.paneObjectTree),t.push(new l.Separator);let e=n();e=r()||e,e&&t.push(new l.Separator),e=c(),e&&t.push(new l.Separator),u.actions.length>0&&"CustomAction"===u.placement&&(t.push(...u.actions),t.push(new l.Separator));const _=this._createActionToggleAnchorLineTools([h]);_&&(t.push(_),
t.push(new l.Separator)),t.push(this._createActionToggleLockLineTools([h])),t.push(tt(this._chartWidget,[h])),t.push(i.lineRemove),h.points().length>0&&this._options.gotoLineTool&&(t.push(new l.Separator),d(h));const p=await this._chartWidget.propertiesDefinitionsForSource(h);a.enabled("property_pages")&&null!==p&&(t.push(new l.Separator),t.push(i.format))}}else{this._options.objectTree&&i.paneObjectTree&&t.push(i.paneObjectTree),u(e)&&s(),o(),t.length>0&&t.push(new l.Separator);let h=n();h=r()||h,h&&t.push(new l.Separator),h=c(),h&&t.push(new l.Separator),t.push(this._createActionToggleLockLineTools(e)),t.push(tt(this._chartWidget,e)),t.push(i.lineRemove),a.enabled("property_pages")&&(t.push(new l.Separator),t.push(i.format))}return t}_createEarningsShow(){return null}_createDividendsShow(){return null}_createSplitsShow(){return null}_contextMenuActionsForESD(){return[]}_contextMenuActionsForRollDates(){return[]}_contextMenuActionsForFuturesContractExpiration(){return[]}_contextMenuActionsForisLatestUpdates(){return[]}_contextMenuActionsForPublishedTimeline(e){const t=this._chartWidget.actions(),i=[];if(i.push(t.lineHide),window.is_authenticated){const t=e.properties().childs().filter,s=new l.Action({actionId:"Chart.ShowAllIdeas",options:{checked:t.value()===PublishedChartsFilter.None,checkable:!0,label:Ne,name:"ToggleAllIdeas",statName:"ToggleAllIdeas",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.None,B)}}),o=new l.Action({actionId:"Chart.ShowIdeasOfFollowedUsers",options:{checked:t.value()===PublishedChartsFilter.Following,checkable:!0,label:Oe,name:"ToggleIdeasOfPeopleAndUser",statName:"ToggleIdeasOfPeopleAndUser",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.Following,V)}}),n=new l.Action({actionId:"Chart.ShowMyIdeasOnly",options:{checked:t.value()===PublishedChartsFilter.Private,checkable:!0,label:Fe,name:"ToggleUserIdeas",statName:"ToggleUserIdeas",onExecute:()=>this._chartWidget.model().setProperty(t,PublishedChartsFilter.Private,R)}});i.push(new l.Separator,s,o,n)}return i}_contextMenuActionsForTradingDrawings(e){return e.contextMenuItems()}async _contextMenuActionsForAlertLabel(e,t){return[]}_contextMenuActionsForChartEvents(e){return[]}_createApplyToEntireLayoutCommand(e){if(!this._chartWidget.chartWidgetCollection().applyIndicatorsToAllChartsAvailable())return null;const t=this._chartWidget.model().model();if(e.parentSources().length>0)return null;const i=(0,s.ensureNotNull)(t.paneForSource(e)),o=t.paneForSource(t.mainSeries())===i,n=e instanceof m.StudyCompare&&e.priceScale()===t.mainSeries().priceScale()&&(0,s.ensureNotNull)(e.priceScale()).isPercentage(),r=o?void 0:t.panes().indexOf(i);let a=He,c=O,h="AddStudyToEntireLayout";return(0,v.isActingAsSymbolSource)(e)&&(a=We,c=N,h="AddSymbolToEntireLayout"),new l.Action({actionId:"Chart.AddIndicatorToAllCharts",options:{label:a,statName:h,onExecute:()=>{const i=(0,s.ensureNotNull)((0,f.clipboardDataForSources)(t.id(),[e])),a=this._chartWidget.chartWidgetCollection(),l={isOnMainPane:o,asCompare:n,
paneIndex:r};a.applyIndicatorToAllCharts(this._chartWidget,i,l,c)}},id:"applyStudyToEntireLayout"})}_createAddIndicatorToFavoritesCommand(e){const t=e.metaInfo();let s;if(!a.enabled("items_favoriting")||(0,d.isCompareOrOverlayStudy)(e))return null;{const{description_localized:e,description:o}=t,n=e||r.t(o,{context:"study"},i(83477));s=()=>i.e(9790).then(i.bind(i,23390)).then((({isFavorite:e,toggleFavorite:t})=>({label:e(n)?$e:qe,onExecute:()=>t(n)})))}return new A.ActionWithStandardIcon({actionId:"Chart.Indicator.AddFavorites",id:"addIndicatorToFavorites",optionsLoader:s,options:{statName:"AddIndicatorToFavorites",iconId:"Indicator.AddToFavorites"}})}}},86920:(e,t,i)=>{"use strict";i.d(t,{clipboardDataForSources:()=>l,isLineToolClipboardData:()=>a});var s=i(50151),o=i(19466),n=i(79036),r=i(32755);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}},7114:(e,t,i)=>{"use strict";i.d(t,{addExclusionArea:()=>P,addExclusionAreaByScope:()=>C,calcTextHorizontalShift:()=>b,clearRect:()=>p,createBoundCanvas:()=>v,createDisconnectedCanvas:()=>g,createDisconnectedCanvasByRenderingInfo:()=>f,disableSelection:()=>w,drawScaled:()=>m,drawWithExclusionAreaByScope:()=>T,fillRect:()=>_,getBindingRenderingInfo:()=>h,getContext2D:()=>d,getPrescaledContext2D:()=>u,measureText:()=>I,tryApplySuggestedCanvasBitmapSize:()=>S});var s=i(27714),o=i(50151),n=i(776),r=i(2844),a=i(63273),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 P(e,t,i){C({context:e,...t},i)}function T(e,t,i){e.context.save(),C(e,t),i(),e.context.restore()}let x;function I(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))}},97990:(e,t,i)=>{"use strict";i.d(t,{ChartChangesWatcher:()=>a,changedAll:()=>r});var s,o=i(84425),n=i(52033);!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._recursiveLoopingGuard=!1,this._handleMetainfoChanged=()=>{this._changesMask=1|this._changesMask},this._recalculateHaveChanges=(e,t)=>{if(!this._recursiveLoopingGuard)try{this._recursiveLoopingGuard=!0;const e=this._undoHistoryHasChanges?1:0;let i=this._lineToolsHaveChanges.value()?2:0;const s=this._changesMask;this._changesMask=e|i,s!==this._changesMask&&(this._changesMask&&(this._chartWidgetCollection.getAll().forEach((e=>{e.lineToolsSynchronizer()?.markAsValidatedBecauseOfSavingToContent(!!t)})),i=this._lineToolsHaveChanges.value()?2:0,this._changesMask=e|i),this._onValueChanged.fire(0!==this._changesMask))}finally{this._recursiveLoopingGuard=!1}},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._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._handleMetainfoChanged)}_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._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._handleMetainfoChanged)}_setUndoHistoryHasChanges(e,t){this._undoHistoryHasChanges=e,this._recalculateHaveChanges(e,t)}_handleChartLoaded(){this._setUndoHistoryHasChanges(!1)}_handleLayoutLoaded(){this._setUndoHistoryHasChanges(!1,!0)}_handleUndoHistoryChange(e){e?.affectsState()&&this._setUndoHistoryHasChanges(!0)}_handleChartMigrated(){this._setUndoHistoryHasChanges(!0)}_handleChartSaved(e){e&&this._setUndoHistoryHasChanges(!1,!0)}}},43550:(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(32755);var a=i(64147),l=i(28331);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}return!(o.isMacKeyboard&&s===o.Modifiers.Mod||!u.includes(s))&&(!(0,n.isNativeUIInteraction)(t,e.target)&&(this._pressedKeyCode=i,s===o.Modifiers.None?this._chartWidget.scrollHelper().moveByBar(r):s===o.Modifiers.Alt||s===o.Modifiers.Mod?this._chartWidget.scrollHelper().move(r):-1===r?this._chartWidget.model().timeScale().scrollToRealtime(!0):this._chartWidget.model().timeScale().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}}},17730:(e,t,i)=>{"use strict";i.d(t,{getChartWidgetApiTimeConverter:()=>r});var s=i(50151),o=i(53388);const n=i(56570).enabled("end_of_period_timescale_marks");function r(e,t,i){return new l(function(e,t){const i=function(e,t){return e+t.session+t.timezone+(t.corrections||"")+(t.session_holidays||"")}(e,t);let s=a.get(i);void 0===s&&(s=(0,o.createDwmAligner)(e,t),a.set(i,s));return s}(e,t),i)}const a=new Map;class l{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=n?function(e,t){const i=e.indexToUserTime(t)
;if(null===i)return null;return i.getTime()/1e3}(t,e):this.convertTimePointIndexToInternalTime(e);return null!==i&&(i=this.convertInternalTimeToPublicTime(i)),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}}},15938:(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}`},40443:(e,t,i)=>{"use strict";i.d(t,{ContextMenuManager:()=>s});var s,o=i(29981),n=i(29023),r=i(59064);!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(3953),i.e(5826),i.e(5323),i.e(2736),i.e(4066),i.e(6489),i.e(7001),i.e(6262),i.e(2227),i.e(2544),i.e(2157),i.e(1584)]).then(i.bind(i,11785));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={}))},69293:(e,t,i)=>{"use strict";i.d(t,{doNotShowDeleteLockedLineConfirmProperty:()=>a,doNotShowDeleteLockedLineKey:()=>n});var s=i(56840),o=i(17625);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())))},29280:(e,t,i)=>{"use strict";i.d(t,{DialogRenderer:()=>o});var s=i(64147);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)}}},26023:(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={}))},9726:(e,t,i)=>{"use strict";i.d(t,{createFavoriteDrawingToolbar:()=>a,getFavoriteDrawingToolbarPromise:()=>r});var s=i(72894);let o=null,n=null;function r(){return n}function a(){null===n&&(n=Promise.all([i.e(7827),i.e(3703),i.e(3953),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(6445),i.e(7384),i.e(5323),i.e(2736),i.e(4066),i.e(6489),i.e(4353),i.e(2440),i.e(9255),i.e(7001),i.e(3745),i.e(6262),i.e(6842),i.e(5099),i.e(2227),i.e(2544),i.e(1890),i.e(2157),i.e(7843),i.e(2306)]).then(i.bind(i,17815)).then((({FavoriteDrawingToolbar:e})=>(o=null!==o?o:new e({left:window.innerWidth/2,top:s.HEADER_TOOLBAR_HEIGHT_EXPANDED+61}),o))))}},776:(e,t,i)=>{"use strict";function s(e){return Math.max(1,e.ownerDocument?.defaultView?.devicePixelRatio||1)}i.d(t,{getCanvasDevicePixelRatio:()=>s})},96152:(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)}},56530:(e,t,i)=>{"use strict";i.d(t,{getTranslatedInputTitle:()=>n});var s=i(11542);const o={PercentageLTP:"Percentage LTP"};function n(e){return s.t(o[e]??e,{context:"input"},i(32856))}},77788:(e,t,i)=>{"use strict";i.d(t,{CHART_WIDGET_COLLECTION_SERVICE:()=>o,chartWidgetCollectionService:()=>n});var s=i(16216);const o={id:"ChartWidgetCollectionService"};function n(){return(0,s.hasService)(o)?(0,s.service)(o):null}var r;!function(e){e.Multichart="multichart",e.ForceFullscreen="force-fullscreen"}(r||(r={}))},62288:(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._priceScalesPriceRangeAnimationsInvalidationMap=new Map,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))}setPriceScaleRangeAnimation(e,t){this._priceScalesPriceRangeAnimationsInvalidationMap.set(e,t)}priceScaleRangeAnimations(){return this._priceScalesPriceRangeAnimationsInvalidationMap}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,e._priceScalesPriceRangeAnimationsInvalidationMap.forEach(((e,t)=>{this._priceScalesPriceRangeAnimationsInvalidationMap.set(t,e)}))}}!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._timeAxisInvalidationLevel=r,this._invalidatedPanes=new Map,this._additionalActions=[],this._timeScaleInvalidations=[],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)}setPriceScaleRangeAnimation(e,t,i){this._invalidationLevel=Math.max(this._invalidationLevel,s.Light),this._invalidatedPanes.has(e)||this._invalidatedPanes.set(e,new n(this._invalidationLevel)),(0,o.ensureDefined)(this._invalidatedPanes.get(e)).setPriceScaleRangeAnimation(t,i)}invalidateTimeScale(e){this._timeAxisInvalidationLevel=Math.max(this._timeAxisInvalidationLevel,e)}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)}invalidateForPane(e){return this._invalidatedPanes.get(e)||new n(this._invalidationLevel)}invalidateForTimeScale(){return Math.max(this._timeAxisInvalidationLevel,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._timeAxisInvalidationLevel=Math.max(this._timeAxisInvalidationLevel,e._timeAxisInvalidationLevel);for(let t=0;t<e._additionalActions.length;t++)this._additionalActions.push(e._additionalActions[t]);for(const t of e._timeScaleInvalidations)this._applyTimeScaleInvalidation(t)}panesOrderInvalidated(){return this._panesOrderChanged}isVisibleTimeRangeLockedOnResize(){return this._keepVisibleTimeRangeOnResize}setTimeScaleAnimation(e,t){this._removeTimeScaleAnimation(),this._timeScaleInvalidations.push({type:0,value:e,rightOffsetPx:t}),this._invalidationLevel=Math.max(this._invalidationLevel,s.Light)}stopTimeScaleAnimation(){this._removeTimeScaleAnimation(),this._timeScaleInvalidations.push({type:1}),this._invalidationLevel=Math.max(this._invalidationLevel,s.Light)}timeScaleInvalidations(){return this._timeScaleInvalidations}static cursor(){return new l(s.Cursor)}static light(){return new l(s.Light)}static full(){return new l(s.Full)}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}_applyTimeScaleInvalidation(e){switch(e.type){case 0:this.setTimeScaleAnimation(e.value,e.rightOffsetPx);break;case 1:this._removeTimeScaleAnimation()}}_removeTimeScaleAnimation(){const e=this._timeScaleInvalidations.findIndex((e=>0===e.type));if(-1!==e){const[t]=this._timeScaleInvalidations.splice(e,1);t.value.onFinish?.(!1)}}}},69186:(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}}},65952:(e,t,i)=>{"use strict";i.d(t,{layoutInitialSizingState:()=>n});var s=i(69708);i(50151);function o(e){return e.map((t=>{if((0,s.default)(t))return{percent:1/e.length};{const i=t.slice(1);return{percent:1/e.length,substate:o(i)}}}))}function n(e){return o(e.slice(1))}},68993:(e,t,i)=>{"use strict";i.d(t,{isMultipleLayout:()=>r,isSupportedLayout:()=>a,layouts:()=>o,tryGuessingTheMostSuitableLayout:()=>l});i(87489),i(65952);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"}},17402:(e,t,i)=>{"use strict";i.d(t,{lineToolsSelectHotkeys:()=>o});i(21251);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"}}},35236:(e,t,i)=>{"use strict";i.d(t,{MouseEventHandler:()=>f,defaultPreventedHandler:()=>m,getClickPosition:()=>_,isTouchMouseEvent:()=>p});var s=i(81251),o=i(50151),n=i(49483),r=i(37265),a=i(80007),l=i(69186);const c=n.isSafari?"click":"auxclick";var h,d;!function(e){e[e.ResetClick=500]="ResetClick",e[e.LongTap=240]="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._pinchInfo=null,this._pinchPrevented=!1,
this._preventTouchDragProcess=!1,this._mousePressed=!1,this._lastTouchEventTimeStamp=0,this._activeTouchId=null,this._acceptMouseLeave=!n.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,r.merge)((0,r.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),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=n>=e&&!this._options.treatVertTouchDragAsPageScroll,i=e>n&&!this._options.treatHorzTouchDragAsPageScroll;t||i||(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;if(this._options.isMouseMoveHandlingEnabled&&!this._options.isMouseMoveHandlingEnabled?.())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),n.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),240)}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;if(this._options.isMouseMoveHandlingEnabled&&!this._options.isMouseMoveHandlingEnabled?.())return;const t=this._target.ownerDocument.documentElement;n.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(){this._target.addEventListener("mouseenter",this._mouseEnterHandler.bind(this)),
this._target.addEventListener("touchcancel",this._touchCancelHandler.bind(this));{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})}n.CheckMobile.iOS()&&(this._unsubscribeMobileSafariEvents=()=>{this._target.removeEventListener("dblclick",this._onMobileSafariDoubleClick)},this._target.addEventListener("dblclick",this._onMobileSafariDoubleClick)),this._target.addEventListener("mouseleave",this._mouseLeaveHandler.bind(this)),this._target.addEventListener("contextmenu",this._contextMenuHandler.bind(this)),this._target.addEventListener("touchstart",this._touchStartHandler.bind(this),{passive:!0}),(0,a.preventScrollByWheelClick)(this._target),this._target.addEventListener("mousedown",this._mouseDownHandler.bind(this)),this._target.addEventListener(c,this._wheelClickHandler.bind(this)),this._initPinch(),this._target.addEventListener("touchmove",(()=>{}),{passive:!1})}_initPinch(){void 0===this._handlers.pinchStartEvent&&void 0===this._handlers.pinchEvent&&void 0===this._handlers.pinchEndEvent||(this._target.addEventListener("touchstart",(e=>this._checkPinchState(e.touches)),{passive:!0}),this._target.addEventListener("touchmove",(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)}}),{passive:!1}),this._target.addEventListener("touchend",(e=>{this._checkPinchState(e.touches)})))}_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=!n.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=(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-o().left},get localY(){return i.clientY-o().top},ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,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}},60859:(e,t,i)=>{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>r,navigationButtonsVisibilityKey:()=>o,property:()=>n,restoreNavigationButtonsVisibilitySettingsValue:()=>l});var s=i(17656);const o="NavigationButtons.visibility",{property:n,availableValues:r,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)(o)},51613:(e,t,i)=>{"use strict";i.d(t,{actualBehavior:()=>a,availableValues:()=>r,property:()=>n,restorePaneButtonsVisibilitySettingsValue:()=>l});var s=i(17656),o=i(60859);const{property:n,availableValues:r,actualBehavior:a,restoreDefaultValue:l}=(0,s.createVisibilityController)("PaneButtons.visibility",o.navigationButtonsVisibilityKey)},65388:(e,t,i)=>{"use strict";i.d(t,{isCustomStudy:()=>o});const s={VbPFixed:!0,PivotPointsStandard:!0,VbPVisible:!0,VbPAnchored:!0};function o(e){return e in s}},28388:(e,t,i)=>{"use strict";i.d(t,{MetaInfoHelper:()=>u})
;var s=i(50151),o=i(9343),n=i(68159),r=i(94113),a=i(37265),l=i(65383);function c(e){return!e.groupId&&!e.isHidden&&e.id!==l.RangeDependentStudyInputNames.FirstBar&&e.id!==l.RangeDependentStudyInputNames.LastBar}var h=i(65388);const d=(0,o.getLogger)("Platform.GUI.PropertyDialog.Indicators.MetaInfo");class u{constructor(e){this._metaInfo=e}hasUserEditableInputs(){return this._metaInfo.inputs.some(c)}getUserEditableInputs(){return this._metaInfo.inputs.filter(c)}hasUserEditableProperties(){return n.StudyMetaInfo.isScriptStrategy(this._metaInfo)}hasUserEditableStyles(){const e=this._metaInfo;return e.plots.length>0||void 0!==e.bands||void 0!==e.filledAreas||(0,h.isCustomStudy)(e.shortId)||n.StudyMetaInfo.isScriptStrategy(this._metaInfo)||Object.values(e.graphics).some((e=>void 0!==e))}getUserEditablePlots(){const e=new Set,t=this._metaInfo;return t.plots.filter((i=>{if((0,r.isColorerPlot)(i)||(0,r.isTextColorerPlot)(i)||(0,r.isDataOffsetPlot)(i)||(0,r.isOhlcColorerPlot)(i)||(0,r.isAlertConditionPlot)(i)||(0,r.isDataPlot)(i))return!1;if((0,r.isOhlcPlot)(i)){const o=i.target;if(e.has(o))return!1;e.add(o);const n=(0,s.ensureDefined)(t.ohlcPlots);return!(0,s.ensureDefined)(n[o]).isHidden}{const e=t.styles?t.styles[i.id]:void 0;return void 0===e||!e.isHidden}}))}hasUserEditableOptions(){return this.hasUserEditableInputs()||this.hasUserEditableProperties()||this.hasUserEditableStyles()}getStrategyProperties(){const e=this._metaInfo,t=e.inputs.filter(p),i={..._};for(const s of t){const t=s.internalID;i[t]=s,_.hasOwnProperty(t)||d.logWarn(`Unknown strategy input internal id ${t} in ${e.fullId}`)}return(0,a.clone)(i)}}const _={currency:void 0,backtest_fill_limits_assumption:void 0,calc_on_every_tick:void 0,calc_on_order_fills:void 0,commission_value:void 0,commission_type:void 0,initial_capital:void 0,pyramiding:void 0,slippage:void 0,default_qty_type:void 0,default_qty_value:void 0,margin_long:void 0,margin_short:void 0,use_bar_magnifier:void 0,process_orders_on_close:void 0,fill_orders_on_standard_ohlc:void 0};function p(e){return"strategy_props"===e.groupId}},59063:(e,t,i)=>{"use strict";i.d(t,{AbstractJsonStoreService:()=>o,CommonJsonStoreService:()=>n});var s=i(52033);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}}},38119:(e,t,i)=>{"use strict";i.d(t,{CustomStatusModel:()=>c});var s=i(64147);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},30141:(e,t,i)=>{"use strict";i.d(t,{restoreShowMarketOpenStatusProperty:()=>c,showMarketOpenStatusProperty:()=>l});var s=i(17625),o=i(56840);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())))},90823:(e,t,i)=>{"use strict";i.d(t,{MarketStatusModel:()=>u});var s,o=i(50151),n=i(64147),r=i(88960),a=i(68805),l=i(17326),c=i(2740);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 n.WatchedValue(null),this._delistedByTypespecs=new n.WatchedValue(!1),this._sessionsSpec=null,this._nextSessionEdgeInternal=null,this._nextSessionEdge=new n.WatchedValue(null),this._recalcNextSessionEdgeTimerId=null,this._delay=0,this._futuresContractExpirationTime=null,this._quotesProvider=e,this._marketStatus=(0,r.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 n.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,a.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,c.get_timezone)(t.timezone()),n=(0,c.utc_to_cal)(o,e),r=d((0,c.cal_to_utc)(o,t.alignToNearestSessionStart(n,1)),(0,c.cal_to_utc)(o,t.alignToNearestSessionEnd(n,1)),e),a=d(void 0!==i?(0,c.cal_to_utc)(o,i.alignToNearestSessionStart(n,1)):1/0,void 0!==i?(0,c.cal_to_utc)(o,i.alignToNearestSessionEnd(n,1)):1/0,e),l=d(void 0!==s?(0,c.cal_to_utc)(o,s.alignToNearestSessionStart(n,1)):1/0,void 0!==s?(0,c.cal_to_utc)(o,s.alignToNearestSessionEnd(n,1)):1/0,e);let u=Math.min(r,a,l);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,n=(0,c.utc_to_cal)(o,s),r=d((0,c.cal_to_utc)(o,t.alignToNearestSessionStart(n,1)),(0,c.cal_to_utc)(o,t.alignToNearestSessionEnd(n,1)),s),_=Math.min(r,a,l);_!==1/0?(this._nextSessionEdgeInternal={timestamp:u},u=_):this._nextSessionEdgeInternal={timestamp:null}}this._nextSessionEdgeInternal=u===l?{timestamp:u,status:"post_market"}:u===a?{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()}}},22118:(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(13665),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}},76032:(e,t,i)=>{"use strict";i.d(t,{getStudyTemplateDescString:()=>a,getStudyTemplateMetaInfo:()=>n,getStudyTemplateSaveData:()=>r});var s=i(19466),o=i(79036);function n(e,t){return{indicators:e.orderedDataSources(!0).filter((e=>(0,o.isStudy)(e)&&!0)).map((e=>({id:e.metaInfo().id,description:e.title(s.TitleDisplayTarget.StatusLine,!0,void 0,!0)}))),interval:t}}function r(e,t,i,s){const o=t.studyTemplate(i,s);return{name:e,content:JSON.stringify(o),meta_info:n(t,o.interval)}}function a(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(", ")}},79652:(e,t,i)=>{"use strict";i.d(t,{canShowSpreadActions:()=>o,globalKeypressMatches:()=>n});var s=i(56570);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")}},50340:(e,t,i)=>{"use strict";function s(){return Promise.all([i.e(359),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(9481),i.e(4600),i.e(2564),i.e(7384),i.e(2197),i.e(1072),i.e(9325),i.e(116),i.e(8985),i.e(4106),i.e(7444),i.e(2227),i.e(4931),i.e(9418),i.e(2544),i.e(3202),i.e(2751),i.e(1754)]).then(i.bind(i,89324))}i.d(t,{loadNewSymbolSearch:()=>s})},79320:(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}},96e3:(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}}},19475:(e,t,i)=>{"use strict";i.d(t,{addPlusButtonProperty:()=>p,restoreAddPlusButtonSettingsValue:()=>m,showPlusButtonOnCursor:()=>d});var s=i(26709),o=i(56570),n=i(56840),r=i(17625),a=i(64147);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"))}))},92934:(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()}},92158:(e,t,i)=>{"use strict";i.d(t,{actualAutoLogButtonsVisibility:()=>l,autoLogButtonsVisibilityOptions:()=>r,autoLogButtonsVisibilityProperty:()=>n,restoreAutoLogButtonsVisibilitySettingsValue:()=>a});var s,o=i(17656);!function(e){e.SettingsKey="PriceAxisAutoLogButtons.visibility"}(s||(s={}));const{property:n,availableValues:r,restoreDefaultValue:a,actualBehavior:l}=(0,o.createVisibilityController)("PriceAxisAutoLogButtons.visibility")},57596:(e,t,i)=>{"use strict";i.d(t,{axisLabelBackgroundColor:()=>o});var s=i(19625);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={}))},53388:(e,t,i)=>{"use strict";i.d(t,{createDwmAligner:()=>c,createTimeToBarTimeAligner:()=>d,isAlignmentEnabled:()=>h});var s=i(2740),o=i(56570),n=i(85049),r=i(42217),a=i(14381);const l=new r.SessionInfo("Etc/UTC","0000-0000:1234567");function c(e,t){if(!h()||!n.Interval.isDWM(e))return null;const i=new r.SessionInfo(t.timezone,t.session,t.session_holidays,t.corrections),o=(0,a.newBarBuilder)(e,i,l);return{timeToSessionStart:e=>o.tradingDayToSessionStart(e),timeToExchangeTradingDay:e=>{const t=(0,s.utc_to_cal)(i.timezone,e),o=i.spec.correctTradingDay(t);return(0,s.set_hms)(o,0,0,0,0,(0,s.get_timezone)("Etc/UTC")),o.getTime()}}}function h(){return!o.enabled("disable_resolution_rebuild")}function d(e,t){if(!h())return e=>e;const i=new r.SessionInfo(t.timezone,t.session,t.session_holidays,t.corrections),s=(0,a.newBarBuilder)(e,i,i,!1);return e=>s.alignTimeIfPossible(e)}},42217:(e,t,i)=>{"use strict";i.d(t,{BarBuilderBase:()=>a,SessionInfo:()=>r});var s=i(2740),o=i(83910),n=i(17326);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)}}},14381:(e,t,i)=>{"use strict";i.r(t),i.d(t,{SessionInfo:()=>r.SessionInfo,alignExchangeTimeToSessionStartAndReturnUTC:()=>D,alignPeriodsBackForDataRequest:()=>M,alignPeriodsBackForVisibleRange:()=>A,getPeriodsBetweenDates:()=>k,isTradingNow:()=>E,newBarBuilder:()=>I})
;var s=i(2740),o=i(85049),n=i(9859),r=i(42217),a=i(83910);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(79324);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 P(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 P(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 P{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 T,x;function I(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 P(t)}throw new Error(`Unknown dwm resolution: ${e}`)}(n.kind(),t),s)}function M(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 D(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 E(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"}(T||(T={})),function(e){e[e.D=864e5]="D",e[e.W=6048e5]="W"}(x||(x={}))},79324:(e,t,i)=>{"use strict";i.d(t,{BusinessDay:()=>n});var s=i(2740),o=i(32956);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))}}},83910:(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={}))},40644:(e,t,i)=>{"use strict";i.d(t,{extrapolateBarsFrontByCount:()=>n,extrapolateBarsFrontToTime:()=>o});var s=i(83910);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}}},17326:(e,t,i)=>{"use strict";i.d(t,{SessionsSpec:()=>P});var s,o=i(50151),n=i(2740),r=i(29981),a=i(79324);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 P{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?P._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=P._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)}}},15716:(e,t,i)=>{"use strict";i.d(t,{barFunctionByStyle:()=>o});var s=i(3070);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")}}},91988:(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)}}},42989:(e,t,i)=>{"use strict";i.d(t,{allChartStyles:()=>o});var s=i(56570);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]))}},91920:(e,t,i)=>{"use strict";var s=i(68979).makeFont,o=i(68979).parseFont,n=i(9343).getLogger;const{drawPoly:r}=i(37743);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},46088:(e,t,i)=>{"use strict";var s;i.d(t,{ColorType:()=>s}),function(e){e.Solid="solid",e.Gradient="gradient"}(s||(s={}))},85856:(e,t,i)=>{"use strict";i.d(t,{ConflatedChunksBuilder:()=>r});var s=i(50151),o=i(29981);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._conflatedChunks={chunks:new Map,priceSource:null,priceSourcesProvider:t},this._clearConflatedChunks()}conflatedChunks(e,t){if(t!==this._conflatedChunks.priceSource){this._conflatedChunks.priceSource=t;const e=this._plots.first();e&&(this._clearConflatedChunks(),this._rebuildConflatedChunks(e))}const i=(0,s.ensureDefined)(n.find((t=>t.forBarspacingLargerThen<=e)));return(0,s.ensureDefined)(this._conflatedChunks.chunks.get(i.barsToMerge))}mergeData(e){const t=this._plots.size(),i=this._plots.merge(e);return i&&null!==this._conflatedChunks.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._clearConflatedChunks()}clearData(){this._plots.clear(),this._clearConflatedChunks()}_rebuildConflatedChunks(e){const t=this._conflatedChunks.priceSource;if(null===t)return;const i=e.index,r=this._conflatedChunks.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._conflatedChunks.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._conflatedChunks.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._conflatedChunks.priceSourcesProvider("close");n.forEach((i=>{const o=(0,s.ensureDefined)(this._conflatedChunks.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}))}_clearConflatedChunks(){n.forEach((e=>this._conflatedChunks.chunks.set(e.barsToMerge,[])))}}},50788:(e,t,i)=>{"use strict";i.d(t,{actualCurrencyUnitVisibility:()=>h,currencyUnitVisibilityOptions:()=>l,currencyUnitVisibilityProperty:()=>a,migrateShowCurrencyAndShowUnitProperties:()=>u,restoreCurrencyUnitVisibilitySettingsValue:()=>c});var s,o=i(17656),n=i(56840),r=i.n(n);!function(e){e.SettingsKey="PriceAxisCurrencyAndUnit.visibility"}(s||(s={}));const{property:a,availableValues:l,restoreDefaultValue:c,actualBehavior:h}=(0,o.createVisibilityController)("PriceAxisCurrencyAndUnit.visibility");let d=!1;function u(e,t){d||(d=!0,void 0===r().getValue("PriceAxisCurrencyAndUnit.visibility")&&a().setValue(e||t?"alwaysOn":"alwaysOff"))}},28120:(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)}}},36915:(e,t,i)=>{"use strict";i.d(t,{isLineToolState:()=>r,isMainSeriesState:()=>o,isStudyLineToolState:()=>a,isStudyState:()=>n});var s=i(15764);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)}},29137:(e,t,i)=>{"use strict";i.d(t,{DataSource:()=>d,getTranslatedStringForSource:()=>c,toInputDisplayFlags:()=>h});var s=i(45126),o=i(19466),n=i(92184),r=i(52033),a=i(64147),l=i(65383);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}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}}},7576:(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){}}},63829:(e,t,i)=>{"use strict";i.d(t,{dateFormatProperty:()=>l,restoreDateFormatSettingsValue:()=>c});var s=i(56840),o=i(17625),n=i(47462);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())))},32679:(e,t,i)=>{"use strict";i.d(t,{DefaultProperty:()=>q,allowSavingDefaults:()=>R,createDefaultsState:()=>B,extractAllPropertiesKeys:()=>N,extractState:()=>F,extractThemedColors:()=>W});var s,o=i(90054),n=i(16738),r=i(81960),a=i(54029),l=i(47339),c=i(39852),h=i(50279),d=i(15943),u=i(82433),_=i(83873),p=i(50151),m=i(24377),g=i(9343);function f(e){return e<0&&(e+=2*Math.PI),e}!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 y=[127,127,127];function v(e){const t=e[3],i=e.slice(0,3);for(let e=0;e<3;e++)i[e]=Math.round(i[e]*t+y[e]*(1-t));return i}function S(e,t){const i=function(e,t){const[i,s,o]=e,[n,r,a]=t,l=(Math.sqrt(s**2+o**2)+Math.sqrt(r**2+a**2))/2,c=.5*(1-Math.sqrt(Math.pow(l,7)/(Math.pow(l,7)+6103515625))),h=(1+c)*s,d=(1+c)*r,u=Math.sqrt(h*h+o*o),_=Math.sqrt(d*d+a*a),p=0===o&&0===h?0:f(Math.atan2(o,h)),m=0===a&&0===d?0:f(Math.atan2(a,d)),g=n-i,y=_-u;let v;const S=u*_;0===S?v=0:(v=m-p,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=(u+_)/2;let P;const T=p+m;P=u*_==0?T:Math.abs(p-m)<=Math.PI?T/2:T<2*Math.PI?(T+2*Math.PI)/2:(T-2*Math.PI)/2;const x=1-.17*Math.cos(P-Math.PI/6)+.24*Math.cos(2*P)+.32*Math.cos(3*P+Math.PI/30)-.2*Math.cos(4*P-Math.PI/180*63),I=Math.PI/6*Math.exp(-Math.pow((P-Math.PI/180*275)/(Math.PI/180*25),2)),M=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,D=-Math.sin(2*I)*M;return Math.sqrt(Math.pow(g/(1*A),2)+Math.pow(y/(1*L),2)+Math.pow(b/(1*k),2)+D*(y/(1*L))*(b/(1*k)))}(C(b(v((0,m.parseRgba)(e)))),C(b(v((0,m.parseRgba)(t)))));return i<3}function b(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 w;function C(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"}(w||(w={}));var P=i(24633),T=i(45345),x=i(85662),I=i(52033),M=i(72595),A=i(35039),L=i(12988);const k=(0,g.getLogger)("ThemedDefaults");function D(e){return e.value()===P.StdTheme.Dark?P.StdTheme.Dark:P.StdTheme.Light}function E(e,t,i){for(const s of t)if((0,r.default)(e,s),i){const t=s.split(".");for(t.pop();t.length;){const i=(0,a.default)(e,t);if(!(0,u.default)(i)||0!==Object.keys(i).length)break;(0,r.default)(e,t),t.pop()}}}function B(e,t,i,s){const r=e?A.defaults:A.factoryDefaults,a=t.startsWith("study_")?(0,o.default)(r("study")):{};let l=(0,o.default)(r(t,s));return t.startsWith("study_")&&l.inputs&&delete l.inputs.symbol,"linetoolicon"===t&&e&&(l.icon=(0,A.defaults)(t).icon),"linetooemoji"===t&&e&&(l.emoji=(0,A.defaults)(t).emoji),"linetoolsticker"===t&&e&&(l.sticker=(0,A.defaults)(t).sticker),l=(0,o.default)(l),E(l,i),(0,n.default)(a,l),a}let V=!1;function R(e){V=e}function N(e){const t=Object.keys(e),i=[];return t.forEach((t=>{const s=e[t];if((0,u.default)(s)){N(s).forEach((e=>i.push(`${t}.${e}`)))}else i.push(t)})),i}function O(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,u.default)(a)){
k.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]=O(a,e,l)}}else{if((0,u.default)(a)){k.logError(`path ${l} must be a primitive, but it is an object`);continue}s[r]=a}}return s}function F(e,t,i){if(!e)return{};let s=e;return t&&(s=O(e,t)),i&&E(s,i,!0),s}function W(e,t){const i=N(e),s=[];for(const o of i){const i=(0,a.default)(e,o),n=(0,a.default)(t,o);(0,p.assert)(void 0!==i,`Light theme value for ${o} is undefined`),(0,p.assert)(void 0!==n,`Dark theme value for ${o} is undefined`),s.push({path:o,colors:[i,n]})}return s}function H(e,t){e.includes(t)||e.push(t)}function z(e,t){const i=e.indexOf(t);-1!==i&&e.splice(i,1)}function U(e,t){const i=(0,c.default)(e,((e,i,s)=>{if(void 0===t[s])return e;if(!(0,h.default)(i,t[s]))if((0,u.default)(i)&&(0,u.default)(t[s])){const o=U(i,t[s]);void 0!==o&&(e[s]=o)}else e[s]=i;return e}),{});return(0,d.default)(i)?void 0:i}function G(e){return e===P.StdTheme.Dark?1:0}function j(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(!(0,_.default)(e)||!(0,_.default)(t))return!1;const i=(0,m.tryParseRgba)(e),s=(0,m.tryParseRgba)(t);return!(!i||!s)&&!!S(e,t)}class q extends L.Property{constructor(e){const{defaultName:t,nonThemedDefaultsKeys:i,themedDefaultsKeys:s,excludedDefaultsKeys:o=[],themedColors:r,replaceThemedColorsOnThemeChange:a=!1,allStateKeys:l,excludedStateKeys:c=[],excludedTemplateKeys:h=[],state:d,useUserPreferences:u=!0,saveNonDefaultUserPreferencesOnly:_=!1,ignoreAllowSavingDefaults:m=!1,alwaysSaveDefaultKeys:g=["version"],saveDefaultsConsumer:f=A.saveDefaults,factoryDefaultsSupplier:y=()=>B(!1,t,[],null),schema:v=(0,M.createPropertySchema)(y()),theme:S=T.watchedTheme.spawnOwnership()}=e;super(void 0,v),this._themedColors=[],this._restoreFactoryDefaultsEvent=new I.Delegate,this._replaceThemedColorsOnThemeChange=!1,this._forbidSavingDefaults=!1,this._defaultName=t,this._useUserPreferences=u,this._saveNonDefaultUserPreferencesOnly=_,this._ignoreAllowSavingDefaults=m,this._saveDefaultsConsumer=f,this._factoryDefaultsSupplier=y,this._allStateKeys=l,this._excludedStateKeys=c,this._nonThemedDefaultsKeys=i,this._themedDefaultsKeys=s,this._allDefaultsKeys=i||s?[...i??[],...s??[]]:void 0,this._excludedDefaultsKeys=o,this._excludedTemplateKeys=h,this._themedColors=r,this._alwaysSaveDefaultKeys=g,(0,p.assert)(void 0===this._allDefaultsKeys||0===this._excludedDefaultsKeys.length,"Defaults keys and excluded defaults keys cannot be used at the same time"),(0,p.assert)(void 0===this._allStateKeys||0===this._excludedStateKeys.length,"State keys and excluded state keys cannot be used at the same time"),this._theme=S;const b=D(this._theme);this.merge((0,n.default)(this._factoryDefaultsForTheme((0,x.isStdThemeName)(b)?b:P.StdTheme.Light),this._userSettings(),F(d,l,c))),r&&a&&this.setThemedColors(r),this._restoreFactoryDefaultsEvent=new I.Delegate}destroy(){this._theme?.release(),this._unsubscribeWatchedTheme?.(),super.destroy()}applyTemplate(e,t){this.mergeAndFire(F((0,
n.default)((0,o.default)(t),e),this._allStateKeys,this._excludedTemplateKeys))}preferences(){return F(this.state(this._excludedDefaultsKeys),this._allDefaultsKeys)}template(){return F(this.state(),void 0,this._excludedTemplateKeys)}mergePreferences(e){this.mergeAndFire(F(e,this._allDefaultsKeys,this._excludedDefaultsKeys))}addExcludedKey(e,t){1&t&&H(this._excludedDefaultsKeys,e),2&t&&H(this._excludedStateKeys,e),4&t&&H(this._excludedTemplateKeys,e)}removeExcludedKey(e,t){1&t&&z(this._excludedDefaultsKeys,e),2&t&&z(this._excludedStateKeys,e)}restoreFactoryDefaults(){const e=this.factoryDefaults();E(e,this._excludedDefaultsKeys),this.mergeAndFire(e),this._defaultName.startsWith("study_")&&!this._defaultName.startsWith("study_VbPFixed")||this.saveDefaults(),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=U(F(t,this._nonThemedDefaultsKeys),F(i,this._nonThemedDefaultsKeys,this._excludedDefaultsKeys)),this._alwaysSaveDefaultKeys.length){const i=F(t,this._alwaysSaveDefaultKeys);e=e??{},(0,n.default)(e,i)}const s=this.themeDefaults(D(this._theme)),o=this.themeState(),r=U(o,s);(0,d.default)(r)||(e=e??{},(0,n.default)(e,o))}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,l.default)(i,s,o[G(t)]);return i}(this._themedColors,e===P.StdTheme.Dark?P.StdTheme.Dark:P.StdTheme.Light);return F(this._factoryDefaultsSupplier(),this._themedDefaultsKeys,this._excludedDefaultsKeys)}factoryDefaults(){return this._factoryDefaultsForTheme(D(this._theme))}themeState(){const e=super.state(this._excludedDefaultsKeys),t=this._themedColors;return F(e,t?t.map((e=>e.path)):this._themedDefaultsKeys)}allThemePropertiesAreDefault(e){(0,p.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(!j((0,a.default)(e,i),(0,a.default)(t,i)))return!1}return!0}(this.themeState(),this.themeDefaults(e),this._themedColors)}clone(e){return new q(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 F(super.state([...this._excludedStateKeys,...e??[]],t),this._allStateKeys)}_updateThemedColors(e){if(!this._themedColors)return;const t=D(this._theme),i=t===P.StdTheme.Light?P.StdTheme.Dark:P.StdTheme.Light;for(const s of this._themedColors){const o=(0,p.ensureDefined)(this.childByPath(s.path)),n=s.colors[G(i)];(""===o.value()||!e&&j(o.value(),n))&&o.setValue(s.colors[G(t)])
}}_userSettings(){if(!this._useUserPreferences)return;const e=B(!0,this._defaultName,[],null);return e?F((0,o.default)(e),this._allDefaultsKeys,this._excludedDefaultsKeys):void 0}_options(){return{defaultName:this._defaultName,factoryDefaultsSupplier:this._factoryDefaultsSupplier,state:this.state(),nonThemedDefaultsKeys:this._nonThemedDefaultsKeys,themedDefaultsKeys:this._themedDefaultsKeys,excludedDefaultsKeys:this._excludedDefaultsKeys,themedColors:this._themedColors,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,n.default)(this._factoryDefaultsSupplier(),this.themeDefaults(e))}_propertyAffectsDefaults(e){return(this._ignoreAllowSavingDefaults||V)&&!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,L.isPrimitiveType)(this.childByPath(e)?.value())}}},35039:(e,t,i)=>{"use strict";var s=i(80720).PlDisplay;const{merge:o}=i(97085),{generateColor:n}=i(19063),{getStdChartTheme:r}=i(24317),{DEFAULT_THEME:a}=i(85662),l=i(49156).colors;var c=i(80720).TradedGroupHorizontalAlignment,h=i(5171),d=i(96333).LineToolPitchforkStyle,u=i(67467).LineToolBarsPatternMode,_=i(94113),p=_.LineStudyPlotStyle,m=_.STUDYPLOTDISPLAYTARGET,g=i(55158),f=i(94164).PriceAxisLastValueMode,y=i(92693).MagnetMode,v=i(49857).LineEnd,S=i(46088).ColorType;const b=i(35578).DEFAULT_LINE_TOOL_LINE_WIDTH;var w=i(39429).StatsPosition,C=i(6290).sessionsPreferencesDefault,P=i(57596).axisLabelBackgroundColor,T=i(9624).mainSeriesProperties;const{LINESTYLE_SOLID:x,LINESTYLE_DASHED:I}=i(51056);var M=i(9343).getLogger("Chart.Defaults")
;const{colorWhite:A,colorWhiteAlpha25:L,colorTvBlue50:k,colorTvBlue500:D,colorTvBlue500Alpha30:E,colorTvBlue500Alpha25:B,colorTvBlue500Alpha20:V,colorTvBlue600:R,colorDeepBlue200:N,colorDeepBlue300:O,colorDeepBlue500:F,colorDeepBlue500Alpha20:W,colorSkyBlue500:H,colorSkyBlue500Alpha20:z,colorSkyBlue700:U,colorSkyBlue700Alpha70:G,colorDefaultRed:j,colorRipeRed200:q,colorRipeRed300:$,colorRipeRed400:K,colorRipeRed400Alpha5:Y,colorRipeRed500:Z,colorRipeRed500Alpha30:X,colorRipeRed500Alpha20:J,colorRipeRed600:Q,colorGrapesPurple500:ee,colorGrapesPurple500Alpha0:te,colorGrapesPurple500Alpha20:ie,colorGrapesPurple500Alpha70:se,colorBerryPink400:oe,colorBerryPink500:ne,colorBerryPink500Alpha20:re,colorMintyGreen100:ae,colorMintyGreen400:le,colorMintyGreen500:ce,colorMintyGreen500Alpha20:he,colorIguanaGreen300:de,colorIguanaGreen500:ue,colorIguanaGreen500Alpha20:_e,colorTanOrange300:pe,colorTanOrange500:me,colorTanOrange500Alpha20:ge,colorTanOrange600:fe,colorTanOrange700:ye,colorColdGray150:ve,colorColdGray400:Se,colorColdGray450:be,colorColdGray500:we,colorColdGray900:Ce,colorColdGray750:Pe,colorForestGreen300:Te,colorForestGreen300Alpha5:xe}=l;var Ie=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},_=function(e,t,i,s,o){return{coeff:e,color:t,visible:i,linestyle:void 0===s?x:s,linewidth:void 0===o?b:o}},M=function(e,t,i){return{color:e,width:void 0===i?b:i,visible:t}},Ie=function(e,t,i,s,o){return{color:e,visible:t,width:i,x:s,y:o}},Me=function(e,t,i,s,o,n){return{coeff1:e,coeff2:t,color:i,visible:s,linestyle:void 0===o?x:o,linewidth:void 0===n?b:n}};if(void 0===TradingView.defaultProperties){var Le;switch(window.locale){case"ar_AE":Le="Asia/Dubai";break;case"au":Le="Australia/Sydney";break;case"br":Le="America/Sao_Paulo";break;case"ca":Le="America/Toronto";break;case"de_DE":case"it":Le="Europe/Berlin";break;case"es":Le="Europe/Madrid";break;case"he_IL":case"tr":Le="Europe/Athens";break;case"hu_HU":case"pl":Le="Europe/Warsaw";break;case"id":case"th_TH":case"vi_VN":Le="Asia/Bangkok";break;case"in":Le="Asia/Kolkata";break;case"ja":case"kr":Le="Asia/Tokyo";break;case"ms_MY":Le="Asia/Singapore";break;case"ru":Le="Europe/Moscow";break;case"uk":Le="Europe/London";break;case"zh_CN":case"zh_TW":Le="Asia/Shanghai";break;default:Le="Etc/UTC"}const e=r(a);TradingView.defaultProperties={chartproperties:o({timezone:Le,priceScaleSelectionStrategyName:"auto",inactivityGaps:!1,paneProperties:{backgroundType:S.Solid,gridLinesMode:"both",vertGridProperties:{style:x},horzGridProperties:{style:x},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},separatorColor:ve},scalesProperties:{fontSize:12,scaleSeriesOnly:!1,showSeriesLastValue:!0,seriesLastValueMode:f.LastValueAccordingToScale,showSeriesPrevCloseValue:!1,showStudyLastValue:!0,showSymbolLabels:!1,showStudyPlotLabels:!1,showBidAskLabels:!1,showPrePostMarketPriceLabel:!0,showFundamentalNameLabel:!1,showFundamentalLastValue:!0,barSpacing:g.DEFAULT_BAR_SPACING,axisHighlightColor:B,axisLineToolLabelBackgroundColorCommon:P.common,axisLineToolLabelBackgroundColorActive:P.active,showPriceScaleCrosshairLabel:!0,showTimeScaleCrosshairLabel:!0,crosshairLabelBgColorLight:Ce,crosshairLabelBgColorDark:Pe,saveLeftEdge:!1},mainSeriesProperties:o(T,e.content.mainSourceProperties),chartEventsSourceProperties:{visible:!0,futureOnly:!0,breaks:{color:"#555555",visible:!1,style:I,width:1}},tradingProperties:{showPositions:!0,positionPL:{visibility:!0,display:s.Money},bracketsPL:{visibility:!0,display:s.Money},showOrders:!0,showExecutions:!0,showExecutionsLabels:!1,showReverse:!0,horizontalAlignment:c.Right,extendLeft:!0,lineLength:5,lineWidth:1,lineStyle:x},volumePaneSize:"large"},e.content.chartProperties),sessions:o(C,e.content.sessions),drawings:{magnet:!1,magnetMode:y.WeakMagnet,stayInDrawingMode:!1,drawOnAllCharts:!0,drawOnAllChartsMode:1},linetoolorder:{extendLeft:"inherit",lineLength:"inherit",lineLengthUnit:"percentage",lineColor:j,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:L,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:A,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:L,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:L,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:A,quantityTextTransparency:0,quantityFontFamily:"Verdana",quantityFontSize:9,quantityFontBold:!0,quantityFontItalic:!1,reverseButtonBorderBuyColor:"#4094e8",reverseButtonBorderSellColor:"#e75656",reverseButtonBackgroundColor:L,reverseButtonBackgroundTransparency:25,reverseButtonIconBuyColor:"#4094e8",reverseButtonIconSellColor:"#e75656",closeButtonBorderBuyColor:"#4094e8",closeButtonBorderSellColor:"#e75656",closeButtonBackgroundColor:L,closeButtonBackgroundTransparency:25,closeButtonIconBuyColor:"#4094e8",closeButtonIconSellColor:"#e75656",tooltip:"",protectTooltip:"",closeTooltip:"",reverseTooltip:""},linetoolexecution:{direction:"buy",arrowHeight:8,arrowSpacing:1,arrowBuyColor:"#4094e8",arrowSellColor:"#e75656",text:"",textColor:l.colorBlack,textTransparency:0,fontFamily:"Verdana",fontSize:10,fontBold:!1,fontItalic:!1,tooltip:""},linetoolicon:{color:D,size:40,icon:61720,angle:.5*Math.PI},linetoolemoji:{size:40,emoji:"😀",angle:.5*Math.PI},linetoolsticker:{size:110,sticker:"bitcoin",angle:.5*Math.PI},linetoolimage:{transparency:0,cssWidth:0,cssHeight:0,angle:0},linetoolbezierquadro:{linecolor:D,linewidth:b,fillBackground:!1,backgroundColor:V,transparency:50,linestyle:x,extendLeft:!1,extendRight:!1,leftEnd:v.Normal,rightEnd:v.Normal},linetoolbeziercubic:{linecolor:F,linewidth:b,fillBackground:!1,backgroundColor:W,transparency:80,linestyle:x,extendLeft:!1,extendRight:!1,leftEnd:v.Normal,rightEnd:v.Normal},linetooltrendline:{linecolor:D,linewidth:b,linestyle:x,extendLeft:!1,extendRight:!1,leftEnd:v.Normal,rightEnd:v.Normal,showLabel:!1,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:w.Right},linetoolinfoline:{linecolor:D,linewidth:b,linestyle:x,extendLeft:!1,extendRight:!1,leftEnd:v.Normal,rightEnd:v.Normal,showLabel:!1,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:w.Center},linetooltimecycles:{linecolor:"#159980",linewidth:b,fillBackground:!0,backgroundColor:"rgba(106, 168, 79, 0.5)",transparency:50,linestyle:x},linetoolsineline:{linecolor:"#159980",linewidth:b,linestyle:x},linetooltrendangle:{linecolor:D,linewidth:b,linestyle:x,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:w.Right},linetooldisjointangle:{linecolor:ce,linewidth:b,linestyle:x,fillBackground:!0,backgroundColor:he,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:v.Normal,rightEnd:v.Normal,textcolor:ce,fontsize:12,bold:!1,italic:!1,showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1,labelVisible:!1,labelHorzAlign:"left",labelVertAlign:"bottom",labelTextColor:ce,labelFontSize:14,labelBold:!1,labelItalic:!1},linetoolflatbottom:{linecolor:me,linewidth:b,linestyle:x,fillBackground:!0,backgroundColor:ge,transparency:20,extendLeft:!1,extendRight:!1,leftEnd:v.Normal,rightEnd:v.Normal,textcolor:me,fontsize:12,bold:!1,italic:!1,showPrices:!1,showPriceRange:!1,showDateTimeRange:!1,showBarsRange:!1,labelVisible:!1,labelHorzAlign:"left",labelVertAlign:"bottom",labelTextColor:me,labelFontSize:14,labelBold:!1,labelItalic:!1},linetoolriskrewardshort:{linecolor:we,linewidth:1,textcolor:A,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:J,profitBackground:he,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:we,linewidth:1,textcolor:A,fontsize:12,fillLabelBackground:!0,labelBackgroundColor:"#585858",fillBackground:!0,stopBackground:J,profitBackground:he,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:b,linestyle:x,extendLeft:!1,extendRight:!1,leftEnd:v.Normal,rightEnd:v.Arrow,showLabel:!1,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:w.Right},linetoolray:{linecolor:D,linewidth:b,linestyle:x,extendLeft:!1,extendRight:!0,leftEnd:v.Normal,rightEnd:v.Normal,showLabel:!1,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:w.Right},linetoolextended:{linecolor:D,linewidth:b,linestyle:x,extendLeft:!0,extendRight:!0,leftEnd:v.Normal,rightEnd:v.Normal,showLabel:!1,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:w.Right},linetoolhorzline:{linecolor:D,linewidth:b,linestyle:x,showPrice:!0,showLabel:!1,textcolor:D,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"middle"},linetoolhorzray:{linecolor:D,linewidth:b,linestyle:x,showPrice:!0,showLabel:!1,textcolor:D,fontsize:12,bold:!1,italic:!1,horzLabelsAlign:"center",vertLabelsAlign:"top"},linetoolvertline:{linecolor:D,linewidth:b,linestyle:x,extendLine:!0,showTime:!0,showLabel:!1,horzLabelsAlign:"center",vertLabelsAlign:"middle",textcolor:D,textOrientation:"vertical",fontsize:14,bold:!1,italic:!1},linetoolcrossline:{linecolor:D,linewidth:b,linestyle:x,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:_(0,we,!0),level2:_(1,D,!0),level3:_(2,D,!0),level4:_(3,D,!0),level5:_(5,D,!0),level6:_(8,D,!0),level7:_(13,D,!0),level8:_(21,D,!0),level9:_(34,D,!0),level10:_(55,D,!0),level11:_(89,D,!0)},linetooltext:{color:D,fontsize:14,fillBackground:!1,backgroundColor:"rgba(91, 133, 191, 0.3)",backgroundTransparency:70,drawBorder:!1,borderColor:"#667b8b",bold:!1,italic:!1,fixedSize:!0,wordWrap:!1,wordWrapWidth:200},linetooltextabsolute:{color:D,fontsize:14,fillBackground:!1,backgroundColor:"rgba(155, 190, 213, 0.3)",backgroundTransparency:70,drawBorder:!1,borderColor:"#667b8b",bold:!1,italic:!1,fixedSize:!1,wordWrap:!1,wordWrapWidth:200},linetoolballoon:{color:A,backgroundColor:se,borderColor:te,fontsize:14,transparency:30},linetoolcomment:{color:A,backgroundColor:D,borderColor:D,fontsize:16,transparency:0},linetoolbrush:{linecolor:H,linewidth:b,smooth:5,fillBackground:!1,backgroundColor:H,transparency:50,leftEnd:v.Normal,rightEnd:v.Normal},linetoolhighlighter:{linecolor:J,smooth:5,transparency:80,width:20},linetoolpolyline:{linecolor:H,linewidth:b,linestyle:x,fillBackground:!0,backgroundColor:z,transparency:80,filled:!1},linetoolsignpost:{emoji:"🙂",showImage:!1,plateColor:D,fontSize:12,bold:!1,italic:!1},linetoolpath:{lineColor:D,lineWidth:b,lineStyle:x,leftEnd:v.Normal,rightEnd:v.Arrow},linetoolarrowmarkleft:{color:D,arrowColor:D,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkup:{color:ce,arrowColor:ce,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkright:{color:D,arrowColor:D,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolarrowmarkdown:{color:Q,arrowColor:Q,fontsize:14,bold:!1,italic:!1,showLabel:!0},linetoolflagmark:{
flagColor:D},linetoolpricelabel:{color:A,backgroundColor:D,borderColor:D,fontWeight:"bold",fontsize:14,transparency:0},linetoolarrowmarker:{backgroundColor:R,textColor:R,bold:!0,italic:!1,fontsize:16,showLabel:!0},linetoolrotatedrectangle:{color:ue,fillBackground:!0,backgroundColor:_e,transparency:50,linewidth:b},linetoolcircle:{color:me,backgroundColor:ge,fillBackground:!0,linewidth:b,showLabel:!1,textColor:me,fontSize:14,bold:!1,italic:!1},linetoolellipse:{color:Z,fillBackground:!0,backgroundColor:J,transparency:50,linewidth:b,showLabel:!1,textColor:Z,fontSize:14,bold:!1,italic:!1},linetoolarc:{color:ne,fillBackground:!0,backgroundColor:re,transparency:80,linewidth:b},linetoolprediction:{linecolor:D,linewidth:b,sourceBackColor:D,sourceTextColor:A,sourceStrokeColor:D,targetStrokeColor:D,targetBackColor:D,targetTextColor:A,successBackground:ue,successTextColor:A,failureBackground:Z,failureTextColor:A,intermediateBackColor:"#ead289",intermediateTextColor:"#6d4d22",transparency:10,centersColor:"#202020"},linetooltriangle:{color:ce,fillBackground:!0,backgroundColor:he,transparency:80,linewidth:b},linetoolcallout:{color:A,backgroundColor:G,transparency:50,linewidth:b,fontsize:14,bordercolor:U,bold:!1,italic:!1,wordWrap:!1,wordWrapWidth:200},linetoolparallelchannel:{linecolor:D,linewidth:b,linestyle:x,extendLeft:!1,extendRight:!1,fillBackground:!0,backgroundColor:V,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:b},linetoolelliotttriangle:{degree:7,showWave:!0,color:me,linewidth:b},linetoolelliotttriplecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:b},linetoolelliottcorrection:{degree:7,showWave:!0,color:"#3d85c6",linewidth:b},linetoolelliottdoublecombo:{degree:7,showWave:!0,color:"#6aa84f",linewidth:b},linetoolbarspattern:{color:D,mode:u.Bars,mirrored:!1,flipped:!1},linetoolghostfeed:{averageHL:20,variance:50,candleStyle:{upColor:ae,downColor:q,drawWick:!0,drawBorder:!0,borderColor:"#378658",borderUpColor:ce,borderDownColor:Z,wickColor:we},transparency:50},study:{inputs:{},styles:{},bands:{},graphics:{},ohlcPlots:{},palettes:{},filledAreasStyle:{},filledAreas:{},visible:!0,showLegendValues:!0,showLabelsOnPriceScale:!0,precision:"default"},linetoolpitchfork:{fillBackground:!0,transparency:80,style:d.Original,median:{visible:!0,color:Z,linewidth:b,linestyle:x},extendLines:!1,level0:_(.25,pe,!1),level1:_(.382,de,!1),level2:_(.5,ce,!0),level3:_(.618,ce,!1),level4:_(.75,H,!1),level5:_(1,D,!0),level6:_(1.5,ee,!1),level7:_(1.75,ne,!1),level8:_(2,$,!1)},linetoolpitchfan:{fillBackground:!0,transparency:80,median:{visible:!0,color:Z,linewidth:b,linestyle:x},level0:_(.25,pe,!1),level1:_(.382,de,!1),level2:_(.5,H,!0),level3:_(.618,ce,!1),level4:_(.75,H,!1),level5:_(1,D,!0),level6:_(1.5,ee,!1),level7:_(1.75,ne,!1),level8:_(2,$,!1)},linetoolgannfan:{linewidth:b,showLabels:!0,fillBackground:!0,
transparency:80,level1:Me(1,8,me,!0),level2:Me(1,4,ce,!0),level3:Me(1,3,ue,!0),level4:Me(1,2,ce,!0),level5:Me(1,1,H,!0),level6:Me(2,1,D,!0),level7:Me(3,1,ee,!0),level8:Me(4,1,ne,!0),level9:Me(8,1,Z,!0)},linetoolganncomplex:{fillBackground:!1,arcsBackground:{fillBackground:!0,transparency:80},reverse:!1,scaleRatio:"",showLabels:!0,labelsStyle:{fontSize:12,bold:!1,italic:!1},levels:[M(we,!0),M(me,!0),M(H,!0),M(ue,!0),M(ce,!0),M(we,!0)],fanlines:[Ie(N,!1,b,8,1),Ie(Z,!1,b,5,1),Ie(we,!1,b,4,1),Ie(me,!1,b,3,1),Ie(H,!0,b,2,1),Ie(ue,!0,b,1,1),Ie(ce,!0,b,1,2),Ie(ce,!1,b,1,3),Ie(D,!1,b,1,4),Ie(O,!1,b,1,5),Ie(N,!1,b,1,8)],arcs:[Ie(me,!0,b,1,0),Ie(me,!0,b,1,1),Ie(me,!0,b,1.5,0),Ie(H,!0,b,2,0),Ie(H,!0,b,2,1),Ie(ue,!0,b,3,0),Ie(ue,!0,b,3,1),Ie(ce,!0,b,4,0),Ie(ce,!0,b,4,1),Ie(D,!0,b,5,0),Ie(D,!0,b,5,1)]},linetoolgannfixed:{fillBackground:!1,arcsBackground:{fillBackground:!0,transparency:80},reverse:!1,levels:[M(we,!0),M(me,!0),M(H,!0),M(ue,!0),M(ce,!0),M(we,!0)],fanlines:[Ie(N,!1,b,8,1),Ie(Z,!1,b,5,1),Ie(we,!1,b,4,1),Ie(me,!1,b,3,1),Ie(H,!0,b,2,1),Ie(ue,!0,b,1,1),Ie(ce,!0,b,1,2),Ie(ce,!1,b,1,3),Ie(D,!1,b,1,4),Ie(O,!1,b,1,5),Ie(N,!1,b,1,8)],arcs:[Ie(me,!0,b,1,0),Ie(me,!0,b,1,1),Ie(me,!0,b,1.5,0),Ie(H,!0,b,2,0),Ie(H,!0,b,2,1),Ie(ue,!0,b,3,0),Ie(ue,!0,b,3,1),Ie(ce,!0,b,4,0),Ie(ce,!0,b,4,1),Ie(D,!0,b,5,0),Ie(D,!0,b,5,1)]},linetoolgannsquare:{color:"rgba(21, 56, 153, 0.8)",linewidth:b,linestyle:x,showTopLabels:!0,showBottomLabels:!0,showLeftLabels:!0,showRightLabels:!0,fillHorzBackground:!0,horzTransparency:80,fillVertBackground:!0,vertTransparency:80,reverse:!1,fans:t(Se,!1),hlevel1:i(0,we,!0),hlevel2:i(.25,me,!0),hlevel3:i(.382,H,!0),hlevel4:i(.5,ue,!0),hlevel5:i(.618,ce,!0),hlevel6:i(.75,D,!0),hlevel7:i(1,we,!0),vlevel1:i(0,we,!0),vlevel2:i(.25,me,!0),vlevel3:i(.382,H,!0),vlevel4:i(.5,ue,!0),vlevel5:i(.618,ce,!0),vlevel6:i(.75,D,!0),vlevel7:i(1,we,!0)},linetoolfibspeedresistancefan:{fillBackground:!0,transparency:80,grid:{color:"rgba(21, 56, 153, 0.8)",linewidth:1,linestyle:x,visible:!0},linewidth:b,linestyle:x,showTopLabels:!0,showBottomLabels:!0,showLeftLabels:!0,showRightLabels:!0,reverse:!1,hlevel1:i(0,we,!0),hlevel2:i(.25,me,!0),hlevel3:i(.382,H,!0),hlevel4:i(.5,ue,!0),hlevel5:i(.618,ce,!0),hlevel6:i(.75,D,!0),hlevel7:i(1,we,!0),vlevel1:i(0,we,!0),vlevel2:i(.25,me,!0),vlevel3:i(.382,H,!0),vlevel4:i(.5,ue,!0),vlevel5:i(.618,ce,!0),vlevel6:i(.75,D,!0),vlevel7:i(1,we,!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:we,linewidth:b,linestyle:I},levelsStyle:{linewidth:b,linestyle:x},level1:i(0,we,!0,!0),level2:i(.236,Z,!0,!0),level3:i(.382,me,!0,!0),level4:i(.5,ue,!0,!0),level5:i(.618,ce,!0,!0),level6:i(.786,H,!0,!0),level7:i(1,we,!0,!0),level8:i(1.618,D,!0,!0),level9:i(2.618,Z,!0,!0),level10:i(3.618,ee,!0,!0),level11:i(4.236,ne,!0,!0),
level12:i(1.272,me,!1,!0),level13:i(1.414,Z,!1,!0),level16:i(2,ce,!1,!0),level14:i(2.272,me,!1,!0),level15:i(2.414,ue,!1,!0),level17:i(3,H,!1,!0),level18:i(3.272,we,!1,!0),level19:i(3.414,D,!1,!0),level20:i(4,Z,!1,!0),level21:i(4.272,ee,!1,!0),level22:i(4.414,ne,!1,!0),level23:i(4.618,me,!1,!0),level24:i(4.764,ce,!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:b,linestyle:x},level1:i(0,we,!0),level2:i(.236,Z,!0),level3:i(.382,me,!0),level4:i(.5,ue,!0),level5:i(.618,ce,!0),level6:i(.786,H,!0),level7:i(1,we,!0),level8:i(1.618,D,!0),level9:i(2.618,Z,!0),level10:i(3.618,ee,!0),level11:i(4.236,ne,!0),level12:i(1.272,me,!1),level13:i(1.414,Z,!1),level16:i(2,ce,!1),level14:i(2.272,me,!1),level15:i(2.414,ue,!1),level17:i(3,H,!1),level18:i(3.272,we,!1),level19:i(3.414,D,!1),level20:i(4,Z,!1),level21:i(4.272,ee,!1),level22:i(4.414,ne,!1),level23:i(4.618,me,!1),level24:i(4.764,ce,!1)},linetoolprojection:{showCoeffs:!0,fillBackground:!0,transparency:80,color1:V,color2:ie,linewidth:b,trendline:{visible:!0,color:Se,linestyle:x},level1:_(1,"#808080",!0)},linetool5pointspattern:{color:D,textcolor:A,fillBackground:!0,backgroundColor:D,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:b},linetoolcypherpattern:{color:D,textcolor:A,fillBackground:!0,backgroundColor:D,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:b},linetooltrianglepattern:{color:F,textcolor:A,fillBackground:!0,backgroundColor:F,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:b},linetoolabcd:{color:ce,textcolor:A,fontsize:12,bold:!1,italic:!1,linewidth:b},linetoolthreedrivers:{color:F,textcolor:A,fillBackground:!0,backgroundColor:"rgba(149, 40, 204, 0.5)",fontsize:12,bold:!1,italic:!1,transparency:50,linewidth:b},linetoolheadandshoulders:{color:ce,textcolor:A,fillBackground:!0,backgroundColor:ce,fontsize:12,bold:!1,italic:!1,transparency:85,linewidth:b},linetoolfibwedge:{showCoeffs:!0,fillBackground:!0,transparency:80,trendline:{visible:!0,color:"#808080",linewidth:b,linestyle:x},level1:_(.236,Z,!0),level2:_(.382,me,!0),level3:_(.5,ue,!0),level4:_(.618,ce,!0),level5:_(.786,H,!0),level6:_(1,we,!0),level7:_(1.618,D,!1),level8:_(2.618,Z,!1),level9:_(3.618,F,!1),level10:_(4.236,ne,!1),level11:_(4.618,ne,!1)},linetoolfibcircles:{showCoeffs:!0,fillBackground:!0,transparency:80,coeffsAsPercents:!1,trendline:{visible:!0,color:we,linewidth:b,linestyle:I},level1:_(.236,Z,!0),level2:_(.382,me,!0),level3:_(.5,ce,!0),level4:_(.618,ue,!0),level5:_(.786,H,!0),level6:_(1,we,!0),level7:_(1.618,D,!0),level8:_(2.618,ne,!0),level9:_(3.618,D,!0),level10:_(4.236,ne,!0),level11:_(4.618,Z,!0)},linetoolfibspeedresistancearcs:{showCoeffs:!0,fillBackground:!0,transparency:80,fullCircles:!1,trendline:{visible:!0,color:we,linewidth:b,linestyle:I},level1:_(.236,Z,!0),level2:_(.382,me,!0),level3:_(.5,ce,!0),level4:_(.618,ue,!0),level5:_(.786,H,!0),level6:_(1,we,!0),level7:_(1.618,D,!0),
level8:_(2.618,ne,!0),level9:_(3.618,D,!0),level10:_(4.236,ne,!0),level11:_(4.618,Z,!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:we,linewidth:b,linestyle:I},levelsStyle:{linewidth:b,linestyle:x},level1:i(0,we,!0,!0),level2:i(.236,Z,!0,!0),level3:i(.382,me,!0,!0),level4:i(.5,ue,!0,!0),level5:i(.618,ce,!0,!0),level6:i(.786,H,!0,!0),level7:i(1,we,!0,!0),level8:i(1.618,D,!0,!0),level9:i(2.618,Z,!0,!0),level10:i(3.618,ee,!0,!0),level11:i(4.236,ne,!0,!0),level12:i(1.272,me,!1,!0),level13:i(1.414,Z,!1,!0),level16:i(2,ce,!1,!0),level14:i(2.272,me,!1,!0),level15:i(2.414,ue,!1,!0),level17:i(3,H,!1,!0),level18:i(3.272,we,!1,!0),level19:i(3.414,D,!1,!0),level20:i(4,Z,!1,!0),level21:i(4.272,ee,!1,!0),level22:i(4.414,ne,!1,!0),level23:i(4.618,me,!1,!0),level24:i(4.764,ce,!1,!0)},linetooltrendbasedfibtime:{showCoeffs:!0,fillBackground:!0,transparency:80,horzLabelsAlign:"right",vertLabelsAlign:"bottom",trendline:{visible:!0,color:we,linewidth:b,linestyle:I},level1:_(0,we,!0),level2:_(.382,Z,!0),level3:_(.5,de,!1),level4:_(.618,ue,!0),level5:_(1,ce,!0),level6:_(1.382,H,!0),level7:_(1.618,we,!0),level8:_(2,D,!0),level9:_(2.382,ne,!0),level10:_(2.618,ee,!0),level11:_(3,F,!0)},linetoolschiffpitchfork:{fillBackground:!0,transparency:80,style:d.Schiff,median:{visible:!0,color:Z,linewidth:b,linestyle:x},extendLines:!1,level0:_(.25,pe,!1),level1:_(.382,de,!1),level2:_(.5,ce,!0),level3:_(.618,ce,!1),level4:_(.75,H,!1),level5:_(1,D,!0),level6:_(1.5,ee,!1),level7:_(1.75,ne,!1),level8:_(2,$,!1)},linetoolschiffpitchfork2:{fillBackground:!0,transparency:80,style:d.Schiff2,median:{visible:!0,color:Z,linewidth:b,linestyle:x},extendLines:!1,level0:_(.25,pe,!1),level1:_(.382,de,!1),level2:_(.5,ce,!0),level3:_(.618,ce,!1),level4:_(.75,H,!1),level5:_(1,D,!0),level6:_(1.5,ee,!1),level7:_(1.75,ne,!1),level8:_(2,$,!1)},linetoolinsidepitchfork:{fillBackground:!0,transparency:80,style:d.Inside,median:{visible:!0,color:Z,linewidth:b,linestyle:x},extendLines:!1,level0:_(.25,pe,!1),level1:_(.382,de,!1),level2:_(.5,ce,!0),level3:_(.618,ce,!1),level4:_(.75,H,!1),level5:_(1,D,!0),level6:_(1.5,ee,!1),level7:_(1.75,ne,!1),level8:_(2,$,!1)},linetoolregressiontrend:{linewidth:1,linestyle:x,styles:{upLine:{display:m.All,color:E,linestyle:x,linewidth:b},downLine:{display:m.All,color:E,linestyle:x,linewidth:b},baseLine:{display:m.All,color:X,linestyle:I,linewidth:1},extendLines:!1,showPearsons:!0,transparency:70}}},Ae(TradingView.defaultProperties.chartproperties),ke()}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:m.All,color:D,linestyle:x,linewidth:1,plottype:p.Line,histogramBase:0,
title:"MA"}}}),void 0===TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]&&(TradingView.defaultProperties["study_PivotPointsHighLow@tv-basicstudies"]={fontsize:10,borderColor:D,backColor:k,textColor:Ce}),void 0===TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]){var De=!0;TradingView.defaultProperties["study_PivotPointsStandard@tv-basicstudies"]={_hardCodedDefaultsVersion:1,fontsize:11,levelsStyle:{showLabels:!0,visibility:{P:De,"S1/R1":De,"S2/R2":De,"S3/R3":De,"S4/R4":De,"S5/R5":De},colors:{P:fe,"S1/R1":fe,"S2/R2":fe,"S3/R3":fe,"S4/R4":fe,"S5/R5":fe},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 Ee={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 Be(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"]=Ee),void 0===TradingView.defaultProperties["study_TPOSessions@tv-volumebyprice"]&&(TradingView.defaultProperties["study_TPOSessions@tv-volumebyprice"]=Ee),void 0===TradingView.defaultProperties["study_VbPSessions@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPSessions@tv-volumebyprice"]=Be(!0)),void 0===TradingView.defaultProperties["study_VbPSessionsRoughDetailed@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPSessionsRoughDetailed@tv-volumebyprice"]=Be(!0)),void 0===TradingView.defaultProperties["study_VbPPeriodic@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPPeriodic@tv-volumebyprice"]=Be(!0)),void 0===TradingView.defaultProperties["study_VbPVisible@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPVisible@tv-volumebyprice"]=Be(!1));const Ve={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"]=Ve),void 0===TradingView.defaultProperties["study_VbPFixed@tv-basicstudies"]&&(TradingView.defaultProperties["study_VbPFixed@tv-basicstudies"]=Ve),
void 0===TradingView.defaultProperties.linetoolanchoredvp&&(TradingView.defaultProperties.linetoolanchoredvp=Be(!0)),void 0===TradingView.defaultProperties["study_VbPAutoAnchored@tv-volumebyprice"]&&(TradingView.defaultProperties["study_VbPAutoAnchored@tv-volumebyprice"]=Be(!0)),void 0===TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]&&(TradingView.defaultProperties["study_ElliottWave@tv-basicstudies"]={inputs:{},level0:t(j,!1),level1:t("#008000",!1),level2:t("#0000ff",!1),level3:t("#ff00ff",!1),level4:t("#0080ff",!0),level5:t(j,!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:m.All,color:E,linestyle:x,linewidth:1},downLine:{display:m.All,color:E,linestyle:x,linewidth:1},baseLine:{display:m.All,color:X,linestyle:x,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:h.STYLE_LINE,allowExtendTimeScale:!1,showPriceLine:!1,minTick:"default",candleStyle:{upColor:le,downColor:oe,drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:le,borderDownColor:oe,wickColor:"#737375",wickUpColor:le,wickDownColor:oe,barColorsOnPrevClose:!1},hollowCandleStyle:{upColor:le,downColor:oe,drawWick:!0,drawBorder:!0,drawBody:!0,borderColor:"#378658",borderUpColor:le,borderDownColor:oe,wickColor:"#737375",wickUpColor:le,wickDownColor:oe,barColorsOnPrevClose:!1},barStyle:{upColor:le,downColor:oe,barColorsOnPrevClose:!1,dontDrawOpen:!1,thinBars:!0},lineStyle:{color:ye,linestyle:x,linewidth:2,priceSource:"close"},lineWithMarkersStyle:{color:ye,linestyle:x,linewidth:2,priceSource:"close"},steplineStyle:{color:ye,linestyle:x,linewidth:2,priceSource:"close"},areaStyle:{color1:D,color2:D,linecolor:D,linestyle:x,linewidth:2,priceSource:"close",transparency:95},baselineStyle:{baselineColor:be,topFillColor1:xe,topFillColor2:xe,bottomFillColor1:Y,bottomFillColor2:Y,topLineColor:Te,bottomLineColor:K,topLineWidth:2,bottomLineWidth:2,priceSource:"close",transparency:50,baseLevelPercentage:50},hiloStyle:{color:D,showBorders:!0,borderColor:D,showLabels:!0,labelColor:D,drawBody:!0},columnStyle:{upColor:n(ce,50),downColor:n(Z,50),barColorsOnPrevClose:!0,priceSource:"close",baselinePosition:"bottom"},hlcAreaStyle:{highLineColor:ce,highLineStyle:x,highLineWidth:2,lowLineColor:Z,lowLineStyle:x,lowLineWidth:2,closeLineColor:be,closeLineStyle:x,closeLineWidth:2,highCloseFillColor:he,closeLowFillColor:J},hlcBarsStyle:{color:D,barColorsOnPrevClose:!1,thinBars:!0},styles:{open:{display:m.All,color:j,linestyle:x,linewidth:1,plottype:p.Line,histogramBase:0},high:{display:m.All,color:j,
linestyle:x,linewidth:1,plottype:p.Line,histogramBase:0},low:{display:m.All,color:j,linestyle:x,linewidth:1,plottype:p.Line,histogramBase:0},close:{display:m.All,color:j,linestyle:x,linewidth:1,plottype:p.Line,histogramBase:0}}}}for(var Re=e.split("."),Ne=TradingView.defaultProperties,Oe=0;Oe<Re.length;Oe++)Ne&&(Ne=Ne[Re[Oe]]);return null!=Ne?TradingView.clone(Ne):{}};function Me(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||M.logWarn("Path `"+e+"` does not exist.")}}function Ae(e,t,i,s){window.__defaultsOverrides&&Me(e,t,i,window.__defaultsOverrides,s)}function Le(e,t){window.__settingsOverrides&&Me(e,null,!1,window.__settingsOverrides,t)}function ke(){var e=/^linetool.+/;Object.keys(TradingView.defaultProperties).forEach((function(t){e.test(t)&&Ae(TradingView.defaultProperties[t],null,!1,t)}))}function De(e,t){return t?function(e,t){var i=Ie(e);if(!window._UNIT_TESTS){var s=TradingView.clone(TVSettings.getJSON(e,null));if(function(e){var t=new Set(["linetoolregressiontrend"]);return e.startsWith("study_")||t.has(e)}(e)&&s&&function(e){if(!e)return!1;e=e.toString();var t=new RegExp("\\d+").exec(e),i=null!==t&&t[0]===e;return i}(s.version)){var o=s.inputs,n=t.updateStudyInputs(s.id,s.version,"last",o,null);s.inputs=n,s=t.updateStudyState(s,s)}TradingView.merge(i,s),Le(i,e)}return i}(e,t):function(e){var t=Ie(e);if(!window._UNIT_TESTS){var i=TradingView.clone(TVSettings.getJSON(e,null));if(i){TradingView.merge(t,i);const s=e.split(".");Le(t,void 0===s[1]?e:s[1])}}return t}(e)}De.create=function(e,t){if(t){var i=Ie(e);TradingView.defaultProperties[e]=TradingView.merge(t,i)}},De.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=Ie,window.applyDefaultOverridesToLinetools=ke,window.applyDefaultsOverrides=Ae,window.applyPropertiesOverrides=Me,window.defaults=De,t.applyDefaultOverridesToLinetools=ke,t.applyDefaultsOverrides=Ae,t.applyPropertiesOverrides=Me,t.defaults=De,t.factoryDefaults=Ie,t.saveDefaults=TradingView.saveDefaults,t.createDefaults=De.create,t.removeDefaults=De.remove},928:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DrawingSyncMode:()=>s,SelectPointMode:()=>o,activePointSelectionMode:()=>Z,alignTo45Degrees:()=>xe,barTimesUnderCursor:()=>J,beenSetLineToolLastPoint:()=>N,cancelLineTool:()=>se,cancelledLineTool:()=>R,changeLineStyle:()=>_e,changeLineTool:()=>ce,changedLineStyle:()=>q,changedLineTool:()=>z,continueLineTool:()=>ie,continuedLineTool:()=>V,copiedLineTool:()=>$,copyLineTool:()=>pe,createLineTool:()=>te,createdLineTool:()=>B,crosshairLock:()=>P,cursorTool:()=>A,drawOnAllCharts:()=>Ie,drawOnAllChartsMode:()=>Me,emojiTool:()=>I,
finishChangingLineTool:()=>he,finishLineTool:()=>ue,finishMovingLineTool:()=>ae,finishedChangingLineTool:()=>U,finishedLineTool:()=>j,finishedMovingLineTool:()=>W,hideAllDrawings:()=>we,hideAllIndicators:()=>Ce,hideMarksOnBars:()=>Te,iconTool:()=>x,init:()=>ve,isDirectionalMovementActive:()=>E,isStudyEditingNow:()=>X,isToolCreatingNow:()=>L,isToolEditingNow:()=>k,isToolMovingNow:()=>D,lockDrawings:()=>Pe,moveLineTool:()=>re,movedLineTool:()=>F,properties:()=>be,removeLineTool:()=>de,removedLineTool:()=>G,resetToCursor:()=>f,restoreLineTool:()=>me,restoreLineToolState:()=>ge,restoredLineTool:()=>K,restoredLineToolState:()=>Y,runOnDrawingStateReady:()=>Se,setLineToolLastPoint:()=>oe,startChangingLineTool:()=>le,startMovingLineTool:()=>ne,startedChangingLineTool:()=>H,startedMovingLineTool:()=>O,stickerTool:()=>M,tool:()=>T,toolIsCursor:()=>p,toolIsDemonstration:()=>m,toolIsMeasure:()=>g});var s,o,n=i(50151),r=i(17625),a=i(32679),l=i(64147),c=i(91676),h=i(52033),d=i(56840),u=i(76422);!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 _=new Set(["cursor","arrow","dot","performance","demonstration"]);function p(e){return _.has(e)}function m(e){return"demonstration"===e}function g(e){return"measure"===e}function f(e=!1){if(!e&&y){if(y.childs().stayInDrawingMode.value())return}T.setValue(A.value())}let y=null,v=null,S=null,b=null,w=null,C=null;const P=new c.WatchedObject(null),T=new l.WatchedValue,x=new l.WatchedValue,I=new l.WatchedValue,M=new l.WatchedValue,A=new l.WatchedValue,L=new l.WatchedValue(!1),k=new l.WatchedValue(!1),D=new l.WatchedValue(!1),E=new l.WatchedValue(!1),B=new h.Delegate,V=new h.Delegate,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,G=new h.Delegate,j=new h.Delegate,q=new h.Delegate,$=new h.Delegate,K=new h.Delegate,Y=new h.Delegate,Z=new l.WatchedValue(o.None),X=new l.WatchedValue(!1),J=new Map;function Q(e,t){const i=t||{value:!1};return t=>{i.value||(i.value=!0,e.fire(t),i.value=!1)}}const ee={value:!1},te=Q(B,ee),ie=Q(V,ee),se=Q(R,ee),oe=Q(N,ee),ne=Q(O),re=Q(F),ae=Q(W),le=Q(H),ce=Q(z),he=Q(U),de=Q(G),ue=Q(j),_e=Q(q,ee),pe=Q($,ee),me=Q(K),ge=Q(Y);let fe=!1,ye=[];function ve(){if(fe)return;const e=d.getValue("chart.cursorPreference","cursor");T.setValue(p(e)?e:"cursor"),T.subscribe((e=>p(e)&&A.setValue(e)),{callWithLast:!0}),A.subscribe((e=>{e&&"performance"!==e&&!m(e)&&d.setValue("chart.cursorPreference",e)})),y=new a.DefaultProperty({defaultName:"drawings"}),v=(0,r.createPrimitiveProperty)(!1),S=(0,r.createPrimitiveProperty)(!1),b=(0,r.createPrimitiveProperty)(!1),w=(0,r.createPrimitiveProperty)(!d.getBool("BarsMarksContainer.visibile",!0)),C=(0,r.createPrimitiveProperty)(!1),T.subscribe((e=>{(0,u.emit)("onSelectedLineToolChanged")})),fe=!0,ye.forEach((e=>e())),ye=[]}function Se(e){fe?e():ye.push(e)}function be(){return(0,n.ensureNotNull)(y)}function we(){return(0,n.ensureNotNull)(v)}
function Ce(){return(0,n.ensureNotNull)(S)}function Pe(){return(0,n.ensureNotNull)(b)}function Te(){return(0,n.ensureNotNull)(w)}function xe(){return(0,n.ensureNotNull)(C)}function Ie(){return be().childs().drawOnAllCharts}function Me(){return be().childs().drawOnAllChartsMode}},28331:(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})}}},73698:(e,t,i)=>{"use strict";i.d(t,{decodeExtendedSymbol:()=>l,encodeExtendedSymbolOrGetSimpleSymbolString:()=>r,isEncodedExtendedSymbol:()=>a,isStudySymbol:()=>n});function s(e){return"="+JSON.stringify(o(e))}function o(e){return Object.keys(e).sort().reduce(((t,i)=>("[object Object]"===Object.prototype.toString.call(e[i])?t[i]=o(e[i]):t[i]=e[i],t)),{})}function n(e){return Boolean(e.inputs)}function r(e){return s(e)}function a(e){return"="===e[0]}function l(e){if(!a(e))return{symbol:e};try{return JSON.parse(e.slice(1))}catch(t){return{symbol:e}}}},32956:(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})},24526:(e,t,i)=>{"use strict";i.d(t,{customFormatters:()=>s});const s={dateFormatter:null,timeFormatter:null,tickMarkFormatter:null,priceFormatterFactory:null,studyFormatterFactory:null}},47462:(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(58683);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=>e.toLocaleDateString(window.language?(0,o.getIsoLanguageCodeFromLanguage)(window.language):void 0,{weekday:"short",timeZone:"UTC"}),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){return"ja"===window.language?(t,i)=>`${f[e](t,i)} (${h(t)})`:(t,i)=>`${h(t)} ${f[e](t,i)}`}const v=Object.keys(f),S=()=>-1!==["ja","ko","zh","zh_TW"].indexOf(window.language||"")?"yyyy-MM-dd":"dd MMM 'yy"},82826:(e,t,i)=>{"use strict";i.d(t,{DateFormatter:()=>n});var s=i(24526),o=i(47462);class n{constructor(e="yyyy-MM-dd",t=!1){this._dateFormatFunc=t?(0,o.getDateFormatWithWeekday)(e):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}}}},52388:(e,t,i)=>{"use strict";i.d(t,{DateTimeFormatter:()=>r});var s=i(15344),o=i(82826);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),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)}`}}},58683:(e,t,i)=>{"use strict";i.d(t,{numDependencyFormatter:()=>n,numberToStringWithLeadingZero:()=>o});var s=i(37265);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("0000000000000000"+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}}},73866:(e,t,i)=>{"use strict";i.d(t,{LimitedPrecisionNumericFormatter:()=>n});var s,o=i(59623);!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}}},53085:(e,t,i)=>{"use strict";i.d(t,{formatNumber:()=>r,parseNumber:()=>l});var s=i(60521),o=i(59332),n=i(63273);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 t=new s.Big(e);a=t.lt(1)?t.toFixed():t.toString()}}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}},11345:(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}}},59623:(e,t,i)=>{"use strict";i.d(t,{NumericFormatter:()=>n});var s=i(53085),o=i(11345);class n{constructor(e={}){this._options=e}format(e,t){if(!Number.isFinite(e))return String(e);const{ignoreLocaleNumberFormat:i,precision:r,minPrecision:a}=this._options,l=(0,o.getNumberFormat)(i||t?.ignoreLocaleNumberFormat);return void 0===r?n._formatNoEImpl(e,l,r,a):(0,
s.formatNumber)(e,l,r,void 0,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)}}},719:(e,t,i)=>{"use strict";i.d(t,{PercentageFormatter:()=>n});var s=i(725),o=i(63273);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)}}},725:(e,t,i)=>{"use strict";i.d(t,{PriceFormatter:()=>T});var s=i(60521),o=i(9343),n=i(50151),r=i(11542),a=i(50335),l=i(37265);function c(e){return e?(0,s.Big)(e.minMove).div(e.priceScale).toNumber():NaN}function h(e){const{minTick:t,price:i,variableMinTickData:s,shouldCheckForEquality:o}=e,n=(0,a.isNumber)(t)?d(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 d(e){const t=function(e){return(new s.Big(e).toFixed().split(".")[1]||"").length}(e),i=Math.pow(10,t);return{priceScale:i,minMove:(0,s.Big)(e).mul(i).toNumber()}}function u(e,t){const i=[{minTick:(0,a.isNumber)(e)?d(e):e,price:1/0,maxIndex:1/0}];try{const e=t.split(" ").map(((e,t)=>(0,l.isEven)(t)?function(e){const t=Number(e);if(Number.isFinite(t))return d(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,l.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(c(e[t])).plus(r).toNumber();i.push({minTick:e[t],price:o,maxIndex:a})}return i}catch{return i}}var _=i(63273);const p=new RegExp(/^(-?)[0-9]+$/);function m(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 g(e,t,i){const s=(0,n.ensureNotNull)(h({price:i,minTick:null,variableMinTickData:t,shouldCheckForEquality:!0})),{priceScale:o,minMove:r,minMove2:a}=s;return{priceScale:o,minMove:r,
fractionalLength:m(o,r,e,a)}}class f{constructor(e){this._formatterErrors={custom:r.t(null,void 0,i(66123)),fraction:r.t(null,void 0,i(39643)),secondFraction:r.t(null,void 0,i(70784))};const{priceScale:t,minMove:s,minMove2:o,ignoreMinMove:n,variableMinTick:a,fractionalLength:l}=e;this._priceScale=t,this._minMove=s,this._minMove2=o,this._ignoreMinMove=n,this._variableMinTickData=void 0===a?void 0:u({priceScale:t,minMove:s,minMove2:o},a),this._fractionalLength=l}formatImpl(e,t={}){const{signPositive:i,signNegative:s=!0,tailSize:o,cutFractionalByPrecision:n=!1,useRtlFormat:r=!0,variableMinTickDataPrice:a,ignoreLocaleNumberFormat:l,removeAllEndingZeros:c}=t;let h="";e<0?h=!1===s?"":"":e&&!0===i&&(h="+");const d=h+this._formatUnsigned(Math.abs(e),o,n,a,l,c);return r?(0,_.forceLTRStr)(d):d}parse(e,t){return"+"===(e=(e=(0,_.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 y=i(53085),v=i(58683),S=i(11345);const b=(0,o.getLogger)("Chart.DecimalPriceFormatter");class w extends f{constructor(e){super(e);const{minMove2:t,ignoreLocaleNumberFormat:i}=e;void 0!==t&&10!==t&&0!==t&&1!==t&&b.logDebug("invalid minmove2"),this._ignoreLocaleNumberFormat=i}hasForexAdditionalPrecision(){return 10===this._minMove2}_parseUnsigned(e,t){return this._parseAsDecimal(e,t)}_formatUnsigned(e,t,i,s,o,n){const r={price:Math.abs(e),priceScale:this._priceScale,minMove:this._minMove,fractionalLength:this._fractionalLength,tailSize:t,cutFractionalByPrecision:i,ignoreLocaleNumberFormat:o,removeAllEndingZeros:n};return void 0!==this._variableMinTickData&&(Object.assign(r,g(!1,this._variableMinTickData,s??r.price)),this._ignoreMinMove&&(r.minMove=1)),this._formatAsDecimal(r)}_formatAsExponential(e,t){const i=Math.floor(.75*Math.log10(this._priceScale)),s=e*Math.pow(10,i),o=`e-${i}`,n=Math.log10(this._priceScale)-i;return`${s.toFixed(n).replace(".",t.decimalSign)}${o}`}_formatAsDecimal(e){const{price:t,priceScale:i,minMove:o,fractionalLength:n=0,tailSize:r=0,cutFractionalByPrecision:a,ignoreLocaleNumberFormat:l,removeAllEndingZeros:c}=e,h=(0,S.getNumberFormat)(this._ignoreLocaleNumberFormat||l);if(t>=1e21)return t.toString().replace(".",h.decimalSign);if(i>1e15)return this._formatAsExponential(t,h);const d=Math.pow(10,r)*i/(a?1:o),u=1/d;let _;if(d>1)_=Math.floor(t);else{const e=Math.floor(Math.round(t/u)*u);_=0===Math.round((t-e)/u)?e:e+u}let p="";if(d>1){let e=a?new s.Big(t).mul(d).round(void 0,0).minus(new s.Big(_).mul(d)).toNumber():parseFloat((Math.round(t*d)-_*d).toFixed(n));e>=d&&(e-=d,_+=1),e=a?new s.Big(e).round(n,0).toNumber():parseFloat(e.toFixed(n))*o;const i=(0,v.numberToStringWithLeadingZero)(e,n+r),l=this._removeEndingZeros(i,c?i.length:r);p=l?h.decimalSign+l:l}return(0,y.formatNumber)(_,h)+p}_parseAsDecimal(e,t={}){const{ignoreLocaleNumberFormat:i}=t,s=(0,S.getNumberFormat)(this._ignoreLocaleNumberFormat||i),o=(0,y.parseNumber)(e,s);return Number.isFinite(o)?{value:o,res:!0,suggest:this.formatImpl(o)
}:{error:this._formatterErrors.custom,res:!1}}}const C=(0,o.getLogger)("Chart.FractionalPriceFormatter");class P extends f{constructor(e){super(e);const{minMove2:t}=e;null!=t&&t>0&&2!==t&&4!==t&&8!==t&&C.logDebug("invalid minmove2")}hasForexAdditionalPrecision(){return!1}_parseUnsigned(e){return this._minMove2?this._parseAsDoubleFractional(e):this._parseAsSingleFractional(e)}_formatUnsigned(e,t,i,s){const o={price:Math.abs(e),priceScale:this._priceScale,minMove:this._minMove,minMove2:this._minMove2,fractionalLength:(0,n.ensureDefined)(this._fractionalLength),tailSize:t};return void 0!==this._variableMinTickData&&Object.assign(o,g(!0,this._variableMinTickData,s??o.price)),this._formatAsFractional(o)}_parseAsSingleFractional(e){let t=p.exec(e);if(t){const t=parseFloat(e);return{value:t,res:!0,suggest:this.formatImpl(t)}}if(t=new RegExp("^(-?)([0-9]+)\\"+S.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=p.exec(e);if(t){const t=parseFloat(e);return{value:t,res:!0,suggest:this.formatImpl(t)}}if(t=new RegExp("^(-?)([0-9]+)\\"+S.formatterOptions.decimalSignFractional+"([0-9]+)\\"+S.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,v.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,v.numberToStringWithLeadingZero)(c,r),i=this._getFractPart(e,2,n);d=t+S.formatterOptions.decimalSignFractional+i}else c=this._getFractPart(c,1,s),d=(0,v.numberToStringWithLeadingZero)(c*o,r);return l.toString()+S.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}}class T{
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,l.isNumber)(e.priceScale)&&(0,l.isInteger)(e.priceScale)?e.priceScale:100,c=m(a,r,i,t),h={...e,minMove:r,priceScale:a,fractionalLength:c};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=c,this._ignoreLocaleNumberFormat=n,this._implementation=i?new P(h):new w(h)}isFractional(){return!!this._fractional}state(){return{minMove:this._minMove,minMove2:this._minMove2,priceScale:this._priceScale,variableMinTick:this._variableMinTick,ignoreMinMove:this._ignoreMinMove,fractional:this._fractional}}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 T(e)}}},15344:(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(24526),o=i(58683);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}}},92953:(e,t,i)=>{"use strict";i.d(t,{TimeSpanFormatter:()=>r});var s=i(11542),o=i(53085),n=i(11345);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()}}},46084:(e,t,i)=>{"use strict";i.d(t,{VolumeFormatter:()=>l});var s=i(11542),o=i(59623),n=i(37265);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,removeSpaceBeforeDimension:l}=e;this._precision=t,this._formatter=new o.NumericFormatter({ignoreLocaleNumberFormat:a,precision:this._precision,minPrecision:i}),this._dimensionPrecision=s,this._dimensionFormatter=new o.NumericFormatter({ignoreLocaleNumberFormat:a,precision:this._dimensionPrecision,minPrecision:n}),this._significantDigits=r,this._fractionalValues=void 0!==t&&t>0,this._spaceBeforeDimension=l?"":"",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),s=i.res?i.value:NaN;return(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})}}},41991:(e,t,i)=>{"use strict";i.d(t,{getPriceValueFormatterForSource:()=>l,getPriceValueFormatterForStudy:()=>c,shouldBeFormattedAsIndexedTo100:()=>r,shouldBeFormattedAsPercent:()=>n});var s=i(68805),o=i(60074);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)}},56468:(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}}},52397:(e,t,i)=>{"use strict";i.d(t,{HorizontalLinePaneView:()=>n});var s=i(50600),o=i(51056);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}}},80720:(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,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={}))},77148:(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={}))},19466:(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={}))},85049:(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)}},31229:(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}},94260:(e,t,i)=>{"use strict";i.d(t,{IntervalsVisibilitiesProperty:()=>o});var s=i(12988);i(10892);class o extends s.Property{state(e,t){return super.state(e,t)}storeStateIfUndefined(){return!1}}},10892:(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(85049),l=i(31229);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={}))},22820:(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={}))},8025:(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={}))},66666:(e,t,i)=>{"use strict";function s(e){return Boolean(e.showInObjectTree)}i.d(t,{isDataSource:()=>s})},1819:(e,t,i)=>{"use strict";i.d(t,{isTicksEnabled:()=>o});var s=i(56570);function o(){return s.enabled("tick_resolution")}},4340:(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"},60074:(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})},23486:(e,t,i)=>{"use strict";i.d(t,{alwaysShowLastPriceAndLastDayChange:()=>s,lastDayChangeAvailable:()=>o});i(56570);const s=!1,o=!1},85719:(e,t,i)=>{"use strict";i.d(t,{lineToolsDoNotAffectChartInvalidation:()=>s});const s=!1},67467:(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={}))},64195:(e,t,i)=>{"use strict";i.d(t,{LineToolBrushBase:()=>r});var s=i(50151),o=i(29875),n=i(64147);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}}},97435:(e,t,i)=>{"use strict";i.d(t,{CircleRenderer:()=>r});var s=i(34026),o=i(56468),n=i(61993);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)}}},35578:(e,t,i)=>{"use strict";i.d(t,{DEFAULT_LINE_TOOL_LINE_WIDTH:()=>s});const s=2},65365:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LineToolElliott:()=>m,LineToolElliottCorrection:()=>T,LineToolElliottDegree:()=>s,LineToolElliottDoubleCombo:()=>I,LineToolElliottImpulse:()=>y,LineToolElliottTriangle:()=>S,LineToolElliottTripleCombo:()=>w});var s,o,n=i(11542),r=i(45126),a=i(29875),l=i(29023),c=i(32679),h=i(73305),d=i(85719);!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(67736))},{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(9116),i.e(1200),i.e(1583)]).then(i.bind(i,98424)).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(6406),i.e(3889),i.e(8009),i.e(8056),i.e(8537)]).then(i.bind(i,70491))).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 P=[["0","A","B","C"],["0","a","b","c"],["0","A","B","C"],["0","a","b","c"],["0","A","B","C"]];class T extends C{constructor(e,t,i,s){super(e,t??T.createProperties(e.backgroundTheme().spawnOwnership()),i,s)}name(){return"Elliott Correction Wave (ABC)"}labelsGroup(){return P}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 I extends C{constructor(e,t,i,s){super(e,t??I.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}}},56991:(e,t,i)=>{"use strict";i.r(t),i.d(t,{ExecutionLineAdapter:()=>_,ExecutionsPositionController:()=>u,LineToolExecution:()=>p})
;var s=i(50151),o=i(29875),n=i(91920),r=i(32679),a=i(8025),l=i(56570),c=i(2718),h=i(44672);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(9116),i.e(1200),i.e(1583)]).then(i.bind(i,256)).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()}}},25931:(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]}`}},3503:(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(25931);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()}},70262:(e,t,i)=>{"use strict";i.d(t,{drawSelection:()=>r,getSymbolCoordinatesInfo:()=>n});var s=i(63273),o=i(7114);function n(e){const{symbolPosition:t,textWidth:i,textByLines:n,lineHeight:r,font:a,textAlign:l,lineSpacing:c=0}=e;let h=0,d=0;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||(h+=_);continue}f&&(h-=_);const S=r&&!c&&y.length===s&&v&&!v.hidden;if(f&&(g+="",s=g.length),"center"===l)if(S)d=i/2;else{const e=(0,o.measureText)(g,a).width,t=(0,o.measureText)(g.slice(0,s),a).width,n=i/2;d=u?n+e/2-t:n-e/2+t}else if("right"===l&&!u||"left"===l&&u||"end"===l)if(S)d=i;else{const e=(0,o.measureText)(g.slice(s),a).width;d=u?e:i-e}else if(S)d=0;else{const e=(0,o.measureText)(g.slice(0,s),a).width;d=u?i-e:e}S?(m=e+1,h+=_):m=e;break}return{x:d,y:h,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),P=Math.max(S,b);d||_.wrappedLinePart&&!_.wrappedLineEnd||(w?C-=t:P+=t);const T=Math.round(C*y),x=Math.round(P*y),I=Math.round((r.y+i*g)*v),M=Math.round((r.y+(i+1)*g)*v);e.fillRect(T,I,x-T,M-I),i+=1}}e.restore()}function a(e,t){return(0,o.measureText)(e,t).width}},15764:(e,t,i)=>{"use strict";i.d(t,{isLineDrawnWithPressedButton:()=>l,isLineToolDrawWithoutPoints:()=>h,isLineToolFinishRequiredWhenCreatedByApi:()=>c,isLineToolName:()=>a,isMtpPredictorToolName:()=>n,isStudyLineToolName:()=>r,isTextToolName:()=>d,simpleLineToolNames:()=>o});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")},78956:(e,t,i)=>{"use strict";i.d(t,{isLineTool:()=>o});var s=i(29875);function o(e){return e instanceof s.LineDataSource}},20834:(e,t,i)=>{"use strict";i.d(t,{LineDataSourcePointIndexProperty:()=>o});var s=i(12988);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)}}},90793:(e,t,i)=>{"use strict";i.d(t,{LineToolPriceAxisView:()=>r});var s=i(50151),o=i(98558),n=i(19063);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)}}},14169:(e,t,i)=>{"use strict";i.d(t,{LineDataSourceTimeAxisView:()=>o});var s=i(66156)
;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}}},29875:(e,t,i)=>{"use strict";i.d(t,{LineDataSource:()=>z,changePointUndoText:()=>H});var s=i(7029),o=i(86441),n=i(50151),r=i(76422),a=i(9343),l=i(56570),c=i(53388),h=i(40644),d=i(52033),u=i(18832),_=i(64147),p=i(62288),m=i(45687),g=i(10892),f=i(31229),y=i(68805),v=i(76350),S=i(85049),b=i(12988),w=i(928),C=i(29137),P=i(94260),T=i(37265),x=i(44672),I=i(60074),M=i(45126),A=i(20834);class L extends b.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 k=i(14169),D=i(90793),E=i(73305),B=i(98523),V=i(35039),R=i(7927);const N=(0,a.getLogger)("Chart.LineDataSource"),O=l.enabled("datasource_copypaste");class F{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 W=0;const H=new M.TranslatedString("change point",s.t(null,void 0,i(76660)));class z extends C.DataSource{constructor(e,t,i,s){if(super(s),this.version=1,this.toolname="",this.customization={forcePriceAxisLabel:!1,disableErasing:!1,disableSave:!1,showInObjectsTree:!0},this._currentPointsetAndSymbolId=null,this._pointChanged=new d.Delegate,this._pointAdded=new d.Delegate,this._priceAxisViews=[],this._timeAxisViews=[],this._timePoint=[],this._points=[],this._lastPoint=null,this._paneViews=new Map,this._normalizedPointsChanged=new d.Delegate,this._fixedPointsChanged=new d.Delegate,this._changeStatesStack=new F,this._startMovingPoint=null,
this._currentMovingPoint=null,this._isActualSymbol=!1,this._isActualInterval=!1,this._isActualCurrency=!1,this._isActualUnit=!1,this._sharingMode=new _.WatchedValue(0),this._onTemplateApplying=new d.Delegate,this._onTemplateApplied=new d.Delegate,this._syncStateExclusions=["interval"],this._definitionsViewModel=null,this._hasEditableCoordinates=new _.WatchedValue(!0),this._syncLineStyleMuted=!1,this._onIsActualIntervalChange=new d.Delegate,this._onPointsetUpdatedDelegate=new d.Delegate,this._onServerUpdateTime=new d.Delegate,this._linkKey=new _.WatchedValue(null),this._serverUpdateTime=null,this._boundCalcIsActualSymbol=this.calcIsActualSymbol.bind(this),this._alignerCache=null,this._alertUndoMode=!1,this._onAlertStatusChanged=()=>{this.updateAllViewsAndRedraw((0,x.sourceChangeEvent)(this.id()))},this._model=e,this._properties=t,this._localAndServerAlertsMismatch=!1,this._properties.hasChild("interval")||this._properties.addChild("interval",new b.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 k.LineDataSourceTimeAxisView(this,e));this._properties.childs().visible.subscribe(this,(e=>{const t=!1===(0,w.hideAllDrawings)().value();e.value()?e.value()&&t&&r.emit("drawing_event",this._id.value(),"show"):(this._model.selection().isSelected(this)&&this._model.selectionMacro((e=>{e.removeSourceFromSelection(this)})),t&&r.emit("drawing_event",this._id.value(),"hide")),this._onSourceHiddenMayChange()})),(0,w.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,R.propertyPathForSource)(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),(0,w.hideAllDrawings)().unsubscribeAll(this),this._sessionConnected.destroy(),this._alertStatus.unsubscribe(this._onAlertStatusChanged),this._properties.destroy(),super.destroy()}setId(e){super.setId(e),this._properties.setNameInOwner((0,R.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}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(){if(!this.isFixed())return;let e;const t=this.priceScale();if(this._positionPercents&&null!==t&&!t.isEmpty()){const i=this._positionPercents,s=this._model.timeScale().width()*i.x,n=t.height()*i.y;e=new o.Point(s,n)}else void 0!==this._fixedPoint&&(e=this._fixedPoint?.clone());if(this._currentMovingPoint&&this._startMovingPoint&&void 0!==e){const t=this._correctFixedPoint(e);t.didCorrect&&(e=t.point)}return e}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,x.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();r.emit("drawing_event",e,"move"),r.emit("drawing_event",e,"points_changed");for(let e=0;e<this._points.length;e++)this._pointChanged.fire(e)}}this._startMovingPoint=null,this._currentMovingPoint=null}const a={indexesChanged:s,pricesChanged:o};return this.isFixed()?(this.calcPositionPercents(),this.updateAllViews((0,x.sourceChangeEvent)(this.id())),a):(s&&this._points.forEach((e=>e.interval=this._model.mainSeries().interval())),this.updateAllViews((0,x.sourceChangeEvent)(this.id())),s&&!e?(this._properties.childs().interval.setValue(this._model.mainSeries().interval()),this._normalizePoints(),this.createServerPoints()):(this._copyPricesWithoutNormalization(),this._normalizedPointsChanged.fire()),a)}startMovingPoint(){return this._startMovingPoint?{...this._startMovingPoint}:null}currentMovingPoint(){return this._currentMovingPoint?{...this._currentMovingPoint}:null}changePointUndoText(e){return H}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()),r.emit("drawing_event",this._id.value(),"points_changed");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,x.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,
T.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();if(null===e)this._isActualSymbol=!1;else{const t=(0,n.ensureNotNull)(e.symbolSource()),i=t.symbolInfo();if(i){this._migrateSymbolProperty(i);const e=this._properties.childs().symbol,s=e.value();if(this._isActualSymbol=t.symbolSameAsCurrent(s),this._isActualSymbol){const o=(0,y.extractLineToolSymbolFromSymbolInfo)(i,t.symbol());(0,v.areEqualSymbols)(s,o)||(N.logWarn('Possible drawing "migrating" detected from "'+s+'" to "'+o+'"'),N.logWarn("Series symbolInfo: "+JSON.stringify(t.symbolInfo())),N.logWarn(`${(new Error).stack}`)),e.setValue(o)}}}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,y.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,g.isActualInterval)(S.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 N.logError("Failed to get alert, alert will not be saved with drawing in chart"),new Error("got_no_alert");return e}catch(e){if("not_exists"===e)throw new Error(e);return N.logError(`Getting alert failed: ${e instanceof Error?e.message:e}`),null}}getAlertSync(){return null}async synchronizeAlert(e=!1){}syncAlert(e){0}stateForAlert(){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):N.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}setOwnerSource(e){null!==this._ownerSource&&(this._ownerSource.currencyChanged().unsubscribeAll(this),this._ownerSource.unitChanged().unsubscribeAll(this)),null!==this._ownerSource&&(0,I.isSymbolSource)(this._ownerSource)&&(this._ownerSource.symbolResolved().unsubscribe(this,this._boundCalcIsActualSymbol),this._ownerSource.isActingAsSymbolSource().unsubscribe(this._boundCalcIsActualSymbol)),super.setOwnerSource(e),e&&(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){const t=this._model.timeScale(),i=this.priceScale(),s=this.ownerSource()?.firstValue();if(!i||i.isEmpty()||t.isEmpty()||null==s)return null;const n=t.indexToCoordinate(e.index),r=i.priceToCoordinate(e.price,s);return new o.Point(n,r)}screenPointToPoint(e,t){const i=this.priceScale(),s=this.ownerSource()?.firstValue();if(null==s||!isFinite(s)||null===i)return null;const o=this._model.timeScale(),n=t?o.coordinateToFloatIndex(e.x):o.coordinateToIndex(e.x);return{price:i.coordinateToPrice(e.y,s),index:n}}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,x.sourceChangeEvent)(this.id())),t||this._syncLineStyleIfNeeded(e),e||void 0!==this._pendingPropertyChangedEvent||(this._pendingPropertyChangedEvent=setTimeout((()=>{this._pendingPropertyChangedEvent=void 0,r.emit("drawing_event",this._id.value(),"properties_changed")}),0))}state(e){const t={type:this.toolname,id:this.id(),state:this.properties().state(this._propertiesStateExclusions()),points:(0,u.deepCopy)(this._timePoint),zorder:this.zorder(),ownerSource:this.ownerSource()?.id()};return t.isSelectionEnabled=this.isSelectionEnabled(),t.userEditEnabled=this.userEditEnabled(),this.linkKey().value()&&(t.linkKey=this.linkKey().value()),delete t.state.points,e&&(t.indexes=this._points),this.isFixed()&&(t.positionPercents=this._positionPercents||this.calcPositionPercents()),"version"in this&&1!==this.version&&(t.version=this.version),t}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){if(this._timePoint=(0,u.deepCopy)(e.points),t.indexesChanged){if(this.properties().childs().interval.setValue(e.interval),!this.isActualSymbol())return this._clearServerPoints(),void this._normalizedPointsChanged.fire();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._normalizedPointsChanged.fire()}restoreExternalState(e){this.properties().mergeAndFire(e)}applyTemplate(e){this._onTemplateApplying.fire(e),this._applyTemplateImpl(e),this.calcIsActualSymbol(),this.updateAllViews((0,
x.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,w.hideAllDrawings)().value()&&this.canBeHidden()||!this._isActualInterval||!this._isActualSymbol||!this._isActualCurrency||!this._isActualUnit}isSynchronizable(){return this.priceScale()===this._model.mainSeries().priceScale()}copiable(){return O}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 B.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;++W,this._currentPointsetAndSymbolId={pointsetId:W,symbolId:(0,n.ensureNotNull)(this._model.mainSeries().seriesSource().symbolInstanceId())};const t=(0,m.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,x.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,w.finishChangingLineTool)(s)}}
enableCurrentIntervalVisibility(){let e=this.properties().childs().intervalsVisibilities.state();void 0!==e&&(e=(0,g.mergeIntervalVisibilitiesDefaults)(e),(0,g.makeIntervalsVisibilitiesVisibleAtInterval)(e,this._model.mainSeries().intervalObj()),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,g.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()}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}}_ignoreSourceEvent(e){return e.sourceId!==this.id()}_pointsForPointset(){return this._timePoint.map((e=>e.interval?[e.time_t,e.offset,(0,m.getServerInterval)(e.interval)]:[e.time_t,e.offset]))}_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,T.clone)(e)}_snapTo45DegreesApplicable(e){return this.snapTo45DegreesAvailable()&&(e?.shift()||(0,w.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(S.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,c.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)),d=e.index-l;return(0,h.extrapolateBarsFrontByCount)(o.barBuilder(),1e3*c,d).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)||null}_updateAllPaneViews(e){this._paneViews.forEach((t=>{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 b.Property({}));const i=t[e];i.addChild("price",new L(this,e)),
i.addChild("bar",new A.LineDataSourcePointIndexProperty(this,e))}_createPointsProperties(){this._pointsProperty=new b.Property,this._pointsProperty.addChild("points",new b.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,y.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(p.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(let i=0;i<e.length;i++){const s=e[i],o=this._timePoint[s.index],n={index:s.value[0],time:s.value[1],price:o.price,interval:o.interval??t};this._points.length<=s.index?(this._points.push(n),this._pointAdded.fire(this._points.length-1)):(this._points[s.index]=n,this._pointChanged.fire(s.index))}this._onPointsetUpdatedDelegate.fire(),this.updateAllViewsAndRedraw((0,x.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,g.mergeIntervalVisibilitiesDefaults)(e.intervalsVisibilities);const t=this.properties();t.applyTemplate(e,(0,V.factoryDefaults)(this.toolname.toLowerCase())),t.saveDefaults(),this.propertiesChanged()}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_getAlertPlots(){return[]}_getUndoHistory(){return this._model.undoModel().undoHistory()}_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,w.restoreLineToolState)({model:this._model,linkKey:e,state:this.state()})}_syncLineStyleChanges(e,t,i){this.anchorable()&&this.isFixed()!==Boolean(this._positionPercents)&&this._onAnchoredChange(),(0,w.changeLineStyle)({linkKey:e,state:t,alertId:i,model:this._model})}static _configureProperties(e){if(this._addCollectedProperties(e),e.hasChild("symbolStateVersion")||e.addChild("symbolStateVersion",new b.Property(1)),e.hasChild("zOrderVersion")||e.addChild("zOrderVersion",new b.Property(1)),e.hasChild("visible")||e.addChild("visible",new b.Property(!0)),e.hasChild("frozen")||e.addChild("frozen",new b.Property(!1)),e.hasChild("symbol")||e.addChild("symbol",new b.Property("")),e.hasChild("currencyId")||e.addChild("currencyId",new b.Property(null)),e.hasChild("unitId")||e.addChild("unitId",new b.Property(null)),e.hasChild("intervalsVisibilities")){const t=(0,T.merge)((0,T.clone)(f.intervalsVisibilitiesDefaults),e.childs().intervalsVisibilities.state());e.removeProperty("intervalsVisibilities"),e.addChild("intervalsVisibilities",new P.IntervalsVisibilitiesProperty(t))}else e.addChild("intervalsVisibilities",new P.IntervalsVisibilitiesProperty(f.intervalsVisibilitiesDefaults));e.hasChild("title")||e.addChild("title",new b.Property("")),["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 E.LineToolWidthsProperty([(0,n.ensureDefined)(e.child("linewidth"))])),e.hasChild("linecolor")&&e.addChild("linesColors",new E.LineToolColorsProperty([(0,n.ensureDefined)(e.child("linecolor"))])),e.hasChild("backgroundColor")&&e.addChild("backgroundsColors",new E.LineToolColorsProperty([(0,n.ensureDefined)(e.child("backgroundColor"))])),e.hasChild("textColor")&&e.addChild("textsColors",new E.LineToolColorsProperty([(0,
n.ensureDefined)(e.child("textColor"))])),e.hasChild("linestyle")&&e.addChild("linesStyles",new E.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;if(this._addAlertSubscriptions(t,e),e.syncAlertFocus){const e=this._model.selection().isSelected(this);t.setSelected(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))}N.logError("Failed to set alert, alert will not be saved with drawing in chart")}}}},73305:(e,t,i)=>{"use strict";i.d(t,{LineToolCollectedProperty:()=>c,LineToolColorsProperty:()=>d,LineToolWidthsProperty:()=>h,MultipleLineColorsProperty:()=>p,MultipleLineWidthsProperty:()=>_});var s=i(9343),o=i(34776),n=i(23073);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{}},77336:(e,t,i)=>{"use strict";i.d(t,{ensureLineToolLoaded:()=>u,getLoadedLineTool:()=>_,isAsyncGenericLineToolName:()=>l,isAsyncStudyLineToolName:()=>c,isLineToolLoaded:()=>h,loadLineTool:()=>d});var s=i(50151);const o=new Map;const n=new Map([["LineToolPriceNote",async()=>(await Promise.all([i.e(8940),i.e(3889),i.e(8009),i.e(380)]).then(i.bind(i,36875))).LineToolPriceNote],["LineToolTextNote",async()=>(await Promise.all([i.e(6645),i.e(3889),i.e(8009),i.e(9116),i.e(9123)]).then(i.bind(i,46902))).LineToolTextNote],["LineToolNote",async()=>(await Promise.all([i.e(3355),i.e(3889),i.e(8009),i.e(9116),i.e(3248)]).then(i.bind(i,40258))).LineToolNote],["LineToolFibSpiral",async()=>(await Promise.all([i.e(3181),i.e(3889),i.e(8009),i.e(8090)]).then(i.bind(i,22717))).LineToolFibSpiral],["LineToolCircleLines",async()=>(await Promise.all([i.e(2787),i.e(3889),i.e(8009),i.e(9445)]).then(i.bind(i,9093))).LineToolCyclicLines],["LineToolNoteAbsolute",async()=>(await Promise.all([i.e(3355),i.e(3889),i.e(8009),i.e(9116),i.e(3248)]).then(i.bind(i,40258))).LineToolNoteAbsolute],["LineToolTable",async()=>(await Promise.all([i.e(9494),i.e(3889),i.e(8009),i.e(9116),i.e(319)]).then(i.bind(i,56176))).LineToolTable],["LineToolFibSpeedResistanceArcs",async()=>(await Promise.all([i.e(1427),i.e(3889),i.e(8009),i.e(9116),i.e(3710)]).then(i.bind(i,49145))).LineToolFibSpeedResistanceArcs],["LineToolPitchfan",async()=>(await Promise.all([i.e(7952),i.e(3889),i.e(8009),i.e(8056),i.e(1313)]).then(i.bind(i,43176))).LineToolPitchfan],["LineToolFibSpeedResistanceFan",async()=>(await Promise.all([i.e(1308),i.e(3889),i.e(8009),i.e(906)]).then(i.bind(i,2662))).LineToolFibSpeedResistanceFan],["LineToolFibWedge",async()=>(await Promise.all([i.e(6760),i.e(3889),i.e(8009),i.e(9116),i.e(3314)]).then(i.bind(i,30051))).LineToolFibWedge],["LineToolEmoji",async()=>(await Promise.all([i.e(6155),i.e(3889),i.e(8009),i.e(1200),i.e(5529)]).then(i.bind(i,39374))).LineToolEmoji],["LineToolBalloon",async()=>(await Promise.all([i.e(3367),i.e(3889),i.e(8009),i.e(3960),i.e(1277)]).then(i.bind(i,69113))).LineToolBalloon],["LineToolComment",async()=>(await Promise.all([i.e(2303),i.e(3889),i.e(8009),i.e(9116),i.e(3960),i.e(3966)]).then(i.bind(i,84738))).LineToolComment],["LineToolBezierCubic",async()=>(await Promise.all([i.e(1432),i.e(3889),i.e(8009),i.e(9014)]).then(i.bind(i,54696))).LineToolBezierCubic],["LineToolInsidePitchfork",async()=>(await Promise.all([i.e(8763),i.e(8468)]).then(i.bind(i,20690))).LineToolInsidePitchfork]]);n.set("LineToolFibRetracement",(async()=>(await Promise.all([i.e(7850),i.e(3723)]).then(i.bind(i,33168))).LineToolFibRetracement)),n.set("LineToolFibChannel",(async()=>(await Promise.all([i.e(7850),i.e(2283)]).then(i.bind(i,42851))).LineToolFibChannel)),
n.set("LineToolProjection",(async()=>(await Promise.all([i.e(7122),i.e(3945)]).then(i.bind(i,12120))).LineToolProjection)),n.set("LineToolTrendBasedFibExtension",(async()=>(await Promise.all([i.e(7850),i.e(4731)]).then(i.bind(i,68554))).LineToolTrendBasedFibExtension)),n.set("LineToolElliott",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliott)),n.set("LineToolFibCircles",(async()=>(await Promise.all([i.e(7850),i.e(2816)]).then(i.bind(i,57994))).LineToolFibCircles)),n.set("LineToolVertLine",(async()=>(await Promise.all([i.e(7122),i.e(1282)]).then(i.bind(i,56096))).LineToolVertLine)),n.set("LineToolCrossLine",(async()=>(await i.e(7203).then(i.bind(i,92007))).LineToolCrossLine)),n.set("LineToolBarsPattern",(async()=>(await Promise.all([i.e(4543),i.e(5206)]).then(i.bind(i,81756))).LineToolBarsPattern)),n.set("LineToolTrendBasedFibTime",(async()=>(await Promise.all([i.e(5111),i.e(7127)]).then(i.bind(i,27172))).LineToolTrendBasedFibTime)),n.set("LineToolFibTimeZone",(async()=>(await Promise.all([i.e(5111),i.e(1506)]).then(i.bind(i,8532))).LineToolFibTimeZone)),n.set("LineToolDateRange",(async()=>(await i.e(4273).then(i.bind(i,42214))).LineToolDateRange)),n.set("LineToolPriceRange",(async()=>(await i.e(6477).then(i.bind(i,23234))).LineToolPriceRange)),n.set("LineToolDateAndPriceRange",(async()=>(await i.e(1455).then(i.bind(i,70791))).LineToolDateAndPriceRange)),n.set("LineToolParallelChannel",(async()=>(await i.e(2050).then(i.bind(i,56621))).LineToolParallelChannel)),n.set("LineToolTrendAngle",(async()=>(await Promise.all([i.e(7122),i.e(8372)]).then(i.bind(i,83776))).LineToolTrendAngle)),n.set("LineToolTrendLine",(async()=>(await Promise.all([i.e(7122),i.e(8673)]).then(i.bind(i,99294))).LineToolTrendLine)),n.set("LineToolInfoLine",(async()=>(await Promise.all([i.e(7122),i.e(7488)]).then(i.bind(i,51065))).LineToolInfoLine)),n.set("LineToolArrowMark",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMark)),n.set("LineToolGannSquare",(async()=>(await i.e(9478).then(i.bind(i,9770))).LineToolGannSquare)),n.set("LineToolGannComplex",(async()=>(await i.e(1963).then(i.bind(i,99083))).LineToolGannComplex)),n.set("LineToolGannFixed",(async()=>(await i.e(6336).then(i.bind(i,8308))).LineToolGannFixed)),n.set("LineToolGannFan",(async()=>(await Promise.all([i.e(5111),i.e(4981)]).then(i.bind(i,85259))).LineToolGannFan)),n.set("LineToolPitchfork",(async()=>(await Promise.all([i.e(8763),i.e(5055)]).then(i.bind(i,64002))).LineToolPitchfork)),n.set("LineToolDisjointAngle",(async()=>(await i.e(9581).then(i.bind(i,57897))).LineToolDisjointChannel)),n.set("LineToolFlatBottom",(async()=>(await i.e(9310).then(i.bind(i,90921))).LineToolFlatBottom)),n.set("LineToolIcon",(async()=>(await i.e(7806).then(i.bind(i,15510))).LineToolIcon)),n.set("LineToolSticker",(async()=>(await i.e(8949).then(i.bind(i,86915))).LineToolSticker)),n.set("LineToolRotatedRectangle",(async()=>(await i.e(4015).then(i.bind(i,23550))).LineToolRotatedRectangle)),
n.set("LineToolHeadAndShoulders",(async()=>(await i.e(3378).then(i.bind(i,47267))).LineToolHeadAndShoulders)),n.set("LineToolTriangle",(async()=>(await i.e(6432).then(i.bind(i,39737))).LineToolTriangle)),n.set("LineToolTrianglePattern",(async()=>(await i.e(3383).then(i.bind(i,33865))).LineToolTrianglePattern)),n.set("LineTool5PointsPattern",(async()=>(await i.e(1155).then(i.bind(i,17658))).LineTool5PointsPattern)),n.set("LineToolThreeDrivers",(async()=>(await i.e(4602).then(i.bind(i,46660))).LineToolThreeDrivers)),n.set("LineToolABCD",(async()=>(await i.e(5283).then(i.bind(i,30906))).LineToolABCD)),n.set("LineToolPolyline",(async()=>(await i.e(3866).then(i.bind(i,51691))).LineToolPolyline)),n.set("LineToolPath",(async()=>(await i.e(961).then(i.bind(i,14150))).LineToolPath)),n.set("LineToolPrediction",(async()=>(await i.e(9534).then(i.bind(i,29356))).LineToolPrediction)),n.set("LineToolPriceLabel",(async()=>(await i.e(6484).then(i.bind(i,83710))).LineToolPriceLabel)),n.set("LineToolArrowMarker",(async()=>(await i.e(1470).then(i.bind(i,66403))).LineToolArrowMarker)),n.set("LineToolSignpost",(async()=>(await Promise.all([i.e(7122),i.e(4674)]).then(i.bind(i,28820))).LineToolSignpost)),n.set("LineToolBrush",(async()=>(await i.e(5122).then(i.bind(i,28462))).LineToolBrush)),n.set("LineToolArc",(async()=>(await i.e(5967).then(i.bind(i,87654))).LineToolArc)),n.set("LineToolCallout",(async()=>(await Promise.all([i.e(7122),i.e(688)]).then(i.bind(i,62828))).LineToolCallout)),n.set("LineToolText",(async()=>(await Promise.all([i.e(7122),i.e(2312)]).then(i.bind(i,424))).LineToolText)),n.set("LineToolHorzLine",(async()=>(await Promise.all([i.e(7122),i.e(4201)]).then(i.bind(i,43636))).LineToolHorzLine)),n.set("LineToolHorzRay",(async()=>(await i.e(574).then(i.bind(i,47845))).LineToolHorzRay)),n.set("LineToolRectangle",(async()=>(await Promise.all([i.e(7122),i.e(8422)]).then(i.bind(i,63397))).LineToolRectangle)),n.set("LineToolCircle",(async()=>(await Promise.all([i.e(7122),i.e(6748)]).then(i.bind(i,17333))).LineToolCircle)),n.set("LineToolEllipse",(async()=>(await Promise.all([i.e(7122),i.e(7660)]).then(i.bind(i,59002))).LineToolEllipse)),n.set("LineToolTimeCycles",(async()=>(await i.e(8334).then(i.bind(i,4741))).LineToolTimeCycles)),n.set("LineToolSineLine",(async()=>(await i.e(1713).then(i.bind(i,8066))).LineToolSineLine)),n.set("LineToolGhostFeed",(async()=>(await i.e(7563).then(i.bind(i,37968))).LineToolGhostFeed)),n.set("LineToolBezierQuadro",(async()=>(await i.e(8061).then(i.bind(i,28904))).LineToolBezierQuadro)),n.set("LineToolArrow",(async()=>(await Promise.all([i.e(7122),i.e(8607)]).then(i.bind(i,96068))).LineToolArrow)),n.set("LineToolRay",(async()=>(await Promise.all([i.e(7122),i.e(4934)]).then(i.bind(i,36224))).LineToolRay)),n.set("LineToolExtended",(async()=>(await Promise.all([i.e(7122),i.e(925)]).then(i.bind(i,6921))).LineToolExtended)),n.set("LineToolSchiffPitchfork",(async()=>(await Promise.all([i.e(8763),i.e(7175)]).then(i.bind(i,63533))).LineToolSchiffPitchfork)),
n.set("LineToolSchiffPitchfork2",(async()=>(await Promise.all([i.e(8763),i.e(341)]).then(i.bind(i,68802))).LineToolSchiffPitchfork2)),n.set("LineToolTextAbsolute",(async()=>(await Promise.all([i.e(7122),i.e(2312)]).then(i.bind(i,424))).LineToolTextAbsolute)),n.set("LineToolArrowMarkLeft",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkLeft)),n.set("LineToolArrowMarkRight",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkRight)),n.set("LineToolArrowMarkUp",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkUp)),n.set("LineToolArrowMarkDown",(async()=>(await i.e(569).then(i.bind(i,27621))).LineToolArrowMarkDown)),n.set("LineToolFlagMark",(async()=>(await i.e(8820).then(i.bind(i,41124))).LineToolFlagMark)),n.set("LineToolCypherPattern",(async()=>(await i.e(6740).then(i.bind(i,16628))).LineToolCypherPattern)),n.set("LineToolElliottImpulse",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottImpulse)),n.set("LineToolElliottTriangle",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottTriangle)),n.set("LineToolElliottTripleCombo",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottTripleCombo)),n.set("LineToolElliottCorrection",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottCorrection)),n.set("LineToolElliottDoubleCombo",(async()=>(await Promise.resolve().then(i.bind(i,65365))).LineToolElliottDoubleCombo)),n.set("LineToolRiskRewardLong",(async()=>(await Promise.all([i.e(2342),i.e(1667),i.e(2277)]).then(i.bind(i,21986))).LineToolRiskRewardLong)),n.set("LineToolRiskRewardShort",(async()=>(await Promise.all([i.e(2342),i.e(1667),i.e(6768)]).then(i.bind(i,65137))).LineToolRiskRewardShort)),n.set("LineToolPosition",(async()=>(await i.e(1314).then(i.t.bind(i,40265,19))).LineToolPosition)),n.set("LineToolOrder",(async()=>(await i.e(2232).then(i.t.bind(i,64732,19))).LineToolOrder)),n.set("LineToolHighlighter",(async()=>(await i.e(2087).then(i.bind(i,65539))).LineToolHighlighter)),n.set("LineToolImage",(async()=>(await Promise.all([i.e(5402),i.e(5231)]).then(i.bind(i,18181))).LineToolImage)),n.set("LineToolExecution",(async()=>(await Promise.resolve().then(i.bind(i,56991))).LineToolExecution));const r=new Map,a=new Map([["LineToolAnchoredVWAP",async()=>(await i.e(5500).then(i.bind(i,13099))).LineToolAnchoredVWAP],["LineToolRegressionTrend",async()=>(await i.e(9748).then(i.bind(i,10986))).LineToolRegressionTrend],["LineToolVbPFixed",async()=>(await i.e(5695).then(i.bind(i,71131))).LineToolVbPFixed],["LineToolFixedRangeVolumeProfile",async()=>(await i.e(5695).then(i.bind(i,25937))).LineToolFixedRangeVolumeProfile]]);function l(e){return n.has(e)||a.has(e)||o.has(e)}function c(e){return a.has(e)}function h(e){return!l(e)||o.has(e)||r.has(e)}async function d(e){if(h(e))return _(e);const t=c(e),i=(0,s.ensureDefined)((t?a:n).get(e)),l=await i();return t?(r.set(e,(0,s.ensureDefined)(l)),_(e)):(o.set(e,(0,s.ensureDefined)(l)),_(e))}async function u(e){l(e)&&!h(e)&&await d(e)}function _(e){return c(e)?(0,
s.ensureDefined)(r.get(e),`Study line tool ${e}`):(0,s.ensureDefined)(o.get(e),`Line tool ${e}`)}},98523:(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))}},15491:(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"}},32755:(e,t,i)=>{"use strict";i.d(t,{cloneLineTool:()=>N,createLineTool:()=>x,createLineToolProperties:()=>M,createStudyLineToolProperties:()=>A,ensureAllLineToolsLoadedForLayout:()=>P,initAllLineToolsFromContent:()=>T,initLineTool:()=>S,isBrushBasedLineTool:()=>k,isEditableTextLineTool:()=>V,isLineTool:()=>g.isLineTool,isStudyLineTool:()=>D,isTrading:()=>E,prepareLineToolPropertiesByOwnerSource:()=>I,setNewToolProperties:()=>y,supportsPhantomMode:()=>L,tryFindStudyLineToolNameByStudyId:()=>R,unsetNewToolProperties:()=>v});var s=i(82433),o=i(50151),n=i(86441),r=i(10892),a=i(43156),l=i(36009),c=i(68805),h=i(15764),d=i(16638),u=i(15491),_=i(64195),p=i(77336),m=i(9343),g=i(78956);let f=null;function y(e,t,i){return null!==f&&f.tool===e&&f.toolData===t||(v(!0),f={properties:M(i.backgroundTheme().spawnOwnership(),e,!i.readOnly()),tool:e,toolData:t}),f.properties}function v(e){e&&f?.properties.destroy(),f=null}async function S(e){["LineToolRiskRewardLong","LineToolRiskRewardShort"].includes(e);const t=e;(D(t)||(0,p.isAsyncStudyLineToolName)(t))&&await(0,d.studyMetaInfoRepository)().findAllJavaStudies(),(0,p.isLineToolLoaded)(t)||(0,h.isLineToolName)(t)&&await(0,p.loadLineTool)(t)}function b(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 w extends Error{constructor(e,t){super(`Failed to load line tool: ${e}`),this.name="LineToolLoadError",this.toolName=e,this.originalError=t}}const C=(0,m.getLogger)("LineToolsSynchronizer");async function P(e){const t=new Set,i=e=>{(0,p.isAsyncGenericLineToolName)(e)&&t.add(e)};for(const t of e)b(t,i);const s=[...t],o=(await Promise.allSettled(s.map((e=>(0,p.ensureLineToolLoaded)(e).catch((t=>{throw new w(e,t)})))))).filter((e=>"rejected"===e.status));o.length>0&&o.forEach((e=>{const t=e.reason;C.logError(`Failed to load line tool: ${t.toolName}`)}))}async function T(e){if(!e)return;const t=new Set;b(e,(e=>{(0,h.isLineToolName)(e)&&t.add(e)})),await Promise.all(Array.from(t).map((e=>S(e))))}function x(e,t,i,s,n,r){(0,o.assert)((0,h.isLineToolName)(e),"Unknown line tool: "+e);const a=e;let l;if((0,o.assert)((0,p.isLineToolLoaded)(a),`Line tool ${a} is not loaded`),n||i||null===f||f.tool!==e||(i=f.properties,v(!1)),(0,p.isAsyncStudyLineToolName)(a)){l=new((0,p.getLoadedLineTool)(a))(t,i,(0,o.ensureDefined)(s),n,r)}else{l=new((0,p.getLoadedLineTool)(a))(t,i,n,r)}return l.toolname=e,v(!0),l}function I(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 M(e,t,i,s){(0,o.assert)((0,h.isLineToolName)(t),`${t} should be name of the line tool`);const n=t;if((0,o.assert)((0,p.isLineToolLoaded)(n),`Line tool ${n} is not loaded`),(0,p.isAsyncStudyLineToolName)(n)){return(0,p.getLoadedLineTool)(n).createProperties(e,s)}return(0,p.getLoadedLineTool)(n).createProperties(e,s,i)}function A(e,t,i,s,n,r){(0,o.assert)((0,h.isStudyLineToolName)(t),`${t} should be name of the study line tool`);const a=t;if((0,p.isAsyncStudyLineToolName)(a)){return(0,p.getLoadedLineTool)(a).createPropertiesFromStudyMetaInfoAndState(i,s,n,r,e)}throw new Error(`Property creation is not implemented for study line tool ${t}`)}function L(e){(0,o.assert)((0,h.isLineToolName)(e),`${e} should be name of the line tool`);const t=e;(0,o.assert)((0,p.isLineToolLoaded)(t),`Line tool ${t} is not loaded`);const i=(0,p.getLoadedLineTool)(t);return void 0!==i&&Boolean(i.supportPhantomMode)}function k(e){return e instanceof _.LineToolBrushBase}function D(e){return e instanceof a.StudyLineDataSource}function E(e){return e instanceof l.LineToolTrading}const B=["editableTextStyle","editableText","editableTextProperties"];function V(e){return(0,s.default)(e)&&B.every((t=>t in e))}function R(e){let t=null
;return e===u.lineToolsStudyIds.LineToolRegressionTrend?t="LineToolRegressionTrend":e===u.lineToolsStudyIds.LineToolVbPFixed?t="LineToolVbPFixed":e===u.lineToolsStudyIds.LineToolFixedRangeVolumeProfile&&(t="LineToolFixedRangeVolumeProfile"),t}function N(e,t,i,s){const a=t.toolname,l=t.properties().state();l.intervalsVisibilities=(0,r.mergeIntervalVisibilitiesDefaults)(l?.intervalsVisibilities);const c=M(e.backgroundTheme().spawnOwnership(),t.toolname,!e.readOnly(),l);c.childs().visible.setValue(!0);const h=(0,o.ensureNotNull)(t.ownerSource()),d=x(a,e,c);void 0!==s&&d.setId(s),d.setOwnerSource(h),d.toolname=a;const u=d.clonePositionOffset();if(t.isFixed()){const e=(0,o.ensureDefined)(t.fixedPoint()),s=i?e.add(new n.Point(u.xCoordOffset,u.yCoordOffset)):e;d.addFixedPoint(s)}const _=t.normalizedPoints(),p=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}}))}(_,h,u):_,m=t.points();return d.restorePoints(p,m),d.cloneData&&d.cloneData(t),d.recalculateStateByData&&d.recalculateStateByData(),d}},96333:(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={}))},43156:(e,t,i)=>{"use strict";i.d(t,{StudyLineDataSource:()=>b});var s=i(64755),o=i(29875),n=i(32679),r=i(68159),a=i(14019),l=i(65383),c=i(71838),h=i(678);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(16685),_=i(82349),p=i(17534),m=i(44672),g=i(27538);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()}text(){return this._source.translatedType()}sourceStatusText(){return(0,h.convertStudyStatusToString)(this._source.status(),!0)}}var y=i(62288),v=i(27777);class S extends v.StatusView{constructor(e){super(e.statusProvider({}))}getSplitTitle(){return this._statusProvider.getSplitTitle()}}class b 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(9116),i.e(1200),i.e(1583)]).then(i.bind(i,8938)),Promise.all([i.e(6290),i.e(9116),i.e(1200),i.e(1583)]).then(i.bind(i,19583))]).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._isDestroyed||(this._dataSource.stop(),this.clearData())}start(){super.start(),this._isDestroyed||null===this._inputs||this._dataSource.start()}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._clearAllDataExceptPointsetPoints(),this._pointsetPoints=null,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}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(){}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;if(null!==this._pointsetPoints&&this._pointsetPoints.length===this.pointsCount()&&(e=this._studyInputs(this._pointsetPoints),null===e&&(this._clearAllDataExceptPointsetPoints(),this.updateAllViews((0,m.sourceChangeEvent)(this.id())))),null!==e){
const t=this.metaInfo().inputs.map((e=>e.id)),i=Object.keys(e);for(const s of i)t.includes(s)||delete e[s]}this._areInputsEqual(this._inputs,e)||this._applyStudyInputs(e)}_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._inputs=null,this._dataSource.clearData(),this._loadedPlots=null,this._indexes=null,this._loadedGraphics=null}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)}_areInputsEqual(e,t){return null===t?null===e:null!==e&&(0,l.areStudyInputsEqual)(this._metaInfo.inputs,e,t)}_applyStudyInputs(e){const t=this._inputs;this._inputs=e,null!==e&&(this._unsubscribeApplyInputsOnSeriesCompleted(),this._dataSource.setInputs(e),null===t&&this.isStarted()&&!this._dataSource.isStarted()&&this._dataSource.start()),this._onInputsChanged()}}},36009:(e,t,i)=>{"use strict";const s=i(29875).LineDataSource,o=i(92934).alignToStep,n=i(24526).customFormatters,r=i(68805).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},58519:(e,t,i)=>{"use strict";i.r(t),i.d(t,{loadTheme:()=>r});var s=i(85662),o=i(76422),n=i(35039)
;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}},92693:(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={}))},81171:(e,t,i)=>{"use strict";i.d(t,{magnetEnabled:()=>p,magnetMode:()=>m,setIsMagnetEnabled:()=>g,setMagnetMode:()=>f});var s=i(32679),o=i(64147),n=i(92693),r=i(928),a=i(15764),l=i(43550);const c=new o.WatchedValue(!1),h=new o.WatchedValue(n.MagnetMode.WeakMagnet),d=(0,l.modifierPressed)(),u=(0,l.shiftPressed)();function _(){const e=d.value();if(u.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 p(){return c}function m(){return h}function g(e){(0,s.allowSavingDefaults)(!0),(0,r.properties)().childs().magnet.setValue(e),(0,s.allowSavingDefaults)(!1)}function f(e){(0,s.allowSavingDefaults)(!0),(0,r.properties)().childs().magnetMode.setValue(e),(0,r.properties)().childs().magnet.setValue(!0),(0,s.allowSavingDefaults)(!1)}(0,r.runOnDrawingStateReady)((()=>{(0,r.properties)().childs().magnet.subscribe(null,_),(0,r.properties)().childs().magnetMode.subscribe(null,_),d.subscribe(_),u.subscribe(_),r.tool.subscribe(_),r.isToolEditingNow.subscribe(_),_()}))},44672:(e,t,i)=>{"use strict";i.d(t,{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"}(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}},18172:(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}},82587:(e,t,i)=>{"use strict";i.d(t,{notAvailable:()=>o});var s=i(11542);const o=i(56570).enabled("use_na_string_for_not_available_values")?s.t(null,void 0,i(90091)):"∅"},74079:(e,t,i)=>{"use strict";i.d(t,{getNumericFormatter:()=>c,getPercentageFormatter:()=>h,getPipFormatter:()=>_,getVolumeFormatter:()=>d});var s=i(59623),o=i(719);var n=i(725);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!!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}=t;let n=this._isForex?this._pipMinMove2:this._pipMinMove;return void 0===n&&(n=NaN),super.format(e*this._pipPriceScale/n,{signPositive:i,tailSize:s,ignoreLocaleNumberFormat:o})}}var a=i(46084),l=i(58683);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}},72791:(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"
}(s||(s={}))},65458:(e,t,i)=>{"use strict";i.d(t,{PanePriceAxisView:()=>n});var s=i(2844);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()}}},52977:(e,t,i)=>{"use strict";i.d(t,{applyColor:()=>c});var s=i(83873),o=i(5201),n=i(46088);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={}))},67716:(e,t,i)=>{"use strict";i.d(t,{AreaBackgroundItem:()=>h,AreaBackgroundItemsGroup:()=>l,AreaBackgroundRenderer:()=>d,CachedMap:()=>c});var s,o,n=i(50151),r=i(30125),a=i(59152);!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()}}}},2271:(e,t,i)=>{"use strict";i.d(t,{PaneRendererArea:()=>a});var s=i(74010),o=i(61993),n=i(37743),r=i(52977);class a extends s.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,a=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1;for(;i<a&&!(0,o.coordinateIsValid)(t.items[i].y);)i++;for(;a>=0&&!(0,o.coordinateIsValid)(t.items[a].y);)a--;if(i>a)return;const{context:l,horizontalPixelRatio:c,verticalPixelRatio:h}=e;l.save(),l.scale(c,h),l.lineCap="round",(0,
r.applyColor)(e,t.lineColor,0,1),l.lineWidth=t.lineWidth,(0,n.setLineStyle)(l,t.lineStyle),l.lineWidth=1;const d=new Map,u=new s.PaneRendererLineItemsIterator(this._data.items,i,a+1,this._data.skipHoles);for(;u.next();){const e=u.currentValue();let i;i=(0,s.isValidPoint)(e)&&e.style?e.style.color:t.lineColor;const o=u.nextValue();if((0,s.isValidPoint)(o)&&o?.style){const t=o.style.color;if(i!==t){const i=d.get(t)??[];i.push(e),d.set(t,i)}}const n=d.get(i)??[];n.push(e),d.set(i,n)}for(const[i,o]of d){l.beginPath();let n=0;for(let e=0;e<o.length;e++){const r=o[e];(0,s.isValidPoint)(r)&&(r.style&&r.style?.color!==i&&(l.moveTo(Math.round(o[n].center),t.bottom),this._walkLine(l,o.slice(n,e),!0,t.bottom,!0),n=e))}if(l.moveTo(Math.round(o[n].center),t.bottom),this._walkLine(l,o.slice(n,o.length),!0,t.bottom,!0),l.closePath(),t.isSeries){const e=l.createLinearGradient(0,0,0,t.bottom);e.addColorStop(0,t.color1),e.addColorStop(1,t.color2),l.fillStyle=e,t.simpleMode=!0}else(0,r.applyColor)(e,i,0,2);l.fill()}l.lineWidth=t.lineWidth,l.restore(),super._drawImpl(e)}}},30125:(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){}}},95201:(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)))}}},37743:(e,t,i)=>{"use strict";i.r(t),i.d(t,{addHorizontalLineToPath:()=>d,addLineToPath:()=>T,addPixelPerfectLineToPath:()=>I,addVerticalLineToPath:()=>_,clearRectWithGradient:()=>c,clipPolygonByEdge:()=>A,computeDashPattern:()=>P,createCircle:()=>b,drawHorizontalLine:()=>u,drawLine:()=>x,drawPixelPerfectLine:()=>M,drawPoly:()=>w,drawRoundRect:()=>f,drawRoundRectWithInnerBorder:()=>y,drawVerticalLine:()=>p,fillRectInnerBorder:()=>h,fillRectWithBorder:()=>S,scaleDrawRoundRectRadii:()=>m,scaledDashPattern:()=>v,setLineStyle:()=>C});var s=i(86441),o=i(5531),n=i(51056),r=i(85904),a=i(7114),l=i(64034);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=P(e.lineWidth,t)),e.setLineDash(i)}function P(e,t){return[[e,2*e],[5*e,6*e],[6*e,6*e],[e,4*e],[2*e,e]][t-1]}function T(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(),T(e,t,i,s,o),e.stroke())}function I(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],T(e,l[0],l[1],l[2],l[3])),l}function M(e,t,i,s,o,n=l.dpr1PixelRatioInfo){e.beginPath(),I(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}},61993:(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(86441),o=i(5531),n=i(69186),r=i(37265),a=i(37743);const l={common:13,line:13,minDistanceBetweenPoints:10,series:14,curve:10,anchor:13,esd:4},c={common:3,line:3,minDistanceBetweenPoints:5,series:2,curve:3,anchor:2,esd:0};function h(e,t,i,n,r,a){if((0,s.equalPoints)(e,t))return null;const l=new s.Point(0,0),c=new s.Point(i,n);if(r){if(a){const i=(0,o.intersectLineAndBox)((0,s.lineThroughPoints)(e,t),(0,s.box)(l,c));return Array.isArray(i)?i:null}{const i=(0,o.intersectRayAndBox)(t,e,(0,s.box)(l,c));return null===i||(0,s.equalPoints)(t,i)?null:(0,s.lineSegment)(t,i)}}if(a){const i=(0,o.intersectRayAndBox)(e,t,(0,s.box)(l,c));return null===i||(0,s.equalPoints)(e,i)?null:(0,s.lineSegment)(e,i)}{const i=(0,o.intersectLineSegmentAndBox)((0,s.lineSegment)(e,t),(0,s.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),P=Math.min(c-1*n/r,n*r*1),T=l.scaled(P),x=t.subtract(C),I=t.add(C),M=t.subtract(T);return[[g,S],[b,f],[x,M.subtract(C)],[I,M.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,n.lastMouseOrTouchEventInfo)().isTouch?l:c}function g(e){return null!=e&&!(0,r.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)}},50600:(e,t,i)=>{"use strict";i.d(t,{HorizontalLineRenderer:()=>l});var s=i(56468),o=i(37743),n=i(61993),r=i(30125),a=i(7114);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)}}},49857:(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={}))},74010:(e,t,i)=>{"use strict";i.d(t,{PaneRendererLine:()=>p,PaneRendererLineItemsIterator:()=>_,isValidPoint:()=>u});var s=i(50151),o=i(86441),n=i(4652),r=i(56468),a=i(61993),l=i(37743),c=i(30125),h=i(52977);const d={y:NaN};function u(e){return null!==e&&!isNaN(e.y)}class _{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&&!u(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&&!u(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=d: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 p 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){if(!t)return;const n=.25*this._data.barSpacing;let r,a,l=null;const c=o?0:this._data.visibleItemsRange?.startItemIndex??0,h=o?t.length:Math.min(this._data.visibleItemsRange?.endItemIndex??t.length,t.length);if(c>h||c>=t.length)return;const d=new _(t,c,h,this._data.skipHoles);for(;d.next();){if(r=d.currentValue(),a=d.nextValue(),u(r)){const t=Math.round(r.center);l&&u(l)?(e.lineTo(t,r.y),i&&!u(a)&&e.lineTo(t,s)):a&&u(a)?i?(d.atStart()||e.lineTo(t,s),e.lineTo(t,r.y)):e.moveTo(t,r.y):i?(d.atStart()||e.lineTo(t-n,s),e.lineTo(t-n,r.y),e.lineTo(t+n,r.y),e.lineTo(t+n,s)):(e.moveTo(t-n,r.y),e.lineTo(t+n,r.y))}l=r}}_drawLines(e){if(!this._data.items.length)return;let t,i,s=null;const o=.25*this._data.barSpacing;e.beginPath();const n=this._data.visibleItemsRange?.startItemIndex??0,r=this._data.visibleItemsRange?.endItemIndex??this._data.items.length;if(n>r||n>=this._data.items.length)return;const l=this._data.items[n];l&&e.moveTo(l.center,l.y);let c,h=e.strokeStyle,d=e.lineWidth;const p=new _(this._data.items,n,r,this._data.skipHoles);for(;p.next();){let n,r,l;s=p.prevValue(),t=p.currentValue(),i=p.nextValue();let _=!1;if(u(t)&&(t.style&&!this._data.forceLineColor?(n=t.style.color,r=t.style.width,l=t.style.style):(n=this._data.lineColor,r=this._data.lineWidth,l=this._data.lineStyle),this._data.ignorePaletteLineWidth&&(r=this._data.lineWidth),_=n!==h||r!==d||l!==c),_)if(h=n,d=r,c=l,e.stroke(),e.beginPath(),e.strokeStyle=n,e.lineWidth=r,(0,a.setValidLineStyle)(e,l),u(s))e.moveTo(s.center,s.y);else{const i=t;e.moveTo(i.center,i.y)}m=s,f=i,u(g=t)&&(u(m)?e.lineTo(g.center,g.y):f&&u(f)?e.moveTo(g.center,g.y):(e.moveTo(g.center-o,g.y),e.lineTo(g.center+o,g.y)))}var m,g,f;e.stroke()}}},75919:(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){}
}},59152:(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]}}},62189:(e,t,i)=>{"use strict";i.d(t,{RectangleRenderer:()=>_});var s,o=i(50151),n=i(86441),r=i(34026),a=i(4652),l=i(19063),c=i(56468),h=i(85904),d=i(37743),u=i(30125);!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}}},12027:(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){const t=e.getAttribute("transform")?.toLowerCase();if(void 0===t)return null;const i=[];let s;a.lastIndex=0;do{if(s=a.exec(t),null!==s){const e=s[1],t=s[2];switch(e){case"matrix":const s=r(t,6);null!==s&&i.push({type:e,a:s[0],b:s[1],c:s[2],d:s[3],e:s[4],f:s[5]});break;case"rotate":const o=r(t,1);null!==o&&i.push({type:e,a:o[0],x:o[1],y:o[2]});break;case"translate":const a=r(t,1);null!==a&&i.push({type:e,x:a[0],y:a[1]});break;case"scale":const l=r(t,1);null!==l&&i.push({type:e,x:l[0],y:l[1]});break;default:n.logWarn(`Unsupported transform operation: ${e}`)}}}while(null!==s);return 0===i.length?null:i}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,P=(0,o.getLogger)("Chart.SvgParser");function T(e,t,i,s){const o=e.children;let n,r=s;"g"!==e.tagName&&"svg"!==e.tagName||(r={...r,..._(e,i,!1)},n=l(e)??void 0),void 0!==n&&t.push(new p(n));for(let e=0;e<o.length;++e){const s=o[e];"defs"!==s.tagName&&T(s,t,i,r)}switch(void 0!==n&&t.push(new p(null)),e.tagName){case"g":case"svg":case"defs":break;case"path":t.push(new g(e,i,s));break;case"circle":t.push(new f(e,i,s));break;case"ellipse":t.push(new y(e,i,s));break;default:P.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={x:n[0],y:n[1],width:n[2],height:n[3]};i.push(new v(r));let a={getStyle:()=>{}};const l=o.getElementsByTagName("defs");return l.length>0&&(a=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}}}(l[0])),T(o,i,a),{viewBox:()=>r,render:(e,t)=>{e.save();for(const s of i)s.apply(e,t);e.restore()}}}},39429:(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={}))},3385:(e,t,i)=>{"use strict";i.d(t,{PaneRendererStepLine:()=>f,StepLineDecoration:()=>s});var s,o,n=i(4652),r=i(86441),a=i(56468),l=i(61993),c=i(37743),h=i(30125),d=i(74010),u=i(52977);!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 _{constructor(e){this._forceExtendFirstBar=!!e}initialize(e,t,i){const{context:s,horizontalPixelRatio:o,verticalPixelRatio:n}=t,r=e.lineStyle;s.lineCap="butt",s.lineJoin="round";const a=Math.max(Math.floor(i.style?.width??e.lineWidth*o));void 0!==r&&(0,c.setLineStyle)(s,r);const l=a%2?.5:0;s.moveTo(Math.round(i.center*o)+l,Math.round(i.y*n)+l),(0,u.applyColor)(t,i.style?.color??e.lineColor,1,1),s.lineWidth=a}startFragment(e,t,i,s){e.beginPath();const o=i.firstItem&&i.extendToBarsEndings?t.center:t.left;e.moveTo(isNaN(o)?-50:o,t.y)}finishFragment(e,t,i){t&&i&&e.lineTo(t.left,i.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){e.lineWidth=t}drawItem(e,t,i,s){const o=e.context;void 0!==s&&o.lineTo(t.left,s.y),o.lineTo(!i.firstItem||i.extendToBarsEndings||this._forceExtendFirstBar?t.left:t.center,t.y),o.lineTo(i.lastItem&&!i.extendToBarsEndings?t.center:t.right,t.y)}}class p{constructor(){this._lineWidth=1,this._initialAlpha=1}initialize(e,t,i){this._initialAlpha=t.context.globalAlpha,this.applyColor(t,i.style?.color??e.lineColor),this._lineWidth=Math.max(Math.floor(i.style?.width??e.lineWidth*t.horizontalPixelRatio))}startFragment(e,t,i,s){e.beginPath()}finishFragment(e){e.fill()}drawItem(e,t,i,s){if(i.valIsNotSameAsPrev&&!isNaN(t.left)){const i=e.context;i.save(),i.translate(t.left,t.y),i.rotate(Math.PI/4);const s=this._scaleByLineWidth(this._lineWidth);i.scale(s,s),this._drawItemRotatedAndTranslated(e),i.restore()}}applyLineWidth(e,t){this._lineWidth=t}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)}_scaleByLineWidth(e){return Math.sqrt(e)}}class m extends p{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 g extends p{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 f 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 _,new g]:[new _];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 _(!0),new m,new g]:[new _]).forEach((t=>this._drawDecorationItem(e,t)))}_drawDecorationItem(e,t){if(null===this._data||0===this._data.items.length)return
;const{lineWidth:i,lineColor:s,items:o,visibleItemsRange:n,skipHoles:r,extendToBarsEndings:a}=this._data,{context:l,horizontalPixelRatio:c,verticalPixelRatio:h}=e;let u=Math.max(Math.floor((o[0].style?.width??i)*c)),_=u%2?.5:0;t.initialize(this._data,e,o[0]);const p=n?.startItemIndex??0,m=n?.endItemIndex??o.length;if(m<=p)return;let g,f,y;l.beginPath(),t.applyColor(e,o[p].style?.color??s),t.applyLineWidth(l,u);let v=!1;const S=new d.PaneRendererLineItemsIterator(o,p,m,r);for(;S.next();){const o=S.currentValue();if(!(0,d.isValidPoint)(o)){g=void 0,v=!0;continue}const n=o.style?.color??s,r=o.style?.width??i,p=n!==f,m=r!==y,b={firstItem:S.currentValueIsFirst(),lastItem:S.currentValueIsLast(),extendToBarsEndings:a,valIsNotSameAsPrev:o.valIsNotSameAsPrev},w={y:Math.round(o.y*h)+_,left:Math.round(o.left*c)+_,center:Math.round(o.center*c)+_,right:Math.round(o.right*c)+_};(p||m||v)&&(f&&y&&t.finishFragment(l,w,g),p&&t.applyColor(e,n),m&&(u=Math.max(1,Math.floor(r*c)),_=u%2?.5:0,t.applyLineWidth(l,u)),t.startFragment(l,w,b,g),v=!1,f=n,y=r),t.drawItem(e,w,b,g),g=w}t.finishFragment(l)}}},17330:(e,t,i)=>{"use strict";i.d(t,{TextRenderer:()=>D,calculateLabelPosition:()=>g,fontSize:()=>M,getTextAlignInBox:()=>k,getTextBoundaries:()=>f,lineSpacing:()=>I,needTextExclusionPath:()=>y,wordWrap:()=>b});var s=i(86441),o=i(50151),n=i(34026),r=i(63273),a=i(30699),l=i(56468),c=i(37743),h=i(70262),d=i(37265),u=i(7114),_=i(51056),p=i(29981),m=i(2844);function g(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 f(e,t,i){if(e.isOutOfScreen(t,i))return null;const s=e.getPolygonPoints();return 0===s.length?null:s}function y(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 v(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 S(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,p.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 b(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=v(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=S(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=S(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 w(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 new s.Point(o,n)}function C(e){return void 0!==e.boxPaddingVert?e.boxPaddingVert*L(e):void 0!==e.boxPadding?e.boxPadding*L(e):M(e)/3}function P(e){return void 0!==e.boxPaddingHorz?e.boxPaddingHorz*L(e):void 0!==e.boxPadding?e.boxPadding*L(e):M(e)/3}function T(e){return void 0!==e.boxPaddingLeft?e.boxPaddingLeft*L(e):P(e)}function x(e){return void 0!==e.boxPaddingRight?e.boxPaddingRight*L(e):P(e)}function I(e){let t=e.lineSpacing;return void 0===t&&e.lineHeight&&(t=(e.lineHeight-1)*A(e)),(t??0)*L(e)}function M(e){return Math.ceil(A(e)*L(e))}function A(e){return e.fontsize||e.fontSize||30}function L(e){const t=Math.min(1,Math.max(.2,e.scale||1));if(1===t)return t;const i=A(e);return Math.ceil(t*i)/i}function k(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 D{constructor(e,t){this._data=null,this._textWidthCache=new m.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.highlightBorder===t.highlightBorder&&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}(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)(new s.Point(0,0),new 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:I(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:p,scaledRight:m,scaledTop:g,scaledBottom:f}=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);if(this._data.backgroundColor||this._data.borderColor||this._data.highlightBorder&&this._data.wordWrapWidth){const t=this._data.borderWidth||Math.max(d/12,1),i=Math.round(t*n),s=i/2;let o=!1;if(this._data.boxShadow){e.save();const{shadowColor:t,shadowBlur:i,shadowOffsetX:s=0,shadowOffsetY:a=0}=this._data.boxShadow;e.shadowColor=t,e.shadowBlur=i*n,e.shadowOffsetX=s*n,e.shadowOffsetY=a*r,o=!0}if(this._data.backgroundRoundRect)this._data.backgroundColor&&((0,c.drawRoundRect)(e,p,g,m-p,f-g,this._data.backgroundRoundRect*n),e.fillStyle=this._data.backgroundColor,e.fill(),o&&(e.restore(),o=!1)),this._data.borderColor&&((0,c.drawRoundRect)(e,p-s,g-s,m-p+i,f-g+i,this._data.backgroundRoundRect*n+i),e.strokeStyle=this._data.borderColor,e.lineWidth=i,e.stroke(),o&&(e.restore(),o=!1));else if(this._data.backgroundColor&&(e.fillStyle=this._data.backgroundColor,e.fillRect(p,g,m-p,f-g),o&&(e.restore(),o=!1)),this._data.borderColor||this._data.highlightBorder){let t;this._data.borderColor?(e.strokeStyle=this._data.borderColor,t=i):(e.strokeStyle=this._data.highlightBorderColor||this._data.color,(0,c.setLineStyle)(e,_.LINESTYLE_DASHED),t=Math.max(1,Math.floor(n))),e.lineWidth=t,e.beginPath(),e.moveTo(p-t/2,g-t/2),e.lineTo(p-t/2,f+t/2),e.lineTo(m+t/2,f+t/2),e.lineTo(m+t/2,g-t/2),e.lineTo(p-t/2,g-t/2),e.stroke(),o&&e.restore()}}this._drawSelectionIfNeeded(e,t),e.fillStyle=this._data.color;const y=(p+Math.round(a.textHorizStart*n))/n,v=.05*d;let S=(g+Math.round((a.textVertStart+v)*r))/r;const b=I(this._data),w=this.getLinesInfo();for(const t of w.lines)(0,u.drawScaled)(e,n,r,(()=>e.fillText(t.text,y,S))),S+=d+b;this._data.decorator?.draw(e,t,this._data,a),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=[w(new s.Point(t,i),r,e),w(new s.Point(t+o,i),r,e),w(new s.Point(t+o,i+n),r,e),w(new 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=w(new 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=b(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=I(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=x(e),u=C(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)(),w=b&&!g,P=w?t+s-d-p:t+h;switch((0,o.ensureDefined)(e.horzTextAlign)){case a.HorizontalAlign.Left:S="start",y=P+f,b&&(e.forceTextAlign?S="left":(y=w?P-m:t+s-d,S="right"));break;case a.HorizontalAlign.Center:S="center";const i=s-h-d-f;y=w?P-m-i/2:P+f+i/2;break;case a.HorizontalAlign.Right:S="end",y=w?P-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+(w?0:f),textRight:t+s-d-(w?f:0),textTop:i+u,textBottom:i+n-u,textHorizStart:y-t,textVertStart:v-i,textAlign:S,textBaseLine:"middle",decoratorLeft:P,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*L(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)+x(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+I(e)*(t-1)+2*C(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 new s.Point(c,h)}}},91046:(e,t,i)=>{"use strict";i.d(t,{TrendLineRenderer:()=>_,drawArrow:()=>u});var s=i(50151),o=i(4652),n=i(49857),r=i(56468),a=i(37743),l=i(61993),c=i(7114),h=i(51056);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)}}}},95173:(e,t,i)=>{"use strict";i.d(t,{VerticalLineRenderer:()=>l});var s=i(56468),o=i(37743),n=i(61993),r=i(7114),a=i(30125);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)}}},2718:(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))}},
64755:(e,t,i)=>{"use strict";i.d(t,{PlotList:()=>u,mergeMinMax:()=>_});var s=i(50151),o=i(29981),n=i(50503),r=i(9343),a=i(8025);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}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)}}},98558:(e,t,i)=>{"use strict";i.d(t,{PriceAxisView:()=>_});var s,o=i(86441),n=i(34026),r=i(69186),a=i(63273),l=i(7114),c=i(56468),h=i(37743);!function(e){e[e.HitTestTolerance=0]="HitTestTolerance",e[e.HitTestToleranceTouch=10]="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,P=r.textColor||p.textColor,T=r.secondLine||"",x=p.secondLineTextColor||P,I=r.thirdLine||"";const M=p.thirdLineTextColor||P;0===T.length&&(T=I,x=M,I=""),0===C.length&&(C=T,P=x,T=I,x=M,I=""),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,D=Boolean(T),E=Boolean(I),B=v+y+w,V=[Math.ceil(s.measureText(e,C)),D?Math.ceil(s.measureText(e,T)):0,E?Math.ceil(s.measureText(e,I)):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),G=Math.round(w*u),j=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?j-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-G-q+H):(Q=X+U,J=X+G+q-H),this._bodyBox=null,C||m){const t=E?N+F:D?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=P,e.fillText(C,0,0)})),e.restore()}D&&(e.fillStyle=x,e.save(),e.translate(J,(K+Y)/2+A+O),(0,l.drawScaled)(e,u,_,(()=>{e.fillText((0,a.startWithLTR)(T),0,0)})),e.restore()),E&&(e.fillStyle=M,e.save(),e.translate(J,(K+Y)/2+A+F),(0,l.drawScaled)(e,u,_,(()=>{e.fillText((0,a.startWithLTR)(I),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?10: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(19063);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)}}},45579:(e,t,i)=>{"use strict";i.d(t,{PriceDataSource:()=>a,isPriceDataSource:()=>r});var s=i(29137),o=i(52033),n=i(60074);function r(e){return e instanceof a}class a extends s.DataSource{constructor(e,t){super(t),this._formatterChanged=new o.Delegate,this._priceStepChanged=new o.Delegate,
this._currencyChanged=new o.Delegate,this._unitChanged=new o.Delegate,this._priceRangeReadyChanged=new o.Delegate,this._priceStep=null,this._priceRangeReady=!0,this._model=e}base(){return 0}model(){return this._model}currencyChanged(){return this._currencyChanged}isCurrencySource(){return!0}isDisplayedInLegend(){return!0}unitChanged(){return this._unitChanged}isUnitSource(){return!0}priceRange(e,t,i){return null}isDraggable(){return!0}priceLineColor(e){return e}formatterChanged(){return this._formatterChanged}priceStep(e){return this._priceStep}priceStepChanged(){return this._priceStepChanged}isIncludedInAutoScale(){return!0}correctScaleMargins(e){return e}priceRangeReady(){return this._priceRangeReady}priceRangeReadyChanged(){return this._priceRangeReadyChanged}disablePriceRangeReady(){const e=this.priceScale();null===e||e.isAutoScale()||e.mainSource()!==this||(this._priceRangeReady=!1,e.recalculatePriceRangeOnce()),this._priceRangeReadyChanged.fire(!1)}statusView(){return null}legendView(){return null}marketStatusModel(){return null}dataUpdatedModeModel(){return null}dataProblemModel(){return null}canHasAlertOnLineTools(){return!0}_enablePriceRangeReady(){this._priceRangeReady=!0,this._priceRangeReadyChanged.fire(!0)}_onSourceCurrencyChanged(){(0,n.isActingAsSymbolSource)(this)||this._currencyChanged.fire()}_onSourceUnitChanged(){(0,n.isActingAsSymbolSource)(this)||this._unitChanged.fire()}_onSourcePriceRangeReadyChanged(e){(0,n.isActingAsSymbolSource)(this)||e||this.disablePriceRangeReady()}}},37626:(e,t,i)=>{"use strict";i.d(t,{PriceLineAxisView:()=>l,SeriesPriceLineAxisView:()=>c,StudyPriceLineAxisView:()=>h});var s=i(98558),o=i(50151),n=i(51056),r=i(37743);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}}},94164:(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={}))},49256:(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(93280),o=i(9859);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}},93280:(e,t,i)=>{"use strict";i.d(t,{PriceRange:()=>n});var s=i(97085);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)}static mergedWithProgress(e,t,i){const s=e.minValue()+(t.minValue()-e.minValue())*i,o=e.maxValue()+(t.maxValue()-e.maxValue())*i;return new n(s,o)}}},17625:(e,t,i)=>{"use strict";i.d(t,{createPrimitiveProperty:()=>o});var s=i(12988);function o(e){return new s.Property(e)}},7927:(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.")}},23073:(e,t,i)=>{"use strict";i.d(t,{PropertyBase:()=>n});var s=i(50151),o=i(52033);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)}}},72595:(e,t,i)=>{"use strict";i.d(t,{DataTypes:()=>s,createPropertySchema:()=>d,dataType:()=>l,isArraySchema:()=>h,validateSchema:()=>c});var s,o=i(69708),n=i(83873),r=i(83350),a=i(56052);function l(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 c(e,t){const i=l(e);switch(t.type){case s.ARRAY:return i===s.ARRAY&&e.every((e=>c(e,t.subschema)));case s.OBJECT:{if(i!==s.OBJECT)return!1;const o=Object.entries(t.subschema);for(const t of o)if(!c(e[t[0]],t[1]))return!1;return!0}default:return i===t.type||t.type===s.UNKNOWN}}function h(e){return e.type===s.ARRAY}function d(e,t){let i;const o=l(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:d(e[0],t)};break;case s.OBJECT:{const o={};for(const[i,s]of Object.entries(e))o[i]=d(s,t);i={type:s.OBJECT,saveFlags:t,subschema:o};break}default:i={type:s.UNKNOWN,saveFlags:t}}return i}!function(e){e.STRING="string",e.NUMBER="number",e.BOOLEAN="boolean",e.OBJECT="object",e.ARRAY="array",e.UNKNOWN="unknown"}(s||(s={}))},39158:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>o});var s=i(17625);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}},42752:(e,t,i)=>{"use strict";i.d(t,{convertPropertyToWatchedValue:()=>o});var s=i(64147);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)}))}},84425:(e,t,i)=>{"use strict";i.d(t,{combineProperty:()=>r.combineProperty,createWVFromGetterAndSubscription:()=>s.createWVFromGetterAndSubscription,
createWVFromGetterAndSubscriptions:()=>o.createWVFromGetterAndSubscriptions,createWVFromProperty:()=>n.createWVFromProperty});var s=i(12184),o=i(23869),n=i(43042);i(17625);var r=i(39158)},12184:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscription:()=>o});var s=i(64147);function o(e,t){const i=new s.WatchedValue(e()),o={};t.subscribe(o,(()=>{i.setValue(e())}));return i.readonly().spawn((()=>t.unsubscribeAll(o)))}},23869:(e,t,i)=>{"use strict";i.d(t,{createWVFromGetterAndSubscriptions:()=>o});var s=i(64147);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)))))}},43042:(e,t,i)=>{"use strict";i.d(t,{createWVFromProperty:()=>o});var s=i(12184);function o(e){return(0,s.createWVFromGetterAndSubscription)((()=>e.value()),e)}},12988:(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(34776),d=i(23073),u=i(72595);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)}}},76742:(e,t,i)=>{"use strict";i.d(t,{QuotesProvider:()=>r});var s=i(42003),o=i(52033),n=i(92184);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)}}},64034:(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}},10074:(e,t,i)=>{"use strict";i.d(t,{compareResolutions:()=>m,convertResolutionsFromSettings:()=>T,getApplicableIntervalForFrequency:()=>g,getCustomResolutions:()=>M,getMaxResolutionValue:()=>P,getResolutionByChartStyle:()=>b,getTranslatedResolution:()=>A,getTranslatedResolutionModel:()=>L,intervalIsSupported:()=>V,isAvailable:()=>v,isIntervalEnabled:()=>B,isResolutionMultiplierValid:()=>w,isSecondsEnabled:()=>D,mergeResolutions:()=>x,normalizeIntervalString:()=>y,setLastUsedResolution:()=>S,sortResolutions:()=>I});var s=i(11542),o=i(85049),n=i(68805),r=i(56840),a=i(82992),l=i(97144),c=i(37265),h=i(56570),d=i(1819);const u={[o.ResolutionKind.Ticks]:1,[o.ResolutionKind.Seconds]:60,[o.ResolutionKind.Minutes]:1440,[o.SpecialResolutionKind.Hours]:24,[o.ResolutionKind.Days]:365,[o.ResolutionKind.Weeks]:52,[o.ResolutionKind.Months]:12,[o.ResolutionKind.Range]:1e6,[o.ResolutionKind.Invalid]:NaN},_={[o.ResolutionKind.Ticks]:0,[o.ResolutionKind.Seconds]:1,[o.ResolutionKind.Minutes]:2,[o.SpecialResolutionKind.Hours]:3,[o.ResolutionKind.Days]:4,[o.ResolutionKind.Weeks]:5,[o.ResolutionKind.Months]:6,[o.ResolutionKind.Range]:7,[o.ResolutionKind.Invalid]:8};function p(e){const t=o.Interval.parse(e),i=t.multiplier()||1;return t.isMinuteHours()?[o.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 o.Interval.parse(e).value()}function v(e){const t=o.Interval.parse(e);if(!D()&&t.isSeconds())return!1;if(!(0,d.isTicksEnabled)()&&t.isTicks())return!1;const i=t.value(),s=a.linking.dataFrequencyResolution.value();if(void 0!==s&&m(i,s)<0)return!1;const n=a.linking.supportedResolutions.value();return void 0!==n?void 0!==n.find((e=>y(e)===i)):t.isSeconds()?Boolean(a.linking.seconds.value()):t.isTicks()?Boolean(a.linking.ticks.value()):t.isIntraday()?Boolean(a.linking.intraday.value()):t.isDWM()}
function S(e){o.Interval.isValid(e)&&(o.Interval.isRange(e)?r.setValue("chart.lastUsedRangeResolution",e):r.setValue("chart.lastUsedTimeBasedResolution",e))}function b(e,t,i){const s=n.isRangeStyle(e),a=o.Interval.isRange(t);return!s&&a?function(e){const t=r.getValue("chart.lastUsedTimeBasedResolution");if(void 0!==t&&o.Interval.isTimeBased(t))return t;let i="1D";for(const t of e){const e=o.Interval.parse(t);if(e.isTimeBased()){const t=e.value();if("1D"===t)return t;i=t}}return i}(i):s&&!a?function(e){const t=r.getValue("chart.lastUsedRangeResolution");if(void 0!==t&&o.Interval.isRange(t))return t;let i="100R";for(const t of e){const e=o.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}=o.Interval.parseExt(e);if(!t.isValid())return!1;const s=t.multiplier();if((0,d.isTicksEnabled)()&&i===o.ResolutionKind.Ticks)return!0;return(i===o.SpecialResolutionKind.Hours?s/60:s)<=C(i)}function C(e){const t=u[e];return Number.isNaN(t)?1:t}function P(e){return C(o.Interval.parseExt(e).guiResolutionKind)}function T(e){return Array.isArray(e)?e:Object.keys(e).map(o.Interval.normalize).filter(c.notNull)}function x(...e){let t=[].concat(...e);return t=(0,l.uniq)(t.filter(w).map(y)),I(t)}function I(e){return e.sort(m)}function M(){return[]}function A(e){const{multiplier:t,shortKind:i}=L(e);return`${t}${i}`}function L(e,t){const i=o.Interval.parse(e);let s=i.multiplier(),n=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),n=o.SpecialResolutionKind.Hours),{multiplier:s.toString(),shortKind:k(n),hint:`${s} ${k(n,s)}`,mayOmitMultiplier:i.isDWM()&&1===s,mayOmitShortKind:i.isMinutes()&&!i.isMinuteHours()}}function k(e,t){if(!t)return{[o.ResolutionKind.Invalid]:"",[o.ResolutionKind.Ticks]:s.t(null,{context:"interval_short"},i(82901)),[o.ResolutionKind.Seconds]:s.t(null,{context:"interval_short"},i(68823)),[o.ResolutionKind.Minutes]:s.t(null,{context:"interval_short"},i(68430)),[o.SpecialResolutionKind.Hours]:s.t(null,{context:"interval_short"},i(38048)),[o.ResolutionKind.Days]:s.t(null,{context:"interval_short"},i(38691)),[o.ResolutionKind.Weeks]:s.t(null,{context:"interval_short"},i(7408)),[o.ResolutionKind.Months]:s.t(null,{context:"interval_short"},i(77995)),[o.ResolutionKind.Range]:s.t(null,{context:"interval_short"},i(93934))}[e];switch(e){case o.ResolutionKind.Ticks:return s.t(null,{plural:"ticks",count:t},i(11913));case o.ResolutionKind.Days:return s.t(null,{plural:"days",count:t},i(41807));case o.ResolutionKind.Weeks:return s.t(null,{plural:"weeks",count:t},i(48898));case o.ResolutionKind.Months:return s.t(null,{plural:"months",count:t},i(98393));case o.ResolutionKind.Seconds:return s.t(null,{plural:"seconds",count:t},i(33232));case o.ResolutionKind.Minutes:return s.t(null,{plural:"minutes",count:t},i(78318));case o.SpecialResolutionKind.Hours:return s.t(null,{plural:"hours",count:t},i(42328));case o.ResolutionKind.Range:return s.t(null,{
plural:"ranges",count:t},i(89937));default:return e}}function D(){return h.enabled("seconds_resolution")}function E(e){return!(!D()&&e.isSeconds()||!(0,d.isTicksEnabled)()&&e.isTicks())&&!(!(0,d.isTicksEnabled)()&&e.isTicks())}function B(e){return E(o.Interval.parse(e))}function V(e){if(h.enabled("allow_supported_resolutions_set_only")){const t=o.Interval.normalize(e);return null!==t&&v(t)}{const t=o.Interval.parse(e);if(!t.isValid()||!E(t))return!1;if(!h.enabled("custom_resolutions")){const t=o.Interval.normalize(e),i=window.ChartApiInstance.defaultResolutions().filter(B);if(!t||-1===i.indexOf(t))return!1}const i=a.linking.dataFrequencyResolution.value();if(void 0!==i&&g(i,t.value())!==t.value())return!1;if(t.isTicks())return a.linking.ticks.value();if(t.isIntraday())return a.linking.intraday.value();{const e=a.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={}))},59769:(e,t,i)=>{"use strict";i.d(t,{barSpacingByScaleRatio:()=>a,priceRangeByScaleRatio:()=>r,scaleRatio:()=>n});var s=i(93280);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}},34391:(e,t,i)=>{"use strict";i.d(t,{allPriceScaleSelectionStrategyInfo:()=>c,createPriceScaleSelectionStrategy:()=>l});var s=i(50151),o=i(11542),n=i(79036);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}},66540:(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}}},11064:(e,t,i)=>{"use strict";i.d(t,{SelectionRenderer:()=>d});var s=i(86441),o=i(34026),n=i(19625),r=i(56468),a=i(72791),l=i(30125);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 new r.HitTestResult(this._data.hittestResult,{pointIndex:i.pointIndex,cursorType:i.cursorType??a.PaneCursorType.Default})}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}},90799:(e,t,i)=>{"use strict";i.d(t,{SeriesBarColorer:()=>_});var s=i(19625),o=i(50151),n=(i(20596),i(8025)),r=i(96e3);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]}}},5171:(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:()=>E,STYLE_CANDLES:()=>P,STYLE_COLUMNS:()=>R,STYLE_HEIKEN_ASHI:()=>k,STYLE_HILO:()=>V,STYLE_HLC_AREA:()=>F,STYLE_HLC_BARS:()=>W,STYLE_HOLLOW_CANDLES:()=>D,STYLE_KAGI:()=>M,STYLE_LINE:()=>T,STYLE_LINE_WITH_MARKERS:()=>N,STYLE_PB:()=>L,STYLE_PNF:()=>A,STYLE_RANGE:()=>B,STYLE_RENKO:()=>I,STYLE_SHORT_NAMES:()=>z,STYLE_STEPLINE:()=>O,SYMBOL_STRING_DATA:()=>U,Status:()=>s,chartStylesWithAttachedStudies:()=>G,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,P=1,T=2,x=3,I=4,M=5,A=6,L=7,k=8,D=9,E=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}},G=[17,18,20]},3070:(e,t,i)=>{"use strict";i.d(t,{SeriesData:()=>p,barFunction:()=>u,barFunctions:()=>l,seriesPlotFunctionMap:()=>h});var s,o,n=i(50151),r=i(64755),a=i(85856);!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: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},c=["open","high","low","close","hl2","hlc3","ohlc4"];function h(){const e=new Map;return c.forEach(((t,i)=>{e.set(t,u(t))})),e}var d;function u(e,t,i){const s=l[t??e],o=l[e],n=l[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]}!function(e){e[e.FirstPrice=0]="FirstPrice",e[e.LastPrice=1]="LastPrice",e[e.LastValuePrice=2]="LastValuePrice"}(d||(d={}))
;class p{constructor(){this.m_bars=new r.PlotList(h(),_),this.m_nsBars=new r.PlotList(h(),_),this._conflatedChunksBuilder=new a.ConflatedChunksBuilder(this.m_bars,(e=>l[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)}}},61105:(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)}}},68805:(e,t,i)=>{"use strict";i.d(t,{actualSymbol:()=>he,chartStyleStudyId:()=>O,createSeriesFormatter:()=>z,displayedSymbolExchange:()=>ce,displayedSymbolName:()=>le,extractLineToolSymbolFromSymbolInfo:()=>se,extractSymbolNameFromSymbolInfo:()=>ie,getChartStyleByResolution:()=>N,getDefaultStyle:()=>R,
getLastUsedSingleValueBasedStyle:()=>V,getLastUsedStyle:()=>B,getSeriesDisplayErrorWV:()=>ve,getSeriesPriceFormattingState:()=>H,getSourceForEconomySymbol:()=>re,getSymbolDelaySeconds:()=>Se,getSymbolExchange:()=>ye,getTranslatedChartStyleName:()=>P,hasVolume:()=>ge,isCloseBasedSymbol:()=>_e,isConvertedToOtherCurrency:()=>$,isConvertedToOtherUnit:()=>X,isEconomicSymbol:()=>fe,isHLCBasedStyle:()=>D,isMeasureUnitSymbol:()=>pe,isPriceSourceStyle:()=>W,isRangeBasedStyle:()=>x,isRangeStyle:()=>M,isRegularSessionId:()=>ue,isSingleValueBasedStyle:()=>k,isTimeBasedStyle:()=>A,isValidStyle:()=>L,measureUnitId:()=>me,preparePriceAxisProperties:()=>F,proSymbol:()=>de,setLastUsedStyle:()=>E,styleChangeRequiresRestart:()=>I,symbolBaseCurrency:()=>q,symbolCurrency:()=>G,symbolCurrencyConvertible:()=>U,symbolHasElectronicSession:()=>ee,symbolHasPreOrPostMarket:()=>Q,symbolHasSeveralSessions:()=>te,symbolOriginalCurrency:()=>j,symbolOriginalUnit:()=>Z,symbolTitle:()=>ae,symbolTitleSeparator:()=>ne,symbolToSaveInState:()=>oe,symbolUnit:()=>Y,symbolUnitConvertibleGroupsIfExist:()=>J});var s=i(11542),o=i(56840),n=(i(49483),i(5171)),r=i(85049),a=i(725),l=i(56570),c=i(46084),h=i(719),d=i(88960),u=i(84425),_=i(36986);const p=l.enabled("pay_attention_to_ticker_not_symbol"),m=l.enabled("uppercase_instrument_names"),g=l.enabled("charting_library_single_symbol_request"),f=l.enabled("use_ticker_on_symbol_info_update"),y=l.enabled("hide_object_tree_and_price_scale_exchange_label");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 P(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 T(e){return-1!==S.indexOf(e)}function x(e){return-1!==b.indexOf(e)}function I(e,t){return!M(e)&&!M(t)&&!(e===t||!T(e)&&!T(t))}function M(e){return 11===e}function A(e){return-1!==w.indexOf(e)}function L(e){return x(e)||A(e)}function k(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 E(e,t){var i;L(e)&&(11!==e&&o.setValue("chart.lastUsedStyle",e),i=e,n.SYMBOL_STRING_DATA[i]||function(e){o.setValue("chart.rawDataStyle",e)}(e),_e(t)&&k(e)&&o.setValue("chart.lastUsedSingleValueBasedStyle",e))}function B(){
const e=o.getInt("chart.lastUsedStyle");return void 0===e?1:e}function V(){const e=o.getInt("chart.lastUsedSingleValueBasedStyle");return void 0===e?14:e}function R(e){return e?11:1}function N(e,t){const i=M(t),s=r.Interval.isRange(e);return!i&&s?R(!0):i&&!s?R(!1):t}function O(e,t){const i=n.SYMBOL_STRING_DATA[e];return void 0===i?null:t?`${i.type}-${i.basicStudyVersion}`:i.type}function F(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 W(e){return C.includes(e)}function H(e,t="default",i=!1){let s,o,n,r=100,a=1;if("default"===t)null!=e&&(({pricescale:r,minmov:a,minmove2:o,fractional:s}=e),n=e.variable_tick_size||void 0);else{let e=t.split(",");3!==e.length&&(e=["100","1","false"]),r=parseInt(e[0]),a=parseInt(e[1]),s="true"===e[2]}return i&&(a=1),{priceScale:r,minMove:a,fractional:s,minMove2:o,variableMinTick:n,ignoreMinMove:i}}function z(e,t,i=!1){const{priceScale:s,minMove:o,fractional:n,minMove2:r,variableMinTick:l}=H(e,t,i);if(null!=e){const a=e.format;if("default"===t&&"volume"===a)return new c.VolumeFormatter({precision:2});if("percent"===a)return new h.PercentageFormatter({priceScale:s,minMove:o,fractional:n,minMove2:r,variableMinTick:l,ignoreMinMove:i})}return new a.PriceFormatter({priceScale:s,minMove:o,fractional:n,minMove2:r,variableMinTick:l,ignoreMinMove:i})}function U(e){return null!==e&&"spread"!==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 j(e,t){return(t?e.original_currency_code:e.original_currency_id)??G(e,t)}function q(e){return e.base_currency_id||null}function $(e){if(null===e||!U(e))return!1;const t=j(e);return null!==t&&t!==G(e)}function K(e,t){return t&&null!==e&&"spread"!==e.type}function Y(e,t){if(null===e||!t)return null;const i=e.unit_id;return void 0===i||""===i?null:i}function Z(e,t){return t?e.original_unit_id||Y(e,t):null}function X(e,t){return!(null===e||!K(e,t))&&(void 0!==e.original_unit_id&&e.original_unit_id!==e.unit_id)}function J(e,t){return null!==e&&K(e,t)?e.unit_conversion_types||null:[]}function Q(e){return null!==e&&void 0!==e.subsessions&&e.subsessions.some((e=>"premarket"===e.id||"postmarket"===e.id))}function ee(e){return null!==e&&void 0!==e.subsessions&&(e.subsessions.some((e=>"regular"===e.id))&&e.subsessions.some((e=>"us_regular"===e.id)))}function te(e){return null!==e&&void 0!==e.subsessions&&e.subsessions.filter((e=>!e.private)).length>1}function ie(e,t,i,s){let o=e&&(i&&e.pro_name||e.full_name||e.name);return g&&t?o=t:(f||!s&&p)&&e&&e.ticker&&(o=e.ticker),m&&o&&(o=o.toUpperCase()),o}function se(e,t){return ie(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,i="exchange"){const s=re(e)??e[i];return t||y?e.name:`${e.name} ${ne} ${s}`}function le(e){let t=e&&(function(e){
return"futures"===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 m?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,_.getChartingLibraryGlobalContext)()?.configurationData?.is_tradingview_data?["stock","fund","index","dr"].includes(t.type)&&"regular"===e||"futures"===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&&"economic"===e.type}function ye(e){const t=re(e);if(null!==t)return t;return e.exchange}function ve(e){return(0,d.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,u.createWVFromGetterAndSubscription)((()=>!e.bars().size()&&!e.isInReplay().value()),e.dataEvents().dataUpdated()).ownership(),(0,u.createWVFromGetterAndSubscription)((()=>({})),e.model().onChartThemeLoaded()).ownership())}function Se(e){return Math.max(0,e?.delay??0)}},98017:(e,t,i)=>{"use strict";i.d(t,{Series:()=>mi});var s=i(50151),o=i(51768),n=i(76422),r=i(9343),a=i(14426),l=i(45579),c=i(80720),h=i(3070),d=i(64755),u=i(8025),_=i(93280),p=i(12988),m=i(68805),g=i(91007),f=i(725),y=i(5171),v=i(27777),S=i(11542),b=i(56570),w=i(22365),C=i(27538),P=(i(56530),i(24708));i(64671);function T(e){const t="QUANDL"===(e=e||{}).exchange,s={title:"",description:"",interval:"",exchange:"",provider:"",chartStyle:"",sessionDescription:"",priceSource:""};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=x(o)):s.title=x(o),e.interval&&(s.interval=(0,P.translatedIntervalString)(e.interval)),t&&e.description){const t=/[\w_]+\/[\w_]+/.exec(e.description);t&&t[0]?s.provider=x(t[0].split("/")[0]):s.provider=x(e.description.split("/")[0])}return e.exchange&&(s.exchange=x(e.exchange)),s.chartStyle=x(function(e){return e.inputs,8===e.style?S.t(null,void 0,i(63876)):""}(e)),e.sessionDescription&&(s.sessionDescription=x(e.sessionDescription)),void 0!==e.priceSource&&(s.priceSource=x(e.priceSource)),s}function x(e){
return e.replace(/'/g,"")}var I=i(62825);const M=S.t(null,void 0,i(70963)),A=S.t(null,void 0,i(75546)),L=b.enabled("hide_unresolved_symbols_in_legend"),k=b.enabled("symbol_info_price_source");class D extends C.StatusProviderBase{constructor(e,t,i){super(),this._series=e,this._statusViewProperties=t,this._options=i||{}}text(){return function(e){const t=T(e);return(e.ticker?t.description:t.title)+(t.interval?", "+t.interval:"")+function(e,t=", "){return(e.provider?`${t}${e.provider}`:"")+(e.exchange?`${t}${e.exchange}`:"")+(e.chartStyle?`${t}${e.chartStyle}`:"")+(e.branding?`${t}${e.branding}`:"")+(e.sessionDescription?`${t}${e.sessionDescription}`:"")+(e.priceSource?`${t}${e.priceSource}`:"")}(t)}(this._getTitleGenerationOptions())}getSplitTitle(){return T(this._getTitleGenerationOptions())}bold(){return!1}size(){return this._statusViewProperties.childs().fontSize.value()+"px"}errorStatus(){const e=this._series.unsupportedResolutionState().value(),t=e?(0,I.getErrorFromUnsupportedResolutionState)(e):this._series.seriesErrorMessage();return null!==t?{error:t,title:e?A:M}:null}_getTitleGenerationOptions(){const e=this._series.symbolInfo(),t=this._statusViewProperties.childs(),i=this._series.symbolTextSourceProxyProperty().value();let s;t.showExchange.value()&&e&&(s=(0,m.getSymbolExchange)(e));const o=(k&&e?.price_source_id?this._series.model().availablePriceSources(this._series.getSymbolString()).name(e.price_source_id):null)??void 0,n=this._series.getInputsProperties().state();return 17===this._series.style()&&(n.type=this._series.properties().childs().volFootprintStyle.childs().type.value()),{description:B(i,e),exchange:s,symbol:L&&null===e?"":this._series.symbol(),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:E(i,e),priceSource:o}}}function E(e,t){return"ticker-and-description"!==e?"":null!==t?t.name:void 0}function B(e,t){if(null!==t)return"ticker"===e?t.name:"long-description"===e&&void 0!==t.long_description?t.long_description:(0,w.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 V extends v.StatusView{constructor(e,t,i){super(new D(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 R=i(50335),N=i(7576),O=i(49483),F=i(928),W=i(15764);const H=O.CheckMobile.any(),z=b.enabled("hide_resolution_in_legend");class U extends N.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 N.DataWindowItem(e.id,e.title,"",e.unimportant))));const t=this._series.symbolInfo();if(t){const e=[t.name];if(z||e.push((0,P.translatedIntervalString)(this._series.interval())),(0,m.isEconomicSymbol)(t)){const i=(0,m.getSourceForEconomySymbol)(t);null!==i&&e.push(i)}else e.push((0,O.onWidget)()||"forex"===t.type?t.exchange:t.listed_exchange);this._header=e.join(` ${m.symbolTitleSeparator} `),this._title=t.description}else this._header=this._series.symbol();let i=this._model.crosshairSource().appliedIndex();b.enabled("use_last_visible_bar_value_in_legend")&&!(0,R.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 H&&(null===this._model.crosshairSource().pane||(0,W.isLineToolName)(F.tool.value())||null!==this._model.lineBeingEdited())}}var G=i(84425);const j=S.t(null,void 0,i(72445));class q extends U{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,G.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)?`${j}:`:""}destroy(){this._backgroundColorSpawn.destroy(),this._visibilityProperty.destroy()}_getValuesProvider(){return this._series.legendValuesProvider()}}var $,K=i(90823),Y=i(50788),Z=i(85049),X=i(14381),J=i(40644),Q=i(92184);!function(e){e[e.ExtrapolateBarsLimit=2e3]="ExtrapolateBarsLimit"}($||($={}));let ee=0;class te{constructor(e,t){this._extrapolatedData=[],this._cacheForFuture=!1,this._modelId=ee++,this._builderCache=null,this._uniqueId=(0,Q.randomHashN)(6),this._resolution=t,this._symbolInfo=e,this._valid=Boolean(e.timezone)&&Boolean(e.session),this._session=new X.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,J.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,J.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 te(this._symbolInfo,e)}barBuilder(){return null===this._builderCache&&(this._builderCache=(0,X.newBarBuilder)(this._resolution,this._session,this._session)),this._builderCache}}var ie=i(91676),se=i(22118);i(13665);(0,r.getLogger)("Chart.Definitions.Series");function oe(e,t){return"TickByTick"===e?{mode:e,updatePeriod:t}:{mode:e}}async function ne(e,t,i){const s=[];return(0,se.isDelay)(e.delay)?async function(e){const t=[];return(0,se.witoutRealtime)(e)?t.push(oe("DelayNoRealtime")):t.push(oe("DelayToRealtime")),t}(e):(0,se.isEod)(e,t)?(s.push(oe("EOD")),s):s}class re{constructor(e,t,i){this._dataUpdatedInfoStatus=new ie.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?e.listed_exchange:""}async description(){const e=this._symbolInfo.value();if(null===e)return"";return{}.description||e.listed_exchange}exchange(){const e=this._symbolInfo.value();return null!==e?e.exchange:""}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,se.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 ne(e,t,this._updatePeriod.value());0!==i.length?this._dataUpdatedInfoStatus.setValue(i):this._dataUpdatedInfoStatus.setValue(null)}}i(84906);var ae=i(37265);(0,r.getLogger)("Chart.DataProblemModel");class le{constructor(e,t){this._mainDataProblem=new ie.WatchedObject(null),this._supportPortalProblems=new ie.WatchedObject([]),this._allDataProblems=new ie.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,ae.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 ce=i(76742),he=i(19063),de=i(98558),ue=i(94164),_e=i(32956),pe=i(49256),me=i(44672);const ge=b.enabled("force_exchange_as_title"),fe=b.enabled("chart_style_hilo_last_price");const ye={alwaysShowGlobalLast:!1,
visibleOnHistoryOnly:!1,showCountdown:!0,showSymbolLabel:!0,useSolidBodyColor:!0};class ve extends de.PriceAxisView{constructor(e,t,i){super(),this._previousCountdown="",this._source=e,this._model=t,this._options={...ye,...i}}updateCountdown(){this._countdownText()!==this._previousCountdown&&(this.update((0,me.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=Z.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,s.ensure)(t.value[0]),o=Z.Interval.parse(this._source.interval()).inMilliseconds(),n=i.valueOf()+o;let r=Math.round((n-this._currentTime())/1e3);if(r<=0)return"";r=Math.min(r,o/1e3);let a=null;r>=3600&&(a=(0,_e.addLeadingZero)(Math.floor(r/3600))),r%=3600;const l=(0,_e.addLeadingZero)(Math.floor(r/60));r%=60;const c=(0,_e.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 o=this._source.properties().childs();if(!fe&&12===o.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()&&o.showCountdown.value()&&(12===(h=o.style.value())?fe:(0,m.isTimeBasedStyle)(h))&&(this._options.alwaysShowGlobalLast||n.contains(r.index));var h;let d=this._options.showSymbolLabel&&a.showSymbolLabels.value();const u=a.seriesLastValueMode.value()===ue.PriceAxisLastValueMode.LastPriceAndPercentageValue,_=this._source.lastValueData(void 0,this._options.alwaysShowGlobalLast);if(_.noData)return;const p=8===o.style.value();if((l||c||d)&&p&&o.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 g=(0,he.resetTransparency)(this._source.priceLineColor(_.color));if(this._options.useSolidBodyColor?(i.background=g,i.borderColor=void 0):(i.background=this._model.backgroundColorAtYPercentFromTop((i.fixedCoordinate??i.coordinate)/(0,s.ensureNotNull)(this._model.paneForSource(this._source)).height()),i.borderColor=g),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=g),e.textColor=i.textColor;const s=l&&u?(0,pe.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,he.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.symbolInfo();return ge?t=(0,m.displayedSymbolExchange)(i):e&&(t=(0,m.displayedSymbolName)(i)),t}_axisFirstLineText(e,t){return t?(0,pe.getCurrentModePriceText)(this._source.priceScale(),e):""}_currentTime(){return window.ChartApiInstance.serverTime()}}var Se=i(18112),be=i(39772),we=i(37626);class Ce extends ve{lastPrice(){return this._getSource().data().lastProjectionPrice}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const o=this._getModel(),n=this._getSource(),r=n.priceScale(),a=o.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(),_=n.data(),p=_.search(d,u.PlotRowSearchMode.NearestLeft);if(null===p)return;const m=n.nearestIndex(h,u.PlotRowSearchMode.NearestRight);if(void 0===m)return;const g=n.model().properties().childs().scalesProperties.childs(),f=(0,s.ensureNotNull)(_.valueAt(m))[4];let y=i.background,v=g.showSeriesLastValue.value(),S=!1,b=!1,w=!1;const C=n.lastValueData(4,!1),P=n.properties().childs();if(8===P.style.value()&&P.haStyle.childs().showRealLastPrice.value()){const e=n.lastValueData(4,!0);if(e.noData||e.color===i.background||(y=(0,he.resetTransparency)(e.color)),!e.noData&&!C.noData){const t=e.index===C.index;S=t&&g.showSymbolLabels.value(),b=g.seriesLastValueMode.value()===ue.PriceAxisLastValueMode.LastPriceAndPercentageValue,v=v&&t,w=t&&this._isCountdownEnabled()&&P.showCountdown.value()}}else{const e=n.barColorer().barStyle(p.index,!0);y=(0,he.resetTransparency)(e.barColor)}if(i.background=y,i.textColor=this.generateTextColor(y),i.secondLineTextColor=i.textColor,i.thirdLineTextColor=(0,he.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 Pe=i(65458),Te=i(52397),xe=i(19625),Ie=i(51056);const Me={light:{lineStyle:Ie.LINESTYLE_DOTTED,lineWidth:1,backgroundColor:xe.colorsPalette["color-tv-blue-50"],lineColor:xe.colorsPalette["color-cold-gray-500"]},dark:{lineStyle:Ie.LINESTYLE_DOTTED,lineWidth:1,backgroundColor:xe.colorsPalette["color-tv-blue-a800"],lineColor:xe.colorsPalette["color-cold-gray-500"]}};function Ae(e){return e?Me.dark:Me.light}class Le extends Te.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=Ae(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 ke extends de.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=Ae(this._model.dark().value()),l=(0,he.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 De extends we.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return Ae(this._model.dark().value()).lineWidth}_lineStyle(){return Ae(this._model.dark().value()).lineStyle}_priceLineColor(e){return Ae(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 Ee;!function(e){e[e.High=0]="High",e[e.Low=1]="Low"}(Ee||(Ee={}));const Be=S.t(null,void 0,i(78254)),Ve=S.t(null,void 0,i(65318));function Re(e,t,i,s){const o=new Le(e,i,s),n=new ke(e,i.label,i,s);return{paneView:o,panePriceAxisView:new Pe.PanePriceAxisView(n,t,e),priceAxisView:n,priceLineAxisView:new De(e,i.lineVisible,s)}}const Ne={light:{lineStyle:Ie.LINESTYLE_DOTTED,lineWidth:1,textColor:(0,xe.getHexColorByName)("color-cold-gray-900"),backgroundColor:(0,xe.getHexColorByName)("color-tv-blue-50"),lineColor:(0,xe.getHexColorByName)("color-cold-gray-500")},dark:{lineStyle:Ie.LINESTYLE_DOTTED,lineWidth:1,textColor:(0,xe.getHexColorByName)("color-white"),backgroundColor:(0,xe.getHexColorByName)("color-tv-blue-a800"),lineColor:(0,xe.getHexColorByName)("color-cold-gray-500")}};function Oe(e){return e?Ne.dark:Ne.light}class Fe extends Te.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=Oe(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 We extends de.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=Oe(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 He extends we.PriceLineAxisView{constructor(e,t,i){super(),this._model=e,this._isLineVisible=t,this._getValue=i}_isVisible(){return this._isLineVisible.value()}_lineWidth(){return Oe(this._model.dark().value()).lineWidth}_lineStyle(){return Oe(this._model.dark().value()).lineStyle}_priceLineColor(e){return Oe(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 ze;!function(e){e[e.Avg=0]="Avg"}(ze||(ze={}));const Ue=S.t(null,void 0,i(73025));function Ge(e,t,i,s){const o=i.childs(),n=function(e,t,i,s){const o=new Fe(e,i,s),n=new We(e,i.label,i.labelVisible,s),r=new Pe.PanePriceAxisView(n,t,e),a=new He(e,i.lineVisible,s);return{paneView:o,panePriceAxisView:r,priceAxisView:n,priceLineAxisView:a}}(e,t,{label:Ue,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 je=i(76748);const qe={open:S.t(null,{context:"in_legend"},i(46728)),high:S.t(null,{context:"in_legend"},i(43253)),low:S.t(null,{context:"in_legend"},i(89923)),close:S.t(null,{context:"in_legend"},i(2696)),hl2:S.t(null,{context:"in_legend"},i(61372)),hlc3:S.t(null,{context:"in_legend"},i(55096)),ohlc4:S.t(null,{context:"in_legend"},i(94174))},$e=O.CheckMobile.any();class Ke extends je.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=qe.open,o.title=qe.high,n.title=qe.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._showSeriesOHLCProp.value(),n=s&&this._showBarChangeProp.value(),r=s&&this._showLastDayChangeProp.value(),a=!$e||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().is1Tick(),u=t[7];u.visible=u.visible&&this._showVolumeProp.value();const _=(0,m.isPriceSourceStyle)(this._seriesStyleProp.value()),p=o&&!_,g=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?"":qe.close,t[4].visible=g,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}}var Ye,Ze=i(52033),Xe=i(76350),Je=i(73698),Qe=i(86441);class et{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 tt(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"}(Ye||(Ye={}));const it=[{start:0,end:.25,startRadius:4,endRadius:10,startFillAlpha:.25,endFillAlpha:0,startStrokeAlpha:.4,endStrokeAlpha:.8,easing:tt},{start:.25,end:.525,startRadius:10,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:.8,endStrokeAlpha:0,easing:tt},{start:.525,end:1,
startRadius:14,endRadius:14,startFillAlpha:0,endFillAlpha:0,startStrokeAlpha:0,endStrokeAlpha:0,easing:tt}];function st(e,t,i,s){const o=i+(s-i)*t;return(0,he.applyTransparency)(e,(0,he.alphaToTransparency)(o))}const ot=(0,xe.getHexColorByName)("color-minty-green-400"),nt=(0,xe.getHexColorByName)("color-ripe-red-500");function rt(e,t,i){const s=e%2600/2600;let o;for(const e of it)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:st(i,n,o.startFillAlpha,o.endFillAlpha),strokeColor:st(i,n,o.startStrokeAlpha,o.endStrokeAlpha),radius:(r=n,a=o.startRadius,l=o.endRadius,a+(l-a)*r)};var r,a,l}class at{constructor(e){this._renderer=new et,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 Qe.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?ot:nt;const c=rt(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=rt(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 lt=i(62288),ct=i(64147),ht=i(18172),dt=i(4340);class ut{constructor(){this._created=new Ze.Delegate,this._modified=new Ze.Delegate,this._loading=new Ze.Delegate,this._completed=new Ze.Delegate,this._error=new Ze.Delegate,this._symbolError=new Ze.Delegate,this._symbolResolved=new Ze.Delegate,this._seriesError=new Ze.Delegate,this._symbolNotPermitted=new Ze.Delegate,this._symbolInvalid=new Ze.Delegate,this._symbolGroupNotPermitted=new Ze.Delegate,this._chartTypeNotPermitted=new Ze.Delegate,this._intradaySpreadNotPermitted=new Ze.Delegate,this._intradayExchangeNotPermitted=new Ze.Delegate,this._customIntervalNotPermitted=new Ze.Delegate,this._secondsIntervalNotPermitted=new Ze.Delegate,this._ticksIntervalNotPermitted=new Ze.Delegate,this._barReceived=new Ze.Delegate,this._seriesTimeFrame=new Ze.Delegate,this._dataUpdated=new Ze.Delegate,this._unsupportedResolutionRequested=new Ze.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){this._dataUpdated.fire(e,t,i,s)}fireUnsupportedResolutionRequested(){this._unsupportedResolutionRequested.fire()}}var _t=i(52270);const pt=(0,r.getLogger)("Chart.SeriesDataSource");var mt;!function(e){e[e.Idle=0]="Idle",e[e.AwaitingConnection=1]="AwaitingConnection",e[e.AwaitingFirstDataUpdate=2]="AwaitingFirstDataUpdate",e[e.Active=3]="Active"}(mt||(mt={}));let gt=1;let ft=1;function yt(e){return e.startDate?e.endDate||e.count?e.endDate?["from_to",e.startDate,e.endDate]:["bar_count",e.startDate,(0,s.ensure)(e.count)]:["from_to",e.startDate]:e.count||300}function vt(e){return(0,ae.isString)(e.symbol)?e.symbol:e.symbol.symbol}function St(e,t){(0,ae.isString)(e.symbol)?e.symbol=t:e.symbol.symbol=t}class bt{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 h.SeriesData,this._dataEvents=new ut,this._status=mt.Idle,this._turnaroundCounter=1,this._boundOnGatewayIsConnectedChanged=this._onGatewayIsConnectedChanged.bind(this),this._ongoingDataUpdate=Promise.resolve(),this._gateway=e,this._turnaroundPrefix=t,this._createSeriesParams=yt(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()}modifySeries(e,t,i=null,o=!1,n=null){o&&(pt.logNormal("Due to force flag clearing symbol & resolution to force re-requesting data."),this._extSymbol=null,this._resolution=null);const r=vt(e),a=!this.symbolSameAsResolved(r);if(a&&(this._lastResolvedSymbol=""),this._extSymbol&&!a){St(e,vt(this._extSymbol))}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,ae.deepEquals)(l,e)[0];h&&St(this._extSymbol,r);const d=null===c||!Z.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,s.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!==mt.Idle}isActive(){return this._status===mt.Active}resolution(){return this._resolution}start(){this.isStarted()?pt.logNormal("start: data source is already started, nothing to do"):((0,s.assert)(null!==this._extSymbol,"symbol must be set before start"),(0,s.assert)(null!==this._resolution,"resolution must be set before start"),this._gateway.isConnected().value()?this._createSeries():this._changeStatusTo(mt.AwaitingConnection))}stop(){this.isStarted()?(null!==this._instanceId&&(this._gateway.removeSeries(this._instanceId),this._instanceId=null),this._symbolInstanceId=null,this._changeStatusTo(mt.Idle)):pt.logNormal("stop: data source is already stopped, nothing to do")}instanceId(){return this._instanceId}data(){return this._data}setData(e){this._data=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}moveData(e){this._enqueueUpdate((()=>this._data.moveData(e)))}setInitialRequestOptions(e){this._createSeriesOverriddenParams=yt(e)}symbolSameAsResolved(e){return null!==this._extSymbol&&(0,_t.symbolSameAsResolved)(e,vt(this._extSymbol),this._lastResolvedSymbol)}resolvedSymbol(){return null===this._extSymbol?null:vt(this._extSymbol)}_resolveSymbol(){null!==this._extSymbol&&(this._symbolInstanceId=this._gateway.resolveSymbol("sds_sym_"+gt++,(0,Je.encodeExtendedSymbolOrGetSimpleSymbolString)(this._extSymbol),this._onMessage.bind(this)))}_clearDataImpl(){this._data.clear()}_changeStatusTo(e){(0,s.assert)(this._status!==e,"Source and destination status should be distinct"),pt.logNormal(`Status changed from ${mt[this._status]} to ${mt[e]}`),this._status=e}_createSeries(){(0,s.assert)(this._status!==mt.Active,'Status should not be "Active" when creating a study'),this._instanceId="sds_"+ft++,this._resolveSymbol();const e=this._createSeriesOverriddenParams||this._createSeriesParams;this._createSeriesOverriddenParams&&(this._createSeriesOverriddenParams=0),this._gateway.createSeries(this._instanceId,this.turnaround(),(0,s.ensureNotNull)(this._symbolInstanceId),(0,s.ensureNotNull)(this._resolution),e,this._timeFrame,this._onMessage.bind(this)),this._timeFrame=null,this._changeStatusTo(mt.AwaitingFirstDataUpdate),this._dataEvents.fireCreated(this._instanceId)}_onGatewayIsConnectedChanged(e){e?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===mt.AwaitingConnection&&this._createSeries()}_onGatewayDisconnected(){
this._status!==mt.Idle&&this._status!==mt.AwaitingConnection&&(this._instanceId=null,this._changeStatusTo(mt.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&&pt.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&&pt.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)){pt.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)){pt.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)){pt.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)){pt.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()){pt.logNormal(`Clear data for old data, expected: ${this.turnaround()}, actual ${e.params.turnaround}`);break}this._clearDataImpl(),this._dataEvents.fireDataUpdated(void 0,!1,null,!1)}}_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,s.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,
s.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]===dt.permissionDenied)switch(e.params[2]){case dt.SymbolErrorPermissionDeniedReason.Symbol:this._dataEvents.fireSymbolNotPermitted(e.params[3]);break;case dt.SymbolErrorPermissionDeniedReason.GroupPermission:this._dataEvents.fireSymbolGroupNotPermitted(e.params[3]);break;default:this._dataEvents.fireSymbolNotPermitted(e.params[2])}else e.params[1]===dt.invalidSymbol&&this._dataEvents.fireSymbolInvalid();this._dataEvents.fireSymbolError(e.params[1])}_onSymbolResolved(e){this._lastResolvedSymbol=(0,s.ensureNotNull)((0,m.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,ht.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===mt.Idle)return;this._status===mt.AwaitingFirstDataUpdate&&(this._changeStatusTo(mt.Active),this._clearDataImpl());const s=this._data.bars().size(),o=this._data.bars().firstIndex(),n=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 r=null===o,a=r||null!==n&&n.index<o;this._dataEvents.fireDataUpdated(t,a,n,r),s!==this._data.bars().size()&&null!==n&&this._dataEvents.fireBarReceived(n)}_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 wt=i(22820),Ct=i(10074),Pt=i(45687);class Tt extends Te.HorizontalLinePaneView{constructor(e){super(),this._series=e,this._model=e.model()}}const xt=b.enabled("chart_style_hilo_last_price");class It extends Tt{constructor(e){super(e),this._lineRendererData.linestyle=Ie.LINESTYLE_DOTTED}_updateImpl(){this._lineRendererData.visible=!1;const e=this._series.properties().childs();if(!e.showPriceLine.value())return;if(!xt&&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 Mt=i(12374),At=i(83379),Lt=i(53766),kt=i(99800),Dt=i(72476),Et=i(80941),Bt=i(84626),Vt=i(70527),Rt=i(95201),Nt=i(61993),Ot=i(11064),Ft=i(25201);class Wt extends Dt.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,Nt.optimalBarWidth)(i),wickVisible:t.drawWick.value(),isPriceScaleInverted:e.isInverted()},o=new Rt.CompositeRenderer;return o.append(new Ft.PaneRendererCandles(s)),this._model.selection().isSelected(this._source)&&this._isMarkersEnabled&&this._selectionData&&o.append(new Ot.SelectionRenderer(this._selectionData)),o}}var Ht=i(15599),zt=i(93250),Ut=i(15716),Gt=i(90799),jt=i(79036),qt=i(24526),$t=i(88145),Kt=(i(20596),i(19466)),Yt=i(42989);class Zt extends Tt{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 Xt=i(88960),Jt=i(678),Qt=i(46088),ei=i(18032);const ti=b.enabled("price_scale_always_last_bar_value"),ii=b.enabled("display_data_mode"),si=!b.enabled("hide_series_legend_item"),oi=b.enabled("hide_price_scale_global_last_bar_value"),ni=b.enabled("show_average_close_price_line_and_label"),ri=b.enabled("no_bars_status"),ai=b.enabled("charting_library_debug_mode"),li=b.enabled("chart_style_hilo_last_price"),ci=(0,r.getLogger)("Chart.Series"),hi=b.enabled("pre_post_market_sessions");const di={countdownEnabled:!0,lastPriceAnimationEnabled:!0};function ui(e,t,i){return void 0===t?null:`${e}=${t} (${i?"changed":"unchanged"})`}function _i(e){const t=e.state();return t.data.forEach((e=>e.value.splice(7,1))),t}function pi(e){const{seriesStatus:t,additionalStudyStatus:i}=e;if(y.seriesLoadingStatuses.has(t))return 2;if(i){if(4!==t&&i.type===Jt.StudyStatusType.Error)return 13;if(y.seriesReadyStatuses.has(t)&&(i.type===Jt.StudyStatusType.Loading||i.type===Jt.StudyStatusType.Undefined))return 2}return t}class mi extends l.PriceDataSource{constructor(e,t,i,o){t.removeProperty("currencyId"),super(e,"_seriesId"),this.isSeries=!0,this.requestingStyleIsNotSupported=new Ze.Delegate,
this.requestingStyleSupportRecovered=new Ze.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 ct.WatchedValue(null),this._isPrePostMarketPricesAvailableProperty=new p.Property(!1),this._isBackAdjustmentForbiddenProperty=new p.Property(!0),this._isSettlementAsCloseForbiddenProperty=new p.Property(!0),this._highLowPriceCache=new Map,this._averagePriceCache=new Map,this._prevClosePriceAxisView=null,this._priceScaleAboutToBeChanged=new Ze.Delegate,this._onRestarted=new Ze.Delegate,this._onStatusChanged=new Ze.Delegate,this._tagsChanged=new Ze.Delegate,this._intervalChanged=new Ze.Delegate,this._sessionIdChanged=new Ze.Delegate,this._requestMoreDataAvailable=!0,this._lineStyleLastPriceCirclePaneView=new at(this),this._prevClosePriceLineView=null,this._dataPoweredBy=null,this._symbolResolvingActive=new ct.WatchedValue(!1),this._predictBars=0,this._syncModel=null,this._data=null,this._lastCompleteFlags=null,this._haStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(8,!0))},this._renkoStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(4,!0))},this._pbStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(7,!0))},this._kagiStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(5,!0))},this._pnfStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(6,!0))},this._rangeStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(11,!0))},this._volFootprintStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(17,!0))},this._tpoStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(18,!0))},this._svpStyle={studyId:(0,s.ensureNotNull)((0,m.chartStyleStudyId)(20,!0))},this._barColorerCache=null,this._boxSizeValue=new ct.WatchedValue,this._base=100,this._pointValue=1,this._formattingDeps=null,this._defaultFormatter=new f.PriceFormatter({priceScale:this._base}),this._formatter=new f.PriceFormatter({priceScale:this._base}),this._ignoreMinMoveFormatter=new f.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 Ze.Delegate,this._intervalObj=null,this._obsoleteZOrder=0,this._seriesErrorMessage=null,this._seriesAlwaysFalseHibernatedVW=new ct.WatchedValue(!1),this._styleToRecover=null,this._precomputedBarStyles=new WeakMap,this._doNotShowLastAvailableBar=!1,this._gotoDateResultCleared=!1,this._endOfDataPaneView=null,this._pendingTimeRange=null,this._replaySubscriber=new ct.WatchedValue(null),this._symbolIntervalChanged=new Ze.Delegate,this._isReplayResolutionAvailableForUser=null,this._onInReplayStateChanged=new Ze.Delegate,this._onReplaySubscriberSeriesModified=new Ze.Delegate,
this._paramsNotApplicableForReplay=new Ze.Delegate,this._onTimeFrameApplied=new Ze.Delegate,this._seriesLoaded=!1,this._seriesCompleted=!1,this._status=new ct.WatchedValue({seriesStatus:0}),this._prevRequestedInterval="",this._isActingAsSymbolSource=new ct.WatchedValue(!0),this._unsupportedResolutionState=new ct.WatchedValue(null),this._countdownUpdateTimer=null,this._deferredDestroyed=(0,a.createDeferredPromise)(),this._volumePointWeights=null,this._studyBindings=null,this._lineColorAtYPercentFromTop=new be.GradientColorCache,this._savedLeftEdge=null,this._pendingScrollToLeftEdge=null,this._updateTimeScaleTimePointWeights=()=>{0},this._seriesStatus=(0,Xt.combine)(pi,this._status.weakReference()),this._seriesSource=new bt(e.chartApi(),"s",o);const n=this._seriesSource.dataEvents();n.symbolResolved().subscribe(this,this._onSymbolResolved),n.symbolError().subscribe(this,this._onSymbolError),n.seriesTimeFrame().subscribe(this,this._onSeriesTimeFrame),n.seriesError().subscribe(this,this._onSeriesError),n.loading().subscribe(this,this._onSeriesLoading),n.completed().subscribe(this,this._onSeriesCompleted),n.dataUpdated().subscribe(this,this._onDataUpdated),n.barReceived().subscribe(this,this._onBarReceived),n.unsupportedResolutionRequested().subscribe(this,this._onUnsupportedResolutionRequested),this._quotesProvider=new ce.QuotesProvider(void 0,e.collapsed().spawnOwnership()),this._quotesProvider.quotesUpdate().subscribe(this,this._onQuotesUpdate);const r=t.childs();if(t.hasChild("extendedHours")){(0,s.ensureDefined)(r.extendedHours).value()&&!t.hasChild("sessionId")&&t.addChild("sessionId",new p.Property("extended")),t.removeProperty("extendedHours")}t.hasChild("sessionId")||t.addChild("sessionId",new p.Property(g.SubsessionId.Regular)),(0,Yt.allChartStyles)().includes(r.style.value())||r.style.setValueSilently(2);const l=r.lineStyle.childs();if(r.lineStyle.hasChild("styleType")){let e,t;const i=l.styleType.value();0===i&&(t=14,e=r.lineWithMarkersStyle.childs()),1===i&&(t=15,e=r.steplineStyle.childs()),e&&(e.color.setValueSilently(l.color.value()),e.linestyle.setValueSilently(l.linestyle.value()),e.linewidth.setValueSilently(l.linewidth.value()),e.priceSource.setValueSilently(l.priceSource.value())),void 0!==t&&2===r.style.value()&&r.style.setValue(t),r.lineStyle.removeProperty("styleType")}this._studyBindings?.bindToSeriesProperties(t),this._setProperties(t),this._sessionIdProxyProperty=new p.Property(r.sessionId.value()),r.sessionId.subscribe(this,(()=>this._updateSessionIdProxyProperty())),this._sessionIdProxyProperty.subscribe(this,this._onSessionIdProxyPropertyChanged),this._symbolTextSourceProxyProperty=new p.Property,this._recalcSymbolTextSourceProxyProperty(),r.statusViewStyle.childs().symbolTextSource.subscribe(this,this._recalcSymbolTextSourceProxyProperty),this._symbolTextSourceProxyProperty.subscribe(this,(()=>e.lightUpdate())),this._options=(0,ae.merge)((0,ae.clone)(di),i),this._prevChartStyle=r.style.value(),this._priceAxisView=new ve(this,e,{alwaysShowGlobalLast:!oi,showCountdown:i.countdownEnabled})
;let c=null;ti||oi||(c=new ve(this,e,{visibleOnHistoryOnly:!0,showSymbolLabel:!1,showCountdown:!1,alwaysShowGlobalLast:!1,useSolidBodyColor:!1})),this._priceLinePriceAxisView=new we.SeriesPriceLineAxisView(this),this._priceLineAxisViews=[this._priceLinePriceAxisView],this._projectionPriceAxisView=new Ce(this,e,{showCountdown:i.countdownEnabled}),this._priceAxisViews=[this._priceAxisView,this._projectionPriceAxisView],null!==c&&this._priceAxisViews.push(c),this._panePriceAxisView=new Pe.PanePriceAxisView(this._priceAxisView,this,e),this._historyPricePanePriceAxisView=null!==c?new Pe.PanePriceAxisView(c,this,e):null,this._projectionPanePriceAxisView=new Pe.PanePriceAxisView(this._projectionPriceAxisView,this,e),this._labelPaneViews=[this._panePriceAxisView,this._projectionPanePriceAxisView],null!==this._historyPricePanePriceAxisView&&this._labelPaneViews.push(this._historyPricePanePriceAxisView),this._highLowAvgPaneViews=[],this._averagePaneViews=[],ni&&this._createAverageViews(),this._createHighLowAvgViews(),this._subscribeRestartToSessionIdChange(),r.visible.subscribe(this,this._updateLastPriceAnimationActive),this._updateLastPriceAnimationActive(),r.minTick.subscribe(this,this._onFormatterPropsChanged),this._dataWindowView=new U(this,e),this._legendView=new q(this,e),this._statusView=new V(this,r.statusViewStyle),this._marketStatusModel=new K.MarketStatusModel(this._quotesProvider),this._dataUpdatedModeModel=ii?new re(this._symbolInfo.spawn().ownership(),this._seriesStatus.spawn().ownership(),(0,G.createWVFromGetterAndSubscription)((()=>this._lastCompleteFlags?.rt_update_period),n.completed()).ownership()):null,this._dataProblemModel=new le(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 Zt(this);for(const[,e]of Object.entries(y.STYLE_SHORT_NAMES))this._properties.child(`${e}Style`)?.subscribe(this,(()=>this.invalidateBarStylesCache()));const h=r.renkoStyle.childs().inputs.childs();h.boxSize.subscribe(this,this.restart),h.style.subscribe(this,this.restart),h.atrLength.subscribe(this,this.restart),h.percentageLTP.subscribe(this,this.restart),h.wicks.subscribe(this,this.restart),h.sources.subscribe(this,this.restart),r.pbStyle.childs().inputs.childs().lb.subscribe(this,this.restart);const d=r.kagiStyle.childs().inputs.childs();d.reversalAmount.subscribe(this,this.restart),d.style.subscribe(this,this.restart),d.atrLength.subscribe(this,this.restart),d.percentageLTP.subscribe(this,this.restart);const u=r.pnfStyle.childs().inputs.childs();u.boxSize.subscribe(this,this.restart),u.reversalAmount.subscribe(this,this.restart),u.sources.subscribe(this,this.restart),
u.style.subscribe(this,this.restart),u.atrLength.subscribe(this,this.restart),u.percentageLTP.subscribe(this,this.restart),u.oneStepBackBuilding.subscribe(this,this.restart),r.rangeStyle.childs().inputs.childs().phantomBars.subscribe(this,this.restart),this._isDWMProperty=new p.Property(this.isDWM()),this._onRestarted.subscribe(this,(()=>this._isDWMProperty.setValue(this.isDWM()))),r.showCountdown.subscribe(this,this._onShowCountdownChanged),this._onShowCountdownChanged(r.showCountdown),this._recreatePriceFormattingDependencies(),r.lineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.lineWithMarkersStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.steplineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.areaStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.baselineStyle.childs().priceSource.subscribe(this,this._updateBarFunction),r.columnStyle.childs().priceSource.subscribe(this,this._updateBarFunction),this._updateBarFunction(),this._isInReplay=(0,Xt.combine)((e=>null!==e),this._replaySubscriber.weakReference()),this._legendValuesProvider=new Ke(this,this.model()),this._dataWindowValuesProvider=new je.SeriesValuesProvider(this,this.model())}setId(e){super.setId(e),(0,Se.getPersistentLogger)()?.addPersistentLogEntry(`Set series Id to ${e}`,r.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:y.seriesLoadingStatuses.has(e)?null:t?.type===Jt.StudyStatusType.Error?(0,Jt.convertStudyStatusToString)({type:Jt.StudyStatusType.Error,errorDescription:t.errorDescription},!0):null}destroy(){this._seriesStatus.destroy(),this._quotesProvider.quotesUpdate().unsubscribeAll(this),this._quotesProvider.destroy(),this.clearGotoDateResult(),this._legendView.destroy(),this._marketStatusModel.destroy(),this._studyBindings&&this._studyBindings.destroy(),null!==this._dataUpdatedModeModel&&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.dataSources();for(let i=t.length-1;i>=0;i--){const o=t[i];if((0,jt.isStudy)(o)&&o.hasBarColorer()&&!o.isSourceHidden()){const t=(0,s.ensureNotNull)(o.barColorer());null===e?e=t:e.pushBackBarColorer(t)}}
return null===e?e=new Gt.SeriesBarColorer(this):e.pushBackBarColorer(new Gt.SeriesBarColorer(this)),this._barColorerCache=e,e}createPaneView(){this._paneView=null,this._projectionBarsPaneView=null,this._waterlineView=null,this._priceLineView=this.hasClosePrice()?new It(this):null;const e=this._properties.childs().style.value();switch(e){case 0:this._paneView=new kt.SeriesBarsPaneView(this,this._model);break;case 17:case 19:case 1:this._paneView=new Dt.SeriesCandlesPaneView(this,this._model,1===e||19===e?1:.2);break;case 2:case 18:case 14:case 15:this._paneView=new Et.SeriesLinePaneView(this,this._model);break;case 3:this._paneView=new Bt.SeriesAreaPaneView(this,this._model);break;case 16:this._paneView=new Vt.SeriesHLCAreaPaneView(this,this._model);break;case 8:this._paneView=new Wt(this,this._model);break;case 9:this._paneView=new Ht.SeriesHollowCandlesPaneView(this,this._model);break;case 13:this._paneView=new Lt.SeriesColumnsPaneView(this,this._model);break;case 10:{this._paneView=new zt.SeriesBaselinePaneView(this,this._model);const e=this._properties.childs().baselineStyle.childs();this._waterlineView=new Mt.SeriesWaterlinePaneView({paneHeight:()=>this.priceScale().height(),color:()=>e.baselineColor.value(),baseLevelPercentage:()=>e.baseLevelPercentage.value()});break}case 12:this._paneView=new At.SeriesHiLoPaneView(this,this._model);break;case 21:this._paneView=new ei.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 te(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(lt.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,s.ensureNotNull)(this._baseHorizontalLineView),(0,s.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,s.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,n.emit)("series_event","price_scale_changed"),this._priceScaleChanged.fire(e))}priceScaleChanged(){return this._priceScaleChanged}priceScaleAboutToBeChanged(){return this._priceScaleAboutToBeChanged}applyPreferences(e){const t=(0,ae.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._symbolInfo.setValue(null)}isStarted(){return this._seriesSource.isStarted()}isCompleted(){return this._seriesCompleted}restart(e,t,i){if(5===this._status.value().seriesStatus)return;this._seriesLoaded=!1,this._seriesCompleted=!1,this._lastCompleteFlags=null,this._onRestarted.fire(),this._setStatus(1),this._updateSymbolInfo(null);const s=this._properties.childs().interval.value();Z.Interval.isEqual(s,this._prevRequestedInterval)&&this._notifyIntervalChanged(s);let o=null;this._pendingTimeRange&&(o=this._pendingTimeRange,this._pendingTimeRange=null),this._onBeforeModifySeries(this.getSymbolString(),s),this._onTimeFrameApplied.fire(o);const n=(0,Pt.getServerInterval)(s);this._data=null,this.model().recalcVisibleRangeStudies(c.RecalcVisibleRangeStudiesReason.SeriesRestart),this._seriesSource.modifySeries(this._getResolvingSymbolObject(),n,o),this._seriesSource.isStarted()||this._seriesSource.start(),this._prevRequestedInterval=this.interval(),this.updateAllViews((0,me.sourceChangeEvent)(this.id())),this._model.lightUpdate()}isSymbolInvalid(){return 4===this._status.value().seriesStatus}getSymbolString(){return(0,Je.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject())}getAlertSymbolString(){return(0,Je.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(this.actualSymbol()))}invalidateBarStylesCache(e){ci.logDebug("Invalidate style cache starting from "+e),this._clearStylePlot(this.bars(),e),this._clearStylePlot(this.nsBars())}isLoading(){return y.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,m.actualSymbol)(this.symbolInfo(),this.symbol())}proSymbol(){return(0,m.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,m.isRangeBasedStyle)(this.style())}symbolSameAsCurrent(e){return this.symbol()===e||(0,Xe.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()}symbolChanged(){return this.properties().childs().symbol}seriesSource(){return this._seriesSource}symbolInfo(){return this._symbolInfo.value()}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,u.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(){const e=this.interval();if(null!==this._intervalObj&&this._intervalObj.resolutionString===e)return this._intervalObj.interval;const t=Z.Interval.parse(e);return this._intervalObj={resolutionString:e,interval:t},t}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 li||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(),u.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),_={...o.getFormattedValues(c,r,!0),noData:!1,color:h.barColor,floatCoordinate:d,coordinate:d,index:l};return i&&(_.price=c),_}isDWM(){return this.intervalObj().isDWM()}isPulse(){const e=this.symbolInfo();return null!==e&&(e.resolutions??[]).length>0}data(){return this._data??this._seriesSource.data()}clearData(){(0,s.assert)(null===this._data,"Cannot clear loaded data"),this._studyBindings?.clearData(),this._seriesSource.clearData()}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(!y.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,s.ensureNotNull)(this.data().last()).index;if(this._predictBars<i&&(this._predictBars=i,this._seriesSource.requestMoreTickmarks(i)),!this._requestMoreDataAvailable)return;const o=(0,s.ensureNotNull)(this.bars().firstIndex()),n=e||Math.max(o-t.firstBar(),o-(this._studyBindings?.requestMoreDataIndex()??o));n<=0||(Number.isFinite(n)?(this._requestMoreDataAvailable=!1,this._seriesSource.requestMoreData(n),this._setStatus(2)):ci.logWarn("requestMoreData: invalid bar count: "+n+", visible bars: ["+t.firstBar()+", "+t.lastBar()+"], last index: "+(0,s.ensureNotNull)(this.data().last()).index+", predicted bars: "+this._predictBars+", required bars:"+e))}isNeedRestart(e){return 5!==this._status.value().seriesStatus&&(void 0===e&&(e=this.properties().childs().style.value()),(0,m.styleChangeRequiresRestart)(this._prevChartStyle,e))}isStyleSupported(e){return!0}sessionId(){return this.properties().childs().sessionId.value()}sessionIdChanged(){return this._sessionIdChanged}priceRange(e,t,i){const o=this._priceScale;if(this.data().isEmpty()||!o)return null;if(o.isLockScale()){const e=this._model.mainSeriesScaleRatio();if(null!==e){const i=o.internalHeight()/(this.model().timeScale().barSpacing()/e),n=(0,s.ensureNotNull)(this.data().search(t,u.PlotRowSearchMode.NearestLeft)).value,r=((0,s.ensure)(n[2])+(0,s.ensure)(n[3]))/2;return new _.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,d.mergeMinMax)(r,a),null===r)l=new _.PriceRange(-.5,.5);else if(r.min===r.max){const e=5/(this.symbolInfo()?.pricescale??100);l=new _.PriceRange(r.min-e,r.max+e)}else l=new _.PriceRange(r.min,r.max);return o.isLog()?new _.PriceRange(o.priceToLogical(l.minValue()),o.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(){this._updateBarFunction(),this.isNeedRestart()&&(this.data().clear(),this._saveLeftEdgeIfRequired(!1)||this.model().timeScale().scrollToRealtime(!1),this.restart());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,Ct.getResolutionByChartStyle)(e,i,this._model.defaultResolutions()),o=Z.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 p.Property}getInputsInfoProperties(){const e=this._studyBindings?.getInputsInfoProperties();if(e)return e;const t=this._properties.child(`${this.getStyleShortName()}Style`);return t?.childs().inputInfo??new p.Property}getSourceIcon(){return{type:"loadSvg",svgId:`series.${this.style()}`}}onSourceIconChanged(){return this._onStyleChanged}purgeSymbolInfo(){this._symbolInfo.setValue(null)}idForAlert(){return super.idForAlert()}hasStateForAlert(){return!1}stateForAlert(){throw new Error("Not implemented")}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,$t.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=y.STYLE_SHORT_NAMES[e];return(0,s.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}statusView(){return si?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,Pt.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()===Qt.ColorType.Solid?t.color.value():this._lineColorAtYPercentFromTop.gradientColor((0,s.ensureDefined)(t.gradientStartColor).value(),(0,s.ensureDefined)(t.gradientEndColor).value(),e):null}updateAllViews(e){if("hover-change"===e.type)return;this._paneView?.update(e),this._dataWindowView.update(),this._legendView.update(),this._statusView.update(),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);const t=this._model.activeStrategySource().value();t?.updateAllViews(e),this._model.replayStudyStrategy().value()?.updateAllViews(e),this._lineStyleLastPriceCirclePaneView.update(e),this._studyBindings?.updateAllViews(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,Xe.symbolParams)(this)}compareSymbolParams(e){return(0,Xe.compareSymbolParams)(this,e,this._model.unitConversionEnabled())}setSymbolParams(e){const{symbol:t,currency:i,unit:o,style:n,interval:r}=e,{symbolChanged:a,intervalChanged:l,currencyChanged:c,unitChanged:h,styleChanged:d}=this.compareSymbolParams(e),u=[ui("symbol",t,a),ui("interval",r,l),ui("currency",i,c),ui("unit",o,h),ui("style",n,d)].filter((e=>null!==e)).join("; ");ci.logInfo(`Applying series symbol params: ${u}`);const _=this.properties().childs();void 0!==t&&_.symbol.setValue(t),void 0!==i&&_.currencyId.setValue(i),void 0!==o&&_.unitId.setValue(o),l&&_.interval.setValue((0,s.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,m.isConvertedToOtherCurrency)(this.symbolInfo())}unit(){return this.properties().childs().unitId.value()||null}setUnit(e){this.setSymbolParams({unit:e})}measureUnitId(){return(0,m.measureUnitId)(this.symbolInfo())}isConvertedToOtherUnit(){return(0,m.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}valueAt(e,t){return this.data().search(e)?.value[t]??null}symbolSource(){return this}barsProvider(){return this}title(e){return this.symbolTitle(e)}name(){return this.symbolTitle(Kt.TitleDisplayTarget.StatusLine)}symbolTitle(e,t,i,s="exchange"){let o=this.properties().childs().symbol.value();const n=this.symbolInfo();if(null!==n){const{type:e}=n;o=(0,m.symbolTitle)(n,t,"forex"===e?"exchange":s)}return i?o:`${o}, ${(0,P.translatedIntervalString)(this.properties().childs().interval.value())}`}setObsoleteZOrder(e){this._obsoleteZOrder=e}obsoleteZOrder(){return this._obsoleteZOrder}legendValuesProvider(){return this._legendValuesProvider}dataWindowValuesProvider(){return this._dataWindowValuesProvider}statusProvider(e){return new D(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,o.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,m.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:_i(e),nsBars:_i(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&&Z.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 h.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,40481));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){this._seriesSource.moveData(e),null!==this._volumePointWeights&&this._volumePointWeights.moveData(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}_updateBarFunction(){this._barFunction=(0,Ut.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 p.Property(null)),e.hasChild("unitId")||e.addChild("unitId",new p.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,o.trackEvent)("Symbol",e.listed_exchange,e.name),(0,o.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}}_onSymbolError(e){this._setStatus(4),this._properties.childs().shortName.setValue(this._properties.childs().symbol.value()),this._model.clearAllStudies(),this.updateAllViews((0,me.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,m.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)}ai&&ci.logNormal("Error reason: "+t),this._seriesErrorMessage=decodeURIComponent(t.split(":",2)[0]);const s="unknown_symbol"!==t?12:ri&&this.symbolInfo()?10:4;this._setStatus(s),this._seriesLoaded=!0,this._enablePriceRangeReady()}_onSeriesLoading(e){this._setStatus(2)}_onDataUpdated(e,t,i,o){this.symbolInfo();if(null!==this._volumePointWeights){const e=t?this.bars().fullRangeIterator():i?this.bars().rangeIterator(i.index,(0,s.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,me.sourceChangeEvent)(this.id())),this._lastBarCloseTime=e&&e.closeTime||null,this._boxSizeValue.setValue(this.data().boxSize),this._statusView.update(),this.clearAveragePriceCache(),this.clearHighLowPriceCache();const n=this.model(),r=(0,s.ensureNotNull)(n.paneForSource(this));n.recalculatePane(r,(0,me.sourceChangeEvent)({sourceId:this.id(),realtime:!t,firstUpdatedTimePointIndex:i?.index??void 0})),n.updateSource(this)}_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(c.RecalcVisibleRangeStudiesReason.DataUpdate)}_onUnsupportedResolutionRequested(){const e=(0,s.ensureNotNull)(this._getStateForUnsupportedResolution());this._seriesErrorMessage=e.reason,this._unsupportedResolutionState.setValue(e),this._setStatus(14),this._seriesLoaded=!0,this._seriesSource.clearData(),this._model.timeScale().points().clear(),this._enablePriceRangeReady()}_getStateForUnsupportedResolution(){const e=this.symbolInfo();if(null===e)return null;const t=this.interval(),i=(0,
I.getResolutionUnsupportedReason)(e,t);if(null===i)return null;const o=e.name;if("less_than_frequency"!==i){let s=["D","W","M"];return s=e.supported_resolutions,{ticker:o,reason:i,unsupportedResolution:t,applicableResolution:s[0],supportedResolutions:s}}{const n=(0,s.ensureDefined)(e.data_frequency);let r=(0,Ct.getApplicableIntervalForFrequency)(n,t);this._model.defaultResolutions();return{ticker:o,reason:i,applicableResolution:r,unsupportedResolution:t,supportedResolutions:[]}}}_recreateFormatter(){let e=null;e=qt.customFormatters?.priceFormatterFactory?.(this.symbolInfo(),this.properties().childs().minTick.value())??null,null!==e?(this._formatter=e,this._ignoreMinMoveFormatter=e):(this._defaultFormatter=(0,m.createSeriesFormatter)(this.symbolInfo()??this._formattingDeps,"default"),this._formatter=(0,m.createSeriesFormatter)(this.symbolInfo()??this._formattingDeps,this.properties().childs().minTick.value()),this._ignoreMinMoveFormatter=(0,m.createSeriesFormatter)(this.symbolInfo(),this.properties().childs().minTick.value(),!0)),this._priceScale?.updateFormatter(),this._formatterChanged.fire()}_recreatePriceStep(){const{minMove:e,priceScale:t}=(0,m.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,m.symbolHasPreOrPostMarket)(e)&&(this.isDWM()||!!e&&(0,m.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(y.SYMBOL_STRING_DATA.hasOwnProperty(i)&&!y.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()&&hi&&(t.session=i.sessionId.value()),t}_checkChartStyle(){const e=this.style();(0,m.isCloseBasedSymbol)(this.symbolInfo())||this.intervalObj().is1Tick()?(0,m.isSingleValueBasedStyle)(e)||(this.requestingStyleIsNotSupported.fire(),this._styleToRecover={correctedStyle:this.style(),originalStyle:e}):"hlc"===this.symbolInfo()?.visible_plots_set?(0,m.isHLCBasedStyle)(e)||(0,
m.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._properties.childs();t.shortName.setValue(e.name);const i=(0,m.extractSymbolNameFromSymbolInfo)(e,this.symbol());i&&t.symbol.setValue(i);const s=(0,m.symbolCurrency)(e),o=(0,m.symbolUnit)(e,this._model.unitConversionEnabled());"alwaysOff"===(0,Y.currencyUnitVisibilityProperty)().value()||s===t.currencyId.value()&&o===t.unitId.value()||this._model.fullUpdate(),t.currencyId.setValue(s),t.unitId.setValue(o),this._updateSessionIdProxyProperty(!0)}this._base=e?e.pricescale/e.minmov:100,this._pointValue=e&&e.pointvalue||1;const t=(0,Je.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getExtendedSymbolObject());this._quotesProvider.setQuotesSessionSymbol(t),this._marketStatusModel.setSymbolInfo(e),e&&this._recreatePriceFormattingDependencies(),this._statusView.update(),this.priceScale().updateFormatter(),this._symbolResolvingActive.setValue(!e),hi&&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=Re(e,t,{label:Be,labelVisible:o.highLowPriceLabelsVisible,lineVisible:o.highLowPriceLinesVisible,lineColor:o.highLowPriceLinesColor,lineWidth:o.highLowPriceLinesWidth},(()=>s(0))),r=Re(e,t,{label:Ve,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=Ge(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,h.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,s.ensureNotNull)(this._model.paneForSource(this));t.recalculatePriceScale(this.priceScale(),(0,me.sourceChangeEvent)(this.id()));const i=lt.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(c.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,s.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,a.createDeferredPromise)(),!0}}}return!1}async _processReplayOnApplySymbolParamsChanges(e,t){}async _applySymbolParamsChanges(e){this._lastCompleteFlags=null,this.clearGotoDateResult();const t=this.interval();this.currency(),this.unit();Z.Interval.isRange(t)&&this._properties.childs().rangeStyle.childs().inputs.childs().range.setValue(Z.Interval.parse(t).multiplier())
;const{symbolChanged:i,intervalChanged:s,currencyChanged:o,unitChanged:n,force:r}=e,a=hi&&s&&Z.Interval.parse(t).isDWM()!=Z.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),hi&&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 h=this._shouldDefineNumberOfBarsForModifySeries(e)&&this._visibleBarsCount()||null;this.model().recalcVisibleRangeStudies(c.RecalcVisibleRangeStudiesReason.SeriesRestart),this._saveLeftEdgeIfRequired(!!i,l),this._data=null,this._seriesSource.modifySeries(this._getResolvingSymbolObject(),(0,Pt.getServerInterval)(t),l,r,h),this._seriesSource.isStarted()||(this._predictBars=0,this._seriesSource.start()),(i||o||n)&&this.disablePriceRangeReady(),this.updateAllViews((0,me.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(this._properties.childs().sessionId,"sessionId",!0),this._updateLastPriceAnimationActive())}_subscribeRestartToSessionIdChange(){this.properties().childs().sessionId.subscribe(this,this._onSessionIdPropertyChangedBound)}_unsubscribeRestartToSessionIdChange(){this.properties().childs().sessionId.unsubscribe(this,this._onSessionIdPropertyChangedBound)}_updateLastPriceAnimationActive(){if(!this._options.lastPriceAnimationEnabled||b.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,m.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(lt.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,me.sourceChangeEvent)(i)),this.model().updateSource(this),(0,n.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,s.ensureNotNull)(e.firstIndex()),o=(0,s.ensureNotNull)(e.lastIndex())+1;e.range(i,o).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 b.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)}_updateTpoSummary(){if(this._model.isInRestoreState())return;const e=this._model.dataSourceForId(tpoSummaryDataSourceId);if(18!==this.style()||!isFeatureEnabled("tpo_summary"))return void(e&&this._model.removeSource(e));const t=this._properties.childs().tpoStyle.childs().summary.childs().visible.value();if(t&&!e){const e=(0,s.ensureNotNull)(this._model.paneForSource(this)),t=this._model.panes().indexOf(e);this._model.createPane(t+1,void 0,void 0,wt.PaneMode.Widget).insertDataSource(new TpoSummaryDataSource(this._model),null,0)}else!t&&e&&this._model.removeSource(e)}}},84626:(e,t,i)=>{"use strict";i.d(t,{SeriesAreaPaneView:()=>l});var s=i(19063),o=i(2271),n=i(95201),r=i(11064),a=i(36897);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}}},59432:(e,t,i)=>{"use strict";i.d(t,{PaneRendererBars:()=>n});var s=i(61993),o=i(3774);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)))}}},99800:(e,t,i)=>{"use strict";i.d(t,{SeriesBarsPaneView:()=>a});var s=i(95201),o=i(11064),n=i(24997),r=i(59432);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}}},93250:(e,t,i)=>{"use strict";i.d(t,{SeriesBaselinePaneView:()=>g});var s,o=i(19063),n=i(95201),r=i(86441),a=i(5531),l=i(4652),c=i(61993),h=i(29981),d=i(75919),u=i(56468);!function(e){e[e.Top=0]="Top",e[e.Bottom=1]="Bottom"}(s||(s={}));class _ 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:_,bottomLineWidth:p}=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 m=e.context,{topItems:g,bottomItems:f}=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);m.lineCap="round",m.lineJoin="round",0!==g.length&&(m.beginPath(),m.moveTo(g[0].center,i),this._makeLine(m,g,!0,0),m.closePath(),m.fillStyle=this._makeLinearGradient(m,l,h,i-s,i),m.fill(),m.beginPath(),this._makeLine(m,g,!1,0),m.lineWidth=_,m.strokeStyle=d,m.stroke()),0!==f.length&&(m.beginPath(),m.moveTo(f[0].center,i),this._makeLine(m,f,!0,1),m.closePath(),m.fillStyle=this._makeLinearGradient(m,o,n,i,i+s),m.fill(),m.beginPath(),this._makeLine(m,f,!1,1),m.lineWidth=p,m.strokeStyle=u,m.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 p=i(11064),m=i(36897);class g extends m.SeriesSingleLinePaneView{constructor(){super(...arguments),this._renderer=new _,this._topFillColor1="",this._topFillColor2="",this._bottomFillColor1="",this._bottomFillColor2="",this._topLineColor="",this._bottomLineColor="",this._topLineWidth=0,this._bottomLineWidth=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,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 p.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._barSpacing=this._model.timeScale().barSpacing(),this._bottom=e.height(),this._baseLevelCoordinate=Math.round(this._bottom*(Math.abs(100-t.baseLevelPercentage.value())/100))}}},12374:(e,t,i)=>{"use strict";i.d(t,{SeriesWaterlinePaneView:()=>a});var s=i(52397),o=i(72791),n=i(56468),r=i(51056);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()}}},3774:(e,t,i)=>{"use strict";i.d(t,{PaneRendererSeriesBase:()=>n});var s=i(56468),o=i(30125);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}}},25201:(e,t,i)=>{"use strict"
;i.d(t,{PaneRendererCandles:()=>h});var s,o=i(50151),n=i(56468),r=i(37743),a=i(61993),l=i(3774);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)}}}))}}},72476:(e,t,i)=>{"use strict";i.d(t,{SeriesCandlesPaneView:()=>l});var s=i(95201),o=i(61993),n=i(11064),r=i(24997),a=i(25201);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}}},53766:(e,t,i)=>{"use strict";i.d(t,{SeriesColumnsPaneView:()=>p});var s=i(50151),o=i(86441),n=i(56570),r=i(69708),a=i(56468),l=i(95201),c=i(8025),h=i(66540),d=i(11064),u=i(81368),_=i(49256);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()}}},83379:(e,t,i)=>{"use strict";i.d(t,{SeriesHiLoPaneView:()=>f});var s=i(59332),o=i(68979),n=i(29981),r=i(61993),a=i(56468),l=i(75919);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(95201),u=i(11064),_=i(15938),p=i(7114),m=i(25201),g=i(24997);!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}}},70527:(e,t,i)=>{"use strict";i.d(t,{
SeriesHLCAreaPaneView:()=>g});var s=i(86441),o=i(50151),n=i(56570),r=i(67716),a=i(66540),l=i(11064),c=i(8025),h=i(61993),d=i(95201),u=i(56468),_=i(74010),p=i(59152);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 P=this._filledAreas.get(b)??new r.AreaBackgroundItemsGroup({type:0,color:b}),T=P.newItem()??new r.AreaBackgroundItem;P.push(T),this._filledAreas.set(b,P);const x=[],I=[],M=[],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),T.addPoints1Point(n,t),T.addPoints2Point(n,s),x.push({y:i,...o}),I.push({y:t,...o}),M.push({y:s,...o}))}const L=e.barSpacing();if(this._renderer.append(new r.AreaBackgroundRenderer({barSpacing:L,colorAreas:this._filledAreas})),this._renderer.append(new _.PaneRendererLine({barSpacing:L,items:M,simpleMode:!0,withMarkers:!1,lineColor:v.lowLineColor.value(),lineStyle:v.lowLineStyle.value(),lineWidth:v.lowLineWidth.value(),skipHoles:!0})),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:I,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()}}},18032:(e,t,i)=>{"use strict";i.d(t,{SeriesHLCBarsPaneView:()=>l});var s=i(95201),o=i(11064),n=i(59432),r=i(99800);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}}}},15599:(e,t,i)=>{"use strict";i.d(t,{SeriesHollowCandlesPaneView:()=>l});var s=i(95201),o=i(61993),n=i(11064),r=i(25201),a=i(72476);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}}},80941:(e,t,i)=>{"use strict";i.d(t,{SeriesLinePaneView:()=>h});var s=i(56468),o=i(95201),n=i(74010),r=i(3385),a=i(11064),l=i(36897),c=i(46088);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}}},24997:(e,t,i)=>{"use strict";i.d(t,{SeriesBarCandlesPaneView:()=>h,baseBarCandlesUpdater:()=>c});var s=i(86441),o=i(56570),n=i(66540),r=i(8025),a=i(56468);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()}}},9624:(e,t,i)=>{"use strict";i.d(t,{mainSeriesProperties:()=>n});var s=i(51056),o=(i(85904),i(64671),i(20596));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:{highLineStyle:s.LINESTYLE_SOLID,highLineWidth:2,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,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}}},36897:(e,t,i)=>{"use strict";i.d(t,{SeriesSingleLinePaneView:()=>d});var s=i(69708),o=i(86441),n=i(50151),r=i(56570),a=i(66540),l=i(8025),c=i(56468),h=i(29981);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=[]}}},20596:(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(46088);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={highLineColor:"",highLineStyle:0,highLineWidth: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,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"}},62825:(e,t,i)=>{"use strict";i.d(t,{getErrorFromUnsupportedResolutionState:()=>c,getResolutionUnsupportedReason:()=>h});var s=i(11542),o=i(85049),n=i(10074);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}},76748:(e,t,i)=>{"use strict";i.d(t,{SeriesValuesProvider:()=>I,calculateColor:()=>T,changesData:()=>x});var s=i(50151),o=i(50335),n=i(24377),r=i(11542),a=i(49483),l=i(19063),c=i(63273),h=i(8025),d=i(928),u=i(74079),_=i(90799);function p(e,t){return 100*(t-e)/Math.abs(e||1)}var m=i(41991),g=i(15764),f=i(82587),y=i(23486);const v=y.lastDayChangeAvailable||y.alwaysShowLastPriceAndLastDayChange,S=a.CheckMobile.any(),b=(0,u.getPercentageFormatter)(),w=(0,u.getVolumeFormatter)(2),C=`${f.notAvailable} (${f.notAvailable}%)`;var P;function T(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 x(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,h.PlotRowSearchMode.NearestLeft,1),c=l?.value[4]??null;return null!==c&&null!=a&&(n={change:a-c,currentPrice:a,prevPrice:c,percentChange:p(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"}(P||(P={}));class I{constructor(e,t){this._series=e,this._model=t,this._emptyValues=[{title:r.t(null,void 0,i(16610)),visible:!1,value:"",index:0,id:""},{title:r.t(null,void 0,i(78254)),visible:!1,value:"",index:1,id:""},{title:r.t(null,void 0,i(65318)),visible:!1,value:"",index:2,id:""},{title:r.t(null,void 0,i(62578)),visible:!1,value:"",index:3,id:""},{title:"",visible:!1,value:"",index:4,id:""},{title:"",visible:!1,value:"",index:5,id:""},{title:r.t(null,void 0,i(37276)),visible:!1,value:"",index:6,id:""},{title:r.t(null,{context:"study"},i(24261)),visible:!1,value:"",index:7,id:""},{title:r.t(null,void 0,i(63815)),visible:!1,value:"",index:8,id:""}]}getItems(){return this._emptyValues}getValues(e){const t=this._showLastPriceAndChangeOnly(),i=this._emptyValues.map(((e,i)=>({...e,value:6===i||8===i?C:f.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._series.nearestIndex(e,h.PlotRowSearchMode.NearestLeft);if(void 0===r)return i;const a=this._series.data().valueAt(r),d=this._model.backgroundTopColor().value();if(null===a)return i;const u=a[1],_=a[2],p=a[3],g=a[4],{barChange:y,lastDayChange:S}=x(this._series.data(),this._series.quotes(),a,r,n.value),P=(0,m.getPriceValueFormatterForSource)(this._series);if((0,m.shouldBeFormattedAsPercent)(this._series)||(0,m.shouldBeFormattedAsIndexedTo100)(this._series))i[6].value="",i[8].value="";else{const e=this._series.formatter(),t={signPositive:!0};if(void 0!==y){const{currentPrice:s,prevPrice:o,change:n,percentChange:r}=y,a=e.formatChange?.(s,o,t)??e.format(n,t);i[6].value=(0,c.forceLTRStr)(`${a} (${b.format(r,t)})`)}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[8].value=(0,c.forceLTRStr)(`${a} (${b.format(r,t)})`)}}let I=null;if(t)i[5].value=null==g?f.notAvailable:P(g),i[5].visible=!0,I=this._getChangeColor(y?.change,r),i[6].visible=void 0!==y,i[8].visible=void 0!==S||v;else{i[0].value=null==u?f.notAvailable:P(u),i[1].value=null==_?f.notAvailable:P(_),i[2].value=null==p?f.notAvailable:P(p),i[3].value=null==g?f.notAvailable:P(g),i[4].value=P(this._series.barFunction()(a));const e=a[5];(0,o.isNumber)(e)?i[7].value=w.format(e):i[7].visible=!1;const t=this._series.intervalObj().is1Tick(),s=21!==this._series.style();i[0].visible=!t&&s,i[1].visible=!t,i[2].visible=!t,i[8].visible=void 0!==S||v,i[6].visible=void 0!==y;const n=this._series.barColorer().barStyle(r,!1);I=T(d,n.barBorderColor??n.barColor)}I=(0,l.resetTransparency)(T(d,I));for(const e of i)e.color||(e.color=I);return i[8].visible&&(i[8].color=(0,l.resetTransparency)(T(d,this._getChangeColor(S?.change,n.index)))),i}_mobileNonTrackingMode(){return S&&(null===this._model.crosshairSource().pane||(0,g.isLineToolName)(d.tool.value())||null!==this._model.lineBeingEdited())}
_showLastPriceAndChangeOnly(){return y.alwaysShowLastPriceAndLastDayChange||this._mobileNonTrackingMode()}_getChangeColor(e,t){const i=this._series.style();if(2===i||15===i||14===i)return this._series.barColorer().barStyle(t,!1).barColor;const s=void 0===e||e>=0?_.SeriesBarColorer.upColor(this._series.properties()):_.SeriesBarColorer.downColor(this._series.properties());return s.barBorderColor??s.barColor}}},6290:(e,t,i)=>{"use strict";i.d(t,{sessionsPreferencesDefault:()=>o});var s=i(19625);const o={sessionHighlight:{backgrounds:{preMarket:{color:"#FF9800",transparency:92,visible:!0},postMarket:{color:s.colorsPalette["color-tv-blue-500"],transparency:92,visible:!0},electronic:{color:s.colorsPalette["color-tv-blue-500"],transparency:92,visible:!0},outOfSession:{color:s.colorsPalette["color-tv-blue-500"],transparency:92,visible:!0}},vertlines:{sessBreaks:{color:"#4985e7",style:2,visible:!1,width:1}}}}},300:(e,t,i)=>{"use strict";i.d(t,{sourcesAffectState:()=>n});var s=i(78956),o=i(85719);function n(e){return!o.lineToolsDoNotAffectChartInvalidation||e.some((e=>!(0,s.isLineTool)(e)))}},27538:(e,t,i)=>{"use strict";i.d(t,{StatusProviderBase:()=>s});class s{size(){return"13px"}bold(){return!1}}},27777:(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]}bold(){return this._bold}size(){return this._size}}},47806:(e,t,i)=>{"use strict";i.d(t,{AbstractFilledAreaPaneView:()=>p});var s=i(50151),o=i(86441),n=i(5531),r=i(29981),a=i(94784),l=i(67716),c=i(62499);function h(e,t){return Array.from({length:e},((e,i)=>({timePointIndex:i+t})))}function d(e,t,i){let s,o;const n=e.length;for(let r=t;r>=0&&r<n;r+=i){const t=e[r];if(void 0===s&&void 0!==t.plot1Value&&(s=r),void 0===o&&void 0!==t.plot2Value&&(o=r),void 0!==s&&void 0!==o)return r}return null}function u(e){return 0===e.type?`${e.color}`:`${e.color1}:${e.color2}:${e.coordinate1}:${e.coordinate2}`}const _={type:0,color:""};class p{constructor(e,t,i){this._isHlineFill=!1,this._bandAKey=null,this._bandBKey=null,this._colorPlotIndex=null,this._areaRenderer=new l.AreaBackgroundRenderer,this._dataInvalidated=null,this._viewportInvalidated=!1,this._plIndex1=null,this._plIndex2=null,this._items=[],this._colorAreas=new l.CachedMap,this._generateColor=(0,a.generateColorCached)(),this._source=e,this._model=t,this._fillGaps=!!i?.fillgaps,this._fillToIntersection=!!i?.fillToIntersection}update(e){if("global-change"===e.type)return this._dataInvalidated=(0,c.mergeDataInvalidation)(this._dataInvalidated,{}),void(this._viewportInvalidated=!0);if("data-source-change"!==e.type)this._viewportInvalidated=!0;else{e.sourceId===this._source.id()&&(this._dataInvalidated=(0,c.mergeDataInvalidation)(this._dataInvalidated,{firstIndex:e.firstUpdatedTimePointIndex,clearData:e.clearData}))}}renderer(){return this._dataInvalidated?this._updateImplFull(this._dataInvalidated)&&(this._dataInvalidated=null,
this._viewportInvalidated=!1):this._viewportInvalidated&&(this._updateImplLight(),this._viewportInvalidated=!1),this._areaRenderer}_minFirstBarIndex(){return-1/0}_priceScale(){return this._source.priceScale()}_firstValue(){return this._source.firstValue()}_plotNames(){return this._source.metaInfo().plots.map((e=>e.id))}_plotIndex1(){return null===this._plIndex1&&(this._plIndex1=this._plotNames().indexOf(this._plotAId())+1),this._plIndex1}_plotIndex2(){return null===this._plIndex2&&(this._plIndex2=this._plotNames().indexOf(this._plotBId())+1),this._plIndex2}_updateImplFull(e){if(this._areaRenderer.setData(null),this._dataInvalidated?.clearData&&(this._items=[]),!this._visible())return!1;if(null===this._priceScale())return!1;if(null===this._firstValue())return!1;const t=this._source.plots().plottableRange(),i=t.size();if(0===i)return!1;const o=this._source.offset(this._plotAId()),n=this._source.offset(this._plotBId()),a=Math.min(o,n),l=Math.max(o,n);let c=e.firstIndex;const d=i+(l-a)+1,u=this._plotIndex1(),_=this._plotIndex2();d!==this._items.length&&(void 0===c||0===this._items.length||c<this._items[0].timePointIndex+a?(c=void 0,this._items=h(d,1e10)):this._items=this._items.concat(h(d-this._items.length,1e10+this._items.length)));const p=this._colorPlotIndex,m=this._transparency(),g=void 0===c?t.fullRangeIterator():t.rangeIterator(c,(0,s.ensureNotNull)(t.lastIndex()));let f=void 0!==c?(0,r.lowerbound)(this._items,c+a,((e,t)=>e.timePointIndex<t))-a:-a;for(const e of g){const t=e.index+o,i=e.index+n,s=this._items[f+o],r=this._items[f+n];if(s.timePointIndex=t,r.timePointIndex=i,this._isHlineFill||(s.plot1Value=e.value[u]??void 0,r.plot2Value=e.value[_]??void 0),null!==p){const t=f+a-1;if(t>=0&&t<this._items.length){const i=this._items[t];let s;s=0===p.type?{type:0,colorIndexOrRgba:e.value[p.colorIndexOrRgba+1]}:{type:1,colorIndexOrRgba1:void 0===p.colorIndexOrRgba1?void 0:e.value[p.colorIndexOrRgba1+1],colorIndexOrRgba2:void 0===p.colorIndexOrRgba2?void 0:e.value[p.colorIndexOrRgba2+1],value1:void 0===p.valueIndex1?void 0:e.value[p.valueIndex1+1],value2:void 0===p.valueIndex2?void 0:e.value[p.valueIndex2+1]};const o=i.color=this._getColorByPlotValue(s)??void 0;void 0!==o&&(1===o.type?(o.color1=o.color1&&this._generateColor(o.color1,m),o.color2=o.color2&&this._generateColor(o.color2,m)):o.color=this._generateColor(o.color,m))}}f+=1}return this._updateImplLight(),!0}_updateImplLight(){if(!this._visible())return;const e=this._priceScale();if(null===e)return;const t=this._firstValue();if(null===t)return;if(0===this._items.length)return;let i;if(this._isHlineFill){const o=this._source.properties().bands[(0,s.ensureNotNull)(this._bandAKey)],n=this._source.properties().bands[(0,s.ensureNotNull)(this._bandBKey)];i={level1:e.priceToCoordinate(o.value.value(),t),level2:e.priceToCoordinate(n.value.value(),t)}}const a=this._model.timeScale(),c=a.visibleBarsStrictRange();if(null===c)return;const h=e.priceToCoordinateFn(t),p=this._transparency(),m=this._minFirstBarIndex(),g=Math.max(m,c.firstBar()),f=(0,
r.lowerbound)(this._items,g,((e,t)=>e.timePointIndex<t));if(f>=this._items.length)return;const y=Math.min(this._items.length-1,(0,r.lowerbound)(this._items,c.lastBar(),((e,t)=>e.timePointIndex<t)));let v,S;this._isHlineFill?(v=m===g?f:Math.max(0,f-1),S=Math.min(this._items.length-1,y+1)):(v=m===g?f:d(this._items,f-1,-1)??f,S=d(this._items,y+1,1)??y);const b=this._colorAreas;b.invalidateCache();let w,C=null,P=null,T=null;const x=(e,t,i)=>{if(this._model.timeScale().barSpacing()<1||!this._fillToIntersection||void 0===w||void 0===w.xCoordinate||void 0===w.plot1Coordinate||void 0===w.plot2Coordinate||null===P||null===C||0===C.points1.length()||void 0===e||void 0===t)return;const s=new o.Point(w.xCoordinate,w.plot1Coordinate),r=new o.Point(w.xCoordinate,w.plot2Coordinate),a=new o.Point(i,e),l=new o.Point(i,t),c=(0,n.intersectLineSegments)(s,a,r,l);if(null!==c){const e=s.add(s.subtract(a).scaled(-c));P.addPoints1Point(C.points1.at(C.points1.length()-1).x,C.points1.at(C.points1.length()-1).y),P.addPoints2Point(C.points2.at(C.points1.length()-1).x,C.points2.at(C.points1.length()-1).y),P.addPoints1Point(e.x,e.y),P.addPoints1Point(e.x,e.y),C.points1.at(C.points1.length()-1).x=e.x,C.points1.at(C.points1.length()-1).y=e.y,C.points2.at(C.points2.length()-1).x=e.x,C.points2.at(C.points2.length()-1).y=e.y}},I=this._commonColor();let M;1===I.type?(I.coordinate1=h(I.value1),I.coordinate2=h(I.value2),I.color1=I.color1&&this._generateColor(I.color1,p),I.color2=I.color2&&this._generateColor(I.color2,p)):I.color=this._generateColor(I.color,p);for(let e=v;e<=S;e+=1){const t=this._items[e],s=t.timePointIndex;let o,n;!this._fillGaps&&void 0!==M&&s-M>1&&(C=null),void 0!==i?(o=i.level1,n=i.level2):(o=t.plot1Coordinate=void 0===t.plot1Value?void 0:h(t.plot1Value),n=t.plot2Coordinate=void 0===t.plot2Value?void 0:h(t.plot2Value));const r=t.xCoordinate=a.indexToCoordinate(t.timePointIndex);if(t.color&&1===t.color.type&&(t.color.coordinate1=h(t.color.value1),t.color.coordinate2=h(t.color.value2)),this._fillGaps?void 0!==o||void 0!==n:void 0!==o&&void 0!==n){const i=null!==this._colorPlotIndex?t.color||_:I;if(x(o,n,r),L=i,!(null===(A=T)||null===L?A===L:0===A.type&&0===L.type?A.color===L.color:1===A.type&&1===L.type&&A.color1===L.color1&&A.color2===L.color2&&A.coordinate1===L.coordinate1&&A.coordinate2===L.coordinate2)||null===C){if(null!==C&&(void 0!==o&&C.addPoints1Point(r,o),void 0!==n&&C.addPoints2Point(r,n)),e===S)continue;T=i;const t=u(i),s=b.get(t)??new l.AreaBackgroundItemsGroup(i);P=C,C=s.newItem()??new l.AreaBackgroundItem,s.push(C),b.set(t,s)}void 0!==o&&C.addPoints1Point(r,o),void 0!==n&&C.addPoints2Point(r,n)}else this._fillGaps||(T=null,C=null,P=null);M=s,w=t}var A,L;b.delete(u(_));const k={barSpacing:this._model.timeScale().barSpacing(),colorAreas:b};this._areaRenderer.setData(k)}}},46463:(e,t,i)=>{"use strict";i.d(t,{AreaBackgroundPaneView:()=>n});var s=i(50151),o=i(47806);class n extends o.AbstractFilledAreaPaneView{constructor(e,t){super(e,t)}_plotAId(){return(0,s.ensureDefined)(this._source.metaInfo().area)[0].name}_plotBId(){
return(0,s.ensureDefined)(this._source.metaInfo().area)[1].name}_commonColor(){return{type:0,color:this._source.properties().areaBackground.backgroundColor.value()}}_transparency(){return this._source.properties().areaBackground.transparency?.value()??0}_visible(){return this._source.properties().areaBackground.fillBackground.value()}_getColorByPlotValue(e){return this._commonColor()}}},17534:(e,t,i)=>{"use strict";i.d(t,{prepareStudyProperties:()=>w,prepareStudyPropertiesForLoadChart:()=>g});var s=i(16738),o=i(30551),n=i(9343),r=i(68159),a=i(37265),l=i(51056),c=i(35039),h=i(79303),d=i(31229),u=i(32679),_=i(94260),p=i(94113);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,a.clone)(l.defaults)??{},d=r.StudyMetaInfo.getStudyPropertyRootName(l),u=r.StudyMetaInfo.getStudyPropertyRootName(e);let _=y();(0,s.default)(_,f(e)),(0,s.default)(_,(0,a.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));r.StudyMetaInfo.versionOf(l)>=1&&(0,s.default)(_,S(h,_));return _}(e,t,i,o,l);return P(t||e,n,d,h)}(e,t,i,o,r.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,a.clone)((0,c.defaults)("study"));return e.intervalsVisibilities=(0,a.clone)(d.intervalsVisibilitiesDefaults),e}function v(e,t,i){let s=(0,a.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,a.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(r.StudyMetaInfo.versionOf(e)<1)throw new Error("This function cannot work with metainfo of the old format version. Required format version >= 1");const l=r.StudyMetaInfo.getStudyPropertyRootName(e),h=(0,a.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=r.StudyMetaInfo.getSourceInputIds(e);return c.forEach(((e,t)=>{const i=l.inputs[e];t<n.length?l.inputs[e]=`${n[t].id()}$0`:(0,a.isString)(i)&&i.includes("$")&&(l.inputs[e]="close")})),P(e,o,l)}(e,t,i,s,r.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 P(e,t,i,s){for(const e of C)delete i[e];const o=["visible","precision","minTick","intervalsVisibilities","inputs.first_visible_bar_time","inputs.last_visible_bar_time","inputs.subscribeRealtime"];for(let t=0;t<e.inputs.length;++t){const i=e.inputs[t];i.isHidden&&(o.push(`inputs.${t}`),o.push(`inputs.${i.id}`))}const n=new u.DefaultProperty({defaultName:t,state:i,excludedDefaultsKeys:o,excludedStateKeys:["version"],theme:s});n.removeProperty("intervalsVisibilities"),n.addChild("intervalsVisibilities",new _.IntervalsVisibilitiesProperty(i&&i.intervalsVisibilities)),"PivotPointsStandard@tv-basicstudies"!==e.id&&"PivotPointsHighLow@tv-basicstudies"!==e.id||!n.hasChild("font")||n.removeProperty("font");const a=r.StudyMetaInfo.versionOf(e);return n.hasChild("version")?n.childs().version?.setValue(a):n.addProperty("version",a),n}},28490:(e,t,i)=>{"use strict";i.d(t,{containsBackgroundTimePointIndexes:()=>r,dematerializeBackground:()=>l,isBackgroundInBarsRange:()=>c,materializeBackground:()=>a});var s=i(50151),o=i(50503),n=i(65039);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()}},14019:(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(58137),n=i(22837),r=i(26246),a=i(98558),l=i(19063);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,56208))).HHistPaneView);case"horizlines":return n((await i.e(507).then(i.bind(i,95258))).HorizLinePaneView);case"vertlines":return n((await i.e(507).then(i.bind(i,51914))).VertLinePaneView);case"polygons":return n((await i.e(507).then(i.bind(i,38332))).PolygonPaneView);case"backgrounds":return n((await i.e(507).then(i.bind(i,55269))).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}},9233:(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(50503),l=i(65039);!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()}},45721:(e,t,i)=>{"use strict";i.d(t,{containsHorizLineTimePointIndexes:()=>r,dematerializeHorizLine:()=>l,isHorizLineInBarsRange:()=>c,materializeHorizLine:()=>a});var s=i(50151),o=i(50503),n=i(65039);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}},26246:(e,t,i)=>{"use strict";i.d(t,{LiveStudyGraphics:()=>_});var s=i(50151),o=i(29981),n=i(52033),r=i(9233),a=i(45721),l=i(28656),c=i(55257),h=i(28490),d=i(58137),u=i(22837);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)}},55257:(e,t,i)=>{"use strict";i.d(t,{containsPolygonTimePointIndexes:()=>n,dematerializePolygon:()=>a,isPolygonInBarsRange:()=>l,materializePolygon:()=>r});var s=i(50503),o=i(65039);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}},65039:(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})},22837:(e,t,i)=>{"use strict";i.d(t,{StaticStudyGraphics:()=>d,emptyStudyGraphics:()=>g,loadStudyGraphics:()=>f,saveStudyGraphics:()=>y});var s=i(50503),o=i(45721),n=i(28656),r=i(9233),a=i(55257),l=i(28490),c=i(58137),h=i(37265);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}},85904:(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={}))},58137:(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)}},28656:(e,t,i)=>{"use strict";i.d(t,{containsVertLineTimePointIndexes:()=>n,dematerializeVertLine:()=>a,isVertLineInBarsRange:()=>l,materializeVertLine:()=>r});var s=i(50503),o=i(65039);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)}},64671:(e,t,i)=>{"use strict";var s;!function(e){e.BuyAndSell="Buy and sell",e.Delta="Delta",e.Total="Total"}(s||(s={}))},7015:(e,t,i)=>{"use strict";i.d(t,{HHistBasedValuesProvider:()=>m});var s=i(50335),o=i(50151),n=i(49483),r=i(8025),a=i(928),l=i(74079),c=i(9233),h=i(15764),d=i(82587);function u(e,t="",i=""){return{id:t,index:e,title:i,value:"",visible:!1}}const _=n.CheckMobile.any(),p=(0,l.getVolumeFormatter)();class m{constructor(e,t,i=!1){this._emptyValues=[],this._study=e,this._model=t,this._emptyTitles=i,void 0!==this._study.metaInfo().graphics.hhists&&this._emptyValues.push(u(0),u(1),u(2))}getItems(){return this._emptyValues}getValues(e){const t=this._emptyValues.map((e=>({...e})));t.forEach((e=>{e.visible=this._study.isVisible(),e.value=d.notAvailable}));const i=this._study.properties().childs().inputs.childs().volume.value();switch(i){case c.HHistVolumeMode.UpDown:this._emptyTitles||(t[0].title="Up",t[1].title="Down",t[2].title="Total");break;case c.HHistVolumeMode.Total:this._emptyTitles||(t[0].title="Total"),t[1].visible=!1,t[2].visible=!1;break;case c.HHistVolumeMode.Delta:this._emptyTitles||(t[0].title="Delta",t[1].title="Max(Up, Down)",t[2].title="Total")}const n=this._study.priceScale(),a=this._model.timeScale();if(null===n||n.isEmpty()||a.isEmpty()||this._hideValues())return t;if(null===e||!isFinite(e)){const i=this._study.data().last();if(null===i)return t;e=i.index}const l=this._model.crosshairSource(),h=l.price;if(!isFinite(l.y)&&null===(e=function(e,t){const i=e.visibleBarsStrictRange()?.lastBar();if(!i)return null;const s=t.data().search(i,r.PlotRowSearchMode.NearestLeft);return s?s.index:null}(this._model.timeScale(),this._model.mainSeries())))return t;const u=function(e,t,i,s){if(0===e.size)return null;if(!i){const e=(0,o.ensureNotNull)(s.data().valueAt(t));i=s.barFunction()(e)}const n=function(e,t){let i=null;return e.forEach(((e,s)=>{null!==s&&s<=t&&(null===i||s>i)&&(i=s)})),i}(e,t);if(null===n)return null;const r=e.get(n);if(!r||0===r.size)return null;return function(e,t){let i=null;return e.forEach((e=>{e.priceLow<=t&&t<e.priceHigh&&(i=e)})),i}(r,i)}(this._study.graphics().hhistsByTimePointIndex(),e,h,this._model.mainSeries());if(null===u)return t.forEach((e=>{e.value="0"})),t;const _=this._study.metaInfo().graphics.hhists;if(void 0===_)return t;if(void 0===_[u.styleId])return t;const m=this._study.properties().childs().graphics.childs().hhists?.childs()[u.styleId]?.childs(),g=e=>(0,s.isNumber)(e)?p.format(e):"";if(i!==c.HHistVolumeMode.Delta){if(u.rate.forEach(((e,i)=>{t[i].value=g(e),t[i].color=(0,o.ensureDefined)(m).colors[i].value()})),i===c.HHistVolumeMode.UpDown){const e=u.rate[0]+u.rate[1];t[2].value=g(e),t[2].color=(0,o.ensureDefined)(m).valuesColor.value()}}else{const e=u.rate[0]>u.rate[1]?0:1,i=(0,
o.ensureDefined)(m).colors[e].value(),s=u.rate[0]+u.rate[1];[2*u.rate[e]-s,u.rate[e],s].forEach(((e,s)=>{t[s].value=g(e),t[s].color=i}))}return t}_hideValues(){return _&&(null===this._model.crosshairSource().pane||(0,h.isLineToolName)(a.tool.value())||null!==this._model.lineBeingEdited())}}},16685:(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={}))},3462:(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}},62499:(e,t,i)=>{"use strict";function s(e,t){if(null===e)return t;const i=e.firstIndex,s=t.firstIndex,o=e.clearData||t.clearData;return{firstIndex:o||void 0===i||void 0===s?void 0:Math.min(i,s),clearData:o}}i.d(t,{mergeDataInvalidation:()=>s})},72530:(e,t,i)=>{"use strict";i.d(t,{migrateMetaInfoAndPropState:()=>p});var s=i(50151),o=i(68159),n=i(37265);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()}))},25149:(e,t,i)=>{"use strict";i.d(t,{NonSeriesStudy:()=>r,isNonSeriesStudy:()=>n});var s=i(50151),o=i(46806);function n(e){return e instanceof r}class r extends o.Study{clearData(){this._customData=null,this._indexes=null}restoreData(e,t,i){super.restoreData(e),this._customData=t,this._indexes=i}state(e){const t=super.state(e);return e&&(t.nonSeriesData=this._customData,t.indexes=this._indexes),t}customData(){return this._customData}_setPaneViews(e){this._paneViews=e,this.model().lightUpdate()}_onDataUpdated(e,t,i){null!==t&&(t.indexes_replace?((0,s.assert)("nochange"!==i),this._indexes=i):(this._customData=t.data,"nochange"!==i&&(this._indexes=i))),super._onDataUpdated(e,t,i)}}},13380:(e,t,i)=>{"use strict";var s;function o(e){e.lineWidth=void 0,e.lineStyle=void 0
;for(let t=0;t<e.colors.length;t++)e.colors[t]=void 0;return e}function n(){return{colors:[void 0,void 0,void 0,void 0,void 0,void 0,void 0],lineWidth:void 0,lineStyle:void 0}}i.d(t,{clearStyle:()=>o,createEmptyStyle:()=>n}),function(e){e[e.Main=0]="Main",e[e.Background=1]="Background",e[e.Text=2]="Text",e[e.Border=3]="Border",e[e.Wick=4]="Wick",e[e.Up=5]="Up",e[e.Down=6]="Down"}(s||(s={}))},81368:(e,t,i)=>{"use strict";i.d(t,{PaneRendererColumns:()=>n});var s=i(30125),o=i(56468);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)}}}},78198:(e,t,i)=>{"use strict";i.d(t,{StudyPlotPaneView:()=>V})
;var s=i(50151),o=i(24377),n=i(56570),r=i(9859),a=i(37265),l=i(19063),c=i(18832);function h(e,t){const i=new Map;return function(...s){const o=""+(t?t.apply(null,s):s[0]);if(!i.has(o)){const t=e.apply(this,s);return i.set(o,t),t}return i.get(o)}}var d=i(2271),u=i(95201),_=i(74010),p=i(3385),m=i(11064),g=i(13380),f=i(86441),y=i(61993),v=i(56468),S=i(30125),b=i(49483);class w extends S.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){const t=this._data,i=t.lineWidth,s=t.vertOffset||0,o=(0,y.interactionTolerance)().series+i,n=t.visibleItemsRange?.startItemIndex??0,r=t.visibleItemsRange?.endItemIndex??t.items.length;for(let a=n;a<r;a++){const n=t.items[a];if(new f.Point(n.center,n.y+s).subtract(e).length()+i<=o)return new v.HitTestResult(v.HitTarget.Regular)}return null}_drawImpl(e){const t=this._data,{horizontalPixelRatio:i,verticalPixelRatio:s,context:o}=e,n=Math.max(1,Math.floor(i))%2?.5:0,r=t.vertOffset||0,l=t.lineColor,c=t.lineWidth;let h="",d=!1;const u=t.visibleItemsRange?.startItemIndex??0,_=t.visibleItemsRange?.endItemIndex??t.items.length;for(let e=u;e<_;e++){const u=t.items[e],_=u.center,p=u.y+r;if((0,a.isNaN)(_)||(0,a.isNaN)(p))continue;let m,g;null!=u.style?(m=u.style.color,g=u.style.width):(m=l,g=c),(m!==h||b.isSafari)&&(h=m,d&&o.fill(),o.beginPath(),o.fillStyle=m);const f=Math.round(_*i)+n,y=Math.round(p*s)+n,v=Math.round(g*i)+n;o.moveTo(f+v,y),o.arc(f,y,v,0,2*Math.PI,!1),d=!0}d&&o.fill()}}var C=i(81368),P=i(4652);class T extends S.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){const t=(0,y.interactionTolerance)().series+this._data.lineWidth/2;let i,s,o,n;for(let r=1;r<this._data.items.length;++r){i=this._data.items[r-1],s=this._data.items[r],o=i.center,n=s.center;if((0,P.distanceToSegment)(new f.Point(o,i.y),new f.Point(n,s.y),new f.Point(e.x,e.y)).distance<=t)return new v.HitTestResult(v.HitTarget.Regular)}return null}_drawImpl(e){const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;let o="",n=!1;const r=this._data.visibleItemsRange?.startItemIndex??0,l=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1;for(let e=r;e<=l;e++){const r=this._data.items[e];if((0,a.isNaN)(r.center)||(0,a.isNaN)(r.y))continue;const l=r.style?.color??this._data.lineColor,c=r.style?.width??this._data.lineWidth,h=Math.max(1,Math.floor(c*i)),d=Math.max(1,Math.floor(c*s));(l!==o||b.isSafari)&&(o=l,n&&t.fill(),t.beginPath(),t.fillStyle=l);let u=3*h;u%2!=h%2&&(u+=1);let _=3*d;_%2!=d%2&&(_+=1);const p=Math.round(Math.round(r.center*i)-u/2),m=Math.round(Math.round(r.y*s)-_/2),g=p+Math.floor(u/2-h/2),f=m+Math.floor(_/2-d/2);t.rect(p,f,u,d),t.rect(g,m,h,_),n=!0}n&&t.fill()}}class x extends S.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){const t=(0,y.interactionTolerance)().series+this._data.lineWidth/2,i=new Map;for(const o of this._data.items){const n=o.center,r=o.y;let a=t;o.style&&(i.has(o.style.width)?a=(0,s.ensureDefined)(i.get(o.style.width)):i.set(this._data.lineWidth,a));if((0,
P.distanceToSegment)(new f.Point(n,r),new f.Point(n,this._data.histogramBase),new f.Point(e.x,e.y)).distance<=a)return new v.HitTestResult(v.HitTarget.Regular)}return null}_drawImpl(e){if(0===this._data.items.length)return;const{context:t,horizontalPixelRatio:i,verticalPixelRatio:s}=e;t.fillStyle=this._data.lineColor;const o=Math.max(1,Math.floor(this._data.lineWidth*i)),n=o/2,r=Math.max(1,Math.floor(i)),a=Math.round(this._data.histogramBase*s)-Math.floor(r/2),l=a+r,c=this._data.visibleItemsRange?.startItemIndex??0,h=(this._data.visibleItemsRange?.endItemIndex??this._data.items.length)-1;for(let e=c;e<=h;e++){const c=this._data.items[e];let h=o,d=n;c.style?(t.fillStyle=c.style.color,h=Math.max(1,Math.floor(c.style.width*i)),d=h/2):t.fillStyle=this._data.lineColor;const u=h%2?.5:0,_=Math.round(c.center*i)+u,p=Math.round(c.y*s);let m,g;p<=a?(m=p,g=l):(m=a,g=p-Math.floor(r/2)+r),t.fillRect(Math.floor(_-d),m,h,g-m)}}}var I=i(94113),M=i(83085),A=i(29981),L=i(35864),k=i(46088);const D=e=>{const t=(0,o.rgbToHsl)((0,o.parseRgb)(e)),i=t[0]+.05;return t[0]=i-Math.floor(i),(0,o.rgbToHexString)((0,o.hslToRgb)(t))},E=h(D),B=new Set([I.LineStudyPlotStyle.Line,I.LineStudyPlotStyle.Area,I.LineStudyPlotStyle.Circles,I.LineStudyPlotStyle.Cross,I.LineStudyPlotStyle.StepLine,I.LineStudyPlotStyle.StepLineWithDiamonds]);class V extends L.StudyPaneViewInplaceUpdatable{constructor(e,t,i,s,o=!1){super(t,i,s),this._histogramBase=null,this._lineColor="",this._lineWidth=1,this._color1="",this._color2="",this._renderer=new u.CompositeRenderer,this._isMarkersEnabled=n.enabled("source_selection_markers"),this._study=e,this._plotIndex=e.metaInfo().plots.findIndex((e=>e.id===s)),this._colorProvider=(0,M.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s),this._extendStepLineToBarsEndings=o,this._isFundamental=!1;const r=this._study.properties().styles[this._plotName].plottype.value();this._isStepLinePlot=r===I.LineStudyPlotStyle.StepLine||r===I.LineStudyPlotStyle.StepLineWithBreaks||r===I.LineStudyPlotStyle.StepLineWithDiamonds}items(){return this._items}renderer(){return this._makeSureRendererIsValid(),this._renderer}_getTranspValue(){const e=this._study.properties(),t=e.styles[this._plotName];let i=0;const s=this._study.metaInfo();return"Volume@tv-basicstudies"===s.id&&s.version<=46&&"transparency"in e?(i=e.transparency.value(),i=(0,a.isNumber)(i)?i:0,i):(t.transparency&&(i=t.transparency.value(),i=(0,a.isNumber)(i)?i:0),i)}_updateImplFull(e){if(this._renderer.clear(),this._dataInvalidated?.clearData&&(this._items=[]),!this._study.isPlotVisibleAt(this._plotName,1))return!1;const t=this._priceScale();if(!t||t.isEmpty())return!1;if(null===this._study.firstValue(void 0,this.isForceOverlay()))return!1;this._histogramBase=null;const i=this._study.properties().styles[this._plotName],o=i.plottype.value(),n=this._isFundamental&&this._isStepLinePlot,a=this._study.plots().plottableRange(n);if(0===a.size())return!1;const c=this._study.offset(this._plotName),h=B.has(o),d=this._preallocateItems(a,((e,t)=>({y:NaN,left:NaN,center:NaN,right:NaN,
origPrices:{price:t??NaN,timePointIndex:e+c},timePointIndex:e+c})));let u=NaN,_=NaN;const p=new Map,m=(e,t)=>{let i=p.get(e);void 0===i&&(i=new Map,p.set(e,i));let s=i.get(t);if(void 0===s){const o=!this._plotName||"vol"!==this._plotName;s=(0,l.generateColor)(e,t,o),i.set(t,s)}return s},f=(0,g.createEmptyStyle)(),y=(0,r.clamp)(this._getTranspValue(),0,100),v=this._model.timeScale().visibleBarsStrictRange();if(null===v)return!1;const{startBar:S,endBar:b}=this._calculateStartEnd(v);if(null===S||null===b||0===this._items.length)return!1;const w=d??(0,s.ensureNotNull)(a.firstIndex()),C=(0,s.ensureNotNull)(a.lastIndex())+1,P=a.rangeIterator(w,C);let T,x=(0,A.lowerbound)(this._items,w+c,((e,t)=>e.timePointIndex<t));for(const e of P){let t=e.index;const s=e.value;t+=c,t=Math.floor(t);let o=s[this._plotIndex+1];const n=null==o;if(o=n?NaN:o,h&&n){_=o,u=t,x++;continue}const r=this._items[x];r.valIsNotSameAsPrev=o!==_||t-1!==u;if(this._colorProvider.isColorDefined()&&(r.style={color:m(i.color.value(),100),width:i.linewidth.value(),style:i.linestyle.value()},null!=o)){const e=this._colorProvider.getPlotPointStyle(s,f),t=e.colors[0];void 0!==t&&(r.style.color=(0,l.isHexColor)(t)?m(t,y):t),r.style.width=e.lineWidth??r.style.width,r.style.style=e.lineStyle??r.style.style}!h&&!isNaN(u)&&u!==t-1&&x>0&&(this._items[x].breakBefore=!0),_=o,u=t,x++,T=r}return this._updateImplLight(),!0}_correctVisibleItemIndexes(e,t){return super._correctVisibleItemIndexes(e,t)}_updateRenderer(e,t){this._renderer.clear();const i=this._study.properties().styles.childs()[this._plotName].childs(),o=this._study.metaInfo().styles?.[this._plotName],n=(0,r.clamp)(this._getTranspValue(),0,100);this._lineColor=(0,l.generateColor)(i.color.value(),n),this._lineWidth=i.linewidth.value();let h=i.color.value();const u=this._colorProvider.getDefaultPlotPointStyle();u&&(h=u.colors[0]||h,this._lineWidth=u.lineWidth??this._lineWidth,this._lineColor=h?(0,l.generateColor)(h,n):this._lineColor),this._color2=(0,l.generateColor)(h,n);const g=this._study.metaInfo().isRGB?D(h):E(h);this._color1=(0,l.generateColor)(g,n);const f=this._histogramBase?this._histogramBase:(0,s.ensureNotNull)(this._priceScale()).height(),y=i.plottype.value(),v={barSpacing:this._model.timeScale().barSpacing(),items:this._items,histogramBase:f,lineIndex:0,lineStyle:i.linestyle.value(),lineColor:this._lineColor,lineWidth:(0,a.isNumber)(this._lineWidth)?this._lineWidth:1,color1:this._color1,color2:this._color2,bottom:f,visibleItemsRange:{startItemIndex:e,endItemIndex:t},simpleMode:this._colorProvider.singleColor(),skipHoles:[I.LineStudyPlotStyle.Line,I.LineStudyPlotStyle.Area,I.LineStudyPlotStyle.Cross,I.LineStudyPlotStyle.Circles,I.LineStudyPlotStyle.StepLine,I.LineStudyPlotStyle.StepLineWithDiamonds].includes(y)},S=this._renderer,b=Boolean(o?.joinPoints);switch(y){case I.LineStudyPlotStyle.Line:case I.LineStudyPlotStyle.LineWithBreaks:S.append(new _.PaneRendererLine({...v,lineColor:{type:k.ColorType.Solid,color:this._lineColor}}));break;case I.LineStudyPlotStyle.Area:
case I.LineStudyPlotStyle.AreaWithBreaks:S.append(new d.PaneRendererArea({...v,lineColor:{type:k.ColorType.Solid,color:this._lineColor}}));break;case I.LineStudyPlotStyle.Histogram:S.append(new x(v));break;case I.LineStudyPlotStyle.Columns:S.append(new C.PaneRendererColumns(v));break;case I.LineStudyPlotStyle.Cross:S.append(new T(v)),b&&S.append(new _.PaneRendererLine({...(0,c.deepCopy)(v),lineWidth:1,lineColor:{type:k.ColorType.Solid,color:this._lineColor},forceLineWidth:!0}));break;case I.LineStudyPlotStyle.Circles:S.append(new w(v)),b&&S.append(new _.PaneRendererLine({...(0,c.deepCopy)(v),lineWidth:1,lineColor:{type:k.ColorType.Solid,color:this._lineColor},ignorePaletteLineWidth:!0}));break;case I.LineStudyPlotStyle.StepLine:case I.LineStudyPlotStyle.StepLineWithBreaks:case I.LineStudyPlotStyle.StepLineWithDiamonds:{const e=new p.PaneRendererStepLine;e.setData({...v,lineColor:{type:k.ColorType.Solid,color:this._lineColor},decoration:i.plottype.value()===I.LineStudyPlotStyle.StepLineWithDiamonds?p.StepLineDecoration.Diamonds:p.StepLineDecoration.None,extendToBarsEndings:this._extendStepLineToBarsEndings}),S.append(e);break}default:S.append(new _.PaneRendererLine({...v,lineColor:{type:k.ColorType.Solid,color:this._lineColor}}))}this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&this._selectionData&&S.append(new m.SelectionRenderer(this._selectionData))}_updateAdditionalPrices(e,t){const i=this._study.metaInfo().styles?.[this._plotName];void 0!==i?.histogramBase&&(this._histogramBase=e.priceToCoordinate(i.histogramBase,t))}}},64559:(e,t,i)=>{"use strict";i.d(t,{StudyForceOverlayPlotView:()=>s});class s{constructor(e,t,i){this._series=e,this._model=t,this._plotName=i}isForceOverlay(){return!!this._study.metaInfo().isPlotForceOverlay(this._plotName)}_priceScale(){return this.isForceOverlay()?this._model.mainSeries().priceScale():this._study.priceScale()}}},35864:(e,t,i)=>{"use strict";i.d(t,{StudyPaneViewInplaceUpdatable:()=>u});var s=i(50151),o=i(86441),n=i(37265),r=i(62499),a=i(8025),l=i(29981),c=i(66540),h=i(56468),d=i(64559);class u extends d.StudyForceOverlayPlotView{constructor(e,t,i){super(e,t,i),this._selectionData=null,this._dataInvalidated=null,this._viewportInvalidated=!1,this._items=[],this._selectionIndexer=new c.SelectionIndexes(t.timeScale())}update(e){if("hover-change"!==e.type){if("global-change"===e.type)return this._dataInvalidated=(0,r.mergeDataInvalidation)(this._dataInvalidated,{}),void(this._viewportInvalidated=!0);if("data-source-change"!==e.type)this._viewportInvalidated=!0;else{if((e.sourceId===this._study.id()||this._dependsOnSeriesData()&&e.sourceId===this._model.mainSeries().id())&&!e.nonSeriesOnly){const t=(0,r.mergeDataInvalidation)(this._dataInvalidated,{firstIndex:e.firstUpdatedTimePointIndex,clearData:e.clearData});this._dataInvalidated=t}}}}_dependsOnSeriesData(){return!1}_makeSureRendererIsValid(){this._dataInvalidated?this._updateImplFull(this._viewportInvalidated)&&(this._dataInvalidated=null):this._viewportInvalidated&&this._updateImplLight(),
this._viewportInvalidated=!1}_preallocateItems(e,t){const i=e.size();let o=this._dataInvalidated?.firstIndex;if(0===i)return o;const n=this._study.offset(this._plotName);if(i!==this._items.length){const i=void 0!==o?o+n:void 0;if(void 0===i||0===this._items.length||i<(0,s.ensureDefined)(this._items[0].timePointIndex))return this._items=[],e.each(((e,i)=>{const s=i[this._plotIndex+1];return this._items.push(t(e,s)),!1})),this._items.length?(0,s.ensureDefined)(this._items[0].timePointIndex)-n:void 0;{const i=(0,s.ensureDefined)(o),r=n>=0?0:n,a=n>=0?n:0;let c=(0,l.lowerbound)(this._items,i+r,((e,t)=>e.timePointIndex<t));const h=(0,s.ensureNotNull)(e.lastIndex()),d=e.rangeIterator(i-a,h);for(const e of d)if(void 0!==c&&this._items[c]?.timePointIndex===e.index+n)c=this._updateItem(e,c);else{const i=e.value[this._plotIndex+1];this._items.push(t(e.index,i))}}}else if(o=o??e.firstIndex()??void 0,void 0!==o){const t=n>=0?0:n,i=n>=0?n:0;let r=(0,l.lowerbound)(this._items,o+t,((e,t)=>e.timePointIndex<t));const a=(0,s.ensureNotNull)(e.lastIndex())+1,c=e.rangeIterator(o-i,a);for(const e of c)r=this._updateItem(e,r)}return o}_updateItem(e,t){const i=this._getValueForUpdating(e);return this._items[t].origPrices.price=i??NaN,t+1}_getValueForUpdating(e){return e.value[this._plotIndex+1]}_calculateStartEnd(e){const t=this._study.offset(this._plotName);let i=e.firstBar()-Math.abs(t)-1,o=e.lastBar()+Math.abs(t)+1;const n=this._study.getMinFirstBarIndexForPlot(this._plotName)+t;if(n>o+1)return{startBar:null,endBar:null};let r=this._study.plots();r=r.range(n,(0,s.ensureNotNull)(r.lastIndex())),i=Math.max(i,n),o=Math.max(o,n);const l=r.search(i,a.PlotRowSearchMode.NearestLeft,this._plotIndex+1),c=r.search(o,a.PlotRowSearchMode.NearestRight,this._plotIndex+1);return null!==l&&(i=l.index),null!==c&&(o=c.index),i=Math.max(n,i),{startBar:i,endBar:o}}_updateImplLight(){const e=this._study.firstValue(void 0,this.isForceOverlay());if(null===e)return this._selectionData=null,void this._updateRenderer(0,-1);const t=this._priceScale();if(null===t||t.isEmpty())return this._selectionData=null,void this._updateRenderer(0,-1);const i=this._model.timeScale().visibleBarsStrictRange();if(null===i)return this._selectionData=null,void this._updateRenderer(0,-1);const{startBar:s,endBar:o}=this._calculateStartEnd(i);if(null===s||null===o||0===this._items.length)return this._selectionData=null,void this._updateRenderer(0,-1);const{startItemIndex:n,endItemIndex:r}=this._correctVisibleItemIndexes(Math.max(0,(0,l.lowerbound)(this._items,s,((e,t)=>e.timePointIndex<t))),Math.min(this._items.length,(0,l.upperbound)(this._items,o,((e,t)=>e<t.timePointIndex))));if(n>=r)return this._selectionData=null,void this._updateRenderer(0,-1);this._convertItemsToCoordinates(t,e,n,r),this._createSelection(e),this._updateRenderer(n,r)}_correctVisibleItemIndexes(e,t){return{startItemIndex:e,endItemIndex:t}}_convertItemsToCoordinates(e,t,i,s){this._convertItemsToCoordinatesImpl(e,t,i,s)}_convertItemsToCoordinatesImpl(e,t,i,s){for(let e=i;e<s;e++){const t=this._items[e]
;t.y=t.origPrices.price}e.pointsArrayToCoordinates(this._items,t,{startItemIndex:i,endItemIndex:s}),this._model.timeScale().fillBarBorders(this._items,{startItemIndex:i,endItemIndex:s},!0),this._updateAdditionalPrices(e,t)}_updateAdditionalPrices(e,t){}_createSelection(e){const t=this._priceScale();if(null!==t)if(this._model.selection().isSelected(this._study)){const i=(0,s.ensureNotNull)(this._model.paneForSource(this._study)).height();this._selectionData={points:[],bgColors:[],visible:!0,hittestResult:h.HitTarget.Regular,barSpacing:this._model.timeScale().barSpacing()};const o=this._study.offset(this._plotName);for(const s of this._selectionIndexer.indexes()){const r=this._study.plots().valueAt(s);if((0,n.isAbsent)(r))continue;const a=r[this._plotIndex+1];if((0,n.isAbsent)(a))continue;const l=this._createSelectionDataPoint(t,Math.floor(s+o),a,e);this._selectionData.points.push(l),this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(l.point.y/i))}}else this._selectionIndexer.clear()}_createSelectionDataPoint(e,t,i,s){const n=this._model.timeScale().indexToCoordinate(t),r=e.priceToCoordinate(i,s);return{point:(0,o.point)(n,r)}}}},83085:(e,t,i)=>{"use strict";i.d(t,{createStudyPlotColorProvider:()=>_});var s=i(94113),o=i(50151),n=i(13380);const r=new Map([[0,"color"],[2,"textColor"],[3,"borderColor"],[4,"wickColor"],[5,"colorup"],[6,"colordown"]]);class a{constructor(e){this._plotStyle=e}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return r.forEach(((e,t)=>{this._plotStyle[e]&&(i.colors[t]=this._plotStyle[e].value())})),i.lineWidth=this._plotStyle.linewidth?this._plotStyle.linewidth.value():void 0,i.lineStyle=this._plotStyle.linestyle?this._plotStyle.linestyle.value():void 0,i}isColorDefined(){return!0}singleColor(){return!0}getDefaultPlotPointStyle(){return null}}const l=[0,1,2,3,4,5,6];class c{constructor(e,t,i,s){this._palettesColors=new Map,this._defaultPlotColors=new Map,this._indexes=s;const n=t.styles[i];if(n)for(const[e,t]of r)this._defaultPlotColors.set(e,n[t]);const a=(0,o.ensureDefined)(e.palettes),l=e.plots;s.forEach(((e,i)=>{const s=l[e];if(s&&"palette"in s){const e=a[s.palette],o=t.palettes[s.palette];if(e&&o){const{valToIndex:t}=e,{colors:s}=o,n={...s};t&&Object.keys(t).forEach((e=>{const i=t[e];void 0!==i&&(n[e]=s[i])})),this._palettesColors.set(i,n)}}}))}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return l.forEach((t=>{if(this._palettesColors.has(t)){const s=e[(0,o.ensureDefined)(this._indexes.get(t))+1];if("number"==typeof s){const e=this._palettesColors.get(t)?.[s];0===t&&e&&(i.lineWidth=e.width.value(),i.lineStyle=e.style.value()),i.colors[t]=e?.color.value()}else i.colors[t]="transparent"}else i.colors[t]=this._defaultPlotColors.get(t)?.value()})),i}getDefaultPlotPointStyle(){const e=this._palettesColors.get(0)?.[0];if(void 0!==e){return{colors:[e.color.value(),void 0,void 0,void 0,void 0,void 0,void 0],lineStyle:void 0,lineWidth:e.width.value()}}return null}isColorDefined(){
return!!this._palettesColors.size}singleColor(){return!1}}var h=i(31599);class d{constructor(e){this._rgbaFromInteger=(0,h.rgbaFromIntegerCached)(),this._indexes=e}getPlotPointStyle(e,t){const i=t?(0,n.clearStyle)(t):(0,n.createEmptyStyle)();return this._indexes.forEach(((t,s)=>{const o=e[t+1];if(null!=o){const e=this._rgbaFromInteger(o);i.colors[s]=e}else i.colors[s]="transparent"})),i}isColorDefined(){return!0}singleColor(){return!1}getDefaultPlotPointStyle(){return null}}const u=new Map([[0,function(e,t){const i=(0,s.isColorerPlot)(t)||(0,s.isOhlcColorerPlot)(t);return"target"in t&&t.target===e&&i}],[2,function(e,t){const i=(0,s.isTextColorerPlot)(t);return"target"in t&&t.target===e&&i}],[1,function(e,t){return(0,s.isBgColorerPlot)(t)&&t.id===e}],[3,function(e,t){const i=(0,s.isCandleBorderColorerPlot)(t);return"target"in t&&t.target===e&&i}],[4,function(e,t){const i=(0,s.isCandleWickColorerPlot)(t);return"target"in t&&t.target===e&&i}],[5,function(e,t){const i=(0,s.isUpColorerPlot)(t);return"target"in t&&t.target===e&&i}],[6,function(e,t){const i=(0,s.isDownColorerPlot)(t);return"target"in t&&t.target===e&&i}]]);function _(e,t,i){const{colorers:s}=function(e,t){const i=e.plots,s=i.findIndex((e=>e.id===t)),o=new Map;return i.forEach(((e,i)=>{u.forEach(((s,n)=>{s(t,e)&&o.set(n,i)}))})),{plotIndex:-1===s?null:s,colorers:o}}(e,i);if(s.size)return e.isRGB?new d(s):new c(e,t,i,s);{const e=t.ohlcPlots;if(e&&e[i])return new a(e[i]);const s=t.styles[i];return new a(s)}}},94113:(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 P(e){return"bar_colorer"===e.type}function T(e){return"bg_colorer"===e.type}function x(e){return"text_colorer"===e.type}function I(e){return"ohlc_colorer"===e.type}function M(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 D(e){return"alertcondition"===e.type}function E(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)||P(e)||T(e)||p(e)||m(e)||I(e)||D(e)||L(e)||k(e)||A(e)||M(e)||x(e)}function O(e){return C(e)||x(e)||P(e)||p(e)||m(e)||I(e)||M(e)||A(e)||L(e)||k(e)||D(e)}i.r(t),i.d(t,{InternalStudyPlotType:()=>n,LineStudyPlotStyle:()=>s,OhlcStudyPlotStyle:()=>l,PlotSymbolSize:()=>c,STUDYPLOTDISPLAYTARGET:()=>a,StudyPlotDisplayTarget:()=>r,StudyPlotType:()=>o,
isAlertConditionPlot:()=>D,isArrowsPlot:()=>_,isBarColorerPlot:()=>P,isBgColorerPlot:()=>T,isCandleBorderColorerPlot:()=>A,isCandleWickColorerPlot:()=>M,isCharsPlot:()=>u,isColorerPlot:()=>C,isDataOffsetPlot:()=>m,isDataPlot:()=>p,isDownColorerPlot:()=>k,isLinePlot:()=>h,isNonVisualPlot:()=>O,isOhlcClosePlot:()=>v,isOhlcColorerPlot:()=>I,isOhlcHighPlot:()=>f,isOhlcLowPlot:()=>y,isOhlcOpenPlot:()=>g,isOhlcPlot:()=>S,isOhlcPlotStyleBars:()=>V,isOhlcPlotStyleCandles:()=>R,isPaletteColorerPlot:()=>b,isPlotSupportDisplay:()=>E,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={}))},49822:(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}},79036:(e,t,i)=>{"use strict";i.d(t,{createStudy:()=>S,hasConfirmInputs:()=>P,hasPendingStudiesModuleLoading:()=>v,isCompareOrOverlayStudy:()=>f,isFundamentalStudy:()=>m,isOverlayStudy:()=>g,isStudy:()=>u,isStudyStrategy:()=>_,isStudyStub:()=>p,isSymbolicStudy:()=>x,studyColorRotationMode:()=>b,useSameColorRotationComparator:()=>C});var s=i(50151),o=i(56570),n=i(68159),r=i(21239);const a="study_Internal$STD;Fund_";function l(e){const t="study_"+(e.classId||e.shortId);return t.startsWith(a)?a:t}var c=i(49822);i(29137);const h=(0,
c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,46806)).then((e=>e.Study))));(0,c.addStudyInfoToMap)("Study",h),(0,c.addStudyInfoToMap)("study_PivotPointsStandard",(0,c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,93378)).then((e=>e.study_PivotPointsStandard))))),(0,c.addStudyInfoToMap)("study_Overlay",(0,c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,38496)).then((e=>e.study_Overlay))),"sexyColors")),(0,c.addStudyInfoToMap)("study_Compare",(0,c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,85604)).then((e=>e.StudyCompare))),"sexyColors")),(0,c.addStudyInfoToMap)("study_Volume",(0,c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,7021)).then((e=>e.VolumeStudy))))),(0,c.addStudyInfoToMap)("study_VbPVisible",(0,c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,34425)).then((e=>e.VbPVisibleWrapper))),"noRotations")),(0,c.addStudyInfoToMap)("study_VbPFixed",(0,c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,34425)).then((e=>e.VolumeProfileStudyWithThemedColors))),"noRotations")),(0,c.addStudyInfoToMap)("study_ScriptWithDataOffset",(0,c.createStudyInfo)((()=>Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,31257)).then((e=>e.study_ScriptWithDataOffset))))),o.enabled("moving_average_study_changable_currency_unit")&&(0,c.addStudyInfoToMap)("study_Moving Average",(0,c.createStudyInfo)((()=>i.e(5248).then(i.bind(i,55288)).then((e=>e.study_MovingAverage)))));const d=["getStudyName","guiPlotName","isLinkedToSeries"];function u(e){return d.every((t=>t in e))}function _(e){return!1}function p(e){return e instanceof r.StudyStub}function m(e){return!1}function g(e){return u(e)&&"Overlay@tv-basicstudies"===e.metaInfo().id}function f(e){return g(e)||u(e)&&"Compare@tv-basicstudies"===e.metaInfo().id}let y=0;function v(){return y>0}async function S(e,t,i,o,n,r){let a;const d=2===r;if(!a){const e=l(o);a=(0,c.getStudyInfoByName)(e??"Study")??h}a.studyConstructor||(y+=1,a.studyConstructor=await(0,s.ensureDefined)(a.studyConstructorAsyncGetter)(),y-=1);const u=new((0,s.ensureDefined)(a?.studyConstructor))(e,t,i,o,d);return void 0!==n&&u.setId(n),u}function b(e){const t=l(e),i=(0,c.getStudyInfoByName)(t);return i?i.colorRotationMode:void 0===e.pine||n.StudyMetaInfo.isStandardPine(e.id)?1!==e.plots.length?"shift":"loop":null}function w(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 C(e){const t=l(e),i=(0,c.getStudyInfoByName)(t);if(i){const e=i.colorRotationComparator;if(void 0!==e)return e}return w}function P(e){return(e??[]).some((e=>e.confirm))}const T=["Overlay@tv-basicstudies","CorrelationCoefficient@tv-basicstudies","Correlation Coeff@tv-basicstudies","Spread@tv-basicstudies","Ratio@tv-basicstudies"];function x(e){return T.includes(e.id)}},14878:(e,t,i)=>{"use strict";i.d(t,{StudyBaseWindowView:()=>n});var s=i(7576),o=i(19466);class n extends s.DataWindowView{constructor(e,t){super(),
this._invalidated=!0,this._study=e,this._model=t,this._valueProvider=this._createValuesProvider(e,t),this._items=this._valueProvider.getItems().map((e=>new s.DataWindowItem(e.id,e.title,"")))}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}items(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._items}study(){return this._study}_updateImpl(){this._header=this._study.title(o.TitleDisplayTarget.DataWindow,!0),this._title=this._study.title(o.TitleDisplayTarget.DataWindow);const e=this._valueProvider.getValues(this._currentIndex());for(let t=0;t<e.length;++t){const i=e[t],s=this._items[t];s.setValue(i.value),s.setVisible(i.visible),s.setColor(i.color),s.setTitle(i.title)}}_currentIndex(){const e=this._model.crosshairSource().appliedIndex();return isNaN(e)?null:e}}},71838:(e,t,i)=>{"use strict";i.d(t,{StudyDataSource:()=>_});var s=i(50151),o=i(52033),n=i(64755),r=i(18172),a=i(3462),l=i(82349),c=i(26246),h=i(16685);const d=(0,i(9343).getLogger)("Chart.StudyDataSource");var u;!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"}(u||(u={}));class _{constructor(e,t,i,s){this._inputs=null,this._status=u.Idle,this._studyId=null,this._turnaroundCounter=1,this._studyStatus={type:h.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._seriesSource=t,this._turnaroundPrefix=i,this._plots=new n.PlotList((0,l.studyPlotFunctionMap)(s),l.studyEmptyPlotValuePredicate),this._gateway.isConnected().subscribe(this._boundOnGatewayIsConnectedChanged),this._graphics=new c.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:h.StudyStatusType.Undefined}),this._gateway.modifyStudy(this._studyId,this._turnaround(),e,this._onMessage.bind(this)),this._status===u.Active&&this._changeStatusTo(u.AwaitingFirstDataUpdate))}isStarted(){return this._status!==u.Idle}isActive(){return this._status===u.Active}start(){this.isStarted()?d.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(u.AwaitingConnection))}stop(){this.isStarted()?(null!==this._studyId&&(this._gateway.isConnected().value()&&this._gateway.removeStudy(this._studyId),this._studyId=null,this._onStudyStatusChangedTo({type:h.StudyStatusType.Undefined})),
this._changeStatusTo(u.Idle)):d.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===u.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,l.studyPlotFunctionMap)(this._metaInfo),l.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:h.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"),d.logNormal(`Status changed from ${u[this._status]} to ${u[e]}`),this._status=e}_createStudy(){const e=this._seriesSource.instanceId();null!==e?this._createStudyUsingParentId(e):(this._changeStatusTo(u.AwaitingParent),this._seriesSource.dataEvents().created().subscribe(this,this._onSeriesCreated,!0))}_createStudyUsingParentId(e){(0,s.assert)(this._status!==u.Active,'Status should not be "Active" when creating a study'),(0,s.assert)(this._studyStatus.type===h.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,a.makeNextStudyId)(),this._gateway.createStudy(this._studyId,this._turnaround(),e,this._metaInfo.fullId+("tv-basicstudies"===this._metaInfo.packageId?"":"!"),(0,s.ensureNotNull)(this._inputs),this._onMessage.bind(this),{id:this._metaInfo.id}),this._changeStatusTo(u.AwaitingFirstDataUpdate)}_onGatewayIsConnectedChanged(e){e?this._onGatewayConnected():this._onGatewayDisconnected()}_onGatewayConnected(){this._status===u.AwaitingConnection&&this._createStudy()}_onGatewayDisconnected(){this._status!==u.Idle&&this._status!==u.AwaitingConnection&&(this._studyId=null,this._changeStatusTo(u.AwaitingConnection),this._studyStatus.type!==h.StudyStatusType.Undefined&&this._onStudyStatusChangedTo({type:h.StudyStatusType.Undefined})),this._turnaroundCounter=1}_onSeriesCreated(){this._status===u.AwaitingParent&&this._createStudyUsingParentId((0,s.ensure)(this._seriesSource.instanceId()))}_onStudyStatusChangedTo(e){const t=this._studyStatus;this._studyStatus=e,d.logNormal(`Study status type changed from ${h.StudyStatusType[t.type]} to ${h.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!==u.Idle&&(this._status===u.AwaitingFirstDataUpdate&&(this._changeStatusTo(u.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:h.StudyStatusType.Loading,startTime:Date.now()})}_onStudyError(e,t,i){this.clearData(),this._onStudyStatusChangedTo(this._createStudyError(e))}_onStudyCompleted(e){this._onStudyStatusChangedTo({type:h.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}`}}},22839:(e,t,i)=>{"use strict";i.d(t,{StudyDataWindowView:()=>a});var s=i(14878),o=i(22739),n=i(7015);class r{constructor(e,t){this._study=e,this._model=t,this._hhistBasedStudy=void 0!==e.metaInfo().graphics.hhists,this._valuesProvider=this._createValuesProvider(e,t)}getItems(){return this._valuesProvider.getItems()}getValues(e){const t=this._valuesProvider.getValues(e),i=e=>!!this._hhistBasedStudy||this._study.isPlotVisibleAt(e,2);for(const e of t)e.visible=e.visible&&i(e.id);return t}_createValuesProvider(e,t){return this._hhistBasedStudy?new n.HHistBasedValuesProvider(e,t):new o.StudyValuesProvider(e,t)}}class a extends s.StudyBaseWindowView{canShowItems(){const e=this._model.paneForSource(this._study);return!!e?.maximized().value()||this._model.panes().every((e=>!e.maximized().value()))}_createValuesProvider(e,t){return new r(e,t)}}},82349:(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})},65383:(e,t,i)=>{"use strict";i.d(t,{ChartColorDependentStudyInputNames:()=>p,InputDisplayFlags:()=>o,RangeDependentStudyInputNames:()=>_,areStudyInputsEqual:()=>m,editableStudyInputs:()=>f,getInputValue:()=>l,isExtendedInput:()=>r,isExtendedInputSource:()=>a,
isStudyInputDependsOnChartColors:()=>y,isStudyInputOptionsInfo:()=>c,isTimeOrPriceNotHiddenInput:()=>g});var s,o,n=i(82433);function r(e){return(0,n.default)(e)}function a(e){return"source"===e.t}function l(e){return r(e)?e.v:e}!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 c(e){return["text","integer","float","price","session","resolution"].includes(e.type)&&e.hasOwnProperty("options")}var h,d,u,_,p;function m(e,t,i){for(const s of e)if(t[s.id]!==i[s.id])return!1;return!0}function g(e){return("time"===e.type||"price"===e.type)&&!0!==e.isHidden}function f(e){return[]}function y(e){return Object.values(p).map((e=>e)).includes(e.id)}!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"}(h||(h={})),function(e){e.Fixed="fixed",e.CashPerOrder="cash_per_order",e.PercentOfEquity="percent_of_equity"}(d||(d={})),function(e){e.Percent="percent",e.CashPerContract="cash_per_contract",e.CashPerOrder="cash_per_order"}(u||(u={})),function(e){e.FirstBar="first_visible_bar_time",e.LastBar="last_visible_bar_time",e.Realtime="subscribeRealtime"}(_||(_={})),function(e){e.FgColor="__chart_fgcolor",e.BgColor="__chart_bgcolor"}(p||(p={}))},16638:(e,t,i)=>{"use strict";i.d(t,{isStudyDescriptor:()=>u,studyMetaInfoRepository:()=>g});var s=i(81251),o=i(11542),n=i(50151),r=i(68159),a=i(72530),l=i(1640),c=i(79303),h=i(9343),d=i(14426);(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)))},70294:(e,t,i)=>{"use strict";i.d(t,{StudyStatusProviderBase:()=>l});var s=i(27538),o=i(678),n=i(19466);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)}text(){
return this._source.isActualInterval()?this._source.isFailed()?`${this._source.title(n.TitleDisplayTarget.StatusLine,!0,r,void 0,a)}: ${this.sourceStatusText()}`:`${this._source.title(n.TitleDisplayTarget.StatusLine,!0,r,void 0,a)} ${this.sourceStatusText()}`:this._source.title(n.TitleDisplayTarget.StatusLine,!0,r,void 0,a)}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}}},44158:(e,t,i)=>{"use strict";i.d(t,{StudyStatusProvider:()=>n});var s=i(11542),o=(i(678),i(70294));s.t(null,void 0,i(24077));class n extends o.StudyStatusProviderBase{sourceStatusText(){this._source.status();return super.sourceStatusText()}}},49936:(e,t,i)=>{"use strict";i.d(t,{StudyStatusView:()=>o});var s=i(27777);class o extends s.StatusView{constructor(e){super(e.statusProvider())}getSplitTitle(){return this._statusProvider.getSplitTitle()}update(e){this._text=this._statusProvider.text()}}},678:(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(82236);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={}))},21239:(e,t,i)=>{"use strict";i.d(t,{StudyStub:()=>b,isStudyStubDescriptor:()=>w});var s=i(50279),o=i(30551),n=i(50151),r=i(64147),a=(i(88960),i(62288)),l=i(49936),c=i(45579),h=i(725),d=i(52033),u=i(12988),_=i(70294),p=i(19466);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(678),f=i(36915),y=i(16638);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?.get()?.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}isFailed(){return this._status.type===g.StudyStatusType.Error}isLoading(){return this._status.type===g.StudyStatusType.Loading}isDisplayedInLegend(){return this._alwaysShowInLegend||this.isFailed()}setFailed(e){this.setStatus({type:g.StudyStatusType.Error,errorDescription:{error:e}}),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()}barsProvider(){return this._model.mainSeries()}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)}}function w(e){return(0,o.isObject)(e)&&"descriptor"in e&&(0,y.isStudyDescriptor)(e.descriptor)}},22739:(e,t,i)=>{"use strict";i.d(t,{StudyValuesProvider:()=>v});var s=i(50335),o=i(49483),n=i(19063),r=i(56570),a=i(8025),l=i(15764),c=i(928),h=i(94113),d=i(83085),u=i(41991),_=i(50151),p=i(82587),m=i(19466);const g=o.CheckMobile.any(),f=r.enabled("hide_last_na_study_output"),y=r.enabled("always_show_legend_values_on_mobile");class v{constructor(e,t,i){this._emptyValues=[],this._colorProviders=new Map,this._study=e,this._model=t,this._studyMetaInfo=this._study.metaInfo(),this._studyProperties=this._study.properties().childs(),this._isFundamental=!1;const s=this._studyMetaInfo.plots;s&&s.forEach(((e,t)=>{if((0,h.isPlotWithTechnicalValues)(e))return;const s=e.id;this._emptyValues.push(function(e,t="",i=""){return{id:t,index:e,title:i,value:"",visible:!1}}(t,s,i?"":this._study.guiPlotName(m.TitleDisplayTarget.StatusLine,s)));const o=(0,h.isOhlcPlot)(e)?e.target:s;this._colorProviders.set(o,(0,d.createStudyPlotColorProvider)(this._studyMetaInfo,this._study.properties(),o))}))}getItems(){return this._emptyValues}getPlotColor(e,t){const i=t[e+1];if(!(0,s.isNumber)(i))return"";const o=i>0;let n;const r=this._studyMetaInfo.plots[e];let a=r.id;const l=this._studyProperties;if((0,h.isOhlcPlot)(r))a=r.target||a,n=(0,_.ensureDefined)(l.ohlcPlots.childs()[a].childs().color).value();else if((0,h.isArrowsPlot)(r)){const e=(0,_.ensureDefined)(l.styles.childs()[a]);n=o?e.childs().colorup.value():e.childs().colordown.value()}else n=(0,_.ensureDefined)(l.styles.childs()[a]?.child("color")).value();let c=n;const d=this._colorProviders.get(a),u=d&&d.getPlotPointStyle(t);return u&&((0,h.isArrowsPlot)(r)?(o&&void 0!==u.colors[5]&&(c=u.colors[5]),o||void 0===u.colors[6]||(c=u.colors[6])):void 0!==u.colors[0]&&(c=u.colors[0])),"transparent"===c&&(c=n),c}getValues(e){const t=this._emptyValues.map((e=>({...e})));let i=null;const o=this._study.data().lastIndex(),r=this._studyProperties;if(null!==o)for(const e of t){const t=r.styles.childs()[e.id]?.childs().display.value();if(0===t)continue;const s=this._study.nearestIndex(o,a.PlotRowSearchMode.NearestLeft,e.index+1);if(void 0===s)continue;const n=s+this._study.offset(e.id);i=null!==i?Math.max(n,i):n}(null===e||null!==i&&e>i)&&(e=i);const l=this._hideValues(),c=this._study.isVisible()&&!l?p.notAvailable:"";for(const e of t)e.value=c;if(l)return t;f&&t.length&&(t[t.length-1].value="");const d=this._study.priceScale();if(!this._study.isVisible()||null===e||null===d||d.isEmpty()||this._model.timeScale().isEmpty())return t;const m={};for(const i of t){
const t=i.id,l=(0,u.getPriceValueFormatterForStudy)(this._study,t),c=(0,_.ensureDefined)(r.styles.childs()[t]),d=c.childs().display.value();if(i.visible=0!==d,!i.visible)continue;const p=c.hasChild("plottype")?c.child("plottype")?.value():null,g=this._isFundamental&&(p===h.LineStudyPlotStyle.StepLine||p===h.LineStudyPlotStyle.StepLineWithDiamonds),f=i.index,y=e-this._study.offset(t),v=g||null!==o&&y>o?a.PlotRowSearchMode.NearestLeft:a.PlotRowSearchMode.Exact,S=this._study.nearestIndex(y,v);if(void 0===S)continue;let b=m[t];if(void 0===b&&(b=this._study.getMinFirstBarIndexForPlot(t),Number.isFinite(b)&&(m[t]=b)),b>S)continue;const w=this._study.data().last(),C=this._study.data().valueAt(S)||(null!==w?w.value:null);if(null===C)continue;const P=C[f+1];(0,s.isNumber)(P)&&(i.value=l(P),i.color=(0,n.resetTransparency)(this.getPlotColor(f,C)))}return t}_hideValues(){return y?(0,l.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited():g&&(null===this._model.crosshairSource().pane||(0,l.isLineToolName)(c.tool.value())||null!==this._model.lineBeingEdited())}}},85604:(e,t,i)=>{"use strict";i.r(t),i.d(t,{StudyCompare:()=>H});var s=i(50151),o=i(50788),n=i(46806),r=i(68805),a=i(12988),l=i(73698),c=i(56570),h=i(94164),d=i(98558),u=i(49256),_=i(19063);const p=c.enabled("force_exchange_as_title");class m extends d.PriceAxisView{constructor(e,t){super(),this._studyCompare=e,this._data=t}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const o=this._studyCompare.priceScale(),n=this._studyCompare.lastValueData(this._data.plotIndex,!1);if(n.noData||null===o||o.isEmpty())return;const r=this._studyCompare.model(),a=r.timeScale().visibleBarsStrictRange(),l=r.mainSeries().bars().lastIndex();if(null===a||null===l)return;if(l<=a.lastBar())i.background=(0,_.resetTransparency)(n.color),i.textColor=this.generateTextColor(i.background),i.borderColor=void 0,e.borderVisible=!1,t.borderVisible=!1;else{const o=r.backgroundColorAtYPercentFromTop(n.coordinate/(0,s.ensureNotNull)(r.paneForSource(this._studyCompare)).height());i.background=o,i.textColor=(0,_.resetTransparency)(n.color),i.borderColor=i.textColor,e.borderVisible=!0,t.borderVisible=!0}i.coordinate=n.coordinate,i.floatCoordinate=n.floatCoordinate;const c=r.properties().childs().scalesProperties.childs();c.showSeriesLastValue.value()&&(e.text=(0,u.getCurrentModePriceText)(o,n),c.seriesLastValueMode.value()!==h.PriceAxisLastValueMode.LastPriceAndPercentageValue?e.secondLine="":e.secondLine=(0,u.getOppositeModePriceText)(o,n),e.visible=!0),t.text="",c.showSymbolLabels.value()&&(t.text=this._paneText(),t.visible=t.text.length>0)}_paneText(){let e="";const t=this._studyCompare.symbolInfo();return p?e=(0,r.displayedSymbolExchange)(t):this._studyCompare.model().properties().childs().scalesProperties.childs().showSymbolLabels.value()&&(e=(0,r.displayedSymbolName)(t)),e}}i(11542);var g=i(22839),f=i(22739),y=i(928),v=i(49483),S=i(15764),b=i(37265),w=i(19466);const C=v.CheckMobile.any();class P extends f.StudyValuesProvider{constructor(e,t){super(e,t),
this._emptyValues[0].title=e.guiPlotName(w.TitleDisplayTarget.StatusLine,"")}getValues(e){return(0,b.isNumber)(e)||(this._showLastPriceAndChangeOnly()?e=this._study.data().lastIndex():(e=this._model.crosshairSource().appliedIndex(),(0,b.isNumber)(e)||(e=this._study.data().lastIndex()))),super.getValues(e)}_hideValues(){return!1}_showLastPriceAndChangeOnly(){return C&&(null===this._model.crosshairSource().pane||(0,S.isLineToolName)(y.tool.value())||null!==this._model.lineBeingEdited())}}class T extends g.StudyDataWindowView{constructor(e,t){super(e,t),this._studyCompare=e}_hideValues(){return!1}_createValuesProvider(e,t){return new P(e,t)}}var x=i(44672);class I extends T{constructor(e,t){super(e,t),this._additional=null,this._showSeriesOHLC=t.properties().childs().paneProperties.childs().legendProperties.childs().showSeriesOHLC,this._showSeriesOHLC.subscribe(this,(()=>this.update((0,x.sourceChangeEvent)(e.id()))))}areValuesVisible(){return this._showSeriesOHLC.value()}destroy(){this._showSeriesOHLC.unsubscribeAll(this)}additional(){return this._additional}_updateImpl(){super._updateImpl()}}var M=i(49936),A=i(24526),L=i(44158);class k extends L.StudyStatusProvider{getSplitTitle(){return this._source.titleInParts(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}text(){return this._source.isActualInterval()?this._source.isFailed()?`${this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}: ${this.sourceStatusText()}`:`${this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)} ${this.sourceStatusText()}`:this._source.title(w.TitleDisplayTarget.StatusLine,!0,void 0,!1,!1)}}var D=i(76350),E=i(52270),B=i(64147);const V=c.enabled("study_overlay_compare_legend_option"),R=c.enabled("force_exchange_as_title"),N=!c.enabled("hide_study_compare_legend_item"),O=c.enabled("hide_unresolved_symbols_in_legend"),F=c.enabled("symbol_info_price_source");var W;!function(e){e.SnapShotSymbolInfoKey="___snapshot"}(W||(W={}));class H extends n.Study{constructor(e,t,i,s,o){super(e,function(e){return e.hasChild("currencyId")||e.addChild("currencyId",new a.Property(null)),e.hasChild("unitId")||e.addChild("unitId",new a.Property(null)),e.addExcludedKey("currencyId",1),e.addExcludedKey("unitId",1),e}(t),i,s,o),this._isActingAsSymbolSource=new B.WatchedValue(!0),this._realignToolsLastParams=null,this._lastResolvedSymbolSource="",this.properties().childs().minTick.subscribe(null,(()=>this._recreatePriceFormattingDependencies())),this.properties().childs().minTick.subscribe(null,(()=>this._model.fullUpdate())),this.properties().childs().currencyId.subscribe(this,this._onCurrencyChanged),this.properties().childs().unitId.subscribe(this,this._onUnitChanged),this._symbolResolvingActive=new B.WatchedValue(!1),this._symbolHibernated=new B.WatchedValue(!1),e.mainSeries().onIntervalChanged().subscribe(this,(()=>e.realignLineTools(this)))}destroy(){this._model.mainSeries().onIntervalChanged().unsubscribeAll(this),super.destroy()}properties(){return this._properties}isActingAsSymbolSource(){
return this._isActingAsSymbolSource.readonly()}symbolParams(){return(0,D.symbolParams)(this)}compareSymbolParams(e){return(0,D.compareSymbolParams)(this,e,this._model.unitConversionEnabled())}async setSymbolParams(e){this._setSymbolCurrencyUnitInternal(e)}symbol(){return this.properties().childs().inputs.childs().symbol.value()}symbolChanged(){return this.properties().childs().inputs.childs().symbol}setSymbol(e){this.setSymbolParams({symbol:e})}symbolInfo(){if(!this._resolvedSymbols)return null;const e=this.symbol();if(!e)return null;let t;return t=this._resolvedSymbols[this._getSymbolForResolve(e)]||null,t}symbolResolved(){return this.symbolsResolved()}symbolResolvingActive(){return this._symbolResolvingActive}symbolHibernated(){return this._symbolHibernated}isVisible(){const e=super.isVisible();return this._symbolHibernated.setValue(!e),e}symbolSameAsCurrent(e){return(0,D.symbolSameAsCurrent)(e,this.symbolInfo())}symbolSameAsResolved(e){return(0,E.symbolSameAsResolved)(e,this._lastResolvedSymbolSource,this.symbol())}currency(){return this.properties().childs().currencyId.value()||null}setCurrency(e){this.setSymbolParams({currency:e})}isConvertedToOtherCurrency(){return(0,r.isConvertedToOtherCurrency)(this.symbolInfo())}unit(){return this.properties().childs().unitId.value()||null}setUnit(e){this.setSymbolParams({unit:e})}isConvertedToOtherUnit(){return(0,r.isConvertedToOtherUnit)(this.symbolInfo(),this._model.unitConversionEnabled())}style(){return 2}setStyle(e){}interval(){return this._model.mainSeries().interval()}setInterval(e){}symbolSource(){return this}valueAt(e,t){return this.data().search(e)?.value[1]??null}state(e,t){const i=super.state(e,t);this._model.unitConversionEnabled()||delete i.state.unitId;const o=this.symbol();return i.state.inputs.symbol=(0,r.symbolToSaveInState)(this.symbolInfo()??this._model.chartApi().lastSymbolResolveInfo(o),o),e&&((0,s.ensureDefined)(i.data).symbols={___snapshot:this.symbolInfo()||void 0}),i}symbolTitle(e,t,i){return this.title(e,!0,{},!1,t)}titleInParts(e,t,i,s,o){const n=this._titleInParts(e,t,i,s,o);return[[n[0],...n[1]??[]].join(", ")]}tags(){const e=this.symbol();return e?[e]:[]}statusView(){return N?super.statusView():null}guiPlotName(e,t){return this.properties().childs().inputs.childs().symbol.value()}canOverrideMinTick(){return!0}canBeHiddenByGlobalFlag(){return!1}legendValuesProvider(){return new P(this,this.model())}statusProvider(e){return new k(this)}measureUnitId(){return(0,r.measureUnitId)(this.symbolInfo())}getSymbolString(e){return void 0===e&&(e=this._getSymbolForApi(this.symbol())),(0,l.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(e))}_createPriceAxisView(e){return new m(this,{plotIndex:"compare"})}_createViews(){this._legendView||(this._legendView=new I(this,this._model)),this._dataWindowView||(this._dataWindowView=new T(this,this._model)),this._statusView||(this._statusView=new M.StudyStatusView(this)),super._createViews()}_onUnitChanged(){"alwaysOff"!==(0,o.currencyUnitVisibilityProperty)().value()&&this._model.fullUpdate(),
this._model.unitConversionEnabled()&&this.isStarted()&&this._tryChangeInputs(),this._unitChanged.fire()}_getSymbolObject(e){const t=super._getSymbolObject(e),i=this.currency();null!==i&&(t["currency-id"]=i);const s=this.unit();return this._model.unitConversionEnabled()&&null!==s&&(t["unit-id"]=s),t}_onSymbolResolvingStart(e,t){this._lastResolvedSymbolSource=t,super._onSymbolResolvingStart(e,t),this._symbolResolvingActive.setValue(!0)}_onSymbolError(){super._onSymbolError(),this._symbolResolvingActive.setValue(!1)}_onSymbolResolved(e,t,i){super._onSymbolResolved(e,t,i),this._recreatePriceFormattingDependencies();const s=t===this.symbol()?(0,r.extractSymbolNameFromSymbolInfo)(i,this.symbol()):null,o=(0,r.symbolCurrency)(i),n=(0,r.symbolUnit)(i,this._model.unitConversionEnabled());this._setSymbolCurrencyUnitInternal({symbol:s??void 0,currency:o,unit:n},i),this._symbolResolvingActive.setValue(!1)}async _changeInputsImpl(e,t){await super._changeInputsImpl(e,t),this._realignLineToolsIfParamsChanged()}_createStudyOnServer(){const e=super._createStudyOnServer();return this._realignLineToolsIfParamsChanged(),e}_tryCreateFormatter(){const e=A.customFormatters?.priceFormatterFactory?.(this.symbolInfo(),this.properties().childs().minTick.value())??null;return null!==e?e:(0,r.createSeriesFormatter)(this.symbolInfo(),this.properties().childs().minTick.value())}_tryCreateDefaultFormatter(){return(0,r.createSeriesFormatter)(this.symbolInfo(),"default")}_titleInParts(e,t,i,s,o){const n=this.symbolInfo();return[this._getSymbolTitlePart(n),[this._getExchangeTitlePart(n,o),this._getPriceSourceTitlePart(n)].filter((e=>null!==e))]}_skipHistogramBaseOnAutoScale(){return!0}_getSymbolTitlePart(e){if(null===e)return O?"":this.properties().childs().inputs.childs().symbol.value();const t=(0,r.getSymbolExchange)(e);if(R&&void 0!==t)return t;if(V)switch(this._model.mainSeries().symbolTextSourceProxyProperty().value()){case"description":return e.description;case"ticker-and-description":return`${e.name}, ${e.description}`;case"long-description":return e.long_description??e.description}return e.name}_getExchangeTitlePart(e,t){return null===e||t?null:(0,r.getSymbolExchange)(e)}_getPriceSourceTitlePart(e){return F&&!1!==this._model.properties().childs().paneProperties.childs().legendProperties.childs().showPriceSource.value()&&void 0!==e?.price_source_id?this._model.availablePriceSources(this.getSymbolString(this._getSymbolForApi(this.symbol()))).name(e.price_source_id)??null:null}_setSymbolCurrencyUnitInternal(e,t){const{symbol:i,currency:s,unit:o}=e,n=this.properties().childs(),a=n.inputs.childs().symbol.value(),l=n.currencyId.value(),c=n.unitId.value();if(void 0!==i&&n.inputs.childs().symbol.setValueSilently(i),void 0!==s&&n.currencyId.setValueSilently(s),void 0!==o&&n.unitId.setValueSilently(o),t)this._resolvedSymbolsByInput[this.symbol()]=t,this._resolvedSymbols[this._getSymbolForResolve(this.symbol())]=t,this._realignToolsLastParams=null;else{const e=this.symbolInfo();null!==e&&(n.currencyId.setValueSilently((0,r.symbolCurrency)(e)),
n.unitId.setValueSilently((0,r.symbolUnit)(e,this._model.unitConversionEnabled())))}n.inputs.childs().symbol.value()!==a&&n.inputs.childs().symbol.fireChanged(),n.currencyId.value()!==l&&n.currencyId.fireChanged(),n.unitId.value()!==c&&n.unitId.fireChanged(),this._realignLineToolsIfParamsChanged()}_realignLineToolsIfParamsChanged(){let e=null===this._realignToolsLastParams;if(null!==this._realignToolsLastParams){const t=this.compareSymbolParams(this._realignToolsLastParams);e=t.symbolChanged||t.intervalChanged||t.currencyChanged||t.unitChanged}e&&(this._model.realignLineTools(this),this._realignToolsLastParams=this.symbolParams())}}},16227:(e,t,i)=>{"use strict";i.d(t,{StudyPriceAxisView:()=>r});var s=i(50151),o=i(98558),n=i(19063);class r extends o.PriceAxisView{constructor(e,t){super(),this._model=e.model(),this._source=e,this._data=t,this._isForceOverlay=!!this._source.metaInfo().isPlotForceOverlay(this._data.plotIndex)}update(e){"hover-change"!==e.type&&super.update(e)}_updateRendererData(e,t,i){e.visible=!1,t.visible=!1;const o=this._source.model(),r=this._isForceOverlay?o.mainSeries().priceScale():this._source.priceScale();if(null===r)return;if(!o.isPriceScaleVisible(r))return;const a=this._source.lastValueData(this._data.plotIndex,!1);if(a.noData)return;const l=o.timeScale().visibleBarsStrictRange(),c=o.mainSeries().bars().lastIndex();if(null!==l&&null!==c){if(c<=l.lastBar()){i.background=(0,n.resetTransparency)(a.color);let s=a.color;"transparent"===s&&(s=this._model.properties().childs().scalesProperties.childs().backgroundColor.value()),i.textColor=this.generateTextColor(s),i.borderColor=void 0,e.borderVisible=!1,t.borderVisible=!1}else{const r=o.backgroundColorAtYPercentFromTop(a.coordinate/(0,s.ensureNotNull)(o.paneForSource(this._source)).height());i.background=r,i.textColor=(0,n.resetTransparency)(a.color),i.borderColor=(0,n.resetTransparency)(i.textColor),e.borderVisible=!0,t.borderVisible=!0}i.coordinate=a.coordinate,i.floatCoordinate=a.floatCoordinate,this._showAxisLabel()&&(e.text=a.text,e.visible=!0),this._updatePaneRendererData(t)}}_showPaneLabel(){return!!this._model.properties().childs().scalesProperties.childs().showStudyPlotLabels.value()&&this._source.properties().childs().showLabelsOnPriceScale.value()&&this._source.isPlotVisibleAt(this._data.plotIndex,4)}_showAxisLabel(){return!!this._model.properties().childs().scalesProperties.childs().showStudyLastValue.value()&&this._source.properties().childs().showLabelsOnPriceScale.value()&&this._source.isPlotVisibleAt(this._data.plotIndex,4)}_updatePaneRendererData(e){e.text="",this._showPaneLabel()&&(e.text=this._source.priceLabelText(this._data.plotIndex),e.visible=!0)}}},78749:(e,t,i)=>{"use strict";i.d(t,{applyOverridesToStudy:()=>d,applyOverridesToStudyDefaults:()=>u});var s=i(50151),o=i(94113),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={}))},46806:(e,t,i)=>{"use strict";i.r(t),i.d(t,{StudiesChunkName:()=>Et,Study:()=>Kt,studyFormatter:()=>qt});var s=i(50279),o=i(90054),n=i(16738),r=i(50151),a=i(11542),l=i(9343),c=i(49822);function h(e){const{name:t,group:i}=e;return t.length>0?`${i?`${i}.`:""}${t}`:void 0}var d=i(71885),u=i(52033),_=i(19063),p=i(58137),m=i(18172),g=i(45579),f=i(93280),y=i(64755),v=i(68159),S=i(14019),b=i(8025),w=i(85904),C=i(14878),P=i(44672),T=i(22739),x=i(7015);class I{constructor(e,t,i,s){this._study=e,this._model=t,this._showStudyValues=s??t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._hhistBasedStudy=void 0!==e.metaInfo().graphics.hhists,this._valuesProvider=this._createValuesProvider(e,t,i)}getItems(){return this._valuesProvider.getItems()}getValues(e){const t=this._valuesProvider.getValues(e),i=this._study.properties(),s=this._showStudyValues.value()&&i.childs().showLegendValues.value(),o=e=>!!this._hhistBasedStudy||this._study.isPlotVisibleAt(e,8);for(const e of t)e.visible=e.visible&&s&&o(e.id);return t}_createValuesProvider(e,t,i){
return this._hhistBasedStudy?new x.HHistBasedValuesProvider(e,t,i):new T.StudyValuesProvider(e,t,i)}}var M=i(94113);class A extends C.StudyBaseWindowView{constructor(e,t){super(e,t),this._showStudyValues=t.properties().childs().paneProperties.childs().legendProperties.childs().showStudyValues,this._showStudyValues.subscribe(this,(()=>this.update((0,P.sourceChangeEvent)(e.id()))));const i=this._study.properties();i.childs().showLegendValues.subscribe(this,(()=>this.update((0,P.sourceChangeEvent)(e.id()))));const s=this._study.metaInfo().plots,o=new Set;s.forEach((t=>{if((0,M.isOhlcPlot)(t)){const s=t.target;if(o.has(s))return;o.add(s),i.childs().ohlcPlots.childs()[s].childs().display.subscribe(this,(()=>this.update((0,P.sourceChangeEvent)(e.id()))))}else(0,M.isPlotSupportDisplay)(t)&&i.childs().styles.childs()[t.id]?.childs().display.subscribe(this,(()=>this.update((0,P.sourceChangeEvent)(e.id()))))}))}areValuesVisible(){return this._showStudyValues.value()}additional(){return null}destroy(){this._showStudyValues.unsubscribeAll(this);const e=this._study.properties();e.childs().showLegendValues.unsubscribeAll(this);const t=this._study.metaInfo().plots,i=new Set;t.forEach((t=>{if((0,M.isOhlcPlot)(t)){const s=t.target;if(i.has(s))return;i.add(s),e.childs().ohlcPlots.childs()[s].childs().display.unsubscribeAll(this)}else(0,M.isPlotSupportDisplay)(t)&&e.childs().styles.childs()[t.id]?.childs().display.unsubscribeAll(this)}))}_createValuesProvider(e,t){return new I(e,t)}}var L=i(928),k=i(49936),D=i(73698),E=i(3462),B=i(4340),V=i(44158),R=i(37265);i(19466),i(84425);function N(e,t){return e.studyId.localeCompare(t.studyId)}function O(e){const t=new Set,i=[];return e.forEach((e=>{t.has(e.studyId)||(t.add(e.studyId),i.push(e))})),i}function F(e){const t=e.model().mainSeries();return{studyId:(0,r.ensureNotNull)(e.sourceId()),turnaround:e.turnaround(),sourceStudies:e.parentSources().filter((e=>e!==t)).map((e=>F(e)))}}var W=i(65383),H=i(56570),z=i(95201),U=i(30125);class G extends U.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return null}_drawImpl(e){}_drawBackgroundImpl(e){const{context:t,horizontalPixelRatio:i,bitmapSize:s}=e,o=this._data;for(let e=0;e<o.items.length;++e){const n=o.items[e];if(null==n.color)continue;t.fillStyle=n.color;const r=Math.round(n.left*i)+1,a=Math.round(n.right*i);t.fillRect(r,0,a-r+1,s.height)}}}var j=i(83085),q=i(64559);class $ extends q.StudyForceOverlayPlotView{constructor(e,t,i,s){super(t,i,s),this._items=[],this._invalidated=!0,this._isMarkersEnabled=H.enabled("source_selection_markers"),this._study=e;const o=this._study.metaInfo().plots;for(let e=0;e<o.length;e++){const t=o[e];t.id===this._plotName&&(this._plotIndex=e,(0,r.assert)((0,M.isBgColorerPlot)(t),"Plot '"+this._plotName+"' is not a background colorer!"))}this._colorProvider=(0,j.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s)}items(){return this._items}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}renderer(){if(1&~(0,
r.ensureDefined)(this._study.properties().childs().styles.childs()[this._plotName]).childs().display.value())return null;if(!this._scalesReady())return null;this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e={items:this._items},t=new z.CompositeRenderer;return t.append(new G(e)),t}_scalesReady(){const e=this._model.timeScale(),t=this._priceScale();return e&&!e.isEmpty()&&null!==t&&!t.isEmpty()}_getTranspValue(){const e=(0,r.ensureDefined)(this._study.properties().childs().styles.childs()[this._plotName]).childs();let t=0;return e.transparency&&(t=e.transparency.value(),t=(0,R.isNumber)(t)?t:40),t}_updateImpl(){this._items=[],(0,r.assert)(this._scalesReady(),"Scales must be ready!");const e=this._model.timeScale().visibleBarsStrictRange();if(null===e)return;const t=this._getTranspValue();let i=(0,r.ensureDefined)(this._series.nearestIndex(e.firstBar(),b.PlotRowSearchMode.NearestRight)),s=(0,r.ensureDefined)(this._series.nearestIndex(e.lastBar(),b.PlotRowSearchMode.NearestLeft));const o=this._study.offset(this._plotName);o>0?(i-=o,s+=o):(i+=o,s-=o);const n=this._study.getMinFirstBarIndexForPlot(this._plotName);if(n>s)return;i=Math.max(n,i);const a=this._study.data();for(const e of a.rangeIterator(i,s)){let i=e.index;const s=e.value;i+=o;const n={timePointIndex:Math.floor(i),left:NaN,center:NaN,right:NaN};let a=(0,R.isNumber)(t)?t:50;a=Math.min(a,100),a=Math.max(a,0);const l=this._colorProvider.getPlotPointStyle(s);void 0!==l.colors[1]&&(n.color=(0,_.generateColor)((0,r.ensureDefined)(l.colors[1]),a)),this._items.push(n)}this._model.timeScale().fillBarBorders(this._items)}}var K,Y=i(86129),Z=i(11064),X=i(31785),J=i(9859),Q=i(66540),ee=i(3070),te=i(13380),ie=i(86441),se=i(34026),oe=i(50335),ne=i(30699),re=i(56468),ae=i(63812),le=i(68979),ce=i(27714),he=i(7114);!function(e){e.Left="left",e.Center="center",e.Right="right"}(K||(K={}));const de=(0,he.createDisconnectedCanvas)(document,(0,ce.size)({width:0,height:0}),1);class ue{constructor(e,t,i,s,o,n="center",a=0){this._lines=e.split(/[^\S\r\n]*(?:\r\n|\r|\n)/),this._font=function(e,t,i,s){return(0,le.makeFont)(s,i,`${e?"bold ":""}${t?"italic ":""}`)}(t,i,s,o),this._fontSize=o,this._verticalPadding=~~(o/6),this._textAlign=n,this._lineSpacing=a;const l=(0,r.ensureNotNull)(de.getContext("2d"));l.font=this._font,l.textBaseline="top";let c=0;for(let e=0;e<this._lines.length;++e){const t=this._lines[e],i=l.measureText(t).width;c=Math.max(c,i)}this.textImageWidth=c+1,this.textImageHeight=this._lines.length*o+(this._lines.length-1)*this._lineSpacing+this._verticalPadding}paintTo(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e;i.save();const n=t.location;i.translate(Math.round(function(e,t,i){let s=e;switch(t){case"left":break;case"right":s-=i;break;case"center":s-=i/2}return Math.round(s)}(n.x,n.horzAlign,this.textImageWidth)*s),Math.round(function(e,t,i){let s=e;switch(t){case"top":break;case"bottom":s-=i;break;case"middle":s-=i/2}return Math.round(s)}(n.y,n.vertAlign,this.textImageHeight)*o));const r=t.style;let a
;switch(i.textBaseline="top",i.font=this._font,i.lineJoin="round",i.fillStyle=r.fillStyle,r.strokeStyle&&(i.strokeStyle=r.strokeStyle),r.lineWidth&&(i.lineWidth=r.lineWidth),this._textAlign){case"left":a=0,i.textAlign="left";break;case"right":a=this.textImageWidth-1,i.textAlign="right";break;default:a=this.textImageWidth/2,i.textAlign="center"}let l=this._verticalPadding;(0,he.drawScaled)(i,s,o,(()=>{for(const e of this._lines)r.strokeStyle&&i.strokeText(e,a,l),i.fillText(e,a,l),l+=this._fontSize,l+=this._lineSpacing})),i.restore()}}class _e extends ae.AbstractMapContainer{constructor(e){super(),this._maxSize=e,this._keysQueue=[]}get(e){const{fontSize:t,text:i,align:s,font:o,bold:n,italic:r,lineSpacing:a=0}=e;if(!i||!t||!s)return null;const l=(0,le.makeFont)(t,o,r?"italic":"",n?"bold":""),c=(0,ae.getDefault3)(this._map,a,s,l,new Map);let h=c.get(i);return void 0!==h||(this._size>=this._maxSize?this._deleteFirstKey():++this._size,this._keysQueue.push([l,s,a,i]),h=new ue(i,n,r,o,t,s,a),c.set(i,h)),h}_deleteFirstKey(){const e=this._keysQueue.shift(),[t,i,s,o]=e,n=(0,r.ensureDefined)(this._map.get(s)),a=(0,r.ensureDefined)(n.get(i)),l=(0,r.ensureDefined)(a.get(t));l.delete(o),0===l.size&&a.delete(t),0===a.size&&n.delete(i),0===n.size&&this._map.delete(s)}}var pe,me=i(15938),ge=i(49483);!function(e){e.Transparent="rgba(0, 0, 0, 0)"}(pe||(pe={}));class fe extends U.BitmapCoordinatesPaneRenderer{constructor(e,t={skipRenderingOptimizations:!1}){super(),this._items=[],this._barSpacing=0,this._vertOffset=0,this._textCache=t.textCache||new _e(5e3),this._drawOperation=t.skipRenderingOptimizations?this._drawWithoutOptimizations.bind(this):this._drawWithOptimizations.bind(this),null!==e&&this.setData(e)}hitTest(e){const t=re.HitTarget.Regular;let i=null;for(const s of this._items){if(!s)continue;const o=this._calcBoundingBox(s);if(o&&(0,se.pointInBox)(e,o)){const e={tooltip:this._getTooltip(s,o)};i=new re.HitTestResult(t,e)}}return i}setData(e){if(this._height=void 0!==e.height?e.height:e.width,this._width=void 0!==e.width?e.width:e.height,this._color=e.color,this._borderColor=e.borderColor,this._vertOffset=e.vertOffset||0,e.text&&(this._text=e.text,this._fontSize=e.fontSize,this._lineSpacing=e.lineSpacing,this._textColor=e.textColor,this._textAlign=e.textAlign||"center"),void 0!==e.items&&void 0!==e.barSpacing){const t=e.visibleItemsRange?.startItemIndex??0,i=e.visibleItemsRange?.endItemIndex??e.items.length;this.setItems(i>t?e.items.slice(t,i):[],e.barSpacing)}}setItems(e,t){this._setBaseData(e,t)}_drawImpl(e){this._preDrawInit(),this._drawOperation(e)}_calcBoundingBox(e){const t=e.vertOffset,i=this._getTextCache(e);if(!i)return;const s=i.textImageWidth,o=i.textImageHeight,n=s/2,r=e.y+t+e.textVertOffset,a=t>0?0:-o,l=t>0?o:0,c=new ie.Point(e.center-n,r+a),h=new ie.Point(e.center+n,r+l);return(0,ie.box)(c,h)}_unionBox(e,t){const i=Math.min(e.min.x,t.min.x),s=Math.max(e.max.x,t.max.x),o=Math.min(e.min.y,t.min.y),n=Math.max(e.max.y,t.max.y),r=new ie.Point(i,o),a=new ie.Point(s,n);return(0,ie.box)(r,a)}_getTooltip(e,t){
if(e.tooltip)return{content:{type:"text",data:e.tooltip},tooltipDelay:200,extendMargin:!0,rect:{x:t.min.x,y:t.min.y,w:Math.abs(t.max.x-t.min.x),h:Math.abs(t.max.y-t.min.y)}}}_setBaseData(e,t){this._items.length=0,this._barSpacing=t;for(const t of e){if((0,oe.isNaN)(t.y))continue;const e=void 0===t.width?(0,r.ensureDefined)(this._width):t.width,i=void 0===t.height?(0,r.ensureDefined)(this._height):t.height,s=void 0===t.vertOffset?this._vertOffset:t.vertOffset,o=s>0?i:-i;this._items.push({width:e,height:i,vertOffset:s,textVertOffset:o,shapeWidth:0,shapeHeight:0,stepX:0,stepY:0,...t})}}_drawItemText(e,t){const i=this._getTextCache(t);if(null===i)return;const s=t.center,o=t.vertOffset,n=t.y+o+t.textVertOffset;let r;r=t.style&&void 0!==t.style.textColor?t.style.textColor:this._textColor;const a={style:{fillStyle:r},location:{x:s,y:n,horzAlign:ne.HorizontalAlign.Center,vertAlign:o>0?ne.VerticalAlign.Top:ne.VerticalAlign.Bottom}};i.paintTo(e,a)}_drawWithOptimizations(e){let t,i,s=null,o=!1;for(const n of this._items)(0,oe.isNaN)(n.y)||(n.style&&void 0!==n.style.color?(t=n.style.color||"rgba(0, 0, 0, 0)",i=n.style.borderColor||"rgba(0, 0, 0, 0)"):(t=this._color,i=this._borderColor),(s!==t||ge.isSafari)&&(s=t,o&&this._endPath(e),this._startPath(e,t,i)),this._drawItemShape(e,n),o=!0);o&&this._endPath(e);for(const t of this._items)(0,oe.isNaN)(t.y)||this._drawItemText(e,t)}_drawWithoutOptimizations(e){let t,i;for(const s of this._items){if((0,oe.isNaN)(s.y))continue;const o=(0,r.ensureDefined)(s.style);t=o.color||"rgba(0, 0, 0, 0)",i=o.borderColor||"rgba(0, 0, 0, 0)",this._startPath(e,t,i),this._drawItemShape(e,s),this._endPath(e),this._drawItemText(e,s)}}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e;(0,he.drawScaled)(i,s,o,(()=>this._drawItemShapeUsingCSSPixels(i,t)))}_drawItemShapeUsingCSSPixels(e,t){}_preDrawInit(){}_startPath(e,t,i){}_endPath(e){}_getTextCache(e){const t=e.text||this._text,i=e.fontSize||this._fontSize,s=e.lineSpacing??this._lineSpacing,o=e.textAlign||this._textAlign,n=e.font??me.CHART_FONT_FAMILY,r=e.bold??!1,a=e.italic??!1;return this._textCache.get({text:t,bold:r,italic:a,font:n,fontSize:i,lineSpacing:s,align:o})}}class ye extends fe{_startPath(e,t,i){const s=e.context;s.beginPath(),s.lineWidth=this._lineWidth(e),s.lineCap="butt",s.strokeStyle=t}_endPath(e){e.context.stroke()}_lineWidth(e){return Math.max(1,Math.floor(2*e.horizontalPixelRatio))}}class ve extends fe{_startPath(e,t,i){const s=e.context;s.beginPath(),s.lineWidth=this._lineWidth(e),s.lineCap="butt",s.fillStyle=t,s.strokeStyle=i}_endPath(e){const t=e.context;t.fill(),t.stroke()}_lineWidth(e){return Math.max(1,Math.floor(e.horizontalPixelRatio))}}class Se extends ve{constructor(){super(...arguments),this._sign=0,this._thinArrow=!1,this._thinArrowLineWidth=0,this._headHeight=0,this._arrowWidth=0}setItems(e,t){this._setBaseData(e,t)}_drawItemShape(e,t){
const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e,n=this._lineWidth(e)%2?.5:0,r=this._sign,a=this._arrowWidth,l=this._headHeight,c=Math.abs(t.height),h=Math.round(t.center*s)+n,d=t.vertOffset,u=Math.round((t.y+d+r*c/2)*o)+n,_=(0,J.ceiledEven)(a*s),p=_/2,m=Math.round(c*o),g=Math.round(l*o);i.translate(h,u),this._thinArrow?(i.moveTo(0,0),i.lineTo(-p,-p*r),i.moveTo(0,0),i.lineTo(p,-p*r),i.moveTo(0,0),i.lineTo(0,-m*r),i.moveTo(-p,-m*r),i.lineTo(p,-m*r)):(i.moveTo(0,0),m<g?(i.lineTo(_,-m*r),i.lineTo(-_,-m*r)):(i.lineTo(_,-g*r),i.lineTo(p,-g*r),i.lineTo(p,-m*r),i.lineTo(-p,-m*r),i.lineTo(-p,-g*r),i.lineTo(-_,-g*r)),i.lineTo(0,0)),i.translate(-h,-u)}_preDrawInit(){const e=this._calculateWidth();this._arrowWidth=e,this._sign=this._isUp()?-1:1,this._thinArrow=e<4,this._thinArrowLineWidth=Math.max(e/2,1),this._headHeight=Math.round(e)}_startPath(e,t,i){const s=e.context;s.beginPath(),s.fillStyle=t,s.strokeStyle=i,s.lineWidth=this._lineWidth(e)}_lineWidth(e){return this._thinArrow?this._thinArrowLineWidth:super._lineWidth(e)}_calcBoundingBox(e){const t=e.vertOffset,i=this._sign,s=this._arrowWidth,o=this._headHeight,n=Math.abs(e.height),r=e.center-s,a=r+2*s,l=e.y+t+i*Math.round(n/2),c=l+(-n-o)*i,h=new ie.Point(r,l),d=new ie.Point(a,c);let u=(0,ie.box)(h,d);const _=super._calcBoundingBox(e);return _&&(u=this._unionBox(u,_)),u}_calculateWidth(){return Math.round(this._barSpacing/4)}}const be=2*Math.PI;class we extends ve{setItems(e,t){this._setBaseData(e,t);for(const e of this._items){if(e.fontSize){const t=e.fontSize;e.stepX=Math.round(t/1.5),e.stepY=Math.round(t/2)-1}else{const t=e.height;e.stepX=Math.round(t/2*.65)+.5,e.stepY=e.stepX}e.vertOffset=this._calcVertOffset(e);const t=this._getTextCache(e);if(null===t){e.shapeWidth=2*e.stepX,e.shapeHeight=2.5*e.stepY;continue}const i=t.textImageWidth,s=t.textImageHeight;e.shapeWidth=i+2*e.stepX,e.shapeHeight=s+2*e.stepY,e.vertOffset=this._calcVertOffset(e),e.textHorizOffset=this._getHorizontalTextOffset(e),e.textVertOffset=this._getVerticalTextOffset(e)}}_calcVertOffset(e){return e.vertOffset}_drawCorner(e,t,i,s){const{context:o,horizontalPixelRatio:n}=e,r=Math.max(1,Math.floor(2*n));o.lineTo(t-r*s.prevPointSignX,i-r*s.prevPointSignY),o.arcTo(t,i,t+r*s.nextPointSignX,i+r*s.nextPointSignY,r)}_getArrowSize(e){return e.stepX}_getHorizontalTextOffset(e){return 0}_getVerticalTextOffset(e){return 0}_hasText(e){return Boolean(e.text)||Boolean(this._text)}_drawItemText(e,t){const i=this._getTextCache(t);if(null===i)return;const s=t.textHorizOffset||0,o=t.center+s,n=t.vertOffset,a=t.y+n+t.textVertOffset,l=t.style?.textColor||this._textColor,c={style:{fillStyle:(0,r.ensureDefined)(l)},location:{x:o,y:Math.floor(a),horzAlign:ne.HorizontalAlign.Center,vertAlign:ne.VerticalAlign.Middle}};i.paintTo(e,c)}}class Ce{constructor(e,t,i,s){this.prevPointSignX=e,this.prevPointSignY=t,this.nextPointSignX=i,this.nextPointSignY=s}}var Pe;!function(e){e.rightUp=new Ce(1,0,0,1),e.rightDown=new Ce(0,1,-1,0),e.leftDown=new Ce(-1,0,0,-1),e.leftUp=new Ce(0,-1,1,0)}(Pe||(Pe={}));class Te extends ve{
_calcBoundingBox(e){const t=e.width,i=e.height,s=t/2,o=Math.round(i/3),n=e.center,r=e.vertOffset-2*o,a=e.y+r,l=n-s,c=n+s,h=a,d=a+i,u=new ie.Point(l,h),_=new ie.Point(c,d);let p=(0,ie.box)(u,_);const m=super._calcBoundingBox(e);return m&&(p=this._unionBox(p,m)),p}}var xe=i(29981),Ie=i(35864);const Me=new Map;Me.set("PaneRendererArrowUp",class extends Se{_isUp(){return!0}}),Me.set("PaneRendererArrowDown",class extends Se{_isUp(){return!1}}),Me.set("PaneRendererCircleShape",class extends ve{_drawItemShapeUsingCSSPixels(e,t){const i=Math.max(t.width,t.height)/2,s=t.center,o=t.vertOffset,n=t.y+o;e.moveTo(s+i,n),e.arc(s,n,i,0,be,!1)}_calcBoundingBox(e){const t=Math.max(e.width,e.height)/2,i=e.center,s=e.vertOffset,o=e.y+s,n=i-t,r=i+t,a=o-t,l=o+t,c=new ie.Point(n,a),h=new ie.Point(r,l);let d=(0,ie.box)(c,h);const u=super._calcBoundingBox(e);return u&&(d=this._unionBox(d,u)),d}}),Me.set("PaneRendererCrossShape",class extends ye{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e,n=t.width,r=t.height,a=t.center-n/2,l=t.vertOffset,c=t.y-r/2+l,h=this._lineWidth(e),d=h%2?.5:0,u=Math.round(a*s);let _=Math.round((a+n)*s);(_-u)%2!=h%2&&(_+=1);const p=Math.floor((u+_)/2)+d,m=Math.round(c*o);let g=Math.round((c+r)*o);(g-m)%2!=h%2&&(g+=1);const f=Math.floor((m+g)/2)+d;i.moveTo(p,m),i.lineTo(p,g),i.moveTo(u,f),i.lineTo(_,f)}_calcBoundingBox(e){const t=e.width,i=e.height,s=e.center-t/2,o=e.vertOffset,n=e.y-i/2+o,r=s,a=s+t,l=n,c=n+i,h=new ie.Point(r,l),d=new ie.Point(a,c);let u=(0,ie.box)(h,d);const _=super._calcBoundingBox(e);return _&&(u=this._unionBox(u,_)),u}}),Me.set("PaneRendererDiamond",class extends ve{_drawItemShapeUsingCSSPixels(e,t){const i=Math.round(t.height/2),s=t.center,o=t.vertOffset,n=t.y+o;e.moveTo(s,n-i),e.lineTo(s+i,n),e.lineTo(s,n+i),e.lineTo(s-i,n),e.lineTo(s,n-i)}_calcBoundingBox(e){const t=Math.round(e.height/2),i=e.center,s=e.vertOffset,o=e.y+s,n=i-t,r=i+t,a=o-t,l=o+t,c=new ie.Point(n,a),h=new ie.Point(r,l);let d=(0,ie.box)(c,h);const u=super._calcBoundingBox(e);return u&&(d=this._unionBox(d,u)),d}}),Me.set("PaneRendererFlagShape",class extends ve{_drawItemShapeUsingCSSPixels(e,t){const i=t.width,s=t.height,o=s/2,n=(i-3)/3,r=t.center-i/2,a=t.vertOffset,l=t.y-o+a;e.moveTo(r,l),e.lineTo(r+3,l),e.bezierCurveTo(r+n,l-n,r+2*n,l+n,r+i,l),e.lineTo(r+i,l+o),e.bezierCurveTo(r+i-n,l+o+n,r+i-2*n,l+o-n,r+3,l+o),e.lineTo(r+3,l+s),e.lineTo(r,l+s),e.lineTo(r,l)}_calcBoundingBox(e){const t=e.width,i=e.height,s=i/2,o=e.center-t/2,n=e.vertOffset,r=e.y-s+n,a=o,l=o+t,c=r,h=r+i,d=new ie.Point(a,c),u=new ie.Point(l,h);let _=(0,ie.box)(d,u);const p=super._calcBoundingBox(e);return p&&(_=this._unionBox(_,p)),_}}),Me.set("PaneRendererLabelUp",class extends we{_calcBoundingBox(e){const t=e.center-e.shapeWidth/2,i=e.center+e.shapeWidth/2,s=e.y+e.vertOffset,o=e.y+e.shapeHeight+e.vertOffset,n=new ie.Point(t,s),r=new ie.Point(i,o);return(0,ie.box)(n,r)}_drawItemShape(e,t){
const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e,n=this._lineWidth(e)%2?.5:0,r=Math.max(1,Math.floor(s))%2?.5:0,a=this._getArrowSize(t);let l=Math.round(a*s);(r+l)%1!=n%1&&(l+=.5);let c=Math.round(t.shapeWidth/2*s);(r+c)%1!=n%1&&(c+=.5);const h=Math.round(t.center*s)+r,d=Math.round((t.y+t.vertOffset)*o)+n,u=h-l,_=Math.round((t.y+t.vertOffset+a)*o)+n,p=h+l,m=h+c,g=Math.round((t.y+t.vertOffset+a+t.shapeHeight)*o)+n,f=h-c;i.moveTo(u,_),i.lineTo(h,d),i.lineTo(p,_),t.shapeWidth<=2*a?(i.lineTo(m,_),this._drawCorner(e,m,g,Pe.rightDown),this._drawCorner(e,f,g,Pe.leftDown),i.lineTo(f,_)):(this._drawCorner(e,m,_,Pe.rightUp),this._drawCorner(e,m,g,Pe.rightDown),this._drawCorner(e,f,g,Pe.leftDown),this._drawCorner(e,f,_,Pe.leftUp)),i.lineTo(u,_)}_getVerticalTextOffset(e){return e.shapeHeight/2+this._getArrowSize(e)}_calcVertOffset(e){return Math.sign(e.vertOffset)>=0?e.vertOffset:e.vertOffset-e.shapeHeight}}),Me.set("PaneRendererLabelDown",class extends we{_calcBoundingBox(e){const t=e.center-e.shapeWidth/2,i=e.center+e.shapeWidth/2,s=e.y-e.shapeHeight+e.vertOffset,o=e.y+e.vertOffset,n=new ie.Point(t,s),r=new ie.Point(i,o);return(0,ie.box)(n,r)}_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e,n=this._lineWidth(e)%2?.5:0,r=Math.max(1,Math.floor(s))%2?.5:0,a=this._getArrowSize(t);let l=Math.round(a*s);(r+l)%1!=n%1&&(l+=.5);let c=Math.round(t.shapeWidth/2*s);(r+c)%1!=n%1&&(c+=.5);const h=Math.round(t.center*s)+r,d=Math.round((t.y+t.vertOffset)*o)+n,u=h+l,_=Math.round((t.y+t.vertOffset-a)*o)+n,p=h-l,m=h+c,g=Math.round((t.y+t.vertOffset-t.shapeHeight-a)*o)+n,f=h-c;i.moveTo(u,_),i.lineTo(h,d),i.lineTo(p,_),t.shapeWidth<=2*a?(i.lineTo(f,_),this._drawCorner(e,f,g,Pe.leftUp),this._drawCorner(e,m,g,Pe.rightUp),i.lineTo(m,_)):(this._drawCorner(e,f,_,Pe.leftDown),this._drawCorner(e,f,g,Pe.leftUp),this._drawCorner(e,m,g,Pe.rightUp),this._drawCorner(e,m,_,Pe.rightDown)),i.lineTo(u,_)}_getVerticalTextOffset(e){return-e.shapeHeight/2-this._getArrowSize(e)}_calcVertOffset(e){return Math.sign(e.vertOffset)<=0?e.vertOffset:e.vertOffset+e.shapeHeight}}),Me.set("PaneRendererSquare",class extends ve{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e,n=Math.max(1,Math.floor(s))%2?.5:0,r=this._lineWidth(e)%2?.5:0;let a=Math.round(t.height/2*o);(n+a)%1!=r%1&&(a+=.5);const l=Math.round(t.center*s)+n,c=Math.round((t.y+t.vertOffset)*o)+n,h=l-a,d=c-a,u=l+a,_=c+a;i.rect(h,d,u-h,_-d)}_calcBoundingBox(e){const t=e.height,i=Math.round(t/2),s=e.center-i,o=e.vertOffset,n=e.y+o-i,r=s,a=s+t,l=n,c=n+t,h=new ie.Point(r,l),d=new ie.Point(a,c);let u=(0,ie.box)(h,d);const _=super._calcBoundingBox(e);return _&&(u=this._unionBox(u,_)),u}}),Me.set("PaneRendererTriangleApexUp",class extends Te{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e,n=t.width,r=t.height,a=Math.round(r/3),l=t.vertOffset-2*a,c=this._lineWidth(e)%2?.5:0,h=Math.max(1,Math.floor(s)),d=h%2?.5:0;let u=Math.round(n*s);u%2!=h%2&&(u+=1)
;const _=Math.round(t.center*s)+d,p=Math.round((t.y+l)*o),m=_+u/2,g=Math.round((t.y+l+r)*o)+c,f=_-u/2;i.moveTo(_,p),i.lineTo(m,g),i.lineTo(f,g),i.lineTo(_,p)}}),Me.set("PaneRendererTriangleApexDown",class extends Te{_drawItemShape(e,t){const{context:i,horizontalPixelRatio:s,verticalPixelRatio:o}=e,n=t.width,r=t.height,a=Math.round(r/3),l=t.vertOffset-a,c=this._lineWidth(e)%2?.5:0,h=Math.max(1,Math.floor(s)),d=h%2?.5:0;let u=Math.round(n*s);u%2!=h%2&&(u+=1);const _=Math.round(t.center*s)+d,p=Math.round((t.y+l)*o)+c,m=_+u/2,g=Math.round((t.y+l+r)*o),f=_-u/2;i.moveTo(f,p),i.lineTo(m,p),i.lineTo(_,g),i.lineTo(f,p)}}),Me.set("PaneRendererXCross",class extends ye{_drawItemShapeUsingCSSPixels(e,t){const i=t.width,s=t.height,o=t.center-i/2,n=t.vertOffset,r=t.y-s/2+n;e.moveTo(o,r),e.lineTo(o+i,r+s),e.moveTo(o,r+s),e.lineTo(o+i,r)}_calcBoundingBox(e){const t=e.width,i=e.height,s=e.center-t/2,o=e.vertOffset,n=e.y-i/2+o,r=s,a=s+t,l=n,c=n+i,h=new ie.Point(r,l),d=new ie.Point(a,c);let u=(0,ie.box)(h,d);const _=super._calcBoundingBox(e);return _&&(u=this._unionBox(u,_)),u}});class Ae extends Ie.StudyPaneViewInplaceUpdatable{constructor(e,t,i,s){super(t,i,s),this._renderer=null,this._shapesRenderer=null,this._selectionRenderer=null,this._isMarkersEnabled=H.enabled("source_selection_markers"),this._study=e;const o=e.metaInfo().plots;for(let e=0;e<o.length;e++)if(o[e].id===this._plotName){this._plotIndex=e;break}this._plotStyleInfo=(0,r.ensureDefined)(e.metaInfo().styles?.[this._plotName]),this._colorProvider=(0,j.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s),this._selectionIndexer=new Q.SelectionIndexes(i.timeScale())}items(){return this._items}renderer(){return this._isPlotVisible()&&this._scalesReady()?(this._makeSureRendererIsValid(),this._renderer):null}_isPlotVisible(){return this._study.isPlotVisibleAt(this._plotName,1)}_scalesReady(){const e=this._model.timeScale(),t=this._priceScale();return e&&null!==t&&!e.isEmpty()&&!t.isEmpty()}_updateImplFull(e){if(this._dataInvalidated?.clearData&&(this._items=[],this._renderer=null),!this._scalesReady())return!1;const t=this._model.timeScale(),i=this._priceScale(),s=t.visibleBarsStrictRange();if(null===s||null===i)return!1;const o=this._study.plots().plottableRange(!1);if(0===o.size())return!1;const n=this._study.offset(this._plotName),a=this._study.firstValue(void 0,this.isForceOverlay());if(null===a)return!1;this._updateAdditionalPrices(i,a);const{hiPlot:l,loPlot:c}=this._hiLoPlots(),h=this._preallocateItems(o,((e,t)=>this._createItem(e,t??null,l,c,n)));let d=this._series.nearestIndex(s.firstBar(),b.PlotRowSearchMode.NearestRight),u=this._series.nearestIndex(s.lastBar(),b.PlotRowSearchMode.NearestLeft);if(void 0===d||void 0===u)return!1;n>0?(d-=n,u+=n):(d+=n,u-=n);const _=this._study.getMinFirstBarIndexForPlot(this._plotName);if(_>u)return!0;d=Math.max(_,d);const p=this._getTranspValue(),m=this._study.properties().childs().styles.childs()[this._plotName].childs(),g=m.color.value(),f=m.textColor?m.textColor.value():void 0,y=g,v=g,S=void 0===f?void 0:f,w=(0,
r.ensureNotNull)(this._plotIndex),C=(0,te.createEmptyStyle)(),P=h??(0,r.ensureNotNull)(o.firstIndex()),T=o.rangeIterator(P,(0,r.ensureNotNull)(o.lastIndex())+1);let x=(0,xe.lowerbound)(this._items,P+n,((e,t)=>e.timePointIndex<t));for(const e of T){const t=e.value,i=t[w+1];if(null==i){x++;continue}const s=this._items[x];if(!isNaN(s.origPrices.price)){if(this._colorProvider.isColorDefined()){s.style={color:y,borderColor:v,textColor:S};const e=this._colorProvider.getPlotPointStyle(t,C);this._fillItemWithPointStyle(s,e,p)}}x++}return this._updateImplLight(),!0}_fillItemWithPointStyle(e,t,i){const s=(0,r.ensureDefined)(e.style);if(void 0!==t.colors[0]){s.color=(0,_.generateColor)((0,r.ensureDefined)(t.colors[0]),i);const e=i>9?i-10:0;s.borderColor=(0,_.generateColor)(s.color,e)}void 0!==t.colors[2]&&(s.textColor=(0,_.generateColor)((0,r.ensureDefined)(t.colors[2]),i))}_updateRenderer(e,t){this._makeSureRendererIsValid();const i=this._model.timeScale(),s={},o=this._getTranspValue(),n=i.barSpacing(),r=this._calculateShapeHeight(n),a=this._study.properties().childs().styles.childs()[this._plotName].childs(),l=a.location.value(),c=this._calculateVerticalOffset(l,r+r/2);s.barSpacing=n,s.items=this._items,s.color=(0,_.generateColor)(a.color.value(),o),s.height=r,s.vertOffset=c,s.visibleItemsRange={startItemIndex:e,endItemIndex:t};const h=a.plottype.value(),d=X.plotShapesData[h],u=new z.CompositeRenderer;d&&(this._shapesRenderer?this._shapesRenderer.setData(s):(this._shapesRenderer=this._createRenderer(d.paneRendererClass,s),u.append(this._shapesRenderer))),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=c,u.append(new Z.SelectionRenderer(this._selectionData))),this._renderer=u}_createRenderer(e,t){const i=Me.get(e);return new((0,r.ensureDefined)(i))(t)}_getSeriesVal(e,t){const i=(0,ee.barFunction)(e),s=this._series.data().valueAt(t);return null===s?null:i(s)}_getTranspValue(){let e=0;const t=this._study.properties().childs();t.transparency&&(e=t.transparency.value(),e=(0,R.isNumber)(e)?e:50);const i=t.styles.childs()[this._plotName].childs();return i.transparency&&(e=i.transparency.value(),e=(0,R.isNumber)(e)?e:50),(0,J.clamp)(e,0,100)}_createItem(e,t,i,s,o){const n=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value(),a={origPrices:{price:NaN},timePointIndex:e+o};if((null===t||0===t)&&n!==w.MarkLocation.Absolute)return a;if(null==t)return a;let l=NaN;switch(n){case w.MarkLocation.AboveBar:{const t=this._getLocationPrice(e,i,o);if(null===t)return a;l=t;break}case w.MarkLocation.BelowBar:{const t=this._getLocationPrice(e,s,o);if(null===t)return a;l=t;break}case w.MarkLocation.Absolute:l=(0,r.ensureNotNull)(t);break;case w.MarkLocation.Top:case w.MarkLocation.Bottom:l=0;break;default:throw new Error("Bad value: "+n)}return{y:NaN,origPrices:{price:l},timePointIndex:e+o}}_dependsOnSeriesData(){const e=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value()
;return e===w.MarkLocation.AboveBar||e===w.MarkLocation.BelowBar}_getValueForUpdating(e){const t=e.value[this._plotIndex+1];if(null==t)return null;const i=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value();if(0===t&&i!==w.MarkLocation.Absolute)return null;const s=this._study.offset(this._plotName),{hiPlot:o,loPlot:n}=this._hiLoPlots();switch(i){case w.MarkLocation.AboveBar:return this._getLocationPrice(e.index,o,s);case w.MarkLocation.BelowBar:return this._getLocationPrice(e.index,n,s)}return super._getValueForUpdating(e)}_convertItemsToCoordinates(e,t,i,s){for(let e=i;e<s;e++){const t=this._items[e];t.y=t.origPrices.price}this._model.timeScale().fillBarBorders(this._items);const o=this._study.properties().childs().styles.childs()[this._plotName].childs().location.value(),n=e.height()*e.topMargin(),r=e.height()*(1-e.bottomMargin()),a=e.isInverted(),l=a?r:n,c=a?n:r,h=e=>{for(let t=i;t<s;t++)isNaN(this._items[t].y)||(this._items[t].y=e)};switch(o){case w.MarkLocation.Top:h(l);break;case w.MarkLocation.Bottom:h(c);break;default:e.pointsArrayToCoordinates(this._items,t,{startItemIndex:i,endItemIndex:s})}}_calculateVerticalOffset(e,t){let i=0;switch(e){case w.MarkLocation.AboveBar:case w.MarkLocation.Bottom:i=-t;break;case w.MarkLocation.BelowBar:case w.MarkLocation.Top:i=t}return(0,r.ensureNotNull)(this._priceScale()).isInverted()&&(i*=-1),i}_calculateShapeHeight(e,t){let i=e;switch(t){case M.PlotSymbolSize.Tiny:i=.3*e;break;case M.PlotSymbolSize.Small:i=.6*e;break;case M.PlotSymbolSize.Normal:i=e;break;case M.PlotSymbolSize.Large:i=1.5*e;break;case M.PlotSymbolSize.Huge:i=2*e}return"number"==typeof t&&t>0&&(i=t),i}_hiLoPlots(){let e,t;let i=null;switch(this._series.properties().childs().style.value()){case 2:i="lineStyle";break;case 14:i="lineWithMarkersStyle";break;case 15:i="steplineStyle";break;case 3:i="areaStyle"}return i?(e=this._series.properties().childs()[i].childs().priceSource.value(),t=e):(e="high",t="low"),{hiPlot:e,loPlot:t}}_getLocationPrice(e,t,i){const s=Math.min(e+i,(0,r.ensureNotNull)(this._series.data().last()).index);return this._getSeriesVal(t,s)}}class Le extends Ae{_updateRenderer(e,t){const i=this._study.properties().childs().styles.childs()[this._plotName].childs(),s=this._model.timeScale(),o={},n=this._getTranspValue(),r=s.barSpacing();let a;a=this._plotStyleInfo.size?this._calculateShapeHeight(25,this._plotStyleInfo.size):Math.round(r/2),a=Math.max(a,1);const l=i.location.value(),c=(0,_.generateColor)(i.color.value(),n),h=n>19?n-10:0,d=this._calculateVerticalOffset(l,Math.round(1.5*a));o.barSpacing=r,o.items=this.items(),o.color=c,o.borderColor=(0,_.generateColor)(i.color.value(),h),o.height=a,o.vertOffset=d,o.visibleItemsRange={startItemIndex:e,endItemIndex:t};const u=i.plottype.value(),p=X.plotShapesData[u],m=this._plotStyleInfo.text;if(void 0!==m&&""!==m.trim()){let e=m.replace(/\\n/gm,"\n");e=(0,Y.cleanButAmpersand)(e,!0),o.text=e,o.fontSize=12;const t=i.textColor?i.textColor.value():void 0;o.textColor=t?(0,_.generateColor)(t,n):c}
if(this._renderer&&this._shapesRenderer&&this._selectionRenderer)this._shapesRenderer.setData(o),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData?(this._selectionData.vertOffset=d,this._selectionRenderer.setData(this._selectionData)):this._selectionRenderer.setData(null);else{const e=new z.CompositeRenderer;this._shapesRenderer=super._createRenderer(p.paneRendererClass,o),e.append(this._shapesRenderer),this._selectionRenderer=new Z.SelectionRenderer(this._selectionData??void 0),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData?this._selectionData.vertOffset=d:this._selectionRenderer.setData(null),e.append(this._selectionRenderer),this._renderer=e}}}var ke,De=i(87795),Ee=i.n(De),Be=i(61993),Ve=i(2844);!function(e){e[e.SimplifiedPaintingMaxFontSize=4]="SimplifiedPaintingMaxFontSize"}(ke||(ke={}));class Re extends fe{constructor(e,t){super(null,t),this._textWidthCache=new Ve.TextWidthCache,this._fontSizeEnsured=0,this._font="",this._ch="",null!==e&&this.setData(e)}setData(e){super.setData(e),this._fontSizeEnsured=(0,r.ensureDefined)(this._height),this._font=(0,le.makeFont)(this._fontSizeEnsured,e.fontFamily||me.CHART_FONT_FAMILY);const t=e.char.slice(0,40);this._ch=Ee()(t)[0]||" "}hitTest(e){const t=(0,Be.interactionTolerance)().series+this._fontSizeEnsured/2;for(const i of this._items){if(new ie.Point(i.center,i.y+i.vertOffset).subtract(e).length()<=t)return new re.HitTestResult(re.HitTarget.Regular)}return null}_drawItemShape(e,t){const i=t.center,s=t.vertOffset>0?1:-1,o=Math.trunc(this._fontSizeEnsured/6),n=t.y+t.vertOffset-s*Math.round(this._fontSizeEnsured/2)+(s>0?o:-this._fontSizeEnsured);let r;r=t.style&&void 0!==t.style.color?t.style.color:this._color;const{context:a,horizontalPixelRatio:l,verticalPixelRatio:c}=e;a.font!==this._font&&(a.font=this._font);const h=this._textWidthCache.measureText(a,this._ch);if(this._fontSizeEnsured<=4/l){a.save();const e=Math.max(1,Math.floor(l));let s=Math.max(1,Math.floor(h*l));s%2!=e%2&&(s+=s>1?-1:1);const o=Math.round(n*c)+(t.vertOffset>=0?0:-s);return a.fillStyle=r,a.fillRect(Math.round(i*l)+(l%2?.5:0)-s/2,o,s,s),void a.restore()}(0,he.drawScaled)(a,l,c,(()=>{a.fillStyle=r,a.textAlign="center",a.textBaseline="top",a.fillText(this._ch,i,n)}))}_startPath(e,t,i){}_endPath(e){}}class Ne extends Ae{constructor(){super(...arguments),this._charRenderer=new Re(null)}_updateRenderer(e,t){const i=this._getTranspValue(),s=this._model.timeScale().barSpacing();let o;const n=this._study.properties().childs().styles.childs()[this._plotName].childs();o=this._plotStyleInfo.size?this._calculateShapeHeight(50,this._plotStyleInfo.size):Math.round(s);const a=n.location.value(),l=(0,_.generateColor)(n.color.value(),i),c=this._calculateVerticalOffset(a,o),h={items:this.items(),barSpacing:s,char:(0,r.ensureDefined)(n.char?.value()??this._plotStyleInfo.char),height:o,vertOffset:c,color:l,visibleItemsRange:{startItemIndex:e,endItemIndex:t}},d=this._plotStyleInfo.text;if(void 0!==d&&""!==d.trim()){
let e=d.replace(/\\n/gm,"\n");e=(0,Y.cleanButAmpersand)(e,!0),h.text=e,h.fontSize=12;const t=n.textColor?n.textColor.value():void 0;h.textColor=t?(0,_.generateColor)(t,i):l}this._charRenderer.setData(h);const u=new z.CompositeRenderer;u.append(this._charRenderer),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&null!==this._selectionData&&(this._selectionData.vertOffset=c,u.append(new Z.SelectionRenderer(this._selectionData))),this._renderer=u}}var Oe=i(24377);class Fe{constructor(e,t,i,s,o){this.left=NaN,this.right=NaN,this.height=NaN,this.center=e,this.y=t,this.origHeight=i,this.isUp=s,this.origPrices=o,this.timePointIndex=e,this.style={}}}function We(e){return Math.round(e/4)}function He(e){return Math.round(e/2)}class ze extends U.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){const t=this._data,i=He(t.barSpacing),s=Math.round(i/2),o=Math.round(i),n=We(t.barSpacing),r=t.visibleItemsRange?.startItemIndex??0,a=t.visibleItemsRange?.endItemIndex??t.items.length;if(r>=a)return null;for(const i of t.items.slice(r,a)){if(!i)continue;if(!Number.isFinite(i.center)||!Number.isFinite(i.y))continue;const t=Math.abs(i.height),r=i.isUp?-1:1,a=t+o,l=i.y-r*n,c=l-r*a,h=i.center-s,d=i.center+s;if(h<e.x&&e.x<d&&(i.isUp?l<e.y&&e.y<c:c<e.y&&e.y<l))return new re.HitTestResult(re.HitTarget.Regular)}return null}_drawImpl(e){const{horizontalPixelRatio:t,verticalPixelRatio:i,context:s}=e,o=this._data,n=He(o.barSpacing),r=We(o.barSpacing),a=n<4,l=Math.max(n/2,1),c=(0,J.ceiledEven)(n*t),h=c/2,d=Math.round(n*i);s.lineCap="butt",s.lineWidth=Math.max(1,Math.floor(t));const u=s.lineWidth%2?.5:0,_=o.visibleItemsRange?.startItemIndex??0,p=o.visibleItemsRange?.endItemIndex??o.items.length;if(!(_>=p))for(const e of o.items.slice(_,p)){if(!Number.isFinite(e.center)||!Number.isFinite(e.y))continue;const n=e.isUp?-1:1,_=Math.round(Math.abs(e.height)*i),p=Math.round(e.center*t)+u,m=Math.round((e.y-n*r)*i)+u;s.beginPath(),s.translate(p,m);const g=(e.style&&e.style.color)??(e.isUp?o.colorup:o.colordown);a?(s.moveTo(0,0),s.lineTo(-h,-h*n),s.moveTo(0,0),s.lineTo(h,-h*n),s.moveTo(0,0),s.lineTo(0,-_*n),s.moveTo(-h,-_*n),s.lineTo(h,-_*n),s.lineWidth=l,s.strokeStyle=g,s.stroke()):(s.moveTo(0,0),_<d?(s.lineTo(c,-_*n),s.lineTo(-c,-_*n)):(s.lineTo(c,-d*n),s.lineTo(h,-d*n),s.lineTo(h,-_*n),s.lineTo(-h,-_*n),s.lineTo(-h,-d*n),s.lineTo(-c,-d*n)),s.lineTo(0,0),s.strokeStyle=e.isUp?o.colorBorderUp:o.colorBorderDown,s.stroke(),s.fillStyle=g,s.fill()),s.translate(-p,-m)}}}class Ue extends Ae{_updateRenderer(e,t){const i=this._study.properties().childs().styles.childs()[this._plotName].childs(),s=(0,J.clamp)(this._getTranspValue(),0,100),o=this._model.timeScale().barSpacing(),n=(0,_.generateColor)(i.colorup.value(),s),r=(0,_.generateColor)(i.colordown.value(),s),a=(0,Oe.parseRgba)(n),l=a?100*(1-a[3]):0,c=(0,Oe.parseRgba)(r),h=c?100*(1-c[3]):0,d={items:this._items,barSpacing:o,colorup:n,colordown:r,colorBorderUp:(0,_.generateColor)("#000000",l),colorBorderDown:(0,_.generateColor)("#000000",h),
minHeight:this._plotStyleInfo.minHeight,visibleItemsRange:{startItemIndex:e,endItemIndex:t}};this._updateItemsHeights(d);const u=new z.CompositeRenderer;u.append(new ze(d)),this._model.selection().isSelected(this._study)&&null!==this._selectionData&&u.append(new Z.SelectionRenderer({...this._selectionData,barSpacing:o,withOutline:!1})),this._renderer=u}_fillItemWithPointStyle(e,t,i){const s=(0,r.ensureDefined)(e.style);e.isUp?void 0!==t.colors[5]?s.color=(0,_.generateColor)((0,r.ensureDefined)(t.colors[5]),i):s.color=(0,_.generateColor)(this._study.properties().childs().styles.childs()[this._plotName].childs().colorup.value(),i):void 0!==t.colors[6]?s.color=(0,_.generateColor)((0,r.ensureDefined)(t.colors[6]),i):s.color=(0,_.generateColor)(this._study.properties().childs().styles.childs()[this._plotName].childs().colordown.value(),i)}_getValueForUpdating(e){const t=e.value[this._plotIndex+1];if(!t)return null;const i=e.index,s=t>0,{hiPlot:o,loPlot:n}=this._hiLoPlots(),a=this._study.offset(this._plotName),l=Math.min(i+a,(0,r.ensureNotNull)(this._series.data().last()).index);if(s){const e=this._getSeriesVal(n,l);if(null!==e)return e}else{const e=this._getSeriesVal(o,l);if(null!==e)return e}return null}_updateItem(e,t){const i=this._getValueForUpdating(e),s=e.value[this._plotIndex+1]>0;return this._items[t].origPrices.price=i??NaN,this._items[t].isUp=s,t+1}_createItem(e,t,i,s,o){const n={center:NaN,y:NaN,origPrices:{price:NaN,timePointIndex:NaN},origHeight:NaN,timePointIndex:e+o};if(!t)return n;const a=Math.min(e+o,(0,r.ensureNotNull)(this._series.data().last()).index),l=t>0;let c;if(l){const e=this._getSeriesVal(s,a);if(null===e)return n;c=e}else{const e=this._getSeriesVal(i,a);if(null===e)return n;c=e}return new Fe(e+o,c,t,l,{price:c,timePointIndex:e+o})}_dependsOnSeriesData(){return!0}_convertItemsToCoordinates(e,t,i,s){this._convertItemsToCoordinatesImpl(e,t,i,s)}_createSelectionDataPoint(e,t,i,s){const o=this._model.timeScale().barSpacing(),n=We(o),r=function(e){return He(e)}(o),a=super._createSelectionDataPoint(e,t,i,s),l=this._items[(0,xe.lowerbound)(this._items,t,((e,t)=>e.timePointIndex<t))];if(!l)return a;const c=l.isUp?1:-1;return{...a,point:a.point.add((0,ie.point)(0,c*(n+r)))}}_updateItemsHeights(e){const t=this._study.properties().childs().styles.childs();let i=Math.abs((0,r.ensureDefined)(t[this._plotName].childs().minHeight?.value()??this._plotStyleInfo.minHeight)),s=Math.abs((0,r.ensureDefined)(t[this._plotName].childs().maxHeight?.value()??this._plotStyleInfo.maxHeight));if(i>s){const e=i;i=s,s=e}const o=this._items,n=e.visibleItemsRange?.startItemIndex??0,a=(e.visibleItemsRange?.endItemIndex??o.length)-1;let l=0;for(let e=n;e<=a;e++){const t=o[e],i=Math.abs(t.origHeight);i>l&&(l=i)}const c=(s-i)/l;for(let e=n;e<=a;e++){const t=o[e],s=Math.abs(t.origHeight);t.height=s*c+i}}}var Ge=i(59432);class je extends q.StudyForceOverlayPlotView{constructor(e,t,i,s){super(t,i,s),this._bars=[],this._invalidated=!1,this._isMarkersEnabled=H.enabled("source_selection_markers"),this._selectionData=null,
this._ohlcPlotIndexes=new Map,this._study=e,this._isMarkersEnabled=H.enabled("source_selection_markers"),this._colorProvider=(0,j.createStudyPlotColorProvider)(e.metaInfo(),e.properties(),s),this._selectionIndexer=new Q.SelectionIndexes(i.timeScale());const o=this._study.metaInfo().plots;for(let e=0;e<o.length;e++){const t=o[e];"target"in t&&(t.target===this._plotName&&((0,M.isOhlcOpenPlot)(t)&&this._ohlcPlotIndexes.set(1,e),(0,M.isOhlcHighPlot)(t)&&this._ohlcPlotIndexes.set(2,e),(0,M.isOhlcLowPlot)(t)&&this._ohlcPlotIndexes.set(3,e),(0,M.isOhlcClosePlot)(t)&&this._ohlcPlotIndexes.set(4,e)))}}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}items(){return this._bars}_updateImpl(){this._bars.length=0;const e=this._priceScale();if(this._model.timeScale().isEmpty()||null===e||e.isEmpty())return;const t=this._model.timeScale().visibleBarsStrictRange();if(null===t)return;let i=this._series.nearestIndex(t.firstBar(),b.PlotRowSearchMode.NearestRight);const s=this._series.nearestIndex(t.lastBar(),b.PlotRowSearchMode.NearestLeft);if(void 0===i||void 0===s)return;const o=this._study.getMinFirstBarIndexForPlot(this._plotName);if(o>s)return;i=Math.max(o,i);const n=this._study.data(),a=this._study.firstValue(void 0,this.isForceOverlay());if(null===a)return;const l=n.rangeIterator(i,s),c=(0,r.ensureDefined)(this._study.properties().childs().ohlcPlots).childs()[this._plotName].childs(),h=new Map,d=(e,t)=>{const i=e+"@"+t;if(!h.has(i)){const s=(0,_.generateColor)(e,t);return h.set(i,s),s}return h.get(i)},u=(0,te.createEmptyStyle)();for(const e of l){let t=e.index;const i=e.value;t=Math.floor(t);let s=!0;const o=new Map;for(let e=1;e<=4;++e){const t=this._ohlcPlotIndexes.get(e);if(void 0===t){s=!1;break}const n=i[t+1];if(null==n){s=!1;break}o.set(e,n)}if(!s)continue;const n=(0,r.ensureDefined)(o.get(1)),a=(0,r.ensureDefined)(o.get(4)),l=(0,r.ensureDefined)(o.get(2)),h=(0,r.ensureDefined)(o.get(3)),_=Math.max(n,l,h,a),p=Math.min(n,l,h,a);let m=(0,r.ensureDefined)(d(c.color.value(),0));const g=this._colorProvider.getPlotPointStyle(i,u);void 0!==g.colors[0]&&(m=(0,r.ensureDefined)(g.colors[0]));const f={open:n,high:_,low:p,close:a,color:m,wickColor:g.colors[4],borderColor:g.colors[3],hollow:null,center:NaN,left:NaN,right:NaN,timePointIndex:Math.round(t)};this._bars.push(f)}if(e.barPricesToCoordinates(this._bars,a),this._model.timeScale().fillBarBorders(this._bars),this._model.selection().isSelected(this._study)){const t=this._selectionIndexer.indexes();this._selectionData={points:[],hittestResult:re.HitTarget.Regular,bgColors:[],visible:!0,barSpacing:this._model.timeScale().barSpacing()};const i=(0,r.ensureNotNull)(this._model.paneForSource(this._study)).height(),s=(0,r.ensureDefined)(this._ohlcPlotIndexes.get(4));for(let o=0;o<t.length;o++){const n=t[o],r=this._study.data().valueAt(n);if(null===r)continue;const l=r[s+1];if(null==l)continue;const c=this._model.timeScale().indexToCoordinate(Math.floor(n)),h=e.priceToCoordinate(l,a);this._selectionData.points.push({point:new ie.Point(c,h)}),
this._selectionData.bgColors.push(this._model.backgroundColorAtYPercentFromTop(h/i))}}else this._selectionIndexer.clear()}_isOHLCPlotVisible(){return this._study.isPlotVisibleAt(this._plotName,1)}}class qe extends je{renderer(){if(!this._isOHLCPlotVisible())return null;this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e={bars:this._bars,dontDrawOpen:this._series.properties().childs().barStyle.childs().dontDrawOpen.value(),thinBars:this._series.properties().childs().barStyle.childs().thinBars.value()},t=new z.CompositeRenderer;return t.append(new Ge.PaneRendererBars(e)),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&this._selectionData&&t.append(new Z.SelectionRenderer(this._selectionData)),t}}var $e=i(25201);class Ke extends je{renderer(){if(!this._isOHLCPlotVisible())return null;const e=this._priceScale();if(!e||e.isEmpty())return null;this._invalidated&&(this._updateImpl(),this._invalidated=!1);const t=(0,r.ensureDefined)(this._study.properties().childs().ohlcPlots).childs()[this._plotName].childs(),i=this._model.timeScale().barSpacing(),s={bars:this._bars,barSpacing:i,wickVisible:t.drawWick.value(),bodyVisible:!0,borderVisible:t.drawBorder.value(),barWidth:(0,Be.optimalBarWidth)(i),borderColor:t.borderColor.value(),wickColor:t.wickColor.value(),isPriceScaleInverted:e.isInverted()},o=new z.CompositeRenderer;return o.append(new $e.PaneRendererCandles(s)),this._model.selection().isSelected(this._study)&&this._isMarkersEnabled&&this._selectionData&&o.append(new Z.SelectionRenderer(this._selectionData)),o}}var Ye=i(65458),Ze=i(78198),Xe=i(52397),Je=i(51056);class Qe extends Xe.HorizontalLinePaneView{constructor(e,t){super(),this._lineRendererData.linestyle=Je.LINESTYLE_DOTTED,this._study=e,this._plotName=t}_updateImpl(){this._lineRendererData.visible=!1;const e=this._study.properties().childs().styles.childs()[this._plotName].childs();if(!e.trackPrice.value()||!this._study.isPlotVisibleAt(this._plotName,1))return;const t=this._study.lastValueData(this._plotName,!0);t.noData||(this._lineRendererData.visible=!0,this._lineRendererData.y=t.coordinate,this._lineRendererData.color=t.color,this._lineRendererData.linewidth=e.linewidth.value())}}var et=i(46463),tt=i(31599),it=i(47806);const st={type:0,color:"transparent"};class ot extends it.AbstractFilledAreaPaneView{constructor(e,t,i,s){super(e,t,i),this._palettesInfo={},this._gradientPropsStateCache=null,this._rgbaFromInteger=(0,tt.rgbaFromIntegerCached)();const o=this._source.metaInfo();this._isRGB=Boolean(o.isRGB),this._isHlineFill="hline_hline"===i.type,(0,r.assert)(this._isHlineFill||"plot_plot"===i.type,"Wrong filledArea type: "+i.type),this._isHlineFill&&this._initBandIndexes(i.objAId,i.objBId),this._fillMetaInfo=i,this._fillStyleProps=s,this._gradientFillType=s.hasChild("fillType")&&"gradient"===s.childs().fillType?.value(),this._gradientStaticState={color1:i.topColor,color2:i.bottomColor,value1:i.topValue,value2:i.bottomValue},
this._hasAllGradientRequiredProps=this._gradientFillType&&(void 0!==this._gradientStaticState.color1||s.hasChild("topColor")||void 0!==this._gradientStaticState.color2||s.hasChild("bottomColor"))&&(void 0!==this._gradientStaticState.value1||s.hasChild("topValue"))&&(void 0!==this._gradientStaticState.value2||s.hasChild("bottomValue"));const n=()=>this._colorPlotIndex=this._colorPlotIndex??{type:1};for(let t=0;t<o.plots.length;++t){const s=o.plots[t];if(((0,M.isColorerPlot)(s)||(0,M.isDataPlot)(s))&&s.target===i.id){if((0,M.isColorerPlot)(s)){let i;void 0!==s.targetField?"topColor"===s.targetField?(n().colorIndexOrRgba1=t,i="color1"):"bottomColor"===s.targetField&&(n().colorIndexOrRgba2=t,i="color2"):this._colorPlotIndex={type:0,colorIndexOrRgba:t},(0,M.isPaletteColorerPlot)(s)&&(this._palettesInfo[i??"color"]={map:(0,r.ensureDefined)((0,r.ensureDefined)(o.palettes)[s.palette]?.valToIndex),values:e.properties().palettes[s.palette].colors})}else(0,M.isDataPlot)(s)&&("topValue"===s.targetField?n().valueIndex1=t:"bottomValue"===s.targetField&&(n().valueIndex2=t));if(0===this._colorPlotIndex?.type)break}}}update(e){super.update(e),this._gradientPropsStateCache=null}isForceOverlay(){return!!this._source.metaInfo().isPlotForceOverlay(this._plotAId())}_firstValue(){const e=this.isForceOverlay();return this._source.firstValue(void 0,e)}_minFirstBarIndex(){return this._source.getMinFirstBarIndexForPlot(this._fillMetaInfo.id)}_getColorByPlotValue(e){if(0===e.type){let t;if(null==e.colorIndexOrRgba)return null;if(this._isRGB)t=this._rgbaFromInteger(e.colorIndexOrRgba);else{const i=(0,r.ensureDefined)(this._palettesInfo.color),s=(0,r.ensureDefined)(i.map[e.colorIndexOrRgba]);t=i.values[s]?.childs().color.value()}return{type:0,color:t}}const t=this._gradientColorPropsState();let i,s;if(this._isRGB)null!=e.colorIndexOrRgba1&&(i=this._rgbaFromInteger(e.colorIndexOrRgba1)),null!=e.colorIndexOrRgba2&&(s=this._rgbaFromInteger(e.colorIndexOrRgba2));else{if(null!=e.colorIndexOrRgba1){const t=(0,r.ensureDefined)(this._palettesInfo.color1);i=t.values[(0,r.ensureDefined)(t.map[e.colorIndexOrRgba1])].childs().color.value()}if(null!=e.colorIndexOrRgba2){const t=(0,r.ensureDefined)(this._palettesInfo.color2);s=t.values[(0,r.ensureDefined)(t.map[e.colorIndexOrRgba2])].childs().color.value()}}const o=e.value1??t.value1,n=e.value2??t.value2;return i=i??t.color1,s=s??t.color2,void 0===o||void 0===n||void 0===i&&void 0===s?null:{type:1,color1:i,color2:s,value1:o,value2:n,coordinate1:NaN,coordinate2:NaN}}_plotAId(){return this._fillMetaInfo.objAId}_plotBId(){return this._fillMetaInfo.objBId}_commonColor(){const e=this._fillStyleProps.childs();if(this._gradientFillType){if(!this._hasAllGradientRequiredProps)return st;const e=this._gradientColorPropsState();return{type:1,color1:e.color1,color2:e.color2,value1:e.value1,value2:e.value2,coordinate1:NaN,coordinate2:NaN}}return{type:0,color:e.color.value()}}_transparency(){return this._fillStyleProps.childs().transparency?.value()??0}_visible(){return this._fillStyleProps.childs().visible.value()}
_priceScale(){return this.isForceOverlay()?this._model.mainSeries().priceScale():this._source.priceScale()}_initBandIndexes(e,t){this._bandAKey=null,this._bandBKey=null;const i=this._source.metaInfo().bands;if(void 0!==i)for(let s=0;s<i.length;++s){const o=i[s];null!==this._bandAKey||o.id!==e?null===this._bandBKey&&o.id===t&&(this._bandBKey=s):this._bandAKey=s}}_gradientColorPropsState(){if(null===this._gradientPropsStateCache){const e=this._fillStyleProps.state();this._gradientPropsStateCache={color1:this._gradientStaticState.color1??e.topColor,color2:this._gradientStaticState.color2??e.bottomColor,value1:this._gradientStaticState.value1??e.topValue,value2:this._gradientStaticState.value2??e.bottomValue}}return this._gradientPropsStateCache}}var nt=i(22839),rt=i(50600);class at{constructor(e,t){this._invalidated=!0,this._lineRenderer=new rt.HorizontalLineRenderer,this._source=t,this._points=[new ie.Point(-1,-1)],this._invalidated=!0,this._properties=e}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}renderer(){this._invalidated&&(this._updateImpl(),this._invalidated=!1);const e={y:this._points[0].y,color:this._properties.childs().color.value(),linewidth:this._properties.childs().linewidth.value(),linestyle:this._properties.childs().linestyle.value()};return this._lineRenderer.setData(e),this._lineRenderer}_updateImpl(){const e=this._source.priceScale();if(!e||e.isEmpty())return void(this._points[0]=new ie.Point(-1,-1));const t=this._properties.childs().value.value(),i=this._source.firstValue(),s=(0,R.isNumber)(t)&&null!==i?e.priceToCoordinate(t,i):NaN;this._points[0]=new ie.Point(-1,s)}}var lt=i(75919);class ct extends lt.MediaCoordinatesPaneRenderer{constructor(){super(),this._data=null,this._data=null}setData(e=null){this._data=e}hitTest(){return null}_drawImpl(e){if(null===this._data||0===this._data.points.length)return;const t=e.context,i=e.mediaSize.width;if(this._data.gradient){const e=t.createLinearGradient(0,this._data.coordinate1,0,this._data.coordinate2);e.addColorStop(0,this._data.backColor1??"transparent"),e.addColorStop(1,this._data.backColor2??"transparent"),t.fillStyle=e}else t.fillStyle=this._data.backcolor;const s=Math.min(this._data.points[0],this._data.points[1]),o=Math.max(this._data.points[0],this._data.points[1]);t.fillRect(0,s,i,o-s)}}class ht{constructor(e){this._bandBgRenderer=new ct,this._invalidated=!0,this._source=e}update(e){"hover-change"!==e.type&&(this._invalidated=!0)}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._bandBgRenderer}_updateImpl(){this._bandBgRenderer.setData(null);const e=this._source.properties().childs(),t=e.bands;if(t.childCount()<2)return;const i=e.bandsBackground;if(!i?.childs().fillBackground.value())return;const s=t[0].childs(),o=t[1].childs(),n=this._source.priceScale(),a=this._source.firstValue();if(!n||n.isEmpty()||null===a)return;const l=[n.priceToCoordinate(s.value.value(),a),n.priceToCoordinate(o.value.value(),a)],c=(0,r.ensureDefined)(e.bandsBackground).childs(),h=(0,J.clamp)(c.transparency?.value()??0,0,100)
;this._bandBgRenderer.setData({gradient:!1,points:l,backcolor:(0,_.generateColor)(c.backgroundColor.value(),h)})}}class dt{constructor(e,t,i){this._bandBgRenderer=new ct,this._bandAKey=null,this._bandBKey=null,this._invalidated=!0,this._source=e,(0,r.assert)("hline_hline"===t.type,"Wrong filledArea type: "+t.type),this._initBandIndexes(t.objAId,t.objBId),this._fillStyleProps=i,this._bandBgRenderer=new ct,this._gradientFillType=i.hasChild("fillType")&&"gradient"===i.childs().fillType?.value(),this._gradientStaticState={color1:t.topColor,color2:t.bottomColor,value1:t.topValue,value2:t.bottomValue}}update(){this._invalidated=!0}renderer(){return this._invalidated&&(this._updateImpl(),this._invalidated=!1),this._bandBgRenderer}_updateImpl(){if(this._bandBgRenderer.setData(null),!this._fillStyleProps.childs().visible.value())return;if(null===this._bandAKey||null===this._bandBKey)return;const e=(0,r.ensureDefined)(this._source.properties().childs().bands),t=e.childs()[this._bandAKey].childs(),i=e.childs()[this._bandBKey].childs(),s=this._source.priceScale(),o=this._source.firstValue();if(!s||s.isEmpty()||null===o)return;const n=[s.priceToCoordinate(t.value.value(),o),s.priceToCoordinate(i.value.value(),o)],a=(0,J.clamp)(this._fillStyleProps.childs().transparency?.value()??0,0,100);let l;const c=this._fillStyleProps.childs();if(this._gradientFillType){const e=this._gradientStaticState,t=c,i=e.value1??t.topValue?.value(),r=e.value2??t.bottomValue?.value();if(void 0===i||void 0===r)return;const h=e.color1??t.topColor?.value(),d=e.color2??t.bottomColor?.value();if(void 0===h&&void 0===d)return;l={gradient:!0,points:n,backColor1:h&&(0,_.generateColor)(h,a),backColor2:d&&(0,_.generateColor)(d,a),coordinate1:s.priceToCoordinate(i,o),coordinate2:s.priceToCoordinate(r,o)}}else l={gradient:!1,points:n,backcolor:(0,_.generateColor)(c.color.value(),a)};this._bandBgRenderer.setData(l)}_initBandIndexes(e,t){this._bandAKey=null,this._bandBKey=null;(0,r.ensureDefined)(this._source.metaInfo().bands).forEach(((i,s)=>{null===this._bandAKey&&i.id===e&&(this._bandAKey=s),null===this._bandBKey&&i.id===t&&(this._bandBKey=s)}))}}var ut=i(678),_t=i(10892),pt=i(62288),mt=i(64147),gt=(i(88960),i(68805)),ft=i(50788),yt=i(16227),vt=i(37626),St=i(96e3);class bt extends St.AbstractBarColorer{constructor(e,t){super(),this._rgbaFromInteger=(0,tt.rgbaFromIntegerCached)(),this._study=e,this._plotIndex=t}applyBarStyle(e,t,i,s){if(t)return i;const o=this._study.properties().childs();if(!o.visible.value())return i;const n=this._study.metaInfo(),a=this._study.data();if(!a||0===a.size())return i;const l=n.plots[this._plotIndex],c=this._getOffset();if(this._study.getMinFirstBarIndexForPlot(l.id)>e+c)return i;if(0===o.styles.childs()[l.id].childs().display.value())return i;const h=a.valueAt(e-c);if(null===h)return i;let d=h[this._plotIndex+1];if(null==d)return i;if(d=Math.round(d),n.isRGB)i.barColor=this._rgbaFromInteger(d),i.upColor=i.barColor,i.downColor=i.barColor;else{const e=n.plots[this._plotIndex];if("palette"in e){
const t=e.palette,s=o.palettes.childs()[t],a=(0,r.ensureDefined)(n.palettes?.[t]),l=a.valToIndex?(0,r.ensureDefined)(a.valToIndex[d]):d,c=s.childs().colors.childs()[l].childs().color.value();i.barColor=c,i.upColor=c,i.downColor=c}}return i}firstColoredBar(e){let t=e;for(const i of this._backColorers)t=Math.min(t,i.firstColoredBar(e)??1/0);const i=this._getOffset();t=Math.min(t,e+i);const s=this._getBars().firstIndex(),o=Math.max(t,s??-1/0),n=this._study.metaInfo().plots[this._plotIndex];return Math.max(this._study.getMinFirstBarIndexForPlot(n.id),o)}_getBars(){return this._study.series().bars()}_getOffset(){const e=this._study.metaInfo().plots[this._plotIndex];return this._study.offset(e.id)}}var wt=i(76422),Ct=i(725),Pt=i(82349);class Tt extends Ye.PanePriceAxisView{constructor(e,t,i,s){super(e,t,i),this._dataSource=t,this._isForceOverlay=t.metaInfo().isPlotForceOverlay(s)}_position(){const e=this._isForceOverlay?this._chartModel.mainPane():this._chartModel.paneForSource(this._dataSource);if(null===e)return null;const t=this._isForceOverlay?this._chartModel.mainSeries().priceScale():this._dataSource.priceScale();if(null===t)return null;let i=e.priceScalePosition(t);return"overlay"===i&&(i=e.priceScalePosition(e.defaultPriceScale())),"overlay"===i?null:i}}var xt=i(74079),It=i(7927),Mt=i(29137),At=i(24526);const Lt=(0,l.getLogger)("Chart.Study"),kt=a.t(null,void 0,i(14285)),Dt=!1;var Et,Bt;!function(e){e.PaneViews="study-pane-views"}(Et||(Et={})),function(e){e[e.DefaultPriceScale=100]="DefaultPriceScale"}(Bt||(Bt={}));const Vt={symbolsForDisplay:!1,symbolsForChartApi:!0,skipHiddenInputs:!1,skipFakeInputs:!1,skipBooleanInputs:H.enabled("dont_show_boolean_study_arguments"),asObject:!0,skippedGroups:[],skippedInputs:[],noExchanges:!1,noResolution:!1,keepOptionalSymbolsEmpty:!1,skipColorInputs:!1,skipTimeInputs:!1,skipOptionalEmptySymbolInputs:!1,skipTextareaInputs:!1,priceInputsForDisplay:!1},Rt=H.enabled("study_symbol_ticker_description"),Nt=H.enabled("hide_main_series_symbol_from_indicator_legend"),Ot=H.enabled("datasource_copypaste"),Ft=H.enabled("hide_unresolved_symbols_in_legend");function Wt(e,t){const i=e.plots[t];if(!i||!(0,M.isOhlcPlot)(i))return!1;const s=i.target,o=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],r=e.ohlcPlots&&e.ohlcPlots[s];return o&&(0,M.isOhlcPlotStyleBars)(o)||n&&(0,M.isOhlcPlotStyleBars)(n)||!!r&&(0,M.isOhlcPlotStyleBars)(r)}function Ht(e,t){const i=e.plots[t];if(!i||!(0,M.isOhlcPlot)(i))return!1;const s=i.target,o=e.defaults.styles&&e.defaults.styles[s],n=e.defaults.ohlcPlots&&e.defaults.ohlcPlots[s],r=e.ohlcPlots&&e.ohlcPlots[s];return o&&(0,M.isOhlcPlotStyleCandles)(o)||n&&(0,M.isOhlcPlotStyleCandles)(n)||!!r&&(0,M.isOhlcPlotStyleCandles)(r)}function zt(e,t){(0,r.assert)(void 0!==e,"zOrder must be defined"),(0,r.assert)(!t.has(e),"zOrder must be unique")}function Ut(e,t){return e.plots.some((e=>((0,M.isColorerPlot)(e)||(0,M.isDataPlot)(e))&&e.target===t))}function Gt(e,t,i){let s=0,o=0;return Math.sign(o)-Math.sign(s)}function jt(e){
return"inherit"===e.type&&(e.type="price"),e}function qt(e,t,i,s){{const t=(0,R.isNumber)(s)?s:void 0,o=At.customFormatters?.studyFormatterFactory?.(e,i,t)??null;if(null!==o)return o}if(null!==t)switch(e.type){case"inherit":case"price":return new Ct.PriceFormatter({priceScale:t});case"volume":return(0,xt.getVolumeFormatter)(Math.log10(t));case"percent":return(0,xt.getPercentageFormatter)(Math.log10(t))}if("inherit"===e.type)return null;const o=(0,R.isNumber)(e.precision)?Math.pow(10,e.precision):void 0;switch(e.type){case"price":return new Ct.PriceFormatter({priceScale:o});case"volume":{let t=e.precision;return void 0===t&&(t=i&&(0,R.isNumber)(i.volume_precision)?i.volume_precision:0),(0,xt.getVolumeFormatter)(t)}case"percent":return(0,xt.getPercentageFormatter)(void 0===o?void 0:Math.log10(o));default:return Lt.logWarn(`Unsupported format type: ${e.type}`),null}}const $t=new Set(["first_visible_bar_time","last_visible_bar_time","subscribeRealtime"]);class Kt extends g.PriceDataSource{constructor(e,t,i,s,o){super(e),this._onStart=new u.Delegate,this._restarting=!1,this._paneViews=[],this._forceOverlaysPaneViews=[],this._legendView=null,this._priceAxisViews=[],this._forceOverlayPriceAxisViews=[],this._priceAxisViewsBase=[],this._resolvedSymbols={},this._resolvedSymbolsByInput={},this._priceLinesAxisViews=[],this._labelPaneViews=[],this._forceOverlayLabelPaneViews=[],this._ownFirstValue=null,this._formatter=null,this._defaultFormatter=null,this._dataUpdated=new u.Delegate,this._currencySourceSymbolInputProperty=null,this._onHibernationStateChange=new u.Delegate,this._symbolsResolved=new u.Delegate,this._statusChanged=new u.Delegate,this._inputsAnchorsPaneView=null,this._inputsLinesPaneView=null,this._inputsTimeAxisPaneViews=[],this._inputsPriceAxisPaneViews=[],this._sources=[],this._status={type:ut.StudyStatusType.Undefined},this._compileActiveStatus=null,this._compileErrorStatus=null,this._wasCompletedBefore=!1,this._studyId=null,this._isSubscribedToSessionId=!1,this._titleStrCache={},this._titleInPartsCache={},this._children=[],this._graphicsPriceAxisViews=[],this._plotOffsets={},this._ongoingDataUpdate=Promise.resolve(),this._studyModified=!1,this._tagsChanged=new u.Delegate,this._studyName="",this._turnaround="st0",this._pendingResolveSymbols=new Map,this._onIsActualIntervalChange=new u.Delegate,this._childStudyByRebind=new u.Delegate,this._lastNonEmptyPlotRowCache={},this._startMovingPoint=null,this._processHibernateBound=this.processHibernate.bind(this,1),this._maxOffset=new mt.WatchedValue(0),this._currencySourceSymbolInfo=null,this._graphicsPriceRangeGroups=null,this._graphicsViewsReady=!1,this._visibleTimeRangeInputs=null,this._turnaroundCounter=0,this._deferredPinePatchProps=!1,this._propertiesPatched=Promise.resolve(),this._aboutToBeDestroyed=new u.Delegate,this._definitionsViewModel=null,this._plotFormatters=new Map,this._showPineVersionInStatusLine=new mt.WatchedValue(!1).spawn(),this._pineSourceCodeModel=null,this._onParentSourcesChanges=new u.Delegate,this._statusChangesSubscriber={},
this._calculationTime=new mt.WatchedValue(0),this._chartApi=e.chartApi(),this._properties=t,this._metaInfo=s,this._hideMatches=s.inputs.filter((e=>e.hideWhenPlotsHidden)).map((e=>({id:e.id,plotIds:e.hideWhenPlotsHidden||[]}))),this._series=this._model.mainSeries(),this._series.onIntervalChanged().subscribe(this,this._calcIsActualInterval),this._series.alertCreationAvailable().subscribe(this._updateAlertCreationAvailable.bind(this)),this._showStudyArgumentsProperty=e.properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments,e.collapsed().subscribe(this._processHibernateBound),this._sources=i,v.StudyMetaInfo.setChildStudyMetaInfoPropertiesSourceId(s,this._sources[0]?.id(),t),i.forEach((e=>{e.setChild(this)})),[this._series,...i].forEach((e=>{e.currencyChanged().subscribe(this,this._onSourceCurrencyChanged),e.unitChanged().subscribe(this,this._onSourceUnitChanged),e.priceRangeReadyChanged().subscribe(this,this._onSourcePriceRangeReadyChanged),e.formatterChanged().subscribe(this,this._onSourceFormatterChanged),e.priceStepChanged().subscribe(this,this._onSourcePriceStepChanged)})),Rt&&this._model.mainSeries().properties().childs().statusViewStyle.childs().symbolTextSource.subscribe(this,(()=>{this.invalidateTitleCache(!0)}));const n=this._properties.childs();for(const e of v.StudyMetaInfo.getSourceInputIds(s))n.inputs.childs()[e]?.subscribe(this,this._onSourceInputChanged);this._properties.subscribe(this,this._onPropertiesChanged),n.visible.subscribe(this,this._visibleChanged),n.visible.subscribe(this,(()=>this.processHibernate())),n.intervalsVisibilities.subscribe(this,this._calcIsActualInterval),n.inputs.subscribe(this,this._updateMaxOffsetValue),void 0!==n.offsets&&n.offsets.subscribe(this,this._updateMaxOffsetValue),void 0!==n.offset&&n.offset.subscribe(this,this._updateMaxOffsetValue),this._initializeCurrencySource(),L.hideAllIndicators().subscribe(this,this._visibleChanged);for(let e=0;e<this._metaInfo.plots.length;e++){const t=this._metaInfo.plots[e].id,i=n.styles.childs()[t];i?.childs().display.subscribe(this,(()=>{this.processHibernate(),this.invalidateTitleCache()}))}for(const e of Object.keys(this._metaInfo.graphics))for(const t of Object.keys(this._metaInfo.graphics[e])){const i=n.graphics.childs()[e]?.childs()[t];i&&i.childs().visible&&(0,r.ensureDefined)(i.childs().visible).subscribe(this,(()=>this.processHibernate()))}this._isActualInterval=(0,_t.isActualInterval)(this._series.intervalObj(),n.intervalsVisibilities),this._initializeStudyInputsPaneViews(),this._handler=e=>this._onData(e),this._valuesProvider=new T.StudyValuesProvider(this,e),this._graphics=new S.LiveStudyGraphics(s.graphics),this._chartApi=e.chartApi(),this._invalidateLastNonEmptyPlotRowCache(),this._data=new y.PlotList((0,Pt.studyPlotFunctionMap)(this._metaInfo),Pt.studyEmptyPlotValuePredicate),this._createViews(),this._recreatePriceFormattingDependencies(this._series.symbolInfo()),n.precision.subscribe(this,this._onFormatterPropsChanged),
this._showStudyArgumentsProperty.subscribe(this,(()=>this.invalidateTitleCache(!0))),n.inputs.subscribe(this,(()=>this.invalidateTitleCache(!0))),H.enabled("update_study_formatter_on_symbol_resolve")&&e.mainSeries().dataEvents().symbolResolved().subscribe(this,this._recreatePriceFormattingDependencies),e.mainSeries().dataEvents().symbolResolved().subscribe(this,(()=>this.invalidateTitleCache(!0)));const a=new Set;if(this._simplePlotsCount=s.plots.filter(((e,t)=>{if((0,M.isLinePlot)(e))return!0;if((0,M.isOhlcPlot)(e)){const t=e.target;return!a.has(t)&&(a.add(t),!0)}return!1})).length,this.hasBarColorer()&&n.visible.subscribe(this,(()=>e.mainSeries().invalidateBarStylesCache)),this._definitionsViewModel=null,this._updateMaxOffsetValue(),s.inputs.some((e=>$t.has(e.id)))){this._visibleTimeRangeInputs=e.visibleRangeStudiesInputs().spawn();const t=this._visibleTimeRangeInputs.value();let i=null!==t;this._visibleTimeRangeInputs.subscribe((e=>{const t=()=>{this._onVisibleTimeRangeInputsChanged(e),i!==(null!==e)&&(i=null!==e,!i||this._restarting||this.isStarted()||this.start(!0))};this._statusChanged.unsubscribeAll(this._statusChangesSubscriber),this._status.type===ut.StudyStatusType.Loading?this._statusChanged.subscribe(this._statusChangesSubscriber,t,!0):t()})),t&&this._updateVisibleTimeRangeInputs(t,!1)}this._properties.setNameInOwner((0,It.propertyPathForSource)(this))}destroy(){this._signlePerformanceValue?.destroy(),this._aboutToBeDestroyed.fire(),null!==this._definitionsViewModel&&(this._definitionsViewModel.destroy(),this._definitionsViewModel=null),this._showStudyArgumentsProperty.unsubscribeAll(this),this._model.mainSeries().dataEvents().symbolResolved().unsubscribeAll(this);this.parentSources().forEach((e=>{e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this),e.priceRangeReadyChanged().unsubscribeAll(this),e.formatterChanged().unsubscribeAll(this),e.priceStepChanged().unsubscribeAll(this)})),this._series.properties().childs().statusViewStyle.childs().symbolTextSource.unsubscribeAll(this),this._series.onIntervalChanged().unsubscribeAll(this),this._series.alertCreationAvailable().unsubscribe(this._updateAlertCreationAvailable),this.formatterChanged().unsubscribe(this,this.invalidateTitleCache),L.hideAllIndicators().unsubscribe(this,this._visibleChanged),this._model.collapsed().unsubscribe(this._processHibernateBound),null!==this._currencySourceSymbolInputProperty&&this._currencySourceSymbolInputProperty.unsubscribeAll(this),this._legendView?.destroy(),this._pineSourceCodeModel?.get()?.destroy(),this._pineSourceCodeModel?.destroy(),this._visibleTimeRangeInputs?.destroy(),this._showPineVersionInStatusLine.destroy(),super.destroy()}setId(e){super.setId(e),this._properties.setNameInOwner((0,It.propertyPathForSource)(this))}properties(){return this._properties}propertiesPatched(){return this._propertiesPatched}isDraggable(){return!this._metaInfo.linkedToSeries}logs(){return null}logLevelMask(){const e=this._properties.childs().inputs.childs().__log_level.value();if(!(0,
R.isNumber)(e)||e<0||e>7)throw new Error(`Value of log level is unexpected, current value is ${e}, but expected values from 0 to 7`);return{error:Boolean(1&e),warning:Boolean(2&e),info:Boolean(4&e)}}setLogLevelMask(e){const t=(Number(e.error)&&1)|(Number(e.warning)&&2)|(Number(e.info)&&4);this._properties.childs().inputs.childs().__log_level.setValue(t)}performance(){return new mt.WatchedValue(null)}profilingEnabled(){return!!this._properties.childs().inputs.childs().__profile?.value()}enableProfiling(e){this._properties.childs().inputs.childs().__profile?.setValue(e)}onAboutToBeDestroyed(){return this._aboutToBeDestroyed}priceScale(e){return e?this._model.mainSeries().priceScale():super.priceScale()}lastValueData(e,t,i){const s={noData:!0},o=this.metaInfo().isPlotForceOverlay(e),n=o?this._model.mainSeries().priceScale():this.priceScale();if(this._model.timeScale().isEmpty()||null===n||n.isEmpty()||this.data().isEmpty())return s;const r=this._model.timeScale().visibleBarsStrictRange(),a=this.firstValue(!0,o);if(null===r||null===a)return s;if(!this._properties.childs().visible.value())return s;const l=this._properties.childs().styles,c=this._properties.childs().ohlcPlots;let h,d;if(l&&l.childs()[e]&&(h=l.childs()[e]),c&&c.childs()[e]&&(h=c.childs()[e]),!h||0===h.childs().display.value())return s;const u=this.metaInfo().plots;for(d=0;d<u.length;d++){const t=u[d];if(t.id===e||(0,M.isOhlcClosePlot)(t)&&t.target===e)break}const _=d+1,p=this.offset(e),m=this.nearestIndex(r.lastBar()-p,b.PlotRowSearchMode.NearestLeft,_);if(void 0===m)return s;const g=this._lastNonEmptyPlotRow(_),f=null!==g&&r.contains(g.index),y=null!==g?g.value:null,v=t||f?y:this.data().valueAt(m);if(!v||!(0,R.isNumber)(v[_]))return s;const S=v[_],w=this._valuesProvider.getPlotColor(d,v),C=n.priceToCoordinate(S,a),P=this.plotFormatter(e).format(S),T={...n.getFormattedValues(S,a,void 0,P),noData:!1,color:w,floatCoordinate:C,coordinate:C};return i&&(T.price=S),T}isFailed(){return this.status().type===ut.StudyStatusType.Error}isLoading(){return this.status().type===ut.StudyStatusType.Loading}isCompleted(){return this.status().type===ut.StudyStatusType.Completed}isSymbolInvalid(){return this._status.type===ut.StudyStatusType.Error&&this._status.errorDescription.error===kt}series(){return this._series}model(){return this._model}state(e,t){const i=(0,r.ensureNotNull)((0,c.getStudyClassName)(this.constructor)),s=this.metaInfo(),o={type:i,id:this.id(),state:this.properties().state(),zorder:this.zorder(),ownFirstValue:this.isVisible()?null:this._ownFirstValue,metaInfo:s.state()},n=this._sources.map((e=>e.id()));if(n.length&&(o.parentSources=n),e){let e=this.data();const t=this._model.timeScale(),i=this._seriesDataRangeToSave(e);null!==i&&(e=e.range(i.firstBar(),i.lastBar())),o.data=e.state(),o.data.symbols=this._resolvedSymbols,o.data.graphics=(0,S.saveStudyGraphics)(this.graphics(),t.visibleBarsStrictRange()),o.data.plotOffsets=this._plotOffsets}this.ownerSource()&&(o.ownerSource=this.ownerSource()?.id())
;for(let e=0;e<s.inputs.length;e++)if("bar_time"===s.inputs[e].type){const t=s.inputs[e].id,i=o.state.inputs[t];if(i<0){const e=this._rightOffsetToUnixTime(-i);o.state.inputs[t]=e&&e>=0?e:0}}if(o.state?.inputs){const e=o.metaInfo.inputs.find((e=>"ILScript"===e.name));e&&delete o.state.inputs[e.id],delete o.state.inputs.__log_level,delete o.state.inputs.__profile}const a=this.stateCustomFields();return a&&(o.customFields=a),o}stateCustomFields(){if(this._compileErrorStatus)return{compileErrorDescription:this._compileErrorStatus.errorDescription}}restoreStateCustomFields(e){const t=e.compileErrorDescription;t&&this.setErrorCompilation([(0,r.ensureDefined)(t.editorError)])}restoreData(e){this._invalidateLastNonEmptyPlotRowCache(),this.data().restoreState(e),this._resolvedSymbols=e.symbols??{},this._graphics=e.graphics?(0,S.loadStudyGraphics)(e.graphics):(0,S.emptyStudyGraphics)(),this._postProcessGraphics(),this._plotOffsets=e.plotOffsets??{},this._setStatus({type:ut.StudyStatusType.Completed},!0)}hasStateForAlert(){return!1}stateForAlert(){throw new Error("Not implemented")}idForAlert(){return super.idForAlert()}hasBarColorer(){return(0,r.ensureNotNull)(this._metaInfo).plots.some(M.isBarColorerPlot)}barColorer(){const e=this._metaInfo.plots;let t=null;for(let i=0;i<e.length;++i)if((0,M.isBarColorerPlot)(e[i])){const e=new bt(this,i);null===t?t=e:t.pushBackBarColorer(e)}return t}isSavedInStudyTemplates(){return this._metaInfo.inputs.every((e=>"bar_time"!==e.type))}restart(e){this._restarting=!0,this.clearData(),(e||H.enabled("stop_study_on_restart"))&&this.stop(),setTimeout(this.start.bind(this),0)}stop(e,t){if(!0===e&&this._children)for(const e of this._children)e.stop(!0);this._stopStudyOnServer(),this.clearData(),this._unsubscribeToSessionId(),this.recalculate()}disconnect(){this._studyId=null,this._model.isSnapshot()||(this._resolvedSymbols={},this._resolvedSymbolsByInput={})}sourceId(){return this._studyId}parentSources(){return this._sources}symbolSource(){return this._firstSourceOrSeries().symbolSource()}valueAt(e,t){return this.symbolSource().valueAt(e,t)}barsProvider(){return this._firstSourceOrSeries().barsProvider()}ownerSource(){return this.isChildStudy()?this._sources[0]:super.ownerSource()}isChildStudy(){return this._sources.length>0}hasChildren(){return this._children.length>0}isStarted(){return Boolean(this._studyId)}isRestarting(){return this._restarting}isActualInterval(){return this._isActualInterval}onIsActualIntervalChange(){return this._onIsActualIntervalChange}isVisible(){const e=this._properties.childs();if(this._model.collapsed().value()||!e.visible.value()||!this.isActualInterval())return!1;const t=this.metaInfo();if(t.plots.length>0)for(let i=0;i<t.plots.length;i++){const s=t.plots[i].id,o=e.styles.childs()[s];if(void 0===o)continue;if(0!==o.childs().display.value())return!0}if(t.bands)for(let i=0;i<t.bands.length;i++)if(e.bands.childs()[i].childs().visible.value())return!0;for(const i of Object.keys(t.graphics))for(const s of Object.keys(t.graphics[i])){
const t=e.graphics.childs()[i]?.childs()[s];if(void 0!==t&&(t.child("visible")?.value()??1))return!0}if(t.filledAreas)for(let i=0;i<t.filledAreas.length;i++)if(e.filledAreasStyle.childs()[t.filledAreas[i].id].childs().visible.value())return!0;return!1}async start(e,t,i){const s=this._model.mainSeries();await s.seriesCreated(),await Promise.all(this._sources.filter((e=>e.isHibernated())).map((e=>e.start())));const o=!(this.isHibernationAllowed()&&!this.isVisible())||!0===t;if(this._chartApi&&this._chartApi.isConnected().value()&&o)try{await this._allSymbolsAreResolved(),await this._startAfterSymbolsResolved(e,t)}catch(e){const t=`ERROR: ${this._debugId()} start failed, ${e}`;Lt.logError(t),this._restarting=!1,"TooManyStudies"===e?.cause&&(0,d.showTooManyStudiesNotice)(this._chartApi.getStudyCounter())}}replaceData(e,t,i){this._invalidateLastNonEmptyPlotRowCache(),this.data().remove(e+1),this.data().addTail(i,t)}inputs(e){const t=(0,n.default)((0,R.clone)(Vt),e||{});t.skipOptionalEmptySymbolInputs&&(t.keepOptionalSymbolsEmpty=!0);const i=(0,o.default)(this._buildInputs(t));return t.patchSosInputs&&v.StudyMetaInfo.patchSoSInputs(i,(e=>this._sources.find((t=>t.id()===e))?.sourceId()??null)),i}data(){return this._data}moveData(e){this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>{this._invalidateLastNonEmptyPlotRowCache(),this._moveData(e)}))}plots(){return this.data()}metaInfo(){return this._metaInfo}status(){return this._compileActiveStatus??this._compileErrorStatus??this._status}name(e){return e?this.metaInfo().shortDescription||"Study":this.metaInfo().description||"Study"}title(e,t,i,s,o,n){s=void 0===s?!this._showStudyArgumentsProperty.value():s;const r=JSON.stringify([e,t,i,s,o,n]);if(this._titleStrCache[r])return this._titleStrCache[r];if(this._titleInPartsCache[r])return this._joinTitlesParts(this._titleInPartsCache[r]);const a=this._title(e,t,i,s,o,n);return this._titleStrCache[r]=a,a}titleInParts(e,t,i,s,o){s=void 0===s?!this._showStudyArgumentsProperty.value():s;const n=JSON.stringify([e,t,i,s,o]);if(this._titleInPartsCache[n])return this._titleInPartsCache[n];const r=this._titleInParts(e,t,i,s,o);return this._titleInPartsCache[n]=r,r}invalidateTitleCache(e){if(this._titleStrCache={},this._titleInPartsCache={},!0===e&&this._children)for(let t=0;t<this._children.length;++t)this._children[t].invalidateTitleCache(e)}graphics(){return this._graphics}graphicsInfo(){return this._metaInfo.graphics}priceLabelText(e){const t=this._metaInfo.styles,i=this._metaInfo.ohlcPlots;let s;t&&t[e]&&(s=t[e]),i&&i[e]&&(s=i[e]);const o=(0,r.ensureDefined)(s).title;return 1!==this._simplePlotsCount||(0,M.isPlotTitleDefined)(o)?this._metaInfo.is_price_study&&o!==this._metaInfo.shortDescription?""===o?this._metaInfo.shortDescription:this._metaInfo.shortDescription+":"+o:o:this._metaInfo.shortDescription}setOwnFirstValue(e){this._ownFirstValue=e}firstValue(e,t){if(t)return this._series.firstValue();if(!this.isChildStudy()&&"Compare@tv-basicstudies"===this._metaInfo.id||!this._metaInfo.is_price_study){
const t=this._model.timeScale().visibleBarsStrictRange();if(null===t)return null;const i=this.properties().childs();if(!i.visible.value()||!this.isActualInterval()||null!==this._startMovingPoint)return this._ownFirstValue;const s=t.firstBar(),o=t.lastBar();let n=null;const a=(this._metaInfo.plots||[]).filter((e=>!this._metaInfo.isPlotForceOverlay(e.id)));if(null===n){const t=new Set,l=this._metaInfo.filledAreas||[];for(let e=0;e<l.length;e++){const s=l[e];i.filledAreasStyle.childs()[s.id].childs().visible.value()&&(t.add(s.objAId),t.add(s.objBId))}for(const l of this.data().rangeIterator(s,o)){const s=l.value;for(let o=0;o<a.length;++o){if((0,M.isColorerPlot)(a[o]))continue;const l=s[o+1];if(null==l)continue;const c=a[o].id;if((0!==(0,r.ensureDefined)(i.styles.childs()[c]).childs().display.value()||t.has(c))&&!(e&&Math.abs(l)<1e-10)){n=l;break}}if(null!==n)break}}return this._ownFirstValue=n,null!==n?n:this._bandsFirstValue(e)}if(this.isChildStudy()){const e=this._getNonPriceParent();if(e&&this.priceScale()===e.priceScale())return null!==e._ownFirstValue?e._ownFirstValue:e.firstValue()}return this._series.firstValue()}desiredPriceScalePosition(){if(this.metaInfo().isTVScriptStub)return"overlay";if(this.metaInfo().linkedToSeries)return"as-series";switch(this.metaInfo().priceScale){case 1:return"left";case 0:return"right";case 2:return"overlay";default:return null}}offset(e){let t=0;this._plotOffsets&&void 0!==this._plotOffsets[e]&&(t+=this._plotOffsets[e]);const i=this.properties().childs(),s=i.offsets?.childs()[e];return s&&(t+=s.childs().val.value()),i.offset&&(t+=i.offset.childs().val.value()),t}tags(){return!this._metaInfo||!this._metaInfo.description||this._metaInfo.isTVScriptStub||this._metaInfo.is_hidden_study||this._metaInfo.isTVScript&&"tv-scripting"===this._metaInfo.productId?[]:[this._metaInfo.description]}copiable(){return Ot&&!this.isChildStudy()}setPriceScale(e){super.setPriceScale(e),(0,wt.emit)("study_event",this.id(),"price_scale_changed")}priceRange(e,t,i){let s=null;const o=this._metaInfo,n=this._fillPrecalculatedAutoscaleInfo(e,t,i);let a=this.data().minMaxOnRangeCached(e,t,n.fields);if(a=(0,y.mergeMinMax)(n.baseValueMinMax,a),n.useMainSeriesRange){const i=[{name:"low",offset:0},{name:"high",offset:0}],s=this.series().data().bars().minMaxOnRangeCached(e,t,i);a=(0,y.mergeMinMax)(a,s)}if(null!==a&&(s=new f.PriceRange(a.min,a.max)),o.bands&&i.targetPriceScale===this.priceScale())for(let e=0;e<o.bands.length;e++){const t=(0,r.ensureDefined)(this._properties.childs().bands.childs()[e]).childs();if(t.visible.value()){const e=t.value.value();if(!(0,R.isNumber)(e))continue;s?s.apply(e,e):s=new f.PriceRange(e,e)}}return this._postProcessPriceRange(s,i)}autoScaleInfo(e,t,i){const s=this.priceRange(e,t,i),o=(this.priceScale()===this._series.priceScale()||(this.priceScale(),i.targetPriceScale),{topPixelMargin:0,bottomPixelMargin:0});return{range:s,topPixelMargin:o.topPixelMargin,bottomPixelMargin:o.bottomPixelMargin}}formatter(e){return this._formatter??this._firstSourceOrSeries().formatter(!1)}
defaultFormatter(){const e=this._firstSourceOrSeries();return this._defaultFormatter??e.defaultFormatter?.()??e.formatter()}plotFormatter(e){return this._plotFormatters.get(e)??this.formatter()}isMultiPaneAvailable(){return this._metaInfo.hasForceOverlayPlots()||(0,p.hasForceOverlayPrimitives)(this._metaInfo)}isMultiPaneEnabled(){return this._metaInfo.hasForceOverlayPlots()}updateAllViews(e){const t=this._model.paneForSource(this),i=this._model.mainPane(),s="viewport-change"===e.type&&e.pane&&e.pane!==i;"viewport-change"===e.type&&e.pane&&e.pane!==t||(this._paneViews.forEach((t=>t.update(e))),this._labelPaneViews.forEach((t=>t.update(e))),this._dataWindowView?.update(e),this._legendView?.update(e),this._statusView?.update(e),this._priceAxisViews.forEach((t=>t.update(e))),this._priceLinesAxisViews.forEach((t=>t.update(e))),this._inputsLinesPaneView?.update(e),this._inputsAnchorsPaneView?.update(e),this._inputsTimeAxisPaneViews.forEach((t=>t.update(e))),this._inputsPriceAxisPaneViews.forEach((t=>t.update(e)))),s||(this._forceOverlaysPaneViews.forEach((t=>t.update(e))),this._forceOverlayLabelPaneViews.forEach((t=>t.update(e))),this._forceOverlayPriceAxisViews.forEach((t=>t.update(e)))),"data-source-change"===e.type&&e.sourceId===this.id()&&e.clearData&&this._children.forEach((e=>e.updateAllViews({type:"data-source-change",sourceId:e.id(),clearData:!0})))}removeByRemoveAllStudies(){return!0}getStudyName(){return this._studyName}nearestIndex(e,t,i){return this.data().search(e,t,i)?.index}getMinFirstBarIndexForPlot(e){const t=this._properties.childs(),i=this._metaInfo,s=t.styles.childs()[e]?.child("showLast")?.value()??t.filledAreasStyle.childs()[e]?.child("showLast")?.value()??i.styles?.[e]?.showLast??t.ohlcPlots.childs()[e]?.child("showLast")?.value()??i.ohlcPlots?.[e]?.showLast??null;if(null===s)return-1/0;const o=this.data().lastIndex();return null===o?-1/0:o-s+1}guiPlotName(e,t){return this._metaInfo.styles?.[t]?.title??this.title(e)}childStudyByRebind(){return this._childStudyByRebind}isPine(){return void 0!==this._metaInfo.pine}isStandardPine(){return this.isPine()&&v.StudyMetaInfo.isStandardPine(this._metaInfo.id)}isLinkedToSeries(){return!0===this._metaInfo.linkedToSeries}preferredZOrder(){return!1===this._metaInfo.behind_chart?0:null}defaultPlotIdForAlert(){return this._metaInfo.plots.length?this._metaInfo.plots[0].id:null}resolvedSymbolInfoBySymbol(e){return this._resolvedSymbols&&e&&this._resolvedSymbols[this._getSymbolForResolve(e)]||null}hasPendingUnresolvedSymbols(){return this._pendingResolveSymbols.size>0}hasSymbolInputs(){return this._metaInfo.inputs.some((e=>"symbol"===e.type))}currency(){if(null!==this._currencySourceSymbolInfo)return(0,gt.symbolCurrency)(this._currencySourceSymbolInfo);const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().currency():null}currencySourceSymbolInfo(){return this._currencySourceSymbolInfo??this.symbolSource()?.symbolInfo()??null}unit(){const e=this.metaInfo();return Boolean(e)&&e.is_price_study?this._firstSourceOrSeries().unit():null}
canOverrideMinTick(){return!1}dataWindowView(){return this._dataWindowView}statusView(){return this._statusView}legendView(){return this._legendView}pineSourceCodeModel(){return Promise.resolve(null)}inputsForAlertState(){return this.inputs()}sessionId(){return this._firstSourceOrSeries().sessionId()}sessionIdChanged(){return this._firstSourceOrSeries().sessionIdChanged()}getSymbolString(e){return""===e?"":(0,D.encodeExtendedSymbolOrGetSimpleSymbolString)(this._getSymbolObject(e))}onStatusChanged(){return this._statusChanged}symbolsResolved(){return this._symbolsResolved}onHibernationStateChange(){return this._onHibernationStateChange}legendValuesProvider(){return new I(this,this.model())}statusProvider(e){return new V.StudyStatusProvider(this)}correctScaleMargins(e){if("Volume"===this.metaInfo().shortId){const t=this.model().paneForSource(this);return null!==t&&t.isOverlay(this)&&t.containsMainSeries()?{top:.75,bottom:0}:{top:e.top,bottom:0}}return e}canBeHiddenByGlobalFlag(){return!0}isSourceHidden(){return!this.isVisible()||this.canBeHiddenByGlobalFlag()&&L.hideAllIndicators().value()}wasCompletedBefore(){return this._wasCompletedBefore}paneViews(e){const t=this._model.mainPane();if(this.isSourceHidden())return null;if(!e.hasPriceDataSource(this))return e!==t?null:this._forceOverlaysPaneViews;const i=[];return!this._startMovingPoint&&this._wasCompletedBefore&&i.push(...this._paneViews.filter((e=>!e.isForceOverlay?.()))),this._inputsLinesPaneView&&(this._startMovingPoint||this._model.selection().isSelected(this))&&i.push(this._inputsLinesPaneView),this._inputsAnchorsPaneView&&i.push(this._inputsAnchorsPaneView),e===t&&i.push(...this._forceOverlaysPaneViews),i}labelPaneViews(e){const t=this._model.mainPane();if(this.isSourceHidden()||!e.hasPriceDataSource(this))return this._metaInfo.hasForceOverlayPlots()?e!==t?null:this._forceOverlayLabelPaneViews:null;const i=[...this._labelPaneViews];return e===t&&i.push(...this._forceOverlayLabelPaneViews),i}timeAxisViews(){return this._model.selection().isSelected(this)?this._inputsTimeAxisPaneViews:null}priceAxisViews(e,t){if(t!==this.priceScale()&&t===this._model.mainSeries().priceScale()&&!e.hasDataSource(this))return this._forceOverlayPriceAxisViews;const i=this._properties.childs().oldShowLastValue;if(i&&!i.value())return null;let s=this._priceAxisViews.slice();return this._model.selection().isSelected(this)&&(s=s.concat(this._inputsPriceAxisPaneViews)),t===this._model.mainSeries().priceScale()&&(s=s.concat(this._forceOverlayPriceAxisViews)),e.findTargetPriceAxisViews(this,t,s,this._priceLinesAxisViews)}movable(){return null!==this._inputsAnchorsPaneView}startMoving(e,t,i,s){this._startMovingPoint=e}move(e,t,i,s){if(void 0!==e.logical&&null!==this._startMovingPoint){if(Array.isArray(t)){const i=t;this._updateInputValue(e.logical,i[0]),this._updateInputValue(e.logical,i[1])}else this._updateInputValue(e.logical,t);this.updateAllViews((0,P.sourceChangeEvent)(this.id()))}}endMoving(e,t){return this._startMovingPoint=null,{indexesChanged:!1,pricesChanged:!1}}clearData(){
this._invalidateLastNonEmptyPlotRowCache(),this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>{this._clearData(),this._graphics instanceof S.LiveStudyGraphics&&this._graphics?.clear()})),this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this.updateAllViews((0,P.sourceChangeEvent)({sourceId:this.id(),clearData:!0}))}convertYCoordinateToPriceForMoving(e,t){const i=this.priceScale();if(!t||!i||i.isEmpty())return null;const s=t.firstValue();return null===s?null:i.coordinateToPrice(e,s)}processHibernate(e){const t=this.isVisible();if(!this.isStarted()&&t&&(this._sources.forEach((e=>{e.processHibernate()})),this.start(void 0,void 0,e),this._onHibernationStateChange.fire(!1)),this.isHibernationAllowed()&&this.isStarted()&&!t){for(const e of this._children)e.processHibernate();this.stop(void 0,e),this._onHibernationStateChange.fire(!0)}}isHibernationAllowed(){return!this.metaInfo().historyCalculationMayChange&&(!this.hasChildren()||!!this._model.collapsed().value()&&this._children.every((e=>e.isHibernationAllowed())))}isPlotVisibleAt(e,t){let i;const s=this.metaInfo().plots.find((t=>t.id===e));if(i=void 0!==s?(0,M.isOhlcPlot)(s)?this._properties.childs().ohlcPlots.childs()[s.target]:this._properties.childs().styles.childs()[e]:this._properties.childs().ohlcPlots.childs()[e],void 0===i)throw new Error(`Study does not contain ${e} plot`);const o=i.childs().display.value();return null!==o&&(o&t)===t}recalculate(){const e=this._model.paneForSource(this);this._model.recalculatePane(e,(0,P.sourceChangeEvent)(this.id())),this._model.updateSource(this)}maxOffset(){return this._maxOffset}onStart(){return this._onStart}onParentSourcesChanges(){return this._onParentSourcesChanges}isHibernated(){return!this.isVisible()&&!this.isStarted()}graphicsViewsReady(){return this._graphicsViewsReady}setLoadingCompilationActive(e){0}setErrorCompilation(e){0}hasCompileError(){return null!==this._compileErrorStatus}turnaround(e){if(!e)return this._turnaround;return function(e,t){let i=t.turnaround,s=[t];for(;s.length>0;){let e=[];const t=[];s.forEach((i=>{const s=O(i.sourceStudies).sort(N);if(s.length>0){e=e.concat(s);const i=s.map((e=>e.turnaround)).join("_");t.push(i)}})),t.length&&(i=t.join("_")+"_"+i),s=e}return e+"_"+i}(this._series.seriesSource().turnaround(),F(this))}canHaveChildren(){return this._canHaveChildren=this._canHaveChildren??v.StudyMetaInfo.canHaveChildren(this._metaInfo),this._canHaveChildren}setChild(e){-1===this._children.indexOf(e)&&this._children.push(e)}unsetChild(e){const t=this._children.indexOf(e);~t&&this._children.splice(t,1)}getAllChildren(){const e=this._children.slice();for(let t=0;t<e.length;++t){const i=e[t].getAllChildren();for(let t=0;t<i.length;++t)~e.indexOf(i[t])||e.push(i[t])}return e}parentSourceForInput(e){if(e.includes("$")){const t=e.split("$")[0];return this._sources.find((e=>e.id()===t))??null}return this._series}priceStep(){return this._priceStep||this._firstSourceOrSeries().priceStep(!1)}recreatePriceFormatter(){this._recreatePriceFormattingDependencies()}
setOwnerSource(e){super.setOwnerSource(e),this._recreatePriceFormattingDependencies()}onTagsChanged(){return this._tagsChanged}getPropertyDefinitionsViewModel(){return null===this._definitionsViewModel?this._getPropertyDefinitionsViewModelClass().then((e=>null===e||this._isDestroyed?null:(null===this._definitionsViewModel&&(this._definitionsViewModel=new e(this._model.undoModel(),this)),this._definitionsViewModel))):Promise.resolve(this._definitionsViewModel)}calculationTime(){return this._calculationTime.readonly()}_getPropertyDefinitionsViewModelClass(){return Promise.resolve(null)}_alertMetaInfo(){return this.metaInfo()}_createStudyOnServer(){if(this._isDestroyed)return!1;const e=this._metaInfo.useVersionFromMetaInfo?(0,v.getStudyIdWithVersion)(this._metaInfo):this._getStudyIdWithLatestVersion();this._studyId=(0,E.makeNextStudyId)(),this._incrementTurnaround(),this._studyName=e;const t=(0,R.clone)((0,r.ensureDefined)(this._inputs));let i;return v.StudyMetaInfo.patchSoSInputs(t,(e=>this._sources.find((t=>t.id()===e))?.sourceId()??null)),i=this._chartApi.createStudy(this._studyId,this._turnaround,this.isChildStudy()?(0,r.ensureNotNull)(this._sources[0].sourceId()):(0,r.ensureNotNull)(this._series.seriesSource().instanceId()),this._studyName,t,this._handler,this._studySpec()),i?(performance.mark(`calculate_study_${this._studyId}`),!0):(this._studyId=null,i)}_stopStudyOnServer(){this._chartApi&&this._chartApi.isConnected().value()&&this.isStarted()&&(this._chartApi.removeStudy((0,r.ensureNotNull)(this._studyId)),this._setStatus({type:ut.StudyStatusType.Undefined})),performance.clearMarks(`calculate_study_${this._studyId}`),this._studyId=null}_modifyStudyOnServer(e,t){const i=(0,R.clone)((0,r.ensureDefined)(e));v.StudyMetaInfo.patchSoSInputs(i,(e=>this._sources.find((t=>t.id()===e))?.sourceId()??null)),this._chartApi.modifyStudy((0,r.ensureNotNull)(this._studyId),this._turnaround,i,this._handler,t),performance.mark(`calculate_study_${this._studyId}`)}_sendNotifyCommand(e,t){this._chartApi.notifyStudy((0,r.ensureNotNull)(this._studyId),e,t)}_transformData(e){}_invalidateLastNonEmptyPlotRowCache(){this._lastNonEmptyPlotRowCache={}}_collectDepsForAlert(){throw new Error("Not implemented")}_allInputsAreValid(){if(null===this._visibleTimeRangeInputs?.value())return!1;for(const e of this._metaInfo.inputs)if("bar_time"===e.type){const t=e.id;if(null==this._properties.childs().inputs.childs()[t].value())return!1}return!0}async _startAfterSymbolsResolved(e,t){await Promise.all(this._sources.map((e=>!e.isStarted()||e.isRestarting()?new Promise((t=>{e.onStart().subscribe(this,t,!0)})):Promise.resolve()))),this.isStarted()&&!this._restarting||(this._restarting=!1,this._allInputsAreValid()&&!this.metaInfo().isTVScriptStub&&(this._inputs=this._apiInputs(),this._createStudyOnServer()&&(this._subscribeToSessionId(),this._onStart.fire(),!0===e&&this._children&&await this._children.map((e=>e.start(!0,t))))))}async _changeInputsImpl(e,t){const s=this._calcSources(),o=Gt(this._metaInfo),n=()=>{for(const i of this._metaInfo.inputs){
if("source"!==i.type)continue;const s=e[i.id].v,o=t[i.id].v;if(s!==o){(0,r.ensureDefined)(this._properties.childs().inputs.child(i.id)).setValue(o)}}};if(this.isStarted()&&this._chartApi.isConnected().value()&&o>0&&!this._chartApi.canCreateStudy(this._studySpec(!0),!0).success){const e=window.user.pro_plan;return createGoProDialog({feature:"studyOnStudy",actions:e&&"pro_premium_expert"===e?[{text:a.t(null,void 0,i(15462)),action:PredefinedAction.Close}]:void 0}),void n()}this._inputs=e;let l=!1;const c=Object.values(W.RangeDependentStudyInputNames);for(const i of Object.keys(e))if(JSON.stringify(e[i])!==JSON.stringify(t[i])&&!c.includes(i)){l=!0;break}this._incrementTurnaround(),l&&this.disablePriceRangeReady();try{await this._updateParentSources(s,o,!0),this._modifyStudyOnServer(e,o),this._studyModified=!0}catch(e){Lt.logError(`Error applying parent sources: ${e}`),n()}this.invalidateTitleCache()}_createPriceAxisView(e){return new yt.StudyPriceAxisView(this,{plotIndex:e})}_createPriceLineAxisView(e){return new vt.StudyPriceLineAxisView(this,e)}_createStudyPlotPaneView(e){return new Ze.StudyPlotPaneView(this,this._series,this._model,e)}_createViews(){this._priceAxisViewsBase=[],this._forceOverlayPriceAxisViews=[],this._priceLinesAxisViews=[],this._paneViews=[],this._forceOverlaysPaneViews=[],this._labelPaneViews=[],this._forceOverlayLabelPaneViews=[];const e=new Set,t=this.metaInfo(),i=Boolean(t.usePlotsZOrder),s=new Map,o=this._properties.childs();if(o.filledAreasStyle&&t.filledAreas)for(let e=0;e<t.filledAreas.length;++e){const n=t.filledAreas[e],a=(0,r.ensureDefined)(o.filledAreasStyle.childs()[n.id]),l=Ut(t,n.id);let c;if("plot_plot"===n.type||l?c=new ot(this,this.model(),n,a):"hline_hline"===n.type?c=new dt(this,n,a):Lt.logWarn("Unsupported filledArea type: "+n.type),void 0!==c){let e=!1;if("plot_plot"===n.type&&(e=t.isPlotForceOverlay(n.objAId)),e)this._forceOverlaysPaneViews.push(c);else{const e=i?(0,r.ensureDefined)(n.zorder):s.size;zt(e,s),s.set(e,{paneViews:[c]})}}}{let o=-1e5;for(let n=0;n<t.plots.length;n++){const a=t.plots[n];let l,c,h,d,u,_=t.isPlotForceOverlay(a.id);if((0,M.isNonVisualPlot)(a))continue;let p=a.id,m=t.styles;const g=(0,M.isBgColorerPlot)(a);if(g)l=new $(this,this._series,this._model,p);else if((0,M.isShapesPlot)(a))l=new Le(this,this._series,this._model,p);else if((0,M.isCharsPlot)(a))l=new Ne(this,this._series,this._model,p);else if((0,M.isArrowsPlot)(a))l=new Ue(this,this._series,this._model,p);else if((0,M.isOhlcPlot)(a)){const i=a.target;if(e.has(i))continue;if(_=t.isPlotForceOverlay(i),e.add(i),Wt(t,n))l=new qe(this,this._series,this._model,i);else{if(!Ht(t,n)){Lt.logError(`plot ${a.id} looks to be invalid`);continue}l=new Ke(this,this._series,this._model,i)}d=this._createPriceAxisView(i),h=new Ye.PanePriceAxisView(d,this,this._model),p=i,m=t.ohlcPlots}else(0,M.isDataPlot)(a)||(d=this._createPriceAxisView(p),u=this._createPriceLineAxisView(p),l=this._createStudyPlotPaneView(p),this._properties.childs().styles.childs()[p]?.child("trackPrice")?.value()&&(c=new Qe(this,p)),
h=new Tt(d,this,this._model,p));const f=i?g?o++:(0,r.ensureDefined)(m?.[p]?.zorder):s.size;if(zt(f,s),_)d&&this._forceOverlayPriceAxisViews.push(d),l&&this._forceOverlaysPaneViews.push(l),h&&this._forceOverlayLabelPaneViews.push(h);else{const e={paneViews:void 0!==l?[l]:[],labelView:h,priceAxisView:d,priceLineAxisView:u};void 0!==c&&e.paneViews.push(c),s.set(f,e)}}}(this._metaInfo.bands??[]).forEach(((e,t)=>{const n=o.bands.childs()[t];if(n&&n.childs().visible.value()){const t=new at(n,this),o=i?(0,r.ensureDefined)(e.zorder):s.size;zt(o,s),s.set(o,{paneViews:[t]})}})),o.bandsBackground&&((0,r.assert)(!i,"'usePlotsZOrder' flag does not supported"),s.set(s.size,{paneViews:[new ht(this)]}));const n=this._paneViews,a=this._forceOverlaysPaneViews;this._createGraphicsPaneViews().then((e=>{for(let t=0;t<e.regularPaneViews.length;t++)n.push(e.regularPaneViews[t]);for(let t=0;t<e.forceOverlayPaneViews.length;t++)a.push(e.forceOverlayPaneViews[t]);this._model.lightUpdate(),this._graphicsViewsReady=!0})),o.areaBackground&&((0,r.assert)(!i,"'usePlotsZOrder' flag does not supported"),s.set(s.size,{paneViews:[new et.AreaBackgroundPaneView(this,this.model())]}));const l=Array.from(s.keys()).sort(((e,t)=>e-t));for(let e=0;e<l.length;e++){const t=(0,r.ensureDefined)(s.get(l[e]));this._paneViews.push(...t.paneViews),t.labelView&&this._labelPaneViews.push(t.labelView),t.priceAxisView&&this._priceAxisViewsBase.push(t.priceAxisView),t.priceLineAxisView&&this._priceLinesAxisViews.push(t.priceLineAxisView)}this._dataWindowView||(this._dataWindowView=new nt.StudyDataWindowView(this,this._model)),this._legendView||(this._legendView=new A(this,this._model)),this._statusView||(this._statusView=new k.StudyStatusView(this)),this._concatPriceAxisViews()}_onData(e){switch(e.method){case"study_loading":this._onStudyLoading(e.time);break;case"study_error":this._onStudyError(e.params[2]);break;case"study_completed":if(!this._checkTurnaround(e.params[1]))return;this._onStudyCompleted(e.time);break;case"data_update":if(e.params.customId!==this.sourceId()||!this._checkTurnaround(e.params.turnaround))return;(0,r.assert)(!!e.params.nonseries,"data.params.nonseries is missing"),this._onDataUpdate(e.params.plots,(0,r.ensureDefined)(e.params.nonseries),e.params.lastBar);break;case"clear_data":this._checkTurnaround(e.params.turnaround)&&this.clearData()}}_getTelemetryObjectName(){return"study"}_onDataUpdated(e,t,i,s){if(this.hasBarColorer()&&e.length>0){const t=(0,r.ensureNotNull)(this.barColorer()).firstColoredBar(e[0].index);null!==t&&this._model.mainSeries().invalidateBarStylesCache(t)}null!==t&&this._postProcessGraphics();const o=this._model.paneForSource(this);this._model.recalculatePane(o,(0,P.sourceChangeEvent)({sourceId:this.id(),firstUpdatedTimePointIndex:s??void 0,nonSeriesOnly:0===e.length})),this._updateSources()}_titleInputs(e,t,i){return this.inputs(this._titleInputsOptions(e,t,i))}_titleInputsOptions(e,t,i){return{symbolsForDisplay:!0,skipHiddenInputs:!0,skipFakeInputs:!1,fakeInputsForDisplay:!0,asObject:!0,skippedGroups:[],
skippedInputs:this._skippedTitleInputs(),noExchanges:t,noResolution:i,priceInputsForDisplay:!0,skipOptionalEmptySymbolInputs:Nt,displayMask:e}}_postProcessGraphics(){this._graphicsPriceAxisViews=this._createGraphicsPriceAxisViews(),this._concatPriceAxisViews()}async _createGraphicsPaneViews(){return(0,S.createGraphicsPaneViews)(this,this.model())}_createGraphicsPriceAxisViews(){return(0,S.createGraphicsPriceAxisViews)(this)}_subscribeToSessionId(){!this._isSubscribedToSessionId&&this.hasSymbolInputs()&&(this.sessionIdChanged().subscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!0)}_recreateFormatter(e){this._recreatePlotsFormatters(e),this._formatter=this._tryCreateFormatter(e),this._defaultFormatter=this._tryCreateDefaultFormatter(e),this._formatterChanged.fire();const t=this.priceScale();null!==t&&t.updateFormatter(),this.getAllChildren().forEach((e=>{e.recreatePriceFormatter()})),this._model.fullUpdate()}_recreatePriceFormattingDependencies(e){this._recreateFormatter(e),this._recreatePriceStep()}_title(e,t,i,s,o,n){const r=this._titleInParts(e,t,i,s,o,n);return this._joinTitlesParts(r)}_postProcessPriceRange(e,t){if(e&&e.minValue()===e.maxValue()&&!this.metaInfo().is_price_study){const t=.005*e.minValue();e=new f.PriceRange(e.minValue()-t,e.maxValue()+t)}const i=t.targetPriceScale;return i&&i.isLog()&&e?new f.PriceRange(i.priceToLogical(e.minValue()),i.priceToLogical(e.maxValue())):e}_titleInParts(e,t,s,o,n,l){const c=this.name(t);s=s||{};const h=[a.t(c,{context:"study"},i(83477))];let d=[];if(!o){const i=this._getMTFResolutionInputTitle();null!==i&&i.length>0&&h.push(i);const o=this.metaInfo(),a=this._titleInputs((0,Mt.toInputDisplayFlags)(e),n,!0),c=o.inputs.filter((e=>a.hasOwnProperty(e.id))).map((e=>({meta:e,value:a[e.id]})));if(c.length>0){const i={};if(this.isChildStudy())for(let s=0;s<o.inputs.length;++s){const a=o.inputs[s];if(!v.StudyMetaInfo.isSourceInput(a))continue;const c=a.id,h=(0,r.ensureDefined)(this._properties.childs().inputs.child(c)).value();if(h.indexOf("$")>=0){const s=this.parentSourceForInput(h);if(s instanceof Kt){const o=s.metaInfo(),r=s.title(e,t,{},!0,n,l);if(1===o.plots.length)i[h]=r;else{const e=h.split("$")[1],t=o.plots[parseInt(e)]?.id,s=o.styles&&o.styles[t],n=s&&s.title||t;i[h]=r+":"+n}}}}d=c.map((({meta:e,value:t})=>{if("time"===e.type)return new Date(t).toISOString();let o=(0,R.isNumber)(t)?(0,xt.getNumericFormatter)().format(t):i&&i[t.toString()]||t.toString();return s&&s[o.toString()]&&(o=s[o.toString()]),o}))}}return[h.join(" · "),d]}_seriesDataRangeToSave(e){return this._model.timeScale().visibleExtendedDataRange(e,0)}_getSymbolForResolve(e){return this.getSymbolString(this._getSymbolForApi(e))}_getSymbolForApi(e){return e}_getSymbolObject(e){const t={symbol:e},i=this.currency();return null!==this._currencySourceSymbolInputProperty&&null!==this._currencySourceSymbolInfo&&this._getSymbolForApi(this._currencySourceSymbolInputProperty.value())===e&&(t["currency-id"]=i),t.session=this.sessionId(),t}_onSymbolResolved(e,t,i){this._onCurrencyMayChange()}
_onSymbolResolvingStart(e,t){}_onSymbolError(){}_setStatus(e,t){const i=this.isFailed();this._status=e,e.type===ut.StudyStatusType.Completed?this._wasCompletedBefore=!0:e.type!==ut.StudyStatusType.Error&&e.type!==ut.StudyStatusType.Undefined||(this._wasCompletedBefore=!1),t||(this._statusView?.update((0,P.sourceChangeEvent)(this.id())),this._model.updateSource(this),this._statusChanged.fire(this.status())),i!==this.isFailed()&&this._updateAlertCreationAvailable()}_onPropertiesChanged(){this._restarting||(this._inputs?this._tryChangeInputs():this._chartApi&&this._chartApi.isConnected().value()&&this.restart()),this._recreatePaneViews(),(0,wt.emit)("study_properties_changed",this._id.value())}_lastNonEmptyPlotRow(e){if(!(0,R.isInteger)(e))return Lt.logDebug("_lastNonEmptyPlotRow: incorrect plotIndex"),null;let t=this._lastNonEmptyPlotRowCache[e]??null;if(null!==t)return t;return t=this.data().findLast(((t,i)=>void 0!==i[e]),1e3),null===t?null:(this._lastNonEmptyPlotRowCache[e]=t,t)}_onCurrencyChanged(){"alwaysOff"!==(0,ft.currencyUnitVisibilityProperty)().value()&&this._model.fullUpdate(),this.isStarted()&&this._tryChangeInputs(),this._currencyChanged.fire()}_apiInputs(){return this.inputs({keepOptionalSymbolsEmpty:!0})}async _tryChangeInputs(){const e=this.isStarted()&&this._chartApi.isConnected().value(),t=this._allInputsAreValid(),i=((0,r.ensureDefined)((0,R.clone)(this._inputs)),this._apiInputs()),s=JSON.stringify(i),o=s!==JSON.stringify(this._inputs);if(e&&t)try{if(await this._allSymbolsAreResolved(),s!==JSON.stringify(this._apiInputs()))return this._tryChangeInputs();if(this._isStopped())return void(o&&this.disablePriceRangeReady());o&&await this._changeInputsImpl(i,(0,r.ensureDefined)((0,R.clone)(this._inputs)))}catch(e){Lt.logError(`ERROR: ${this._debugId()} _tryChangeInputs: cannot modify study, ${e}`)}else if(e&&!t&&this.stop(!0),!e&&t&&this.start(!0),o){const e=this._calcSources(),t=Gt(this._metaInfo);this._updateParentSources(e,t,!0),this._inputs=i}this._tagsChanged.fire()}_onCurrencyMayChange(){if(null!==this._currencySourceSymbolInputProperty){const e=this.currency();this._updateCurrencySourceSymbolInfo(),e!==this.currency()&&this._onCurrencyChanged()}}_fillPrecalculatedAutoscaleInfo(e,t,i){const s=this._metaInfo,o=this.properties().childs(),n=new Set,r=this._metaInfo.filledAreas||[];for(let e=0;e<r.length;e++){const t=r[e];o.filledAreasStyle.childs()[t.id].childs().visible.value()&&(n.add(t.objAId),n.add(t.objBId))}return s.plots.filter((e=>!(0,M.isPlotWithTechnicalValues)(e))).filter((e=>this._metaInfo.isPlotForceOverlay(e.id)?i.targetPriceScale===this._model.mainSeries().priceScale():i.targetPriceScale===this.priceScale()&&!i.forceOverlayOnly)).filter((e=>n.has(e.id)||this.isPlotVisibleAt(e.id,1))).reduce(((i,s)=>this._applyPlotToPrecalculatedAutoscaleInfo(e,t,i,s)),{fields:[],useMainSeriesRange:!1,baseValueMinMax:null})}_firstSourceOrSeries(){return this._sources[0]??this._series}_skipHistogramBaseOnAutoScale(){return!1}_tryCreateFormatter(e){const t=void 0===e?this.symbolSource().symbolInfo():e
;return qt(this._metaInfo.format,this._priceScaleByProperties(),t,this.properties().childs().precision.value())}_tryCreateDefaultFormatter(e){return this._tryCreateFormatter(e)}_mergeData(e){return this._invalidateLastNonEmptyPlotRowCache(),this.data().merge(e)}_skippedTitleInputs(){return this._hideMatches.filter((e=>e.plotIds.every((e=>0===this._getPlotDisplayValue(e))))).map((e=>e.id))}_getPlotDisplayValue(e){return this.properties()?.childs()?.styles?.childs()?.[e]?.childs()?.display?.value()}_onStudyError(e){performance.clearMarks(`calculate_study_${this._studyId}`),this._handleStudyError(this._createStudyError(e)),this._enablePriceRangeReady()}_onStudyCompleted(e){if(performance.getEntriesByName(`calculate_study_${this._studyId}`).length){try{const e=performance.measure(`measure_study_${this._studyId}`,`calculate_study_${this._studyId}`);this._calculationTime.setValue(e.duration)}catch(e){Lt.logError("Error during measuring study calculation time")}performance.clearMarks(`calculate_study_${this._studyId}`),performance.clearMeasures(`measure_study_${this._studyId}`)}this._studyModified&&(this.clearData(),this._studyModified=!1),this._setStatus({type:ut.StudyStatusType.Completed}),this._statusView?.update((0,P.sourceChangeEvent)(this.id()));const t=this._model.paneForSource(this);this._model.recalculatePane(t,(0,P.sourceChangeEvent)(this.id())),this._updateSources();const i=pt.InvalidationMask.full();null!==this._model.appliedTimeFrame().value()&&i.lockVisibleTimeRangeOnResize(),this._model.invalidate(i)}_clearData(){this._data.clear()}_moveData(e){this.data().move(e)}_incrementTurnaround(){this._turnaround="st"+ ++this._turnaroundCounter}_checkTurnaround(e){return e===this._turnaround||e===this._model.mainSeries().seriesSource().turnaround()||e===this.turnaround(!0)}_updateMaxOffsetValue(){let e=-1/0;for(const t of this._metaInfo.plots)e=Math.max(this.offset(t.id),e);this._maxOffset.setValue(e)}_rightOffsetToUnixTime(e){if(this._series.bars().size()>=e){const t=(0,r.ensureNotNull)(this._series.bars().lastIndex())-e;return(0,r.ensureNotNull)(this._series.bars().valueAt(t))[0]}return null}_concatPriceAxisViews(){this._priceAxisViews=[...this._priceAxisViewsBase,...this._graphicsPriceAxisViews]}_onStudyLoading(e){this._setStatus({type:ut.StudyStatusType.Loading,startTime:Date.now()}),this._statusView?.update((0,P.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_handleStudyError(e){this.clearData(),this._setStatus(e),this._statusView?.update((0,P.sourceChangeEvent)(this.id())),this._model.updateSource(this)}_createStudyError(e){let t;return t=(0,R.isString)(e)?{error:this._getStudyErrorText(e),title:e.includes("study_not_auth")?"Access error":"Runtime error"}:{...e,title:e.title??"Runtime error"},(0,ut.createStudyError)(t,this.symbolSource().symbolInfo()?.exchange)}_updateSources(){this._model.updateSource(this),this.hasBarColorer()&&this._model.updateSource(this._model.mainSeries())}_unsubscribeToSessionId(){
this._isSubscribedToSessionId&&(this.sessionIdChanged().unsubscribe(this,this._onSessionIdChanged),this._isSubscribedToSessionId=!1)}_onSessionIdChanged(){this.restart(!0)}_recreatePriceStep(){let e=null;const t=this._priceScaleByProperties()??this._priceScaleByMetaInfo();null!==t&&(e=1/t),this._priceStep!==e&&(this._priceStep=e,this._priceStepChanged.fire())}_recreatePlotsFormatters(e){this._plotFormatters.clear();const t=this._metaInfo.format,i=this._priceScaleByProperties(),s=void 0===e?this.symbolSource().symbolInfo():e;for(const[e,o]of Object.entries(this._metaInfo.ohlcPlots??{}))if(o?.format){const n=qt(jt({...t,...o?.format}),i,s,this.properties().childs().precision.value());n&&this._plotFormatters.set(e,n)}for(const[e,o]of Object.entries(this._metaInfo.styles??{}))if(o?.format){const n=qt(jt({...t,...o?.format}),i,s,this.properties().childs().precision.value());n&&this._plotFormatters.set(e,n)}for(const e of this._metaInfo.plots)if((0,M.isOhlcPlot)(e)){const t=this._plotFormatters.get(e.target);t&&this._plotFormatters.set(e.id,t)}}_joinTitlesParts(e){const t=e[1]?e[1].join(", "):"";return e[0]+(t.length>0?" ("+t+")":"")}_getMTFResolutionInputTitle(){const e=this.metaInfo();for(let t=0;t<e.inputs.length;t++){const i=e.inputs[t];if("resolution"===i.type&&i.isMTFResolution)return(0,r.ensureDefined)(this._properties.childs().inputs.child(i.id)).value()}return null}_onDataUpdate(e,t,i){this._studyModified&&(this.clearData(),this._studyModified=!1);const s=(0,m.unpackNonSeriesData)(t.d);return this._ongoingDataUpdate=this._ongoingDataUpdate.then((()=>s),(()=>s)).then(this._onDataUnpacked.bind(this,e,t.indexes,i)),this._ongoingDataUpdate}_allSymbolsAreResolved(){const e=this._inputSymbols(),t=[];let i=!1;for(const s of e){const e=this._getSymbolForResolve(s);if(""!==e)if(this._resolvedSymbols[e])i=!0;else{const i=this._resolveSymbol(e,s);t.push(i)}}if(0===t.length){const e=Promise.resolve();return i?e.then((()=>this._symbolsResolved.fire())):e}return Promise.all(t).catch((e=>(this._inputSymbols().includes(e)&&this.stop(!0),this._setStatus({type:ut.StudyStatusType.Error,errorDescription:{error:kt}}),this._model.updateSource(this),Promise.reject("Invalid symbol, "+e)))).then((()=>{this._symbolsResolved.fire(),this._recheckLineToolsActuality()}))}_resolveSymbol(e,t){if(""===e)return Promise.resolve();let i=this._pendingResolveSymbols.get(e);return void 0!==i||(i=new Promise(((i,s)=>{this._onSymbolResolvingStart(e,t),this._chartApi.resolveSymbol((0,E.makeNextSymbolId)(),e,(o=>{switch(this._pendingResolveSymbols.delete(e),o.method){case"symbol_resolved":{this._setStatus({type:ut.StudyStatusType.Undefined});const s=o.params[1];this._resolvedSymbols[e]=s,this._resolvedSymbolsByInput[t]=s,this._onSymbolResolved(e,t,s),this.invalidateTitleCache(!0),i();break}case"symbol_error":if(this._setStatus({type:ut.StudyStatusType.Error,errorDescription:{error:o.params[1]}}),this._onSymbolError(),o.params[1]===B.permissionDenied&&o.params[2]){
if(o.params[2]!==B.SymbolErrorPermissionDeniedReason.Symbol)return void this._resolveSymbol(o.params[2],t).then(i);if(o.params[3])return void this._resolveSymbol(o.params[3],t).then(i)}0,s(t)}}))})),this._pendingResolveSymbols.set(e,i)),i}_recheckLineToolsActuality(){const e=this._model.paneForSource(this);null!==e&&e.sourcesByGroup().lineSourcesForAllSymbols().forEach((e=>{e.ownerSource()===this&&e.calcIsActualSymbol()}))}_sendTelemetryCounter(e,t){void 0===t&&(t=this._getTelemetryAdditionalData());const i={count:1,additional:t};telemetry.sendChartReport(e,i)}_getTelemetryAdditionalData(){let e="";return this._metaInfo.pine&&this._metaInfo.pine.version&&this._metaInfo.shortId.indexOf("USER")>=0&&(e="_v"+this._metaInfo.pine.version),{symbol:this.series().actualSymbol(),resolution:this.series().interval(),study:this._metaInfo.shortId+e}}_onSourceFormatterChanged(){null===this._formatter&&(null!==this._priceScale&&this._priceScale.updateFormatter(),this._formatterChanged.fire())}_onSourcePriceStepChanged(){null===this._priceStep&&this._priceStepChanged.fire()}_bandsFirstValue(e){const t=this._metaInfo;if(!t.bands)return null;for(let i=0;i<t.bands.length;i++){const t=(0,r.ensureDefined)(this._properties.childs().bands).childs()[i];if(t.childs().visible.value()){const i=t.childs().value.value();if(e&&0===i)continue;return i}}return null}_prepareInputs(e){(0,r.assert)(!!e,"options not set");const t=this.metaInfo(),i={},s=e.allowedInputTypes?new Set(e.allowedInputTypes):null,o=!(!e.asObject||!e.useNameAndGroupAsKey);for(let n=0;n<t.inputs.length;n++){const a=t.inputs[n];if(null!==s&&!s.has(a.type))continue;if(a.isFake&&e.skipFakeInputs)continue;if(a.isMTFResolution&&e.noResolution)continue;if(void 0!==e.displayMask&&!((0,r.ensureDefined)(a.display)&e.displayMask))continue;if(e.skipHiddenInputs&&(!e.doNotSkipHiddenWithMigrate||!a.migrate)){let t=!1;switch(a.type){case"bool":t=e.skipBooleanInputs;break;case"color":t=e.skipColorInputs;break;case"time":t=e.skipTimeInputs;break;case"text_area":t=e.skipTextareaInputs;break;default:t=Boolean(a.isHidden)}if(t)continue}if(void 0!==a.groupId&&-1!==e.skippedGroups.indexOf(a.groupId))continue;if(-1!==e.skippedInputs.indexOf(a.id))continue;const l=this._prepareInput(a,e);if("symbol"===a.type&&e.skipOptionalEmptySymbolInputs&&""===l)continue;let c;o&&(c=h(a),void 0!==c&&c in i&&(c=void 0)),i[c||a.id]=(0,R.clone)(l)}return i}_prepareInputValue(e,t){const i=e.id,s=this._properties.childs();if(t.valuesAsIsFromProperties)return s.inputs.childs()[i].value();if("symbol"===e.type){const o=t&&t.symbolsForDisplay,n=s.inputs.childs()[i].value();let r=o?n:this._getSymbolForApi(n),a=this._resolvedSymbols?.[this._getSymbolForResolve(r)]??null;if(""===r&&e.optional){if(t&&t.keepOptionalSymbolsEmpty)return r;r=this._model.mainSeries().symbol(),a=this._model.mainSeries().symbolInfo()}if(o)if(a)if(Rt){switch(this._model.mainSeries().symbolTextSourceProxyProperty().value()){case"description":r=a.description;break;case"ticker-and-description":r=`${a.name}, ${a.description}`;break;case"ticker":r=a.name}
}else r=(0,gt.symbolTitle)(a,t.noExchanges);else Ft&&(r="");else a&&(r=a.ticker||a.full_name),!this.isPine()&&t&&t.symbolsForChartApi&&(r=this.getSymbolString(r));return r}if("bar_time"===e.type){let e=s.inputs.childs()[i].value();if(e<0){const t=this._rightOffsetToUnixTime(-e);e=t&&t>=0?t:e}return e}if(this._metaInfo.isTVScript||this._metaInfo.pine){if("text"===i)return this._metaInfo.defaults.inputs?.text??"";if("pineId"===i)return this._metaInfo.scriptIdPart;if("pineVersion"===i)return this._metaInfo.pine?this._metaInfo.pine.version:"-1";if("color"===e.type&&this._metaInfo.isRGB){const e=s.inputs.childs()[i].value();return(0,_.colorToInteger)(e)}if("price"===e.type){const e=s.inputs.childs()[i].value();return t.priceInputsForDisplay?this.formatter().format(e):e}}return s.inputs.childs()[i].value()}_getAllOwnerSources(){const e=[];let t=this.ownerSource();for(;null!==t;)e.push(t),t=t.ownerSource();return e}_getStudyIdWithLatestVersion(){return v.StudyMetaInfo.getStudyIdWithLatestVersion(this.metaInfo())}_debugId(){const e=[];return this._studyId&&e.push(this._studyId),e.push(this._metaInfo.fullId),e.push(this._metaInfo.description),JSON.stringify({study:e})}_hasAvailableAlertPlots(){return!1}_hasAlertConditions(){return!1}_hasAlertFunction(){return!1}async _updateParentSources(e,t,i){if(this._sources.forEach((e=>e.unsetChild(this))),i&&await Promise.all(e.map((e=>e.isStarted()?Promise.resolve():e.start(!1,!0)))),e.forEach((e=>e.setChild(this))),this._setSources(e),this._recreatePriceFormattingDependencies(),0!==t&&this._sources.length<=1){const e=this._firstSourceOrSeries(),t=this._priceScale,i=(0,r.ensureNotNull)(e.priceScale());if(t!==i){const t=this._model.paneForSource(this),s=(0,r.ensureNotNull)(this._model.paneForSource(e));t===s&&s.move(this,i,!0)}}}_calcSources(){const e=this._properties.childs().inputs.state();return v.StudyMetaInfo.getSourceIdsByInputs(this._metaInfo.inputs,e).map((e=>{if("high"===e||"open"===e||"low"===e||"close"===e||"hl2"===e||"ohl3"===e||"ohlc4"===e)return null;return this._model.allStudies().find((t=>t.canHaveChildren()&&t.id()===e))??null})).filter(R.notNull)}_isStopped(){return!this.isStarted()}_onDataUnpacked(e,t,i,s){if(this._isDestroyed)return;"nochange"!==t&&this._processPlotOffsets(s),this._transformData(e);const o=this._mergeData(e);null!==s&&(s.indexes_replace?((0,r.assert)("nochange"!==t),this._graphics.replaceIndexesTo(t)):("nochange"!==t&&this._graphics.replaceIndexesTo(t),void 0!==s.graphicsCmds&&this._graphics.processCommands(s.graphicsCmds))),this._onDataUpdated(e,s,t,o&&o.index),this.priceRangeReady()||this._enablePriceRangeReady(),this._dataUpdated.fire(i,!1,o)}_processPlotOffsets(e){if(e&&e.indexes_replace)return;const t=this._plotOffsets;this._plotOffsets=e&&e.offsets||{},(0,s.default)(t,this._plotOffsets)||this.updateAllViews((0,P.sourceChangeEvent)({sourceId:this.id(),clearData:!0})),this._updateMaxOffsetValue()}_applyPlotToPrecalculatedAutoscaleInfo(e,t,i,s){const o=s.id,n=this._properties.childs().styles.childs()[o],a=(0,M.isShapesPlot)(s)||(0,M.isCharsPlot)(s)
;i.useMainSeriesRange=i.useMainSeriesRange||(0,M.isArrowsPlot)(s);let l=(0,M.isLinePlot)(s)||(0,M.isOhlcPlot)(s);if(a){const e=(0,r.ensureDefined)(n).childs().location.value(),t=[w.MarkLocation.Absolute,w.MarkLocation.Top,w.MarkLocation.Bottom].indexOf(e)<0;i.useMainSeriesRange=i.useMainSeriesRange||a&&t,l=l||e===w.MarkLocation.Absolute}if(!l)return i;const c={name:o,offset:this.offset(o)},h=n.childs().plottype.value();if(!this._skipHistogramBaseOnAutoScale()&&[M.LineStudyPlotStyle.Histogram,M.LineStudyPlotStyle.Columns,M.LineStudyPlotStyle.Area].indexOf(h)>=0){const s=(this._metaInfo.styles??{})?.[o]?.histogramBase;if(void 0===s)return i;const n=this.data().minMaxOnRangeCached(e,t,[c]);return(0,R.isNumber)(s)&&null!==n&&(i.baseValueMinMax=(0,y.mergeMinMax)(i.baseValueMinMax,{min:s,max:s}),i.baseValueMinMax=(0,y.mergeMinMax)(i.baseValueMinMax,n)),i}return i.fields.push(c),i}async _onSourceInputChanged(){if(!this.isStarted()){this._calcSources();Dt}}_buildInputs(e){(0,r.assert)(!!e,"options not set");let t={};try{t=this._prepareInputs(e)}catch(e){Lt.logWarn("Failed to prepare study inputs: "+e)}if(e.asObject){const e={};return Object.keys(t).forEach((i=>{null!=t[i]&&(e[i]=t[i])})),e}{const e=[];return Object.keys(t).forEach((i=>{null!=t[i]&&e.push(t[i])})),e}}_prepareInput(e,t){const i=this._prepareInputValue(e,t);return!e.isFake||t.fakeInputsForDisplay||t.onlyAtomValues?i:{v:i,f:!0,t:e.type}}_plotsForAlert(){return[]}_formatterStateForAlert(){try{const e=this.formatter();return FormattersSerializer.isSerializable(e)?FormattersSerializer.serialize(e):null}catch{return null}}_calcIsActualInterval(){const e=this._isActualInterval;this._isActualInterval=(0,_t.isActualInterval)(this._series.intervalObj(),this._properties.childs().intervalsVisibilities),e!==this._isActualInterval&&(this._onIsActualIntervalChange.fire(),this._visibleChanged(),this.processHibernate())}_visibleChanged(){this._series.invalidateBarColorerCache()}_getNonPriceParent(){const e=this._sources;for(const t of e)if(t instanceof Kt){const e=t.metaInfo();return e.is_price_study&&"Compare@tv-basicstudies"!==e.id?t._getNonPriceParent():t}return null}_updateInputValue(e,t){const i=this._properties.childs().inputs.childs();if(i[t.id])if("price"===t.type)i[t.id].setValue(e.price);else if("time"===t.type){const s=this._model.timeScale().indexToTimePoint(e.index);null!==s&&i[t.id].setValue(1e3*s)}}_initializeStudyInputsPaneViews(){}_updateCurrencySourceSymbolInfo(){null!==this._currencySourceSymbolInputProperty&&(this._currencySourceSymbolInfo=this._resolvedSymbolsByInput[this._currencySourceSymbolInputProperty.value()]??null)}_initializeCurrencySource(){const e=this.metaInfo(),t="symbolInputSymbolSource"===e.symbolSource?.type&&e.symbolSource?.inputId,i=e.inputs.find((e=>e.id===t));if("string"==typeof t&&"symbol"===i?.type&&e.is_price_study){const e=this._properties.childs().inputs.childs()[t];void 0!==e&&(e.subscribe(this,this._onCurrencyMayChange),this._currencySourceSymbolInputProperty=e)}}_recreatePaneViews(){
this.hasBarColorer()&&this._model.mainSeries().invalidateBarStylesCache(),this._createViews(),this.recalculate(),this.updateAllViews((0,P.sourceChangeEvent)(this.id()))}_pinePatchProps(){throw new Error("Not implemented")}_areStudyInputsModified(e){if(0===Object.keys(e).length)return!1;if(void 0===this._oldStudyInputs)return!0;const t=Object.keys(this._oldStudyInputs);(0,r.assert)(t.length===Object.keys(e).length,"keys quantity should be equal");for(const i of t)if((0,r.assert)(e.hasOwnProperty(i),`key '${i}' should exist in study inputs`),(0,r.ensureDefined)(this._oldStudyInputs)[i]!==e[i])return!0;return!1}_onVisibleTimeRangeInputsChanged(e){null!==e?this._updateVisibleTimeRangeInputs(e):this.isStarted()&&this._chartApi.isConnected().value()&&this.stop(!0)}_updateVisibleTimeRangeInputs(e,t=!0){const i={first_visible_bar_time:e.firstVisibleBarTime,last_visible_bar_time:e.lastVisibleBarTime,subscribeRealtime:e.subscribeRealtime},s=this.metaInfo().inputs,o=[];for(const e of s)i.hasOwnProperty(e.id)&&o.push(e.id);const n=this.properties().childs().inputs;for(const e of o)n.childs()[e].setValueSilently(i[e]);t&&o.length>0&&n.fireChanged()}_getStudyErrorText(e){const t=e.split(":",2)[0];return decodeURIComponent(t)}_priceScaleByProperties(){if("default"===this.properties().childs().precision.value())return null;const e=parseInt(this.properties().childs().precision.value());return isFinite(e)?Math.pow(10,e):null}_priceScaleByMetaInfo(){const e=this.metaInfo().format,t="inherit"!==e.type?e.precision:void 0,i=(0,R.isNumber)(t)?Math.pow(10,t):void 0;if("price"===e.type||"percent"===e.type)return i||100;if("volume"===e.type){if(void 0===e.precision){const e=this.series().symbolInfo();if(null!==e&&(0,R.isNumber)(e.volume_precision))return Math.pow(10,e.volume_precision)}return 1}return"inherit"===e.type||Lt.logWarn("Unsupported format type: "+e.type),null}_inputSymbols(){return this.metaInfo().inputs.filter((e=>"symbol"===e.type)).map((e=>(0,r.ensureDefined)(this._properties.childs().inputs.child(e.id)).value()))}_studySpec(e){return{id:this._metaInfo.id,child:e??this.isChildStudy(),fundamental:!1}}_onFormatterPropsChanged(){this._recreatePriceFormattingDependencies()}_setSources(e){this.invalidateTitleCache(),this._sources=e,this._onParentSourcesChanges.fire()}}},31785:(e,t,i)=>{"use strict";i.d(t,{plotShapesData:()=>o});var s=i(11542);const o={shape_arrow_down:{guiName:s.t(null,void 0,i(34247)),id:"shape_arrow_down",paneRendererClass:"PaneRendererArrowDown",pineName:"shape.arrowdown",icon:"arrow_down"},shape_arrow_up:{guiName:s.t(null,void 0,i(77231)),id:"shape_arrow_up",paneRendererClass:"PaneRendererArrowUp",pineName:"shape.arrowup",icon:"arrow_up"},shape_circle:{guiName:s.t(null,void 0,i(91944)),id:"shape_circle",paneRendererClass:"PaneRendererCircleShape",pineName:"shape.circle",icon:"circle"},shape_cross:{guiName:s.t(null,void 0,i(6969)),id:"shape_cross",paneRendererClass:"PaneRendererCrossShape",pineName:"shape.cross",icon:"cross"},shape_diamond:{guiName:s.t(null,void 0,i(15179)),id:"shape_diamond",
paneRendererClass:"PaneRendererDiamond",pineName:"shape.diamond",icon:"diamond"},shape_flag:{guiName:s.t(null,void 0,i(33885)),id:"shape_flag",paneRendererClass:"PaneRendererFlagShape",pineName:"shape.flag",icon:"flag"},shape_label_down:{guiName:s.t(null,void 0,i(85924)),id:"shape_label_down",paneRendererClass:"PaneRendererLabelDown",pineName:"shape.labeldown",icon:"label_down"},shape_label_up:{guiName:s.t(null,void 0,i(52402)),id:"shape_label_up",paneRendererClass:"PaneRendererLabelUp",pineName:"shape.labelup",icon:"label_up"},shape_square:{guiName:s.t(null,void 0,i(66205)),id:"shape_square",paneRendererClass:"PaneRendererSquare",pineName:"shape.square",icon:"square"},shape_triangle_down:{guiName:s.t(null,void 0,i(76152)),id:"shape_triangle_down",paneRendererClass:"PaneRendererTriangleApexDown",pineName:"shape.triangledown",icon:"triangle_down"},shape_triangle_up:{guiName:s.t(null,void 0,i(21236)),id:"shape_triangle_up",paneRendererClass:"PaneRendererTriangleApexUp",pineName:"shape.triangleup",icon:"triangle_up"},shape_xcross:{guiName:s.t(null,void 0,i(11316)),id:"shape_xcross",paneRendererClass:"PaneRendererXCross",pineName:"shape.xcross",icon:"x_cross"}}},9482:(e,t,i)=>{"use strict";var s=i(1640).Version,o=i(9343).getLogger("Chart.StudyMigration");function n(e){this._studyId=e,this._maxToVers=s.ZERO,this._maxFromVers=s.ZERO,this._migrs=[]}n.prototype.addMigration=function(e,t,i){var o=s.parse(e),n=s.parse(t);o.isGreater(this._maxFromVers)&&(this._maxFromVers=o),n.isGreater(this._maxToVers)&&(this._maxToVers=n),this._migrs.push({fromVers:o,toVers:n,rules:i})},n.prototype.updateInputs=function(e,t,i){if(!i)return i;for(var s=TradingView.clone(i),n=e;n.isLess(t);){var r=this._findMigration(n);if(null==r)break;if(o.logNormal("Migrating study inputs from "+r.fromVers+" to "+r.toVers+" version, studyId: "+this._studyId+", migration: "+JSON.stringify(r)+", inputs: "+JSON.stringify(i)),s=this._applyMigration(s,r),!n.isLess(r.toVers))throw new Error("Problems in study migration process... Possible infinite cycle has been detected and stopped.");n=r.toVers}return n>e&&o.logNormal("Study inputs migration is done, studyId: "+this._studyId+", inputs: "+JSON.stringify(s)),s},n.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]},n.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},n.prototype._getApplyRuleFun=function(e){if("inputRemoved"===e)return n._applyInputRemovedRule;if("inputChangedType"===e)return n._applyInputChangedTypeRule;if("inputChangedMinMax"===e)return n._applyInputChangedMinMaxRule;if("inputChangedOptions"===e)return n._applyInputChangedOptionsRule;throw new Error("Unknown migration rule type: "+e)},n._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],o.logNormal("Input "+t.inputId+"="+i+" removed"),e},n._applyInputChangedTypeRule=function(e,t){var i=e[t.inputId];if("resetToDefVal"===t.action)return e[t.inputId]=t.defVal,o.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]),o.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 n._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)},n._isValidSource=function(e,t){return e.indexOf("$")>=0||t.indexOf(e)>=0},n._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),o.logNormal("Input "+t.inputId+"="+i+" adjusted to value "+e[t.inputId]),e},n._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,o.logNormal("Input "+t.inputId+"="+i+" reset to default value "+t.defVal)),e},e.exports=n},79303:(e,t,i)=>{"use strict";i.d(t,{StudyVersioning:()=>m});var s=i(16738),o=i(50151),n=i(68159),r=i(9482),a=i.n(r),l=i(9343),c=i(1640),h=i(72530),d=i(37265);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=52]="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){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}}},52270:(e,t,i)=>{"use strict";function s(e,t,i){return e===t||e===i}i.d(t,{symbolSameAsResolved:()=>s})},95700:(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)??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(35342))],["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)??e}},76350:(e,t,i)=>{"use strict";i.d(t,{areEqualSymbols:()=>a,compareSymbolParams:()=>d,symbolParams:()=>h,symbolSameAsCurrent:()=>c});var s=i(56570),o=i(68805),n=i(85049);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())}}},2844:(e,t,i)=>{"use strict";i.d(t,{TextWidthCache:()=>n,getMinTextMetrics:()=>o});var s=i(5201);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}}},66156:(e,t,i)=>{"use strict";i.d(t,{TimeAxisView:()=>r});var s=i(19063),o=i(7114);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)}}},50503:(e,t,i)=>{"use strict";i.d(t,{INVALID_TIME_POINT_INDEX:()=>s,UNPLOTTABLE_TIME_POINT_INDEX:()=>o});const s=-2e6,o=-1e6},11497:(e,t,i)=>{"use strict";i.d(t,{restoreTimeHoursFormatSettingsValue:()=>l,timeHoursFormatProperty:()=>a});var s=i(56840),o=i(17625);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())))},55158:(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},63146:(e,t,i)=>{"use strict";i.d(t,{getHourMinuteFormat:()=>o,getHourMinuteSecondFormat:()=>n,getTimeFormatForInterval:()=>r});var s=i(15344);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)}},24708:(e,t,i)=>{"use strict";i.d(t,{translatedIntervalString:()=>o});var s=i(10074);function o(e){const t=(0,s.getTranslatedResolutionModel)(e,!0);return null===t?e:t.multiplier+(t.mayOmitShortKind?"":t.shortKind)}},70618:(e,t,i)=>{"use strict";i.d(t,{ExcludeLineToolsFromGroupUndoCommand:()=>h});var s=i(50151),o=(i(21251),i(11542)),n=i(45126),r=i(37265),a=i(60265),l=i(85719);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)}}},69661:(e,t,i)=>{"use strict";i.d(t,{LineToolSynchronizeUndoCommand:()=>o});var s=i(60265);class o extends s.UndoCommand{constructor(e,t,i,s=!0){super(t,i,s),this._invalidateViaSync=!1,this._chartModel=e}redo(){this._invalidateViaSync?this._chartModel.lineToolsSynchronizer().executeSyncedAction((()=>this._redo())):this._redo()}undo(){this._invalidateViaSync?this._chartModel.lineToolsSynchronizer().executeSyncedAction((()=>this._undo())):this._undo()}}},74174:(e,t,i)=>{"use strict";i.d(t,{RemoveSourcesUndoCommand:()=>y});var s=i(50151),o=i(11542),n=i(45126),r=i(69661),a=i(9343),l=i(96286),c=i(79036),h=i(85719),d=i(70618);class u extends r.LineToolSynchronizeUndoCommand{constructor({chartModel:e,title:t,lineDataSourceIds:i}){super(e,t,void 0,!h.lineToolsDoNotAffectChartInvalidation),this._excludeLineToolsFromGroupUndoCommands=[],this._undoState=[],this._lineDataSourceIds=i}_redo(){
const e=this._lineDataSourceIds.map((e=>(0,s.ensureNotNull)(this._chartModel.dataSourceForId(e))));this._groupLineToolsByGroups(e).forEach(((e,t)=>{const i=new d.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,s.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 _=i(21239),p=i(300),m=i(78956);const g=(0,a.getLogger)("Chart.RemoveSourcesUndoCommand"),f=new n.TranslatedString("remove line data sources",o.t(null,void 0,i(38199)));class y extends r.LineToolSynchronizeUndoCommand{constructor(e,t,i){super(e,i,void 0,(0,p.sourcesAffectState)(t)),this._removeLineDataSourcesUndoCommand=null,this._initialPriceScaleMode=null;const[o,n]=(0,l.closeSourcesSet)(e,t).reduce(((e,t)=>((0,m.isLineTool)(t)?e[1].push(t.id()):e[0].push(t.id()),e)),[[],[]]);this._sourceIds=o,this._lineDataSourceIds=n,this._sourceStates=[],this._paneIndexes=[],this._priceScalePositionIds=[],this._paneStates=[],this._restorePanes=[];const r=t[0];1===t.length&&(0,c.isStudy)(r)&&(this._initialPriceScaleMode=(0,s.ensureNotNull)(r.priceScale()).mode())}removedIds(){return[...this._sourceIds,...this._lineDataSourceIds]}_redo(){this._chartModel.panes().length;const e=this._sourceIds.map((e=>(0,s.ensureNotNull)(this._chartModel.dataSourceForId(e))));this._sourceStates=e.map((e=>{const t=e.state(!1);return null===t&&(0,c.isStudyStub)(e)?e.getDescriptor():t}));const t=e.map((e=>(0,s.ensureNotNull)(this._chartModel.paneForSource(e))));this._paneIndexes=t.map((e=>this._chartModel.panes().indexOf(e))),this._lineDataSourceIds.length>0&&(this._removeLineDataSourcesUndoCommand=new u({title:f,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(!1,!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,
_.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]))&&g.logError("Source was restored improperly - source ids does not match"),null!==this._initialPriceScaleMode&&(0,s.ensureNotNull)(e[0].priceScale()).setMode(this._initialPriceScaleMode),this._removeLineDataSourcesUndoCommand&&this._removeLineDataSourcesUndoCommand.undo()}}},96286:(e,t,i)=>{"use strict";function s(e,t){let i=[];const o=e.children(t,!1);for(let t=0;t<o.length;t++)i=i.concat(s(e,o[t]));return i.push(t),i}function o(e,t){const i=new Set,o=t=>{e.children(t,!1).forEach((e=>{i.has(e)||(i.add(e),o(e))}))};return t.forEach(o),t.filter((e=>!i.has(e))).map((t=>s(e,t))).reduce(((e,t)=>e.concat(t)),[])}i.d(t,{closeSourcesSet:()=>o})},60265:(e,t,i)=>{"use strict";i.d(t,{UndoCommand:()=>o});var s=i(45126);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")}}},17656:(e,t,i)=>{"use strict";i.d(t,{createVisibilityController:()=>d});var s,o=i(11542),n=i(32563),r=i(17625),a=i(56840);!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={}))},94664:(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}},5633:(e,t,i)=>{"use strict";i.d(t,{StudyMetaInfoBase:()=>g})
;var s=i(83873),o=i(90054),n=i(50151),r=i(94113),a=i(65383),l=i(37265),c=i(35039);const h=new Set(["CorrelationCoefficient@tv-basicstudies","Correlation - Log@tv-basicstudies-1"]),d=new Set([]),u=new Set(["line","shapes","chars","arrows","alertcondition"]),_=new Map([["AnchoredVWAP@tv-basicstudies","linetoolanchoredvwap"],["RegressionTrend@tv-basicstudies","linetoolregressiontrend"],["VbPAnchored@tv-basicstudies","linetoolanchoredvp"]]),p=/^([^\$]+)\$\d+$/,m=["bool","color","time","text_area"];class g{constructor(e,t=!1){(0,l.merge)(this,{palettes:{},inputs:[],plots:[],graphics:{},defaults:{}}),(0,l.merge)(this,e);const i=e.fullId||e.id;(0,l.merge)(this,g.parseIdString(i)),this._updateInputDisplayDefaults(),this.useVersionFromMetaInfo=t}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}createDefaults(){if(this.defaults){const e=(0,l.clone)(this.defaults);e.precision="default";const t=g.getStudyPropertyRootName(this);(0,c.createDefaults)(t,e)}}removeDefaults(){(0,c.removeDefaults)(g.getStudyPropertyRootName(this))}isPlotForceOverlay(e){const t=this.styles?.[e],i=this.plots.find((t=>t.id===e));return!!t?.forceOverlay||i&&(0,r.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(g.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)g.isSourceInput(i)&&t.push(i.id);return t}static setChildStudyMetaInfoPropertiesSourceId(e,t,i){for(const s of e.inputs){if(!g.isSourceInput(s))continue;const e=i.childs().inputs&&i.childs().inputs.childs()[s.id];if(e){const i=e.value(),s=p.exec(i);if(2===s?.length){if("{pid}"===s[1]){const s=i.replace(/^[^\$]+/,t);e.setValue(s)}}}}}static patchSoSInputs(e,t){const i=e=>{const i=p.exec(e);if(2===i?.length){const s=i[1],o=`${(0,n.ensureNotNull)(t(s))}`;return e.replace(/^[^\$]+/,o)}return e};for(const t in e)if(/in_[\d+]/.test(t)||"source"===t){const o=e[t];(0,s.default)(o)?e[t]=i(o):(0,a.isExtendedInput)(o)&&(0,a.isExtendedInputSource)(o)&&(o.v=i(o.v))}}static canBeChild(e){if((0,s.default)(e))return!0;if(!e)return!1;if(e.extra&&!g.isAllowedSourceInputsCount(e.extra.sourceInputsCount)||!0===e.canNotBeChild||!1===e.canBeChild||h.has(e.id))return!1;let t=0;for(const i of e.inputs)g.isSourceInput(i)&&(t+=1);return g.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&&!d.has(e.id)&&Array.isArray(e.plots))for(const t of e.plots)if(u.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&&u.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 u.has(e)}static getStudyPropertyRootName(e){const t=_.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=_.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)}_updateInputDisplayDefaults(){this.inputs.filter((e=>void 0===e.display)).forEach((e=>{m.includes(e.type)?e.display=a.InputDisplayFlags.None:e.display=a.InputDisplayFlags.All}))}}},68159:(e,t,i)=>{"use strict";i.d(t,{StudyMetaInfo:()=>h,getStudyIdWithVersion:()=>c});var s=i(9343).getLogger("Chart.Study.MetaInfo"),o=i(9343).LOGLEVEL,n=i(78749).applyOverridesToStudyDefaults,r=i(18112).getPersistentLogger,a=i(5633).StudyMetaInfoBase,l={};function c(e){return h.cutDollarHash(e.id)+"-"+e.version}class h extends a{static versionOf(e){var t="_metainfoVersion"in e&&isNumber(e._metainfoVersion)?e._metainfoVersion:0;return t<0&&s.logError("Metainfo format version cannot be negative: "+t),t}static getPackageName(e){const t=/^[^@]+@([^-]+-[^-]+)/.exec(e||"");return null!==t&&0!==t.length&&t[1]||r()?.addPersistentLogEntry(`getStudyPackageName: study id ${e} with stack ${(new Error).stack}`,o.INFO,"chart.StudyMetaInfo"),(t||[0,"tv-basicstudies"])[1]}static cutDollarHash(e){var t=e.indexOf("$"),i=e.indexOf("@");return-1===t?e:e.substring(0,t)+(i>=0?e.substring(i):"")}static hasUserIdSuffix(e){return/^USER;[\d\w]+;\d+$/.test(e)}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){const t=h.cutDollarHash(e.id);let i=t
;return"ReplayStrategy@tv-scripting"===i?i+="-581!":t.indexOf("@tv-scripting")>=0?i+="-101!":t.endsWith("CP@tv-basicstudies")?i+="-"+Math.min(e.version,207):t.endsWith("CP@tv-chartpatterns")?i+="-"+Math.min(e.version,9):t.endsWith("@tv-volumebyprice")?i+="-"+e.version+"!":i+="-"+e.version,i}defaultInputs(){for(var e=[],t=0;t<this.inputs.length;t++)e.push(this.inputs[t].defval);return e}symbolInputId(){var e=this.inputs.filter((function(e){return"symbol"===e.type}));return e.length>0?e[0].id:null}static findStudyMetaInfoByDescription(e,t){if(e){for(var i=0;i<e.length;++i)if(e[i].description.toLowerCase()===t.toLowerCase())return e[i];throw new Error("unexpected study id:"+t)}throw new Error("There is no studies metainfo")}static isParentSourceId(e){return"string"==typeof e&&/^[^\$]+\$\d+$/.test(e)}static overrideDefaults(e){0!==e.length&&n(l,e,(function(e){return TradingView.defaultProperties[h.getStudyPropertyRootName(e)]||null}))}static mergeDefaultsOverrides(e){TradingView.merge(l,e)}}TradingView.StudyMetaInfo=h},81503:(e,t,i)=>{"use strict";window.TradingView=window.TradingView||{},i(32563).setClasses(),i(44286),i(56186).install(),i(49483),i(37265),i(21251),i(11417),i(86129),i(55561),i(56840)},93364:(e,t,i)=>{"use strict";var s=i(81251),o=i(20057),n=i(50151),r=i(36986),a=i(11542),l=(i(20041),i(17192),i(69681),i(73052),i(95047),i(56570));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(81503);var h=i(35039),d=(i(80437),i(56840)),u=i.n(d);const _=(0,r.getChartingLibraryGlobalContext)(),p=(0,r.getChartingLibraryOwner)();_.__settingsOverrides=p.settingsOverrides||{};const m=p.settingsAdapter;null!=m?(d.setSettingsAdapter(m),d.sync()):l.enabled("use_localstorage_for_settings")&&d.sync();var g=i(15938);const f=(0,r.getChartingLibraryGlobalContext)();f.urlParams.customFontFamily&&(0,g.setChartFontFamily)(f.urlParams.customFontFamily);var y=i(38881);class v extends y.ChunkLoader{_startLoading(){return Promise.all([i.e(8356),i.e(3703),i.e(3953),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(7384),i.e(2197),i.e(2736),i.e(4066),i.e(6489),i.e(9766),i.e(4353),i.e(3362),i.e(3745),i.e(4876),i.e(5168),i.e(6164),i.e(5975),i.e(2444),i.e(779),i.e(8054),i.e(2227),i.e(8402),i.e(2544),i.e(3999),i.e(653),i.e(5516)]).then(i.bind(i,95230)).then((e=>e.getRestrictedToolSet()))}}var S,b,w=i(72894),C=i(10048);function P(e=[],t=[]){const i=document.createElement("div"),s=document.createElement("div");return i.appendChild(s),i.classList.add(C.container),s.classList.add(C.inner),e.forEach((e=>{i.classList.add(C[e])})),t.forEach((e=>{i.classList.add(C[e])})),i}!function(e){e.Top="border-top",e.Right="border-right",e.Bottom="border-bottom",e.Left="border-left"}(S||(S={})),function(e){e.TopLeft="top-left-radius",e.TopRight="top-right-radius",e.BottomLeft="bottom-left-radius",e.BottomRight="bottom-right-radius"}(b||(b={}));class T extends y.ChunkLoader{constructor(e,t){super(),this._toolsBootloader=e,
this._headerProps=t,this._headerProps.resizerBridge.negotiateHeight(w.HEADER_TOOLBAR_HEIGHT_EXPANDED),this._headerProps.resizerBridge.container.value().appendChild(P())}_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(4256),i.e(2227),i.e(3005)]).then(i.bind(i,39214)).then((e=>e.HeaderToolbarRenderer))}}var x=i(6307),I=i(27235);class M extends y.ChunkLoader{constructor(e){super(),this._opts=e,x.isDrawingToolbarVisible.value()&&(this._opts.resizerBridge.negotiateWidth(I.TOOLBAR_WIDTH_EXPANDED),this._opts.resizerBridge.container.value().appendChild(P()))}_startLoading(){return Promise.all([i.e(2134),i.e(3703),i.e(3953),i.e(4178),i.e(5826),i.e(9481),i.e(2197),i.e(2736),i.e(9766),i.e(4353),i.e(5375),i.e(3362),i.e(6842),i.e(5975),i.e(5699),i.e(2227),i.e(4931),i.e(2544),i.e(769),i.e(1890),i.e(7843),i.e(2878)]).then(i.bind(i,37159)).then((e=>new e.DrawingToolbarRenderer(this._opts.resizerBridge.container.value(),{...this._opts})))}}var A=i(97990),L=i(32563),k=i(85662),D=i(45345);var E=i(64289),B=i(26709),V=i(3343);function R(e){if("number"==typeof e)return e;switch(e.toLowerCase()){case"ctrl":return V.Modifiers.Control;case"shift":return V.Modifiers.Shift;case"alt":return V.Modifiers.Alt;default:return e.toUpperCase().charCodeAt(0)}}function N(e){let t=0;for(let i=0;i<e.length;i++)t|=R(e[i]);return t}var O=i(97488),F=i(64147),W=i(76422),H=i(22980);function z(e,t){l.enabled("saveload_requires_authentication")?(0,H.runOrSigninWithFeature)(e,{...t,feature:"savedCharts"}):e()}i(21251);l.enabled("atsv2s");var U;!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"}(U||(U={}));var G=i(39076);async function j(){return!0}var q=i(3615);const $=l.enabled("confirm_overwrite_if_chart_layout_with_name_exists");class K{constructor(e,t,i){this._visibility=new F.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,q.showRename)({title:this._dialogTitle(),text:this._dialogText(),maxLength:64,emojiPicker:!0,initValue:e,onRename:async e=>{if(!$)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,q.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 Y extends K{cloneChart(){this._cloneChart().then((()=>this._visibility.setValue(!0)))}show(){z((()=>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 j()}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.deleteValue(),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 Z extends K{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 j()}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 X extends K{show(){z((()=>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 J{constructor(e,t){if(this._autosaveTimer=null,this._watchedAutoSaveEnabled=new F.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=()=>G.backend.getCharts(),this._chartWidgetCollection=e,this._chartSaver=t,this._createController=new Z(e,this._doSave,this._doLoad),this._renameController=new X(e,this._doSave,this._doLoad),this._saveAsController=new Y(e,this._doSave,this._doLoad),this._chartChangesWatcher=new A.ChartChangesWatcher(e,t,W),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)||z((()=>{null!=this._chartWidgetCollection.metaInfo.id.value()?this.saveExistentChart(e,t,i):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()||z((()=>{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()}_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 Q=i(29280),ee=(i(14051),i(21097)),te=i(59063)
;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 Q.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=>G.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(ee.TVXWindowEvents,d);const t=this._favoriteChartsService?.get()||{};this._state=new F.WatchedValue({chartList:[],recents:[],favorites:t}),this._chartWidgetCollection?.metaInfo.name.subscribe(this._onActiveChartNameChange),window.loginStateChange.subscribe(null,this._onLoginStateChange)}showLoadDialog(){z(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()?G.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 G.backend.loadLayout(e);W.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(3357),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(9481),i.e(6445),i.e(3799),i.e(1072),i.e(2736),i.e(4066),i.e(9766),i.e(4353),i.e(625),i.e(4876),i.e(8692),i.e(6190),i.e(9967),i.e(9977),i.e(2227),i.e(4931),i.e(9418),i.e(2544),i.e(3999),i.e(5378),i.e(5009)]).then(i.bind(i,55127)).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(51768),re=i(52033),ae=i(9343);const le=(0,ae.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,G.backend.invalidateStudyTemplatesList),this._list=new F.WatchedValue([]),this._onChange=new re.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(3597),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(5826),i.e(4600),i.e(2564),i.e(6445),i.e(3799),i.e(5480),i.e(5323),i.e(6489),i.e(9766),i.e(8222),i.e(5375),i.e(5083),i.e(601),i.e(4876),i.e(4137),i.e(9654),i.e(2227),i.e(4931),i.e(9418),i.e(2544),i.e(769),i.e(4411),i.e(6631)]).then(i.bind(i,3606)).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((()=>{const e=this._chartWidgetCollection.activeChartWidget.value(),i=i=>{(0,ne.trackEvent)("GUI","Load Study Template"),e.model().applyStudyTemplate(JSON.parse(i.content),t.name)};t.is_default&&"number"==typeof t.id?G.backend.getStandardStudyTemplateById(t.id,i):G.backend.getStudyTemplateById(t.id).then(i)}),{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){G.backend.getStudyTemplatesList().then((t=>{this._list.setValue(t),void 0!==e&&e()}))}invalidate(){G.backend.invalidateStudyTemplatesList()}_removeTemplate(e,t,i){window.runOrSignIn((()=>{(0,q.showConfirm)({text:ce.format({name:e.name}),
onConfirm:({dialogClose:t})=>new Promise((s=>{G.backend.invalidateStudyTemplatesList(),G.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(82992),ue=i(11345),_e=i(24526);class pe{constructor(e,t){this._visibility=new F.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(2530),i.e(3703),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(6445),i.e(1072),i.e(9325),i.e(2736),i.e(7572),i.e(9967),i.e(643),i.e(2227),i.e(9418),i.e(5378),i.e(6456)]).then(i.bind(i,37020)).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(14426),ge=i(31054),fe=i(92184),ye=i(42752),ve=i(60859),Se=i(51613),be=i(63829),we=i(11497),Ce=i(2740),Pe=i(63950),Te=i(23998);const xe=/^Etc\/GMT([+-])(\d{1,2}):?(\d\d)?$/,Ie=new Map;function Me(e){if(Ie.has(e))return Ie.get(e);const t=xe.test(e);return Ie.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 De=new Map;class Ee{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(De.has(e))return De.get(e);let t=null;if(Me(e))t=Le(e);else if(this.timezoneIsAvailable(e)){const i=this.getAliasTimezone(e);Te.tzData[i]&&(t=Te.tzData[i]),!t&&Me(i)&&(t=Le(i))}return t&&De.set(e,t),t}
static instance(){return null===ke&&(ke=new Ee),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)&&!Me(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)(Ee);var Be=i(50788);let Ve=null;var Re=i(85049);class Ne{constructor(e){this._alive=new F.WatchedValue,this._container=new F.WatchedValue,this._width=new F.WatchedValue,this._height=new F.WatchedValue,this._fullscreen=new F.WatchedValue,this._detachable=new F.WatchedValue,this._fullscreenable=new F.WatchedValue,this._visible=new F.WatchedValue,this._availWidth=new F.WatchedValue,this._availHeight=new F.WatchedValue,this._owner=new F.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 F.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 F.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 Ge(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 je(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(42003),Xe=i(77788),Je=i(16216),Qe=(i(9001),i(16738)),et=i(83873),tt=i(60265);const it=(0,ae.getLogger)("Common.UndoStack");class st{constructor(){
this._commands=[],this._onChange=new re.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 tt.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 it.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 ot extends tt.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 nt extends tt.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 rt extends nt{constructor(e,t,i,s,o=!0){super((e=>this._vwState.setValue(e)),t,i,s,o),this._vwState=e}}const at=(0,ae.getLogger)("Common.UndoHistory");var lt=i(928),ct=i(68335),ht=i(91676),dt=i(37265),ut=i(14729),_t=i(5171),pt=i(36915);class mt extends Q.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(2486),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(2564),i.e(6445),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(5323),i.e(1072),i.e(9325),i.e(4066),i.e(116),i.e(8985),i.e(9766),i.e(8222),i.e(4106),i.e(7444),i.e(4353),i.e(5375),i.e(2440),i.e(9296),i.e(625),i.e(5083),i.e(3362),i.e(9255),i.e(7935),i.e(601),i.e(422),i.e(1531),i.e(8544),i.e(7519),i.e(7572),i.e(779),i.e(6710),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(769),i.e(9928),i.e(7223),i.e(9443),i.e(3489),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 gt extends Q.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),W.emit("compare_add")}))}hide(){this._dialog?.hide()}_load(){return Promise.all([Promise.all([i.e(4040),i.e(7271)]).then(i.bind(i,56217)),Promise.all([i.e(6703),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(2564),i.e(7384),i.e(2197),i.e(5323),i.e(1072),i.e(9325),i.e(116),i.e(8985),i.e(4106),i.e(7444),i.e(2444),i.e(7435),i.e(2227),i.e(4931),i.e(9418),i.e(2544),i.e(3202),i.e(2751),i.e(731)]).then(i.bind(i,14283))]).then((([e,t])=>{const i=new e.CompareModel(this._chartWidgetCollection);return t.getCompareDialogRenderer(i)}))}}var ft=i(29981),yt=i(68805);const vt=()=>i.e(4389).then(i.bind(i,7960));function St(e,t={}){return vt().then((i=>i.copyToClipboardImageOfChart(e,t)))}function bt(e,t={}){return vt().then((i=>i.getImageOfChartSilently(e,t)))}var wt=i(15764);var Ct=i(68993);function Pt(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 Tt(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 xt{constructor(){this._ariaElement=null,this._customProvider=null,this._lastDescription=null,this._locale="en"}createElement(e){this._ariaElement=Pt(e)}setCustomProvider(e){this._customProvider=e}setLocale(e){this._locale=e}async updateChartDescription(e,t,i){const s=function(e){const t=Ct.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=It(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=It(e,(e=>"value"===e.type&&"series"===e.sourceType&&"low"===e.plotTitle),i),o=It(e,(e=>"value"===e.type&&"series"===e.sourceType&&"high"===e.plotTitle),i),n=It(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 ${Tt(t.start.time)}.`,s=`The last price is ${e.priceFormatter.format(t.close.close)} at ${Tt(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 ${Tt(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 ${Tt(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 xt),this._instance}async _getExportData(e,t){return(await i.e(9498).then(i.bind(i,99992))).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,yt.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 It(e,t,i){const s=e.schema.findIndex(t);return s>=0?s:i}xt._instance=null;var Mt,At=i(86441),Lt=i(19625),kt=i(24377),Dt=i(27714),Et=i(35236),Bt=i(44672),Vt=i(56468),Rt=i(95201),Nt=i(34026),Ot=i(51056),Ft=i(37743),Wt=i(7114),Ht=i(61993);!function(e){e[e.SizeDelta=1]="SizeDelta"}(Mt||(Mt={}));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 At.Point(n+a,r-l);this._drawLollipop(e,c,t),this._drawLabel(e,c,t)}hitTest(e){const t=(0,
Ht.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,At.box)(new At.Point(s,i),new At.Point(s+this._data.style.lollipop.width+2*t,i+this._data.style.lollipop.height+2*t));return(0,Nt.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,Wt.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,Ft.setLineStyle)(e,Ot.LINESTYLE_SOLID),(0,Ft.createCircle)(e,t.x,t.y,s),e.stroke()}_drawFilledCircle(e,t,i,s){e.fillStyle=s,(0,Ft.createCircle)(e,t.x,t.y,i),e.fill()}}var Ut,Gt=i(95173),jt=i(2844),qt=i(72791);!function(e){e[e.SpaceBetweenRows=25]="SpaceBetweenRows",e[e.TooltipTopMargin=15]="TooltipTopMargin",e[e.SpaceBetweenCardAndLollipop=8]="SpaceBetweenCardAndLollipop"}(Ut||(Ut={}));class $t{constructor(e,t,i){this._invalidated=!1,this._renderer=new Rt.CompositeRenderer,this._textWidthCache=new jt.TextWidthCache,this._stylesCache=null,this._lollipops={},this._lollipopsCounter=0,this._lastClickedId=new F.WatchedValue(null),this.onPaneBgChange=()=>{this._recreateStyles(this._model)},this._model=e,this._source=t,this._clickHandler=i,this._recreateStyles(e),e.backgroundColor().subscribe(this.onPaneBgChange),e.mainSeries().onSymbolIntervalChanged().subscribe(this,this._onSymbolOrIntervalChanged),this._lastClickedId.subscribe((e=>{null===e&&this._source.destroyTooltip()})),this._lastClickedId.subscribe((()=>{this._source.model().updateSource(this._source),this.update((0,Bt.sourceChangeEvent)(this._source.id()))}))}destroy(){this._model.backgroundColor().unsubscribe(this.onPaneBgChange),this._model.mainSeries().onSymbolIntervalChanged().unsubscribeAll(this)}processClickOutside(e,t){const i=this._lastClickedId.value();if(null===i||!t)return void this.clearLastClicked();const s=(0,Et.getClickPosition)(t);if(null===s)return;const o=this._renderer.hitTest(new At.Point(s.x,s.y),e);null!==o&&o.data()?.activeItem===(0,n.ensureDefined)(this._lollipops[i]).itemIndex||this.clearLastClicked()}processClickInside(e,t,i){const s=this._lollipops[i];return!(!s||!s.visible)&&(s.active=!s.active,
this._lollipopMouseClickHandler(e,this._getLollipopRendererData(s),(0,Dt.size)({width:t.clientWidth,height:t.clientHeight}),{preventDefault:()=>{},target:t}),!0)}clearLastClicked(){const e=this._lastClickedId.value(),t=null!==e&&this._lollipops[e]||null;null!==t&&(t.active=!1,this.update((0,Bt.sourceChangeEvent)(this._source.id())),this._source.model().updateSource(this._source)),this._lastClickedId.setValue(null)}getLastClickedLollipopId(){return this._lastClickedId.value()}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,dt.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}_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||e.active)}_getLollipopRendererData(e){const t=this._getLollipopStatus(e),i=this.getStyle(e,t);return{id:e.id,centerPoint:new At.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;this._renderer.clear();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,centerPoint:new At.Point(i.basePoint.x,i.basePoint.y-o.lollipop.bottom-o.lollipop.height/2-(o.lollipop.incHeight||0)),style:o,status:s},r={cursorType:qt.PaneCursorType.Default,activeItem:i.itemIndex,hideCrosshairLinesOnHover:!0,clickHandler:this._lollipopMouseClickHandler.bind(this,e,n,t),tapHandler:this._lollipopMouseClickHandler.bind(this,e,n,t)};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 Gt.VerticalLineRenderer;r.setData(n),this._renderer.insert(r,0)}}}_recreateStyles(e){this._stylesCache=null}_createRendererForLollipop(e,t){return new zt(e,new Vt.HitTestResult(Vt.HitTarget.Custom,t),this._textWidthCache)}_onSymbolOrIntervalChanged(){this._lollipops={},this._lollipopsCounter=0,this._renderer.clear(),this.clearLastClicked()}async _lollipopMouseClickHandler(e,t,i,s){s.preventDefault();const o=t.id;this._lastClickedId.setValue(this._lastClickedId.value()===o?null:o);const r={target:s.target,targetSize:i,point:new At.Point(t.centerPoint.x,t.centerPoint.y-t.style.lollipop.height/2-8),marginTop:15};await this._clickHandler(null!==this._lastClickedId.value(),e,r,(()=>{const e=(0,n.ensureDefined)(this._lollipops[o]);return this._createTooltipContent(e)}))}_getLollipopStatus(e){
return e.active?"active":e.hovered?"hovered":"default"}}var Kt,Yt=i(68979);class Zt 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,Ft.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(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"}(Kt||(Kt={}));const Xt={fillPath:new Path2D("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"),strokePath:new Path2D("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")},Jt={fillPath:new Path2D("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"),strokePath:new Path2D("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")},Qt={fillPath:new Path2D("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"),
strokePath:new Path2D("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")};function ei(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&&(e.fillStyle=s.lollipop.backgroundColor,e.fill(o.fillPath)),e.strokeStyle=s.lollipop.strokeStyle,e.lineWidth=Math.round(s.lollipop.lineWidth*n)/n,(0,Ft.setLineStyle)(e,Ot.LINESTYLE_SOLID),s.lollipop.fillCircle&&s.lollipop.fillStyle&&(e.fillStyle=s.lollipop.fillStyle,e.fill(o.strokePath)),e.stroke(o.strokePath),e.restore()}function ti(e,t,i,s){ei(e,t,i,s,Xt)}function ii(e,t,i,s){ei(e,t,i,s,Jt)}function si(e,t,i,s){ei(e,t,i,s,Qt)}class oi extends zt{_drawLollipop(e,t,i){const s=this._data.style;switch(s.shape){case"earningUp":ti(e,t,i,s);break;case"earningDown":ii(e,t,i,s);break;case"earning":si(e,t,i,s);break;default:super._drawLollipop(e,t,i)}}}var ni;!function(e){e[e.HoveredColorTransparency=85]="HoveredColorTransparency",e.ActiveTextColor="rgba(255, 255, 255, 0.92)"}(ni||(ni={}));const ri={backgroundDark:(0,Lt.getHexColorByName)("color-cold-gray-900"),backgroundLight:(0,Lt.getHexColorByName)("color-white")};class ai extends $t{constructor(e,t,i){super(e,t,i),this.stylesCache={},this.templatesCache={},this._itemIndexToId=new Map,this.source=t}clearCaches(){this.clearLastClicked(),this._lollipops={},this._lollipopsCounter=0}renderer(e){return this._invalidated&&(this._createLollipops(e),this._invalidated=!1),this._renderer}getStyle(e){const t=e.active?"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?[{type:"common",subTitle:Array.isArray(t)?t.map((e=>({value:e}))):[{value:t}],style:{color:e.color}}]:null}_createRendererForLollipop(e,t){return new(e.style.lollipop.image?Zt:oi)(e,new Vt.HitTestResult(Vt.HitTarget.Custom,t),this._textWidthCache)}async _lollipopMouseClickHandler(e,t,i,s){(0,W.emit)("onTimescaleMarkClick",t.id),await super._lollipopMouseClickHandler(e,t,i,s)}_createLollipops(e){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=l===this.getLastClickedLollipopId(),n=this._lollipops[l],h=void 0!==n?n.itemIndex:this._lollipopsCounter++;this._itemIndexToId.has(h)||this._itemIndexToId.set(h,l);const d=o===this.source&&null!==s&&s.activeItem===h,u=(r.get(c)??-1)+1;r.set(c,u),this._lollipops[l]={id:l,itemIndex:h,basePoint:new At.Point(t.indexToCoordinate(c)+1,i),hovered:d,active:e,label:a.label,color:a.color,items:a.tooltip,visible:!0,stack:u,shape:a.shape,image:this._getImageForUrl(a.imageUrl),showLabelWhenImageLoaded:a.showLabelWhenImageLoaded,textColor:a.labelFontColor}}})),super._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()?ri.backgroundDark:ri.backgroundLight;let h,d=i;if("active"===e)h=i,d="rgba(255, 255, 255, 0.92)";else if("hovered"===e){const e=(0,kt.tryParseRgba)(i);if(null!==e){const t=e[3]*(1-.85);h=(0,kt.rgbaToString)((0,kt.rgba)(e[0],e[1],e[2],t))}}a&&(d=a);let u=23,_=23,p=1,m=0;"earning"===n?(_=21,u=21,p=2):"earningUp"===n?(u=21,m=1,p=2):"earningDown"===n&&(u=21,m=-.5,p=.5);const f={barLine:{lineStyle:Ot.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:m,strokeStyle:d,font:(0,Yt.makeFont)(12,g.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 li=i(32679),ci=i(2718),hi=i(19938),di=i(29137);const ui=(0,ae.getLogger)("Chart.BarsMarksContainer"),_i=Math.round(new Date(2037,0,1).getTime()/1e3);var pi;!function(e){e[e.MaxPlatesPerBar=10]="MaxPlatesPerBar"}(pi||(pi={}));class mi extends di.DataSource{constructor(e,t,i){const s=e.onWidget();let o;o=s?!e.hideIdeas():!!l.enabled("bars_marks")&&u().getBool("BarsMarksContainer.visibile",!1),t.merge({visible:o}),t.childs().visible.subscribe(null,(t=>{s||e.isSnapshot()||!l.enabled("bars_marks")||u().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()):_i;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,yt.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,Bt.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,dt.isNumber)(e.start)&&(0,dt.isNumber)(e.end)?(this._lastRange=e,e.end=_i,this._pushGetDataStack(Object.assign({},e))):ui.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,dt.isNumber)(e.start)&&(0,dt.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)):ui.logError("Wrong tickmark range")}_abortAllRequests(){this._requests.forEach((e=>{e.cancel()})),this._requests=[],this._getDataTimeout&&clearTimeout(this._getDataTimeout),this._getDataTimeout=this._collectedRange=null}}const gi=(0,ae.getLogger)("Chart.UserDefinedImageMarks");class fi extends mi{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,hi.getImage)(e,e).then((e=>{this._destroyed||(t.imageElement=e,this.updateAllViewsAndRepaint(),this._model.updateSource(this))})).catch((()=>{gi.logWarn(`An error ocurred while loading image ${e}`)})),this._imageItems.set(e,t)}}var yi=i(45687);class vi extends fi{constructor(e){super(e,new li.DefaultProperty({defaultName:"UserDefinedTimescaleMarks",state:{visible:!0}})),this._requestedPointsets=new Set,this._lollipopTooltipRenderer=null,(0,lt.hideMarksOnBars)().subscribe(this,(()=>this._properties.childs().visible.setValue(!(0,lt.hideMarksOnBars)().value()))),this._paneView=new ai(e,this,this._onLollipopClicked.bind(this)),this._paneViews=[this._paneView]}destroy(){(0,lt.hideMarksOnBars)().unsubscribeAll(this),super.destroy()}zorder(){return ci.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){
null!==this._lollipopTooltipRenderer&&t&&this._lollipopTooltipRenderer.isClickInside(t)||this._paneView.processClickOutside(e,t)}isVisible(){return this.properties().childs().visible.value()}hideTooltip(){this._paneView.clearLastClicked()}destroyTooltip(){this._lollipopTooltipRenderer?.hide(),this._lollipopTooltipRenderer=null}lollipopsAtIndex(e){throw new Error("Method not implemented.")}_initialize(){this._properties.childs().visible.setValue(!(0,lt.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,yi.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()}async _onLollipopClicked(e,t,s,o){if(!e)return;const r=o();if(!r)return;const{showLollipopTooltip:a}=await Promise.all([i.e(6838),i.e(3953),i.e(5826),i.e(2564),i.e(1933),i.e(2227),i.e(2544),i.e(9039)]).then(i.bind(i,184));if(this._isDestroyed)return;const l=this._model.timeScale(),c=[l.onScroll(),l.barSpacingChanged(),this._model.mainSeries().onSymbolIntervalChanged()];this._lollipopTooltipRenderer=a({items:r,position:s,customCloseSubscriptions:c,onClose:()=>this._paneView.processClickOutside(t),onClickOutside:e=>this.onClickOutside(t,e),onSizeChanged:(0,n.ensureNotNull)(this._model.paneForSource(this)).onSizeChanged()})}}var Si,bi,wi=i(71382);function Ci(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 Pi(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}=Ci(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}=Ci(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,Ft.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,Wt.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"}(Si||(Si={}));class Ti{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(Pi.bind(null,e,t,this._data.highlightByAuthor))}_hitTestDot(e,t,i){const s=new At.Point(e.x,Ci(e,i).y/i.verticalPixelRatio);if((0,Nt.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 Vt.HitTestResult(Vt.HitTarget.Regular,{activeItem:e.originalItem.id,cursorType:qt.PaneCursorType.Default,...i})}return null}}!function(e){e[e.BarSpacingToSizeRatio=.8]="BarSpacingToSizeRatio",e[e.MinSize=7]="MinSize",e[e.MaxSize=553]="MaxSize"}(bi||(bi={}));const xi={green:{border:(0,Lt.getHexColorByName)("color-minty-green-700"),background:(0,Lt.getHexColorByName)("color-minty-green-a600")},red:{border:(0,Lt.getHexColorByName)("color-ripe-red-700"),background:(0,Lt.getHexColorByName)("color-ripe-red-500")},neutral:{border:(0,Lt.getHexColorByName)("color-tan-orange-700"),background:(0,Lt.getHexColorByName)("color-tan-orange-500")},yellow:{border:"#EAC300",background:"#FFD400"},blue:{border:"#047ACE",background:"#0496FF"}};class Ii{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 Ti(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,Et.isTouchMouseEvent)(t)?t.isTouch:(0,wi.isTouchEvent)(t))&&null!==this._tooltip&&!this._tooltip.contains(t.target)&&this._tooltip.hide(!0)}_extractBarMarksRendererItemData(e,t){const i=t.overridedTheme??xi[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:Mi(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,Yt.makeFont)(Math.ceil(Math.max(10,Math.min(s/2,20))),g.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 Mi(e){return e.hovered||e.highlightByAuthor?e.overrideBorderWidth?.hoveredWidth??4:e.overrideBorderWidth?.width??2}class Ai extends Ii{async _createTooltipRenderer(){const[{TooltipRenderer:e},{UserDefinedBarsMarksTooltip:t}]=await Promise.all([Promise.all([i.e(4057),i.e(2227),i.e(8020)]).then(i.bind(i,6897)),Promise.all([i.e(4057),i.e(2227),i.e(8020)]).then(i.bind(i,16608))]);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 Li extends fi{constructor(e){super(e,new li.DefaultProperty({defaultName:"UserDefinedBarsMarks",state:{visible:!0}})),this._paneView=new Ai(this,e),this._paneViews=[this._paneView],(0,lt.hideMarksOnBars)().subscribe(this,(()=>{this.properties().childs().visible.setValue(!(0,lt.hideMarksOnBars)().value())}))}destroy(){(0,lt.hideMarksOnBars)().unsubscribeAll(this),this._paneView.destroy(),super.destroy()}zorder(){return ci.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)}_initialize(){this.properties().childs().visible.setValue(!(0,lt.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,dt.isNumber)(e.borderWidth)?e.borderWidth:void 0,s=(0,dt.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,yi.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 ki=i(69109),Di=i(45126);function Ei(e){const t={};return{promise:new Promise(((i,s)=>{e.subscribe(t,i,!0)})),destroy:()=>{e.unsubscribeAll(t)}}}var Bi=i(22820);class Vi extends tt.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 Ri=i(91682),Ni=i(56616);const Oi=(0,ae.getLogger)("Clipboard");var Fi;!function(e){e.MagicAttrName="data-tradingview-clip"}(Fi||(Fi={}));class Wi{constructor(e){this._e=e}write(e){return(0,Ni.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,Ri.htmlEscape)(e)}">${t?(0,Ri.htmlEscape)(t.slice(0,256)):"&#128200;"}</span>`}}class Hi{constructor(e){this._e=e}async read(){this._e&&0===this._e.eventPhase&&(Oi.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,Ni.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 Hi(null).read()}uiRequestCopy(e){this._callbacks.copyRequested&&this._callbacks.copyRequested(new Wi(null),e)}uiRequestCut(e){this._callbacks.cutRequested&&this._callbacks.cutRequested(new Wi(null),e)}uiRequestPaste(e){this._callbacks.pasteRequested&&this._callbacks.pasteRequested(new Hi(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 Wi(e))}_onCutEv(e){e.defaultPrevented||this._callbacks.cutRequested&&this._callbacks.cutRequested(new Wi(e))}_onPasteEv(e){
e.defaultPrevented||this._callbacks.pasteRequested&&this._callbacks.pasteRequested(new Hi(e))}}var Ui=i(35749);function Gi(e){const t=e.target;return null!==t&&1===t.nodeType&&(0,Ui.isTextEditingField)(t)}function ji(e){const t=e.target;if(null===t)return!1;const i=(t.ownerDocument||t).getSelection();return null!==i&&!i.isCollapsed}class qi extends zi{_onCopyEv(e){if(!Gi(e)&&!ji(e))return super._onCopyEv(e)}_onCutEv(e){if(!Gi(e)&&!ji(e))return super._onCutEv(e)}_onPasteEv(e){if(!Gi(e))return super._onPasteEv(e)}}var $i=i(65952);const Ki=new Di.TranslatedString("change chart layout to {title}",a.t(null,void 0,i(68846)));class Yi extends tt.UndoCommand{constructor(e,t){super(Ki.format({title:Ct.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)}}const Zi=new Di.TranslatedString("apply toolbars theme",a.t(null,void 0,i(86708)));class Xi extends tt.UndoCommand{constructor(e,t,i=!0){super(Zi),this._prevThemeName=e,this._themeName=t,this._syncState=i}undo(){(0,k.isStdThemeName)(this._prevThemeName)&&((0,D.setTheme)(this._prevThemeName),this._syncState&&(0,k.syncTheme)())}redo(){(0,k.isStdThemeName)(this._themeName.toLowerCase())&&((0,D.setTheme)(this._themeName.toLowerCase()),this._syncState&&(0,k.syncTheme)())}}var Ji=i(88960),Qi=i(23869),es=i(10074),ts=i(16638),is=i(68159);i(99647);(0,ae.getLogger)("ChartWidgetCollectionBase");const ss=new Di.TranslatedString("apply indicators to entire layout",a.t(null,void 0,i(70507))),os=new Di.TranslatedString("sync time",a.t(null,void 0,i(91677))),ns=new Di.TranslatedString("reset layout sizes",a.t(null,void 0,i(85366))),rs=new Di.TranslatedString("apply chart theme",a.t(null,void 0,i(68231))),as=new Di.TranslatedString("symbol lock",a.t(null,void 0,i(53278))),ls=new Di.TranslatedString("interval lock",a.t(null,void 0,i(56558))),cs=new Di.TranslatedString("date range lock",a.t(null,void 0,i(58850))),hs=new Di.TranslatedString("track time",a.t(null,void 0,i(46807))),ds=new Di.TranslatedString("change series style",a.t(null,void 0,i(49965)));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(85902)),a.t(null,void 0,i(94656));function us(e,t){for(const i of e.sources){if("study"!==i.type)return!0;if(t.checkIfFeatureAvailable(new is.StudyMetaInfo(i.source.metaInfo),[]))return!0}return!1}function _s(e){return function(e){return vt().then((t=>t.downloadClientScreenshot(e)))}(e)}function ps(e){return function(e){return vt().then((t=>t.copyToClipboardClientScreenshot(e)))}(e).then((()=>{(0,W.emit)("onClientScreenshotCopiedToClipboard")}))}const ms={s:0,"2h":0,"2v":1,"2-1":1,"3s":0,"3h":0,"3v":2,4:1,6:1,8:1,"1-2":1,"3r":1,"4h":0,"4v":3,"4s":0,"4s-l":0,"5h":0,"5v":0,"6h":0,"6v":0,"7h":0,"8h":0,"8v":0,"1-3":1,"2-2":3,"2-2-l":0,"2-3":2,"3-2":3,"1-4":1,"2-4":2,"5s":0,"6c":4,"8c":6,"9s":6,"9h":0,"9v":0,"10h":0,
"10v":0,"10c5":1,"12c6":1,"12c4":3,"14c7":1,"16c8":1,"16c4":3};function gs(e,t,i,s){const o=e.actualLayoutCount();return e.chartWidgetsDefs.slice(0,o).filter((e=>e.rdState.bridge().visible.value())).map((e=>e.chartWidget)).filter((t=>t.id()!==i&&(!!t.hasModel()&&e.crosshairLockRaw))).forEach((e=>e.model().model().setExternalPosition(t,s))),!0}function fs(e,t){return t}async function ys(e,t=this.activeChartWidget.value()){return!!t&&(function(e,t){const i=e.model(),s=i.mainSeries().properties().childs().style;i.setChartStyleProperty(s,t,ds)}(t,e),!0)}async function vs(e,t,i,s){return!(e.flags.loadingChart||e.flags.setTimeFrameActive||e.flags.setNewResolution)&&(function(e,t,i,s){(0,es.setLastUsedResolution)(t),e.flags.setNewResolution=!0,s=s??e.activeChartWidget.value(),void 0===i&&(i=s.linkingGroupIndex().value());if(e.intervalLock.value())for(const i of e.chartWidgetsDefs){const e=i.chartWidget;e.resolutionWV().value()!==t&&e.setResolution(t)}else s.setResolution(t);e.flags.setNewResolution=!1}(e,t,i,s),!0)}function Ss(e,t){t=null;let i=e.linkingGroupsCharts.get(t);return void 0===i&&(i=new ht.WatchedObject([],ft.compareTwoCollectionsByIds),e.linkingGroupsCharts.set(t,i)),i}function bs(e,t,i){return(0,Ji.combine)(((e,t)=>e||t),t.weakReference(),new F.WatchedValue(!1).spawn().ownership())}function ws(e){e.syncChartsDateRangesWithActiveChartRange()}const Cs=new Map;function Ps(e){const t=Cs.get(e.id())??{};return Cs.set(e.id(),t),t}var Ts=i(15943),xs=i(24317),Is=i(19063),Ms=i(48341);function As(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 Ls=i(58473),ks=i(90995);let Ds;class Es extends Q.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 Ds||(Ds=new Es),Ds}_load(){return Promise.all([i.e(7714),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(9325),i.e(2736),i.e(4066),i.e(116),i.e(4353),i.e(3745),i.e(8692),i.e(3693),i.e(6190),i.e(2709),i.e(2227),i.e(4931),i.e(7746),i.e(9418),i.e(3202),i.e(4862)]).then(i.bind(i,34489)).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 Bs,Vs=i(65383),Rs=i(12988);async function Ns(e,t,s,o,n,r="default"){let l,c=[];const h=e.model().model(),d=(0,dt.clone)(t),u=new Rs.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(Vs.isTimeOrPriceNotHiddenInput);if(f.length>0)try{
const t=await Promise.all([i.e(9003),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(9481),i.e(4600),i.e(2564),i.e(6445),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(5323),i.e(1072),i.e(9325),i.e(116),i.e(8985),i.e(8222),i.e(4106),i.e(7444),i.e(2440),i.e(9296),i.e(625),i.e(5083),i.e(9255),i.e(7935),i.e(422),i.e(1531),i.e(6316),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(9928),i.e(7223),i.e(9443),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){const e=o.destPane.mainDataSource();c=e===h.mainSeries()?[]:[e]}else c=[]}catch(e){return void m()}f.length!==_.length?Promise.all([i.e(9003),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(9481),i.e(4600),i.e(2564),i.e(6445),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(5323),i.e(1072),i.e(9325),i.e(116),i.e(8985),i.e(8222),i.e(4106),i.e(7444),i.e(2440),i.e(9296),i.e(625),i.e(5083),i.e(9255),i.e(7935),i.e(422),i.e(1531),i.e(6316),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(9928),i.e(7223),i.e(9443),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"}(Bs||(Bs={}));let Os=null;i(15216);var Fs=i(49481),Ws=i(58096);const Hs=(0,Fs.parseHtmlElement)(function(e=""){return`<div class="tv-spinner ${e}" role="progressbar"></div>`}());class zs{constructor(e){this._shown=!1,this._el=Hs.cloneNode(!0),this.setSize(Ws.spinnerSizeMap[e||Ws.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 Us(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Gs(e){return e.reduce(((e,t)=>{for(const i in t)if(Us(t,i)){const s=t[i],o=e[i];o?o.push(s):e[i]=[s]}return e}),{})}var js=i(43550);const qs=new Di.TranslatedString("move left",a.t(null,void 0,i(79209))),$s=new Di.TranslatedString("move right",a.t(null,void 0,i(60114)));var Ks;!function(e){e[e.AccelerationPerMSecPixels=.003]="AccelerationPerMSecPixels",e[e.MaxSpeedPerMSecPixels=1.1]="MaxSpeedPerMSecPixels"}(Ks||(Ks={}));class Ys{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(e,((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(e,((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){null!==this._chartModel&&this._chartModel.timeScale().scrollToRealtime(e)}_moveImpl(e,t,i,s){if(null===this._chartModel)return;const o=this._chartModel.timeScale();if(o.isEmpty())return;if(this._chartModel.changeTimeScale(1===e?qs:$s,!1),s&&null!==o.visibleBarsStrictRange()){const e=o.indexToCoordinate(o.visibleBarsStrictRange().lastBar())+o.barSpacing()/2;Math.abs(o.width()-e)>o.barSpacing()/6&&o.setRightOffset(Math.round(o.rightOffset()))}const n=performance.now();let r=1/0;this._animation={getStartPosition:()=>0,getPosition:e=>(e=Math.min(r,e),t(0,e-n,r-e)),finished:e=>e>=r,stop:()=>{const e=performance.now()-n;r=performance.now()+i(e)}},this._chartModel.model().stopTimeScaleAnimation(),this._chartModel.model().setTimeScaleAnimation(this._animation)}}var Zs=i(26023);function Xs(e,t,s,o,n){return Promise.all([i.e(4593),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(2564),i.e(6445),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(5323),i.e(1072),i.e(9325),i.e(4066),i.e(116),i.e(8985),i.e(9766),i.e(8222),i.e(4106),i.e(7444),i.e(5375),i.e(2440),i.e(9296),i.e(625),i.e(5083),i.e(3362),i.e(9255),i.e(7935),i.e(601),i.e(422),i.e(1531),i.e(8544),i.e(3828),i.e(7519),i.e(5168),i.e(6847),i.e(2864),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(769),i.e(9928),i.e(7223),i.e(9443),i.e(3489),i.e(6265)]).then(i.bind(i,81346)).then((i=>{const r=new(0,i.EditObjectDialogRenderer)(e,t,o,n);return r.show(s),r}))}var Js=i(79036);let Qs=null;var eo=i(32755);const to={[Zs.TabNames.symbol]:"symbol",[Zs.TabNames.legend]:"legend",[Zs.TabNames.scales]:"scales",[Zs.TabNames.trading]:"trading",[Zs.TabNames.events]:"events",[Zs.TabNames.alerts]:"alerts",[Zs.TabNames.timezoneSessions]:"canvas",[Zs.TabNames.text]:"text",[Zs.TabNames.style]:"style",[Zs.TabNames.visibility]:"visibility"},io={[Zs.TabNames.style]:"style",[Zs.TabNames.visibility]:"visibilities"};async function so(e,t,s={},o,n){const r=o.activeChartWidget.value(),{initialTab:a,tabName:l}=s;if(l&&!a&&(s.initialTab=io[l]),(0,eo.isStudyLineTool)(e)&&function(e){if(!(0,eo.isStudyLineTool)(e))return!1;return["LineToolFixedRangeVolumeProfile","LineToolVbPFixed",null].filter(dt.notNull).some((t=>e.toolname===t))}(e))return r.propertiesDefinitionsForSource(e).then((i=>null!==i?Xs(e,t,s,n,i):null))
;if((0,Js.isStudy)(e)&&function(e){const{shortId:t}=e.metaInfo();return"Overlay"===t}(e)||(0,eo.isLineTool)(e))return r.propertiesDefinitionsForSource(e).then((o=>{if(null!==o){return function(e){return Promise.all([i.e(6655),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(2564),i.e(6445),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(5323),i.e(1072),i.e(9325),i.e(4066),i.e(116),i.e(8985),i.e(9766),i.e(8222),i.e(4106),i.e(7444),i.e(5375),i.e(2440),i.e(9296),i.e(625),i.e(5083),i.e(9255),i.e(7935),i.e(601),i.e(422),i.e(1531),i.e(8544),i.e(3828),i.e(7519),i.e(6847),i.e(1833),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(769),i.e(9928),i.e(7223),i.e(9443),i.e(3489),i.e(6780)]).then(i.bind(i,75892)).then((t=>{const i=new(0,t.SourcePropertiesEditorRenderer)(e);return null!==Qs&&Qs.hide(),i.show({shouldReturnFocus:e.shouldReturnFocus}),Qs=i,i}))}({propertyPages:o,model:t,source:e,activePageId:l&&to[l],shouldReturnFocus:s.shouldReturnFocus})}return null}));if((0,Js.isStudy)(e))return Xs(e,t,s,n);{const e=l&&to[l],t=o.getChartPropertiesDialogRenderer();return t.setActivePage(e),t.show(s)}}var oo=i(24633);async function no(){return(await Promise.all([i.e(2564),i.e(8666),i.e(2227),i.e(139)]).then(i.bind(i,81200))).ErrorCardRenderer}var ro=i(82236),ao=i(62825);const lo=(0,Lt.getHexColorByName)("color-cold-gray-700"),co=(0,Lt.getHexColorByName)("color-cold-gray-400"),ho=(0,Lt.getHexColorByName)("color-cold-gray-900"),uo=(0,Lt.getHexColorByName)("color-white"),_o=a.t(null,void 0,i(18905));function po(e){return e?{...e,message:(0,ro.formatStudyError)(e.message),rawHtml:!0}:null}class mo{constructor(e){this._container=null,this._errorCardRenderer=null,this._mainSeriesErrorMessage=null,this._banErrorMessage=new F.WatchedValue(null).spawn(),this._errorMessageHandler=e=>{e=po(e),this._chartWidget.hasModel()?this._updatePaneWidgets(e):this._renderErrorWithoutModel(e)},this._chartWidget=e,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)}}_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 no())}_createErrorCardRendererState(e){return e?{message:e.message,icon:e.icon,
textColor:D.watchedTheme.value()===oo.StdTheme.Dark?co:lo,backgroundColor:D.watchedTheme.value()===oo.StdTheme.Dark?ho:uo,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,Ji.combine)(((t,s)=>{if(t)return t;if(null===s)return null;switch(s.type){case"invalid_symbol":return{message:a.t(null,void 0,i(52969)),icon:"ghost"};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,yt.getSeriesDisplayErrorWV)(t).ownership()),this._mainSeriesErrorMessage.subscribe(this._errorMessageHandler,{callWithLast:!0})}))}_createErrorParamsForUnsupportedResolution(e){const t=e.model(),i=t.mainSeries().unsupportedResolutionState().value();return null===i?null:{message:(0,ao.getErrorFromUnsupportedResolutionState)(i,!0),icon:"unsupported-resolution",rawHtml:!0,maxHeight:400,zeroHeight:200,buttons:[{name:_o.format({resolution:i.applicableResolution}),onClick:()=>{t.setResolution(t.model().mainSeries(),i.applicableResolution)}}]}}_getErrorMessage(){return po(this._banErrorMessage.value()||this._mainSeriesErrorMessage?.value()||null)}}var go,fo=i(776),yo=i(62288),vo=i(69186),So=i(46088),bo=i(4340),wo=i(20350);class Co{constructor(e,t){this._showed=!1,this._additionalReadyPromise=null,this._cw=e,this._element=document.createElement("div"),this._element.classList.add(wo.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!==bo.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(),_t.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()===So.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(wo.fade)}_hide(){this._showed=!1,this._element.classList.remove(wo.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"}(go||(go={}));class To{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 xo,Io=i(9859),Mo=i(56479);!function(e){e[e.Height=1]="Height",e[e.MinPaneHeight=30]="MinPaneHeight"}(xo||(xo={}));class Ao{constructor(e,t,i){this._handleEl=null,this._resizeInfo=null,this._colorCache={lineColor:"",backgroundColor:"",color:""},this._selected=new F.WatchedValue,this._chart=e,this._topPaneIndex=t,this._bottomPaneIndex=i,this._element=document.createElement("div"),this._element.classList.add(Mo.paneSeparator),this._element.style.background=this._color(),this.adjustSize(),this._element.addEventListener("click",(()=>{}));const s=document.createElement("div");s.classList.add(Mo.handle),this._element.appendChild(s),this._mouseEventHandler=new Et.MouseEventHandler(s,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._handleEl=s,this._handleEl.classList.toggle(Mo.mobile,ze.CheckMobile.any()),this._element.setAttribute("aria-hidden","true"),this._selected.subscribe((e=>this._handleEl?.classList.toggle(Mo.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=Ao.height()+"px"}mouseEnterEvent(e){const{topPane:t,bottomPane:i}=this._topBottomPane(!0);null!==t&&null!==i&&(0,n.ensureNotNull)(this._handleEl).classList.add(Mo.hovered)}mouseLeaveEvent(e){(0,n.ensureNotNull)(this._handleEl).classList.remove(Mo.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,Wt.createDisconnectedCanvas)(document,(0,Dt.size)({width:t,height:1})),r=(0,Wt.getPrescaledContext2D)(n);r.fillStyle=o,r.fillRect(0,0,t,1);const a=(0,Wt.createDisconnectedCanvas)(document,(0,Dt.size)({width:i,height:1})),l=(0,Wt.getPrescaledContext2D)(a);l.fillStyle=o,l.fillRect(0,0,i,1);const c=(0,Wt.createDisconnectedCanvas)(document,(0,Dt.size)({width:s,height:1})),h=(0,Wt.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(Mo.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,Io.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(Mo.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,kt.parseRgba)(t),s=(0,kt.parseRgba)(e),o=0===i[3]&&0===s[3]?"rgba(0,0,0,0)":(0,kt.rgbaToString)((0,kt.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 Lo,ko,Do=i(50279),Eo=i(80720),Bo=i(28331),Vo=i(66666),Ro=i(77336),No=i(12027),Oo=i(40443),Fo=i(94194),Wo=i(7983);!function(e){e[e.LabelRadius=9.5]="LabelRadius",e[e.LabelFontSize=11]="LabelFontSize"}(Lo||(Lo={})),function(e){e[e.Gear=0]="Gear",
e[e.Symbol=1]="Symbol",e[e.Auto=2]="Auto"}(ko||(ko={}));const Ho=(0,Yt.makeFont)(11,g.CHART_FONT_FAMILY),zo={enableTooltip:!0,showLabels:!0,enableMenu:!0,enableHighlight:!0};function Uo(e,t){return Math.max(1,Math.floor(e.borderSize*t))}class Go{constructor(e,t,i,s,o,n=null){this._invalidated=!0,this._size=(0,Dt.size)({width:0,height:0}),this._offset=0,this._axisInfo=null,this._onLabelHovered=new re.Delegate,this._highlighted=!1,this._labelMode=2,this._fixedLabelMode=null,this._textWidthCache=new jt.TextWidthCache(5),this._gearRenderer=(0,No.svgRenderer)(Wo),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 F.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={...zo,...o},this._properties.lineColor.subscribe(this,this._onPropertyChanged),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,Fo.setTooltipData)(this._cell,"text",(e=>this._tooltipContent())),this._onActiveOrHoveredChart.subscribe(d)),this._mouseEventHandler=new Et.MouseEventHandler(this._cell,this,{treatHorzTouchDragAsPageScroll:!0,treatVertTouchDragAsPageScroll:!0}),this._canvasBinding=(0,Wt.createBoundCanvas)(this._cell,(0,Dt.size)({width:16,height:16})),this._canvasBinding.subscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler);const m=this._canvasBinding.canvasElement;m.style.position="absolute",m.style.left="0",m.style.top="0",this._cell.setAttribute("aria-hidden","true")}destroy(){this._canvasBinding.unsubscribeSuggestedBitmapSizeChanged(this._canvasConfiguredHandler),this._canvasBinding.dispose(),this._properties.lineColor.unsubscribe(this,this._onPropertyChanged),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,
Dt.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._invalidated=!0),this._offset!==t&&(this._offset=t,this._cell.style.left=`${t}px`)}paint(e){e<yo.InvalidationLevel.Full&&!this._invalidated||0!==this._size.width&&0!==this._size.height&&(this._invalidated=!1,(0,Wt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),this._paintImpl((0,Wt.getContext2D)(this._canvasBinding.canvasElement),(0,Wt.getBindingRenderingInfo)(this._canvasBinding)))}getWidth(){return this._size.width}getImage(){const e=(0,Wt.getBindingRenderingInfo)(this._canvasBinding),t=(0,Wt.createDisconnectedCanvasByRenderingInfo)(document,e);return this._paintImpl((0,Wt.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._invalidated=!0))}_onPropertyChanged(){this._invalidated=!0}_drawVerticalBorder(e,t){e.save(),e.fillStyle=this._vertBorderColor();const i=Uo(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=Uo(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,Wt.clearRect)(e,0,0,o.width,o.height,i):(0,Ft.clearRectWithGradient)(e,0,0,o.width,o.height,i,s),this._highlighted){const t=k.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight");(0,Wt.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=Uo(this._rendererOptionsProvider.options(),r),c=Math.round(n.width)-l,h=Uo(this._rendererOptionsProvider.options(),a),d=Math.round(n.height)-h,u=(0,At.point)(l+c/2,h+d/2);if(1===this._labelMode||2===this._labelMode&&(!this._highlighted||i)){e.fillStyle=k.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=k.themes[s].getThemedColor("color-price-axis-label-text"),e.font=Ho,e.textAlign="center",e.textBaseline="middle";const t=this._textWidthCache.yMidCorrection(e,o.label);(0,Wt.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=k.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._labelOptions.showLabels&&this._labelOptions.enableHighlight&&this._setHighlighted(!0)}_mouseOrTouchLeaveEvent(e){this._labelOptions.showLabels&&this._labelOptions.enableHighlight&&this._setHighlighted(!1)}_mouseClickOrTapEvent(e){if(e.preventDefault(),null!==this._fixedLabelMode||1===this._labelMode||!this._labelOptions.enableMenu||!this._labelOptions.showLabels)return void Oo.ContextMenuManager.hideAll();this._fixedLabelMode=this._labelMode,this.setLabelMode(0);const t=this._cell.getBoundingClientRect();Oo.ContextMenuManager.showMenu(this._contextMenuItemsProvider(),{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.setLabelMode((0,n.ensureNotNull)(this._fixedLabelMode)),this._fixedLabelMode=null}))}}var jo=i(96152);class qo{constructor(e,t,i,s,o,n=null){this._axises=[],this._stubs=[],this._size=(0,Dt.size)({width:0,height:0}),this._onLabelHovered=new re.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={...zo,...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,jo.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,jo.getPriceAxisNameInfo)(this._side,this._stubs.length):null,t=new Go(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,Dt.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,Dt.size)({width:n,height:e}),i),i+=n}))}update(){this._axises.forEach((e=>e.update())),this._stubs.forEach((e=>e.update()))}paint(e){this._axises.forEach(((t,i)=>t.paint(e(i)))),this._stubs.forEach(((t,i)=>t.paint(e(i))))}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}highlightPriceAxisByLabel(e){this._axises.forEach((t=>{const i=t.axisInfo();t.setHighlighted(null!==i&&i.equals(e))}))}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,Wt.createDisconnectedCanvas)(document,this._size),t=(0,Wt.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 $o=i(55824),Ko=i(98714);class Yo{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=Ko["price-axis-currency-label-wrapper"],this._currencyAndUnitLabelsWrapper.setAttribute("data-name","currency-unit-label-wrapper"),this._controlsContainer=document.createElement("div"),this._controlsContainer.className=Ko["price-axis-currency-label"],this._currencyAndUnitLabelsWrapper.appendChild(this._controlsContainer),this._currencyLabelDiv=document.createElement("div"),this._currencyLabelDiv.classList.add(Ko.row,"apply-common-tooltip"),this._currencyLabelDiv.dataset.name="currency-label-selector",(0,Fo.setTooltipData)(this._currencyLabelDiv,"text",(e=>this._currencyTooltipContent())),this._currencyText=document.createElement("div"),this._currencyText.className=Ko["price-axis-currency-label-text"],this._currencyLabelDiv.appendChild(this._currencyText),this._currencyArrowDown=document.createElement("div"),this._currencyArrowDown.className=Ko["price-axis-currency-label-arrow-down"],this._currencyArrowDown.innerHTML=$o,this._currencyLabelDiv.appendChild(this._currencyArrowDown),this._measureUnitIdLabelDiv=document.createElement("div"),this._measureUnitIdLabelDiv.className=Ko.row,this._measureUnitIdLabelDiv.classList.add("apply-common-tooltip"),this._measureUnitIdLabelDiv.classList.add("readonly"),(0,Fo.setTooltipData)(this._measureUnitIdLabelDiv,"text",(e=>this._measureUnitIdTooltipContent())),this._measureUnitIdText=document.createElement("div"),this._measureUnitIdText.className=Ko["price-axis-currency-label-text"],this._measureUnitIdLabelDiv.appendChild(this._measureUnitIdText),this._unitLabelDiv=document.createElement("div"),this._unitLabelDiv.classList.add(Ko.row,"apply-common-tooltip"),this._unitLabelDiv.dataset.name="unit-label-selector",(0,Fo.setTooltipData)(this._unitLabelDiv,"text",(e=>this._unitTooltipContent())),this._unitText=document.createElement("div"),this._unitText.className=Ko["price-axis-currency-label-text"],this._unitLabelDiv.appendChild(this._unitText),this._unitArrowDown=document.createElement("div"),this._unitArrowDown.className=Ko["price-axis-currency-label-arrow-down"],this._unitArrowDown.innerHTML=$o,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(Ko.hidden)}setCurrencyExpanded(e){this._currencyLabelDiv.classList.toggle(Ko.expanded,e)}setUnitExpanded(e){this._unitLabelDiv.classList.toggle(Ko.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(Ko.css_wrapper_margin)*i),o=(0,Io.ceiledEven)(t*i)-2*s,n=Math.round(this.labelBottom()*i),r=n-2*s,a=Math.round(Number(Ko.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,Yt.makeFont)(this._fontSize,g.CHART_FONT_FAMILY);const c=new jt.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,Ft.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,m=u/2;let f=s+m;l.forEach(((t,s)=>{""!==t&&((0,Wt.drawScaled)(e,i,i,(()=>{e.fillText(t,p/i,(f+d[s])/i)})),f=Math.ceil(f+2*m))}))}setHidden(e){this._currencyAndUnitLabelsWrapper.classList.toggle(Ko.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(Ko.css_wrapper_margin)+Number(Ko.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 Zo(e,t,s,o){const{UnitConversionRenderer:n}=await Promise.all([i.e(9093),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(4600),i.e(1072),i.e(2736),i.e(3362),i.e(6164),i.e(8257),i.e(2227),i.e(9418),i.e(2544),i.e(2704)]).then(i.bind(i,28587));return new n(e,s,t,o)}async function Xo(e,t,s){const{CurrencyMenuResultEvents:o}=await i.e(5639).then(i.bind(i,19550));return new o(e,t,s)}var Jo=i(29023);class Qo{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 en extends Jo.Action{constructor(e,t){super(e),this._binding=new Qo({action:this,...t})}destroy(){this._binding.destroy(),super.destroy()}}var tn=i(73866),sn=i(56657),on=i(92158),nn=i(81199);i(82815);const rn=new Di.TranslatedString("change no overlapping labels",a.t(null,void 0,i(61557))),an=new Di.TranslatedString("toggle auto scale",a.t(null,void 0,i(42240))),ln=new Di.TranslatedString("toggle log scale",a.t(null,void 0,i(49403))),cn=a.t(null,void 0,i(88314)),hn=a.t(null,void 0,i(5119)),dn=a.t(null,void 0,i(59396)),un=a.t(null,void 0,i(15432)),_n=a.t(null,void 0,i(15332)),pn=a.t(null,void 0,i(24157)),mn=a.t(null,{context:"scale_menu"},i(34954)),gn=a.t(null,{context:"scale_menu"},i(35210)),fn=a.t(null,{context:"scale_menu"},i(31340)),yn=a.t(null,{context:"scale_menu"},i(55300)),vn=a.t(null,{context:"scale_menu"},i(19405)),Sn=a.t(null,{context:"scale_menu"},i(75163));const bn=function(e){const t=new tn.LimitedPrecisionNumericFormatter(e);return(e,i)=>(0,dt.isNumber)(i)&&!e.isLog()?t.format(i):""}(4),wn=l.enabled("currency_menu_disabled"),Cn=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 Tn,xn,In;!function(e){e[e.LabelOffset=4]="LabelOffset",e[e.DefaultOptimalWidth=34]="DefaultOptimalWidth",e[e.WheelScaleCoeff=15]="WheelScaleCoeff",e[e.CurrencyLabelFontSize=12]="CurrencyLabelFontSize"}(Tn||(Tn={})),function(e){e[e.Back=0]="Back",e[e.Top=1]="Top",e[e.All=2]="All"}(xn||(xn={}));class Mn{constructor(e,t,i,s,o,n,r,a,l){this._actions=null,this._priceScale=null,this._scaleModeButtons=null,this._widthCache=new jt.TextWidthCache(1e3),this._color=null,this._fontSize=null,this._isVisible=!0,this._currencyMenu=null,this._unitMenu=null,this._size=(0,Dt.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 F.WatchedValue(!1),this._selectedViaTap=new F.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())switch((0,on.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,dt.merge)((0,dt.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,Wt.createBoundCanvas)(this._cell,(0,Dt.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,Wt.createBoundCanvas)(this._cell,(0,Dt.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 Et.MouseEventHandler(this._cell,this,{treatVertTouchDragAsPageScroll:!1,treatHorzTouchDragAsPageScroll:!0}),this._options.currencyConversionEnabled||this._options.unitConversionEnabled?(this._currencyLabel=new Yo(12),this._cell.appendChild(this._currencyLabel.element())):this._currencyLabel=null,this._properties.childs().fontSize.subscribe(this,this._onFontSizeChanged),this._options.mouseWheelScale&&(this._mouseWheelHelper=new To,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,on.actualAutoLogButtonsVisibility)().subscribe(this,this._handleActualAutoLogButtonsVisibility),this._handleActualAutoLogButtonsVisibility((0,on.actualAutoLogButtonsVisibility)()).catch((()=>{})),this._chart.anyPriceAxisHovered().subscribe(this._recalcCurrencyAndUnitVisibility,{callWithLast:!0}),this._pane.visuallyCollapsed().subscribe(this._recalcCurrencyAndUnitVisibility,{callWithLast:!0}),this.update()}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 Jo.Separator),s.push(this._autoScaleAction()),this._isMainSeriesAxis()&&s.push(this._lockScaleAction()),s.push(i.scaleSeriesOnly,this._invertAction(),new Jo.Separator,this._regularScaleAction(),this._percentageAction(),this._indexedTo100Action(),this._logAction(),new Jo.Separator),ze.CheckMobile.any()||(s.push(this._createMergeScalesAction()),s.push(new Jo.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 Jo.Separator,t.alignLabels].filter(dt.notNull);s.push(new Jo.Action({actionId:"Chart.PriceScale.Labels",options:{label:hn,subItems:e}}))}return s.push((0,sn.createLinesAction)(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 Jo.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,Wt.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=.11111111111111,a=s.formatPrice(Math.min(i,n)-r,o),l=s.formatPrice(Math.max(i,n)+r,o);e=Math.max(e,this._widthCache.measureText(t,a),this._widthCache.measureText(t,l))}}}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,Dt.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,Wt.createDisconnectedCanvas)(document,e);return(0,Wt.getPrescaledContext2D)(t).drawImage(this._canvasBinding.canvasElement,0,0,e.width,e.height),null===this._currencyLabel||this._currencyLabel.isHidden()||this._currencyLabel.drawLabel((0,Wt.getContext2D)(t),e.width,(0,fo.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===yo.InvalidationLevel.None)return;const t=this._pane.state(),i=!t.maximized().value()&&t.collapsed().value();if(i&&e<yo.InvalidationLevel.Full)return;const s=this._pane.hasState();(0,Wt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),(0,Wt.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>yo.InvalidationLevel.Cursor){const e=(0,Wt.getContext2D)(this._canvasBinding.canvasElement),t=(0,Wt.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,Wt.getContext2D)(this._topCanvasBinding.canvasElement),t=(0,Wt.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,on.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,Yt.makeFont)(this.fontSize(),g.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._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 At.Point(e,t),c=(0,Wt.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,Wt.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,ne.trackEvent)("GUI","Currency conversion");const t=()=>{this._currencyMenu=null,this._recalcCurrencyAndUnitVisibility(),this._currencyLabel?.setCurrencyExpanded(!1)};if(wn)e=await Xo((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(9093),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(4600),i.e(1072),i.e(2736),i.e(3362),i.e(6164),i.e(8257),i.e(2227),i.e(9418),i.e(2544),i.e(2704)]).then(i.bind(i,75556));e=await Zo(dn,(()=>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,ne.trackEvent)("GUI","Unit conversion");const t=()=>{this._unitMenu=null,this._recalcCurrencyAndUnitVisibility(),this._currencyLabel?.setUnitExpanded(!1)};if(Cn)e=await Xo((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(9093),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(4600),i.e(1072),i.e(2736),i.e(3362),i.e(6164),i.e(8257),i.e(2227),i.e(9418),i.e(2544),i.e(2704)]).then(i.bind(i,59363));e=await Zo(un,(()=>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(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))}))}_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,ne.trackEvent)("GUI","Double click price scale"))}_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=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;Oo.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,Wt.clearRect)(e,0,0,o.width,o.height,this.backgroundColor()):(0,Ft.clearRectWithGradient)(e,0,0,o.width,o.height,i,s),this._highlighted){e.globalAlpha=.5;const t=k.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight");(0,Wt.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,Wt.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 nn.ActionWithStandardIcon({actionId:"Chart.PriceScale.Reset",options:{label:_n,iconId:"Chart.Reset",shortcutHint:(0,ct.humanReadableHash)(ct.Modifiers.Alt+82),statName:"ResetScale",onExecute:()=>this.reset()}}),i=new Jo.Action({actionId:"Chart.PriceScale.ToggleAutoScale",options:{label:pn,checkable:!0,checked:!0,statName:"ToggleAutoScale",onExecute:()=>{e.togglePriceScaleAutoScaleMode(this.priceScale()),this._updateScalesActions()}}}),s=new Jo.Action({actionId:"Chart.PriceScale.TogglePercentage",options:{label:mn,checkable:!0,checked:this.priceScale().isPercentage(),statName:"TogglePercantage",onExecute:()=>{
e.togglePriceScalePercentageScaleMode(this.priceScale()),this._updateScalesActions()}}}),o=new Jo.Action({actionId:"Chart.PriceScale.ToggleIndexedTo100",options:{label:gn,checkable:!0,checked:this.priceScale().isIndexedTo100(),statName:"ToggleIndexedTo100",onExecute:()=>{e.togglePriceScaleIndexedTo100ScaleMode(this.priceScale()),this._updateScalesActions()}}}),n=new Jo.Action({actionId:"Chart.PriceScale.ToggleLogarithmic",options:{label:fn,checkable:!0,checked:this.priceScale().isLog(),statName:"ToggleLogScale",onExecute:()=>{e.togglePriceScaleLogScaleMode(this.priceScale()),this._updateScalesActions()}}}),r=new Jo.Action({actionId:"Chart.PriceScale.ToggleRegular",options:{label:yn,checkable:!0,checked:this.priceScale().isRegular(),statName:"ToggleRegularScale",onExecute:()=>{e.setPriceScaleRegularScaleMode(this.priceScale()),this._updateScalesActions()}}}),a=new en({actionId:"Chart.PriceScale.Labels.ToggleNoOverlappingLabelsVisibility",options:{label:vn,checkable:!0,checked:this.priceScale().properties().childs().alignLabels.value(),statName:"TogglePreciseLabels"}},{property:this.priceScale().properties().childs().alignLabels,undoModel:e,undoText:rn}),l=new Jo.Action({actionId:"Chart.PriceScale.ToggleInvertScale",options:{label:Sn,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=bn(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 Jo.Action({actionId:"Chart.PriceScale.MergeAllScales",options:{label:cn,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(5446),i.e(2227),i.e(3555)]).then(i.bind(i,49976)),t=new e({className:"price-axis__modeButtons",setMode:e=>{this._priceScale&&("log"===e?this._chart.model().setPriceScaleMode({log:!this._priceScale.isLog()},this._priceScale,ln):this._chart.model().setPriceScaleMode({autoScale:!this._priceScale.isAutoScale()},this._priceScale,an))},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,Is.applyTransparency)(k.themes[this._backgroundBasedTheme.value()].getThemedColor("color-price-axis-highlight"),50),s=(0,kt.rgbaToString)((0,kt.blendRgba)((0,kt.parseRgba)(this.backgroundColor()),(0,kt.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 An(e,t){return e.position-t.position}function Ln(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"}(In||(In={}));class kn{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=Ln(this._position1,this._position2,this._maxSpeed),o=An(this._position1,this._position2),n=[s],r=[o];if(i+=o,null!==this._position3){const e=Ln(this._position2,this._position3,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=An(this._position2,this._position3);if(n.push(e),r.push(t),i+=t,null!==this._position4){const e=Ln(this._position3,this._position4,this._maxSpeed);if(Math.sign(e)===Math.sign(s)){const t=An(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)}}const Dn=(0,ae.getLogger)("Chart.ChartUndoModel");class En extends tt.UndoCommand{constructor(e,t,i,s=!0){super(i,!1,s),this._newRightOffsetAndBarSpacing=null,this._model=e,this._rightOffsetAndBarSpacing=t}undo(){if(null!==this._newRightOffsetAndBarSpacing)return void Dn.logDebug("TimeScaleChangeUndoCommand.undo: Command is already undone");const e=this._model.timeScale();this._newRightOffsetAndBarSpacing={barSpacing:e.barSpacing(),rightOffset:e.rightOffset()},e.setBarSpacing(this._rightOffsetAndBarSpacing.barSpacing),e.setRightOffset(this._rightOffsetAndBarSpacing.rightOffset),this._model.lightUpdate()}redo(){if(null===this._newRightOffsetAndBarSpacing)return void Dn.logDebug("TimeScaleChangeUndoCommand.redo: Command is not undone");const e=this._model.timeScale();e.setBarSpacing(this._newRightOffsetAndBarSpacing.barSpacing),e.setRightOffset(this._newRightOffsetAndBarSpacing.rightOffset),this._model.lightUpdate(),this._newRightOffsetAndBarSpacing=null}}const Bn=(0,ae.getLogger)("Chart.ChartUndoModel");var Vn;!function(e){e[e.MergeTimeout=1e3]="MergeTimeout"}(Vn||(Vn={}));const Rn=new Di.TranslatedString("scale price",a.t(null,void 0,i(94981)));class Nn extends tt.UndoCommand{constructor(e,t,i,s,o,n=!0){super(Rn,!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 Bn.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 Bn.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 Nn&&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 On,Fn=i(45579);function Wn(e,t){0}function Hn(e){Wn()}!function(e){e.Create="create",e.Paste="paste",e.Clone="clone"}(On||(On={}));var zn=i(38780),Un=i(81171);function Gn(e){return"startMoving"in e&&"move"in e&&"endMoving"in e&&"convertYCoordinateToPriceForMoving"in e}var jn=i(98017);let qn=null;function $n(){return qn}var Kn=i(17730),Yn=i(45982);i(26572);const Zn=parseInt(Yn["css-value-pane-controls-padding-left"]),Xn=parseInt(Yn["css-value-pane-controls-padding-right"]),Jn=(0,Lt.getHexColorByName)("color-cold-gray-700"),Qn=(0,Lt.getHexColorByName)("color-cold-gray-400"),er=new Di.TranslatedString("scroll",a.t(null,void 0,i(42070))),tr=a.t(null,void 0,i(66005));a.t(null,void 0,i(78972));function ir(e,t,i){e.drawBackground&&e.drawBackground(t,i)}function sr(e,t,i){e.draw(t,i)}function or(e,t){return e.paneViews(t)}function nr(e,t){return e.topPaneViews?.(t)??[]}function rr(e,t){return e.labelPaneViews(t)}function ar(e,t){const i=e.strategyOrdersPaneView();return null===i?null:[i]}function lr(e,t){return null===e||e.source!==t?null:e.hittest.data()}function cr(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 hr={contextMenuEnabled:!0,contextMenu:sn.defaultContextMenuOptions,priceScaleContextMenuEnabled:!0,legendWidgetEnabled:!0,controlsEnabled:!0,propertyPagesEnabled:!0,sourceSelectionEnabled:!0,countdownEnabled:!0},dr=new Map([[Vt.AreaName.Text,"Text"],[Vt.AreaName.Style,"Style"]]),ur=!l.enabled("display_legend_on_all_charts");var _r;!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"}(_r||(_r={}));let pr=null;function mr(e,t){return!(0,Vt.shouldDefaultActionBeExecuted)(e,t,"pressedMouseMoveHandler","touchMoveHandler")}var gr;!function(e){e[e.None=0]="None",e[e.DownWithoutMove=1]="DownWithoutMove",e[e.DownWithMove=2]="DownWithMove"}(gr||(gr={}));class fr{constructor(e,t,i,s){
this._legendWidget=null,this._paneControls=null,this._isDestroyed=!1,this._trackCrosshairOnlyAfterLongTap=(0,vo.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,Dt.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._highlightedPriceAxis=new F.WatchedValue({owner:"",axis:null}),this._visuallyCollapsed=new F.WatchedValue(!1),this._maximized=new F.WatchedValue(!1),this._endOfSeriesDataBanner=null,this._selectionBeforeMouseDown=new WeakSet,this._mouseTouchDownUpInfo=null,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,dt.merge)((0,dt.clone)(hr),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 Mn(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:()=>[],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()===Bi.PaneMode.Regular?new qo(a,"left",r,h,d):new PaneWidgetSideArea(c,"left"),this._rhsPriceAxisesContainer=t.mode()===Bi.PaneMode.Regular?new qo(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,Wt.createBoundCanvas)(this._div,(0,Dt.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,Wt.createBoundCanvas)(this._div,(0,Dt.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._updateAccesibilityAttr),p.onIntervalChanged().subscribe(this,this._updateAccesibilityAttr),this._updateAccesibilityAttr(),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,Un.magnetEnabled)().subscribe(this._onMagnetStateChangedListener),(0,js.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._chartModel().dragExportEnabled().value()&&(0,W.emit)("dragend")})),_.addEventListener("dragstart",(async e=>{if(!this._chartModel().dragExportEnabled().value())return void e.preventDefault();e.stopPropagation();const t=this._chartUndoModel().model().hoveredSource(),i=$n();(0,W.emit)("dragstart",{preventDefault:()=>e.preventDefault(),hoveredSourceId:t?.id()??null,exportData:e=>{const t=e=>s().convertPublicTimeToInternalTime(e),s=()=>(0,Kn.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")||e.preventDefault()}))),this.setCursorForTool(),this._mouseEventHandler=new Et.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{isMouseMoveHandlingEnabled:()=>!this._chartModel().dragExportEnabled().value(),treatVertTouchDragAsPageScroll:!this._options.handleScroll.vertTouchDrag,treatHorzTouchDragAsPageScroll:!this._options.handleScroll.horzTouchDrag}),this._paneCellMouseEventHandler=new Et.MouseEventHandler(this._paneCell,{doubleTapEvent:this._paneDblClickOrTapEvent.bind(this),mouseDoubleClickEvent:this._paneDblClickOrTapEvent.bind(this)}),this._prevHoveredHittest=null,this._highlightedPriceAxis.subscribe((e=>this._highlightPriceAxisByLabel(e.axis))),this._prevPinchScale=0,this._isDestroyed=!1;const m=(0,Ji.combine)((()=>{const e=this._chart.paneWidgetSeparators(this);return[e.separatorAbove?.selected()?.weakReference()??new F.WatchedValue(!1).ownership(),e.separatorBelow?.selected()?.weakReference()??new F.WatchedValue(!1).ownership()]}),this._chart.paneWidgetsWV().weakReference());this._anySeparatorSelected=(0,Ji.accumulate)((e=>e.some(Boolean)),m.ownership())}destroy(){this._chart.onPaneWidgetDestroyed(this);const e=this._chartModel().mainSeries();e.dataEvents().symbolResolved().unsubscribeAll(this),e.onIntervalChanged().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,Un.magnetEnabled)().unsubscribe(this._onMagnetStateChangedListener),(0,js.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._isDestroyed=!0}updateOptions(e){if((0,dt.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===Bi.PaneMode.Regular&&!(this._lhsPriceAxisesContainer instanceof qo)){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 Mn(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:()=>[],titlesProvider:()=>[],rendererOptionsProvider:i,getBackgroundTopColor:r,getBackgroundBottomColor:n,requestRepaint:()=>this._chartModel().lightUpdate()};this._lhsPriceAxisesContainer=new qo(o,"left",s,a,e),this._rhsPriceAxisesContainer=new qo(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!==Bi.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,Dt.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()}highlightedPriceAxis(){return this._highlightedPriceAxis}processDoubleClickOnSource(e,t,i){if((0,eo.isEditableTextLineTool)(e)){const t=e.textEditingActivationTime()
;null!==t&&performance.now()-t<500&&e.deactivateTextEditing()}(0,Vo.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 qt.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case qt.PaneCursorType.HorizontalResize:this._setCursorClassName("ew-resize");break;case qt.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case qt.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize");break;case qt.PaneCursorType.Default:this._setCursorClassName("default");break;case qt.PaneCursorType.Pointer:this._setCursorClassName("pointer");break;case qt.PaneCursorType.Grabbing:this._setCursorClassName("grabbing");break;case qt.PaneCursorType.Text:this._setCursorClassName("text")}return}const s=lt.tool.value();if((0,lt.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(lt.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 n=e[0],r=(0,dt.merge)((0,dt.clone)(this._options.contextMenu),i||{}),a=new sn.ActionsProvider(this._chart,r);if(n===this._chartUndoModel().crosshairSource())return n.handleContextMenuEvent(t),Promise.resolve(null);{const i=await a.contextMenuActionsForSources(e,this._state,t,s?.origin,o?.data()?.customActions);if(0===i.length)return Promise.resolve(null);{let e;return e=n instanceof jn.Series?{menuName:s?.origin??"ObjectTreeContextMenu",detail:{type:"series",id:n.instanceId()}}:(0,eo.isLineTool)(n)?{menuName:s?.origin??"ObjectTreeContextMenu",detail:{type:"shape",id:n?.id()??null}}:{menuName:s?.origin??"ObjectTreeContextMenu",detail:{type:"study",id:n?.id()||null}},Oo.ContextMenuManager.createMenu(i,{takeFocus:!0,returnFocus:!0,isKeyboardEvent:r.isKeyboardEvent},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._updateAccesibilityAttr()))}getScreenshotData(e){const t=[],i=[];let s,o=[];const n=this.state(),r=n.mode()===Bi.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,Js.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()){s=c.statusProvider(e?.status||{}).text();const t=l.enabled("use_last_visible_bar_value_in_legend")?this._chartModel().timeScale().visibleBarsStrictRange()?.lastBar()??null:null;o=c.legendValuesProvider().getValues(t)}}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()===Bi.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()===Bi.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,Wt.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!==pr&&pr.stateId===this.state().id()&&Math.abs(pr.x-e.localX)+Math.abs(pr.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()!==lt.SelectPointMode.None?this.startTrackingMode(new At.Point(e.localX,e.localY),new At.Point(e.localX,e.localY)):!this._chart.readOnly()&&null!==i&&(0,eo.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._pressedMouseOrTouchMoveEvent(e)}touchMoveEvent(e){this._preventTouchEventsExceptPinch()||(this._onTouchEvent(),this._pressedMouseOrTouchMoveEvent(e))}mouseLeaveEvent(e){this._onMouseEvent(),this._updateHoveredSource(null,new Bo.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)<=Vt.HitTarget.MovePointBackground)return;const i=new Bo.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,lr(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 At.Point(e.localX,e.localY),new At.Point(e.localX,e.localY),new Bo.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 Bo.EnvironmentState(e)),this.setCursorPosition(e.localX,e.localY,new Bo.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._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){if(!this._chartUndoModel()||!this.hasState()||0===this._size.width||0===this._size.height)return;(0,Wt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),(0,
Wt.tryApplySuggestedCanvasBitmapSize)(this._topCanvasBinding),this._state&&(e.priceScaleSideMaxLevel("left")>yo.InvalidationLevel.Cursor||e.priceScaleSideMaxLevel("right")>yo.InvalidationLevel.Cursor)&&(this._recalculatePriceScales((0,Bt.viewportChangeEvent)(this.state())),null!==pr&&pr.stateId===this.state().id()&&this.setCursorPosition(pr.x,pr.y,pr.envState));const t=e.fullInvalidation();if(t>yo.InvalidationLevel.Cursor&&null!==pr&&pr.stateId===this.state().id()){const e=this._dataSourceAtPoint(pr.x,pr.y);this._updateHoveredSource(e,(0,js.globalEnvironmentState)())}if(this._lhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("left")),this._rhsPriceAxisesContainer.paint(e.getterForPriceScaleInvalidationLevelBySide("right")),t===yo.InvalidationLevel.None)return;const i=this._state&&(this._state.maximized().value()||!this._state.collapsed().value()||this._state.mode()===Bi.PaneMode.Widget);if(t>yo.InvalidationLevel.Cursor){const e=(0,n.ensureNotNull)(this._canvasBinding.canvasElement.getContext("2d"));e.setTransform(1,0,0,1,0,0);const t=(0,Wt.getBindingRenderingInfo)(this._canvasBinding);this._makeSureIsUpdated(t),this._drawBackground(e,t),i&&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,Wt.getBindingRenderingInfo)(this._topCanvasBinding);e.clearRect(0,0,t.bitmapSize.width,t.bitmapSize.height),i&&this._drawTopViews(e,t),this._drawCrossHair(e,t),i&&this._drawActiveLineTools(e,t)}}cancelCreatingLineTool(){const e=this._chartUndoModel(),t=this._chartUndoModel().lineBeingCreated();if(t)if(t.pointsCount()<=0&&!(0,wt.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){this.hasState()&&(await(0,Ro.ensureLineToolLoaded)(e),this._chartUndoModel().drawRightThere(e,this.state()))}cancelMeasuring(){this._chartUndoModel().crosshairSource().clearMeasure(),(0,lt.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()?Qn:Jn,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,lt.toolIsMeasure)(lt.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,lt.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"===lt.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,lt.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition()}_tryFinishZoom(e){return null!==this._firstZoomPoint&&(this._finishZoom(e),!0)}_tryHandleEraserMouseDown(e,t){if(!("eraser"!==lt.tool.value()||e.isCustom||(i=e.source,i&&i.customization&&i.customization.disableErasing))){const i=this._chartUndoModel();if((0,eo.isLineTool)(e.source)||(0,Js.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,eo.isLineTool)(t.source)&&o.target()===Vt.HitTarget.ChangePoint){const r=this._chartUndoModel(),a=(0,n.ensure)(this.state().mainDataSource()?.firstValue()),l=(0,n.ensureNotNull)(t.source.priceScale()).coordinateToPrice(e.localY,a);r.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(t.source,o.data())}));let c=l;t.source.priceScale()===r.mainSeries().priceScale()&&(c=r.model().magnet().align(l,s,this.state()));const h=o.data()?.nonDiscreteIndex;h&&(s=r.timeScale().coordinateToFloatIndex(e.localX));const d=o.data()?.pointIndex;return this._startChangeLineToolParams={source:t.source,startPoint:{index:s,price:c,
nonDiscreteIndex:h},screenPoint:{x:e.localX,y:e.localY},pointIndex:d,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 At.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 At.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=lr(i,s)),e.addSourceToSelection(s,t)}))}));const r=new At.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=lt.tool.value();if(!this.hasState()||(0,wt.isLineToolDrawWithoutPoints)(o)||this.state().mode()===Bi.PaneMode.Widget)return;const r=this._chartUndoModel();let a=!1,l=null;(0,lt.hideAllDrawings)().value()&&(0,ks.toggleHideMode)(),(0,lt.lockDrawings)().setValue(!1),e.isTouch&&!e.stylus&&((0,wt.isLineToolName)(o)&&!(0,wt.isLineDrawnWithPressedButton)(o)||r.lineBeingCreated())&&this._initToolCreationModeParams(e);const c=r.lineBeingCreated();if(c&&!(0,wt.isLineDrawnWithPressedButton)(c.toolname)){const o=(0,n.ensure)(c.ownerSource()?.firstValue());if(e.isTouch&&!e.stylus){if(!this._startTouchPoint){this._startTouchPoint=new At.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 At.Point(s,a))}}else if(!e.isTouch){l=c;const h=r.model().paneForSource(c);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,wt.isLineDrawnWithPressedButton)(o);if(!e.isTouch||e.stylus||t){const e=null===c||(0,eo.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}),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()>=Vt.HitTarget.MovePointBackground:t.hittest.target()>Vt.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,ne.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,zn.hide)(t);if(this._prevTooltipData&&(0,Do.default)(i,this._prevTooltipData))return;this._prevTooltipData=i;const s=(0,dt.clone)(i);if(void 0!==s.rect){const e=this._paneCell.getBoundingClientRect();s.rect.x+=e.left,s.rect.y+=e.top}(0,zn.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();pr={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,wt.isLineToolName)(lt.tool.value())||(0,lt.toolIsMeasure)(lt.tool.value())||e.startMeasurePoint()&&!e.endMeasurePoint()||null!==this._firstZoomPoint||null!==this._chartModel().lineBeingEdited()||null!==this._chartModel().lineBeingCreated()}_clearCursorPosition(){pr=null,this._chartModel().clearCurrentPosition()}_dataSourceAtPoint(e,t){if(!this.hasState())return null;const i={result:null},s=this._chartUndoModel();if((0,wt.isLineToolName)(lt.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,Wt.getBindingRenderingInfo)(this._canvasBinding);this._makeSureIsUpdated(r);const a=cr.bind(null,i),l=new At.Point(e,t);if(!n.maximized().value()&&n.collapsed().value()||(0,vo.lastMouseOrTouchEventInfo)().isTouch&&(lt.activePointSelectionMode.value()!==lt.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(Eo.CustomSourceLayer.Topmost),l,a,!0,o),this._hitTestSources(r,c.tradingSources(),l,a,!1,o),this._hitTestSources(r,n.customSources(Eo.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&&cr(i,t,e,s,!1)}}}}return null===i.result&&this._hitTestSources(r,n.customSources(Eo.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(Gn);const h=c.filter((e=>(0,eo.isLineTool)(e)&&!e.isSourceHidden()));c=h.length>0?h:c.includes(t.source)?[t.source]:[c[0]];const d=new At.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(er),null===this._scrollXAnimation&&this._options.useKineticScroll&&(this._scrollXAnimation=new kn(.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,wt.isLineToolName)(lt.tool.value())||Boolean(this._chartUndoModel().lineBeingCreated())||null!==this._startTrackPoint||this._preventScrollUntilNextMouseDownOrTouchStart}_isSelectPointModeEnabled(){return this._chartUndoModel().crosshairSource().selectPointMode().value()!==lt.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===lt.tool.value()&&(0,lt.resetToCursor)(),this._preventCrossHairMove()&&this._clearCursorPosition(),i.selectionMacro((i=>{i.addSourceToSelection(e,lr(t,e))})),(0,eo.isEditableTextLineTool)(e)&&e.activateEditingOnCreation())e.activateTextEditingOn(this._div,!0);else if((0,wt.isTextToolName)(s)){const t=i.createUndoCheckpoint();this._chart.showChartPropertiesForSource(e,Zs.TabNames.text,void 0,t)}this._lastFinishedToolId=e.id(),(0,W.emit)("drawing_event",e.id(),"create"),Hn()}_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,Js.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 At.Point(t,i),logical:{index:a,price:l}},s)}))}_resetMeasureIfRequired(){this._needResetMeasureLater&&((0,lt.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()===Bi.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,Wt.clearRect)(e,0,0,t.bitmapSize.width,t.bitmapSize.height,r)}else s===o?(0,Wt.clearRect)(e,0,0,t.bitmapSize.width,t.bitmapSize.height,o):(0,Ft.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===lt.crosshairLock.value()||i.updateAllViews((0,Bt.sourceChangeEvent)(i.id())),this._drawSourceImpl(e,t,or,sr,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,Vo.isDataSource)(o)&&o.isMultiPaneEnabled())&&this._drawSourceImpl(e,t,or,sr,o)}}_drawTopViews(e,t){
for(const i of this.state().sourcesByGroup().all())i.topPaneViews&&this._drawSourceImpl(e,t,nr,sr,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(Eo.CustomSourceLayer.Background).slice(),c=i.customSources(Eo.CustomSourceLayer.Foreground).slice(),h=i.customSources(Eo.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,or,sr,s.gridSource()),this._drawWatermark(e,t);for(const i of l)this._drawSourceImpl(e,t,or,ir,i);for(const i of r)this._drawSourceImpl(e,t,or,ir,i);for(const i of c)this._drawSourceImpl(e,t,or,ir,i);for(const i of a)this._drawSourceImpl(e,t,or,ir,i);const _=new Set;[s.lineBeingCreated(),s.lineBeingEdited(),...s.sourcesBeingMoved(),s.customSourceBeingMoved()].filter(dt.notNull).forEach((e=>_.add(e.id())));let p=s.hoveredSource();null!==p&&((0,Vo.isDataSource)(p)&&!p.showOnTopOnHovering()||_.has(p.id())||(0,Vo.isDataSource)(p)&&!r.includes(p)?p=null:_.add(p.id()));const m=s.selection().allSources().filter((e=>!((0,Vo.isDataSource)(e)&&!r.includes(e))&&!_.has(e.id())));m.forEach((e=>_.add(e.id())));for(const i of l)this._drawSourceImpl(e,t,or,sr,i,_);for(const i of r)this._drawSourceImpl(e,t,or,sr,i,_);for(const i of c)this._drawSourceImpl(e,t,or,sr,i,_);d&&this.containsMainSeries()&&this._drawSourceImpl(e,t,ar,sr,d,_),u&&this._drawSourceImpl(e,t,ar,sr,u,_);for(const i of n)this._drawSourceImpl(e,t,or,ir,i);for(const i of h)this._drawSourceImpl(e,t,or,ir,i);for(const i of r)this._drawSourceImpl(e,t,rr,sr,i,_);for(const i of c)this._drawSourceImpl(e,t,rr,sr,i,_);for(const i of n)this._drawSourceImpl(e,t,or,sr,i,_);for(const i of h)this._drawSourceImpl(e,t,or,sr,i,_);for(const i of m)this._drawSourceImpl(e,t,or,sr,i),i===d&&this.containsMainSeries()&&this._drawSourceImpl(e,t,ar,sr,d);for(const i of m)this._drawSourceImpl(e,t,rr,sr,i);p&&(this._drawSourceImpl(e,t,or,sr,p),p===d&&this.containsMainSeries()&&this._drawSourceImpl(e,t,ar,sr,d),this._drawSourceImpl(e,t,rr,sr,p));for(const i of a)this._drawSourceImpl(e,t,or,sr,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 ot))return!1;if(t.isEmpty())return!1;const i=t.commands()[0];return i instanceof Nn||i instanceof En}_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,Vt.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,ne.trackEvent)("chart_alert","edit","start_change_line_tool_params"),this._chartUndoModel().startChangingLinetool(e.source,e.startPoint,e.pointIndex,e.envState)}if(null!==this._startMoveSourceParams){const e=this._startMoveSourceParams;(0,ne.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,Wt.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),!this._isSelectPointModeEnabled()||o||e.isTouch&&this.trackingModeEnabled()&&!this._exitTrackingModeOnNextTry||s.crosshairSource().trySelectCurrentPoint();const r=this._sourceWasSelected(t);!(0,wt.isLineToolName)(lt.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,eo.isLineTool)(i)&&this._lastFinishedToolId!==i.id()&&(0,W.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,W.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 Bo.EnvironmentState(e);s.mainSeries().clearGotoDateResult();const r=this.state().defaultPriceScale();if(s.timeScale().isEmpty())return;const a=s.crosshairSource();if(!e.isTouch&&!(0,wt.isLineDrawnWithPressedButton)(lt.tool.value())){const t=s.lineBeingCreated(),i=null!==t?s.model().paneForSource(t):null;null!==i&&i!==this._state?this._setCursorPositionOnExternalPane(i,e.localX,e.localY,o):this.setCursorPosition(e.localX,e.localY,o)}e.isTouch&&(0,wt.isLineToolName)(lt.tool.value())&&((0,wt.isLineDrawnWithPressedButton)(lt.tool.value())||null!==a.pane?(0,wt.isLineDrawnWithPressedButton)(lt.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,lt.toolIsCursor)(lt.tool.value())){const e=s.selection().isEmpty();(null===t||e&&!t.hittest.data()?.hasOwnShortcutsBehaviourFor?.shiftKey)&&(lt.tool.setValue("measure"),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 At.Point(e.localX,e.localY)):this._isSelectPointModeEnabled()&&null===this._chart.trackingModePaneWidget()&&this.startTrackingMode(new At.Point(e.localX,e.localY),new At.Point(e.localX,e.localY),new Bo.EnvironmentState(e))),e.isTouch&&(this._preventSourceChange=null===t||!s.selection().isSelected(t.source)),!this._isSelectPointModeEnabled()&&!this._isScrolling){if(e.isTouch&&!e.stylus&&((0,lt.toolIsMeasure)(lt.tool.value())||null!==a.measurePane().value()))return void this._initToolCreationModeParams(e);if(null!==c&&((0,
wt.isLineToolName)(lt.tool.value())||s.lineBeingCreated()))return o.shift()||s.selectionMacro((e=>e.clearSelection())),void this._mouseDownEventForLineTool(e,o,h,c)}if((0,lt.toolIsDemonstration)(lt.tool.value())&&o.altOnly()){e.isTouch&&!this.trackingModeEnabled()&&this.startTrackingMode(new At.Point(e.localX,e.localY),new At.Point(e.localX,e.localY),new Bo.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===Vt.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,eo.isLineTool)(t.source)&&t.source.isLocked&&t.source.isLocked();if(!((0,lt.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;if(void 0!==s&&null!==l&&(u=(0,n.ensure)(t.source?.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())===Vt.HitTarget.MovePoint||d===Vt.HitTarget.MovePointBackground&&(0,vo.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,Fn.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()===Vt.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,Wt.getBindingRenderingInfo)(this._canvasBinding));s.selectionMacro((t=>{let i=null;e.forEach((e=>{null===i&&(i=lr(l,e)),t.addSourceToSelection(e,i)}))})),a.clearSelection(),(0,ne.trackEvent)("GUI","Multiselect","Area Select")}(0,W.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 Bo.EnvironmentState(e),d=lt.tool.value();if(e.isTouch&&((0,lt.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,wt.isLineDrawnWithPressedButton)(d)&&(0,wt.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}));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,wt.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 Bo.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,Vt.tryCallHandler)(e,{sourceWasSelected:t},o.mouseUpHandler,o.touchEndHandler),this.setCursorForTool()}if(r.setMovingCustomSource(null,null),mr(e,o))return}if(r.lineBeingEdited())return s.endChangingLinetool(!1),
void(this._preventCrossHairMove()&&this._clearCursorPosition());if((0,wt.isLineDrawnWithPressedButton)(d)&&!this._isSelectPointModeEnabled()){const t=s.lineBeingCreated();null!==t&&(Hn(),t.finish(),"LineToolBrush"===t.toolname&&(0,W.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(eo.isLineTool).forEach((e=>{this.setCursorForTool(e)})),void r.invalidate(yo.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()===Bi.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()>Vt.HitTarget.MovePointBackground||(0,vo.lastMouseOrTouchEventInfo)().isTouch)&&s.selectionMacro((e=>{e.clearSelection();const t=(0,n.ensureNotNull)(l.source);e.addSourceToSelection(t,lr(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 At.Point(s,o);const n=new Bo.EnvironmentState(e);if(null===this._firstZoomPoint){if(this._updateHoveredSource(t,n,e),!e.isTouch&&i.lineBeingCreated()){
const e=i.lineBeingCreated(),t=null===e?null:i.model().paneForSource(e);if(null!==t&&t!==this._state)return void this._setCursorPositionOnExternalPane(t,s,o,n)}e.isTouch||this.setCursorPosition(s,o,n)}else this._processMouseMoveWhileZoom(e,n)}_pressedMouseOrTouchMoveEvent(e){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 Bo.EnvironmentState(e),i=this._chartUndoModel(),s=i.crosshairSource(),o=e.localX,r=e.localY;if(this._prevMoveEventPosition=new At.Point(o,r),null!==this._firstZoomPoint)return this._processMouseMoveWhileZoom(e),void(this._firstZoomPoint.draggingMode=!0);const a=lt.tool.value();if(e.isTouch&&this._startTouchPoint&&(0,wt.isLineToolName)(a)&&!(0,wt.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,lt.toolIsMeasure)(a)||null!==l))return void(e.stylus?this.setCursorPosition(e.localX,e.localY,new Bo.EnvironmentState(e)):this._updateCrosshairPositionInToolCreationMode(e,l||this.state()));const c=i.lineBeingCreated();if(e.isTouch&&!e.stylus&&c&&!(0,wt.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 At.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,wt.isLineToolName)(a)&&!(0,wt.isLineDrawnWithPressedButton)(a)&&!h&&!t.mod())return;if((0,wt.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())return;if(i.customMoveBeingProcessed())return void i.processCustomMove(e);const _=i.model().customSourceMovingHitTestData();if(null!==_&&(this._updateCommonTooltip(null,!0),_.cancelled||(i.model().processingCustomSourceMove(),(0,Vt.tryCallHandler)(e,{sourceWasSelected:this._selectionBeforeMouseDown.has(i.model().customSourceBeingMoved())},_.pressedMouseMoveHandler,_.touchMoveHandler)),mr(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 Bo.EnvironmentState(e),p))return;const m=(0,lt.toolIsMeasure)(a)||s.startMeasurePoint()&&s.endMeasurePoint();this._chart.readOnly()||!t.mod()||(0,wt.isLineToolName)(a)||m||h?(this._processScroll(e),this._preventScroll()&&!this._preventCrossHairMove()&&null===this._startTrackPoint&&this.setCursorPosition(e.localX,e.localY,new Bo.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,Vt.tryCallHandler)(e,{sourceWasSelected:t},this._prevHoveredHittest.hittest.data()?.mouseLeaveHandler),this._prevHoveredHittest=null}this._updateCommonTooltip(null),this._chart.unsetActivePaneWidget()}_mouseDoubleClickOrDoubleTapEvent(e){if(!this.hasState())return;const t=!this._chart.readOnly()&&!(0,wt.isLineToolName)(lt.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()>Vt.HitTarget.MovePointBackground))t.hittest.tryCallDblClickOrDblTapHandler(e,{sourceWasSelected:i})&&!(0,Vt.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,wt.isLineToolName)(lt.tool.value())&&!this._chartUndoModel().lineBeingCreated()&&this._chartUndoModel().selection().isEmpty()){const t=this.state();new Bo.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,lt.resetToCursor)(!0)
;if(this._pinching)return;if(null===this._firstZoomPoint||this._trackCrosshairOnlyAfterLongTap||this.cancelZoom(),!(0,lt.toolIsCursor)(lt.tool.value())||this._isSelectPointModeEnabled()){if(e.isTouch)return;return(0,lt.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>=Vt.HitTarget.Regular||o>=Vt.HitTarget.MovePointBackground&&e.isTouch;if(t.selectionMacro((t=>{null!==s&&n?t.selection().isSelected(s)||(t.clearSelection(),t.addSourceToSelection(s,lr(i,s))):(this._options.contextMenu.general&&this._showContextMenu(e),t.clearSelection())})),null!==i&&n&&null!==s)if((0,Vo.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 At.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 At.Point(e.localX,e.localY),new At.Point(i.x,e.localY),new Bo.EnvironmentState(e))}}async _showContextMenu(e){const t=e=>e instanceof Jo.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 Jo.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),Oo.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 Jo.Separator)),!this.state().isEmpty()&&l.enabled("datasource_copypaste")&&this.state().mode()===Bi.PaneMode.Regular){const t=(0,sn.createActionCopyPrice)(this.state(),e.localY),s=(0,sn.createPasteAction)(this._chart,this.state());(t||s)&&(t&&i.push(t),s&&i.push(s),
i.push(new Jo.Separator))}i[i.length-1]instanceof Jo.Separator||i.push(new Jo.Separator),l.enabled("text_notes")&&i.push(t.addToTextNotes),i[i.length-1]instanceof Jo.Separator||i.push(new Jo.Separator),i.push(this._createLockTimeAxisAction(e)),i.push(new Jo.Separator),i[i.length-1]instanceof Jo.Separator||i.push(new Jo.Separator),this._chart.applyIndicatorsToAllChartsAvailable()&&(i.push(t.applyStudiesToAllCharts),i.push(new Jo.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 Jo.Separator),i.push(t.hideAllMarks),i.push(new Jo.Separator),l.enabled("show_chart_property_page")&&i.push(t.chartProperties),i[i.length-1]instanceof Jo.Separator&&i.pop(),i}_loadAndCreateLegendWidget(){Promise.all([i.e(2199),i.e(4178),i.e(8985),i.e(6489),i.e(9753),i.e(4170),i.e(2227),i.e(7973),i.e(5093)]).then(i.bind(i,60786)).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};const s=(0,Ji.combine)(((e,t)=>ur&&this._chart!==e&&!t),this._chart.chartWidgetCollection().activeChartWidget.weakReference(),this._chart.chartWidgetCollection().lock.crosshair.weakReference()),o=(0,Ji.combine)(((e,t)=>null!==e?e===this._state:(0,lt.toolIsMeasure)(t)),this._chartModel().crosshairSource().measurePane().weakReference(),lt.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(2199),i.e(4178),i.e(8985),i.e(6489),i.e(9753),i.e(4170),i.e(2227),i.e(7973),i.e(5093)]).then(i.bind(i,61560)).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+Zn+Xn;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(Bo.EnvironmentState.create((0,js.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,wt.isLineToolName)(lt.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?(lt.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(Zs.TabNames.symbol);else if((0,eo.isLineTool)(e)||(0,Js.isStudy)(e)){let i;const s=t?.data();if(null!=s){const e=s.areaName;void 0!==e&&(i=dr.get(e))}this._chart.showChartPropertiesForSource(e,i).then((e=>{this._editDialog=e}))}}_initToolCreationModeParams(e){this._startTouchPoint=new At.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 At.Point(s,o).subtract((0,n.ensureNotNull)(this._startTouchPoint)),l=r.add(a);this.setCursorPosition(l.x,l.y,new Bo.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,eo.isLineTool)(i)||t.recalculatePriceScale(i.priceScale(),e)}_createLockTimeAxisAction(e){const t=0===lt.crosshairLock.value()?.type;return new Jo.Action({actionId:"Chart.Crosshair.LockVerticalCursor",options:{label:tr,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 lt.crosshairLock.setValue({type:0,time:s})}lt.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,eo.isLineTool)(e.source))||this._editDialog&&this._editDialog.visible().value())a&&(o.setHoveredSource(null,null),this.setCursorForTool());else{const l=lt.tool.value();let c=null;if(!this._processing&&((0,lt.toolIsCursor)(l)||"eraser"===l&&!a||t.mod()||!s.lineBeingCreated())){const t=e?.hittest;n=Boolean(t?.data()?.hideCrosshairLinesOnHover),t&&t.target()>Vt.HitTarget.MovePointBackground?(c=r,!r?.isHoveredEnabled()||"eraser"===l&&r===s.mainSeries()?o.setHoveredSource(null,null):o.setHoveredSource(r,t.data(),0)):o.setHoveredSource(null,null)}a?this.setCursorForTool(c,t,qt.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 qt.PaneCursorType.VerticalResize:this._setCursorClassName("ns-resize");break;case qt.PaneCursorType.HorizontalResize:this._setCursorClassName("we-resize");break;case qt.PaneCursorType.DiagonalNeSwResize:this._setCursorClassName("nesw-resize");break;case qt.PaneCursorType.DiagonalNwSeResize:this._setCursorClassName("nwse-resize")}}}this._preventCrossHairMove()&&this._clearCursorPosition(),1!==this._pressedMoveStage&&o.crosshairSource().setLinesShouldBeHidden(n)}async _createErrorBlock(){const e=new(await no())
;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,W.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 Jo.Separator:new Jo.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}_highlightPriceAxisByLabel(e){this._state?.mode()===Bi.PaneMode.Regular&&(this._lhsPriceAxisesContainer.highlightPriceAxisByLabel(e),this._rhsPriceAxisesContainer.highlightPriceAxisByLabel(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)}_updateAccesibilityAttr(){if(this.hasState()&&this.state().isMainPane().value()){const e=this._chartModel().mainSeries(),t=e.symbol(),s=(0,es.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,eo.isEditableTextLineTool)(t.source)){const e=t.source.textEditingActivationTime();null!==e&&performance.now()-e<500&&this.processDoubleClickOnSource(t.source,t.hittest)}}}class yr{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 vr,Sr=i(55158),br=i(95700);i(60070);!function(e){e[e.BorderSize=1]="BorderSize",e[e.OffsetSize=5]="OffsetSize"}(vr||(vr={}));const wr={contextMenuEnabled:!0,timezoneMenuEnabled:!0,pressedMouseMoveScale:!0},Cr=new Di.TranslatedString("change session",a.t(null,void 0,i(87041))),Pr=a.t(null,void 0,i(94031));class Tr{constructor(e,t,i,s,o){this._rendererOptions=null,this._onLabelHovered=new re.Delegate,this._mousedown=!1,this._currentCursorClassName="invalid",this._options=(0,dt.merge)((0,dt.clone)(wr),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:(e,t)=>{const i=s(e,t),o=this.getContextMenuActions(!0);return 0===o.length?i:i.concat(new Jo.Separator,o)},backgroundBasedTheme:o.spawnOwnership(),onActiveOrHoveredChart:(0,Ji.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().lightUpdate(),showHorizontalBorder:!0};this._lhsStubContainer=new qo(this._properties,"left",a,l,this._options.priceAxisLabelsOptions,this),this._lhsStubContainer.onLabelHovered().subscribe(this,((e,t)=>{this._onLabelHovered.fire(e,t)})),this._rhsStubContainer=new qo(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,Wt.createBoundCanvas)(this._dv,(0,Dt.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,Wt.createBoundCanvas)(this._dv,(0,Dt.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=Sr.MINUTE_SPAN,this._mouseEventHandler=new Et.MouseEventHandler(this._topCanvasBinding.canvasElement,this,{treatVertTouchDragAsPageScroll:!0,treatHorzTouchDragAsPageScroll:!1}),this.size=(0,Dt.size)({width:0,height:0}),(0,lt.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,lt.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,Dt.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,Yt.makeFont)(e,g.CHART_FONT_FAMILY,""),widthCache:new jt.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,kt.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,Yt.makeFont)(this.fontSize(),g.CHART_FONT_FAMILY)}baseBoldFont(){return(0,Yt.makeFont)(this.fontSize(),g.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 Jo.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 Jo.Action({actionId:"Chart.SetSession",options:{label:(0,br.translateSessionDescription)(e.description),checkable:!0,checked:i.value()===e.id,statName:"SetSession",onExecute:()=>{t.model().setProperty(i,e.id,Cr)}}}))),n=new Jo.Action({actionId:"Chart.SetSession",options:{label:Pr,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 Jo.Separator),s.push(i.scalesProperties)),s}update(){if(!this.chart.hasModel())return;const e=this.chart.model().timeScale().marks();if(e){this._minVisibleSpan=Sr.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===yo.InvalidationLevel.None||0===this.size.width||0===this.size.height)return;(0,Wt.tryApplySuggestedCanvasBitmapSize)(this._canvasBinding),(0,Wt.tryApplySuggestedCanvasBitmapSize)(this._topCanvasBinding);const t=(0,Wt.getContext2D)(this._topCanvasBinding.canvasElement);if(e>yo.InvalidationLevel.Cursor){const i=(0,Wt.getContext2D)(this._canvasBinding.canvasElement),s=(0,Wt.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,Wt.getBindingRenderingInfo)(this._topCanvasBinding))}
drawBackground(e,t){if((0,Wt.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,Wt.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,Vo.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()}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,Wt.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(){return!this.chart.model().timeScale().isEmpty()&&this.chart.model().model().zoomEnabled()&&this._options.pressedMouseMoveScale}_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&&Oo.ContextMenuManager.showMenu(this.getContextMenuActions(),e,{statName:"TimeScaleContextMenu"},{menuName:"TimeScaleContextMenu"})}_mouseOrTouchEnterEvent(e){this._zoomAvailable()&&this.setCursor("ew-resize")}_mouseOrTouchLeaveEvent(e){this.restoreDefaultCursor()}_mouseDoubleClickOrDoubleTapEvent(e){(0,ne.trackEvent)("GUI","Double click time scale"),this.chart.model().resetTimeScale()}}var xr=i(85459),Ir=i.n(xr),Mr=i(78871),Ar=i(71885),Lr=i(77148),kr=i(82783);function Dr(e,t){return!!Re.Interval.isEqual(e.res,t.res)&&(0,kr.areEqualTimeFrames)(e.val,t.val)}var Er=i(61119);const Br={duration:250,easing:Mr.easingFunc.easeOutCubic};class Vr{constructor(e){this._onFinishCalled=!1,this._options={...Br,...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,Er.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 Rr=i(86920),Nr=i(60074);function Or(e,t,i,s){let o=null;if(i.currencyConversionEnabled()&&(0,Nr.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 Fr=new Di.TranslatedString("toggle collapsed pane state",a.t(null,void 0,i(46054)));class Wr extends tt.UndoCommand{constructor(e,t){super(Fr),this._chartModel=e,this._paneIndex=t}redo(){this._chartModel.toggleCollapsedPane(this._paneIndex)}undo(){this._chartModel.toggleCollapsedPane(this._paneIndex)}}const Hr=new Di.TranslatedString("toggle maximized pane state",a.t(null,void 0,i(63095)));class zr extends tt.UndoCommand{constructor(e,t){super(Hr),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 Ur=new Di.TranslatedString("move all scales to left",a.t(null,void 0,i(64077))),Gr=new Di.TranslatedString("move all scales to right",a.t(null,void 0,i(19013))),jr=(0,ae.getLogger)("Chart.MergeAllScales");class qr extends tt.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 $r=i(85719);class Kr extends tt.UndoCommand{constructor(e,t,i,s){super(s,void 0,!$r.lineToolsDoNotAffectChartInvalidation),this._createdIds=[],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(),t=this._origStates.map(((t,i)=>{const s=(0,
n.ensureNotNull)(this._model.dataSourceForId(t.id)),o=0===this._createdIds.length?void 0:(0,n.ensureDefined)(this._createdIds[i]),r=(0,eo.cloneLineTool)(this._model,s,!this._withoutShift,o);void 0!==t.sharingMode&&r.share(t.sharingMode);const a=(0,n.ensureNotNull)(s.priceScale());(0,n.ensureNotNull)(this._model.paneForSource(s)).addDataSource(r,a,!1);const l=this._origGroups[i];if(null!==l){const t=e.groupForId(l);t&&t.addLineTools([r])}return this._model.updateSource(r),r}));0===this._createdIds.length&&(this._createdIds=t.map((e=>e.id()))),this._model.selectionMacro((e=>{e.clearSelection(),t.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}}var Yr=i(74174),Zr=i(70618),Xr=i(300);class Jr extends tt.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(dt.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,Js.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 this._model.restoreLineToolState(e,t,!0)}}}class Qr extends tt.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 ea extends Qr{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);t.bulkActionMacro((()=>{i.forEach((e=>this._chartModel.detachSource(e))),this._chartModel.detachSource(e)}));const s=this._chartModel.createPane(this.targetPaneIndex()),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);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 ta extends ea{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()===Bi.PaneMode.Regular)return t;return e.length}}class ia extends ea{constructor(e,t,i){super(e,t,i)}targetPaneIndex(){return this._initialPaneIndex}}class sa extends ea{constructor(e,t,i){super(e,t,i)}targetPaneIndex(){return this._chartModel.panes().length}}class oa extends Qr{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);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);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 na extends oa{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()===Bi.PaneMode.Regular)return t;throw new Error("No regular pane found above for merging")}}class ra extends oa{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()===Bi.PaneMode.Regular)return t;throw new Error("No regular pane found below for merging")}}class aa extends oa{constructor(e,t,i,s,o){super(e,t,s,o),this._targetPane=i}_targetPaneIndex(){return this._targetPane}}var la=i(69661),ca=i(98523);const ha=new Di.TranslatedString("create {tool}",a.t(null,void 0,i(12898)));class da extends la.LineToolSynchronizeUndoCommand{constructor({model:e,pane:t,lineTool:i,ownerSource:s,drawOnAllChartsMode:o=0,id:n}){super(e,ha.format({tool:new Di.TranslatedString(i,ca.lineToolsLocalizedNames[i])}),!1,!$r.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){const n=this._chartModel.panes()[this._paneIndex],r=this._chartModel.dataSourceForId(this._ownerSourceId)||void 0,a=this._chartModel.createLineTool({pane:n,point:e,linetool:this._lineTool,properties:t,linkKey:i,sharingMode:s,ownerSource:r,id:this._lineId??void 0,fromExternalModel:o});return this._lineId=a.id(),this._fromExternalModel=o,!this._chartModel.lineBeingCreated()}continueCreatingLine(e,t,i,s){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 ua=i(19466)
;const _a=new Di.TranslatedString("bring {title} to front",a.t(null,void 0,i(53159))),pa=new Di.TranslatedString("send {title} to back",a.t(null,void 0,i(5005))),ma=new Di.TranslatedString("insert {title} after {targetTitle}",a.t(null,void 0,i(56307))),ga=new Di.TranslatedString("insert {title} before {targetTitle}",a.t(null,void 0,i(46229))),fa=new Di.TranslatedString("send {title} backward",a.t(null,void 0,i(40962))),ya=new Di.TranslatedString("bring {title} forward",a.t(null,void 0,i(41966))),va=new Di.TranslatedString("send group {title} backward",a.t(null,void 0,i(69546))),Sa=new Di.TranslatedString("bring group {title} forward",a.t(null,void 0,i(1979)));function ba(e){return new Di.TranslatedString(e.name(),e.title(ua.TitleDisplayTarget.StatusLine))}class wa extends tt.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 Ca extends wa{constructor(e,t){super(e,t,_a.format({title:ba(t[0])}))}_paneOperation(e,t){e.bringToFront(t)}}class Pa extends wa{constructor(e,t){super(e,t,pa.format({title:ba(t[0])}))}_paneOperation(e,t){e.sendToBack(t)}}class Ta extends wa{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertAfter(t,this._targetSource)}}class xa extends Ta{constructor(e,t,i){super(e,t,i,ma.format({title:ba(t[0]),targetTitle:ba(i)}))}}class Ia extends wa{constructor(e,t,i,s){super(e,t,s),this._targetSource=i}_paneOperation(e,t){e.insertBefore(t,this._targetSource)}}class Ma extends Ia{constructor(e,t,i){super(e,t,i,ga.format({title:ba(t[0]),targetTitle:ba(i)}))}}function Aa(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,eo.isLineTool)(o)){const t=e.model().lineToolsGroupModel().groupForLineTool(o);null!==t&&(o=t.lineTools()[0])}return o}class La extends Ia{constructor(e,t,i){super(e,i,Aa(t,i),fa.format({title:ba(i[0])}))}}function ka(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,eo.isLineTool)(o)){
const t=e.model().lineToolsGroupModel().groupForLineTool(o);if(null!==t){const e=t.lineTools();o=e[e.length-1]}}return o}class Da extends Ta{constructor(e,t,i){super(e,i,ka(t,i),ya.format({title:ba(i[0])}))}}function Ea(e,t){return(0,n.ensureNotNull)(e.paneForSource(t.lineTools()[0]))}class Ba extends Ia{constructor(e,t){super(e,t.lineTools(),Aa(Ea(e,t),t.lineTools()),va.format({title:t.name().value()}))}}class Va extends Ta{constructor(e,t){super(e,t.lineTools(),ka(Ea(e,t),t.lineTools()),Sa.format({title:t.name().value()}))}}const Ra=new Di.TranslatedString("rearrange panes",a.t(null,void 0,i(2618)));class Na extends tt.UndoCommand{constructor(e,t,i){super(Ra),this._chartModel=e,this._index=t,(0,dt.isNumber)(i)?this._dstIndex=i:this._dstIndex="up"===i?t-1:t+1}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 Oa=i(7927);function Fa(e){return{val:e.value(),dependenValues:e.dependents?.().map(Fa)??[]}}function Wa(e){return(e.dependents?.()??[]).map(Fa)}function Ha(e,t){(e.dependents?.()??[]).forEach(((e,i)=>{e.setValue(t[i].val),(e.dependents?.()??[]).forEach((e=>Ha(e,t[i].dependenValues)))}))}function za(e,t){return"string"==typeof t?(0,Oa.propertyByPath)(e,t):t}class Ua extends tt.UndoCommand{constructor(e,t,i,s,o=!0){super(i,void 0,o);const n=e.pathToRoot();this._targetObj=(0,Oa.isRootPath)(n)?n:e,this._newValue=t,this._oldValue=e.value(),this._dependentValues=Wa(e),this._model=s}targetValue(){return this._newValue}redo(e){(0,li.allowSavingDefaults)(!0),za(e.chartWidgetCollection,this._targetObj).setValue(this._newValue),(0,li.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,Bt.globalChangeEvent)()),this._model.lightUpdate()}undo(e){(0,li.allowSavingDefaults)(!0);const t=za(e.chartWidgetCollection,this._targetObj);t.setValue(this._oldValue),Ha(t,this._dependentValues),(0,li.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,Bt.globalChangeEvent)()),this._model.lightUpdate()}}class Ga extends tt.UndoCommand{constructor(e,t,i,s,o,n){super(s),this._prevPriceAxisProps={},this._dependentValues=[],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=Wa(this._property),this._prevResolution=t.interval.value(),this._prevValue=this._property.value(),this._storePriceAxisProps(),(0,li.allowSavingDefaults)(!0);const i=t.interval.value(),s=this._model.defaultResolutions(),o=(0,es.getResolutionByChartStyle)(this._value,i,s);de.linking.interval.setValue(o),e.setChartStyleWithIntervalIfNeeded(this._value,o),(0,yt.setLastUsedStyle)(this._value,e.symbolInfo()),(0,yt.preparePriceAxisProperties)(t),(0,li.allowSavingDefaults)(!1),this._invalidateModel(),this._chartWidget.screen.show(!0)}undo(){const e=this._mainSeries;(0,li.allowSavingDefaults)(!0),
e.setChartStyleWithIntervalIfNeeded(this._prevValue,this._prevResolution),this._restorePriceAxisProps(),de.linking.interval.setValue(this._prevResolution),Ha(this._property,this._dependentValues),(0,li.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,Bt.sourceChangeEvent)(this._model.mainSeries().id())),this._model.lightUpdate())}}const ja=new Di.TranslatedString("change date range",a.t(null,void 0,i(16979)));class qa extends tt.UndoCommand{constructor(e,t){super(ja),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 qa&&Dr(e._rangeOptions,this._rangeOptions)}merge(e){if(!(e instanceof qa))throw new Error("Invalid command to merge");this._modelsData=this._modelsData.concat(e._modelsData)}}function $a(e){return e.properties().visible.value()}function Ka(e){return!$a(e)}class Ya{constructor(e,t,i){this._instanceId=(0,fe.randomHashN)(6),this._onChanged=new re.Delegate,this._lineToolsSet=new Set,this._lineTools=[...e],this._lineToolsSet=new Set(this._lineTools),this._name=new F.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($a),t=this._lineTools.some(Ka);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 Ya(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 Za extends tt.UndoCommand{constructor(e,t,i){super(i,void 0,!$r.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 Ya(e,this._groupName,this._groupId);this._model.lineToolsGroupModel().addGroup(t)}}const Xa=new Di.TranslatedString("create line tools group",a.t(null,void 0,i(46219)));class Ja extends tt.UndoCommand{constructor(e,t){super(Xa,void 0,!$r.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 Qa=new Di.TranslatedString("add line tool(s) to group {group}",a.t(null,void 0,i(21162)));class el extends tt.UndoCommand{constructor(e,t,i){super(Qa.format({group:t.name().value()}),void 0,!$r.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 tl extends tt.UndoCommand{constructor(e,t,i,s){super(s,void 0,!$r.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 il=new Di.TranslatedString("create line tools group from selection",a.t(null,void 0,i(95394))),sl=new Di.TranslatedString("removing line tools group {name}",a.t(null,void 0,i(41430))),ol=new Di.TranslatedString("add line tool {lineTool} to group {name}",a.t(null,void 0,i(12570))),nl=new Di.TranslatedString("make group {group} visible",a.t(null,void 0,i(45987))),rl=new Di.TranslatedString("make group {group} invisible",a.t(null,void 0,i(76709))),al=new Di.TranslatedString("lock group {group}",a.t(null,void 0,i(20453))),ll=new Di.TranslatedString("unlock group {group}",a.t(null,void 0,i(74590))),cl=new Di.TranslatedString("rename group {group} to {newName}",a.t(null,void 0,i(80491)));class hl{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,ci.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(il);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 Zr.ExcludeLineToolsFromGroupUndoCommand(e,i,t);this._environment.pushUndoCommand(s)}));const c=new Ja(e,(0,ci.sortSources)(t));if(this._environment.pushUndoCommand(c),i){const i=new xa(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(sl.format({name:e.name().value()}));const s=new Za(t,e,null);this._environment.pushUndoCommand(s);const o=new Yr.RemoveSourcesUndoCommand(t,i,null);this._environment.pushUndoCommand(o)
;const r=t.mainSeries().symbol();i.forEach((e=>{null!==e.linkKey().value()&&(0,lt.removeLineTool)({withUndo:!0,model:t,symbol:r,sourceTitle:new Di.TranslatedString(e.name(),e.title(ua.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 Zr.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=ol.format({lineTool:new Di.TranslatedString(t.name(),t.title(ua.TitleDisplayTarget.StatusLine)),name:e.name().value()});this._environment.beginUndoMacro(o),null!==s&&this._environment.pushUndoCommand(new Zr.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 el(i,e,[t])),this._environment.endUndoMacro()}bringToFront(e){const t=this._environment.model(),i=new Ca(t,e.lineTools());this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendToBack(e){const t=this._environment.model(),i=new Pa(t,e.lineTools());this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}bringForward(e){const t=this._environment.model(),i=new Va(t,e);this._environment.pushUndoCommand(i),this._environment.emitEvent("changeZOrder",[e.lineTools()])}sendBackward(e){const t=this._environment.model(),i=new Ba(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 Ya){const e=t.lineTools();s=e[e.length-1]}else s=t;const o=new xa(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 Ya){s=t.lineTools()[0]}else s=t;const o=new Ma(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?nl:rl).format({group:e.name().value()}),s=this._environment.model();this._environment.beginUndoMacro(i),e.lineTools().forEach((e=>{const i=e.properties().visible,o=new Ua(i,t,null,s,!$r.lineToolsDoNotAffectChartInvalidation);this._environment.pushUndoCommand(o)})),this._environment.endUndoMacro()}setGroupLock(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().frozen,o=new Ua(i,t,null,s,!$r.lineToolsDoNotAffectChartInvalidation);this._environment.pushUndoCommand(o)})),this._environment.endUndoMacro()}setGroupName(e,t){const i=this._environment.model(),s=cl.format({group:e.name().value(),newName:t}),o=new tl(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 dl,ul,_l,pl,ml=i(96286);function gl(e){return e.isSeries}function fl(e){return(0,eo.isLineTool)(e)&&!e.isSpeciallyZOrderedSource()}function yl(e){return(0,Js.isStudy)(e)&&!e.isSpeciallyZOrderedSource()||(0,Js.isStudyStub)(e)}function vl(e,t){return e.zorder-t.zorder}function Sl(e,t){(0,pt.isMainSeriesState)(e)?e.zorder=0:e.zorder=t}function bl(e,t){e.setZorder(t)}function wl(e){return e.zorder()}function Cl(e){return Math.round(1e3*e)/1e3}function Pl(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 Tl(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 xl(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=Dl(n);if(o-1===s)s>=0&&i(e[s],r);else{const t=Pl(o,s);let a=0;for(;0===a;){const e=Tl(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=Cl(n-a);i(e[l],t),n=t,l--}s>=0&&i(e[s],r)}n=r,o=s}}function Il(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=kl(n);if(o+1===s)s<=e.length-1&&i(e[s],r);else{const t=Pl(o,s);let a=0;for(;0===a;){const e=Tl(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=Cl(n+a);i(e[l],t),n=t,l++}s<=e.length-1&&i(e[s],r)}n=r,o=s}}function Ml(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?(xl(a.slice(0,l),0,o,i),Il(a.slice(l+1),0,o,i)):Il(a,0,o,i)}(e,pt.isMainSeriesState,pt.isStudyState,pt.isLineToolState,Sl,vl)}function Al(e,t){const i=Math.floor(e/1e4);let s=t.get(i);return void 0===s&&(s=[],t.set(i,s)),s}function Ll(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),Al(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=Tl(e,kl(e),1);return Cl(t.startZOrder+t.zOrderStep)}if(r===-1/0){const e=a===1/0?0:a,t=Tl(Dl(e),e,1);return Cl(t.startZOrder+t.zOrderStep)}const d=Tl(r,kl(r),1);if(0!==d.zOrderStep)return Cl(d.startZOrder+d.zOrderStep)
;const u=Al(r,h).sort(((e,t)=>o(e)-o(t)));let _=Dl(o(u[0]));const p=kl(_),m=Tl(_,p,u.length+1).zOrderStep;return 0!==m?(u.forEach((e=>{const t=Cl(_+m);s(e,t),_=t})),Cl(_+m)):Cl(p+5e3)}function kl(e){const t=1e4*Math.ceil(e/1e4);return t===e?t+1e4:t}function Dl(e){const t=1e4*Math.floor(e/1e4);return t===e?t-1e4:t}function El(e,t,i,s,o,n,r){const a=t.length,{newItems:l,movedItemsStartIndex:c}=i>0?(0,ft.moveAfter)(e,t,i-1):(0,ft.moveBefore)(e,t,0);let h=!1;for(let t=c;t<c+a;t++)if(l[t]!==e[t]){h=!0;break}if(!h)return;if(s(t[0]))return void(i<e.length&&r(e[i])<0?Il(l.slice(c+1),0,n,o):xl(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=Bl(e,i+t,s),a=n(e[c])):i+t===e.length?(l=Vl(e,i-1,s),r=n(e[l])):(l=Vl(e,i-1,s),r=n(e[l]),c=Bl(e,i+t,s),a=n(e[c]));if((void 0===r||r<0)&&void 0!==a&&a<=0)xl(e.slice(0,c),a,o,s);else if((void 0===a||a>0)&&void 0!==r&&r>=0)Il(e.slice(l+1),r,o,s);else{i+t<e.length-i?xl(e.slice(0,i+t),n(e[i+t]),o,s):Il(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=Tl(c,void 0!==a?a:Dl(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=Tl(c,void 0!==l?l:kl(a),t);c=e.startZOrder,_=e.zOrderStep,d=i,u=d+t,h=1}if(0!==_)for(;d!==u;){const t=Cl(c+h*_);n(e[d],t),c=t,d+=h}else{const t=e.findIndex((e=>o(e)));-1!==t?(xl(e.slice(0,t),0,n,s),Il(e.slice(t+1),0,n,s)):Il(e,0,n,s)}}(l,a,c,o,s,n,r)}function Bl(e,t,i){for(;t<e.length&&i(e[t]);)t++;return Math.min(t,e.length-1)}function Vl(e,t,i){for(;t>=0&&i(e[t]);)t--;return Math.max(0,t)}function Rl(e,t,i,s,o,n,r){const a=e.indexOf(i)+1;El(e,t,a,s,o,n,r)}function Nl(e,t,i,s,o,n,r){const a=e.indexOf(i);El(e,t,a,s,o,n,r)}function Ol(e,t,i){Rl(e,t,i,gl,yl,bl,wl)}function Fl(e,t,i){Nl(e,t,i,gl,yl,bl,wl)}!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"}(dl||(dl={})),function(e){e.Value="_seriesId"}(ul||(ul={})),function(e){e[e.InvalidSymbol=0]="InvalidSymbol",e[e.ReplayUnsupported=1]="ReplayUnsupported",e[e.UnsupportedDepth=2]="UnsupportedDepth",e[e.UnsupportedIntradyReplay=3]="UnsupportedIntradyReplay"}(_l||(_l={})),function(e){e[e.MainSeriesZOrder=0]="MainSeriesZOrder",e[e.StudyBaseZOrder=1e4]="StudyBaseZOrder",e[e.MaxFractionLength=3]="MaxFractionLength"}(pl||(pl={}));const Wl=new Di.TranslatedString("apply study template {template}",a.t(null,void 0,i(69604)));function Hl(e){for(const t of e.panes)for(const e of t.sources)if((0,pt.isMainSeriesState)(e))return e.id
;return null}class zl extends tt.UndoCommand{constructor(e,t,i){super(Wl.format({template:i})),this._newSymbolParams={},this._model=e,this._templateContent=function(e,t){const i=(0,Qe.default)({},e),s=(0,n.ensureNotNull)(Hl(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,yt.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(eo.isLineTool);this._model.lineToolsGroupModel().removeLineTools(e);const t=this._model.mainSeries().properties();(0,yt.preparePriceAxisProperties)(t),this._model.recalcVisibleRangeStudies(Eo.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()===Hl(e)),s.priceScale().properties().childs().lockScale.setValue(!1);const o=i.panes(),r=[],a=e.panes.reduce(((e,t)=>{const i=t.sources.find((e=>(0,pt.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;18===s.style()&&s.properties().childs().tpoStyle.childs().summary.childs().visible.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,Js.isStudy)(t)||(0,Js.isStudyStub)(t))&&t.isRemovedByStudyTemplates())&&r.push(t)}}i.resetDeferredStudies();const l=(0,ml.closeSourcesSet)(i,r);for(let e=0;e<l.length;++e)i.removeSource(l[e]);const c=e.panes;for(let e=0;e<c.length;e++){let s=-1;const n=(0,dt.clone)(c[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,pt.isMainSeriesState)(t)){delete t.state,s=e;break}}const r=s>-1,a=r?o[e]:i.createPane(e);r&&t<3&&Ml(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===s.style()&&s.properties().childs().tpoStyle.childs().summary.childs().visible.setValue(a),i.startNotStartedStudies(),i.recalculateAllPanes((0,Bt.globalChangeEvent)()),i.fullUpdate(),l}}const Ul=(0,ae.getLogger)("Chart.ChartUndoModel");var Gl;!function(e){e[e.PasteYCoordOffset=-40]="PasteYCoordOffset"}(Gl||(Gl={}));const jl=new Di.TranslatedString("paste drawing",a.t(null,void 0,i(62192)));class ql extends tt.UndoCommand{constructor(e,t,i,s,o){super(jl,void 0,!$r.lineToolsDoNotAffectChartInvalidation),this._needCopyToOtherCharts=!1,this._sourceState=null,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();null===this._sourceState&&(this._sourceState=this._getSourceState(t,i));const s=(0,n.ensureNotNull)(e.restoreLineTool(this._sourceState,this._pasteWithData,this._keepZIndex,void 0,t));(0,n.ensureNotNull)(t.priceScale()).addDataSource(s),this._clipboardData.centeredOnChart&&s.centerPosition&&s.centerPosition(),s.restoreFixedPoint(),s.createServerPoints(),this._needCopyToOtherCharts=Boolean(i&&s.isSynchronizable()&&0!==s.sharingMode().value()),this._model.setShouldBeSavedEvenIfHidden(!0)}undo(){if(!this._sourceState)return void Ul.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,dt.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,yt.symbolCurrency)(c.symbolInfo(),void 0,!0):c.isConvertedToOtherCurrency())||(null!==l?l!==(0,yt.symbolUnit)(c.symbolInfo(),this._model.unitConversionEnabled()):c.isConvertedToOtherUnit())||((0,Nr.isActingAsSymbolSource)(e)?h=!0:(0,Js.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 At.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 $l extends tt.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,yt.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 Kl extends tt.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,yt.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 Yl extends Qr{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);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);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 Zl extends Yl{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 Xl extends Yl{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 Jl extends tt.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,ki.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,ki.muteLinkingGroup)(this._linkingGroupIndex,!1),this._firstRedo=!1}undo(){(0,ki.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,ki.muteLinkingGroup)(this._linkingGroupIndex,!1)}canMerge(e){if(!(e instanceof Jl)||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 Jl)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 Ql=new Di.TranslatedString("change symbol",a.t(null,void 0,i(35400)));class ec extends Jl{constructor(e,t,i){super(Ql,e,{symbol:t,currency:null,unit:null},i),this._symbol=t}canMerge(e){return e instanceof ec&&e._symbol===this._symbol&&super.canMerge(e)}}const tc=(0,ae.getLogger)("Chart.ChartUndoModel"),ic=new Di.TranslatedString("paste indicator",a.t(null,void 0,i(1064)));class sc extends tt.UndoCommand{constructor(e,t,i){super(ic),this._sourceState=null,this._model=e,
this._clipboardData=t,this._paneId=i}redo(){if(!this._sourceState){const e=(0,dt.clone)(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,Js.isStudy)(s)&&s.start()}undo(){if(null===this._sourceState)return void tc.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 oc extends tt.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 nc=new Di.TranslatedString("move",a.t(null,void 0,i(98277)));class rc extends tt.UndoCommand{constructor(e,t,i,s){super(nc,!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 At.Point(e.localX,e.localY),this._itemIndex,new Bo.EnvironmentState(e))}}class ac extends tt.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,ne.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,Nr.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 lc extends tt.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,li.allowSavingDefaults)(!0),t.setMode(e),(0,li.allowSavingDefaults)(!1),this._model&&(this._model.recalculateAllPanes((0,Bt.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 cc=i(90484),hc=i(90054),dc=i(11417),uc=i(59769)
;const _c=["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"],pc=["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 mc{constructor(e,t=_c){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=Lt.colorsPalette[s],n=(0,Is.isHexColor)(e)?1:(0,kt.parseRgba)(e)[3];return(0,Is.generateColor)(o,(0,Is.alphaToTransparency)(n))}}class gc{constructor(e,t){this._calcColorOffset=e,this._modelStartOffset=t}getColor(e){const t=this._calcColorOffset();if((0,Is.isHexColor)(e)){const i=(0,kt.parseRgb)(e);return(0,kt.rgbToHexString)((0,kt.shiftRgb)(i,t,this._modelStartOffset))}{const i=(0,kt.parseRgba)(e);return(0,kt.rgbaToString)((0,kt.shiftRgba)(i,t,this._modelStartOffset))}}}class fc{constructor(e){this._rotators=new WeakMap,this._calcDefaultColorsOffset=e=>{const t=(0,Js.useSameColorRotationComparator)(e);return this._chartModel.dataSources().filter((i=>(0,Js.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,Js.studyColorRotationMode)(e)){case"sexyColors":return new mc(t,pc);case"loop":return new mc(t);case"shift":return new gc(t,this._chartModel.getStudyShiftColorStartOffset());case null:case"noRotations":return null}}}function yc(e){return(0,eo.isLineTool)(e)&&e.boundToSymbol()||!1}class vc{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&&!yc(this._items[0])&&this.clear(),yc(e)){const t=(0,
ft.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||yc(this._items[0])&&yc(e)}isSelected(e){return this._set.has(e)}allSources(){return this._items.slice(0)}dataSources(){return null===this._dataSourcesCache&&(this._dataSourcesCache=this._items.filter(Vo.isDataSource)),this._dataSourcesCache}lineDataSources(){return null===this._lineSourcesCache&&(this._lineSourcesCache=this._items.filter(eo.isLineTool)),this._lineSourcesCache}customSources(){return null===this._customSourcesCache&&(this._customSourcesCache=this._items.filter((e=>!(0,Vo.isDataSource)(e)))),this._customSourcesCache}checkLineToolSelection(){this._items.forEach((e=>(0,eo.isLineTool)(e)&&e.calcIsActualSymbol())),this._items=this._items.filter((e=>!(0,eo.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 Sc,bc,wc=i(21239),Cc=i(17534);!function(e){e[e.BorderSize=1]="BorderSize"}(Sc||(Sc={})),function(e){e[e.AdditionalInnerPadding=4]="AdditionalInnerPadding",e[e.HorzPadding=4]="HorzPadding",e[e.VertPadding=2.5]="VertPadding",e[e.LineSpacing=2]="LineSpacing"}(bc||(bc={}));class Pc{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,Yt.makeFont)(i,g.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}}class Tc{constructor(e,t){this._destroyed=!1,this._callbacks=[],this._resource={pendingResource:e},e.then((e=>{if(this._destroyed)this._destroyFn?.(e);else{for(const t of this._callbacks)t(e);this._resource.resource=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}}var xc=i(6290);const Ic=(0,li.extractThemedColors)(xs.lightTheme.content.sessions,xs.darkTheme.content.sessions)
;class Mc extends li.DefaultProperty{constructor(e){super({defaultName:"sessions",themedColors:Ic,excludedDefaultsKeys:["graphics"],excludedStateKeys:["graphics"],excludedTemplateKeys:["graphics"]}),this._symbolInfo=e,this._symbolInfo.subscribe((()=>this._updateGraphicsProps())),this.hasChild("graphics")||this.addProperty("graphics",{}),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="graphics"in e?e.graphics.backgrounds:void 0;if(void 0!==t){const i=(0,n.ensureDefined)(t.outOfSession);if(i.color===xc.sessionsPreferencesDefault.sessionHighlight.backgrounds.outOfSession.color||"postMarket"in t)e.sessionHighlight=e.sessionHighlight??{},e.sessionHighlight.backgrounds=t;else{const t="visible"in i?i.visible:void 0;e.sessionHighlight=e.sessionHighlight??{},e.sessionHighlight.backgrounds={...e.sessionHighlight?.backgrounds??{},postMarket:{color:i.color,transparency:i.transparency,visible:t??e.sessionHighlight.backgrounds.preMarket.visible},preMarket:{color:i.color,transparency:i.transparency,visible:t??e.sessionHighlight.backgrounds.postMarket.visible}},"visible"in i&&(e.sessionHighlight.backgrounds.preMarket.visible=i.visible,e.sessionHighlight.backgrounds.postMarket.visible=i.visible)}}const i="graphics"in e?e.graphics.vertlines:void 0;i&&(e.sessionHighlight=e.sessionHighlight??{},e.sessionHighlight.vertlines=i)}(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,li.allowSavingDefaults)(!0),this.fireChanged(),(0,li.allowSavingDefaults)(!1))}_userSettings(){const e=super._userSettings();return e&&!e.sessionHighlight&&(e.sessionHighlight=e.graphics),delete e?.graphics,e}_updateGraphicsProps(){this.childs().graphics.mergeAndFire(this.childs().sessionHighlight.state()),"futures"===this._symbolInfo.value()?.type&&(0,n.ensureDefined)(this.childs().graphics.childs().backgrounds).childs().preMarket.mergeAndFire(this.childs().sessionHighlight.childs().backgrounds.childs().electronic.state())}}class Ac extends Tc{constructor(e,t,i){super(e,(e=>e.destroy())),this._sessionsStateData=null,this._model=t,this._properties=i,t.mainSeries().sessionIdProxyProperty().subscribe(this,this._updateVisibleOfPreAndPostMarketBackground),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().sessionIdProxyProperty().unsubscribeAll(this),
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().sessionIdProxyProperty().value(),t=this._model.mainSeries().symbolInfo();if(t){const i=!((0,yt.isRegularSessionId)(e,t)||"futures"===t.type),s=this._properties.childs().sessionHighlight.childs().backgrounds.childs();s.electronic.childs().visible.setValue(i),s.outOfSession.childs().visible.setValue(i),s.preMarket.childs().visible.setValue(i),s.postMarket.childs().visible.setValue(i)}}}const Lc="symbolWatermark",kc={visibility:!1,color:"rgba(80, 83, 94, 0.25)"};function Dc(){const e=d.getJSON(Lc);return Object.assign({},kc,e)}const Ec=(0,s.default)((()=>{const e=new Rs.Property(Dc());return d.onSync.subscribe(null,(()=>e.mergeAndFire(Dc()))),e.subscribe(null,(()=>d.setJSON(Lc,e.state()))),e}));var Bc=i(22365),Vc=i(24708),Rc=i(75919);class Nc extends Rc.MediaCoordinatesPaneRenderer{constructor(){super(...arguments),this._data=null,this._widthCache=new jt.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;s.fillStyle=i;let r=0;const a=[];for(const e of t){if(!e.text)continue;s.font=e.font;const t=this._widthCache.measureText(s,e.text),i=t>o?o/t:1;a.push(i),r+=e.lineHeight*i}let l=Math.max((n-r)/2,0),c=-1;for(const e of t){if(!e.text)continue;c+=1;const t=a[c];s.save(),s.translate(o/2,l),s.textBaseline="top",s.textAlign="center",s.font=e.font,s.scale(t,t),s.fillText(e.text,0,e.vertOffset),s.restore(),l+=e.lineHeight*t}}}class Oc{constructor(e,t){this._renderer=new Nc,this._invalidated=!0,this._model=e,this._watermark=t}update(){this._invalidated=!0}renderer(){return this._invalidated&&this._updateImpl(),this._renderer}_updateImpl(){const e=this._watermark.properties().childs(),t=this._model.mainSeries(),i=t.symbolInfo();if(!i||!e.visibility.value())return void this._renderer.setData(null);let s;{const e=this._model.watermarkContentProvider(),o=e?e({symbolInfo:i,interval:t.interval()}):null;s=o?o.map((e=>({text:e.text,font:(0,Yt.makeFont)(e.fontSize,g.CHART_FONT_FAMILY),lineHeight:e.lineHeight,vertOffset:e.vertOffset}))):null}let o=i.name;if(/QUANDL/.test(i.exchange)){const e=o.split(/\//)
;e.length&&(o=e[e.length-1])}const n={description:i.description,short_description:i.short_description,pro_name:i.pro_name,short_name:i.name,local_description:i.local_description,language:i.language},r=s||[{text:o?`${o}, ${(0,Vc.translatedIntervalString)(t.interval())}`:"",font:(0,Yt.makeFont)(96,g.CHART_FONT_FAMILY),lineHeight:117,vertOffset:0},{text:(0,Bc.getTranslatedSymbolDescription)(n)||"",font:(0,Yt.makeFont)(48,g.CHART_FONT_FAMILY),lineHeight:58,vertOffset:5}];this._renderer.setData({color:e.color.value(),lines:r})}}const Fc="symbolWatermark";class Wc extends di.DataSource{constructor(e){super(),this._model=e,this._properties=Ec(),(0,h.applyDefaultsOverrides)(this._properties,void 0,!1,Fc),this._properties.subscribe(this,(()=>e.updateSource(this))),this._paneView=new Oc(e,this)}destroy(){this._properties.unsubscribeAll(this),super.destroy()}model(){return this._model}name(){return"watermark"}properties(){return this._properties}restorePropertiesDefaults(){Ec().mergeAndFire(kc)}applyOverrides(e){(0,h.applyPropertiesOverrides)(this._properties,void 0,!1,e,Fc)}paneViews(){return[this._paneView]}updateAllViews(e){super.updateAllViews(e),this._paneView.update()}}var Hc,zc=i(34776),Uc=i(23073);!function(e){e[e.StepForChangeValue=.1]="StepForChangeValue",e[e.MinValue=1e-7]="MinValue",e[e.MaxValue=99999999]="MaxValue"}(Hc||(Hc={}));class Gc extends Uc.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 Gc(this._model)}storeStateIfUndefined(){return!0}weakReference(){return(0,zc.weakReference)(this)}ownership(){return(0,zc.ownership)(this)}}var jc=i(18112),qc=i(34391);class $c{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 Kc,Yc=i(56991);function Zc(e,t,i){return i.hasDataSource(t)?Qc(t,i)===e:!!i.isMainPane().value()&&Qc(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.HitTest="hitTest",e.General="general",e.Price="price",e.ExceptSpecial="exceptSpecial",e.AllSorted="allSorted",e.VisibleSorted="visibleSorted"}(Kc||(Kc={}));const Xc=new Map([["price",e=>(0,Fn.isPriceDataSource)(e)],["trading",e=>(0,eo.isTrading)(e)],["drawing",e=>(0,eo.isLineTool)(e)&&!(0,eo.isTrading)(e)&&!e.isPhantom()],["drawingsForAllSymbols",e=>(0,eo.isLineTool)(e)&&!(0,eo.isTrading)(e)&&!e.isPhantom()],["phantom",e=>(0,eo.isLineTool)(e)&&e.isPhantom()],["restRowSources",e=>!(0,eo.isLineTool)(e)&&!(0,eo.isTrading)(e)],["legendViewSources",(e,t)=>t.hasDataSource(e)&&((0,Fn.isPriceDataSource)(e)||(0,eo.isStudyLineTool)(e))],["leftPriceScale",Zc.bind(null,"left")],["rightPriceScale",Zc.bind(null,"right")],["overlayPriceScale",Zc.bind(null,"overlay")],["multipane",(e,t)=>!t.hasDataSource(e)],["allWithoutMultipane",(e,t)=>t.hasDataSource(e)],["allWithoutMultipaneWithHidden",(e,t)=>t.hasDataSource(e)]]),Jc=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"]]);function Qc(e,t){const i=e.priceScale();return null===i?"overlay":t.priceScalePosition(i)}class eh{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"))}allIncludingHidden(){return this._groupedSources.has("allSorted")||this._sortSources(),(0,n.ensureDefined)(this._groupedSources.get("allSorted"))}allWithoutMultipane(){return this._getSourcesByGroupType("allWithoutMultipane")}allWithoutMultipaneWithHidden(){return this._getSourcesByGroupType("allWithoutMultipaneWithHidden")}allExceptSpecialSources(){if(!this._groupedSources.has("exceptSpecial")){const e=this.allIncludingHidden().filter((e=>!e.isSpeciallyZOrderedSource()));this._groupedSources.set("exceptSpecial",e)}return(0,n.ensureDefined)(this._groupedSources.get("exceptSpecial"))}tradingSources(){return this._getSourcesByGroupType("trading")}priceSources(){return this._getSourcesByGroupType("price")}lineSources(){return this._getSourcesByGroupType("drawing")}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",(0,ci.sortSources)(e,this._pane))}return(0,
n.ensureDefined)(this._groupedSources.get("hitTest"))}generalSources(){if(!this._groupedSources.has("general")){const e=this.allExceptLineAndTradingSources().concat(this.lineSources());this._groupedSources.set("general",(0,ci.sortSources)(e,this._pane))}return(0,n.ensureDefined)(this._groupedSources.get("general"))}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){const t=(0,n.ensureDefined)(Jc.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,ci.sortSources)(this._sources.concat(e),this._pane),i=t.filter((e=>!(0,eo.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()&&e.isActualUnit()));this._groupedSources.set("allSorted",t),this._groupedSources.set("visibleSorted",i)}_groupSources(e){const t=(0,n.ensureDefined)(Jc.get(e)),i=Xc.get(e);if(void 0!==i){const s=(0,n.ensureDefined)(this._groupedSources.get(t)).filter((e=>i(e,this._pane)));this._groupedSources.set(e,s)}}}var th=i(93280),ih=i(49256);function sh(e,t,i){const s=(0,yt.symbolUnitConvertibleGroupsIfExist)(e,!0);if(null!==s)return s;const o=i.unitGroupById(t);return null===o?[]:[o]}function oh(e,t,i,s){let o=null;if(i.unitConversionEnabled()&&(0,Nr.isSymbolSource)(e)){const n=i.availableUnits(),r=t.unit(n),a=e.unit(),l=null===a?[]:sh(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 nh=i(60521);function rh(e,t,i){const s=e.div(t).toNumber();return Math.abs(Math.round(s)-s)<i}const ah=[2,5],lh=[5,2];class ch{constructor(e,t,i){if(this._base=e,this._integralDividers=t,(0,Io.isBaseDecimal)(e))this._fractionalDividers=[2,2.5,2];else{this._fractionalDividers=[];const e=i?ah:lh;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,Io.log10)(e-t))));if(!isFinite(n))return 1e305;let r=0,a=this._integralDividers[0];for(;;){const e=(0,Io.greaterOrEqual)(n,s,o)&&n>s+o,t=(0,Io.greaterOrEqual)(n,i*a,o),l=(0,Io.greaterOrEqual)(n,1,o),c=new nh.Big(n).div(a),h=0===s||rh(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,Io.equal)(n,1,o))for(r=0,a=this._fractionalDividers[0];;){const e=(0,Io.greaterOrEqual)(n,i*a,o)&&n>s+o,t=new nh.Big(n).div(a),l=0===s||rh(t,s,o);if(!e||!l)break;n=t.toNumber(),a=this._fractionalDividers[++r%this._fractionalDividers.length]}return n}}class hh{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 ch(this._base,[2,2.5,2],!0),new ch(this._base,[2,2,2.5],!0),new ch(this._base,[2.5,2,2],!0),new ch(this._base,[2,2.5,2],!1),new ch(this._base,[2,2,2.5],!1),new ch(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 dh=i(725),uh=i(74079);const _h=l.enabled("hide_price_scale_if_all_sources_hidden"),ph=(0,uh.getPercentageFormatter)(),mh=new dh.PriceFormatter({priceScale:100,minMove:1}),gh={autoScale:!0,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,log:!1,logDisabled:!1,alignLabels:!0,isInverted:!1,indexedTo100:!1};class fh{constructor(e,t){this._marksCache=null,this._onMarksChanged=new re.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 re.Delegate,this._scaleSeriesOnly=!1,this._invalidatedForRange={isValid:!0,visibleBars:null},this._priceRange=null,this._hasCalculatedPriceRange=!1,this._logFormula=(0,ih.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 re.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 re.Delegate,this._priceRangeAnimationRequested=new re.Delegate,this._modeChanged=new re.Delegate,this._sourcesToUpdateViews=null,this._markBuilder=new hh(this,100,this._coordinateToLogical.bind(this),this._logicalToCoordinate.bind(this)),this._formatter=null,this._resetScaleAvailable=new F.WatchedValue(!1),this._priceRangeAnimation=null,this._id="",this._isVisible=new F.WatchedValue(!0),t=Object.assign({},gh,t),this._properties=new Rs.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 th.PriceRange))throw new TypeError("incorrect price range");const s=this._priceRange;if(!t&&th.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,Bt.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}priceRangeAnimationRequested(){return this._priceRangeAnimationRequested}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,Fn.isPriceDataSource)(t)&&!((0,Js.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,dt.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 th.PriceRange||(t=new th.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,ih.toLog)(e,this._logFormula):e}logicalToPrice(e){return this.isLog()?(0,ih.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,ih.fromPercent)(i,t):this.isIndexedTo100()&&(i=(0,ih.fromIndexedTo100)(i,t)),i}mainSource(){if(null!==this._mainSource)return this._mainSource;let e;for(const t of this._priceDataSources){if(gl(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,ih.toPercent)(t,e)):this.isIndexedTo100()?t=>h((0,ih.toIndexedTo100)(t,e)):this.isLog()?e=>h((0,ih.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,ih.toPercent)(m,t):u?m=(0,ih.toIndexedTo100)(m,t):_&&(m=(0,ih.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,ih.toPercent)(d[e].y,t);if(this.isIndexedTo100())for(let e=u;e<_;e++)d[e].y=(0,ih.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=ih.toPercent:this.isIndexedTo100()?c=ih.toIndexedTo100:this.isLog()&&(c=(e,t)=>e?(0,ih.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=ph,t=100):this.isIndexedTo100()?(this._formatter=mh,t=100):this._formatter=e?e.formatter():mh,this._markBuilder=new hh(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,ih.toPercent)(e,t),ph.format(e,i)}formatPriceIndexedTo100(e,t,i){const s=(0,ih.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,ih.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,Fn.isPriceDataSource)(e)){const t=this._priceDataSources.indexOf(e);if((0,n.assert)(-1!==t,"Source is not found"),this._priceDataSources.splice(t,1),(0,Nr.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),gl(e)&&(this._hasSeries=!1)}e.currencyChanged().unsubscribeAll(this),e.unitChanged().unsubscribeAll(this)}this.mainSource()||this.setMode({autoScale:!0}),(0,Js.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,lt.hideAllIndicators)().unsubscribe(this,this._dropScaleCache)),(0,eo.isLineTool)(e)&&(this._drawingCount--,0===this._drawingCount&&(0,lt.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,Fn.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(Nr.isActingAsSymbolSource);for(const u of _){if(!u.isVisible())continue;const _=u.symbolInfo();if(null===_){t=null;break}const p=(0,yt.symbolOriginalCurrency)(_);if(null===p){t=null;break}r.set(p,(0,n.ensureNotNull)((0,yt.symbolOriginalCurrency)(_,!0)));const m=u.currency();if(null===m){t=null;break}r.set(m,(0,n.ensureNotNull)((0,yt.symbolCurrency)(_,!0)));const g=(0,yt.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,yt.symbolCurrencyConvertible)(_)||(c=!0),d+=1,a.add((0,yt.proSymbol)(_,u.symbol()))}if(null!==t)for(const i of this._priceDataSources){if(_.includes(i))continue;const s=i;if(!s.isCurrencySource()||!s.isVisible())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,yt.symbolCurrencyConvertible)(d)||(c=!0),r.set(a,(0,n.ensureNotNull)((0,yt.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(Nr.isActingAsSymbolSource);for(const n of _){if(!n.isVisible())continue;const u=n.symbolInfo();if(null===u){t=null;break}const _=(0,yt.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=sh(u,p,e);c=(0,ft.intersect)(c,new Set(t))}d+=1,a.add((0,yt.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())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=sh(p,h,e);c=(0,ft.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(Nr.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,dt.isNumber)(e.top)||!(0,dt.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,ih.toLog)(e.from,this._logFormula):e.from,r=o?(0,ih.toLog)(e.to,this._logFormula):e.to;const a=r-n;n+=s*a,r-=i*a,this.setMode({autoScale:!1}),this.setPriceRange(new th.PriceRange(n,r)),this._marksCache=null,this._onMarksChanged.fire()}hasMainSeries(){return this._hasSeries}getStudies(){return this.dataSources().filter(Js.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,ci.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 th.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,Fn.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,Nr.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),gl(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,Js.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,lt.hideAllIndicators)().subscribe(this,this._dropScaleCache),this._studiesCount++),(0,eo.isLineTool)(e)&&(0===this._drawingCount&&(0,
lt.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()&&!gl(t))&&(e?gl(t):(0,Js.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,ih.toPercentRange)(u,i):o&&(u=(0,ih.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 th.PriceRange(t.minValue()-.5,t.maxValue()+.5)),this.setPriceRange(t)):this._priceRange||this.setPriceRange(new th.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,ih.fromLog)(e.minValue(),this._logFormula),i=(0,ih.fromLog)(e.maxValue(),this._logFormula);return new th.PriceRange(t,i)}_convertPriceRangeToLog(e){if(null===e)return null;const t=(0,ih.toLog)(e.minValue(),this._logFormula),i=(0,ih.toLog)(e.maxValue(),this._logFormula);return new th.PriceRange(t,i)}_canConvertPriceRangeFromLog(e){if(null===e)return!1;const t=(0,ih.fromLog)(e.minValue(),this._logFormula),i=(0,ih.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(!_h)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,ih.logFormulaForBase)(null);else{const e=t.base()||null,i=(0,ih.logFormulaForBase)(e);(0,ih.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,eo.isLineTool)(e)||e.isActualSymbol()&&e.isActualCurrency()))),this._sourcesToUpdateViews}_mainSourceFormatter(){const e=this.mainSource();return e?.formatter()||mh}_priceToPercentOrIndexedTo100IfNeeded(e,t){return this.isPercentage()?(0,ih.toPercent)(e,t):this.isIndexedTo100()?(0,ih.toIndexedTo100)(e,t):e}_onSourceIsActingAsSymbolSourceChanged(){this._dropScaleCache()}_onIsInvertedChanged(){this._marksCache=null,this._markBuilder.rebuildTickMarks()}_updateResetAvailableValue(){this._resetScaleAvailable.setValue(!this.isLockScale()&&!this.isAutoScale())}}var yh=i(678);const vh=[],Sh=[];class bh{constructor(e){this._studies={},this._deferreds={},this._container=e,vh.push(e),Sh.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=vh.indexOf(this._container);~e&&(vh.splice(e,1),Sh.splice(e,1))}static instance(e){const t=vh.indexOf(e);return~t?Sh[t]:new bh(e)}static ready(){for(const e of Sh)if(Object.keys(e._deferreds).length>0)return!1;return!0}}var wh=i(65365);var Ch=i(10892),Ph=i(42989),Th=i(79303);function xh(e){e.wickUpColor=e.wickUpColor??e.wickColor,e.wickDownColor=e.wickDownColor??e.wickColor,delete e.wickColor}function Ih(e){e&&(e.colorType??=So.ColorType.Solid)}const Mh=l.enabled("clear_price_scale_on_error_or_empty_bars"),Ah=(0,ae.getLogger)("Chart.Pane");var Lh;function kh(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"}(Lh||(Lh={}));const Dh="chart.pane";class Eh{constructor(e,t,i,s,o){this.m_dataSources=[],this._sourceWatchedValuesSubscriptions=new Map,this.m_mainDataSource=null,this._cachedOrderedSources=new eh(this),this._sourcesById=new Map,this._priceSourcesById=new Map,this._sourcePropertiesChanged=new re.Delegate,this._sourcesZOrderChanged=new re.Delegate,this._tagsChanged=new re.Delegate,this._stretchFactor=1e3,this._isInInsertManyDataSourcesState=!1,this._lastLineDataSourceZOrder=null,this._rightPriceScales=[],this._leftPriceScales=[],this._allPriceScalesIncludingOverlays=[],this._lockedPriceScale=null,this._currentPriceScaleRatio=null,
this._onPriceScalesChanged=new re.Delegate,this._isRecalculatingScales=!1,this._priceDataSources=[],this._symbolSources=[],this._lollipopDataSources=[],this._symbolSourceResolved=new re.Delegate,this._symbolSourceResolvingActive=new F.WatchedValue(!1),this._bulkActions={activeCounter:0},this._height=0,this._width=0,this._sizeChanged=new re.Delegate,this._dataSourcesCollectionChanged=new re.Delegate,this._symbolSourceCollectionChanged=new re.Delegate,this._priceSourcesCollectionChanged=new re.Delegate,this._isMainPane=new F.WatchedValue(!1),this._collapsed=new F.WatchedValue(!1),this._resetPriceScalesAvailable=new F.WatchedValue(!1),this._destroyed=new re.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,qc.createPriceScaleSelectionStrategy)(i.properties().childs().priceScaleSelectionStrategyName.value()),this._id=s??(0,fe.randomHashN)(6),this._mode=o??Bi.PaneMode.Regular,this._timeScale=e,this.m_mainDataSource=null,this._properties=t,this._model=i,this._maximized=(0,Ji.combine)((e=>e===this),i.maximizedPane().spawnOwnership()),this._collapsingAvailable=(0,Ji.combine)(((e,t)=>t),this._isMainPane.weakReference(),i.paneCollapsingAvailable().weakReference()),i.properties().childs().priceScaleSelectionStrategyName.subscribe(null,(e=>{this._priceScaleSelectionStrategy=(0,qc.createPriceScaleSelectionStrategy)(e.value()),this._priceScaleSelectionStrategy.apply(this)})),this._timeScale.barSpacingChanged().subscribe(this,(()=>{this.m_mainDataSource===this._model.mainSeries()&&this._recalculatePriceScaleByScaleRatio(this.m_mainDataSource.priceScale())})),Mh&&(this._seriesDisplayError=(0,yt.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 $c((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===Bi.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 fh(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,ft.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,ft.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,jc.getPersistentLogger)()?.addPersistentLogEntry(`changeSourceId for series from ${e.id()} to ${t}`,ae.LOGLEVEL.INFO,Dh),(0,n.assert)(this.hasDataSource(e));const i=e.id();e.setId(t),this._sourcesById.delete(i),this._sourcesById.set(t,e),(0,Fn.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),th.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,Fn.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===Bi.PaneMode.Regular&&this._processMainSourceChange(),this._tagsChanged.fire(),(0,Fn.isPriceDataSource)(e)&&this.recalculatePriceScale(t,(0,Bt.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}addDataSource(e,t,i){let s=e.zorder();i||((0,eo.isLineTool)(e)&&!e.isSpeciallyZOrderedSource()?(s=null!==this._lastLineDataSourceZOrder?this._lastLineDataSourceZOrder+1:this.newLineToolZOrder(),this._isInInsertManyDataSourcesState&&(this._lastLineDataSourceZOrder=s)):(0,Js.isStudy)(e)&&!e.isSpeciallyZOrderedSource()&&(s=this.newStudyZOrder())),this.insertDataSource(e,t,s)}removeDataSource(e,t=!1,i=!1,s=!1){const o=this.m_dataSources.indexOf(e);if(-1===o)return void Ah.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,Fn.isPriceDataSource)(e)&&!t&&this._processMainSourceChange(),(0,Js.isStudy)(e)&&e.metaInfo().hasForceOverlayPlots()&&this._model.removeMultiPaneSource(e),this._tagsChanged.fire(),n&&(0,Fn.isPriceDataSource)(e)&&this.recalculatePriceScale(n,(0,Bt.sourceChangeEvent)(e.id())),this._invalidateSourcesCache()}hasDataSource(e){return this._sourcesById.has(e.id())}hasPriceDataSource(e){return this._priceSourcesById.has(e.id())}dataSources(){return this.m_dataSources}priceDataSources(){return this._priceDataSources}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,Fn.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,eo.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 fh(this.model().properties().childs().scalesProperties,i);return s.setHeight(this.height()),kh(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&&Ah.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,Bt.sourceChangeEvent)(e.id())),this.recalculatePriceScale(t,(0,Bt.sourceChangeEvent)(e.id()))),this._onPriceScalesChanged.fire()}setZOrders(e){e.forEach(((e,t)=>{t.setZorder(e)})),this._invalidateSourcesCache(),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 function(e){let t=-1e4
;for(const i of e)yl(i)&&(t=Math.min(t,i.zorder()-1e4));return 0===t?-1e4:t}(this._priceDataSources)}newLineToolZOrder(e){return function(e,t){return Ll(e,fl,yl,bl,wl,t)}(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],Fl)}bringToFront(e){const t=this.sourcesByGroup().allExceptSpecialSources();this._batchReorder(e,t[t.length-1],Ol)}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,Ol)}insertBefore(e,t){this._batchReorder(e,t,Fl)}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,Vo.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,Fn.isPriceDataSource)(e))||this._nonOverlayPricesSourcesCount()>1}properties(){return this._properties}setPriceAutoScale(e,t){e.setMode({autoScale:t}),this.timeScale().isEmpty()||this.recalculatePriceScale(e,(0,Bt.viewportChangeEvent)())}state(e,t,i,s,o,n){const r={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},a=new Map,l=e=>{if(a.has(e))return a.get(e);let r=null;const l=i&&!e.isSavedInStudyTemplates()||!e.state||(0,eo.isLineTool)(e)&&n||!e.isSavedInChart(Boolean(t))||!(r=e.state(t,o))||s&&(0,
eo.isLineTool)(e)&&e.isActualSymbol&&!e.isActualSymbol()||e.isPhantom()?null:r;return a.set(e,l),l};if(e){r.sources=[];for(let e=0;e<this.m_dataSources.length;e++){const t=l(this.m_dataSources[e]);null!==t&&r.sources.push(t)}}const c=e=>null!==a.get(e),h=e=>!n||!(0,eo.isLineTool)(e);r.leftAxisesState=this._leftPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(c).filter(h).map((e=>e.id()))}))),r.rightAxisesState=this._rightPriceScales.map((e=>({state:e.state(),sources:e.dataSources().filter(c).filter(h).map((e=>e.id()))}))),r.overlayPriceScales={};for(const e of this.m_dataSources)if(this.isOverlay(e)&&e.isSavedInChart(Boolean(t))){const t=e.priceScale();r.overlayPriceScales[e.id()]=t?.state()??null}return r}restoreState(e){const{state:t,withData:i,version:s,seriesId:o=this._model.mainSeries().id(),settingsMigration:r={},contentOverrides:a,restoreSilently:l,reason:c=0,targetSeriesStyle:d=this._model.mainSeries().style()}=e;(0,jc.getPersistentLogger)()?.addPersistentLogEntry(`Restoring pane with seriesId ${o}`,ae.LOGLEVEL.INFO,Dh),this._mode=t.mode??Bi.PaneMode.Regular,t.stretchFactor&&(this._stretchFactor=t.stretchFactor);const u={};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)))||(Ah.logNormal("Dropped invalid "+e.type+". Reason: non-numeric point time"),!1))))),n=e.findIndex(pt.isMainSeriesState);-1!==n&&this.model().mainSeries().setObsoleteZOrder(e[n].zorder),s<3&&Ml(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 Ah.logWarn("There is no main source with id "+t.mainSourceId+", total sources="+e.length);if(!window.TradingView[i.type]||!(0,wt.isLineToolName)(i.type))return void Ah.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,wt.isLineToolName)(t.type)){if(null!==s)return void Ah.logWarn("Pane contains more than 1 possibly main sources - auto fix cannot be applied");s=t}if(null===s)return void Ah.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)})),Ah.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?(u[t.id]=t.ownerSource,(0,pt.isMainSeriesState)(t)?this._restoreMainSeries(t,i,h,r,a,l):(0,pt.isStudyState)(t)?this.restoreStudy(t,i,o,r,l,c):(0,pt.isLineToolState)(t)?(t.state&&(t.state.zOrderVersion=2),
this.restoreLineTool(t,i,void 0,l)):"TpoSummaryDataSource"===t.type&&18===d&&this.restoreTpoSummaryDataSource(t,i,l)):Ah.logError("Duplicate id while restoring pane: "+t.type+","+t.id))}const _=new Set,p=(e,t)=>{e.priceScale()!==t&&(this.removeSourceFromPriceScale(e),e.setPriceScale(t),t.addDataSource(e))},m=(e,i,s)=>{if(_.has(e))return;_.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).forEach((e=>{t.overlayPriceScales?.[e.id()]||m(e,i,s)})),p(e,i)},g=e=>{const t=(0,h.defaults)("chartproperties").paneProperties.axisProperties,i=new fh(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&&m(s,i,t)})),0===i.dataSources().length?null:i},f=e=>e.map(g).filter((e=>null!==e));let y;if(t.leftAxisesState)y=f(t.leftAxisesState);else{const e=g({state:t.leftAxisState,sources:t.leftAxisSources});y=null!==e?[e]:[]}let v;if(this._leftPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._leftPriceScales=[],y.forEach((e=>this._placePriceScale(e,"left"))),t.rightAxisesState)v=f(t.rightAxisesState);else{const e=g({state:t.rightAxisState,sources:t.rightAxisSources});v=null!==e?[e]:[]}this._rightPriceScales.slice().forEach((e=>this.removePriceScale(e))),this._rightPriceScales=[],v.forEach((e=>this._placePriceScale(e,"right"))),this._currentPriceScaleRatio=t.priceScaleRatio||t.leftPriceScaleRatio||t.rightPriceScaleRatio||null;const S=new Map;for(const e of this.m_dataSources){if(_.has(e))continue;let i;if(t.overlayPriceScales&&t.overlayPriceScales[e.id()]){let s=t.overlayPriceScales[e.id()];S.has(s?.id)?i=S.get(s?.id):(s=(0,n.ensure)(s),i=new fh(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),S.set(s.id,i))}else i=new fh(this._model.properties().childs().scalesProperties),i.setHeight(this._height);p(e,i)}for(const e of Object.keys(u)){const t=u[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,Fn.isPriceDataSource)(e)){this.m_mainDataSource=e;break}for(const e of this.m_dataSources)(0,eo.isLineTool)(e)?(e.ownerSource()||e.setOwnerSource(this.mainDataSource()),e.isFixed()&&e.restoreFixedPoint()):(0,Js.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(){Yc.ExecutionsPositionController.recreateOrderedByBarsSourcesCache(this)}clearDrawingCaches(){Yc.ExecutionsPositionController.clearOrderedByBarsSourcesCache()}executionsPositionController(){return this._executionsPositionController||(this._executionsPositionController=new Yc.ExecutionsPositionController(this)),this._executionsPositionController}width(){return this._width}height(){return this._height}setHeight(e){if(this._height!==e&&(this._height=e,this._mode===Bi.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,Bt.viewportChangeEvent)()),this._sizeChanged.fire()}}setWidth(e){return this._width!==e&&(this._width=e,this.updateAllViews((0,Bt.viewportChangeEvent)()),this._sizeChanged.fire(),!0)}onSizeChanged(){return this._sizeChanged}onTagsChanged(){return this._tagsChanged}onDestroyed(){return this._destroyed}dataSourcesCollectionChanged(){return this._dataSourcesCollectionChanged}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(eo.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 At.Point(Math.min(r,l),Math.min(o,a)),h=new At.Point(Math.max(r,l),Math.max(o,a));return(0,At.box)(c,h)}timeScale(){return this._timeScale}restoreLineTool(e,t,i,s,o){if((0,wt.isMtpPredictorToolName)(e.type))return Ah.logWarn(`No longer supported tool ${e.type} is skipped while restoring state`),null;var r;delete e.state.lastUpdateTime,e.state.intervalsVisibilities=(0,Ch.mergeIntervalVisibilitiesDefaults)(e.state.intervalsVisibilities),i=void 0===i||i,wh.LineToolElliott.migrateState(e),"LineToolGannComplex"!==(r=e).type||void 0!==r.version&&1!==r.version||(r.type="LineToolGannFixed"),Array.isArray(e.positionPercents)&&(e.positionPercents=e.positionPercents[0])
;const a=e.type,l=e.id,c=e.state,h=i?e.zorder:this.newLineToolZOrder();(0,n.assert)((0,wt.isLineToolName)(a),"invalid data source type:"+a+" (expected to be a Line Tool)");let d,u,_=null;if((0,pt.isStudyLineToolState)(e)){_=this._model.isSnapshot()?new Th.StudyVersioning([],[]):(0,ts.studyMetaInfoRepository)().studyVersioning();const t=Th.StudyVersioning.patchPointsBasedStudyState(e);e=t;const i=new is.StudyMetaInfo(t.metaInfo);0;const s=_.updateMetaInfo(i)??i;u=(0,eo.createStudyLineToolProperties)(this._model.backgroundTheme().spawnOwnership(),a,i,s,c,_),d=(0,eo.createLineTool)(a,this._model,u,s,!0)}else u=(0,eo.createLineToolProperties)(this._model.backgroundTheme().spawnOwnership(),a,!this._model.readOnly(),c),d=(0,eo.createLineTool)(a,this._model,u,null,!0);d.setId(l),d.linkKey().setValue(e.linkKey||null);e.alertId&&d.canHasAlert();let p=e.indexes??[];if(p=p.slice(0,e.points?.length??p.length),d.isFixed()?void 0!==e.positionPercents?d.restorePositionPercents(e.positionPercents):d.restorePositionPercents({x:.5,y:.5}):e.points&&d.restorePoints(e.points,p,t),(0,eo.isLineTool)(d)&&["LineToolBarsPattern","LineToolCallout","LineToolTrendAngle","LineToolGhostFeed","LineToolParallelChannel"].includes(d.toolname))d.restoreData?.(e);else if(t&&(0,pt.isStudyLineToolState)(e)&&d.restoreData){const t=e;_&&(t.graphics=Th.StudyVersioning.patchPointsBasedStudyData(new is.StudyMetaInfo(t.metaInfo),t.graphics)),d.restoreData?.(t)}const m=null==e.version?1:e.version,g=null==d.version?1:d.version;if(m!==g&&d.migrateVersion?.(m,g,{pane:this,model:this._model,properties:u}),void 0!==h&&d.setZorder(h),o)(0,eo.prepareLineToolPropertiesByOwnerSource)(d.properties(),o),d.setOwnerSource(o);else{const t=e.ownerSource?this.dataSourceForId(e.ownerSource):null;d.setOwnerSource(t)}return d.isFixed()&&d.restoreFixedPoint(),void 0!==e.userEditEnabled&&d.setUserEditEnabled(e.userEditEnabled),void 0!==e.isSelectionEnabled&&d.setSelectionEnabled(e.isSelectionEnabled),this._addSourceToCollections(d,s),this._cachedOrderedSources.clear(),d}restoreStudy(e,t,s,o,n,r){if(t&&void 0===e.data&&void 0===e.nonSeriesData&&void 0===e.indexes)return Ah.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));let u=new is.StudyMetaInfo(e.metaInfo);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}(u.id)&&!t)return Ah.logNormal("Skipping study "+u.id),null;let _=c;const p=new wc.StudyStub(this._model,e,u.shortDescription??u.name);p.setId(l),p.setZorder(h);const m=bh.instance(this._model);m.get(l);let g=!1;const f=(i,s)=>{
if(g&&this._model.dataSourceForId(l)!==p)return;p.setStatus({type:yh.StudyStatusType.Undefined});const o=i??u,n=async n=>{const a=(0,Cc.prepareStudyPropertiesForLoadChart)(u,i,_,s),c=await(0,Js.createStudy)(this._model,a,n,o,void 0,r);if(c.setId(l),c.setOwnFirstValue(e.ownFirstValue??null),e.customFields&&c.restoreStateCustomFields(e.customFields),t){const t=e,{data:i,nsData:s,indexes:o}=Th.StudyVersioning.patchStudyData(u,t.data,t.nonSeriesData,t.indexes);c.restoreData(i,s,o)}this._model.replaceStudyStub(p,c),m.add(l,c)};if(d.length>0){const e=d.map((e=>m.get(e)));Promise.all(e).then(n)}else n([])};let y;if(t){const e=Th.StudyVersioning.patchPropsStateAndMetaInfo(c,u,{oldShowStudyLastValueProperty:!o?.showStudyLastValueProperty});y=Promise.resolve(new is.StudyMetaInfo(e.metaInfo))}else{y=(0,ts.studyMetaInfoRepository)().requestMetaInfo().then((()=>{const e=Th.StudyVersioning.patchPropsStateAndMetaInfo(c,u,{oldShowStudyLastValueProperty:t&&!o?.showStudyLastValueProperty});return _=e.propsState,new is.StudyMetaInfo(e.metaInfo)}))}y.then((e=>{const t=this._model.isSnapshot()?new Th.StudyVersioning([],[]):(0,ts.studyMetaInfoRepository)().studyVersioning();if(null===e||this._model.isSnapshot())return void f(e,t);const i=t.updateMetaInfoAsync(e);i.sync?f(i.result??e,t):i.result.then((e=>f(e,t))).catch((e=>p.setFailed("error: "+e)))})).catch((()=>p.setFailed(a.t(null,void 0,i(11768))))),p.setZorder(h);const v=e.metaInfo.linkedToSeries?this._model.mainSeries():d.length?this.dataSourceForId(d[0]):null;return p.setOwnerSource(v),this._addSourceToCollections(p,n),g=!0,this._processMainSourceChange(),this._cachedOrderedSources.clear(),p}restoreTpoSummaryDataSource(e,t,i){const s=new TpoSummaryDataSource(this._model);return this._addSourceToCollections(s,i),this._cachedOrderedSources.clear(),s}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,Fn.isPriceDataSource)(e)&&null!==e.firstValue())return e;return null}realignLineTools(e){let t=!1;for(const i of this.m_dataSources)!(0,eo.isLineTool)(i)||void 0!==e&&i?.ownerSource()?.symbolSource()!==e&&(0,Nr.isActingAsSymbolSource)(e)||(i.realign(),i.updateAllViews((0,Bt.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,Bt.viewportChangeEvent)())}endScalePrice(e){e.endScale()}startScrollPrice(e,t){e.startScroll(t)}scrollPriceTo(e,t){e.scrollTo(t),this.updateAllViews((0,Bt.viewportChangeEvent)())}endScrollPrice(e){e.endScroll()}resetPriceScale(e){const t=this.timeScale().visibleBarsStrictRange();e.resetScaleAvailable().value()&&e.resetScale(),e.recalculatePriceRange(t),this.updateAllViews((0,Bt.viewportChangeEvent)())}resetPriceScalesAvailable(){return this._resetPriceScalesAvailable.readonly()}restorePriceScaleState(e,t){e.restoreState(t),this.updateAllViews((0,
Bt.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)}}setPriceScaleRangeAnimation(e,t){const i=yo.InvalidationMask.cursor(),s=this._model.panes().indexOf(this),o=this.priceScalePosition(e);i.setPriceScaleRangeAnimation(s,e.id(),t),"overlay"!==o&&i.invalidatePriceScale(s,o,(0,n.ensureDefined)(this.priceScaleIndex(e,o)),yo.InvalidationLevel.Light),this._model.invalidate(i)}_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,Fn.isPriceDataSource)(t)&&!this.isOverlay(t)&&(!(0,Js.isStudy)(t)||!t.isLinkedToSeries())){this.m_mainDataSource=t,e=!0;break}if(this.m_mainDataSource&&e){let e=this.m_dataSources.filter(eo.isLineTool);e=(0,ci.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,Fn.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).forEach((e=>{this.removeSourceFromPriceScale(e),i.addDataSource(e),e.setPriceScale(i)})),this.removePriceScale(t)}this.move(e,i,!0),this.recalculatePriceScale(e.priceScale(),(0,Bt.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,eo.isLineTool)(e)){e.normalizedPointsChanged().subscribe(this,i),e.fixedPointChanged().subscribe(this,i),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,Nr.isSymbolSource)(e)?e:null;(0,Fn.isPriceDataSource)(e)&&(this._priceSourcesById.set(e.id(),e),e.currencyChanged().subscribe(this,(()=>this._invalidateSourcesCache())),e.unitChanged().subscribe(this,(()=>this._invalidateSourcesCache())),
e.priceScaleChanged().subscribe(this,(()=>this._onPriceScalesCollectionIncludingOverlaysMayChange())),this._priceDataSources.push(e),this._onPriceSourcesCollectionChanged(),this._onPriceScalesCollectionIncludingOverlaysMayChange(),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,eo.isLineTool)(i)){if(i.normalizedPointsChanged().unsubscribeAll(this),i.fixedPointChanged().unsubscribeAll(this),this._sourceWatchedValuesSubscriptions.has(s)){const e=this._sourceWatchedValuesSubscriptions.get(s);e&&(i.hasAlert().unsubscribe(e.commonCallback),i.linkKey().unsubscribe(e.linkKeyCallback))}this._lineToolsByLinkKey.removeByKey2(i.id())}this._invalidateSourcesCache();const o=(0,Nr.isSymbolSource)(i)?i:null;(0,Fn.isPriceDataSource)(i)&&(this._priceSourcesById.delete(i.id()),i.currencyChanged().unsubscribeAll(this),i.unitChanged().unsubscribeAll(this),i.priceScaleChanged().unsubscribeAll(this),(0,ft.removeItemFromArray)(this._priceDataSources,i),this._onPriceSourcesCollectionChanged(),null!==o&&((0,ft.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)kh(i,e,t);for(const i of this._rightPriceScales)kh(i,e,t);for(const i of this.m_dataSources)if(this.isOverlay(i)){const s=i.priceScale();null!==s&&(kh(s,e,t),this.recalculatePriceScale(s,(0,Bt.viewportChangeEvent)()))}for(const e of this._leftPriceScales)this.recalculatePriceScale(e,(0,Bt.viewportChangeEvent)())
;for(const e of this._rightPriceScales)this.recalculatePriceScale(e,(0,Bt.viewportChangeEvent)());this.updateAllViews((0,Bt.viewportChangeEvent)())}_batchReorder(e,t,i){i(this.sourcesByGroup().allExceptSpecialSources(),e,t),this._invalidateSourcesCache(),this._dataSourcesCollectionChanged.fire(),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,uc.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,Bt.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,uc.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,uc.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,uc.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 th.PriceRange(-.5,.5)}_setMinMaxPriceRange(){const e=(0,n.ensureNotNull)(this._lockedPriceScale),t=(0,uc.priceRangeByScaleRatio)(e,this.timeScale().maxBarSpacing(),this._currentPriceScaleRatio),i=(0,uc.priceRangeByScaleRatio)(e,this.timeScale().minBarSpacing(),this._currentPriceScaleRatio);null!==t&&e.setMaxPriceRange(t),null!==i&&e.setMinPriceRange(i)}_onPriceScaleSetMinMaxPriceRange(e){e===this._lockedPriceScale&&this._setMinMaxPriceRange()}_onPriceSourcesCollectionChanged(){0===this._bulkActions.activeCounter?this._priceSourcesCollectionChanged.fire():this._bulkActions.priceSourcesCollectionChanged=!0}_nonOverlayPricesSourcesCount(){return this.m_dataSources.filter((e=>(!(0,Js.isStudy)(e)||!e.isLinkedToSeries())&&((0,Fn.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,Ph.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,dt.clone)(l.lineStyle)),1===e&&(t=15,l.steplineStyle=(0,dt.clone)(l.lineStyle)),void 0!==t&&2===l.style&&(l.style=t)}if(l)for(const e of["lineStyle","lineWithMarkersStyle","steplineStyle"])Ih(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,jc.getPersistentLogger)()?.addPersistentLogEntry(`Restore series. source.id: ${e.id} id: ${a}`,ae.LOGLEVEL.INFO,Dh),c.restoreState(e,t),this.changeSourceId(c,a),(0,jc.getPersistentLogger)()?.addPersistentLogEntry(`Series has been successfully restored. id: ${c.id()}`,ae.LOGLEVEL.INFO,Dh),c.sessionId()!==u&&h.sessionId.fireChanged()}async _restoreMainSeriesStudyInputs(e,t){await(0,ts.studyMetaInfoRepository)().requestMetaInfo();const i=(0,ts.studyMetaInfoRepository)().studyVersioning(),s={haStyle:(0,yt.chartStyleStudyId)(8,!0),renkoStyle:(0,yt.chartStyleStudyId)(4,!0),pbStyle:(0,yt.chartStyleStudyId)(7,!0),kagiStyle:(0,yt.chartStyleStudyId)(5,!0),pnfStyle:(0,yt.chartStyleStudyId)(6,!0),rangeStyle:(0,yt.chartStyleStudyId)(11,!0),volFootprintStyle:(0,yt.chartStyleStudyId)(17,!0),tpoStyle:(0,yt.chartStyleStudyId)(18,!0),svpStyle:(0,yt.chartStyleStudyId)(20,!0)},o={},r=(0,n.ensureDefined)(e.state);for(const[n]of Object.entries(_t.SYMBOL_STRING_DATA)){const a=`${_t.STYLE_SHORT_NAMES[n]}Style`,l=r[a]?.inputs;if(null==l)continue;const c=a in e?e[a].studyId:s[a],h=is.StudyMetaInfo.parseIdString(c),d=t[a].studyId,u=is.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))}_onPriceScalesCollectionIncludingOverlaysMayChange(){const e=Array.from(new Set(this._priceDataSources.map((e=>e.hasPriceScale()?e.priceScale():null)).filter(dt.notNull))),t=e.filter((e=>!this._allPriceScalesIncludingOverlays.includes(e))),i=this._allPriceScalesIncludingOverlays.filter((t=>!e.includes(t)));for(const e of t)e.priceRangeAnimationRequested().subscribe(this,this.setPriceScaleRangeAnimation.bind(this,e));for(const e of i)e.priceRangeAnimationRequested().unsubscribeAll(this);this._allPriceScalesIncludingOverlays=e}}var Bh,Vh=i(91988);!function(e){e[e.Contains=0]="Contains",e[e.PlacedBefore=1]="PlacedBefore",e[e.PlacedAfter=2]="PlacedAfter"}(Bh||(Bh={}));class Rh{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 Nh=(0,ae.getLogger)("Chart.TimePoints");function Oh(e,t){
return null===e||null===t?e===t:e.firstIndex===t.firstIndex&&e.lastIndex===t.lastIndex}var Fh;!function(e){e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Nearest=2]="Nearest"}(Fh||(Fh={}));class Wh{constructor(){this._zoffset=0,this._items=[],this._range=new ht.WatchedObject(null,Oh)}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,ft.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 Nh.logError("merge: 'values' does not contain any time points"),[]
;if(t>this._zoffset&&e+t>0)return Nh.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 Nh.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 Hh=i(50503);const zh=new Map([[0,.1],[11,.1],[1,.35],[9,.35],[12,.35],[8,.35]]);class Uh{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=(zh.get(e)||0)/2;t=new Vh.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 Uh(null,1)}}class Gh{constructor(){this._marksByIndex=new Map,this._marksBySpan=[],this._changed=new re.Delegate}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;for(let t=0;t<e.length;t++){const i=e[t],s=i.index,o=i.span,n=this._marksByIndex.get(s);if(n){if(n.index===s&&n.span===o){n.time=i.time;continue}this._removeTickmark(n)}}for(let t=0;t<e.length;t++){const i=e[t],s=i.index,o=i.span;if(this._marksByIndex.has(i.index))continue;this._marksByIndex.set(s,i);let a=n[o];void 0===a&&(a=[],n[o]=a);const l=0===a.length||a[a.length-1].index<i.index;n[o].push(i),l||r.add(o)}this.minIndex=void 0===this.minIndex?i:Math.min(this.minIndex,i),this.maxIndex=void 0===this.maxIndex?s:Math.max(this.maxIndex,s);for(let e=n.length;e--;)n[e]&&(n[e].length||delete n[e],r.has(e)&&n[e].sort(((e,t)=>e.index-t.index)));this._cache=void 0,this._changed.fire()}build(e,t){const i=Math.ceil(t/e);if(this._maxbar===i&&this._cache)return this._cache;this._maxbar=i;let s=[];for(let e=this._marksBySpan.length;e--;){if(!this._marksBySpan[e])continue;const t=s;s=[];const o=t.length;let n=0;const r=this._marksBySpan[e],a=r.length;let l=1/0,c=-1/0;for(let e=0;e<a;e++){const a=r[e],h=a.index;for(;n<o;){const e=t[n],i=e.index;if(!(i<h)){l=i;break}n++,s.push(e),c=i,l=1/0}l-h>=i&&h-c>=i&&(s.push(a),c=h)}for(;n<o;n++)s.push(t[n])}return this._cache=s,this._cache}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._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){const t=new Map;this.maxIndex=this.minIndex,this._marksByIndex.forEach(((i,s)=>{i.time<e&&(t.set(s,i),this.maxIndex=Math.max(this.maxIndex??0,s))})),this._marksByIndex=t}addTail(e){for(let t=0;t<e.length;t++)e[t].index=(this.maxIndex??0)+t+1;this.merge(e)}_resetImpl(){this._marksByIndex=new Map,this._marksBySpan=[],this.minIndex=void 0,this.maxIndex=void 0,this._cache=void 0}_removeTickmark(e){if(void 0===this.minIndex||void 0===this.maxIndex)return;const t=e.index;if(this._marksByIndex.get(t)!==e)return;this._marksByIndex.delete(t),t<=this.minIndex&&this.minIndex++,t>=this.maxIndex&&this.maxIndex--,this.maxIndex<this.minIndex&&(this.minIndex=void 0,this.maxIndex=void 0);const i=this._marksBySpan[e.span],s=i.indexOf(e);-1!==s&&i.splice(s,1)}_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}}class jh{constructor(e,t=50){this._actualSize=0,this._usageTick=1,this._oldestTick=1,this._cache=new Map,this._tick2Labels=new Map,this._format=e,this._maxSize=t}format(e){
const t=this._cache.get(e.valueOf());if(void 0!==t)return t.string;if(this._actualSize===this._maxSize){const e=this._tick2Labels.get(this._oldestTick);this._tick2Labels.delete(this._oldestTick),this._cache.delete((0,n.ensureDefined)(e)),this._oldestTick++,this._actualSize--}const i=this._format(e);return this._cache.set(e.valueOf(),{string:i,tick:this._usageTick}),this._tick2Labels.set(this._usageTick,e.valueOf()),this._actualSize++,this._usageTick++,i}}let qh;var $h=i(15344),Kh=i(63146),Yh=i(8025);class Zh{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}}const Xh={preserveBarSpacing:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!0,minBarSpacing:.5},Jh=l.enabled("low_density_bars"),Qh=Jh?1:2,ed=(0,ae.getLogger)("Chart.TimeScale");var td;!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"}(td||(td={}));class id{constructor(e,t){this._width=0,this._widthChanged=new re.Delegate,this._rightOffset=10,this._rightOffsetChanged=new re.Delegate,this._maxRightOffsetChanged=new re.Delegate,this._defaultRightOffset=new F.WatchedValue(10),this._defaultRightOffsetPercentage=new F.WatchedValue(5),this._usePercentageRightOffset=new F.WatchedValue(!1),this._lastDefaultRightOffset=void 0,this._baseIndex=null,this._leftEdgeIndex=null,this._barSpacingChanged=new re.Delegate,this._barSpacing=6,this._snapshotBarSpacing=null,this._visibleBars=Uh.invalid(),this._visibleBarsInvalidated=!0,this._visibleBarsChanged=new re.Delegate,this._logicalRangeChanged=new re.Delegate,this._points=new Wh,this._tickMarks=new Gh,this._onScroll=new re.Delegate,this._resetDelegate=new re.Delegate,this._scrollData=null,this._scaleStartPoint=null,this._commonTransitionStartState=null,this._formattedBySpan=new Map,this._requestingMoreData=!1,this._requestedTickmarksCount=0,this._endOfData=!1,this._lockBarsAndLogicalRangeEvents=!1,this._resetAvailable=new F.WatchedValue(!1),this._pointWeights=new Zh,this._weightedPointsCache=[],this._throttleRequestMoreDataOnScroll=(0,o.default)(this._requestMoreData,300),this._options=(0,ge.deepExtend)({},Xh,t),this._model=e,this._scalesProperties=e.properties().childs().scalesProperties,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()}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 ed.logDebug("restoreState: invalid state");if(void 0===e.m_rightOffset)return void ed.logDebug("restoreState: invalid state");e.weights&&(this._pointWeights=function(e){let t;switch(e.type){case"constant":return t=new Zh,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,t),l=[];for(const e of a){if(!(o<=e.index&&e.index<=r))continue;const t=this._tickMarks.indexToTime(e.index);null!==t&&l.push({coord:this.indexToCoordinate(e.index),label:this.formatLabel(t,e.span),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(),Yh.PlotRowSearchMode.NearestRight),s=e.search(t.lastBar(),Yh.PlotRowSearchMode.NearestLeft);return null===i||null===s?null:new Vh.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,Yh.PlotRowSearchMode.NearestLeft),o=0===t?null:e.search(i.lastBar()+1,Yh.PlotRowSearchMode.NearestRight);return null===s&&(s=e.search(i.firstBar(),Yh.PlotRowSearchMode.NearestRight)),null===o&&(o=e.search(i.lastBar(),Yh.PlotRowSearchMode.NearestLeft)),null===s||null===o?null:new Vh.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 ed.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().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,ft.upperbound)(e,Hh.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,ft.upperbound)(e,Hh.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 Vr({from:0,to:i-o,duration:1e3,easing:Mr.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,Bt.viewportChangeEvent)()),void this._model.lightUpdate();const r=s+(e-s)*t;this._updateRightOffset(r),this._model.recalculateAllPanes((0,Bt.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 ed.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,li.allowSavingDefaults)(!0),this._scalesProperties.childs().barSpacing.setValue(this._barSpacing),(0,li.allowSavingDefaults)(!1)),this._model.recalculateAllPanes((0,Bt.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+Qh}maxRightOffset(){return this.width()/this._barSpacing-Qh}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 ed.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),Qh);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 Jh?e:e/Qh}minVisibleBarCount(){return Qh}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 ed.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,Bt.viewportChangeEvent)()),this._model.lightUpdate())}resetBaseIndex(){this._visibleBarsInvalidated=!0,this._baseIndex=null}setRightOffset(e){Number.isFinite(e)?(this._visibleBarsInvalidated=!0,this._updateRightOffset(e)):ed.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 Zh,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,Io.clamp)(this._width-e,0,this._width),i=(0,Io.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())}formatLabel(e,t){const i="24-hours"===we.timeHoursFormatProperty.value()?t.toString():`${t}_ampm`;let s=this._formattedBySpan.get(i);return void 0===s&&(s=new jh((e=>this.formatLabelImpl(e,t))),this._formattedBySpan.set(i,s)),s.format(new Date(e))}formatLabelImpl(e,t){if(!(e&&e instanceof Date))return"incorrect time";const s=function(e,t){if(e===Sr.MILLISECOND_SPAN&&t)return"TimeWithMilliseconds";if(e<Sr.MINUTE_SPAN&&t)return"TimeWithSeconds";if(e<Sr.DAY_SPAN&&t)return"Time";if(e<Sr.WEEK_SPAN)return"DayOfMonth";if(e<Sr.MONTH_SPAN)return"DayOfMonth";if(e<Sr.YEAR_SPAN)return"Month";return"Year"}(t,!this._model.mainSeries().isDWM());return null!==_e.customFormatters.tickMarkFormatter?_e.customFormatters.tickMarkFormatter(e,s):function(e,t){switch(t){case"TimeWithMilliseconds":return new $h.TimeFormatter($h.hourMinuteSecondMillisecFormat).format(e);case"TimeWithSeconds":case"Time":const s="TimeWithSeconds"===t?(0,Kh.getHourMinuteSecondFormat)(we.timeHoursFormatProperty.value()):(0,Kh.getHourMinuteFormat)(we.timeHoursFormatProperty.value());return new $h.TimeFormatter(s).format(e);case"DayOfMonth":return e.getUTCDate().toString();case"Month":return(void 0===qh&&(qh=[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))]),qh)[e.getUTCMonth()];case"Year":return e.getUTCFullYear().toString()}}(e,s)}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 ed.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?ed.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=Uh.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 Uh(new Rh(r,s),this._model.mainSeries().style()),this._lockBarsAndLogicalRangeEvents||this._fireVisibleBarsChangedIfRequired(e,this._visibleBars)):ed.logWarn(`updateVisibleBars error: baseIndex: ${i}, barSpacing: ${this._barSpacing}, rightOffset: ${this._rightOffset}`)}_fireVisibleBarsChangedIfRequired(e,t){Vh.BarsRange.compare(e.strictRange(),t.strictRange())||this._visibleBarsChanged.fire(t.strictRange(),e.strictRange()),Rh.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,Bt.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(52388),od=i(82826);class nd{constructor(e){this._onChanged=new re.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 Ya(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=Ya.fromState(e,s);null!==t&&i.push(t)}return new nd(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 rd=i(14381);function ad(e){return Boolean(e.session.timezone)&&Boolean(e.session.spec)}class ld{constructor(e,t){var i,s;this._sourceTargetBarBuilder=null,this._cache=new Map,this._source=e,this._target=t,this._sourceSession=rd.SessionInfo.fromState(e.session),this._targetSession=rd.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(!ad(this._source)||!ad(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,rd.newBarBuilder)(this._target.resolution,this._targetSession,this._sourceSession)),this._sourceTargetBarBuilder}}var cd=i(65458),hd=i(28120),dd=i(37626)
;class ud extends dd.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 _d=i(98558);class pd extends _d.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,Is.resetTransparency)(h.preMarketColor.value()):(0,Is.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 md=i(52397);class gd extends md.HorizontalLinePaneView{constructor(e,t,i){super(),this._model=e,this._source=t;const s={doubleClickHandler:i,doubleTapHandler:i};this._lineRenderer.setHitTest(new Vt.HitTestResult(Vt.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())}}Ot.LINESTYLE_DOTTED,Lt.colorsPalette["color-tv-blue-500"];class fd extends hd.CustomSourceBase{constructor(e,t,i){super(e,t),this._extraHoursPrice=null,
this._currentSession="holiday",this._quotesProvider=t.mainSeries().quotesProvider(),this._prePostMarketLinePaneView=new gd(t,this,i),this._prePostPriceAxisView=new pd(t,this),this._prePostLabelPaneView=new cd.PanePriceAxisView(this._prePostPriceAxisView,t.mainSeries(),t),this._prePostPriceLineAxisView=new ud(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,Bt.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 yd=i(39772);function vd(e,t){return e.code<t.code?-1:e.code>t.code?1:0}class Sd{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(vd),i}getItems(){return this._convertibleItems.map((e=>e.id))}}class bd{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 wd=i(50335);class Cd{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,wt.isLineToolName)(lt.tool.value())&&(0,eo.supportsPhantomMode)(lt.tool.value())}onCursorPositionUpdated(){if(!this._currentToolSupportsPhantomMode)return;const e=this._model.crosshairSource();if(this._sourcePane!==e.pane&&this._removeSource(),null===e.pane||!(0,wd.isNumber)(e.index)||!(0,wd.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:lt.tool.value()}),this._sourcePane=e.pane)}_removeSource(){null!==this._source&&(this._model.removeSource(this._source),this._source=null,this._sourcePane=null)}}var Pd,Td=i(92693);!function(e){e[e.MagnetTolerance=50]="MagnetTolerance"}(Pd||(Pd={}));class xd{constructor(){this._lastValue=null}align(e,t,i){this._lastValue=null;let s=e;if(!(0,Un.magnetEnabled)().value())return s;const o=i.mainDataSource();if(null===o)return s;const r=o.model().mainSeries();if(o!==r)return s;const a=r.priceScale();if(a.isEmpty())return s;const l=function(e,t){const i=e.bars().valueAt(t);if(null===i)return;let s;if(null!==e.priceSource())s=[e.barFunction()(i)];else switch(e.style()){case 12:s=[i[2],i[3]];break;case 16:case 21:s=[(0,n.ensure)(i[2]),(0,n.ensure)(i[4]),(0,n.ensure)(i[3])];break;default:s=[i[1],i[2],i[3],i[4]]}return s}(r,t);if(!l)return s;const c=(0,n.ensure)(r.firstValue()),h=l.map((e=>({y:a.priceToCoordinate(e,c),price:e}))),d=a.priceToCoordinate(e,c);h.sort(((e,t)=>Math.abs(e.y-d)-Math.abs(t.y-d)));const u=h[0];return((0,Un.magnetMode)().value()===Td.MagnetMode.StrongMagnet||Math.abs(u.y-d)<50)&&(s=u.price,this._lastValue=s),s}lastValue(){return this._lastValue}resetLastValue(){this._lastValue=null}}class Id{constructor(e){this._appliedTimeFrame=new ht.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 Md=i(53388),Ad=i(30125);class Ld extends Ad.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,Ft.setLineStyle)(t,this._data.vertLineStyle);for(const e of this._data.timeMarks){const i=Math.round(e.coord*s);(0,Ft.drawVerticalLine)(t,i,0,r)}}if(this._data.horzLinesVisible){t.strokeStyle=this._data.horzLinesColor,(0,Ft.setLineStyle)(t,this._data.horzLineStyle);for(const e of this._data.priceMarks){const s=Math.round(e.coord*i);(0,Ft.drawHorizontalLine)(t,s,0,a)}}}}class kd{constructor(e){this._renderer=new Ld,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 Dd extends di.DataSource{constructor(e){super(),this._model=e}id(){return"grid"}paneViews(e){return e.mode()===Bi.PaneMode.Regular?[new kd(e)]:null}name(){return"Grid"}model(){return this._model}}class Ed extends _d.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){e.visible=!1,t.visible=!1;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,
Is.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 Bd extends Ed{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=lt.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()?Lt.colorsPalette["color-cold-gray-600"]:Lt.colorsPalette["color-cold-gray-650"]:t.backgroung=void 0,s||(t.visible=s)}}class Vd extends Ed{_isVisible(){return null!==this._source.measurePane().value()}_bgColor(){return this._properties.childs().axisLineToolLabelBackgroundColorCommon.value()}}var Rd,Nd,Od=i(19475);function Fd(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"}(Rd||(Rd={}));class Wd extends cd.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=Fd(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,Nr.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(Od.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,At.box)(new At.Point(l,a),new At.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(Od.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,ne.trackEvent)(this._gaOrigin,"click");const n=this._mainDataSourceOnPane(),r=null!==n&&(0,Nr.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};W.emit("onPlusClick",a)}_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([])}_createAddHorizontalLineMenuItem(){return[]}_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?lt.crosshairLock.value():void 0;if(void 0!==_){const e=(0,n.ensureNotNull)(this._chartModel.timeScale().points().roughTime(this._crosshair.index));lt.crosshairLock.setValue({type:1,price:this._crosshair.price,time:e,modelId:this._chartModel.id(),paneId:(0,n.ensureNotNull)(this._crosshair.pane).id()})}Oo.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!==_&&lt.crosshairLock.setValue(_)}))}))}_mainDataSourceOnPane(){const e=this._crosshair.pane;return null!==e?e.mainDataSource():null}}class Hd extends Ad.BitmapCoordinatesPaneRenderer{constructor(e){super(),this._data=e}hitTest(e){return void 0===this._data.clickHandler?null:new Vt.HitTestResult(Vt.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,Ft.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,Ft.drawVerticalLine)(s,a,0,h),i&&l>=0&&(0,Ft.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="#1A1A1A",s.fill(zd),s.strokeStyle="#fff",s.lineWidth=1,s.stroke(zd)}(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="#1A1A1A",e.StrokeColor="#fff",e[e.StrokeWidth=1]="StrokeWidth"}(Nd||(Nd={}));const zd=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 Ud=Lt.colorsPalette["color-tv-blue-500"];class Gd{constructor(e,t){this._rendererData={},this._renderer=new Hd(this._rendererData),this._source=e,this._pane=t}update(){}renderer(){const e=this._source.selectPointMode().value()!==lt.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()||Ud,r?(s.lineWidth=2,s.scissors=l):s.lineWidth=1,s.lineStyle=Ot.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=lt.tool.value(),i=(0,vo.lastMouseOrTouchEventInfo)(),o=i.isTouch&&!i.stylus&&((0,wt.isLineToolName)(t)||(0,lt.toolIsMeasure)(t));let n;n=o?Ud:e.childs().color.value();const r=e.childs().transparency.value();!o&&r>0&&(n=(0,Is.generateColor)(n,r)),
s.color=n,s.horzLinesVisible=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 jd=i(62189);const qd={backgroundColor:(0,Is.generateColor)(Lt.colorsPalette["color-tv-blue-500"],70),borderColor:(0,Is.generateColor)(Lt.colorsPalette["color-tv-blue-500"],20)};class $d{constructor(e){this._renderer=new jd.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:qd.backgroundColor,color:qd.borderColor,fillBackground:!0,linewidth:1,points:[this._rectangle.min,this._rectangle.max],extendLeft:!1,extendRight:!1};return this._renderer.setData(e),this._renderer}}var Kd=i(63273),Yd=i(30699),Zd=i(92953),Xd=i(91046),Jd=i(17330),Qd=i(49857);const eu=a.t(null,void 0,i(41643)),tu=a.t(null,{context:"study"},i(24261)),iu=(0,uh.getPercentageFormatter)(),su=new Zd.TimeSpanFormatter,ou=(0,uh.getVolumeFormatter)(),nu=(0,Lt.getHexColorByName)("color-tv-blue-500"),ru=(0,Lt.getHexColorByName)("color-ripe-red-400"),au={bgColorPositive:(0,Is.generateColor)(nu,80),bgColorNegative:(0,Is.generateColor)(ru,80),colorPositive:(0,Lt.getHexColorByName)("color-tv-blue-600"),colorNegative:(0,Lt.getHexColorByName)("color-ripe-red-400"),labelBgColorPositive:nu,labelBgColorNegative:ru};var lu;!function(e){e[e.MinArrowDistance=50]="MinArrowDistance"}(lu||(lu={}));class cu{constructor(e,t){this._horzTrenRenderer=new Xd.TrendLineRenderer,this._vertTrenRenderer=new Xd.TrendLineRenderer,this._bgRenderer=new jd.RectangleRenderer,this._labelRenderer=new Jd.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,Kd.forceLTRStr)(""+a),c=(0,n.ensureNotNull)(s.mainDataSource()),h=(0,n.ensureNotNull)(c.firstValue()),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 At.Point(d,_),this._p2=new At.Point(u,p);const m=this._source.model().timeScale().indexToUserTime(t.index),f=this._source.model().timeScale().indexToUserTime(i.index);let y=null;null!==m&&null!==f&&(y=(f.valueOf()-m.valueOf())/1e3);const v=r-o,S=100*v/Math.abs(o),b=this._pane.model().mainSeries().symbolInfo(),w=b&&(0,uh.getPipFormatter)(b),C=(0,n.ensureNotNull)(c.formatter()),P=(C.formatChange?.(r,o)??C.format(v))+" ("+iu.format(Math.round(100*S)/100)+") "+(w?w.format(v):""),T=null!==y?su.format(y):null,x=null!==T?", "+(0,
Kd.startWithLTR)(T):"";let I=(0,Kd.forceLTRStr)(P)+"\n"+eu.format({count:l})+x;const M=this._source.measureVolume();Number.isNaN(M)||(I+=`\n${tu} ${ou.format(M)}`);const A=r<o?au.bgColorNegative:au.bgColorPositive,L=r<o?au.colorNegative:au.colorPositive,k=r<o?au.labelBgColorNegative:au.labelBgColorPositive,D={points:[this._p1,this._p2],linewidth:0,fillBackground:!0,color:A,backcolor:A,extendLeft:!1,extendRight:!1};this._bgRenderer.setData(D);const E=this._p1.add(this._p2).scaled(.5);{const e=Math.round(E.y),t=new At.Point(this._p1.x,e),i=new At.Point(this._p2.x,e),s={points:[t,i],color:L,linewidth:1,linestyle:Ot.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:Qd.LineEnd.Normal,rightend:Math.abs(t.x-i.x)>=50?Qd.LineEnd.Arrow:Qd.LineEnd.Normal};this._horzTrenRenderer.setData(s)}{const e=Math.round(E.x),t=new At.Point(e,this._p1.y),i=new At.Point(e,this._p2.y),s={points:[t,i],color:L,linewidth:1,linestyle:Ot.LINESTYLE_SOLID,extendleft:!1,extendright:!1,leftend:Qd.LineEnd.Normal,rightend:Math.abs(t.y-i.y)>=50?Qd.LineEnd.Arrow:Qd.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 At.Point(V,R),O={points:[N],text:I,color:"#FFFFFF",horzAlign:Yd.HorizontalAlign.Center,vertAlign:Yd.VerticalAlign.Middle,font:g.CHART_FONT_FAMILY,offsetX:B.x,offsetY:B.y,bold:!1,italic:!1,fontsize:12,lineSpacing:8,highlightBorder:!1,backgroundColor:k,backgroundTransparency:10,boxPaddingVert:9,boxPaddingHorz:9,backgroundRoundRect:4};this._labelRenderer.setData(O);const F=this._labelRenderer.measure(),W=(0,Jd.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 Rt.CompositeRenderer;return e.append(this._bgRenderer),e.append(this._horzTrenRenderer),e.append(this._vertTrenRenderer),e.append(this._labelRenderer),e}}var hu,du=i(99875);!function(e){e[e.Light=0]="Light",e[e.Dark=1]="Dark"}(hu||(hu={}));class uu extends Rc.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?du.replace("backgroundColor",(0,Lt.getHexColorByName)("color-cold-gray-900")).replace("lineColor",(0,Lt.getHexColorByName)("color-cold-gray-450")):du.replace("backgroundColor",(0,Lt.getHexColorByName)("color-white")).replace("lineColor",(0,Lt.getHexColorByName)("color-cold-gray-550"));return(0,No.svgRenderer)(t)}}class _u{constructor(e){this._source=e,this._renderer=new uu(this._getRenderData(0))}update(){}renderer(){
const e=this._source.visible&&this._source.areLinesVisible,t=this._source.lockedX(),i=0===lt.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 pu=i(7576),mu=i(82587);class gu extends pu.DataWindowView{constructor(e){super(),this._invalidated=!0,this._dateItem=new pu.DataWindowItem("",a.t(null,void 0,i(22677)),""),this._timeItem=new pu.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(mu.notAvailable),this._dateItem.setValue(mu.notAvailable),this._model.timeScale().isEmpty())return;let t=this._model.crosshairSource().appliedIndex();if(!(0,wd.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 fu=i(66156);const yu=Lt.colorsPalette["color-tv-blue-500"],vu=a.t(null,{context:"Replay"},i(53310));class Su extends fu.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?`${vu}: ${this._model.dateTimeFormatter().format(t)}`:""}return super._getText(e)}_getBgColor(){if(this._source.isReplaySelection())return yu;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 bu,wu=i(61105),Cu=i(97435),Pu=i(49156);!function(e){e[e.LineWidth=36]="LineWidth",e[e.CircleBorderWidth=1]="CircleBorderWidth",e[e.AnimationDuration=4e3]="AnimationDuration"}(bu||(bu={}));const Tu=(0,Is.applyAlpha)(Pu.colors.colorRipeRed500,.25),xu=(0,Is.applyAlpha)(Pu.colors.colorRipeRed500,.03);class Iu{constructor(e){this._invalidated=!0,this._circleRenderer=new Cu.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,At.point)(e,t),radius:18,lineWidth:1,color:xu,backColor:Tu,disableInteractions:!0}):this._circleRenderer.setData(null)}}class Mu{constructor(e){
this._activeHighlighter=null,this._highlighters=new Map,this._toolsFactory=null,this._throttleUpdateHighlighters=(0,o.default)((()=>{const e=(0,Bt.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 Iu(e),this._currentTool=lt.tool.spawn(),this._currentTool.subscribe((e=>{(0,lt.toolIsDemonstration)(e)&&null===this._toolsFactory&&(this._toolsFactory=new Tc((async()=>{const e=await i.e(360).then(i.bind(i,13506));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,lt.toolIsDemonstration)(lt.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(),Tu,36,4e3);const t=(0,n.ensureNotNull)(this._crosshair.pane),i=(0,n.ensureNotNull)(t.mainDataSource());(0,eo.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,Bt.sourceChangeEvent)(this._crosshair.id()))}isThereUnfinishedHighlighter(){return null!==this._activeHighlighter}finishHighlighter(){this._activeHighlighter?.finish(),this._activeHighlighter=null,this._throttleUpdateHighlighters()}}const Au={menuEnabled:!1,menuForMainSourceOnly:!1,disableTradingMenuActions:!1,disableDrawHorizLineMenuAction:!1};let Lu=0;const ku=(0,ae.getLogger)("Chart.Crosshair");class Du extends di.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 Mu(this),this._measurePane=new F.WatchedValue(null),this._measurePaneViewCache=new WeakMap,this._startMeasurePoint=null,this._endMeasurePoint=null,this._lastValidMeasurePoint=null,this._linesShouldBeHidden=!1,this._isOnHoveredChartWidget=!1,this._crossHairSelectPointMode=new F.WatchedValue(lt.SelectPointMode.None),this._selectionPane=null,this._selectionView=new $d(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 re.Delegate,this._pointSelectedDelegate=new re.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({},Au,i||{}),this._dataWindowView=new gu(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 Su(e,this,(()=>this.appliedIndex()),!1),this._startMeasureTimeAxisView=new Su(e,this,(()=>(0,n.ensureNotNull)(this._startMeasurePoint).index),!0),this._endMeasureTimeAxisView=new Su(e,this,(()=>(0,n.ensureNotNull)(this._lastMeasurePoint()).index),!0),this._cursorTool=lt.cursorTool.spawn(),e.readOnly()||this._cursorTool.subscribe((e=>this.areLinesVisible="arrow"!==e),{callWithLast:!0}),this._crosshairLock=lt.crosshairLock.spawn(),this._showPlusButtonOnCursor=Od.showPlusButtonOnCursor.spawn();const o=()=>{this.updateAllViews((0,Bt.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 At.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=lt.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 wu.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()!==lt.SelectPointMode.None&&this._setSelectPointModeState(lt.SelectPointMode.None),this._selectFromAllChartsIfOutOfData=null}requestSelectPoint(e){(0,n.assert)(this._crossHairSelectPointMode.value()===lt.SelectPointMode.None,"Point already requested");const{pointType:t,pane:i,lineColor:s=null,selectFromAllChartsIfOutOfData:o,selectPointMode:r=lt.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,Yh.PlotRowSearchMode.Exact)&&"price"!==t&&(this._selectFromAllChartsIfOutOfData&&(i=Math.min(...Array.from(lt.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(lt.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,Yh.PlotRowSearchMode.NearestRight);return o&&lt.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()!==lt.SelectPointMode.None&&this._setSelectPointModeState(lt.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,Bd,!0)[0]),this._startMeasurePoint&&s.push(this._createPriceAxisViewOnDemand(this._startMeasurePriceAxisViews,null,e,t,this._startMeasurePriceProvider,Vd)[0]),this._lastMeasurePoint()&&s.push(this._createPriceAxisViewOnDemand(this._endMeasurePriceAxisViews,null,e,t,this._endMeasurePriceProvider,Vd)[0]),s}timeAxisViews(){const e=[],t=null===this._requestedPoint||"price"!==this._requestedPoint||!this._isOnHoveredChartWidget;return this._linesShouldBeHidden||!this.visible&&null===lt.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()!==Bi.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 Gd(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 cu(this,e),this._measurePaneViewCache.set(e,i)),i.update((0,Bt.sourceChangeEvent)(this.id())),t.push(i)}if((Od.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value())&&1!==lt.crosshairLock.value()?.type){const i=e===this.pane,s=!ze.CheckMobile.any()||window.screen.width>=320,o=lt.tool.value(),n=(0,wt.isLineToolName)(o),r=null!==this._model.lineBeingEdited()||null!==this._model.lineBeingCreated()||this._model.sourcesBeingMoved().length>0||null!==this._model.customSourceBeingMoved()||(0,lt.toolIsMeasure)(o)
;if(i&&this._isOnHoveredChartWidget&&this._crossHairSelectPointMode.value()===lt.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,Bd,!0)[1];null!==i&&t.push(i)}}}}return 0===lt.crosshairLock.value()?.type&&(null===this._timeLockPaneView&&(this._timeLockPaneView=new _u(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 Od.addPlusButtonProperty.value()||this._showPlusButtonOnCursor.value()}isHovered(){return this._model.hoveredSource()===this}pointToSelect(){return this._requestedPoint}paneForPointSelect(){return this._paneForRequestedPoint}_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 Wd(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,Bt.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===lt.SelectPointMode.None&&(this._requestedPoint=null,this._selectLineColor=null,this._paneForRequestedPoint&&(this._paneForRequestedPoint=null,this._model.panesCollectionChanged().unsubscribe(this,this._paneCollectionChanged))),lt.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=lt.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}_createMeasurePointset(e,t){const i=this._normalizePoint(e),s=this._normalizePoint(t),o=[[i.time_t,i.offset],[s.time_t,s.offset]];this._removeMeasurePointset(),++Lu,this._currentMeasurePointsetAndSymbolId={measurePointsetId:Lu,symbolId:(0,n.ensureNotNull)(this._model.mainSeries().seriesSource().symbolInstanceId())};const r=(0,yi.getServerInterval)(this._model.mainSeries().interval());this._model.chartApi().createPointset(this._currentMeasurePointsetIdWithPrefix(),"turnaround",this._currentMeasurePointsetAndSymbolId.symbolId,r,o,this._onPointsetResponse.bind(this))}_removeMeasurePointset(){null!==this._currentMeasurePointsetAndSymbolId&&this._model.chartApi().isConnected().value()&&this._model.chartApi().removePointset(this._currentMeasurePointsetIdWithPrefix()),this._currentMeasurePointsetAndSymbolId=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 ku.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,Bt.sourceChangeEvent)(this.id())),this._model.updateSource(this)}}var Eu=i(63812),Bu=i(20596),Vu=i(94164);const Ru=(0,ae.getLogger)("Chart.ApplyPreferencesToAllCharts"),Nu={color:"",style:0},Ou={autoScale:!1,autoScaleDisabled:!1,lockScale:!1,percentage:!1,percentageDisabled:!1,log:!1,logDisabled:!1,alignLabels:!1,isInverted:!1,indexedTo100:!1},Fu={backgroundType:So.ColorType.Solid,background:"",backgroundGradientStartColor:"",backgroundGradientEndColor:"",topMargin:0,bottomMargin:0,gridLinesMode:"both",horzGridProperties:(0,ge.deepExtend)({},Nu),vertGridProperties:(0,ge.deepExtend)({},Nu),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}),axisProperties:(0,ge.deepExtend)({},Ou),separatorColor:""},Wu={lineColor:"",textColor:"",fontSize:0,scaleSeriesOnly:!1,showSeriesLastValue:!1,seriesLastValueMode:Vu.PriceAxisLastValueMode.LastValueAccordingToScale,showSeriesPrevCloseValue:!1,showStudyLastValue:!1,showSymbolLabels:!1,showStudyPlotLabels:!1,showBidAskLabels:!1,showPrePostMarketPriceLabel:!0,showFundamentalLastValue:!1,showFundamentalNameLabel:!1,showPriceScaleCrosshairLabel:!0,showTimeScaleCrosshairLabel:!0},Hu={...Wu},zu={visible:!1,futureOnly:!1,breaks:(0,ge.deepExtend)({},{color:"",visible:!1,style:0,width:0})},Uu={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)({},Ou),highLowAvgPrice:(0,ge.deepExtend)({},{highLowPriceLinesVisible:!1,highLowPriceLabelsVisible:!1,averageClosePriceLabelVisible:!1,averageClosePriceLineVisible:!1,highLowPriceLinesColor:"",highLowPriceLinesWidth:0,averagePriceLineColor:"",averagePriceLineWidth:0}),candleStyle:(0,ge.deepExtend)({},Bu.candleStylePreferencesDefault),hollowCandleStyle:(0,ge.deepExtend)({},Bu.hollowCandlePreferencesStyleDefault),barStyle:(0,ge.deepExtend)({},Bu.barStylePreferencesDefault),lineStyle:(0,ge.deepExtend)({},Bu.lineStyleDefault),lineWithMarkersStyle:(0,ge.deepExtend)({},Bu.lineStyleDefault),steplineStyle:(0,ge.deepExtend)({},Bu.lineStyleDefault),areaStyle:(0,ge.deepExtend)({},Bu.areaStylePreferencesDefault),hlcAreaStyle:(0,
ge.deepExtend)({},Bu.hlcAreaStylePreferencesDefault),baselineStyle:(0,ge.deepExtend)({},Bu.baselineStylePreferencesDefault),hiloStyle:(0,ge.deepExtend)({},Bu.hiloStylePreferencesDefault),haStyle:(0,ge.deepExtend)({},Bu.haStylePreferencesDefault),renkoStyle:(0,ge.deepExtend)({},Bu.renkoStylePreferencesDefault),pbStyle:(0,ge.deepExtend)({},Bu.pbStylePreferencesDefault),kagiStyle:(0,ge.deepExtend)({},Bu.kagiStylePreferencesDefault),pnfStyle:(0,ge.deepExtend)({},Bu.pnfStylePreferencesDefault),rangeStyle:(0,ge.deepExtend)({},Bu.rangeStylePreferencesDefault),columnStyle:(0,ge.deepExtend)({},Bu.columnStylePreferencesDefault),hlcBarsStyle:(0,ge.deepExtend)({},Bu.hlcBarsStylePreferencesDefault)},Gu={priceScaleSelectionStrategyName:"auto",timeScale:(0,ge.deepExtend)({},{defaultRightOffset:0,defaultRightOffsetPercentage:5,usePercentageRightOffset:!1}),mainSeries:(0,ge.deepExtend)({},Uu),sessions:(0,ge.deepExtend)({},xc.sessionsPreferencesDefault),paneProperties:(0,ge.deepExtend)({},Fu),chartEventsSourceProperties:(0,ge.deepExtend)({},zu),tradingProperties:(0,ge.deepExtend)({},Eo.tradingPreferencesDefault)},ju={timezone:"",inactivityGaps:!1,scalesProperties:(0,ge.deepExtend)({},Hu),...Gu},qu={scalesProperties:(0,ge.deepExtend)({},Wu),...Gu};function $u(e,t,i,s,o=!0){if(void 0===t[e])return Ru.logDebug(`We haven't had this property ${s}.${e} yet, please, remove it from whiteList`),null;if((0,dt.isObject)(i[e])){const n=Object.keys(i[e]);let r="";return n.map((n=>({[n]:$u(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 Ku,Yu=i(31229),Zu=i(25149);!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"}(Ku||(Ku={}));const Xu=(0,ae.getLogger)("Chart.Studies.StudyInserter"),Ju=/^PUB;.*/;class Qu{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:yh.StudyStatusType.Error,errorDescription:s}),t&&i.setMetaInfo(t),this._inserterImpl.storeFailedStub(i)}};let r,a,l=!0;try{r=await(0,ts.studyMetaInfoRepository)().findById(this._studyDescriptor)}catch(e){Xu.logWarn(`Cannot get study ${JSON.stringify(this._studyDescriptor)}`)
;const t=this._studyDescriptor.pineId;Ju.test(t);return n("Error: cannot compile script"),Promise.reject(Ku.CannotGetMetainfo)}finally{null!==s&&(l=this._inserterImpl.removeStub(s))}if(!l)return Promise.reject(Ku.StubWasRemoved);if(void 0!==t&&t.cancelled)return Promise.reject(Ku.Cancelled);if(!this._canApplyStudyToParent(r))return n("Error: cannot be child"),Promise.reject(Ku.StudyCannotBeChild);const c={...r.defaults.inputs};let d={};if(void 0!==e){const t=is.StudyMetaInfo.getStudyPropertyRootName(r),i=(0,dt.clone)((0,h.defaults)(t));(0,dt.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(Ku.Cancelled);const u=this._insertStudy(r,d,i);if(null===u)return n("Error: unknown error"),Promise.reject(Ku.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||is.StudyMetaInfo.canBeChild(e)}}class e_{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(84425);class i_{constructor(){this._widgets=null,this._provider=null,this._watermarkProperties=Ec();const e=(0,n.ensureDefined)(this._watermarkProperties.child("color")),t=(0,n.ensureDefined)(this._watermarkProperties.child("visibility"));this._colorWatchedValue=(0,ye.convertPropertyToWatchedValue)(e),this._visibilityWatchedValue=(0,ye.convertPropertyToWatchedValue)(t)}setWidgetCollection(e){this._widgets=e}setContentProvider(e){this._provider=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()}visibility(){return this._visibilityWatchedValue}color(){return this._colorWatchedValue}static getInstance(){return null===this._instance&&(this._instance=new i_),this._instance}}i_._instance=null;var s_=i(71838);class o_ extends hd.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,ts.studyMetaInfoRepository)().findById({type:"java",studyId:"IntradayInactivityGaps@tv-basicstudies"});this._destroyed||(this._setMetaInfo(e),null!==this._metaInfo&&(this._studySource=new s_.StudyDataSource(this._model.chartApi(),this._model.mainSeries().seriesSource(),"intradayinactivitygaps_",this._metaInfo),this._studySource.dataCleared().subscribe(this,this.updateAllViews.bind(this,(0,Bt.sourceChangeEvent)(this.id()))),this._studySource.dataUpdated().subscribe(this,this.updateAllViews.bind(this,(0,Bt.sourceChangeEvent)(this.id()))),this._studySource.setInputs({display_session:this._session})))}_setMetaInfo(e){this._metaInfo=e}_clearData(){this._studySource?.clearData()}}const n_=new Di.TranslatedString("remove deselected empty line tools",a.t(null,void 0,i(27171))),r_=l.enabled("auto_enable_symbol_labels"),a_=l.enabled("saveload_separate_drawings_storage"),l_=(0,ae.getLogger)("Chart.ChartModel");function c_(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}function h_(e){for(let t=e.length;t--;){const i=e[t].dataSources();for(let e=i.length;e--;)i[e].dataWindowView()?.update((0,Bt.sourceChangeEvent)(i[e].id()));const s=e[t].priceDataSources();for(let e=s.length;e--;)s[e].legendView()?.update((0,Bt.sourceChangeEvent)(i[e].id()))}}const d_={isSnapshot:!1,readOnly:!1,watermarkEnabled:!0,shiftVisibleRangeOnNewBar:!0,currencyConversionEnabled:!1,unitConversionEnabled:!1,countdownEnabled:!0,lastPriceAnimationEnabled:!0,onWidget:!1,hideIdeas:!1};var u_;!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"}(u_||(u_={}));const __={throttle:o.default,debounce:cc.default},p_=new Map([[Eo.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction,{timeout:500,adapter:"debounce"}],[Eo.RecalcVisibleRangeStudiesReason.DataUpdate,{timeout:500,adapter:"throttle"}],[Eo.RecalcVisibleRangeStudiesReason.SeriesRestart,{timeout:500,adapter:"debounce"}],[Eo.RecalcVisibleRangeStudiesReason.SeriesCompleted,{timeout:500,adapter:"debounce"}],[Eo.RecalcVisibleRangeStudiesReason.StudyCreation,{timeout:500,adapter:"debounce"}]]),m_=Array.from(p_.values());class g_{constructor(e,t,i,s,o,n,r,a,c,d,u){
this._onRearrangePanes=new re.Delegate,this._lineToolsGroupModel=new nd,this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,this._lineBeingEdited=null,this._linePointBeingEdited=null,this._linePointBeingChanged=null,this._customSourceBeingMovedHitTestData=null,this._customSourceBeingMoved=null,this._dataSourceCollectionChanged=new re.Delegate,this._sourceProperitesChanged=new re.Delegate,this._sourceZOrderChanged=new re.Delegate,this._symbolSourceResolved=new re.Delegate,this._symbolSourceResolvingActive=new F.WatchedValue(!1),this._adjustForDividendsAvailability=new F.WatchedValue(0),this._adjustForDividendsEnabled=new F.WatchedValue(!1),this._intradayInactivityGapsWatchedValue=null,this._currentTool=lt.tool.spawn(),this._lineBeingCreated=null,this._paneBeingCreatedLineOn=null,this._lineCancelled=new re.Delegate,this._phantomSourceContainer=new Cd(this),this._destroyed=!1,this._restoringState=!1,this._isSettingsExternalPosition=!1,this._isTimeScrolling=!1,this._magnet=new xd,this._scrollingState=null,this._modelIntervals=[],this._rendererOptionsProvider=new Pc(this),this._studyInserted=new re.Delegate,this._cachedStudiesMaxOffset=0,this._replayStatus=new F.WatchedValue(0),this._panes=[],this._maximizedPane=new F.WatchedValue(null),this._tagsChanged=new re.Delegate,this._strategySources=[],this._strategySourcesChange=new re.Delegate,this._activeStrategySource=new F.WatchedValue(null),this._symbolIntervalChanged=new re.Delegate,this._paneCollapsingAvailable=new F.WatchedValue(!1),this._panesCollectionChanged=new re.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 re.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 F.WatchedValue(!1),this._multiPaneSources=[],this._showLegendProperty=new Rs.Property,this._id=(0,fe.guid)(),this._chartSaveTime=null,this._availableCurrenciesList=null,this._availableCurrencies=new Sd([]),this._availablePriceSources=new e_([]),this._availableUnitsObject=null,this._availableUnits=new bd({}),this._availablePriceSourcesBySymbol=new Map,this._shouldBeSavedEvenIfHidden=!1,this._watchedThemeSpawn=D.watchedTheme.spawn(),this._backgroundColorAtYPercentFromTop=new yd.GradientColorCache,this._studiesWV=new ht.WatchedObject([],ft.compareTwoCollectionsByIds),this._studiesExcludeInternalWV=new ht.WatchedObject([],ft.compareTwoCollectionsByIds),this._resetScalesAvailable=new F.WatchedValue(!1),this._recalcVRStudiesParams={reasons:new Set},this._recalcColorStudiesParams={},this._replayStudyStrategy=new F.WatchedValue(null),this._studyColorRotatorFactory=new fc(this),this._mainSeriesScaleRatioProperty=new Gc(this),
this._recalcVisibleRangeStudiesImplDebouncedByAdapter=new Map(Object.keys(__).map((e=>[e,new Map(m_.filter((t=>t.adapter===e)).map((e=>[e.timeout,__[e.adapter](this._recalcVisibleRangeStudiesImpl.bind(this,this._recalcVRStudiesParams),e.timeout)])))]))),this._recalcColorStudiesImplDebounced=(0,cc.default)(this._recalcColorStudiesImpl.bind(this,this._recalcColorStudiesParams),250),this._width=0,this._resetScales=new re.Delegate,this._chartThemeLoaded=new re.Delegate,this._selection=new vc,this._selectedSourceChanged=new re.Delegate,this._symbolSourceCollectionChanged=new re.Delegate,this._gridSource=new Dd(this),this._visibleRangeStudiesInputs=new ht.WatchedObject(null),this._syncPointCache=new Map,this._lastAppliedGotoTimeRange=null,this._lastGotoTimeRange=null,this._lollipopSourcesWatcherLoader=null,this._sessions=null,this._onMultipaneSourcesCollectionChanged=new re.Delegate,this._replayStudyStrategyInputs=null,this._studyShiftColorStartOffset=void 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(Nr.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._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,eo.isLineTool)(e)&&e.properties().visible.value();t&&i?(0,W.emit)("drawing_event",e.id(),"show"):!t&&i&&(0,W.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,dt.merge)((0,dt.clone)(d_),a),this._hibernateWV=c,this._linkingGroupIndex=d,this._isAutoSaveEnabled=u,this._readOnly=this._options.readOnly,this._isSnapshot=this._options.isSnapshot,this._chartSaveTime=(new Date).valueOf(),this._backgroundColor=new F.WatchedValue(this._getBackgroundColor()),this._backgroundTopColor=new F.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 F.WatchedValue(this._getBackgroundCounterColor()),this._backgroundColor.subscribe((()=>this._backgroundCounterColor.setValue(this._getBackgroundCounterColor()))),this._backgroundTheme=(0,Ji.combine)((e=>"white"===e?oo.StdTheme.Dark:oo.StdTheme.Light),this._backgroundCounterColor.weakReference()),this._isDark=(0,Ji.combine)((e=>e===oo.StdTheme.Dark),this._backgroundTheme.weakReference()),this._watchedThemeSpawn.subscribe(this._updateBackgroundColor.bind(this)),this._symbolSourceResolvingActive.subscribe(this._recalcAdjustForDividendsAvailability),(0,lt.init)();const _=this._readOnly?new Rs.Property((0,dt.merge)((0,dt.clone)(xs.lightTheme.content.chartProperties.paneProperties.crossHairProperties),(0,h.defaults)("chartproperties.paneProperties.crossHairProperties"))):this._properties.childs().paneProperties.childs().crossHairProperties;this._crossHairSource=new Du(this,_,this._options.crossHair),this._crossHairSelectPointMode=this._crossHairSource.selectPointMode().spawn(),this._crossHairSelectPointMode.subscribe((e=>{if(e!==lt.SelectPointMode.None&&this.lineBeingCreated()){const e=lt.tool.value();this.cancelCreatingLine(),lt.tool.setValue(e)}})),this._tagsChanged=new re.Delegate,this._timeScale=new id(this,this._options.timeScale),
this._timeScale.resetAvailable().subscribe(this._updateResetScalesAvailableValue);const p={countdownEnabled:this._options.countdownEnabled,lastPriceAnimationEnabled:this._options.lastPriceAnimationEnabled};this._mainSeries=new jn.Series(this,s,p,o),this._appliedTimeFrame=new Id(this),this._mainSeries.onStyleChanged().subscribe(this._timeScale,this._timeScale.invalidateVisibleBars);const m=()=>this.fullUpdate();this._mainSeries.properties().childs().showCountdown.subscribe(this,(()=>{this._mainSeries.updateAllViews((0,Bt.sourceChangeEvent)(this._mainSeries.id())),m()})),(0,Be.currencyUnitVisibilityProperty)().subscribe(this,m),(0,on.autoLogButtonsVisibilityProperty)().subscribe(this,m),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&&(0,kr.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,i)){const e=this.appliedTimeFrame().value();null!==e&&!this._lastAppliedGotoTimeRange.actual&&(0,kr.areEqualTimeFrames)(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=null)}));const g=this._panes[0];g.setStretchFactor(2*g.stretchFactor()),this._properties.subscribe(this,this.lightUpdate),this._properties.childs().timezone.subscribe(null,(()=>{this._chartSession&&this._chartSession.isConnected().value()&&this._chartSession.switchTimezone(this.timezone())})),g.addDataSource(this._mainSeries,g.findSuitableScale(this._mainSeries),!1),this._barsMarksSources=r(this);for(const e of this._barsMarksSources)e.setOwnerSource(this._mainSeries),g.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 Wc(this):null,this._timezoneExceptExchange=(0,Ji.combine)(((e,t)=>"exchange"!==e?e:t),(0,t_.createWVFromProperty)(this._properties.childs().timezone).ownership(),(0,
t_.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,lt.hideAllDrawings)().subscribe(this,this._onDrawingsVisibilityChanged),(0,lt.hideAllIndicators)().subscribe(this,this._onIndicatorsVisibilityChanged),be.dateFormatProperty.subscribe(this,this._updateDateTimeFormatter),we.timeHoursFormatProperty.subscribe(this,this._updateDateTimeFormatter),this._currentTool.subscribe((e=>{(0,wt.isLineToolName)(e)&&this.selectionMacro((e=>{e.clearSelection()})),!(0,Ro.isLineToolLoaded)(e)&&(0,Ro.isAsyncGenericLineToolName)(e)?(0,Ro.loadLineTool)(e).then((()=>this._phantomSourceContainer.onToolChanged())):this._phantomSourceContainer.onToolChanged()})),this._initialiseInactivityGaps()}destroy(){this.clearIntervals(),this.resetDeferredStudies(),this.allStudies().forEach((e=>this.removeSource(e))),be.dateFormatProperty.unsubscribe(this,this._updateDateTimeFormatter),we.timeHoursFormatProperty.unsubscribe(this,this._updateDateTimeFormatter),(0,lt.hideAllIndicators)().unsubscribe(this,this._onIndicatorsVisibilityChanged),(0,lt.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._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,on.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._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,Js.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}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 li.DefaultProperty({defaultName:"replayStudyStrategyInputs",factoryDefaultsSupplier:()=>(0,dt.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===qn){const e=await i.e(9498).then(i.bind(i,99992));qn=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 th.PriceRange(n,r)),this.recalculateAllPanes((0,Bt.viewportChangeEvent)()),this.invalidate(this._paneInvalidationMask(o,yo.InvalidationLevel.Light))}setTimeViewport(e,t){const i=this.appliedTimeFrame().value();null!==this._lastAppliedGotoTimeRange&&null!==i&&(0,kr.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,i.val)&&!this._lastAppliedGotoTimeRange.actual||(this.timeScale().zoomToBarsRange(e,t),this.recalculateAllPanes((0,Bt.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Eo.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}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,Bt.viewportChangeEvent)()),this.lightUpdate(),this.recalcVisibleRangeStudies(Eo.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction)}lineBeingEdited(){return this._lineBeingEdited}linePointBeingEdited(){return this._linePointBeingEdited}activeItemBeingMoved(){return this._activeItemBeingMoved}linePointBeingChanged(){return this._linePointBeingChanged}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,ft.subtract)(i,this.selection().allSources()),o=(0,ft.subtract)(this.selection().allSources(),i);o.concat(i).forEach((e=>e.updateAllViews((0,Bt.selectionChangeEvent)())));let n=[];if(s.forEach((e=>{if((0,eo.isLineTool)(e)){const i=e.hasAlert().value()&&e.getAlertSync();i&&!i.isPrice()&&i.setSelected(!1),!t&&e.shouldBeRemovedOnDeselect()&&n.push(e)}})),o.forEach((e=>{const t=(0,eo.isLineTool)(e)&&e.hasAlert&&e.hasAlert().value()&&e.getAlertSync();t&&t.setSelected(!0)})),1===o.length){const[e]=o;(0,eo.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,n_),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=nd.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,lt.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();t.isEmpty()||this._updateBaseIndex((0,n.ensureNotNull)(t.lastIndex()),!!(e&&e.index>0))}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 Qu(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,dt.merge)((0,hc.default)(s??{}),{inputs:t,parentSources:[]});let g=!1,f=null,y=null;const v=r??[],S=(0,Cc.prepareStudyProperties)(e,m,p,(0,
ts.studyMetaInfoRepository)().studyVersioning(),v),b=(0,Js.createStudy)(this,S,v,e,_),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,Nr.isSymbolSource)(e)){const i=l?Or(e,t,this,!0):null,s=c?oh(e,t,this,!0):null;null===i&&null===s||e.setSymbolParams({currency:i||void 0,unit:s||void 0})}if((0,Nr.isSymbolSource)(e)&&(0,n.ensureNotNull)(p).hasDataSource(this.mainSeries())&&r_&&!d.getBool("enable_symbol_labels_on_inserting_compare_once",!1)&&((0,li.allowSavingDefaults)(!0),this.properties().childs().scalesProperties.childs().showSymbolLabels.setValue(!0),(0,li.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,Bt.sourceChangeEvent)(e.id())),this.fullUpdate(),this._invalidateBarColorerCaches(),this._recalcVisibleRangeStudiesImpl({studies:[e],reasons:new Set([Eo.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,Bt.sourceChangeEvent)(t.id())),this.fullUpdate(),!0}insertStudyStub(e,t,i,s){const o=void 0!==t,r=new wc.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,Bt.sourceChangeEvent)(r.id())),this.fullUpdate(),r}removeStudyStub(e){const t=this.dataSourceForId(e);return null===t?(l_.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(eo.isLineTool)}setHoveredSource(e,t=null,i){const s=this._hoveredSource!==e;this._hoveredSourceOrigin=i??null,!s&&(0,
Vt.hitTestResultDataAreEqual)(this._lastHoveredHittestData,t)||(this._lastHoveredHittestData=t,this._hoveredSource&&(this._hoveredSource.updateAllViews((0,Bt.hoverChangeEvent)()),this.updateSource(this._hoveredSource)),this._hoveredSource=e,this._hoveredSource&&(this._hoveredSource.updateAllViews((0,Bt.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(yo.InvalidationMask.light())}fullUpdate(){this.invalidate(yo.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)}gotoTimeRange(e,t){const i=this.timeScale(),s=i.tickMarks(),o=this.mainSeries();if(void 0===s.minIndex)return void(this._lastGotoTimeRange={from:e,to:t});let r=e,a=t;if(null!==o.symbolInfo()){const i=(0,n.ensureNotNull)(this.timezoneExceptExchange().value()),s=(0,Ce.get_timezone)(i),l=(0,Ce.utc_to_cal)(s,e),c=(0,Ce.utc_to_cal)(s,t);if(o.isDWM()){const e=(0,Ce.get_timezone)("Etc/UTC");(0,Ce.set_hms)(l,0,0,0,0,e),(0,Ce.set_hms)(c,0,0,0,0,e)}r=l.getTime(),a=c.getTime()}const l=(0,n.ensureDefined)(s.maxIndex),c=(0,n.ensureDefined)(s.minIndex);if(r>=(0,n.ensureNotNull)(s.indexToTime(c)).valueOf()||o.endOfData()){const e=(e,t)=>e<t,t=e=>(0,n.ensureNotNull)(s.indexToTime(e)).valueOf(),h=(0,ft.lowerboundExt)(t,r,e,s.nearestIndex(r),l);let d=r===a?h:(0,ft.lowerboundExt)(t,a,e,s.nearestIndex(a),l);this._lastGotoTimeRange=null,null!==this._lastAppliedGotoTimeRange&&(this._lastAppliedGotoTimeRange.actual=!1);const u=i.baseIndex();if(h+Math.max(d-h+1,i.minVisibleBarCount())>u){const e=i.targetDefaultRightOffset();d-u<e&&(d=u+e)}
const _=h===d&&h===c&&o.endOfData()?h-1:h;i.zoomToBarsRange(_,d),this.updateAllPaneViews((0,Bt.viewportChangeEvent)()),this.lightUpdate()}else{const i={type:"time-range",from:e/1e3,to:t/1e3};null===this._lastAppliedGotoTimeRange?(this._lastAppliedGotoTimeRange={range:i,actual:!0},o.loadDataTo(i)):(0,kr.areEqualTimeFrames)(this._lastAppliedGotoTimeRange.range,i)||(this._lastGotoTimeRange={from:e,to:t})}}paneForSource(e){if(!(0,Vo.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 mi?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&&(this._lineBeingEdited=null,lt.isToolEditingNow.setValue(!1)),e===this.lineBeingCreated()&&(this._lineBeingCreated=null,lt.isToolCreatingNow.setValue(!1)),!t&&e.stop&&e.stop();const i=this.detachSource(e),s=this.mainSeries().priceScale();return(0,Js.isStudy)(e)&&(0,Nr.isActingAsSymbolSource)(e)&&e.priceScale()===s&&s.isPercentage()&&1===s.seriesLikeSources().filter(Nr.isActingAsSymbolSource).length&&s.setMode({percentage:!1}),this.fullUpdate(),this._invalidateBarColorerCaches(),(0,Js.isStudy)(e)&&((0,W.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,eo.isLineTool)(e)&&(e.removeAlert(),(0,W.emit)("drawing_event",e.id(),"remove")),i}mainSeriesScaleRatio(){return(0,uc.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,Js.isStudy)(e)&&!0:Js.isStudy;return this._getAllSources(t)}studiesWV(e){return e?this._studiesExcludeInternalWV.readonly():this._studiesWV.readonly()}listUserStudies(e){const t=[];for(const i of this._panes)for(const s of i.priceDataSources())if(!(0,Js.isFundamentalStudy)(s)&&(0,Js.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,
Js.isStudy)(i)&&i.metaInfo().groupingKey===e&&!t.isOverlay(i)));if(void 0!==i)return{pane:t,study:i}}return null}movePaneUp(e){this.movePane(e,e-1)}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.invalidate(yo.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 Sd(e)),this._availableCurrencies}currencyConversionEnabled(){return this._options.currencyConversionEnabled}availableUnits(){const e=this._getAvailableUnits();return this._availableUnits.unitsChanged(e)&&(this._availableUnits=new bd(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 e_(t)),this._availablePriceSources}resetDeferredStudies(){bh.instance(this).reset()}waitForStudy(e){const t=this.dataSourceForId(e);return t&&(0,Js.isStudy)(t)?Promise.resolve(t):bh.instance(this).get(e)}resetWaitForStudy(e){bh.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(!0,!1,!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,Js.isStudy)(t)?t:null}getLineToolById(e){const t=this.dataSourceForId(e);return null!==t&&(0,eo.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,Ch.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities),e.properties().merge(t.state),e.restoreData&&e.restoreData(t),e.linkKey().setValue(t.linkKey||null),
e.createServerPoints(),e.setZorder(t.zorder??e.zorder()),this.fullUpdate();const s=e.linkKey().value();null!==s&&i&&(0,lt.restoreLineToolState)({model:this,linkKey:s,state:t})}restoreFactoryDefaults(e){e.restoreFactoryDefaults(),this.recalcVisibleRangeStudies(Eo.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction)}preferences(){return function(e,t,i=ju){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]=$u(e,l,n,"mainSeries")})),u.forEach((e=>{s.sessions[e]=$u(e,c,d,"sessions")})),r.forEach((e=>{o.includes(e)||(s[e]=$u(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,Bt.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,Js.isStudy)(e)&&(a=!0);const l=(0,n.ensureNotNull)(this.paneForSource(e)),c=(0,eo.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,yo.InvalidationLevel.Light);this.invalidate(d)})),!r){const s=e.filter(eo.isLineTool).filter((e=>e.linkKey().value()&&e.isSynchronizable())).map((e=>e.linkKey().value()));if(s.length&&t.logical){const r=this.externalTimeStamp(t.logical.index),a={linkKeys:s,model:this,symbol:this.mainSeries().symbol(),point:{price:t.logical.price,timeStamp:r},activeItem:null!==i?i:void 0,envState:o,pointPositionPercents:new Map};e.forEach((e=>{if((0,eo.isLineTool)(e)){const i=e.linkKey().value()
;if(i&&e.isSynchronizable()&&e.isFixed()){const s=(0,n.ensureNotNull)(this.paneForSource(e));a.pointPositionPercents.set(i,this._pointToPercentPosition((0,n.ensureDefined)(t.screen),s))}}})),(0,lt.startMovingLineTool)(a)}}lt.isToolMovingNow.setValue(!0),a&&lt.isStudyEditingNow.setValue(!0)}moveSources(e,t,i,s){if(this._sourcesBeingMoved.filter((e=>!e.isLocked||!e.isLocked())).forEach((o=>{const r=(0,eo.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){const t=this._sourcesBeingMoved.filter(eo.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey().value())).map((e=>e.linkKey().value())),s=this.externalTimeStamp(e.logical.index),o={linkKeys:t,model:this,point:{price:e.logical.price,timeStamp:s},envState:i,pointPositionPercents:new Map};this._sourcesBeingMoved.filter(eo.isLineTool).forEach((t=>{if(t.linkKey().value()&&t.isSynchronizable()&&t.isFixed()){const i=(0,n.ensureNotNull)(this.paneForSource(t));o.pointPositionPercents.set(t.linkKey().value(),this._pointToPercentPosition((0,n.ensureDefined)(e.screen),i))}})),(0,lt.moveLineTool)(o)}}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,yo.InvalidationLevel.Light);return a.invalidateAll(yo.InvalidationLevel.Light),this.invalidate(a),r})),o=this._sourcesBeingMoved.filter(eo.isLineTool).filter((e=>e.isSynchronizable()&&!!e.linkKey().value())).map((e=>e.linkKey().value())),r=this._sourcesBeingMoved.filter(eo.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}));o.length&&(0,lt.finishMovingLineTool)({linkKeys:o,model:this,finalStates:r,changes:s}),this._sourcesBeingMoved=[],this._activeItemBeingMoved=null,lt.isToolMovingNow.setValue(!1),lt.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,
Bt.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Eo.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction))}setPaneHeight(e,t){e.setHeight(t),this.recalculateAllPanes((0,Bt.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 Eh(this._timeScale,o,this,i,s??Bi.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.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.invalidate(yo.InvalidationMask.panesOrder()),n}removePane(e){e===this._maximizedPane.value()&&this._maximizedPane.setValue(null);const t=e;t.destroy();const i=this._panes.indexOf(t);-1!==i&&(this._panes.splice(i,1),e.dataSourcesCollectionChanged().unsubscribeAll(this),e.symbolSourceCollectionChanged().unsubscribeAll(this),e.priceSourcesCollectionChanged().unsubscribeAll(this),e.sourcePropertiesChanged().unsubscribeAll(this),e.onTagsChanged().unsubscribeAll(this),e.symbolSourceResolved().unsubscribeAll(this),t.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.invalidate(yo.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,Bt.sourceChangeEvent)(e.id())),h_(this._panes),this.invalidate(yo.InvalidationMask.cursor()),this._undoModel.syncCrosshair(null),this._phantomSourceContainer.onCursorPositionUpdated()}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.lineBeingCreated())?.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()!==lt.SelectPointMode.None,h=lt.tool.value(),d=this.mainSeries(),u=this.crosshairSource(),_=u.index,p=u.price,m=c||lt.isStudyEditingNow.value();let g=!1;if(a===this._mainSeries.priceScale())if((0,wt.isLineDrawnWithPressedButton)(h))g=null===this._lineBeingCreated||(0,eo.isBrushBasedLineTool)(this._lineBeingCreated.lineDataSource)&&this._lineBeingCreated.lineDataSource.hasOnlyOnePoint();else{g=Boolean(this._lineBeingCreated||this._lineBeingEdited||(0,wt.isLineToolName)(h)||(0,lt.toolIsMeasure)(h))||m}!this._isSettingsExternalPosition&&g?(o=this._magnet.align(o,r,i),null!==l&&this._setCorrectedPositionToCrosshair(r,o,i)):this._magnet.resetLastValue();let f=null;if(isNaN(o)||(f=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,f);return}u.setOnHoveredChartWidget(!0),u.setPosition(r,o,f),(0,n.ensureNotNull)(u.dataWindowView()).update((0,Bt.sourceChangeEvent)(u.id())),h_(this._panes);const y=d.syncModel();this.crosshairSource().startMeasurePoint()||this._lineBeingCreated?this.lightUpdate():this.invalidate(yo.InvalidationMask.cursor());const v=this.lineBeingCreated();if(v){const e=v.linkKey().value();if(!this._isSettingsExternalPosition){const t=v.setLastPoint({index:r,price:o},s);if(v.updateAllViews((0,Bt.sourceChangeEvent)(v.id())),t.price===o&&t.index===r||this._setCorrectedPositionToCrosshair(t.index,t.price,i),y&&e){const i=this._timeScale.points().roughTime(t.index,y.projectTime.bind(y));(0,lt.setLineToolLastPoint)({model:this,linkKey:e,point:{timeStamp:(0,n.ensureNotNull)(i),price:t.price}})}}}if(!this._isSettingsExternalPosition&&null!==this._lineBeingEdited&&null!==this._linePointBeingEdited){const e={index:r,price:o};if(this._linePointBeingChanged?.nonDiscreteIndex){const t=this.crosshairSource().originX();Number.isFinite(t)&&(e.index=this._timeScale.coordinateToFloatIndex(t))}this.changeLinePoint(e,s)
;const t=this._lineBeingEdited.alignCrossHairToAnchor(this._linePointBeingEdited)?this._lineBeingEdited.getPoint(this._linePointBeingEdited):e;null!==t&&this._setCorrectedPositionToCrosshair(t.index,t.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,dt.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,Bt.sourceChangeEvent)(s.id())),h_(this._panes),this.invalidate(yo.InvalidationMask.cursor())}startScaleTime(e){this._timeScale.startScale(e)}scaleTimeTo(e){this._timeScale.scaleTo(e),this.recalculateAllPanes((0,Bt.viewportChangeEvent)()),this.lightUpdate()}endScaleTime(){this._timeScale.endScale(),this.lightUpdate(),this.recalcVisibleRangeStudies(Eo.RecalcVisibleRangeStudiesReason.ViewportChangeUserAction)}resetTimeScale(){this._timeScale.restoreDefault(),this.recalculateAllPanes((0,Bt.viewportChangeEvent)()),this.recalcVisibleRangeStudies(Eo.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,yo.InvalidationLevel.Light))}endScalePrice(e,t){e.endScalePrice(t),this.invalidate(this._paneInvalidationMask(e,yo.InvalidationLevel.Light))}startTwoPointsScalePrice(e,t,i,s){t.startTwoPointsScale(i,s)}twoPointsScalePriceTo(e,t,i,s){t.twoPointsScale(i,s),t.updateAllViews((0,Bt.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,yo.InvalidationLevel.Light))}
restorePriceScaleState(e,t,i){e.restorePriceScaleState(t,i),this.invalidate(this._paneInvalidationMask(e,yo.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,pt.isStudyState)(s),a=r?n.restoreStudy(s):(0,pt.isLineToolState)(s)?n.restoreLineTool(s):s.id===tpoSummaryDataSourceId&&18===this.mainSeries().style()?n.restoreTpoSummaryDataSource(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,Bt.sourceChangeEvent)(a.id())),this.mainSeries().invalidateBarColorerCache(),this.fullUpdate()),a}children(e,t){return this.dataSources().filter((i=>(0,Js.isStudy)(i)?!t&&i.parentSources().includes(e):i.ownerSource()===e))}onRearrangePanes(){return this._onRearrangePanes}studyInserted(){return this._studyInserted}finishLineTool(e){const t=e.linkKey().value();(0,lt.drawOnAllCharts)().value()&&null!==t&&e.isSynchronizable()&&(0,lt.finishLineTool)({linkKey:t,model:this})}startChangingLinetool(e,t,i,s,o){this._lineBeingEdited=e,this._linePointBeingChanged=t||null,this._linePointBeingEdited=void 0===i?null:i,this._lineBeingEdited.startChanging(i,t,o),lt.isToolEditingNow.setValue(!0);const r=(0,n.ensureNotNull)(this.paneForSource(e));this._lineBeingEdited.startDragPoint&&void 0!==i&&void 0!==t&&this._lineBeingEdited.startDragPoint(i,t),o||void 0===i||void 0===t||this._lineBeingEdited.setPoint(i,t,s,o),this._lineBeingEdited.updateAllViews((0,Bt.sourceChangeEvent)(this._lineBeingEdited.id()));const a=this._paneInvalidationMask(r,yo.InvalidationLevel.Light);this.invalidate(a);const l=e.linkKey().value();if(l&&e.isSynchronizable()&&void 0!==i&&void 0!==t){const o=(0,n.ensureNotNull)(this.externalTimeStamp(t.index));(0,lt.startChangingLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:t.price,timeStamp:o},positionPercents:e.positionPercents(),pointIndex:i,envState:s||null})}}createLineTool(e){const{pane:t,point:i,linetool:s,linkKey:o=null,sharingMode:r=0,id:a,fromExternalModel:l}=e;let{properties:c,ownerSource:h}=e;if((0,n.assert)((0,wt.isLineToolName)(s),`Cannot create unknown line tool: ${s}`),c){const e={...Yu.intervalsVisibilitiesDefaults},t=c.childs().intervalsVisibilities.state();(0,
dt.merge)(e,t??{});const i=c.state();i.intervalsVisibilities=e,c=(0,eo.createLineToolProperties)(this.backgroundTheme().spawnOwnership(),s,!this.readOnly(),i)}const d=(0,eo.createLineTool)(s,this,c,null,void 0,a);if("LineToolExecution"!==s){let e;switch(s){case"LineToolIcon":e=d.properties().childs().icon.value().toString(16).toUpperCase();break;case"LineToolEmoji":e=d.properties().childs().emoji.value();break;case"LineToolSticker":e=d.properties().childs().sticker.value()}(0,ne.trackEvent)("drawings","Study_Drawing_"+s,e)}(0,eo.isStudyLineTool)(d)&&(0,ne.trackEvent)("studies",`Study_${d.metaInfo().id}`);const u=!d.linkKey().value()&&!o;h=(0,n.ensureDefined)(h||(0,n.ensureNotNull)(t.mainDataSource())),c||(0,eo.prepareLineToolPropertiesByOwnerSource)(d.properties(),h),d.setOwnerSource(h);const _=h.priceScale();if(d.setPriceScale(_),a_&&h===this.mainSeries()&&d.share(r),t.addDataSource(d,_,!1),null!==d.preferredZOrder()&&t.insertAfter([d],this.mainSeries()),(0,lt.drawOnAllCharts)().value()){const e=d.isSynchronizable()?o||(0,fe.randomHash)():null;d.linkKey().setValue(e)}else d.linkKey().setValue(o);let p;if(u&&d.enableCurrentIntervalVisibility(),d.isFixed()){const e=(0,n.ensureNotNull)((0,n.ensureNotNull)(t.mainDataSource()).firstValue()),s=this._timeScale.indexToCoordinate(i.index),o=(0,n.ensureNotNull)(_).priceToCoordinate(i.price,e);p=d.addFixedPoint(new At.Point(s,o))}else p=d.addPoint(i);return p||(this._lineBeingCreated={lineDataSource:d,fromExternal:!!l},this._paneBeingCreatedLineOn=t,lt.isToolCreatingNow.setValue(!0)),this.fullUpdate(),d}endChangingLinetool(e,t){const i=(0,n.ensureNotNull)(this._lineBeingEdited),s=i.endChanging(!1,e,t);this._lineBeingEdited=null,lt.isToolEditingNow.setValue(!1),this._linePointBeingEdited=null,this._linePointBeingChanged=null,this.lightUpdate();const o={points:i.normalizedPoints(),interval:this.mainSeries().interval()},r=i.linkKey().value();null!==r&&i.isSynchronizable()&&!t&&(0,lt.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,Bt.sourceChangeEvent)(r.id()));const l=new yo.InvalidationMask(yo.InvalidationLevel.Light);return a&&(this._paneBeingCreatedLineOn=null,this._lineBeingCreated=null,lt.isToolCreatingNow.setValue(!1)),this.invalidate(l),a}cancelCreatingLine(){const e=this.lineBeingCreated();e&&(this.removeSource(e),this._lineBeingCreated=null,this._lineCancelled.fire(),lt.isToolCreatingNow.setValue(!1),(0,lt.drawOnAllCharts)().value()&&e.isSynchronizable()&&(0,lt.cancelLineTool)({model:this}))}lineBeingCreated(){return this._lineBeingCreated?.lineDataSource||null}lineBeingCreateFromExternal(){return this._lineBeingCreated?.fromExternal||!1}paneBeingCreatedLineOn(){return this._paneBeingCreatedLineOn}lineCancelled(){return this._lineCancelled}isPhantomLine(e){return this._phantomSourceContainer.source()===e}alignTo45Degrees(e,t){const[i,s]=t,o={...s};e.snapPoint45Degree(i,o),
this.startChangingLinetool(e,s,s.pointIndex),this.changeLinePoint(o,Bo.EnvironmentState.create(!0)),this.endChangingLinetool(!1)}changeLinePoint(e,t,i){const s=(0,n.ensureNotNull)(this._lineBeingEdited),o=(0,n.ensureNotNull)(this._linePointBeingEdited);let r=e.price,a=e.index;if(s.setPoint(o,e,t,i),!i){const t=s.alignCrossHairToAnchor(o)?s.getPoint(o):e;null!==t&&(a=t.index,r=t.price)}s.updateAllViews((0,Bt.sourceChangeEvent)(s.id())),this.lightUpdate();const l=s.linkKey().value();if(!i&&null!==l&&s.isSynchronizable()){const e=(0,n.ensureNotNull)(this._linePointBeingChanged),i={indexesChanged:a!==e.index,pricesChanged:r!==e.price},c=s.getChangePointForSync(o);if(null!==c){const e=this.externalTimeStamp(a);null!==e&&(r=c.price,(0,lt.changeLineTool)({linkKey:l,model:this,symbol:this.mainSeries().symbol(),point:{price:r,timeStamp:e},positionPercents:s.positionPercents(),envState:t,changes:i}))}}}changeLinePoints(e,t,i){const s=e.points(),o=e.linkKey().value();!i&&o&&e.isSynchronizable()&&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,lt.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,Bt.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,Bt.viewportChangeEvent)()),this.lightUpdate()}endScrollTime(){this._timeScale.endScroll(),this.lightUpdate(),this.recalcVisibleRangeStudies(Eo.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,yo.InvalidationLevel.Light))}endScrollPrice(e,t){e.endScrollPrice(t),this.invalidate(this._paneInvalidationMask(e,yo.InvalidationLevel.Light))}addCustomSource(e,t,i=Eo.CustomSourceLayer.Foreground){this._customSourcesMap.has(e)&&l_.logWarn(`Attempt to add the same custom source multiple time "${e}"`),l_.logNormal(`Adding custom source "${e}"`);const s=t(e,this);switch(i){case Eo.CustomSourceLayer.Background:this._bgCustomSources.push(s);break;case Eo.CustomSourceLayer.Foreground:this._fgCustomSources.push(s);break;case Eo.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 Eo.CustomSourceLayer.Background:return this._bgCustomSources;case Eo.CustomSourceLayer.Foreground:return this._fgCustomSources;case Eo.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?l_.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()===Bi.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()===Bi.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 Mc(e);return(0,h.applyDefaultsOverrides)(t.childs().sessionHighlight,void 0,!1,"sessions"),t.removeDuplicateProperties(),t}((0,t_.createWVFromGetterAndSubscription)((()=>this.mainSeries().symbolInfo()),this.mainSeries().dataEvents().symbolResolved()).ownership());this._sessions=new Ac((async()=>{const s=await Promise.all([i.e(4821),i.e(7539)]).then(i.bind(i,83943));return this.addCustomSource("sessions",((i,o)=>{const n=new s.Sessions(i,o,t,e)
;return n.start(),n}),Eo.CustomSourceLayer.Background),this.customSourceForName("sessions")})(),this,t)}}createPrePostMarket(e){this.addCustomSource("prePostMarket",((t,i)=>new fd(t,i,e)))}createIntradayInactivityGaps(){this.addCustomSource("intradayInactivityGaps",((e,t)=>new o_(e,t)))}intradayInactivityGaps(){if(!l.enabled("intraday_inactivity_gaps"))throw new Error("intraday_inactivity_gaps featureset is not enabled");return(0,n.ensureNotNull)(this._intradayInactivityGapsWatchedValue)}setIntradayInactivityGapsSession(e){(0,n.ensureNotNull)(this.customSourceForName("intradayInactivityGaps")).setSession(e||"session")}watermarkSource(){return this._watermarkSource}watermarkContentProvider(){return i_.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 re.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(oo.StdTheme.Light)&&t.allThemePropertiesAreDefault(oo.StdTheme.Light)&&i.allThemePropertiesAreDefault(oo.StdTheme.Light)?oo.StdTheme.Light:e.allThemePropertiesAreDefault(oo.StdTheme.Dark)&&t.allThemePropertiesAreDefault(oo.StdTheme.Dark)&&i.allThemePropertiesAreDefault(oo.StdTheme.Dark)?oo.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(Vs.isStudyInputDependsOnChartColors).length>0));await Promise.all(e.map((e=>e.propertiesPatched())))}state(e,t,i,s){const o=this.publishedChartsTimelineSource(),n=this.properties().childs(),r=n.tradingProperties.state(),a={panes:this._panes.map((o=>o.state(!0,e,!1,t,i,s))),timeScale:this._timeScale.state(e),chartProperties:{
paneProperties:n.paneProperties.state(["horzGridProperties.style","vertGridProperties.style"]),scalesProperties:n.scalesProperties.state(),publishedChartsTimelineProperties:o?o.state(e):void 0,chartEventsSourceProperties:n.chartEventsSourceProperties?.state(),tradingProperties:r,priceScaleSelectionStrategyName:n.priceScaleSelectionStrategyName.value(),inactivityGaps:n.inactivityGaps.value()},sessions:this.sessions().state(e),version:this.version(),timezone:this.timezone(),shouldBeSavedEvenIfHidden:this._shouldBeSavedEvenIfHidden,linkingGroup:this._linkingGroupIndex.value()};return s||(a.lineToolsGroups=this.lineToolsGroupModel().state(t)),a}isInRestoreState(){return this._restoringState}restoreState(e,t,i){bh.instance(this).reset();const s={};if(!e.panes)return void l_.logDebug("ChartModel.restoreState: invalid state");if(!Array.isArray(e.panes))return void l_.logDebug("ChartModel.restoreState: invalid state");if(e.panes.length<1)return void l_.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,dt.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,dt.clone)(t.gridProperties),t.horzGridProperties=t.horzGridProperties||(0,dt.clone)(t.gridProperties),"backgroundType"in t||(t.backgroundType=So.ColorType.Solid),"separatorColor"in t||(t.separatorColor=(0,k.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?Eo.TradedGroupHorizontalAlignment.Right:o>=60?Eo.TradedGroupHorizontalAlignment.Left:Eo.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||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??Bi.PaneMode.Regular)===Bi.PaneMode.Regular){l_.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()?_+=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,eo.isLineTool)(t)&&(m++,t.calcIsActualSymbol())}this.updateTimeScaleBaseIndex(),this.recalculateAllPanes((0,Bt.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=dc.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=nd.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)(p_.get(e)).adapter,i=Math.min(...Array.from(this._recalcVRStudiesParams.reasons).map((e=>(0,n.ensureDefined)(p_.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,eo.isStudyLineTool)(e)&&e.recalcStudyIfNeeded()}))}alertsWatcher(){return this._alertsWatcher}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,Eu.getDefault2Lazy)(this._syncPointCache,e.uniqueId,t.uniqueId,(()=>new ld(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=yo.InvalidationMask.light(),s=this._timeScale;i.setTimeScaleAnimation(e,t??s.width()-s.indexToCoordinate(s.baseIndex())),this.invalidate(i)}stopTimeScaleAnimation(){this._timeScale.endScroll();const e=yo.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,yo.InvalidationLevel.Light))}calculateDefaultTags(){return this.dataSources().reduce(((e,t)=>(t.tags&&e.push(...t.tags()),e)),[])}_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=void 0;if(this._dateFormatter=new od.DateFormatter(e,t),this.mainSeries().isDWM())this._dateTimeFormatter=new od.DateFormatter(e,t),this._timeFormatter=new $h.TimeFormatter((0,Kh.getHourMinuteFormat)(we.timeHoursFormatProperty.value()));else{const i=Re.Interval.parse(this.mainSeries().interval()),s=(0,Kh.getTimeFormatForInterval)(i,we.timeHoursFormatProperty.value());this._dateTimeFormatter=new sd.DateTimeFormatter({dateFormat:e,withWeekday:t,timeFormat:s,dateTimeSeparator:" "}),this._timeFormatter=new $h.TimeFormatter(s)}}_invalidationMaskForSource(e,t=yo.InvalidationLevel.Light){if(e===this.crosshairSource())return yo.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 yo.InvalidationMask;return e.invalidateAll(t),e}if(!(0,Vo.isDataSource)(e))return null;if(e.isMultiPaneEnabled())return new yo.InvalidationMask(t);const i=this.paneForSource(e);return null!==i?this._paneInvalidationMask(i,t):null}_paneInvalidationMask(e,t=yo.InvalidationLevel.Light){const i=new yo.InvalidationMask,s=this._panes.indexOf(e);return i.invalidateAllPane(s,t),i}_invalidationMaskForSourcePriceScale(e,t=yo.InvalidationLevel.Light){if(!(0,Vo.isDataSource)(e))return new yo.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 yo.InvalidationMask;return a.invalidatePriceScale(o,n,r,t),a}_removeCustomSource(e){
const t=this._customSourcesMap.get(e);if(void 0===t)return void l_.logWarn(`Attempt to remove custom source which does not exist in the model - "${e}"`);l_.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=c_(this._bgCustomSources,t),s=c_(this._fgCustomSources,t),o=c_(this._topmostCustomSources,t),r=c_(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 At.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(),Yh.PlotRowSearchMode.NearestRight),o=i.search(t.lastBar(),Yh.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=[Eo.RecalcVisibleRangeStudiesReason.SeriesRestart,Eo.RecalcVisibleRangeStudiesReason.SeriesCompleted,Eo.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()?Lt.colorsPalette["color-cold-gray-200"]:Lt.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,Js.isStudy)(e)){const s=e.metaInfo().inputs.filter(Vs.isStudyInputDependsOnChartColors),o=e.properties().childs().inputs;s.forEach((e=>{const s=e.id===Vs.ChartColorDependentStudyInputNames.FgColor?i:t;o.childs()[e.id].setValueSilently(s)})),s.length>0&&o.fireChanged()}}_getAllSources(e){const t=[];for(const i of this._panes){const s=i.sourcesByGroup().allWithoutMultipane()
;for(const i of s)e(i)&&t.push(i)}return t}_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(l_.logDebug(u),!h&&h!==this._timeScale.canNormalize())for(const e of this.dataSources())!(0,eo.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,Bt.globalChangeEvent)()),this.lightUpdate()}_getAvailableCurrencies(){return!this.currencyConversionEnabled()||this.isSnapshot()?[]:(0,dt.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=>{l_.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=>{l_.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,dt.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=>{l_.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()===So.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,kt.rgbToBlackWhiteString)((0,kt.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,Md.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 l_.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._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,Js.isStudy)(e)&&!e.isLinkedToSeries()&&!(0,Zu.isNonSeriesStudy)(e)&&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,pt.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("intraday_inactivity_gaps"))return;this.createIntradayInactivityGaps();const e=async e=>{const t=this.customSourceForName("intradayInactivityGaps");e?t.start():t.stop()};if(null===this._intradayInactivityGapsWatchedValue){const t=this.properties().childs().inactivityGaps;this._intradayInactivityGapsWatchedValue=(0,ye.convertPropertyToWatchedValue)(t),this._intradayInactivityGapsWatchedValue.subscribe((t=>{e(t)})),e(t.value())}}}var f_=i(3503);class y_ extends tt.UndoCommand{constructor(e,t,i,s){super(s,void 0,!$r.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,lt.removeLineTool)({withUndo:!1,model:this._model,symbol:e.symbol(),linkKey:(0,n.ensureNotNull)(e.linkKey().value()),sourceTitle:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e),lineToolState:e.state(!1),unlink:!0}),e.linkKey().setValue(null)))}}
const v_=new Di.TranslatedString("zoom",a.t(null,void 0,i(91084)));class S_ extends tt.UndoCommand{constructor(e,t,i,s,o,n){super(v_),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,Bt.viewportChangeEvent)()),this._model.lightUpdate()}}const b_=(0,ae.getLogger)("Chart.ChartUndoModel"),w_=new Di.TranslatedString("zoom",a.t(null,void 0,i(91084)));class C_ extends tt.UndoCommand{constructor(e,t,i){super(w_),this._baseCmd=e,this._zoomStack=t,this._inOut=i}undo(e){if(this._inOut){if(this._baseCmd!==this._zoomStack.head())return void b_.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 b_.logDebug("zoom stack inconsistency");this._baseCmd.undo(e),this._zoomStack.pop()}}}const P_=new Di.TranslatedString("stop syncing drawing",a.t(null,void 0,i(3350)));class T_ extends tt.UndoCommand{constructor(e,t){super(P_,void 0,!$r.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 x_=new Di.TranslatedString("restore defaults",a.t(null,void 0,i(85815)));class I_ extends tt.UndoCommand{constructor(e,t,i=x_,s=!0){super(i,void 0,s),this._chartModel=e,this._defaultProperty=t,this._state=t.state()}redo(){this._chartModel.restoreFactoryDefaults(this._defaultProperty)}undo(){this._defaultProperty.mergeAndFire(this._state),this._chartModel.mainSeries().onChartStyleChanged()}}class M_ extends I_{constructor(e,t,i,s){super(e,t,i,s??!$r.lineToolsDoNotAffectChartInvalidation)}redo(){this._defaultProperty.child("intervalsVisibilities")?.mergeAndFire(Yu.intervalsVisibilitiesDefaults),super.redo()}}const A_=new Di.TranslatedString("restore study defaults",a.t(null,void 0,i(96881)))
;class L_ extends M_{constructor(e,t,i=A_){super(e,t.properties(),i,!0),this._study=t}redo(){super.redo(),this._chartModel.recalcColorStudies(!0),this._patchProperties()}undo(){super.undo(),this._chartModel.recalcColorStudies(!0),this._patchProperties()}_patchProperties(){0}}function k_(e,t){return(0,li.extractState)(e,t.map((e=>e.path)))}const D_=new Di.TranslatedString("apply chart theme",a.t(null,void 0,i(68231)));class E_ extends tt.UndoCommand{constructor(e,t,i){super(D_),this._model=e,t.sessions&&(this._newSessionProps=i?t.sessions:k_(t.sessions,(0,li.extractThemedColors)(xs.lightTheme.content.sessions,xs.darkTheme.content.sessions))),xh(t.mainSourceProperties.candleStyle),xh(t.mainSourceProperties.hollowCandleStyle),xh(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,hc.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:k_(l,(0,li.extractThemedColors)(xs.lightTheme.content.chartProperties,xs.darkTheme.content.chartProperties)),e.timeScale().preserveBarSpacing()&&"barSpacing"in this._newChartProps.scalesProperties&&delete this._newChartProps.scalesProperties.barSpacing,Ih(t.mainSourceProperties.lineStyle),Ih(t.mainSourceProperties.lineWithMarkersStyle),Ih(t.mainSourceProperties.steplineStyle);const c=(0,h.factoryDefaults)("chartproperties.mainSeriesProperties"),d=(0,ge.deepExtend)({},c,t.mainSourceProperties);this._newSeriesProps=i?d:k_(d,(0,li.extractThemedColors)(xs.lightTheme.content.mainSourceProperties,xs.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,li.allowSavingDefaults)(!0);const o=s.properties(),n=s.mainSeries().properties(),r=s.sessions().properties();o.applyDefaultThemedProperties(D.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(D.watchedTheme.value()),n.mergeAndFire(t),n.saveDefaults(),s.mainSeries().createPaneView(),s.mainSeries().invalidateBarStylesCache(),s.recalculateAllPanes((0,Bt.globalChangeEvent)()),i&&(r.applyDefaultThemedProperties(D.watchedTheme.value()),r.loadThemeState(i),r.saveDefaults()),s.fullUpdate(),(0,li.allowSavingDefaults)(!1)}}const B_=new Di.TranslatedString("change resolution",a.t(null,void 0,i(32829)));class V_ extends Jl{constructor(e,t,i){super(B_,e,function(e,t){let i;const s=(0,yt.isRangeStyle)(e.style()),o=Re.Interval.isRange(t);return!s&&o?i=11:s&&!o&&(i=(0,yt.getLastUsedStyle)()),{interval:t,style:i}}(e,t),i),this._resolution=t}canMerge(e){return e instanceof V_&&e._resolution===this._resolution&&super.canMerge(e)}_showFade(e,t){return!0}}class R_ extends rt{constructor(){super(...arguments),this._firstRedo=!0}redo(){this._firstRedo||(0,ki.muteLinkingGroup)(this._newValue,!0),(0,ki.muteLinkingGroup)(this._oldValue,!0),super.redo(),this._firstRedo||(0,ki.muteLinkingGroup)(this._newValue,!1),(0,ki.muteLinkingGroup)(this._oldValue,!1),this._firstRedo=!1}undo(){(0,ki.muteLinkingGroup)(this._newValue,!0),(0,ki.muteLinkingGroup)(this._oldValue,!0),super.undo(),(0,ki.muteLinkingGroup)(this._newValue,!1),(0,ki.muteLinkingGroup)(this._oldValue,!1)}}var N_=i(15491);class O_ extends tt.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 F_ extends tt.UndoCommand{constructor(e,t,i){super(i,void 0,!$r.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 W_=i(30141),H_=i(79320);const z_=new Di.TranslatedString("apply all chart properties",a.t(null,void 0,i(99551)));class U_ extends tt.UndoCommand{constructor(e){super(z_),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,H_.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=qu,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]=$u(e,d,r,"mainSeries",!1))})),a.forEach((e=>{n.includes(e)||(o[e]=$u(e,u,i,"preferences",!1))})),h.forEach((e=>{o.sessions[e]=$u(e,_,c,"sessions",!1)})),o}(this._model,this._model.mainSeries()),this._oldPreferences=e.preferences(),this._prevDateFormat=be.dateFormatProperty.value(),this._prevTimeHoursFormat=we.timeHoursFormatProperty.value(),this._prevAddPlusButton=Od.addPlusButtonProperty.value(),this._prevShowOpenMarkerStatus=W_.showMarketOpenStatusProperty.value(),this._prevCurrencyUnitVisibility=(0,Be.currencyUnitVisibilityProperty)().value(),this._prevAutoLogButtonsVisibility=(0,on.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._model.applyPreferences(this._defaultsPreferences),this._model.updateScales(),(0,be.restoreDateFormatSettingsValue)(),(0,we.restoreTimeHoursFormatSettingsValue)(),(0,Od.restoreAddPlusButtonSettingsValue)(),(0,W_.restoreShowMarketOpenStatusProperty)(),(0,Be.restoreCurrencyUnitVisibilitySettingsValue)(),(0,on.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),W_.showMarketOpenStatusProperty.setValue(this._prevShowOpenMarkerStatus),Od.addPlusButtonProperty.setValue(this._prevAddPlusButton),(0,Be.currencyUnitVisibilityProperty)().setValue(this._prevCurrencyUnitVisibility),(0,on.autoLogButtonsVisibilityProperty)().setValue(this._prevAutoLogButtonsVisibility),(0,ve.property)().setValue(this._prevNavigationButtonsVisibility),(0,Se.property)().setValue(this._prevPaneButtonsVisibility);const e=this._model.watermarkSource();null!==e&&null!==this._prevWatermarkPreferences&&e.properties().mergeAndFire(this._prevWatermarkPreferences)}}class G_ extends tt.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,li.allowSavingDefaults)(!0),this._priceScale.setMode({autoScale:!1,percentage:!1,log:!1}),this._property.setValue(this._newValue),(0,li.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,Bt.viewportChangeEvent)()),this._model.lightUpdate()}undo(){(0,li.allowSavingDefaults)(!0),this._property.setValue(this._oldValue),this._priceScale.setMode(this._oldMode),(0,li.allowSavingDefaults)(!1),this._model.recalculateAllPanes((0,Bt.viewportChangeEvent)()),this._model.lightUpdate()}}class j_{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 q_ extends tt.UndoCommand{constructor(e,t,i){super(i),this._chartModel=e,this._targetStrategy=(0,qc.createPriceScaleSelectionStrategy)(t),this._initialState=e.panes().map((e=>new j_(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 $_=new Di.TranslatedString("send {title} backward",a.t(null,void 0,i(40962))),K_=new Di.TranslatedString("bring {title} forward",a.t(null,void 0,i(41966))),Y_=new Di.TranslatedString("insert {title} after {target}",a.t(null,void 0,i(32960))),Z_=new Di.TranslatedString("insert {title} before {target}",a.t(null,void 0,i(57106))),X_=new Di.TranslatedString("cut {title}",a.t(null,void 0,i(11500))),J_=new Di.TranslatedString("cut sources",a.t(null,void 0,i(94227))),Q_=new Di.TranslatedString("remove {title}",a.t(null,void 0,i(94543))),ep=new Di.TranslatedString("remove drawings group",a.t(null,void 0,i(1193))),tp=new Di.TranslatedString("move scale",a.t(null,void 0,i(44854))),ip=new Di.TranslatedString("stop syncing line tool(s)",a.t(null,void 0,i(49183))),sp=new Di.TranslatedString("zoom out",a.t(null,void 0,i(73638))),op=new Di.TranslatedString("zoom in",a.t(null,void 0,i(49856))),np=new Di.TranslatedString("move drawing(s)",a.t(null,void 0,i(52510))),rp=new Di.TranslatedString("load default drawing template",a.t(null,void 0,i(43364))),ap=new Di.TranslatedString("apply factory defaults to selected sources",a.t(null,void 0,i(27851))),lp=new Di.TranslatedString("change currency",a.t(null,void 0,i(32302))),cp=new Di.TranslatedString("change unit",a.t(null,void 0,i(85975))),hp=new Di.TranslatedString("clone line tools",a.t(null,void 0,i(32943))),dp=new Di.TranslatedString("merge up",a.t(null,void 0,i(52458))),up=new Di.TranslatedString("merge down",a.t(null,void 0,i(78055))),_p=new Di.TranslatedString("merge to pane",a.t(null,void 0,i(41866))),pp=new Di.TranslatedString("unmerge up",a.t(null,void 0,i(79443))),mp=new Di.TranslatedString("unmerge down",a.t(null,void 0,i(46453))),gp=new Di.TranslatedString("unmerge to new bottom pane",a.t(null,void 0,i(81576))),fp=new Di.TranslatedString("move {title} to new right scale",a.t(null,void 0,i(77482))),yp=new Di.TranslatedString("move {title} to new left scale",a.t(null,void 0,i(58228))),vp=new Di.TranslatedString("make {title} no scale (Full screen)",a.t(null,void 0,i(10625))),Sp=new Di.TranslatedString("scroll time",a.t(null,void 0,i(87840))),bp=new Di.TranslatedString("scale time",a.t(null,void 0,i(70771))),wp=new Di.TranslatedString("reset time scale",a.t(null,void 0,i(17336))),Cp=new Di.TranslatedString("reset scales",a.t(null,void 0,i(3323))),Pp=new Di.TranslatedString("create {tool}",a.t(null,void 0,i(12898))),Tp=new Di.TranslatedString("paste {title}",a.t(null,void 0,i(57010))),xp=new Di.TranslatedString("insert {title}",a.t(null,void 0,i(48818))),Ip=new Di.TranslatedString("remove pane",a.t(null,void 0,i(93333))),Mp=new Di.TranslatedString("invert scale",a.t(null,void 0,i(6830))),Ap=new Di.TranslatedString("toggle auto scale",a.t(null,void 0,i(42240))),Lp=new Di.TranslatedString("toggle lock scale",a.t(null,void 0,i(49695))),kp=new Di.TranslatedString("toggle regular scale",a.t(null,void 0,i(80688))),Dp=new Di.TranslatedString("toggle indexed to 100 scale",a.t(null,void 0,i(24736))),Ep=new Di.TranslatedString("toggle percentage scale",a.t(null,void 0,i(98994))),Bp=new Di.TranslatedString("toggle log scale",a.t(null,void 0,i(49403))),Vp=new Di.TranslatedString("move left",a.t(null,void 0,i(79209))),Rp=new Di.TranslatedString("move right",a.t(null,void 0,i(60114))),Np=new Di.TranslatedString("align to 45 degrees",a.t(null,void 0,i(4128))),Op=new Di.TranslatedString("set price scale selection strategy to {title}",a.t(null,void 0,i(82241))),Fp=new Di.TranslatedString("remove all indicators",a.t(null,void 0,i(60806))),Wp=new Di.TranslatedString("remove drawings",a.t(null,void 0,i(30538))),Hp=new Di.TranslatedString("remove all indicators and drawing tools",a.t(null,void 0,i(29096))),zp=new Di.TranslatedString("turn line tools sharing off",a.t(null,void 0,i(8040))),Up=new Di.TranslatedString("share line tools in layout",a.t(null,void 0,i(90221))),Gp=new Di.TranslatedString("share line tools globally",a.t(null,void 0,i(63934))),jp=new Di.TranslatedString("change linking group",a.t(null,void 0,i(88849))),qp=(new Di.TranslatedString("apply drawing template",a.t(null,void 0,i(89720))),
(0,ae.getLogger)("Chart.ChartUndoModel"));var $p;function Kp(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"}($p||($p={}));const Yp=(0,l.enabled)("saveload_separate_drawings_storage");function Zp(){return Yp?(0,lt.drawOnAllCharts)().value()?1===(0,lt.drawOnAllChartsMode)().value()?1:2:0:(0,lt.drawOnAllCharts)().value()?1:0}function Xp(e,t){(0,Ar.showTooManyStudiesNotice)(t.limitValue)}class Jp extends(Ir()){constructor(e,t,i,s,o,n,r,a,l,c,h,d){super(),this._createLineCommand=null,this._initialTimeScrollState=null,this._initialTimeScrollPos=null,this._initialTimeScaleState=null,this._scalePriceInfo=null,this._currentSourceMoveCommand=null,this._currentLineChangeCommand=null,this._currentCustomMoveCommand=null,this._zoomStack=new st,this._initialPriceScrollState=null,this._initialPriceScrollPos=null,this._chartWidget=n,this.m_model=new g_(e,t,i,s,o,this,a,l,c,h,d),this._undoHistory=r,this._lineToolsGroupController=new hl({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?Ur:Gr),e.model().panes().forEach((i=>{const s="left"===t?i.rightPriceScales():i.leftPriceScales(),o=("left"===t?i.leftPriceScales():i.rightPriceScales()).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){jr.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 qr(this._model(),e,t,i,s,tp);this._pushUndoCommand(o)}createLineTool({pane:e,point:t,linetool:i,properties:s,linkKey:o,ownerSource:r,synchronizationMode:a=Lr.CreateLineToolSyncMode.Default,sharingMode:l=Zp(),id:c}){const h=N_.lineToolsStudyIds[i];if((0,n.assert)(!(0,wt.isStudyLineToolName)(h)||!!h),h){const e=this.canCreateStudy({id:h});if(!e.success)return Xp(this.model(),e),(0,wt.isStudyLineToolName)(lt.tool.value())&&(0,lt.resetToCursor)(),null}const d=Pp.format({tool:new Di.TranslatedString(i,ca.lineToolsLocalizedNames[i])});this.beginUndoMacro(d);const u=a!==Lr.CreateLineToolSyncMode.ForceOff;this._createLineCommand=new da({model:this._model(),pane:e,lineTool:i,ownerSource:r||(0,n.ensureNotNull)(e.mainDataSource()),drawOnAllChartsMode:l,id:c})
;const _=this._createLineCommand.startCreatingLine(t,s,o||null,l,a===Lr.CreateLineToolSyncMode.ForceOff),p=(0,n.ensureNotNull)(this._createLineCommand.line());let m=null;if(_&&(u&&this.finishLineTool(p),this._pushUndoCommand(this._createLineCommand),this._createLineCommand=null,m={points:p.normalizedPoints(),interval:this.mainSeries().interval()}),(void 0===o&&a===Lr.CreateLineToolSyncMode.Default&&(0,lt.drawOnAllCharts)().value()||a===Lr.CreateLineToolSyncMode.ForceOn)&&p.isSynchronizable()){const e=(0,n.ensureNotNull)(this.model().externalTimeStamp(t.index)),s={point:{price:t.price,timeStamp:e},linetool:i,properties:p.properties(),symbol:this.mainSeries().symbol(),model:this.model(),linkKey:(0,n.ensureNotNull)(p.linkKey().value()),finalState:m,id:p.id(),sharingMode:p.sharingMode().value()};p.isFixed()&&(s.pointPositionPercents=p.calcPositionPercents()),(0,lt.createLineTool)(s)}return this.endUndoMacro(),p}continueCreatingLine(e,t,i,s){const o=(0,n.ensureNotNull)(this._createLineCommand);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._createLineCommand=null,l={points:r.normalizedPoints(),interval:this.mainSeries().interval()}),o.drawOnAllCharts()&&r.isSynchronizable()){const i=(0,n.ensureNotNull)(this._model().externalTimeStamp(e.index));(0,lt.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.ensureNotNull)(this._createLineCommand),o=s.continueCreatingLine(e,t,i);return o&&(this._pushUndoCommand(s),this._createLineCommand=null),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,eo.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,eo.prepareLineToolPropertiesByOwnerSource)(d,u);const _=this.createLineTool({pane:i,point:h,linetool:"LineToolImage",properties:d});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,lt.removeLineTool)({withUndo:!1,model:i,linkKey:t,symbol:_.symbol(),sourceTitle:new Di.TranslatedString(_.name(),_.translatedType()),lineToolState:_.state(!1)}),i.removeSource(_)}))),_}loadRange(e){const t=this._model(),i=t.appliedTimeFrame().value();return(null===i||!Dr(i,e))&&(this._pushUndoCommand(new qa(t,e)),(0,W.emit)("timeframe_interval",e),!0)}
mainSeries(){return this.m_model.mainSeries()}model(){return this.m_model}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,lt.removeLineTool)({withUndo:!0,model:this.model(),symbol:i.symbol(),linkKey:(0,n.ensureNotNull)(i.linkKey().value()),sourceTitle:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,i),lineToolState:i.state(!1),unlink:!0}),this._pushUndoCommand(new T_(t,i));this.endUndoMacro()}zoomFromViewport(){const e=new C_((0,n.ensureDefined)(this._zoomStack.head()),this._zoomStack,!1);this._pushUndoCommand(e)}zoomToViewport(e,t,i,s,o){const n=new S_(this.m_model,e,t,i,s,o),r=new C_(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 Ua(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(),Mp)}togglePriceScaleAutoScaleMode(e){const t={autoScale:!e.isAutoScale()};this.setPriceScaleMode(t,e,Ap)}togglePriceScaleLockScaleMode(e){const t={lockScale:!e.isLockScale()};this.setPriceScaleMode(t,e,Lp)}togglePriceScalePercentageScaleMode(e){const t={percentage:!e.isPercentage()};this.setPriceScaleMode(t,e,Ep)}togglePriceScaleIndexedTo100ScaleMode(e){const t={indexedTo100:!e.isIndexedTo100()};this.setPriceScaleMode(t,e,Dp)}togglePriceScaleLogScaleMode(e){const t={log:!e.isLog()};this.setPriceScaleMode(t,e,Bp)}setPriceScaleRegularScaleMode(e){this.setPriceScaleMode({log:!1,percentage:!1,indexedTo100:!1},e,kp)}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(Wp),this._removeAllDrawingToolsImpl(e),this.endUndoMacro()}removeAllStudiesAndDrawingTools(e){this.beginUndoMacro(Hp),this._removeAllDrawingToolsImpl(e),this._removeAllStudiesImpl(),this.endUndoMacro()}removeAllStudies(){this.beginUndoMacro(Fp),
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()&&(this.changeTimeScale(sp),(0,Er.doAnimate)({to:e/5,onStep:e=>{this.startScaleTime(0),this.scaleTimeTo(e),this.endScaleTime()}}))}zoomIn(){const e=this.timeScale().width();this.canZoomIn()&&(this.changeTimeScale(op),(0,Er.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 Jr(this.model(),e,np,!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){this._currentLineChangeCommand=new Jr(this.model(),[e],e.changePointUndoText(i),!1),this.model().startChangingLinetool(e,t,i,s,o)}changeLinePoint(e,t){this.model().changeLinePoint(e,t)}alignToolTo45Degrees(e){const t=e.alignTo45DegreesPoints();t&&(this._pushUndoCommand(new Jr(this.model(),[e],Np,!1)),this.model().alignTo45Degrees(e,t))}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 Ga(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 Nn(this.m_model,e,t,t.state())),this.m_model.setPriceAutoScale(e,t,i)}setPriceScaleMode(e,t,i){if(!(0,Do.default)(t.mode(),e)){const s=new lc(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,ne.trackEvent)("Chart","Change PriceScale Selection Strategy");const i=Op.format({title:e});this.beginUndoMacro(i),this.setProperty(t.priceScaleSelectionStrategyName,e,i);const s=new q_(this.m_model,e,i);this._pushUndoCommand(s),this.endUndoMacro()}setScaleRatioProperty(e,t,i){if(e.value()!==t){const s=new G_(e,t,i,this.m_model);this._pushUndoCommand(s)}}createUndoCheckpoint(){return this._undoHistory.createUndoCheckpoint()}undoToCheckpoint(e){this._undoHistory.undoToCheckpoint(e)}
restorePropertiesForSource(e){(0,eo.isLineTool)(e)?this._restoreLineToolFactoryDefaults(e):this._restoreStudyFactoryDefaults(e)}restoreLineToolsFactoryDefaults(e){1===e.length?this._restoreLineToolFactoryDefaults(e[0]):(this.beginUndoMacro(ap),e.forEach((e=>this._restoreLineToolFactoryDefaults(e))),this.endUndoMacro())}restorePreferences(){const e=new U_(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,Js.isStudy)(e)&&e.isChildStudy())throw new Error("Can not copy child study");const s=(0,Rr.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?X_:J_).format({title:(0,di.getTranslatedStringForSource)(ua.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 zl(this._model(),e,t);this.beginUndoMacro(i.text());const s=this.m_model.panes().reduce(((e,t)=>e.concat(t.sourcesByGroup().allWithoutMultipaneWithHidden().filter((e=>(0,eo.isLineTool)(e)&&e.ownerSource()!==this.m_model.mainSeries())))),[]);this.removeSources(s,!1,null),this._pushUndoCommand(i),this.endUndoMacro(),(0,W.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 qp.logNormal("Cannot insert study "+e.id),null;(0,ne.trackEvent)("studies","Study_"+e.id),"Compare@tv-basicstudies"===e.id&&(0,ne.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,W.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 Qu(e,n);return r.setParentSources(t),r}applyLineToolTemplate(e,t,i){this.beginUndoMacro(i),this.saveLineToolState(e,i);const s=new F_(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 rc(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,t,i,s){return this.m_model.state(e,t,i,s)}panes(){return this.m_model.panes()}cloneLineTools(e,t){for(let t=0;t<Math.min(5,e.length);++t)e[t],Wn();this.beginUndoMacro(hp);const i=new Kr(this._model(),e,t,hp);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,Q_.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e)}),i):this.cancelCreatingLine()}removeSelectedSources(){const e=this._model().selection().dataSources();if(!e.length)return;const t=(e.length>1?ep:Q_).format({title:(0,di.getTranslatedStringForSource)(ua.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,eo.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,lt.removeLineTool)({withUndo:!0,model:this.model(),linkKey:(0,n.ensureNotNull)(e.linkKey().value()),symbol:this.model().mainSeries().symbol(),lineToolState:e.state(!1),sourceTitle:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e)})}}));const l=new Yr.RemoveSourcesUndoCommand(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(dt.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 Vr({from:0,to:h-d,duration:Mr.dur,easing:Mr.easingFunc.easeInOutCubic}))}mergeSourceUp(e){const t=new na(this._model(),e,dp);this._mergeUnmergeSource(e,t)}mergeSourceDown(e){const t=new ra(this._model(),e,up);this._mergeUnmergeSource(e,t)}mergeToPane(e,t,i){const s=this._model().panes().indexOf(t),o=new aa(this._model(),e,s,_p,i);this._mergeUnmergeSource(e,o)}unmergeSourceUp(e){const t=new ia(this._model(),e,pp);this._mergeUnmergeSource(e,t)}unmergeSourceDown(e){const t=new ta(this._model(),e,mp);this._mergeUnmergeSource(e,t)}unmergeToNewBottomPane(e){const t=new sa(this._model(),e,gp);this._mergeUnmergeSource(e,t)}moveLeft(){this.beginUndoMacro(Vp),(0,Er.doAnimate)({to:this.m_model.timeScale().width()/5,onStep:e=>{this.startScrollTime(e),this.scrollTimeTo(0),this.endScrollTime()},onComplete:()=>{this.endUndoMacro()}})}moveRight(){this.beginUndoMacro(Rp),(0,Er.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(eo.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,ci.sortSources)(e)){if((0,eo.isLineTool)(t)&&null!==o){const e=(0,ci.sortSources)(o.lineTools().filter((e=>!a.has(e)||e===t)));r=Kp(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=Kp(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,eo.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new Ma(this.model(),(0,ci.sortSources)(e),i[0])}}null===t&&(t=new Pa(this.model(),(0,ci.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,eo.isLineTool)(i)){const s=this._model().lineToolsGroupModel().groupForLineTool(i);if(null!==s){const i=s.lineTools();t=new xa(this.model(),(0,ci.sortSources)(e),i[i.length-1])}}null===t&&(t=new Ca(this.model(),(0,ci.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=$_.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,ci.sortSources)(e),((e,t)=>new La(this.model(),e,t)))}bringForward(e){if(!this.availableZOrderOperations(e).bringForwardEnabled)throw new Error("Bring forward operation is unavailable");const t=K_.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e[0])});this._sendBackOrBringForward(t,(0,ci.sortSources)(e),((e,t)=>new Da(this.model(),e,t)))}insertAfter(e,t){e=(0,ci.sortSources)(e);const i=Y_.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e[0]),target:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new xa(this.model(),e,t)))}insertBefore(e,t){e=(0,ci.sortSources)(e);const i=Z_.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e[0]),target:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,t)});this._insertAfterOrBefore(i,e,t,(()=>new Ma(this.model(),e,t)))}detachToRight(e,t){(0,ne.trackEvent)("Chart","Move to new right scale");const i=fp.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e)}),s=new Zl(this.model(),e,t,"right",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachToLeft(e,t){(0,ne.trackEvent)("Chart","Move to new left scale");const i=yp.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e)}),s=new Zl(this.model(),e,t,"left",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}detachNoScale(e,t){(0,ne.trackEvent)("Chart","Make source no scale");const i=vp.format({title:(0,di.getTranslatedStringForSource)(ua.TitleDisplayTarget.StatusLine,e)}),s=new Zl(this.model(),e,t,"overlay",i);this._pushUndoCommand(s),this.emitEvent("moveSource",[e])}moveToScale(e,t,i,s,o){(0,ne.trackEvent)("Chart","Move source to target scale"),this.beginUndoMacro(s);const n=new Xl(this.model(),e,t,i,s),r=o?null:Or(e,i,this._model()),a=o?null:oh(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(jp),this._pushUndoCommand(new R_(t,t.value(),e,jp)),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 Nn(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){const t=this.timeScale();this._initialTimeScrollState={rightOffset:t.rightOffset(),barSpacing:t.barSpacing()},this._initialTimeScrollPos=e,this.model().startScrollTime(e)}scrollTimeTo(e){null!==this._initialTimeScrollPos&&null!==this._initialTimeScrollState&&Math.abs(e-this._initialTimeScrollPos)>20&&(this._pushUndoCommand(new En(this.model(),this._initialTimeScrollState,Sp,!1)),this._initialTimeScrollPos=null,this._initialTimeScrollState=null),this.model().scrollTimeTo(e)}endScrollTime(){this.model().endScrollTime(),this._initialTimeScrollPos=null,this._initialTimeScrollState=null}startScaleTime(e){const t=this.timeScale();this._initialTimeScaleState={rightOffset:t.rightOffset(),barSpacing:t.barSpacing()},this.model().startScaleTime(e)}scaleTimeTo(e){null!==this._initialTimeScaleState&&this._initialTimeScaleState.barSpacing!==this.timeScale().barSpacing()&&(this._pushUndoCommand(new En(this.model(),this._initialTimeScaleState,bp,!0)),this._initialTimeScaleState=null),this.model().scaleTimeTo(e)}endScaleTime(){this.model().endScaleTime()}resetTimeScale(){this.changeTimeScale(wp,this.timeScale().resetAvailable().value()),this.model().resetTimeScale()}changeTimeScale(e,t=!0){const i=this.timeScale(),s={rightOffset:i.rightOffset(),barSpacing:i.barSpacing()};this._pushUndoCommand(new En(this.model(),s,e,t))}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,Do.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new Nn(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,Do.default)(i.priceScaleState,t.state())||this._pushUndoCommand(new Nn(this.model(),e,t,i.priceScaleState,i.tryMergeConsecutiveScales)),this._scalePriceInfo=null}resetPriceScale(e,t){const i=t.state();this.model().resetPriceScale(e,t),(0,
Do.default)(i,t.state())||this._pushUndoCommand(new Nn(this.m_model,e,t,i))}rearrangePanes(e,t){const i=new Na(this._model(),e,t);this._pushUndoCommand(i)}movePane(e,t){const i=new Na(this._model(),e,t);this._pushUndoCommand(i)}toggleCollapsedPane(e){const t=this.panes().findIndex((t=>t===e));t<0||this._pushUndoCommand(new Wr(this._model(),t))}toggleMaximizedPane(e){this._pushUndoCommand(new zr(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||(Xp(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(Rr.isLineToolClipboardData).map((e=>e.source.type))));await Promise.all(r.map((e=>(0,eo.initLineTool)(e)))),this.beginUndoMacro(Tp.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&&(Wn(),a+=1),c.push(e),l.push(e)}else"study"===t.type&&t.source&&t.source.metaInfo&&this.checkIfFeatureAvailable(new is.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,Ro.ensureLineToolLoaded)(t.source.type),t.source.state.intervalsVisibilities=(0,Ch.mergeIntervalVisibilitiesDefaults)(t.source.state.intervalsVisibilities),(0,Ch.makeIntervalsVisibilitiesVisibleAtInterval)(t.source.state.intervalsVisibilities,this.model().mainSeries().intervalObj());const o=new ql(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 sc(this.model(),e,t?.id());this._pushUndoCommand(i);const s=(0,n.ensureNotNull)(i.state()).id;return(0,W.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,Ip)}createPane(e){return this.m_model.createPane(e)}setPriceScaleCurrency(e,t){const i=new $l(this.m_model,e,t,lp);this._pushUndoCommand(i)}setPriceScaleUnit(e,t){const i=new Kl(this.m_model,e,t,cp);this._pushUndoCommand(i)}setSymbol(e,t){e.symbolSameAsResolved(t)||this._pushUndoCommand(new ec(e,t,this._chartWidget))}setResolution(e,t){Re.Interval.isEqual(e.interval(),t)||this._pushUndoCommand(new V_(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 E_(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 oc(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 Jr(this.m_model,[e],t))}resetScales(){this._model().stopTimeScaleAnimation(),this.beginUndoMacro(Cp),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,Bt.viewportChangeEvent)())}shareLineTools(e,t){if(!Yp)return;const i=0===t?zp:1===t?Up:Gp;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 y_(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){if((0,wt.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 s=this.createLineTool({point:i,linetool:e,pane:t});s&&this.selectionMacro((e=>{e.clearSelection(),e.addSourceToSelection(s)}))}}_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 Zr.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=xp.format({title:e.description}),_=new ac({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=xp.format({title:e.title()});this.beginUndoMacro(t);const i=new O_(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(f_.blobImageFilter);if(e){const t=URL.createObjectURL(e),s=(0,f_.uploadImage)(e);return void 0===i&&(i=(0,n.ensureNotNull)(this._model().paneForSource(this.mainSeries()))),await(0,Ro.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,eo.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._pushUndoCommand(r),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,lt.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(np);const o=i.firstBar(),n=this.timeScale().indexToCoordinate(o),r=o+(3===e?1:2===e?-1:0),a=this.timeScale().indexToCoordinate(r)
;return lt.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 At.Point(n,d)},p={logical:{index:r,price:h},screen:new At.Point(a,u)};this.startMovingSources(t.sources,_,null),this.moveSources(p),this.endMovingSource(!1,!0)})),lt.isDirectionalMovementActive.setValue(!1),this.endUndoMacro(),!0}_restoreStudyFactoryDefaults(e){const t=new L_(this.m_model,e);this._pushUndoCommand(t)}_restoreLineToolFactoryDefaults(e){this.beginUndoMacro(rp),this.saveLineToolState(e,rp);const t=new M_(this.m_model,e.properties(),rp);this._pushUndoCommand(t),this.saveLineToolState(e,rp),this.endUndoMacro(),this.model().updateSource(e)}_removeAllDrawingToolsImpl(e,t){this.selectionMacro((()=>{this.lineBeingCreated()&&this.cancelCreatingLine();this.dataSources().filter(eo.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(Js.isStudy).filter((e=>!e.isChildStudy()&&e.removeByRemoveAllStudies())),i=e.filter(Js.isStudyStub);t.concat(i).forEach((e=>this.removeSource(e,!1)))}}class Qp{constructor(){this._ariaElement=null,this._nextAnnouncementTime=Date.now().valueOf(),this._latestDescription="",this._timeoutId=null,this._locale="en"}createElement(e){this._ariaElement=Pt(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 ${Tt(i/1e3,s)}`}this._setChartDescription(o)}static getInstance(){return null===this._instance&&(this._instance=new Qp),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}}Qp._instance=null;var em=i(17402);const tm=a.t(null,void 0,i(47773));class im{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 tm.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 sm extends im{show(){(0,q.showWarning)({title:"Unavailable",html:this._getPopupContent(),onClose:()=>this._onPopupClosed()})}}const om=(0,ae.getLogger)("ChartApi.AbstractSession");var nm;!function(e){e[e.Disconnected=0]="Disconnected",e[e.Registered=1]="Registered",e[e.Connected=2]="Connected"}(nm||(nm={}));class rm{constructor(e,t,i){this._isConnected=new F.WatchedValue(!1),this._state=0,this._isConnectForbidden=!1,this._sessionId="",this._sessionIdChanged=new re.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){om.logNormal(this._generateLogMessage(e))}_logError(e){om.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 am extends rm{constructor(e,t=!1){super(e,"cs",!1),this._sessionDisabled=!1,this._handler=null,this._criticalError=new re.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 lm=i(2433),cm=i(72595);const hm=(0,li.extractThemedColors)(xs.lightTheme.content.mainSourceProperties,xs.darkTheme.content.mainSourceProperties),dm="chartproperties.mainSeriesProperties",um=(0,s.default)((()=>{const e=(0,cm.createPropertySchema)((0,Qe.default)((0,h.factoryDefaults)(dm),lm.light.content.mainSourceProperties),7);return(0,Qe.default)(e,{subschema:{priceAxisProperties:{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:cm.DataTypes.BOOLEAN,saveFlags:2},symbol:{type:cm.DataTypes.STRING,saveFlags:2},shortName:{type:cm.DataTypes.STRING,saveFlags:2},timeframe:{type:cm.DataTypes.STRING,saveFlags:2},interval:{type:cm.DataTypes.STRING,saveFlags:2},currencyId:{type:cm.DataTypes.STRING,saveFlags:2},unitId:{type:cm.DataTypes.STRING,saveFlags:2},style:{type:cm.DataTypes.NUMBER,saveFlags:2},sessionId:{type:cm.DataTypes.STRING,saveFlags:2}}}),e}));class _m extends li.DefaultProperty{constructor(){super({defaultName:dm,themedColors:hm,schema:um()})}}let pm=null;var mm=i(7029),gm=i(34585),fm=i(80387),ym=i(62400);var vm=i(78956);function Sm(e){const t=e.model().dataSources(),s=t.filter(vm.isLineTool).filter((e=>e.isActualSymbol()&&e.isUserDeletable())).length,o=t.filter(Js.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 bm=i(86235);function wm(e){const t=e.options(),s={label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(2569))),statName:"ChangeInterval",onExecute:()=>(0,bm.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 Jo.Action({actionId:"Chart.Dialogs.ShowChangeInterval",options:s})}class Cm extends Jo.Action{constructor(e,t=new F.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 Pm=(0,l.enabled)("show_average_close_price_line_and_label"),Tm=new Di.TranslatedString("scale price chart only",mm.t(null,void 0,i(63796))),xm=new Di.TranslatedString("stay in drawing mode",mm.t(null,void 0,i(4114))),Im=new Di.TranslatedString("hide marks on bars",mm.t(null,void 0,i(62249))),Mm=new Di.TranslatedString("change symbol last value visibility",mm.t(null,void 0,i(67453))),Am=(new Di.TranslatedString("change symbol previous close value visibility",mm.t(null,void 0,i(4729))),new Di.TranslatedString("change previous close price line visibility",mm.t(null,void 0,i(58419))),new Di.TranslatedString("change symbol labels visibility",mm.t(null,void 0,i(73357)))),Lm=new Di.TranslatedString("change indicators value labels visibility",mm.t(null,void 0,i(64729))),km=new Di.TranslatedString("change indicators name labels visibility",mm.t(null,void 0,i(24893))),Dm=(new Di.TranslatedString("change bid and ask labels visibility",mm.t(null,void 0,i(69362))),new Di.TranslatedString("change bid and ask lines visibility",mm.t(null,void 0,i(52919))),new Di.TranslatedString("change pre/post market price label visibility",mm.t(null,void 0,i(30870))),new Di.TranslatedString("change pre/post market price line visibility",mm.t(null,void 0,i(11718))),
new Di.TranslatedString("change high and low price labels visibility",mm.t(null,void 0,i(24226)))),Em=new Di.TranslatedString("change high and low price lines visibility",mm.t(null,void 0,i(80692))),Bm=new Di.TranslatedString("change average close price label visibility",mm.t(null,void 0,i(76852))),Vm=new Di.TranslatedString("change average close price line visibility",mm.t(null,void 0,i(1022))),Rm=new Di.TranslatedString("change countdown to bar close visibility",mm.t(null,void 0,i(39383))),Nm=new Di.TranslatedString("change plus button visibility",mm.t(null,void 0,i(96379))),Om=new Di.TranslatedString("change session breaks visibility",mm.t(null,void 0,i(38413))),Fm=new Di.TranslatedString("change price line visibility",mm.t(null,void 0,i(8662))),Wm=new Di.TranslatedString("change timezone",mm.t(null,void 0,i(20137)));function Hm(e){const t=e.hotkeys(),s=e.model(),o=e.options(),n=e.properties(),r=new Jo.Action({actionId:"Chart.Series.PriceScale.ToggleInvertPriceScale",options:{label:mm.t(null,void 0,i(37189)),statName:"Invert Scale",checkable:!0,onExecute:()=>s.invertPriceScale(s.mainSeries().priceScale()),hotkeyGroup:t,hotkeyHash:V.Modifiers.Alt+73}}),c=new Jo.Action({actionId:"Chart.Series.PriceScale.ToggleAutoScale",options:{label:mm.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 Jo.Action({actionId:"Chart.Scales.ToggleLockPriceToBarRatio",options:{label:mm.t(null,void 0,i(14017)),checkable:!0,statName:"ToggleLockScale",onExecute:()=>s.togglePriceScaleLockScaleMode(s.mainSeries().priceScale())}}),d=new Jo.Action({actionId:"Chart.Series.PriceScale.ToggleRegular",options:{label:mm.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 Jo.Action({actionId:"Chart.Series.PriceScale.TogglePercentage",options:{label:mm.t(null,void 0,i(6919)),checkable:!0,statName:"TogglePercantage",onExecute:()=>s.togglePriceScalePercentageScaleMode(s.mainSeries().priceScale()),hotkeyGroup:t,hotkeyHash:V.Modifiers.Alt+80}}),_=new Jo.Action({actionId:"Chart.Series.PriceScale.ToggleIndexedTo100",options:{label:mm.t(null,void 0,i(89999)),checkable:!0,statName:"ToggleIndexedTo100",onExecute:()=>s.togglePriceScaleIndexedTo100ScaleMode(s.mainSeries().priceScale())}}),p=new Jo.Action({actionId:"Chart.Series.PriceScale.ToggleLogarithmic",options:{label:mm.t(null,void 0,i(16170)),statName:"ToggleLogScale",checkable:!0,onExecute:()=>s.togglePriceScaleLogScaleMode(s.mainSeries().priceScale()),hotkeyGroup:t,hotkeyHash:V.Modifiers.Alt+76}}),m=new Jo.Action({actionId:"Chart.ChangeTimeZone",options:{label:mm.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 Jo.Action({
actionId:"Chart.ChangeTimeZone",options:{label:i.title,checkable:!0,checked:s(i),statName:"SetTimeZone",onExecute:()=>{e.model().setProperty(g,i.id,Wm)}}});t.push(o)})),m.update({subItems:t})};f(),g.subscribe(m,f);const y=new nn.ActionWithStandardIcon({actionId:"Chart.TimeScale.Reset",options:{label:mm.t(null,void 0,i(54170)),iconId:"Chart.Reset",statName:"ResetScale",onExecute:()=>s.resetTimeScale(),hotkeyGroup:e.hotkeys(),hotkeyHash:V.Modifiers.Mod+V.Modifiers.Alt+81}}),v=new Jo.Action({actionId:"Chart.Dialogs.ShowInsertIndicators",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(87829))),statName:"InsertIndicator",onExecute:()=>e.showIndicators(),...o.indicatorsDialogShortcutEnabled?{hotkeyGroup:t,hotkeyHash:191}:void 0}}),S=new Jo.Action({actionId:"Chart.Dialogs.ShowCompareOrAddSymbol",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(53942))),statName:"CompareOrAddSymbol",onExecute:()=>e.toggleCompareOrAdd()}}),b=new nn.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowGeneralSettings",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(32514))),iconId:"Settings",statName:"ChartProperties",onExecute:()=>e.showGeneralChartProperties()}}),w=new nn.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowGeneralSettings.SymbolTab",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(32514))),iconId:"Settings",statName:"MainSeriesProperties",onExecute:()=>e.showGeneralChartProperties(Zs.TabNames.symbol)}}),C=new nn.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowGeneralSettings.ScalesTab",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(93907))),iconId:"Settings",statName:"ScalesProperties",onExecute:()=>e.showGeneralChartProperties(Zs.TabNames.scales)}}),P=new Jo.Action({actionId:"Chart.SelectedObject.ToggleLocked",options:{label:mm.t(null,void 0,i(79777)),statName:"ToggleLockSelectedObject",onExecute:()=>e.toggleLockSelectedObject()}}),T=new nn.ActionWithStandardIcon({actionId:"Chart.SelectedObject.Hide",options:{label:mm.t(null,void 0,i(27298)),iconId:"Chart.Hide",statName:"HideSelectedObject",onExecute:()=>e.hideSelectedObject()}}),x=new en({actionId:"Chart.PriceScale.ToggleAutoScaleSeriesOnly",options:{label:mm.t(null,void 0,i(43758)),checkable:!0,statName:"ScalePriceChartOnly"}},{property:n.childs().scalesProperties.childs().scaleSeriesOnly,undoModel:s,undoText:Tm}),I=new Cm({actionId:"Chart.DrawingToolbar.ToggleVisibility",options:{label:mm.t(null,void 0,i(93864)),statName:"ToggleDrawingToolbar"}},o.isDrawingToolbarVisible),M=new en({actionId:"",options:{label:mm.t(null,void 0,i(4035)),checkable:!0,statName:"ToggleStayInDrawingMode"}},{property:lt.properties().childs().stayInDrawingMode,undoModel:s,undoText:xm}),A=new en({actionId:"Chart.Marks.ToggleVisibility",options:{label:mm.t(null,void 0,i(28345)),checkable:!0,statName:"ToggleHideMarksOnBars"}},{property:lt.hideMarksOnBars(),undoModel:s,undoText:Im,callback:e=>lt.hideMarksOnBars().setValue(e.isChecked())}),L=new en({actionId:"Chart.PriceScale.Labels.ToggleSeriesLastValueVisibility",options:{label:mm.t(null,void 0,i(10127)),
checkable:!0,checked:!1,statName:"ToggleSymbolLastValue"}},{property:n.childs().scalesProperties.childs().showSeriesLastValue,undoModel:s,undoText:Mm}),k=new en({actionId:"Chart.PriceScale.Labels.ToggleSymbolNameLabelsVisibility",options:{label:mm.t(null,void 0,i(32390)),checkable:!0,checked:!1,statName:"ToggleSymbolLabels"}},{property:n.childs().scalesProperties.childs().showSymbolLabels,undoModel:s,undoText:Am}),D=(0,t_.combineProperty)(((e,t)=>e||!1),n.childs().scalesProperties.childs().showStudyLastValue.weakReference(),n.childs().scalesProperties.childs().showFundamentalLastValue.weakReference()),E=new en({actionId:"Chart.PriceScale.Labels.ToggleIndicatorsValueLabelsVisibility",options:{label:mm.t(null,void 0,i(46850)),checkable:!0,checked:!1,statName:"ToggleStudiesAndFundamentalsPriceLabels",onDestroy:()=>{D.destroy()}}},{property:D,undoModel:s,undoText:null,callback:()=>{const e=!D.value();s.beginUndoMacro(Lm),s.setProperty(n.childs().scalesProperties.childs().showStudyLastValue,e,null),s.endUndoMacro()}}),B=(0,t_.combineProperty)(((e,t)=>e||!1),n.childs().scalesProperties.childs().showStudyPlotLabels.weakReference(),n.childs().scalesProperties.childs().showFundamentalNameLabel.weakReference()),R=new en({actionId:"Chart.PriceScale.Labels.ToggleIndicatorsNameLabelsVisibility",options:{label:mm.t(null,void 0,i(54418)),checkable:!0,checked:!1,statName:"ToggleStudiesAndFundamentalsNameLabels",onDestroy:()=>{B.destroy()}}},{property:B,undoModel:s,undoText:null,callback:()=>{const e=!B.value();s.beginUndoMacro(km),s.setProperty(n.childs().scalesProperties.childs().showStudyPlotLabels,e,null),s.endUndoMacro()}}),N=s.mainSeries().properties().childs().highLowAvgPrice.childs(),O=new en({actionId:"Chart.PriceScale.Labels.ToggleHighLowPriceLabelsVisibility",options:{label:mm.t(null,void 0,i(99479)),checkable:!0,checked:!1,statName:"ToggleHighLowPriceLabels"}},{property:N.highLowPriceLabelsVisible,undoModel:s,undoText:Dm}),F=new en({actionId:"Chart.Lines.ToggleHighLowLinesVisibility",options:{label:mm.t(null,void 0,i(33766)),checkable:!0,checked:!1,statName:"ToggleHighLowPriceLine"}},{property:N.highLowPriceLinesVisible,undoModel:s,undoText:Em}),W=new en({actionId:"Chart.PriceScale.ToggleCountdownToBarCloseVisibility",options:{label:mm.t(null,void 0,i(83140)),checkable:!0,checked:!1,statName:"ToggleCountdown"}},{property:s.mainSeries().properties().childs().showCountdown,undoModel:s,undoText:Rm}),H=new en({actionId:"Chart.PriceScale.ToggleAddOrderPlusButtonVisibility",options:{label:mm.t(null,void 0,i(71566)),checkable:!0,checked:Od.addPlusButtonProperty.value(),statName:"ToggleAddOrderPlusButton"}},{property:Od.addPlusButtonProperty,undoModel:s,undoText:Nm}),z=new nn.ActionWithStandardIcon({actionId:"Chart.Dialogs.ShowSymbolInfo",options:{label:(0,gm.appendEllipsis)(mm.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,fm.showSymbolInfoDialog)({
symbolInfo:i,showUnit:s,unitDescription:t=>t?e.description(t):"",dateFormatter:t.dateFormatter()})}}}}}),U=new Jo.Action({actionId:"Chart.PriceScale.MergeAllScalesToLeft",options:{label:mm.t(null,void 0,i(62329)),statName:"MergeAllScalesToLeft",onExecute:()=>s.mergeAllScales("left")}}),G=new Jo.Action({actionId:"Chart.PriceScale.MergeAllScalesToRight",options:{label:mm.t(null,void 0,i(55813)),statName:"MergeAllScalesToRight",onExecute:()=>s.mergeAllScales("right")}}),j=new Jo.Action({actionId:"Chart.PriceScale.MoveToLeft",options:{label:mm.t(null,void 0,i(26493)),statName:"MoveScaleToLeft",onExecute:()=>s.mergeAllScales("left")}}),q=new Jo.Action({actionId:"Chart.PriceScale.MoveToRight",options:{label:mm.t(null,void 0,i(40789)),statName:"MoveScaleToRight",onExecute:()=>s.mergeAllScales("right")}}),$=new nn.ActionWithStandardIcon({actionId:"Chart.Scales.Reset",options:{label:mm.t(null,void 0,i(75246)),iconId:"Chart.Reset",statName:"ResetChart",onExecute:()=>e.GUIResetScales(),hotkeyGroup:t,hotkeyHash:V.Modifiers.Alt+82}}),K=e.model().model().sessions().properties().childs().sessionHighlight.childs().vertlines.childs().sessBreaks.childs().visible,Y=(0,t_.createWVFromProperty)(e.model().mainSeries().isDWMProperty()),Z=new Jo.Action({actionId:"Chart.SessionBreaks.ToggleVisibility",options:{label:mm.t(null,void 0,i(66707)),checkable:!0,checked:K.value(),statName:"ToggleSessionBreaks",disabled:Y.value(),onExecute:()=>{K&&s.setProperty(K,!K.value(),Om)},onDestroy:()=>Y.destroy()}});Y.subscribe((()=>Z.update({disabled:Y.value()})));const X=new en({actionId:"Chart.Lines.ToggleSeriesPriceLineVisibility",options:{label:mm.t(null,void 0,i(72926)),checkable:!0,statName:"TogglePriceLine"}},{property:s.mainSeries().properties().childs().showPriceLine,undoModel:s,undoText:Fm}),J=new Jo.Action({actionId:"Chart.Undo",options:{label:mm.t(null,void 0,i(14804)),onExecute:()=>{(0,ne.trackEvent)("GUI","Undo"),s.undoHistory().undo()},onDestroy:()=>{e.model().undoHistory().undoStack().onChange().unsubscribeAll(J)},disabled:!0,hotkeyGroup:t,hotkeyHash:V.Modifiers.Mod+90,isRepeatAccepted:!0}});e.model().undoHistory().undoStack().onChange().subscribe(J,(()=>J.update({disabled:e.model().undoHistory().undoStack().isEmpty()})));const Q=new Jo.Action({actionId:"Chart.Redo",options:{label:mm.t(null,void 0,i(48236)),onExecute:()=>{(0,ne.trackEvent)("GUI","Redo"),e.model().undoHistory().redo()},onDestroy:()=>{e.model().undoHistory().redoStack().onChange().unsubscribeAll(Q)},disabled:!0,hotkeyGroup:t,hotkeyHash:V.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 Jo.Action({actionId:"Chart.Dialogs.ShowChangeSymbol",options:{label:(0,gm.appendEllipsis)(a.t(null,void 0,i(85124))),statName:"ChangeSymbol",onExecute:()=>{(0,Ls.showDialog)({defaultValue:"",
trackResultsOptions:{trackResults:!1,emptySearchType:"empty_result__supercharts"},enableOptionsChain:l.enabled("symbol_search_option_chain_selector")})}}}),changeInterval:wm(e),timeScaleReset:y,insertIndicator:v,compareOrAdd:S,chartProperties:b,mainSeriesPropertiesAction:w,scalesProperties:C,lineToggleLock:P,seriesHide:T,studyHide:T,lineHide:T,scaleSeriesOnly:x,drawingToolbarAction:I,stayInDrawingModeAction:M,hideAllMarks:A,showSeriesLastValue:L,showSymbolLabelsAction:k,showStudyLastValue:E,showStudyPlotNamesAction:R,showHighLowPriceLabels:O,showHighLowPriceLines:F,showCountdown:W,addPlusButton:H,showSymbolInfoDialog:z,mergeLeftScalesAction:U,mergeRightScalesAction:G,moveScaleToLeft:j,moveScaleToRight:q,chartReset:$,sessionBreaks:Z,showPriceLine:X,undo:J,redo:Q};if(o.goToDateEnabled&&(ee.gotoDate=new Jo.Action({actionId:"Chart.Dialogs.ShowGoToDate",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(54280))),statName:"GoToDate",onExecute:()=>(0,ym.showGoToDateDialog)(e.chartWidgetCollection().activeChartWidget.value()),hotkeyGroup:t,hotkeyHash:V.Modifiers.Alt+71}})),(0,l.enabled)("show_object_tree")&&(ee.paneObjectTree=new Jo.Action({actionId:"Chart.ObjectTree.Show",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(51221))),statName:"ObjectsTree",onExecute:()=>e.showObjectsTreePanelOrDialog()}})),(0,l.enabled)("property_pages")&&(ee.format=new nn.ActionWithStandardIcon({actionId:"Chart.SelectedObject.ShowSettingsDialog",options:{label:(0,gm.appendEllipsis)(mm.t(null,void 0,i(32514))),iconId:"Settings",statName:"EditSelectedObject",onExecute:()=>e.showSelectedSourcesProperties()}})),Pm&&(ee.showAverageClosePriceLabel=new en({actionId:"Chart.PriceScale.Labels.ToggleAveragePriceLabelVisibility",options:{label:mm.t(null,void 0,i(21841)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLabel"}},{property:N.averageClosePriceLabelVisible,undoModel:s,undoText:Bm}),ee.showAverageClosePriceLine=new en({actionId:"Chart.Lines.ToggleAverageLineVisibility",options:{label:mm.t(null,void 0,i(16138)),checkable:!0,checked:!1,statName:"ToggleAverageClosePriceLine"}},{property:N.averageClosePriceLineVisible,undoModel:s,undoText:Vm})),!e.readOnly()){const s=function(e){const t=Sm(e),i=new Jo.Action({actionId:"Chart.RemoveAllLineTools",options:{label:t.drawings.label,disabled:t.drawings.disabled,statName:"RemoveAllDrawingTools",onExecute:()=>e.removeAllDrawingTools()}}),s=new Jo.Action({actionId:"Chart.RemoveAllIndicators",options:{label:t.studies.label,disabled:t.studies.disabled,statName:"RemoveAllIndicators",onExecute:()=>e.removeAllStudies()}}),o=new Jo.Action({actionId:"Chart.RemoveAllIndicatorsAndLineTools",options:{label:t.all.label,disabled:t.all.disabled,statName:"RemoveAllIndicatorsAndDrawingTools",onExecute:()=>e.removeAllStudiesDrawingTools()}});return e.model().model().dataSourceCollectionChanged().subscribe(null,(()=>{const{studies:t,drawings:n,all:r}=Sm(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 Jo.Action({actionId:"Chart.ApplyIndicatorsToAllCharts",options:{label:mm.t(null,void 0,i(22437)),statName:"ApplyIndicatorsToAllCharts",onExecute:()=>e.chartWidgetCollection().applyIndicatorsToAllCharts(e)}}),ee.studyRemove=ee.lineRemove=new nn.ActionWithStandardIcon({actionId:"Chart.SelectedObject.Remove",options:{label:mm.t(null,void 0,i(67410)),iconId:"Chart.RemoveSelectedObject",statName:"RemoveSelectedObject",onExecute:()=>{(e.chartWidgetCollection().activeChartWidget.value()??e).removeSelectedSources()},hotkeyGroup:t,hotkeyHash:V.isMacKeyboard?8:46}})}return ee}var zm=i(19334),Um=i(55744);i(43882);const Gm=(0,ae.getLogger)("ChartWidget",{color:"#606"}),jm=l.enabled("chart_content_overrides_by_defaults"),qm=l.enabled("symphony_embed"),$m=new Di.TranslatedString("hide {title}",a.t(null,void 0,i(13017))),Km=new Di.TranslatedString("unlock {title}",a.t(null,void 0,i(12525))),Ym=new Di.TranslatedString("lock {title}",a.t(null,void 0,i(76104))),Zm=new Di.TranslatedString("change session",a.t(null,void 0,i(87041)));const Xm={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}},Jm=(0,li.extractThemedColors)(xs.lightTheme.content.chartProperties,xs.darkTheme.content.chartProperties);var Qm;function eg(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"}(Qm||(Qm={}))
;const tg=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","IntradayInactivityGaps@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=>tg.has(e)))}));class sg{constructor(e,t){this.activePaneWidget=null,this._model=null,this._mainDiv=null,this._parent=null,this._elTooltipDiv=null,this._paneWidgets=new F.WatchedValue([]),this._timeAxisWidget=null,this._paneSeparators=[],this._controlBarNavigation=null,this._lineToolsSynchronizer=null,this._lineToolsSynchronizerHasChanges=null,this._modelCreated=new re.Delegate,this._isDestroyed=!1,this._customLegendWidgetsFactoryMap=new Map,this._backgroundTopTheme=new F.WatchedValue("light"),this._backgroundBasedTheme=new F.WatchedValue("light"),this._backgroundBottomTheme=new F.WatchedValue("light"),this._backgroundTopColorSpawn=null,this._backgroundBottomColorSpawn=null,this._lhsAxesWidth=0,this._rhsAxesWidth=0,this._lhsPriceAxisWidthChanged=new re.Delegate,this._rhsPriceAxisWidthChanged=new re.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 re.Delegate,this._redraw=new re.Delegate,this._isVisible=new F.WatchedValue(!0),this._collapsed=new F.WatchedValue(!1),this._dataWindowWidget=null,this._resizeHandler=null,this._spinner=null,this._symbolWV=new F.WatchedValue,this._resolutionWV=new F.WatchedValue,this._actions=null,this._updateThemedColorBound=this._updateThemedColor.bind(this),this._disconnected=new re.Delegate,this._reconnectBailout=new re.Delegate,this._connected=new re.Delegate,this._chartWidgetInitialized=new re.Delegate,this._aboutToBeDestroyed=new re.Delegate,this._saveChartService=null,this._objectTreeDialogController=null,this._chartPaintedPromise=null,this._noExchangeSubscrptionWarning=null,this._paneWidgetsSharedState=new yr,this._onZoom=new re.Delegate,this._onScroll=new re.Delegate,this._availableScreen=null,this._hoveredPriceAxes=new Set,this._anyAxisHovered=new F.WatchedValue(!1),this._linkingGroupIndex=new F.WatchedValue(null),this._isHovered=new F.WatchedValue(!1),this._activeHint=null,this._eventHintDeferredPromise=null,this._warningHintDeferredPromise=null,this._setSymbolIntervalContentOverrides={},this._ariaPriceDescription=null,this._definitionsViewModel=null,this._barsButton=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._invalidationHandler=e=>{if(!(e instanceof yo.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,dt.merge)((0,dt.clone)(Xm),e),this._chartWidgetCollection=this._options.chartWidgetCollection,this._isActive=new F.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)})),this._errorRenderer=new mo(this),this._scrollHelper=new Ys(this),this._objectTreeDialogController=Es.getInstance(),this._properties=new li.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:Jm}),this._mainSeriesProperties=new _m,this._startSpinner(this._options.container.value()),this._chartSession=new am(window.ChartApiInstance),ig(),
this._isMultipleLayout=(0,Ji.combine)((e=>(0,Ct.isMultipleLayout)(e)),this._chartWidgetCollection.layout.weakReference()),this._properties.childs().scalesProperties.childs().scaleSeriesOnly.subscribe(null,(()=>{const e=this.model().model();e.recalculateAllPanes((0,Bt.viewportChangeEvent)()),e.invalidate(yo.InvalidationMask.full())})),this._hotkeys=B.createGroup({desc:"Chart actions",isDisabled:()=>!this.isActive().value()}),this._ariaPriceDescription=Qp.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 i=this._options.onCmeWidget;i&&Gm.logWarn("[ChartWidget] 'onCmeWidget' option is depricated");const s=this._options.widgetCustomer,o=this._options.timezone;let r=this._options.defSymbol??"",a=Re.Interval.isValid(this._options.defInterval)?this._options.defInterval:null;const l=this._options.defStyle;let c=(0,yt.isValidStyle)(l)?l:null;const d=this._options.defSessionId,u=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=r,this._defInterval=a,this._defTimeframe=u,this._defStyle=c,this._onWidget&&(i?this._widgetCustomer="cme":s&&(this._widgetCustomer=s)),this._compareDialog=this._chartWidgetCollection.getCompareDialogRenderer();const _=this._contentSeriesProperties();_&&(r=_.symbol,a=_.interval),void 0===this._options.useUserChartPreferences&&(this._options.useUserChartPreferences=!0);const p="chartproperties.mainSeriesProperties",m=this._options.useUserChartPreferences?(0,h.defaults)(p):(0,h.factoryDefaults)(p),g=this._mainSeriesProperties;g.merge(m);const f=a||m.interval||"D";null!==c&&(0,yt.isValidStyle)(c)||(c=(0,yt.isValidStyle)(m.style)?m.style:(0,yt.getDefaultStyle)(Re.Interval.isRange(f))),g.merge({visible:!0,symbol:r||window.DEFAULT_SYMBOL,shortName:"",timeframe:"",interval:f,currencyId:null,unitId:null,style:c,sessionId:d}),this._symbolWV.setValue(r),this._resolutionWV.setValue(f),this._containsData&&this._mainSeriesProperties.merge({showCountdown:!1}),o&&(0,Pe.timezoneIsAvailable)(o)&&this._properties.childs().timezone.setValue(o),this._options.container.subscribe((e=>{this._setElement(e)}),{callWithLast:!0});const y=()=>{this.resize()};this._options.width.subscribe(y),this._options.height.subscribe(y),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(){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(),lt.createdLineTool.unsubscribeAll(this),lt.continuedLineTool.unsubscribeAll(this),lt.cancelledLineTool.unsubscribeAll(this),lt.beenSetLineToolLastPoint.unsubscribeAll(this),lt.startedMovingLineTool.unsubscribeAll(this),lt.movedLineTool.unsubscribeAll(this),lt.finishedMovingLineTool.unsubscribeAll(this),lt.startedChangingLineTool.unsubscribeAll(this),lt.changedLineTool.unsubscribeAll(this),lt.finishedChangingLineTool.unsubscribeAll(this),lt.removedLineTool.unsubscribeAll(this),lt.finishedLineTool.unsubscribeAll(this),lt.changedLineStyle.unsubscribeAll(this),lt.restoredLineToolState.unsubscribeAll(this),lt.restoredLineTool.unsubscribeAll(this),lt.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,Js.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,Um.confirmRemovingLockedLineTools)(Um.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,Um.confirmRemovingLockedLineTools)(Um.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,Js.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,eo.isLineTool)(e)&&e.isLocked?.()));s&&s.hasChildren()?(0,Ms.showDeleteStudyTreeConfirm)((()=>{t.removeSelectedSources()})):o?(0,Um.showDeleteLockedLineToolsConfirm)(Um.DeleteLockedLineToolReason.RemoveSelected,(e=>{e||t.selectionMacro((e=>{i.filter((e=>(0,eo.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()}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,85662)),Promise.resolve().then(i.bind(i,58519))]),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,eo.isLineTool)(e)||(0,Js.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=Gs(t.map((e=>e.properties().childs()))),d=Gs(t.map((e=>e.properties().childs().intervalsVisibilities))),[{createPropertyPage:u},{getSelectionStylePropertiesDefinitions:_},{getSelectionIntervalsVisibilitiesPropertiesDefinition:p},{getSelectionCoordinatesPropertyDefinition:m}]=await Promise.all([Promise.all([i.e(6406),i.e(3889),i.e(8009),i.e(8056),i.e(8537)]).then(i.bind(i,57717)),Promise.all([i.e(6406),i.e(3889),i.e(8009),i.e(8056),i.e(8537)]).then(i.bind(i,72707)),Promise.all([i.e(6406),i.e(3889),i.e(8009),i.e(8056),i.e(8537)]).then(i.bind(i,26434)),Promise.all([i.e(6406),i.e(3889),i.e(8009),i.e(8056),i.e(8537)]).then(i.bind(i,73174))]);return async function(e){const{SourcesPropertiesEditorRenderer:t}=await Promise.all([i.e(6655),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(2564),i.e(6445),i.e(7384),i.e(3799),i.e(2197),i.e(5480),i.e(5323),i.e(1072),i.e(9325),i.e(4066),i.e(116),i.e(8985),i.e(9766),i.e(8222),i.e(4106),i.e(7444),i.e(5375),i.e(2440),i.e(9296),i.e(625),i.e(5083),i.e(9255),i.e(7935),i.e(601),i.e(422),i.e(1531),i.e(8544),i.e(3828),i.e(7519),i.e(6847),i.e(1833),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(769),i.e(9928),i.e(7223),i.e(9443),i.e(3489),i.e(6780)]).then(i.bind(i,66512)),s=new t(e);return null!==Os&&(Os.hide(),Os=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?Km:Ym).format({title:new Di.TranslatedString(t.name(),t.title(ua.TitleDisplayTarget.StatusLine))}),$r.lineToolsDoNotAffectChartInvalidation)}))}hideDataSources(e){if(e.length){const t=e.map((e=>e.properties().visible)),i=e.map((()=>!1));this.model().setProperties(t,i,$m.format({title:new Di.TranslatedString(e[0].name(),e[0].title(ua.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}paneByState(e){return this._paneWidgets.value().find((t=>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===lt.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,lt.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()===lt.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=Zs.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,Js.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,Bt.globalChangeEvent)());const i=(t,i)=>{t.paint(i);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,yo.InvalidationMask.light().invalidateForPane(e)))}else{const e=this._paneWidgets.value();e.forEach(((t,o)=>{s.push(i(t,yo.InvalidationMask.light().invalidateForPane(o))),o<e.length-1&&s.push(this._paneSeparators[o].image())}))}let n
;this._timeAxisWidget&&(this._timeAxisWidget.paint(yo.InvalidationLevel.Light),n=this._timeAxisWidget.getScreenshotData()),window.TradingView.printing=!1,this.model().selectionMacro((e=>{t.forEach((t=>{e.addSourceToSelection(t)}))})),this.model().model().recalculateAllPanes((0,Bt.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,ts.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,ts.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,vo.lastMouseOrTouchEventInfo)();if(e.isTouch){const t=this.maximizedPaneWidget()||this._paneWidgets.value()[0];if(t.hasState()&&(!e.stylus&&(this._isLineToolModeExceptBrush()||(0,
lt.toolIsMeasure)(lt.tool.value()))||this.selectPointMode().value()!==lt.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,Bt.sourceChangeEvent)(i.id()))}}}trackingModePaneWidget(){if(!(0,vo.lastMouseOrTouchEventInfo)().isTouch)return null;for(const e of this.paneWidgets())if(e.trackingModeEnabled())return e;return null}startTrackingMode(){if((0,vo.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,vo.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()!==lt.SelectPointMode.None&&this.cancelRequestSelectPoint(),this.exitTrackingMode()}setInLoadingState(e){this._inLoadingState=e}paint(e){const t=e??yo.InvalidationMask.full();t.validationActions().forEach((e=>e()));const i=this.maximizedPaneWidget();this._paneWidgets.value().forEach(((e,s)=>{null!==i&&i!==e||e.paint(t.invalidateForPane(s))})),this._timeAxisWidget&&this._timeAxisWidget.paint(t.invalidateForTimeScale()),this._redraw.fire()}GUIResetScales(){(0,ne.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,vo.lastMouseOrTouchEventInfo)().isTouch&&(e&&this.selectPointMode().value()!==lt.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}unsetActivePaneWidget(){this.activePaneWidget=null}setActivePaneWidget(e){
this.activePaneWidget=e}onPaneWidgetDestroyed(e){this.activePaneWidget===e&&(this.activePaneWidget=null)}getResizerDetacher(){return this._options}toggleFullscreen(){const e=this.getResizerDetacher();e.fullscreenable.value()&&(e.fullscreen.value()?e.exitFullscreen():e.requestFullscreen())}generalPropertiesDefinitions(){return this._getChartPropertyDefinitionsViewModel().then((e=>e.propertyPages()))}propertiesDefinitionsForSource(e){return(0,eo.isLineTool)(e)||(0,Js.isStudy)(e)||(0,eo.isStudyLineTool)(e)?e.getPropertyDefinitionsViewModel().then((e=>null===e?null:e.propertyPages())).catch((e=>(Gm.logWarn(e),null))):Promise.resolve(null)}backgroundTopTheme(){return this._backgroundTopTheme.readonly()}backgroundBasedTheme(){return this._backgroundBasedTheme.readonly()}backgroundBottomTheme(){return this._backgroundBottomTheme.readonly()}state(e,t,i,s){if(this._model){const o=this._model.state(e,t,i,s);return o.chartId=this.id(),o}return this._content}lineToolsAndGroupsDTO(){return(0,n.ensureNotNull)(this._lineToolsSynchronizer).prepareDTO()}applyLineToolUpdateNotification(e,t){(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,Js.isStudy)(e)&&!0)))return!0}return!1}widget(){return(0,n.ensureNotNull)(this._mainDiv)}restoreState(e,t,i){this._adjustSize();const s=(0,n.ensureNotNull)(this._model),o=(s.restoreState(this._content,t,i),s.mainSeries().properties().childs());this._symbolWV.setValue(o.symbol.value()),this._resolutionWV.setValue(o.interval.value())}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,ts.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(eo.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._chartSession.disconnect()}async loadContent(e,t){this.screen.show();const i=this.model()
;i.model().setMaximizedPane(null);const s=i.mainSeries();i.model().isInReplay().value()&&i.model().switchToRealtime();i.crosshairSource().clearMeasure(),this._lineToolsSynchronizer?.destroy(),this._lineToolsSynchronizer=null,this._chartSession.disconnect();const o=i.model().dataSources().filter((e=>!!(0,Js.isStudy)(e)||(0,eo.isLineTool)(e)));let n,r;new Yr.RemoveSourcesUndoCommand(i.model(),o,null).redo(),this._chartSession.connect(this._onData.bind(this)),this.activePaneWidget=null,s.purgeSymbolInfo(),e.loading=!0,await(0,eo.ensureAllLineToolsLoadedForLayout)([e]),this._content=e,this._setSymbolIntervalContentOverrides={},this._initialLoading=t;const a=this._contentSeriesProperties();if(a&&(n=a,r=e.chartProperties.priceScaleSelectionStrategyName),!n)throw Error("An error occurred while determining main series on the chart");this._mainSeriesProperties.mergeAndFire({visible:!0,symbol:n.symbol,timeframe:"",interval:n.interval||"D",style:n.style}),void 0!==r&&this._properties.childs().priceScaleSelectionStrategyName.setValue(r),this._init(),i.undoHistory().clearStack()}resetDrawingState(){(0,lt.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()!==lt.SelectPointMode.None)return this.selectPointMode().value()===lt.SelectPointMode.Replay&&this._chartWidgetCollection.getAll().forEach((e=>{e!==this&&e.selectPointMode().value()===lt.SelectPointMode.Replay&&e.cancelRequestSelectPoint()})),void this.cancelRequestSelectPoint();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()===lt.SelectPointMode.None;return t&&i&&s}}}_insertStudyOrReplaceStub(e,t,i,s,o,n){const r="java"===e.type;return new Promise((async a=>{if(0===t.length)return n?.(),r&&await(0,ts.studyMetaInfoRepository)().requestMetaInfo(),void a(this._insertOrReplaceStubByStudyImpl(e,t,i,s,o));window.runOrSignIn((async()=>{n?.(),r&&await(0,ts.studyMetaInfoRepository)().requestMetaInfo(),a(this._insertOrReplaceStubByStudyImpl(e,t,i,s,o))}),{source:"study on study"})})).catch((()=>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()!==lt.SelectPointMode.None&&this.cancelRequestSelectPoint(),o?n(o(e,i,s)):(0,Js.isSymbolicStudy)(s)?((0,
ne.trackEvent)("GUI","Confirmation dialogs","Symbol confirmation dialog"),Ns(this,e,s,n,r,"symbol")):(0,Js.hasConfirmInputs)(i)?((0,ne.trackEvent)("GUI","Confirmation dialogs","Inputs confirmation dialog"),Ns(this,e,s,n,r)):n({inputs:{},parentSources:t})}))),void 0,i);return a.then((()=>{(0,lt.hideAllIndicators)().value()&&(0,ks.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 so(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 F.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(!pm)throw new Error("LineToolsSynchronizer Class not loaded");return pm}();this._lineToolsSynchronizer=new i(t,this.model().model(),e,this._lineToolsSynchronizerHasChanges),null!==this._saveChartService&&this._lineToolsSynchronizer.setSaveChartService(this._saveChartService),this._lineToolsSynchronizer.invalidateAll(),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,Is.isColorDark)(t),n=(0,Is.isColorDark)(i),r=(0,Is.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,k.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=lt.tool.value();return(0,wt.isLineToolName)(e)&&!(0,wt.isLineDrawnWithPressedButton)(e)&&this.selectPointMode().value()===lt.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===lt.tool.value()&&(0,lt.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,fo.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:Ao.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),C=o.reduce(l,0);w=h(s,w,n),C=h(o,C,r);let P=Math.max(d-w-C,0);if(P<=102){w=0,C=0,P=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 T=p+v+g,x=u<T?0:u-T,I=x/t;let M=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-M)*a)/a:Math.round(e.stretchFactor()*I*a)/a;i=Math.max(t,2),M+=i}e.setPriceAxisSizes("left",i,s),e.setPriceAxisSizes("right",i,o),A=A||i!==e.height(),e.setSize((0,Dt.size)({width:P,height:i})),L&&e.state()&&L.setPaneHeight(e.state(),i)})),null!==this._timeAxisWidget&&this._timeAxisWidget.setSizes((0,Dt.size)({width:P,height:g}),s,o),L&&L.setWidth(P,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&&W.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()===Bi.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()};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 fr(this,e[n],r,this._paneWidgetsSharedState);if(s.push(t),n>0){const e=new Ao(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():yo.InvalidationLevel.Full,s=!!e&&e.isVisibleTimeRangeLockedOnResize();if(null!==this._timingsMeter&&this._timingsMeter.startDraw(i),i===yo.InvalidationLevel.Full&&(this._model?this._updateGui(s):this._adjustSize(s)),i>yo.InvalidationLevel.Cursor){this._timeAxisWidget?.update(),this._paneWidgets.value().forEach((e=>{e.updatePriceAxisWidgets()}));for(let i=0;i<this._paneWidgets.value().length;i++)for(const[s,o]of e.invalidateForPane(i).priceScaleRangeAnimations()){const e=this.model().model().panes()[i];if(e&&o){const i=e.getPriceScaleById(s);if(i){const s=o.getPosition(t);i.setPriceRange(s),i.updateAllViews((0,Bt.viewportChangeEvent)(e))}}}this._applyTimeScaleInvalidations(e,t),this._invalidationMask?.fullInvalidation()===yo.InvalidationLevel.Full&&(this._invalidationMask.merge(e),this._adjustSize(this._invalidationMask.isVisibleTimeRangeLockedOnResize()),this._applyTimeScaleInvalidations(this._invalidationMask,t),e=this._invalidationMask,
this._invalidationMask=null)}if(this.paint(e),this._dataWindowWidget){const t=e.maxPaneInvalidation();t===yo.InvalidationLevel.Full?this._dataWindowWidget.fullUpdate():t>yo.InvalidationLevel.None&&this._dataWindowWidget.update()}this._paneWidgets.value().forEach(((t,i)=>{t.updateStatusWidget(e.invalidateForPane(i))})),null!==this._timingsMeter&&this._timingsMeter.stopDraw(),e&&e.panesOrderInvalidated()&&W.emit("panes_order_changed")}_initMaximizeHotkey(e){const t=e=>!e.defaultPrevented&&(0,V.modifiersFromEvent)(e)===V.Modifiers.Alt&&!(0,lt.toolIsDemonstration)(lt.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(!(0,ze.onWidget)()&&!qm&&parent&&parent!==window&&parent.IS_DEMO_PAGE)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 Gm.logWarn("Incorrect mouse wheel processing: scrollPosition: "+o+", zoomScale: "+t);const r=new Bo.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,vo.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,Zs.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,yt.hasVolume)(t);if(!this.containsVolume()&&i){const t=(0,h.factoryDefaults)("chartproperties.volumePaneSize");await(0,
ts.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,Js.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,ne.trackEvent)("Chart",`Chart Style ${this.model().mainSeries().getStyleShortName().toUpperCase()}`)}_addPerfMark(e){(0,zm.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 js.ChartHotkeysListener(this,this._mainDiv),(this._options.controlBarEnabled||l.enabled("control_bar"))&&this._createControlBar(),this._options.handleScale.mouseWheel||this._options.handleScroll.mouseWheel){this._mouseWheelHelper=new To;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,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(yo.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(yo.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,...As(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 Jp(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 F.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;jm&&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.restoreState(this._content,this._containsData,e),this._setSymbolIntervalContentOverrides={},jm&&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,es.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,yt.getLastUsedSingleValueBasedStyle)(),n=(0,es.getResolutionByChartStyle)(o,i,s);t.setChartStyleWithIntervalIfNeeded(o,n)})),t.requestingStyleSupportRecovered.subscribe(null,(i=>{const s=t.interval(),o=e.model().defaultResolutions(),n=(0,es.getResolutionByChartStyle)(i,s,o);t.setChartStyleWithIntervalIfNeeded(i,n)}))})()}_addHotkeys(){if(this._hotkeys.add({desc:"Maximize",hotkey:V.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:V.isMacKeyboard?46:8,handler:()=>this.removeSelectedSources()}),this._hotkeys.add({desc:"Switch between sessions",hotkey:V.Modifiers.Shift+V.Modifiers.Alt+69,handler:()=>this._switchSubSession()});{const e=async(e,t)=>{this.activePaneWidget&&("drawRightThere"===t.action?await this.activePaneWidget.drawRightThere(e):lt.tool.setValue(e))},t=(t,i)=>()=>e(t,i);Object.entries(em.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:V.Modifiers.Mod+V.Modifiers.Alt+72,handler:()=>(0,ks.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,Zm)}_startSpinner(e){this._spinner||e&&(this._spinner=(new zs).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,Wt.disableSelection)(this._elMainTable),this._updateAndPaint()}_makeLoadingScreen(){if(l.enabled("lean_chart_load")){if(this.screen)return;this.screen=new Co(this,(0,n.ensureNotNull)(this._parent))}else this.screen?.destroy(),this.screen=new Co(this,(0,n.ensureNotNull)(this._mainDiv))}_makeAvailableOnTVPopup(){this._availableScreen||(this._availableScreen=new sm(this))}_activateSymbolSearchHotkeys(){this.readOnly()||this._options.hideSymbolSearch||(0,Ls.activateKeyPressHandler)()}_makeTimeAxisWidget(){if(this._timeAxisWidget)return void this._timeAxisWidget.updatePriceAxisStubs();const e=this.model();this._timeAxisWidget=new Tr(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))).highlightedPriceAxis(),a=r.value();(i||a.owner===t.owner)&&(r.setValue({owner:t.owner,axis:i?t.axis:null}),this.model().model().lightUpdate())}))}_updateAriaPriceDescription(e){
if(this._ariaPriceDescription&&l.enabled("aria_crosshair_price_description")){const t=this.model().mainSeries().nearestData(e.index,Yh.PlotRowSearchMode.Exact);if(!t)return;const i=t.value[4];if(!(0,dt.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,Js.isStudy)(e)));return a.reverse(),a=(0,ft.moveToHead)(a,i.mainSeries()),a.map((e=>e.title(ua.TitleDisplayTarget.StatusLine,!0,void 0,!1)))}_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 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.timeScaleInvalidations())if(0===i.type&&!i.value.finished(e)){this.model().model().setTimeScaleAnimation(i.value,i.rightOffsetPx);break}for(let i=0;i<this._paneWidgets.value().length;i++)for(const[s,o]of t.invalidateForPane(i).priceScaleRangeAnimations())if(o&&!o.finished(e)){const e=this.model().model().panes()[i];if(e){const t=e.getPriceScaleById(s);t&&e.setPriceScaleRangeAnimation(t,o)}}}null!==this._chartPaintedPromise&&(this._chartPaintedPromise.resolve(),this._chartPaintedPromise=null)}}_applyTimeScaleInvalidations(e,t){for(const i of e.timeScaleInvalidations())this._applyTimeScaleInvalidation(i,t)}_applyTimeScaleInvalidation(e,t){const i=this._model?.timeScale();if(i&&0===e.type){const s=e.value.getStartPosition()-e.value.getPosition(t),o=e.rightOffsetPx+s,n=i.width()-o,r=i.indexToCoordinate(i.baseIndex());i.startScroll(r),i.scrollTo(n),i.endScroll(),i.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,eo.initAllLineToolsFromContent)(this._content),this._init(),this._chartWidgetInitialized.fire())}async _requestMetadata(){this._addPerfMark("RequestMetadataStart"),await(0,ts.studyMetaInfoRepository)().requestMetaInfo(),this._addPerfMark("RequestMetadataEnd")}async _createControlBar(){const e=await Promise.all([i.e(2199),i.e(4178),i.e(8985),i.e(6489),i.e(9753),i.e(4170),i.e(2227),i.e(7973),i.e(5093)]).then(i.bind(i,22136));this._controlBarNavigation=new e.ControlBarNavigation(this,(0,n.ensureNotNull)(this._mainDiv),this._options.controlBar),this._model&&this._adjustSize()}_subscribeToDrawingState(){if(this.readOnly())return;(0,lt.init)();const e=(e,t)=>{const i=this._model;if(null===i)return;const s=i.model();e.model!==s&&(this._lineToolsSynchronizer?this._lineToolsSynchronizer.executeSyncedAction((()=>t(s,i))):t(s,i))};lt.createdLineTool.subscribe(this,(t=>{e(t,((e,i)=>{const s=(0,n.ensureNotNull)(e.paneForSource(e.mainSeries()));let o,r=null;if(void 0===t.pointPositionPercents){if(r=eg(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:Lr.CreateLineToolSyncMode.ForceOff,id:t.id,sharingMode:t.sharingMode});null!==l&&!Boolean(this.model().lineBeingCreated())&&t.finalState&&l.restoreExternalPoints(t.finalState,{indexesChanged:!0,pricesChanged:!0})}))})),lt.continuedLineTool.subscribe(this,(t=>{e(t,((e,i)=>{const s=eg(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})}))})),lt.cancelledLineTool.subscribe(this,(t=>{e(t,((e,t)=>{e.cancelCreatingLine()}))})),lt.beenSetLineToolLastPoint.subscribe(this,(t=>{e(t,((e,i)=>{const s=e.lineBeingCreated();if(null===s||s.linkKey().value()!==t.linkKey)return;const o=eg(e,t.model,t.point.timeStamp);if(null===o)return;const n={index:o,price:t.point.price};s.setLastPoint(n),s.updateAllViews((0,Bt.sourceChangeEvent)(s.id())),e.lightUpdate()}))})),lt.startedMovingLineTool.subscribe(this,(t=>{e(t,((e,i)=>{const s=t.linkKeys.filter(dt.notNull).map((t=>e.lineToolByLinkKey(t))).filter(dt.notNull);if(s.length){const i=eg(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)}}))})),lt.movedLineTool.subscribe(this,(t=>{e(t,((e,i)=>{
const s=e.sourcesBeingMoved().filter(eo.isLineTool).filter((e=>(e=>t.linkKeys.some((t=>e.linkKey().value()===t)))(e)));if(!s.length)return;const o=eg(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)}))})),lt.finishedMovingLineTool.subscribe(this,(t=>{e(t,((e,i)=>{const s=e.sourcesBeingMoved().filter(eo.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))}))}))})),lt.startedChangingLineTool.subscribe(this,(t=>{e(t,((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,At.point)(o,r),!0),!i)return}else{const o=s.getPoint(t.pointIndex),n=o?o.index:eg(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,i,t.pointIndex,t.envState??void 0,!0)}}))})),lt.changedLineTool.subscribe(this,(t=>{e(t,((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,At.point)(i,r),!0),!o)return}else{let i=null;if(i=t.changes.indexesChanged?eg(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)}))})),lt.finishedChangingLineTool.subscribe(this,(t=>{e(t,((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))}))})),lt.removedLineTool.subscribe(this,(t=>{e(t,((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)))}))})),lt.finishedLineTool.subscribe(this,(t=>{e(t,((e,i)=>{const s=e.lineToolByLinkKey(t.linkKey);null!==s&&(0,wt.isLineToolFinishRequiredWhenCreatedByApi)(s.toolname)&&s.finish()}))})),lt.changedLineStyle.subscribe(this,(t=>{e(t,((e,i)=>{const s=e.lineToolByLinkKey(t.linkKey)
;if(null!==s){const{zOrder:e,...i}=t.state;void 0!==e&&s.setZorder(e),(0,Ts.default)(i)||(s.restoreExternalState(i),s.propertiesChanged(!0)),t.alertId&&s.syncAlert(t.alertId)}}))})),lt.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:eg(e,t.model,i.time_t),price:i.price}))),await(0,Ro.ensureLineToolLoaded)(s.toolname),e.restoreLineToolState(s,i,!1)}}))})),lt.restoredLineTool.subscribe(this,(t=>{e(t,((e,i)=>{e.restoreSource(t.state.restorePane,t.state.paneIndex,t.state.paneState,t.state.sourceState,null)}))})),lt.copiedLineTool.subscribe(this,(async t=>{await(0,Ro.ensureLineToolLoaded)(t.linetool),e(t,((e,i)=>{const s=(0,n.ensureNotNull)(e.paneForSource(e.mainSeries()));let o;const r={...t.state,intervalsVisibilities:(0,Ch.mergeIntervalVisibilitiesDefaults)(t.state.intervalsVisibilities)},a=(0,eo.createLineToolProperties)(e.backgroundTheme().spawnOwnership(),t.linetool,!e.readOnly(),r),l=e.dataSourceForId(t.id);if(l){if(!(0,eo.isLineTool)(l))return void Gm.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 Gm.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:Lr.CreateLineToolSyncMode.ForceOff,id:t.id}),null===o)return;o.restorePositionPercents((0,n.ensureDefined)(t.pointPositionPercents))}else{const r=i=>({index:(0,n.ensureNotNull)(eg(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:Lr.CreateLineToolSyncMode.ForceOff,id:t.id});else{const e=new da({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 Bo.EnvironmentState(void 0,!0),s,!0):i.model().continueCreatingLine(e,new Bo.EnvironmentState(void 0,!0),s,!0)},_=(0,wt.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,rd.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,rd.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(1737),i.e(2227),i.e(6166)]).then(i.bind(i,5015)).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)))}_setActions(){return this._unsetActions(),this._addHotkeys(),this._actions=Hm(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,pt.isMainSeriesState)(i))return i.state??null}}return null}async _getChartPropertyDefinitionsViewModel(){if(null===this._definitionsViewModel){const e=await Promise.all([i.e(7458),i.e(3889),i.e(4482),i.e(3596)]).then(i.bind(i,61857));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 og=i(87489),ng=i(76351);const rg=!l.enabled("widget_logo")||!1;var ag;function lg(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=lg(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=lg(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.FooterTextFontSize=13]="FooterTextFontSize",e[e.Padding=10]="Padding",e[e.ChartsSpacing=5]="ChartsSpacing",e[e.FooterHeight=35]="FooterHeight",e[e.LogoHeight=15]="LogoHeight",e[e.LogoWidth=20]="LogoWidth",e[e.LogoTextMargin=3]="LogoTextMargin"}(ag||(ag={}));const cg=function(e){const t={};for(const i of Object.keys(e)){const s=lg(e[i]).relativePositions;t[i]=s}return t}(og);function hg(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=hg(r.l,t,i,s);o=e.x+e.width+Math.round(5*s)}if(null!==r.t){const e=hg(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 dg(e,t,i){const s=(new DOMParser).parseFromString(ng,"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 ug(e,t,i,s,o){e.save(),e.drawImage(s.image,t,i,s.width,s.height),
e.textBaseline="bottom";const n=(t+s.width)/o+3,r=(i+s.height)/o;(0,Wt.drawScaled)(e,o,o,(()=>{e.fillText("TradingView",n,r)})),e.restore()}function _g(e,t,i,s){return(0,Wt.drawScaled)(e,s,s,(()=>{e.fillText(i,t.x/s,t.y/s)})),e.measureText(i).width*s}function pg(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,ft.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+=_g(e,new At.Point(a,i.y),s.text,t),s.color&&e.restore(),h+=s.text.length}return l.elided&&(a+=_g(e,new At.Point(a,i.y),"...",t)),a}function mg(e){return e.map((e=>({...e,title:""})))}function gg(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 fg{constructor(e,t){this._logoTextColor=null,this._snapshotData=e,t=t||{},this._options={backgroundColor:k.themes[e.theme].getThemedColor("color-bg-primary"),borderColor:k.themes[e.theme].getThemedColor("color-border"),font:g.CHART_FONT_FAMILY,fontSize:12,legendMode:"vertical",hideResolution:!1,hideStudiesFromLegend:!1,showHeaderPublishedBy:!1,showHeaderMainSymbol:!1,...t};const i=cg[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,Dt.size)({width:i,height:s})}(e)));if(this._pixelRatio=e.hidpiRatio,this._chartsGeometry=e.charts.map(((e,t)=>hg(t,s,i,this._pixelRatio))),!rg){let i=e.theme;void 0!==t.backgroundColor&&(i="black"===(0,kt.rgbToBlackWhiteString)((0,kt.parseRgb)(t.backgroundColor),150)?oo.StdTheme.Dark:oo.StdTheme.Light),this._logoTextColor=k.themes[i].getThemedColor("color-text-primary")}this._headerDefaultTextColor=k.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=rg?Math.round(10*e):Math.round(35*e),c=i;i+=l;const h=(0,Wt.createDisconnectedCanvas)(document,(0,Dt.size)({width:t,height:i}),1),d=(0,Wt.getContext2D)(h);d.font=(0,Yt.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 At.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 At.Point(0,a))}if(null!==this._logoTextColor){const t=await dg(Math.round(20*e),Math.round(15*e),this._logoTextColor);d.fillStyle=this._logoTextColor,d.font=(0,Yt.makeFont)(13,g.CHART_FONT_FAMILY);const i=c+Math.round(l/2-t.height/2);ug(d,Math.round(10*e),i,t,e)}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 At.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(gg(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)=>{pg(e,this._pixelRatio,new At.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=pg(t,this._pixelRatio,new At.Point(a,l),e.contentWidth*this._pixelRatio,gg(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=pg(t,this._pixelRatio,new At.Point(a,l),e.contentWidth*this._pixelRatio,this._options.hideStudiesFromLegend?[]:gg(s,mg(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 yg=i(18832),vg=i(63844);function Sg(e){return`chart-widget-collection-border-${e}`}
const bg=new Di.TranslatedString("resize layout",mm.t(null,void 0,i(47418))),wg=new Di.TranslatedString("reset layout sizes",mm.t(null,void 0,i(85366)));var Cg;function Pg(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"}(Cg||(Cg={}));class Tg{constructor(e){this._selected=new ht.WatchedObject({selected:!1,withShift:!1},Pg),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,js.shiftPressed)().subscribe(this._onShiftPressed),this._selected.subscribe((e=>{if(e.selected){const t=Sg(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(t)).forEach((e=>e.classList.remove(vg.hovered)));(e.withShift?Array.from(this._state.parent.getElementsByClassName(t)):[this._splitterElement]).forEach((e=>e.classList.add(vg.hovered)))}else{const e=Sg(this._splitter.className);Array.from(this._state.parent.getElementsByClassName(e)).forEach((e=>e.classList.remove(vg.hovered)))}}))}destroy(){(0,js.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 At.Point(e.localX+this._splitterElement.offsetLeft,e.localY+this._splitterElement.offsetTop),i=(0,yg.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,yg.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 At.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(vg["i-active"]),this._state.currentLayoutResizeAction.setValue(null),t.currentState)){this._state.undoHistory.beginUndoMacro(bg),this._state.undoHistory.pushUndoCommand(new rt(this._state.sizingState,t.initialState,t.currentState,bg));const e=this._state.layoutTemplate.value().layoutType;this._state.undoHistory.pushUndoCommand(new nt((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(),wg)),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,yg.deepCopy)(s),t),this._state.sizingState.setValue(i.currentState)}_resetLayoutSizes(e){const t=(0,$i.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(wg),this._state.undoHistory.pushUndoCommand(new rt(this._state.sizingState,this._state.sizingState.value(),t,wg)),this._state.undoHistory.pushUndoCommand(new nt(s,this._state.allLayoutSizesState.get(this._state.layoutTemplate.value().layoutType),t,wg)),this._state.undoHistory.endUndoMacro()}}const xg=(0,ae.getLogger)("Chart.ChartWidgetCollection"),Ig=(a.t(null,void 0,i(40947)),a.t(null,void 0,i(55801)),a.t(null,void 0,i(32482)),function(e,t){const i=t.model().model().studyTemplate();e.undoHistory.beginUndoMacro(ss);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()}),Mg=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(!us(i,t))continue;let r;if(s.isOnMainPane)r=(0,n.ensureNotNull)(t.model().paneForSource(a.model().model().mainSeries()));else{const i=new Vi(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()},Ag=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())),
o.forEach((e=>e.applyLineToolUpdateNotification(i,s)))}finally{o.forEach((e=>e.endApplyingLineToolUpdateNotification()))}},Lg=function(e){return new qi({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()===Bi.PaneMode.Widget)return;(i?i.model().undoModel():e.activeChartWidget.value().model()).clipboardPaste(t,i)}})},kg=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},Dg=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])},Eg=function(e){let t=1;for(;e(""+t);)t++;return""+t},Bg=function(e,t,i,s){if(gs(e,t,i,s)){const i=e.crossHairSyncBroadcast;if(i){const e={type:"crosshair",payload:{point:t,envState:s,sourceUniqueId:i.uniqueId}};i.channel.postMessage(e)}}},Vg=function(e){e.crossHairSyncBroadcast?.channel.close()},Rg=function(e,t,i){if(!e.combinedTrackTimeLock.value()||e.dateRangeLock.value())return;const s=e.layoutTemplate.value().count;e.undoHistory.beginUndoMacro(os),e.chartWidgetsDefs.slice(0,s).filter((e=>e.chartWidget.hasModel()&&e.chartWidget.model().model()!==i)).forEach((e=>{const i=e.chartWidget.model().model(),s=i.mainSeries().syncModel();s&&i.syncTimeWithModel(s.syncSourceTarget(),t)})),e.undoHistory.endUndoMacro(),(0,W.emit)("sync_time",t)},Ng=function e(t){return t.chartWidgetsDefs.every((e=>e.chartWidget.hasModel()))?Promise.resolve(t.chartWidgetsDefs.map((e=>e.chartWidget))):Promise.all(t.chartWidgetsDefs.map((e=>e.chartWidget.hasModel()||Ei(e.chartWidget.modelCreated()).promise))).then((()=>e(t)))},Og=function(e){return Promise.all(e.map((e=>{const t=e.model().mainSeries();return t.symbolResolvingActive().value()?Ei(t.dataEvents().symbolResolved()).promise:t.symbolInfo()})))},Fg=async function(e,t,i){
const{theme:s,onlyActiveChart:o,restoreNonThemeDefaults:n,themeName:r,standardTheme:a,syncState:l=!0,noUndo:c}=i,h=(0,k.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 Xi(h,r,l).redo(),d.forEach((e=>{e.model().model().restoreTheme(s,n,c)}))):(e.undoHistory.beginUndoMacro(rs),a&&e.undoHistory.pushUndoCommand(new Xi(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())))},Wg=function(e,t){const{internalDateRangeLock:i,undoHistory:s,loadingContent:o}=e;o?i.setValue(t):s.setWatchedValue(i,t,cs)},Hg=function(e,t){const i=e.activeChartWidget.value();if(i&&i.hasModel()){const s=i.model();t?(e.subscribeToEventsForDateRangeSync(s),e.syncChartsDateRangesWithActiveChartRange(i)):e.unsubscribeFromEventsForDateRangeSync(s)}e.dateRangeLock.setValue(t)},zg=function(e,t){const{internalTrackTimeLock:i,undoHistory:s,loadingContent:o}=e;o?i.setValue(t):s.setWatchedValue(i,t,hs)},Ug=function(e,t){e.trackTimeLock.setValue(t)},Gg=function(e,t){const{internalIntervalLock:i,activeChartWidget:s,undoHistory:o,dateRangeLock:n,loadingContent:r,chartWidgetsDefs:a,linkingGroupsCharts:l}=e;if(t!==i.value())if(r)i.setValue(t);else{if(o.beginUndoMacro(ls),t&&t){const t=s.value();a.map((e=>e.chartWidget));l.forEach(((i,s)=>{const o=(t.linkingGroupIndex().value(),t);if(void 0!==o){(0,ki.muteLinkingGroup)(s,!0);for(const t of i.value())t!==o&&t.resolutionWV().value()!==o.resolutionWV().value()&&(t.setResolution(o.resolutionWV().value()),n.value()&&e.subscribeToCompletedEventForDateRangeSync(t,!0));(0,ki.muteLinkingGroup)(s,!1)}}))}o.setWatchedValue(i,t,ls),o.endUndoMacro()}},jg=function(e,t){e.intervalLock.setValue(t)},qg=function(e,t){const{internalSymbolLock:i,activeChartWidget:s,undoHistory:o,dateRangeLock:n,loadingContent:r,linkingGroupsCharts:a,chartWidgetsDefs:l}=e;if(t!==i.value())if(r)i.setValue(t);else{if(e.undoHistory.beginUndoMacro(as),t){const t=s.value();l.map((e=>e.chartWidget));a.forEach(((i,s)=>{const o=(t.linkingGroupIndex().value(),t);if(void 0!==o){(0,ki.muteLinkingGroup)(s,!0);for(const t of i.value())t!==o&&t.symbolWV().value()!==o.symbolWV().value()&&(t.setSymbol(o.symbolWV().value()),n.value()&&e.subscribeToCompletedEventForDateRangeSync(t,!0));(0,ki.muteLinkingGroup)(s,!1)}}))}o.setWatchedValue(i,t,as),o.endUndoMacro()}},$g=function(e,t){e.symbolLock.setValue(t)},Kg=function(e,t,i,s){let o=0;const n=(0,Qi.createWVFromGetterAndSubscriptions)((()=>++o),[i,s]);return(0,Ji.combine)((t=>e()[ms[t]]??null),t.weakReference(),n.ownership())},Yg=function(e,t){t.timeScale().visibleBarsStrictRangeChanged().subscribe(Ps(t),ws.bind(null,e))},Zg=function(e,t){t.timeScale().visibleBarsStrictRangeChanged().unsubscribeAll(Ps(t)),e.chartWidgetIdToCompletedCallbackMap.forEach((e=>{
const t=e.cw,i=e.callback;t.model().mainSeries().dataEvents().completed().unsubscribe(null,i)})),e.chartWidgetIdToCompletedCallbackMap.clear()},Xg=function(e,t){!function(e,t){const i=(0,$i.layoutInitialSizingState)(e.layoutTemplate.value().expression),s=e.layoutTemplate.value().layoutType,o=t=>t?e.allLayoutSizesState.set(s,t):e.allLayoutSizesState.delete(s);if(t)return e.sizingState.setValue(i),void o(i);e.undoHistory.beginUndoMacro(ns),e.undoHistory.pushUndoCommand(new rt(e.sizingState,e.sizingState.value(),i,ns)),e.undoHistory.pushUndoCommand(new nt(o,e.allLayoutSizesState.get(e.layoutTemplate.value().layoutType),i,ns)),e.undoHistory.endUndoMacro()}(e,t)},Jg=function(e){is.StudyMetaInfo.mergeDefaultsOverrides(e),(0,ts.studyMetaInfoRepository)().isReady()&&is.StudyMetaInfo.overrideDefaults((0,ts.studyMetaInfoRepository)().getInternalMetaInfoArray())};const Qg=new Map;var ef;function tf(e){return e.value()?1:0}!function(e){e[e.EDGE=0]="EDGE",e[e.BORDER=0]="BORDER",e[e.PADDING=2]="PADDING"}(ef||(ef={}));const sf={saveChartEnabled:!0,takeScreenshotEnabled:!0,publishedChartsEnabled:!0};class of{constructor(e){this.activeChartStyle=new F.WatchedValue,this.activeChartWidget=new F.WatchedValue,this.onAboutToBeDestroyed=new re.Delegate,this.clientId=(0,fe.randomHash)(),this._destroyed=!1,this._chartWidgetsDefs=[],this._activeIndex=0,this._globalDetachable=new F.WatchedValue,this._layoutTemplate=new F.WatchedValue,this._layoutType="s",this._layoutWV=new F.WatchedValue(this._layoutType),this._currentLayoutResizeAction=new F.WatchedValue(null),this._inlineChartsCount=new F.WatchedValue,this._selectedSources=new F.WatchedValue([]),this._lineToolsSynchronizerHasChanges=new F.WatchedValue(!1),this._viewMode=new F.WatchedValue(void 0),this._allLayoutSizesState=new Map,this._splitters=new F.WatchedValue([]),this._savedChartWidgetOptions=[],this._flags={isConfirmationAboutReplayLocked:!1,loadingChart:!1,setTimeFrameActive:!1,setNewResolution:!1},this._loadingContent=!1,this._initialLoading=!1,this._isPhoneSize=new F.WatchedValue(!1),this._sizingState=new F.WatchedValue,this._layoutSizesChangedWV=new F.WatchedValue(!1),this._symbolLock=new F.WatchedValue(!1),this._internalSymbolLock=new F.WatchedValue(this._symbolLock.value()),this._intervalLock=new F.WatchedValue(!1),this._internalIntervalLock=new F.WatchedValue(this._intervalLock.value()),this._trackTimeLock=new F.WatchedValue(!1),this._combinedTrackTimeLock=bs(this._layoutWV,this._trackTimeLock,this._chartWidgetsDefs),this._internalTrackTimeLock=new F.WatchedValue(this._combinedTrackTimeLock.value()),this._dateRangeLock=new F.WatchedValue(!1),this._internalDateRangeLock=new F.WatchedValue(this._dateRangeLock.value()),this._crosshairLock=new F.WatchedValue(d.getBool("chart.syncCrosshair",!0)),this._activeChartCanBeMoved=new F.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,B.createGroup)({desc:"Layout"}),this._saveChartService=null,this._chartStorageNotification=null,this._newsNotifier=null,this._crossHairSyncBroadcast=null,this._crossHairSyncEnabledSubscriptionId=null,this._maximizedChartDef=new F.WatchedValue(null),this._maximizedChart=new F.WatchedValue(null),this._chartWidgetCreatedDelegate=new re.Delegate,this._onZoom=new re.Delegate,this._onScroll=new re.Delegate,this._bottomToolbar=new F.WatchedValue(null),this._bottomToolbarWidget=null,this._bottomToolbarDestroyer=null,this._linkingGroupsCharts=new Map,this._chartModels=new ht.WatchedObject([],ft.compareTwoCollectionsByIds),this._customLegendWidgetsFactoriesMap=new Map,this._customSources=new Map,this._replayContainer=null,this._prevMaximizedChartDef=null,this._phoneStates=[],this._chartsSwappedDelegate=new re.Delegate,this._saveKeysPressedDelegate=new re.Delegate,this._subscribedChartWidget=null,this._tool=lt.tool.spawn(),this._hasChanges=new F.WatchedValue(!1),this._hasChangesSpawn=null,this._pendingSetSymbolCancellationToken={cancelled:!0},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._updateLinkingGroupCharts=()=>{!function(e){const t=new Map;for(const i of e.chartWidgetsDefs){const e=null;let s=t.get(e);void 0===s&&(s=[],t.set(e,s)),s.push(i.chartWidget)}for(const i of(0,ft.join)(new Set(e.linkingGroupsCharts.keys()),new Set(t.keys())))Ss(e,i).setValue(t.get(i)??[])}(this._stateImpl())},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._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()),n=this._splitters.value()??[];n.forEach(((e,t)=>{t>=o.length&&(e.splitterElement.remove(),e.mouseHandler.destroy(),e.mouseListener.destroy())}));const 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 Tg({state:this._stateImpl(),splitterElement:i,splitter:e,computeContentBox:this._computeContentBox.bind(this)
}),o=new Et.MouseEventHandler(i,s));const r=e.metrics,a=i.classList.contains(vg.hovered),l=i.classList.contains(vg["i-active"]);return i.className="",i.classList.add(vg.chartsSplitter),i.classList.add(`chart-widget-collection-border-${e.className}`),a&&i.classList.add(vg.hovered),l&&i.classList.add(vg["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 st,s=new st,o={chartWidgetCollection:e},r=new re.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&&at.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 ot(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),at.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 rt(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),at.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)({},sf,e),this._readOnly=this._options.readOnly||!1,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=>qg(this._stateImpl(),e))),this._internalSymbolLock.subscribe((e=>$g(this._stateImpl(),e))),
this._intervalLock.subscribe((e=>Gg(this._stateImpl(),e))),this._internalIntervalLock.subscribe((e=>jg(this._stateImpl(),e))),this._trackTimeLock.subscribe((e=>zg(this._stateImpl(),e))),this._internalTrackTimeLock.subscribe((e=>Ug(this._stateImpl(),e))),this._dateRangeLock.subscribe((e=>Wg(this._stateImpl(),e))),this._internalDateRangeLock.subscribe((e=>Hg(this._stateImpl(),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)})),this._widgetOptions=this._options.widgetOptions||{},this.onWidget=!!this._widgetOptions.onWidget;const t=this._options.metaInfo||{};this.metaInfo={id:new F.WatchedValue(t.id||null),name:new F.WatchedValue(t.name),description:new F.WatchedValue(t.description),username:new F.WatchedValue(t.username),uid:new F.WatchedValue(t.uid),lastModified:new F.WatchedValue(t.lastModified)};this.undoHistory.onChange().subscribe(null,(e=>{W.emit("undo_redo_state_changed",e)})),this._parent=this._options.resizerBridge.container.value(),this._parent.addEventListener("contextmenu",ut.preventDefaultForContextMenu),this._options.seriesControlBarEnabled&&this._createSeriesControlWidget(),this._chartPropertiesDialogRenderer=new mt(this),this._compareDialogRenderer=new gt(this),this._sizingState.subscribe((()=>this._updateLayout())),this._widthWV.subscribe(this._updateLayout),this._heightWV.subscribe(this._updateLayout),this._activeLinkingGroupWV=(this.activeChartWidget,new F.WatchedValue(null).spawn()),this._allLinkingGroupsWV=function(e){const t=new ht.WatchedObject((e.chartWidgetsDefs,[null])),i=()=>{t.setValue((e.chartWidgetsDefs,[null]))};e.chartWidgetsDefs.forEach((e=>e.chartWidget.linkingGroupIndex().subscribe(i)));const s=e=>{e.linkingGroupIndex().subscribe(i),i()};return e.chartWidgetCreatedDelegate.subscribe(null,s),t.spawn((()=>{e.chartWidgetsDefs.forEach((e=>e.chartWidget.linkingGroupIndex().unsubscribe(i))),e.chartWidgetCreatedDelegate.unsubscribe(null,s)}))}(this._stateImpl()),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),lt.activePointSelectionMode.setValue(e.selectPointMode().value())}
this._updateActiveChartCanBeMoved(),this._subscribeToProperties(e)}),{callWithLast:!0}),this._readOnly||(this._hotkeys.add({desc:"Switch active chart",hotkey:(0,l.enabled)("accessible_keyboard_shortcuts")?B.Modifiers.Shift+39:9,handler:()=>this.switchChart(!1)}),this._hotkeys.add({desc:"Switch active chart",hotkey:(0,l.enabled)("accessible_keyboard_shortcuts")?B.Modifiers.Shift+37:ct.Modifiers.Shift+9,handler:()=>this.switchChart(!0)})),this._hotkeys.add({desc:"Fullscreen mode",hotkey:B.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:B.Modifiers.Alt+83,handler:this.takeServerScreenshot.bind(this)}),(0,He.isOnMobileAppPage)("any")||(this._hotkeys.add({desc:"Download client screenshot",hotkey:B.Modifiers.Mod+B.Modifiers.Alt+83,handler:_s.bind(this,this)}),this._hotkeys.add({desc:"Copy client screenshot",hotkey:B.Modifiers.Mod+B.Modifiers.Shift+83,handler:ps.bind(this,this)}))),this._options.saveChartEnabled&&this._hotkeys.add({desc:"Save Chart Layout",hotkey:B.Modifiers.Mod+83,handler:()=>this._saveKeysPressedDelegate.fire()}),this._clipboardHandler=Lg(this._stateImpl()),this.clipboard=this._clipboardHandler,this._options.globalEvents&&this._clipboardHandler.listen(),this._leftBottomChartWidget=Kg(this.getAll.bind(this),this._layoutWV.readonly(),this._chartsSwappedDelegate,this._chartWidgetCreatedDelegate),this.loadContent(this._options.content,!0),this._layoutWV.subscribe((()=>this._updateActivityView())),this._inlineChartsCount.subscribe(this._updateActiveChartCanBeMoved),this._readOnly&&(this._layoutWV.writeLock=!0),window.addEventListener("resize",this._updateLayout);let i=0;const s=()=>{--i,0===i&&W.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)}}))})),Ng(this._stateImpl()).then(Og).then((()=>{window.saver&&window.is_authenticated&&this._options.widgetOptions.justCloned&&window.saver.saveChartSilently()})).catch(xg.logError.bind(xg))}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._splitters.value().forEach((e=>{e.mouseHandler.destroy(),e.mouseListener.destroy()})),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),Vg(this._stateImpl())}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 Ct.layouts||(e="s");const t=this._layoutType,i=Ct.layouts[e].count;W.emit("layout_about_to_be_changed",e),(this._splitters.value()??[]).forEach(((e,t)=>{e.splitterElement.remove(),e.mouseHandler.destroy()})),this._splitters.setValue([]);const s=Ct.layouts[e];this._layoutTemplate.setValue(s);const o=this._allLayoutSizesState.get(s.layoutType)??(0,$i.layoutInitialSizingState)(s.expression);this._allLayoutSizesState.set(s.layoutType,o),this._sizingState.setValue(o);const r=this._maximizedChartDef.value();t!==e&&this._maximizedChartDef.value()&&this._maximizedChartDef.setValue(null),r&&this.activeChartWidget.setValue((0,n.ensureNotNull)(r.chartWidget));for(let e=0;e<i||e<this._chartWidgetsDefs.length;e++){let t,s=this._chartWidgetsDefs[e];const o=e>=i;if(t=this._maximizedChartDef.value()?this._maximizedChartDef.value()===s:e<i,t){if(s){if(this._parent.insertBefore(s.container.value(),this._bottomToolbar.value()),s.hiddenInLayout.setValue(!1),this._loadingContent){const e=this._savedChartWidgetOptions.shift();e&&await(0,n.ensureNotNull)(s.chartWidget).loadContent(e.content,this._initialLoading)}}else this._addNewChartWidget(e,void 0),s=this._chartWidgetsDefs[e];s.container.value().classList.toggle("multiple",i>1),s.fullscreen.setValue(this._maximizedChartDef.value()===s),s.collapsed.setValue(o)}else s&&(this._hideChart(s),s.collapsed.setValue(o))}this._sizingState.setValue(o),this._updateLayout(),this._layoutWV.setValue(e),this._setLayoutType(e),this._updateWatchedValue(),this._updateInlineChartsCount(),this._checkAllPendingModelsAlreadyCreated(),
this._inlineChartsCount.value()<1&&i>0&&this._chartWidgetsDefs[i-1].rdState.bridge().attach()}setChartStyleToWidget(e,t){return ys.call(this,e,t)}state(e,t,i,s,o){let n=o?this.getAll().indexOf(this.activeChartWidget.value()):0;const r=o?n+1:this._chartsCountToSave(),a=[];for(;n<r;n++){const o=this._getStateForChartImpl(n,e,t,i,s);if(o){let e=o;0,a.push(e)}}const l=o?void 0:Array.from(this._allLayoutSizesState.entries()).reduce(((e,[t,i])=>(e[t]=i,e)),{});return{name:this.metaInfo.name.value(),layout:o?"s":this._layoutType,charts:a,symbolLock:tf(this._symbolLock),intervalLock:tf(this._intervalLock),trackTimeLock:tf(this._trackTimeLock),dateRangeLock:tf(this._dateRangeLock),crosshairLock:tf(this._crosshairLock),layoutsSizes:l,studyMetaInfoMap:undefined}}applyLineToolUpdateNotification(e,t,i){Ag.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)}setResolution(e,t,i){return vs(this._stateImpl(),e,t,i)}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)}setChartLayoutWithUndo(e){return async function(e,t,i){return i=fs(0,i),e.layoutWV.value()!==i&&(e.undoHistory.pushUndoCommand(new Yi(t,i)),!0)}(this._stateImpl(),this,e)}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,k.getCurrentTheme)().name,charts:[this.activeChartWidget.value().images(e)],publishedBy:s};const n=[],r=Ct.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,k.getCurrentTheme)().name,charts:n,publishedBy:s}}clientSnapshot(e={}){const t={hideResolution:Boolean(e.hideResolution)};return async function(e,t){return new fg(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){Bg(this._stateImpl(),e,t,i)}syncScroll(e,t){Rg(this._stateImpl(),e,t)}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 bt(this,e);return W.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?bt:St,s=await i(this,e);return W.emit("onScreenshotReady",s),t||W.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),await this.loadContent(e.chartWidgetCollectionState),this.unloadUnusedCharts(),this.undoHistory.clearStack(),W.emit("layout_loaded")}saveLayoutState(){return new Promise(((e,t)=>{this._saveChartService?.saveChartOrShowTitleDialog((()=>{}),e,t)}))}async loadContent(e,t){if(xg.logNormal("Loading layout content"),this.getAll().forEach((e=>e.onAboutToLoadContent())),this._loadingContent=!0,this._initialLoading=Boolean(t),this._savedChartWidgetOptions.splice(0),lt.init(),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;t.charts.forEach((e=>{e.chartId&&i.add(e.chartId)})),t.charts.forEach((e=>{if(!e.chartId){const t=Eg((e=>i.has(e)));i.add(t),e.chartId=t}}));let s=t.layout;if(!(0,Ct.isSupportedLayout)(s)){const e=(0,Ct.tryGuessingTheMostSuitableLayout)(s);xg.logError(`Loading unsupported layout ${s}. Force migration to ${e}`),s=e}this._layoutType=this._checkProFeature(s||"s");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,dt.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))}this._maximizedChartDef.setValue(null),await this.setLayout(this._layoutType),this._tool.subscribe(this._onToolChanged.bind(this)),this._tool.subscribe(this._updateCrossHairPositionIfNeeded.bind(this)),this._loadingContent=!1,this._initialLoading=!1}applyOverrides(e){
for(let t=0;t<this._chartWidgetsDefs.length;t++)this._chartWidgetsDefs[t].chartWidget.applyOverrides(e)}applyStudiesOverrides(e){Jg(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 Fg(this._stateImpl(),this,e)}applyIndicatorsToAllCharts(e){Ig(this._stateImpl(),e)}applyIndicatorsToAllChartsAvailable(){return!this._readOnly&&this._actualLayoutCount()>1}async applyIndicatorToAllCharts(e,t,i,s){await Mg(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()}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?"":_t.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 kg(this._stateImpl())}resetLayoutSizes(e){Xg(this._stateImpl(),e)}unloadUnusedCharts(){const e=this._chartWidgetsDefs.splice(Ct.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);xt.getInstance().updateChartDescription(e,t,this._layoutType)}}chartModels(){return this._chartModels.readonly()}_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,crosshairLockRaw:this._crosshairLock.value(),crossHairSyncBroadcast:this._crossHairSyncBroadcast,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,setLayoutType:this._setLayoutType.bind(this),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),chartWidgetCreatedDelegate:this._chartWidgetCreatedDelegate,sizingState:this._sizingState,currentLayoutResizeAction:this._currentLayoutResizeAction,allLayoutSizesState:this._allLayoutSizesState,splitters:this._splitters,widgetOptions:this._widgetOptions,bottomToolbar:this._bottomToolbar,replayContainer:this._replayContainer,layoutSizesChanged:this._layoutSizesChangedWV,subscribeToCompletedEventForDateRangeSync:this._subscribeToCompletedEventForDateRangeSync.bind(this),subscribeToEventsForDateRangeSync:e=>Yg(this._stateImpl(),e),unsubscribeFromEventsForDateRangeSync:e=>Zg(this._stateImpl(),e),syncChartsDateRangesWithActiveChartRange:this._syncChartsDateRangesWithActiveChartRange.bind(this),combinedTrackTimeLock:this._combinedTrackTimeLock,chartWidgetIdToCompletedCallbackMap:Qg,flags:this._flags,linkingGroupsCharts:this._linkingGroupsCharts,chartModels:this._chartModels,updateLinkingGroupCharts:this._updateLinkingGroupCharts.bind(this),hideChart:this._hideChart.bind(this),addNewChartWidget:this._addNewChartWidget.bind(this)}}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(6822),i.e(3703),i.e(3953),i.e(9258),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(7384),i.e(2197),i.e(6489),i.e(4353),i.e(3362),i.e(7001),i.e(3745),i.e(1252),i.e(2227),i.e(2544),i.e(653),i.e(7260)]).then(i.bind(i,68426));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 re.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 fs(this._stateImpl(),e)}_actualLayoutCount(){return Ct.layouts[this._layoutType].count}_setMaximized(e){this._maximizedChartDef.value()!==e&&(this._maximizedChartDef.setValue(e),this.setLayout(this._layoutType))}_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(),W.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 Dg(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()&&Zg(this._stateImpl(),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()&&(Yg(this._stateImpl(),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();return t.chartId=Eg((e=>this._alreadyHasId(e))),t.shouldBeSavedEvenIfHidden=!1,t.panes.forEach((e=>{e.sources.forEach((e=>{(0,pt.isLineToolState)(e)&&!e.linkKey&&(e.alertId=void 0)}))})),{content:t}}}_onIdeaClickedHandler(e){0}_barsMarksContainersFactory(e){const t=[];{const i=new Li(e);t.push(i);const s=new vi(e);t.push(s)}return t}_getLinkingGroupCharts(e){e=null;let t=this._linkingGroupsCharts.get(e);return void 0===t&&(t=new ht.WatchedObject([],ft.compareTwoCollectionsByIds),this._linkingGroupsCharts.set(e,t)),t}_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 F.WatchedValue(!0),container:new F.WatchedValue(i),width:new F.WatchedValue,height:new F.WatchedValue,collapsed:new F.WatchedValue(!1),hiddenInLayout:new F.WatchedValue(!1),visible:new F.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 F.WatchedValue,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=()=>{(0,n.ensureNotNull)(s.chartWidget).setCollapsed(s.collapsed.value())},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):Eg((e=>this._alreadyHasId(e))),h=s.chartWidget=new sg(t,c);this._saveChartService&&h.setSaveChartService(this._saveChartService),t.containsData?h.finishInitWithoutConnect():h.connect(),h.withModel(null,(()=>{const e=h.model().model();this._customSources.forEach(((t,i)=>{e.addCustomSource(i,t.factory,t.layer)}))})),this._updateWatchedValue(),this._updateActivityView();const d=t?.content?.linkingGroup??null;h.linkingGroupIndex().setValue(d),h.linkingGroupIndex().subscribe(this._updateLinkingGroupCharts);const u=this._getLinkingGroupCharts(d).value();return u.length>0&&(this._symbolLock.value()&&h.setSymbol(u[0].symbolWV().value()),this._intervalLock.value()&&h.setResolution(u[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=()=>{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()},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()}))}));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(Qg.has(i))return;const s=()=>{Qg.has(i)&&(Qg.delete(i),this._syncChartsDateRangesWithActiveChartRange(t?e:void 0))};e.model().mainSeries().dataEvents().completed().subscribe(null,s,!0),Qg.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,yt.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);Qg.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,yt.isTimeBasedStyle)(s.model().mainSeries().style())&&setTimeout(this._chartWidgetGotoTimeRange.bind(null,s,c,h))}}_chartWidgetGotoTimeRange(e,t,i){e.model().model().gotoTimeRange(t,i),W.emit("sync_date_range",t,i)}_hideChart(e){e.hiddenInLayout.setValue(!0);const t=e.container.value();t.parentNode&&t.parentNode.removeChild(t),e.fullscreen.setValue(!1)}_setLayoutType(e){this._layoutType=e}_updateInlineChartsCount(){const e=this._layoutTemplate.value().count;this._inlineChartsCount.setValue(e),this._globalDetachable.setValue(e>1)}_getStateForChartImpl(e,t,i,s,o){const n=this.innerState();if(e<n.chartWidgetsDefs.length){const r=n.chartWidgetsDefs[e].chartWidget;return e<n.actualLayoutCount()||r.shouldBeSavedEvenIfHidden()?r.state(t,i,s,o):null}const r=n.savedChartWidgetOptions[e-n.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,wt.isLineToolName)(e.type))))};var t})))}):r;var a,l}_chartsCountToSave(){return this._actualLayoutCount()}}var nf=i(9726);const rf=["LineToolTrendLine","LineToolRay","LineToolInfoLine","LineToolExtended","LineToolRegressionTrend","LineToolRotatedRectangle","LineToolParallelChannel","LineToolFlatBottom","LineToolDisjointAngle","LineToolPitchfork","LineToolSchiffPitchfork","LineToolSchiffPitchfork2","LineToolInsidePitchfork","LineToolVertLine","LineToolCrossLine","LineToolHorzLine","LineToolHorzRay","LineToolTrendAngle"];function af(e,t=!1,s=!1){if(!l.enabled("popup_hints"))return()=>{};const o=e.getContainer();let r=null,c=null;return lt.tool.subscribe(h),lt.createdLineTool.subscribe(null,u),lt.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{const e=ct.isMacKeyboard?"⌘":"Ctrl";m(a.t(null,void 0,i(81712)).format({key:e}),"hint.startFocusedZoom")}}))),()=>{lt.tool.unsubscribe(h),lt.createdLineTool.unsubscribe(null,u),lt.finishedLineTool.unsubscribe(null,_),e.layoutSizesChanged().unsubscribe(p),c?.()};function h(){const e=lt.tool.value(),t=ze.CheckMobile.any();if(s&&t&&(o=e,rf.includes(o)))return void async function(){0}();var o;if(!g("hint.touchPainting"))return;const n=(0,wt.isLineToolDrawWithoutPoints)(e);!(0,wt.isStudyLineToolName)(e)||"LineToolRegressionTrend"===e||n||t?(0,wt.isLineToolName)(e)&&!(0,wt.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=lt.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=lt.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=lt.tool.value();Promise.all([i.e(1737),i.e(2227),i.e(6166)]).then(i.bind(i,5015)).then((i=>{r=new i.ChartEventHintRenderer(o),s===lt.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}}var lf=i(51243),cf=i.n(lf),hf=i(58519);class df{constructor(e){this._toolbarThemeChanged=new re.Delegate,this._onWatchedThemeChanged=e=>{this._toolbarThemeChanged.fire(e)},this._opts=e,D.watchedTheme.subscribe(this._onWatchedThemeChanged)}destroy(){D.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,hf.loadTheme)(this._opts.chartWidgetCollection,{themeName:e,standardTheme:!0,syncState:t,noUndo:i})}setStdThemeForLayout(e,t=!0){(0,D.setTheme)(e),t&&(0,k.syncTheme)()}getCurrentThemeName(){return(0,k.getCurrentTheme)().name}toolbarThemeChanged(){return this._toolbarThemeChanged}}function uf(e){return e in _f}const _f={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 pf=new re.Delegate;var mf=i(78749),gf=i(9447);class ff{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 yf=new Di.TranslatedString("change timezone",a.t(null,void 0,i(20137)));class vf{constructor(e){this._onTimezoneChanged=new re.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,yf)}onTimezoneChanged(){return this._onTimezoneChanged}}class Sf{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 bf(e){return{id:e.id(),name:(t=e.toolname,Object.keys(_f).find((e=>_f[e].name===t))||null)};var t}function wf(e){return{id:e.id(),name:e.metaInfo().description}}const Cf=new Di.TranslatedString("change pane height",a.t(null,void 0,i(14691)));class Pf extends tt.UndoCommand{constructor(e,t,i){super(Cf),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 Tf{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,Js.isStudy)(t)?wf(t):(0,eo.isLineTool)(t)?bf(t):null}(e,t))).filter(dt.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 Pf(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 Sf(this._chartWidget.model(),e),this._priceScales.set(e,t)),t}}var xf=i(56530);function If(e){return void 0===e.inputs?[]:e.inputs.map((e=>({...e,id:e.id,localizedName:void 0!==e.name?(0,xf.getTranslatedInputTitle)(e.name):""})))}function Mf(e){const t={};if(e.defaults){const i=(0,hc.default)(e.defaults);t.defaults=i}return void 0!==e.plots&&(t.plots=(0,hc.default)(e.plots)),void 0!==e.styles&&(t.styles=(0,hc.default)(e.styles)),void 0!==e.bands&&(t.bands=(0,hc.default)(e.bands)),void 0!==e.filledAreas&&(t.filledAreas=(0,hc.default)(e.filledAreas)),void 0!==e.palettes&&(t.palettes=(0,hc.default)(e.palettes)),t}var Af=i(58137);class Lf{constructor(e,t){this._onStudyCompleted=new re.Delegate,this._onStudyError=new re.Delegate,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._study.onStatusChanged().subscribe(this,(e=>{switch(e.type){case yh.StudyStatusType.Completed:
this._onStudyCompleted.fire();break;case yh.StudyStatusType.Error:this._onStudyError.fire()}}))}isUserEditEnabled(){return this._study.userEditEnabled()}setUserEditEnabled(e){this._study.setUserEditEnabled(e)}getInputsInfo(){return If(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,dt.isObject)(i)?i.v:i}}))}getStyleInfo(){return Mf(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 na(this._model,this._study,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._study)&&new ra(this._model,this._study,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._study)&&new ia(this._model,this._study,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._study)&&new ta(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 Sf(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 Zl(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 Xl(this._model,this._study,i,this._model.mainSeries().priceScale(),null).redo();break;case"new-left":new Zl(this._model,this._study,i,"left",null).redo();break;case"new-right":new Zl(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=Or(this._study,r,this._model),l=oh(this._study,r,this._model);new Xl(this._model,this._study,i,r,null).redo(),null!==a&&new $l(this._model,r,a,null).redo(),null!==l&&new Kl(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,mf.applyOverridesToStudy)(this._study,e)}hasPlots(){return this._study.metaInfo().plots.length>0}dataLength(){return this._study.status().type!==yh.StudyStatusType.Completed?0:this._study.metaInfo().plots.length>0?this._study.data().size():this._model.mainSeries().bars().size()}isLoading(){const e=this._study.status();return e.type===yh.StudyStatusType.Undefined||e.type===yh.StudyStatusType.Loading}hasError(){return this._study.status().type===yh.StudyStatusType.Error}hasPendingUnresolvedSymbols(){return this._study.hasPendingUnresolvedSymbols()}anyGraphicsReady(){return!(0,Af.isStudyGraphicsEmpty)(this._study.graphics())}graphicsViewsReady(){return this._study.graphicsViewsReady()}properties(){return this._study.properties()}setProperties(e){this._study.properties().mergeAndFire(e)}async applyToEntireLayout(){const e=new sn.ActionsProvider(this._chartWidget),t=(await e.contextMenuActionsForSources([this._study],(0,n.ensureNotNull)(this._chartWidget.model().paneForSource(this._study)))).find((e=>"applyStudyToEntireLayout"===e.id));t&&t.execute()}status(){return{...this._study.status()}}title(){return this._study.title(ua.TitleDisplayTarget.StatusLine)}symbolsResolved(){return this._study.symbolsResolved()}study(){return this._study}}const kf=new Map([["LineToolBezierQuadro",3],["LineToolBezierCubic",4]]);function Df(e){const t=kf.get(e.toolname);if(void 0!==t)return t;const i=e.pointsCount();return-1===i?e.points().length:i}function Ef(e){return"LineToolRiskRewardLong"===e||"LineToolRiskRewardShort"===e}const Bf=["alwaysShowStats","entryPrice","inputs.first bar time","inputs.last bar time","interval","linesWidths","points","snapTo45Degrees","stopPrice","symbol","symbolStateVersion","currencyId","unitId","targetPrice","zOrderVersion"];class Vf{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(){return this._source.properties().state(Bf)}setProperties(e,t){(0,li.allowSavingDefaults)(!!t),this._source.properties().mergeAndFire(e),(0,li.allowSavingDefaults)(!1)}getPoints(){let e=this._source.points();const t=Df(this._source);return e.length>t&&((0,n.assert)(Ef(this._source.toolname)),e=e.slice(0,t)),this._pointsConverter.dataSourcePointsToPriced(e)}setPoints(e){if(this._source.isFixed())return;const t=Df(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),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,{...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,{...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 Rf{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 na(this._model,this._series,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._series)&&new ra(this._model,this._series,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._series)&&new ia(this._model,this._series,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._series)&&new ta(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 Zl(this._model,this._series,this._pane(),"right",null).redo()}detachToLeft(){new Zl(this._model,this._series,this._pane(),"left",null).redo()}detachNoScale(){new Zl(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 Zl(this._model,this._series,t,"left",null).redo();break;case"new-right":new Zl(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 Zl(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 Xl(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()[Nf(e)].state():this._series.properties().childs()[Nf(e)].state(["inputs","inputsInfo"])}setChartStyleProperties(e,t){this._series.properties().childs()[Nf(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()}}isLoading(){return this._series.isLoading()}isInReplay(){return this._series.isInReplay()}data(){return this._series.data()}priceScale(){return new Sf(this._undoModel,this._series.priceScale())}seriesErrorMessage(){return this._series.seriesErrorMessage()}compositeStatusVW(){return this._series.compositeStatusVW()}properties(){return this._series.properties()}lastConfirmedBarUTCTime(){
return this._series.bars().last()?.value[0]??null}_pane(){return(0,n.ensureNotNull)(this._model.paneForSource(this._series))}}function Nf(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 Of=i(32112);function Ff(e,t){const{symbolChanged:i,currencyChanged:s,unitChanged:o,styleChangeRequiresRestart:n}=e.compareSymbolParams(t);return!(i||s||o||n)}function Wf(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),(Ff(e,o)||e.seriesSource().symbolInstanceId()===i)&&t(!1)},r=()=>{s.error().unsubscribe(null,n),(Ff(e,o)||e.seriesSource().symbolInstanceId()===i)&&t(!0)};s.completed().subscribe(null,n,!0),s.error().subscribe(null,r,!0)}class Hf{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,ci.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,eo.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,eo.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,eo.isLineTool)(e)))&&this._controller.canBeGroupped(t)}_groupById(e){return this._controller.groups().find((t=>t.id===e))}}var zf=i(76032);const Uf=new Di.TranslatedString("change price to bar ratio",a.t(null,void 0,i(2509))),Gf=new Di.TranslatedString("toggle lock scale",a.t(null,void 0,i(49695)));function jf(e,t){return t.map((t=>(0,n.ensureNotNull)(e.dataSourceForId(t))))}class qf{constructor(e,t){this._visibleBarsChanged=new re.Delegate,this._crosshairMoved=new re.Delegate,this._dataSourceHovered=new re.Delegate,this._ranges=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._chartWidget=e,this._activateChart=t,this._timezoneApi=new vf(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._widgetLinkingGroupIndex=e.linkingGroupIndex().spawn(),this._widgetLinkingGroupIndex.subscribe((e=>this._apiLinkingGroupIndex.setValue(e))),this._apiLinkingGroupIndex=new F.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 G_(o,e,null,s).redo():i.setScaleRatioProperty(o,e,Uf)}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 lc({lockScale:e},o,null,s).redo():i.setPriceScaleMode({lockScale:e},o,Gf)}id(){return this._chartWidget.id()}
onDataLoaded(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().completed())}onSymbolChanged(){return this._makeSubscriptionFromDelegate(this._chartWidget.model().mainSeries().dataEvents().symbolResolved())}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,dt.isFunction)(t)&&(t={dataReady:t});const{dataReady:i,doNotActivateChart:s}=t||{};if(e===this.symbol()||this._chartWidget.hasModel()&&this._chartWidget.model().mainSeries().symbolSameAsResolved(e))return i?.(),!0;s||this._activateChart();const o=await this._chartWidget.chartWidgetCollection().setSymbol(e,void 0,this._chartWidget);return o&&Wf(this._chartWidget.model().mainSeries(),(e=>{!e&&i&&i()})),o}async setResolution(e,t){(0,dt.isFunction)(t)&&(t={dataReady:t});const{dataReady:i,doNotActivateChart:s}=t||{},o=Re.Interval.normalize(e);if(null===o||o===this.resolution())return i?.(),!0;s||this._activateChart();const n=await this._chartWidget.chartWidgetCollection().setResolution(o,void 0,this._chartWidget);return n&&Wf(this._chartWidget.model().mainSeries(),(e=>{!e&&i&&i()})),n}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 Wf(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(bf).filter((e=>null!==e.name))}getAllStudies(){return this._chartWidget.model().model().allStudies(!0).map(wf)}getStudyTemplateSnapshot(e,t,i){return(0,zf.getStudyTemplateSaveData)(e,this._chartWidget.model().model(),t,i)}getStudyTemplateDescString(){const e=(0,zf.getStudyTemplateMetaInfo)(this._chartWidget.model().model());return(0,zf.getStudyTemplateDescString)(e.indicators)}applyStudyTemplateByRecord(e){if(!e)return;const t=t=>this._chartWidget.model().applyStudyTemplate(JSON.parse(t.content),e.name);e.is_default?G.backend.getStandardStudyTemplateById(e.id,t):G.backend.getStudyTemplateById(e.id).then(t)}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=jf(this._chartWidget.model().model(),e);return this._chartWidget.model().availableZOrderOperations(t)}sendToBack(e){const t=jf(this._chartWidget.model().model(),e);this._chartWidget.model().sendToBack(t)}bringToFront(e){const t=jf(this._chartWidget.model().model(),e);this._chartWidget.model().bringToFront(t)}bringForward(e){const t=jf(this._chartWidget.model().model(),e);this._chartWidget.model().bringForward(t)}sendBackward(e){const t=jf(this._chartWidget.model().model(),e);this._chartWidget.model().sendBackward(t)}insertAfter(e,t){const i=this._chartWidget.model().model(),s=jf(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=jf(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,ts.studyMetaInfoRepository)().findAllJavaStudies(),a=is.StudyMetaInfo.findStudyMetaInfoByDescription(r,e);if(n.checkLimit){const e=this._chartWidget.model().canCreateStudy({id:a.id});if(!e.success)return(0,Ar.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,mf.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 Rf(t,e)}createShape(e,t){return this.createMultipointShape([e],t)}async createMultipointShape(e,t){const i=()=>new Error(`Cannot create "${s.shape}" shape`),s=Object.assign({},{filled:!0},t),o=_f[s.shape]||_f.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),h=this._convertUserPointsToDataSource(e);if(null===h||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,Ro.ensureLineToolLoaded)(o.name);const d=(0,eo.createLineToolProperties)(r.backgroundTheme().spawnOwnership(),o.name,!r.readOnly());if((0,eo.prepareLineToolPropertiesByOwnerSource)(d,l),s.overrides)for(const e in s.overrides)d.hasChild(e)?(0,
n.ensureDefined)(d.child(e)).mergeAndFire(s.overrides[e]):Ef(o.name)&&-1!==["profitLevel","stopLevel"].indexOf(e)&&d.addProperty(e,s.overrides[e]);let u;void 0!==d.hasChild("text")&&s.text&&(0,n.ensureDefined)(d.child("text")).setValue(s.text),d.hasChild("filled")&&s.filled&&(0,n.ensureDefined)(d.child("filled")).setValue(!0),u=s.disableUndo?this._chartWidget.model().model():this._chartWidget.model();const _=u.createLineTool({pane:c,point:h[0],linetool:o.name,properties:d,ownerSource:l});if(null===_)throw d.destroy(),i();if(_.properties()!==d&&d.destroy(),Ef(o.name)){if(h.length>2)throw new Error(`Wrong points count for ${s.shape}. Required 1 or 2`);2===h.length&&(_.startChanging(1,h[1]),_.setPoint(1,h[1]),_.endChanging(!0,!1))}else{const e=_.pointsCount();if(e!==h.length&&-1!==e)throw new Error(`Wrong points count for ${s.shape}. Required ${e}`);const t=new Bo.EnvironmentState(void 0,!0),i=(0,wt.isLineDrawnWithPressedButton)(o.name);for(let e=1;e<h.length&&this._chartWidget.model().lineBeingCreated();e++)_.setLastPoint(h[e]),u.continueCreatingLine(h[e],t,e<h.length-1||i);(0,wt.isLineToolFinishRequiredWhenCreatedByApi)(o.name)&&(_.finish(),u.finishLineTool(_),u.continueCreatingLine(h[h.length-1],t,!1))}if(s.lock&&_.setUserEditEnabled(!1),s.disableSelection&&_.setSelectionEnabled(!1),s.disableSave&&(void 0===_.customization&&(_.customization={}),_.customization.disableSave=!0),s.hasOwnProperty("showInObjectsTree")&&(void 0===_.customization&&(_.customization={}),_.customization.showInObjectsTree=s.showInObjectsTree),s.zOrder){const e=this._chartWidget.model().availableZOrderOperations([_]);"top"===s.zOrder&&e.bringToFrontEnabled?u.bringToFront([_]):"bottom"===s.zOrder&&e.sendToBackEnabled&&u.sendToBack([_])}return _.id()}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?new Yr.RemoveSourcesUndoCommand(this._chartWidget.model().model(),[i],null).redo():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 Of.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,lt.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}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)),i.e(9498).then(i.bind(i,99992)).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()}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 Hf(this._chartWidget.model().lineToolsGroupController(),this._chartWidget.model().model())}isSelectBarRequested(){return this._chartWidget.selectPointMode().value()!==lt.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(0,gf.barTimeToEndOfPeriod)(t.barBuilder,e,t.intervalObj)}endOfPeriodToBarTime(e){const t=this._prepareEndOfPeriodArgs();return(0,gf.endOfPeriodToBarTime)(t.barBuilder,e,t.intervalObj)}createAnchoredShape(e,t){const i=()=>new Error(`Cannot create "${t.shape}" shape`),s=t.shape;if(uf(s)&&!0!==_f[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._convertPositionPercentToPricedPoint(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 sg.prototype}ranges(){throw new Error("not implemented")}getTimeScale(){return new ff(this._chartWidget.model().timeScale())}async loadChartTemplate(e){await(0,hf.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,ts.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 is.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()}intradayInactivityGaps(){return this._chartWidget.model().model().intradayInactivityGaps()}setIntradayInactivityGapsSession(e){this._chartWidget.model().model().setIntradayInactivityGapsSession(e)}_destroy(){this._chartWidget.hasModel()&&(this._chartWidget.model().crosshairSource().moved().unsubscribeAll(this),this._chartWidget.model().timeScale().logicalRangeChanged().unsubscribe(this,this._onLogicalRangeChanged)),this._widgetLinkingGroupIndex.destroy()}async _createTradingPrimitive(e){const t=this._chartWidget.model(),i=t.model(),s=(0,n.ensureNotNull)(i.paneForSource(i.mainSeries()));await(0,Ro.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};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)}_convertPositionPercentToPricedPoint(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()),r=i.indexToTimePoint(n);if(null===r)return null;return{price:s.coordinateToPrice(e.y*s.height(),o),time:r}}_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,dt.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}_convertTimeFromPublic(e){return this._getTimeConverter().convertPublicTimeToInternalTime(e)}_getTimeConverter(){const e=this._chartWidget.model().mainSeries();return(0,Kn.getChartWidgetApiTimeConverter)(e.interval(),(0,n.ensureNotNull)(e.symbolInfo(),"main series symbol info"),this._chartWidget.model().model())}_onHoveredSourceChanged(e){const t=null!==e&&(0,Fn.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,Bt.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 rd.SessionInfo(t,i.session,i.session_holidays,i.corrections);return{barBuilder:(0,rd.newBarBuilder)(s,o,o),intervalObj:Re.Interval.parse(s)}}_getPaneApi(e){let t=this._panes.get(e);return void 0===t&&(t=new Tf(e,this._chartWidget),this._panes.set(e,t)),t}_getStudyApi(e){let t=this._studies.get(e);return void 0===t&&(t=new Lf(e,this._chartWidget),this._studies.set(e,t)),t}_getLineDataSourceApi(e){let t=this._lineDataSources.get(e);return void 0===t&&(t=new Vf(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,Md.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,dt.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`)}}var $f=i(52092);class Kf{loginRequired(){throw new Error("Not implemented")}onGoProDialog(e,t){throw new Error("Not implemented")}}function Yf(){throw new Error("not implemented")}class Zf extends Kf{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._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._magnetEnabledWatchedValue=null,this._magnetModeWatchedValue=null,this._drawOnAllCharts=(0,ye.convertPropertyToWatchedValue)((0,lt.drawOnAllCharts)()),this._replayApi=null,this._pineEditorApi=null,this._backtestingStrategyApi=null,this._supportTicketData=null,this._activeChangedChangedDelegate=new re.Delegate,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._activeChangedChangedDelegate.fire()})),W.subscribe("toggle_currency_menu_inner",((...e)=>{this._toggleUnitConversionMenu("toggle_currency_menu",...e)}),this),W.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,(0,lt.properties)().childs().magnet.unsubscribeAll(this),(0,lt.properties)().childs().magnetMode.unsubscribeAll(this),W.unsubscribeAll("toggle_currency_menu_inner",this),W.unsubscribeAll("toggle_unit_menu_inner",this)}themes(){return null===this._themesApi&&(this._themesApi=new df({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){W.subscribe(e,t,void 0)}unsubscribe(e,t){W.unsubscribe(e,t,void 0)}onActiveChartChanged(){return this._activeChangedChangedDelegate}webview(){return Yf(),this._webview}connect(){Yf()}disconnect(){Yf()}onConnectionStatusChanged(e){Yf()}isConnected(){Yf()}supportTicketData(){return this._supportTicketData}setPublishChartOptions(e){Yf()}publishChart(e){Yf()}studyTemplatesDrawerApi(){Yf()}fontIconsSettingsDrawer(){Yf()}
intervalsService(){Yf()}alertService(){Yf()}supportedChartTypes(){return this._supportedChartStylesSpawn}setBrokerName(e){this._chartWidgetCollection.setBroker(e)}getDrawOnAllCharts(){return(0,lt.drawOnAllCharts)().value()}drawOnAllCharts(e){return(0,lt.drawOnAllCharts)().setValue(e)}drawOnAllChartsEnabled(){return this._drawOnAllCharts}getDrawOnAllChartsMode(){return(0,lt.drawOnAllChartsMode)().value()}drawOnAllChartsMode(e){(0,lt.drawOnAllChartsMode)().setValue(e)}currencies(){return this._chartApiInstance?.availableCurrencies()??Promise.reject()}units(){return this._chartApiInstance?.availableUnits()??Promise.reject()}disableTrackingEvents(){(0,ne.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){Yf()}chart(e=0){if(e<0||e>=this.chartsCount())throw Error("Incorrect index: "+e);return this._getChartWidgetApi(this._chartWidgetCollection.getAll()[e])}activeChart(){return this._getChartWidgetApi(this._activeChartWidget())}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(){Yf()}async backtestingStrategyApi(){Yf()}pineEditorApi(){Yf()}activeChartIndex(){return this._chartIndex(this._activeChartWidget())}chartsCount(){return Ct.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(){Yf()}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")}unloadUnusedCharts(){throw new Error("Unsupported. This API is only applicable to the Trading Edition of the library")}moveActiveChart(e){this._chartWidgetCollection.moveActiveChartWithUndo(e)}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){if(!uf(e))return;const i=_f[e].name;if("icon"===e){const e=t?.icon;void 0!==e&&lt.iconTool.setValue(e)}if(await(0,eo.initLineTool)(i),"emoji"===e){const e=t?.emoji;void 0!==e&&lt.emojiTool.setValue(e)}if("sticker"===e){const e=t?.sticker;void 0!==e&&lt.stickerTool.setValue(e)}lt.tool.setValue(i)}favoriteDrawingsToolbar(){return i.e(5551).then(i.bind(i,17072)).then((e=>(this._favoriteDrawingsToolbar||(this._favoriteDrawingsToolbar=new e.FavoriteDrawingsApi),this._favoriteDrawingsToolbar)))}
sharingChart(){return this._sharingChartService}watchlist(){Yf()}setWatchlistApiPromise(e){Yf()}news(){Yf()}setNewsApiPromise(e){Yf()}widgetbar(){Yf()}setWidgetbarApiPromise(e){Yf()}getChartStorage(){return getChartStorage()}setDebugMode(e){l.setEnabled("charting_library_debug_mode",e)}setFeatureEnabled(e,t){"chart_crosshair_menu"!==e?l.setEnabled(e,t):Od.addPlusButtonProperty.setValue(t)}magnetEnabled(){return null===this._magnetEnabledWatchedValue&&(this._magnetEnabledWatchedValue=new F.WatchedValue((0,lt.properties)().childs().magnet.value()),this._magnetEnabledWatchedValue.subscribe((e=>{(0,li.allowSavingDefaults)(!0),(0,lt.properties)().childs().magnet.setValue(e),(0,li.allowSavingDefaults)(!1)})),(0,lt.properties)().childs().magnet.subscribe(this,(()=>{(0,n.ensureNotNull)(this._magnetEnabledWatchedValue).setValue((0,lt.properties)().childs().magnet.value())}))),this._magnetEnabledWatchedValue}magnetMode(){return null===this._magnetModeWatchedValue&&(this._magnetModeWatchedValue=new F.WatchedValue((0,lt.properties)().childs().magnetMode.value()),this._magnetModeWatchedValue.subscribe((e=>{(0,li.allowSavingDefaults)(!0),(0,lt.properties)().childs().magnetMode.setValue(e),(0,li.allowSavingDefaults)(!1)})),(0,lt.properties)().childs().magnetMode.subscribe(this,(()=>{(0,n.ensureNotNull)(this._magnetModeWatchedValue).setValue((0,lt.properties)().childs().magnetMode.value())}))),this._magnetModeWatchedValue}flushBufferedData(){pf.fire()}chartWidgetCollectionState(...e){return this._chartWidgetCollection.state(...e)}chartWidgetCollectionSeriesStatuses(){return this._chartWidgetCollection.chartSeriesStatuses()}initAllLineTools(){const e=Array.from(wt.simpleLineToolNames).concat(["LineToolAnchoredVWAP","LineToolRegressionTrend","LineToolAnchoredVolumeProfile","LineToolFixedRangeVolumeProfile","LineToolVbPFixed","LineToolRiskRewardLong","LineToolRiskRewardShort"]);return Promise.all(e.map((e=>(0,eo.initLineTool)(e)))).then((()=>{}))}watermark(){{const e=i_.getInstance();if(!e.ready())throw new Error("Watermark API is not initialised yet.");return e}}setContextMenuOptions(e){Zf.setContextMenuOptions(e)}changeSymbol(e,t,i){de.linking.interval.setValue((0,n.ensureNotNull)(Re.Interval.normalize(t))),de.linking.setSymbolAndLogInitiator(e,"API"),i&&this.activeChart().onDataLoaded().subscribe(null,i,!0)}closePopupsAndDialogs(){Oo.ContextMenuManager.hideAll(),W.emit($f.CLOSE_POPUPS_AND_DIALOGS_COMMAND)}startFullscreen(){return this._chartWidgetCollection.startFullscreen()}exitFullscreen(){return this._chartWidgetCollection.exitFullscreen()}getFavoriteChartStylesService(){Yf()}getFavoriteIntervalsService(){Yf()}getFavoriteCurrencyUnitConversionApi(){Yf()}getIntervals(){let e=[];const t=(0,es.getCustomResolutions)();return null!==this._chartApiInstance&&(e=this._chartApiInstance.defaultResolutions()),(0,es.mergeResolutions)(e,t)}getLinetoolsFavoritesStore(){Yf()}getSavedCharts(e){G.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 If(is.StudyMetaInfo.findStudyMetaInfoByDescription((0,n.ensureNotNull)(this._chartApiInstance).allStudiesMetadata(),e))}getStudyStyles(e){return Mf(is.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)),await this._chartWidgetCollection.loadContent(e.json),this._chartWidgetCollection.unloadUnusedCharts(),this._chartApiInstance?.connect(),de.linking.setSymbolAndLogInitiator(this.activeChart().symbol(),"API"),W.emit("chart_loaded")}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){Yf()}lockAllDrawingTools(){return null===this._lockDrawingsWatchedValue&&(this._lockDrawingsWatchedValue=new F.WatchedValue((0,lt.lockDrawings)().value()),this._lockDrawingsWatchedValue.subscribe((e=>{(0,lt.lockDrawings)().setValue(e)})),(0,lt.lockDrawings)().subscribe(this,(()=>{(0,n.ensureNotNull)(this._lockDrawingsWatchedValue).setValue((0,lt.lockDrawings)().value())}))),this._lockDrawingsWatchedValue}hideAllDrawingTools(){return null===this._hideDrawingsWatchedValue&&(this._hideDrawingsWatchedValue=new F.WatchedValue((0,lt.hideAllDrawings)().value()),this._hideDrawingsWatchedValue.subscribe((e=>{(0,lt.hideAllDrawings)().setValue(e)})),(0,lt.hideAllDrawings)().subscribe(this,(()=>{(0,n.ensureNotNull)(this._hideDrawingsWatchedValue).setValue((0,lt.hideAllDrawings)().value())}))),this._hideDrawingsWatchedValue}hideAllIndicators(){return null===this._hideIndicatorsWatchedValue&&(this._hideIndicatorsWatchedValue=new F.WatchedValue((0,lt.hideAllIndicators)().value()),this._hideIndicatorsWatchedValue.subscribe((e=>{(0,lt.hideAllIndicators)().setValue(e)})),(0,lt.hideAllIndicators)().subscribe(this,(()=>{(0,n.ensureNotNull)(this._hideIndicatorsWatchedValue).setValue((0,lt.hideAllIndicators)().value())}))),this._hideIndicatorsWatchedValue}logs(){return{getLogHistory:ae.getLogHistory,enable:ae.loggingOn,disable:ae.loggingOff}}mainSeriesPriceFormatter(){return this._chartWidgetCollection.activeChartWidget.value().model().mainSeries().priceScale().formatter()}onContextMenu(e){W.subscribe("onContextMenu",(t=>{t.callback(e(t.unixtime,t.price))}),void 0)}onGrayedObjectClicked(e){W.subscribe("onGrayedObjectClicked",e,void 0)}removeChartFromServer(e,t){
G.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(_f),t=lt.tool.value();for(let i=0;i<e.length;++i)if(_f[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(){Yf()}setMultichartMode(){Yf()}setDateRangeLinkingEnabled(e){this._chartWidgetCollection.lock.dateRange.setValue(e)}studyMetaIntoRepository(){return(0,ts.studyMetaInfoRepository)()}deferredStudiesReady(){return bh.ready()}hasPendingStudiesModuleLoading(){return(0,Js.hasPendingStudiesModuleLoading)()}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,q.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,q.showWarning)({title:e.title,text:e.body||"",onClose:e.callback})}showSupportDialog(){Yf()}showSaveAsChartDialog(){const e=this._saveChartService;e&&window.runOrSignIn((()=>{e.saveChartAs()}),{source:"Save as chart dialogue"})}showRenameChartDialog(){Yf()}saveChartOrShowTitleDialog(e,t,i){Yf()}showCreateAlertDialog(){Yf()}createGoProDialog(e){Yf()}setUserInfo(e){Yf()}openMobileChartPicker(){Yf()}closeMobileChartPicker(){Yf()}takeClientScreenshot(e){return this._chartWidgetCollection.clientSnapshot(e)}takeScreenshot(){return this._chartWidgetCollection.takeScreenshot()}trading(){Yf()}waitTrading(){Yf()}viewMode(){Yf()}viewModeWatchedValue(){Yf()}async dummyBrokerController(){return Promise.reject("Not implemented")}pineLibApi(){return Yf(),{saveNew,saveNext,requestBuiltinScripts}}resetCache(){window.ChartApiInstance.resetCache()}static setContextMenuOptions(e){void 0!==e.items_processor&&Oo.ContextMenuManager.setCustomItemsProcessor(e.items_processor),void 0!==e.renderer_factory&&Oo.ContextMenuManager.setCustomRendererFactory(e.renderer_factory)}_getChartWidgetApi(e){let t=this._chartWidgets.get(e);return void 0===t&&(t=new qf(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 W.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&&W.emit(e,t,a,l,o)
}}i(42924),i(23863);var Xf=i(78136),Jf=i(73772);var Qf=i(64034),ey=i(70893),ty=i(50946);i(25043);const iy={customBrandingTradingViewText:Lt.colorsPalette["color-brand"],customBrandingText:Lt.colorsPalette["color-cold-gray-850"],background:Lt.colorsPalette["color-cold-gray-900"],shadow:Lt.colorsPalette["color-cold-gray-700"],text:Lt.colorsPalette["color-white"],staticTextBackground:(0,Is.generateColor)(Lt.colorsPalette["color-cold-gray-800"],20),logo:Lt.colorsPalette["color-white"],platformBgColor:Lt.colorsPalette["color-cold-gray-900"],platformFgColor:Lt.colorsPalette["color-cold-gray-200"]},sy={customBrandingTradingViewText:Lt.colorsPalette["color-brand"],customBrandingText:Lt.colorsPalette["color-cold-gray-850"],background:Lt.colorsPalette["color-white"],shadow:Lt.colorsPalette["color-cold-gray-150"],text:Lt.colorsPalette["color-cold-gray-900"],staticTextBackground:(0,Is.generateColor)(Lt.colorsPalette["color-white"],20),logo:Lt.colorsPalette["color-cold-gray-900"],platformBgColor:Lt.colorsPalette["color-white"],platformFgColor:Lt.colorsPalette["color-cold-gray-900"]};const oy=new Map([["logo-old-style",ty],["tradingview-old-style",ey]]),ny=l.enabled("adaptive_logo"),ry=l.enabled("small_no_display"),ay=l.enabled("38914"),ly="site_branding",cy="widget_branding",hy="widget_referral_branding",dy="widget_custom_branding",uy="widget_custom_no_powered_branding",_y="fundamental_branding",py="fundamental_custom_branding",my="fundamental_custom_no_powered_branding",gy="library_branding",fy="library_custom_branding",yy="library_custom_no_powered_branding",vy=navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("edge"),Sy=window.urlParams||{},by=window.initData||{};Sy.no_referral_id&&enable(Sy.referral_id||"","aggressive");const wy=a.t(null,void 0,i(98856)),Cy=ay?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 Py;!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"}(Py||(Py={}));(0,ze.onWidget)();class Ty extends hd.CustomSourceBase{constructor(e,t,i){super(e,t),this._canvasWidth=0,this._paneHeight=0,this._left=13,this._bottom=36,this._layout=ly,this._needToShow=!0,this._showBranding=!1,this._customLogoSrc="",this._customLogoLink="",this._tradingviewLogoLinkToPath="",
this._cubicBezier=new Mr.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!==dy&&this._layout!==py||(this._left=8,this._bottom=5);const o=()=>{this._needToShow?this._showBranding=!0:this._showBranding=!1};this._resizeHandlerDelayed=(0,cc.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!==uy&&this._layout!==my)return[];if(!this._visible.value())return[];if(this._layout===ly&&!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!==uy&&this._layout!==my&&(this._powBy.hitTest(e)||this._custom&&this._custom.hitTest(e))){const e=!0;return new Vt.HitTestResult(Vt.HitTarget.Custom,{hideCrosshairLinesOnHover:!0,cursorType:e?qt.PaneCursorType.Pointer:qt.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({ar_AE:"ar",de_DE:"de",en:"www",es:"es",ca_ES:"es",fr:"fr",he_IL:"il",
id:"id",in:"in",it:"it",ja:"jp",kr:"kr",ms_MY:"my",pl:"pl",br:"br",ru:"ru",th_TH:"th",tr:"tr",uk:"uk",vi_VN:"vn",zh_CN:"cn",zh_TW:"tw"}[e]||"www")+".tradingview.com"}((by.querySettings?.locale??by.currentLocaleInfo?.language)||"en");let t=new URL(e);if(this._customLogoLink)return this._customLogoLink;if(this._layout===gy||this._layout===fy){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;Sy.utm=!0,(0,Wt.drawScaled)(e,t.horizontalPixelRatio,t.verticalPixelRatio,(()=>{if(this._powBy&&this._powBy.show){i=this._powBy.height,e.save();const s=new At.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 At.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 ky(this._layout,e?.name||"",this._model,(()=>this._model.fullUpdate())),this._custom=new Dy(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(Sy.logo)||{};e.image?(this._customLogoSrc=e.image,this._customLogoLink=e.link,this._needToShow=l.enabled("widget_logo"),l.enabled("link_to_tradingview")?this._layout=fy:this._layout=yy):(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,Er.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,Er.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===ly)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 xy(e){return!ry||e>480}function Iy(e){return!ny||e>500}let My={},Ay={};class Ly{constructor(){this._topLeftPoint=null,this._hitTestHeight=null}hitTest(e){const t=this._getHitTestBox();if(t)return(0,Nt.pointInBox)(e,t)}_getHitTestBox(){const e=this._topLeftPoint;if(e){const{x:t,y:i}=e;return(0,At.box)(e,new At.Point(t+this.width,i+(this._hitTestHeight??this.height)))}}}class ky extends Ly{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 ${g.CHART_FONT_FAMILY}`,this._txt="TradingView",this._maximizedAnimationTextWidth=0,this._logoWidth=0,this._textWidthCache=new jt.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===cy,this._alwaysMaximized=l.enabled("logo_always_maximized")||this._model.isSnapshot()&&!ze.CheckMobile.any()||!1,this._fontSize=this._showAnimatedBranding||this._layout===hy?11:14,this._showAnimatedBranding||this._layout!==dy&&this._layout!==py||(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&&xy(s)&&(e=new At.Point(e.x+r,e.y-a)),this._topLeftPoint=e,t.translate(e.x,e.y);const{horizontalPixelRatio:l,verticalPixelRatio:c}=i;(0,Qf.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===dy||this._layout===py){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(xy(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 At.Point(Math.round((o-i)/2)-1+n,Math.floor((o-r)/2)+1);this._drawLogoImage(t,a,e.logoImage);const l=Iy(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=Iy(s);e&&(t.save(),t.translate(vy?-.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 At.Point(Math.round((n-d)/2)-1+r,Math.floor((n-u)/2)+1);if(o){const t=new At.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(){Ay={},My={},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,Wt.createDisconnectedCanvas)(document,(0,
Dt.size)({width:0,height:0})),t=(0,Wt.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()?iy:sy}_getLogoImage(e){return function(e,t,i,s,o){const r=Ay,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)(oy.get(c)))),textImage:e(u((0,n.ensureDefined)(oy.get(h)))),proBadgeImage:d?e(u((0,n.ensureDefined)(oy.get(d)))):void 0};return r[a]=_,_}(No.svgRenderer,this._model.dark().value()?"dark":"light",e,0,this._showTradeWithLogo)}_checkLayout(){switch(this._layout){case cy:case hy:case dy:case _y:case py:case fy:case gy:case ly:this.show=!0;break;case uy:case my:case yy:this.show=!1}switch(this._layout){case gy:this._needDisplayImage=!0,this._txt=wy;break;case fy:this._txt=Cy}}_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,Ft.drawRoundRect)(e,t-1,i-1,s+2,o+2,n),e.fillStyle=this._backgroundShadowFillStyle(),e.fill(),e.closePath(),e.restore(),e.save(),(0,Ft.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 Dy extends Ly{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 dy:case uy:case py:case my:case fy:case yy:this.show=!0;break;case ly:case cy:case hy:case _y:case gy:this.show=!1}}}var Ey=i(4454),By=i(94664);class Vy{constructor(e,t){this._headerToolbar=e,this._dropdownId=t}applyOptions(e){this._headerToolbar.updateDropdown(this._dropdownId,e)}remove(){this._headerToolbar.removeDropdown(this._dropdownId)}}var Ry=i(38119);class Ny{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 Oy{symbol(e){return new Ny(this._model().getSymbolCustomStatus(e))}hideAll(){this._model().hideAll()}static getInstance(){return null===this._instance&&(this._instance=new Oy),this._instance}_model(){return Ry.CustomStatusModel.getInstance()}}Oy._instance=null;var Fy=i(19291),Wy=i(15754);var Hy=i(27514),zy=i(25931),Uy=i(43222);(0,L.setClasses)();const Gy=(0,r.getChartingLibraryGlobalContext)(),jy=(0,r.getChartingLibraryOwner)(),qy=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 F.WatchedValue(!0),fullscreenable:new F.WatchedValue(!0),container:new F.WatchedValue(t),width:new F.WatchedValue,height:new F.WatchedValue,availWidth:new F.WatchedValue,availHeight:new F.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),$y=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=Ge(e);je(s.negotiations.width,t)||(s.negotiations.width=t,this.recalculate())},negotiateHeight:e=>{if(!s.canNegotiate.height)return;const t=Ge(e);je(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 F.WatchedValue,height:new F.WatchedValue,availWidth:new F.WatchedValue,availHeight:new F.WatchedValue,alive:new F.WatchedValue(!0),container:new F.WatchedValue(i),visible:new F.WatchedValue(!0),fullscreen:new F.WatchedValue(!1),fullscreenable:new F.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 P=Boolean(d&&(_||S));if(this._container.classList.toggle("layout-with-border-radius",P),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=P&&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}
}(qy.allocate()),Ky=(jy.brokerFactory,Boolean(!1)),Yy=Gy.urlParams;Gy.DEFAULT_SYMBOL=Yy.symbol??"";const Zy=new AbortController,Xy=jy.getCustomIndicators,Jy=(0,me.createDeferredPromise)(),Qy=(0,me.createDeferredPromise)(),ev=(0,me.createDeferredPromise)(),tv=l.enabled("left_toolbar"),iv=l.enabled("library_custom_color_themes"),sv=JSON.parse(Yy.widgetbar),ov=l.enabled("right_toolbar")&&(sv.watchlist||sv.details||sv.news||sv.datawindow||l.enabled("dom_widget")||l.enabled("order_panel")||l.enabled("show_object_tree")||l.enabled("bugreport_button")),nv=l.enabled("header_widget")?$y.allocate({areaName:"top"}):null,rv=tv?$y.allocate({areaName:"left"}):null,av=$y.allocate({areaName:"center"}),lv=(ov&&$y.allocate({areaName:"right"}),null);if(void 0!==jy.contextMenu&&Zf.setContextMenuOptions(jy.contextMenu),Promise.all([Jy.promise,Qy.promise,ev.promise]).then((()=>{Gy.ChartApiInstance.start()})),"function"==typeof Xy){const e=Xy({Std:Jf.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 Jy.resolve();const t=Gy.JSServer;t.studyLibrary.push.apply(t.studyLibrary,e),Jy.resolve(),console.log("{0} custom indicators loaded.".format(e.length))})).catch((e=>{console.warn("Error loading custom indicators "+e),Jy.resolve()})):(console.warn("custom_indicators_getter should be a function that returns a Promise object"),Jy.resolve())}else Jy.resolve();Gy.widgetReady=e=>{W.subscribe("onChartReady",e,null)};const cv=Yy.theme?.toLowerCase()??oo.StdTheme.Light;var hv;function dv(e){Gy.__defaultsOverrides=Gy.__defaultsOverrides||{},(0,ge.deepExtend)(Gy.__defaultsOverrides,e),void 0!==TradingView.defaultProperties&&void 0!==TradingView.defaultProperties.chartproperties&&((0,h.applyDefaultsOverrides)(TradingView.defaultProperties.chartproperties),(0,h.applyDefaultOverridesToLinetools)())}hv=cv,k.themes[hv]&&(0,D.setTheme)(hv),async function(e){if(!iv||void 0===e)return;try{const{overrideStandardThemes:t}=await i.e(2413).then(i.bind(i,57626));t(e)}catch(e){console.error("Error applying custom themes",e)}}(jy.customThemes).then(ev.resolve).catch(ev.resolve),Gy.applyStudiesOverrides=e=>{e&&(Gy.chartWidgetCollection?Gy.chartWidgetCollection.applyStudiesOverrides?.(e):is.StudyMetaInfo.mergeDefaultsOverrides(e))},Gy.applyOverrides=e=>{dv(e),Gy.chartWidgetCollection&&Gy.chartWidgetCollection.applyOverrides(e)},Gy.doWhenApiIsReady=e=>{Gy.tradingViewApi?e():Qy.promise.then(e)},Gy.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];null!==lv&&lv.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}})}))},Gy.changeTheme=(e,t)=>{const i=k.themes[e.toLowerCase()];return i?Gy.tradingViewApi.themes().setStdTheme(i.name,!0,t&&t.disableUndo):Promise.resolve()},Gy.getTheme=()=>Gy.tradingViewApi.themes().getCurrentThemeName(),Gy.customThemes=async()=>{if(!iv)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,20688))).CustomThemesApi)},Gy.is_authenticated=!1;JSON.parse(Gy.urlParams.brokerConfig);a.t(null,void 0,i(94566)),a.t(null,void 0,i(92800)),a.t(null,void 0,i(44676));let uv=null;const _v=(0,me.createDeferredPromise)();let pv;const mv=()=>{if(l.setEnabled("charting_library_export_chart_data",!Gy.configurationData.is_tradingview_data),l.setEnabled("charting_library_debug_mode","true"===Yy.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!=Yy.studiesOverrides&&is.StudyMetaInfo.mergeDefaultsOverrides(JSON.parse(Yy.studiesOverrides)),(0,n.assert)(void 0===TradingView.defaultProperties,"Default properties are inited before applying overrides"),dv(JSON.parse(Yy.overrides));const e=Yy.numeric_formatting?JSON.parse(Yy.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])),Gy.ChartApiInstance=new(cf())(jy.datafeed);const t=jy.customFormatters;t&&(t.timeFormatter&&(_e.customFormatters.timeFormatter=t.timeFormatter),t.dateFormatter&&(_e.customFormatters.dateFormatter=t.dateFormatter),t.tickMarkFormatter&&(_e.customFormatters.tickMarkFormatter=t.tickMarkFormatter),t.priceFormatterFactory&&(_e.customFormatters.priceFormatterFactory=t.priceFormatterFactory),t.studyFormatterFactory&&(_e.customFormatters.studyFormatterFactory=t.studyFormatterFactory)),jy.customTimezones&&Ee.instance().addTimezones(jy.customTimezones),Gy.ChartApiInstance.setStudiesAccessController(Gy.ChartApiInstance.createStudiesAccessController(Yy.studiesAccess));const s=Yy.chartContent?JSON.parse(Yy.chartContent).json:void 0,r=Yy.chartContentExtendedData?JSON.parse(Yy.chartContentExtendedData):s?s.extendedData:void 0,c=Yy.interval||"D",h=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(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:l.toUpperCase(),type:"period-back"},targetResolution:c.value(),requiresIntraday:c.isIntraday()}}))}(JSON.parse(Yy.timeFrames)),d={resizerBridge:av,padding:l.enabled("border_around_the_chart")?2:0,content:s,widgetOptions:{addToWatchlistEnabled:!1,hideIdeas:!0,addVolume:(0,n.ensureDefined)(Gy.ChartApiInstance.studiesAccessController).isToolEnabled("Volume"),muteSessionErrors:!0,timezone:Yy.timezone,defSymbol:Yy.symbol??"",defInterval:s?"":c,compareSymbols:Yy.compareSymbols&&JSON.parse(Yy.compareSymbols),defTimeframe:(u=jy.timeframe,u?"string"==typeof u?u:{...u,type:"time-range"}:u),paneContextMenuEnabled:l.enabled("pane_context_menu"),paneContextMenu:{mainSeriesTrade:Ky},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:Yy.time_scale&&JSON.parse(Yy.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!==_t.STATUS_DELAYED&&t!==_t.STATUS_DELAYED_STREAMING&&t!==_t.STATUS_EOD&&t!==_t.STATUS_READY)return[];return h.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,fullscreenButtonEnabled:!0,mobileChangeLayoutEnabled:!1},globalEvents:!0,snapshotUrl:Yy.snapshotUrl,mobileForceChartMaximizeEnabled:!1,saveChartEnabled:l.enabled("save_shortcut")};var u;tv&&((0,nf.createFavoriteDrawingToolbar)(),d.widgetOptions.isDrawingToolbarVisible=x.isDrawingToolbarVisible),r&&(d.metaInfo={id:r.uid,name:r.name,description:r.description,uid:r.uid,username:""}),jy.additionalSymbolInfoFields&&(0,Ey.setAdditionalSymbolInfoFields)(jy.additionalSymbolInfoFields);const _=jy.symbolSearchComplete;_&&(0,By.setSymbolSearchCompleteOverrideFunction)(_);const p=Gy.chartWidgetCollection=new of(d);let m=!1;p.onAboutToBeDestroyed.subscribe(null,(()=>{m=!0}),!0),function(e){e.addCustomSource("branding",((t,i)=>{const s=(0,Ji.combine)(((e,t)=>{const s=e??t;return null!==s&&s.hasModel()&&s.model().model()===i}),e.maximizedChartWidget().weakReference(),e.leftBottomChartWidget().weakReference());return new Ty(t,i,s.ownership())}),Eo.CustomSourceLayer.Topmost)}(p),Gy.studyMarket=new pe(p),Je.registerService(Xe.CHART_WIDGET_COLLECTION_SERVICE,p),p.activeChartWidget.subscribe((e=>{W.emit("activeChartChanged",p.getAll().indexOf(e))})),Gy.saver=new O.ChartSaver(p);const g=new J(p,Gy.saver);p.setSaveChartService(g);const f=new oe(p);Gy.chartWidget=p.activeChartWidget.value(),Gy.pro=new TradingView.Pro;const y=function(e){if(!nv)return null;const t=new A.ChartChangesWatcher(e.chartWidgetCollection,Gy.saver,W),s=JSON.parse(Yy.favorites);s.intervals=s.intervals.map((e=>{let t=""+e;return t.match(/1[DWMYdwmy]/)&&(t=t.slice(1)),t})),l.enabled("study_templates")&&(pv=new he({chartWidgetCollection:e.chartWidgetCollection}));let o;const n=Yy.header_widget_buttons_mode;"fullsize"===n&&(o=["full"]);"compact"===n&&(o=["small"]);const r=(0,Hy.shouldShowQuickSearchOnLib)()?function(e){const t=t=>Promise.all([i.e(4211),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(2564),i.e(7384),i.e(2197),i.e(5323),i.e(1072),i.e(9325),i.e(2736),i.e(4066),i.e(116),i.e(8985),i.e(6489),i.e(4106),i.e(7444),i.e(7001),i.e(6262),i.e(1906),i.e(2227),i.e(4931),i.e(9418),i.e(3202),i.e(2751),i.e(1890),i.e(2157),i.e(9754)]).then(i.bind(i,46350)).then((i=>{const s=new(0,i.GlobalSearchDialogRenderer)(e);return null!==Ve&&Ve.hide(),s.show(t),Ve=s,s}));return(0,B.createGroup)({desc:"GlobalSearch"}).add({desc:"Open",hotkey:B.Modifiers.Mod+75,handler:()=>t()}),t}(e.loadChartService):void 0;return new T(new v,{chartSaver:Gy.saver,chartApiInstance:Gy.ChartApiInstance,chartWidgetCollection:e.chartWidgetCollection,defaultFavoriteStyles:s.chartTypes,defaultFavoriteIntervals:s.intervals,resizerBridge:nv,studyMarket:Gy.studyMarket,studyTemplates:pv,allowedModes:o,saveChartService:e.saveChartService,loadChartService:e.loadChartService,chartChangesWatcher:t,onClick:Sv,snapshotUrl:e.snapshotUrl,openGlobalSearch:r})}({chartWidgetCollection:p,saveChartService:g,loadChartService:f,snapshotUrl:Yy.snapshotUrl})
;null!==y?y.load().then((e=>{uv=e.getComponent(),_v.resolve()})):(_v.promise.catch((()=>{})),_v.reject("header widget is not loaded"));const S=function(e){if(rv){const t=Yy.toolbarbg&&/^[0-9a-f]+$/i.test(Yy.toolbarbg)?String(Yy.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:Yy.drawingsAccess?JSON.parse(Yy.drawingsAccess):void 0,resizerBridge:rv,onClick:Sv})}return null}(p),b=null;Gy.tradingViewApi=new Zf({chartWidgetCollection:p,chartApiInstance:Gy.ChartApiInstance,saveChartService:g,loadChartService:f,studyMarket:null});if(de.linking.bindToChartWidgetCollection(p),isNaN(Yy.studyCountLimit)||(TradingView.STUDY_COUNT_LIMIT=Math.max(2,+(0,n.ensureDefined)(Yy.studyCountLimit))),!isNaN(Yy.ssreqdelay)){const e=Math.max(0,+(0,n.ensureDefined)(Yy.ssreqdelay));(0,Xf.setSearchRequestDelay)(e)}Gy.ChartApiInstance.connect(),(async()=>{const{default:e}=await Promise.all([i.e(7827),i.e(3703),i.e(3953),i.e(4178),i.e(5826),i.e(9481),i.e(4600),i.e(6445),i.e(7384),i.e(5323),i.e(2736),i.e(4066),i.e(6489),i.e(4353),i.e(2440),i.e(9255),i.e(7001),i.e(3745),i.e(6262),i.e(6842),i.e(5099),i.e(2227),i.e(2544),i.e(1890),i.e(2157),i.e(7843),i.e(2306)]).then(i.t.bind(i,36074,23));m||(Gy.lineToolPropertiesToolbar=new e(p))})();const w=document.querySelector(".tv-content");null!==w&&w.addEventListener("contextmenu",(e=>{e.target instanceof Element&&"input"!==e.target.tagName.toLowerCase()&&"textarea"!==e.target.tagName.toLowerCase()&&e.preventDefault()})),Qy.resolve(),p.undoHistory.undoStack().onChange().subscribe(null,(0,o.default)((e=>{e?.affectsState()&&W.emit("onAutoSaveNeeded")}),1e3*(Number(Yy.autoSaveDelay)||5),{leading:!1,trailing:!0}));let C=!1;function P(){S&&S.load(Zy.signal),b&&b.load(Zy.signal).then((e=>{Gy.footerWidget=e.getComponent()}))}Gy.chartWidget.withModel(null,(()=>{Gy.ChartApiInstance.on("realtime_tick",(e=>{W.emit("onTick",e)}));if(!k.savedThemeName()&&cv){const e=k.getStdTheme(cv);e&&e.content&&void 0===s&&p.applyTheme({theme:e.content,onlyActiveChart:!1,restoreNonThemeDefaults:!1,themeName:cv,standardTheme:!0,syncState:!0,noUndo:!0}).then((()=>Gy.applyOverrides(Gy.__defaultsOverrides)))}if(l.enabled("charting_library_debug_mode")&&W.subscribeToAll(((...e)=>{console.log(`${(new Date).toISOString()} Event "${e[0]}", arguments: ${JSON.stringify(e.slice(1))}`)})),C)return;C=!0,af(p),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:"👍"});W.on("onServerScreenshotCopiedToClipboard",(()=>h(s)),null),W.on("onClientScreenshotCopiedToClipboard",(()=>h(o)),null),W.on("onServerScreenshotEmbedCodeCopiedToClipboard",(()=>h(r)),null);let l=null;const c=e.getContainer();function h(e){l?l.show(e):Promise.all([i.e(4524),i.e(4052),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))}))}}(p,{seriesControlBarEnabled:l.enabled("timeframes_toolbar")});i_.getInstance().setWidgetCollection(Gy.chartWidgetCollection)})),p.getAll().some((e=>e.isInitialized()))?P():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)}))}(p,P),W.subscribe("chart_load_requested",(e=>{Gy.tradingViewApi.loadChart({json:JSON.parse(e.content),extendedData:e})}),null)};window.addEventListener("unload",(()=>{Zy.abort(),Gy.widgetbar&&(Gy.widgetbar.destroy(),Gy.widgetbar=null),Gy.chartWidgetCollection&&(Gy.chartWidgetCollection.destroy(),Gy.chartWidgetCollection=null),Gy.ChartApiInstance&&Gy.ChartApiInstance.disconnect(),(0,Ze.destroyQuoteSessions)(),Gy.ChartApiInstance&&(Gy.ChartApiInstance.destroy(),Gy.ChartApiInstance=null)})),l.enabled("saveload_storage_customization")&&(jy.saveLoadAdapter?E.setCustomAdapter(jy.saveLoadAdapter):Gy.urlParams.chartsStorageUrl&&Gy.urlParams.clientId?E.initialize(Gy.urlParams.clientId,Gy.urlParams.userId,Gy.urlParams.chartsStorageUrl,Gy.urlParams.chartsStorageVer||"1.0"):(l.setEnabled("saveload_storage_customization",!1),l.setEnabled("header_saveload",!1))),void 0!==jy.imageStorageAdapter&&l.enabled("image_drawingtool")&&(0,zy.setImageStorageAdapter)(jy.imageStorageAdapter);const gv=(0,me.createDeferredPromise)();function fv(){gv.resolve()}jy.loadLastChart&&l.enabled("saveload_storage_customization")?E.getCharts().then((e=>{if(0===e.length)return void fv();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,Yy.chartContent=JSON.stringify({json:i}),fv()})).catch(fv)})).catch(fv):fv();const yv=async function(){if(l.enabled("saveload_separate_drawings_storage")){const e=await i.e(7129).then(i.bind(i,40076));return pm=e.LineToolsSynchronizer,!0}return!1}(),vv=(0,me.createDeferredPromise)();function Sv(){const e=TradingView.bottomWidgetBar;e&&e.turnOffMaximize()}Promise.all([vv.promise,gv.promise,Gy.loadedCustomCss,yv,ev.promise]).then((()=>{const e=document.querySelector(".loading-indicator");if(e&&(e.style.display="none"),setTimeout(mv,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];Gy.ga("create","UA-112911840-1","auto"),Gy.ga("set","anonymizeIp",!0),Gy.ga("set",{hostname:e,page:e,referrer:e}),Gy.ga("send","pageview")}var t,i,s,o,r,a})),(()=>{let e=!0;jy.datafeed.onReady((t=>{e&&console.warn("`onReady` should return result asynchronously. Use `setTimeout` with 0 interval to execute the callback function."),Gy.configurationData=t,vv.resolve()})),e=!1})(),
Gy.createShortcutAction=(()=>{const e=B.createGroup({desc:"API",order:Uy.ACTION_API_GROUP_ORDER});return(t,i)=>{var s;e.add({hotkey:(s=t,"number"==typeof s?s:"string"==typeof s?N(s.split("+")):Array.isArray(s)?N(s):0),handler:i})}})(),Gy.initializationFinished=()=>{Gy.chartWidgetCollection.undoHistory.clearStack()},Gy.headerReady=()=>_v.promise,function e(t=0,i=10){const s={received:!1};Gy.dispatchEvent(new CustomEvent("innerWindowLoad",{detail:s})),!s.received&&t<i&&setTimeout((()=>{e(t+1,i)}),10*Math.pow(2,t))}(),Gy.createButton=e=>{if(null===uv)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 uv.addButton(t,e)??t},Gy.removeButton=e=>{if(null===uv)throw new Error("Cannot remove button: header widget is not ready or is not loaded - use `headerReady` to wait until header is ready");return uv.removeButton(e)},Gy.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 uv?(uv.addDropdown(t,e),Promise.resolve(new Vy(uv,t))):_v.promise.then((()=>((0,n.ensureNotNull)(uv).addDropdown(t,e),new Vy((0,n.ensureNotNull)(uv),t))))},Gy.getAllFeatures=()=>{const e=l.getAllFeatures();return Object.keys(e).forEach((t=>{isNaN(parseFloat(t))||delete e[t]})),e},Gy.getNavigationButtonsVisibility=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)((0,ve.property)()))),Gy.getPaneButtonsVisibility=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)((0,Se.property)()))),Gy.getDateFormat=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)(be.dateFormatProperty))),Gy.getTimeHoursFormat=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)(we.timeHoursFormatProperty))),Gy.getCurrencyAndUnitVisibility=(0,s.default)((()=>(0,ye.convertPropertyToWatchedValue)((0,Be.currencyUnitVisibilityProperty)()))),Gy.customSymbolStatus=()=>Oy.getInstance();Gy.urlParams.debugBroker,new Set(["connectionStatus"]);const bv=Yy.locale||"en",wv=xt.getInstance();wv.createElement(document),wv.setLocale(bv),Gy.customChartDescriptionFunction&&wv.setCustomProvider(Gy.customChartDescriptionFunction);const Cv=Qp.getInstance();Cv.createElement(document),Cv.setLocale(bv),function(){const e=l.enabled("accessible_keyboard_shortcuts")?(0,V.humanReadableHash)(9):`${(0,V.humanReadableModifiers)(V.Modifiers.Alt,!1)} + ${(0,V.humanReadableHash)(90)}`,t=`${(0,V.humanReadableModifiers)(V.Modifiers.Mod,!1)} + ${(0,V.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,V.hashFromEvent)(e);9!==t&&t!==B.Modifiers.Shift+9||(0,Fy.updateTabIndexes)()})),new Jo.Action({actionId:"UnknownAction",options:{label:"",onExecute:()=>{(0,Fy.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,Wy.createScopedVisibleElementFilter)(document.documentElement)).sort(Fy.navigationOrderComparator);void 0!==e&&e.focus()},hotkeyHash:l.enabled("accessible_keyboard_shortcuts")?9:B.Modifiers.Alt+90,hotkeyGroup:(0,B.createGroup)({desc:"Global shortcuts"})}})},36986:(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})},86129:(e,t,i)=>{e=i.nmd(e),TradingView.cleanButAmpersand=function(e,t){var i=t?["&amp;"]:["&"];return TradingView.clean(e,t,i)},TradingView.strip_tags=function(e){return e&&e.replace?e.replace(/(<([^>]+)>)/gi,""):e},TradingView.encodeSpread=function(e){return encodeURIComponent(e)},TradingView.clean=function(e,t,i){const s=[["&","&amp;"],["<","&lt;"],[">","&gt;"],['"',"&quot;"],["'","&#039;"],["'","&#39;"]];t&&s.forEach((e=>e.reverse()));let o=e;if(!e||!e.replace)return o;for(const e of s){const[t,s]=e;i&&-1!==i.indexOf(t)||(o=o.replace(new RegExp(t,"g"),s))}return o},e&&e.exports&&(e.exports={clean:TradingView.clean,cleanButAmpersand:TradingView.cleanButAmpersand,stripTags:TradingView.strip_tags})},55561:(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(52033),m=i(11417);var g=i(31054);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 P{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 T=f((()=>new P));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 I=f((()=>{T()}));var M=i(7047);let A;function L(e){const t=window.user.available_offers||{};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)):(Object.keys(t).forEach((e=>{const i=e;t[i].available_for_anons||delete t[i]})),window.user={username:"Guest",following:"0",followers:"0",ignore_list:[],available_offers:t},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,I(),(0,M.initMouseClickAutoBlurHandler)()},19063:(e,t,i)=>{"use strict";i.r(t),i.d(t,{alphaToTransparency:()=>a,applyAlpha:()=>r,applyTransparency:()=>c,colorFromBackground:()=>_,colorToInteger:()=>y,generateColor:()=>n,
getLuminance:()=>d,gradientColorAtPercent:()=>p,isColorDark:()=>m,isHexColor:()=>u,resetTransparency:()=>h,rgbaFromInteger:()=>g,rgbaToInteger:()=>f,transparencyToAlpha:()=>l});var s,o=i(24377);function n(e,t,i){if(t=t||0,!u(e))return i?(0,o.rgbaToString)((0,o.rgba)((0,o.parseRgb)(e),(0,o.normalizeAlphaComponent)(l(t)))):e;const[s,n,r]=(0,o.parseRgb)(e),a=(0,o.normalizeAlphaComponent)(l(t));return(0,o.rgbaToString)([s,n,r,a])}function r(e,t,i){const s=(0,o.tryParseRgba)(e);if(null===s)throw new Error(`Invalid color: ${e}`);const[n,r,a,l]=s,c=(0,o.normalizeAlphaComponent)(t*(i?l:1));return(0,o.rgbaToString)((0,o.rgba)([n,r,a],c))}function a(e){return 100*(1-e)}function l(e){if(e<0||e>100)throw new Error("invalid transparency");return 1-e/100}function c(e,t){if("transparent"===e)return e;const i=(0,o.parseRgba)(e),s=i[3];return(0,o.rgbaToString)((0,o.rgba)(i[0],i[1],i[2],l(t)*s))}function h(e){return"transparent"===e?e:u(e)?e.slice(0,7):(0,o.rgbaToString)((0,o.rgba)((0,o.parseRgb)(e),(0,o.normalizeAlphaComponent)(1)))}function d(e){const t=(0,o.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 u(e){return 0===e.indexOf("#")}function _(e){return"black"===(0,o.rgbToBlackWhiteString)((0,o.parseRgb)(e),150)?"#ffffff":"#000000"}function p(e,t,i){const[s,n,r,a]=(0,o.parseRgba)(e),[l,c,h,d]=(0,o.parseRgba)(t),u=(0,o.rgba)(Math.round(s+i*(l-s)),Math.round(n+i*(c-n)),Math.round(r+i*(h-r)),a+i*(d-a));return(0,o.rgbaToString)(u)}function m(e){return d(h(e))<.5}function g(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 f(e){const t=Math.round(255*e[3]);return e[0]+256*e[1]+65536*e[2]+16777216*t}function y(e){const t=(0,o.tryParseRgba)(e);return null===t?0:f(t)}!function(e){e[e.BgLuminanceThreshold=.5]="BgLuminanceThreshold"}(s||(s={}))},61119:(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(78871).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)}},84906:(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)}},94784:(e,t,i)=>{"use strict";i.d(t,{generateColorCached:()=>r});var s=i(59332),o=i(19063),n=i(5201);function r(e=1e3){const t=s.default.Cache;s.default.Cache=n.CircularCacheBuffer.bind(n.CircularCacheBuffer,e);const i=(0,s.default)(o.generateColor,((e,t,i)=>`${e}_${t}_${i}`));return s.default.Cache=t,i}},39772:(e,t,i)=>{"use strict";i.d(t,{GradientColorCache:()=>o});var s=i(19063);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}}},68979:(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])}}},18112:(e,t,i)=>{"use strict";i.d(t,{getPersistentLogger:()=>o});let s=null;function o(){return s}},66800:(e,t,i)=>{"use strict";function s(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}i.d(t,{regExpEscape:()=>s})},31599:(e,t,i)=>{"use strict";i.d(t,{rgbaFromIntegerCached:()=>r});var s=i(59332),o=i(19063),n=i(5201);function r(e=1e3){const t=s.default.Cache;s.default.Cache=n.CircularCacheBuffer.bind(n.CircularCacheBuffer,e);const i=(0,s.default)(o.rgbaFromInteger);return s.default.Cache=t,i}},63273:(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":""}},78871:(e,t,i)=>{"use strict";i.d(t,{CubicBezier:()=>s.CubicBezier,dur:()=>s.dur,easingFunc:()=>s.easingFunc});var s=i(74991)},86001:(e,t,i)=>{"use strict";function s(){
return Promise.all([i.e(6342),i.e(3703),i.e(7939),i.e(3799),i.e(5480),i.e(1390),i.e(2227),i.e(2077)]).then(i.bind(i,71090))}i.d(t,{loadChangeIntervalDialog:()=>s})},86235:(e,t,i)=>{"use strict";i.d(t,{showChangeIntervalDialogAsync:()=>n});var s=i(86001);let o=null;function n(e){const t=o=(0,s.loadChangeIntervalDialog)().then((i=>{t===o&&i.showChangeIntervalDialog(e)}));return t}},62400:(e,t,i)=>{"use strict";function s(e){return Promise.all([i.e(5683),i.e(3703),i.e(3953),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(4178),i.e(9481),i.e(2564),i.e(6445),i.e(3799),i.e(5480),i.e(8222),i.e(9296),i.e(7935),i.e(3828),i.e(5579),i.e(2227),i.e(9418),i.e(2544),i.e(3202),i.e(9928),i.e(7223),i.e(1859)]).then(i.bind(i,84828)).then((t=>t.showGoToDateDialog(e)))}i.d(t,{showGoToDateDialog:()=>s})},22980:(e,t,i)=>{"use strict";i.d(t,{runOrSigninWithFeature:()=>s});const s=(e,t)=>{e()};window.TradingView.runOrSigninWithFeature=s},55744:(e,t,i)=>{"use strict";i.d(t,{DeleteLockedLineToolReason:()=>d,confirmRemovingLockedLineTools:()=>m,showDeleteLockedLineToolsConfirm:()=>p});var s=i(11542),o=i(3615),n=i(69293),r=i(56840),a=i(17625);const l="delete_locked_linetools";function c(){return r.getBool(l,!0)}const h=(0,a.createPrimitiveProperty)(c());var d;h.subscribe(null,(()=>r.setValue(l,h.value()))),r.onSync.subscribe(null,(()=>h.setValue(c()))),function(e){e[e.RemoveSelected=0]="RemoveSelected",e[e.RemoveAll=1]="RemoveAll"}(d||(d={}));const u=s.t(null,void 0,i(41019)),_=s.t(null,void 0,i(41019));async function p(e,t){if(n.doNotShowDeleteLockedLineConfirmProperty.value())return void t(h.value());const{getContent:r}=await Promise.all([i.e(7328),i.e(5323),i.e(5083),i.e(9608),i.e(4598)]).then(i.bind(i,20307));(0,o.showConfirm)({title:s.t(null,void 0,i(71692)),content:r(e===d.RemoveSelected?u:_),id:`${n.doNotShowDeleteLockedLineKey}-confirm`,mainButtonText:s.t(null,void 0,i(93123)),mainButtonIntent:"danger",cancelButtonText:s.t(null,void 0,i(99024)),onConfirm:({dialogClose:e})=>{h.setValue(!0),t(!0),e()},onCancel:({dialogClose:e})=>{h.setValue(!1),t(!1),e()}})}function m(e){return new Promise((t=>{p(e,t)}))}},48341:(e,t,i)=>{"use strict";i.d(t,{showDeleteStudyTreeConfirm:()=>n});var s=i(11542),o=i(3615);function n(e){(0,o.showConfirm)({title:s.t(null,void 0,i(81605)),text:s.t(null,void 0,i(77174)),onConfirm:({dialogClose:t})=>{e(),t()}})}},71885:(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))})}},4454:(e,t,i)=>{"use strict";i.d(t,{getAdditionalSymbolInfoFields:()=>n,setAdditionalSymbolInfoFields:()=>o});let s=[];function o(e){s=e}function n(){return s}},80387:(e,t,i)=>{"use strict";function s(e){Promise.all([i.e(8622),i.e(3703),i.e(4524),i.e(7939),i.e(9258),i.e(5387),i.e(7384),i.e(4106),i.e(9753),i.e(9276),i.e(2227),i.e(9418),i.e(7973),i.e(9374)]).then(i.bind(i,30995)).then((({SymbolInfoDialogImpl:t})=>{t.getInstance().show(e)}))}i.d(t,{showSymbolInfoDialog:()=>s})},28153:(e,t,i)=>{"use strict"
;i.d(t,{ChartSaverBase:()=>u});var s=i(50279),o=i(50151),n=(i(11542),i(97990)),r=i(23024),a=i(37265),l=i(52033),c=i(56570),h=i(39076);function d(e,t){e.content=JSON.stringify(t)}new WeakMap;new TextEncoder;class u{constructor(e){this._prevChartState=null,this._chartSavedDelegate=new l.Delegate,this._chartAboutToBeSavedDelegate=new l.Delegate,this._chartSizeLimitExceededDelegate=new l.Delegate,this._isSaveInProcess=!1,this._savingToken=null,this._chartWidgetCollection=e}async saveChartLineTools(e,t,s,o){if(c.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&&c.enabled("saveload_separate_drawings_storage"),i=this._getChartWidgetCollectionState(!1,void 0,void 0,void 0,t),o=this._getCommonSavingInfo(!1);return d(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 d(i,this._getChartWidgetCollectionState(!1,!0,t,void 0,t)),i}isSaveInProcess(){return this._isSaveInProcess}_getChartWidgetCollectionState(e,t,i,s,o){return e||(t=!0,s=!1),this._chartWidgetCollection.state(!!e,!!i,!!s,o,!t)}_getCommonSavingInfo(e){const t=this._chartWidgetCollection,i=this._chartWidgetCollection.chartsSymbols(),s=i[t.activeChartWidget.value().id()],o={...(n=s,{...n,legs:JSON.stringify(n.legs??[])})};var n;const r=t.metaInfo,a=r.id.value();return null!==a&&(o.id=a),o.name=r.name.value()||"",o.description=r.description.value()||"",o.charts_symbols=function(e){const t={};for(const i of Object.keys(e))t[i]={symbol:e[i].symbol};return JSON.stringify(t)}(i),o.is_realtime=o.is_realtime=e?"0":"1",o}async _saveLineToolsToStorage(){if(!c.enabled("saveload_separate_drawings_storage"))return Promise.resolve();{this.layoutId();0;const e=this._chartWidgetCollection.getAll().map((e=>e.lineToolsSynchronizer()?.flushPendingSavings()??null)).filter(a.notNull);e.length&&await Promise.all(e)}}_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?h.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,l={name:a.name.value(),description:a.description.value(),uid:a.uid.value(),id:a.id.value(),lastModified:a.lastModified.value(),username:a.username.value()};let h=r.changes??n.changedAll;c.enabled("saveload_separate_drawings_storage")&&this._invalidateAllLineTools();let d=!0;if(2&h||c.enabled("saveload_separate_drawings_storage"))try{await this._saveLineToolsToStorage()}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!==l.id)return this._chartSavedDelegate.fire(!0),void t(l,i);0;const n=(e,i)=>(d||this._chartWidgetCollection.getAll().forEach((e=>e.lineToolsSynchronizer()?.markAsValidatedBecauseOfSavingToContent(!0))),t(e,i));return this._saveChartImpl(i,l,n,o,r,e)}this._chartSavedDelegate.fire(!0),t(l,e(d))}}},97488:(e,t,i)=>{"use strict";var s=i(28153).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){}}},22365:(e,t,i)=>{"use strict";i.d(t,{getTranslatedSymbolDescription:()=>s});i(11542);function s(e){return e.description||""}},34585:(e,t,i)=>{"use strict";function s(e){return e+"…"}i.d(t,{appendEllipsis:()=>s})},14051:(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}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})},18832:(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})},31054:(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})},14426:(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})},14712:(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})},92184:(e,t,i)=>{"use strict";i.r(t),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}},49481:(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={}))},14729:(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()}},97144:(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>'},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>'},37924: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)"><circle stroke="currentColor" cx="9.5" cy="9.5" r="9"/><path stroke="currentColor" d="M7 14.5h2.5v-5H7"/><path stroke="currentColor" stroke-linecap="square" d="M9.5 14.5h2"/><path fill="currentColor" d="M9.5 7a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3z"/></g></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>'},77067:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28"><path fill="currentColor" d="M13.39 3.84a1 1 0 0 1 1.22 0l8.19 6.37a1 1 0 0 1 0 1.58l-8.19 6.37a1 1 0 0 1-1.22 0L5.2 11.79a1 1 0 0 1 0-1.58l8.19-6.37zm.61.8L5.81 11 14 17.37 22.19 11 14 4.63zM5.3 13.6l8.7 6.76 8.7-6.76.6.78-8.69 6.77a1 1 0 0 1-1.22 0l-8.7-6.77.62-.78zm8.09 10.55l-8.7-6.77.62-.78L14 23.37l8.7-6.76.6.78-8.69 6.77a1 1 0 0 1-1.22 0z"/></svg>'},76351:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 28" width="36" height="28"><path fill="currentColor" d="M14 22H7V11H0V4h14v18zM28 22h-8l7.5-18h8L28 22z"/><circle fill="currentColor" cx="20" cy="8" r="4"/></svg>'},9343:(e,t,i)=>{"use strict";i.r(t),i.d(t,{LOGLEVEL:()=>n,getLogHistory:()=>b,getLogLevel:()=>g,getLogger:()=>C,getRawLogHistory:()=>v,isHighRateEnabled:()=>f,loggingOff:()=>x,loggingOn:()=>T,serializeLogHistoryEntry:()=>S,setLogLevel:()=>y});const s="undefined"!=typeof window?window:{};let o=!1;try{localStorage.getItem(""),o=!0}catch(e){}var n;!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"}(n||(n={}));let r=0;const a="tv.logger.loglevel",l="tv.logger.logHighRate",c=[];let h=null,d=null,u=null,_=null,p=n.WARNING,m=!1;function g(){return p}function f(){return m}function y(e){e=Math.max(n.ERROR,Math.min(n.DEBUG,e)),p=e,I()}function v(e,t){let i=c.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 S(e){return new Date(e.timestamp).toISOString()+":"+e.subSystemId+":"+e.message.replace(/"/g,"'")}const b=(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)}(v(e,t).map(S),75497472);function w(e,t,i,s){if(t===d&&s.id===u)return;const o=new Date;if(e<=n.NORMAL&&function(e,t,i,s,o){"function"==typeof structuredClone&&(t=structuredClone(t));const n={id:r,message:t,subSystemId:s,timestamp:Number(e)};r+=1,i.push(n),void 0!==o&&i.length>o&&i.splice(0,1)}(o,t,i,s.id,s.maxCount),e<=p&&(!s.highRate||f())&&(!h||s.id.match(h))){const i=o.toISOString()+":"+s.id+":"+t;switch(e){case n.DEBUG:console.debug(i);break;case n.INFO:case n.NORMAL:s.color?console.log("%c"+i,"color: "+s.color):console.log(i);break;case n.WARNING:console.warn(i);break;case n.ERROR:console.error(i)}d=t,u=s.id,null!==_&&clearTimeout(_),_=setTimeout((()=>{d=null,u=null,_=null}),1e3)}}function C(e,t={}){const i=[];c.push(i);const s=Object.assign(t,{id:e});function o(e){return t=>w(e,String(t),i,s)}return{logDebug:o(n.DEBUG),logError:o(n.ERROR),logInfo:o(n.INFO),logNormal:o(n.NORMAL),logWarn:o(n.WARNING)}}const P=C("logger"),T=(e,t)=>{y(n.DEBUG),P.logNormal("Debug logging enabled"),m=Boolean(e),h=t||null,I()},x=()=>{y(n.INFO),P.logInfo("Debug logging disabled")};function I(){try{o&&(localStorage.setItem(l,String(m)),localStorage.setItem(a,String(p)))}catch(e){P.logWarn(`Cannot save logger state (level: ${p}, high-rate: ${m}) to localStorage: ${e.message}`)}}s.lget=b,s.lon=T,s.loff=x,function(){m=!!o&&"true"===localStorage.getItem(l);let e=parseInt(o&&localStorage.getItem(a)||"");Number.isNaN(e)&&(e=n.WARNING),y(e),P.logNormal(`Init with settings - level: ${p}, high-rate: ${m}`)}(),s.performance&&s.performance.now?P.logNormal(`Sync logger and perf times, now is ${s.performance.now()}`):P.logWarn("Perf time is not available")},
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},87489: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]],"2h":["h",0,1],"2v":["v",0,1],"2-1":["v",["h",0,2],1],"3s":["h",0,["v",1,2]],"3h":["h",0,1,2],"3v":["v",0,1,2],"1-2":["v",0,["h",1,2]],"3r":["h",["v",0,1],2],"4h":["h",0,1,2,3],"4v":["v",0,1,2,3],"4s":["h",0,["v",1,2,3]],"4s-l":["h",["v",1,2,3],0],"5h":["h",0,1,2,3,4],"5v":["v",0,1,2,3,4],"6h":["h",0,1,2,3,4,5],"6v":["v",0,1,2,3,4,5],"7h":["h",0,1,2,3,4,5,6],"8h":["h",0,1,2,3,4,5,6,7],"8v":["v",0,1,2,3,4,5,6,7],"9h":["h",0,1,2,3,4,5,6,7,8],"9v":["v",0,1,2,3,4,5,6,7,8],"10h":["h",0,1,2,3,4,5,6,7,8,9],"10v":["v",0,1,2,3,4,5,6,7,8,9],"1-3":["v",0,["h",1,2,3]],"2-2":["v",["h",0,1],["v",2,3]],"2-2-l":["h",0,1,["v",2,3]],"2-3":["v",["h",0,1],["h",2,3,4]],"3-2":["v",["h",0,1,2],["h",3,4]],"1-4":["v",0,["h",1,2,3,4]],"2-4":["v",["h",0,1],["h",2,3,4,5]],"5s":["h",0,["v",1,2,3,4]],"6c":["v",["h",0,1],["h",2,3],["h",4,5]],"8c":["v",["h",0,1],["h",2,3],["h",4,5],["h",6,7]],"9s":["v",["h",0,1,2],["h",3,4,5],["h",6,7,8]],"10c5":["v",["h",0,2,4,6,8],["h",1,3,5,7,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]],"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]],"s":0}')},23420:e=>{"use strict"
;e.exports=JSON.parse('{"color-white":"#ffffff","color-black":"#000000","color-transparent":"#00000000","color-transparent-80":"#000000CC","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":"#303030","color-cold-gray-850":"#262626","color-cold-gray-900":"#1A1A1A","color-cold-gray-950":"#0F0F0F","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"}')
},20913:e=>{"use strict"
;e.exports=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"}')
},579:e=>{"use strict"
;e.exports=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"}')
}},e=>{e.O(0,[2464,1996,207],(()=>{return t=93364,e(e.s=t);var t}));e.O()}]);