@barchart/chart-lib 2.382.1 → 2.382.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
13
13
  `?(n++,r=1):t===`\r`?e[i+1]!==`
14
14
  `&&(n++,r=1):r++}return{line:n,column:r}}function vu(e,t){if(!(e instanceof su)||!e.location)return;let n=Array.isArray(e.expected)?e.expected:[],r=e.found??null,i=hu(n);if(!(r===null&&i.expectsCloseParen))return e.location;let a=gu(t);if(a===void 0)return e.location;let o=Math.max(t.lastIndexOf(`
15
15
  `),t.lastIndexOf(`\r`))+1,s=a-1;for(;s>=o&&/\s/.test(t[s]);)s--;if(s<o)return e.location;let c=s+1,l=_u(t,c);return{...e.location,start:{...e.location.start,offset:c,line:l.line,column:l.column},end:{...e.location.end,offset:c,line:l.line,column:l.column}}}function yu(e,t){if(!(e instanceof su))return e instanceof Error?e.message:`Invalid expression.`;let n=Array.isArray(e.expected)?e.expected:[],r=e.found??null,i=hu(n),a=e.location?.start?.offset??0,o=a>0?t[a-1]:``;return r===null?pu(t)?`Expression contains only comments. Add a value (for example {AAPL} or 1).`:i.expectsFieldName&&o===`.`?`Missing field name after '.'.`:i.expectsCloseBrace?`Missing closing brace '}' in symbol.`:i.expectsCloseParen?`Missing closing parenthesis ')'.`:i.expectsValue?`Expression ended unexpectedly; expected a value.`:`Expression ended unexpectedly.`:i.expectsFieldName&&o===`.`?`Expected a field name (letters only) after '.', but found ${mu(r)}.`:i.expectsCloseBrace&&o===`{`&&r===`}`?`Symbol name cannot be empty inside '{}'.`:i.expectsOperator&&i.expectsEnd?`Expected an operator (+, -, *, /, or ^) or end of expression, but found ${mu(r)}.`:i.expectsOperator&&i.expectsCloseParen?`Expected an operator or closing parenthesis ')' but found ${mu(r)}.`:i.expectsValue?`Expected a value (number, symbol, or parenthesized expression), but found ${mu(r)}.`:i.expectsCloseParen?`Expected a closing parenthesis ')', but found ${mu(r)}.`:i.expectsCloseBrace?`Expected a closing brace '}', but found ${mu(r)}.`:`Invalid expression near ${mu(r)}.`}var bu=new Map,xu=/\w:\w/;function Su(e,t){return e.some(e=>e.includes(`:`))?(Du(t,(e,t,n)=>{let r=(e,t=null,n=`sym`)=>({op:n,left:e,right:t}),i=e;if(i.op!==`sym`||!xu.test(t))return null;let a=t.split(`:`);return i.op=`grp`,i.left=r(r(a[0]),r(a[1]),`-`),null}),!0):!1}function Cu(e){return`error`in e}function wu(e,t=!1,n=!0){let r=e.trim();if(t&&bu.has(r))return F(bu.get(r));try{let i=lu(r);ju(i,e=>e.toUpperCase(),!0,!0);let a=ku(i);n&&Su(a,i)&&(a=ku(i));let o={text:e,model:i,clean:Ou(i,!1),verbose:Ou(i,!0),symbols:a};return t&&bu.set(r,o),o}catch(t){return{text:e,error:yu(t,r),loc:vu(t,r)??t?.location}}}function Tu(e,t){return Du(e,Eu(t))}function Eu(e){return(t,n,r)=>{let i=t;if(Mu(i)){if(n===null)return null;switch(i.op){case`-`:return-n;case`grp`:return n;case`sym`:return e(n);case`num`:return n;default:throw Error(`Unrecognized unary operator ${i.op}`)}}else{if(n===null||r===null)return null;let t=n,a=r;switch(i.op){case`+`:return t+a;case`-`:return t-a;case`*`:return t*a;case`/`:return t/a;case`^`:return t**+a;case`sym`:return e(n,r);default:throw Error(`Unrecognized binary operator ${i.op}`)}}}}function Du(e,t,n){if(!P(e))return null;let r=typeof e;if(r===`number`||r===`string`)return e;let i=e;return t(i,Du(i.left,t,n),Du(i.right,t,n),n)}function Ou(e,t=!1){let n={preserveComments:t};if(t){let t=e.leadingComments;return((t?t.map(e=>`// ${e}\n`).join(``):``)+Du(e,Nu,n)).trimEnd()}return Du(e,Nu,n)}function ku(e){let t=new Set;return Du(e,(e,n,r)=>(e.op===`sym`&&t.add(n),null)),Array.from(t)}function Au(e){let t=0,n=[`+`,`-`,`*`,`/`,`^`];return Du(e,(e,r,i)=>(n.includes(e.op)&&t++,null)),t>0}function ju(e,t,n=!1,r=!1){let i=(e,n,i)=>{let a=e;return a.op===`sym`&&(a.left=t(n),r&&a.right&&(a.right=t(a.right))),null},a=n?e:F(e);return Du(a,i),a}function Mu(e){return!P(e.right)}function Nu(e,t,n,r){let i=e,a=r?.preserveComments??!1,o;if(Mu(i))switch(i.op){case`-`:o=`${i.op}${t}`;break;case`grp`:o=`(${t})`;break;case`sym`:o=`{${t}}`;break;case`num`:o=t.toString();break;default:throw Error(`Unrecognized unary operator ${i.op}`)}else{let e=String(t),r=String(n);switch(i.op){case`+`:case`-`:case`*`:case`/`:case`^`:o=a&&e.endsWith(`
16
- `)?`${e}${i.op} ${r}`:`${e} ${i.op} ${r}`;break;case`sym`:o=`{${t}}.${n}`;break;default:throw Error(`Unrecognized binary operator ${i.op}`)}}return a&&i.trailingComment!==void 0?`${o} // ${i.trailingComment}\n`:o}function Pu(e){let t=[];for(let n of e.panes)for(let e of n.axes)for(let n of e.plots)t.push(n);return t}function Fu(e,t,n){return!Pu(e).some(e=>e.uid===t&&e.uid!==n)}function Iu(e,t,n){if(!Fu(e,t,n))throw Error(`Plot uid '${t}' is already in use on this chart.`)}function Lu(e){return Pu(e).find(e=>e.main===!0)}function Ru(e,t){let n=0;for(let r=0;r<e.panes.length;r++){let i=e.panes[r].axes;for(let e=0;e<i.length;e++){let a=i[e].plots;for(let i=0;i<a.length;i++){if(n===t)return{pane:r,axis:e,plot:i};n++}}}return null}function zu(){return{plots:[]}}function Bu(e,t){let n=e.panes[t],r=n.axes.map(e=>e.plots.reduce((e,t)=>e+ +!!t.detachedScale,0)),i=n.axes.length;return n.axes.forEach((e,t)=>{let a=r[t],o=e.plots.length;if(!(a===0||a<o)&&a===o)if(i>1&&a===1){let a=(t+1)%i;if(r[a]<n.axes[a].plots.length){let t=e.plots.find(e=>e.detachedScale);t&&(n.axes[a].plots.push(t),e.plots=e.plots.filter(e=>!e.detachedScale),r[a]++)}}else{let t=e.plots.find(e=>e.detachedScale);t&&(t.detachedScale=!1)}}),e}function Vu(e,t,n){let r=Ru(e,t);if(r===null)return e;let i=e.panes[r.pane],a=i.axes[r.axis].plots[r.plot];return n===r.axis?delete a.detachedScale:(delete a.detachedScale,i.axes.length<2&&n>0&&i.axes.push(zu()),i.axes[n].plots.push(a),i.axes[r.axis].plots.splice(r.plot,1)),Ld(Bu(e,r.pane))}function Hu(e,t){let n=Ru(e,t);if(n===null)return e;let r=e.panes[n.pane].axes[n.axis].plots[n.plot];return r.detachedScale=!0,Ld(Bu(e,n.pane))}function Uu(e,t){let n=Pu(e).find(e=>e.uid===t.uid);if(!n||n.type!==`Seasonal`)return null;let r=n.offsets;return!Array.isArray(r)||!r.includes(t.offset)?null:n}function Wu(e,t){let n=t??{kind:`main`};return n.kind===`main`?Lu(e)??null:n.kind===`seasonal`?Uu(e,n):null}function Gu(e,t,n){let r=Wu(e,n);return r?r.type===`Forward`?{eligible:!1,reason:`it cannot be based on a forward plot`}:r.type===`Expression`&&vs(t)?{eligible:!1,reason:`it cannot be based on an expression; the study needs more than "OHLCV" fields`}:r.type===`Seasonal`&&!ys(t)?{eligible:!1,reason:`it cannot be based on a seasonal plot`}:{eligible:!0}:{eligible:!1,reason:`its basis does not resolve to an existing target plot`}}var Ku=`..plots{.main === true}`;function qu(e){return V(e,Ku)[0]}function Ju(e){let t=V(e,`..panes{${Ku}}`)[0];return{mainPane:t,mainAxis:V(t,`..axes{${Ku}}`)[0]}}function Yu(e,t,n){let r=qu(t);if(r[r.type.toLowerCase()]===z.PLACEHOLDER_SYMBOL_NAME){let r=qu(e),{mainAxis:i}=Ju(t),a=i.annotations,o=nd(t,r);if(n){let{mainAxis:e}=Ju(o);e.annotations=a}return o}return t}var Xu=`Symbol`,Zu=`Expression`,Qu=`Forward`,$u=`Seasonal`,ed=[Xu,Zu,Qu,$u];function td(e){let t=wu(e),n=Cu(t),r=n?0:t.symbols.length,i=!n&&r>0?t.symbols[0]:null;return{clean:n?void 0:t.clean,hasErrors:n,symbolCount:r,firstSymbol:i,error:n?t.error:void 0}}function nd(e,t){let n=qu(e);P(t.uid)&&Iu(e,t.uid,n.uid);let r=e=>n.type===e,i=e=>P(t[e.toLowerCase()]),a=ed.find(e=>i(e)),o=a.toLowerCase(),s=t[o],c=s===z.PLACEHOLDER_SYMBOL_NAME,l=i(Zu)||i(Qu)||i($u),u=ed.some(e=>i(e)&&!r(e)),d=$().config.cachedAnnotationsCount||0,f=d>0,{mainAxis:p}=Ju(e);u&&(p.comparison=`None`);let m=td(s),h=e=>{throw Error(e)};c||(l?(m.hasErrors&&h(`[Main Plot] "${s}" is an invalid expression.\n${m.error}`),s=m.clean):m.hasErrors||h(`[Main Plot] "${s}" is an expression, unsupported for ${o}.`));let g=(e,t)=>e.findIndex(e=>e.symbol===t),_=(e,t)=>{if(e===z.PLACEHOLDER_SYMBOL_NAME)return;let n=t.annotations||[],r=t.annCache||[],i=g(r,e);if(i!==-1&&r.splice(i,1),n.length>0){let t={symbol:e,annotations:n};r.length+1>d&&r.splice(0,r.length+1-d),r.push(t)}t.annCache=r},v=(e,t)=>{let n=t.annCache||[],r=g(n,e);r!==-1&&(t.annotations=n[r].annotations)},y=e=>{let a=n;if(r(Xu))_(a.symbol,e);else if(r(Zu))_(a.expression,e);else if(r($u)){let t=td(a.seasonal);t.symbolCount===1&&_(t.firstSymbol,e)}delete e.annotations,i(Xu)?v(t.symbol,e):i(Zu)?v(t.expression,e):i($u)&&m.symbolCount===1&&v(t.seasonal,e)};if(f){let t=V(e,`..axes`);for(let e of t)y(e)}let b=i(Zu)&&r(Xu)||i(Xu)&&r(Zu),x=H(e,Ku,e=>(P(t.uid)&&(e.uid=t.uid),u&&(delete e.expression,delete e.symbol,delete e.showPrevious,delete e.forward,delete e.offsets,delete e.seasonal,e.type=a,b||(e.curves=[{}]),(i(Qu)||i($u))&&(e.offsets=[0])),e[o]=s,e));if(i(Xu)&&Yr(s)&&(x.data.aggregation.contractRoll=oi(s)?`expiration`:`combined`),u)if(i(Qu))x.data.aggregation={unit:`Month`},x.display.period=`P10Y`;else if(i($u)&&!x.data.aggregation.isEndOfDay)x.data.aggregation={unit:`Day`},x.display.period=i($u)?`P9M`:`P1Y10D`;else if(r(Qu)||r($u)){x.data.aggregation=$().getDefaultAggregation(),x.data.maxDataPoints=z.DEFAULT_MAX_RECORDS;let e=$().getDefaultPeriod();P(e)&&(x.display.period=e)}else i(Zu)&&r(Xu)&&(iu.includes(n.curves[0].style)&&(x=H(x,Ku,e=>(delete e.inputs,e))),x.data.aggregation.spec===`PerRange`&&(x.data.aggregation={unit:`Day`}));let S=new Map([[`..plots{.type === "Study"}`,e=>{let t=B(e.study);return N(t)&&Gu(x,t,e.basis).eligible?e:z.NULL_OBJECT}],[`..plots{.type === "BalanceSheet" || .type === "IncomeStatement"}`,e=>i(Xu)?(e.symbol=s,e):z.NULL_OBJECT],[`..plots{..events}`,e=>(i(Xu)||delete e.events,e)]]);for(let[e,t]of S)x=H(x,e,t);return u&&!b&&(x=au(x,{type:a,curves:[{}]})),x=Ld(x),x}function rd(e){let t=$().getDefaultDensity();P(t)&&(e.display.density=t)}function id(e,t){return H(e,`..plots{.type === "Study" && (.study === "VOL" || .study === "MAVOL")}.curves{.fields === "TradeSize" || .fields === "Volume"}`,e=>(e.fields=t?[W.TradeSize.id]:[W.Volume.id],e))}function ad(e,t){let n=Il(e.data.aggregation),r=n.isTick&&!n.hasSpec,i=Il(t),a=i.isTick&&!i.hasSpec,o=e=>e.isIntraday&&e.hasSpec&&e.spec===_.PerRange,s=o(n),c=o(i),l=H(e,`${Ku}.curves[0]`,e=>{let t=[W.Open.id,W.High.id,W.Low.id,W.Close.id,W.Change.id].slice();if(!s&&c)return tu(`Range`,!0);if(s&&!c&&(e.style=`OHLC`),!a&&r){let n=$().getDefaultMultiFieldCurve();if(n!==null)return n;e.fields=t,e.style!==`Candlestick`&&e.style!==`OHLC`&&e.style!==`HLC`&&(e.style=`Candlestick`,e.colors=[`#ff6961`,`#77dd77`],e.varyColorPerBar=!0),e.style===`HLC`&&e.fields.splice(0,1)}else a&&!r&&(e.fields=[W.Last.id,W.Change.id],e.style=`Line`,e.colors=[`#0055cc`],e.varyColorPerBar=!1);return e});return l=id(l,a),ht(l.data.aggregation,t),(n.unit!==i.unit||n.size!==i.size)&&(Kl(l),Gl(l),rd(l),Wl(l)),l}function od(e){return P(e)&&e!==z.AUTOFIT_PERIOD}function sd(e){e.display?.density?(Kl(e),Gl(e)):od(e.display?.period)&&Gl(e)}function cd(e){let t=rt(e.display,null,`chart`,`bar`);if(P(t)){let[e,n]=yt(t.width||0,t.spacing||0,z.MINIMUM_BAR_WIDTH,z.MAXIMUM_BAR_WIDTH);t.width=e,t.spacing=n}}function ld(e){e.display?.period&&e.display.period===`YTD`&&delete e.display.period}function ud(e){let t=V(e,`..annotations{.id === 'RewardRisk' || .id === 'ProfitLoss' }`);t.length>0&&t.forEach(e=>{e.traits.prices=e.traits.prices.map(e=>typeof e==`string`?Number.parseFloat(e):e),e.id===`RewardRisk`&&(e.traits.ratio=Math.abs(e.traits.ratio),e.traits.textLines=e.traits.textLines.map(e=>e.match(/Ratio/)?e.replace(`-`,``):e))})}function dd(e){let t=V(e,`..annotations{.traits.fill.color === null}`);t.length>0&&t.forEach(e=>{e.traits.fill.color=`rgba(0, 0, 0, 0)`})}function fd(e){let{from:t,to:n}=e.display?.xAxis?.visibleRange||{},r=t===null,i=n===null;r&&delete e.display.xAxis.visibleRange.from,i&&delete e.display.xAxis.visibleRange.to,r&&i&&delete e.display.xAxis.visibleRange}function pd(e){let t=V(e,`..panes[0].axes[0].scale`);if(t.length===1){let n=t[0],r=V(e,`..panes[0]..axes`);r.length>0&&r.forEach(e=>e.scale=n)}}function md(e){let[t]=V(e,Ku);P(t)&&t.type===C[C.Symbol]&&!iu.includes(t.curves[0].style)&&P(t.inputs)&&delete t.inputs}function hd(e){let[t]=V(e,Ku);P(t)&&t.type===C[C.Symbol]&&t.curves[0].style===h[h.Renko]&&P(t.inputs)&&t.inputs.map(e=>e.value).some(e=>e===void 0)&&(t.inputs=F(z.DEFAULT_RENKO_INPUTS))}function gd(e){let[t]=V(e,Ku);if(P(t)&&t.type===C[C.Expression]){let n=t.curves[0].style,r=n===h[h.Range],i=n===h[h.Baseline],a=iu.includes(n);r&&e.data?.aggregation.spec===_[_.PerRange]&&(e.data.aggregation={unit:`Day`}),!i&&(a||r)&&(delete t.inputs,t.curves[0]=tu(`Candlestick`,!0))}}function _d(e){let t=H(e,`..annCache{!.annotations}`,e=>z.NULL_OBJECT);t=H(t,`..annCache`,e=>{let t=di(e.symbol);return t===null?e:Dr(t,Lr(new Date,3))?z.NULL_OBJECT:e}),t=H(t,`..annotations{.id === 'ComputedText' && !.traits.textLines}`,e=>z.NULL_OBJECT);let n=t.data.aggregation,r=n.unit===`Tick`&&n.spec===`None`;return id(t,r)}function vd(e){V(e,`..annotations`).forEach(e=>{let{id:t,traits:n}=e;Rc(t,n),Lc(t,n)})}function yd(e){try{ds(!1),V(e,`..plots{.type === "Study" && .curves.zones}`).forEach(e=>{let t=B(e.study).defaults;for(let n=0;n<(e.curves?.length??0);n++){let r=e.curves[n];if(r.zones&&(r.colors?.length??0)<(t.curves[n].colors?.length??0)){let e=t.curves[n].colors.slice(r.colors?.length??0);r.colors?.length?r.colors.push(...e):r.colors=e}}})}finally{ds(!0)}}function bd(e){let[t]=V(e,Ku);if(t.type===`Symbol`&&t.curves?.length===1){let e=t.curves[0];if(e.style===`HLC`){let t=e.colors?.length;if(t===1){let t=e.colors[0];e.colors=[t,t],e.varyColorPerBar=!0,e.attributes=[`OpenVsClose`]}else t===2&&!e.attributes&&(e.attributes=[`OpenVsClose`])}}}function xd(e){$()?.config?.mode===`cmdtyView`&&(delete e.data?.extendedHours,delete e.data?.buildContinuation)}function Sd(e){let t=e.data?.aggregation,n=e.data?.extendedHours,r=N(n);t&&t.spec===`FormT`&&(t.spec=`None`,r||(e.data.extendedHours=!0))}function Cd(e){let t=e.data?.buildContinuation,n=N(t),r=e.data?.aggregation;n&&r&&(r.spec===`Continue`&&!t&&(r.spec=`None`),t&&(r.spec=`Continue`))}function wd(e){try{ds(!1),V(e,`..plots{.type === "Study" && .curves.varyColorPerBar}`).forEach(e=>{let t=B(e.study).defaults;if(e?.curves?.length===t?.curves.length&&t?.curves.length>0)for(let n=0;n<e.curves.length;n++)e.curves[n].varyColorPerBar=t.curves[n].varyColorPerBar})}finally{ds(!0)}}function Td(e){try{ds(!1),V(e,`..plots{.type === "Study"}`).forEach(e=>{let t=B(e.study).defaults;N(e.inputs)&&e.inputs.forEach((e,n)=>{let r=t.inputs?.[n]?.value;!N(e.value)&&N(r)&&(e.value=r)}),N(e.levels)&&e.levels.forEach((e,n)=>{let r=t.levels?.[n]?.value;!N(e.value)&&N(r)&&(e.value=r)}),N(e.bands)&&e.bands.forEach((e,n)=>{let r=t.bands?.[n]?.range;!N(e.range.from)&&N(r?.from)&&(e.range.from=r.from),!N(e.range.to)&&N(r?.to)&&(e.range.to=r.to)})})}finally{ds(!0)}}function Ed(e){let t=V(e,`..axes{.annotations{.points{!.price || !.time}}}`);t.length>0&&t.forEach(e=>{let t=e.annotations.map(e=>{let t=e.points.find(e=>P(e.price)),n=e.points.find(e=>P(e.time));return!P(t)||!P(n)?null:(e.points.forEach(e=>{P(e.price)||(e.price=t.price),P(e.time)||(e.time=n.time)}),e)}).filter(e=>P(e));t.length>0?e.annotations=t:delete e.annotations});let n=V(e,`..panes`),r=e=>P(e.height)?e.height:1,i=n.map(e=>r(e)),a=Math.min(...i),o=a<.01?5/a:1;n.forEach(e=>e.height=Xe(o*r(e),4));let s=$().config.showResizeHandles||!1;e.display.xAxis.resizeHandles=s;let c=`wheel+shift`,l=$().config.scrollBehavior||c;Object.values(ie).filter(e=>typeof e==`string`).includes(l)||(l=c),e.display.scrollBehavior=l;let u=V(e,`..plots{.type === "Study" && .study === "RSI"}`);return u.length>0&&u.forEach(e=>{if(P(e.bands)&&e.bands.length>0){let t=e.inputs&&e.inputs.length===1&&e.inputs[0].name===z.INPUT_PERIOD?e.inputs[0].value:null,n=B(`RSI`).defaults;e.curves=n.curves,e.inputs=n.inputs,P(t)&&(e.inputs[0].value=t),delete e.bands,e.levels=n.levels}}),sd(e),cd(e),ld(e),dd(e),fd(e),pd(e),md(e),hd(e),gd(e),vd(e),yd(e),bd(e),ud(e),xd(e),Sd(e),Cd(e),wd(e),Td(e),_d(e)}var Dd=o(((e,t)=>{(function(){var e=function(t){if(typeof t!=`object`||!t)return t;var n;if(t instanceof Date)return n=new Date,n.setTime(t.getTime()),n;if(t instanceof RegExp)return n=new RegExp(t),n;if(t instanceof Array){n=[];for(var r=0,i=t.length;r<i;r++)n[r]=e(t[r]);return n}if(t instanceof Object){for(var a in n={},t)t.hasOwnProperty(a)&&(n[a]=e(t[a]));return n}throw Error(`Unable to clone object!`)},n=function(t){for(var n=[e(t[0])],r=n[0].key,i=n[0].object,a=1,o=t.length;a<o;a++)i=i[r],r=t[a].key,n.push({object:i,key:r});return n},r=function(e,t){var n=e.length-1,r=e[n].key;t[n].object[r]=e[n].object[r]},i={type:!0,not:!0,anyOf:!0,allOf:!0,oneOf:!0,$ref:!0,$schema:!0,id:!0,exclusiveMaximum:!0,exclusiveMininum:!0,properties:!0,patternProperties:!0,additionalProperties:!0,items:!0,additionalItems:!0,required:!0,default:!0,title:!0,description:!0,definitions:!0,dependencies:!0},a={null:function(e){return e===null},string:function(e){return typeof e==`string`},boolean:function(e){return typeof e==`boolean`},number:function(e){return typeof e==`number`&&e===e},integer:function(e){return typeof e==`number`&&e%1==0},object:function(e){return e&&typeof e==`object`&&!Array.isArray(e)},array:function(e){return Array.isArray(e)},date:function(e){return e instanceof Date}},o={alpha:function(e){return/^[a-zA-Z]+$/.test(e)},alphanumeric:function(e){return/^[a-zA-Z0-9]+$/.test(e)},identifier:function(e){return/^[-_a-zA-Z0-9]+$/.test(e)},hexadecimal:function(e){return/^[a-fA-F0-9]+$/.test(e)},numeric:function(e){return/^[0-9]+$/.test(e)},"date-time":function(e){return!isNaN(Date.parse(e))&&e.indexOf(`/`)===-1},uppercase:function(e){return e===e.toUpperCase()},lowercase:function(e){return e===e.toLowerCase()},hostname:function(e){return e.length<256&&/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$/.test(e)},uri:function(e){return/[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/.test(e)},email:function(e){return/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/.test(e)},ipv4:function(e){return!!(/^(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)$/.test(e)&&e.split(`.`).sort()[3]<=255)},ipv6:function(e){return/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/.test(e)}},s={readOnly:function(e,t){return!1},minimum:function(e,t,n){return!(e<t||n.exclusiveMinimum&&e<=t)},maximum:function(e,t,n){return!(e>t||n.exclusiveMaximum&&e>=t)},multipleOf:function(e,t){return e/t%1==0||typeof e!=`number`},pattern:function(e,t){if(typeof e!=`string`)return!0;var n,r;return typeof t==`string`?n=t:(n=t[0],r=t[1]),new RegExp(n,r).test(e)},minLength:function(e,t){return e.length>=t||typeof e!=`string`},maxLength:function(e,t){return e.length<=t||typeof e!=`string`},minItems:function(e,t){return e.length>=t||!Array.isArray(e)},maxItems:function(e,t){return e.length<=t||!Array.isArray(e)},uniqueItems:function(e,t){for(var n={},r,i=0,a=e.length;i<a;i++){if(r=JSON.stringify(e[i]),n.hasOwnProperty(r))return!1;n[r]=!0}return!0},minProperties:function(e,t){if(typeof e!=`object`)return!0;var n=0;for(var r in e)e.hasOwnProperty(r)&&(n+=1);return n>=t},maxProperties:function(e,t){if(typeof e!=`object`)return!0;var n=0;for(var r in e)e.hasOwnProperty(r)&&(n+=1);return n<=t},constant:function(e,t){return JSON.stringify(e)==JSON.stringify(t)},enum:function(e,t){var n,r,i;if(typeof e==`object`){for(i=JSON.stringify(e),n=0,r=t.length;n<r;n++)if(i===JSON.stringify(t[n]))return!0}else for(n=0,r=t.length;n<r;n++)if(e===t[n])return!0;return!1}},c=function(e){return e.indexOf(`://`)===-1?e:e.split(`#`)[0]},l=function(e,t,n){var r,i,a=n.indexOf(`#`),o;if(a===-1)return e.schema.hasOwnProperty(n)?[e.schema[n]]:null;if(a>0)if(o=n.substr(0,a),n=n.substr(a+1),e.schema.hasOwnProperty(o))t=[e.schema[o]];else if(t&&t[0].id===o)t=[t[0]];else return null;else{if(!t)return null;n=n.substr(1)}if(n===``)return[t[0]];if(n.charAt(0)===`/`){for(n=n.substr(1),r=t[0],i=n.split(`/`);i.length>0;){if(!r.hasOwnProperty(i[0]))return null;r=r[i[0]],t.push(r),i.shift()}return t}else return null},u=function(e,t){var n,r,i=e.length-1,a,o,s=/^(\d+)/.exec(t);if(s){if(t=t.substr(s[0].length),a=parseInt(s[1],10),a<0||a>i)return;if(o=e[i-a],t===`#`)return o.key}else o=e[0];if(r=o.object[o.key],t===``)return r;if(t.charAt(0)===`/`){for(t=t.substr(1),n=t.split(`/`);n.length>0;){if(n[0]=n[0].replace(/~1/g,`/`).replace(/~0/g,`~`),!r.hasOwnProperty(n[0]))return;r=r[n[0]],n.shift()}return r}else return},d=function(e,t,a,o){var s,c,f,p,m,h,g,_=!1,v={},y,b,x,S=t.length-1,C=t[S],w,T=a.length-1,ee=a[T].object,E=a[T].key,D=ee[E],te,ne;if(C.hasOwnProperty(`$ref`))return t=l(e,t,C.$ref),t?d(e,t,a,o):{$ref:C.$ref};if(C.hasOwnProperty(`type`))if(typeof C.type==`string`){if(o.useCoerce&&e.coerceType.hasOwnProperty(C.type)&&(D=ee[E]=e.coerceType[C.type](D)),!e.fieldType[C.type](D))return{type:C.type}}else{for(_=!0,s=0,c=C.type.length;s<c&&_;s++)e.fieldType[C.type[s]](D)&&(_=!1);if(_)return{type:C.type}}if(C.hasOwnProperty(`allOf`)){for(s=0,c=C.allOf.length;s<c;s++)if(y=d(e,t.concat(C.allOf[s]),a,o),y)return y}if(!o.useCoerce&&!o.useDefault&&!o.removeAdditional){if(C.hasOwnProperty(`oneOf`)){for(ne=1/0,s=0,c=C.oneOf.length,f=0;s<c;s++)if(y=d(e,t.concat(C.oneOf[s]),a,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else if(f+=1,f>1)break;if(f>1)return{oneOf:!0};if(f<1)return v;v={}}if(C.hasOwnProperty(`anyOf`)){for(v=null,ne=1/0,s=0,c=C.anyOf.length;s<c;s++)if(y=d(e,t.concat(C.anyOf[s]),a,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else{v=null;break}if(v)return v}if(C.hasOwnProperty(`not`)&&(y=d(e,t.concat(C.not),a,o),!y))return{not:!0}}else{if(C.hasOwnProperty(`oneOf`)){for(ne=1/0,s=0,c=C.oneOf.length,f=0;s<c;s++)if(w=n(a),y=d(e,t.concat(C.oneOf[s]),w,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else{if(f+=1,f>1)break;r(w,a)}if(f>1)return{oneOf:!0};if(f<1)return v;v={}}if(C.hasOwnProperty(`anyOf`)){for(v=null,ne=1/0,s=0,c=C.anyOf.length;s<c;s++)if(w=n(a),y=d(e,t.concat(C.anyOf[s]),w,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else{r(w,a),v=null;break}if(v)return v}if(C.hasOwnProperty(`not`)&&(w=n(a),y=d(e,t.concat(C.not),w,o),!y))return{not:!0}}if(C.hasOwnProperty(`dependencies`)){for(h in C.dependencies)if(C.dependencies.hasOwnProperty(h)&&D.hasOwnProperty(h)){if(Array.isArray(C.dependencies[h])){for(s=0,c=C.dependencies[h].length;s<c;s++)if(!D.hasOwnProperty(C.dependencies[h][s]))return{dependencies:!0}}else if(y=d(e,t.concat(C.dependencies[h]),a,o),y)return y}}if(Array.isArray(D)){if(C.hasOwnProperty(`items`))if(Array.isArray(C.items)){for(s=0,c=C.items.length;s<c;s++)y=d(e,t.concat(C.items[s]),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0);if(D.length>c&&C.hasOwnProperty(`additionalItems`))if(typeof C.additionalItems==`boolean`){if(!C.additionalItems)return{additionalItems:!0}}else for(s=c,c=D.length;s<c;s++)y=d(e,t.concat(C.additionalItems),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0)}else for(s=0,c=D.length;s<c;s++)y=d(e,t.concat(C.items),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0);else if(C.hasOwnProperty(`additionalItems`)&&typeof C.additionalItems!=`boolean`)for(s=0,c=D.length;s<c;s++)y=d(e,t.concat(C.additionalItems),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0);if(_)return{schema:v}}else{for(h in b=[],v={},D)D.hasOwnProperty(h)&&b.push(h);if(o.checkRequired&&C.required)for(s=0,c=C.required.length;s<c;s++)D.hasOwnProperty(C.required[s])||(v[C.required[s]]={required:!0},_=!0);if(p=C.hasOwnProperty(`properties`),m=C.hasOwnProperty(`patternProperties`),p||m)for(s=b.length;s--;){if(x=!1,p&&C.properties.hasOwnProperty(b[s])&&(x=!0,y=d(e,t.concat(C.properties[b[s]]),a.concat({object:D,key:b[s]}),o),y!==null&&(v[b[s]]=y,_=!0)),m)for(h in C.patternProperties)C.patternProperties.hasOwnProperty(h)&&b[s].match(h)&&(x=!0,y=d(e,t.concat(C.patternProperties[h]),a.concat({object:D,key:b[s]}),o),y!==null&&(v[b[s]]=y,_=!0));x&&b.splice(s,1)}if(o.useDefault&&p&&!_)for(h in C.properties)C.properties.hasOwnProperty(h)&&!D.hasOwnProperty(h)&&C.properties[h].hasOwnProperty(`default`)&&(D[h]=C.properties[h].default);if(o.removeAdditional&&p&&C.additionalProperties!==!0&&typeof C.additionalProperties!=`object`)for(s=0,c=b.length;s<c;s++)delete D[b[s]];else if(C.hasOwnProperty(`additionalProperties`))if(typeof C.additionalProperties==`boolean`){if(!C.additionalProperties)for(s=0,c=b.length;s<c;s++)v[b[s]]={additional:!0},_=!0}else for(s=0,c=b.length;s<c;s++)y=d(e,t.concat(C.additionalProperties),a.concat({object:D,key:b[s]}),o),y!==null&&(v[b[s]]=y,_=!0);if(_)return{schema:v}}for(g in C)C.hasOwnProperty(g)&&!i.hasOwnProperty(g)&&(g===`format`?e.fieldFormat.hasOwnProperty(C[g])&&!e.fieldFormat[C[g]](D,C,a,o)&&(v[g]=!0,_=!0):e.fieldValidate.hasOwnProperty(g)&&!e.fieldValidate[g](D,C[g].hasOwnProperty(`$data`)?u(a,C[g].$data):C[g],C,a,o)&&(v[g]=!0,_=!0));return _?v:null},f={useDefault:!1,useCoerce:!1,checkRequired:!0,removeAdditional:!1};function p(){if(!(this instanceof p))return new p;this.coerceType={},this.fieldType=e(a),this.fieldValidate=e(s),this.fieldFormat=e(o),this.defaultOptions=e(f),this.schema={}}p.prototype={validate:function(e,t,n){var r=[e],i=null,a=[{object:{__root__:t},key:`__root__`}];if(typeof e==`string`&&(r=l(this,null,e),!r))throw Error(`jjv: could not find schema '`+e+`'.`);if(!n)n=this.defaultOptions;else for(var o in this.defaultOptions)this.defaultOptions.hasOwnProperty(o)&&!n.hasOwnProperty(o)&&(n[o]=this.defaultOptions[o]);return i=d(this,r,a,n),i?{validation:i.hasOwnProperty(`schema`)?i.schema:i}:null},resolveRef:function(e,t){return l(this,e,t)},addType:function(e,t){this.fieldType[e]=t},addTypeCoercion:function(e,t){this.coerceType[e]=t},addCheck:function(e,t){this.fieldValidate[e]=t},addFormat:function(e,t){this.fieldFormat[e]=t},addSchema:function(e,t){if(!t&&e&&(t=e,e=void 0),t.hasOwnProperty(`id`)&&typeof t.id==`string`&&t.id!==e){if(t.id.charAt(0)===`/`)throw Error(`jjv: schema id's starting with / are invalid.`);this.schema[c(t.id)]=t}else if(!e)throw Error(`jjv: schema needs either a name or id attribute.`);e&&(this.schema[c(e)]=t)}},t!==void 0&&t.exports!==void 0?t.exports=p:typeof define==`function`&&define.amd?define(function(){return p}):this.jjv=p}).call(e)})),Od=c(o(((e,t)=>{t.exports=Dd()}))(),1),kd=null;function Ad(e){let{id:t,context:n}=e,r=e=>P(n[e]),i=(e,t)=>{if(!P(n[e]))throw Error(`${t} plot accessor: you must provide '${e}'`)},a=(e,t)=>{if(!e.some(e=>r(e)))throw Error(`${t} plot accessor: you must provide either '${e[0]}' or '${e[1]}'`)},o=e=>{if(r(`placement`)&&n.placement===`clone`&&!r(`cloneUid`)&&!r(`cloneIndex`))throw Error(`${e} plot accessor: when placement is 'clone', you must provide either 'cloneUid' or 'cloneIndex'.`)};if(t===`Plot`)switch(n.id){case`Add`:switch(i(`type`,`Add`),n.type){case`Study`:i(`studyId`,`Add`),o(`Add`);break;case`IncomeStatement`:case`BalanceSheet`:i(`fundamentalId`,`Add`);break;case`Expression`:i(`expression`,`Add`);break}break;case`Get`:if(!r(`main`)&&!r(`type`))throw Error(`Get plot accessor: you must provide either 'main' or 'type'`);break;case`Delete`:i(`type`,`Delete`),a([`uid`,`index`],`Delete`);break;case`Update`:switch(i(`type`,`Update`),r(`main`)||a([`uid`,`index`],`Update`),o(`Update`),n.type){case`Forward`:if(!P(n.forward)){if(!P(n.curves)||!P(n.offsets))throw Error(`Update forward plot accessor: you must provide either 'forward' or 'curves' and 'offsets'`);if(n.curves.length!==n.offsets.length)throw Error(`Update forward plot accessor: you must provide same number of elements for 'curves' and 'offsets'`)}break;case`Seasonal`:if(!P(n.seasonal)){if(!P(n.curves)||!P(n.offsets))throw Error(`Update seasonal plot accessor: you must provide either 'seasonal' or 'curves' and 'offsets'`);if(n.curves.length!==n.offsets.length&&n.curves.length!==n.offsets.length+1)throw Error(`Update seasonal plot accessor: you must provide either same number of elements for 'curves' and 'offsets' or one curve more`)}break;case`Study`:{i(`studyId`,`Update`),o(`Update`);let e=e=>e.reduce((e,t)=>e.concat(t.fields),[]),t=B(n.studyId),r=e=>`Update study plot accessor: you must provide same number of elements for '${e}' of the study as defined in the taxonomy`,a=e=>`Update study plot accessor: incoming list of ${e} is different from the ${e} as defined in the taxonomy`;if(P(n.curves)){if(n.curves.length!==t.defaults.curves.length)throw Error(r(`curves`));let i=e(n.curves);if(j(e(t.defaults.curves),i).length!==0)throw Error(a(`fields`))}break}}break}}function jd(){kd===null&&(kd=(0,Od.default)(),kd.defaultOptions.useDefault=!0,[z.CHART_SCHEMA,z.STUDIES_SCHEMA,z.FIELDS_SCHEMA,z.ACCESSOR_SCHEMA].forEach(e=>{kd.addSchema(e,ss(e))}))}function Md(e,t){kd.addSchema(e,t)}function Nd(e){V(e,`..plots{.type}`).forEach(e=>{P(e.uid)||(e.uid=bt())}),V(e,`..plots{.type==="${C[C.Study]}"}`).forEach(e=>{let t=B(e.study);P(t)&&ut(e,t.defaults)})}function Pd(e){return e===z.CHART_SCHEMA}function Fd(e){return e===z.ACCESSOR_SCHEMA}function Id(e,t){jd();let n=Pl(e,t);Pd(t)&&(Nd(n),n=Ed(n));let r=kd.validate(t,n);if(r){let e=JSON.stringify(r,null,4);throw Error(`Document not valid according to schema ${t}; error is ${e}`)}return Fd(t)&&Ad(n),n}function Ld(e){return H(H(e,`..panes{.axes{!.plots}}`,e=>(e.axes.length===1?e.axes=[]:e.axes[1].plots.length===0&&(e.axes.pop(),e.axes[0].plots.length===0&&(e.axes=[])),e)),`..panes{!.axes}`,e=>z.NULL_OBJECT)}var Rd=JSON.parse(`[{"id":"DateTime","type":"Date"},{"id":"Open"},{"id":"High"},{"id":"Low"},{"id":"Close"},{"id":"TradeSize","format":"AsInteger"},{"id":"Volume","format":"UseMetricUnit","shortName":"VOL"},{"id":"OpenInterest","format":"UseMetricUnit","shortName":"OI"},{"id":"Last"},{"id":"Bid"},{"id":"BidSize","format":"AsInteger"},{"id":"Ask"},{"id":"AskSize","format":"AsInteger"},{"id":"Symbol","type":"String"},{"id":"Change"},{"id":"PercentChange","format":"AsPercent"},{"id":"TradingDay"},{"id":"PreviousClose"},{"id":"PreviousOpen"},{"id":"PreviousHigh"},{"id":"PreviousLow"},{"id":"WeekPreviousClose"},{"id":"WeekPreviousHigh"},{"id":"WeekPreviousLow"},{"id":"MonthPreviousClose"},{"id":"MonthPreviousHigh"},{"id":"MonthPreviousLow"},{"id":"YearHigh"},{"id":"YearLow"},{"id":"Projection","name":"Projection"},{"id":"BarIndex","name":"Bar Index"},{"id":"Dividends","type":"String","category":"Event","name":"Dividend","shortName":"D"},{"id":"Splits","type":"String","category":"Event","name":"Split","shortName":"S"},{"id":"Earnings","type":"String","category":"Event","shortName":"E"},{"id":"Buy","category":"Event","name":"BuySignal","shortName":"B"},{"id":"Sell","category":"Event","name":"SellSignal","shortName":"S"},{"id":"Custom","category":"Event","name":"CustomEvent","shortName":"Z"},{"id":"Call","category":"Option"},{"id":"Put","category":"Option"},{"id":"Delta","category":"Option"},{"id":"Gamma","category":"Option"},{"id":"Theta","category":"Option"},{"id":"Vega","category":"Option"},{"id":"WeighImplVolHigh","category":"Option","name":"Implied Volatility High","shortName":"WeighImplVolHigh"},{"id":"WeighImplVolLow","category":"Option","name":"Implied Volatility Low","shortName":"WeighImplVolLow"},{"id":"WeighImplVol","category":"Option","name":"Implied Volatility","shortName":"WeighImplVol"},{"id":"WeighImplVolHigh5D","category":"Option","name":"Weighted Implied Volatility High 5D","shortName":"WeighImplVolHigh5D"},{"id":"WeighImplVolLow5D","category":"Option","name":"Weighted Implied Volatility Low 5D","shortName":"WeighImplVolLow5D"},{"id":"WeighImplVol5D","category":"Option","name":"Weighted Implied Volatility 5D","shortName":"WeighImplVol5D"},{"id":"WeighImplVolHigh1M","category":"Option","name":"Weighted Implied Volatility High 1M","shortName":"WeighImplVolHigh1M"},{"id":"WeighImplVolLow1M","category":"Option","name":"Weighted Implied Volatility Low 1M","shortName":"WeighImplVolLow1M"},{"id":"WeighImplVol1M","category":"Option","name":"Weighted Implied Volatility 1M","shortName":"WeighImplVol1M"},{"id":"WeighImplVolHigh3M","category":"Option","name":"Weighted Implied Volatility High 3M","shortName":"WeighImplVolHigh3M"},{"id":"WeighImplVolLow3M","category":"Option","name":"Weighted Implied Volatility Low 3M","shortName":"WeighImplVolLow3M"},{"id":"WeighImplVol3M","category":"Option","name":"Weighted Implied Volatility 3M","shortName":"WeighImplVol3M"},{"id":"WeighImplVolHigh6M","category":"Option","name":"Weighted Implied Volatility High 6M","shortName":"WeighImplVolHigh6M"},{"id":"WeighImplVolLow6M","category":"Option","name":"Weighted Implied Volatility Low 6M","shortName":"WeighImplVolLow6M"},{"id":"WeighImplVol6M","category":"Option","name":"Weighted Implied Volatility 6M","shortName":"WeighImplVol6M"},{"id":"WeighImplVolHigh1Y","category":"Option","name":"Weighted Implied Volatility High 1Y","shortName":"WeighImplVolHigh1Y"},{"id":"WeighImplVolLow1Y","category":"Option","name":"Weighted Implied Volatility Low 1Y","shortName":"WeighImplVolLow1Y"},{"id":"WeighImplVol1Y","category":"Option","name":"Weighted Implied Volatility 1Y","shortName":"WeighImplVol1Y"},{"id":"WeighImplVolHighYTD","category":"Option","name":"Weighted Implied Volatility High YTD","shortName":"WeighImplVolHighYTD"},{"id":"WeighImplVolLowYTD","category":"Option","name":"Weighted Implied Volatility Low YTD","shortName":"WeighImplVolLowYTD"},{"id":"WeighImplVolYTD","category":"Option","name":"Weighted Implied Volatility YTD","shortName":"WeighImplVolYTD"},{"id":"WeighImplVolChg","category":"Option","name":"Weighted Implied Volatility Change","shortName":"WeighImplVolChg"},{"id":"ImplVolRank5D","category":"Option","name":"Implied Volatility Rank 5D","shortName":"ImplVolRank5D"},{"id":"ImplVolRank1M","category":"Option","name":"Implied Volatility Rank 1M","shortName":"ImplVolRank1M"},{"id":"ImplVolRank3M","category":"Option","name":"Implied Volatility Rank 3M","shortName":"ImplVolRank3M"},{"id":"ImplVolRank6M","category":"Option","name":"Implied Volatility Rank 6M","shortName":"ImplVolRank6M"},{"id":"ImplVolRank1Y","category":"Option","name":"Implied Volatility Rank","shortName":"ImplVolRank1Y"},{"id":"ImplVolRankYTD","category":"Option","name":"Implied Volatility Rank YTD","shortName":"ImplVolRankYTD"},{"id":"ImplVolPerc5D","category":"Option","name":"Implied Volatility Perc. 5D","shortName":"ImplVolPerc5D"},{"id":"ImplVolPerc1M","category":"Option","name":"Implied Volatility Perc. 1M","shortName":"ImplVolPerc1M"},{"id":"ImplVolPerc3M","category":"Option","name":"Implied Volatility Perc. 3M","shortName":"ImplVolPerc3M"},{"id":"ImplVolPerc6M","category":"Option","name":"Implied Volatility Perc. 6M","shortName":"ImplVolPerc6M"},{"id":"ImplVolPerc1Y","category":"Option","name":"Implied Volatility Percentile","shortName":"ImplVolPerc1Y"},{"id":"ImplVolPercYTD","category":"Option","name":"Implied Volatility Perc. YTD","shortName":"ImplVolPercYTD"},{"id":"OptTotVol","category":"Option","name":"Options Total Volume","shortName":"OptTotVol","format":"UseMetricUnit"},{"id":"OptCallVol","category":"Option","name":"Options Call Volume","shortName":"OptCallVol","format":"UseMetricUnit"},{"id":"OptPutVol","category":"Option","name":"Options Put Volume","shortName":"OptPutVol","format":"UseMetricUnit"},{"id":"PutCallVolRatio","category":"Option","name":"Put Call Volume Ratio","shortName":"PutCallVolRatio"},{"id":"TotalOpenInt","category":"Option","name":"Total Open Interest","shortName":"Total OI","format":"UseMetricUnit"},{"id":"CallOpenInt","category":"Option","name":"Call Open Interest","shortName":"Call OI","format":"UseMetricUnit"},{"id":"PutOpenInt","category":"Option","name":"Put Open Interest","shortName":"Put OI","format":"UseMetricUnit"},{"id":"PutCallOIRatio","category":"Option","name":"Put Call OI Ratio","shortName":"Put Call OI Ratio"},{"id":"CallIVCurve","category":"Option","name":"Call IV Curve","shortName":"Call IV Curve"},{"id":"PutIVCurve","category":"Option","name":"Put IV Curve","shortName":"Put IV Curve"},{"id":"CallTheoretical","category":"Option","name":"Call Theoretical","shortName":"Call Theoretical"},{"id":"PutTheoretical","category":"Option","name":"Put Theoretical","shortName":"Put Theoretical"},{"id":"HL/2","category":"Study","name":"(High+Low)/2","shortName":"(H+L)/2"},{"id":"OC/2","category":"Study","name":"(Open+Close)/2","shortName":"(O+C)/2"},{"id":"HLC/3","category":"Study","name":"(High+Low+Close)/3","shortName":"(H+L+C)/3"},{"id":"OHLC/4","category":"Study","name":"(Open+High+Low+Close)/4","shortName":"(O+H+L+C)/4"},{"id":"HLCC/4","category":"Study","name":"(High+Low+Close+Close)/4","shortName":"(H+L+C+C)/4"},{"id":"AVG","category":"Study","name":"Average","shortName":"AVG"},{"id":"FRAMA","category":"Study","name":"FRAMA","shortName":"FRAMA"},{"id":"MA","category":"Study","name":"MA-Simple","shortName":"MA"},{"id":"MACLD1","category":"Study","name":"MA-Cloud-Fast","shortName":"MACLD1"},{"id":"MACLD2","category":"Study","name":"MA-Cloud-Slow","shortName":"MACLD2"},{"id":"MA1","category":"Study","name":"MA1-Simple","shortName":"MA1"},{"id":"MA2","category":"Study","name":"MA2-Simple","shortName":"MA2"},{"id":"MA3","category":"Study","name":"MA3-Simple","shortName":"MA3"},{"id":"MA4","category":"Study","name":"MA4-Simple","shortName":"MA4"},{"id":"MA5","category":"Study","name":"MA5-Simple","shortName":"MA5"},{"id":"MA6","category":"Study","name":"MA6-Simple","shortName":"MA6"},{"id":"MA7","category":"Study","name":"MA7-Simple","shortName":"MA7"},{"id":"MA8","category":"Study","name":"MA8-Simple","shortName":"MA8"},{"id":"MA9","category":"Study","name":"MA9-Simple","shortName":"MA9"},{"id":"MA10","category":"Study","name":"MA10-Simple","shortName":"MA10"},{"id":"MAS","category":"Study","name":"MA-Shorter","shortName":"MAS"},{"id":"MAL","category":"Study","name":"MA-Longer","shortName":"MAL"},{"id":"CMBCI","category":"Study","name":"Composite Index","shortName":"CMBCI"},{"id":"CMBCIF","category":"Study","name":"Fast Ma","shortName":"CMBCIF"},{"id":"CMBCIS","category":"Study","name":"Slow Ma","shortName":"CMBCIS"},{"id":"COTI","category":"Study","name":"COT Index","shortName":"COTI"},{"id":"CHEXL","category":"Study","name":"ChandelierExitLong","shortName":"CHEXL"},{"id":"CHEXS","category":"Study","name":"ChandelierExitShort","shortName":"CHEXS"},{"id":"SUPTR","category":"Study","name":"Supertrend","shortName":"SUPTR"},{"id":"BARCOLIX","category":"Study","name":"BarColorIndex","shortName":"BARCOLIX"},{"id":"BARKIND","category":"Study","name":"BarKind","shortName":"BARKIND"},{"id":"BREL","category":"Study","name":"BarRelation","shortName":"BREL"},{"id":"EMA","category":"Study","name":"MA-Exp","shortName":"MA(EXP)"},{"id":"MAHI","category":"Study","name":"MA-High","shortName":"MA(HI)"},{"id":"MALO","category":"Study","name":"MA-Low","shortName":"MA(LO)"},{"id":"MACD","category":"Study","name":"MACD","shortName":"MACD"},{"id":"MACDS","category":"Study","name":"MACD-Signal","shortName":"MACD(S)"},{"id":"MACDH","category":"Study","name":"MACD-Histogram","shortName":"MACD(H)"},{"id":"MACDV","category":"Study","name":"MACD-V","shortName":"MACD-V"},{"id":"MACDVS","category":"Study","name":"MACD-V-Signal","shortName":"MACD-V(S)"},{"id":"MACDVH","category":"Study","name":"MACD-V-Histogram","shortName":"MACD-V(H)"},{"id":"ENVU","category":"Study","name":"Envelope-Up","shortName":"ENV(UP)"},{"id":"ENVD","category":"Study","name":"Envelope-Down","shortName":"ENV(DN)"},{"id":"ENVEXPU","category":"Study","name":"Envelope-Exponential-Up","shortName":"ENVEXP(UP)"},{"id":"ENVEXPD","category":"Study","name":"Envelope-Exponential-Down","shortName":"ENVEXP(DN)"},{"id":"ENVSMOU","category":"Study","name":"Envelope-Smoothed-Up","shortName":"ENVSMO(UP)"},{"id":"ENVSMOD","category":"Study","name":"Envelope-Smoothed-Down","shortName":"ENVSMO(DN)"},{"id":"SMA","category":"Study","name":"MA-Smoothed","shortName":"MA(S)"},{"id":"CSHO","category":"Study","name":"Cash-Overlay","shortName":"CSHO"},{"id":"CSHB","category":"Study","name":"Cash-Basis","shortName":"CSHB"},{"id":"MKTCAP","category":"Study","name":"Market-Cap","format":"UseMetricUnit","shortName":"MktCap"},{"id":"TMA","category":"Study","name":"MA-Triangular","shortName":"MA(TRI)"},{"id":"WMA","category":"Study","name":"MA-Weighted","shortName":"MA(W)"},{"id":"VOLMA","category":"Study","format":"UseMetricUnit","name":"MA-Volume","shortName":"VOLMA"},{"id":"OSC","category":"Study","name":"OSC","shortName":"OSC"},{"id":"VOSC","category":"Study","format":"UseMetricUnit","name":"OSC-Volume","shortName":"VOLOSC"},{"id":"RSI","category":"Study","name":"RSI","shortName":"RSI"},{"id":"RSIAVG","category":"Study","name":"RSI-Average","shortName":"RSIAVG"},{"id":"RSA","category":"Study","name":"RSA","shortName":"RSA"},{"id":"RSAAVG","category":"Study","name":"RSA-Average","shortName":"RSIAVG"},{"id":"STORSI","category":"Study","name":"StochRSI","shortName":"STOCHRSI"},{"id":"STORSIAVG","category":"Study","name":"StochRSIAvg","shortName":"STOCHRSIAVG"},{"id":"HH","category":"Study","name":"HighestHigh","shortName":"HHIGH"},{"id":"LL","category":"Study","name":"LowestLow","shortName":"LLOW"},{"id":"PercK","category":"Study","name":"%K","shortName":"PCNTK"},{"id":"PercD","category":"Study","name":"%D","shortName":"PCNTD"},{"id":"PercR","category":"Study","name":"%R","shortName":"PCNTR"},{"id":"WGCL","category":"Study","name":"WeightedClose","shortName":"WTCL"},{"id":"WGALPH","category":"Study","name":"WeightedAlpha","shortName":"WGALPH"},{"id":"UPVOL","category":"Study","format":"UseMetricUnit","name":"UpVol","shortName":"UPVOL"},{"id":"DNVOL","category":"Study","format":"UseMetricUnit","name":"DownVol","shortName":"DNVOL"},{"id":"TOTVOL","category":"Study","format":"UseMetricUnit","name":"TotVol","shortName":"TOTVOL"},{"id":"POC","category":"Study","name":"PointOfControl","shortName":"POC"},{"id":"VAREA","category":"Study","name":"ValueArea","shortName":"VAREA"},{"id":"BARBACK","category":"Study","name":"Background","shortName":"BARBACK"},{"id":"BOLLBU","category":"Study","name":"Bollinger-Upper","shortName":"BOLL(U)"},{"id":"BOLLBL","category":"Study","name":"Bollinger-Lower","shortName":"BOLL(L)"},{"id":"BOLLBM","category":"Study","name":"Bollinger-Mid","shortName":"BOLL(M)"},{"id":"BOLLW","category":"Study","name":"Bollinger-Width","shortName":"BOLL(W)"},{"id":"BOLLP","category":"Study","name":"Bollinger-Percent","shortName":"BOLL(%B)"},{"id":"BOLLBW","category":"Study","name":"Bollinger-BandWidth","shortName":"BOLL(BW)"},{"id":"BOLLBWA","category":"Study","name":"Bollinger-BandWidthAvg","shortName":"BOLL(BWA)"},{"id":"PCUP1","category":"Study","name":"ProbCone-Up1","shortName":"PCUP1"},{"id":"PCDN1","category":"Study","name":"ProbCone-Down1","shortName":"PCDN1"},{"id":"PCUP2","category":"Study","name":"ProbCone-Up2","shortName":"PCUP2"},{"id":"PCDN2","category":"Study","name":"ProbCone-Down2","shortName":"PCDN2"},{"id":"PCUP3","category":"Study","name":"ProbCone-Up3","shortName":"PCUP3"},{"id":"PCDN3","category":"Study","name":"ProbCone-Down3","shortName":"PCDN3"},{"id":"PCTD","category":"Study","name":"ProbCone-TgtDate","shortName":"PCTD"},{"id":"PCTP","category":"Study","name":"ProbCone-TgtPrice","shortName":"PCTP"},{"id":"MBBUO","category":"Study","name":"ModifiedBoll-UppOut","shortName":"MBOLL(UO)"},{"id":"MBBUI","category":"Study","name":"ModifiedBoll-UppIn","shortName":"MBOLL(UI)"},{"id":"MBBM","category":"Study","name":"ModifiedBoll-Mid","shortName":"MBOLL(M)"},{"id":"MBBLI","category":"Study","name":"ModifiedBoll-LowIn","shortName":"MBOLL(LI)"},{"id":"MBBLO","category":"Study","name":"ModifiedBoll-LowOut","shortName":"MBOLL(LO)"},{"id":"OBVOL","category":"Study","format":"UseMetricUnit","name":"OnBalanceVol","shortName":"OBVOL"},{"id":"OBVOLAVG","category":"Study","format":"UseMetricUnit","name":"OnBalanceVolAvg","shortName":"OBVOL"},{"id":"TR","category":"Study","name":"TrueRange","shortName":"TR"},{"id":"ATR","category":"Study","name":"AvgTrueRange","shortName":"ATR"},{"id":"ATRMA","category":"Study","name":"MA-ATR","shortName":"MA(ATR)"},{"id":"ADJATR","category":"Study","name":"AdjAvgTrueRange","shortName":"ADJATR"},{"id":"COTR","category":"Study","name":"ChgOverTrueRange","shortName":"COTR"},{"id":"ATRP","category":"Study","name":"AvgTrueRangePerc","shortName":"ATRP"},{"id":"STOMOMIX","category":"Study","name":"StochMomIndex","shortName":"STOMOMIX"},{"id":"CHDMOMOSC","category":"Study","name":"ChandeMomOsc","shortName":"CHDMOMOSC"},{"id":"CHDMOMOSCAVG","category":"Study","name":"ChandeMomOsc-Avg","shortName":"CHDMOMOSCAVG"},{"id":"PDI","category":"Study","name":"+DI","shortName":"+DI"},{"id":"MDI","category":"Study","name":"-DI","shortName":"-DI"},{"id":"PLVI","category":"Study","name":"+VI","shortName":"+VI"},{"id":"MNVI","category":"Study","name":"-VI","shortName":"-VI"},{"id":"ADX","category":"Study","name":"ADX","shortName":"ADX"},{"id":"ADXM","category":"Study","name":"ADX-Modified","shortName":"ADXM"},{"id":"ADL","category":"Study","format":"UseMetricUnit","name":"AccDist","shortName":"ACCDIS"},{"id":"ADWM","category":"Study","name":"AccDistWill","shortName":"ACCDISWIL"},{"id":"ADWMMA","category":"Study","name":"AccDistWillMovAvg","shortName":"ACCDISWILMA"},{"id":"MCGD","category":"Study","name":"McGinleyDyn","shortName":"MCGD"},{"id":"HMA","category":"Study","name":"HullMovAvg","shortName":"HMA"},{"id":"COPP","category":"Study","name":"CoppCurve","shortName":"COPP"},{"id":"CHAOSC","category":"Study","format":"UseMetricUnit","name":"ChaikinOsc","shortName":"CHAIKOSC"},{"id":"TP","category":"Study","name":"TypicalPrice","shortName":"TP"},{"id":"KCUP","category":"Study","name":"KeltChan-Up","shortName":"KELT(UP)"},{"id":"KCMID","category":"Study","name":"KeltChan-Mid","shortName":"KELT(MID)"},{"id":"KCLOW","category":"Study","name":"KeltChan-Low","shortName":"KELT(LO)"},{"id":"KBUP","category":"Study","name":"KeltBands-Up","shortName":"KELB(UP)"},{"id":"KBMID","category":"Study","name":"KeltBands-Mid","shortName":"KELB(MID)"},{"id":"KBLOW","category":"Study","name":"KeltBands-Low","shortName":"KELB(LO)"},{"id":"DONUP","category":"Study","name":"Donchian-Up","shortName":"DON(U)"},{"id":"DONMID","category":"Study","name":"Donchian-Mid","shortName":"DON(M)"},{"id":"DONLOW","category":"Study","name":"Donchian-Low","shortName":"DON(L)"},{"id":"DONW","category":"Study","name":"Donchian-Width","shortName":"DON(W)"},{"id":"PVT","category":"Study","format":"UseMetricUnit","name":"PriceVolChange","shortName":"PVOL"},{"id":"TRIX","category":"Study","name":"Triple-MA-Exp","shortName":"TRIX"},{"id":"ROC","category":"Study","name":"RateOfChange","shortName":"ROC"},{"id":"PVPT","category":"Study","name":"PivotPoint","shortName":"PVMOV"},{"id":"PVPTR","category":"Study","name":"PvtPt-Resistance","shortName":"PVMOV(R)"},{"id":"PVPTS","category":"Study","name":"PvtPt-Support","shortName":"PVMOV(S)"},{"id":"FISHER","category":"Study","name":"Fisher","shortName":"Fisher"},{"id":"FISHTRG","category":"Study","name":"Fisher-Trigger","shortName":"Trigger"},{"id":"ARNUP","category":"Study","name":"Aroon-Up","shortName":"ARN(UP)"},{"id":"ARNLOW","category":"Study","name":"Aroon-Down","shortName":"ARN(DN)"},{"id":"VSTOPUP","category":"Study","name":"VolaStop-Up","shortName":"VSTOP(UP)"},{"id":"VSTOPLOW","category":"Study","name":"VolaStop-Down","shortName":"VSTOP(DN)"},{"id":"ARNOSC","category":"Study","name":"Aroon-Osci","shortName":"ARNOSC"},{"id":"TCHNUP","category":"Study","name":"TurtleChn-Up","shortName":"TCH(UP)"},{"id":"TCHNLOW","category":"Study","name":"TurtleChn-Low","shortName":"TCH(LO)"},{"id":"TCHRE","category":"Study","name":"TurtleChnRetrace","shortName":"TCHRE"},{"id":"ALJAW","category":"Study","name":"Alligator-Jaw","shortName":"AL(J)"},{"id":"ALTEETH","category":"Study","name":"Alligator-Teeth","shortName":"AL(T)"},{"id":"ALLIPS","category":"Study","name":"Alligator-Lips","shortName":"AL(L)"},{"id":"PLTLN","category":"Study","name":"PlotLine","shortName":"LINE"},{"id":"AWOS","category":"Study","name":"AwesomeOsc","shortName":"AWOSC"},{"id":"AWOSMA","category":"Study","name":"AwesomeOsc-MA","shortName":"AWOSC(MA)"},{"id":"MFMUL","category":"Study","name":"MoneyFlowMul"},{"id":"CLV","category":"Study","name":"CloseLocationValue","shortName":"CLV"},{"id":"CHOP","category":"Study","name":"ChoppinessIndex","shortName":"ChopIx"},{"id":"CHAMF","category":"Study","name":"ChaikinMoneyFlow","shortName":"CHAIKMF"},{"id":"CHAVOL","category":"Study","name":"ChaikinVolatility","shortName":"CHAIKVOL"},{"id":"DPO","category":"Study","name":"DetrendedPriceOsc","shortName":"DPO"},{"id":"CCI","category":"Study","name":"CommodityChannelIndex","shortName":"CCI"},{"id":"EMV","category":"Study","name":"EaseOfMovement","shortName":"EOM"},{"id":"EMVMA","category":"Study","name":"EaseOfMovementMA","shortName":"EOM(MA)"},{"id":"ERBLPOW","category":"Study","name":"ElderRayBullPow","shortName":"ER(BULL)"},{"id":"ERBRPOW","category":"Study","name":"ElderRayBearPow","shortName":"ER(BEAR)"},{"id":"FI","category":"Study","format":"UseMetricUnit","name":"ForceIndex","shortName":"FORCE"},{"id":"MI","category":"Study","name":"MassIndex","shortName":"MASS"},{"id":"MOM","category":"Study","name":"Momentum","shortName":"MOM"},{"id":"MOMMA","category":"Study","name":"MA-Momentum","shortName":"MA(MOM)"},{"id":"MFI","category":"Study","name":"MoneyFlowIndex","shortName":"MFI"},{"id":"MSD","category":"Study","name":"MovingStdDev","shortName":"MSD"},{"id":"PCTCHG","category":"Study","name":"PercentChange","shortName":"PCTCHG"},{"id":"LINRUP","category":"Study","name":"LinRegUpper","shortName":"LINRUP"},{"id":"LINRMID","category":"Study","name":"LinRegMiddle","shortName":"LINRMID"},{"id":"LINRLOW","category":"Study","name":"LinRegLower","shortName":"LINRLOW"},{"id":"NVI","category":"Study","name":"NegativeVolIndex","shortName":"NVI"},{"id":"NVIEMA","category":"Study","name":"NegativeVolIndexEMA","shortName":"NVI(EMA)"},{"id":"PVI","category":"Study","name":"PositiveVolIndex","shortName":"PVI"},{"id":"PVIEMA","category":"Study","name":"PositiveVolIndexEMA","shortName":"PVI(EMA)"},{"id":"PPO","category":"Study","name":"PercPriceOsc","shortName":"PPO"},{"id":"PPOS","category":"Study","name":"PPO-Signal","shortName":"PPO(S)"},{"id":"PPOH","category":"Study","name":"PPO-Histogram","shortName":"PPO(H)"},{"id":"PVO","category":"Study","name":"PercVolOsc","shortName":"PVO"},{"id":"PVOS","category":"Study","name":"PVO-Signal","shortName":"PVO(S)"},{"id":"PVOH","category":"Study","name":"PVO-Histogram","shortName":"PVO(H)"},{"id":"HV","category":"Study","name":"HistVolatility","shortName":"HISTVOL"},{"id":"PERF","category":"Study","name":"Performance","shortName":"PERF"},{"id":"STC","category":"Study","name":"SchaffTrendCycle","shortName":"STC"},{"id":"MCCLO","category":"Study","name":"McClellanOsc","shortName":"MCCLO"},{"id":"BTI","category":"Study","name":"BreadthThrust","shortName":"BTI"},{"id":"NHLAI","category":"Study","name":"NewHiLoAccIx","shortName":"NHLAI"},{"id":"KST","category":"Study","name":"KnowSureThing","shortName":"KST"},{"id":"KSTSIG","category":"Study","name":"KST-Signal","shortName":"KSTSIG"},{"id":"WASI","category":"Study","name":"WilderAccSwingIndex","shortName":"WACCSW"},{"id":"WWVSARU","category":"Study","name":"WilderVolSarUp","shortName":"WVOL-UP"},{"id":"WWVSARD","category":"Study","name":"WilderVolSarDown","shortName":"WVOL-DN"},{"id":"PARSARS","category":"Study","name":"ParabolicSarShort","shortName":"SHORT"},{"id":"PARSARL","category":"Study","name":"ParabolicSarLong","shortName":"LONG"},{"id":"REATRS","category":"Study","name":"RetraceATRStop","shortName":"REATRS"},{"id":"MOVLR","category":"Study","name":"MovingLinRegression","shortName":"MOVLINREG"},{"id":"TRSP1","category":"Study","name":"TrendSeeker®","shortName":"TREND"},{"id":"TRSP2","category":"Study","name":"TrendSeeker®","shortName":"TREND"},{"id":"TARGP","category":"Study","name":"Target Price","shortName":"TARGP"},{"id":"COTLCCMSP","category":"Study","name":"Comm Spec","shortName":"COT(C)"},{"id":"COTLCLGSP","category":"Study","name":"Large Spec","shortName":"COT(L)"},{"id":"COTLCSMSP","category":"Study","name":"Small Spec","shortName":"COT(S)"},{"id":"COTDAGPRO","category":"Study","name":"Producers","shortName":"COTDIS(P)"},{"id":"COTDAGSPD","category":"Study","name":"Swap Dealers","shortName":"COTDIS(S)"},{"id":"COTDAGMNM","category":"Study","name":"Managed Money","shortName":"COTDIS(M)"},{"id":"COTDAGOTH","category":"Study","name":"Other Report","shortName":"COTDIS(O)"},{"id":"COTFTRDLI","category":"Study","name":"Dealer Intermediary","shortName":"COTFIN(D)"},{"id":"COTFTRASM","category":"Study","name":"Asset Manager","shortName":"COTFIN(A)"},{"id":"COTFTRLVF","category":"Study","name":"Leveraged Funds","shortName":"COTFIN(L)"},{"id":"COTFTROTH","category":"Study","name":"Other Report","shortName":"COTFIN(O)"},{"id":"PPTPIV","category":"Study","name":"Pivot Point","shortName":"PPT(P)"},{"id":"PPTR1","category":"Study","name":"1st Resistance","shortName":"PPT(R1)"},{"id":"PPTR2","category":"Study","name":"2nd Resistance","shortName":"PPT(R2)"},{"id":"PPTR3","category":"Study","name":"3rd Resistance","shortName":"PPT(R3)"},{"id":"PPTS1","category":"Study","name":"1st Support","shortName":"PPT(S1)"},{"id":"PPTS2","category":"Study","name":"2nd Support","shortName":"PPT(S2)"},{"id":"PPTS3","category":"Study","name":"3rd Support","shortName":"PPT(S3)"},{"id":"CPPH4","category":"Study","name":"4th Camarilla Res","shortName":"CPP(H4)"},{"id":"CPPH3","category":"Study","name":"3rd Camarilla Res","shortName":"CPP(H3)"},{"id":"CPPH2","category":"Study","name":"2nd Camarilla Res","shortName":"CPP(H2)"},{"id":"CPPH1","category":"Study","name":"1st Camarilla Res","shortName":"CPP(H1)"},{"id":"CPPL1","category":"Study","name":"1st Camarilla Supp","shortName":"CPP(L1)"},{"id":"CPPL2","category":"Study","name":"2nd Camarilla Supp","shortName":"CPP(L2)"},{"id":"CPPL3","category":"Study","name":"3rd Camarilla Supp","shortName":"CPP(L3)"},{"id":"CPPL4","category":"Study","name":"4th Camarilla Supp","shortName":"CPP(L4)"},{"id":"IMPVOL","category":"Study","name":"Implied Volatility","shortName":"IV"},{"id":"CTM","category":"Study","name":"Cycle Trading Momentum","shortName":"CTM"},{"id":"CPMI","category":"Study","name":"Principal Momentum","shortName":"CPMI"},{"id":"CTPI","category":"Study","name":"Turning Point","shortName":"CTPI"},{"id":"CTLTM","category":"Study","name":"Long-Term Momentum","shortName":"LTM"},{"id":"CTLTMF","category":"Study","name":"Long-Term Momentum, Fast","shortName":"LTM(F)"},{"id":"DEMA","category":"Study","name":"Double EMA","shortName":"DEMA"},{"id":"EOSC","category":"Study","name":"Exponential Oscillator","shortName":"EOSC"},{"id":"TEMA","category":"Study","name":"Triple EMA","shortName":"TEMA"},{"id":"TSI","category":"Study","name":"True Strength Index","shortName":"Tsi"},{"id":"TSISIG","category":"Study","name":"True Strength Index Signal","shortName":"TsiSig"},{"id":"GMMA3","category":"Study","name":"GMMA-EMA3","shortName":"GMMA(3)"},{"id":"GMMA5","category":"Study","name":"GMMA-EMA5","shortName":"GMMA(5)"},{"id":"GMMA8","category":"Study","name":"GMMA-EMA8","shortName":"GMMA(8)"},{"id":"GMMA10","category":"Study","name":"GMMA-EMA10","shortName":"GMMA(10)"},{"id":"GMMA12","category":"Study","name":"GMMA-EMA12","shortName":"GMMA(12)"},{"id":"GMMA15","category":"Study","name":"GMMA-EMA15","shortName":"GMMA(15)"},{"id":"GMMA30","category":"Study","name":"GMMA-EMA30","shortName":"GMMA(30)"},{"id":"GMMA35","category":"Study","name":"GMMA-EMA35","shortName":"GMMA(35)"},{"id":"GMMA40","category":"Study","name":"GMMA-EMA40","shortName":"GMMA(40)"},{"id":"GMMA45","category":"Study","name":"GMMA-EMA45","shortName":"GMMA(45)"},{"id":"GMMA50","category":"Study","name":"GMMA-EMA50","shortName":"GMMA(50)"},{"id":"GMMA60","category":"Study","name":"GMMA-EMA60","shortName":"GMMA(60)"},{"id":"CONVLN","category":"Study","name":"ConversionLine","shortName":"ConvLn"},{"id":"BASELN","category":"Study","name":"BaseLine","shortName":"BaseLn"},{"id":"LEADSP1","category":"Study","name":"LeadingSpanA","shortName":"LeadSpA"},{"id":"LEADSP2","category":"Study","name":"LeadingSpanB","shortName":"LeadSpB"},{"id":"LAGGSP","category":"Study","name":"LaggingSpan","shortName":"LaggSp"},{"id":"VWAP","category":"Study","name":"VWAP","shortName":"VWAP"},{"id":"AVWAP","category":"Study","name":"Anchored VWAP","shortName":"Anch-VWAP"},{"id":"VWAPSD1U","category":"Study","name":"VWAP Stdev1 Upper","shortName":"VWAP-Std1-Up"},{"id":"VWAPSD1L","category":"Study","name":"VWAP Stdev1 Lower","shortName":"VWAP-Std1-Lo"},{"id":"VWAPSD2U","category":"Study","name":"VWAP Stdev2 Upper","shortName":"VWAP-Std2-Up"},{"id":"VWAPSD2L","category":"Study","name":"VWAP Stdev2 Lower","shortName":"VWAP-Std2-Lo"},{"id":"DIFA","category":"Study","name":"Distance From Average","shortName":"DistAvg"},{"id":"DOSCH","category":"Study","name":"Derivative Oscillator","shortName":"DerOsc"},{"id":"DOSCS","category":"Study","name":"Derivative Oscillator Signal","shortName":"DerOscSig"},{"id":"TTMSQZON","category":"Study","name":"TTM Squeeze On","shortName":"TtmSqzOn"},{"id":"TTMSQZOFF","category":"Study","name":"TTM Squeeze Off","shortName":"TtmSqzOff"},{"id":"TTMSQZOSC","category":"Study","name":"TTM Squeeze Osc","shortName":"TtmSqzOsc"},{"id":"CRS","category":"Study","name":"CompRelStrength","shortName":"CRS"},{"id":"CRSAVG","category":"Study","name":"CompRelStrengthAvg","shortName":"CRS-Avg"},{"id":"DRS","category":"Study","name":"DorseyRelStrength","shortName":"DRS"},{"id":"MRS","category":"Study","name":"MansfieldRelStrength","shortName":"MRS"},{"id":"PMO","category":"Study","name":"PriceMomOsc","shortName":"PMO"},{"id":"PMOS","category":"Study","name":"PriceMomOscSig","shortName":"PMOS"},{"id":"RVOL","category":"Study","name":"Relative Volume","shortName":"RVOL"},{"id":"AccountsPayable","category":"BalanceSheet","format":"UseMetricUnit","name":"Accounts Payable","shortName":"AcctsPay"},{"id":"AccruedExpenses","category":"BalanceSheet","format":"UseMetricUnit","name":"Accrued Expenses","shortName":"AccrdExp"},{"id":"Cash","category":"BalanceSheet","format":"UseMetricUnit","name":"Cash & Cash Equivalents","shortName":"Cash&CashEqv"},{"id":"CommonShares","category":"BalanceSheet","format":"UseMetricUnit","name":"Common Shares","shortName":"CommonShares"},{"id":"SharesOutstanding","category":"BalanceSheet","format":"UseMetricUnit","name":"Shares Outstanding","shortName":"SharesOutstanding"},{"id":"DeferredIncomeTax","category":"BalanceSheet","format":"UseMetricUnit","name":"Deferred Income Tax","shortName":"DefIncTax"},{"id":"DeferredLongRevenues","category":"BalanceSheet","format":"UseMetricUnit","name":"Deferred Revenues","shortName":"DefRev"},{"id":"EquityOtherInvestments","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Equity Investments","shortName":"OthEquityInvest"},{"id":"IncomeTaxPayable","category":"BalanceSheet","format":"UseMetricUnit","name":"Income Tax Payable","shortName":"IncTaxPayble"},{"id":"Intangibles","category":"BalanceSheet","format":"UseMetricUnit","name":"Intangibles","shortName":"Intangibles"},{"id":"Inventories","category":"BalanceSheet","format":"UseMetricUnit","name":"Inventories","shortName":"Inventory"},{"id":"LongTermDebt","category":"BalanceSheet","format":"UseMetricUnit","name":"Long Term Debt","shortName":"LTDebt"},{"id":"MarketableSec","category":"BalanceSheet","format":"UseMetricUnit","name":"Liquid Securities","shortName":"LiqSecurities"},{"id":"OtherCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Miscellaneous Current Assets","shortName":"MiscCurrAssets"},{"id":"OtherCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Current Liabilities","shortName":"OthCurrLiab"},{"id":"OtherEquity","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Equity","shortName":"OthEquity"},{"id":"OtherNonCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Non-Current Assets","shortName":"OthNonCurrAssets"},{"id":"OtherNonCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Non-Current Liabilities","shortName":"OthNonCurrLiab"},{"id":"PpeNet","category":"BalanceSheet","format":"UseMetricUnit","name":"PPE Net","shortName":"PPENet"},{"id":"PrepaidExpenses","category":"BalanceSheet","format":"UseMetricUnit","name":"Prepaid Expenses","shortName":"PpdExp"},{"id":"Receivables","category":"BalanceSheet","format":"UseMetricUnit","name":"Receivables","shortName":"Receivables"},{"id":"RetainedEarnings","category":"BalanceSheet","format":"UseMetricUnit","name":"Retained Earnings","shortName":"RetEarnings"},{"id":"ShorttermDebt","category":"BalanceSheet","format":"UseMetricUnit","name":"Short-Term Debt","shortName":"ShortTermDebt"},{"id":"TotalAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Assets","shortName":"TotAssets"},{"id":"TotalCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Current Assets","shortName":"TotCurrAssets"},{"id":"TotalCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Current Liabilities","shortName":"TotCurrLiab"},{"id":"TotalLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Liabilities","shortName":"TotalLiab"},{"id":"TotalLiabilitiesAndEquity","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Liabilities & Equity","shortName":"TotLiab&Equity"},{"id":"TotalNonCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Non-Current Assets","shortName":"TotNonCurrAssets"},{"id":"TotalNonCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Non-Current Liabilities","shortName":"TotNonCurrLiabs"},{"id":"TotalShareholdersEquity","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Shareholders Equity","shortName":"TotShareEquity"},{"id":"BasicEpsContOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Basic EPS Continued Operations","shortName":"EPSContOps"},{"id":"BasicEpsTotalOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Basic EPS Total Operations","shortName":"EPSTotOps"},{"id":"CostGoods","category":"IncomeStatement","format":"UseMetricUnit","name":"Cost of Goods","shortName":"COGS"},{"id":"DilutedEpsContOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Diluted EPS Continued Operations","shortName":"DilutedEPSContOps"},{"id":"DilutedEpsTotalOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Diluted EPS Total Operations","shortName":"DilutedEPSTotOps"},{"id":"Ebitda","category":"IncomeStatement","format":"UseMetricUnit","name":"EBITDA","shortName":"EBITDA"},{"id":"GrossProfit","category":"IncomeStatement","format":"UseMetricUnit","name":"Gross Profit","shortName":"GrProfit"},{"id":"IncomeTax","category":"IncomeStatement","format":"UseMetricUnit","name":"Income Tax","shortName":"IncomeTax"},{"id":"InterestExpense","category":"IncomeStatement","format":"UseMetricUnit","name":"Interest Expense","shortName":"IntExp"},{"id":"NetIncome","category":"IncomeStatement","format":"UseMetricUnit","name":"Net Income Less Expenses & Tax","shortName":"NetIncome"},{"id":"OperatingExpenses","category":"IncomeStatement","format":"UseMetricUnit","name":"Operating Expenses","shortName":"OpExpense"},{"id":"OperatingIncome","category":"IncomeStatement","format":"UseMetricUnit","name":"Operating Income","shortName":"OpIncome"},{"id":"OtherIncomeExpenses","category":"IncomeStatement","format":"UseMetricUnit","name":"Other Income","shortName":"OthInc"},{"id":"PreTaxIncome","category":"IncomeStatement","format":"UseMetricUnit","name":"Pretax Income","shortName":"PretaxInc"},{"id":"Sales","category":"IncomeStatement","format":"UseMetricUnit","name":"Sales","shortName":"Sales"},{"id":"JPIB","category":"Study","name":"JPI-Buy","shortName":"Buy"},{"id":"JPIS","category":"Study","name":"JPI-Sell","shortName":"Sell"},{"id":"TDIPRC","category":"Study","name":"TDI Price Line","shortName":"PriceLn"},{"id":"TDITSL","category":"Study","name":"TDI Trade Signal","shortName":"TradeSig"},{"id":"TDIMBL","category":"Study","name":"TDI Market Base","shortName":"MktBase"},{"id":"TDIUPR","category":"Study","name":"TDI Upper Band","shortName":"UpperBnd"},{"id":"TDILWR","category":"Study","name":"TDI Lower Band","shortName":"LowerBnd"},{"id":"PPS","category":"Study","name":"PricePercentStop","shortName":"PPS"},{"id":"RCI","category":"Study","name":"RankCorrelationIndex","shortName":"RCI"},{"id":"RCISIG","category":"Study","name":"RCI Signal","shortName":"RCISig"},{"id":"ZZPIVOT","category":"Study","name":"ZigZag Pivot","shortName":"ZZPivot"},{"id":"ADR","category":"Study","name":"AvgDailyRange","shortName":"ADR"},{"id":"ADRP","category":"Study","name":"AvgDailyRangePerc","shortName":"ADRP"},{"id":"BOP","category":"Study","name":"BalanceOfPower","shortName":"BOP"},{"id":"BOPAVG","category":"Study","name":"BalanceOfPowerAvg","shortName":"BOPAVG"},{"id":"CORR","category":"Study","name":"CorrelationCoefficient","shortName":"Corr"},{"id":"RVI","category":"Study","name":"RelativeVigorIndex","shortName":"RVI"},{"id":"RVISIG","category":"Study","name":"RVI Signal","shortName":"RVISig"}]`),zd=class{constructor(e,t=v.Number,n=b.Common,r,i=y.FromMetaData,a){this.id=e,this.type=t,this.category=n,this.name=r,this.format=i,this.shortName=a;let o=e.charAt(0)===`_`;r??(this.name=o?e:this.id.replace(/([A-Z])/g,` $1`).trim()),this.shortName=a??this.name}},Bd={},Vd=!1;function Hd(e){Id(e,z.FIELDS_SCHEMA).map(e=>{Bd[e.id]=new zd(e.id,v[e.type],b[e.category],e.name,y[e.format],e.shortName)})}function Ud(){return Vd||=(Hd(Rd),!0),Bd}var W=Ud(),G={CH_ALL:`ch`,CH_DIDBECOMEACTIVE:`ch.didbecomeactive`,CH_RECREATED:`ch.recreated`,CH_RESET:`ch.reset`,CH_ANNOTATIONCHANGED:`ch.annotationchanged`,CH_ANNNEEDSCONTEXTMENU:`ch.annneedscontextmenu`,CH_CHTNEEDSCONTEXTMENU:`ch.chtneedscontextmenu`,CH_ANNSELECTIONCHANGED:`ch.annselectionchanged`,CH_ANNPOINTPICKED:`ch.annpointpicked`,CH_ANNMODIFIEDBYTOOL:`ch.annmodifiedbytool`,CH_PANEHEIGHTSCHANGED:`ch.paneheightschanged`,CH_PANESREORDERED:`ch.panesreordered`,CH_AXISSCALECHANGED:`ch.axisscalechanged`,CH_CHTLAYOUTCHANGED:`ch.chtlayoutchanged`,CH_NODATAFORMAINSYMBOL:`ch.nodataformainsymbol`,CH_CARDPLOTCLICKED:`ch.cardplotclicked`,CH_CARDPLOTREMOVED:`ch.cardplotremoved`,CH_CARDPLOTVISIBILITYCHANGED:`ch.cardplotvisibilitychanged`,CH_TOOLTIPCHANGED:`ch.tooltipchanged`,CH_LOGOCLICKED:`ch.logoclicked`,CH_SHUTDOWN:`ch.shutdown`,CH_ZOOMCHANGED:`ch.zoomchanged`,CH_ALL_DATA_PROJECTED:`ch.all.data.projected`,CH_API_ACTIONS_RECEIVED:`ch.api.actions.received`,CH_HOST_PROPS_CHANGED:`ch.host.props.changed`,CH_DEFINITION_CHANGED:`ch.definition.changed`,CH_PLOTNEEDSCONTEXTMENU:`ch.plotneedscontextmenu`,DF_ALL:`df`,DF_STREAMRECONNECTED:`df.streamreconnected`,TS_ALL:`ts`,TS_LOADING:`ts.loading`,TS_MANYCHANGED:`ts.manychaged`,TS_DATAPOINTADDED:`ts.datapointadded`,TS_DATAPOINTCHANGED:`ts.datapointchanged`,TS_TIMELINECORRECTION:`ts.timelinecorrection`,TS_EVENTSCHANGED:`ts.eventschanged`,TS_QUOTEMARKER:`ts.quotemarker`,MD_ALL:`md`,MD_CHANGED:`md.changed`,RT_ALL:`rt`,RT_QUOTE:`rt.quote`,RT_QUOTEGROUP:`rt.quotegroup`,RT_TRADE:`rt.trade`,RT_VOLUME:`rt.volume`,TL_CHANGED:`tl.changed`,ME_ALL:`me`,ME_MOUSE_OUT_SERIES:`me.mouse.out.series`,ME_MOUSE_OVER_SERIES:`me.mouse.over.series`},Wd=[W.Open,W.High,W.Low,W.Close,W.Volume,W.Change,W.PercentChange,W.PreviousClose].reduce((e,t,n)=>(e.set(t.id,1<<n),e),new Map);function Gd(...e){return e.reduce((e,t)=>Wd.has(t.id)?e|Wd.get(t.id):e,0)}var Kd=class{storage;fields=[];_updated=0;isValid=!1;constructor(e=``){this.symbol=e,this.storage=new Map,this.isValid=!1,this.resetUpdated()}get updated(){return this._updated}resetUpdated(){this._updated=0}addFields(...e){this.fields=ye(this.fields,e),this.fields.forEach(e=>{this.storage.has(e.id)||this.storage.set(e.id,null)})}update(e,t){if(this.hasField(e)){let n=e.id,r=this.storage.get(n);this.storage.set(n,t);let i=r!==t;return i&&Wd.has(n)&&(this._updated|=Wd.get(n)),i}}computeWellKnown(){let e=this.getValue(W.Close),t=this.getValue(W.PreviousClose);P(e,t)&&(this.hasField(W.Change)&&this.update(W.Change,e-t),this.hasField(W.PercentChange)&&this.update(W.PercentChange,(e-t)/t))}hasField(e){return P(this.fields)&&this.fields.some(t=>t.id===e.id)}hasSymbol(e){return!1}getValue(e){return this.hasField(e)?this.storage.get(e.id):null}shutdown(){}async ready(){return!1}},qd=class extends Kd{translated;constructor(e){super(),this.symbol=e,this.translated=Ki(this.symbol)}hasSymbol(e){return this.symbol===e}},Jd=class extends Kd{actual;constructor(e){super(z.PLACEHOLDER_SYMBOL_NAME),this.actual=e}async ready(){return!1}},Yd=class extends Kd{constructor(e){super(),this.symbol=e}hasSymbol(e){return this.symbol===e}async ready(){return!0}hasField(e){return!1}getValue(e){return null}},Xd={previousOpen:W.PreviousOpen,previousClose:W.PreviousClose,previousHigh:W.PreviousHigh,previousLow:W.PreviousLow,weeklyPreviousClose:W.WeekPreviousClose,weeklyPreviousHigh:W.WeekPreviousHigh,weeklyPreviousLow:W.WeekPreviousLow,monthlyPreviousClose:W.MonthPreviousClose,monthlyPreviousHigh:W.MonthPreviousHigh,monthlyPreviousLow:W.MonthPreviousLow,fiftyTwoWkHigh:W.YearHigh,fiftyTwoWkLow:W.YearLow},Zd={open:W.Open,high:W.High,low:W.Low,close:W.Close,lastPrice:W.Last,volume:W.Volume,netChange:W.Change,percentChange:W.PercentChange},Qd=Object.values(Xd),$d=Object.keys(Xd),ef=Object.keys(Zd),tf=class extends qd{triedFetchingExtraValues=!1;includeBaseFields=!1;async ready(){return Ai.call(this,async()=>(this.isValid=await $().getMetaDataSource().getMetaData(this.symbol).ready(),this.isValid))}shutdown(){}getValue(e){return this.hasField(e)&&Qd.some(t=>t.id===e.id)&&super.getValue(e)===null&&!this.triedFetchingExtraValues&&this.supplementPreviousValues(),super.getValue(e)}supplementPreviousValues(){this.triedFetchingExtraValues=!0,VM(`ondemand`,`/getQuote.json?symbols=${this.translated}&fields=${$d.join(`,`)}`).then(e=>{try{let t=JSON.parse(e);if(t.status.code===200&&t.results.length===1){let e=t.results[0];$d.forEach(t=>this.update(Xd[t],e[t])),this.includeBaseFields&&ef.forEach(t=>this.update(Zd[t],e[t])),$().getRecordSource().subject.next({topic:G.RT_QUOTE,data:{symbol:this.symbol}})}}catch{I(`Failed to fetch extra values for ${this.translated}`,`error`)}})}},nf=class extends tf{constructor(e){super(e),this.includeBaseFields=!0,this.supplementPreviousValues()}async ready(){return Promise.resolve(!0)}},rf=class extends qd{isValid=!1;constructor(e){super(e)}addOptionalField(e,t){P(t)&&(this.addFields(e),this.update(e,t))}async ready(){return Ai.call(this,async()=>{let e=$().config.environment===l[l.NodeJs]?null:yi(`#${z.INLINE_DATA_ELEMENT_ID}`);if(!P(e))this.isValid=!1;else{let t=JSON.parse(e);if(!(this.translated in t))this.isValid=!1;else{let e=t[this.translated].quote;this.update(W.Open,e.open),this.update(W.High,e.high),this.update(W.Low,e.low),this.update(W.Close,e.close),this.update(W.PreviousClose,e.previousClose),this.update(W.Volume,e.volume),$d.filter(e=>e!==`previousClose`).forEach(t=>{this.addOptionalField(Xd[t],e[t])}),this.isValid=!0}}return this.isValid})}},af=[W.Open,W.High,W.Low,W.Close,W.PreviousClose],of=class extends Kd{mapping;resolved;model;constructor(e,t){super();let n=e=>$().getRecordSource().getRecord(e);this.resolved=e.map(([e,t])=>t),this.mapping=new Map(e.map(([e,t])=>[e,n(t)])),this.model=t;let r=af.concat(W.Change,W.PercentChange);this.addFields(...r.filter(e=>e!==W.Volume))}async ready(){return Ai.call(this,async()=>{let e=Array.from(this.mapping.values()).map(e=>e.ready());return this.isValid=(await Promise.all(e)).every(e=>e),this.isValid&&this.evaluate(),this.isValid})}hasSymbol(e){return this.resolved.includes(e)}getOneValue(e){return t=>this.mapping.get(t).getValue(e)}evaluate(){af.forEach(e=>{let t=Tu(this.model,this.getOneValue(e));this.update(e,Number.isFinite(t)?t:null)}),this.computeWellKnown()}};function sf(e,t){return n=>n.topic===e&&n.data.symbol===t}var cf=function(e,t){return cf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},cf(e,t)};function lf(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);cf(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function uf(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function df(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function ff(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function pf(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function mf(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function hf(e){return this instanceof hf?(this.v=e,this):new hf(e)}function gf(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof hf?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function _f(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ff==`function`?ff(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function vf(e){return typeof e==`function`}function yf(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var bf=yf(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
16
+ `)?`${e}${i.op} ${r}`:`${e} ${i.op} ${r}`;break;case`sym`:o=`{${t}}.${n}`;break;default:throw Error(`Unrecognized binary operator ${i.op}`)}}return a&&i.trailingComment!==void 0?`${o} // ${i.trailingComment}\n`:o}function Pu(e){let t=[];for(let n of e.panes)for(let e of n.axes)for(let n of e.plots)t.push(n);return t}function Fu(e,t,n){return!Pu(e).some(e=>e.uid===t&&e.uid!==n)}function Iu(e,t,n){if(!Fu(e,t,n))throw Error(`Plot uid '${t}' is already in use on this chart.`)}function Lu(e){return Pu(e).find(e=>e.main===!0)}function Ru(e,t){let n=0;for(let r=0;r<e.panes.length;r++){let i=e.panes[r].axes;for(let e=0;e<i.length;e++){let a=i[e].plots;for(let i=0;i<a.length;i++){if(n===t)return{pane:r,axis:e,plot:i};n++}}}return null}function zu(){return{plots:[]}}function Bu(e,t){let n=e.panes[t],r=n.axes.map(e=>e.plots.reduce((e,t)=>e+ +!!t.detachedScale,0)),i=n.axes.length;return n.axes.forEach((e,t)=>{let a=r[t],o=e.plots.length;if(!(a===0||a<o)&&a===o)if(i>1&&a===1){let a=(t+1)%i;if(r[a]<n.axes[a].plots.length){let t=e.plots.find(e=>e.detachedScale);t&&(n.axes[a].plots.push(t),e.plots=e.plots.filter(e=>!e.detachedScale),r[a]++)}}else{let t=e.plots.find(e=>e.detachedScale);t&&(t.detachedScale=!1)}}),e}function Vu(e,t,n){let r=Ru(e,t);if(r===null)return e;let i=e.panes[r.pane],a=i.axes[r.axis].plots[r.plot];return n===r.axis?delete a.detachedScale:(delete a.detachedScale,i.axes.length<2&&n>0&&i.axes.push(zu()),i.axes[n].plots.push(a),i.axes[r.axis].plots.splice(r.plot,1)),Ld(Bu(e,r.pane))}function Hu(e,t){let n=Ru(e,t);if(n===null)return e;let r=e.panes[n.pane].axes[n.axis].plots[n.plot];return r.detachedScale=!0,Ld(Bu(e,n.pane))}function Uu(e,t){let n=Pu(e).find(e=>e.uid===t.uid);if(!n||n.type!==`Seasonal`)return null;let r=n.offsets;return!Array.isArray(r)||!r.includes(t.offset)?null:n}function Wu(e,t){let n=t??{kind:`main`};return n.kind===`main`?Lu(e)??null:n.kind===`seasonal`?Uu(e,n):null}function Gu(e,t,n){let r=Wu(e,n);return r?r.type===`Forward`?{eligible:!1,reason:`it cannot be based on a forward plot`}:r.type===`Expression`&&vs(t)?{eligible:!1,reason:`it cannot be based on an expression; the study needs more than "OHLCV" fields`}:r.type===`Seasonal`&&!ys(t)?{eligible:!1,reason:`it cannot be based on a seasonal plot`}:{eligible:!0}:{eligible:!1,reason:`its basis does not resolve to an existing target plot`}}var Ku=`..plots{.main === true}`;function qu(e){return V(e,Ku)[0]}function Ju(e){let t=V(e,`..panes{${Ku}}`)[0];return{mainPane:t,mainAxis:V(t,`..axes{${Ku}}`)[0]}}function Yu(e,t,n){let r=qu(t);if(r[r.type.toLowerCase()]===z.PLACEHOLDER_SYMBOL_NAME){let r=qu(e),{mainAxis:i}=Ju(t),a=i.annotations,o=nd(t,r);if(n){let{mainAxis:e}=Ju(o);e.annotations=a}return o}return t}var Xu=`Symbol`,Zu=`Expression`,Qu=`Forward`,$u=`Seasonal`,ed=[Xu,Zu,Qu,$u];function td(e){let t=wu(e),n=Cu(t),r=n?0:t.symbols.length,i=!n&&r>0?t.symbols[0]:null;return{clean:n?void 0:t.clean,hasErrors:n,symbolCount:r,firstSymbol:i,error:n?t.error:void 0}}function nd(e,t){let n=qu(e);P(t.uid)&&Iu(e,t.uid,n.uid);let r=e=>n.type===e,i=e=>P(t[e.toLowerCase()]),a=ed.find(e=>i(e)),o=a.toLowerCase(),s=t[o],c=s===z.PLACEHOLDER_SYMBOL_NAME,l=i(Zu)||i(Qu)||i($u),u=ed.some(e=>i(e)&&!r(e)),d=$().config.cachedAnnotationsCount||0,f=d>0,{mainAxis:p}=Ju(e);u&&(p.comparison=`None`);let m=td(s),h=e=>{throw Error(e)};c||(l?(m.hasErrors&&h(`[Main Plot] "${s}" is an invalid expression.\n${m.error}`),s=m.clean):m.hasErrors||h(`[Main Plot] "${s}" is an expression, unsupported for ${o}.`));let g=(e,t)=>e.findIndex(e=>e.symbol===t),_=(e,t)=>{if(e===z.PLACEHOLDER_SYMBOL_NAME)return;let n=t.annotations||[],r=t.annCache||[],i=g(r,e);if(i!==-1&&r.splice(i,1),n.length>0){let t={symbol:e,annotations:n};r.length+1>d&&r.splice(0,r.length+1-d),r.push(t)}t.annCache=r},v=(e,t)=>{let n=t.annCache||[],r=g(n,e);r!==-1&&(t.annotations=n[r].annotations)},y=e=>{let a=n;if(r(Xu))_(a.symbol,e);else if(r(Zu))_(a.expression,e);else if(r($u)){let t=td(a.seasonal);t.symbolCount===1&&_(t.firstSymbol,e)}delete e.annotations,i(Xu)?v(t.symbol,e):i(Zu)?v(t.expression,e):i($u)&&m.symbolCount===1&&v(t.seasonal,e)};if(f){let t=V(e,`..axes`);for(let e of t)y(e)}let b=i(Zu)&&r(Xu)||i(Xu)&&r(Zu),x=H(e,Ku,e=>(P(t.uid)&&(e.uid=t.uid),u&&(delete e.expression,delete e.symbol,delete e.showPrevious,delete e.forward,delete e.offsets,delete e.seasonal,e.type=a,b||(e.curves=[{}]),(i(Qu)||i($u))&&(e.offsets=[0])),e[o]=s,e));if(i(Xu)&&Yr(s)&&(x.data.aggregation.contractRoll=oi(s)?`expiration`:`combined`),u)if(i(Qu))x.data.aggregation={unit:`Month`},x.display.period=`P10Y`;else if(i($u)&&!Il(x.data.aggregation).isEndOfDay)x.data.aggregation={unit:`Day`},x.display.period=i($u)?`P9M`:`P1Y10D`;else if(r(Qu)||r($u)){x.data.aggregation=$().getDefaultAggregation(),x.data.maxDataPoints=z.DEFAULT_MAX_RECORDS;let e=$().getDefaultPeriod();P(e)&&(x.display.period=e)}else i(Zu)&&r(Xu)&&(iu.includes(n.curves[0].style)&&(x=H(x,Ku,e=>(delete e.inputs,e))),x.data.aggregation.spec===`PerRange`&&(x.data.aggregation={unit:`Day`}));let S=new Map([[`..plots{.type === "Study"}`,e=>{let t=B(e.study);return N(t)&&Gu(x,t,e.basis).eligible?e:z.NULL_OBJECT}],[`..plots{.type === "BalanceSheet" || .type === "IncomeStatement"}`,e=>i(Xu)?(e.symbol=s,e):z.NULL_OBJECT],[`..plots{..events}`,e=>(i(Xu)||delete e.events,e)]]);for(let[e,t]of S)x=H(x,e,t);return u&&!b&&(x=au(x,{type:a,curves:[{}]})),x=Ld(x),x}function rd(e){let t=$().getDefaultDensity();P(t)&&(e.display.density=t)}function id(e,t){return H(e,`..plots{.type === "Study" && (.study === "VOL" || .study === "MAVOL")}.curves{.fields === "TradeSize" || .fields === "Volume"}`,e=>(e.fields=t?[W.TradeSize.id]:[W.Volume.id],e))}function ad(e,t){let n=Il(e.data.aggregation),r=n.isTick&&!n.hasSpec,i=Il(t),a=i.isTick&&!i.hasSpec,o=e=>e.isIntraday&&e.hasSpec&&e.spec===_.PerRange,s=o(n),c=o(i),l=H(e,`${Ku}.curves[0]`,e=>{let t=[W.Open.id,W.High.id,W.Low.id,W.Close.id,W.Change.id].slice();if(!s&&c)return tu(`Range`,!0);if(s&&!c&&(e.style=`OHLC`),!a&&r){let n=$().getDefaultMultiFieldCurve();if(n!==null)return n;e.fields=t,e.style!==`Candlestick`&&e.style!==`OHLC`&&e.style!==`HLC`&&(e.style=`Candlestick`,e.colors=[`#ff6961`,`#77dd77`],e.varyColorPerBar=!0),e.style===`HLC`&&e.fields.splice(0,1)}else a&&!r&&(e.fields=[W.Last.id,W.Change.id],e.style=`Line`,e.colors=[`#0055cc`],e.varyColorPerBar=!1);return e});return l=id(l,a),ht(l.data.aggregation,t),(n.unit!==i.unit||n.size!==i.size)&&(Kl(l),Gl(l),rd(l),Wl(l)),l}function od(e){return P(e)&&e!==z.AUTOFIT_PERIOD}function sd(e){e.display?.density?(Kl(e),Gl(e)):od(e.display?.period)&&Gl(e)}function cd(e){let t=rt(e.display,null,`chart`,`bar`);if(P(t)){let[e,n]=yt(t.width||0,t.spacing||0,z.MINIMUM_BAR_WIDTH,z.MAXIMUM_BAR_WIDTH);t.width=e,t.spacing=n}}function ld(e){e.display?.period&&e.display.period===`YTD`&&delete e.display.period}function ud(e){let t=V(e,`..annotations{.id === 'RewardRisk' || .id === 'ProfitLoss' }`);t.length>0&&t.forEach(e=>{e.traits.prices=e.traits.prices.map(e=>typeof e==`string`?Number.parseFloat(e):e),e.id===`RewardRisk`&&(e.traits.ratio=Math.abs(e.traits.ratio),e.traits.textLines=e.traits.textLines.map(e=>e.match(/Ratio/)?e.replace(`-`,``):e))})}function dd(e){let t=V(e,`..annotations{.traits.fill.color === null}`);t.length>0&&t.forEach(e=>{e.traits.fill.color=`rgba(0, 0, 0, 0)`})}function fd(e){let{from:t,to:n}=e.display?.xAxis?.visibleRange||{},r=t===null,i=n===null;r&&delete e.display.xAxis.visibleRange.from,i&&delete e.display.xAxis.visibleRange.to,r&&i&&delete e.display.xAxis.visibleRange}function pd(e){let t=V(e,`..panes[0].axes[0].scale`);if(t.length===1){let n=t[0],r=V(e,`..panes[0]..axes`);r.length>0&&r.forEach(e=>e.scale=n)}}function md(e){let[t]=V(e,Ku);P(t)&&t.type===C[C.Symbol]&&!iu.includes(t.curves[0].style)&&P(t.inputs)&&delete t.inputs}function hd(e){let[t]=V(e,Ku);P(t)&&t.type===C[C.Symbol]&&t.curves[0].style===h[h.Renko]&&P(t.inputs)&&t.inputs.map(e=>e.value).some(e=>e===void 0)&&(t.inputs=F(z.DEFAULT_RENKO_INPUTS))}function gd(e){let[t]=V(e,Ku);if(P(t)&&t.type===C[C.Expression]){let n=t.curves[0].style,r=n===h[h.Range],i=n===h[h.Baseline],a=iu.includes(n);r&&e.data?.aggregation.spec===_[_.PerRange]&&(e.data.aggregation={unit:`Day`}),!i&&(a||r)&&(delete t.inputs,t.curves[0]=tu(`Candlestick`,!0))}}function _d(e){let t=H(e,`..annCache{!.annotations}`,e=>z.NULL_OBJECT);t=H(t,`..annCache`,e=>{let t=di(e.symbol);return t===null?e:Dr(t,Lr(new Date,3))?z.NULL_OBJECT:e}),t=H(t,`..annotations{.id === 'ComputedText' && !.traits.textLines}`,e=>z.NULL_OBJECT);let n=t.data.aggregation,r=n.unit===`Tick`&&n.spec===`None`;return id(t,r)}function vd(e){V(e,`..annotations`).forEach(e=>{let{id:t,traits:n}=e;Rc(t,n),Lc(t,n)})}function yd(e){try{ds(!1),V(e,`..plots{.type === "Study" && .curves.zones}`).forEach(e=>{let t=B(e.study).defaults;for(let n=0;n<(e.curves?.length??0);n++){let r=e.curves[n];if(r.zones&&(r.colors?.length??0)<(t.curves[n].colors?.length??0)){let e=t.curves[n].colors.slice(r.colors?.length??0);r.colors?.length?r.colors.push(...e):r.colors=e}}})}finally{ds(!0)}}function bd(e){let[t]=V(e,Ku);if(t.type===`Symbol`&&t.curves?.length===1){let e=t.curves[0];if(e.style===`HLC`){let t=e.colors?.length;if(t===1){let t=e.colors[0];e.colors=[t,t],e.varyColorPerBar=!0,e.attributes=[`OpenVsClose`]}else t===2&&!e.attributes&&(e.attributes=[`OpenVsClose`])}}}function xd(e){$()?.config?.mode===`cmdtyView`&&(delete e.data?.extendedHours,delete e.data?.buildContinuation)}function Sd(e){let t=e.data?.aggregation,n=e.data?.extendedHours,r=N(n);t&&t.spec===`FormT`&&(t.spec=`None`,r||(e.data.extendedHours=!0))}function Cd(e){let t=e.data?.buildContinuation,n=N(t),r=e.data?.aggregation;n&&r&&(r.spec===`Continue`&&!t&&(r.spec=`None`),t&&(r.spec=`Continue`))}function wd(e){try{ds(!1),V(e,`..plots{.type === "Study" && .curves.varyColorPerBar}`).forEach(e=>{let t=B(e.study).defaults;if(e?.curves?.length===t?.curves.length&&t?.curves.length>0)for(let n=0;n<e.curves.length;n++)e.curves[n].varyColorPerBar=t.curves[n].varyColorPerBar})}finally{ds(!0)}}function Td(e){try{ds(!1),V(e,`..plots{.type === "Study"}`).forEach(e=>{let t=B(e.study).defaults;N(e.inputs)&&e.inputs.forEach((e,n)=>{let r=t.inputs?.[n]?.value;!N(e.value)&&N(r)&&(e.value=r)}),N(e.levels)&&e.levels.forEach((e,n)=>{let r=t.levels?.[n]?.value;!N(e.value)&&N(r)&&(e.value=r)}),N(e.bands)&&e.bands.forEach((e,n)=>{let r=t.bands?.[n]?.range;!N(e.range.from)&&N(r?.from)&&(e.range.from=r.from),!N(e.range.to)&&N(r?.to)&&(e.range.to=r.to)})})}finally{ds(!0)}}function Ed(e){let t=V(e,`..axes{.annotations{.points{!.price || !.time}}}`);t.length>0&&t.forEach(e=>{let t=e.annotations.map(e=>{let t=e.points.find(e=>P(e.price)),n=e.points.find(e=>P(e.time));return!P(t)||!P(n)?null:(e.points.forEach(e=>{P(e.price)||(e.price=t.price),P(e.time)||(e.time=n.time)}),e)}).filter(e=>P(e));t.length>0?e.annotations=t:delete e.annotations});let n=V(e,`..panes`),r=e=>P(e.height)?e.height:1,i=n.map(e=>r(e)),a=Math.min(...i),o=a<.01?5/a:1;n.forEach(e=>e.height=Xe(o*r(e),4));let s=$().config.showResizeHandles||!1;e.display.xAxis.resizeHandles=s;let c=`wheel+shift`,l=$().config.scrollBehavior||c;Object.values(ie).filter(e=>typeof e==`string`).includes(l)||(l=c),e.display.scrollBehavior=l;let u=V(e,`..plots{.type === "Study" && .study === "RSI"}`);return u.length>0&&u.forEach(e=>{if(P(e.bands)&&e.bands.length>0){let t=e.inputs&&e.inputs.length===1&&e.inputs[0].name===z.INPUT_PERIOD?e.inputs[0].value:null,n=B(`RSI`).defaults;e.curves=n.curves,e.inputs=n.inputs,P(t)&&(e.inputs[0].value=t),delete e.bands,e.levels=n.levels}}),sd(e),cd(e),ld(e),dd(e),fd(e),pd(e),md(e),hd(e),gd(e),vd(e),yd(e),bd(e),ud(e),xd(e),Sd(e),Cd(e),wd(e),Td(e),_d(e)}var Dd=o(((e,t)=>{(function(){var e=function(t){if(typeof t!=`object`||!t)return t;var n;if(t instanceof Date)return n=new Date,n.setTime(t.getTime()),n;if(t instanceof RegExp)return n=new RegExp(t),n;if(t instanceof Array){n=[];for(var r=0,i=t.length;r<i;r++)n[r]=e(t[r]);return n}if(t instanceof Object){for(var a in n={},t)t.hasOwnProperty(a)&&(n[a]=e(t[a]));return n}throw Error(`Unable to clone object!`)},n=function(t){for(var n=[e(t[0])],r=n[0].key,i=n[0].object,a=1,o=t.length;a<o;a++)i=i[r],r=t[a].key,n.push({object:i,key:r});return n},r=function(e,t){var n=e.length-1,r=e[n].key;t[n].object[r]=e[n].object[r]},i={type:!0,not:!0,anyOf:!0,allOf:!0,oneOf:!0,$ref:!0,$schema:!0,id:!0,exclusiveMaximum:!0,exclusiveMininum:!0,properties:!0,patternProperties:!0,additionalProperties:!0,items:!0,additionalItems:!0,required:!0,default:!0,title:!0,description:!0,definitions:!0,dependencies:!0},a={null:function(e){return e===null},string:function(e){return typeof e==`string`},boolean:function(e){return typeof e==`boolean`},number:function(e){return typeof e==`number`&&e===e},integer:function(e){return typeof e==`number`&&e%1==0},object:function(e){return e&&typeof e==`object`&&!Array.isArray(e)},array:function(e){return Array.isArray(e)},date:function(e){return e instanceof Date}},o={alpha:function(e){return/^[a-zA-Z]+$/.test(e)},alphanumeric:function(e){return/^[a-zA-Z0-9]+$/.test(e)},identifier:function(e){return/^[-_a-zA-Z0-9]+$/.test(e)},hexadecimal:function(e){return/^[a-fA-F0-9]+$/.test(e)},numeric:function(e){return/^[0-9]+$/.test(e)},"date-time":function(e){return!isNaN(Date.parse(e))&&e.indexOf(`/`)===-1},uppercase:function(e){return e===e.toUpperCase()},lowercase:function(e){return e===e.toLowerCase()},hostname:function(e){return e.length<256&&/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$/.test(e)},uri:function(e){return/[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/.test(e)},email:function(e){return/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/.test(e)},ipv4:function(e){return!!(/^(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)\.(\d?\d?\d)$/.test(e)&&e.split(`.`).sort()[3]<=255)},ipv6:function(e){return/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/.test(e)}},s={readOnly:function(e,t){return!1},minimum:function(e,t,n){return!(e<t||n.exclusiveMinimum&&e<=t)},maximum:function(e,t,n){return!(e>t||n.exclusiveMaximum&&e>=t)},multipleOf:function(e,t){return e/t%1==0||typeof e!=`number`},pattern:function(e,t){if(typeof e!=`string`)return!0;var n,r;return typeof t==`string`?n=t:(n=t[0],r=t[1]),new RegExp(n,r).test(e)},minLength:function(e,t){return e.length>=t||typeof e!=`string`},maxLength:function(e,t){return e.length<=t||typeof e!=`string`},minItems:function(e,t){return e.length>=t||!Array.isArray(e)},maxItems:function(e,t){return e.length<=t||!Array.isArray(e)},uniqueItems:function(e,t){for(var n={},r,i=0,a=e.length;i<a;i++){if(r=JSON.stringify(e[i]),n.hasOwnProperty(r))return!1;n[r]=!0}return!0},minProperties:function(e,t){if(typeof e!=`object`)return!0;var n=0;for(var r in e)e.hasOwnProperty(r)&&(n+=1);return n>=t},maxProperties:function(e,t){if(typeof e!=`object`)return!0;var n=0;for(var r in e)e.hasOwnProperty(r)&&(n+=1);return n<=t},constant:function(e,t){return JSON.stringify(e)==JSON.stringify(t)},enum:function(e,t){var n,r,i;if(typeof e==`object`){for(i=JSON.stringify(e),n=0,r=t.length;n<r;n++)if(i===JSON.stringify(t[n]))return!0}else for(n=0,r=t.length;n<r;n++)if(e===t[n])return!0;return!1}},c=function(e){return e.indexOf(`://`)===-1?e:e.split(`#`)[0]},l=function(e,t,n){var r,i,a=n.indexOf(`#`),o;if(a===-1)return e.schema.hasOwnProperty(n)?[e.schema[n]]:null;if(a>0)if(o=n.substr(0,a),n=n.substr(a+1),e.schema.hasOwnProperty(o))t=[e.schema[o]];else if(t&&t[0].id===o)t=[t[0]];else return null;else{if(!t)return null;n=n.substr(1)}if(n===``)return[t[0]];if(n.charAt(0)===`/`){for(n=n.substr(1),r=t[0],i=n.split(`/`);i.length>0;){if(!r.hasOwnProperty(i[0]))return null;r=r[i[0]],t.push(r),i.shift()}return t}else return null},u=function(e,t){var n,r,i=e.length-1,a,o,s=/^(\d+)/.exec(t);if(s){if(t=t.substr(s[0].length),a=parseInt(s[1],10),a<0||a>i)return;if(o=e[i-a],t===`#`)return o.key}else o=e[0];if(r=o.object[o.key],t===``)return r;if(t.charAt(0)===`/`){for(t=t.substr(1),n=t.split(`/`);n.length>0;){if(n[0]=n[0].replace(/~1/g,`/`).replace(/~0/g,`~`),!r.hasOwnProperty(n[0]))return;r=r[n[0]],n.shift()}return r}else return},d=function(e,t,a,o){var s,c,f,p,m,h,g,_=!1,v={},y,b,x,S=t.length-1,C=t[S],w,T=a.length-1,ee=a[T].object,E=a[T].key,D=ee[E],te,ne;if(C.hasOwnProperty(`$ref`))return t=l(e,t,C.$ref),t?d(e,t,a,o):{$ref:C.$ref};if(C.hasOwnProperty(`type`))if(typeof C.type==`string`){if(o.useCoerce&&e.coerceType.hasOwnProperty(C.type)&&(D=ee[E]=e.coerceType[C.type](D)),!e.fieldType[C.type](D))return{type:C.type}}else{for(_=!0,s=0,c=C.type.length;s<c&&_;s++)e.fieldType[C.type[s]](D)&&(_=!1);if(_)return{type:C.type}}if(C.hasOwnProperty(`allOf`)){for(s=0,c=C.allOf.length;s<c;s++)if(y=d(e,t.concat(C.allOf[s]),a,o),y)return y}if(!o.useCoerce&&!o.useDefault&&!o.removeAdditional){if(C.hasOwnProperty(`oneOf`)){for(ne=1/0,s=0,c=C.oneOf.length,f=0;s<c;s++)if(y=d(e,t.concat(C.oneOf[s]),a,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else if(f+=1,f>1)break;if(f>1)return{oneOf:!0};if(f<1)return v;v={}}if(C.hasOwnProperty(`anyOf`)){for(v=null,ne=1/0,s=0,c=C.anyOf.length;s<c;s++)if(y=d(e,t.concat(C.anyOf[s]),a,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else{v=null;break}if(v)return v}if(C.hasOwnProperty(`not`)&&(y=d(e,t.concat(C.not),a,o),!y))return{not:!0}}else{if(C.hasOwnProperty(`oneOf`)){for(ne=1/0,s=0,c=C.oneOf.length,f=0;s<c;s++)if(w=n(a),y=d(e,t.concat(C.oneOf[s]),w,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else{if(f+=1,f>1)break;r(w,a)}if(f>1)return{oneOf:!0};if(f<1)return v;v={}}if(C.hasOwnProperty(`anyOf`)){for(v=null,ne=1/0,s=0,c=C.anyOf.length;s<c;s++)if(w=n(a),y=d(e,t.concat(C.anyOf[s]),w,o),y)te=y.schema?Object.keys(y.schema).length:1,te<ne&&(ne=te,v=y);else{r(w,a),v=null;break}if(v)return v}if(C.hasOwnProperty(`not`)&&(w=n(a),y=d(e,t.concat(C.not),w,o),!y))return{not:!0}}if(C.hasOwnProperty(`dependencies`)){for(h in C.dependencies)if(C.dependencies.hasOwnProperty(h)&&D.hasOwnProperty(h)){if(Array.isArray(C.dependencies[h])){for(s=0,c=C.dependencies[h].length;s<c;s++)if(!D.hasOwnProperty(C.dependencies[h][s]))return{dependencies:!0}}else if(y=d(e,t.concat(C.dependencies[h]),a,o),y)return y}}if(Array.isArray(D)){if(C.hasOwnProperty(`items`))if(Array.isArray(C.items)){for(s=0,c=C.items.length;s<c;s++)y=d(e,t.concat(C.items[s]),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0);if(D.length>c&&C.hasOwnProperty(`additionalItems`))if(typeof C.additionalItems==`boolean`){if(!C.additionalItems)return{additionalItems:!0}}else for(s=c,c=D.length;s<c;s++)y=d(e,t.concat(C.additionalItems),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0)}else for(s=0,c=D.length;s<c;s++)y=d(e,t.concat(C.items),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0);else if(C.hasOwnProperty(`additionalItems`)&&typeof C.additionalItems!=`boolean`)for(s=0,c=D.length;s<c;s++)y=d(e,t.concat(C.additionalItems),a.concat({object:D,key:s}),o),y!==null&&(v[s]=y,_=!0);if(_)return{schema:v}}else{for(h in b=[],v={},D)D.hasOwnProperty(h)&&b.push(h);if(o.checkRequired&&C.required)for(s=0,c=C.required.length;s<c;s++)D.hasOwnProperty(C.required[s])||(v[C.required[s]]={required:!0},_=!0);if(p=C.hasOwnProperty(`properties`),m=C.hasOwnProperty(`patternProperties`),p||m)for(s=b.length;s--;){if(x=!1,p&&C.properties.hasOwnProperty(b[s])&&(x=!0,y=d(e,t.concat(C.properties[b[s]]),a.concat({object:D,key:b[s]}),o),y!==null&&(v[b[s]]=y,_=!0)),m)for(h in C.patternProperties)C.patternProperties.hasOwnProperty(h)&&b[s].match(h)&&(x=!0,y=d(e,t.concat(C.patternProperties[h]),a.concat({object:D,key:b[s]}),o),y!==null&&(v[b[s]]=y,_=!0));x&&b.splice(s,1)}if(o.useDefault&&p&&!_)for(h in C.properties)C.properties.hasOwnProperty(h)&&!D.hasOwnProperty(h)&&C.properties[h].hasOwnProperty(`default`)&&(D[h]=C.properties[h].default);if(o.removeAdditional&&p&&C.additionalProperties!==!0&&typeof C.additionalProperties!=`object`)for(s=0,c=b.length;s<c;s++)delete D[b[s]];else if(C.hasOwnProperty(`additionalProperties`))if(typeof C.additionalProperties==`boolean`){if(!C.additionalProperties)for(s=0,c=b.length;s<c;s++)v[b[s]]={additional:!0},_=!0}else for(s=0,c=b.length;s<c;s++)y=d(e,t.concat(C.additionalProperties),a.concat({object:D,key:b[s]}),o),y!==null&&(v[b[s]]=y,_=!0);if(_)return{schema:v}}for(g in C)C.hasOwnProperty(g)&&!i.hasOwnProperty(g)&&(g===`format`?e.fieldFormat.hasOwnProperty(C[g])&&!e.fieldFormat[C[g]](D,C,a,o)&&(v[g]=!0,_=!0):e.fieldValidate.hasOwnProperty(g)&&!e.fieldValidate[g](D,C[g].hasOwnProperty(`$data`)?u(a,C[g].$data):C[g],C,a,o)&&(v[g]=!0,_=!0));return _?v:null},f={useDefault:!1,useCoerce:!1,checkRequired:!0,removeAdditional:!1};function p(){if(!(this instanceof p))return new p;this.coerceType={},this.fieldType=e(a),this.fieldValidate=e(s),this.fieldFormat=e(o),this.defaultOptions=e(f),this.schema={}}p.prototype={validate:function(e,t,n){var r=[e],i=null,a=[{object:{__root__:t},key:`__root__`}];if(typeof e==`string`&&(r=l(this,null,e),!r))throw Error(`jjv: could not find schema '`+e+`'.`);if(!n)n=this.defaultOptions;else for(var o in this.defaultOptions)this.defaultOptions.hasOwnProperty(o)&&!n.hasOwnProperty(o)&&(n[o]=this.defaultOptions[o]);return i=d(this,r,a,n),i?{validation:i.hasOwnProperty(`schema`)?i.schema:i}:null},resolveRef:function(e,t){return l(this,e,t)},addType:function(e,t){this.fieldType[e]=t},addTypeCoercion:function(e,t){this.coerceType[e]=t},addCheck:function(e,t){this.fieldValidate[e]=t},addFormat:function(e,t){this.fieldFormat[e]=t},addSchema:function(e,t){if(!t&&e&&(t=e,e=void 0),t.hasOwnProperty(`id`)&&typeof t.id==`string`&&t.id!==e){if(t.id.charAt(0)===`/`)throw Error(`jjv: schema id's starting with / are invalid.`);this.schema[c(t.id)]=t}else if(!e)throw Error(`jjv: schema needs either a name or id attribute.`);e&&(this.schema[c(e)]=t)}},t!==void 0&&t.exports!==void 0?t.exports=p:typeof define==`function`&&define.amd?define(function(){return p}):this.jjv=p}).call(e)})),Od=c(o(((e,t)=>{t.exports=Dd()}))(),1),kd=null;function Ad(e){let{id:t,context:n}=e,r=e=>P(n[e]),i=(e,t)=>{if(!P(n[e]))throw Error(`${t} plot accessor: you must provide '${e}'`)},a=(e,t)=>{if(!e.some(e=>r(e)))throw Error(`${t} plot accessor: you must provide either '${e[0]}' or '${e[1]}'`)},o=e=>{if(r(`placement`)&&n.placement===`clone`&&!r(`cloneUid`)&&!r(`cloneIndex`))throw Error(`${e} plot accessor: when placement is 'clone', you must provide either 'cloneUid' or 'cloneIndex'.`)};if(t===`Plot`)switch(n.id){case`Add`:switch(i(`type`,`Add`),n.type){case`Study`:i(`studyId`,`Add`),o(`Add`);break;case`IncomeStatement`:case`BalanceSheet`:i(`fundamentalId`,`Add`);break;case`Expression`:i(`expression`,`Add`);break}break;case`Get`:if(!r(`main`)&&!r(`type`))throw Error(`Get plot accessor: you must provide either 'main' or 'type'`);break;case`Delete`:i(`type`,`Delete`),a([`uid`,`index`],`Delete`);break;case`Update`:switch(i(`type`,`Update`),r(`main`)||a([`uid`,`index`],`Update`),o(`Update`),n.type){case`Forward`:if(!P(n.forward)){if(!P(n.curves)||!P(n.offsets))throw Error(`Update forward plot accessor: you must provide either 'forward' or 'curves' and 'offsets'`);if(n.curves.length!==n.offsets.length)throw Error(`Update forward plot accessor: you must provide same number of elements for 'curves' and 'offsets'`)}break;case`Seasonal`:if(!P(n.seasonal)){if(!P(n.curves)||!P(n.offsets))throw Error(`Update seasonal plot accessor: you must provide either 'seasonal' or 'curves' and 'offsets'`);if(n.curves.length!==n.offsets.length&&n.curves.length!==n.offsets.length+1)throw Error(`Update seasonal plot accessor: you must provide either same number of elements for 'curves' and 'offsets' or one curve more`)}break;case`Study`:{i(`studyId`,`Update`),o(`Update`);let e=e=>e.reduce((e,t)=>e.concat(t.fields),[]),t=B(n.studyId),r=e=>`Update study plot accessor: you must provide same number of elements for '${e}' of the study as defined in the taxonomy`,a=e=>`Update study plot accessor: incoming list of ${e} is different from the ${e} as defined in the taxonomy`;if(P(n.curves)){if(n.curves.length!==t.defaults.curves.length)throw Error(r(`curves`));let i=e(n.curves);if(j(e(t.defaults.curves),i).length!==0)throw Error(a(`fields`))}break}}break}}function jd(){kd===null&&(kd=(0,Od.default)(),kd.defaultOptions.useDefault=!0,[z.CHART_SCHEMA,z.STUDIES_SCHEMA,z.FIELDS_SCHEMA,z.ACCESSOR_SCHEMA].forEach(e=>{kd.addSchema(e,ss(e))}))}function Md(e,t){kd.addSchema(e,t)}function Nd(e){V(e,`..plots{.type}`).forEach(e=>{P(e.uid)||(e.uid=bt())}),V(e,`..plots{.type==="${C[C.Study]}"}`).forEach(e=>{let t=B(e.study);P(t)&&ut(e,t.defaults)})}function Pd(e){return e===z.CHART_SCHEMA}function Fd(e){return e===z.ACCESSOR_SCHEMA}function Id(e,t){jd();let n=Pl(e,t);Pd(t)&&(Nd(n),n=Ed(n));let r=kd.validate(t,n);if(r){let e=JSON.stringify(r,null,4);throw Error(`Document not valid according to schema ${t}; error is ${e}`)}return Fd(t)&&Ad(n),n}function Ld(e){return H(H(e,`..panes{.axes{!.plots}}`,e=>(e.axes.length===1?e.axes=[]:e.axes[1].plots.length===0&&(e.axes.pop(),e.axes[0].plots.length===0&&(e.axes=[])),e)),`..panes{!.axes}`,e=>z.NULL_OBJECT)}var Rd=JSON.parse(`[{"id":"DateTime","type":"Date"},{"id":"Open"},{"id":"High"},{"id":"Low"},{"id":"Close"},{"id":"TradeSize","format":"AsInteger"},{"id":"Volume","format":"UseMetricUnit","shortName":"VOL"},{"id":"OpenInterest","format":"UseMetricUnit","shortName":"OI"},{"id":"Last"},{"id":"Bid"},{"id":"BidSize","format":"AsInteger"},{"id":"Ask"},{"id":"AskSize","format":"AsInteger"},{"id":"Symbol","type":"String"},{"id":"Change"},{"id":"PercentChange","format":"AsPercent"},{"id":"TradingDay"},{"id":"PreviousClose"},{"id":"PreviousOpen"},{"id":"PreviousHigh"},{"id":"PreviousLow"},{"id":"WeekPreviousClose"},{"id":"WeekPreviousHigh"},{"id":"WeekPreviousLow"},{"id":"MonthPreviousClose"},{"id":"MonthPreviousHigh"},{"id":"MonthPreviousLow"},{"id":"YearHigh"},{"id":"YearLow"},{"id":"Projection","name":"Projection"},{"id":"BarIndex","name":"Bar Index"},{"id":"Dividends","type":"String","category":"Event","name":"Dividend","shortName":"D"},{"id":"Splits","type":"String","category":"Event","name":"Split","shortName":"S"},{"id":"Earnings","type":"String","category":"Event","shortName":"E"},{"id":"Buy","category":"Event","name":"BuySignal","shortName":"B"},{"id":"Sell","category":"Event","name":"SellSignal","shortName":"S"},{"id":"Custom","category":"Event","name":"CustomEvent","shortName":"Z"},{"id":"Call","category":"Option"},{"id":"Put","category":"Option"},{"id":"Delta","category":"Option"},{"id":"Gamma","category":"Option"},{"id":"Theta","category":"Option"},{"id":"Vega","category":"Option"},{"id":"WeighImplVolHigh","category":"Option","name":"Implied Volatility High","shortName":"WeighImplVolHigh"},{"id":"WeighImplVolLow","category":"Option","name":"Implied Volatility Low","shortName":"WeighImplVolLow"},{"id":"WeighImplVol","category":"Option","name":"Implied Volatility","shortName":"WeighImplVol"},{"id":"WeighImplVolHigh5D","category":"Option","name":"Weighted Implied Volatility High 5D","shortName":"WeighImplVolHigh5D"},{"id":"WeighImplVolLow5D","category":"Option","name":"Weighted Implied Volatility Low 5D","shortName":"WeighImplVolLow5D"},{"id":"WeighImplVol5D","category":"Option","name":"Weighted Implied Volatility 5D","shortName":"WeighImplVol5D"},{"id":"WeighImplVolHigh1M","category":"Option","name":"Weighted Implied Volatility High 1M","shortName":"WeighImplVolHigh1M"},{"id":"WeighImplVolLow1M","category":"Option","name":"Weighted Implied Volatility Low 1M","shortName":"WeighImplVolLow1M"},{"id":"WeighImplVol1M","category":"Option","name":"Weighted Implied Volatility 1M","shortName":"WeighImplVol1M"},{"id":"WeighImplVolHigh3M","category":"Option","name":"Weighted Implied Volatility High 3M","shortName":"WeighImplVolHigh3M"},{"id":"WeighImplVolLow3M","category":"Option","name":"Weighted Implied Volatility Low 3M","shortName":"WeighImplVolLow3M"},{"id":"WeighImplVol3M","category":"Option","name":"Weighted Implied Volatility 3M","shortName":"WeighImplVol3M"},{"id":"WeighImplVolHigh6M","category":"Option","name":"Weighted Implied Volatility High 6M","shortName":"WeighImplVolHigh6M"},{"id":"WeighImplVolLow6M","category":"Option","name":"Weighted Implied Volatility Low 6M","shortName":"WeighImplVolLow6M"},{"id":"WeighImplVol6M","category":"Option","name":"Weighted Implied Volatility 6M","shortName":"WeighImplVol6M"},{"id":"WeighImplVolHigh1Y","category":"Option","name":"Weighted Implied Volatility High 1Y","shortName":"WeighImplVolHigh1Y"},{"id":"WeighImplVolLow1Y","category":"Option","name":"Weighted Implied Volatility Low 1Y","shortName":"WeighImplVolLow1Y"},{"id":"WeighImplVol1Y","category":"Option","name":"Weighted Implied Volatility 1Y","shortName":"WeighImplVol1Y"},{"id":"WeighImplVolHighYTD","category":"Option","name":"Weighted Implied Volatility High YTD","shortName":"WeighImplVolHighYTD"},{"id":"WeighImplVolLowYTD","category":"Option","name":"Weighted Implied Volatility Low YTD","shortName":"WeighImplVolLowYTD"},{"id":"WeighImplVolYTD","category":"Option","name":"Weighted Implied Volatility YTD","shortName":"WeighImplVolYTD"},{"id":"WeighImplVolChg","category":"Option","name":"Weighted Implied Volatility Change","shortName":"WeighImplVolChg"},{"id":"ImplVolRank5D","category":"Option","name":"Implied Volatility Rank 5D","shortName":"ImplVolRank5D"},{"id":"ImplVolRank1M","category":"Option","name":"Implied Volatility Rank 1M","shortName":"ImplVolRank1M"},{"id":"ImplVolRank3M","category":"Option","name":"Implied Volatility Rank 3M","shortName":"ImplVolRank3M"},{"id":"ImplVolRank6M","category":"Option","name":"Implied Volatility Rank 6M","shortName":"ImplVolRank6M"},{"id":"ImplVolRank1Y","category":"Option","name":"Implied Volatility Rank","shortName":"ImplVolRank1Y"},{"id":"ImplVolRankYTD","category":"Option","name":"Implied Volatility Rank YTD","shortName":"ImplVolRankYTD"},{"id":"ImplVolPerc5D","category":"Option","name":"Implied Volatility Perc. 5D","shortName":"ImplVolPerc5D"},{"id":"ImplVolPerc1M","category":"Option","name":"Implied Volatility Perc. 1M","shortName":"ImplVolPerc1M"},{"id":"ImplVolPerc3M","category":"Option","name":"Implied Volatility Perc. 3M","shortName":"ImplVolPerc3M"},{"id":"ImplVolPerc6M","category":"Option","name":"Implied Volatility Perc. 6M","shortName":"ImplVolPerc6M"},{"id":"ImplVolPerc1Y","category":"Option","name":"Implied Volatility Percentile","shortName":"ImplVolPerc1Y"},{"id":"ImplVolPercYTD","category":"Option","name":"Implied Volatility Perc. YTD","shortName":"ImplVolPercYTD"},{"id":"OptTotVol","category":"Option","name":"Options Total Volume","shortName":"OptTotVol","format":"UseMetricUnit"},{"id":"OptCallVol","category":"Option","name":"Options Call Volume","shortName":"OptCallVol","format":"UseMetricUnit"},{"id":"OptPutVol","category":"Option","name":"Options Put Volume","shortName":"OptPutVol","format":"UseMetricUnit"},{"id":"PutCallVolRatio","category":"Option","name":"Put Call Volume Ratio","shortName":"PutCallVolRatio"},{"id":"TotalOpenInt","category":"Option","name":"Total Open Interest","shortName":"Total OI","format":"UseMetricUnit"},{"id":"CallOpenInt","category":"Option","name":"Call Open Interest","shortName":"Call OI","format":"UseMetricUnit"},{"id":"PutOpenInt","category":"Option","name":"Put Open Interest","shortName":"Put OI","format":"UseMetricUnit"},{"id":"PutCallOIRatio","category":"Option","name":"Put Call OI Ratio","shortName":"Put Call OI Ratio"},{"id":"CallIVCurve","category":"Option","name":"Call IV Curve","shortName":"Call IV Curve"},{"id":"PutIVCurve","category":"Option","name":"Put IV Curve","shortName":"Put IV Curve"},{"id":"CallTheoretical","category":"Option","name":"Call Theoretical","shortName":"Call Theoretical"},{"id":"PutTheoretical","category":"Option","name":"Put Theoretical","shortName":"Put Theoretical"},{"id":"HL/2","category":"Study","name":"(High+Low)/2","shortName":"(H+L)/2"},{"id":"OC/2","category":"Study","name":"(Open+Close)/2","shortName":"(O+C)/2"},{"id":"HLC/3","category":"Study","name":"(High+Low+Close)/3","shortName":"(H+L+C)/3"},{"id":"OHLC/4","category":"Study","name":"(Open+High+Low+Close)/4","shortName":"(O+H+L+C)/4"},{"id":"HLCC/4","category":"Study","name":"(High+Low+Close+Close)/4","shortName":"(H+L+C+C)/4"},{"id":"AVG","category":"Study","name":"Average","shortName":"AVG"},{"id":"FRAMA","category":"Study","name":"FRAMA","shortName":"FRAMA"},{"id":"MA","category":"Study","name":"MA-Simple","shortName":"MA"},{"id":"MACLD1","category":"Study","name":"MA-Cloud-Fast","shortName":"MACLD1"},{"id":"MACLD2","category":"Study","name":"MA-Cloud-Slow","shortName":"MACLD2"},{"id":"MA1","category":"Study","name":"MA1-Simple","shortName":"MA1"},{"id":"MA2","category":"Study","name":"MA2-Simple","shortName":"MA2"},{"id":"MA3","category":"Study","name":"MA3-Simple","shortName":"MA3"},{"id":"MA4","category":"Study","name":"MA4-Simple","shortName":"MA4"},{"id":"MA5","category":"Study","name":"MA5-Simple","shortName":"MA5"},{"id":"MA6","category":"Study","name":"MA6-Simple","shortName":"MA6"},{"id":"MA7","category":"Study","name":"MA7-Simple","shortName":"MA7"},{"id":"MA8","category":"Study","name":"MA8-Simple","shortName":"MA8"},{"id":"MA9","category":"Study","name":"MA9-Simple","shortName":"MA9"},{"id":"MA10","category":"Study","name":"MA10-Simple","shortName":"MA10"},{"id":"MAS","category":"Study","name":"MA-Shorter","shortName":"MAS"},{"id":"MAL","category":"Study","name":"MA-Longer","shortName":"MAL"},{"id":"CMBCI","category":"Study","name":"Composite Index","shortName":"CMBCI"},{"id":"CMBCIF","category":"Study","name":"Fast Ma","shortName":"CMBCIF"},{"id":"CMBCIS","category":"Study","name":"Slow Ma","shortName":"CMBCIS"},{"id":"COTI","category":"Study","name":"COT Index","shortName":"COTI"},{"id":"CHEXL","category":"Study","name":"ChandelierExitLong","shortName":"CHEXL"},{"id":"CHEXS","category":"Study","name":"ChandelierExitShort","shortName":"CHEXS"},{"id":"SUPTR","category":"Study","name":"Supertrend","shortName":"SUPTR"},{"id":"BARCOLIX","category":"Study","name":"BarColorIndex","shortName":"BARCOLIX"},{"id":"BARKIND","category":"Study","name":"BarKind","shortName":"BARKIND"},{"id":"BREL","category":"Study","name":"BarRelation","shortName":"BREL"},{"id":"EMA","category":"Study","name":"MA-Exp","shortName":"MA(EXP)"},{"id":"MAHI","category":"Study","name":"MA-High","shortName":"MA(HI)"},{"id":"MALO","category":"Study","name":"MA-Low","shortName":"MA(LO)"},{"id":"MACD","category":"Study","name":"MACD","shortName":"MACD"},{"id":"MACDS","category":"Study","name":"MACD-Signal","shortName":"MACD(S)"},{"id":"MACDH","category":"Study","name":"MACD-Histogram","shortName":"MACD(H)"},{"id":"MACDV","category":"Study","name":"MACD-V","shortName":"MACD-V"},{"id":"MACDVS","category":"Study","name":"MACD-V-Signal","shortName":"MACD-V(S)"},{"id":"MACDVH","category":"Study","name":"MACD-V-Histogram","shortName":"MACD-V(H)"},{"id":"ENVU","category":"Study","name":"Envelope-Up","shortName":"ENV(UP)"},{"id":"ENVD","category":"Study","name":"Envelope-Down","shortName":"ENV(DN)"},{"id":"ENVEXPU","category":"Study","name":"Envelope-Exponential-Up","shortName":"ENVEXP(UP)"},{"id":"ENVEXPD","category":"Study","name":"Envelope-Exponential-Down","shortName":"ENVEXP(DN)"},{"id":"ENVSMOU","category":"Study","name":"Envelope-Smoothed-Up","shortName":"ENVSMO(UP)"},{"id":"ENVSMOD","category":"Study","name":"Envelope-Smoothed-Down","shortName":"ENVSMO(DN)"},{"id":"SMA","category":"Study","name":"MA-Smoothed","shortName":"MA(S)"},{"id":"CSHO","category":"Study","name":"Cash-Overlay","shortName":"CSHO"},{"id":"CSHB","category":"Study","name":"Cash-Basis","shortName":"CSHB"},{"id":"MKTCAP","category":"Study","name":"Market-Cap","format":"UseMetricUnit","shortName":"MktCap"},{"id":"TMA","category":"Study","name":"MA-Triangular","shortName":"MA(TRI)"},{"id":"WMA","category":"Study","name":"MA-Weighted","shortName":"MA(W)"},{"id":"VOLMA","category":"Study","format":"UseMetricUnit","name":"MA-Volume","shortName":"VOLMA"},{"id":"OSC","category":"Study","name":"OSC","shortName":"OSC"},{"id":"VOSC","category":"Study","format":"UseMetricUnit","name":"OSC-Volume","shortName":"VOLOSC"},{"id":"RSI","category":"Study","name":"RSI","shortName":"RSI"},{"id":"RSIAVG","category":"Study","name":"RSI-Average","shortName":"RSIAVG"},{"id":"RSA","category":"Study","name":"RSA","shortName":"RSA"},{"id":"RSAAVG","category":"Study","name":"RSA-Average","shortName":"RSIAVG"},{"id":"STORSI","category":"Study","name":"StochRSI","shortName":"STOCHRSI"},{"id":"STORSIAVG","category":"Study","name":"StochRSIAvg","shortName":"STOCHRSIAVG"},{"id":"HH","category":"Study","name":"HighestHigh","shortName":"HHIGH"},{"id":"LL","category":"Study","name":"LowestLow","shortName":"LLOW"},{"id":"PercK","category":"Study","name":"%K","shortName":"PCNTK"},{"id":"PercD","category":"Study","name":"%D","shortName":"PCNTD"},{"id":"PercR","category":"Study","name":"%R","shortName":"PCNTR"},{"id":"WGCL","category":"Study","name":"WeightedClose","shortName":"WTCL"},{"id":"WGALPH","category":"Study","name":"WeightedAlpha","shortName":"WGALPH"},{"id":"UPVOL","category":"Study","format":"UseMetricUnit","name":"UpVol","shortName":"UPVOL"},{"id":"DNVOL","category":"Study","format":"UseMetricUnit","name":"DownVol","shortName":"DNVOL"},{"id":"TOTVOL","category":"Study","format":"UseMetricUnit","name":"TotVol","shortName":"TOTVOL"},{"id":"POC","category":"Study","name":"PointOfControl","shortName":"POC"},{"id":"VAREA","category":"Study","name":"ValueArea","shortName":"VAREA"},{"id":"BARBACK","category":"Study","name":"Background","shortName":"BARBACK"},{"id":"BOLLBU","category":"Study","name":"Bollinger-Upper","shortName":"BOLL(U)"},{"id":"BOLLBL","category":"Study","name":"Bollinger-Lower","shortName":"BOLL(L)"},{"id":"BOLLBM","category":"Study","name":"Bollinger-Mid","shortName":"BOLL(M)"},{"id":"BOLLW","category":"Study","name":"Bollinger-Width","shortName":"BOLL(W)"},{"id":"BOLLP","category":"Study","name":"Bollinger-Percent","shortName":"BOLL(%B)"},{"id":"BOLLBW","category":"Study","name":"Bollinger-BandWidth","shortName":"BOLL(BW)"},{"id":"BOLLBWA","category":"Study","name":"Bollinger-BandWidthAvg","shortName":"BOLL(BWA)"},{"id":"PCUP1","category":"Study","name":"ProbCone-Up1","shortName":"PCUP1"},{"id":"PCDN1","category":"Study","name":"ProbCone-Down1","shortName":"PCDN1"},{"id":"PCUP2","category":"Study","name":"ProbCone-Up2","shortName":"PCUP2"},{"id":"PCDN2","category":"Study","name":"ProbCone-Down2","shortName":"PCDN2"},{"id":"PCUP3","category":"Study","name":"ProbCone-Up3","shortName":"PCUP3"},{"id":"PCDN3","category":"Study","name":"ProbCone-Down3","shortName":"PCDN3"},{"id":"PCTD","category":"Study","name":"ProbCone-TgtDate","shortName":"PCTD"},{"id":"PCTP","category":"Study","name":"ProbCone-TgtPrice","shortName":"PCTP"},{"id":"MBBUO","category":"Study","name":"ModifiedBoll-UppOut","shortName":"MBOLL(UO)"},{"id":"MBBUI","category":"Study","name":"ModifiedBoll-UppIn","shortName":"MBOLL(UI)"},{"id":"MBBM","category":"Study","name":"ModifiedBoll-Mid","shortName":"MBOLL(M)"},{"id":"MBBLI","category":"Study","name":"ModifiedBoll-LowIn","shortName":"MBOLL(LI)"},{"id":"MBBLO","category":"Study","name":"ModifiedBoll-LowOut","shortName":"MBOLL(LO)"},{"id":"OBVOL","category":"Study","format":"UseMetricUnit","name":"OnBalanceVol","shortName":"OBVOL"},{"id":"OBVOLAVG","category":"Study","format":"UseMetricUnit","name":"OnBalanceVolAvg","shortName":"OBVOL"},{"id":"TR","category":"Study","name":"TrueRange","shortName":"TR"},{"id":"ATR","category":"Study","name":"AvgTrueRange","shortName":"ATR"},{"id":"ATRMA","category":"Study","name":"MA-ATR","shortName":"MA(ATR)"},{"id":"ADJATR","category":"Study","name":"AdjAvgTrueRange","shortName":"ADJATR"},{"id":"COTR","category":"Study","name":"ChgOverTrueRange","shortName":"COTR"},{"id":"ATRP","category":"Study","name":"AvgTrueRangePerc","shortName":"ATRP"},{"id":"STOMOMIX","category":"Study","name":"StochMomIndex","shortName":"STOMOMIX"},{"id":"CHDMOMOSC","category":"Study","name":"ChandeMomOsc","shortName":"CHDMOMOSC"},{"id":"CHDMOMOSCAVG","category":"Study","name":"ChandeMomOsc-Avg","shortName":"CHDMOMOSCAVG"},{"id":"PDI","category":"Study","name":"+DI","shortName":"+DI"},{"id":"MDI","category":"Study","name":"-DI","shortName":"-DI"},{"id":"PLVI","category":"Study","name":"+VI","shortName":"+VI"},{"id":"MNVI","category":"Study","name":"-VI","shortName":"-VI"},{"id":"ADX","category":"Study","name":"ADX","shortName":"ADX"},{"id":"ADXM","category":"Study","name":"ADX-Modified","shortName":"ADXM"},{"id":"ADL","category":"Study","format":"UseMetricUnit","name":"AccDist","shortName":"ACCDIS"},{"id":"ADWM","category":"Study","name":"AccDistWill","shortName":"ACCDISWIL"},{"id":"ADWMMA","category":"Study","name":"AccDistWillMovAvg","shortName":"ACCDISWILMA"},{"id":"MCGD","category":"Study","name":"McGinleyDyn","shortName":"MCGD"},{"id":"HMA","category":"Study","name":"HullMovAvg","shortName":"HMA"},{"id":"COPP","category":"Study","name":"CoppCurve","shortName":"COPP"},{"id":"CHAOSC","category":"Study","format":"UseMetricUnit","name":"ChaikinOsc","shortName":"CHAIKOSC"},{"id":"TP","category":"Study","name":"TypicalPrice","shortName":"TP"},{"id":"KCUP","category":"Study","name":"KeltChan-Up","shortName":"KELT(UP)"},{"id":"KCMID","category":"Study","name":"KeltChan-Mid","shortName":"KELT(MID)"},{"id":"KCLOW","category":"Study","name":"KeltChan-Low","shortName":"KELT(LO)"},{"id":"KBUP","category":"Study","name":"KeltBands-Up","shortName":"KELB(UP)"},{"id":"KBMID","category":"Study","name":"KeltBands-Mid","shortName":"KELB(MID)"},{"id":"KBLOW","category":"Study","name":"KeltBands-Low","shortName":"KELB(LO)"},{"id":"DONUP","category":"Study","name":"Donchian-Up","shortName":"DON(U)"},{"id":"DONMID","category":"Study","name":"Donchian-Mid","shortName":"DON(M)"},{"id":"DONLOW","category":"Study","name":"Donchian-Low","shortName":"DON(L)"},{"id":"DONW","category":"Study","name":"Donchian-Width","shortName":"DON(W)"},{"id":"PVT","category":"Study","format":"UseMetricUnit","name":"PriceVolChange","shortName":"PVOL"},{"id":"TRIX","category":"Study","name":"Triple-MA-Exp","shortName":"TRIX"},{"id":"ROC","category":"Study","name":"RateOfChange","shortName":"ROC"},{"id":"PVPT","category":"Study","name":"PivotPoint","shortName":"PVMOV"},{"id":"PVPTR","category":"Study","name":"PvtPt-Resistance","shortName":"PVMOV(R)"},{"id":"PVPTS","category":"Study","name":"PvtPt-Support","shortName":"PVMOV(S)"},{"id":"FISHER","category":"Study","name":"Fisher","shortName":"Fisher"},{"id":"FISHTRG","category":"Study","name":"Fisher-Trigger","shortName":"Trigger"},{"id":"ARNUP","category":"Study","name":"Aroon-Up","shortName":"ARN(UP)"},{"id":"ARNLOW","category":"Study","name":"Aroon-Down","shortName":"ARN(DN)"},{"id":"VSTOPUP","category":"Study","name":"VolaStop-Up","shortName":"VSTOP(UP)"},{"id":"VSTOPLOW","category":"Study","name":"VolaStop-Down","shortName":"VSTOP(DN)"},{"id":"ARNOSC","category":"Study","name":"Aroon-Osci","shortName":"ARNOSC"},{"id":"TCHNUP","category":"Study","name":"TurtleChn-Up","shortName":"TCH(UP)"},{"id":"TCHNLOW","category":"Study","name":"TurtleChn-Low","shortName":"TCH(LO)"},{"id":"TCHRE","category":"Study","name":"TurtleChnRetrace","shortName":"TCHRE"},{"id":"ALJAW","category":"Study","name":"Alligator-Jaw","shortName":"AL(J)"},{"id":"ALTEETH","category":"Study","name":"Alligator-Teeth","shortName":"AL(T)"},{"id":"ALLIPS","category":"Study","name":"Alligator-Lips","shortName":"AL(L)"},{"id":"PLTLN","category":"Study","name":"PlotLine","shortName":"LINE"},{"id":"AWOS","category":"Study","name":"AwesomeOsc","shortName":"AWOSC"},{"id":"AWOSMA","category":"Study","name":"AwesomeOsc-MA","shortName":"AWOSC(MA)"},{"id":"MFMUL","category":"Study","name":"MoneyFlowMul"},{"id":"CLV","category":"Study","name":"CloseLocationValue","shortName":"CLV"},{"id":"CHOP","category":"Study","name":"ChoppinessIndex","shortName":"ChopIx"},{"id":"CHAMF","category":"Study","name":"ChaikinMoneyFlow","shortName":"CHAIKMF"},{"id":"CHAVOL","category":"Study","name":"ChaikinVolatility","shortName":"CHAIKVOL"},{"id":"DPO","category":"Study","name":"DetrendedPriceOsc","shortName":"DPO"},{"id":"CCI","category":"Study","name":"CommodityChannelIndex","shortName":"CCI"},{"id":"EMV","category":"Study","name":"EaseOfMovement","shortName":"EOM"},{"id":"EMVMA","category":"Study","name":"EaseOfMovementMA","shortName":"EOM(MA)"},{"id":"ERBLPOW","category":"Study","name":"ElderRayBullPow","shortName":"ER(BULL)"},{"id":"ERBRPOW","category":"Study","name":"ElderRayBearPow","shortName":"ER(BEAR)"},{"id":"FI","category":"Study","format":"UseMetricUnit","name":"ForceIndex","shortName":"FORCE"},{"id":"MI","category":"Study","name":"MassIndex","shortName":"MASS"},{"id":"MOM","category":"Study","name":"Momentum","shortName":"MOM"},{"id":"MOMMA","category":"Study","name":"MA-Momentum","shortName":"MA(MOM)"},{"id":"MFI","category":"Study","name":"MoneyFlowIndex","shortName":"MFI"},{"id":"MSD","category":"Study","name":"MovingStdDev","shortName":"MSD"},{"id":"PCTCHG","category":"Study","name":"PercentChange","shortName":"PCTCHG"},{"id":"LINRUP","category":"Study","name":"LinRegUpper","shortName":"LINRUP"},{"id":"LINRMID","category":"Study","name":"LinRegMiddle","shortName":"LINRMID"},{"id":"LINRLOW","category":"Study","name":"LinRegLower","shortName":"LINRLOW"},{"id":"NVI","category":"Study","name":"NegativeVolIndex","shortName":"NVI"},{"id":"NVIEMA","category":"Study","name":"NegativeVolIndexEMA","shortName":"NVI(EMA)"},{"id":"PVI","category":"Study","name":"PositiveVolIndex","shortName":"PVI"},{"id":"PVIEMA","category":"Study","name":"PositiveVolIndexEMA","shortName":"PVI(EMA)"},{"id":"PPO","category":"Study","name":"PercPriceOsc","shortName":"PPO"},{"id":"PPOS","category":"Study","name":"PPO-Signal","shortName":"PPO(S)"},{"id":"PPOH","category":"Study","name":"PPO-Histogram","shortName":"PPO(H)"},{"id":"PVO","category":"Study","name":"PercVolOsc","shortName":"PVO"},{"id":"PVOS","category":"Study","name":"PVO-Signal","shortName":"PVO(S)"},{"id":"PVOH","category":"Study","name":"PVO-Histogram","shortName":"PVO(H)"},{"id":"HV","category":"Study","name":"HistVolatility","shortName":"HISTVOL"},{"id":"PERF","category":"Study","name":"Performance","shortName":"PERF"},{"id":"STC","category":"Study","name":"SchaffTrendCycle","shortName":"STC"},{"id":"MCCLO","category":"Study","name":"McClellanOsc","shortName":"MCCLO"},{"id":"BTI","category":"Study","name":"BreadthThrust","shortName":"BTI"},{"id":"NHLAI","category":"Study","name":"NewHiLoAccIx","shortName":"NHLAI"},{"id":"KST","category":"Study","name":"KnowSureThing","shortName":"KST"},{"id":"KSTSIG","category":"Study","name":"KST-Signal","shortName":"KSTSIG"},{"id":"WASI","category":"Study","name":"WilderAccSwingIndex","shortName":"WACCSW"},{"id":"WWVSARU","category":"Study","name":"WilderVolSarUp","shortName":"WVOL-UP"},{"id":"WWVSARD","category":"Study","name":"WilderVolSarDown","shortName":"WVOL-DN"},{"id":"PARSARS","category":"Study","name":"ParabolicSarShort","shortName":"SHORT"},{"id":"PARSARL","category":"Study","name":"ParabolicSarLong","shortName":"LONG"},{"id":"REATRS","category":"Study","name":"RetraceATRStop","shortName":"REATRS"},{"id":"MOVLR","category":"Study","name":"MovingLinRegression","shortName":"MOVLINREG"},{"id":"TRSP1","category":"Study","name":"TrendSeeker®","shortName":"TREND"},{"id":"TRSP2","category":"Study","name":"TrendSeeker®","shortName":"TREND"},{"id":"TARGP","category":"Study","name":"Target Price","shortName":"TARGP"},{"id":"COTLCCMSP","category":"Study","name":"Comm Spec","shortName":"COT(C)"},{"id":"COTLCLGSP","category":"Study","name":"Large Spec","shortName":"COT(L)"},{"id":"COTLCSMSP","category":"Study","name":"Small Spec","shortName":"COT(S)"},{"id":"COTDAGPRO","category":"Study","name":"Producers","shortName":"COTDIS(P)"},{"id":"COTDAGSPD","category":"Study","name":"Swap Dealers","shortName":"COTDIS(S)"},{"id":"COTDAGMNM","category":"Study","name":"Managed Money","shortName":"COTDIS(M)"},{"id":"COTDAGOTH","category":"Study","name":"Other Report","shortName":"COTDIS(O)"},{"id":"COTFTRDLI","category":"Study","name":"Dealer Intermediary","shortName":"COTFIN(D)"},{"id":"COTFTRASM","category":"Study","name":"Asset Manager","shortName":"COTFIN(A)"},{"id":"COTFTRLVF","category":"Study","name":"Leveraged Funds","shortName":"COTFIN(L)"},{"id":"COTFTROTH","category":"Study","name":"Other Report","shortName":"COTFIN(O)"},{"id":"PPTPIV","category":"Study","name":"Pivot Point","shortName":"PPT(P)"},{"id":"PPTR1","category":"Study","name":"1st Resistance","shortName":"PPT(R1)"},{"id":"PPTR2","category":"Study","name":"2nd Resistance","shortName":"PPT(R2)"},{"id":"PPTR3","category":"Study","name":"3rd Resistance","shortName":"PPT(R3)"},{"id":"PPTS1","category":"Study","name":"1st Support","shortName":"PPT(S1)"},{"id":"PPTS2","category":"Study","name":"2nd Support","shortName":"PPT(S2)"},{"id":"PPTS3","category":"Study","name":"3rd Support","shortName":"PPT(S3)"},{"id":"CPPH4","category":"Study","name":"4th Camarilla Res","shortName":"CPP(H4)"},{"id":"CPPH3","category":"Study","name":"3rd Camarilla Res","shortName":"CPP(H3)"},{"id":"CPPH2","category":"Study","name":"2nd Camarilla Res","shortName":"CPP(H2)"},{"id":"CPPH1","category":"Study","name":"1st Camarilla Res","shortName":"CPP(H1)"},{"id":"CPPL1","category":"Study","name":"1st Camarilla Supp","shortName":"CPP(L1)"},{"id":"CPPL2","category":"Study","name":"2nd Camarilla Supp","shortName":"CPP(L2)"},{"id":"CPPL3","category":"Study","name":"3rd Camarilla Supp","shortName":"CPP(L3)"},{"id":"CPPL4","category":"Study","name":"4th Camarilla Supp","shortName":"CPP(L4)"},{"id":"IMPVOL","category":"Study","name":"Implied Volatility","shortName":"IV"},{"id":"CTM","category":"Study","name":"Cycle Trading Momentum","shortName":"CTM"},{"id":"CPMI","category":"Study","name":"Principal Momentum","shortName":"CPMI"},{"id":"CTPI","category":"Study","name":"Turning Point","shortName":"CTPI"},{"id":"CTLTM","category":"Study","name":"Long-Term Momentum","shortName":"LTM"},{"id":"CTLTMF","category":"Study","name":"Long-Term Momentum, Fast","shortName":"LTM(F)"},{"id":"DEMA","category":"Study","name":"Double EMA","shortName":"DEMA"},{"id":"EOSC","category":"Study","name":"Exponential Oscillator","shortName":"EOSC"},{"id":"TEMA","category":"Study","name":"Triple EMA","shortName":"TEMA"},{"id":"TSI","category":"Study","name":"True Strength Index","shortName":"Tsi"},{"id":"TSISIG","category":"Study","name":"True Strength Index Signal","shortName":"TsiSig"},{"id":"GMMA3","category":"Study","name":"GMMA-EMA3","shortName":"GMMA(3)"},{"id":"GMMA5","category":"Study","name":"GMMA-EMA5","shortName":"GMMA(5)"},{"id":"GMMA8","category":"Study","name":"GMMA-EMA8","shortName":"GMMA(8)"},{"id":"GMMA10","category":"Study","name":"GMMA-EMA10","shortName":"GMMA(10)"},{"id":"GMMA12","category":"Study","name":"GMMA-EMA12","shortName":"GMMA(12)"},{"id":"GMMA15","category":"Study","name":"GMMA-EMA15","shortName":"GMMA(15)"},{"id":"GMMA30","category":"Study","name":"GMMA-EMA30","shortName":"GMMA(30)"},{"id":"GMMA35","category":"Study","name":"GMMA-EMA35","shortName":"GMMA(35)"},{"id":"GMMA40","category":"Study","name":"GMMA-EMA40","shortName":"GMMA(40)"},{"id":"GMMA45","category":"Study","name":"GMMA-EMA45","shortName":"GMMA(45)"},{"id":"GMMA50","category":"Study","name":"GMMA-EMA50","shortName":"GMMA(50)"},{"id":"GMMA60","category":"Study","name":"GMMA-EMA60","shortName":"GMMA(60)"},{"id":"CONVLN","category":"Study","name":"ConversionLine","shortName":"ConvLn"},{"id":"BASELN","category":"Study","name":"BaseLine","shortName":"BaseLn"},{"id":"LEADSP1","category":"Study","name":"LeadingSpanA","shortName":"LeadSpA"},{"id":"LEADSP2","category":"Study","name":"LeadingSpanB","shortName":"LeadSpB"},{"id":"LAGGSP","category":"Study","name":"LaggingSpan","shortName":"LaggSp"},{"id":"VWAP","category":"Study","name":"VWAP","shortName":"VWAP"},{"id":"AVWAP","category":"Study","name":"Anchored VWAP","shortName":"Anch-VWAP"},{"id":"VWAPSD1U","category":"Study","name":"VWAP Stdev1 Upper","shortName":"VWAP-Std1-Up"},{"id":"VWAPSD1L","category":"Study","name":"VWAP Stdev1 Lower","shortName":"VWAP-Std1-Lo"},{"id":"VWAPSD2U","category":"Study","name":"VWAP Stdev2 Upper","shortName":"VWAP-Std2-Up"},{"id":"VWAPSD2L","category":"Study","name":"VWAP Stdev2 Lower","shortName":"VWAP-Std2-Lo"},{"id":"DIFA","category":"Study","name":"Distance From Average","shortName":"DistAvg"},{"id":"DOSCH","category":"Study","name":"Derivative Oscillator","shortName":"DerOsc"},{"id":"DOSCS","category":"Study","name":"Derivative Oscillator Signal","shortName":"DerOscSig"},{"id":"TTMSQZON","category":"Study","name":"TTM Squeeze On","shortName":"TtmSqzOn"},{"id":"TTMSQZOFF","category":"Study","name":"TTM Squeeze Off","shortName":"TtmSqzOff"},{"id":"TTMSQZOSC","category":"Study","name":"TTM Squeeze Osc","shortName":"TtmSqzOsc"},{"id":"CRS","category":"Study","name":"CompRelStrength","shortName":"CRS"},{"id":"CRSAVG","category":"Study","name":"CompRelStrengthAvg","shortName":"CRS-Avg"},{"id":"DRS","category":"Study","name":"DorseyRelStrength","shortName":"DRS"},{"id":"MRS","category":"Study","name":"MansfieldRelStrength","shortName":"MRS"},{"id":"PMO","category":"Study","name":"PriceMomOsc","shortName":"PMO"},{"id":"PMOS","category":"Study","name":"PriceMomOscSig","shortName":"PMOS"},{"id":"RVOL","category":"Study","name":"Relative Volume","shortName":"RVOL"},{"id":"AccountsPayable","category":"BalanceSheet","format":"UseMetricUnit","name":"Accounts Payable","shortName":"AcctsPay"},{"id":"AccruedExpenses","category":"BalanceSheet","format":"UseMetricUnit","name":"Accrued Expenses","shortName":"AccrdExp"},{"id":"Cash","category":"BalanceSheet","format":"UseMetricUnit","name":"Cash & Cash Equivalents","shortName":"Cash&CashEqv"},{"id":"CommonShares","category":"BalanceSheet","format":"UseMetricUnit","name":"Common Shares","shortName":"CommonShares"},{"id":"SharesOutstanding","category":"BalanceSheet","format":"UseMetricUnit","name":"Shares Outstanding","shortName":"SharesOutstanding"},{"id":"DeferredIncomeTax","category":"BalanceSheet","format":"UseMetricUnit","name":"Deferred Income Tax","shortName":"DefIncTax"},{"id":"DeferredLongRevenues","category":"BalanceSheet","format":"UseMetricUnit","name":"Deferred Revenues","shortName":"DefRev"},{"id":"EquityOtherInvestments","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Equity Investments","shortName":"OthEquityInvest"},{"id":"IncomeTaxPayable","category":"BalanceSheet","format":"UseMetricUnit","name":"Income Tax Payable","shortName":"IncTaxPayble"},{"id":"Intangibles","category":"BalanceSheet","format":"UseMetricUnit","name":"Intangibles","shortName":"Intangibles"},{"id":"Inventories","category":"BalanceSheet","format":"UseMetricUnit","name":"Inventories","shortName":"Inventory"},{"id":"LongTermDebt","category":"BalanceSheet","format":"UseMetricUnit","name":"Long Term Debt","shortName":"LTDebt"},{"id":"MarketableSec","category":"BalanceSheet","format":"UseMetricUnit","name":"Liquid Securities","shortName":"LiqSecurities"},{"id":"OtherCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Miscellaneous Current Assets","shortName":"MiscCurrAssets"},{"id":"OtherCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Current Liabilities","shortName":"OthCurrLiab"},{"id":"OtherEquity","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Equity","shortName":"OthEquity"},{"id":"OtherNonCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Non-Current Assets","shortName":"OthNonCurrAssets"},{"id":"OtherNonCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Other Non-Current Liabilities","shortName":"OthNonCurrLiab"},{"id":"PpeNet","category":"BalanceSheet","format":"UseMetricUnit","name":"PPE Net","shortName":"PPENet"},{"id":"PrepaidExpenses","category":"BalanceSheet","format":"UseMetricUnit","name":"Prepaid Expenses","shortName":"PpdExp"},{"id":"Receivables","category":"BalanceSheet","format":"UseMetricUnit","name":"Receivables","shortName":"Receivables"},{"id":"RetainedEarnings","category":"BalanceSheet","format":"UseMetricUnit","name":"Retained Earnings","shortName":"RetEarnings"},{"id":"ShorttermDebt","category":"BalanceSheet","format":"UseMetricUnit","name":"Short-Term Debt","shortName":"ShortTermDebt"},{"id":"TotalAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Assets","shortName":"TotAssets"},{"id":"TotalCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Current Assets","shortName":"TotCurrAssets"},{"id":"TotalCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Current Liabilities","shortName":"TotCurrLiab"},{"id":"TotalLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Liabilities","shortName":"TotalLiab"},{"id":"TotalLiabilitiesAndEquity","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Liabilities & Equity","shortName":"TotLiab&Equity"},{"id":"TotalNonCurrentAssets","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Non-Current Assets","shortName":"TotNonCurrAssets"},{"id":"TotalNonCurrentLiabilities","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Non-Current Liabilities","shortName":"TotNonCurrLiabs"},{"id":"TotalShareholdersEquity","category":"BalanceSheet","format":"UseMetricUnit","name":"Total Shareholders Equity","shortName":"TotShareEquity"},{"id":"BasicEpsContOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Basic EPS Continued Operations","shortName":"EPSContOps"},{"id":"BasicEpsTotalOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Basic EPS Total Operations","shortName":"EPSTotOps"},{"id":"CostGoods","category":"IncomeStatement","format":"UseMetricUnit","name":"Cost of Goods","shortName":"COGS"},{"id":"DilutedEpsContOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Diluted EPS Continued Operations","shortName":"DilutedEPSContOps"},{"id":"DilutedEpsTotalOp","category":"IncomeStatement","format":"UseMetricUnit","name":"Diluted EPS Total Operations","shortName":"DilutedEPSTotOps"},{"id":"Ebitda","category":"IncomeStatement","format":"UseMetricUnit","name":"EBITDA","shortName":"EBITDA"},{"id":"GrossProfit","category":"IncomeStatement","format":"UseMetricUnit","name":"Gross Profit","shortName":"GrProfit"},{"id":"IncomeTax","category":"IncomeStatement","format":"UseMetricUnit","name":"Income Tax","shortName":"IncomeTax"},{"id":"InterestExpense","category":"IncomeStatement","format":"UseMetricUnit","name":"Interest Expense","shortName":"IntExp"},{"id":"NetIncome","category":"IncomeStatement","format":"UseMetricUnit","name":"Net Income Less Expenses & Tax","shortName":"NetIncome"},{"id":"OperatingExpenses","category":"IncomeStatement","format":"UseMetricUnit","name":"Operating Expenses","shortName":"OpExpense"},{"id":"OperatingIncome","category":"IncomeStatement","format":"UseMetricUnit","name":"Operating Income","shortName":"OpIncome"},{"id":"OtherIncomeExpenses","category":"IncomeStatement","format":"UseMetricUnit","name":"Other Income","shortName":"OthInc"},{"id":"PreTaxIncome","category":"IncomeStatement","format":"UseMetricUnit","name":"Pretax Income","shortName":"PretaxInc"},{"id":"Sales","category":"IncomeStatement","format":"UseMetricUnit","name":"Sales","shortName":"Sales"},{"id":"JPIB","category":"Study","name":"JPI-Buy","shortName":"Buy"},{"id":"JPIS","category":"Study","name":"JPI-Sell","shortName":"Sell"},{"id":"TDIPRC","category":"Study","name":"TDI Price Line","shortName":"PriceLn"},{"id":"TDITSL","category":"Study","name":"TDI Trade Signal","shortName":"TradeSig"},{"id":"TDIMBL","category":"Study","name":"TDI Market Base","shortName":"MktBase"},{"id":"TDIUPR","category":"Study","name":"TDI Upper Band","shortName":"UpperBnd"},{"id":"TDILWR","category":"Study","name":"TDI Lower Band","shortName":"LowerBnd"},{"id":"PPS","category":"Study","name":"PricePercentStop","shortName":"PPS"},{"id":"RCI","category":"Study","name":"RankCorrelationIndex","shortName":"RCI"},{"id":"RCISIG","category":"Study","name":"RCI Signal","shortName":"RCISig"},{"id":"ZZPIVOT","category":"Study","name":"ZigZag Pivot","shortName":"ZZPivot"},{"id":"ADR","category":"Study","name":"AvgDailyRange","shortName":"ADR"},{"id":"ADRP","category":"Study","name":"AvgDailyRangePerc","shortName":"ADRP"},{"id":"BOP","category":"Study","name":"BalanceOfPower","shortName":"BOP"},{"id":"BOPAVG","category":"Study","name":"BalanceOfPowerAvg","shortName":"BOPAVG"},{"id":"CORR","category":"Study","name":"CorrelationCoefficient","shortName":"Corr"},{"id":"RVI","category":"Study","name":"RelativeVigorIndex","shortName":"RVI"},{"id":"RVISIG","category":"Study","name":"RVI Signal","shortName":"RVISig"}]`),zd=class{constructor(e,t=v.Number,n=b.Common,r,i=y.FromMetaData,a){this.id=e,this.type=t,this.category=n,this.name=r,this.format=i,this.shortName=a;let o=e.charAt(0)===`_`;r??(this.name=o?e:this.id.replace(/([A-Z])/g,` $1`).trim()),this.shortName=a??this.name}},Bd={},Vd=!1;function Hd(e){Id(e,z.FIELDS_SCHEMA).map(e=>{Bd[e.id]=new zd(e.id,v[e.type],b[e.category],e.name,y[e.format],e.shortName)})}function Ud(){return Vd||=(Hd(Rd),!0),Bd}var W=Ud(),G={CH_ALL:`ch`,CH_DIDBECOMEACTIVE:`ch.didbecomeactive`,CH_RECREATED:`ch.recreated`,CH_RESET:`ch.reset`,CH_ANNOTATIONCHANGED:`ch.annotationchanged`,CH_ANNNEEDSCONTEXTMENU:`ch.annneedscontextmenu`,CH_CHTNEEDSCONTEXTMENU:`ch.chtneedscontextmenu`,CH_ANNSELECTIONCHANGED:`ch.annselectionchanged`,CH_ANNPOINTPICKED:`ch.annpointpicked`,CH_ANNMODIFIEDBYTOOL:`ch.annmodifiedbytool`,CH_PANEHEIGHTSCHANGED:`ch.paneheightschanged`,CH_PANESREORDERED:`ch.panesreordered`,CH_AXISSCALECHANGED:`ch.axisscalechanged`,CH_CHTLAYOUTCHANGED:`ch.chtlayoutchanged`,CH_NODATAFORMAINSYMBOL:`ch.nodataformainsymbol`,CH_CARDPLOTCLICKED:`ch.cardplotclicked`,CH_CARDPLOTREMOVED:`ch.cardplotremoved`,CH_CARDPLOTVISIBILITYCHANGED:`ch.cardplotvisibilitychanged`,CH_TOOLTIPCHANGED:`ch.tooltipchanged`,CH_LOGOCLICKED:`ch.logoclicked`,CH_SHUTDOWN:`ch.shutdown`,CH_ZOOMCHANGED:`ch.zoomchanged`,CH_ALL_DATA_PROJECTED:`ch.all.data.projected`,CH_API_ACTIONS_RECEIVED:`ch.api.actions.received`,CH_HOST_PROPS_CHANGED:`ch.host.props.changed`,CH_DEFINITION_CHANGED:`ch.definition.changed`,CH_PLOTNEEDSCONTEXTMENU:`ch.plotneedscontextmenu`,DF_ALL:`df`,DF_STREAMRECONNECTED:`df.streamreconnected`,TS_ALL:`ts`,TS_LOADING:`ts.loading`,TS_MANYCHANGED:`ts.manychaged`,TS_DATAPOINTADDED:`ts.datapointadded`,TS_DATAPOINTCHANGED:`ts.datapointchanged`,TS_TIMELINECORRECTION:`ts.timelinecorrection`,TS_EVENTSCHANGED:`ts.eventschanged`,TS_QUOTEMARKER:`ts.quotemarker`,MD_ALL:`md`,MD_CHANGED:`md.changed`,RT_ALL:`rt`,RT_QUOTE:`rt.quote`,RT_QUOTEGROUP:`rt.quotegroup`,RT_TRADE:`rt.trade`,RT_VOLUME:`rt.volume`,TL_CHANGED:`tl.changed`,ME_ALL:`me`,ME_MOUSE_OUT_SERIES:`me.mouse.out.series`,ME_MOUSE_OVER_SERIES:`me.mouse.over.series`},Wd=[W.Open,W.High,W.Low,W.Close,W.Volume,W.Change,W.PercentChange,W.PreviousClose].reduce((e,t,n)=>(e.set(t.id,1<<n),e),new Map);function Gd(...e){return e.reduce((e,t)=>Wd.has(t.id)?e|Wd.get(t.id):e,0)}var Kd=class{storage;fields=[];_updated=0;isValid=!1;constructor(e=``){this.symbol=e,this.storage=new Map,this.isValid=!1,this.resetUpdated()}get updated(){return this._updated}resetUpdated(){this._updated=0}addFields(...e){this.fields=ye(this.fields,e),this.fields.forEach(e=>{this.storage.has(e.id)||this.storage.set(e.id,null)})}update(e,t){if(this.hasField(e)){let n=e.id,r=this.storage.get(n);this.storage.set(n,t);let i=r!==t;return i&&Wd.has(n)&&(this._updated|=Wd.get(n)),i}}computeWellKnown(){let e=this.getValue(W.Close),t=this.getValue(W.PreviousClose);P(e,t)&&(this.hasField(W.Change)&&this.update(W.Change,e-t),this.hasField(W.PercentChange)&&this.update(W.PercentChange,(e-t)/t))}hasField(e){return P(this.fields)&&this.fields.some(t=>t.id===e.id)}hasSymbol(e){return!1}getValue(e){return this.hasField(e)?this.storage.get(e.id):null}shutdown(){}async ready(){return!1}},qd=class extends Kd{translated;constructor(e){super(),this.symbol=e,this.translated=Ki(this.symbol)}hasSymbol(e){return this.symbol===e}},Jd=class extends Kd{actual;constructor(e){super(z.PLACEHOLDER_SYMBOL_NAME),this.actual=e}async ready(){return!1}},Yd=class extends Kd{constructor(e){super(),this.symbol=e}hasSymbol(e){return this.symbol===e}async ready(){return!0}hasField(e){return!1}getValue(e){return null}},Xd={previousOpen:W.PreviousOpen,previousClose:W.PreviousClose,previousHigh:W.PreviousHigh,previousLow:W.PreviousLow,weeklyPreviousClose:W.WeekPreviousClose,weeklyPreviousHigh:W.WeekPreviousHigh,weeklyPreviousLow:W.WeekPreviousLow,monthlyPreviousClose:W.MonthPreviousClose,monthlyPreviousHigh:W.MonthPreviousHigh,monthlyPreviousLow:W.MonthPreviousLow,fiftyTwoWkHigh:W.YearHigh,fiftyTwoWkLow:W.YearLow},Zd={open:W.Open,high:W.High,low:W.Low,close:W.Close,lastPrice:W.Last,volume:W.Volume,netChange:W.Change,percentChange:W.PercentChange},Qd=Object.values(Xd),$d=Object.keys(Xd),ef=Object.keys(Zd),tf=class extends qd{triedFetchingExtraValues=!1;includeBaseFields=!1;async ready(){return Ai.call(this,async()=>(this.isValid=await $().getMetaDataSource().getMetaData(this.symbol).ready(),this.isValid))}shutdown(){}getValue(e){return this.hasField(e)&&Qd.some(t=>t.id===e.id)&&super.getValue(e)===null&&!this.triedFetchingExtraValues&&this.supplementPreviousValues(),super.getValue(e)}supplementPreviousValues(){this.triedFetchingExtraValues=!0,VM(`ondemand`,`/getQuote.json?symbols=${this.translated}&fields=${$d.join(`,`)}`).then(e=>{try{let t=JSON.parse(e);if(t.status.code===200&&t.results.length===1){let e=t.results[0];$d.forEach(t=>this.update(Xd[t],e[t])),this.includeBaseFields&&ef.forEach(t=>this.update(Zd[t],e[t])),$().getRecordSource().subject.next({topic:G.RT_QUOTE,data:{symbol:this.symbol}})}}catch{I(`Failed to fetch extra values for ${this.translated}`,`error`)}})}},nf=class extends tf{constructor(e){super(e),this.includeBaseFields=!0,this.supplementPreviousValues()}async ready(){return Promise.resolve(!0)}},rf=class extends qd{isValid=!1;constructor(e){super(e)}addOptionalField(e,t){P(t)&&(this.addFields(e),this.update(e,t))}async ready(){return Ai.call(this,async()=>{let e=$().config.environment===l[l.NodeJs]?null:yi(`#${z.INLINE_DATA_ELEMENT_ID}`);if(!P(e))this.isValid=!1;else{let t=JSON.parse(e);if(!(this.translated in t))this.isValid=!1;else{let e=t[this.translated].quote;this.update(W.Open,e.open),this.update(W.High,e.high),this.update(W.Low,e.low),this.update(W.Close,e.close),this.update(W.PreviousClose,e.previousClose),this.update(W.Volume,e.volume),$d.filter(e=>e!==`previousClose`).forEach(t=>{this.addOptionalField(Xd[t],e[t])}),this.isValid=!0}}return this.isValid})}},af=[W.Open,W.High,W.Low,W.Close,W.PreviousClose],of=class extends Kd{mapping;resolved;model;constructor(e,t){super();let n=e=>$().getRecordSource().getRecord(e);this.resolved=e.map(([e,t])=>t),this.mapping=new Map(e.map(([e,t])=>[e,n(t)])),this.model=t;let r=af.concat(W.Change,W.PercentChange);this.addFields(...r.filter(e=>e!==W.Volume))}async ready(){return Ai.call(this,async()=>{let e=Array.from(this.mapping.values()).map(e=>e.ready());return this.isValid=(await Promise.all(e)).every(e=>e),this.isValid&&this.evaluate(),this.isValid})}hasSymbol(e){return this.resolved.includes(e)}getOneValue(e){return t=>this.mapping.get(t).getValue(e)}evaluate(){af.forEach(e=>{let t=Tu(this.model,this.getOneValue(e));this.update(e,Number.isFinite(t)?t:null)}),this.computeWellKnown()}};function sf(e,t){return n=>n.topic===e&&n.data.symbol===t}var cf=function(e,t){return cf=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},cf(e,t)};function lf(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);cf(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function uf(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function df(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function ff(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function pf(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function mf(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function hf(e){return this instanceof hf?(this.v=e,this):new hf(e)}function gf(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof hf?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function _f(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ff==`function`?ff(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function vf(e){return typeof e==`function`}function yf(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var bf=yf(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
17
17
  `+t.map(function(e,t){return t+1+`) `+e.toString()}).join(`
18
18
  `):``,this.name=`UnsubscriptionError`,this.errors=t}});function xf(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Sf=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=ff(a),s=o.next();!s.done;s=o.next())s.value.remove(this)}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var c=this.initialTeardown;if(vf(c))try{c()}catch(e){i=e instanceof bf?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=ff(l),d=u.next();!d.done;d=u.next()){var f=d.value;try{Tf(f)}catch(e){i??=[],e instanceof bf?i=mf(mf([],pf(i)),pf(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new bf(i)}},e.prototype.add=function(t){if(t&&t!==this)if(this.closed)Tf(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=this._finalizers??[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&xf(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&xf(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e}(),Cf=Sf.EMPTY;function wf(e){return e instanceof Sf||e&&`closed`in e&&vf(e.remove)&&vf(e.add)&&vf(e.unsubscribe)}function Tf(e){vf(e)?e():e.unsubscribe()}var Ef={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Df={setTimeout:function(e,t){var n=[...arguments].slice(2),r=Df.delegate;return r?.setTimeout?r.setTimeout.apply(r,mf([e,t],pf(n))):setTimeout.apply(void 0,mf([e,t],pf(n)))},clearTimeout:function(e){return(Df.delegate?.clearTimeout||clearTimeout)(e)},delegate:void 0};function Of(e){Df.setTimeout(function(){var t=Ef.onUnhandledError;if(t)t(e);else throw e})}function kf(){}var Af=(function(){return Nf(`C`,void 0,void 0)})();function jf(e){return Nf(`E`,void 0,e)}function Mf(e){return Nf(`N`,e,void 0)}function Nf(e,t,n){return{kind:e,value:t,error:n}}var Pf=null;function Ff(e){if(Ef.useDeprecatedSynchronousErrorHandling){var t=!Pf;if(t&&(Pf={errorThrown:!1,error:null}),e(),t){var n=Pf,r=n.errorThrown,i=n.error;if(Pf=null,r)throw i}}else e()}function If(e){Ef.useDeprecatedSynchronousErrorHandling&&Pf&&(Pf.errorThrown=!0,Pf.error=e)}var Lf=function(e){lf(t,e);function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,wf(t)&&t.add(n)):n.destination=Gf,n}return t.create=function(e,t,n){return new Vf(e,t,n)},t.prototype.next=function(e){this.isStopped?Wf(Mf(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?Wf(jf(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?Wf(Af,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Sf),Rf=Function.prototype.bind;function zf(e,t){return Rf.call(e,t)}var Bf=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Hf(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Hf(e)}else Hf(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Hf(e)}},e}(),Vf=function(e){lf(t,e);function t(t,n,r){var i=e.call(this)||this,a;if(vf(t)||!t)a={next:t??void 0,error:n??void 0,complete:r??void 0};else{var o;i&&Ef.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&zf(t.next,o),error:t.error&&zf(t.error,o),complete:t.complete&&zf(t.complete,o)}):a=t}return i.destination=new Bf(a),i}return t}(Lf);function Hf(e){Ef.useDeprecatedSynchronousErrorHandling?If(e):Of(e)}function Uf(e){throw e}function Wf(e,t){var n=Ef.onStoppedNotification;n&&Df.setTimeout(function(){return n(e,t)})}var Gf={closed:!0,next:kf,error:Uf,complete:kf},Kf=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})();function qf(e){return e}function Jf(e){return e.length===0?qf:e.length===1?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var Yf=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this,i=Qf(e)?e:new Vf(e,t,n);return Ff(function(){var e=r,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?r._subscribe(i):r._trySubscribe(i))}),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return t=Xf(t),new t(function(t,r){var i=new Vf({next:function(t){try{e(t)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t});n.subscribe(i)})},e.prototype._subscribe=function(e){return this.source?.subscribe(e)},e.prototype[Kf]=function(){return this},e.prototype.pipe=function(){return Jf([...arguments])(this)},e.prototype.toPromise=function(e){var t=this;return e=Xf(e),new e(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function Xf(e){return e??Ef.Promise??Promise}function Zf(e){return e&&vf(e.next)&&vf(e.error)&&vf(e.complete)}function Qf(e){return e&&e instanceof Lf||Zf(e)&&wf(e)}function $f(e){return vf(e?.lift)}function ep(e){return function(t){if($f(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw TypeError(`Unable to lift unknown Observable type`)}}function tp(e,t,n,r,i){return new np(e,t,n,r,i)}var np=function(e){lf(t,e);function t(t,n,r,i,a,o){var s=e.call(this,t)||this;return s.onFinalize=a,s.shouldUnsubscribe=o,s._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,s._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)==null||t.call(this))}},t}(Lf),rp=yf(function(e){return function(){e(this),this.name=`ObjectUnsubscribedError`,this.message=`object unsubscribed`}}),ip=function(e){lf(t,e);function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return t.prototype.lift=function(e){var t=new ap(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new rp},t.prototype.next=function(e){var t=this;Ff(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||=Array.from(t.observers);try{for(var i=ff(t.currentObservers),a=i.next();!a.done;a=i.next())a.value.next(e)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;Ff(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;Ff(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,`observed`,{get:function(){return this.observers?.length>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,a=n.observers;return r||i?Cf:(this.currentObservers=null,a.push(e),new Sf(function(){t.currentObservers=null,xf(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new Yf;return e.source=this,e},t.create=function(e,t){return new ap(e,t)},t}(Yf),ap=function(e){lf(t,e);function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return t.prototype.next=function(e){var t,n;(n=(t=this.destination)?.next)==null||n.call(t,e)},t.prototype.error=function(e){var t,n;(n=(t=this.destination)?.error)==null||n.call(t,e)},t.prototype.complete=function(){var e,t;(t=(e=this.destination)?.complete)==null||t.call(e)},t.prototype._subscribe=function(e){return this.source?.subscribe(e)??Cf},t}(ip),op={now:function(){return(op.delegate||Date).now()},delegate:void 0},sp=function(e){lf(t,e);function t(t,n){return e.call(this)||this}return t.prototype.schedule=function(e,t){return t===void 0&&(t=0),this},t}(Sf),cp={setInterval:function(e,t){var n=[...arguments].slice(2),r=cp.delegate;return r?.setInterval?r.setInterval.apply(r,mf([e,t],pf(n))):setInterval.apply(void 0,mf([e,t],pf(n)))},clearInterval:function(e){return(cp.delegate?.clearInterval||clearInterval)(e)},delegate:void 0},lp=function(e){lf(t,e);function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return t.prototype.schedule=function(e,t){if(t===void 0&&(t=0),this.closed)return this;this.state=e;var n=this.id,r=this.scheduler;return n!=null&&(this.id=this.recycleAsyncId(r,n,t)),this.pending=!0,this.delay=t,this.id=this.id??this.requestAsyncId(r,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return n===void 0&&(n=0),cp.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(n===void 0&&(n=0),n!=null&&this.delay===n&&this.pending===!1)return t;t!=null&&cp.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return Error(`executing a cancelled action`);this.pending=!1;var n=this._execute(e,t);if(n)return n;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n=!1,r;try{this.work(e)}catch(e){n=!0,r=e||Error(`Scheduled action threw falsy error`)}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,r=t.scheduler,i=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,xf(i,this),n!=null&&(this.id=this.recycleAsyncId(r,n,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(sp),up=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=op.now,e}(),dp=new(function(e){lf(t,e);function t(t,n){n===void 0&&(n=up.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return t.prototype.flush=function(e){var t=this.actions;if(this._active){t.push(e);return}var n;this._active=!0;do if(n=e.execute(e.state,e.delay))break;while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}},t}(up))(lp),fp=dp;function pp(e){return e&&vf(e.schedule)}function mp(e){return e[e.length-1]}function hp(e){return pp(mp(e))?e.pop():void 0}var gp=(function(e){return e&&typeof e.length==`number`&&typeof e!=`function`});function _p(e){return vf(e?.then)}function vp(e){return vf(e[Kf])}function yp(e){return Symbol.asyncIterator&&vf(e?.[Symbol.asyncIterator])}function bp(e){return TypeError(`You provided `+(typeof e==`object`&&e?`an invalid object`:`'`+e+`'`)+` where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}function xp(){return typeof Symbol!=`function`||!Symbol.iterator?`@@iterator`:Symbol.iterator}var Sp=xp();function Cp(e){return vf(e?.[Sp])}function wp(e){return gf(this,arguments,function(){var t,n,r,i;return df(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,hf(t.read())];case 3:return n=a.sent(),r=n.value,i=n.done,i?[4,hf(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,hf(r)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Tp(e){return vf(e?.getReader)}function Ep(e){if(e instanceof Yf)return e;if(e!=null){if(vp(e))return Dp(e);if(gp(e))return Op(e);if(_p(e))return kp(e);if(yp(e))return jp(e);if(Cp(e))return Ap(e);if(Tp(e))return Mp(e)}throw bp(e)}function Dp(e){return new Yf(function(t){var n=e[Kf]();if(vf(n.subscribe))return n.subscribe(t);throw TypeError(`Provided object does not correctly implement Symbol.observable`)})}function Op(e){return new Yf(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function kp(e){return new Yf(function(t){e.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Of)})}function Ap(e){return new Yf(function(t){var n,r;try{for(var i=ff(e),a=i.next();!a.done;a=i.next()){var o=a.value;if(t.next(o),t.closed)return}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function jp(e){return new Yf(function(t){Np(e,t).catch(function(e){return t.error(e)})})}function Mp(e){return jp(wp(e))}function Np(e,t){var n,r,i,a;return uf(this,void 0,void 0,function(){var o,s;return df(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=_f(e),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(a=n.return)?[4,a.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Pp(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var a=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(a),!i)return a}function Fp(e){return e instanceof Date&&!isNaN(e)}function Ip(e,t){return ep(function(n,r){var i=0;n.subscribe(tp(r,function(n){r.next(e.call(t,n,i++))}))})}function Lp(e,t,n){e===void 0&&(e=0),n===void 0&&(n=fp);var r=-1;return t!=null&&(pp(t)?n=t:r=t),new Yf(function(t){var i=Fp(e)?+e-n.now():e;i<0&&(i=0);var a=0;return n.schedule(function(){t.closed||(t.next(a++),0<=r?this.schedule(void 0,r):t.complete())},i)})}function Rp(e,t){return e===void 0&&(e=0),t===void 0&&(t=dp),e<0&&(e=0),Lp(e,e,t)}function zp(e,t){return ep(function(n,r){var i=0;n.subscribe(tp(r,function(n){return e.call(t,n,i++)&&r.next(n)}))})}function Bp(e){var t=[...arguments].slice(1),n=hp(t)??dp,r=t[0]??null,i=t[1]||1/0;return ep(function(t,a){var o=[],s=!1,c=function(e){var t=e.buffer;e.subs.unsubscribe(),xf(o,e),a.next(t),s&&l()},l=function(){if(o){var t=new Sf;a.add(t);var r={buffer:[],subs:t};o.push(r),Pp(t,n,function(){return c(r)},e)}};r!==null&&r>=0?Pp(a,n,l,r,!0):s=!0,l();var u=tp(a,function(e){var t,n,r=o.slice();try{for(var a=ff(r),s=a.next();!s.done;s=a.next()){var l=s.value,u=l.buffer;u.push(e),i<=u.length&&c(l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},function(){for(;o?.length;)a.next(o.shift().buffer);u?.unsubscribe(),a.complete(),a.unsubscribe()},void 0,function(){return o=null});t.subscribe(u)})}function Vp(e){return ep(function(t,n){var r=null,i=null,a=function(){i?.unsubscribe();var t=r;r=[],t&&n.next(t),Ep(e()).subscribe(i=tp(n,a,kf))};a(),t.subscribe(tp(n,function(e){return r?.push(e)},function(){r&&n.next(r),n.complete()},void 0,function(){return r=i=null}))})}var Hp=o(((e,t)=>{function n(e){return e&&e.__esModule?e:{default:e}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})),Up=o(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=n;function n(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}t.exports=e.default})),Wp=o(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=n;function n(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}t.exports=e.default}));function Gp(e,t){var n=Xp(t);return n.formatToParts?qp(n,e):Jp(n,e)}var Kp={year:0,month:1,day:2,hour:3,minute:4,second:5};function qp(e,t){try{for(var n=e.formatToParts(t),r=[],i=0;i<n.length;i++){var a=Kp[n[i].type];a>=0&&(r[a]=parseInt(n[i].value,10))}return r}catch(e){if(e instanceof RangeError)return[NaN];throw e}}function Jp(e,t){var n=e.format(t),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var Yp={};function Xp(e){if(!Yp[e]){var t=new Intl.DateTimeFormat(`en-US`,{hourCycle:`h23`,timeZone:`America/New_York`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(`2014-06-25T04:00:00.123Z`));Yp[e]=t===`06/25/2014, 00:00:00`||t===`‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00`?new Intl.DateTimeFormat(`en-US`,{hourCycle:`h23`,timeZone:e,year:`numeric`,month:`numeric`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):new Intl.DateTimeFormat(`en-US`,{hour12:!1,timeZone:e,year:`numeric`,month:`numeric`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}return Yp[e]}function Zp(e,t,n,r,i,a,o){var s=new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(r,i,a,o),s}var Qp=36e5,$p=6e4,em={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-])(\d{2}):?(\d{2})$/};function tm(e,t,n){var r,i;if(!e||(r=em.timezoneZ.exec(e),r))return 0;var a;if(r=em.timezoneHH.exec(e),r)return a=parseInt(r[1],10),am(a)?-(a*Qp):NaN;if(r=em.timezoneHHMM.exec(e),r){a=parseInt(r[2],10);var o=parseInt(r[3],10);return am(a,o)?(i=Math.abs(a)*Qp+o*$p,r[1]===`+`?-i:i):NaN}if(sm(e)){t=new Date(t||Date.now());var s=rm(n?t:nm(t),e);return-(n?s:im(t,s,e))}return NaN}function nm(e){return Zp(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function rm(e,t){var n=Gp(e,t),r=Zp(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),i=e.getTime(),a=i%1e3;return i-=a>=0?a:1e3+a,r-i}function im(e,t,n){var r=e.getTime()-t,i=rm(new Date(r),n);if(t===i)return t;r-=i-t;var a=rm(new Date(r),n);return i===a?i:Math.max(i,a)}function am(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}var om={};function sm(e){if(om[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),om[e]=!0,!0}catch{return!1}}var cm=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,lm=c(Up()),um=c(Wp()),dm=36e5,fm=6e4,pm=2,mm={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:cm};function hm(e,t){if(arguments.length<1)throw TypeError(`1 argument required, but only `+arguments.length+` present`);if(e===null)return new Date(NaN);var n=t||{},r=n.additionalDigits==null?pm:(0,lm.default)(n.additionalDigits);if(r!==2&&r!==1&&r!==0)throw RangeError(`additionalDigits must be 0, 1 or 2`);if(e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`)return new Date(e.getTime());if(typeof e==`number`||Object.prototype.toString.call(e)===`[object Number]`)return new Date(e);if(!(typeof e==`string`||Object.prototype.toString.call(e)===`[object String]`))return new Date(NaN);var i=gm(e),a=_m(i.date,r),o=a.year,s=a.restDateString,c=vm(s,o);if(isNaN(c))return new Date(NaN);if(c){var l=c.getTime(),u=0,d;if(i.time&&(u=ym(i.time),isNaN(u)))return new Date(NaN);if(i.timeZone||n.timeZone){if(d=tm(i.timeZone||n.timeZone,new Date(l+u)),isNaN(d))return new Date(NaN)}else d=(0,um.default)(new Date(l+u)),d=(0,um.default)(new Date(l+u+d));return new Date(l+u+d)}else return new Date(NaN)}function gm(e){var t={},n=mm.dateTimePattern.exec(e),r;if(n?(t.date=n[1],r=n[3]):(n=mm.datePattern.exec(e),n?(t.date=n[1],r=n[2]):(t.date=null,r=e)),r){var i=mm.timeZone.exec(r);i?(t.time=r.replace(i[1],``),t.timeZone=i[1].trim()):t.time=r}return t}function _m(e,t){var n=mm.YYY[t],r=mm.YYYYY[t],i=mm.YYYY.exec(e)||r.exec(e);if(i){var a=i[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(i=mm.YY.exec(e)||n.exec(e),i){var o=i[1];return{year:parseInt(o,10)*100,restDateString:e.slice(o.length)}}return{year:null}}function vm(e,t){if(t===null)return null;var n,r,i,a;if(e.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(n=mm.MM.exec(e),n)return r=new Date(0),i=parseInt(n[1],10)-1,wm(t,i)?(r.setUTCFullYear(t,i),r):new Date(NaN);if(n=mm.DDD.exec(e),n){r=new Date(0);var o=parseInt(n[1],10);return Tm(t,o)?(r.setUTCFullYear(t,0,o),r):new Date(NaN)}if(n=mm.MMDD.exec(e),n){r=new Date(0),i=parseInt(n[1],10)-1;var s=parseInt(n[2],10);return wm(t,i,s)?(r.setUTCFullYear(t,i,s),r):new Date(NaN)}if(n=mm.Www.exec(e),n)return a=parseInt(n[1],10)-1,Em(t,a)?bm(t,a):new Date(NaN);if(n=mm.WwwD.exec(e),n){a=parseInt(n[1],10)-1;var c=parseInt(n[2],10)-1;return Em(t,a,c)?bm(t,a,c):new Date(NaN)}return null}function ym(e){var t=mm.HH.exec(e),n,r;if(t)return n=parseFloat(t[1].replace(`,`,`.`)),Dm(n)?n%24*dm:NaN;if(t=mm.HHMM.exec(e),t)return n=parseInt(t[1],10),r=parseFloat(t[2].replace(`,`,`.`)),Dm(n,r)?n%24*dm+r*fm:NaN;if(t=mm.HHMMSS.exec(e),t){n=parseInt(t[1],10),r=parseInt(t[2],10);var i=parseFloat(t[3].replace(`,`,`.`));return Dm(n,r,i)?n%24*dm+r*fm+i*1e3:NaN}return null}function bm(e,t,n){t||=0,n||=0;var r=new Date(0);r.setUTCFullYear(e,0,4);var i=r.getUTCDay()||7,a=t*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var xm=[31,28,31,30,31,30,31,31,30,31,30,31],Sm=[31,29,31,30,31,30,31,31,30,31,30,31];function Cm(e){return e%400==0||e%4==0&&e%100!=0}function wm(e,t,n){if(t<0||t>11)return!1;if(n!=null){if(n<1)return!1;var r=Cm(e);if(r&&n>Sm[t]||!r&&n>xm[t])return!1}return!0}function Tm(e,t){if(t<1)return!1;var n=Cm(e);return!(n&&t>366||!n&&t>365)}function Em(e,t,n){return!(t<0||t>52||n!=null&&(n<0||n>6))}function Dm(e,t,n){return!(e!=null&&(e<0||e>=25)||t!=null&&(t<0||t>=60)||n!=null&&(n<0||n>=60))}var Om=o(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=n;function n(e,t){if(e==null)throw TypeError(`assign requires that input parameter not be null or undefined`);for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}t.exports=e.default})),km=o(((e,t)=>{var n=Hp().default;Object.defineProperty(e,`__esModule`,{value:!0}),e.default=i;var r=n(Om());function i(e){return(0,r.default)({},e)}t.exports=e.default}));function Am(e,t,n){var r=hm(e,n),i=tm(t,r,!0),a=new Date(r.getTime()-i),o=new Date(0);return o.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),o.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),o}var jm=c(km());function Mm(e,t,n){if(typeof e==`string`&&!e.match(cm)){var r=(0,jm.default)(n);return r.timeZone=t,hm(e,r)}var i=hm(e,n),a=Zp(i.getFullYear(),i.getMonth(),i.getDate(),i.getHours(),i.getMinutes(),i.getSeconds(),i.getMilliseconds()).getTime(),o=tm(t,new Date(a));return new Date(a+o)}var Nm=`__barchartChartDebug`,Pm=new WeakMap,Fm=1;function Im(){try{let e=globalThis.localStorage?.getItem(Nm);if(!e)return{};let t=JSON.parse(e);return typeof t==`object`&&t?t:{}}catch{return{}}}function Lm(){let e=globalThis,t=e.barchart_namespace?.chartDebug,n=e.__barchartChartDebug;return{...Im(),...t||{},...n||{}}}function Rm(e){return typeof e==`boolean`?e:null}function zm(){return Rm(Lm().traceLifecycle)===!0}function Bm(e){return e===`record:post-init:stale`?{kind:`warn`,labelStyle:`color: #fff; background: #7a271a; font-weight: 700; padding: 1px 4px; border-radius: 2px;`,eventStyle:`color: #7a271a; font-weight: 700;`}:e===`record:evict`||e===`openfeed:unsubscribe`?{kind:`warn`,labelStyle:`color: #fff; background: #b42318; font-weight: 700; padding: 1px 4px; border-radius: 2px;`,eventStyle:`color: #b42318; font-weight: 700;`}:e===`record:subscribe`||e===`openfeed:subscribe`?{kind:`info`,labelStyle:`color: #fff; background: #027a48; font-weight: 700; padding: 1px 4px; border-radius: 2px;`,eventStyle:`color: #027a48; font-weight: 700;`}:e.startsWith(`gc:`)?{kind:`info`,labelStyle:`color: #111827; background: #f59e0b; font-weight: 700; padding: 1px 4px; border-radius: 2px;`,eventStyle:`color: #b54708; font-weight: 700;`}:e.startsWith(`chart:`)||e.startsWith(`plot:`)?{kind:`info`,labelStyle:`color: #fff; background: #175cd3; font-weight: 700; padding: 1px 4px; border-radius: 2px;`,eventStyle:`color: #175cd3; font-weight: 700;`}:{kind:`info`,labelStyle:`color: #fff; background: #475467; font-weight: 700; padding: 1px 4px; border-radius: 2px;`,eventStyle:`color: #344054; font-weight: 700;`}}function Vm(e,t){if(!zm())return;let{kind:n,labelStyle:r,eventStyle:i}=Bm(e);t&&Object.keys(t).length>0?I(`%c[chart-debug]%c `+e,n,r,i,t):I(`%c[chart-debug]%c `+e,n,r,i)}function Hm(e){if(!e)return null;let t=Pm.get(e);return t||(t=Fm++,Pm.set(e,t)),t}var Um=[W.Open,W.High,W.Low,W.Last,W.Close,W.TradingDay,W.PreviousClose,W.PreviousHigh,W.PreviousLow,W.PreviousOpen,W.Volume,W.Change,W.PercentChange,W.YearHigh,W.YearLow,W.WeekPreviousClose,W.WeekPreviousHigh,W.WeekPreviousLow,W.MonthPreviousClose,W.MonthPreviousHigh,W.MonthPreviousLow],Wm=class{recordCache;translateSymbolBack;_subject;constructor(){this.recordCache=new Map,this.translateSymbolBack=new Map}traceRecord(e,t,n={}){let r=t;Vm(e,{symbol:r?.symbol??null,translated:r?.translated??r?.symbol??null,recordId:Hm(t),...n})}get subject(){if(!P(this._subject)){let e=Rp(Math.max(z.MINIMUM_THROTTLE,$().config.throttleMillis||0)),t=Rp(z.BACKGROUND_TAB_THROTTLE);this._subject=new ip().pipe(Vp(()=>globalThis.document?.hidden?t:e),zp(e=>e.length>0))}return this._subject}addRecordForSymbol(e,t){let n=Ki(e);n!==e&&this.translateSymbolBack.set(n,e),this.recordCache.set(e,t)}removeRecordForSymbol(e){this.recordCache.delete(e);let t=Ki(e);this.translateSymbolBack.has(t)&&this.translateSymbolBack.delete(t)}findRecordForSymbol(e){let t=this.translateSymbolBack.has(e)?this.translateSymbolBack.get(e):e;return this.recordCache.get(t)}getSupportedFields(){return Um}makeAndCacheRecord(e,t){if(e===z.PLACEHOLDER_SYMBOL_NAME)return new Jd(z.PLACEHOLDER_SYMBOL_NAME);if(this.recordCache.has(e))return this.recordCache.get(e);let n=t(e),r=this.getSupportedFields();return n.addFields(...r),this.traceRecord(`record:create`,n),this.addRecordForSymbol(e,n),this.initializeRecord(e,n),n}initializeRecord(e,t){t.ready().then(n=>{let r=this.recordCache.get(e)??null,i=r===t;this.traceRecord(i?`record:post-init`:`record:post-init:stale`,t,{isValid:n,isCurrent:i,currentRecordId:Hm(r)}),i&&this.postInit(n,t)})}refresh(e=new Set(this.recordCache.values())){for(let t of e)t.isValid||t.symbol===z.PLACEHOLDER_SYMBOL_NAME||(ji.call(t),this.initializeRecord(t.symbol,t))}evictUnused(e,t){for(let[n,r]of this.recordCache)e.has(r)||(t(r),this.removeRecordForSymbol(n))}postInit(e,t){}},Gm=class extends Wm{getRecord(e){return this.makeAndCacheRecord(e,()=>new rf(e))}evictUnused(e){super.evictUnused(e,e=>e.shutdown())}},Km=class extends Wm{getRecord(e){return this.makeAndCacheRecord(e,()=>new nf(e))}evictUnused(e){super.evictUnused(e,e=>e.shutdown())}},qm=class extends Wm{constructor(){super(),this.onMarketUpdate=this.onMarketUpdate.bind(this)}evictUnused(e){super.evictUnused(e,e=>{e.shutdown(),$().connection.off(`marketUpdate`,this.onMarketUpdate,e.translated)})}getRecord(e){return this.makeAndCacheRecord(e,()=>new tf(e))}postInit(e,t){e&&$().connection.on(`marketUpdate`,this.onMarketUpdate,t.translated)}onMarketUpdate(e){if(e.type===z.REALTIME_INITIAL_QUOTE){let t=this.updateFromQuote(e,!0);this.subject.next({topic:G.RT_QUOTE,data:e,updated:t})}else if(e.type===z.REALTIME_TRADE){let t=$().connection.getMarketState().getQuote(e.symbol),n=this.updateFromQuote(t);this.subject.next({topic:G.RT_TRADE,data:e,updated:n}),e.symbol===z.DEBUG_SYMBOL&&I(`Trade\nSymbol: ${e.symbol} \t%cPrice: ${e.tradePrice} \t%cSize: ${e.tradeSize} \t%cTime: ${_r(e.time,z.DEBUG_TIME_FORMAT)} \t%cSession: ${e.session}`,`log`,`color:#0f0`,`color:#a7a`,`color:#f96`,`color:#bee`)}else if(e.type===z.REALTIME_VOLUME){let t=this.updateFromVolume(e);t!==0&&(this.subject.next({topic:G.RT_VOLUME,data:e,updated:t}),e.symbol===z.DEBUG_SYMBOL&&I(`Volume\n Symbol: ${e.symbol} \t%cValue: ${e.value} \t%cSession: ${e.session}`,`log`,`color:#a7a`,`color:#bee`))}}updateFromQuote(e,t=!1){let n=this.findRecordForSymbol(e.symbol);n.resetUpdated(),n.update(W.Open,e.openPrice),n.update(W.High,e.highPrice),n.update(W.Low,e.lowPrice),n.update(W.Last,e.lastPrice),n.update(W.Close,e.lastPrice);let r=(e,t)=>{P(t)&&n.update(e,t)};return r(W.Volume,e.volume),n.update(W.PreviousClose,e.previousPrice),t&&(r(W.PreviousOpen,e.previousOpenPrice),r(W.PreviousHigh,e.previousHighPrice),r(W.PreviousLow,e.previousLowPrice)),n.computeWellKnown(),n.updated}updateFromVolume(e){let t=this.findRecordForSymbol(e.symbol);return t.resetUpdated(),t.update(W.Volume,e.value),t.updated}},Jm=class extends Wm{localTimeZone;constructor(){super(),this.localTimeZone=Intl.DateTimeFormat().resolvedOptions().timeZone}get feed(){return $()}evictUnused(e){super.evictUnused(e,e=>{this.traceRecord(`record:evict`,e,{symbol:e.translated}),e.shutdown(),this.feed.unsubscribe(e.translated)})}getRecord(e){return this.makeAndCacheRecord(e,()=>new tf(e))}postInit(e,t){e&&(this.traceRecord(`record:subscribe`,t,{symbol:t.translated}),this.feed.subscribe(t.translated))}onSnapshot(e,t){let n=this.findRecordForSymbol(t),r=$().metaDataSource.getMetaData(t);if(!r.isReady)return;let i=(e,t)=>{if(N(t)){let i=r.asPrice(t);return n.update(e,i),i}};n.resetUpdated();let a=i(W.Open,e.open?.price),o=i(W.High,e.high?.price),s=i(W.Low,e.low?.price),c=i(W.Last,e.last?.price);if(N(i(W.Close,e.close?.price))||N(i(W.Close,e.settlement?.price))||i(W.Close,e.last?.price),N(e.instrumentStatus?.tradeDate)){let t=e.instrumentStatus.tradeDate%100;n.update(W.TradingDay,t)}N(e.volume?.volume)&&n.update(W.Volume,r.asQuantity(e.volume.volume));let l=this.toExchangeTime(e.transactionTime,r.timeZone);N(i(W.PreviousClose,e.prevClose?.price))||i(W.PreviousClose,e.previousSession?.settlement?.price),i(W.PreviousOpen,e.previousSession?.open?.price),i(W.PreviousHigh,e.previousSession?.high?.price),i(W.PreviousLow,e.previousSession?.low?.price),i(W.YearHigh,e.yearHigh?.price),i(W.YearLow,e.yearLow?.price),n.computeWellKnown();let u={topic:`rt.quote`,data:{symbol:t,openPrice:a,highPrice:o,lowPrice:s,lastPrice:c,tradeTime:l},updated:n.updated};this.subject.next(u)}skip(e){return e===void 0||e.blockTrade||e.doesNotUpdateLast||e.doesNotUpdateVolume}asDate(e){return!N(e)||e.isZero()?null:new Date(e.div(1e6).toNumber())}toExchangeTime(e,t){let n=this.asDate(e);return n===null?null:Am(Mm(n,this.localTimeZone),t)}onUpdate(e,t){if(!this.recordCache.has(t)){I(`[OpenFeed] update for unsubscribed symbol: ${t}`,`warn`);return}let n=$().metaDataSource.getMetaData(t);if(!n.isReady)return;let r=this.toExchangeTime(e.transactionTime,n.timeZone);if(e.trades?.trades)for(let{trade:i}of e.trades.trades){if(this.skip(i))continue;let e=n.asPrice(i.price);if(e===null)continue;let a=n.asQuantity(i.quantity),o=this.toExchangeTime(i.transactionTime,n.timeZone),s=this.findRecordForSymbol(t),[c,l,u,d]=[`High`,`Low`,`Volume`,`TradingDay`].map(e=>W[e]).map(e=>s.getValue(e));(!N(l)||e<l)&&s.update(W.Low,e),(!N(c)||e>c)&&s.update(W.High,e),s.update(W.Last,e),s.update(W.Close,e),s.update(W.Volume,(N(u)?u:0)+a),s.computeWellKnown();let f={data:{symbol:t,tradePrice:e,tradeSize:a,session:i.session,time:o??r,tradingDay:d},topic:`rt.trade`,updated:s.updated};this.subject.next(f)}}};function Ym(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return n.length>=t?e.apply(null,n.slice(0,t).reverse()):function(){var r=[...arguments];return Ym(e,t,n.concat(r))}}var Xm=Ym(jt,2),Zm=Ym(Ut,2),Qm=Ym(Mt,2),$m=Ym(Wt,2),eh=Ym(Gt,2),th=Ym(Kt,2),nh=Ym(qt,2),rh=Ym(_r,2),ih=Ym(Ir,2);function ah(e,t){let{unit:n}=e;return n===g.Year?wn(t):n===g.Quarter?xn(t):n===g.Month?Sn(t):n===g.Week?Lt(t):n===g.Day?zt(t):t}function oh(e,t){switch(e){case g.Tick:return eh(t);case g.Intraday:return Zm(t);case g.Day:return Xm(t);case g.Week:return th(t);case g.Month:return Qm(t);case g.Quarter:return $m(t);case g.Year:return nh(t);default:throw Error(`Unexpected aggregation unit ${g[e]}`)}}function sh(e){switch(e.unit){case g.Tick:case g.Intraday:case g.Day:return oh(e.unit,e.size);case g.Week:case g.Month:case g.Quarter:case g.Year:return oh(e.unit,1);default:throw Error(`Unexpected aggregation unit ${g[e.unit]}`)}}function ch(e,t){return t.getFullYear()-1-(t.getFullYear()-1)%e}function lh(e){return ch(10,e)}function uh(e){return ch(100,e)}function dh(e,t){return lh(e)===lh(t)}function fh(e,t){return uh(e)===lh(t)}function ph(e){return new Date(e*z.OPTIONS_DATA_INCREMENT+z.OPTIONS_DATA_BASE)}function mh(e){return(e.valueOf()-z.OPTIONS_DATA_BASE)/z.OPTIONS_DATA_INCREMENT}function hh(e,t=z.ZERO_DATE){let n=new Date(`${e}T00:00:00`);return nn(n)?n:t}function gh(e,t=z.ZERO_DATE){let n=new Date(e.replace(` `,`T`));return nn(n)?n:t}function _h(e){return e.size-1}var vh=class{container;supportsChunks=!0;retryCountForChunk=1;constructor(){this.container=null}get base(){return this.container}ready(){return Promise.resolve()}processRetrieved(){}getFirstDate(e){return this.base.getTimeData()[0]}getLastDate(){return this.base.getLastDataPoint(W.DateTime)}prepend(e){this.base.prepend(e),this.processRetrieved()}append(e){this.base.append(e),this.processRetrieved()}},yh=class extends vh{constructor(e){super(),this.container=e,this.retryCountForChunk=z.FETCH_TICK_CHUNK_RETRY_COUNT}getFirstDate(e){let t=super.getFirstDate(0);return e>0&&e<this.retryCountForChunk?mn(Ir(t,e)):t}process(e){let t=this.container,n=t.size>0?t.getLastDataPoint(W.Last):null,r=t.getLastDataPoint(W.DateTime),i=e.time;return r!==void 0&&i<=r&&(i=Pt(r,1)),t.addDataPoint(W.DateTime,i),t.addDataPoint(W.Last,e.tradePrice),t.addDataPoint(W.TradeSize,e.tradeSize),t.addDataPoint(W.Change,P(n)?e.tradePrice-n:null),t.hasField(W.TradingDay)&&t.addDataPoint(W.TradingDay,e.tradingDay),{isUpdate:!1,time:i.getTime(),index:_h(t)}}},bh=class extends vh{agg;durationAdd;constructor(e,t){super(),this.agg=t,this.container=e,this.durationAdd=sh(t)}isSameBar(e,t){switch(this.agg.unit){case g.Tick:case g.Intraday:case g.Day:return Dr(t,this.durationAdd(e));case g.Week:return jr(e,t);case g.Month:return Nr(e,t);case g.Quarter:return Pr(e,t);case g.Year:return Fr(e,t);default:throw Error(`Unexpected aggregation unit ${g[this.agg.unit]}`)}}fixupTimeBasedAggregationTimestamp(e){return e}isCorrection(e,t){let n=Dr(t,e);return n&&I(`Currently not handling data corrections (updates of the past historical data)`,`error`),n}computeNextStamp(e,t){if(this.isCorrection(e,t))return null;let n=e;for(;!this.isSameBar(n,t);)n=this.durationAdd(n);return n}isUpdate(e,t,n,r){return Or(n,e)}getPosition(e){if(this.container.size===0){let t=this.fixupTimeBasedAggregationTimestamp(e.time);return{lastTimestamp:null,newTimestamp:t,nextTimestamp:t,isUpdate:!1}}let t=this.container.getLastDataPoint(W.DateTime),n=e.time,r=this.computeNextStamp(t,n);if(r===null)return null;let i=this.isUpdate(t,n,r,e);return i===null?null:{lastTimestamp:t,newTimestamp:n,nextTimestamp:r,isUpdate:i}}createBar(e,t,n,r,i,a,o){let s=this.container,c=s.size>0?s.getLastDataPoint(W.Close):null;s.addDataPoint(W.DateTime,a),s.addDataPoint(W.Open,e),s.addDataPoint(W.High,t),s.addDataPoint(W.Low,n),s.addDataPoint(W.Close,r),s.addDataPoint(W.Change,P(c)?r-c:null),s.addDataPoint(W.Volume,i),s.hasField(W.OpenInterest)&&s.addDataPoint(W.OpenInterest,null),s.hasField(W.TradingDay)&&s.addDataPoint(W.TradingDay,o??null)}addBar(e,t){let{nextTimestamp:n}=t,{tradePrice:r,tradingDay:i}=e;return this.createBar(r,r,r,r,e.tradeSize,n,i),{isUpdate:!1,time:n.getTime(),index:_h(this.container)}}updateLastBar(e,t,n,r){let i=this.container,a=e=>i.getLastDataPoint(e);if(P(e)&&e>a(W.High)&&i.setLastDataPoint(W.High,e),P(t)&&t<a(W.Low)&&i.setLastDataPoint(W.Low,t),P(n)){i.setLastDataPoint(W.Close,n);let e=i.getData(W.Close)[i.size-2];i.setLastDataPoint(W.Change,n-e)}if(P(r)){let e=i.getLastDataPoint(W.Volume)+r;i.setLastDataPoint(W.Volume,e)}}changeLastBar(e,t){let{lastTimestamp:n}=t;if(n==null)return null;let r=e.tradePrice;return this.updateLastBar(r,r,r,e.tradeSize),{isUpdate:!0,time:n.getTime(),index:_h(this.container)}}process(e){let t=this.getPosition(e);if(t===null)return null;let n=rh(z.DEBUG_TIME_FORMAT);return t.isUpdate?(e.symbol===z.DEBUG_SYMBOL&&I(`Adding ${this.agg.describe()} Bar\nBars %cnot same %c${n(t.lastTimestamp)} < ${n(t.newTimestamp)} %cnext is %c${n(t.nextTimestamp)}`,`log`,`color:#f00`,`color:#f96`,``,`color:#fff`),this.changeLastBar(e,t)):P(e.tradePrice)?(e.symbol===z.DEBUG_SYMBOL&&I(`Updating ${this.agg.describe()} Bar\nBars %csame %c${n(t.lastTimestamp)} == ${n(t.newTimestamp)}`,`log`,`color:#0f0`,`color:#f96`),this.addBar(e,t)):null}alignToQuote(e){if(P(e.lastPrice,e.time))return this.updateLastBar(e.highPrice,e.lowPrice,e.lastPrice,void 0),{isUpdate:!0,time:e.time.getTime(),index:_h(this.container)}}},xh=class extends bh{innerBuilder;constructor(e,t,n){super(t,n),this.innerBuilder=e,this.processRetrieved()}get base(){return this.innerBuilder.container}fixupTimeBasedAggregationTimestamp(e){return Ir(e,sn(e,z.START_OF_LAST_CENTURY)%this.agg.size)}processRetrieved(){this.container.clear();for(let e=0;e<this.base.size;e++){let t={isTrade:!0,time:this.base.getData(W.DateTime)[e],tradeSize:0,tradePrice:0,tradingDay:0};[W.Open,W.High,W.Low].forEach(n=>{t.tradePrice=this.base.getData(n)[e],super.process(t)}),t.tradePrice=this.base.getData(W.Close)[e],t.tradeSize=this.base.getData(W.Volume)[e],super.process(t)}}process(e){return this.innerBuilder.process(e),super.process(e)}},Sh=class{fields;storage={};constructor(e){this.fields=e,this.clear()}clear(){this.storage={},this.fields.forEach(e=>{this.storage[e.id]=[]})}fixupTransition(e,t){if(e!==W.Change||!this.hasField(W.Close)||t<1)return;let n=this.storage[e.id],r=this.storage[W.Close.id];n[t]=r[t]-r[t-1]}concat(e,t,n){this.storage[e.id]=t.concat(n),this.fixupTransition(e,t.length)}prependData(e,t){this.checkField(e),this.concat(e,t,this.getData(e))}prepend(e){let t=e.getLastDataPoint(W.DateTime),n=this.getTimeData()[0],r=P(t)&&P(n)&&t.getTime()===n.getTime(),i=e.size;e.fields.forEach(t=>{r&&e.getData(t).splice(i-1,1),this.prependData(t,e.getData(t))})}appendData(e,t){this.checkField(e),this.concat(e,this.getData(e),t)}append(e){let t=e.getTimeData()[0],n=this.getLastDataPoint(W.DateTime),r=P(t)&&P(n)&&t.getTime()===n.getTime(),i=this.size;return e.fields.forEach(t=>{r&&this.getData(t).splice(i-1,1),this.appendData(t,e.getData(t))}),e.size-+!!r}getTimeData(){return this.getData(W.DateTime)}getData(e){return this.storage[e.id]}setData(e,t){this.checkField(e),this.storage[e.id]=t}hasField(e){return this.fields.findIndex(t=>t.id===e.id)!==-1}get size(){return this.fields.length===0?0:this.getData(this.fields[0]).length}get isEmpty(){return this.size===0}checkField(e){if(!this.hasField(e))throw Error(`This container does not store values for field ${e.id}`)}addDataPoint(e,t){this.checkField(e),this.getData(e).push(t)}getLastDataPoint(e){return this.checkField(e),xe(this.getData(e))}setLastDataPoint(e,t){this.checkField(e);let n=this.getData(e);n[n.length-1]=t}keepOnlyLast(e){if(this.size<=e)return;let t=this.size-e;this.fields.forEach(e=>this.getData(e).splice(0,t))}},Ch=class extends Sh{constructor(){super([])}get size(){return 0}},wh=class extends Sh{wrapper;constructor(e,t){super(e),this.wrapper=t}isWrapped(e){return nt(this.wrapper,e.id)}hasField(e){return this.isWrapped(e)||super.hasField(e)}getData(e){return this.isWrapped(e)?this.wrapper[e.id]():super.getData(e)}},Th=z.RENKO_KAGI_NAMES;function Eh(e){let{Method:t,Period:n,Source:r,BrickSize:i}=dt(e);return{method:et(t,[Th.ATR,Th.TRD,Th.PCT],Th.ATR),period:Number.isFinite(n)?n:14,source:et(r,[Th.CLS,Th.HL],Th.CLS),brickSize:Number.isFinite(i)?i:10}}function Dh(e,t,n){return e.getData(t)[n]}function Oh(e,t){let[n,r]=[W.High,W.Low].map(n=>Dh(e,n,t)),i=Dh(e,W.Close,t-1);return Math.max(n-r,Math.abs(n-i),Math.abs(r-i))}function kh(e,t){if(e.size<t)return null;let n=t-1,r=[];r.push(Dh(e,W.High,0)-Dh(e,W.Low,0));for(let n=1;n<t;++n)r.push(Oh(e,n));let i=me(r);for(let r=t;r<e.size;++r){let a=Oh(e,r);i=(i*n+a)/t}return i}var Ah=e=>W[e],jh=[`DateTime`,`Open`,`High`,`Low`,`Close`,`Volume`].map(Ah),Mh=jh.concat([`Change`,`Projection`,`BarIndex`].map(Ah)),Nh=class extends vh{innerBuilder;inputs;brickSize;lastFinalBrick;projectionCount;refPrices;constructor(e,t){super(),this.supportsChunks=!1,this.innerBuilder=e,this.inputs=F(t.inputs),this.brickSize=null,this.container=new Sh(Mh),this.processRetrieved()}get base(){return this.innerBuilder.container}baseVal(e,t){return this.base.getData(e)[t]}isLastBase(e){return e===this.base.size-1}getValuesAt(e,t){let[n,r,i,a,o,s]=jh.map(n=>t.getData(n)[e]);return{date:n,open:r,high:i,low:a,close:o,volume:s}}getBrickAt(e){return this.getValuesAt(e,this.container)}getBarAt(e){return this.getValuesAt(e,this.base)}getBricksCount(e){return Math.floor(e/this.brickSize)}getMove(e,t,n){let[r,i]=this.refPrices(t.close,t.high,t.low),a=r-e.high,o=e.low-i;return{climbing:(n&&a>0||a>=this.brickSize)&&a>=o,falling:(n&&o>0||o>=this.brickSize)&&o>a,moveUp:a,moveDown:o}}initFirstBrick(e,t){e.open=e.high=e.low=e.close=Math.max(this.brickSize,Xe(t.close-t.close%this.brickSize,4)),e.date=t.date,e.volume=e.change=0}findSafeStartIndex(){let e=0,t=this.base.size-1,n=2*z.RENKO_MAX_BARS;for(;t>0&&e<n;){let n=Oh(this.base,t);e+=Math.floor(n/this.brickSize),t--}return t}processRetrieved(){let e=Eh(this.inputs),{method:t,period:n,source:r}=e;if(this.brickSize=e.brickSize,t===Th.ATR?this.brickSize=kh(this.base,n):t===Th.PCT&&((this.base?.size??0)>0?this.brickSize=this.base.getLastDataPoint(W.Close)*this.brickSize/100:this.brickSize=null),!P(this.brickSize))return;this.refPrices=r===Th.HL?(e,t,n)=>[t,n]:(e,t,n)=>[e,e];let i={},a=this.findSafeStartIndex();for(let e=a;e<this.base.size;e++){let t=this.getBarAt(e);if(e===a){this.initFirstBrick(i,t);continue}let n=this.isLastBase(e),{climbing:r,falling:o,moveUp:s,moveDown:c}=this.getMove(i,t,n);if(!r&&!o){i.volume+=t.volume;continue}i.proj=Number(n),i.barIndex=e;let l=t.date.getTime();if(r){let e=this.getBricksCount(s);for(let t=0;t<e;++t)this.constructClimbing(i,l,t,this.brickSize);n&&(this.constructClimbing(i,l,e,s%this.brickSize),this.projectionCount=e+1)}else if(o){let e=this.getBricksCount(c);for(let t=0;t<e;++t)this.constructFalling(i,l,t,this.brickSize);n&&(this.constructFalling(i,l,e,c%this.brickSize),this.projectionCount=e+1)}n||(this.lastFinalBrick=this.container.size-1,i.volume=0)}this.container.keepOnlyLast(z.RENKO_MAX_BARS)}constructClimbing(e,t,n,r,i=!0){let a=e.high,o=e.close;e.open=e.low=a,e.high=e.close=a+r,e.date=new Date(t+n),e.change=e.close-o,i?this.addToContainer(e):this.updateLastDataPoint(e)}constructFalling(e,t,n,r,i=!0){let a=e.low,o=e.close;e.open=e.high=a,e.low=e.close=a-r,e.date=new Date(t+n),e.change=e.close-o,i?this.addToContainer(e):this.updateLastDataPoint(e)}process(e){let t=this.innerBuilder.process(e);return this.processUpdate(t)}alignToQuote(e){let t=this.innerBuilder.alignToQuote(e);return this.processUpdate(t)}rebuild(){return this.container.clear(),this.processRetrieved(),{isUpdate:!1,time:0,index:-1}}processUpdate(e){if(!Number.isFinite(this.lastFinalBrick))return null;let t=this.base.size-1,n=this.getBarAt(t),r=this.getBrickAt(this.lastFinalBrick),{climbing:i,falling:a,moveUp:o,moveDown:s}=this.getMove(r,n,!0),c=this.container.getLastDataPoint(W.Projection)===1;if(!i&&!a)return c?this.rebuild():null;let l=i?o:s,u=this.getBricksCount(l)+1;if(c&&this.projectionCount===u){let e=this.getBrickAt(this.container.size-1),r=this.getBrickAt(Math.min(this.container.size-2,0));return e.proj=1,e.barIndex=t,e.open===e.high?e.low=e.close=n.close:e.open===e.low&&(e.high=e.close=n.close),e.change=e.close-r.close,this.updateLastDataPoint(e),{isUpdate:!0,time:e.date.getTime(),index:this.container.size-1}}else return this.rebuild()}addToContainer(e){let t=this.container;t.addDataPoint(W.DateTime,e.date),t.addDataPoint(W.Open,e.open),t.addDataPoint(W.Close,e.close),t.addDataPoint(W.High,e.high),t.addDataPoint(W.Low,e.low),t.addDataPoint(W.Change,e.change),t.addDataPoint(W.Volume,e.volume),t.addDataPoint(W.Projection,e.proj),t.addDataPoint(W.BarIndex,e.barIndex)}updateLastDataPoint(e){let t=this.container;t.setLastDataPoint(W.DateTime,e.date),t.setLastDataPoint(W.Open,e.open),t.setLastDataPoint(W.Close,e.close),t.setLastDataPoint(W.High,e.high),t.setLastDataPoint(W.Low,e.low),t.setLastDataPoint(W.Change,e.change),t.setLastDataPoint(W.Volume,e.volume),t.setLastDataPoint(W.Projection,e.proj),t.setLastDataPoint(W.BarIndex,e.barIndex)}},Ph=[W.DateTime,W.TradingDay,W.Last,W.TradeSize,W.Change],Fh=[W.DateTime,W.Open,W.High,W.Low,W.Close,W.Volume,W.Change],Ih=[...Fh,W.OpenInterest],Lh=[...Ih,W.Symbol],Rh=[W.Open,W.High,W.Low,W.Close,W.Change];function zh(e,t){let n=si(e);if(t.isTick)return Ph;{let e=Fh;return t.isMultiContract?e=Lh:(n||t.isEndOfDay)&&(e=Ih),t.isIntraday?[...e,W.TradingDay]:e}}var Bh=class{symbol;aggregation;offset;container;previousTime;timeZone;isFuture;needsResolution;hasOpenInterest;padded;constructor(e,t,n=0,r=!1){this.symbol=e,this.aggregation=t,this.offset=n||0,this.previousTime=new Date(0),this.timeZone=this.getTimeZone(),this.isFuture=Yr(e),this.padded=r,this.needsResolution=oi(e),this.hasOpenInterest=si(e)}makeContainer(){return new Sh(zh(this.symbol,this.aggregation))}parse(e){this.container=this.makeContainer();let t=e.split(`
19
19
  `),n=this.getParseFunc();if(n!==null){let e=n.bind(this);t.forEach(t=>{let n=t.trim();n&&e(n.split(`,`))})}return this.container}getParseFunc(){return this.aggregation.isTick?this.parseTick:this.aggregation.isIntraday?this.parseMinutes:this.parseEod}parseTick(e){let t=e.length-5;(t===0||t===1)&&(this.container.addDataPoint(W.DateTime,this.parseDate(e[0+t])),this.container.addDataPoint(W.TradingDay,parseInt(e[1+t])),this.container.addDataPoint(W.Last,parseFloat(e[3+t])),this.container.addDataPoint(W.TradeSize,parseInt(e[4+t])),this.container.addDataPoint(W.Change,this.calculateChange(W.Last)))}nullify(e){return e==null||e===0?null:e}parseMinutes(e){let t=this.aggregation.isMultiContract&&this.isFuture||this.needsResolution,n=+!!t;e.length===7+n&&(this.container.hasField(W.Symbol)&&this.container.addDataPoint(W.Symbol,t?e[0]:this.symbol),this.container.addDataPoint(W.DateTime,this.parseDate(e[0+n])),this.container.addDataPoint(W.TradingDay,parseInt(e[1+n])),this.container.addDataPoint(W.Open,parseFloat(e[2+n])),this.container.addDataPoint(W.High,parseFloat(e[3+n])),this.container.addDataPoint(W.Low,parseFloat(e[4+n])),this.container.addDataPoint(W.Close,parseFloat(e[5+n])),this.container.addDataPoint(W.Volume,this.nullify(parseInt(e[6+n]))),this.container.addDataPoint(W.Change,this.calculateChange()))}parseFloatOrNull(e){let t=parseFloat(e);return isNaN(t)&&this.padded?null:t}parseIntOrNull(e){let t=parseInt(e);return isNaN(t)&&this.padded?null:t}parseEod(e){let t=this.aggregation.isMultiContract,n=7+ +!!this.hasOpenInterest;e.length===n&&(t&&this.container.addDataPoint(W.Symbol,e[0]),this.container.addDataPoint(W.DateTime,this.parseDate(e[1])),this.container.addDataPoint(W.Open,this.parseFloatOrNull(e[2])),this.container.addDataPoint(W.High,parseFloat(e[3])),this.container.addDataPoint(W.Low,parseFloat(e[4])),this.container.addDataPoint(W.Close,parseFloat(e[5])),this.container.addDataPoint(W.Volume,this.nullify(this.parseIntOrNull(e[6]))),this.hasOpenInterest&&this.container.addDataPoint(W.OpenInterest,this.nullify(this.parseIntOrNull(e[7]))),this.container.addDataPoint(W.Change,this.calculateChange()))}calculateChange(e=W.Close){let t=this.container.size;if(t>1){let n=this.container.getData(e);return n[t-1]-n[t-2]}else return 0}parseTimestamp(e){switch(this.aggregation.unit){case g.Tick:case g.Intraday:return gh(e);default:return hh(e)}}parseDate(e){let t=this.parseTimestamp(e);return this.aggregation.isEndOfDay?qt(t,this.offset):(Er(t,this.previousTime)?this.previousTime=t:this.previousTime=Pt(this.previousTime,1),this.previousTime)}getTimeZone(){return ci(this.symbol)}},Vh=class extends Bh{makeContainer(){return new Sh([W.DateTime,W.TradingDay,W.Symbol,W.Bid,W.BidSize,W.Ask,W.AskSize])}getParseFunc(){return this.parseTopOfBook}getTopOfBookPayload(e){if(e.length<7)return null;let t=e[0],n=t===`Q`||t===`T`;if(n&&t!==`Q`)return null;let r=+!!n,i=7+r;if(e.length!==i&&e.length!==i+1)return null;let a=e.length===i+1,o=r+ +!!a,s=o+1,c=o+3,l=o+4,u=o+5,d=o+6;return{symbol:a?e[o-1]:this.symbol,timestamp:e[o],tradingDay:parseInt(e[s]),bid:parseFloat(e[c]),bidSize:parseInt(e[l]),ask:parseFloat(e[u]),askSize:parseInt(e[d])}}parseTopOfBook(e){let t=this.getTopOfBookPayload(e);t!==null&&(this.container.addDataPoint(W.DateTime,this.parseDate(t.timestamp)),this.container.addDataPoint(W.TradingDay,t.tradingDay),this.container.addDataPoint(W.Symbol,t.symbol),this.container.addDataPoint(W.Bid,t.bid),this.container.addDataPoint(W.BidSize,t.bidSize),this.container.addDataPoint(W.Ask,t.ask),this.container.addDataPoint(W.AskSize,t.askSize))}},{BARCHART_HIST_SRV_NEAREST_INTRADAY_PAGE_NAME:Hh,BARCHART_HIST_SRV_INTRADAY_PAGE_NAME:Uh}=z,Wh=[_.PerCount,_.PerVolume,_.PerSeconds],Gh=class{supportsChunks;constructor(){this.supportsChunks=!0}getPageNameFor(e,t){switch(e.unit){case g.Tick:return z.BARCHART_HIST_SRV_TICKS_PAGE_NAME;case g.Intraday:return t&&e.spec===_.Nearest?Hh:Uh;case g.Day:case g.Week:case g.Month:case g.Quarter:case g.Year:return z.BARCHART_HIST_SRV_EOD_PAGE_NAME;default:return``}}addExtraParams(e){}makeUrl(e){let t={},n=Ki(e.symbol);t.symbol=n;let r=e.aggregation,i=this.getDataParam(r);i.length>0&&(t.data=i),r.size>1&&r.unit===g.Intraday&&(t.interval=(r.spec===_.PerRange?1:r.size).toString());let[a,o]=e.range,s=a!==null,c=o!==null;if(s&&(t.start=this.toHistoricalFeedDate(a,r)),!s||e.alwaysUseBarsToFetch){let n=e.barsToFetch||z.DEFAULT_MAX_RECORDS;r.unit===g.Tick&&Wh.includes(r.spec)&&(n*=z.TICK_CUSTOM_AGG_MULTIPLIER),t.maxrecords=n.toString()}c&&(t.end=this.toHistoricalFeedDate(o,r)),t.volume=r.isContractVolume?`contract`:`total`,t.order=`asc`,t.dividends=r.dividendsAdjust.toString(),t.backadjust=r.backAdjust.toString(),t.daystoexpiration=r.daysToExpiration.toString(),t.contractroll=r.contractRoll,r.isTick&&(t.type=`T`,t.skipOldEmulation=`true`),e.extendedHours===!0&&(t.formt=`true`),t.splits=(e?.splits??!0).toString(),t.padded=(e.padded??!1).toString(),this.addExtraParams(t);let l=mt(t),u=Yr(n);return`/${this.getPageNameFor(r,u)}?${l}`}toHistoricalFeedDate(e,t){return _r(e,t.isTick||t.isIntraday?z.FMT_HIST_FEED_PARAM_DATE_TIME:z.FMT_HIST_FEED_PARAM_DATE_ONLY)}getDataParam(e){let t=``,n=this.getSpecPart(e);switch(e.unit){case g.Tick:case g.Intraday:break;case g.Day:t=`daily${n}`;break;case g.Week:t=`weekly${n}`;break;case g.Month:t=`monthly${n}`;break;case g.Quarter:t=`quarterly${n}`;break;case g.Year:t=`yearly${n}`;break}return t}getSpecPart(e){return e.isMultiContract?e.spec===_.Continue?`continue`:`nearest`:``}getParser(e){return new Bh(Ki(e.symbol),e.aggregation,e.offset,e.padded)}async retrieve(e){let t=this.makeUrl(e),n=await VM(e.aggregation.unit===g.Tick?`timeseriesNew`:`timeseries`,t);return this.getParser(e).parse(n)}},Kh=class extends Gh{addExtraParams(e){e.type=`B`}getParser(e){return new Vh(Ki(e.symbol),e.aggregation,e.offset)}async retrieve(e){let t=await VM(`timeseriesNew`,this.makeUrl(e));return this.getParser(e).parse(t)}},qh=class{supportsChunks;constructor(){this.supportsChunks=!1}addExtraParams(e){}async retrieve(e){let t=Ki(e.symbol),n=this.emptyContainer(t,e.aggregation);if(e.aggregation.unit!==g.Day)return n;let r={symbol:t};this.addExtraParams(r);let i=await VM(`ondemand`,`/${this.getPageName()}.json?${mt(r)}`);try{let e=JSON.parse(i);if(e.status.code===200){let t=e.results;if(this.iterateForward)for(let e=0;e<t.length;e++)this.processRow(t[e],e,n);else for(let e=t.length-1;e>=0;e--)this.processRow(t[e],e,n);return n}}catch(e){I(`Failed parsing the JSON result from OnDemand, error is ${e.message}`)}return n}},Jh=class extends qh{emptyContainer(e,t){return new Sh(zh(e,t))}get iterateForward(){return!0}getPageName(){return`getEquityOptionsHistory`}processRow(e,t,n){let r=n.hasField(W.Symbol),i=t>0?n.getLastDataPoint(W.Close):null;n.addDataPoint(W.DateTime,hh(e.date)),r&&n.addDataPoint(W.Symbol,e.symbol),n.addDataPoint(W.Open,e.open),n.addDataPoint(W.High,e.high),n.addDataPoint(W.Low,e.low),n.addDataPoint(W.Close,e.close),n.addDataPoint(W.Volume,e.volume),n.addDataPoint(W.OpenInterest,e.openInterest);let a=i===null?null:Xe(e.close-i,2);n.addDataPoint(W.Change,a)}},Yh={WeighImplVolHigh:`weightedImpliedVolatility`,WeighImplVolLow:`weightedImpliedVolatility`,WeighImplVol:`weightedImpliedVolatility`,WeighImplVolHigh5D:`weightedImpliedVolatilityHigh5d`,WeighImplVolLow5D:`weightedImpliedVolatilityLow5d`,WeighImplVol5D:`weightedImpliedVolatility5d`,WeighImplVolHigh1M:`weightedImpliedVolatilityHigh1m`,WeighImplVolLow1M:`weightedImpliedVolatilityLow1m`,WeighImplVol1M:`weightedImpliedVolatility1m`,WeighImplVolHigh3M:`weightedImpliedVolatilityHigh3m`,WeighImplVolLow3M:`weightedImpliedVolatilityLow3m`,WeighImplVol3M:`weightedImpliedVolatility3m`,WeighImplVolHigh6M:`weightedImpliedVolatilityHigh6m`,WeighImplVolLow6M:`weightedImpliedVolatilityLow6m`,WeighImplVol6M:`weightedImpliedVolatility6m`,WeighImplVolHigh1Y:`weightedImpliedVolatilityHigh1y`,WeighImplVolLow1Y:`weightedImpliedVolatilityLow1y`,WeighImplVol1Y:`weightedImpliedVolatility1y`,WeighImplVolHighYTD:`weightedImpliedVolatilityHighYtd`,WeighImplVolLowYTD:`weightedImpliedVolatilityLowYtd`,WeighImplVolYTD:`weightedImpliedVolatilityYtd`,WeighImplVolChg:`weightedImpliedVolatilityChange`,ImplVolRank5D:`impliedVolatilityRank5d`,ImplVolRank1M:`impliedVolatilityRank1m`,ImplVolRank3M:`impliedVolatilityRank3m`,ImplVolRank6M:`impliedVolatilityRank6m`,ImplVolRank1Y:`impliedVolatilityRank1y`,ImplVolRankYTD:`impliedVolatilityRankYtd`,ImplVolPerc5D:`impliedVolatilityPercentile5d`,ImplVolPerc1M:`impliedVolatilityPercentile1m`,ImplVolPerc3M:`impliedVolatilityPercentile3m`,ImplVolPerc6M:`impliedVolatilityPercentile6m`,ImplVolPerc1Y:`impliedVolatilityPercentile1y`,ImplVolPercYTD:`impliedVolatilityPercentileYtd`,OptTotVol:`totalVolume`,OptCallVol:`callVolume`,OptPutVol:`putVolume`,PutCallVolRatio:`putCallVolumeRatio`,TotalOpenInt:`totalOpenInterest`,CallOpenInt:`callOpenInterest`,PutOpenInt:`putOpenInterest`,PutCallOIRatio:`putCallOpenInterestRatio`,DateTime:`date`},Xh=class{supportsChunks;constructor(){this.supportsChunks=!1}async retrieve(e){let t=Ki(e.symbol).replace(/\.bz$/i,``),n=e.fields.concat(W.DateTime),r=()=>new Sh(n);if(e.aggregation.unit!==g.Day)return r();let i=await VM(`options`,`/get?${mt({symbol:t,apiKey:`default`,fields:n.map(e=>Yh[e.id]).join(`,`)})}`);try{let e=JSON.parse(i).data,t=r(),a=e=>Number.parseFloat(e.replace(/,/g,``));return e.forEach(e=>{n.forEach(n=>{n===W.DateTime?t.addDataPoint(W.DateTime,hh(e.date)):t.addDataPoint(n,a(e[Yh[n.id]]))})}),t}catch(e){I(`Failed parsing options JSON historical data result, error is ${e.message}`)}return r()}},Zh=class extends bh{innerBuilder;isBuildingBars;constructor(e,t,n){super(t,n),this.innerBuilder=e,this.isBuildingBars=!1,this.retryCountForChunk=z.FETCH_TICK_CHUNK_RETRY_COUNT,this.processRetrieved()}get base(){return this.innerBuilder.container}getFirstDate(e){return this.innerBuilder.getFirstDate(e)}get startFromIndex(){return 0}processRetrieved(){this.container.clear(),this.isBuildingBars=!0;let[e,t,n,r]=[W.DateTime,W.TradeSize,W.Last,W.TradingDay].map(e=>this.base.getData(e));for(let i=this.startFromIndex;i<this.base.size;i++){let a={isTrade:!0,time:e[i],tradeSize:t[i],tradePrice:n[i],tradingDay:r[i]};super.process(a)}this.isBuildingBars=!1}process(e){let t=this.innerBuilder.process(e);return e.time=new Date(t.time),super.process(e)}},Qh=class extends Zh{constructor(e,t,n){super(e,t,n)}fixupTimeBasedAggregationTimestamp(e){return Rr(e,vn(e,Sn(Lr(e,1)))%this.agg.size)}},$h=class extends Zh{series;constructor(e,t,n,r){super(e,n,r),this.series=t}computeNextStamp(e,t){return this.isCorrection(e,t)?null:t}},eg=new zd(`_TICK_COUNT`),tg=class extends $h{anchorTimestamp=null;constructor(e,t,n,r){super(e,t,n,r)}get startFromIndex(){let e=0,t=this.base.getTimeData();if(P(this.anchorTimestamp))e=Ce(t,e=>e===this.anchorTimestamp);else{let n=this.base.size;if(n>2)for(let r=n-2;r>2;--r){let n=t[r].valueOf();if(n-t[r-1].valueOf()>1&&t[r+1].valueOf()-n>1){e=r;break}}this.anchorTimestamp=t[e]}return e>this.agg.size&&(e%=this.agg.size),Math.max(e,0)}addBar(e,t){let n=super.addBar(e,t);return this.container.addDataPoint(eg,1),n}changeLastBar(e,t){let n=super.changeLastBar(e,t),r=this.container.getLastDataPoint(eg);return this.container.setLastDataPoint(eg,r+1),n}isUpdate(e,t,n,r){return this.container.getLastDataPoint(eg)<this.agg.size}},ng=new zd(`_VOLUME_TALLY`),rg=class extends $h{constructor(e,t,n,r){super(e,t,n,r)}addBar(e,t){let n=this.container,r=(n.getLastDataPoint(ng)||0)+e.tradeSize,i=Math.floor(r/this.agg.size),a=r%this.agg.size,o=r<this.agg.size;n.size>0&&(n.setLastDataPoint(W.Volume,o?1:i),n.setLastDataPoint(ng,r));let s=super.addBar(e,t);return n.setLastDataPoint(W.Volume,1),n.addDataPoint(ng,o?0:a),s}changeLastBar(e,t){let n=this.container,r=super.changeLastBar(e,t);n.setLastDataPoint(W.Volume,1);let i=n.getLastDataPoint(ng)??0;return n.setLastDataPoint(ng,i+e.tradeSize),r}isUpdate(e,t,n,r){if(!en(e,t))return!1;let i=this.container.getLastDataPoint(ng)??0;return r.tradeSize+i<this.agg.size}},ig=class extends bh{innerBuilder;metadata;range;step;constructor(e,t,n,r){super(t,n),this.innerBuilder=e,this.range=n.size,this.step=1,this.metadata=$().getMetaDataSource().getMetaData(r)}get priceRange(){return this.step*this.range}get base(){return this.innerBuilder.container}ready(){return Ai.call(this,async()=>{let e=await this.metadata.ready();return e&&(this.step=this.metadata.minMovement,this.processRetrieved()),e})}processRetrieved(){this.container.clear();for(let e=0;e<this.base.size;e++){let t=this.base.getData(W.Volume)[e],n=this.useHighOrLow(e);if(!P(n)){this.updateLastBar(void 0,void 0,void 0,t);continue}let r={isTrade:!0,time:this.base.getData(W.DateTime)[e],tradeSize:t,tradePrice:n,tradingDay:0};super.process(r)}}useHighOrLow(e){let t=this.base.getData(W.Close)[e];if(this.container.size==0)return t;let n=this.container.getLastDataPoint(W.High),r=this.container.getLastDataPoint(W.High),i=this.base.getData(W.High)[e],a=this.base.getData(W.Low)[e],o=i>n,s=a<r;if(o&&s)return i-t<t-a?i:a;if(o)return i;if(s)return a}computeNextStamp(e,t){return this.isCorrection(e,t)?null:t}isUpdate(e,t,n,r){return!0}process(e){return this.innerBuilder.process(e),super.process(e)}changeLastBar(e,t){let n=e.tradePrice,r=this.container.getLastDataPoint(W.Low)+this.priceRange;if(n>r)return this.changeAndAddBar(r,e,t);let i=this.container.getLastDataPoint(W.High)-this.priceRange;return n<i?this.changeAndAddBar(i,e,t):super.changeLastBar(e,t)}changeAndAddBar(e,t,n){return this.updateLastBar(e,e,e,0),this.container.setLastDataPoint(W.Projection,0),this.addBar(t,n)}addBar(e,t){return this.container.addDataPoint(W.Projection,1),super.addBar(e,t)}},ag=[W.Open,W.High,W.Low,W.Close],og=[W.BARCOLIX,W.High,W.Low],sg=z.RENKO_KAGI_NAMES;function cg(e){let{BoxSizeMethod:t,Period:n,ReversalAmount:r}=dt(e);return{method:et(t,[sg.ATR,sg.TRD],sg.ATR),period:Number.isFinite(n)?n:14,reversal:Number.isFinite(r)?r:30}}var lg=class extends bh{innerBuilder;inputs;reversal;isProcessingRetrieved=!1;constructor(e,t,n){super(t,n.aggregation),this.innerBuilder=e,this.inputs=F(n.inputs),this.reversal=null,this.processRetrieved()}get base(){return this.innerBuilder.container}_at(e,t,n){return e.getData(t)[n]}baseAt(e,t){return this._at(this.base,e,t)}dataAt(e,t){return this._at(this.container,e,t)}getLast(e){return this.container.getLastDataPoint(e)}setLast(e,t){this.container.setLastDataPoint(e,t)}computeNextStamp(e,t){return t}addBar(e,t){if(super.addBar(e,t),this.container.addDataPoint(W.BARCOLIX,null),this.container.size>1){let e=this.dataAt(W.Close,this.container.size-2);this.setLast(W.Open,e),this.updateLastBar(e,e)}return null}isUpdate(e,t,n,r){let i=r.tradePrice,a=e=>e>=0,o=i-this.getLast(W.Close),s=a(o),c=Math.abs(o)>=this.reversal,[l,u,d,f]=ag.map(e=>this.getLast(e)),p=f-l,m=a(p)!==s||p===0;return m&&!c||!m&&(s?i<u:i>d)?null:Math.abs(p)<this.reversal||!m||!c}computeBarColor(){let e=e=>this.dataAt(W.Close,e)>this.dataAt(W.Open,e),t=this.container.size;if(t>1){let n=e(t-1),[r,i,a]=og.map(e=>this.dataAt(e,t-2)),[,o,s]=og.map(e=>this.dataAt(e,t-1)),c=r;r===0&&n&&o>i?c=1:r===1&&!n&&s<a&&(c=0),this.setLast(W.BARCOLIX,c)}else this.setLast(W.BARCOLIX,+!!e(0))}process(e){this.isProcessingRetrieved||this.innerBuilder.process(e);let t=super.process(e);return this.computeBarColor(),t}processRetrieved(){let{method:e,period:t,reversal:n}=cg(this.inputs);if(this.reversal=n,e===sg.ATR&&(this.reversal=kh(this.base,t)),P(this.reversal)){this.container.clear(),this.isProcessingRetrieved=!0;for(let e=0;e<this.base.size;e++){let t={isTrade:!0,time:this.baseAt(W.DateTime,e),tradePrice:this.baseAt(W.Close,e),tradeSize:this.baseAt(W.Volume,e),tradingDay:0};this.process(t)}this.isProcessingRetrieved=!1}}};function ug(e){let{LineCount:t}=dt(e);return{lineBreak:Number.isFinite(t)?t:3}}var dg=class extends bh{innerBuilder;lineBreak;currentVolume;inputs;constructor(e,t,n,r){super(t,n),this.innerBuilder=e,this.inputs=F(r.inputs),this.lineBreak=ug(this.inputs).lineBreak,this.currentVolume=0,this.processRetrieved()}get base(){return this.innerBuilder.container}readTrade(e){return{isTrade:!0,time:this.base.getData(W.DateTime)[e],tradeSize:this.base.getData(W.Volume)[e],tradePrice:this.base.getData(W.Close)[e],tradingDay:0}}processRetrieved(){if(this.container.clear(),!(this.base.size<2)){this.startLine(this.readTrade(1));for(let e=1;e<this.base.size-1;e++){let t=this.readTrade(e);this.insertBar(t,t.time)}super.process(this.readTrade(this.base.size-1))}}process(e){return this.innerBuilder.process(e),super.process(e)}updateLastBar(e,t,n,r){let i=this.findOpen(n,0,1);this.currentVolume+=r,i===null?this.resetProjection():(super.updateLastBar(void 0,void 0,n,void 0),this.container.setLastDataPoint(W.Open,i),this.container.setLastDataPoint(W.Low,Math.min(i,n)),this.container.setLastDataPoint(W.High,Math.max(i,n)))}resetProjection(){let e=this.container;e.setLastDataPoint(W.High,null),e.setLastDataPoint(W.Low,null),e.setLastDataPoint(W.Open,null),e.setLastDataPoint(W.Close,null),e.setLastDataPoint(W.Change,null)}isProjection(e){return this.agg.isIntraday||this.durationAdd(e).getTime()>Date.now()}updateProjection(e,t){this.container.setLastDataPoint(W.DateTime,t.nextTimestamp);let n=this.changeLastBar(e,t);return n.timeCorrection={from:t.lastTimestamp,to:t.nextTimestamp},n}addBar(e,t){let n=this.container,{nextTimestamp:r}=t;if(n.getLastDataPoint(W.Projection)===1){let r=n.getLastDataPoint(W.Close);if(this.findOpen(r,this.lineBreak,1)!==null)n.setLastDataPoint(W.Projection,0),n.setLastDataPoint(W.Volume,this.currentVolume),this.currentVolume=0;else return this.updateProjection(e,t)}return(this.isProjection(r)||!this.insertBar(e,r))&&!this.addProjection(e,r)?null:{isUpdate:!1,time:r.getTime(),index:this.container.size-1}}insertBar(e,t){this.currentVolume+=e.tradeSize;let n=e.tradePrice,r=this.findOpen(n,this.lineBreak);return r===null?!1:(this.createBar(r,Math.max(r,n),Math.min(r,n),n,this.currentVolume,t),this.container.addDataPoint(W.Projection,0),this.currentVolume=0,!0)}addProjection(e,t){this.currentVolume+=e.tradeSize;let n=e.tradePrice,r=this.findOpen(n,0);return r===null?!1:(this.createBar(r,Math.max(r,n),Math.min(r,n),n,0,t),this.container.addDataPoint(W.Projection,1),!0)}findOpen(e,t,n=0){if(!P(e))return null;let r=this.container,i=r.size-1-n,a=r.getData(W.Close)[i],o=r.getData(W.Open)[i];if(a>o){if(e<=a){if(e>=o)return null;for(let n=0;n<Math.min(r.size,t);n++)if(e>=r.getData(W.Low)[i-n])return null;return o}return a}else{if(e>=a){if(e<=o)return null;for(let n=0;n<Math.min(r.size,t);n++)if(e<=r.getData(W.High)[i-n])return null;return o}return a}}startLine(e){this.container.addDataPoint(W.Projection,0);let t=this.readTrade(0);this.createBar(t.tradePrice,Math.max(t.tradePrice,e.tradePrice),Math.min(t.tradePrice,e.tradePrice),e.tradePrice,e.tradeSize+t.tradeSize,e.time)}},fg=z.RENKO_KAGI_NAMES,pg={Positive:1,Negative:2,Both:3};function mg(e){switch(e){case z.BARKIND_OX:case z.BARKIND_XO:return!0;default:return!1}}function hg(e){switch(e){case z.BARKIND_O:case z.BARKIND_XO:return!0;default:return!1}}function gg(e){switch(e){case z.BARKIND_X:case z.BARKIND_OX:return!0;default:return!1}}function _g(e){let t=dt(e),{Source:n,BoxSizeMethod:r,Period:i}=t,{ReversalAmount:a,BoxSize:o,OneStepBack:s}=t,c=et(n,[fg.CLS,fg.HL],fg.CLS),l=et(r,[fg.ATR,fg.TRD],fg.ATR),u=Number.isFinite(i)?o:14,d=Number.isFinite(a)?a:3;return{method:l,period:u,source:c,boxSize:Number.isFinite(o)?o:20,reversal:d,oneStepBack:s===`Yes`}}var vg=class extends bh{innerBuilder;inputs;boxSize;reversal;source;firstTrend;oneStepBack;isProcessingRetrieved=!1;constructor(e,t,n){super(t,n.aggregation),this.innerBuilder=e,this.inputs=F(n.inputs),this.boxSize=this.reversal=this.source=this.firstTrend=this.oneStepBack=null,this.processRetrieved()}get base(){return this.innerBuilder.container}_at(e,t,n){return e.getData(t)[n]}baseAt(e,t){return this._at(this.base,e,t)}dataAt(e,t){return this._at(this.container,e,t)}getLast(e){return this.container.getLastDataPoint(e)}setLast(e,t){this.container.setLastDataPoint(e,t)}computeNextStamp(e,t){return t}roundToBox(e){return e-e%this.boxSize}roundedDiff(e,t,n){let r=Math.abs(t-e);return e+n*this.roundToBox(r)}get closeBased(){return this.source===fg.CLS}get currentKind(){return this.getLast(W.BARKIND)}getTrendField(e){return this.closeBased?W.Close:e?W.Low:W.High}getTrendPrice(e,t){if(this.closeBased)return e.tradePrice;let n=e;return t?n._lowPrice:n._highPrice}changeLastBar(e,t){let n=hg(this.currentKind),r=n?-1:1,i=this.getLast(this.getTrendField(n)),a=this.getTrendPrice(e,n);return e.tradePrice=this.roundedDiff(i,a,r),super.changeLastBar(e,t),null}addBar(e,t){let n=this.container.size===0,r=hg(this.currentKind),i=r?1:-1,a=n?null:this.getLast(W.Close),o=this.getTrendPrice(e,!r);if(e.tradePrice=(n?this.roundToBox(this.baseAt(W.Open,0)):a)+i*(n?0:this.boxSize),super.addBar(e,t),!n){let e=this.roundedDiff(a,o,i);this.updateLastBar(e,e,e)}return this.container.addDataPoint(W.BARKIND,null),this.computeBarColor(),null}inplaceReverse(){let e=hg(this.currentKind)?z.BARKIND_OX:z.BARKIND_XO;this.setLast(W.BARKIND,e)}canInplaceReverse(){return mg(this.currentKind)?!1:this.getLast(W.High)===this.getLast(W.Low)}isUpdate(e,t,n,r){let i=hg(this.currentKind),a=this.getTrendPrice(r,i),o=this.getTrendPrice(r,!i),s=e=>e>=0,c=a-this.getLast(W.Close),l=s(c),u=Math.abs(c)>=this.boxSize,d=o-this.getLast(W.Close),f=s(d),p=Math.abs(d)>=this.reversal*this.boxSize;return i?!l&&u?!0:f&&p?!this.oneStepBack||!this.canInplaceReverse()?!1:(this.inplaceReverse(),!0):null:l&&u?!0:!f&&p?!this.oneStepBack||!this.canInplaceReverse()?!1:(this.inplaceReverse(),!0):null}findFirstDiffLargerThanBox(e,t){let n=this.baseAt(W.Open,0),r=this.innerBuilder.container.size;for(let i=1;i<r;++i){let r=this.baseAt(e,i)-n;if(Math.abs(r)>this.boxSize){if(t===pg.Positive&&r>0)return[i,z.BARKIND_X];if(t===pg.Negative&&r<0)return[i,z.BARKIND_O];if(t===pg.Both)return[i,r>0?z.BARKIND_X:z.BARKIND_O]}}return[null,null]}findFirstBarTrend(){if(this.innerBuilder.container.size<2)return null;if(this.closeBased){let[,e]=this.findFirstDiffLargerThanBox(W.Close,pg.Both);return e}else{let[e,t]=this.findFirstDiffLargerThanBox(W.High,pg.Positive),[n,r]=this.findFirstDiffLargerThanBox(W.Low,pg.Negative);return t===null&&r===null?null:r===null?t:t===null?r:e<n?t:r}}computeBarColor(){let e=this.container.size,t=this.firstTrend;e>1&&(t=hg(this.dataAt(W.BARKIND,e-2))?z.BARKIND_X:z.BARKIND_O),this.setLast(W.BARKIND,t)}process(e){return this.isProcessingRetrieved||this.innerBuilder.process(e),this.firstTrend===null?null:super.process(e)}processRetrieved(){let{method:e,period:t,reversal:n,source:r,boxSize:i,oneStepBack:a}=_g(this.inputs);if(this.reversal=n,this.source=r,e===fg.ATR?this.boxSize=kh(this.base,t):this.boxSize=i,P(this.reversal,this.boxSize)&&(this.oneStepBack=a&&this.reversal===1,this.container.clear(),this.firstTrend=this.findFirstBarTrend(),this.firstTrend!==null)){this.isProcessingRetrieved=!0;for(let e=0;e<this.base.size;e++){let t={isTrade:!0,time:this.baseAt(W.DateTime,e),tradePrice:this.baseAt(W.Close,e),_highPrice:this.baseAt(W.High,e),_lowPrice:this.baseAt(W.Low,e),tradeSize:this.baseAt(W.Volume,e),tradingDay:0};this.process(t)}this.isProcessingRetrieved=!1}}},yg=new Ul(g.Intraday,0),bg=class extends yh{constructor(e){super(e)}process(e){return{isUpdate:!1,time:0,index:-1}}},xg=class{container;canLoadMoreData=!0;alignToQuote=!1;isCached;record;isLoading=!1;serverComputedSeries;builder;retriever;streamingSubscription;records;constructor(e){this.query=e,this.container=null,this.canLoadMoreData=!0,this.alignToQuote=!1,this.record=new Jd(e.symbol)}get isTotalVolumeMode(){let e=this.query.symbol,t=this.query.aggregation;return Yr(e)&&!t.isContractVolume&&t.isEndOfDay}getHasVisible(e){return this.query.visibleRange!=null&&this.query.visibleRange[e]!=null}get hasVisibleFrom(){return this.getHasVisible(`from`)}get hasVisibleTo(){return this.getHasVisible(`to`)}get hasHistoricalData(){return this.hasData&&!this.container.isEmpty}refresh(){if(Vm(`ts:refresh`,{symbol:this.query.symbol??null,hasData:this.hasData,hasHistoricalData:this.hasHistoricalData,isCached:this.isCached??!1}),!this.hasHistoricalData){ji.call(this),this.ready().then(e=>{Vm(`ts:refresh:result`,{symbol:this.query.symbol??null,hasData:e,containerSize:this.container?.size??null}),e&&Ge(G.TS_MANYCHANGED,{series:this,part:re.Unspecified})});return}this.query.aggregation.isEndOfDay?this.alignToQuote=!0:this.loadMoreData(!1)}makeInnerBuilder(e){let t=this.query.aggregation;if(t.isTick)switch(t.spec){case _.None:case _.PerSeconds:case _.PerCount:case _.PerVolume:return new yh(e);default:throw Error(`Custom tick aggregation ${t.describe()} has not been implemented yet`)}else return new bh(e,t)}makeBuilder(e){let t=this.makeInnerBuilder(e),n=this.query.aggregation,r=(e,t=[])=>new Sh(zh(this.query.symbol,e).concat(t)),i=t;switch(this.query.curveStyle){case h.Renko:return new Nh(i,this.query);case h.Kagi:return new lg(i,r(yg,[W.BARCOLIX]),this.query);case h.PointAndFigure:return new vg(i,r(yg,[W.BARKIND]),this.query);case h.LineBreak:return new dg(i,r(n,[W.Projection]),n,this.query)}if(n.isIntraday&&n.spec===_.PerRange)return new ig(i,r(yg,[W.Projection]),n,this.query.symbol);let a=t;if(n.isTick)switch(n.spec){case _.PerSeconds:return new Qh(a,r(yg),n);case _.PerCount:{let e=r(yg,[eg]);return new tg(a,this,e,n)}case _.PerVolume:{let e=r(yg,[ng]);return new rg(a,this,e,n)}}return n.unit===g.Day&&n.size>1?new xh(i,r(n),n):t}onStreamingUpdates(e){this.isLoading||e.map(e=>{if(`isTrade`in e)return this.builder.process(e);if(`isQuote`in e&&(Ge(G.TS_QUOTEMARKER,{series:this}),this.alignToQuote)){let t=this.builder.alignToQuote(e);return this.alignToQuote=!1,t}return null}).filter(e=>P(e)).filter((e,t,n)=>{if(t===0)return!0;let r=n[t-1];return r.isUpdate!==e.isUpdate||r.time!==e.time||e.timeCorrection}).forEach(e=>{if(e.index===-1)Ge(G.TS_MANYCHANGED,{series:this,part:re.Unspecified});else{let t={series:this,index:e.index};Ge(e.isUpdate?G.TS_DATAPOINTCHANGED:G.TS_DATAPOINTADDED,t)}e.timeCorrection&&Ge(G.TS_TIMELINECORRECTION,{...e.timeCorrection,series:this})})}get hasData(){return this.container!==null}getRetriever(){return ei(this.query.symbol)&&this.query.aggregation.isEndOfDay?new Jh:new Gh}getStreamingSubscription(){return $().getRecordSource().subject.pipe(Ip(e=>{let t=this.query.aggregation.isEndOfDay,n=this.record,r=n?.symbol;if(!r)return[];let i=sf(G.RT_TRADE,r),a=e.filter(i).filter(e=>P(e.data.time)).filter(e=>e.data.session!==`T`||this.query.extendedHours&&!t).map(e=>({isTrade:!0,tradePrice:e.data.tradePrice,tradeSize:e.data.tradeSize,time:e.data.time,tradingDay:e.data.tradingDay}));if(this.isTotalVolumeMode&&this.records){let t=this.getSiblingVolume(e);if(t>0&&a.length>0)a[0].tradeSize+=t;else if(t>0&&a.length===0){let e=n.getValue(W.Last)??n.getValue(W.Close);if(P(e)){let r=new Date;a.push({isTrade:!0,tradePrice:e,tradeSize:t,time:r,tradingDay:n.getValue(W.TradingDay)})}}}let o=a.reduce((e,t)=>{let n=xe(e);return P(n)&&P(n.tradePrice)&&P(t.tradePrice)&&n.tradePrice===t.tradePrice&&n.time.getTime()===t.time.getTime()&&n.tradingDay===t.tradingDay?n.tradeSize+=t.tradeSize:e.push(st(t)),e},[]),s=sf(G.RT_QUOTE,r);return o.concat(e.filter(s).map(e=>({isQuote:!0,openPrice:e.data.openPrice,highPrice:e.data.highPrice,lowPrice:e.data.lowPrice,lastPrice:e.data.lastPrice,time:e.data.tradeTime})))}),zp(e=>e.length>0)).subscribe(this.onStreamingUpdates.bind(this))}getSiblingVolume(e){return this.records?e.filter(e=>e.topic===G.RT_TRADE&&e.data.symbol in this.records).filter(e=>P(e.data.time)).filter(e=>e.data.session!==`T`).reduce((e,t)=>e+t.data.tradeSize,0):0}async loadMoreData(e=!0){if(this.isLoading||!this.builder||!this.retriever||!this.builder.supportsChunks||!this.retriever.supportsChunks||!this.canLoadMoreData)return Promise.resolve();this.isLoading=!0,e?await this.loadHeadChunk():await this.loadTailChunk(),this.isLoading=!1}async loadTailChunk(){let e=this.query.duplicate(),t=this.builder.getLastDate();P(e.offset)&&e.offset!==0&&(t=qt(t,-e.offset)),e.range=[t,null];let n=await this.retriever.retrieve(e),r=this.container.size;this.builder.append(n);let i=this.container.size-r;Ge(G.TS_MANYCHANGED,{series:this,part:re.Tail,count:i,index:r})}async loadHeadChunk(){let e=!1,t=null;for(let n=0;n<this.builder.retryCountForChunk&&!e;++n){let r=this.query.duplicate(),i=this.builder.getFirstDate(n);P(r.offset)&&r.offset!==0&&(i=qt(i,-r.offset)),r.range=[null,i],t=await this.retriever.retrieve(r),e=t.size>1}this.canLoadMoreData=e,e&&t!==null&&(this.builder.prepend(t),Ge(G.TS_MANYCHANGED,{series:this,part:re.Head}))}async applyNearbyFixup(e){let t=this.query.aggregation,n=t.spec===_.Nearest,r=this.query.symbol,i=Yr(r);return!i||!t.isMultiContract||!n||e.size<1||this.serverComputedSeries?i&&oi(r)?await qr(r):r:e.getLastDataPoint(W.Symbol)}async ready(){return Ai.call(this,async()=>{try{Vm(`ts:ready:start`,{symbol:this.query.symbol??null,isCached:this.isCached??!1,hasVisibleFrom:this.hasVisibleFrom,hasVisibleTo:this.hasVisibleTo}),this.retriever=this.getRetriever();let e=await this.retriever.retrieve(this.query);Vm(`ts:ready:retrieved`,{symbol:this.query.symbol??null,containerSize:e.size});let t=await this.applyNearbyFixup(e);return this.hasVisibleTo||(this.record=$().getRecordSource().getRecord(t)),this.canLoadMoreData=!this.hasVisibleFrom&&e.size>0,this.isTotalVolumeMode&&await this.setupTotalVolumeSubscriptions(),this.builder=this.makeBuilder(e),await this.builder.ready(),this.container=this.builder.container,Vm(`ts:ready:done`,{symbol:this.query.symbol??null,recordSymbol:this.record?.symbol??null,containerSize:this.container?.size??null}),this.query.disableStreamingUpdates||(this.streamingSubscription=this.getStreamingSubscription()),!0}catch(e){return Vm(`ts:ready:failed`,{symbol:this.query.symbol??null,message:e.message}),I(`Failed loading the historical data for ${this.query.symbol}, error is ${e.message}`,`warn`),this.builder=void 0,this.container=null,!1}})}async setupTotalVolumeSubscriptions(){let e=this.query.symbol,t=ui(e);if(t)try{let n=await li(t),r=this.record?.symbol??e,i=n.map(e=>e.name).filter(e=>e!==r),a=$().getRecordSource();this.records={};for(let e of i)this.records[e]=a.getRecord(e);await Promise.all(Object.values(this.records).map(e=>e.ready()))}catch{this.records=void 0}}getCacheableEntities(e){e.add(this)}shutdown(){P(this.streamingSubscription)&&this.streamingSubscription.unsubscribe(),this.records=void 0}},Sg=class extends xg{getRetriever(){return new Kh}makeBuilder(e){return new bg(e)}getStreamingSubscription(){}onStreamingUpdates(e){}},Cg=class{query;container;_pretendEmpty;constructor(e,t=!1){this._pretendEmpty=t,this.query=e,this.container=new Ch}refresh(){}canLoadMoreData=!1;isLoading=!1;calculable=!1;loadMoreData(e){throw Error(`Should not be called.`)}get hasData(){return this._pretendEmpty}async ready(){return this._pretendEmpty}getCacheableEntities(e){}shutdown(){}},wg=class{query;container;canLoadMoreData=!1;isLoading=!1;constructor(e,t){this.query=e,this.container=t}get hasData(){return this.container!==null}loadMoreData(e){throw Error(`Should not be called.`)}refresh(){}async ready(){return!0}getCacheableEntities(e){}shutdown(){}},Tg=class{container;supplyCustomDemoData;canLoadMoreData=!0;isLoading=!0;constructor(e){this.query=e,this.container=null,this.supplyCustomDemoData=$().config.mode===`DemoSite`}refresh(){}loadMoreData(e){throw Error(`Should not be called.`)}get hasData(){return this.container!==null}shutdown(){}parseEvents(e){let t=new Sh([W.DateTime,W.Dividends,W.Earnings,W.Splits,W.Custom]),n=e.split(`
@@ -39,4 +39,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
39
39
  `);if(this.isNew){let{actualWidth:r,actualHeight:i}=this.getTextDimensions(n);t.points[0].update(e.price,e.time);let{x:a,y:o}=t.points[0].point;t.points[1].updateFromPoint({x:a+r,y:o+i}),t.drawn=!1}t.textLines=n,this.textArea.onblur=null,this.getChartParent().removeChild(this.textArea),t.requestRedraw(),this.isNew||t.requestRedraw(),kk(t,!0,this.isNew?O.Created:O.TextChanged)}getTextDimensions(e){let t=globalThis.getComputedStyle(this.textArea).getPropertyValue(`font-size`),n=parseFloat(t)*e.length,r=0,i=this.anchor.axis.pane.presenter,a=i.view.mainContext;a.save();let{chart:{fontFamily:o}}=i.display;a.font=`${t} ${o}`;for(let t=0;t<e.length;t++){let n=a.measureText(e[t]).width;n>r&&(r=n)}return a.restore(),{actualWidth:r,actualHeight:n}}};function zD(e){return $().config.tooltipMovement===e}function BD(){return zD(`Draggable`)}function VD(){return zD(`Auto`)}var HD=z.TOOLTIP_STD_LEGACY_CLASS,UD=z.TOOLTIP_STD_CLASS,WD=z.TOOLTIP_BUBBLE_CLASS;function GD(e,t){let n=e.filter(e=>e.visible),r=n.find(e=>e.isMain)||n[0],i=r?.values.find(e=>[`Close`,`Last`].includes(e.id))?.y??r?.values[0]?.y??t,a=n.map(e=>e.values.filter(e=>e.id!==`Change`&&e.y>0).map(e=>e.y)).flat(),[o,s]=a.length>0?[Math.min(...a),Math.max(...a)]:[i,i];return{plots:n,y:i,yMin:o,yMax:s}}var KD=class{tooltipElem;leftSide;mode;isDrag=!1;canDrag;isToggling;constructor(e){this.view=e,this.tooltipElem=Ei(e.el,`div`),Ci(this.tooltipElem,{id:`${e.presenter.elementId}-global-tooltip`,class:`${UD} ${HD}`}),this.leftSide=!0,Si(this.tooltipElem,{visibility:`hidden`,position:`absolute`,cursor:BD()?`move`:`default`,zIndex:20,top:`${z.TOOLTIP_Y_OFFSET}px`,left:`${z.TOOLTIP_X_OFFSET}px`}),this.setMode(e.presenter.display.tooltip.mode),this.handleMouseMove=this.handleMouseMove.bind(this),this.startDrag=this.startDrag.bind(this),this.stopDrag=this.stopDrag.bind(this),this.view.el.addEventListener(`mousemove`,this.handleMouseMove),this.view.el.addEventListener(`mouseleave`,this.stopDrag),this.tooltipElem.addEventListener(`mousedown`,this.startDrag),this.tooltipElem.addEventListener(`mouseup`,this.stopDrag)}startDrag(){this.isDrag=!0}stopDrag(){this.isDrag=!1}setMode(e){if(this.mode!==e){if(this.mode=e,e===z.TOOLTIP_BUBBLE)this.canDrag=!1,this.tooltipElem.style.transition=`none`,this.tooltipElem.classList.remove(UD,HD),this.tooltipElem.classList.add(WD),Si(this.tooltipElem,{pointerEvents:`none`});else if(e===z.TOOLTIP_STD){this.canDrag=BD(),this.tooltipElem.classList.remove(WD),this.tooltipElem.classList.add(UD,HD);let e=z.TOOLTIP_TOGGLE_SIDE_ANIM_MS;Si(this.tooltipElem,{pointerEvents:`all`,top:`${z.TOOLTIP_Y_OFFSET}px`,left:`${z.TOOLTIP_X_OFFSET}px`,transition:VD()?`left ${e}ms ease-out`:null})}}}show(e,t){let n=this.tooltipElem;if(t){let{width:e,height:r,leftOffset:i,rightOffset:a}=this.view,o=n.getBoundingClientRect(),s=o.width/2,c=n.style,l=r*z.TOOLTIP_BUBBLE_OFFSET,u=t.yMin-o.height-l,d=t.x-s,f=t.yMax+l,p=f+o.height,m=u<0?p<r?f:0:u,h=d,g=e-a;h<i?h=i:h+o.width>g&&(h=g-o.width),c.top=`${m}px`,c.left=`${h}px`}n.style.visibility===`hidden`&&(n.style.visibility=`visible`),Oi(n,e)}hide(){this.tooltipElem.style.visibility=`hidden`}remove(){this.view.el.removeEventListener(`mousemove`,this.handleMouseMove),this.view.el.removeEventListener(`mouseleave`,this.stopDrag),this.tooltipElem.removeEventListener(`mousedown`,this.startDrag),this.tooltipElem.removeEventListener(`mouseup`,this.stopDrag),bi(this.tooltipElem)}reposition(e,t){Si(this.tooltipElem,{left:`${e}px`,top:`${t}px`})}isAutoMove(){return this.mode===z.TOOLTIP_STD&&VD()}handleMouseMove(e){if(this.isDrag&&this.canDrag){let{movementX:t,movementY:n}=e,{top:r,left:i}=this.tooltipElem.style,a=parseInt(r)+n,o=parseInt(i)+t;this.reposition(o,a)}else if(this.isAutoMove()){let t=this.tooltipElem.getBoundingClientRect(),n=this.view.el.getBoundingClientRect(),r=e.pageX,i=z.TOOLTIP_TOGGLE_DISTANCE_TOLERANCE,a=n.width>t.width*2,o=r>t.x&&r<=t.right+i,s=r<t.x&&r>=t.x-i;a&&(o||s)&&this.toggleSide()}}repositionAuto(){if(this.isAutoMove()){let e=this.view.presenter.mainPane.getBoundsWithoutScales(),t=this.tooltipElem.offsetY,n=e.x+(this.leftSide?z.TOOLTIP_X_OFFSET:e.width-this.tooltipElem.offsetWidth-z.TOOLTIP_X_OFFSET);this.reposition(n,t)}}toggleSide(){this.isToggling||(this.isToggling=!0,setTimeout(()=>this.isToggling=!1,z.TOOLTIP_TOGGLE_SIDE_ANIM_MS),this.leftSide=!this.leftSide,this.repositionAuto())}};function qD(e){e.showTooltip&&JD(e,{time:z.ZERO_DATE,offset:z.OFFSCREEN_OFFSET,price:0,lastBarRefresh:void 0,justMain:void 0})}function JD(e,{time:t,lastBarRefresh:n,justMain:r,offset:i,price:a}){let o=V_(e,t,i,n,r,a),{mode:s,showMainPlot:c,hideSymbols:l,revealingClose:u}=e.display.tooltip,{includeTimestamp:d,showMainPlot:f,showPlotActions:p}=$().config.tooltipHeaders||{},m=P(f)?f:c,h=P(d)?d:!1,g=P(l)?l:!1,_=P(u)?u:!1,v=P(p)?p:!1,y=t.valueOf()===z.ZERO_DATE.valueOf();switch(s){case z.TOOLTIP_CARDS:r||XD(e,o,m,!y,h&&!y,!1,g,_,v,e.hasLegend?e.view?.legend?.getLegendElem().clientHeight:0);break;case z.TOOLTIP_BUBBLE:if(!y){let t=GD(o.panes.find(e=>{let{top:t,left:n,width:r,height:a}=e.bounds;return new za(n,t,r,a).contains(i)}).plots,i.y),n=`<div class="bubble-box">${C_({...o,hideSymbols:g,revealingClose:_,plots:t.plots})}</div>`;e.view.tooltip.show(n,{x:i.x,y:t.y,yMin:t.yMin,yMax:t.yMax})}XD(e,o,m,!1,!1,e.hasLegend,g,_,v);break;case z.TOOLTIP_STD:if(!y){let t=C_({...o,hideSymbols:g,revealingClose:_,plots:o.panes.map(e=>e.plots).flat()});e.view.tooltip.show(t)}XD(e,o,m,!1,!1,e.hasLegend,g,_,v);break;case z.TOOLTIP_EXTERNAL:e.notifyHost(G.CH_TOOLTIPCHANGED,o);break;default:I(`Unknown tooltip mode requested: ${s}`,`warn`);break}}function YD(e,t,n,r,i,a){Si(e,{position:`absolute`,display:`flex`,"flex-direction":t,"flex-wrap":`wrap`,left:`${n+z.CARDS_X_OFFSET}px`,top:`${i+z.CARDS_Y_OFFSET}px`,maxWidth:`${a-r-z.CARDS_X_OFFSET*2}px`})}function XD(e,t,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=0){let u=e.view.el,d=w_(e,t,n,r,i,o,s,c);d.some(e=>!P(e.bounds))||d.forEach(({id:t,isMainPane:n,content:r,moveContent:i,bounds:{left:o,right:s,top:c,width:d}},f)=>{if(r!==``&&(!a||!n)){let i=wi(t,u,`div`);YD(i,n&&b_(e)?`column`:`row`,o,s,c+l,d),Ti(i,{"bcharts-card":!0,"bcharts-card-main":n,"bcharts-card-first":f===0}),i.innerHTML=r}let p=xi(`#right-${t}`,u);P(p)||(p=document.createElement(`div`),p.id=`right-${t}`,u.appendChild(p),Ti(p,`bcharts-card bcharts-card-move`)),Si(p,{position:`absolute`,display:`block`,right:`${s+z.CARDS_X_OFFSET}px`,top:`${c+l+z.CARDS_Y_OFFSET}px`}),p.innerHTML=i})}var ZD=null;function QD(){return ZD===null&&(ZD=$().config.hostingModel===ae[ae.Application]),ZD}var $D=class extends dD{presenter;panY;snapToSupported=!1;warmUp=!0;preventDefault=!1;lastOffset;lastPanningExtremes;constructor(e){super(),this.ap=e,this.presenter=e.presenter,this.panY=e.axis.isCustomDomain}activated(){}deactivated(){this.cancelLongPress()}startPan(e){this.startLongPress(this.presenter,this.ap,e),this.lastOffset=e,this.lastPanningExtremes=this.ap.axis.yScale.domain();let t=this.ap.presenter;t.enableTooltip(!1),t.view.tooltip.hide(),t.view.drawCrosshair({ap:void 0})}onMouseMove(e){if(e.pinchZoom){this.presenter.resetActiveTool();return}let{point:t,view:n,offset:r}=e;if(t&&t.axis!==this.ap.axis)return;let{x:i,y:a}=r,o=i-this.lastOffset.x,s=Math.abs(o),c=this.lastOffset.y,l=a-c,u=Math.abs(l);s>=1&&this.cancelLongPress();let d=QD();if(Ie()&&!d&&this.warmUp)return(s>7||u>7)&&(this.warmUp=!1,this.preventDefault=s>u),!1;if(this.preventDefault||!Ie()||d){if(n.xAxis.pan(o),this.panY&&t&&t.axis){u>=1&&this.cancelLongPress();let e=eO(t.axis,c,a,this.lastPanningExtremes);this.lastPanningExtremes=e,t.axis.yScale.domain(e)}this.lastOffset=r,n.redraw(),t&&t.presenter.view.setCursor(ee.Grabbing)}return d||this.preventDefault}finished(){Ok(this.presenter)}onMouseLeave(){this.finished()}onMouseUp(){this.finished()}onMouseDblClick({presenter:e,offset:t,originalEvent:n}){Ie()&&fO(e,t,n)}performLongPress(e,t,n){e.enableTooltip(!0),e.resetActiveTool(),e.activeTool.startTouchCrosshairMode(e,t,n)}};function eO(e,t,n,r){let i=(n-t)/e.viewBox.height,[a,o]=r,s=i*(o-a);return[a+s,o+s]}var tO=null;function nO(e,t){let n=new DOMParser().parseFromString(e,`image/svg+xml`),r=n.querySelector(`svg`)?.getAttribute(`viewBox`),i=n.querySelector(`path`)?.getAttribute(`d`);if(N(r)&&N(i)){let e=r.split(` `).map(Number);e.length===4&&e.every(Number.isFinite)&&(tO={path:new Path2D(i),width:e[2],height:e[3],rect:new za(0,0,0,0),logoClickable:t})}}var rO=5,iO=50;function aO(e,{x:t,y:n,height:r,width:i}){if(!N(tO))return;let{path:a,width:o,height:s,rect:c}=tO,l=i/8,u=Math.min(Math.max(iO,l),o)/o;c.width=o*u,c.height=s*u,c.x=t+rO,c.y=n+r-c.height-rO,e.save();let d=getComputedStyle(e.canvas).getPropertyValue(`--widget-logo-fill-color`);e.fillStyle=d.length===0?`rgba(127, 127, 127, 0.6)`:d,e.translate(c.x,c.y),e.scale(u,u),e.fill(a),e.restore()}function oO(){return N(tO)&&tO.logoClickable?tO.rect:null}var sO=class extends AD{constructor(e,t){super(e,t)}hitTest(e){if(!this.visible)return!1;let t=this.getRect();return t===null?!1:t.contains(e)}draw(e,t){return super.draw(e,t)?(Xa(e,this.getRect()),!0):!1}};function cO(e,t){return e<t?[e,t]:[t,e]}var lO={line:{width:1,color:`rgba(127, 127, 127, 0.3)`,dashStyle:`LongDash`},fill:{color:`rgba(127, 127, 127, 0.1)`}},uO=class extends FD{snapToSupported=!1;preventDefault=!1;axis;presenter;constructor(){super(xD(`Rectangle`,sO,null,lO),!1)}activated(){}deactivated(){P(this.axis,this.annotation)&&this.axis.deleteAnnotation(this.annotation,!1)}onMouseDown(e){let t=super.onMouseDown(e);if(t===!0){let{point:t}=e;this.axis=t.axis,this.presenter=t.presenter}return t}finish(){if(P(this.axis,this.presenter)){Ok(this.presenter,{toolChange:O.Executed,annId:`ZoomIn`});let e=this.annotation.points,t=cO(e[0].price,e[1].price),n=cO(e[0].time,e[1].time),r=(e,t)=>Math.abs(t(e[0])-t(e[1])),i=r(n,e=>this.axis.toX(e)),a=r(t,e=>this.axis.toY(e)),o=this.presenter.view,s=z.MINIMUM_ZOOM_DIMENSION;if(i>s&&a>s){let e=o.xAxis.xScale;this.axis.isCustomDomain=!0,this.axis.yScale.domain(t),e.wasZoomed=!0,e.scaleBarToFitRange(n,!1),e.domain(n)}o.redraw()}}};function dO(e,t){let n=yD(e);n.offset={x:t.x,y:t.y},n.canFlip=e.getFlipAnchorIndices()!==null;let r=e.axis.pane.presenter;r.clearSelection(),r.notifyHost(G.CH_ANNNEEDSCONTEXTMENU,n)}function fO(e,t,n){let r={offset:{x:t.x,y:t.y},chart:e.accessor,originalEvent:n};e.notifyHost(G.CH_CHTNEEDSCONTEXTMENU,r)}function pO(e,t,n,r=1,i=-1){let a=(n.y-t.y)/10,o=e.yScale.rangeWithPadding().reverse();return[o[0]+a*r,o[1]+a*i].map(t=>e.yScale.yToPrice(t))}function mO(e,t){return t.x===e.x||t.x===e.x+e.width||t.y===e.y||t.y===e.y+e.height}function hO(){let e=$().config.touchCrosshairTimeoutMillis;return P(e)&&Number.isFinite(e)?e:z.LONG_PRESS_TIMEOUT_MILLIS}var gO=class{resizingPanes=!1;snapToSupported=!1;touchCrosshairMode=!1;notifyZoomChanged;previousTouchTimestamp=null;resizingScale=!1;resizingScaleId=null;lastScaleResizingOffset=null;touchCrosshairTimeout=null;lastResizingOffset=null;splitter;prevZoomingOffset;prevPinchDistance=null;constructor(){this.stopResizingScale(),this.notifyZoomChanged=Ke(G.CH_ZOOMCHANGED,1e3)}startTouchCrosshairMode(e,t,n){this.touchCrosshairMode=!0,this.showCrosshairAndTooltips(e.view,t,n)}activated(){}deactivated(){}findHit(e){if(!e.point)return[];if(e.axis.pane.axes.some(t=>t.plots.some(t=>t.hitTestCustomEvent(e.point))))return z.EVENT_PIN_HIT;let t=e.presenter.selectedAnnotation,n;t!==void 0&&(n=t.points.find(t=>t.hitTest(e.point)));let r=xe(e.axis.annotations.filter(t=>t.computed?null:t.hitTest(e.point)));return n!==void 0&&r==null&&(r=t),[r,n]}stopResizingScale(){this.resizingScale=!1,this.resizingScaleId=null,this.lastScaleResizingOffset=null}resetVerticalAxis(e,t=!0){this.stopResizingScale(),e.isCustomDomain=!1,t&&e.setDomain()}resetHorizontalAxis(e,t=!0){e.view.xAxis.resetZoom(),t&&e.view.setPriceAxesDomains(),this.fireZoomChanged(e)}canVerticalZoom(e){return Qe(e.display.chart.zooming)[0]}canHorizontalZoom(e){return Qe(e.display.chart.zooming)[1]}canRectangleZoom(e){return this.canVerticalZoom(e)&&this.canHorizontalZoom(e)}fireZoomChanged(e){this.notifyZoomChanged({chart:e.accessor})}onMouseDblClick({priceAxis:e,offset:t,presenter:n,view:r}){let i=r.xAxis.viewBox.contains(t),a=!1;if(P(e))this.resetVerticalAxis(e),a=!0;else if(i)this.resetHorizontalAxis(n),a=!0;else if(Ie()){let e=n.selectedAnnotation;e==null?fO(n,t):dO(e,t)}a&&r.redraw()}onMouseEnter(){this.previousTouchTimestamp=null}computePreviousTouchStartDuration(){if(!Ie())return null;let e=new Date().getTime(),t=P(this.previousTouchTimestamp)?e-this.previousTouchTimestamp:null;return this.previousTouchTimestamp=e,t}onMouseDown(e){let{point:t,button:n,splitter:r,offset:i,priceAxis:a,presenter:o,originalEvent:s}=e,c=window.navigator.platform.toLowerCase().startsWith(`mac`),l=c?D.Meta:D.Control,u=n===E.Right||c&&n===E.Left&&e.getModifier(D.Control);this.touchCrosshairMode&&P(this.touchCrosshairTimeout)&&(clearTimeout(this.touchCrosshairTimeout),this.touchCrosshairTimeout=null);let d=this.computePreviousTouchStartDuration();if(P(d)&&d<z.DOUBLE_CLICK_DURATION_MILLIS)return this.onMouseDblClick(e),!0;if(!u&&this.isLogoLink(i)&&o.notifyHost(G.CH_LOGOCLICKED,{chart:o.accessor}),P(t)&&o.allPlots.some(e=>e.tryHandleCustomEventClick(t.point)))return!0;if(P(r))return this.resizingPanes=!0,this.lastResizingOffset=i,this.splitter=r,o.enableTooltip(!1),!0;if(P(a))return this.canVerticalZoom(o)&&this.startAxisScaling(a,i),!0;if(t!=null){if(e.getModifier(l)&&this.canRectangleZoom(o))return o.activeTool=new uO,o.activeTool.onMouseDown(e),!0;let[n,r]=this.findHit(t);if(o.clearSelection(),n!=null&&o.setSelection(n),n==null||n?.locked)return u?(this.hideCrosshairAndTooltips(o.view),n==null?fO(o,i,s):n?.locked&&dO(n,i),!0):this.touchCrosshairMode?!0:(o.activeTool=new $D(t),o.activeTool.startPan(i),QD());let a=r!=null;return u?(dO(n,i),Ie()):a&&!r.movable||!a&&!n.canMove(t.point)?!1:(o.activeTool=a&&n.points.indexOf(r)!==-1?new mD(n,r):new pD(n,t,i),Ie())}else this.canHorizontalZoom(o)&&(this.prevZoomingOffset=i);return!1}onContextMenu(e){return!0}isLogoLink(e){let t=oO();return P(t)&&t.contains(e)}onMouseMove(e){let{point:t,splitter:n,priceAxis:r,view:i,presenter:a,offset:o}=e;if(P(e.pinchZoom)&&e.pinchZoom&&P(e.pinchDistance))return P(this.prevPinchDistance)&&(e.delta=this.prevPinchDistance-e.pinchDistance,this.onWheel(e)),this.prevPinchDistance=e.pinchDistance,Ie();if(n!=null||this.resizingPanes)i.setCursor(ee.ResizeVertical),this.resizingPanes&&this.resizePanes(i,o);else if(P(t)){let[e,n]=this.findHit(t);P(n)?t.presenter.view.setCursor(ee.Crosshair):P(e)?e.isSelected?t.presenter.view.setCursor(ee.Move):t.presenter.view.setCursor(ee.Hand):t.presenter.view.setCursor(ee.Arrow)}else if(P(r))this.canVerticalZoom(a)&&(i.setCursor(ee.ResizeVertical),this.performAxisScaling(i,r,o));else{let e=this.canHorizontalZoom(a);if(!e&&this.prevZoomingOffset&&delete this.prevZoomingOffset,this.prevZoomingOffset&&e){let{x:e}=this.prevZoomingOffset,{x:t}=o,n=e-t;this.applyZoom(i.presenter,-n),this.prevZoomingOffset=o}i.setCursor(e?ee.ResizeHorizontal:ee.Arrow)}return!t||this.resizingPanes?(this.hideCrosshairAndTooltips(i),Ie()):(this.isLogoLink(o)&&i.setCursor(ee.Hand),this.showCrosshairAndTooltips(i,t,o),Ie())}showCrosshairAndTooltips(e,t,n){t.time&&(!Ie()||this.touchCrosshairMode)&&e.drawCrosshair({ap:t,offset:n})&&e.presenter.showTooltip&&JD(e.presenter,{time:t.time,offset:n,price:t.price,lastBarRefresh:void 0,justMain:void 0})}hideCrosshairAndTooltips(e,t=!1){e.drawCrosshair({ap:void 0}),e.tooltip.hide(),e.presenter.hideCards(t),t&&e.tooltip.mode===`cards`&&!e.presenter?.hasLegend&&qD(e.presenter)}onMouseLeave(e){let{view:t,offset:n}=e;t.presenter.accessor.getPaneBounds()?.every(e=>!e||!e.contains(n)||mO(e,n))&&(this.hideCrosshairAndTooltips(t,!0),this.stopResizeZoom(t.presenter)),t.setCursor(ee.Arrow),this.touchCrosshairMode=!1}stopResizeZoom(e){this.resizingPanes&&(this.resizingPanes=!1,e.enableTooltip(!0),e.onPaneHeightsUpdated()),this.resizingScale&&this.stopResizingScale(),this.prevZoomingOffset&&delete this.prevZoomingOffset}onMouseUp({presenter:e}){if(this.stopResizeZoom(e),Ie()){let t=hO();this.touchCrosshairTimeout=window.setTimeout(()=>{this.hideCrosshairAndTooltips(e.view,!0),this.touchCrosshairMode=!1},t)}}applyZoom(e,t,n=!0){if(!this.canHorizontalZoom(e))return;let r=Math.sign(t)*(Ie()?2:10),i=e.view;i.xAxis.zoom(r)&&(i.setPriceAxesDomains(),i.redraw(),n&&this.fireZoomChanged(e))}onWheel({view:e,presenter:t,getModifier:n,delta:r}){let{scrollBehavior:i}=t.display;return!(Ie()?i!==`none`:i===`wheel`||i===`wheel+shift`&&n(D.Shift))||r===0?!1:(e.drawCrosshair({ap:void 0}),e.tooltip.hide(),e.presenter.hideCards(),this.applyZoom(t,r),!0)}get useKeyboardShortcuts(){return $().config.hostingModel!==ae[ae.Application]}onKeyDown(e){let{key:t,code:n,presenter:r}=e;if(P(r.selectedAnnotation)&&Le(t,n)){let e=r.selectedAnnotation;e.axis.deleteAnnotation(e),r.onAnnotationModifiedByTool(e,O.Deleted)}if(P(r.selectedAnnotation)&&(Re(t,n)?r.clearSelection():ze(t,n)&&r.selectedAnnotation instanceof MD&&r.selectedAnnotation.textEditable&&(r.activeTool=new RD(null,r.selectedAnnotation),r.activeTool.startEditing())),Be(t,n)||Ve(t,n)){let e=Be(t,n)?1:-1,i=r.view;i.xAxis.pan(e*i.xAxis.xScale.bar.totalWidth),this.hideCrosshairAndTooltips(i),i.redraw()}let i=window.navigator.platform.toLowerCase().startsWith(`mac`)?D.Meta:D.Control;if(e.getModifier(i)&&this.useKeyboardShortcuts){let e=He(t,n),i=We(t,n);return e&&r.undoRedoManager.undo(),i&&r.undoRedoManager.redo(),e||i}Ue(t,n)&&e.getModifier(D.Alt)&&this.resetView(r)}resetView(e){e.allAxes.forEach(e=>this.resetVerticalAxis(e,!1)),this.resetHorizontalAxis(e,!1),e.view.xAxis.goToLatest(!0)}resizePanes(e,t){let n=t.y-this.lastResizingOffset.y;if(n===0)return;let r=e.presenter.panes,[i,a]=this.splitter,o=r.map((e,t)=>{let r=e.getBounds().height;return t===i?r+n:t===a?r-n:r});if(o.some(e=>e<z.MINIMUM_PANE_HEIGHT))return;let s=(e,t)=>e+t,c=o.reduce(s,0),l=r.map(e=>e.height).reduce(s,0),u=e=>Xe(e,4);r.forEach((e,t)=>e.height=u(o[t]/c*l)),this.lastResizingOffset=t,e.recalculateLayout(),e.redraw()}startAxisScaling(e,t){this.resizingScale=!0,this.resizingScaleId=e.id,this.lastScaleResizingOffset=t}performAxisScaling(e,t,n){if(this.resizingScale&&this.resizingScaleId===t.id){let r=Ie()?4:5,i=pO(t,this.lastScaleResizingOffset,n,r,-r);this.lastScaleResizingOffset=n,t.isCustomDomain=!0,t.yScale.domain(i),e.redraw()}}},_O=class extends PD{clicks=0;snapToSupported=!0;isDrawingAnnotation=!0;constructor(e,t){super(e.annName),this.factory=e,this.maxClicks=t}onMouseMove(e){let{point:t,view:n,offset:r}=e;n.drawCrosshair({ap:t,offset:r})}onMouseDown(e){let{point:t,view:n}=e;if(this.clicks===0){if(t===void 0)return Ak(e),!1;t.axis.pane.presenter.clearSelection(),this.annotation=this.factory(t.axis)}this.applyToPoints(t),this.clicks++,this.clicks===this.maxClicks&&this.annotation!==void 0?(this.annotation.drawn=!1,this.annotation.requestRedraw(),typeof this.annotation.updateOtherPoints==`function`&&this.annotation.updateOtherPoints(n.mainContext),kk(this.annotation,!0,O.Created)):this.annotation.requestRedraw()}applyToPoints(e){this.annotation.points[this.clicks].update(e.price,e.time)}},vO=class{snapToSupported=!1;constructor(e,t){setTimeout(()=>this.finalize(e,t),10)}finalize(e,t){let n=e(t);t.pane.presenter.clearSelection(),n.drawn=!1,n.requestRedraw(),kk(n,!0,O.None)}},yO=z.MARKER_ARROW_ANGLE*Math.PI/180/2;function bO(e,t){return xO(e.map(e=>e.point),t)}function xO(e,t,n=z.MARKER_ARROW_LENGTH){return new SO(e,t,n)}var SO=class{p1;p2;constructor(e,t,n=z.MARKER_ARROW_LENGTH){this.vertex=t,this.arrowLen=n,this.p1=e[0],this.p2=e[1]}hitTest(e){let{anchor:t,p1:n,p2:r}=this.getArrowPoints();return Sa([t,n],e,z.HIT_TEST_TOLERANCE)||Sa([t,r],e,z.HIT_TEST_TOLERANCE)}draw(e){let{anchor:t,p1:n,p2:r}=this.getArrowPoints();Qa(e,t,n),Qa(e,t,r)}getArrowPoints(){let e=xa(this.p1,this.p2),t=this.vertex===`start`?0:Math.PI,n=e-yO+t,r=e+yO+t,i=this.vertex===`start`?this.p1:this.p2,a=this.arrowLen*Math.cos(n)+i.x,o=this.arrowLen*Math.sin(n)+i.y,s=this.arrowLen*Math.cos(r)+i.x,c=this.arrowLen*Math.sin(r)+i.y;return{anchor:i,p1:{x:a,y:o},p2:{x:s,y:c}}}},CO=class{hitTest(){return!1}draw(){}},wO=class extends wD{constructor(e,t){super(e,t),this.addPoints(2),this.alignPointsSupported=!0}get extend1(){return this.traits[z.AT_EXTEND_PT_1]}get extend2(){return this.traits[z.AT_EXTEND_PT_2]}get showPercentDiff(){return this.traits[z.AT_SHOW_PERCENTDIFF]}get showBarCount(){return this.traits[z.AT_SHOW_BARCOUNT]}get showRatio(){return this.traits[z.AT_RATIO]}getElements(){let e=this.points[0].point,t=this.points[1].point,n=new SD(e,t,this.extend1,this.extend2,this.axis),r=[];return this.extend1&&r.push(new SD(n.p1,e,!0,!1,this.axis)),r.push(new SD(e,t,!1,!1,this.axis)),this.extend2&&r.push(new SD(t,n.p2,!1,!0,this.axis)),r}formatRatio(e,t){return` (${Xe(e/t,3)})`}formatPercDiff(e,t){let n=(t-e)/e*100;return` (${n>0?`+`:``}${Xe(n,2)}%)`}formatPrice(e){return l_(this.axis,this.priceMap(e))}adornElements(e,t){if(!this.showBarCount&&!this.showPrices&&!this.showPercentDiff&&!this.showRatio)return;let[n,r]=this.points,i=e[+!!this.extend1].getAdornOffset(t);if(this.showBarCount){let e=ba(ga(n.point,r.point),i);Ja(t,this.getBarCount(n.time,r.time).toFixed(0),e,T.Right)}let a=this.showRatio?this.formatRatio(n.price,r.price):``,o=`${this.showPrices?this.formatPrice(n.price):``}${a}`.trim();o!==``&&Ja(t,o,ba(n.point,i),T.Right);let s=this.showPercentDiff?this.formatPercDiff(n.price,r.price):``,c=`${this.showPrices?this.formatPrice(r.price):``}${s}`.trim();c!==``&&Ja(t,c,ba(r.point,i),T.Right)}getMarkers(){let e=this.marker;if(!e||e.vertex===`none`)return[];let{vertex:t,kind:n}=e;return(t===`both`?[`start`,`end`]:[t]).map(e=>n===`arrow`?bO(this.points,e):(I(`There is no marker of ${n} kind`,`warn`),new CO))}},TO=class extends wD{constructor(e,t){super(e,t),this.addPoints(1)}get showTimestamps(){return this.traits[z.AT_SHOW_TIMESTAMPS]}getElements(){return[new hD(this.points[0].point,!0,this.axis)]}getTimeScaleAdornments(){return this.showTimestamps?[{time:this.points[0].time,color:this.traits.line.color}]:super.getTimeScaleAdornments()}},EO=class extends wD{constructor(e,t){super(e,t),this.addPoints(1)}getElements(){return[new hD(this.points[0].point,!1,this.axis)]}getPriceScaleAdornments(){return this.showPrices?[{price:this.points[0].price,color:this.traits.line.color}]:super.getPriceScaleAdornments()}},DO=class extends wD{constructor(e,t,n){super(e,t),this.addPoints(2),P(n)&&P(n.points)&&n.points.forEach((e,t)=>this.points[t].update(e.price,e.time))}allPoints(){let[e,t]=this.points;return P(e,e.point,t,t.point)?[e,this.axis.toAnnotationPoint(ga(e.point,t.point)),t]:z.EMPTY_ARRAY}line2(){return this.traits[z.AT_LINE_2]}use52WeekPrices(){return this.traits[z.AT_USE_52WEEK_PRICES]}getElements(){let e=this.allPoints();return e===z.EMPTY_ARRAY?z.EMPTY_ARRAY:e.map(e=>new SD({x:-z.OUT_OF_SCREEN,y:e.point.y},{x:z.OUT_OF_SCREEN,y:e.point.y},!1,!1,this.axis))}wasPointMovedByTool(e,t){P(this.use52WeekPrices())&&(this.traits[z.AT_USE_52WEEK_PRICES]=!1)}getStyleForElement(e,t){let n=this.line2();if(t!==1||!P(n))return super.getStyleForElement(e,t);let r=F(this.traits);return r.line=n,ko(r)}getPriceScaleAdornments(){let e=this.allPoints();if(!this.showPrices||e===z.EMPTY_ARRAY)return super.getPriceScaleAdornments();let t=this.traits.line,n=e.map(e=>({price:e.price,color:t.color})),r=this.line2();return P(r)&&(n[1].color=r.color),n}getFlipAnchorIndices(){return null}},OO=5,kO=class extends TD{helper;constructor(e,t,n){super(e,t),this.addPoints(n),this.helper=new gD(e)}get showTrendLine(){return this.traits[z.AT_SHOW_TRENDLINE]}get hasAllPoints(){return P(...this.points.map(e=>e.point))}get line2(){return this.traits[z.AT_LINE_2]}get extendLeft(){return this.traits[z.AT_EXTEND_LEFT]}get extendRight(){return this.traits[z.AT_EXTEND_RIGHT]}get reverse(){return this.traits[z.AT_REVERSE]}get levelsRespectLogScale(){return this.traits[z.AT_LEVELS_RESPECT_LOG_SCALE]}getStyleForElement(e,t){if(e.isTrend){let e=F(this.traits);return e.line=this.line2,ko(e)}return super.getStyleForElement(e,t)}getKeyPoints(){let e=e=>e.map(e=>this.points[e]);return this.isExtended?e(this.reverse?[1,0,2]:[0,1,2]):e(this.reverse?[0,1,0]:[1,0,1])}getElements(){if(!this.hasAllPoints)return[];let[e,t,n]=this.getKeyPoints(),r=t.price-e.price,i=t.price/e.price,a=this.extendLeft,o=this.extendRight,s=this.leftPoint,c=this.rightPoint,l=(e,t,n=!1)=>{let r=new SD(e,t,!n&&a,!n&&o,this.axis);return r.isTrend=n,r},u=this.levelsRespectLogScale&&this.axis.scale===S.Logarithmic,d=this.getColoredElements(({value:e})=>{let t=n.price+r*e,a=n.price*i**+e,o=u?a:t;this.helper.update(o,n.time);let d=this.helper.point.y;return l({x:s.x,y:d},{x:c.x,y:d})});return this.showTrendLine&&(d.push(l(e.point,t.point,!0)),this.isExtended&&d.push(l((this.reverse?e:t).point,n.point,!0))),d}getAdornPointAndAlign(e,t){let n=this.labels,r=(e,t,n)=>({pt:e,align:t,offset:n}),i=this.axis.pane.getBoundsWithoutScales();switch(n){case z.AT_LABELS_LEFT:return this.extendLeft?r({x:i.x,y:e.anchor1.y},T.Left,t):super.getAdornPointAndAlign(e,t);default:case z.AT_LABELS_RIGHT:return this.extendRight?r({x:i.x+i.width,y:e.anchor2.y},T.Right,-t):super.getAdornPointAndAlign(e,t);case z.AT_LABELS_CENTER:return super.getAdornPointAndAlign(e,t)}}getTextRef(){return(e,t,n)=>{let r=this.formatLevelPrice(n,t.anchor1.y);return{ref:t,spacing:OO,offsetY:-OO,text:r}}}adornElements(e,t){this.adornElementsForColoredFactors(e,(e,t)=>{let n=new Path2D;return e===null?n:(Va(n,e.p1),n.lineTo(t.p2.x,e.p1.y),Ha(n,t.p2),n.lineTo(e.p1.x,t.p2.y),n)},this.getTextRef(),t)}getPriceScaleAdornments(){if(!this.pricesOnScale)return super.getPriceScaleAdornments();let e=this.getElements();if(e.length===0)return super.getPriceScaleAdornments();let t=this.traits.line.color;return this.factors.map((n,r)=>{let i=e[r++].p1,a=this.singleStyle?t:n.line.color;return{price:this.axis.toPrice(i.y),color:a}})}},AO=class extends kO{constructor(e,t){super(e,t,2)}},jO=class extends kO{constructor(e,t){super(e,t,3)}},MO=5,NO=(e,t)=>{let n=new Path2D;return e===null?n:(Va(n,e.p1),Ha(n,e.p2),Ha(n,t.p2),n)},PO=class extends TD{constructor(e,t){super(e,t),this.addPoints(2)}get reverse(){return this.traits[z.AT_REVERSE]}getElements(){let[e,t]=this.getScreenPoints(),n=t.y-e.y;return this.getColoredElements(({value:r})=>{let i=this.reverse?e.y+r*n:t.y-r*n;return new SD(e,{x:t.x,y:i},!1,!0,this.axis)})}getTextRef(){let[e,t]=this.getScreenPoints(),n=t.y-e.y,[r,i]=[this.leftPoint,this.rightPoint];return(a,o,s)=>{let c=this.reverse?e.y+s*n:t.y-s*n;return{ref:new SD({x:r.x,y:c},{x:i.x,y:c},!1,!1,this.axis),spacing:MO,offsetY:!0,text:s.toString()}}}adornElements(e,t){this.adornElementsForColoredFactors(e,NO,this.getTextRef(),t)}},FO=class extends PO{constructor(e,t){super(e,t)}};function IO(e,t,n){return new RO(e,t,va(e,t),0,Math.PI,null,n)}function LO(e,t,n,r,i,a){return new RO(e,null,t,n,r,i,a)}var RO=class{left=null;right=null;scale=null;clip=null;style;constructor(e,t,n,r,i,a,o){this.center=e,this.rim=t,this.radius=n,this.startAngle=r,this.endAngle=i,this.antiClockwise=a,this.axis=o,t!==null&&(this.left={x:this.center.x-this.radius,y:this.center.y},this.right={x:this.center.x+this.radius,y:this.center.y})}get hasScale(){return this.scale!==null}get hasClip(){return this.clip!==null}get hasRim(){return this.rim!==null}applyScale(e){e.translate(this.center.x,this.center.y),e.scale(this.scale.x,this.scale.y),e.translate(-this.center.x,-this.center.y)}inverseScale(e){let t=new DOMPointReadOnly(e.x,e.y),n=this.axis.pane.presenter.view.mouseContext;n.save(),n.resetTransform(),this.applyScale(n);let r=n.getTransform().inverse();return n.restore(),r.transformPoint(t)}hitTest(e){let t=999;if(this.hasRim&&(this.center.y<this.rim.y&&e.y<=this.center.y||this.center.y>=this.rim.y&&e.y>=this.center.y))t=Math.min(va(this.left,e),va(this.right,e));else{let{x:n,y:r}=ya(this.hasScale?this.inverseScale(e):e,this.center);if(!this.hasRim){let{startAngle:e,endAngle:t,antiClockwise:i}=this,a=Math.PI/2;if(e===0&&t===a&&!i&&(n<0||r<0)||e===a&&t===Math.PI&&!i&&(n>0||r<0)||e===-a&&t===Math.PI&&i&&(n>0||r>0)||e===0&&t===-a&&i&&(n<0||r>0))return!1}t=Math.abs(Math.sqrt(n*n+r*r)-this.radius)}return t<=z.HIT_TEST_TOLERANCE}get isAntiClockwise(){return this.hasRim?this.rim.y<=this.center.y:this.antiClockwise}draw(e){e.save(),this.hasClip&&e.clip(this.clip),this.hasScale&&this.applyScale(e),Za(e,this.center,this.radius,this.startAngle,this.endAngle,this.isAntiClockwise??!1),e.restore()}},zO=(e,t)=>{let n=new Path2D,{center:r}=t;if(Va(n,r),n.arc(r.x,r.y,t.radius,t.startAngle,t.endAngle,t.isAntiClockwise??!1),e===null)return n;let i=new Path2D,{center:a}=e;return Va(i,a),i.arc(a.x,a.y,e.radius,e.endAngle,e.startAngle,!e.isAntiClockwise),n.addPath(i),n},BO=class extends TD{constructor(e,t){super(e,t),this.addPoints(2)}getElements(){let[e,t]=this.getScreenPoints();if(!P(e,t))return[];let n=va(e,t),r=ya(t,e),i=r.y/n,a=r.x/n,o=this.getColoredElements(({value:t})=>{let r=n*t,o=i*r,s=a*r;return IO(e,{x:e.x+s,y:e.y+o},this.axis)});if(this.showTrendLine){let n=new SD(e,t,!1,!1,this.axis);n.isTrend=!0,o.unshift(n)}return o}get showTrendLine(){return!0}getTextRef(){return(e,t,n)=>{let{center:r}=t,i=t.isAntiClockwise?-1:1;return{ref:{x:r.x,y:r.y+i*t.radius},spacing:0,offsetY:!0,text:n.toString()}}}adornElements(e,t){this.adornElementsForColoredFactors(e,zO,this.getTextRef(),t)}},VO=class extends BO{constructor(e,t){super(e,t)}getStyleForElement(e,t){if(e.isTrend){let e=F(this.traits);return e.line=this.line2,ko(e)}return super.getStyleForElement(e,t)}get showTrendLine(){return this.traits[z.AT_SHOW_TRENDLINE]}get line2(){return this.traits[z.AT_LINE_2]}},HO=class extends TD{constructor(e,t){super(e,t),this.addPoints(2)}get factorsPropName(){return z.AT_ANGLES}getElements(){let[e,t]=this.getScreenPoints(),{x:n,y:r}=ya(t,e);return this.getColoredElements(({value:i})=>{let a=(t,n)=>new SD(e,{x:t,y:n},!1,!0,this.axis),o=i.charAt(0)!==`1`,s=Number(o?i.charAt(0):i.charAt(2));return o?a(t.x,e.y+r/s):a(e.x+n/s,t.y)})}getTextRef(){return(e,t,n)=>({ref:t.anchor2,spacing:0,offsetY:!0,text:n.toString()})}adornElements(e,t){this.adornElementsForColoredFactors(e,NO,this.getTextRef(),t)}},UO=class extends PO{constructor(e,t){super(e,t),this._factors=[{shown:!0,value:1/3},{shown:!0,value:2/3}]}getElements(){let[e,t]=this.getScreenPoints();return[new SD(e,t,!1,!1,this.axis)].concat(super.getElements())}},WO=class extends BO{constructor(e,t){super(e,t),this._factors=[{shown:!0,value:1/3},{shown:!0,value:2/3}]}},GO=class extends wD{constructor(e,t){super(e,t),this.addPoints(3)}getElements(){let e=this.points[0].point,t=this.points[1].point,n=this.points[2].point,r=(t.x+n.x)/2-e.x,i=(t.y+n.y)/2-e.y,a=[];return a.push(new SD(t,{x:t.x+r,y:t.y+i},!1,!0,this.axis)),a.push(new SD(e,{x:e.x+r,y:e.y+i},!1,!0,this.axis)),a.push(new SD(n,{x:n.x+r,y:n.y+i},!1,!0,this.axis)),a.push(new SD(t,n,!1,!1,this.axis)),a}},KO=class extends AD{constructor(e,t){super(e,t)}getEllipse(){let e=this.getRect();return e===null?null:new Ba(e.centerX,e.centerY,e.width/2,e.height/2)}hitTest(e){if(!this.visible)return!1;let t=this.getEllipse();return t===null?!1:t.contains(e)}draw(e,t){return super.draw(e,t)?(Ya(e,this.getEllipse()),!0):!1}},qO=class extends wD{constructor(e,t){super(e,t),this.addPoints(3)}get extend1(){return this.traits[z.AT_EXTEND_PT_1]}get extend2(){return this.traits[z.AT_EXTEND_PT_2]}getLastPoint(){let[e,t,n]=this.points;var r=va(e.point,t.point),i=xa(e.point,t.point);return{x:n.point.x+r*Math.cos(i),y:n.point.y+r*Math.sin(i)}}getElements(){let[e,t,n]=this.points;var r=[];if(r.push(new SD(e.point,t.point,this.extend1,this.extend2,this.axis)),P(n?.price)){var i=this.getLastPoint();r.push(new SD(n.point,i,this.extend1,this.extend2,this.axis))}return r}},JO=class extends AD{constructor(e,t,n){super(e,t),this.kind=n,this.adjustFill=!0}hitTest(e){if(!this.visible)return!1;let t=this.getRect();return t===null?!1:t.contains(e)}get dimension(){let e=this.kind===`fish_hook`?2:1;return z.DEFAULT_SYMBOL_WIDTH_HEIGHT*e}updateOtherPoints(){this.points[1].price||this.setBottomRight()}setBottomRight(){let e=this.dimension,t=this.axis.pane.presenter.timeline,{price:n,time:r}=this.points[0],i=Te(t,r,Number,__);if(i!==-1){let r=this.axis.pane.presenter.view.xAxis.xScale.bar.totalWidth,a=1;for(;(2*a+1)*r<e;)a++;this.points[0].update(n,t.at(i-a)),this.points[1].update(n,t.at(i+a));let o=ba(this.points[0].point,{x:0,y:-e/2}),s=ba(this.points[1].point,{x:0,y:e/2});this.points[0].updateFromPoint(o),this.points[1].updateFromPoint(s)}}draw(e,t){if(!super.draw(e,t))return!1;let n=this.getRect();return n.width===0&&(n.width=this.dimension),no(e,this.kind,n),!0}},YO=class extends TD{helper;constructor(e,t){super(e,t),this.addPoints(2),this.helper=new gD(e)}getElements(){let e=this.axis.pane.presenter.timeline,{price:t,time:n}=this.points[0],r=Te(e,n,Number,__),i=Te(e,this.points[1].time,Number,__),a=i-r;return r===-1||i===-1?[]:this.getColoredElements(({value:n})=>{let i=e.at(r+n*a);return i===null?null:(this.helper.update(t,i),new hD(this.helper.point,!0,this.axis))})}getTextRef(){return(e,t,n)=>({ref:t.anchor,spacing:3,offsetY:!0,text:n.toString()})}adornElements(e,t){let n=this.axis.pane.getBoundsWithoutScales();this.adornElementsForColoredFactors(e,(e,t)=>{let r=new Path2D;if(e===null)return r;let i=t.anchor.x-e.anchor.x;return r.rect(e.anchor.x,n.y,i,n.height),r},this.getTextRef(),t)}getTimeScaleAdornments(){let e=e=>({time:this.points[e].time,color:this.traits.line.color});return[e(0),e(1)]}},XO=class{snapToSupported=!0;isDrawingAnnotation=!0;constructor(){}onMouseMove(e){let{point:t,view:n,offset:r}=e;n.drawCrosshair({ap:t,offset:r})}onMouseDown(e){if(Ie()&&e.originalEvent instanceof TouchEvent)return;let{point:t}=e;if(!t?.axis?.pane?.presenter||!t.time)return;let n=t.axis.pane.presenter,r={chart:n.accessor,axis:t.axis,point:{time:t.time.getTime(),price:t.price}};n.notifyHost(G.CH_ANNPOINTPICKED,r),Ok(n,void 0)}},ZO={Open:`Open`,Closed:`Closed`};function QO(e){let t=e?.minMovement;if(!Number.isFinite(t)||t<=0)return z.MIN_POSITION_PRICE_PRECISION;let[n,r=`0`]=t.toString().toLowerCase().split(`e`),i=(n.includes(`.`)?n.split(`.`)[1].length:0)+Math.max(0,-Number.parseInt(r,10));return Math.max(z.MIN_POSITION_PRICE_PRECISION,i)}function $O(e){let t=e?.pointValue;return Number.isFinite(t)?t:1}var ek=class extends wD{twoDecMeta;_dataWindow;_metaData;isHit=!1;constructor(e,t,n){super(e,t),this.isLong=n,this.addPoints(4);let r=(e,t)=>this.points[e].moveDirection=t;r(1,te.Vertical),r(2,te.Vertical),r(3,te.Horizontal),this.twoDecMeta=new ia(2)}data(e){return this.presenter.mainPlot.timeSeries.container.getData(e)}get presenter(){return this.axis.pane.presenter}get metaData(){return this._metaData||=this.presenter.mainPlot.metaData,this._metaData}getDataWindow(e,t,n=!0,r=!0){let i=this.data(W.DateTime),a=Te(i,+e,Number),o=Te(i,+t,Number),s={refIndex:-1,highestIndex:-1,lowestIndex:-1,highest:null,lowest:null,data:[]},[c,l,u]=[W.High,W.Low,W.Close].map(e=>this.data(e)),d=e=>e-a;for(let e=a;e<=o;e++)n&&s.refIndex===-1&&P(this.entryPrice)&&this.entryPrice>=l[e]&&this.entryPrice<=c[e]&&(s.refIndex=d(e)),(!n||s.refIndex>=0&&d(e)>=s.refIndex)&&((!P(s.highest)||c[e]>s.highest)&&(s.highest=c[e]),(!P(s.lowest)||l[e]<s.lowest)&&(s.lowest=l[e])),n&&s.refIndex!==-1&&(s.highestIndex===-1&&c[e]>this.upperPrice&&(s.highestIndex=d(e)),s.lowestIndex===-1&&l[e]<this.lowerPrice&&(s.lowestIndex=d(e))),r&&s.data.push({high:c[e],low:l[e],close:u[e],time:i[e]});if(r&&s.data&&s.data.length>0){s.state=P(s.highest,s.lowest)&&(this.upperPrice<s.highest||this.lowerPrice>s.lowest)?ZO.Closed:ZO.Open,s.special=s.highestIndex===-1&&s.lowestIndex===-1||s.highestIndex===s.lowestIndex;let e=xe(s.data);if(s.toPrice=e.close,s.toTime=e.time,s.state===ZO.Closed)if(s.special)s.refIndex!==-1&&(s.toTime=s.data[s.refIndex].time,s.toPrice=(this.isLong?this.lowerPrice<s.lowest:this.upperPrice<s.highest)?this.upperPrice:this.lowerPrice);else{let e=s.highestIndex!==-1&&s.lowestIndex!==-1;e&&s.highestIndex<s.lowestIndex||s.lowestIndex===-1?(s.toPrice=this.upperPrice,s.toTime=s.data[s.highestIndex].time):(e&&s.lowestIndex<s.highestIndex||s.highestIndex===-1)&&(s.toPrice=this.lowerPrice,s.toTime=s.data[s.lowestIndex].time)}let t=this.isLong?s.toPrice-this.entryPrice:this.entryPrice-s.toPrice;s.pAndL=this.roundPriceDelta(t)}return s}get dataWindow(){return P(this._dataWindow)||(this._dataWindow=this.getDataWindow(this.entryAnchor.time,this.exitAnchor.time)),this._dataWindow}getVisiblePriceRange(){let e=this.axis.yScale.domain();return e[1]-e[0]}getFutureTimestamp(){let e=this.axis.pane.presenter.timeline,t=Te(e,+this.points[0].time,Number,__);if(!Number.isFinite(t)||t<0)return Date.now();let n=Math.min(e.length-1,t+50),r=e.at(n);return P(r)?r.getTime():Date.now()}get entryPrice(){return this.entryAnchor.price}get entryAnchor(){return this.points[0]}get upperPrice(){return this.upperAnchor.price}get upperAnchor(){return this.points[1]}get lowerPrice(){return this.lowerAnchor.price}get lowerAnchor(){return this.points[2]}get exitAnchor(){return this.points[3]}get accountSize(){return this.traits[z.AT_ACCOUNT_SIZE]}get risk(){let e=this.traits[z.AT_RISK_IS_PERCENT],t=this.traits[z.AT_RISK];return Xe(e?t/100*this.accountSize:t,2)}get pricePrecision(){return QO(this.metaData)}get pointValue(){return $O(this.metaData)}roundPriceDelta(e){return Xe(e,this.pricePrecision)}formatDollarValue(e){return Number.isFinite(e)?`${e<0?`-`:``}$${this.twoDecMeta.format(Math.abs(e))}`:z.NOT_APPLICABLE}formatRatioValue(e){return Number.isFinite(e)?e.toFixed(2):z.NOT_APPLICABLE}formatQuantityValue(e){return Number.isFinite(e)?`${e}`:z.NOT_APPLICABLE}formatPercentChange(e){return Number.isFinite(e)?`(${Xe(e,2).toFixed(2)}%)`:`(${z.NOT_APPLICABLE})`}get qty(){let e=this.isLong?this.entryPrice-this.lowerPrice:this.upperPrice-this.entryPrice;return!Number.isFinite(e)||e<=0?NaN:Math.floor(this.risk/e)}get upperDiff(){return this.roundPriceDelta(this.upperPrice-this.entryPrice)}get amountMultiplier(){return this.isLong?1:-1}get upperAmount(){return Xe(this.accountSize+this.amountMultiplier*this.qty*this.upperDiff,2)}get upperPandL(){return Xe(this.amountMultiplier*this.upperDiff*this.pointValue,2)}get isCompact(){return this.traits[z.AT_COMPACT]}get upper(){let e=l_(this.axis,this.priceMap(this.upperPrice)),t=this.formatPercentChange(this.upperDiff/this.entryPrice*100);return this.isCompact,`${e} ${t}`}get upperText(){let e=`${this.formatDollarValue(this.upperPandL)}`,t=`${this.formatDollarValue(this.upperAmount)}`,n=this.isLong?`Target`:`Stop`;return this.isCompact?`${this.upper} ${e}`:`${n}: ${this.upper}, P&L: ${e}, Amount: ${t}`}get lowerDiff(){return this.roundPriceDelta(this.entryPrice-this.lowerPrice)}get lowerAmount(){return Xe(this.accountSize-this.amountMultiplier*this.qty*this.lowerDiff,2)}get lowerPandL(){return Xe(-this.amountMultiplier*this.lowerDiff*this.pointValue,2)}get lower(){let e=l_(this.axis,this.priceMap(this.lowerPrice)),t=this.formatPercentChange(this.lowerDiff/this.entryPrice*100);return this.isCompact,`${e} ${t}`}get lowerText(){let e=`${this.formatDollarValue(this.lowerPandL)}`,t=`${this.formatDollarValue(this.lowerAmount)}`,n=this.isLong?`Stop`:`Target`;return this.isCompact?`${this.lower} ${e}`:`${n}: ${this.lower}, P&L: ${e}, Amount: ${t}`}get riskReward(){let e=this.isLong?this.upperDiff:this.lowerDiff,t=this.isLong?this.lowerDiff:this.upperDiff;return!Number.isFinite(t)||t===0?NaN:Xe(e/t,2)}get state(){return this.dataWindow.state}get pAndL(){return this.dataWindow.pAndL}get pAndLValue(){return this.pAndL*this.pointValue}positionPoints(){let e=this.getVisiblePriceRange()/5,t=this.getFutureTimestamp();this.upperAnchor.update(this.entryPrice+e,this.entryAnchor.time),this.lowerAnchor.update(this.entryPrice-e,this.entryAnchor.time),this.exitAnchor.update(this.entryPrice,t)}get lowerStyle(){return this.fillOnlyStyle(z.AT_FILL2)}get upperStyle(){return this.fillOnlyStyle(z.AT_FILL)}get textStyle(){return this.fillOnlyStyle(z.AT_FILL_TEXT)}get secondaryLineStyle(){return ko({line:{color:this.traits.line.color,dashStyle:`ShortDash`},fill:{color:z.COLOR_TRANSPARENT}})}wasModifiedByTool(){P(this.points[2].price)||this.positionPoints(),this._dataWindow=void 0}wasPointMovedByTool(e,t){let n=this.getVisiblePriceRange()/5e3;if(this.points.indexOf(e)<3){let t=t=>e.update(t,e.time);this.entryAnchor.price>this.upperAnchor.price&&(e===this.entryAnchor?t(this.upperAnchor.price-n):t(this.entryAnchor.price+n)),this.entryAnchor.price<this.lowerAnchor.price&&(e===this.entryAnchor?t(this.lowerAnchor.price+n):t(this.entryAnchor.price-n))}if(e===this.entryAnchor){let t=(t,n,r)=>t.update(n?e.price:t.price,r?e.time:t.time);t(this.exitAnchor,!0,!1),t(this.upperAnchor,!1,!0),t(this.lowerAnchor,!1,!0)}this.wasModifiedByTool()}get isUpperPerPAndL(){let e=this.dataWindow;return Number.isFinite(e.pAndL)?this.isLong?e.pAndL>0:e.pAndL<=0:!0}getStyleForElement(e,t){return e.style||this.defaultStyle}getElements(){let e=new SD(this.entryAnchor.point,this.exitAnchor.point,!1,!1,this.axis),t=this.exitAnchor.point.x<this.entryAnchor.point.x,n=Math.abs(this.exitAnchor.point.x-this.entryAnchor.point.x),r=(e,t)=>({x:e.x+t,y:e.y}),i=new CD(r(this.upperAnchor.point,t?-n:0),n,Math.abs(this.upperAnchor.point.y-this.entryAnchor.point.y),this.axis);i.style=this.upperStyle;let a=new CD(r(this.entryAnchor.point,t?-n:0),n,Math.abs(this.entryAnchor.point.y-this.lowerAnchor.point.y),this.axis);a.style=this.lowerStyle;let o=[e,i,a],s=this.dataWindow;if(s.refIndex!==-1){let e=s.data[s.refIndex],t=new gD(this.axis,this.entryPrice,e.time),n=new gD(this.axis,s.toPrice,s.toTime),r=new SD(t.point,n.point,!1,!1,this.axis);if(r.style=this.secondaryLineStyle,o.push(r),t.time!==n.time){let e=this.entryPrice<s.toPrice,r=new CD({x:t.point.x,y:Math.min(t.point.y,n.point.y)},n.point.x-t.point.x,Math.abs(n.point.y-t.point.y),this.axis);r.style=e?this.upperStyle:this.lowerStyle,o.push(r)}}return o}hitTest(e){if(!this.visible)return!1;let t=this.isHit||!1;return this.isHit=super.hitTest(e),this.isHit!==t&&this.requestRedraw(),this.isHit}get showTextAdornments(){return this.isHit||this.isSelected}getPriceScaleAdornments(){let e=e=>wa(this.traits[e].color);return[{price:this.upperPrice,color:e(z.AT_FILL)},{price:this.entryPrice,color:e(z.AT_LINE)},{price:this.lowerPrice,color:e(z.AT_FILL2)}]}adornElements(e,t){let[n,r,i]=e;if(this.showTextAdornments){let[e,a]=[!0,!1].map(e=>Ga(t,e)),{x:o,y:s,width:c}=r.rect,l={x:o+c/2,y:s+e},u=this.textStyle.fillStyle;Ja(t,this.upperText,l,T.Center,u,wa(this.upperStyle.fillStyle));let{x:d,y:f,width:p,height:m}=i.rect,h={x:d+p/2,y:f+m+Math.abs(a)};Ja(t,this.lowerText,h,T.Center,u,wa(this.lowerStyle.fillStyle));let{p1:g,p2:_}=n,{x:v,y}=g,{x:b}=_,x=this.state||z.NOT_APPLICABLE,S=this.isCompact?`${this.formatDollarValue(this.pAndLValue)}`:`${x} P&L: ${this.formatDollarValue(this.pAndLValue)}, Qty: ${this.formatQuantityValue(this.qty)}`,C=this.isCompact?`${this.formatRatioValue(this.riskReward)}`:`Risk/Reward Ratio: ${this.formatRatioValue(this.riskReward)}`,w=e=>t.measureText(e).width,ee=Math.max(w(S),w(C)),E=Math.abs(b-v)<ee*1.25?y+Math.abs(a)+5:y+e+10,D={x:v+(b-v)/2,y:E},te=wa(this.isUpperPerPAndL?this.upperStyle.fillStyle:this.lowerStyle.fillStyle);Ja(t,[S,C],D,T.Center,u,te)}}updatePoints(e){super.updatePoints(e),this.wasModifiedByTool()}},tk=class extends ED{markers;display=null;constructor(e,t){super(e,t),this.points=kD(e),this.points[2].visible=!1,this.points[3].visible=!1,this.markers=[new CO]}isPointDrawn(e){return super.isPointDrawn(e)?e.visible:!1}makeLineArrow(e,t,n,r){let i=[ga(e,t),ga(n,r)];return[this.makeLine(i[0],i[1]),xO(i,`end`,10)]}get rectColor(){return this.traits[z.AT_FILL].color}get textColor(){return this.traits[z.AT_FILL_TEXT].color}getMarkers(){return this.markers}getScreenPoints(){return this.points.slice(2).forEach(e=>e.toPoint()),super.getScreenPoints()}formatDateDifference(e,t){return this.presenter.data.aggregation.isEndOfDay?`${sn(t,e)}d`:br(Tr({start:e,end:t}),{format:[`days`,`hours`,`minutes`,`seconds`]}).replaceAll(/(days?)|(hours?)|(minutes?)|(seconds?)/g,e=>e[0])}computeState(){}get text(){return this.display===null&&this.computeState(),this.display}getTextCoord(e,t){let n=this.points[0].price<this.points[1].price,r=Ga(t,n,this.text.length),{x:i,y:a,width:o,height:s}=e.rect;return{x:i+o/2,y:a+(n?0:s)+(n?r:Math.abs(r))}}adornElements(e,t){Ja(t,this.text,this.getTextCoord(e[0],t),T.Center,this.textColor,wa(this.rectColor))}getDateDifference(){let[e,t]=this.points.slice(0,2).map(e=>e.time);if(!e||!t)return[`0 bars, `,`Vol ${this.formatter.format(0,W.Volume)}`];let n=Math.min(+e,+t),r=Math.max(+e,+t),i=this.data(W.DateTime);if(!i||i.length===0)return[`0 bars, `,`Vol ${this.formatter.format(0,W.Volume)}`];let a=Te(i,+n,Number),o=Te(i,+r,Number),s=this.data(W.Volume);if(!Array.isArray(s))return[`0 bars, `,`Vol ${this.formatter.format(0,W.Volume)}`];let c=pe(s.slice(a,o+1)),l=this.formatter.format(c,W.Volume),u=o-a,d=u===0?``:this.formatDateDifference(n,r),f=e<t?``:`-`;return[`${f}${u} bars, ${f}${d}`,`Vol ${l}`]}getPriceDifference(){let[e,t]=this.points.slice(0,2).map(e=>e.price),n=t-e,r=n/e;return[`${this.formatter.format(n,W.Close)} (${this.formatter.format(r,W.PercentChange)})`]}resetComputedState(){this.display=null}getFlipAnchorIndices(){return[0,1]}},nk=class extends tk{getElements(){let[e,t,n,r]=this.getScreenPoints(),i=this.makeLine(e,r),a=this.makeLine(t,n),[o,s]=this.makeLineArrow(e,r,t,n);return this.markers[0]=s,[this.rect,i,a,o]}computeState(){this.display=this.getDateDifference()}},rk=class extends tk{getElements(){let[e,t,n,r]=this.getScreenPoints(),i=this.makeLine(e,n),a=this.makeLine(t,r),[o,s]=this.makeLineArrow(e,n,t,r);return this.markers[0]=s,[this.rect,i,a,o]}computeState(){this.display=this.getPriceDifference()}},ik=class extends tk{get drawBorder(){return this.traits[z.AT_DRAW_BORDER]}getBorderElements(){if(!this.drawBorder)return[];let[e,t,n,r]=this.getScreenPoints();return[this.makeLine(e,r),this.makeLine(t,n),this.makeLine(e,n),this.makeLine(t,r)]}getElements(){let[e,t,n,r]=this.getScreenPoints(),[i,a]=this.makeLineArrow(e,r,t,n),[o,s]=this.makeLineArrow(e,n,t,r);this.markers=[a,s];let c=this.getBorderElements();return[this.rect,i,o].concat(c)}computeState(){this.display=this.getPriceDifference().concat(this.getDateDifference())}},ak=class extends ED{constructor(e,t){super(e,t),this.points=kD(e)}get priceLevels(){return So(this.traits[z.AT_PRICE_LEVELS])}get timeLevels(){return So(this.traits[z.AT_TIME_LEVELS])}get showAngles(){return this.traits[z.AT_SHOW_ANGLES]}get reverse(){return this.traits[z.AT_REVERSE]}get showLeftLabels(){return this.traits[z.AT_SHOW_LEFT_LABELS]}get showRightLabels(){return this.traits[z.AT_SHOW_RIGHT_LABELS]}get showTopLabels(){return this.traits[z.AT_SHOW_TOP_LABELS]}get showBottomLabels(){return this.traits[z.AT_SHOW_BOTTOM_LABELS]}getAngles(e,t){let n=this.getScreenPoints(),r=this.lineOnlyStyle(z.AT_LINE_2),i=(e,t)=>e.x===t.x&&e.y===t.y,a=(e,t)=>e.x===t.x||e.y===t.y,o=[];e.concat(t).flatMap(e=>[e.p1,e.p2]).map(e=>{o.some(t=>i(e,t))||o.push(e)});let s=n.map(e=>o.filter(t=>!a(t,e)).map(t=>this.makeLine(e,t))).flat();return s.forEach(e=>e.style=r),s}getElements(){let e=this.getLinesDataAtLevels(this.priceLevels,this.timeLevels),{priceLines:t,timeLines:n}=this.getLineElements(e),r=this.showAngles?this.getAngles(t,n):[];return[...t,...n,...r]}adornElements(e,t){let n=this.singleStyle,r=this.showBackground,i=t.fillStyle,a=Wa(t,1)/2,o=e=>Number(e.toFixed(4)).toString(),{x:s,y:c}=z.DEFAULT_ADORN_OFFSET,l=(e,n,r,i,a)=>{let s=ba(e,n);Ja(t,o(r),s,i,a)},u=(e,n)=>{let r=new Path2D;Ua(r,e.p1,n.p2),t.fillStyle=n.style.fillStyle,t.fill(r)},d=null;if(e.forEach(e=>{if(!e._data)return;let{level:t,isPrice:o}=e._data,f=n?i:e.style.strokeStyle,p=d&&r&&!n;o?(this.showLeftLabels&&l(e.p1,{x:s,y:a},t,T.Right,f),this.showRightLabels&&l(e.p2,{x:-s,y:a},t,T.Left,f),p&&u(d,e)):(this.showTopLabels&&l(e.p1,{x:0,y:c},t,T.Center,f),this.showBottomLabels&&l(e.p2,{x:0,y:-c*2},t,T.Center,f),p&&u(d,e)),d=e}),n&&r){let e=this.applyBackgroundOpacity(this.traits.line.color),n=new Path2D,[r,i]=this.getScreenPoints();Ua(n,r,i),t.fillStyle=e,t.fill(n)}}resetComputedState(){this.lines=void 0}updateFrom(e,t,n,r,i){let a=e.reverse!==this.reverse;super.updateFrom(e,t,n,r,i),a&&this.resetComputedState()}getFlipAnchorIndices(){return[0,1]}},ok=e=>e.map(e=>({...e,dimensions:e.value.split(`x`).map(Number)})),sk=5,ck=(e,t)=>Math.abs(e-t)<1e-7,lk=class extends ED{_parsedFans=null;_parsedArcs=null;constructor(e,t){super(e,t),this.points=kD(e),this._parsedFans=this._parsedArcs=null}get levels(){return So(this.traits[z.AT_LEVELS])}setComputedAndTraits(e,t){let n={...e,computed:t,traits:this.getTraitsFor(e)};return delete n.line,n}get computedLevels(){return this.levels.map(e=>this.setComputedAndTraits(e,e.value/sk))}get showRangesRatio(){return this.traits[z.AT_SHOW_RANGES_RATIO]}get arcs(){return So(this.traits[z.AT_ARCS])}get fans(){return So(this.traits[z.AT_FANS])}get reverse(){return this.traits[z.AT_REVERSE]}get parsedFans(){return this._parsedFans===null&&(this._parsedFans=ok(this.fans)),this._parsedFans}get computedFans(){let[,,e,t]=this.getReversedScreenPoints(),{dx:n,dy:r}=this.unit,{signX:i,signY:a}=this.getOrientation();return this.parsedFans.map(o=>{let[s,c]=o.dimensions;return this.setComputedAndTraits(o,s>=c?{x:e.x,y:e.y+c/s*a*sk*r}:{x:t.x+s/c*sk*i*n,y:t.y})})}get parsedArcs(){return this._parsedArcs===null&&(this._parsedArcs=ok(this.arcs)),this._parsedArcs}get computedArcs(){let{dx:e}=this.unit;return this.parsedArcs.map(t=>{let[n,r]=t.dimensions;return this.setComputedAndTraits(t,Math.sqrt(e**2*(n**2+r**2)))})}getReversedScreenPoints(){let[e,t,n,r]=this.getScreenPoints();return this.reverse?[t,e,r,n]:[e,t,n,r]}get unit(){let[e,t]=this.getReversedScreenPoints();return e.x!==t.x&&e.y!==t.y?{dx:Math.abs(t.x-e.x)/sk,dy:Math.abs(t.y-e.y)/sk}:null}get priceBarRatio(){return this.traits[z.AT_PRICE_BAR_RATIO]}set priceBarRatio(e){this.traits[z.AT_PRICE_BAR_RATIO]=e}makeStyledLine(e,t,n){let r=this.makeLine(e,t);return this.singleStyle||(r.style=ko(n)),r}getGridLines(e,t){let n=t.x-e.x,r=t.y-e.y;return this.computedLevels.map(({computed:i,traits:a})=>{let o=e.x+i*n,s=e.y+i*r;return[this.makeStyledLine({x:o,y:e.y},{x:o,y:t.y},a),this.makeStyledLine({x:e.x,y:s},{x:t.x,y:s},a)]}).flat()}getArcs(e){let{flipX:t,flipY:n,signY:r}=this.getOrientation(),{dx:i,dy:a}=this.unit,o=ck(i,a)?null:{x:1,y:a/i},s=this.getClipPath();return this.computedArcs.map(({computed:i,traits:a})=>{let c=LO(e,i,t?r*Math.PI/2:0,t?Math.PI:r*Math.PI/2,n,this.axis);return o!==null&&(c.scale=o),c.clip=s,this.singleStyle||(c.style=ko(a)),c})}getFans(e){return this.computedFans.map(({computed:t,traits:n})=>this.makeStyledLine(e,t,n))}getElements(){if(this.unit===null)return[];let[e,t]=this.getReversedScreenPoints(),n=this.getGridLines(e,t),r=this.getArcs(e),i=this.getFans(e);return[...n,...r,...i]}getOrientation(){let[e,t]=this.getReversedScreenPoints(),n=t.x<e.x,r=t.y<e.y;return{flipX:n,signX:n?-1:1,flipY:r,signY:r?-1:1}}getClipPath(){let[e,t]=this.getReversedScreenPoints(),n=new Path2D;return Ua(n,e,t),n}adornElements(e,t){if(e.length===0)return;let n=(e,n,r)=>{t.fillStyle=r;let i=n.hasScale;i&&(t.save(),n.applyScale(t)),t.fill(e),i&&t.restore()};if(this.showBackground){let r=e.filter(e=>e.radius),i=this.getClipPath();if(t.save(),t.clip(i),this.singleStyle){let e=xe(r);n(zO(null,e),e,this.applyBackgroundOpacity(this.traits.line.color))}else{let e=null;r.forEach(t=>{let r=zO(e,t),i=t.style.fillStyle;n(r,t,i),e=t})}t.restore()}if(this.showRangesRatio&&this.unit!==null){let e=xe(this.computedLevels),n=(this.singleStyle?this:e).traits.line.color,[,r,i,a]=this.getReversedScreenPoints(),{x:o,y:s}=z.DEFAULT_ADORN_OFFSET,{flipX:c,signX:l,signY:u}=this.getOrientation(),d=ba(i,{x:-o*l,y:s*u}),{priceDiff:f,barsDiff:p}=this.getLinesDataAtLevels(null,null),m=c?T.Right:T.Left;Ja(t,p.toFixed(0),d,m,n);let h=ba(a,{x:o*2*l,y:-s*u}),g=c?T.Left:T.Right;Ja(t,this.formatter.format(f,W.Close),h,g,n);let _=ba(r,{x:-o*l,y:-s*u});Ja(t,this.priceBarRatio.toFixed(6),_,m,n)}}resetComputedState(){if(this.lines=void 0,this.points.length===4&&this.unit!==null){let{priceDiff:e,barsDiff:t}=this.getLinesDataAtLevels(null,null);this.priceBarRatio=Math.abs(e/t)}}updateFrom(e,t,n,r,i){if(super.updateFrom(e,t,n,r,i),this._parsedFans=this._parsedArcs=null,!ck(e.priceBarRatio,this.priceBarRatio)){let[t,n,,]=this.points;this.reverse&&([t,n]=[n,t]);let{priceDiff:r,barsDiff:i}=this.getLinesDataAtLevels(null,null);n.update(t.price+Math.sign(r)*e.priceBarRatio*i,n.time),this.resetComputedState()}}getFlipAnchorIndices(){return[0,1]}},uk=5,dk=(e,t)=>{let n=new Path2D;return e===null?n:(Va(n,e.p1),Ha(n,e.p2),Ha(n,t.p2),Ha(n,t.p1),n)},fk=class extends TD{constructor(e,t){super(e,t),this.addPoints(3)}get extend1(){return this.traits[z.AT_EXTEND_PT_1]}get extend2(){return this.traits[z.AT_EXTEND_PT_2]}getElements(){let[e,t,n]=this.getScreenPoints(),{x:r,y:i}=ya(n,e),a=n=>{let[r,i]=[e,t].map(e=>ba(e,n));return new SD(r,i,this.extend1,this.extend2,this.axis)};return this.getColoredElements(({value:e})=>a({x:r*e,y:i*e}))}getTextRef(){return(e,t,n)=>({ref:t,spacing:uk,offsetY:!0,text:this.formatLevelPrice(n,t.anchor1.y)})}adornElements(e,t){this.adornElementsForColoredFactors(e,dk,this.getTextRef(),t)}},pk=class extends wD{levelSize=0;alignLeft=!0;totalVolume=!1;widthPercent=30;useChange=!1;studyPlotId;gotData;boxes=[];periodType=`VisibleScreen`;period=0;valueRangePercent=.7;levelMode=`Count`;usesFinerGrainedAgg=!0;constructor(e,t,n){super(e,t),this.computed=!0,this.studyPlotId=n,this.gotData=!1}setOptions(e){switch(this.levelMode=e.LevelMode,this.levelSize=xt(1,1e3,e.LevelSize),this.alignLeft=e.Position===`Left`,this.totalVolume=e.Volume===`Total`,this.widthPercent=xt(5,100,e.WidthPercent)/100,e.BarColoring){case`OpenToClose`:this.useChange=!1;break;case`CloseToClose`:this.useChange=!0;break;default:this.useChange=(this.presenter.mainPlot?.mainCurve?.attributes)?.includes(m.ChangeBased)??!1}N(e.PeriodType)&&(this.periodType=e.PeriodType),this.period=e.Period,this.valueRangePercent=e.ValueRangePercent/100;let t=ne[$()?.config.mode??`Unspecified`];this.usesFinerGrainedAgg=bs(t)}get isCountMode(){return this.levelMode===`Count`}updateLastBox(){if(this.boxes.length>0){let e=this.boxes.pop(),t=this.getDataForRange(e.firstDate,e.lastDate);t&&this.boxes.push(t)}}invalidate(e){switch(this.periodType){case`VisibleScreen`:this.gotData=!1,this.boxes=[];break;case`Bars`:case`Days`:switch(e){case`DataPointAdded`:{let e=this.studySeries.innCont(0)?.getTimeData();if(!P(e))return;let t=e[e.length-1],n=this.boxes.length>0?this.boxes[this.boxes.length-1]:null;if(N(n)&&t.valueOf()<n.lastDate.valueOf())this.updateLastBox();else{let e=this.getDataForRange(t,this.getBoxEndFromStart(t));e&&this.boxes.push(e)}break}case`DataPointChanged`:this.updateLastBox();break;case`NewChunkArrived`:this.gotData=!1;break}break}}getBoxRect(e){switch(this.periodType){case`VisibleScreen`:return this.axis.pane.getBoundsWithoutScales();case`Bars`:case`Days`:{let t=this.axis.pane.presenter.view.xAxis.xScale.bar,n=this.axis.toY(e.min),r=this.axis.toY(e.max),i=this.axis.pane.presenter.view.toX(e.firstDate)-t.width/2,a=0;if(this.periodType===`Days`){let n=e.lastDate,r=this.axis.pane.presenter.view.xAxis.xScale.timeline,o=r.at(r.lastSeriesIndex),s=o.valueOf()<n.valueOf(),c=s?o:n,l=(s?1:-2)*t.width/2;a=this.axis.pane.presenter.view.toX(c)+l-i}else a=this.period*t.width+(this.period-1)*t.spacing;return new za(i,r,a,n-r)}default:throw Error(`Unexpected period type for Volume At Price annotation`)}}getElementsForBox(e){let t=this.getBoxRect(e),n=[];if(this.isPeriodic){let e=new CD({x:t.x,y:t.y},t.width,t.height,this.axis);e.style=this.backgroundStyle,n.push(e)}let{x:r,width:i}=t,a=i*this.widthPercent,o=e.bars[e.maxVolumeIndex];return e.bars.forEach((t,s)=>{let{upVolume:c,downVolume:l,totalVolume:u,isValue:d}=t;if(c===0&&l===0)return null;let f=this.axis.toY(e.min+s*e.zone),p=this.axis.toY(e.min+(s+1)*e.zone),m=Math.abs(f-p),h=(e,t,n=0)=>{let a=new CD({x:this.alignLeft?r+n:r+i-e-n,y:p},e,m,this.axis);return a.style=t,a},g=(e,t,n)=>e/t.totalVolume*n,_=this.studyPlot.curves[2].visible,v=_&&d?this.upValueStyle:this.upStyle,y=_&&d?this.downValueStyle:this.downStyle,b=_&&d?this.totalValueStyle:this.totalStyle;if(this.totalVolume){let e=g(u,o,a);n.push(h(e,b))}else{let e=g(l,o,a),t=g(c,o,a);n.push(h(t,v),h(e,y,t))}if(this.studyPlot.curves[1].visible&&s===e.maxVolumeIndex){let e=n[n.length-1].rect,t=this.alignLeft?e.x+e.width:r,a=(p+f)/2,o=this.alignLeft?r+i:e.x;n.push(new SD({x:t,y:a},{x:o,y:a},!1,!1,this.axis))}}),n}get isVisible(){return this.studyPlot.visible&&this.studyPlot.mainCurve.visible}getElements(){if(this.gotData||this.getData(),!this.gotData||!this.isVisible||this.boxes.length===0)return[];switch(this.periodType){case`VisibleScreen`:{let e=this.boxes[0];return!e||e.bars.length===0?[]:this.getElementsForBox(e)}case`Bars`:case`Days`:{let[e,t]=this.presenter.view.xAxis.xScale.domain()||[];if(!nn(e)||!nn(t))return[];let n=this.boxes.findIndex(t=>t.firstDate.getTime()<=e.getTime()&&t.lastDate.getTime()>=e.getTime());n===-1&&(n=0,this.studySeries.loadMoreData());let r=this.boxes.findIndex(e=>e.firstDate.getTime()<=t.getTime()&&e.lastDate.getTime()>=t.getTime());r===-1&&n!==-1&&(r=this.boxes.length-1);let i=[];for(let e=n;e<=r;e++)i.push(...this.getElementsForBox(this.boxes[e]));return i}default:throw Error(`Unexpected period type for Volume At Price annotation`)}}getStyleForElement(e,t){return e.style||super.getStyleForElement(e,t)}get presenter(){return this.axis.pane.presenter}get downStyle(){return this.fillOnlyStyle(z.AT_FILL)}get upStyle(){return this.fillOnlyStyle(z.AT_FILL2)}get totalStyle(){return this.fillOnlyStyle(z.AT_FILL3)}get downValueStyle(){return this.fillOnlyStyle(z.AT_FILL4)}get upValueStyle(){return this.fillOnlyStyle(z.AT_FILL5)}get totalValueStyle(){return this.fillOnlyStyle(z.AT_FILL6)}get backgroundStyle(){return this.fillOnlyStyle(z.AT_FILL7)}get lineStyle(){return this.lineOnlyStyle(z.AT_LINE)}getBoxEndFromStart(e){switch(this.periodType){case`VisibleScreen`:default:return null;case`Days`:return Tn(oh(g.Day,this.period)(e),1);case`Bars`:{let t=this.axis.pane.presenter.data.aggregation;return Tn(oh(t.unit,t.size*this.period)(e),1)}}}getData(){let e=this.axis.pane.presenter.data.aggregation;if(e.isTick||e.hasSpec&&!_w(e.spec))return;let[t,n]=this.presenter.view.xAxis.xScale.domain()||[];if(!nn(t)||!nn(n))return;let r=oh(e.unit,e.size);switch(this.periodType){case`VisibleScreen`:{let e=this.boxes[0];if(!e||e.firstDate!==t||e.lastDate!==n){let e=this.getDataForRange(t,n);e&&(this.boxes[0]=e)}else this.gotData=!0;break}case`Bars`:{let[e,t]=[0,1].map(e=>this.studySeries.innCont(e));if((e?.size??0)<1||(t?.size??0)<1)return;let n=e.getTimeData(),i=0;for(this.boxes=[];i<n.length;){let e=n[i],t=i+this.period,a=Tn(t<n.length?n[t]:r(n[n.length-1]),1),o=this.getDataForRange(e,a);o&&this.boxes.push(o),i+=this.period}this.gotData=!0;break}case`Days`:{if(e.isEndOfDay){this.boxes=[],this.gotData=!0;return}let[t,n]=[0,1].map(e=>this.studySeries.innCont(e));if((t?.size??0)<1||(n?.size??0)<1)return;let i=t.getTimeData(),a=t.getData(W.TradingDay),o=e=>{let t=0,n=i[e],r=a[e];for(let o=e;o<i.length;o++)if(Vt(i[o],n)>0&&a[o]!==r&&(t+=1,n=i[o],r=a[o],t===this.period))return o;return-1},s=0,c=i[s],l=o(s)-1;for(;(l<0||l===s)&&s<i.length;)s+=1,l=o(s)-1;for(this.boxes=[];s<i.length&&l<i.length&&s<l;){let e=Tn(r(i[l]),1),t=this.getDataForRange(c,e);t&&this.boxes.push(t),s=l+1,c=i[s],l=o(s)-1}if(l<0&&s<i.length-1){let e=Tn(r(i[i.length-1]),1),t=this.getDataForRange(i[s],e);t&&this.boxes.push(t)}this.gotData=!0;break}}}getBoxAt(e){if(this.boxes.length===0)return null;switch(this.periodType){case`VisibleScreen`:{let t=this.boxes[0];return t.firstDate>e||t.lastDate<e?null:t}case`Bars`:case`Days`:{let t=e.getTime();return this.boxes.find(e=>e.firstDate.getTime()<=t&&e.lastDate.getTime()>=t)||null}}}getValueAt(e,t,n){if(!this.isVisible)return null;let r=this.getBoxAt(t);if(!r)return null;let i=this.getBarIndex(r,n);if(i<0||i>=r.bars.length)return null;let a=r.bars[i];switch(e){case W.UPVOL:return this.totalVolume?null:a.upVolume;case W.DNVOL:return this.totalVolume?null:a.downVolume;case W.TOTVOL:return this.totalVolume?a.totalVolume:null;case W.POC:case W.VAREA:case W.BARBACK:return null;default:throw Error(`Unexpected Volume At Price field`)}}getBarIndex(e,t,n=!1){if(e.bars.length===0||e.zone===0)return-1;let r=Math.floor((t-e.min)/e.zone);return n?Math.min(e.bars.length-1,r):r}get studyPlot(){return this.presenter.allPlots.find(e=>e.id===this.studyPlotId)}get studySeries(){return this.studyPlot.timeSeries}makeBox(e,t){return{min:Number.MAX_VALUE,max:Number.MIN_VALUE,zone:0,bars:[],maxVolumeIndex:-1,firstDate:e,lastDate:t}}findExtremes(e,t,n,r,i,a){let o=N(i)&&N(a);for(let s=t;s<=n;s++)if(o){let t=i[s];t>e.max&&(e.max=t);let n=a[s];n<e.min&&(e.min=n)}else{let t=r[s];t<e.min&&(e.min=t),t>e.max&&(e.max=t)}}findValueArea(e){if(e.maxVolumeIndex===-1||e.bars.length===0)return;e.bars[e.maxVolumeIndex].isValue=!0;let t=pe(e.bars.map(e=>e.totalVolume))*this.valueRangePercent,n=e.bars[e.maxVolumeIndex].totalVolume,r=e.maxVolumeIndex,i=e.maxVolumeIndex;for(;n<t;){let a=[{dir:`lower`,count:2,startIdx:r-2,endIdx:r-1},{dir:`lower`,count:1,startIdx:r-1,endIdx:r-1},{dir:`upper`,count:2,startIdx:i+1,endIdx:i+2},{dir:`upper`,count:1,startIdx:i+1,endIdx:i+1}].filter(t=>t.startIdx>=0&&t.endIdx<e.bars.length).map(t=>{let r=pe(e.bars.slice(t.startIdx,t.endIdx+1).map(e=>e.totalVolume));return{...t,volume:r,newTotal:n+r}});if(a.length===0)break;let o=(e,t)=>t.newTotal<e.newTotal?t:e,s=(e,t)=>t.volume>e.volume?t:e,c=a.filter(e=>e.newTotal>=t),l=c.length>0?c.reduce(o):a.reduce(s);for(let t=l.startIdx;t<=l.endIdx;t++)e.bars[t].isValue=!0;if(l.dir===`lower`?r=l.startIdx:i=l.endIdx,n=l.newTotal,n>=t)break}}tallyVolume(e,t,n,r,i,a,o){let s=Number.MIN_VALUE,c=!1;for(let l=t;l<=n;l++){let t=i[l],n=this.getBarIndex(e,t,!0);if(n===-1){c=!0;break}let u=o[l],d=this.useChange?a[l]>=0:r[l]<=i[l],f=e.bars[n];d?f.upVolume+=u:f.downVolume+=u,f.totalVolume=f.downVolume+f.upVolume,f.totalVolume>s&&(s=f.totalVolume,e.maxVolumeIndex=n)}c||this.findValueArea(e)}get isPeriodic(){return this.periodType===`Bars`||this.periodType===`Days`}get isVisibleScreen(){return this.periodType===`VisibleScreen`}getDataForRange(e,t){let n=this.makeBox(e,t),r=this.studySeries.innCont(1),i=r?.getTimeData();if(!P(i)||i.length===0)return null;let a=e=>Te(i,+e,Number),o=a(e),s=a(t);if(s<0||s>=i.length||o<0||o>=i.length)return null;let c=i[s];if(!P(c)||(c.getTime()>t.getTime()&&--s,s<0)||o>s)return null;if(this.axis.pane.presenter.data.aggregation.unit===g.Day&&this.periodType===`Bars`){let e=r.getData(W.TradingDay),t=e[o];for(;t===e[o]&&o>0;)--o;o+=1;let n=0;for(s=o;s<i.length&&n<this.period;)e[s]!==t&&(n+=1,t=e[s]),s+=1;s-=2}this.isVisibleScreen&&this.usesFinerGrainedAgg&&o<1e3&&this.studySeries.loadMoreData();let l=e=>r.getData(e),[u,d,f,p,m,h]=[`Open`,`High`,`Low`,`Close`,`Change`,`Volume`].map(e=>l(W[e]));this.findExtremes(n,o,s,p,d,f);let _=n.max-n.min,v=e=>({upVolume:0,downVolume:0,isValue:!1,totalVolume:0});if(this.isCountMode)n.zone=_/this.levelSize,n.bars=De(this.levelSize,v);else{let e=(this.presenter.mainPlot?.metaData.minMovement??1)*this.levelSize,t=Math.max(1,Math.ceil(_/e));n.zone=_/t,n.bars=De(t,v)}return this.tallyVolume(n,o,s,u,p,m,h),this.gotData=!0,n}},mk=[`None`,`Absolute`,`Percent`],hk=`#16A34A`,gk=`#DC2626`;function _k(e){return typeof e==`string`&&mk.includes(e)}var vk=class extends wD{studyPlotId;displayMode=`None`;visibleLabelSegments=[];constructor(e,t,n){super(e,t),this.studyPlotId=n}get studyPlot(){return this.presenter.allPlots.find(e=>e.id===this.studyPlotId)}get studySeries(){return this.studyPlot.timeSeries}setOptions(e){let t=e.ReversalChange;this.displayMode=_k(t)?t:`None`}formatSegmentValue(e,t){return this.displayMode===`Absolute`?this.formatter.format(t-e,W.Close):this.displayMode===`Percent`?e===0?``:this.formatter.format((t-e)/e,W.PercentChange):``}getElements(){if(this.visibleLabelSegments=[],!this.studyPlot.visible||!this.studyPlot.mainCurve.visible)return[];let e=this.studySeries.getCurrentState();if(!e)return[];let t=e.confirmedPivots,n=Array.from(t.keys()).sort((e,t)=>e-t);if(n.length===0)return[];let r=this.presenter.mainPlot?.timeSeries?.container;if(!r||r.size<2)return[];let i=r.getTimeData();if(!i)return[];let a=this.presenter.view,[o,s]=a.xAxis.xScale.domain()||[];if(!o||!s)return[];let c=o.getTime(),l=s.getTime(),u=-1,d=-1;for(let e=0;e<n.length;e++){let t=i[n[e]].getTime();if(u===-1&&t>=c&&(u=Math.max(0,e-1)),t<=l)d=e;else if(u!==-1)break}if(u===-1){if(n.length>0&&i[n[0]].getTime()>l)return[];u=n.length-1,d=n.length-1}else d===-1&&(d=u);d=Math.min(n.length-1,d+1);let f=[];for(let e=u;e<d;e++){let r=n[e],o=n[e+1],s=t.get(r),u=t.get(o),d=a.toX(i[r]),p=this.axis.toY(s),m=a.toX(i[o]),h=this.axis.toY(u);f.push(this.makeLine({x:d,y:p},{x:m,y:h}));let g=i[o].getTime();g>=c&&g<=l&&this.visibleLabelSegments.push({fromPrice:s,toPrice:u,toPoint:{x:m,y:h}})}if(P(e.pivotPrice)&&P(e.candPrice)){let t=i[e.pivotIndex].getTime();if(i[e.candIndex].getTime()>=c&&t<=l){let t=a.toX(i[e.pivotIndex]),n=this.axis.toY(e.pivotPrice),r=a.toX(i[e.candIndex]),o=this.axis.toY(e.candPrice);f.push(this.makeLine({x:t,y:n},{x:r,y:o}))}}return f}adornElements(e,t){if(this.displayMode===`None`||this.visibleLabelSegments.length===0)return;let n=Math.abs(Ga(t,!0));this.visibleLabelSegments.forEach(e=>{let r=this.formatSegmentValue(e.fromPrice,e.toPrice);if(r===``)return;let i=e.toPrice>=e.fromPrice;Ja(t,r,{x:e.toPoint.x,y:e.toPoint.y+(i?-n:n)},T.Right,i?hk:gk)})}},yk=[z.AT_LINE,z.AT_LINE_2,z.AT_LINE_3],bk=class extends wD{studyPlotId;constructor(e,t,n){super(e,t),this.studyPlotId=n}get studyPlot(){return this.presenter.allPlots.find(e=>e.id===this.studyPlotId)}get studySeries(){return this.studyPlot.timeSeries}isCurveVisible(e){return this.studyPlot.curves[e]?.visible??!1}getChannelPrices(){let e=this.studySeries.getCurrentState();if(!e)return null;let{startIndex:t,endIndex:n,slope:r,intercept:i,stdDevWidth:a}=e;if(!N(t)||!N(n)||!N(r)||!N(i)||!N(a)||!Ze(r)||!Ze(i)||!Ze(a))return null;let o=n-t+1;if(o<1)return null;let s=e=>i+r*(e+1),c=s(0),l=s(o-1);return{start:[c+a,c,c-a],end:[l+a,l,l-a]}}makeLines(){if(!this.studyPlot?.visible)return null;let e=this.studySeries.getCurrentState(),t=this.getChannelPrices();if(!e||!t)return null;let{startIndex:n,endIndex:r,extendLeft:i,extendRight:a}=e;if(!N(n)||!N(r))return null;let o=this.studyPlot.basePlot?.timeSeries?.container??this.presenter.mainPlot?.timeSeries?.container;if(!o||o.size<2)return null;let s=o.getTimeData();if(!s||s.length<=r)return null;let c=this.presenter.view,[[l,u,d],[f,p,m]]=[t.start,t.end],h=c.toX(s[n]),g=c.toX(s[r]),_=(e,t,n)=>{let r=this.axis.toY(e),o=this.axis.toY(t),s=new SD({x:h,y:r},{x:g,y:o},i,a,this.axis);return s._data={lineIndex:n},s};return[_(l,f,0),_(u,p,1),_(d,m,2)]}getStyleForElement(e,t){let n=yk[e._data?.lineIndex??t],r=this.traits[n];return r?ko({line:r,fill:{color:z.COLOR_TRANSPARENT}}):super.getStyleForElement(e,t)}getElements(){let e=this.makeLines();return e?e.filter((e,t)=>this.isCurveVisible(t)):[]}getPriceScaleAdornments(){let e=this.getChannelPrices();if(!e)return[];let t=[this.traits?.[z.AT_LINE]?.color,this.traits?.[z.AT_LINE_2]?.color,this.traits?.[z.AT_LINE_3]?.color];return e.end.map((e,n)=>({price:e,color:t[n]??this.traits?.line?.color??`#000`}))}getDomainPrices(){let e=this.getChannelPrices();return e?[...e.start,...e.end]:[]}adornElements(e,t){let n=this.makeLines();if(!n||!n.every(e=>P(e.p1,e.p2)))return;let[r,i,a]=n,o=(e,n,r)=>{t.fillStyle=r,t.fill(dk(e,n))};this.isCurveVisible(3)&&o(r,i,this.traits?.[z.AT_FILL]?.color),this.isCurveVisible(4)&&o(i,a,this.traits?.[z.AT_FILL2]?.color)}};function xk(e){let t=e<0?-1:1,n=Math.abs(e)/Math.SQRT2,r=1/(1+.3275911*n);return .5*(1+t*(1-((((1.061405429*r+-1.453152027)*r+1.421413741)*r+-.284496736)*r+.254829592)*r*Math.exp(-n*n)))}var Sk=class extends wD{studyPlotId;periodTarget=0;targetPrice1=0;targetPrice2=0;pricesCount=0;targetDate;computed=!1;anchorPrice=0;sigmaAnnualized=0;unitsPerYear=0;probabilityAbove=0;probabilityBelow=0;probabilityBetween=0;styles=[];constructor(e,t,n){super(e,t),this.studyPlotId=n}makeStyles(){let e=this.lineOnlyStyle(z.AT_LINE),t=this.lineOnlyStyle(z.AT_LINE_2);this.styles=[e,t,t]}containerOf(e){return e?.timeSeries.container}get mainCont(){return this.containerOf(this.presenter.mainPlot)}get studyCont(){return this.containerOf(this.studyPlot)}get studyPlot(){return this.presenter.allPlots.find(e=>e.id===this.studyPlotId)}get targetPrice(){return this.targetPrice1===0?this.targetPrice2:this.targetPrice1}setOptions(e){if(this.periodTarget=e.PeriodTarget,this.targetPrice1=e.TargetPrice1,this.targetPrice2=e.TargetPrice2,this.pricesCount=(this.targetPrice1===0?0:1)+(this.targetPrice2===0?0:1),this.pricesCount>1&&this.targetPrice1<this.targetPrice2){let e=this.targetPrice1;this.targetPrice1=this.targetPrice2,this.targetPrice2=e}}get haveInput(){return this.periodTarget!==0&&(this.targetPrice1!==0||this.targetPrice2!==0)}get haveData(){return N(this.mainCont)&&!this.mainCont.isEmpty&&this.studySeries.haveVolatility}get studySeries(){return this.studyPlot.timeSeries}getData(){let e=this.presenter.timeline;this.targetDate=e.at(e.lastSeriesIndex+this.periodTarget),this.points=[new gD(this.axis,this.targetPrice,this.targetDate)],this.pricesCount>1&&this.points.push(new gD(this.axis,this.targetPrice2,this.targetDate)),this.unitsPerYear=zE(this.presenter.data.aggregation),this.anchorPrice=this.mainCont.getLastDataPoint(W.Close),this.sigmaAnnualized=this.studySeries.getVolatilityPercent()}computeProbabilities(){let e=this.sigmaAnnualized*Math.sqrt(this.periodTarget/this.unitsPerYear),t=t=>(t-this.anchorPrice)/(this.anchorPrice*e),n=xk(t(this.targetPrice));if(this.pricesCount>1){let e=xk(t(this.targetPrice2));this.probabilityAbove=1-n,this.probabilityBelow=e,this.probabilityBetween=n-e}else this.probabilityBelow=n,this.probabilityAbove=1-this.probabilityBelow;this.computed=!0}compute(){!this.haveInput||!this.haveData||(this.getData(),this.computeProbabilities())}getElements(){if(this.computed||this.compute(),!this.computed||!this.studyPlot.mainCurve.visible)return[];let e=[];return e.push(new hD(this.points[0].point,!0,this.axis)),e.push(new hD(this.points[0].point,!1,this.axis)),this.pricesCount>1&&e.push(new hD(this.points[1].point,!1,this.axis)),e}getStyleForElement(e,t){return this.styles.length||this.makeStyles(),this.styles[t]}get hasPoint(){return this.points.length>0}getTimeScaleAdornments(){return this.hasPoint?[{time:this.points[0].time,color:this.traits.line.color}]:[]}getPriceScaleAdornments(){if(!this.hasPoint)return[];let e=[];return e.push({price:this.points[0].price,color:this.traits.line2.color}),this.pricesCount>1&&e.push({price:this.points[1].price,color:this.traits.line2.color}),e}adornElements(e,t){if(this.computed){let[e,n]=[!0,!1].map(e=>Math.abs(Ga(t,e))),r=this.pricesCount>1,i=this.points[0].point,a=r?this.points[1].point:i,o=this.traits.line2.color,s=Pa(o),c=Wa(t),l=[`Above`,`Below`,`Between`],u=(e,t)=>`${Xe(e*100,2).toFixed(2)}% Probability ${l[t]}`,d=(e,n)=>Ja(t,e,n,T.Right,s,o);if(d(u(this.probabilityAbove,0),{x:i.x-10,y:i.y-e}),r){let e=i.y+(a.y-i.y+c)/2;d(u(this.probabilityBetween,2),{x:i.x-10,y:e})}d(u(this.probabilityBelow,1),{x:a.x-10,y:a.y+n})}}},Ck=new gO,wk=e=>Q(_O,JO,1,e),Tk=e=>Q(_O,ND,1,e),Ek={Default:()=>function(){return Ck},Line:()=>Q(FD,wO,!1),DateRange:()=>Q(FD,nk,!1),PriceRange:()=>Q(FD,rk,!1),DatePriceRange:()=>Q(FD,ik,!1),GannBox:()=>Q(FD,ak,!1),GannSquare:()=>Q(LD,lk),Ray:()=>Q(FD,wO,!1),GannLine:()=>Q(ID,wO,!1),VerticalLine:()=>Q(_O,TO,1),HorizontalLine:()=>Q(_O,EO,1),LongPosition:()=>Q(_O,ek,1,!0),ShortPosition:()=>Q(_O,ek,1,!1),FiftyPercentLine:function(e,t){return P(e)?Q(vO,DO,e.axis||t.mainAxis,e):Q(_O,DO,2)},FibonacciRetracement:()=>Q(FD,AO,!1),TrendBasedFibExtension:()=>Q(FD,jO,!0),FibonacciFan:()=>Q(FD,FO,!1),FibonacciArcs:()=>Q(FD,VO,!1),FibonacciChannel:()=>Q(FD,fk,!0),GannFan:()=>Q(FD,HO,!1),SpeedResistanceFan:()=>Q(FD,UO,!1),SpeedResistanceArcs:()=>Q(FD,WO,!1),AndrewsPitchfork:()=>Q(_O,GO,3),Rectangle:()=>Q(FD,sO,!1),Ellipse:()=>Q(FD,KO,!1),TrendChannel:()=>Q(FD,qO,!0),SymbolArrowUp:()=>wk(`arrow_up`),SymbolArrowDown:()=>wk(`arrow_down`),SymbolArrowRight:()=>wk(`arrow_right`),SymbolArrowLeft:()=>wk(`arrow_left`),SymbolArrowHorizontal:()=>wk(`arrow_horizontal`),SymbolArrowVertical:()=>wk(`arrow_vertical`),SymbolArcDown:()=>wk(`arc_down`),SymbolArcUp:()=>wk(`arc_up`),SymbolThumbsUp:()=>wk(`thumbs_up`),SymbolThumbsDown:()=>wk(`thumbs_down`),SymbolZero:()=>wk(`zero`),SymbolOne:()=>wk(`one`),SymbolTwo:()=>wk(`two`),SymbolThree:()=>wk(`three`),SymbolFour:()=>wk(`four`),SymbolFive:()=>wk(`five`),SymbolSix:()=>wk(`six`),SymbolSeven:()=>wk(`seven`),SymbolEight:()=>wk(`eight`),SymbolNine:()=>wk(`nine`),SymbolQuestion:()=>wk(`question`),SymbolFishHook:()=>wk(`fish_hook`),SymbolBuy:()=>wk(`buy`),SymbolSell:()=>wk(`sell`),FibonacciTimeZones:()=>Q(FD,YO,!1),Text:()=>Q(RD,MD,null),PickPoint:()=>function(){return new XO},ZoomIn:()=>function(){return new uO},ProfitLoss:Tk,RewardRisk:Tk,VolumeAtPrice:function(e){return Q(_O,pk,2,e)},ZigZag:function(e){return Q(vO,vk,null,e)},ProbabilityCones:function(e){return Q(_O,Sk,2,e)},LinearRegressionChannel:function(e){return Q(vO,bk,null,e)}};function Dk(e,t=!1,n=null,r=null,i=null){let a=Ek[e];return a=a(r,i),a(e,t,n)}function Ok(e,t={}){e.enableTooltip(!0),e.resetActiveTool();let{axis:n,annotation:r,toolChange:i,annId:a}=t;P(n)&&e.onAnnotationsUpdated(n),P(r)&&e.onAnnotationModifiedByTool(r,i),[O.Cancelled,O.Executed,O.TextChanged].includes(i)&&e.onAnnotationDone(a,i)}function kk(e,t=!0,n=O.None){e.wasModifiedByTool();let r=e.axis,i={axis:r,annotation:e,toolChange:n};Ok(r.pane.presenter,t?i:void 0)}function Q(e,t,n,r){return function(i,a,o){let s=xD(i,t,r,o);return s.annName=i,a?s:new e(s,n)}}function Ak(e){e.button===E.Right&&Ok(e.presenter)}function jk(e,t,n){let r={};r.inputs=dt(e.inputs);let i=r.inputs[z.INPUT_SOURCE],a=N(i)?W[i]:void 0;r.source=W[e.source]??a;let o=e.target!==void 0,s=P(n)?n:e.curves;return r.outFields=Oe(o?[W[e.target]]:s.map(e=>e.fields).flat()),r.target=o?W[e.target]:r.outFields[0],r.aggregation=t,r}function Mk(e){return Array.isArray(e.innerSeries)}function Nk(e){return e.query?.symbol===z.PLACEHOLDER_SYMBOL_NAME?!0:Mk(e)?e.innerSeries.some(e=>Nk(e)):!1}var Pk=class extends cD{model;basePlot;_hasEvents;_params;_shiftFmt;_title;range;shouldMaybePriceMap;annIndex;_canPriceMap;#e(e=3){let t=this.model.inputs||[],n=t.length;if(n===0)return``;let r=``;n>e&&(t=t.slice(0,3),r=`, ...`);let i=this.model.study===`AVWAP`;return t.length===0?``:`(${t.map(e=>i&&e.name===`Anchor`?new Date(e.value).toLocaleString():e.value).join(`, `)}${r})`}get params(){return P(this._params)||(this._params=this.#e()),this._params}get fullParams(){return this.#e(Number.MAX_VALUE)}get shiftFmt(){if([`PC`,`TARGP`].includes(this.model.study))return``;if(!P(this._shiftFmt)){let e=this.curves.map(e=>Number(e.shift)).filter(e=>e!==0);this._shiftFmt=e.length===0?``:`[${e.join(`, `)}]`}return this._shiftFmt}get title(){if(!P(this._title)){let e=this.params,t=this.shiftFmt;this._title=`${this.model.study} ${e} ${t}`.trim()}return this._title}getStandalonePaneTitle(){let e=this.getStandalonePaneBasisTitle();return e?`${this.title} on ${e}`:this.title}getStandalonePaneBasisTitle(){if(this.model?.basis?.kind!==`seasonal`)return null;let e=this.basePlot??this.tryResolveBasePlot();if(!e?.isSeasonal)return null;let t=e;if(t.isFutures&&!t.hasComputation){let t=e.metaData?.symbol;if(typeof t==`string`&&t.length>0)return t}return e.title||null}tryResolveBasePlot(){if(!this.axis?.pane?.presenter)return null;try{return this.#r()}catch{return null}}fromModel(e){this.model=e,super.fromModel(this.model)}getMetaData(){let e=B(this.model.study),t=e.meta.decimals;this.metaData=t===void 0?this.basePlot.metaData:new ia(t),P(e.meta.range)&&(this.range=e.meta.range)}getDetachedScaleMargins(){return this.model?.study===`VOL`&&this.axis?.pane.isMain?z.VOLUME_DETACHED_SCALE_MARGINS:super.getDetachedScaleMargins()}applySpecifics(e){let t=this.model.study;B(t).meta.shiftable===!0&&this.curves.forEach(t=>{Number.isFinite(e.inputs.Offset)&&(t.shift=e.inputs.Offset)});let n=(e,t,n)=>this.curves[e].zones[t].value=this.model.levels[n].value;switch(t){case`ICHCLD`:{let t=e.inputs.Displacement;this.curves[2].shift=-t,this.curves[3].shift=t,this.curves[4].shift=t,this.curves[5].shift=t;break}case`MARIB`:{let t=Math.min(Math.max(0,e.inputs.Count),10);this.curves.forEach((e,n)=>e.visible=e.visible&&n<t);break}case`CRS`:{let t=e.inputs.Display===`PercentChange`;this.axis.comparison=t?x.Percent:x.None;break}case`PERF`:{let t=e.inputs.Anchor===`VisibleStart`;this.axis.comparison=t?x.Percent:x.None;break}case`JPI`:case`CTTP`:case`CTTI`:{let t=De(10,e=>(e+1)*.025),n=e=>t.map(t=>Aa(t)(e)),r=([e,t])=>[...n(e).reverse(),t,`#6a4a3a`,`#a000c8`,`#ffffff`];this.curves[0].colors=r(this.curves[0].colors),this.curves[1].colors=r(this.curves[1].colors);let i=this.curves[0].colors.length;this.curves[0].colors[i-1]=this.curves[1].colors[t.length],this.curves[1].colors[i-1]=this.curves[0].colors[t.length],this.shouldMaybePriceMap=e.inputs.Height===`Performance`;break}case`RSI`:case`RSIMOD`:case`RSISTO`:case`CCI`:n(0,0,0),n(0,1,2);break;case`STC`:n(0,0,0),n(0,1,1);break;case`RVOL`:case`DPO`:case`COPP`:n(0,0,0);break;case`VOL`:this.setCurveAttributes(0,e.inputs.BarColoring);break;case`MAVOL`:this.setCurveAttributes(1,e.inputs.BarColoring);break;case`VOLAP`:{this.notifyAboutPriceDomains=!0,this.customPlotValues=!0,P(this.annotations)||(this.annotations=[]);let t=this.curves[1],n=this.curves[2],r=Dk(`VolumeAtPrice`,!0,{[z.AT_LINE]:{color:t.colors[0],width:t.lineWidth,dashStyle:t.dashStyle},[z.AT_FILL]:{color:this.curves[0].colors[0]},[z.AT_FILL2]:{color:this.curves[0].colors[1]},[z.AT_FILL3]:{color:this.curves[0].colors[2]},[z.AT_FILL4]:{color:n.colors[0]},[z.AT_FILL5]:{color:n.colors[1]},[z.AT_FILL6]:{color:n.colors[2]}},this.id)(this.axis,!1);r.setOptions(e.inputs),this.annIndex=this.annotations.push(r)-1;break}case`PVACP`:{this.customPlotValues=!0,P(this.annotations)||(this.annotations=[]);let t=this.curves[1],n=this.curves[2],r=this.curves[3],i=Dk(`VolumeAtPrice`,!0,{[z.AT_LINE]:{color:t.colors[0],width:t.lineWidth,dashStyle:t.dashStyle},[z.AT_FILL]:{color:this.curves[0].colors[0]},[z.AT_FILL2]:{color:this.curves[0].colors[1]},[z.AT_FILL3]:{color:this.curves[0].colors[2]},[z.AT_FILL4]:{color:n.colors[0]},[z.AT_FILL5]:{color:n.colors[1]},[z.AT_FILL6]:{color:n.colors[2]},[z.AT_FILL7]:{color:r.colors[0]}},this.id)(this.axis,!1);i.setOptions(e.inputs),this.annIndex=this.annotations.push(i)-1;break}case`ZIGZAG`:{this.customPlotValues=!0,P(this.annotations)||(this.annotations=[]);let t=Dk(`ZigZag`,!0,{[z.AT_LINE]:{color:this.curves[0].colors[0],width:this.curves[0].lineWidth,dashStyle:this.curves[0].dashStyle??`Solid`}},this.id)(this.axis,!1);t.setOptions(e.inputs),this.annIndex=this.annotations.push(t)-1;break}case`LINRCHN`:{this.customPlotValues=!0,P(this.annotations)||(this.annotations=[]);let e=this.curves[0],t=this.curves[1],n=this.curves[2],r=this.curves[3],i=this.curves[4],a=Dk(`LinearRegressionChannel`,!0,{[z.AT_LINE]:{color:e.colors[0],width:e.lineWidth,dashStyle:e.dashStyle??`Solid`},[z.AT_LINE_2]:{color:t.colors[0],width:t.lineWidth,dashStyle:t.dashStyle??`Solid`},[z.AT_LINE_3]:{color:n.colors[0],width:n.lineWidth,dashStyle:n.dashStyle??`Solid`},[z.AT_FILL]:{color:r.colors[0]},[z.AT_FILL2]:{color:i.colors[0]}},this.id)(this.axis,!1);this.annIndex=this.annotations.push(a)-1;break}case`IVRANK`:{let t=W.ImplVolRank1Y;switch(e.inputs.TimeFrame){case`1-Year`:default:break;case`5-Day`:t=W.ImplVolRank5D;break;case`1-Month`:t=W.ImplVolRank1M;break;case`3-Month`:t=W.ImplVolRank3M;break;case`6-Month`:t=W.ImplVolRank6M;break;case`YTD`:t=W.ImplVolRankYTD;break}this.curves[0].fields[0]=t,e.outFields[0]=t;break}case`IVPCTL`:{let t=W.ImplVolPerc1Y;switch(e.inputs.TimeFrame){case`1-Year`:default:break;case`5-Day`:t=W.ImplVolPerc5D;break;case`1-Month`:t=W.ImplVolPerc1M;break;case`3-Month`:t=W.ImplVolPerc3M;break;case`6-Month`:t=W.ImplVolPerc6M;break;case`YTD`:t=W.ImplVolPercYTD;break}this.curves[0].fields[0]=t,e.outFields[0]=t;break}case`OPTIV`:{let t=[W.WeighImplVolHigh,W.WeighImplVol,W.WeighImplVolLow];switch(e.inputs.TimeFrame){case`Implied Volatility`:default:break;case`5-Day Average IV`:t=[W.WeighImplVolHigh5D,W.WeighImplVol5D,W.WeighImplVolLow5D];break;case`1-Month Average IV`:t=[W.WeighImplVolHigh1M,W.WeighImplVol1M,W.WeighImplVolLow1M];break;case`3-Month Average IV`:t=[W.WeighImplVolHigh3M,W.WeighImplVol3M,W.WeighImplVolLow3M];break;case`6-Month Average IV`:t=[W.WeighImplVolHigh6M,W.WeighImplVol6M,W.WeighImplVolLow6M];break;case`1-Year Average IV`:t=[W.WeighImplVolHigh1Y,W.WeighImplVol1Y,W.WeighImplVolLow1Y];break;case`YTD Average IV`:t=[W.WeighImplVolHighYTD,W.WeighImplVolYTD,W.WeighImplVolLowYTD];break}this.curves[0].fields[0]=t[0],this.curves[1].fields[0]=t[1],this.curves[2].fields[0]=t[2],e.outFields=[...t];break}case`PC`:{let t=e.inputs.PeriodForecast-1;this.curves.forEach(e=>e.shift=t),P(this.annotations)||(this.annotations=[]);let n=this.curves[11],r=this.curves[12],i=Dk(`ProbabilityCones`,!0,{[z.AT_LINE]:{color:n.colors[0],width:n.lineWidth,dashStyle:n.dashStyle},[z.AT_LINE_2]:{color:r.colors[0],width:r.lineWidth,dashStyle:r.dashStyle}},this.id)(this.axis,!1);i.setOptions(e.inputs),this.annIndex=this.annotations.push(i)-1;break}case`TARGP`:this.curves.forEach(e=>e.shift=1);break}}getValueAt(e,t,n){return this.isVolAP?this.annotations[this.annIndex].getValueAt(e,t,n):super.getValueAt(e,t,n)}getColorOf(e){if(!this.isVolAP&&!this.isZigZag&&!this.isLinRegChannel)return null;let t=this.curves[0].colors;if(this.isZigZag)return t[0];switch(e){case W.UPVOL:return t[1];case W.DNVOL:return t[0];case W.TOTVOL:return t[2];case W.POC:case W.VAREA:case W.BARBACK:return z.COLOR_TRANSPARENT;case W.LINRUP:return t[0];case W.LINRMID:return this.curves[1].colors[0];case W.LINRLOW:return this.curves[2].colors[0];default:throw Error(`Unexpected Volume At Price field`)}}isEmpty(){return this.isVolAP||this.isZigZag||this.isLinRegChannel?!1:super.isEmpty()}setCurveAttributes(e,t){let n=t=>this.curves[e].attributes=[m[t]];switch(t){case`LikeMain`:{let t=this.axis.pane.presenter.mainPlot.curves[0].attributes,r=$().config.defaultVolumeBarColoring;P(t)?this.curves[e].attributes=[t[0]]:P(r)?n(r===`OpenToClose`?`OpenVsClose`:`ChangeBased`):n(`OpenVsClose`);break}case`OpenToClose`:n(`OpenVsClose`);break;case`CloseToClose`:n(`ChangeBased`);break;default:throw Error(`Unexpected bar coloring choice: ${t}`)}}get hasEvents(){return!!this._hasEvents&&this.curves.every(e=>e.visible)}get eventsSeries(){return this.timeSeries}doesSeriesEmitEvents(){let e=this.timeSeries.helpers;return e.includes(W.Buy)||e.includes(W.Sell)}getEventFor(e){switch(e){case W.Buy:return{show:!0,title:`B`,color:`#03c03c`};case W.Sell:return{show:!0,title:`S`,color:`#c23b22`};default:return null}}getEventFields(){return this.hasEvents?[W.Buy,W.Sell]:[]}getRefPlot(e){return this.axis?.pane.isMain&&this.basePlot?this.basePlot:super.getRefPlot(e)}#t(){return this.model.basis??{kind:`main`}}#n(e){let t=this.axis.pane.presenter.allPlots.find(t=>t.uid===e.uid&&t.isSeasonal&&t.offset===e.offset);if(P(t))return t;throw Error(`Unable to resolve seasonal basis plot for uid '${e.uid}' and offset '${e.offset}'`)}#r(){let e=this.#t();switch(e.kind){case`main`:return this.axis.pane.presenter.mainPlot;case`seasonal`:return this.#n(e);default:throw Error(`Unknown study basis kind '${e.kind}'`)}}async initialize(){return Ai.call(this,async()=>{this.basePlot=this.#r(),await this.basePlot.initialize(),this.getMetaData();let e=this.axis.pane.presenter.data.aggregation,t=jk(this.model,e,this.curves);if(this.basePlot.isSeasonal){let e=this.basePlot.mainCurve.fields[0];P(e)&&(t.source=e)}this.applySpecifics(t);let n=this.basePlot.timeSeries;n instanceof Bv&&(n=n.actual),this.timeSeries=tE(this.model.study,t,n),this._hasEvents=this.doesSeriesEmitEvents(),this.timeSeries.useNotifications=!0;let r=this.title;return this.timeSeries.ready().then(e=>{let t=this.basePlot.timeSeries instanceof Cg||Nk(this.timeSeries);!e&&!this.timeSeries.hasData&&!t&&!this.timeSeries.computedServerSide&&I(`Unable to calculate study values for ${r}`,`error`)}),!0})}get isJpi(){return[`JPI`,`CTTP`,`CTTI`].includes(this.model.study)}get isVolAP(){return this.model.study===`VOLAP`||this.model.study===`PVACP`}get isZigZag(){return this.model.study===`ZIGZAG`}get isLinRegChannel(){return this.model.study===`LINRCHN`}invalidateAssociatedAnnotations(e){this.isVolAP&&this.annotations[this.annIndex].invalidate(e)}onPriceDomainsUpdated(){this.invalidateAssociatedAnnotations(`PriceDomainsChanged`)}shouldPriceMap(e){return this.isJpi?this.shouldMaybePriceMap?e.id===W.JPIB.id||e.id===W.JPIS.id:!1:super.shouldPriceMap(e)}canPriceMap(e,t){if(!this.isJpi)return super.canPriceMap(e,t);this._canPriceMap=e>0}priceMap(e,t,n){if(!this.isJpi)return super.priceMap(e,t,n);if(t>this.visToIndex)return e;let r=(e,t)=>this.timeSeries.container.getData(e)[t],i=r(W.JPIB,t),a=r(W.JPIS,t);if(i===null&&n.id===W.JPIB.id||a===null&&n.id===W.JPIS.id)return null;let o=0,s=this.visFromIndex,c=this.timeSeries.helpers[0],l=this.timeSeries.helpers[2];for(;s<=t;){let e=r(l,s);o+=e===1?0:r(c,s),s++}return o}},Fk=[W.Open,W.High,W.Low,W.Close,W.Volume],Ik=class extends cD{_expression;exprModel=null;symbols=null;errorText;get title(){return this.expression}get expression(){return this._expression}async parseExpression(){let e=wu(this._expression);if(this.exprModel=null,this.symbols=null,Cu(e))this.errorText=e.error;else{let{model:t,clean:n,symbols:r}=e;this.errorText=void 0,this.symbols=r,this.exprModel=t,this._expression=n}}get isValid(){return!P(this.errorText)}#e(e){return{mapper:e=>e.query.symbol,loadMoreData:!0,recompute:d.Minimum,missing:u.UseNext,stretch:e=>!1,fieldMap:new Map(Fk.map(e=>[e,e])),noDataApproach:f.NoAction,modelTransform:(e,t)=>null,skipLeadingEmpty:e}}getTimeSeries(){let e=this.getInnerSeries(),t=this.axis?.pane.presenter.data?.exprSkipLeadingEmpty??!1,n=new jv(this.exprModel,e,this.#e(t));this.timeSeries=this.wrapIfAdvancedStyle(n);let r=this.title;this.timeSeries.ready().then(e=>{e||I(`Unable to calculate expression: ${r}`,`error`)})}getInnerSeries(){let e=ku(this.exprModel),t=$().getTimeSeriesDataSource();return e.map(e=>{let n=this.makeQuery();return n.symbol=e,t.getTimeSeries(n)})}getRecord(){P(this.errorText)||(this.record=new of(this.metaData.inner.map(e=>[e.symbol,e.resolved]),F(this.exprModel)),this.record.ready().then(e=>e))}getMetaData(){this.isValid&&(this.metaData=new oa(this.symbols),this.metaData.ready().then(e=>{e&&(this.getRecord(),this.presenter?.notifyHost(G.MD_CHANGED,{plot:this}))}))}fromModel(e){super.fromModel(e),this._expression=e.expression}async initialize(){return Ai.call(this,async()=>(await this.parseExpression(),this.isShutDown?!1:(this.getMetaData(),this.getTimeSeries(),!0)))}},Lk=class extends cD{suffix;_forward;offset;errorText;fwdModel=null;outField;roots=null;symbols=[];get title(){return`${this.forward}${this.suffix}`}get forward(){return this._forward}fromModel(e){super.fromModel(e);let t=e;this.offset=t.offset,this._forward=t.forward}async parseForward(){let e=wu(this.forward),t=Cu(e);if(t?(this.errorText=e.error,this.fwdModel=null,this._forward=e.text):(this.errorText=void 0,this.fwdModel=e.model,this._forward=e.clean),t)this.roots=null;else{this.offset>0?(this.suffix=` (${le(ih(this.offset),rh(z.FMT_US_DATE_ONLY))(new Date)})`,this.outField=new zd(`Close_${this.offset}`,v.Number,b.Forward,`Close (${this.offset})`),this.curves[0].fields[0]=this.outField):(this.suffix=``,this.outField=W.Close);let{yes:t,no:n}=A(e.symbols,e=>Yr(`${e}*1`)),r=(await Promise.all(t.map(e=>li(e)))).map(e=>e.map(e=>e.name));this.roots=t.reduce((e,t,n)=>(e[t]=r[n],e),{}),this.symbols=n}}get isValid(){return!P(this.errorText)}getMetaData(){this.isValid&&(this.metaData=new oa(Object.values(this.roots).flat()),this.metaData.ready().then(e=>{e&&this.presenter?.notifyHost(G.MD_CHANGED,{plot:this})}))}getForwardPolicy(e){return{mapper:e=>e.query.root,loadMoreData:!1,recompute:d.Everything,missing:u.UseNext,stretch:e=>!1,fieldMap:new Map([[W.Close,this.outField]]),noDataApproach:f.NoAction,modelTransform:(e,t)=>null,skipLeadingEmpty:!1,valueProvider:e}}getTimeSeries(){let e=$().getTimeSeriesDataSource(),t=Object.keys(this.roots),n=this.offset===0?w.Forward:w.HistoricalForward,r=t.map(t=>{let r={seriesKind:n,root:t,offset:this.offset,symbols:this.roots[t],getHashKey:()=>`${n}|${t}|${this.offset}`};return e.getTimeSeries(r)}),i=this.symbols.length>0?new kg(this.symbols):void 0;this.timeSeries=new jv(this.fwdModel,r,this.getForwardPolicy(i)),this.timeSeries.ready().then(e=>{if(e){let e={series:this.timeSeries,part:re.Unspecified};this.presenter?.notifyHost(G.TS_MANYCHANGED,e)}})}async initialize(){return Ai.call(this,async()=>(await this.parseForward(),this.isShutDown?!1:(this.getMetaData(),this.getTimeSeries(),!0)))}},Rk=e=>e.substring(0,e.lastIndexOf(`::`)),zk=class extends cD{isAverage;hasComputation;offset;offsets;_seasonal;symbolToOffset;errorText;seaModel=null;isPlain=!1;isFutures=!1;suffix=``;outField;symbols;coreModel;coreHasComputation;refSeasonal;get title(){if(this.isAverage){let e=`YB `;return this.offset<-1&&(e=`${Math.abs(this.offset)}y `),`${e}Average`}return!this.hasComputation&&(this.symbols?.length??0)>0?this.outField.name:`${this.seasonal}${this.suffix}`}get seasonal(){return this._seasonal}fromModel(e){super.fromModel(e);let t=e;this.offset=t.offset,this.offsets=t.offsets,this.isAverage=t.offset<0,this._seasonal=this.refSeasonal=t.seasonal}constructSeasonal(e,t){return Ou(ju(e,e=>this.applyOffset(e,t)))}constructAverage(e,t=null){let n=t===null?null:t.map(e=>this.symbolToOffset[e]),r=n===null,i=this.offsets.filter(e=>r?!0:n.includes(e)).map(t=>`(${this.constructSeasonal(e,t)})`);return`(${i.join(`+`)})/${i.length}`}prepareFields(){let e=this.isPlain?`${this.yearFromOffset(this.offset)}`:`${this.offset}Y`,t=this.isAverage?`Avg`:e;this.suffix=this.offset===0?``:` (${t})`,this.outField=new zd(`Close_${t}`,v.Number,b.Seasonal,`Close${this.suffix}`),this.curves[0].fields[0]=this.outField}applyOffset(e,t){return`${this.isPlain?e:hi(e,-t)}::${t}`}createSymbolToOffsetMapping(e){this.symbolToOffset={},e.forEach(e=>{this.offsets.forEach(t=>{this.symbolToOffset[this.applyOffset(e,t)]=t})})}async parseSeasonal(){let e=wu(this.seasonal,!0),t=Cu(e),n=e=>(this.errorText=e,this.seaModel=null,null);if(t)return n(e.error);let{model:r,symbols:i}=e;this.prepareFields();let a=new Map;for(let e of i){let t=ai(await qr(e));a.set(e,t)}r=ju(r,e=>a.get(e)),i=Array.from(a.values());let o=i.every(e=>Yr(e)||Zr(e)),s=i.every(e=>$r(e)),c=i.every(e=>!Yr(e)&&!$r(e)&&!Zr(e));if(!o&&!s&&!c)return n(`Mixed types of symbols aren't supported yet`);this.isPlain=c,this.isFutures=o,this.createSymbolToOffsetMapping(i),this.coreModel=this.isAverage?r:null,this.coreHasComputation=Au(r);let{model:l,symbols:u}=wu(this.isAverage?this.constructAverage(r):this.constructSeasonal(r,this.offset),!0);this.seaModel=l,this.hasComputation=Au(l),this._seasonal=Ou(ju(l,Rk)),this.symbols=u,this.outField.name=this.outField.shortName=this.fixupFieldDescription()}get isValid(){return!P(this.errorText)}getActualSymbols(){return[...new Set(this.symbols.map(Rk))]}fixupFieldDescription(){if(!this.hasComputation&&!this.isAverage){let e=Rk(this.symbols[0]);if(this.isPlain)return`${e} ${new Date().getFullYear()-this.offset}`;if(this.isFutures)return ai(e,!0)}return this.title}getMetaData(){if(this.isValid){let e=this.getActualSymbols(),t=e.length===1&&!this.hasComputation&&!this.isAverage,n=$().getMetaDataSource();this.metaData=t?n.getMetaData(e[0]):new oa(e),this.metaData.ready().then(e=>{e&&this.presenter?.notifyHost(G.MD_CHANGED,{plot:this})})}}getNoDataApproach(){return this.isAverage&&!this.coreHasComputation?f.ModelTransformRequired:this.hasComputation?f.NoAction:f.IgnoreTimelineOnly}get seasonalPolicy(){return{mapper:e=>e.query.surrogate||e.query.symbol,loadMoreData:!1,recompute:d.Everything,missing:this.hasComputation?u.UsePrevious:u.UseNone,stretch:e=>this.shouldStretch(e),fieldMap:new Map([[W.Close,this.outField]]),noDataApproach:this.getNoDataApproach(),modelTransform:(e,t)=>t.length===0?this.seaModel:wu(this.constructAverage(this.coreModel,e)).model,skipLeadingEmpty:!1}}shouldStretch(e){return this.symbolToOffset[e]===0&&(this.isAverage&&this.symbols.length>1||this.offset>0)}shiftYears(e){return qt(new Date,-e)}yearFromOffset(e){return wr(this.shiftYears(e))}getCmdtyRange(e){let t=this.shiftYears(e);return[wn(t),Cn(t)]}getSeasonalRange(e,t){let n=P(e[0],e[1]);return this.isPlain&&!n?this.getCmdtyRange(t):this.isFutures?[null,null]:this.isPlain&&t>0&&n?e.map(e=>qt(e,-t)):e}getTimeSeries(){if(!this.isValid)return;let e=$().getTimeSeriesDataSource(),t=Object.keys(this.symbolToOffset).map(t=>{let n=this.makeQuery();return n.surrogate=t,n.symbol=Rk(t),n.offset=this.symbolToOffset[t],n.cacheMe=!this.isPlain||n.offset===0,n.range=this.getSeasonalRange(n.range,n.offset),n.offset>0&&(n.disableStreamingUpdates=!0),e.getTimeSeries(n)});this.timeSeries=new jv(this.seaModel,t,this.seasonalPolicy),this.timeSeries.seasonalAverageOffset=this.offset,this.timeSeries.ready().then(e=>{if(e){let e={series:this.timeSeries,part:re.Unspecified};this.presenter?.notifyHost(G.TS_MANYCHANGED,e)}})}async initialize(){return Ai.call(this,async()=>(await this.parseSeasonal(),this.isShutDown?!1:(this.getMetaData(),this.getTimeSeries(),!0)))}},Bk=[`bottom`,`right`,`left`],Vk={bottom:`center`,right:`start`,left:`end`},Hk=class{lineWidth;arrowLength;position;textAlign;fontSize;fontFamily;padding;strokeColor;textColor;backgroundColor;constructor(e){this.lineWidth=1,this.arrowLength=7,this.position=`bottom`,this.textAlign=`center`,this.fontSize=12,this.fontFamily=`Arial`,this.padding=4,this.strokeColor=`white`,this.textColor=`white`,this.backgroundColor=`black`,e&&this.configure(e)}configure(e){Object.assign(this,e)}draw(e,t,n,r,i,a){let o=P(i);if(a||=this.fontSize+this.padding+this.padding+(o?this.padding:0),!Bk.includes(this.position.toLowerCase())){I(`Can not draw indicator in position [${this.position}]`,`error`);return}e.font=`bold ${this.fontSize}px ${this.fontFamily}`,e.textAlign=Vk[this.position],e.strokeStyle=this.strokeColor,e.fillStyle=wa(this.backgroundColor),e.lineWidth=this.lineWidth;let s=[r,i??``].map(t=>e.measureText(t).width),c=Math.max(...s),l=this.position===`bottom`?0:this.arrowLength,u=Math.round(c+l+this.padding+this.padding),d=Math.round(u/2),f=Math.round(a/2);e.setLineDash([]);let p=t;e.beginPath(),e.moveTo(p,n);let m=n+f,h=n+2*f,g=n-f;if(this.position===`right`){e.lineTo(p,m);let t=p+u;o&&(e.lineTo(p,h),e.lineTo(t,h)),e.lineTo(t,m),e.lineTo(t,g),e.lineTo(p,g)}else if(this.position===`left`){e.lineTo(p,m);let t=p-u;o&&(e.lineTo(p,h),e.lineTo(t,h)),e.lineTo(t,m),e.lineTo(t,g),e.lineTo(p,n-f)}else if(this.position===`bottom`){let t=p-d,r=p+d;e.lineTo(p,n),e.lineTo(r,n),e.lineTo(r,n+a),e.lineTo(t,n+a),e.lineTo(t,n),e.lineTo(p,n)}if(e.closePath(),e.stroke(),e.fill(),e.fillStyle=this.textColor,e.textBaseline=`middle`,this.position===`bottom`)e.fillText(r,p,n+Wa(e,1));else if(this.position===`right`){let t=p+this.arrowLength+this.padding;e.fillText(r,t,n),o&&e.fillText(i,t,n+this.padding+f)}else if(this.position===`left`){let t=p-this.arrowLength-this.padding;e.fillText(r,t,n),o&&e.fillText(i,t,n+this.padding+f)}}},Uk=({y:e,halfHeight:t})=>e-t,Wk=({y:e,halfHeight:t})=>e+t;function Gk(e,t){e.forEach((e,n,r)=>{if(n===0&&e.y-e.halfHeight<t.y)e.y=t.y+e.halfHeight+1;else if(n>0){let i=r[n-1],a=Uk(e),o=Wk(i);a<o&&(e.y=o+1+e.halfHeight),Wk(e)>t.y+t.height&&(e.y=t.y+t.height-e.halfHeight-1)}})}var Kk=4,qk=({x:e,halfWidth:t})=>e-t-Kk,Jk=({x:e,halfWidth:t})=>e+t+Kk,Yk=(e,t)=>e-1-t-Kk,Xk=(e,t)=>e+1+t+Kk;function Zk(e,t){let n=e.length-1;e.forEach((e,r,i)=>{let a=r===0,o=a?null:i[r-1],s=qk(e),c=a?t.x:Jk(o);if(e.x-e.halfWidth<t.x&&(e.x=Xk(t.x,e.halfWidth)),s<c)e.x=Xk(c,e.halfWidth+Kk);else{let t=Jk(e),a=r<n?qk(i[r+1]):2**53-1;if(t>a){let n=Yk(e.x,t-a),r=Yk(e.x,e.halfWidth-2),i=Xk(c,o?.halfWidth??0);e.x=Math.max(r,n,i)}}Jk(e)>t.x+t.width&&(e.x=Yk(t.x+t.width,e.halfWidth))})}var Qk=Array.from([,,,,,,],(e,t)=>++t).reverse();function $k(e,t){let n=e.timeSeries.container;if(n===null||n.size<1)return[null,-1];let r=n.getLastDataPoint(t),i=n.getData(t),a=i.length-1,o=e.type===C.Study&&[`JPI`,`CTTP`,`CTTI`].includes(e.model.study);return r==null&&!o&&(a=ve(i,e=>e!==null),r=a===-1?null:i[a]),[r,a]}function eA(e){let t=e.plot.timeSeries.container;return t===null||t.size<1?null:e.getColor(t.size-1)}function tA(e){return e.curves.filter(t=>e.visible&&t.visible&&(e.type!==C.Study||t.style!==h.Ribbon)).map(t=>{let n=t.pickMainField(),[r,i]=$k(e,n);return{value:r,color:eA(t),field:n,index:i}})}var nA=class{annotations=[];id;isCustomDomain=!1;primary=!1;onTheRight=!0;viewBox;plots=[];comparison;scale;yScale;label=``;crosshairIndicator;ticks;lastUsedOptions;config;_fullDomain;constructor(e){this.pane=e,this.id=bt(),this.ticks=null,this.lastUsedOptions=null;let{chart:{fontSize:t},yAxis:{fontSize:n}}=this.pane.presenter.display;this.config={innerTickSize:7,tickPadding:5,indicatorPadding:4,fontWeight:400,fontSize:n||t||12},this.crosshairIndicator=new Hk({fontSize:this.config.fontSize,arrowLength:this.config.innerTickSize})}makePlot(e){let t=null;switch(C[e.type]){case C.Symbol:t=new lD;break;case C.Expression:t=new Ik;break;case C.Study:t=new Pk;break;case C.IncomeStatement:t=new uD(w.IncomeStatement);break;case C.BalanceSheet:t=new uD(w.BalanceSheet);break;case C.Forward:t=new Lk;break;case C.Seasonal:t=new zk;break;default:throw Error(`${e.type} isn't supported yet`)}return t.axis=this,t.fromModel(e),t}toPrice(e){let t=this.yScale.yToPrice(e);return this.comparison===x.None?t:this.pane.presenter.mainPlot.priceMap(t,void 0,W.Close,!0)}toTime(e){return this.pane.presenter.view.toTime(e)}toAnnotationPoint(e){let t=this.toPrice(e.y),n=this.toTime(e.x);return new gD(this,t,n||void 0)}toX(e){return this.pane.presenter.view.toX(e)}priceMap(e){return this.comparison===x.None?e:this.pane.presenter.mainPlot.priceMap(e,void 0,W.Close)}toY(e){let t=this.priceMap(e);return this.yScale.priceToY(t)}get plotAnnotations(){let e=[];return this.plots.forEach(t=>{t.annotations&&e.push(...t.annotations)}),e}annTimeToX(e){return this.pane.presenter.view.xAxis?.annTimeToX(e)}snapTo(e){let t={x:this.annTimeToX(e.time),y:this.toY(e.price)},n=this.pane.presenter,r=n.activeTool,i=r.annotation;return r.alignPointsMode&&i&&i.alignPointsSupported&&i.points.includes(e)?this.alignPoints(i,e,t):r.snapToSupported&&n.display.yAxis.snapAnnotationsToPrices&&!e.passive&&(e.moveDirection===te.Both||e.moveDirection===te.Vertical)&&this.snapToPrices(e,t),t}snapToPrices(e,t){let n=this.plots.find(e=>e.main);if(n&&n.timeSeries&&n.timeSeries.hasData){let r=n.timeSeries.container,i=Te(r.getTimeData(),+e.time,Number),a=[].concat(...n.curves.map(e=>e.fields)).filter(e=>r.hasField(e)).map(e=>{let n=r.getData(e)[i],a=this.toY(n);return{priceSnap:n,ySnap:a,dist:Math.abs(a-t.y)}}).filter(e=>e.dist<=z.SNAP_PROXIMITY_PIXELS).reduce((e,t)=>e===null||t.dist<e.dist?t:e,null);P(a)&&(e.price=a.priceSnap,t.y=a.ySnap,e.time=r.getTimeData()[i],t.x=this.toX(e.time))}}alignPoints(e,t,n){let r=e.points.find(e=>e!==t);if(t!==r&&r&&r.point){let e=r.point,i=(360+-xa(e,n)*180/Math.PI)%360,a=45/2,o=i>360-a||i<a||i>180-a&&i<180+a,s=i>90-a&&i<90+a||i>270-a&&i<270+a;if(o)n.y=e.y,t.price=this.toPrice(n.y);else if(s)n.x=e.x,t.time=this.toTime(n.x);else{let r=Math.abs(n.x-e.x),i=e.y>n.y?-1:1;n.y=e.y+r*i,t.price=this.toPrice(n.y)}}}toPoint(e){if(P(this.pane.presenter.view))return this.snapTo(e)}makeAnnotation(e,t=!0){let n=Dk(e.id,!0,e.traits)(this,!1);t&&e.uid&&(n.uid=e.uid);let r=n.activePoints,i=e.points.length-r.length;return i>0&&n.addPoints(i),n.activePoints.forEach((t,n)=>{let r=e.points[n];Ze(r.price)&&Ze(r.time)&&t.update(r.price,r.time)}),n.visible=e.visible,n.locked=e.locked,n}expand(e){let t=[];switch(e.type){case`Forward`:{let n=e.curves,r=e.offsets;delete e.curves,delete e.offsets;for(let i=0;i<n.length;i++){let a=Object.assign({},e);a.curves=[n[i]],a.offset=r[i],t.push(a)}break}case`Seasonal`:{let n=e.curves,r=e.offsets;delete e.curves,delete e.offsets;let i=r.filter(e=>e>=0);for(let a=0;a<n.length;a++){let o=Object.assign({},e);o.curves=[n[a]],o.offset=r[a];let s=o.offset<0;s?o.offsets=o.offset===-1?i:De(Math.abs(o.offset),e=>e+1):o.offsets=[o.offset],(!s||o.offsets.length>1)&&t.push(o)}break}default:t.push(e)}return t}fromModel(e){this.comparison=x[e.comparison??`None`],this.scale=S[e.scale??`Linear`],this.yScale=new $E(this.scale,this),this.label=e.label,this.plots=[].concat(...e.plots.map(e=>this.expand(e))).map(e=>this.makePlot(e)),this.annotations=(e.annotations||[]).map(e=>this.makeAnnotation(e));let{chart:{fontFamily:t,backgroundColor:n},yAxis:{textColor:r,crosshair:{color:i},primaryOnTheLeft:a}}=this.pane.presenter.display,o=a??!1;this.onTheRight=this.primary&&!o||!this.primary&&o,this.crosshairIndicator.configure({position:this.onTheRight?`right`:`left`,fontFamily:t,strokeColor:i,textColor:r,backgroundColor:Aa(.15)(n)})}findIndex(e){return this.annotations.findIndex(t=>t.uid===e.uid)}addAnnotation(e){let t=this.makeAnnotation(e,!0);this.appendAnnotation(t),t.requestRedraw(),this.fireAnnotationsChanged()}appendAnnotation(e){this.findIndex(e)===-1&&this.annotations.push(e)}fireAnnotationsChanged(e=!1){this.pane.presenter.onAnnotationsUpdated(this,e)}deleteAnnotation(e,t=!0){e.isSelected&&this.pane.presenter.clearSelection();let n=this.findIndex(e);n!==-1&&this.annotations.splice(n,1),t&&this.fireAnnotationsChanged(!e.isSelected)}fliphorizontalAnnotation(e){e.flip(!0),this.fireAnnotationsChanged(!0)}flipverticalAnnotation(e){e.flip(!1),this.fireAnnotationsChanged(!0)}duplicateAnnotation(e){let t=e.axis,n=this.makeAnnotation(e.toModel(),!1);n.drawPoints(null,!0),n.offset({x:z.ANN_DUPLICATE_OFFSET,y:z.ANN_DUPLICATE_OFFSET}),t.appendAnnotation(n),n.requestRedraw(),this.fireAnnotationsChanged()}updateAnnotation(e,t){e.isSelected&&this.pane.presenter.clearSelection(),Lc(e.name,t.traits),e.updateFrom(t.traits,t.extras,t.isUndoRedo?null:t.points,t.visible,t.locked),t.isUndoRedo&&P(t.points)&&e.updateActivePoints(t.points),t.isUndoRedo||this.pane.presenter.undoRedoManager.done(vD(e,O.Moved)),e.requestRedraw(),this.fireAnnotationsChanged()}setViewBox(e){this.viewBox=e;let{y:t,height:n}=this.viewBox;this.yScale.range([Math.floor(t),Math.floor(t+n)]),this.plots.forEach(t=>t.setViewBox(e))}get fullDomain(){return P(this._fullDomain)||(this._fullDomain=this.getDataDomain().domain),this._fullDomain}updateFullDomain(e=null){if(e===null&&this.comparison!==x.None)return;let t=this.fullDomain;this._fullDomain=this.getDataDomain([e,e],t).domain}getPlotDataDomain(e,t,n){let r=e.timeSeries;if(!r.hasData)return{domain:null};let i=r.container,a=i.getTimeData(),o=e=>Te(a,+e,Number),s=P(t),c=s?o(t):0,l=P(n),u=l?o(n):a.length-1,d=e.curves.map(e=>e.fields).flat().filter(e=>e.id!==W.Change.id),f=P(e.targetFields);f&&d.push(...e.targetFields);let p={},m=t=>{let n=f?e.curves[0]:e.curves.find(e=>e.fields.includes(t));if(!P(n)||n.shift===0)return[c,u];if(!P(p[n.id])){let e=n.shiftedTimeDomain;if(!P(e))return[c,u];p[n.id]=[o(e[0]),o(e[1])]}return p[n.id]},g=t=>{let[n,r]=m(t),a=i.getData(t),o=Math.max(n,0),s=Math.min(a.length-1,r);return a.slice(o,s+1).map((n,r)=>e.priceMapper(n,r,t))},_=e=>Ee(g(e)),v=[null,null],y=e=>e.id,b=new Set(be(i.fields,d,y).map(y));e.curves.filter(e=>e.visible).map(e=>{let t=e.fields.filter(e=>b.has(e.id));e.isStackedColumn?M(Ee(t.map(e=>g(e)).reduce((e,t)=>t.map((t,n)=>(e[n]||0)+(t||0)),[])),v):t.map(e=>{M(_(e),v)})});let x=(e.annotations||[]).filter(e=>e.visible!==!1).flatMap(e=>{let t=e.getDomainPrices;return typeof t==`function`?t.call(e):[]}).filter(e=>Ze(e));x.length>0&&M(Ee(x),v);let S=oe.None,C=[h.Column,h.MultiColumn,h.StackedColumn];if(s&&l&&!e.main&&e.curves.some(e=>C.includes(e.style))){let e=v[0]>0,t=v[1]<0;e?(S=oe.Min,v[0]=0):t&&(S=oe.Max,v[1]=0)}return{domain:v,clamped:S}}getDataDomain([e,t]=[null,null],n=[null,null]){let r=F(n),i=!1;for(let n of this.plots.filter(e=>e.visible&&e.hasVisibleCurves&&!e.hasDetachedScale)){let{domain:a,clamped:o}=this.getPlotDataDomain(n,e,t);P(a)&&(M(a,r),i||=o!==oe.None)}if(!P(r))return{domain:null};let[a,o]=r;if(!P(a,o))return{domain:null};let s=[Number(a),Number(o)];s[0]===s[1]&&(--s[0],s[1]+=1);let c=oe.None;return i&&(s[0]===0?c=oe.Min:s[1]===0&&(c=oe.Max)),{domain:s,clamped:c}}setDomain(){let e=this.pane.presenter,t=e.view.xAxis.xScale.domain();if(!P(t))return;for(let e of this.plots.filter(e=>e.visible&&e.hasVisibleCurves&&e.hasDetachedScale)){let{domain:n}=this.getPlotDataDomain(e,t[0],t[1]);P(n)&&e.yScale.domain(n)}if(this.isCustomDomain)return;let{domain:n,clamped:r}=this.getDataDomain(t);if(this===e.mainAxis&&e.mainPlot?.showPrevious){let t=e.mainPlot.getPreviousValue(),r=rt(e.display,!1,`chart`,`previous`,`forceVisible`);P(t,n)&&r&&(n[0]=Math.min(n[0],t),n[1]=Math.max(n[1],t))}if(this.yScale.domain(n),P(n)){let e=this.getPadding(r);P(e)&&this.yScale.padding(e)}}getInitialPadding(){let e=vi(this.pane.presenter.hostElement),t=xi(`#${z.HEADER_SIZE_PLACEHOLDER_ID}`,e);if(!P(t)){t=Ei(e,`div`),Si(t,{display:`none`}),Ci(t,{id:z.HEADER_SIZE_PLACEHOLDER_ID,class:`bcharts-card bcharts-card-first`});let{lineHeight:n}=getComputedStyle(t);isNaN(Number.parseFloat(n))&&Si(t,{lineHeight:`120%`})}let{paddingTop:n,paddingBottom:r,marginTop:i,lineHeight:a}=getComputedStyle(t),o=this.pane.isMain?i:`0`;return this.pane.presenter.display.tooltip.mode===`cards`?[n,r,o,a].map(Number.parseFloat).reduce((e,t)=>e+t,0)+z.CARDS_Y_OFFSET:Number.parseFloat(o)}getPadding(e){let t=this.pane.presenter,n=this.viewBox?.height;if(n==null)return[0,0];let r=t.display,i=rt(r,null,`yAxis`,`minPaddingPercent`),a=rt(r,null,`yAxis`,`maxPaddingPercent`),o=P(i),s=P(a),c=o||s?0:this.getInitialPadding(),l=o?i:z.PANE_CAP_MIN_PADDING_PERCENT,u=s?a:z.PANE_CAP_MAX_PADDING_PERCENT,d=l*n,f=[s?u*n:Math.max(d,Math.min(u*n,c)),d];e===oe.Max?f[0]=z.PANE_TINY_PADDING_PIXELS:e===oe.Min&&(f[1]=z.PANE_TINY_PADDING_PIXELS);let p=t.mainPlot;return p&&p.hasEvents&&t.view&&(f[0]+=3*t.view.getEventRadius()),f}clearTicks(){this.ticks=null}getTicks(e,t=0){let{height:n}=this.viewBox,r=Wa(e,1.3),i={height:n,approxLineHeight:r,domain:this.yScale.domain()};if(P(this.ticks)&&P(i.domain)&&P(this.lastUsedOptions)&&P(this.lastUsedOptions.domain)&&i.height===this.lastUsedOptions.height&&i.approxLineHeight===this.lastUsedOptions.approxLineHeight&&i.domain[0]===this.lastUsedOptions.domain[0]&&i.domain[1]===this.lastUsedOptions.domain[1])return this.ticks;this.lastUsedOptions=i;let a=Math.floor((n+40)/(r+40)),o=this.yScale.getTicks(a),s=rt($().config,null,`overrides`,`yAxis`,`tickProvider`);if(P(s)&&typeof s==`function`&&i.height>0&&P(i.domain)){let e=F(i);e.autoTicks=F(o),o=s(e)}let{innerTickSize:c,tickPadding:l,fontSize:u}=this.config,d=null,f=this.yScale?.checkTicks(),p=f?40/4*3:40;return this.ticks=o.map(n=>{let r=Math.round(this.yScale.priceToY(n)),i=Math.abs(r-(d??r));if(f&&d!==null&&i<p)return null;d=r;let a=l_(this,n),o=e.measureText(a).width,s={x1:0,x2:0,y1:r,y2:r,dy:0,label:a,labelX:0,labelY:r+u*.32};return this.onTheRight?(s.x1=t,s.x2=s.x1+c,s.labelX=s.x2+o+l):(s.x1=t-c,s.x2=s.x1+c,s.labelX=s.x1-l),s}).filter(e=>e!==null),this.ticks}widthNeeded(e){if(!P(this.fullDomain))return z.DEFAULT_PRICE_AXIS_WIDTH;e.save();let{fontWeight:t,fontSize:n}=this.config,{chart:{fontFamily:r}}=this.pane.presenter.display;e.font=`${t} ${n}px ${r}`;let i=Math.max(...this.fullDomain.map(t=>e.measureText(l_(this,t,!0)).width)),{innerTickSize:a,tickPadding:o}=this.config,s=P(this.label)?Wa(e,1.6):0,c=i+a+2*o+s;return e.restore(),c}draw(e){let{chart:{fontFamily:t},yAxis:{gridLines:n,textColor:r,visible:i}}=this.pane.presenter.display;if(!i||!this.viewBox)return;e.save();let{x:a,y:o,width:s,height:c}=this.viewBox,{fontWeight:l,fontSize:u}=this.config;if(Ra(e,this.viewBox),e.font=`${l} ${u}px ${t}`,e.lineWidth=2,e.strokeStyle=n.color,e.textAlign=`end`,P(this.label)){e.save(),e.fillStyle=ka(.4)(r),e.translate(0,0);let t=this.onTheRight?1:-1;e.rotate(t*Math.PI/2),e.textAlign=`center`;let n=Wa(e),i=t*(o+c/2);this.onTheRight?e.fillText(this.label,i,-(a+s-n)):e.fillText(this.label,i,a+n),e.restore()}let d=this.onTheRight?a:s;e.setLineDash([]),$a(e,d,o,o+c);let f=this.getTicks(e,d);this.drawTicks(e,f,r),this.drawPriceAdornments(e),e.restore()}drawTicks(e,t,n){t&&(e.fillStyle=n,t.forEach(t=>{e.fillText(t.label,t.labelX,t.labelY+t.dy)}))}drawCrosshairIndicator(e,t){if(!this.plots.some(e=>e.visible&&e.hasVisibleCurves)||!this.pane.presenter.display.yAxis.crosshair.enabled||!Number.isFinite(t)||!this.yScale)return;let n=this.onTheRight?this.viewBox.x:this.viewBox.width,r=this.yScale.yToPrice(t);if(r==null)return;let i=l_(this,r);this.crosshairIndicator.draw(e,n,t,i)}get indicatorHeight(){return this.config.fontSize+this.config.indicatorPadding+this.config.indicatorPadding}drawPriceAdornments(e){let t=this.pane.presenter,{chart:{fontFamily:n,previous:r},yAxis:{showLastValue:i,preventLabelOverlap:a,includePercentChangeWithLastValue:o}}=t.display,s=t.view,c=[],l=(e,t,n,r,i,a)=>{if(t!=null){let s=t;t=e.priceMapper(t,a,i);let l,u=e.is(C.Symbol)||e.is(C.Expression);if(o&&u){let t=e.axis.comparison===x.Percent?x.None:x.Percent;l=e.priceMapper(s,a,i,t)}let d=e.hasDetachedScale?e.metaData.format(t,i):void 0,f=P(l)?1:2;c.push({y:e.priceToY(t),formattedValue:d,value:t,auxValue:l,color:n,halfHeight:Math.round(this.indicatorHeight/f),priority:r})}};this.plots.forEach(e=>{if(!(!e.visible||!e.hasVisibleCurves||!e.timeSeries||!e.timeSeries.hasData)){if(i===`All`||i===`Main`&&e.main){let t=e.main?1:3;tA(e).filter(e=>e.value!=null&&e.index!==-1).forEach(n=>l(e,n.value,n.color,t,n.field,n.index))}e.showPrevious&&l(e,e.getPreviousValue(),r.color,2,W.PreviousClose,void 0)}}),this.annotations.concat(this.plotAnnotations).forEach(e=>{c.push(...e.getPriceScaleAdornments().map(e=>({y:this.toY(e.price),value:this.priceMap(e.price),color:e.color,halfHeight:Math.round(this.indicatorHeight/2),priority:4})))}),c.sort((e,t)=>e.y-t.y),a&&Gk(c,this.viewBox);let u=({y:t,value:r,formattedValue:i,color:a,auxValue:o})=>{let{leftOffset:c,rightOffset:l}=s,u=this.onTheRight?this.pane.viewBox.width-l:c,d=Pa(a),f=new Hk({position:this.onTheRight?`right`:`left`,fontSize:this.config.fontSize,padding:this.config.indicatorPadding,fontFamily:n,textColor:d,strokeColor:a,backgroundColor:a}),p=i||l_(this,r),m,h=this.comparison===x.Percent;N(o)&&(m=h?c_(this,o):s_(o)),f.draw(e,u,t,p,m)};a?c.forEach(u):Qk.forEach(e=>c.filter(t=>t.priority===e).forEach(u))}};function rA(e){let t=e.map(e=>e.plots).flat().filter(e=>C[e.type]==C.Symbol).map(e=>e.symbol).map(e=>di(e)).filter(e=>e!==null).map(e=>e.getFullYear());return t.length==0?null:Math.max(...t)}var iA=Symbol.for(`__dloacip__`),aA=class{id;axes=[];height=0;alignedToYear=null;viewBox;constructor(e){this.presenter=e,this.id=bt()}fromModel(e){this.height=e.height,e.alignOnExpirations===!0&&(this.alignedToYear=rA(e.axes)),this.axes=e.axes.map((e,t)=>{let n=new nA(this);return n.primary=t===0,n.fromModel(e),n},this)}getBounds(){return this.viewBox}setViewBox(e){this.viewBox=e}drawBackground(e){P(this.viewBox)&&(this.drawAxes(e),e.save(),this.clipToNoScales(e),this.drawGrid(e),e.restore())}draw(e){P(this.viewBox)&&(e.save(),this.clipToNoScales(e),this.drawPrevious(e),this.drawPlots(e),this.drawAnnotations(e),this.drawLogo(e),e.restore())}drawLogo(e){!this.isMain||this.presenter[iA]===!1||aO(e,this.getBoundsWithoutScales())}drawAxes(e){for(let t of this.axes)t.draw(e)}drawPrevious(e){let t=this.presenter.mainPlot;if(t.showPrevious&&this.isMain){let n=t.getPreviousValue();if(n=t.priceMapper(n,void 0,W.PreviousClose),n!=null){let{leftOffset:r,rightOffset:i}=this.presenter.view,a=r,o=this.viewBox.width-i,s=t.axis.yScale.priceToY(n),{color:c,dashStyle:l,lineWidth:u}=this.presenter.display.chart.previous,d=Ca(l);e.save(),e.strokeStyle=c,e.lineWidth=u,e.setLineDash(d),eo(e,s,a,o),e.restore()}}}getBoundsWithoutScales(){let e=this.viewBox.duplicate(),t=this.presenter.view;return e.x=t.leftOffset,e.width-=t.leftOffset+t.rightOffset,e}clipToNoScales(e){Ra(e,this.getBoundsWithoutScales())}drawAnnotations(e){e.save();let{chart:{fontFamily:t},yAxis:{fontSize:n}}=this.presenter.display;e.font=`${n??12}px ${t}`;let r=t=>t.draw(e,!0);this.axes.forEach(e=>{e.annotations.forEach(r),e.plotAnnotations.forEach(r)}),e.restore()}drawGrid(e){let{chart:{fontFamily:t},yAxis:{gridLines:n,visible:r,minorGridLines:i}}=this.presenter.display;if(!r||!n.visible)return;let{lineWidth:a,color:o,dashStyle:s}=n;e.save();let c=!(e=>e.plots.some(e=>e.visible&&e.hasVisibleCurves&&!e.hasDetachedScale))(this.axes[0])&&this.axes.length>1,l=this.axes[+!!c],{fontWeight:u,fontSize:d}=l.config;e.font=`${u} ${d}px ${t}`;let f=l.getTicks(e),{leftOffset:p,rightOffset:m}=this.presenter.view,h=p,g=this.viewBox.width-m,_=(t,n,r)=>{e.lineWidth=t,e.strokeStyle=n,e.setLineDash(Ca(r)),e.beginPath()};if(_(a,o,s),f.forEach(t=>{e.moveTo(h,t.y1),e.lineTo(g,t.y2)}),e.stroke(),i&&i.visible&&f.length>=2){let{lineWidth:t,color:n,dashStyle:r}=i,a=(f[0].y1-f[1].y1)/5;_(t,n,r),f.forEach(t=>{for(let n=1;n<5;n++){let r=Math.ceil(t.y1+n*a);e.moveTo(h,r),e.lineTo(g,r)}}),e.stroke()}e.restore()}drawYCrosshair(e,t){let{yAxis:{crosshair:{enabled:n,showValue:r,color:i,dashStyle:a}}}=this.presenter.display;if(!n)return;let o=Ca(a);e.strokeStyle=i,e.setLineDash(o);let s=this.presenter.view.leftOffset,c=this.viewBox.width-this.presenter.view.rightOffset,l=vo();l.prolog(e),eo(e,l.adjust(t.y),l.adjust(s),l.adjust(c)),l.epilog(e),r&&this.axes.forEach(n=>{n.drawCrosshairIndicator(e,t.y)})}drawNoData(e){e.save(),e.font=`800 14px ${this.presenter.display.chart.fontFamily}`,e.fillStyle=`#f00`,Ja(e,$().config.noDataText||z.NO_DATA_TEXT,{x:this.viewBox.centerX,y:this.viewBox.centerY},T.Center),e.restore()}get isMain(){let e=this.presenter.mainPlot;return this.axes.some(t=>t.plots.includes(e))}drawPlots(e){e.save();let t=this.presenter.mainPlot,n=this.presenter.display.chart.showNoDataText,r=!P(n)||n,i=t=>t.draw(e),a=new Map,o=t=>t.drawTopmost(e,a),s=!0,c=n=>{for(let e of this.axes){for(let r of e.plots){let e=r.isEmpty();s=s&&r.main&&e,r!==t&&!e&&n(r)}e.plots.includes(t)&&!t.isEmpty()&&n(t)}r&&s&&this.drawNoData(e)};c(i),c(o),e.restore()}};function oA(e,t){return{width:e,spacing:t,get totalWidth(){return this.width+this.spacing},offset:0}}var sA=class extends GE{marginBars;bar;resetBar;wasZoomed;fitAllData;constructor(e,t){super(),this.timeline=e,this.aggregation=t;let n=e.presenter.display;this.marginBars=n.xAxis.marginBars||0,this.bar=oA(rt(n,z.DEFAULT_BAR_WIDTH,`chart`,`bar`,`width`),rt(n,z.DEFAULT_BAR_SPACING,`chart`,`bar`,`spacing`)),this._extent=null,this.wasZoomed=!1,this.fitAllData=!1}extent(e){return WE.call(this,`_extent`,e)}get presenter(){return this.timeline.presenter}get display(){return this.presenter.display}scaleBarToFit(){if(this.wasZoomed)return;if(this.fitAllData)return this._domain=null,this.scaleBarToFitDensity(this.timeline.withoutPrologEpilogLength);let e=this.display.xAxis.visibleRange;if(P(e))return this.scaleBarToFitRange([e.from,e.to]);let t=this.display.density;if(Number.isFinite(t))return this.scaleBarToFitDensity(t);let n=this.display.period;if(Number.isFinite(n))return this.scaleBarToFitPeriod(n)}deriveExtentsFromBarWidth(e){if(!P(this._range)||this.timeline.length===0)return null;let t=this._range[1]-this._range[0],n=t/e.totalWidth,r=Math.ceil(n);e.offset=t-r*e.totalWidth;let i=this.timeline.lastSeriesIndex+this.marginBars,a=this._domain&&this._domain[1];return a&&(i=Te(this.timeline,+a,Number,__)),[i-r+1,i]}adjustDomain(){if(!P(this._range))return;this.scaleBarToFit();let e=this.deriveExtentsFromBarWidth(this.bar);if(P(e))this.extent(e);else return;this.setDomainFromExtent()}xToTime(e){if(!this.ready)return null;let t=e-this._range[0]-this.bar.offset,n=Math.floor(t/this.bar.totalWidth),r=this._extent[0]+n;return this.timeline.at(r)}timeToIndex(e){return this.ready?(e=typeof e==`number`?e:+e,Te(this.timeline,e,Number,__)):null}indexToX(e){let t=e-this._extent[0];return this.bar.width/2+this.range()[0]+this.bar.offset+t*this.bar.totalWidth}timeToX(e){if(!this.ready)return null;let t=this.timeToIndex(e);return this.indexToX(t)}zoom(e){let t=e,n=t*this.bar.width/100,r=this.bar.width-n,i=this.bar.spacing-t*this.bar.spacing/100;if(r>z.MAXIMUM_BAR_WIDTH||r<z.MINIMUM_BAR_WIDTH)return!1;let a=oA(r,i),o=this.deriveExtentsFromBarWidth(a);return this.isUsableExtent(o)?(this.setBar(r,i),this.adjustDomain(),this.wasZoomed=!0,!0):!1}scaleBarToFitRange(e,t=!0){let n=(e,t,n,r)=>P(e)?Te(this.timeline,e,Number,__,n,r):t,{from:r,to:i}=this.presenter.data.range||{},a=+e[0]===r&&+e[1]===i,{firstSeriesIndex:o,lastSeriesIndex:s}=this.timeline,c=a?o:void 0,l=a?s:void 0,u=[n(e[0],o,c,l),n(e[1],s,c,l)];this.timeline.at(u[1])>e[1]&&(u[1]=Math.max(0,u[1]-1));let d=u[1]-u[0]+1,f=t?this.marginBars:0;u[1]+=f,this.extent(u),this.setDomainFromExtent(),this.scaleBarToFitDensity(d,t)}scaleBarToFitDensity(e,t=!0){let n=Math.max(z.MINIMUM_BARS_VISIBLE,e),r=t&&this.display.xAxis.marginBars||0,i=(this._range[1]-this._range[0])/(n+r);this.setBar(2/3*i,1/3*i,!1)}scaleBarToFitPeriod(e){let t=this.timeline.lastSeriesIndex,n=this.timeline.at(t),r=n,i=t,a=this.presenter.data.aggregation;if(a.isEndOfDay||a.isIntraday&&e>=z.INTRA_THRESHOLD)for(;i>0&&cn(n,r)<e;)i--,r=this.timeline.at(i);else if(!a.isTick){let t=Math.floor(e/z.ONE_DAY_MILLIS),r=e=>pn(e,zt(e)),a=r(n),o=n;for(;i>0;){let e=this.timeline.at(i),n=en(e,o);if(t===0){if(r(e)<=a||!n)break}else n||(t--,o=e);i--}}this.scaleBarToFitDensity(t-i+1)}setBar(e,t,n=!0){let[r,i]=yt(e,t,z.MINIMUM_BAR_WIDTH,z.MAXIMUM_BAR_WIDTH);this.bar.width=r,this.bar.spacing=i,this.wasZoomed||(this.resetBar={width:r,spacing:i}),n&&(this.presenter.model.display.chart.bar={width:e,spacing:t})}resetZoom(){P(this.resetBar)?(this.bar.width=this.resetBar.width,this.bar.spacing=this.resetBar.spacing):(this.bar.width=z.DEFAULT_BAR_WIDTH,this.bar.spacing=z.DEFAULT_BAR_SPACING),delete this.presenter.model.display.chart.bar,this.adjustDomain()}isUsableExtent(e){return P(e)&&P(e[0],e[1])&&e[0]>=0&&e[1]<this.timeline.withPrologEpilogLength&&e[1]-e[0]>=z.MINIMUM_BARS_VISIBLE}shiftBars(e,t=null){if(!this._extent)return;let n=this._extent.map(t=>t+e);this.isUsableExtent(n)&&(P(t)&&(this.bar.offset=t),this.extent(n),this.setDomainFromExtent())}setDomainFromExtent(){this.domain(this.extent().map(e=>this.timeline.at(e)))}pan(e){if(!Number.isFinite(e)||e===0)return;let t=e%this.bar.totalWidth,n=this.bar.offset+t,r=Math.sign(e),i=-(e<0?Math.ceil:Math.floor)(e/this.bar.totalWidth);(n>this.bar.totalWidth||n<-this.bar.totalWidth)&&(i+=n>0?-1:1,n-=r*this.bar.totalWidth),this.shiftBars(i,n)}getSeriesThatCouldLoadMoreData(){let e=this.domain();if(!P(e)||!P(e[0]))return[];let t=e[0].getTime();return this.timeline.presenter.allPlots.map(e=>e.timeSeries).filter(e=>{if(!P(e)||!e.hasData||e.container.size===0||e.canLoadMoreData!==!0)return!1;let n=e.container.getTimeData()[0];return P(n)&&t<=n.getTime()})}};function cA(e){return{date:e,priority:1,text:o_(e)}}var lA=class{xScale;ticks;lastUsedOptions;wasPanned;panningXAxisAllowed;config;isVisible;crosshairIndicator;viewBox;overrideTickGetter;overrideFormatter;contractParityCache=null;contractParityCacheKey=null;constructor(e){this.view=e,this.xScale=new sA(e.presenter.timeline,e.presenter.data.aggregation),this.ticks=null,this.lastUsedOptions=null,this.wasPanned=!1,this.panningXAxisAllowed=rt(e.presenter.display,!0,`xAxis`,`panning`),this.updateConfigFromModel();let t=e.presenter.renderTo.id,n=rt($().config,null,`overrides`,`xAxis`,`tickProvider`);P(n)&&typeof n==`function`&&(this.overrideTickGetter=se(n,t));let r=rt($().config,null,`overrides`,`xAxis`,`formatter`);P(r)&&typeof r==`function`&&(this.overrideFormatter=se(r,t))}updateConfigFromModel(){let{chart:{fontFamily:e,backgroundColor:t,fontSize:n},xAxis:{textColor:r,visible:i,fontSize:a,crosshair:{color:o}}}=this.view.presenter.display;this.config={innerTickSize:5,tickPadding:5,indicatorPadding:5,fontWeight:400,fontSize:a||n||12},this.isVisible=i,this.crosshairIndicator=new Hk({position:`bottom`,fontSize:this.config.fontSize,fontFamily:e,padding:this.config.indicatorPadding,strokeColor:o,textColor:r,backgroundColor:Aa(.15)(t),arrowLength:this.config.innerTickSize})}setDomain(){this.xScale.adjustDomain();let e=this.view.presenter.display.period===z.FIFTY_YEARS_MILLIS;P(this.xScale.extent())&&!e&&this.checkForMoreData()}zoom(e){let t=this.xScale.zoom(e);return this.checkForMoreData(),t}checkForMoreData(){this.xScale.getSeriesThatCouldLoadMoreData().forEach(e=>e.loadMoreData())}shouldScrollIntoView(e){let t=this.xScale.extent();return P(t)?e-this.xScale.timeline.lastSeriesIndex>=0&&e-t[1]<=1:!1}pan(e){this.panningXAxisAllowed&&(this.xScale.pan(e),this.checkForMoreData(),this.view.setPriceAxesDomains(),this.wasPanned=!0)}get wasVisibleRangeChanged(){return this.wasPanned||this.xScale.wasZoomed}resetZoom(){this.xScale.resetZoom()}get barsToLast(){let e=this.xScale.timeline.lastSeriesIndex+this.getMaxCurveOffset(),t=this.xScale.extent();return e-(t?t[1]:e)}canGoToLast(){return this.barsToLast>0}getMaxCurveOffset(){return Math.max(...this.view.presenter.allCurves.map(e=>e.shift))}goToLatest(e=!1){if(this.canGoToLast()||e){let e=this.barsToLast===0?0:this.barsToLast+this.xScale.marginBars+1;this.xScale.shiftBars(e),this.view.setPriceAxesDomains(),this.view.redraw()}}setViewBox(e){this.viewBox=e;let{x:t,width:n}=this.viewBox;this.xScale.range([t,t+n])}heightNeeded(e){if(!this.isVisible)return 0;let t=this.view.presenter.display.chart.fontFamily,{fontWeight:n,fontSize:r}=this.config;e.save(),e.font=`${n} ${r}px ${t}`;let{innerTickSize:i,tickPadding:a,indicatorPadding:o}=this.config,s=Wa(e,1)+i+a+o;return e.restore(),s}getTickGetter(e){if(this.overrideTickGetter)return this.overrideTickGetter;let t=this.view.presenter.display.xAxis.isOrdinal||!1,n=Ug(e);return t?cA:e=>n.getTick(e)}getTicks(e){if(P(this.lastUsedOptions)&&((e,t)=>e.unit===t.unit&&e.size===t.size&&e.spec===t.spec)(e.agg,this.lastUsedOptions.agg)&&e.unitWidth===this.lastUsedOptions.unitWidth&&e.barWidth===this.lastUsedOptions.barWidth&&e.extent[0]===this.lastUsedOptions.extent[0]&&e.extent[1]===this.lastUsedOptions.extent[1]&&e.formatString===this.lastUsedOptions.formatString&&e.minTickInterval===this.lastUsedOptions.minTickInterval&&P(this.ticks))return this.ticks;this.lastUsedOptions=e;let t=this.getTickGetter(e),n=Math.max(0,e.extent[0]),r=Math.min(this.xScale.timeline.withPrologEpilogLength-1,e.extent[1]+1);return this.ticks=this.view.presenter.timeline.slice(n,r).map((e,r)=>{if(!P(e)||Number.isNaN(e.getTime()))return null;let i=t(e);return P(i)&&(i.index=n+r),i}).filter(e=>P(e)),this.ticks}normalizeDuration(e){let t=Hg(),n=t.Year,r=Object.keys(t);for(let i=0;i<r.length-1;++i){let a=t[r[i]].Multipliers,o=t[r[i+1]].Multipliers;if(e<=(xe(a)+Se(o))/2){n=t[r[i]];break}}let i=n.Multipliers,a=i.findIndex(t=>e<t),o=a===-1?xe(i):i[a];return n.Period===`P1M`?o*=.9:n.Period===`P1W`&&(o*=.84),o}draw(e){if(!this.isVisible)return;let{xAxis:{gridLines:t,textColor:n,minTickInterval:r,tickPixelInterval:i,format:a,forceTicksVisible:o},chart:{fontFamily:s}}=this.view.presenter.display,{fontWeight:c,fontSize:l,innerTickSize:u,tickPadding:d}=this.config,{x:f,y:p,width:m}=this.viewBox,{lineWidth:h,color:g,dashStyle:_}=t,v=Ca(_);e.textAlign=`center`,e.font=`${c} ${l}px ${s}`,e.lineWidth=1,e.strokeStyle=g,e.fillStyle=n,e.setLineDash([]),eo(e,p,f,f+m);let y=this.xScale.extent(),b=e=>!P(e)||!P(e[0],e[1]);if(b(y))return;let x=t=>e.measureText(t).width,S=(e,t)=>P(e)?cn(t,e):z.FIFTY_YEARS_MILLIS,C=i>0?i:120,w=this.xScale.domain();if(b(w))return;let T=(w[1].getTime()-w[0].getTime())*C*.6/m,ee=this.normalizeDuration(T),E=this.view.presenter.data.aggregation.isEndOfDay,D=(e,t)=>{if(e.date.valueOf()===z.ZERO_DATE.valueOf())return!0;if(S(e.date,t.date)<r)return!1;let n=t.x-e.x,i=t.date.getTime()-e.date.getTime()>=ee,a=n>C;return!(e.x+e.textWidth/2>=t.x-t.textWidth/2)&&(a||(E?i:!1))},te=f+m,ne=({text:n,x:r,date:i,forced:a})=>{P(i)&&(a||$a(e,r,p,p+u),e.fillText(n,r,p+u+d+l*.71),t.visible&&!a&&(e.save(),e.lineWidth=h,e.setLineDash(v),$a(e,r,0,p),e.restore()))},re={agg:this.view.presenter.data.aggregation,unitWidth:x(`M`),barWidth:this.xScale.bar.width,extent:y,formatString:a,minTickInterval:r||0,duration:T},ie=this.getTicks(re),ae=e=>{let{x:t,textWidth:n}=e,r=t;if(o){let i=n/2;r=t-i<f?f+i:t,r=r+i>te?te-i:r,e.x=r,e.forced=t!==r}else e.forced=!1},O={date:z.ZERO_DATE,priority:999,x:-999,text:``,index:-1,textWidth:0};ie.forEach(e=>{e.x=this.xScale.indexToX(e.index),e.textWidth=x(e.text),ae(e),D(O,e)?(ne(O),O=e):e.priority<O.priority&&(O=e)}),ne(O),this.drawTimeTransitions(e),this.drawTimeAdornments(e)}drawTransitionsFor(e,t,n,r,i){let a=this.xScale.domain(),o=this.view.presenter?.mainPlot?.timeSeries.container;if(!N(o))return;let s=o.getTimeData(),c=t===null?s:o.getData(t);if(!P(c))return;let l=Te(s,+a[0],Number),u=Te(s,+a[1],Number,we,l);if(l<u){let t=this.viewBox.y,a=this.view.leftOffset,o=this.viewBox.x+this.viewBox.width;if(r.save(),i){r.fillStyle=e.fillColor;let d=c[l],f=Math.max(a,this.xScale.timeToX(s[l]));for(let e=l+1;e<=u;++e){let a=e<c.length?c[e]:null;if(e===u||n(a,d)){let n=e<s.length?s[e]:null,c=N(n)?this.xScale.timeToX(n):o;c=Math.min(c,o),i(d)%2==0&&r.fillRect(f,0,c-f,t),d=a,f=c}}}let d=vo();d.prolog(r),r.strokeStyle=e.color,r.lineWidth=e.width,r.setLineDash(Ca(e.dashStyle));let f=null;for(let e=l;e<u;++e){let i=c[e];if(n(i,f)){let n=s[e],a=this.xScale.timeToX(n);P(a,f)&&$a(r,a,0,t),f=i}}d.epilog(r),r.restore()}}drawTimeTransitions(e){let t=this.xScale.domain();if(!N(t)||!P(t[0],t[1]))return;let n=this.view.presenter,{xAxis:{contractTransition:r,cycleTransition:i}}=n.display,a=(e,t)=>e!==t;if(r.enabled&&n?.data?.aggregation.isMultiContract){let t=(n?.mainPlot?.timeSeries.container)?.getData(W.Symbol);if(t&&t.length>0){let n=t[0];if(this.contractParityCacheKey!==n||!this.contractParityCache){let e=[...new Set(t)];e.sort((e,t)=>{let n=di(e),r=di(t);return(n?.getTime()??0)-(r?.getTime()??0)});let r=0;if(this.contractParityCache)for(let t=0;t<e.length;t++){let n=e[t],i=this.contractParityCache.get(n);if(i!==void 0){r=(i-t)%2==0?0:1;break}}this.contractParityCache=new Map,e.forEach((e,t)=>this.contractParityCache.set(e,t+r)),this.contractParityCacheKey=n}this.drawTransitionsFor(r,W.Symbol,a,e,e=>this.contractParityCache.get(e)??0)}}i.enabled&&(n?.data?.aggregation.isIntraday?this.drawTransitionsFor(i,W.TradingDay,a,e,e=>e):n?.data?.aggregation.unit===g.Day?this.drawTransitionsFor(i,null,(e,t)=>!Nr(e,t),e,e=>e.getMonth()):n?.data?.aggregation.unit===g.Week&&this.drawTransitionsFor(i,null,(e,t)=>!Fr(e,t),e,e=>e.getFullYear()))}getAnnXScore(e,t){return[en,jr,Nr,Fr].map((n,r)=>(4-r)*Number(n(e,t))).reduce((e,t)=>e+t,0)}annTimeToX(e){let t=this.xScale.timeToIndex(e);if(!N(t))return null;let n=this.xScale.timeline.at(t),r=this.xScale.timeToX(e);if(t>0&&n.valueOf()!==e.valueOf()){let i=t-1,a=this.xScale.timeline.at(i),o=this.xScale.indexToX(i);if(!this.view.presenter.display?.xAxis?.isOrdinal){if(a.valueOf()>e.valueOf())return r;let t=this.getAnnXScore(a,e),i=this.getAnnXScore(n,e);return t>i?o:i>t?r:this.view.presenter?.data?.aggregation?.isIntraday?o:r}let s=(e.valueOf()-a.valueOf())/(n.valueOf()-a.valueOf());return o+(r-o)*s}else return r}drawTimeAdornments(e){e.save();let t=this.view.presenter,{chart:{fontFamily:n},xAxis:{preventLabelOverlap:r}}=t.display,i=[],a=t.mainPane?.getBoundsWithoutScales()??new za(0,0,0,0);t.allAnnotations.concat(t.plotAnnotations).forEach(n=>{i.push(...n.getTimeScaleAdornments().map(n=>{let r=this.annTimeToX(n.time);if(r<a.x||r>a.x+a.width)return null;let i=u_(t,this.view.presenter?.display?.xAxis?.isOrdinal?n.time:this.xScale.xToTime(r)),o=e.measureText(i).width/2;return{x:r,value:i,color:n.color,halfWidth:o}}).filter(e=>e!=null))}),i.sort((e,t)=>e.x-t.x),r&&Zk(i,this.viewBox),i.forEach(t=>{let r=Pa(t.color);new Hk({position:`bottom`,fontSize:this.config.fontSize,fontFamily:n,padding:this.config.indicatorPadding,strokeColor:z.COLOR_TRANSPARENT,textColor:r,backgroundColor:t.color,arrowLength:this.config.innerTickSize}).draw(e,t.x,this.viewBox.y+1,t.value)}),e.restore()}drawCrosshair(e,{x:t}){if(!Number.isFinite(t))return!1;let n=this.view.presenter,r=n.display.xAxis,{enabled:i,showValue:a,color:o,dashStyle:s,format:c}=r.crosshair,l=this.xScale.xToTime(t);if(!(P(l)&&nn(l)))return!1;if(!i)return!0;t=this.xScale.timeToX(l);let u=Ca(s);e.strokeStyle=o,e.setLineDash(u);let d=vo();if(d.prolog(e),$a(e,d.adjust(t),0,d.adjust(this.viewBox.y)),d.epilog(e),!a||!r.visible)return!0;let f=u_(n,l,P(r.format)?c:void 0);this.crosshairIndicator.draw(e,t,this.viewBox.y+1,f,void 0,this.viewBox.height-2);let{plotHover:p}=n.display.chart;return p&&n.allPlots.filter(e=>e.visible).forEach(n=>n.curves.forEach(n=>n.drawHover(e,l,t))),!0}},uA={mousedown:`onMouseDown`,mousemove:`onMouseMove`,mouseup:`onMouseUp`,dblclick:`onMouseDblClick`,contextmenu:`onContextMenu`,mouseover:`onMouseEnter`,mouseout:`onMouseLeave`,wheel:`onWheel`,touchstart:`onMouseDown`,touchmove:`onMouseMove`,touchend:`onMouseUp`,keydown:`onKeyDown`},dA={Shift:`shiftKey`,Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`},fA=e=>e.startsWith(`touch`),pA=class{subscriptions=[];constructor(e){this.view=e}init(e){let t=Ie();Object.keys(uA).filter(e=>!fA(e)||t).forEach(t=>{let n=e=>{let n=uA[t];this.notifyActiveTool(n,e)===!0&&e.preventDefault()};e.addEventListener(t,n),this.subscriptions.push(()=>{e.removeEventListener(t,n)})})}shutdown(){this.subscriptions.forEach(e=>e()),this.subscriptions=[]}notifyActiveTool(e,t){let n=this.view.presenter;if(n===void 0||n.activeTool===null)return!1;let r=this.getPayload(t,n),i=n.activeTool,a=!1;return typeof i[e]==`function`&&(a=i[e](r)||!1),a}getPayload(e,t){let n=e instanceof MouseEvent,r=Ie()&&e instanceof TouchEvent;if(n||r){let i={x:0,y:0};if(r&&e.touches.length===1){let t=e.touches[0],{left:n,top:r}=e.target.getBoundingClientRect();i.x=t.clientX-n,i.y=t.clientY-r}else n&&(i.x=e.offsetX,i.y=e.offsetY);let a={button:n?e.which:E.Left,offset:i,view:t.view,presenter:t,originalEvent:e,getModifier:t=>e[dA[D[t]]]};if(e instanceof WheelEvent&&(a.delta=e.shiftKey?e.deltaX:e.deltaY),r&&e.touches.length===2){let t=e.touches[0],n=e.touches[1];a.pinchZoom=!0;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;a.pinchDistance=Math.sqrt(r*r+i*i)}return this.view.splitters.forEach((e,t)=>{e?.contains(i)&&(a.splitter=[t,t+1])}),t.panes.forEach(e=>{let t=e.getBounds();if(P(t)&&t.contains(i)){let t=e.axes.find(e=>e.viewBox?.contains(i));if(t)a.priceAxis=t;else{let t=e.axes.find(e=>e.primary);t&&(a.point=t.toAnnotationPoint(i))}}}),a}else if(e instanceof KeyboardEvent)return{key:e.key??e.keyIdentifier,code:e.keyCode||e.charCode,repeat:e.repeat,presenter:t,getModifier:t=>e.getModifierState(D[t])}}},mA=Rh.concat(W.PercentChange);function hA(e){let t=[],n=new Map;for(let r of e){if(!r.isSeasonal){t.push([r]);continue}let e=n.get(r.uid);e||(e=[],n.set(r.uid,e),t.push(e)),e.push(r)}return t}function gA(e,t){let n=hA(t),r=e.isSeasonal?n.find(t=>t.some(t=>t.uid===e.uid)):void 0,i=[];return r&&i.push(r),n.forEach(e=>{e!==r&&i.push(e)}),i}function _A(e,t){return gA(e,t).flat().filter(t=>t!==e)}var vA=class{id;isOptionsChart=!1;constructor(e){this.view=e,this.id=`bc-legend-${bt()}`}getLegendElem(){let e=this.view.el;return wi(this.id,e,`div`)}update(){let e=this.getLegendElem(),t=U_(this.presenter.mainPane);if(!P(t))return;this.isOptionsChart=this.mainPlot?.title?.startsWith(z.FAKE_SYMBOL_PREFIX)??!1;let{left:n,right:r,top:i,width:a}=t;YD(e,`row`,n,r,i,a),Ti(e,{"bcharts-card":!0,"bcharts-legend":!0});let o=this.mainPlot,s=o.isSeasonal||this.isOptionsChart?this.getFirstColorBadge(o):``,c=this.getPlotTitle(o),l=this.maybeGetQuote();if(o.isSeasonal){e.innerHTML=this.renderSeasonalLegend();return}e.innerHTML=`${this.div(`${s} ${c} `)+this.div(`${l}`)} ${this.maybeGetAdditionalPlots()}`}remove(){bi(this.getLegendElem())}get presenter(){return this.view.presenter}get mainPlot(){return this.presenter.mainPlot}getAttributes(e){return Object.entries(e).map(([e,t])=>t===null?``:`${e} = "${at(Array.isArray(t)?t.join(` `):t)}" `).join(` `)}span(e,t={}){return`<span ${this.getAttributes(t)}>${e}</span>`}div(e){return`<div class="plot" style="flex: 0 0 auto">${e}</div>`}spanAsPlot(e){return`<span class="plot" style="display:inline-flex; align-items:center">${e}</span>`}divAsGroup(e,t=!1){return`<div class="plot-group" style="display:block; flex:0 0 100%;${t?` margin-top:2px;`:``}">${e}</div>`}get meta(){return this.mainPlot.metaData}isSingleSymbolSeasonal(e){return e.isSeasonal&&!e.hasComputation}format(e,t,n){return(n??this.meta).format(e,t)}spanAsName(e){return this.span(it(e),{class:`field-name`})}spanAsValue(e,t=null,n=null){return this.span(it(e),{class:[`field-value`,t],style:n})}getQuoteFromRecord(e){let t=mA.map(t=>e.getValue(t));if(k(t)){let e=t[4],n=`field-${e>0?`up`:e<0?`down`:`same`}-value`;return`${t.slice(0,-1).map((e,t)=>{let r=mA[t],i=this.format(e,r),a=J_(r);return`${this.spanAsName(a)}${this.spanAsValue(i,n)}`}).join(` `)} ${this.spanAsValue(`(${this.format(xe(t),xe(mA))})`,n)}`}return``}maybeGetQuote(){if(this.mainPlot.isSymbol&&this.mainPlot.timeSeries?.record?.isValid){let e=$().getRecordSource().getRecord(this.mainPlot.timeSeries.record.symbol);return this.getQuoteFromRecord(e)}else if(this.mainPlot.isExpression&&this.mainPlot.record.isValid){let e=this.mainPlot.record;return e.evaluate(),this.getQuoteFromRecord(e)}return``}getTitle(e,t,n,r=e.symbol){let i=t?`value-main`:null,a=`${it(e.name)} (${it(r)})`,o=this.span(a,{"data-plot-uid":n,class:[`value-title`,i]}),s=it(e.exchange);return`${o}${t?` ${this.span(s,{class:`value-subtitle`})}`:``}`}getPlotTitle(e){if(e.isSymbol){let t=z_(e.title,e.metaData.symbol);return this.getTitle(e.metaData,e.main,e.uid,t)}else if(this.isSingleSymbolSeasonal(e)&&e.offset===0&&(e.symbols?.length??0)>0){let t=$().getMetaDataSource().getMetaData(e.getActualSymbols()[0]);return this.getTitle(t,!0,e.uid)}else{let t=it(B_(e)??e.title);return this.span(t,{"data-plot-uid":e.uid,class:`value-title`})}}getCondensedSeasonalTitle(e){return!this.isSingleSymbolSeasonal(e)||!e.isPlain||!Ze(e.offset)?null:String(new Date().getFullYear()-e.offset)}getSeasonalFamilyTitle(e,t){if(t)return this.getPlotTitle(e);let n=this.getCondensedSeasonalTitle(e);return n?this.span(n,{"data-plot-uid":e.uid,class:`value-title`}):this.getPlotTitle(e)}renderSeasonalLegend(){let e=this.presenter.mainPane.axes.map(e=>e.plots).flat();return gA(this.mainPlot,e).map((e,t)=>{let n=e.map((e,t)=>{let n=this.getFirstColorBadge(e),r=e.isSeasonal?this.getSeasonalFamilyTitle(e,t===0):this.getPlotTitle(e);return this.spanAsPlot(`${n} ${r}`)}).join(` `);return e[0]?.isSeasonal?this.divAsGroup(n,t>0):n}).join(` `)}getFirstColorBadge(e){return D_(`rectangle`,e.mainCurve.colors[0])}getLastValues(e){return this.isOptionsChart?``:tA(e).filter(e=>P(e.value)).map(t=>{let n=this.format(t.value,t.field,e.metaData);return this.spanAsValue(n,null,`color:${t.color}`)}).join(` `)}canBeDeleted(e){return e.isStudy||!e.main&&(e.isSymbol||this.isOptionsChart)}maybeGetAdditionalPlots(){let e=this.presenter.mainPane.axes.map(e=>e.plots).flat(),t=_A(this.mainPlot,e),n=this.presenter.display.yAxis.showLastValue;return t.length>0?t.map(e=>{let t=this.getFirstColorBadge(e),r=this.getPlotTitle(e),i=this.canBeDeleted(e)?L_(e.uid):``,a=n!==`All`&&!e.isSeasonal?this.getLastValues(e):``;return this.div(`${i} ${t} ${r} ${a}`)}).join(` `):``}},yA=class{presenter;splitters=[];canvasContainer=null;mouseCanvas=null;mainCanvas=null;mouseContext;mainContext;leftOffset=0;rightOffset=0;legend;notifyLayoutChanged;el=null;listeners=[];tooltip;width;height;customEventPopup=null;goToLatestButton=null;xAxis;eventCapture;resetZoomAndVisibleRange=!1;constructor(){this.legend=new vA(this),this.draw=this.draw.bind(this),this.notifyLayoutChanged=qe(G.CH_CHTLAYOUTCHANGED,z.LAYOUT_THROTTLE_DELAY)}get canShowLegend(){if(!this.presenter.hasLegend)return!1;let e=this.presenter.display.chart.showLegend;return!(typeof e==`boolean`&&!e)}updateLegend(){this.canShowLegend&&this.legend.update()}removeLegend(){this.legend.remove()}findSvgParentWithClass(e,t){return[e,e.parentElement,e.parentElement.parentElement].find(e=>P(e)&&e.className===t)}onNonToolHandledMouseDown(e){let t=this.presenter,n=e.target;if(typeof n.className==`string`&&n.className.split(` `).includes(`value-title`))t.onCardClicked(n);else{let r=this.findSvgParentWithClass(n,`move-pane`);if(N(r)){t.onMovePaneClicked(r);return}let i=this.findSvgParentWithClass(n,`delete-plot`);if(N(i)){t.deletePlotClicked(i);return}let a=this.findSvgParentWithClass(n,`show-hide-plot`);if(N(a)){t.showHidePlotClicked(a);return}let o=this.findSvgParentWithClass(n,`more-actions`);if(N(o)){t.plotMoreActionsClicked(o,e);return}}}initialize(e){this.presenter=e,this.el=this.presenter.hostElement;let t=new ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t.contentRect;this.setSize(e,n,!0),P(this.tooltip)&&this.tooltip.repositionAuto()}});t.observe(this.el.parentElement),this.listeners.push(()=>t.unobserve(this.el.parentElement));let n=e=>this.onNonToolHandledMouseDown(e);this.el.addEventListener(`mousedown`,n),this.listeners.push(()=>this.el.removeEventListener(`mousedown`,n)),Si(this.el,{flex:1,display:`flex`,position:`relative`,"flex-direction":`column`,"touch-action":`pan-x pan-y`}),this.tooltip=new KD(this);let r=$().config.getCustomEventPopup;this.customEventPopup=r?r(this):null;let{clientHeight:i,clientWidth:a}=this.el;this.width=a,this.height=i,this.canvasContainer=Ei(this.el,`div`),Ci(this.canvasContainer,{class:`chart-canvas-container`}),Si(this.canvasContainer,{flex:1,display:`flex`,"flex-direction":`column`,position:`relative`,height:`100%`}),this.mainCanvas=Ei(this.canvasContainer,`canvas`);let o={height:`${i}px`,width:`${a}px`,"z-index":2,position:`absolute`,top:0,left:0};Si(this.mainCanvas,o),this.mouseCanvas=Ei(this.canvasContainer,`canvas`),Ci(this.mouseCanvas,{tabIndex:0}),o[`z-index`]=3,o.outline=`none`,Si(this.mouseCanvas,o),this.goToLatestButton=Ei(this.el,`button`),Oi(this.goToLatestButton,`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
40
40
  <path d="M13.707 17.707l5-5c0.391-0.391 0.391-1.024 0-1.414l-5-5c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414l4.293 4.293-4.293 4.293c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0zM6.707 17.707l5-5c0.391-0.391 0.391-1.024 0-1.414l-5-5c-0.391-0.391-1.024-0.391-1.414 0s-0.391 1.024 0 1.414l4.293 4.293-4.293 4.293c-0.391 0.391-0.391 1.024 0 1.414s1.024 0.391 1.414 0z"></path>
41
41
  </svg>`),Si(this.goToLatestButton,{position:`absolute`,right:0,bottom:0,"z-index":3}),Ci(this.goToLatestButton,{class:`go-to-latest`}),this.goToLatestButton.onclick=()=>{this.xAxis.goToLatest()},this.listeners.push(()=>{this.goToLatestButton.onclick=null}),this.mainContext=this.mainCanvas.getContext(`2d`),this.mouseContext=this.mouseCanvas.getContext(`2d`),this.splitters=[],this.xAxis=new lA(this),this.eventCapture=new pA(this),this.eventCapture.init(this.mouseCanvas),this.setChartSize(a,i);let s=vi(this.el);P(xi(`.${z.SVG_ICONS_DOM_NODE}`,s))||x_(s)}reinitialize(){this.el&&Di(`.bcharts-card`,this.el).forEach(e=>e.remove()),this.customEventPopup?.hide(),this.drawCrosshair({ap:void 0}),this.tooltip.hide(),this.tooltip.setMode(this.presenter.display.tooltip.mode),this.resetZoomAndVisibleRange?this.xAxis=new lA(this):this.xAxis?.updateConfigFromModel(),this.recalculateLayout(),this.redraw()}setSize(e,t,n=!1){this.setChartSize(e,t),this.redraw(n)}setChartSize(e,t){let n={width:`${e}px`,height:`${t}px`};Si(this.el,n),this.width=e,this.height=t;let r=globalThis.devicePixelRatio||1,i={height:this.height*r,width:this.width*r};[this.mainCanvas,this.mouseCanvas].forEach(e=>{Ci(e,i),Si(e,n)}),this.mainContext.scale(r,r),this.mouseContext.scale(r,r),this.recalculateLayout(),this.presenter&&qD(this.presenter)}widthNeeded(e,t){let n=this.presenter.allAxes.filter(e=>e.onTheRight===t&&e.plots.some(e=>e.visible&&e.hasVisibleCurves&&!e.hasDetachedScale));return n.length===0?0:Math.max(...n.map(t=>t.widthNeeded(e)))}recalculateLayout(){if(!this.isHostElementVisible)return;this.leftOffset=0,this.rightOffset=0,this.presenter.allAxes.forEach(e=>e.clearTicks()),this.splitters.length=0;let e=this.xAxis.heightNeeded(this.mainContext),t=this.widthNeeded(this.mainContext,!0),n=this.widthNeeded(this.mainContext,!1),r=this.height-e,i=this.presenter.panes,a=pe(i.map(e=>e.height)),o=0,s=z.PANE_SPLITTER_PERCENT_HEIGHT/100,c=Math.floor(s*r);a*=1+(i.length-1)*s;let l=this.presenter.display?.yAxis?.primaryOnTheLeft??!1;this.presenter.display.yAxis.visible&&(i.some(e=>e.axes.length>1)?(this.leftOffset=n,this.rightOffset=t):l?this.leftOffset=n:this.rightOffset=t),i.forEach((e,n,i)=>{let s=n===i.length-1,l=Math.floor(r*e.height/a),u=new za(0,o,this.width,l);e.setViewBox(u);let d=new za(this.width-this.rightOffset,o,t,l),f=new za(0,o,this.leftOffset,l),p=e=>e.setViewBox(e.onTheRight?d:f);if(p(e.axes[0]),e.axes[1]&&p(e.axes[1]),o+=l,!s){let e=new za(this.leftOffset,o,this.width-this.rightOffset-this.leftOffset,c);this.splitters.push(e),o+=c}});let u=new za(this.leftOffset,o,this.width-this.rightOffset-this.leftOffset,e);this.xAxis.setViewBox(u),Si(this.goToLatestButton,{right:`${t+5}px`,bottom:`${e+5}px`}),this.updateLegend(),this.xAxis.setDomain(),this.setPriceAxesDomains(),this.notifyLayoutChanged({chart:this.presenter.accessor})}setPriceAxesDomains(){this.presenter.allAxes.forEach(e=>{e.setDomain(),e.updateFullDomain()}),this.presenter.priceDomainsUpdated()}draw(){this.mainContext.save(),this.mainContext.miterLimit=1,this.drawBackground(this.mainContext);for(let e of this.presenter.panes)e.drawBackground(this.mainContext);this.xAxis.draw(this.mainContext);for(let e of this.presenter.panes)e.draw(this.mainContext);this.drawSplitters(this.mainContext),this.presenter.title.draw(this.mainContext),this.goToLatestButton.style.display=this.canShowGoToLatestButton()?`block`:`none`,this.mainContext.restore()}canShowGoToLatestButton(){let e=$().config.showGoToLatest,{showGoToLatest:t}=this.presenter.display.chart;return!!(P(e)?e:t)&&this.xAxis.panningXAxisAllowed&&this.xAxis.canGoToLast()}get isHostElementVisible(){return P(this.el)&&P(this.el.offsetParent)}redraw(e=!1){this.isHostElementVisible&&(e?this.draw():$().redraw(this.presenter.hostElement))}drawBackground(e){let t=this.presenter.display.chart.backgroundColor;e.clearRect(0,0,this.width,this.height),e.fillStyle=t,e.fillRect(0,0,this.width,this.height)}drawCrosshair({ap:e,offset:t}){let n=this.mouseContext;return n.clearRect(0,0,this.width,this.height),!e||!t||!this.xAxis||!this.xAxis.drawCrosshair(n,t)?!1:(this.presenter.display.yAxis.visible&&e.axis?.pane&&e.axis.pane.drawYCrosshair(n,t),!0)}drawSplitters(e){let t=this.presenter.display.chart.backgroundColor;e.strokeStyle=Oa(t),e.lineWidth=2,this.splitters.forEach(t=>{let{x:n,y:r,width:i,height:a}=t,o=r+a/2;e.beginPath(),e.moveTo(n,o),e.lineTo(n+i,o),e.stroke()})}toTime(e){return this.xAxis.xScale.xToTime(e)}toIndex(e){return this.xAxis.xScale.timeToIndex(e)}toX(e){return this.xAxis.xScale.timeToX(e)}setCursor(e){let t=bA(e);Si(this.el,{cursor:t})}shutdown(){this.listeners.forEach(e=>e()),this.eventCapture&&this.eventCapture.shutdown(),this.tooltip&&this.tooltip.remove(),this.el&&Di(`.bcharts-card`,this.el).forEach(e=>e.remove()),this.canvasContainer.remove()}getEventRadius(){let e=this.xAxis.xScale.bar.width/2;return Math.max(e,z.MIN_EVENT_RADIUS)}};function bA(e){switch(e){case ee.Arrow:default:return`default`;case ee.Crosshair:return`crosshair`;case ee.Hand:return`pointer`;case ee.Move:return`move`;case ee.ResizeVertical:return`ns-resize`;case ee.Grabbing:return`grabbing`;case ee.ResizeHorizontal:return`ew-resize`}}var xA=class{view;popupElement;date;value;visible;_initialized;constructor(e){this.view=e,this.date=null,this.value=null,this.visible=!1,this._initialized=!1}initialize(){this.popupElement=Ei(this.view.el,`div`),Ci(this.popupElement,{id:`${this.view.presenter.elementId}-custom-event-host`}),Si(this.popupElement,{visibility:`hidden`,position:`absolute`,"z-index":30,top:`0px`,left:`0px`,padding:`5px 10px 10px 10px`,display:`flex`,"flex-direction":`column`,background:`var(--chartPopupElemBg, #999)`,"box-shadow":`0px 2px 10px rgba(0,0,0,.3)`,"border-radius":`4px`,border:`1px solid var(--chartPopupElemBorderColor, #888)`,"max-height":`400px`,overflow:`auto`});let e=Ei(this.popupElement,`a`);Ci(e,{class:`custom-event-close-button`}),Si(e,{position:`absolute`,right:`10px`,top:`5px`,fill:`var(--text-color,#888)`,cursor:`pointer`}),e.innerHTML=`<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="12px" height="12px"><use xlink:href="#bchart-icon-delete"></use></svg>`,e.addEventListener(`click`,e=>this.hide()),this._initialized=!0}showValue(){}show(e,t,n){this._initialized||this.initialize(),this.date=t,this.value!==n&&(this.value=n,this.showValue()),Si(this.popupElement,{visibility:`visible`,top:`${e.y}px`,left:`${e.x}px`,width:`310px`}),this.visible=!0}hideValue(){}hide(){this.visible&&=(this.hideValue(),Si(this.popupElement,{visibility:`hidden`}),!1)}};function SA(e,t){return H(e,`..axes[${t.axisIndex}]`,e=>(e.annotations=t.annotations,e))}function CA(e){return e.annotations&&e.annotations.length>0}function wA(e,t){CA(e)&&(t.annotations=(t.annotations||[]).concat(e.annotations))}var TA=`..axes{..plots{.type==="Study"}}`;function EA(e,t){let{mainAxis:n}=Ju(e),{mainAxis:r}=Ju(t);wA(n,r);let i=e=>V(e,`..plots{.type==="Study"}.study`)[0],a=V(e,TA).filter(e=>e!==n),o=V(t,TA).filter(e=>e!==r);return a.forEach(e=>{let t=i(e),n=o.find(e=>t===i(e));P(n)&&wA(e,n)}),t}function DA(e,t){let n=e=>`..panes[${e}]`,r=e;return t.paneHeights.forEach(e=>{r=H(r,n(e.index),t=>(t.height=e.relativeHeight,t))}),r}var OA={ok:!1,change:void 0,toApply:void 0},kA=class{paused=null;undoStack=[];redoStack=[];initial=new Map;isPaused=!1;constructor(e){this.presenter=e,this.clear()}clear(e=!1){this.undoStack=[],this.redoStack=[],this.initial=new Map,e&&this.presenter.allAnnotations.forEach(e=>this.initial.set(e.uid,vD(e,O.Moved)))}done(e){if(this.isPaused){this.paused=e;return}this.undoStack.push(e),this.redoStack.length=0}undo(){this.undoRedo(this.undoStack,this.redoStack,!0)}pause(){this.isPaused=!0}resume(e){this.isPaused=!1,e&&N(this.paused)&&this.done(this.paused),this.paused=null}redo(){this.undoRedo(this.redoStack,this.undoStack,!1)}delete(e){let t={...e,id:`Delete`};this.presenter.handleAnnotationChange(t)}add(e){let t={annotation:e,id:`Add`};this.presenter.handleAnnotationChange(t)}apply(e,t,n){if(!P(e))return!1;switch(t){case O.None:case O.Undo:case O.Redo:I(`Unexpected tool change ${O[t]} for undo/redo`,`warn`);break;case O.Created:n?this.delete(e):this.add(e);break;case O.Deleted:n?this.add(e):this.delete(e);break;default:{let t={...e,id:`Update`};this.presenter.handleAnnotationChange(t);break}}let r=this.presenter.allAnnotations.find(t=>t.uid===e.uid),i=n?O.Undo:O.Redo;return P(r)&&this.presenter.onAnnotationModifiedByTool(r,i),!0}can(e){let t=e?this.undoStack:this.redoStack;if(t.length<1)return OA;let n=xe(t),r=n.toolChange;if(!(e&&r!==O.Deleted&&r!==O.Created))return{ok:!0,change:r,toApply:n};let i=Ce(t,e=>e.uid===n.uid,t.length-2),a=i===-1?null:t[i],o=a===null;return o&&!this.initial.has(n.uid)?OA:{ok:!0,change:r,toApply:o?this.initial.get(n.uid):a}}get canUndo(){return this.can(!0).ok}get canRedo(){return this.can(!1).ok}undoRedo(e,t,n){let{ok:r,change:i,toApply:a}=this.can(n);if(!r)return;let o=e.pop();this.apply(a,i,n),t.push(o)}},AA=class{text=null;align=`center`;verticalAlign=`top`;x=0;y=0;style={color:`#333`,fontSize:18};constructor(e){this.presenter=e}update({style:e,...t}){Object.assign(this,t),Object.assign(this.style,e)}draw(e){if(!this.text)return;let{fontFamily:t}=this.presenter.display.chart,{fontSize:n,color:r,fontWeight:i}=this.style,{x:a,y:o,width:s,height:c}=this.presenter.mainPlot.axis.pane.getBounds(),l=a+this.presenter.view.leftOffset,u=a+s-this.presenter.view.rightOffset,d=l;d=this.align===`center`?s/2:this.align===`right`?u:l;let f=o+n;this.verticalAlign===`middle`?f=o+n+c/2:this.verticalAlign===`bottom`&&(f=o+c),d+=this.x,f+=this.y,e.save(),e.font=`${i||`normal`} ${n}px ${t}`,e.textAlign=this.align,e.textBaseline=`bottom`,e.fillStyle=r,e.fillText(this.text,d,f),e.restore()}};function jA(e={}){let t=this.allPlots;if(!t.every(e=>P(e.timeSeries)&&e.timeSeries.hasData))return`No data to export`;let n=e.excludeHeader??!1,r=e.numDecimals??null,i=e.excludeFields??[],a=e=>{let t=new Map;return e.main&&(t.set(W.DateTime,0),this.data.aggregation.isMultiContract&&!e.isExpression&&t.set(W.Symbol,0)),e.curves.forEach(e=>{e.fields.forEach(n=>{i.includes(n.id)||t.set(n,e.shift)})}),Array.from(t)},o=e=>`"${C[e.type]}: ${e.title}"`,s=this.data.aggregation.isEndOfDay?z.FMT_ISO_DATE_ONLY:z.FMT_EXPORT_ALL_BUT_MILLIS,c=e=>P(r,e)?Xe(e,r):e,l=(e,t)=>e===W.DateTime?_r(t,s):c(t)?.toString()??``,u={},d=this.timeline.lastSeriesIndex,f=Se(this.mainPlot.timeSeries.container.getTimeData()),p=Te(this.timeline,+f,Number,__),m=(e,t)=>{let n=this.timeline.at(e),r=t.timeSeries.container,i=r.getTimeData(),o=u[t.id]||0,c=Te(i,+n,Number,we,o),d=+n==+i[c];return d&&(u[t.id]=c),a(t).map(([t,a])=>{if(a===0)return d?l(t,r.getData(t)[c]):t===W.DateTime?_r(n,s):``;{let n=this.timeline.at(e-a),o=Te(i,+n,Number,we,0);return+n==+i[o]?l(t,r.getData(t)[o]):``}})},h=e=>{let n=t.map(e).flat();return n.slice(1).every(e=>e.length===0)?null:n.join(`,`)},g=[];n||(g.push(h(e=>{let t=Array(a(e).length).fill(``);return t[0]=o(e),t})),g.push(h(e=>a(e).map(([e,t])=>`"${e.name}"`))));let _=[0,0];this.allCurves.forEach(e=>{e.fields.every(e=>i.includes(e.id))||(e.shift<0&&(_[0]=Math.min(_[0],e.shift)),e.shift>0&&(_[1]=Math.max(_[1],e.shift)))});for(let e=p+_[0];e<=d+_[1];e++){let t=h(se(m,e));t!==null&&g.push(t)}return g.join(`
42
- `)}function MA(e={}){let t=this.view.mainCanvas,{width:n,height:r}=t,{width:i,height:a,title:o}=e,s=(e,t)=>{let n=document.createElement(`canvas`);return n.width=e,n.height=t,n.getContext(`2d`)},c=s(n,r),l=globalThis.devicePixelRatio;if(c.drawImage(t,0,0),c.scale(l,l),N(o)){let e=new AA(this);e.update(o),e.draw(c)}let u=this.mainPlot?.timeSeries.container?.getLastDataPoint(W.DateTime);if(N(u)){let{fontFamily:e}=this.display.chart,{fontWeight:n,fontSize:r}=this.mainAxis.config;c.font=`${n} ${r*1.2}px ${e}`,c.textBaseline=`top`;let i=r*1.5,a=getComputedStyle(t),o=a.getPropertyValue(`--app-hc-color`),s=a.getPropertyValue(`--app-color-pl`),l={x:z.CARDS_X_OFFSET,y:z.CARDS_Y_OFFSET},d=V_(this,u,l,void 0,!1,0),f=`${d.date} ${d.time??``}`.trim(),[p,m]=[1,5],h=(e,t)=>c.measureText(e).width+t,g=(e,t,n,r,i)=>(c.fillStyle=r,c.fillText(e,t,n),h(e,i)),_=(e,t)=>e.type===C[t],v=e=>{let t=e.name;return e.isMain&&_(e,`Symbol`)?t=`${e.description} (${e.name}) [${e.exchange}]`:_(e,`Study`)&&(t=`${e.description} ${e.name.substring(e.name.indexOf(` `))}`),t};d.panes.forEach(e=>{let{top:t,left:n,width:r,right:a}=e.bounds,c=n+r-a-m,u=n+l.x,d=t+l.y;e.plots.some(e=>e.isMain)&&(u+=g(f,u,d,o,m)),e.plots.forEach((e,t)=>{let r=v(e),a=!_(e,`Study`)&&e.values.length>1;if(!e.isMain&&t>0){let t=u+h(r,m);e.values.forEach(e=>{a&&(t+=h(e.abbreviation,p)),t+=h(e.value,m)}),t>=c&&(u=n+l.x,d+=i)}u+=g(r,u,d,o,m),e.values.forEach(e=>{a&&(u+=g(e.abbreviation,u,d,s,p)),u+=g(e.value,u,d,e.color,m)})})})}let d=e=>({width:i??n,height:a??r,data:e.toDataURL(`image/png`)});if(N(i)&&N(a)){let e=s(i,a);return e.drawImage(c.canvas,0,0,i,a),d(e.canvas)}else return d(c.canvas)}var NA=Symbol.for(`__ias__`),PA=class{view;defaultTool;_activeTool;tooltipEnabled=!0;timeline;sentInitialLoadNotification=!1;_hostElement=null;undoRedoManager;title;display;model;data;panes=[];_hasLegend;renderTo;seriesChangedToken=``;metaChangedToken=``;streamingSubscription=null;_previousMask=0;_ohlcMask;selectedAnnotation;forceResetVisibleRange=!1;_maxOffset=0;_isShutdown=!1;notifySelectionChanged;notifyRecreated;notifyDefinitionChanged;constructor(e){this.accessor=e,this.defaultTool=Dk(`Default`),this._activeTool=this.defaultTool,this.timeline=new v_(this),this.undoRedoManager=new kA(this),this.title=new AA(this),this.notifySelectionChanged=Ke(G.CH_ANNSELECTIONCHANGED),this.notifyRecreated=Ke(G.CH_RECREATED),this.notifyDefinitionChanged=Ke(G.CH_DEFINITION_CHANGED)}traceChart(e,t={}){Vm(e,{chartId:this.elementId,...t})}getModel(){return this.model}get isEmpty(){return!P(this.model)}notifyHost(e,t){Ge(e,t)}async fromModel(e,t){if(this._isShutdown)return;this.traceChart(`chart:fromModel:start`,{hadModel:P(this.model)}),P(this.model)&&this.allPlots.forEach(e=>e.shutdown()),this.sentInitialLoadNotification=!1,this.clearSelection(),this.model=e;let n=F(e);this.data=n.data,this.data.aggregation=Il(n.data.aggregation),this.display=n.display,P(this.display.period)&&(this.display.period=vt(this.display.period)),this.panes=n.panes.map(e=>{let t=new aA(this);return t.fromModel(e),t},this);let r=this.allPlots.map(e=>e.initialize());await Promise.all(r),this.traceChart(`chart:fromModel:plots-ready`,{plotCount:this.allPlots.length}),!this._isShutdown&&(this.timeline.invalidate(),this.checkZoomAndVisibleRange(e,t),P(e,t)&&this.notifyDefinitionChanged({chart:this.accessor}),this.reinitializeView())}checkZoomAndVisibleRange(e,t){if(this.view)if(this.forceResetVisibleRange)this.forceResetVisibleRange=!1,this.view.resetZoomAndVisibleRange=!0,this._maxOffset=0;else{let n=!t||zA(e,t,this);this.view.resetZoomAndVisibleRange=n,n&&(this._maxOffset=0)}}closeView(){P(this.view)&&(this.view.shutdown(),this.view=void 0)}reinitializeView(){this._isShutdown||(P(this.view)?this.view.reinitialize():(this.view=new yA,this.view.initialize(this)),this.notifyRecreated({elementId:this.elementId}))}getCacheableEntities(e){let t={metaData:e.metaData.size,records:e.records.size,timeSeries:e.timeSeries.size};this.isEmpty||this.allPlots.map(t=>t.getCacheableEntities(e)),this.traceChart(`chart:cacheable-entities`,{plotCount:this.allPlots.length,addedMetaData:e.metaData.size-t.metaData,addedRecords:e.records.size-t.records,addedTimeSeries:e.timeSeries.size-t.timeSeries})}get activeTool(){return this._activeTool}set activeTool(e){P(this._activeTool.deactivated)&&this._activeTool.deactivated(this),this._activeTool=e,P(this._activeTool.activated)&&this._activeTool.activated(this),this.notifyHost(G.TL_CHANGED,{chart:this.accessor})}get mainPlot(){return this.allPlots.find(e=>e.main)}get mainAxis(){return this.mainPlot?.axis}get mainPane(){return this.mainAxis?.pane}get allAxes(){let e=[];return this.panes.forEach(t=>{t.axes.forEach(t=>{e.push(t)})}),e}get plotAnnotations(){let e=[];return this.allPlots.forEach(t=>{t.annotations?.forEach(t=>{e.push(t)})}),e}get allAnnotations(){let e=[];return this.allAxes.forEach(t=>{t.annotations.forEach(t=>{e.push(t)})}),e}get allPlots(){let e=[];return this.allAxes.forEach(t=>{t.plots.forEach(t=>{e.push(t)})}),e}findAxis(e){return this.allAxes.find(t=>t.id===e)}findPlot(e){return this.allPlots.find(t=>t.id===e)}get allCurves(){let e=[];return this.allPlots.forEach(t=>{t.curves.forEach(t=>{e.push(t)})}),e}findCurve(e){return this.allCurves.find(t=>t.id===e)}fixupDensityForForwards(){let e=this.allPlots.filter(e=>e.isForward).map(e=>e.timeSeries.container?.size??0);e.some(e=>e>0)&&(this.display.density=Math.max(...e))}onSeriesChanged(e,t){if(!this.view||!this.allPlots)return;let n=t.series,r=e=>e.timeSeries===n||e.eventsSeries===n,i=this.allPlots.find(r);if(!P(i))return;let a=P(i)&&i.main,o=!1,s=!1;if(e===G.TS_TIMELINECORRECTION){if(!this.timeline.tryToCorrectLastBar(t.from,t.to))return;o=!0}let c=P(t.index)?n.container.getTimeData()[t.index]:null,l=e===G.TS_EVENTSCHANGED,u=this.view.xAxis,d=u.xScale;if(e===G.TS_MANYCHANGED||l){if(a&&this.data.checkRange)if(P(this.display.xAxis.visibleRange)){let e={id:`Period`,context:{range:this.display.xAxis.visibleRange}};e[NA]=!0,this.accessor.change(e);return}else delete this.data.checkRange;i.isForward&&this.fixupDensityForForwards();let e=this.view.xAxis?.getMaxCurveOffset()??0;i.isStudy&&(e!==this._maxOffset&&(this._maxOffset=e,u.goToLatest(!0)),i.invalidateAssociatedAnnotations(`NewChunkArrived`));let n=P(this.display?.xAxis?.visibleRange);if((i.isSeasonal&&!u.wasVisibleRangeChanged&&!n||this.display?.xAxis?.isOrdinal)&&u.goToLatest(!0),t.part===re.Tail){let e=Te(this.timeline,c,Number,__);u.shouldScrollIntoView(e)&&d.shiftBars(t.count)}this.timeline.invalidate(),this.allPlots.forEach(e=>e.invalidatePriceMappingCache()),o=!0}else if(e===G.TS_DATAPOINTADDED){let e=this.timeline.mergeDateIntoTimeline(c);e!=-1&&u.shouldScrollIntoView(e)?(d.shiftBars(1),o=!0):s=!0,i.isStudy&&i.invalidateAssociatedAnnotations(`DataPointAdded`)}else e===G.TS_DATAPOINTCHANGED&&(s=!0,i.isStudy&&i.invalidateAssociatedAnnotations(`DataPointChanged`));if(!l&&r(this.mainPlot)&&n.hasData&&n.container.size===0&&this.notifyHost(G.CH_NODATAFORMAINSYMBOL,{chart:this.accessor}),o&&this.view.recalculateLayout(),s&&(o&&I(`Performance : redundant call to recompute price domains (layout recalculation took care of this)`,`warn`),this.allAxes.filter(e=>e.plots.includes(i)).forEach(e=>{e.setDomain(),P(c)&&e.updateFullDomain(c)})),!this.sentInitialLoadNotification&&e===G.TS_MANYCHANGED&&this.allPlots.every(e=>e.timeSeries&&e.timeSeries.hasData)){this.sentInitialLoadNotification=!0,this.notifyHost(G.CH_ALL_DATA_PROJECTED,{chart:this.accessor}),qD(this);let e=this.display.period===z.FIFTY_YEARS_MILLIS;this.mainPlot&&e&&(d.fitAllData=!0,d.adjustDomain())}this.view.redraw()}onMetaChanged(e,t){e===G.MD_CHANGED&&this.view&&this.allPlots&&this.allPlots.find(e=>e.id===t.plot.id)&&(this.view.recalculateLayout(),this.view.redraw())}priceDomainsUpdated(){this.allPlots.forEach(e=>{e.notifyAboutPriceDomains&&e.onPriceDomainsUpdated()})}onScaleDomainChanged(e){let t=this.panes.indexOf(e.pane),n=e.pane.axes.indexOf(e),r={chart:this.accessor,paneIndex:t,axisIndex:n};this.notifyHost(G.CH_AXISSCALECHANGED,r)}get previousMask(){return P(this._previousMask)||(this._previousMask=Gd(W.PreviousClose)),this._previousMask}hasMatch(e,t){return e.some(e=>e.updated&&t)}get hasLegend(){return P(this._hasLegend)||(this._hasLegend=$().config.mode===ne[ne.cmdtyView]),this._hasLegend}onStreamingUpdates(e){P(this.view)&&(this.mainPlot.showPrevious&&this.hasMatch(e,this.previousMask)&&this.view.redraw(),this.hasLegend&&this.hasMatch(e,this.ohlcMask)&&this.view.updateLegend())}get ohlcMask(){return P(this._ohlcMask)||(this._ohlcMask=Gd(W.Open,W.High,W.Low,W.Close,W.PreviousClose)),this._ohlcMask}updateMatches(e,t){if((e&this.ohlcMask)===0)return!1;let n=(e,t)=>N(e)&&e.isValid&&e.hasSymbol(t);return this.mainPlot.isSymbol?n(this.mainPlot.timeSeries.record,t):this.mainPlot.isExpression?n(this.mainPlot.record,t):!1}getStreamingSubscription(){return $().getRecordSource().subject.pipe(Ip(e=>e.filter(e=>this.updateMatches(e.updated,e.data.symbol))),zp(e=>e.length>0)).subscribe(this.onStreamingUpdates.bind(this))}get hostElement(){return this._hostElement}get elementId(){return P(this._hostElement)?this._hostElement.id:null}initialize(e){if(this._hostElement=e instanceof HTMLElement?e:xi(`#${e}`),!this._hostElement)throw Error(`There is no element ${e} in the DOM`);this.renderTo=e,this.seriesChangedToken=kv.default.subscribe(G.TS_ALL,this.onSeriesChanged.bind(this)),this.metaChangedToken=kv.default.subscribe(G.MD_ALL,this.onMetaChanged.bind(this)),this.streamingSubscription=this.getStreamingSubscription()}shutdown(){return kv.default.unsubscribe(this.seriesChangedToken),kv.default.unsubscribe(this.metaChangedToken),P(this.streamingSubscription)&&this.streamingSubscription.unsubscribe(),this.allPlots.forEach(e=>e.shutdown()),this.model=void 0,this.closeView(),this.notifyHost(G.CH_SHUTDOWN,{elementId:this.elementId}),this._isShutdown=!0,!0}setSelection(e){this.selectedAnnotation=e,this.selectedAnnotation.isSelected=!0,this.selectedAnnotation.requestRedraw(),this.notifySelectionChanged({chart:this.accessor})}clearSelection(){P(this.selectedAnnotation)&&(this.selectedAnnotation.isSelected=!1,this.selectedAnnotation.requestRedraw(),this.selectedAnnotation=void 0),this.notifySelectionChanged({chart:this.accessor})}resetActiveTool(){this.activeTool=this.defaultTool,this.view.setCursor(ee.Arrow)}print(e={}){let t=Ei(document.body,`iframe`);t.src=``,t.style.display=`none`,t.onload=()=>{let{title:n}=e,r=MA.call(this,{title:n}),i=new Image;i.src=r.data,i.style.width=`100%`,t.contentDocument.body.appendChild(i),ki(i).then(()=>{let e=t.contentWindow;t.focus(),e.print(),t.remove()})}}setTitle(e,t=!1){this.title.update(e),P(this.view)&&this.view.redraw(t)}enableTooltip(e){this.tooltipEnabled=e;let t=this.display.tooltip.mode===z.TOOLTIP_CARDS;!e&&t&&this.hideCards()}get showTooltip(){return this.display.tooltip.visible&&this.tooltipEnabled}hideCards(e=!1){let t=this.display.tooltip,n=Ie();!e&&t.visible&&t.mode===z.TOOLTIP_CARDS&&Di(`.bcharts-card`,this.hostElement).forEach(e=>{let t=e.classList.contains(`bcharts-card-move`);n&&t||e.classList.contains(`bcharts-legend`)||(e.style.display=`none`)})}handleAnnotationChange(e){let t=(e,t=!0)=>({id:t?e.name:e.id,uid:e.uid,visible:e.visible});if(e.id===`List`)return this.allAnnotations.map(t);if(e.id===`Cache`)return V(this.model,`..annCache{.annotations}`).map(e=>({symbol:e.symbol,annotations:e.annotations.map(e=>t(e,!1))}));if(e.id===`Add`)return this.mainAxis.addAnnotation(e.annotation);let n=this.allAnnotations.find(t=>t.uid===e.uid);if(n!==void 0){let t=n.axis,r=t[`${e.id.toLowerCase()}Annotation`];if(typeof r==`function`){r.call(t,n,e),e.id===`Delete`&&!e.isUndoRedo&&this.onAnnotationModifiedByTool(n,O.Deleted);return}}throw Error(`Unknown sub-action ${e.id} for action ${z.ANN_ACTION_ID}`)}getPlotInfoFromDom(e){let t=e.attributes.getNamedItem(`data-plot-uid`);if(!t)throw Error(`Unable to resolve plot info: missing data-plot-uid attribute.`);let n=t.value,r=0;for(let e of this.model.panes)for(let t of e.axes)for(let e of t.plots){if(e.uid===n)return{type:e.type,index:r};r++}throw Error(`Unable to resolve plot info: model plot index not found for uid '${n}'.`)}getSimplePlot(e,t){return this.accessor.change({id:`Plot`,context:{id:z.ACTION_GET,type:e,index:t}})[0]}onCardClicked(e){let t=this.getPlotInfoFromDom(e),n=this.getSimplePlot(t.type,t.index),r={chart:this.accessor,plot:n};this.notifyHost(G.CH_CARDPLOTCLICKED,r)}deletePlotClicked(e){let t=this.getPlotInfoFromDom(e),n=this.getSimplePlot(t.type,t.index);this.accessor.change({id:`Plot`,context:{id:`Delete`,type:t.type,index:t.index}});let r={chart:this.accessor,plot:n};this.notifyHost(G.CH_CARDPLOTREMOVED,r)}showHidePlotClicked(e){this.defaultTool.hideCrosshairAndTooltips(this.view,!0);let t=this.getPlotInfoFromDom(e),n=e.attributes.getNamedItem(`data-act`).value===`Show`;this.accessor.change({id:`Plot`,context:{id:`Update`,type:t.type,index:t.index,visible:n}});let r=this.getSimplePlot(t.type,t.index),i={chart:this.accessor,plot:r,visible:n};this.notifyHost(G.CH_CARDPLOTVISIBILITYCHANGED,i)}plotMoreActionsClicked(e,t){let n=this.getPlotInfoFromDom(e),r=this.getSimplePlot(n.type,n.index),i={x:t.clientX,y:t.clientY},a={chart:this.accessor,plot:r,offset:i,originalEvent:t};this.notifyHost(G.CH_PLOTNEEDSCONTEXTMENU,a)}onMovePaneClicked(e){let t=parseInt(e.attributes.getNamedItem(`data-pane`).value),n=e.attributes.getNamedItem(`data-dir`).value===`Down`,r=t+ +!!n,i=t-+!n;setTimeout(()=>{this.accessor.change({id:`MovePane`,context:{from:r,to:i}}),this.notifyHost(G.CH_PANESREORDERED,{chart:this.accessor})})}onAnnotationsUpdated(e,t=!1){let n=this.allAxes.indexOf(e),r=e.annotations.map(e=>e.toModel()),i=SA(this.model,{axisIndex:n,annotations:r});try{this.model=Id(i,z.CHART_SCHEMA)}catch(e){I(`Cannot update annotation (corrupts definition), error is: ${e.message}`,`error`)}t&&this.view.draw(),this.notifyHost(G.CH_ANNOTATIONCHANGED,{chart:this.accessor}),this.notifyDefinitionChanged({chart:this.accessor})}onAnnotationModifiedByTool(e,t,n=!0){if(t!==O.None){if(n&&t!==O.Undo&&t!==O.Redo){let n=vD(e,t);this.undoRedoManager.done(n)}let r=yD(e);r.toolChange=O[t],this.notifyHost(G.CH_ANNMODIFIEDBYTOOL,r)}}onAnnotationDone(e,t){let n={id:e,chart:this.accessor,toolChange:O[t]};this.notifyHost(G.CH_ANNMODIFIEDBYTOOL,n)}onPaneHeightsUpdated(){let e=this.panes.map((e,t)=>({index:t,relativeHeight:e.height}));this.model=DA(this.model,{paneHeights:e}),this.notifyHost(G.CH_PANEHEIGHTSCHANGED,{chart:this.accessor}),this.notifyDefinitionChanged({chart:this.accessor})}getDataStats(){let e=this.mainPlot.timeSeries.container;if(!P(e)||e.size===0)return null;let t=e.getTimeData(),n=Se(t),r=xe(t);return P(n,r)?{dataRange:{from:n.getTime(),to:r.getTime()},barCount:e.size}:null}};function FA(e,t){return e?.from===t?.from&&e?.to===t?.to}var IA=[`Renko`,`Range`,`LineBreak`,`Kagi`,`PointAndFigure`];function LA(e,t){for(let n of Object.keys(e))if(e[n]!==t[n])return!0}function RA(e,t){let n=e=>e.curves[0],r=n(e),i=n(t),a=IA.includes(r.style),o=IA.includes(i.style);return a===o?o?!!(r.style!==i.style||t.inputs&&LA(dt(e.inputs),dt(t.inputs))):!1:!0}function zA(e,t,n){let r={id:`Aggregation`,context:{id:`Get`}};if(LA(Fl(mM(r,t,n)),Fl(mM(r,e,n)))||!FA(e.display?.xAxis?.visibleRange,t.display?.xAxis?.visibleRange)||e.display?.xAxis?.marginBars!==t.display?.xAxis?.marginBars||!FA(e.data?.range,t.data?.range)||e.data?.extendedHours!==t.data?.extendedHours||e.display?.period!==t.display?.period||e.display?.density!==t.display?.density)return!0;let i=qu(t),a=qu(e);if(RA(i,a))return!0;let o=(e,t)=>e.type===t,s=e=>{let t=e.toLowerCase();return o(a,e)&&o(i,e)&&i[t]!==a[t]},c=i.type!==a.type,l=s(`Forward`),u=s(`Expression`),d=s(`Symbol`);return c||l||u||d}function BA(e,t){let[n,r]=Qe(t.crosshair),{color:i,dashStyle:a}=t.horizontal||{},{color:o,dashStyle:s}=t.vertical||{},c=(e,t,n)=>{t&&(e.color=t),n&&(e.dashStyle=n)},l=H(e,`.display.xAxis.crosshair`,e=>(e.enabled=n,c(e,o,s),e));return l=H(l,`.display.yAxis.crosshair`,e=>(e.enabled=r,c(e,i,a),e)),P(t.haloTracking)&&typeof t.haloTracking==`boolean`&&(l=H(l,`.display.chart`,e=>(e.plotHover=t.haloTracking,e))),l}function VA(e,t){return H(e,`.display.tooltip`,e=>(t.visible!=null&&(e.visible=t.visible),t.mode&&(e.mode=t.mode),t.showMainTitle!=null&&(e.showMainTitle=t.showMainTitle),t.mainTitle&&(e.mainTitle=t.mainTitle),e))}function HA(e,t){let n=F(t);return Object.keys(t).forEach(e=>{z.EVENTS.includes(e)||delete n[e];let r=t[e];typeof r==`boolean`?r={show:t[e]}:Object.keys(r).forEach(e=>{z.EVENT_PROPERTIES.includes(e)||delete r[e]}),n[e]=r}),H(e,Ku,e=>(e.type===`Symbol`&&(e.events=e.events||{},Object.keys(n).forEach(t=>{e.events[t]=e.events[t]||{},ct(e.events[t],n[t],!1)})),e))}function UA(e,t){let n=H(e,`..panes{${Ku}}.axes`,e=>(N(t.scale)&&(e.scale=t.scale),e));n=H(n,`.display.xAxis`,e=>(N(t.marginBars)&&(e.marginBars=t.marginBars),N(t.nonEodLabelWithDate)&&(e.nonEodLabelWithDate=t.nonEodLabelWithDate),N(t.ordinalName)&&(e.ordinalName=t.ordinalName),N(t.preventHorizontalLabelOverlap)&&(e.preventLabelOverlap=t.preventHorizontalLabelOverlap),e));let r=()=>I(`The 'minPadding' and 'maxPadding' are deprecated (ignored)`,`warn`),i=()=>I(`The 'preventLabelOverlap' is deprecated, please use 'preventVerticalLabelOverlap'`,`warn`);return n=H(n,`.display.yAxis`,e=>{(P(t.minPadding)||P(t.maxPadding))&&r();let n=N(t.preventLabelOverlap)&&!N(t.preventVerticalLabelOverlap);n&&i();let a=n?t.preventLabelOverlap:t.preventVerticalLabelOverlap;return N(a)&&(e.preventLabelOverlap=a),P(t.includePercentChangeWithLastValue)&&(e.includePercentChangeWithLastValue=t.includePercentChangeWithLastValue),P(t.snapAnnotationsToPrices)&&(e.snapAnnotationsToPrices=t.snapAnnotationsToPrices),P(t.primaryOnTheLeft)&&(e.primaryOnTheLeft=t.primaryOnTheLeft),e}),P(t.labels)&&Array.isArray(t.labels)&&t.labels.forEach(e=>{let{axis:t,text:r,index:i,paneIndex:a}=e;P(t,r,i)&&t===`vertical`&&Number.isInteger(i)&&(n=H(n,`..panes[${a??0}]..axes[${i}]`,e=>P(e)?(e.label=r,e):z.NULL_OBJECT))}),N(t.contractTransition)&&(n=H(n,`.display.xAxis`,e=>(lt(e.contractTransition,t.contractTransition),e))),N(t.cycleTransition)&&(n=H(n,`.display.xAxis`,e=>(lt(e.cycleTransition,t.cycleTransition),e))),n}function WA(e,t,n){let r=e;if(P(t.comparisonMode)&&typeof t.comparisonMode==`string`&&nt(x,t.comparisonMode)&&(r=H(r,`..panes{${Ku}}.axes`,e=>(e.comparison=t.comparisonMode,e))),P(t.gridLines)){let[e,n]=Qe(t.gridLines);r=H(r,`.display.xAxis.gridLines`,t=>(t.visible=e,t)),r=H(r,`.display.yAxis.gridLines`,e=>(e.visible=n,e))}if(P(t.minorGridLines)){let[,e]=Qe(t.minorGridLines);r=H(r,`.display.yAxis.minorGridLines`,t=>(t.visible=e,t))}P(t.newPaneHeight)&&typeof t.newPaneHeight==`number`&&(r=H(r,`.display.chart{.newPaneHeight > 0}`,e=>(e.newPaneHeight=t.newPaneHeight,e))),P(t.showNavigator)&&typeof t.showNavigator==`boolean`&&(r=H(r,`.display.scrollbar`,e=>(e.visible=t.showNavigator,e))),P(t.plotHover)&&typeof t.plotHover==`boolean`&&(r=H(r,`.display.chart`,e=>(e.plotHover=t.plotHover,e))),P(t.showLastValue)&&typeof t.showLastValue==`string`&&(r=H(r,`.display.yAxis`,e=>(e.showLastValue=t.showLastValue,e))),P(t.showMinMaxArc)&&typeof t.showMinMaxArc==`boolean`&&(r=H(r,`.display.chart`,e=>(e.showMinMaxArc=t.showMinMaxArc,e))),P(t.showGoToLatest)&&typeof t.showGoToLatest==`boolean`&&(r=H(r,`.display.chart`,e=>(e.showGoToLatest=t.showGoToLatest,e))),P(t.showLegend)&&typeof t.showLegend==`boolean`&&(r=H(r,`.display.chart`,e=>(e.showLegend=t.showLegend,e)),t.showLegend||n.view.removeLegend()),P(t.allAnnotationsLocked)&&typeof t.allAnnotationsLocked==`boolean`&&(r=H(r,`.display`,e=>(e.allAnnotationsLocked=t.allAnnotationsLocked,e))),P(t.exprSkipLeadingEmpty)&&typeof t.exprSkipLeadingEmpty==`boolean`&&(r=H(r,`.data`,e=>(e.exprSkipLeadingEmpty=t.exprSkipLeadingEmpty,e)));let i=[];if(P(t.extendedHours)&&typeof t.extendedHours==`boolean`&&(r=H(r,`.data`,e=>(e.extendedHours=t.extendedHours,e))),P(t.realTimeCboeBzx)&&typeof t.realTimeCboeBzx==`boolean`&&(r=H(r,`.data`,e=>(e.realTimeCboeBzx!==t.realTimeCboeBzx&&i.push(`realTimeCboeBzx`),e.realTimeCboeBzx=t.realTimeCboeBzx,e))),P(t.buildContinuation)&&typeof t.buildContinuation==`boolean`&&(r=H(r,`.data`,e=>(e.buildContinuation=t.buildContinuation,e))),i.length>0){let e={chart:n.accessor,hostPropsChanged:i};n.notifyHost(G.CH_HOST_PROPS_CHANGED,e)}return r}var GA=`MARKED_FOR_DELETION`;function KA(e,t){if(t.plots.length===0)return e;let n=e;for(let e of t.plots){let t=tj(n,e);if(t===void 0)continue;let r=QA(t),i=$A(n,r);P(i)&&(P(e.type)&&i.type!==e.type||(n=H(n,r,e=>(e[GA]=!0,e))))}return n=H(n,`..plots{.${GA} === true}`,e=>z.NULL_OBJECT),n=H(n,`..plots{.type === "Study"}`,e=>{let t=B(e.study);return P(t)&&Gu(n,t,e.basis).eligible?e:z.NULL_OBJECT}),Ld(n)}function qA(e,t,n,r){let i=C[e.type],a={curves:F(e.curves),type:e.type,uid:e.uid};a.precision=e.precision,a.visible=e.visible,a.detachedScale=e.detachedScale;let o=(e,t)=>{P(e[t])?a[t]=e[t].map(e=>F(e)):a[t]=[]},s=(e,t,n=!1)=>{t.main===!0&&(e.main=!0,e.showPrevious=t.showPrevious,n&&t.events!=null&&(e.events=F(t.events)))},c=(e,t=e=>!0)=>{P(r)&&(e.subtitles=r.allPlots.filter(e=>e.type===i).filter(t).map(e=>e.title))};switch(i){case C.Symbol:{a.title=e.symbol;let t=a.curves[0].style,n=t=>{o(e,`inputs`),a.inputs.length===0&&(a.inputs=F(t))};switch(t){case`Renko`:n(z.DEFAULT_RENKO_INPUTS);break;case`Kagi`:n(z.DEFAULT_KAGI_INPUTS);break;case`PointAndFigure`:n(z.DEFAULT_PNF_INPUTS);break;case`LineBreak`:n(z.DEFAULT_LINEBREAK_INPUTS);break;case`Baseline`:n(z.DEFAULT_BASELINE_INPUTS);break}s(a,e,!0);break}case C.Study:{o(e,`inputs`);let r=B(e.study),i=a.inputs,s=e.study===`AVWAP`,c=i.length===0?``:` (${i.map(e=>s&&e.name===`Anchor`?new Date(e.value).toLocaleString():e.value).join(`, `)})`,l=a.curves.map(e=>Number(e.shift)).filter(e=>e>0),u=l.length===0?``:` [${l.join(`, `)}]`;a.title=`${r.id}${c}${u}`,a.studyId=r.id,o(e,`levels`),o(e,`bands`),a.basis=F(e.basis)||{kind:`main`},a.placement=t?n?`overlay`:`withMain`:`standalone`;break}case C.BalanceSheet:case C.IncomeStatement:{let t=W[e.curves[0].fields[0]];a.title=`${t.name} (${e.fundamental.substring(0,1)})`,a.fundamentalId=t.id,a.frequency=e.fundamental;break}case C.Expression:a.title=e.expression,s(a,e);break;case C.Forward:a.title=e.forward,o(e,`offsets`),c(a),s(a,e);break;case C.Seasonal:a.title=e.seasonal,c(a,e=>e.refSeasonal===a.title),o(e,`offsets`),s(a,e);break;default:throw Error(`Unexpected plot type`)}return a}function JA(e,{main:t,type:n,index:r,uid:i},a){let o=`..plots{.main === true}`,s=V(e,`..panes`).map((e,t)=>{let n=V(e,o).length===1;return V(e,`..axes`).map((e,r)=>{let i=V(e,o).length===1;return V(e,`..plots`).map(e=>{let o=qA(e,n,i,a);return o.paneIndex=t,o.axisIndex=r,o})})}).flat(2).map((e,t)=>(e.index=t,e));if(P(i))return s.filter(e=>e.uid===i);if(t)return s.filter(e=>e.main);if(P(n)){let e=s.filter(e=>e.type===n);return P(r)?e.filter(e=>e.index===r):e}else return s}var YA=[`overlay`,`standalone`,`withMain`,`clone`];function XA(e,t,n){t[n]&&(e[n]=t[n])}function ZA(e,t){e.type===`Study`&&t.curves?.forEach(e=>delete e.varyColorPerBar),rj(e)?P(t.curves)&&(e.curves=t.curves):cj(e.curves,t.curves);let n=C[t.type],r=e;if(P(t.precision)?r.precision=t.precision:delete r.precision,n===C.Symbol)P(t.symbol)&&(e.symbol=t.symbol);else if(n===C.Study)P(t.basis)&&(e.basis=F(t.basis)),lj(e.inputs,t.inputs,e),[`bands`,`levels`,`detachedScale`].forEach(n=>XA(e,t,n));else if((n===C.BalanceSheet||n===C.IncomeStatement)&&t.frequency)e.fundamental=t.frequency;else if(n===C.Expression){let n=e;P(t.expression)&&(n.expression=t.expression)}else if(n===C.Forward){let n=e;P(t.offsets)&&(n.offsets=t.offsets),P(t.forward)&&(n.forward=t.forward)}else if(n===C.Seasonal){let n=e;P(t.offsets)&&(n.offsets=t.offsets),P(t.seasonal)&&(n.seasonal=t.seasonal),P(t.usesInAverage)&&(r.usesInAverage=t.usesInAverage),vl(n)}}var QA=e=>`..plots[${e}]`;function $A(e,t){let n=V(e,t);return n.length===1?n[0]:null}function ej(e,t){let n=0;for(let r of e.panes)for(let e of r.axes)for(let r of e.plots){if(r.uid===t)return n;n+=1}}function tj(e,t){return P(t.uid)?ej(e,t.uid):t.index}function nj(e){let t=C[e.type];return t===C.Symbol||t===C.Expression}function rj(e){let t=C[e.type];return t===C.Forward||t===C.Seasonal}function ij(e){let t=C[e.type];return t===C.Symbol||t===C.Expression||t===C.Seasonal}function aj(e,t,n){if(P(t))return t;let r=n?.uid;return typeof r==`string`?ej(e,r):void 0}function oj(e,t,n){if(P(t.placement)&&!YA.includes(t.placement))throw Error(`Unknown placement: ${t.placement}`);let r=tj(e,t),i=r===void 0?t.main?Ku:``:QA(r);if(!i)return e;let a=$A(e,i);if(!N(a)||N(t.type)&&a.type!==t.type)return e;let o=aj(e,r,a);if(t.type===C[C.Study]){let n=a,r=B(t.studyId??n.study);if(!N(r))return e;let i=P(t.basis)?t.basis:n.basis,o=Gu(e,r,i);if(!o.eligible)return I(`Cannot update study "${r.meta.title}" because ${o.reason}.`,`error`),e}if(N(t.visible))return a.visible=t.visible,e;if(a.main&&nj(a)){if(t.curves){let n=e=>e.curves[0].style===h[h.Range],[r,i]=[n(a),n(t)];r&&!i?e=ad(e,{unit:`Day`,size:1,spec:`None`}):!r&&i&&(e=ad(e,{unit:`Intraday`,size:100,spec:`PerRange`}))}t.type||=a.type;let n=a;P(t.precision)?n.precision=t.precision:delete n.precision,P(t.showPrevious)&&(e=H(e,Ku,e=>(e.showPrevious=t.showPrevious,e)));let r=t.curves?au(e,t):e;return P(t.oppositeScale)&&ij(a)&&P(o)&&(r=Vu(r,o,+!!t.oppositeScale)),r}else{let s=H(e,i,e=>(ZA(e,t),e));if(P(t.oppositeScale)&&ij(a)&&P(o)&&(s=Vu(s,o,+!!t.oppositeScale)),!(t.type===C[C.Study]&&P(t.placement)))return s;let c=P(r)?r:t.index,l=JA(s,{...t,index:c},n).find(e=>e.index===c);if(!P(l))return e;if(t.placement===l.placement)return s;let u=$A(s,i);if(!P(u))return e;s=KA(s,{id:`Delete`,plots:[{uid:u.uid,type:t.type}]});let d=mj(s,t.placement,t.cloneIndex,t.cloneUid);return d!==null&&d.plots.push(u),s}}function sj(e){return e!==void 0}function cj(e,t){if(sj(t)&&t.length===e.length)for(let n=0;n<e.length;++n){let r=t[n],i=e[n];lt(i,r);for(let e of[`shift`,`dashStyle`,`lineSmoothing`,`lineMarker`]){let t=r[e];P(t)&&(i[e]=t)}}}function lj(e,t,n){let r=dt(e),i=dt(t);lt(r,i);let a=ft(i);a.length>0&&(n.inputs=a)}function uj(){return{plots:[]}}function dj(e){let t=e.display.chart.newPaneHeight??1;return{axes:[uj()],height:t}}function fj(e){let t=dj(e);return e.panes.push(t),t}function pj(e,t){let n=N(t.paneIndex)&&t.paneIndex<e.panes.length?e.panes[t.paneIndex]:fj(e),r=n.axes[0];return t.oppositeScale??!1?Pj(n,r):r}function mj(e,t,n,r,i){let a=null,{mainPane:o,mainAxis:s}=Ju(e),c=(()=>{if(i?.kind!==`seasonal`)return null;for(let t of e.panes)for(let e of t.axes)for(let n of e.plots){if(n.uid!==i.uid||n.type!==`Seasonal`)continue;let r=n.offsets;if(Array.isArray(r)&&r.includes(i.offset))return{pane:t,axis:e}}return null})();switch(t){case`withMain`:a=c?Pj(c.pane,c.axis):Pj(o,s);break;case`overlay`:a=c?.axis??s;break;case`standalone`:a=fj(e).axes[0];break;case`clone`:{let t={main:!1,type:C[C.Study]};if(typeof r==`string`&&r.length>0?t.uid=r:typeof n==`number`&&(t.index=n),t.uid||typeof t.index==`number`){let n=JA(e,t).find(e=>e.type===C[C.Study]&&(t.uid?e.uid===t.uid:e.index===t.index));if(!n)break;a=V(e,`..panes[${n.paneIndex}]..axes[${n.axisIndex}]`)[0]}break}}return a}function hj(e,t){let n=B(t.studyId);if(!N(n))return I(`Unknown or unavailable study with the id '${t.studyId}'`,`error`),e;let r=Gu(e,n,t.basis);if(!r.eligible)return I(`Cannot add study "${n.meta.title}" because ${r.reason}.`,`error`),e;let i=t.placement||(n.meta.overlay?`overlay`:`standalone`),a=t.uid??bt();P(t.uid)&&Iu(e,a);let o={uid:a,type:`Study`,study:t.studyId,visible:!0};i===`overlay`&&t.studyId===`VOL`&&(o.detachedScale=!0),t.curves!==void 0&&(o.curves=n.defaults.curves),ZA(o,t);let s=mj(e,i,t.cloneIndex,t.cloneUid,t.basis);P(s)&&s.plots.push(o);let c=e.data.aggregation;return id(e,c.unit===`Tick`&&c.spec===`None`)}function gj(e,t){e.panes.push({axes:[{plots:[t]}]})}function _j(e,t){let n=qu(e);if(n.type!==C[C.Symbol])throw Error(`Cannot add fundamental to the chart whose main plot is not a Symbol plot.`);let r=n.symbol,i=t.uid??bt();P(t.uid)&&Iu(e,i);let a={uid:i,curves:[{fields:[t.fundamentalId],lineWidth:2,style:`Line`,varyColorPerBar:!1,visible:!0,colors:[`#888`]}],fundamental:`Quarter`,symbol:r,type:b[W[t.fundamentalId].category],visible:!0};return ZA(a,t),gj(e,a),e}var vj=[{fields:[W.Close.id],colors:[`#888`],style:`Line`,lineWidth:2,varyColorPerBar:!1,visible:!0}];function yj(e){return e.type===`Symbol`}function bj(e,t){let n=qu(e),r=F(yj(n)?n.curves:vj),i=t.uid??bt();P(t.uid)&&Iu(e,i);let a={uid:i,curves:r,expression:``,type:`Expression`,visible:!0};return ZA(a,t),pj(e,t).plots.push(a),e}function xj(e,t){let n=t.uid??bt();P(t.uid)&&Iu(e,n);let r={uid:n,curves:F(vj),offsets:[0],seasonal:``,type:`Seasonal`,visible:!0,main:!1};return ZA(r,t),pj(e,t).plots.push(r),e}var Sj={attributes:[`OpenVsClose`],colors:[`#b63400`,`#007f3e`,`#1664db`],fields:[`Open`,`High`,`Low`,`Close`,`Change`],style:`Candlestick`,varyColorPerBar:!0,lineWidth:1};function Cj(e,t){let n=qu(e),r=$().getDefaultMultiFieldCurve(),i=P(r)?r:Sj,a=n.curves?.length,o=a===t.curves.length&&a===1?(e=>F(e?n.curves:[i]))(yj(n)):t.curves,s=t.uid??bt();P(t.uid)&&Iu(e,s);let c={uid:s,curves:o,symbol:``,type:`Symbol`,visible:!0};return ZA(c,t),pj(e,t).plots.push(c),e}function wj(e,t){switch(t.type){case`Study`:return hj(e,t);case`IncomeStatement`:case`BalanceSheet`:return _j(e,t);case`Expression`:return bj(e,t);case`Symbol`:return Cj(e,t);case`Seasonal`:return xj(e,t);default:throw Error("Unexpected plot type '${type}', not supported currently")}}var Tj=0,Ej=z.AUTO_COLORS,Dj=`Symbol`,Oj=`Expression`,kj=`Seasonal`;function Aj(e,t){let n={attributes:[],colors:Ej.slice(Tj,Tj+1),fields:e?[W.Last.id]:[W.Close.id],style:`Line`,dashStyle:`Solid`,varyColorPerBar:!1,lineWidth:2,lineMarker:void 0,lineSmoothing:void 0},r={uid:t.uid??bt(),curves:[n]},{curves:i,oppositeScale:a,...o}=t;return ut(r,o),N(i)&&(r.curves=i.map(e=>{let t=F(e);return ut(t,n),t})),r.main=!1,Tj=(Tj+1)%Ej.length,r}function jj(e){return P(e.symbols)&&(I(`Use of 'symbols' for Compare API is deprecated. Please see docs for the latest version which supports more plot types`,`warn`),e.plots=e.symbols.map(e=>(e.type=Dj,e))),e.plots?.some(e=>P(e.leftScale))?(I(`Use of 'leftScale' for Compare API is deprecated. Please use 'oppositeScale'`,`warn`),e.plots.map(e=>{let t=e.leftScale;return delete e.leftScale,{...e,oppositeScale:t}})):e.plots}function Mj(e,t){let n=jj(t),r=n.map(e=>e.uid).filter(e=>typeof e==`string`),i=new Set;for(let t of r){if(i.has(t))throw Error(`Plot uid '${t}' is duplicated in the Compare request.`);i.add(t),Iu(e,t)}let{yes:a,no:o}=A(n,e=>e.oppositeScale??!1),{mainPane:s,mainAxis:c}=Ju(e);s.alignOnExpirations=t.alignOnExpirations||!1;let l=Pj(s,c),u=e=>![Dj,Oj,kj].includes(e.type);l.plots=l.plots.filter(u);let d=c.plots.filter(e=>e.main||u(e)),f=e.data.aggregation.unit===`Tick`;Tj=0;let p=se(Aj,f);return c.plots=d.concat(o.map(p)),a.length>0&&(l.plots.push(...a.map(p)),l.comparison=c.comparison,l.scale=c.scale),Ld(e)}var Nj=`..plots{(.type === "Symbol" || .type === "Expression" || .type === "Seasonal") && .main !== true}`;function Pj(e,t){let n=e.axes.find(e=>e!==t);return P(n)||(n=uj(),e.axes.push(n)),n}function Fj(e,t){let n=V(e,Nj),r=V(t,Nj),i=Math.max(0,4-r.length);if(i===0)return t;let a=n.filter(e=>!r.find(t=>e.symbol===t.symbol)).slice(0,i);if(a.length===0)return t;let{mainPane:o,mainAxis:s}=Ju(t),{mainAxis:c}=Ju(e);return a.forEach(e=>{c.plots.includes(e)?s.plots.push(e):Pj(o,s).plots.push(e)}),t}function Ij(e,t){let n=e.panes;return n.splice(t.to,0,n.splice(t.from,1)[0]),e}var Lj=()=>z.NULL_OBJECT;function Rj(e){return H(e,`..axes.annotations`,Lj)}function zj(e){return Ld(H(e,`..plots{.type === "Symbol" && .main !== true}`,Lj))}function Bj(e,t){let n=F(e);if(t.strip.main){let e=qu(n),t=e.type.toLowerCase();e[t]=z.PLACEHOLDER_SYMBOL_NAME}return t.strip.annotations&&(n=Rj(n)),t.strip.compare&&(n=zj(n)),n=H(n,`.data`,e=>(e.range&&(delete e.range,e.checkRange=!0),e)),n}function Vj(e,t,n){let r=JA(e,{main:!0},n)[0],i=r.title===z.PLACEHOLDER_SYMBOL_NAME,a=r.type===`Symbol`,o=r.type===`Expression`,s=wu(r.title),c=[];return o&&!Cu(s)?c=s.symbols:i||(c=[r.title]),{isTemplate:i,isDefinition:!i,main:{isSymbol:a,isExpression:o,symbols:c,title:i?null:r.title},compare:V(e,Nj).map(e=>e.symbol),annotations:V(e,`..annotations`).map(e=>e.id),studies:JA(e,{type:`Study`},n).map(e=>e.title)}}function Hj(e,t,n){let r=V(e,`..panes`).map((e,t)=>V(e,`..axes`).map((e,n)=>V(e,`.annotations`).map(e=>({...e,paneIndex:t,axisIndex:n})))).flat(2).map((e,t)=>({...e,index:t}));return P(t.index)&&Number.isFinite(t.index)?t.index<r.length?[r[t.index]]:z.EMPTY_ARRAY:r}function Uj(e,t,n){let r=V(e,`..panes{${Ku}}.axes.comparison`)[0],i=e.display,a=(e,t)=>rt(e,!1,t,`visible`),o=e=>$e(a(i.xAxis,e),a(i.yAxis,e)),s=rt(i.chart,!0,`showLegend`);return{comparison:r,gridLines:o(`gridLines`),minorGridLines:o(`minorGridLines`),newPaneHeight:i.chart.newPaneHeight,showLastValue:i.yAxis.showLastValue,showLegend:s,showMinMaxArc:i.chart.showMinMaxArc,allAnnotationsLocked:i.allAnnotationsLocked,exprSkipLeadingEmpty:e.data?.exprSkipLeadingEmpty??!1,extendedHours:e.data?.extendedHours??!1,realTimeCboeBzx:e.data?.realTimeCboeBzx??!1,buildContinuation:e.data?.buildContinuation??!1}}function Wj(e,t){let n=e,{backgroundColor:r,axis:{gridLinesColor:i,textColor:a,crosshairColor:o,gridLinesStyle:s},fontSize:c}=t,{chart:l,xAxis:u,yAxis:d}=c||{};if((r||l)&&(n=H(e,`.display.chart`,e=>(r&&(e.backgroundColor=r),l&&(e.fontSize=l),e))),i){let e=e=>(e.color=i,e);n=H(n,`.display.xAxis.gridLines`,e),n=H(n,`.display.yAxis.gridLines`,e),n=H(n,`.display.yAxis.minorGridLines`,e)}if(s){let e=e=>(e.dashStyle=s,e);n=H(n,`.display.xAxis.gridLines`,e),n=H(n,`.display.yAxis.gridLines`,e),n=H(n,`.display.yAxis.minorGridLines`,e)}if(a){let e=e=>(e.textColor=a,e);n=H(n,`.display.xAxis`,e),n=H(n,`.display.yAxis`,e)}if(o){let e=e=>(e.color=o,e);n=H(n,`.display.xAxis.crosshair`,e),n=H(n,`.display.yAxis.crosshair`,e)}if(u||d){let e=e=>t=>(t.fontSize=e,t);u&&(n=H(n,`.display.xAxis`,e(u))),d&&(n=H(n,`.display.yAxis`,e(d)))}return n}function Gj(e,t,n){let{chart:r,xAxis:i,yAxis:a}=e.display||{},{fontSize:o,backgroundColor:s}=r||{},{fontSize:c,gridLines:l,textColor:u,crosshair:d}=i||{},{color:f,dashStyle:p}=l||{},{fontSize:m}=a||{},{color:h}=d||{};return{backgroundColor:s,axis:{gridLinesColor:f,textColor:u,crosshairColor:h,gridLinesStyle:p},fontSize:{chart:o,xAxis:c,yAxis:m}}}function Kj(e,t,n){let{mainAxis:r}=Ju(e),i=V(e,`.display.xAxis`)[0],a=V(e,`.display.yAxis`)[0];return{scale:r.scale,marginBars:i.marginBars??0,preventLabelOverlap:a.preventLabelOverlap,preventVerticalLabelOverlap:a.preventLabelOverlap,preventHorizontalLabelOverlap:i.preventLabelOverlap,snapAnnotationsToPrices:a.snapAnnotationsToPrices,primaryOnTheLeft:a.primaryOnTheLeft??!1,nonEodLabelWithDate:i.nonEodLabelWithDate??!1,includePercentChangeWithLastValue:a.includePercentChangeWithLastValue??!1,ordinalName:i.ordinalName??``,contractTransition:i.contractTransition,cycleTransition:i.cycleTransition}}function qj(e,t,n){let r=t=>V(e,t)[0],i=r(`.display.chart`),a=r(`.display.xAxis.crosshair`),o=r(`.display.yAxis.crosshair`),s=`none`;return a.enabled&&o.enabled?s=`both`:a.enabled?s=`vertical`:o.enabled&&(s=`horizontal`),{crosshair:s,horizontal:{color:o.color,dashStyle:o.dashStyle},vertical:{color:a.color,dashStyle:a.dashStyle},haloTracking:i.plotHover}}function Jj(e,t,n){return F(e.data.aggregation)}function Yj(e,t){let n=V(e,Nj),{mainPane:r,mainAxis:i}=Ju(e),a=[];for(let e of n){let t=!i.plots.includes(e),n=e.type.toLowerCase(),r={curves:F(e.curves),type:e.type,[n]:e[n],oppositeScale:t,leftScale:t};a.push(r)}return{plots:a,alignOnExpirations:r.alignOnExpirations}}function Xj(e,t,n){let{paneIndex:r,annotations:i,studies:a}=t||{},o=`..panes${Number.isInteger(r)?`[${r}]`:``}`,s=e,c=e=>z.NULL_OBJECT;return i===!0&&(n.allAnnotations.forEach(e=>n.onAnnotationModifiedByTool(e,O.Deleted,!1)),s=H(s,`${o}..annotations`,c)),a===!0&&(s=H(s,`${o}..plots{.type=="Study"}`,c)),s=Ld(s),s}var Zj=`.display.chart.previous`;function Qj(e,t,n){return V(e,Zj)[0]}function $j(e,t,n){return H(e,Zj,e=>(lt(e,t),e))}function eM(e,t,n){let r=[],i=tj(e,t);if(i===void 0||$A(e,QA(i))?.type!==t.type)return r;let a=Ru(e,i);if(a===null)return r;let o=a.pane,s=o===0,c=o===e.panes.length-1,l=e.panes[o].axes.reduce((e,t)=>e+t.plots.length,0)===1;return s||r.push(`ExistingAbove`),l||r.push(`NewAbove`),c||r.push(`ExistingBelow`),l||r.push(`NewBelow`),r}function tM(e,t,n){if(!eM(e,t,n).includes(t.targetPane))return e;let r=tj(e,t);if(r===void 0)return e;let i=Ru(e,r);if(i===null)return e;let a=$A(e,QA(r));e.panes[i.pane].axes[i.axis].plots.splice(i.plot,1);let o=i.pane,s=!0;switch(t.targetPane){case`ExistingAbove`:o--;break;case`NewAbove`:e.panes.splice(o,0,dj(e)),s=!1;break;case`ExistingBelow`:o++;break;case`NewBelow`:o++,s=!1,e.panes.splice(o,0,dj(e));break}let{mainPane:c}=Ju(e),l=e.panes[o]===c;s&&l&&a?.type===`Study`&&a.study===`VOL`&&(a.detachedScale=!0);let u=e.panes[o];u.axes.length<2&&u.axes[0].plots.length>0&&u.axes.push(uj());let d=u.axes.findIndex(e=>e.plots.length===0),f=d===-1?u.axes.length-1:d;u.axes[f].plots.push(a);let p=Bu(e,i.pane);return p=Bu(p,o),Ld(p)}function nM(e,t,n){return P(t.period)&&t.period&&(delete e.display.period,rd(e),n&&(n.forceResetVisibleRange=!0)),e}function rM(e,t,n){let r=[],i=tj(e,t);if(i===void 0)return r;let a=$A(e,QA(i));if(a?.type!==t.type)return r;let o=Ru(e,i);if(o===null)return r;let s=e.panes[o.pane],c=o.axis===0,l=s.axes.some((e,t)=>e.plots.some((e,n)=>!(t===o.axis&&n===o.plot)&&!e.detachedScale)),u=a.detachedScale===!0;return(c||u)&&r.push(`SecondaryAxis`),(!c||u)&&r.push(`PrimaryAxis`),l&&r.push(`NoAxis`),r}function iM(e,t,n){if(!rM(e,t,n).includes(t.targetAxis))return e;let r=tj(e,t);if(r===void 0)return e;let i=-1;switch(t.targetAxis){case`PrimaryAxis`:i=0;break;case`SecondaryAxis`:i=1;break;case`NoAxis`:return Hu(e,r)}return Vu(e,r,i)}function aM(e,t,n){let r=V(e,`.display.tooltip`)[0];return{visible:r.visible,mode:r.mode,showMainTitle:r.showMainTitle,mainTitle:r.mainTitle}}var oM=`..plots{.type === "Seasonal" && .main === true}`,sM=`..plots{.type === "Seasonal" && .main !== true}`,cM=z.AUTO_COLORS;function lM(e){return JSON.parse(JSON.stringify(e))}function uM(e,t){let n=V(e,oM);if(n.length===0)return e;let r=n[0];if(!r.offsets||r.offsets.length===0)return e;let i=r.offsets,a=V(e,sM);for(let e of a){let t=e.offsets??[],n=e.curves??[],r=new Map;t.length===n.length?t.forEach((e,t)=>{let i=n[t];i&&r.set(e,lM(i))}):n.forEach((e,t)=>{let n=i[t];e&&P(n)&&r.set(n,lM(e))});let a=r.get(0);a?.colors?.[0];let o=i.map((e,t)=>{let n=r.get(e);if(n)return n;let i=cM[t%cM.length];return{...a?lM(a):{},colors:[i],fields:[`Close`],style:`Line`,dashStyle:`Solid`,varyColorPerBar:!1,lineWidth:2}});e.offsets=[...i],e.curves=o}return Ld(e)}var dM={MainPlot:nd,Aggregation:{Update:ad,Get:Jj},Period:{Update:Xl,Delete:nM},Crosshair:{Update:BA,Get:qj},Tooltip:{Update:VA,Get:aM},Events:HA,Scale:{Update:UA,Get:Kj},Other:{Update:WA,Get:Uj},Plot:{Add:wj,Get:JA,Delete:KA,Update:oj},Compare:{Update:Mj,Get:Yj},Annotation:{Get:Hj},MovePane:Ij,Template:Bj,Outline:Vj,Theme:{Update:Wj,Get:Gj},Clear:Xj,Previous:{Update:$j,Get:Qj},MovePlot:{Update:tM,Get:eM},PinPlot:{Update:iM,Get:rM},SeasonalOffsets:{Update:uM}};function fM(e){return typeof e==`function`}function pM(e,t){let n=dM[e];if(fM(n))return n;{let e=t===void 0?void 0:n[t];if(!fM(e)&&(e=n[z.DEFAULT_ACCESSOR_SUBACTION],!fM(e)))throw Error(`Invalid accesor id and/or sub id`);return e}}function mM(e,t,n){return pM(e.id,e.context.id)(t,e.context,n)}function hM(e){return{id:`MainPlot`,context:e}}var gM={id:`SeasonalOffsets`,context:{}};function _M(e){return Array.isArray(e)&&e.some(e=>e?.type===`Seasonal`)}function vM(e){let{id:t,context:n}=e;if(!P(n))return!1;if(t===`Compare`)return _M(n.plots);if(t!==z.ACTION_PLOT)return!1;let r=n.id;return r===`Add`||r===`Update`?n.type===`Seasonal`:r===z.ACTION_DELETE?_M(n.plots):!1}function yM(e){return e.some(vM)?e[e.length-1]?.id!==`SeasonalOffsets`:!1}var bM={keepOldAnnotations:!1,keepNewAnnotations:!0,keepOldCompare:!1,keepNewCompare:!0,keepOldAggregation:!1,keepNewBarWidth:!1},xM=Symbol.for(`__ias__`),SM=class{presenter;_model;constructor(e=!1){this.headless=e,this.presenter=e?null:new PA(this)}get elementId(){return this.headless?null:this.presenter?.elementId??null}get hostElement(){return this.headless?null:this.presenter?.hostElement??null}initialize(e,t=null){if(this.headless){I(`You cannot initialize a headless chart.`,`error`);return}if(this.presenter.initialize(e),N(t)){let e=typeof t==`string`;e?I(`Initializing the chart with symbol name is deprecated. Please use object form instead (see docs for details). This API will be removed in the future.`,`warn`):(t.template&&this.load(t.template),delete t.template);let n=e?{symbol:t}:t;this.change(hM(n))}}shutdown(){if(!this.headless){let e=this.presenter?.shutdown();return this.presenter=null,e}return!1}annotate(e,t=null,n=null){if(!this.headless)if(P(e)){Rc(e,t),Lc(e,t);let r=Dk(e,!1,t,n,this.presenter);r.isDrawingAnnotation&&this.presenter.view.setCursor(ee.Crosshair),this.presenter.activeTool=r,Ie()||this.presenter.view.mouseCanvas.focus({preventScroll:!0})}else this.presenter.resetActiveTool()}cancelAnnotation(){this.headless||this.presenter.resetActiveTool()}zoom(e){!this.headless&&typeof e==`boolean`&&(e?this.annotate(`ZoomIn`):this.presenter.defaultTool.resetView(this.presenter))}getDefaultTemplate(){return qM()}get model(){return(this.headless?this._model:this.presenter.getModel())||qM()}asTemplate(e={main:!0,annotations:!1,compare:!1}){return this.change({id:z.ACTION_TEMPLATE,context:{strip:e}})}change(...e){let t={chart:this,actions:e.filter(e=>!e[xM])};t.actions.length>0&&this.presenter?.notifyHost(G.CH_API_ACTIONS_RECEIVED,t);let n=$().config.validateInput,r=e.map(e=>n?Id(e,z.ACCESSOR_SCHEMA):e);if(r.length===1){let e=r[0];if(e.id===z.ACTION_TEMPLATE||e.context.id===z.ACTION_GET)return mM(e,this.model,this.presenter);if(!this.headless&&e.id===z.ANN_ACTION_ID)return this.presenter.handleAnnotationChange(e.context)}let{yes:i,no:a}=A(r,e=>e.id===z.ACTION_PLOT&&P(e.context)&&e.context.id===z.ACTION_DELETE),o=F(this.model),s=F(this.model),c=a;i.length>0&&c.push({id:z.ACTION_PLOT,context:{id:z.ACTION_DELETE,plots:i.map(e=>e.context)}}),c.forEach(e=>{if(s=mM(e,s,this.presenter),!P(s))throw Error(`Forgot to return model from accessor`)}),yM(c)&&(s=mM(gM,s,this.presenter)),this.fromModel(s,o)}async fromModel(e,t){let n=Id(e,z.CHART_SCHEMA);this.headless?this._model=n:await this.presenter?.fromModel(n,t)}async load(e,t){let n={...bM,...t},r=Id(JSON.parse(e),z.CHART_SCHEMA),i=this.model,a=F(i);if(P(i)){if(r=Yu(i,r,n.keepNewAnnotations),n.keepNewAnnotations||(r=Rj(r)),n.keepOldAnnotations&&(r=EA(i,r)),n.keepNewCompare||(r=zj(r)),n.keepOldCompare&&(r=Fj(i,r)),n.keepOldAggregation){let e={id:z.ACTION_AGGREGATION,context:i.data.aggregation},t=r.display.density;r=mM(e,r,this.presenter),n.keepNewBarWidth&&P(t)&&(r.display.density=t)}await this.fromModel(r,a),this.clearUndoRedo()}}save(){return JSON.stringify(this.model)}clearUndoRedo(){!this.headless&&this.presenter?.undoRedoManager&&this.presenter.undoRedoManager.clear(!0)}reset(e=!0){let t=qM();if(this.headless)this._model=t;else if(this.presenter.getModel()){let n=this.presenter.mainPlot,r=null,i=n;if(n.isSymbol?r={symbol:i.symbol}:n.isExpression?r={expression:i.expression}:n.isForward?r={forward:i.forward}:n.isSeasonal&&(r={seasonal:i.seasonal}),P(r)){let n=mM({id:`Theme`,context:{id:`Get`}},this.model,this.presenter),i=mM(hM(r),t,this.presenter);e&&(i=mM({id:`Theme`,context:n},i,this.presenter)),this.presenter?.fromModel(i)}}this.clearUndoRedo(),this.presenter?.notifyHost(G.CH_RESET,{elementId:this.elementId})}print(e={}){this.headless||this.presenter.print(e)}getSVGForExport(){I(`Obsolete: please use 'exportImage' method instead.`,`warn`)}setTitle(e){this.headless||this.presenter.setTitle(e)}getPaneBounds(e=!0){if(!this.headless)return this.presenter.panes.map(t=>e?t.getBounds():t.getBoundsWithoutScales())}exportData(e={}){return this.headless?null:jA.call(this.presenter,e)}exportImage(e={}){return this.headless?null:MA.call(this.presenter,e)}getDataStats(){return this.presenter.getDataStats()}get canUndo(){return!this.headless&&(this.presenter?.undoRedoManager?.canUndo??!1)}get canRedo(){return!this.headless&&(this.presenter?.undoRedoManager?.canRedo??!1)}undo(){this.canUndo&&this.presenter?.undoRedoManager?.undo()}redo(){this.canRedo&&this.presenter?.undoRedoManager?.redo()}pauseUndoRedo(){this.headless||this.presenter?.undoRedoManager?.pause()}resumeUndoRedo(e){this.headless||this.presenter?.undoRedoManager?.resume(e)}priceToY(e,t=0,n=0){let r=this.presenter;if(this.headless||t<0||n<0||t>r.panes.length)return null;let i=r.panes[t];return n>i.axes.length?null:i.axes[n].toY(e)}yToPrices(e){let t=this.presenter;if(this.headless)return null;for(let[n,r]of t.panes.entries()){let t=r.getBounds();if(P(t)&&e>=t.y&&e<=t.y+t.height)return{pane:n,prices:r.axes.map(t=>t.toPrice(e))}}return{pane:-1,prices:[]}}activate(){this.presenter?.notifyHost(G.CH_DIDBECOMEACTIVE,{chart:this})}};function CM(e){let t=e.split(`.`);if(!t||t.length!==4)return!1;let n=t.map(Number);if(!n.every(e=>Number.isFinite(e)&&e>=0&&e<=255))return!1;let[r,i]=n;return r===10||r===172&&i>=16&&i<=31||r===192&&i===168}function wM(){let e=globalThis.parent?.location?.hostname||``;return[``,`localhost`,`127.0.0.1`].includes(e)||CM(e)}function TM(){let e=document.domain,t=e.split(`.`),n=`__tld`+new Date().getTime(),r=0;for(;r<t.length-1&&document.cookie.indexOf(`${n}=${n}`)===-1;)e=t.slice(-1-++r).join(`.`),document.cookie=`${n}=${n};domain=${e};`;return document.cookie=`${n}=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=${e};`,e}function EM(e,t){return ot(t),`${e}/?${new URLSearchParams(t).toString()}`}var DM=`aHR0cHM6Ly9iYXJjaGFydHdpZGdldHMud2Vic29sLmJhcmNoYXJ0LmNvbQ==`,OM=`YXV0aGVudGljYXRlQ2hhcnRSZWZlcmVy`;function kM(e,t=``){return EM(atob(DM),{module:atob(OM),secret:t,referer:e})}function AM(e,t){return e+Math.random()*(t-e)}var jM=Function(atob(`Y29uc29sZS5sb2coIlBsZWFzZSBjb250YWN0IEJhcmNoYXJ0IGluIG9yZGVyIHRvIG9idGFpbiB0aGUgbGljZW5zZSBmb3IgdGhlIGNoYXJ0IGNvbXBvbmVudC4iKTsg`)),MM=Function(`f`,atob(`Zi5yZW1vdmVBbGxDaGFydHMoKTsg`)),NM=Function(`m`,atob(`cmV0dXJuIG0gPT09ICJJbnRlcm5hbEZlZWQiIHx8IG0gPT09ICJXaWRnZXQiIHx8IG0gPT09ICJGcmVlV2lkZ2V0IiB8fCBtID09PSAiRGVtb1NpdGUiOw==`)),PM=`YXV0aG9yaXplZA==`,FM=`ZGF0YS1lbmRwb2ludA==`,IM=`YWxsb3dDcmVkZW50aWFscw==`;async function LM(e,t){if(t&&!NM(e.mode))return;let n=!1,r=0,i=25;for(;!n&&r<5;){let t=wM()||e.mode===`FreeWidget`,a=t?e.apiKey:``;try{let i=kM(t?``:TM(),a),o=await fetch(i);if(!o.ok)r++;else{let t=await o.json(),r=t[atob(PM)];e.knownSite=r,r?(e.dataEndpoint=(t[atob(FM)]||``).replace(/\/$/g,``),e.allowCredentials=t[atob(IM)]):(e.dataEndpoint=``,e.allowCredentials=!1),n=!0;break}}catch{}r++,i*=2,await new Promise(e=>setTimeout(e,i))}(!n||!e.knownSite)&&RM()}function RM(){setTimeout(jM,AM(2e3,3e3)),setTimeout(()=>MM($()),AM(4e3,5e3))}var zM={major:2,minor:382,patch:1,prerelease:!1},BM={environment:`Browser`,validateInput:!1,throttleMillis:0,isAlt64:!0,defaultTemplate:`/${z.CHART_DEFINITION}`,cachedAnnotationsCount:0,showResizeHandles:!1,scrollBehavior:`wheel+shift`,bypassSmoothing:!1,showGoToLatest:void 0,tooltipMovement:`Auto`,tooltipHeaders:void 0,touchCrosshairTimeoutMillis:void 0,touchCrosshairDelayMillis:void 0,mode:`Unspecified`,hostingModel:`Page`,overrides:void 0,logo:void 0,logoClickable:void 0,noDataText:void 0,useAllFieldsForComparison:void 0,colorfulAnnotations:!1,baseUrl:{instruments:`/proxies/instruments`,futures:`/proxies/futures`,timeseries:`/proxies/timeseries`,timeseriesNew:`/proxies/new-timeseries`,ondemand:`/proxies/ondemand`,options:`/proxies/core-api`},credentials:void 0,apiKey:void 0,extensions:void 0,defaultVolumeBarColoring:void 0,defaultMainPlotBarColoring:void 0,async fetch(e,t){let n=this.baseUrl[e],r=`${n}${t}`;if(NM(this.mode)&&this.knownSite){let{username:i,password:a}=this.credentials||{},o=P(i,a),s=(e===`timeseries`||e===`timeseriesNew`)&&o&&this.allowCredentials?`&username=${i}&password=${a}`:``;r=`https://${this.dataEndpoint}${n}${t}${s}`}return await(await fetch(r)).text()},getCustomEventPopup:e=>null};async function VM(e,t){let n=$()?.config;if(!n||!n.fetch)throw Error(`You should call initFeed first`);let r=t;return e===`timeseries`?r=`/historical${t}`:e===`options`&&(r=`/options-historical${t}`),await n.fetch.call(n,e,r)}var HM=!1,UM=null;function WM(){let e=zM,t=e.prerelease?`-${e.prerelease.identifier}.${e.prerelease.ordinal}`:``;return`${e.major}.${e.minor}.${e.patch}${t}`}function GM(e){let t=e.extensions?.studyProvider;if(!P(t))return;let n=t.getFields(),r=t.getStudies(),i=F(ss(z.CHART_SCHEMA)),a=i.definitions,o=a.studyField.enum,s=a.study.enum;for(let e of n)if(o.includes(e.id))throw Error(`Field with id ${e.id} already exists`);for(let e of r)if(s.includes(e.id))throw Error(`Study with id ${e.id} already exists`);o.push(...n.map(e=>e.id)),s.push(...r.map(e=>e.id)),Md(z.CHART_SCHEMA,i),Hd(n),fs(r)}function KM(e,t={}){if(HM)throw Error(`You should only call initFeed once during page's lifetime`);HM=!0;let n=Object.assign(BM);return lt(n,t),N(n.logo)&&nO(n.logo,n.logoClickable??!1),GM(n),UM=new e(n),UM.version=WM(),I(`%cBarchart Chart version ${UM.version}`,`info`,`font-size: larger`),UM.cachesData&&(UM.subject?.subscribe(UM.onPerformInternalGc.bind(UM)),kv.default.subscribe(G.CH_ALL,UM.onChartChanged.bind(UM))),UM}function $(){return UM}function qM(){return F($()?.template)}function JM(){N(UM)&&(UM.shutdown(),HM=!1,UM=null)}function YM(){return new SM(!0)}function XM(e){let t=YM();return t.load(e),t.change({id:`Outline`,context:{id:`Get`}})}function ZM(e,t,n,r=null){return new Proxy(e,{get:function(e,i,a){return i===t?function(t){let a=r?t[r]:t;return(n.handlesRequestsFor(a)?n:e)[i](t)}:Reflect.get(e,i,a)}})}var QM=class{version;cachesData;timeSeriesSource;metaDataSource;recordSource;charts;pendingRedraw;template;ongoingAnimationCallbackId;_altDataSource;_subject;knowDefaultCurve;defaultOhlcCurve;knowDefaultAggregation;defaultAggregation;knowDefaultPeriod;defaultPeriod;knowDefaultDensity;defaultDensity;id;_mainFeed=null;onBrowserOnline;constructor(e){this.config=e,this.timeSeriesSource=this.metaDataSource=this.recordSource=null,this.charts=new Map,this.pendingRedraw=new Set,this.ongoingAnimationCallbackId=null,this.drawCharts=this.drawCharts.bind(this),this.template=null,this.cachesData=!1,this._altDataSource=null,this._subject=null,this.id=bt(),this.onBrowserOnline=()=>{!this.cachesData||this.isAuxiliary||(this.traceFeed(`refresh:online`),this.refreshCaches())},globalThis.addEventListener?.(`online`,this.onBrowserOnline)}traceFeed(e,t={}){Vm(e,{feedId:this.id,isAuxiliary:this.isAuxiliary,...t})}get subject(){return!this.isAuxiliary&&!N(this._subject)&&(this.traceFeed(`gc:stream:init`,{gcMillis:z.INTERNAL_GC_MILLIS}),this._subject=new ip().pipe(Bp(z.INTERNAL_GC_MILLIS),zp(e=>e.length>0))),this._subject}get isAuxiliary(){return window.opener!==null}setAltDataSource(e){this._altDataSource=e,this.timeSeriesSource=ZM(this.timeSeriesSource,`getTimeSeries`,e,`symbol`),this.metaDataSource=ZM(this.metaDataSource,`getMetaData`,e),this.recordSource=ZM(this.recordSource,`getRecord`,e)}replaceDataSources(e){this._altDataSource=e._altDataSource,this.timeSeriesSource=e.timeSeriesSource,this.metaDataSource=e.metaDataSource,this.recordSource=e.recordSource}getAltDataSource(){return this._altDataSource}getTimeSeriesDataSource(){if(!N(this.timeSeriesSource))throw Error(`No time series source defined`);return this.timeSeriesSource}getMetaDataSource(){if(!N(this.metaDataSource))throw Error(`No metadata source defined`);return this.metaDataSource}getRecordSource(){if(!N(this.recordSource))throw Error(`No record source defined`);return this.recordSource}async ready(){return Ai.call(this,async()=>{let e=this instanceof rN||this instanceof $M||this instanceof oN;await LM(this.config,e);let t=this.config.defaultTemplate;if(!t)throw Error(`Must provide a default template`);return typeof t==`string`&&(t=await(await fetch(t)).json()),this.template=Id(t,z.CHART_SCHEMA),!0})}getHeadlessChart(){return YM()}fixupRenderTo(e){if(!N(e))return null;if(e instanceof HTMLElement)return e;let t=xi(`#${e}`);if(N(t))return t;let n=[...this.charts.keys()].find(t=>t.id===e);return N(n)?n:null}checkChart(e,t){let n=this.fixupRenderTo(e),r=N(n)&&this.charts.has(n);return N(t)&&t!==r&&I(`There is ${t?`no`:`already a`} chart inside the element ${e}`,`error`),n}addChart(e,t=null){let n=this.checkChart(e,!1),r=new SM;return this.charts.set(n,r),r.initialize(e,t),r}removeChart(e){let t=this.checkChart(e,!0);N(t)&&(this.charts.get(t).shutdown(),this.charts.delete(t))}removeAllCharts(){for(let e of this.charts.keys())this.removeChart(e)}getChart(e){let t=this.checkChart(e);return N(t)?this.charts.get(t):null}redraw(e){let t=this.checkChart(e,!0);N(this.ongoingAnimationCallbackId)||(this.ongoingAnimationCallbackId=requestAnimationFrame(this.drawCharts)),N(t)&&this.pendingRedraw.add(t)}drawCharts(){this.ongoingAnimationCallbackId=null,this.pendingRedraw.forEach(e=>{let t=this.getChart(e);if(!N(t?.presenter?.view))return;let n=t.presenter.view;n.isHostElementVisible&&n.draw()}),this.pendingRedraw.clear()}get emptyEntities(){return{metaData:new Set,records:new Set,timeSeries:new Set}}getAllCacheableEntities(e){for(let t of this.charts.values())t.presenter.getCacheableEntities(e)}getCacheableEntities(){let e=this.emptyEntities;return this.getAllCacheableEntities(e),e.timeSeries.forEach(t=>{N(t)&&(N(t.record)&&e.records.add(t.record),N(t.records)&&Object.values(t.records).forEach(t=>e.records.add(t)))}),e}clearCaches(){this.evictUnused(this.emptyEntities)}refreshCaches(){let e=this.getCacheableEntities();this.traceFeed(`refresh:caches`,{metaData:e.metaData.size,records:e.records.size,timeSeries:e.timeSeries.size}),this.getMetaDataSource().refresh?.(),this.getRecordSource().refresh?.(e.records),e.timeSeries.forEach(e=>{e.isCached||e.refresh()}),this.getTimeSeriesDataSource().refresh(),Ge(G.DF_STREAMRECONNECTED,{})}evictUnused(e){this.getMetaDataSource().evictUnused(e.metaData),this.getRecordSource().evictUnused(e.records),this.getTimeSeriesDataSource().evictUnused(e.timeSeries)}onPerformInternalGc(){let e=this.getCacheableEntities();this.traceFeed(`gc:run`,{chartCount:this.charts.size,metaData:e.metaData.size,records:e.records.size,timeSeries:e.timeSeries.size}),this.evictUnused(e)}triggerGc(e=`unknown`){this.traceFeed(`gc:request`,{reason:e}),this.subject?.next()}onChartChanged(e,t){(e===G.CH_RECREATED||e===G.CH_SHUTDOWN)&&(this.isAuxiliary?this._mainFeed?.triggerGc(`${e}:aux:${this.id}`):this.triggerGc(e))}getDefaultMultiFieldCurve(){if(!N(this.template))return null;if(!this.knowDefaultCurve){let e=qu(this.template);e.curves.length===1&&Zl(e.curves[0].style)?this.defaultOhlcCurve=F(e.curves[0]):this.defaultOhlcCurve=null,this.knowDefaultCurve=!0}return this.defaultOhlcCurve}getDefaultAggregation(){return!this.knowDefaultAggregation&&this.template&&(this.defaultAggregation=F(this.template.data.aggregation),this.knowDefaultAggregation=!0),this.defaultAggregation}getDefaultPeriod(){return!this.knowDefaultPeriod&&this.template&&(this.defaultPeriod=this.template.display?.period,this.knowDefaultPeriod=!0),this.defaultPeriod}getDefaultDensity(){return!this.knowDefaultDensity&&this.template&&(this.defaultDensity=this.template.display?.density,this.knowDefaultDensity=!0),this.defaultDensity}shutdown(){globalThis.removeEventListener?.(`online`,this.onBrowserOnline),this.isAuxiliary||this.clearCaches(),this.removeAllCharts()}},$M=class extends QM{constructor(e){super(e),this.timeSeriesSource=new Ng(!1),this.metaDataSource=new ca,this.recordSource=new Gm}},eN=class extends QM{constructor(e){super(e),this.timeSeriesSource=new Ng(!0),this.metaDataSource=new ca,this.recordSource=new Km}},tN=class extends QM{constructor(e){super(e),this.cachesData=!0,this.timeSeriesSource=new Ng(!0),this.metaDataSource=new ca,this.recordSource=new Gm}},nN=[`drazen.dotlic@barchart.com`,`princec`,`b.hebert24@barchart.com`],rN=class extends QM{lastStreamingTimestamp=null;_isActivelyStreaming=null;needToResubscribe=!1;_connection;constructor(e){super(e),this.cachesData=!0,this.timeSeriesSource=new Ng(!0),this.metaDataSource=new la,this.recordSource=new qm,this.onEvents=this.onEvents.bind(this),this.onTimestamp=this.onTimestamp.bind(this),this.resetStreamingState()}resetStreamingState(){this.lastStreamingTimestamp=null,this._isActivelyStreaming=null,this.needToResubscribe=!1}get connection(){return this._connection}set connection(e){this._connection=e,N(e)&&this.initializeStreaming()}addChart(e,t=null){return this.needToResubscribe&&this.initializeStreaming(),super.addChart(e,t)}set isActivelyStreaming(e){N(this._isActivelyStreaming)&&!this._isActivelyStreaming&&e&&(this.debug(`need to refresh caches`),this.refreshCaches()),this._isActivelyStreaming=e}get isActivelyStreaming(){return this._isActivelyStreaming}initializeStreaming(){this.resetStreamingState(),this.connection.on(`events`,this.onEvents),this.connection.on(`timestamp`,this.onTimestamp)}onTimestamp(e){this.isActivelyStreaming&&(this.lastStreamingTimestamp=e)}debug(e){this.connection&&nN.includes(this.connection._username)&&I(`[chart] Connection ${e}, last timestamp ${this.lastStreamingTimestamp}`)}onEvents({event:e}){e===z.BC_EVENT_DISCONNECTED||e===z.BC_EVENT_FEED_PAUSED?(this.debug(e),this.isActivelyStreaming=!1):(e===z.BC_EVENT_LOGGED_IN||e===z.BC_EVENT_FEED_RESUMED)&&(this.debug(e),this.isActivelyStreaming=!0)}shutdown(){super.shutdown(),N(this._connection)&&(this.connection.off(`timestamp`,this.onTimestamp),this.connection.off(`events`,this.onEvents),this.resetStreamingState(),this.connection.disconnect(),this.connection=null)}};function iN(e,t){return new aN(e,t)}var aN=class{_client;_subscriptions=new Map;_listeners=new Set;constructor(e,t){this._client=e;let n=e=>e.find(e=>this._subscriptions.has(e))??null;t.onConnected=()=>{this._listeners.forEach(e=>e?.onConnected())},t.onMessageWithMetadata=(e,t)=>{let r=e.marketSnapshot;if(N(r)){let e=n(t);e!==null&&this._listeners.forEach(t=>t.onSnapshot?.(r,e))}let i=e.marketUpdate;if(N(i)){let e=n(t);e!==null&&this._listeners.forEach(t=>t.onUpdate?.(i,e))}},t.onDisconnected=()=>{this._listeners.forEach(e=>e?.onDisconnected())},t.onHeartBeat=e=>{this._listeners.forEach(t=>t.onHeartBeat?.(e))}}addListener(e){this._listeners.add(e)}removeListener(e){this._listeners.delete(e)}async ready(){return N(await this._client.connection)}shutdown(){N(this._client)&&(this._client.dispose(),this._subscriptions.clear(),this._listeners.clear())}subscribeToRealTime(e){if(this._subscriptions.has(e)||!N(this._client))return;let t=this._client.subscribe(1,5,0,[e],null,null,null);this._subscriptions.set(e,t)}unsubscribeFromRealTime(e){if(!this._subscriptions.has(e)||!N(this._client))return;let t=this._subscriptions.get(e);this._client.unsubscribe(t),this._subscriptions.delete(e)}async getInstrument(e){return await(await this._client.connection)?.getInstrument(e)??[]}},oN=class extends QM{_adapter=null;_auxFeeds=[];constructor(e){super(e),this.cachesData=!0,this.isAuxiliary||(this.timeSeriesSource=new Ng(!0),this.metaDataSource=new ua,this.recordSource=new Jm,kv.default.subscribe(G.TS_ALL,this.onTimeSeriesMessage.bind(this)))}onTimeSeriesMessage(e,t){if(!this.isAuxiliary)for(let n of this._auxFeeds)n.notifySeriesMessage(e,t)}notifySeriesMessage(e,t){this.isAuxiliary&&Ge(e,t)}getAdapter(){return this.isAuxiliary?this._mainFeed?._adapter:this._adapter}setAdapter(e){if(this.isAuxiliary)throw Error(`Cannot set adapter on auxiliary feed`);this._adapter=e,this._adapter.addListener(this)}async ready(){if(this.isAuxiliary){let e=await this._mainFeed?.ready()??!1;return e&&(this.template=this._mainFeed.template),e}return await super.ready(),await this._adapter?.ready()??!1}subscribe(e){this.traceFeed(`openfeed:subscribe`,{symbol:e}),this.getAdapter()?.subscribeToRealTime(e)}unsubscribe(e){this.traceFeed(`openfeed:unsubscribe`,{symbol:e}),this.getAdapter()?.unsubscribeFromRealTime(e)}shutdown(){super.shutdown(),this.isAuxiliary?(this._mainFeed?.removeAuxFeed(this),this._mainFeed=null):this._adapter?.shutdown()}onConnected(){this.refreshCaches()}onDisconnected(){}onHeartBeat(){}onUpdate(e,t){this.ofRecordSource.onUpdate(e,t)}onSnapshot(e,t){this.ofRecordSource.onSnapshot(e,t)}get ofRecordSource(){return this.recordSource}replaceDataSources(e){super.replaceDataSources(e),this._mainFeed=e}addAuxFeed(e){e.replaceDataSources(this),this._auxFeeds.push(e),this._adapter?.addListener(e)}removeAuxFeed(e){let t=this._auxFeeds.findIndex(t=>t.id==e.id);t!==-1&&(this._auxFeeds.splice(t,1),this._adapter?.removeListener(e),this.triggerGc(`removeAuxFeed:${e.id}`))}getAllCacheableEntities(e){if(super.getAllCacheableEntities(e),!this.isAuxiliary)for(let t of this._auxFeeds)t.getAllCacheableEntities(e)}},sN=kv.default;export{Ul as Aggregation,_ as AggregationSpec,g as AggregationUnit,$M as BarchartSiteDataFeed,QM as BaseDataFeed,Wm as BaseRecordSource,re as ChunkPart,wg as ContainerWrapperTimeSeries,xA as CustomEventPopup,Yd as EmptyRecord,u as ExpressionMissingBar,f as ExpressionNoDataApproach,d as ExpressionRecompute,jv as ExpressionSeries,zd as Field,b as FieldCategory,y as FieldFormat,v as FieldValueType,W as Fields,rN as MarketDataFeed,tN as MiniWidgetDataFeed,bh as OHLCDataPointBuilder,oN as OpenFeed,sN as PubSub,w as SeriesKind,eN as SnapshotDataFeed,q as StudySeries,Sh as TimeSeriesContainer,Ov as TimeSeriesQuery,G as Topics,iN as adaptOpenFeedClient,Ei as appendDOMElement,Ai as asyncReady,X as convertSeries,Au as doesExpressionHaveComputation,_s as doesStudyExist,Tu as evaluateExpression,Ou as formatExpression,Xi as formatPriceWithDecimals,bt as generateUid,hs as getAnnotationTraits,XM as getChartOutline,Zi as getCombinedMetaData,ku as getExpressionSymbols,$ as getFeed,Na as getLightness,jk as getStudyOptions,ws as getTaxonomies,si as hasOpenInterest,KM as initFeed,EE as linReg,Av as makeExpression,K as makeHelperField,tE as makeStudy,Z as mapSeries,J as movAvg,Y as movExp,oE as movHul,iE as movSmo,aE as movWei,ph as optionValueToDate,wu as parseExpression,ju as replaceExpressionSymbols,_E as roc,Ci as setAttributesDOMElement,JM as shutdownFeed,bE as stdDev,Si as styleDOMElement,fE as trueRange,gE as typical};
42
+ `)}function MA(e={}){let t=this.view.mainCanvas,{width:n,height:r}=t,{width:i,height:a,title:o}=e,s=(e,t)=>{let n=document.createElement(`canvas`);return n.width=e,n.height=t,n.getContext(`2d`)},c=s(n,r),l=globalThis.devicePixelRatio;if(c.drawImage(t,0,0),c.scale(l,l),N(o)){let e=new AA(this);e.update(o),e.draw(c)}let u=this.mainPlot?.timeSeries.container?.getLastDataPoint(W.DateTime);if(N(u)){let{fontFamily:e}=this.display.chart,{fontWeight:n,fontSize:r}=this.mainAxis.config;c.font=`${n} ${r*1.2}px ${e}`,c.textBaseline=`top`;let i=r*1.5,a=getComputedStyle(t),o=a.getPropertyValue(`--app-hc-color`),s=a.getPropertyValue(`--app-color-pl`),l={x:z.CARDS_X_OFFSET,y:z.CARDS_Y_OFFSET},d=V_(this,u,l,void 0,!1,0),f=`${d.date} ${d.time??``}`.trim(),[p,m]=[1,5],h=(e,t)=>c.measureText(e).width+t,g=(e,t,n,r,i)=>(c.fillStyle=r,c.fillText(e,t,n),h(e,i)),_=(e,t)=>e.type===C[t],v=e=>{let t=e.name;return e.isMain&&_(e,`Symbol`)?t=`${e.description} (${e.name}) [${e.exchange}]`:_(e,`Study`)&&(t=`${e.description} ${e.name.substring(e.name.indexOf(` `))}`),t};d.panes.forEach(e=>{let{top:t,left:n,width:r,right:a}=e.bounds,c=n+r-a-m,u=n+l.x,d=t+l.y;e.plots.some(e=>e.isMain)&&(u+=g(f,u,d,o,m)),e.plots.forEach((e,t)=>{let r=v(e),a=!_(e,`Study`)&&e.values.length>1;if(!e.isMain&&t>0){let t=u+h(r,m);e.values.forEach(e=>{a&&(t+=h(e.abbreviation,p)),t+=h(e.value,m)}),t>=c&&(u=n+l.x,d+=i)}u+=g(r,u,d,o,m),e.values.forEach(e=>{a&&(u+=g(e.abbreviation,u,d,s,p)),u+=g(e.value,u,d,e.color,m)})})})}let d=e=>({width:i??n,height:a??r,data:e.toDataURL(`image/png`)});if(N(i)&&N(a)){let e=s(i,a);return e.drawImage(c.canvas,0,0,i,a),d(e.canvas)}else return d(c.canvas)}var NA=Symbol.for(`__ias__`),PA=class{view;defaultTool;_activeTool;tooltipEnabled=!0;timeline;sentInitialLoadNotification=!1;_hostElement=null;undoRedoManager;title;display;model;data;panes=[];_hasLegend;renderTo;seriesChangedToken=``;metaChangedToken=``;streamingSubscription=null;_previousMask=0;_ohlcMask;selectedAnnotation;forceResetVisibleRange=!1;_maxOffset=0;_isShutdown=!1;notifySelectionChanged;notifyRecreated;notifyDefinitionChanged;constructor(e){this.accessor=e,this.defaultTool=Dk(`Default`),this._activeTool=this.defaultTool,this.timeline=new v_(this),this.undoRedoManager=new kA(this),this.title=new AA(this),this.notifySelectionChanged=Ke(G.CH_ANNSELECTIONCHANGED),this.notifyRecreated=Ke(G.CH_RECREATED),this.notifyDefinitionChanged=Ke(G.CH_DEFINITION_CHANGED)}traceChart(e,t={}){Vm(e,{chartId:this.elementId,...t})}getModel(){return this.model}get isEmpty(){return!P(this.model)}notifyHost(e,t){Ge(e,t)}async fromModel(e,t){if(this._isShutdown)return;this.traceChart(`chart:fromModel:start`,{hadModel:P(this.model)}),P(this.model)&&this.allPlots.forEach(e=>e.shutdown()),this.sentInitialLoadNotification=!1,this.clearSelection(),this.model=e;let n=F(e);this.data=n.data,this.data.aggregation=Il(n.data.aggregation),this.display=n.display,P(this.display.period)&&(this.display.period=vt(this.display.period)),this.panes=n.panes.map(e=>{let t=new aA(this);return t.fromModel(e),t},this);let r=this.allPlots.map(e=>e.initialize());await Promise.all(r),this.traceChart(`chart:fromModel:plots-ready`,{plotCount:this.allPlots.length}),!this._isShutdown&&(this.timeline.invalidate(),this.checkZoomAndVisibleRange(e,t),P(e,t)&&this.notifyDefinitionChanged({chart:this.accessor}),this.reinitializeView())}checkZoomAndVisibleRange(e,t){if(this.view)if(this.forceResetVisibleRange)this.forceResetVisibleRange=!1,this.view.resetZoomAndVisibleRange=!0,this._maxOffset=0;else{let n=!t||zA(e,t,this);this.view.resetZoomAndVisibleRange=n,n&&(this._maxOffset=0)}}closeView(){P(this.view)&&(this.view.shutdown(),this.view=void 0)}reinitializeView(){this._isShutdown||(P(this.view)?this.view.reinitialize():(this.view=new yA,this.view.initialize(this)),this.notifyRecreated({elementId:this.elementId}))}getCacheableEntities(e){let t={metaData:e.metaData.size,records:e.records.size,timeSeries:e.timeSeries.size};this.isEmpty||this.allPlots.map(t=>t.getCacheableEntities(e)),this.traceChart(`chart:cacheable-entities`,{plotCount:this.allPlots.length,addedMetaData:e.metaData.size-t.metaData,addedRecords:e.records.size-t.records,addedTimeSeries:e.timeSeries.size-t.timeSeries})}get activeTool(){return this._activeTool}set activeTool(e){P(this._activeTool.deactivated)&&this._activeTool.deactivated(this),this._activeTool=e,P(this._activeTool.activated)&&this._activeTool.activated(this),this.notifyHost(G.TL_CHANGED,{chart:this.accessor})}get mainPlot(){return this.allPlots.find(e=>e.main)}get mainAxis(){return this.mainPlot?.axis}get mainPane(){return this.mainAxis?.pane}get allAxes(){let e=[];return this.panes.forEach(t=>{t.axes.forEach(t=>{e.push(t)})}),e}get plotAnnotations(){let e=[];return this.allPlots.forEach(t=>{t.annotations?.forEach(t=>{e.push(t)})}),e}get allAnnotations(){let e=[];return this.allAxes.forEach(t=>{t.annotations.forEach(t=>{e.push(t)})}),e}get allPlots(){let e=[];return this.allAxes.forEach(t=>{t.plots.forEach(t=>{e.push(t)})}),e}findAxis(e){return this.allAxes.find(t=>t.id===e)}findPlot(e){return this.allPlots.find(t=>t.id===e)}get allCurves(){let e=[];return this.allPlots.forEach(t=>{t.curves.forEach(t=>{e.push(t)})}),e}findCurve(e){return this.allCurves.find(t=>t.id===e)}fixupDensityForForwards(){let e=this.allPlots.filter(e=>e.isForward).map(e=>e.timeSeries.container?.size??0);e.some(e=>e>0)&&(this.display.density=Math.max(...e))}onSeriesChanged(e,t){if(!this.view||!this.allPlots)return;let n=t.series,r=e=>e.timeSeries===n||e.eventsSeries===n,i=this.allPlots.find(r);if(!P(i))return;let a=P(i)&&i.main,o=!1,s=!1;if(e===G.TS_TIMELINECORRECTION){if(!this.timeline.tryToCorrectLastBar(t.from,t.to))return;o=!0}let c=P(t.index)?n.container.getTimeData()[t.index]:null,l=e===G.TS_EVENTSCHANGED,u=this.view.xAxis,d=u.xScale;if(e===G.TS_MANYCHANGED||l){if(a&&this.data.checkRange)if(P(this.display.xAxis.visibleRange)){let e={id:`Period`,context:{range:this.display.xAxis.visibleRange}};e[NA]=!0,this.accessor.change(e);return}else delete this.data.checkRange;i.isForward&&this.fixupDensityForForwards();let e=this.view.xAxis?.getMaxCurveOffset()??0;i.isStudy&&(e!==this._maxOffset&&(this._maxOffset=e,u.goToLatest(!0)),i.invalidateAssociatedAnnotations(`NewChunkArrived`));let n=P(this.display?.xAxis?.visibleRange);if((i.isSeasonal&&!u.wasVisibleRangeChanged&&!n||this.display?.xAxis?.isOrdinal)&&u.goToLatest(!0),t.part===re.Tail){let e=Te(this.timeline,c,Number,__);u.shouldScrollIntoView(e)&&d.shiftBars(t.count)}this.timeline.invalidate(),this.allPlots.forEach(e=>e.invalidatePriceMappingCache()),o=!0}else if(e===G.TS_DATAPOINTADDED){let e=this.timeline.mergeDateIntoTimeline(c);e!=-1&&u.shouldScrollIntoView(e)?(d.shiftBars(1),o=!0):s=!0,i.isStudy&&i.invalidateAssociatedAnnotations(`DataPointAdded`)}else e===G.TS_DATAPOINTCHANGED&&(s=!0,i.isStudy&&i.invalidateAssociatedAnnotations(`DataPointChanged`));if(!l&&r(this.mainPlot)&&n.hasData&&n.container.size===0&&this.notifyHost(G.CH_NODATAFORMAINSYMBOL,{chart:this.accessor}),o&&this.view.recalculateLayout(),s&&(o&&I(`Performance : redundant call to recompute price domains (layout recalculation took care of this)`,`warn`),this.allAxes.filter(e=>e.plots.includes(i)).forEach(e=>{e.setDomain(),P(c)&&e.updateFullDomain(c)})),!this.sentInitialLoadNotification&&e===G.TS_MANYCHANGED&&this.allPlots.every(e=>e.timeSeries&&e.timeSeries.hasData)){this.sentInitialLoadNotification=!0,this.notifyHost(G.CH_ALL_DATA_PROJECTED,{chart:this.accessor}),qD(this);let e=this.display.period===z.FIFTY_YEARS_MILLIS;this.mainPlot&&e&&(d.fitAllData=!0,d.adjustDomain())}this.view.redraw()}onMetaChanged(e,t){e===G.MD_CHANGED&&this.view&&this.allPlots&&this.allPlots.find(e=>e.id===t.plot.id)&&(this.view.recalculateLayout(),this.view.redraw())}priceDomainsUpdated(){this.allPlots.forEach(e=>{e.notifyAboutPriceDomains&&e.onPriceDomainsUpdated()})}onScaleDomainChanged(e){let t=this.panes.indexOf(e.pane),n=e.pane.axes.indexOf(e),r={chart:this.accessor,paneIndex:t,axisIndex:n};this.notifyHost(G.CH_AXISSCALECHANGED,r)}get previousMask(){return P(this._previousMask)||(this._previousMask=Gd(W.PreviousClose)),this._previousMask}hasMatch(e,t){return e.some(e=>e.updated&&t)}get hasLegend(){return P(this._hasLegend)||(this._hasLegend=$().config.mode===ne[ne.cmdtyView]),this._hasLegend}onStreamingUpdates(e){P(this.view)&&(this.mainPlot.showPrevious&&this.hasMatch(e,this.previousMask)&&this.view.redraw(),this.hasLegend&&this.hasMatch(e,this.ohlcMask)&&this.view.updateLegend())}get ohlcMask(){return P(this._ohlcMask)||(this._ohlcMask=Gd(W.Open,W.High,W.Low,W.Close,W.PreviousClose)),this._ohlcMask}updateMatches(e,t){if((e&this.ohlcMask)===0)return!1;let n=(e,t)=>N(e)&&e.isValid&&e.hasSymbol(t);return this.mainPlot.isSymbol?n(this.mainPlot.timeSeries.record,t):this.mainPlot.isExpression?n(this.mainPlot.record,t):!1}getStreamingSubscription(){return $().getRecordSource().subject.pipe(Ip(e=>e.filter(e=>this.updateMatches(e.updated,e.data.symbol))),zp(e=>e.length>0)).subscribe(this.onStreamingUpdates.bind(this))}get hostElement(){return this._hostElement}get elementId(){return P(this._hostElement)?this._hostElement.id:null}initialize(e){if(this._hostElement=e instanceof HTMLElement?e:xi(`#${e}`),!this._hostElement)throw Error(`There is no element ${e} in the DOM`);this.renderTo=e,this.seriesChangedToken=kv.default.subscribe(G.TS_ALL,this.onSeriesChanged.bind(this)),this.metaChangedToken=kv.default.subscribe(G.MD_ALL,this.onMetaChanged.bind(this)),this.streamingSubscription=this.getStreamingSubscription()}shutdown(){return kv.default.unsubscribe(this.seriesChangedToken),kv.default.unsubscribe(this.metaChangedToken),P(this.streamingSubscription)&&this.streamingSubscription.unsubscribe(),this.allPlots.forEach(e=>e.shutdown()),this.model=void 0,this.closeView(),this.notifyHost(G.CH_SHUTDOWN,{elementId:this.elementId}),this._isShutdown=!0,!0}setSelection(e){this.selectedAnnotation=e,this.selectedAnnotation.isSelected=!0,this.selectedAnnotation.requestRedraw(),this.notifySelectionChanged({chart:this.accessor})}clearSelection(){P(this.selectedAnnotation)&&(this.selectedAnnotation.isSelected=!1,this.selectedAnnotation.requestRedraw(),this.selectedAnnotation=void 0),this.notifySelectionChanged({chart:this.accessor})}resetActiveTool(){this.activeTool=this.defaultTool,this.view.setCursor(ee.Arrow)}print(e={}){let t=Ei(document.body,`iframe`);t.src=``,t.style.display=`none`,t.onload=()=>{let{title:n}=e,r=MA.call(this,{title:n}),i=new Image;i.src=r.data,i.style.width=`100%`,t.contentDocument.body.appendChild(i),ki(i).then(()=>{let e=t.contentWindow;t.focus(),e.print(),t.remove()})}}setTitle(e,t=!1){this.title.update(e),P(this.view)&&this.view.redraw(t)}enableTooltip(e){this.tooltipEnabled=e;let t=this.display.tooltip.mode===z.TOOLTIP_CARDS;!e&&t&&this.hideCards()}get showTooltip(){return this.display.tooltip.visible&&this.tooltipEnabled}hideCards(e=!1){let t=this.display.tooltip,n=Ie();!e&&t.visible&&t.mode===z.TOOLTIP_CARDS&&Di(`.bcharts-card`,this.hostElement).forEach(e=>{let t=e.classList.contains(`bcharts-card-move`);n&&t||e.classList.contains(`bcharts-legend`)||(e.style.display=`none`)})}handleAnnotationChange(e){let t=(e,t=!0)=>({id:t?e.name:e.id,uid:e.uid,visible:e.visible});if(e.id===`List`)return this.allAnnotations.map(t);if(e.id===`Cache`)return V(this.model,`..annCache{.annotations}`).map(e=>({symbol:e.symbol,annotations:e.annotations.map(e=>t(e,!1))}));if(e.id===`Add`)return this.mainAxis.addAnnotation(e.annotation);let n=this.allAnnotations.find(t=>t.uid===e.uid);if(n!==void 0){let t=n.axis,r=t[`${e.id.toLowerCase()}Annotation`];if(typeof r==`function`){r.call(t,n,e),e.id===`Delete`&&!e.isUndoRedo&&this.onAnnotationModifiedByTool(n,O.Deleted);return}}throw Error(`Unknown sub-action ${e.id} for action ${z.ANN_ACTION_ID}`)}getPlotInfoFromDom(e){let t=e.attributes.getNamedItem(`data-plot-uid`);if(!t)throw Error(`Unable to resolve plot info: missing data-plot-uid attribute.`);let n=t.value,r=0;for(let e of this.model.panes)for(let t of e.axes)for(let e of t.plots){if(e.uid===n)return{type:e.type,index:r};r++}throw Error(`Unable to resolve plot info: model plot index not found for uid '${n}'.`)}getSimplePlot(e,t){return this.accessor.change({id:`Plot`,context:{id:z.ACTION_GET,type:e,index:t}})[0]}onCardClicked(e){let t=this.getPlotInfoFromDom(e),n=this.getSimplePlot(t.type,t.index),r={chart:this.accessor,plot:n};this.notifyHost(G.CH_CARDPLOTCLICKED,r)}deletePlotClicked(e){let t=this.getPlotInfoFromDom(e),n=this.getSimplePlot(t.type,t.index);this.accessor.change({id:`Plot`,context:{id:`Delete`,type:t.type,index:t.index}});let r={chart:this.accessor,plot:n};this.notifyHost(G.CH_CARDPLOTREMOVED,r)}showHidePlotClicked(e){this.defaultTool.hideCrosshairAndTooltips(this.view,!0);let t=this.getPlotInfoFromDom(e),n=e.attributes.getNamedItem(`data-act`).value===`Show`;this.accessor.change({id:`Plot`,context:{id:`Update`,type:t.type,index:t.index,visible:n}});let r=this.getSimplePlot(t.type,t.index),i={chart:this.accessor,plot:r,visible:n};this.notifyHost(G.CH_CARDPLOTVISIBILITYCHANGED,i)}plotMoreActionsClicked(e,t){let n=this.getPlotInfoFromDom(e),r=this.getSimplePlot(n.type,n.index),i={x:t.clientX,y:t.clientY},a={chart:this.accessor,plot:r,offset:i,originalEvent:t};this.notifyHost(G.CH_PLOTNEEDSCONTEXTMENU,a)}onMovePaneClicked(e){let t=parseInt(e.attributes.getNamedItem(`data-pane`).value),n=e.attributes.getNamedItem(`data-dir`).value===`Down`,r=t+ +!!n,i=t-+!n;setTimeout(()=>{this.accessor.change({id:`MovePane`,context:{from:r,to:i}}),this.notifyHost(G.CH_PANESREORDERED,{chart:this.accessor})})}onAnnotationsUpdated(e,t=!1){let n=this.allAxes.indexOf(e),r=e.annotations.map(e=>e.toModel()),i=SA(this.model,{axisIndex:n,annotations:r});try{this.model=Id(i,z.CHART_SCHEMA)}catch(e){I(`Cannot update annotation (corrupts definition), error is: ${e.message}`,`error`)}t&&this.view.draw(),this.notifyHost(G.CH_ANNOTATIONCHANGED,{chart:this.accessor}),this.notifyDefinitionChanged({chart:this.accessor})}onAnnotationModifiedByTool(e,t,n=!0){if(t!==O.None){if(n&&t!==O.Undo&&t!==O.Redo){let n=vD(e,t);this.undoRedoManager.done(n)}let r=yD(e);r.toolChange=O[t],this.notifyHost(G.CH_ANNMODIFIEDBYTOOL,r)}}onAnnotationDone(e,t){let n={id:e,chart:this.accessor,toolChange:O[t]};this.notifyHost(G.CH_ANNMODIFIEDBYTOOL,n)}onPaneHeightsUpdated(){let e=this.panes.map((e,t)=>({index:t,relativeHeight:e.height}));this.model=DA(this.model,{paneHeights:e}),this.notifyHost(G.CH_PANEHEIGHTSCHANGED,{chart:this.accessor}),this.notifyDefinitionChanged({chart:this.accessor})}getDataStats(){let e=this.mainPlot.timeSeries.container;if(!P(e)||e.size===0)return null;let t=e.getTimeData(),n=Se(t),r=xe(t);return P(n,r)?{dataRange:{from:n.getTime(),to:r.getTime()},barCount:e.size}:null}};function FA(e,t){return e?.from===t?.from&&e?.to===t?.to}var IA=[`Renko`,`Range`,`LineBreak`,`Kagi`,`PointAndFigure`];function LA(e,t){for(let n of Object.keys(e))if(e[n]!==t[n])return!0}function RA(e,t){let n=e=>e.curves[0],r=n(e),i=n(t),a=IA.includes(r.style),o=IA.includes(i.style);return a===o?o?!!(r.style!==i.style||t.inputs&&LA(dt(e.inputs),dt(t.inputs))):!1:!0}function zA(e,t,n){let r={id:`Aggregation`,context:{id:`Get`}};if(LA(Fl(mM(r,t,n)),Fl(mM(r,e,n)))||!FA(e.display?.xAxis?.visibleRange,t.display?.xAxis?.visibleRange)||e.display?.xAxis?.marginBars!==t.display?.xAxis?.marginBars||!FA(e.data?.range,t.data?.range)||e.data?.extendedHours!==t.data?.extendedHours||e.display?.period!==t.display?.period||e.display?.density!==t.display?.density)return!0;let i=qu(t),a=qu(e);if(RA(i,a))return!0;let o=(e,t)=>e.type===t,s=e=>{let t=e.toLowerCase();return o(a,e)&&o(i,e)&&i[t]!==a[t]},c=i.type!==a.type,l=s(`Forward`),u=s(`Expression`),d=s(`Symbol`);return c||l||u||d}function BA(e,t){let[n,r]=Qe(t.crosshair),{color:i,dashStyle:a}=t.horizontal||{},{color:o,dashStyle:s}=t.vertical||{},c=(e,t,n)=>{t&&(e.color=t),n&&(e.dashStyle=n)},l=H(e,`.display.xAxis.crosshair`,e=>(e.enabled=n,c(e,o,s),e));return l=H(l,`.display.yAxis.crosshair`,e=>(e.enabled=r,c(e,i,a),e)),P(t.haloTracking)&&typeof t.haloTracking==`boolean`&&(l=H(l,`.display.chart`,e=>(e.plotHover=t.haloTracking,e))),l}function VA(e,t){return H(e,`.display.tooltip`,e=>(t.visible!=null&&(e.visible=t.visible),t.mode&&(e.mode=t.mode),t.showMainTitle!=null&&(e.showMainTitle=t.showMainTitle),t.mainTitle&&(e.mainTitle=t.mainTitle),e))}function HA(e,t){let n=F(t);return Object.keys(t).forEach(e=>{z.EVENTS.includes(e)||delete n[e];let r=t[e];typeof r==`boolean`?r={show:t[e]}:Object.keys(r).forEach(e=>{z.EVENT_PROPERTIES.includes(e)||delete r[e]}),n[e]=r}),H(e,Ku,e=>(e.type===`Symbol`&&(e.events=e.events||{},Object.keys(n).forEach(t=>{e.events[t]=e.events[t]||{},ct(e.events[t],n[t],!1)})),e))}function UA(e,t){let n=H(e,`..panes{${Ku}}.axes`,e=>(N(t.scale)&&(e.scale=t.scale),e));n=H(n,`.display.xAxis`,e=>(N(t.marginBars)&&(e.marginBars=t.marginBars),N(t.nonEodLabelWithDate)&&(e.nonEodLabelWithDate=t.nonEodLabelWithDate),N(t.ordinalName)&&(e.ordinalName=t.ordinalName),N(t.preventHorizontalLabelOverlap)&&(e.preventLabelOverlap=t.preventHorizontalLabelOverlap),e));let r=()=>I(`The 'minPadding' and 'maxPadding' are deprecated (ignored)`,`warn`),i=()=>I(`The 'preventLabelOverlap' is deprecated, please use 'preventVerticalLabelOverlap'`,`warn`);return n=H(n,`.display.yAxis`,e=>{(P(t.minPadding)||P(t.maxPadding))&&r();let n=N(t.preventLabelOverlap)&&!N(t.preventVerticalLabelOverlap);n&&i();let a=n?t.preventLabelOverlap:t.preventVerticalLabelOverlap;return N(a)&&(e.preventLabelOverlap=a),P(t.includePercentChangeWithLastValue)&&(e.includePercentChangeWithLastValue=t.includePercentChangeWithLastValue),P(t.snapAnnotationsToPrices)&&(e.snapAnnotationsToPrices=t.snapAnnotationsToPrices),P(t.primaryOnTheLeft)&&(e.primaryOnTheLeft=t.primaryOnTheLeft),e}),P(t.labels)&&Array.isArray(t.labels)&&t.labels.forEach(e=>{let{axis:t,text:r,index:i,paneIndex:a}=e;P(t,r,i)&&t===`vertical`&&Number.isInteger(i)&&(n=H(n,`..panes[${a??0}]..axes[${i}]`,e=>P(e)?(e.label=r,e):z.NULL_OBJECT))}),N(t.contractTransition)&&(n=H(n,`.display.xAxis`,e=>(lt(e.contractTransition,t.contractTransition),e))),N(t.cycleTransition)&&(n=H(n,`.display.xAxis`,e=>(lt(e.cycleTransition,t.cycleTransition),e))),n}function WA(e,t,n){let r=e;if(P(t.comparisonMode)&&typeof t.comparisonMode==`string`&&nt(x,t.comparisonMode)&&(r=H(r,`..panes{${Ku}}.axes`,e=>(e.comparison=t.comparisonMode,e))),P(t.gridLines)){let[e,n]=Qe(t.gridLines);r=H(r,`.display.xAxis.gridLines`,t=>(t.visible=e,t)),r=H(r,`.display.yAxis.gridLines`,e=>(e.visible=n,e))}if(P(t.minorGridLines)){let[,e]=Qe(t.minorGridLines);r=H(r,`.display.yAxis.minorGridLines`,t=>(t.visible=e,t))}P(t.newPaneHeight)&&typeof t.newPaneHeight==`number`&&(r=H(r,`.display.chart{.newPaneHeight > 0}`,e=>(e.newPaneHeight=t.newPaneHeight,e))),P(t.showNavigator)&&typeof t.showNavigator==`boolean`&&(r=H(r,`.display.scrollbar`,e=>(e.visible=t.showNavigator,e))),P(t.plotHover)&&typeof t.plotHover==`boolean`&&(r=H(r,`.display.chart`,e=>(e.plotHover=t.plotHover,e))),P(t.showLastValue)&&typeof t.showLastValue==`string`&&(r=H(r,`.display.yAxis`,e=>(e.showLastValue=t.showLastValue,e))),P(t.showMinMaxArc)&&typeof t.showMinMaxArc==`boolean`&&(r=H(r,`.display.chart`,e=>(e.showMinMaxArc=t.showMinMaxArc,e))),P(t.showGoToLatest)&&typeof t.showGoToLatest==`boolean`&&(r=H(r,`.display.chart`,e=>(e.showGoToLatest=t.showGoToLatest,e))),P(t.showLegend)&&typeof t.showLegend==`boolean`&&(r=H(r,`.display.chart`,e=>(e.showLegend=t.showLegend,e)),t.showLegend||n.view.removeLegend()),P(t.allAnnotationsLocked)&&typeof t.allAnnotationsLocked==`boolean`&&(r=H(r,`.display`,e=>(e.allAnnotationsLocked=t.allAnnotationsLocked,e))),P(t.exprSkipLeadingEmpty)&&typeof t.exprSkipLeadingEmpty==`boolean`&&(r=H(r,`.data`,e=>(e.exprSkipLeadingEmpty=t.exprSkipLeadingEmpty,e)));let i=[];if(P(t.extendedHours)&&typeof t.extendedHours==`boolean`&&(r=H(r,`.data`,e=>(e.extendedHours=t.extendedHours,e))),P(t.realTimeCboeBzx)&&typeof t.realTimeCboeBzx==`boolean`&&(r=H(r,`.data`,e=>(e.realTimeCboeBzx!==t.realTimeCboeBzx&&i.push(`realTimeCboeBzx`),e.realTimeCboeBzx=t.realTimeCboeBzx,e))),P(t.buildContinuation)&&typeof t.buildContinuation==`boolean`&&(r=H(r,`.data`,e=>(e.buildContinuation=t.buildContinuation,e))),i.length>0){let e={chart:n.accessor,hostPropsChanged:i};n.notifyHost(G.CH_HOST_PROPS_CHANGED,e)}return r}var GA=`MARKED_FOR_DELETION`;function KA(e,t){if(t.plots.length===0)return e;let n=e;for(let e of t.plots){let t=tj(n,e);if(t===void 0)continue;let r=QA(t),i=$A(n,r);P(i)&&(P(e.type)&&i.type!==e.type||(n=H(n,r,e=>(e[GA]=!0,e))))}return n=H(n,`..plots{.${GA} === true}`,e=>z.NULL_OBJECT),n=H(n,`..plots{.type === "Study"}`,e=>{let t=B(e.study);return P(t)&&Gu(n,t,e.basis).eligible?e:z.NULL_OBJECT}),Ld(n)}function qA(e,t,n,r){let i=C[e.type],a={curves:F(e.curves),type:e.type,uid:e.uid};a.precision=e.precision,a.visible=e.visible,a.detachedScale=e.detachedScale;let o=(e,t)=>{P(e[t])?a[t]=e[t].map(e=>F(e)):a[t]=[]},s=(e,t,n=!1)=>{t.main===!0&&(e.main=!0,e.showPrevious=t.showPrevious,n&&t.events!=null&&(e.events=F(t.events)))},c=(e,t=e=>!0)=>{P(r)&&(e.subtitles=r.allPlots.filter(e=>e.type===i).filter(t).map(e=>e.title))};switch(i){case C.Symbol:{a.title=e.symbol;let t=a.curves[0].style,n=t=>{o(e,`inputs`),a.inputs.length===0&&(a.inputs=F(t))};switch(t){case`Renko`:n(z.DEFAULT_RENKO_INPUTS);break;case`Kagi`:n(z.DEFAULT_KAGI_INPUTS);break;case`PointAndFigure`:n(z.DEFAULT_PNF_INPUTS);break;case`LineBreak`:n(z.DEFAULT_LINEBREAK_INPUTS);break;case`Baseline`:n(z.DEFAULT_BASELINE_INPUTS);break}s(a,e,!0);break}case C.Study:{o(e,`inputs`);let r=B(e.study),i=a.inputs,s=e.study===`AVWAP`,c=i.length===0?``:` (${i.map(e=>s&&e.name===`Anchor`?new Date(e.value).toLocaleString():e.value).join(`, `)})`,l=a.curves.map(e=>Number(e.shift)).filter(e=>e>0),u=l.length===0?``:` [${l.join(`, `)}]`;a.title=`${r.id}${c}${u}`,a.studyId=r.id,o(e,`levels`),o(e,`bands`),a.basis=F(e.basis)||{kind:`main`},a.placement=t?n?`overlay`:`withMain`:`standalone`;break}case C.BalanceSheet:case C.IncomeStatement:{let t=W[e.curves[0].fields[0]];a.title=`${t.name} (${e.fundamental.substring(0,1)})`,a.fundamentalId=t.id,a.frequency=e.fundamental;break}case C.Expression:a.title=e.expression,s(a,e);break;case C.Forward:a.title=e.forward,o(e,`offsets`),c(a),s(a,e);break;case C.Seasonal:a.title=e.seasonal,c(a,e=>e.refSeasonal===a.title),o(e,`offsets`),s(a,e);break;default:throw Error(`Unexpected plot type`)}return a}function JA(e,{main:t,type:n,index:r,uid:i},a){let o=`..plots{.main === true}`,s=V(e,`..panes`).map((e,t)=>{let n=V(e,o).length===1;return V(e,`..axes`).map((e,r)=>{let i=V(e,o).length===1;return V(e,`..plots`).map(e=>{let o=qA(e,n,i,a);return o.paneIndex=t,o.axisIndex=r,o})})}).flat(2).map((e,t)=>(e.index=t,e));if(P(i))return s.filter(e=>e.uid===i);if(t)return s.filter(e=>e.main);if(P(n)){let e=s.filter(e=>e.type===n);return P(r)?e.filter(e=>e.index===r):e}else return s}var YA=[`overlay`,`standalone`,`withMain`,`clone`];function XA(e,t,n){t[n]&&(e[n]=t[n])}function ZA(e,t){e.type===`Study`&&t.curves?.forEach(e=>delete e.varyColorPerBar),rj(e)?P(t.curves)&&(e.curves=t.curves):cj(e.curves,t.curves);let n=C[t.type],r=e;if(P(t.precision)?r.precision=t.precision:delete r.precision,n===C.Symbol)P(t.symbol)&&(e.symbol=t.symbol);else if(n===C.Study)P(t.basis)&&(e.basis=F(t.basis)),lj(e.inputs,t.inputs,e),[`bands`,`levels`,`detachedScale`].forEach(n=>XA(e,t,n));else if((n===C.BalanceSheet||n===C.IncomeStatement)&&t.frequency)e.fundamental=t.frequency;else if(n===C.Expression){let n=e;P(t.expression)&&(n.expression=t.expression)}else if(n===C.Forward){let n=e;P(t.offsets)&&(n.offsets=t.offsets),P(t.forward)&&(n.forward=t.forward)}else if(n===C.Seasonal){let n=e;P(t.offsets)&&(n.offsets=t.offsets),P(t.seasonal)&&(n.seasonal=t.seasonal),P(t.usesInAverage)&&(r.usesInAverage=t.usesInAverage),vl(n)}}var QA=e=>`..plots[${e}]`;function $A(e,t){let n=V(e,t);return n.length===1?n[0]:null}function ej(e,t){let n=0;for(let r of e.panes)for(let e of r.axes)for(let r of e.plots){if(r.uid===t)return n;n+=1}}function tj(e,t){return P(t.uid)?ej(e,t.uid):t.index}function nj(e){let t=C[e.type];return t===C.Symbol||t===C.Expression}function rj(e){let t=C[e.type];return t===C.Forward||t===C.Seasonal}function ij(e){let t=C[e.type];return t===C.Symbol||t===C.Expression||t===C.Seasonal}function aj(e,t,n){if(P(t))return t;let r=n?.uid;return typeof r==`string`?ej(e,r):void 0}function oj(e,t,n){if(P(t.placement)&&!YA.includes(t.placement))throw Error(`Unknown placement: ${t.placement}`);let r=tj(e,t),i=r===void 0?t.main?Ku:``:QA(r);if(!i)return e;let a=$A(e,i);if(!N(a)||N(t.type)&&a.type!==t.type)return e;let o=aj(e,r,a);if(t.type===C[C.Study]){let n=a,r=B(t.studyId??n.study);if(!N(r))return e;let i=P(t.basis)?t.basis:n.basis,o=Gu(e,r,i);if(!o.eligible)return I(`Cannot update study "${r.meta.title}" because ${o.reason}.`,`error`),e}if(N(t.visible))return a.visible=t.visible,e;if(a.main&&nj(a)){if(t.curves){let n=e=>e.curves[0].style===h[h.Range],[r,i]=[n(a),n(t)];r&&!i?e=ad(e,{unit:`Day`,size:1,spec:`None`}):!r&&i&&(e=ad(e,{unit:`Intraday`,size:100,spec:`PerRange`}))}t.type||=a.type;let n=a;P(t.precision)?n.precision=t.precision:delete n.precision,P(t.showPrevious)&&(e=H(e,Ku,e=>(e.showPrevious=t.showPrevious,e)));let r=t.curves?au(e,t):e;return P(t.oppositeScale)&&ij(a)&&P(o)&&(r=Vu(r,o,+!!t.oppositeScale)),r}else{let s=H(e,i,e=>(ZA(e,t),e));if(P(t.oppositeScale)&&ij(a)&&P(o)&&(s=Vu(s,o,+!!t.oppositeScale)),!(t.type===C[C.Study]&&P(t.placement)))return s;let c=P(r)?r:t.index,l=JA(s,{...t,index:c},n).find(e=>e.index===c);if(!P(l))return e;if(t.placement===l.placement)return s;let u=$A(s,i);if(!P(u))return e;s=KA(s,{id:`Delete`,plots:[{uid:u.uid,type:t.type}]});let d=mj(s,t.placement,t.cloneIndex,t.cloneUid);return d!==null&&d.plots.push(u),s}}function sj(e){return e!==void 0}function cj(e,t){if(sj(t)&&t.length===e.length)for(let n=0;n<e.length;++n){let r=t[n],i=e[n];lt(i,r);for(let e of[`shift`,`dashStyle`,`lineSmoothing`,`lineMarker`]){let t=r[e];P(t)&&(i[e]=t)}}}function lj(e,t,n){let r=dt(e),i=dt(t);lt(r,i);let a=ft(i);a.length>0&&(n.inputs=a)}function uj(){return{plots:[]}}function dj(e){let t=e.display.chart.newPaneHeight??1;return{axes:[uj()],height:t}}function fj(e){let t=dj(e);return e.panes.push(t),t}function pj(e,t){let n=N(t.paneIndex)&&t.paneIndex<e.panes.length?e.panes[t.paneIndex]:fj(e),r=n.axes[0];return t.oppositeScale??!1?Pj(n,r):r}function mj(e,t,n,r,i){let a=null,{mainPane:o,mainAxis:s}=Ju(e),c=(()=>{if(i?.kind!==`seasonal`)return null;for(let t of e.panes)for(let e of t.axes)for(let n of e.plots){if(n.uid!==i.uid||n.type!==`Seasonal`)continue;let r=n.offsets;if(Array.isArray(r)&&r.includes(i.offset))return{pane:t,axis:e}}return null})();switch(t){case`withMain`:a=c?Pj(c.pane,c.axis):Pj(o,s);break;case`overlay`:a=c?.axis??s;break;case`standalone`:a=fj(e).axes[0];break;case`clone`:{let t={main:!1,type:C[C.Study]};if(typeof r==`string`&&r.length>0?t.uid=r:typeof n==`number`&&(t.index=n),t.uid||typeof t.index==`number`){let n=JA(e,t).find(e=>e.type===C[C.Study]&&(t.uid?e.uid===t.uid:e.index===t.index));if(!n)break;a=V(e,`..panes[${n.paneIndex}]..axes[${n.axisIndex}]`)[0]}break}}return a}function hj(e,t){let n=B(t.studyId);if(!N(n))return I(`Unknown or unavailable study with the id '${t.studyId}'`,`error`),e;let r=Gu(e,n,t.basis);if(!r.eligible)return I(`Cannot add study "${n.meta.title}" because ${r.reason}.`,`error`),e;let i=t.placement||(n.meta.overlay?`overlay`:`standalone`),a=t.uid??bt();P(t.uid)&&Iu(e,a);let o={uid:a,type:`Study`,study:t.studyId,visible:!0};i===`overlay`&&t.studyId===`VOL`&&(o.detachedScale=!0),t.curves!==void 0&&(o.curves=n.defaults.curves),ZA(o,t);let s=mj(e,i,t.cloneIndex,t.cloneUid,t.basis);P(s)&&s.plots.push(o);let c=e.data.aggregation;return id(e,c.unit===`Tick`&&c.spec===`None`)}function gj(e,t){e.panes.push({axes:[{plots:[t]}]})}function _j(e,t){let n=qu(e);if(n.type!==C[C.Symbol])throw Error(`Cannot add fundamental to the chart whose main plot is not a Symbol plot.`);let r=n.symbol,i=t.uid??bt();P(t.uid)&&Iu(e,i);let a={uid:i,curves:[{fields:[t.fundamentalId],lineWidth:2,style:`Line`,varyColorPerBar:!1,visible:!0,colors:[`#888`]}],fundamental:`Quarter`,symbol:r,type:b[W[t.fundamentalId].category],visible:!0};return ZA(a,t),gj(e,a),e}var vj=[{fields:[W.Close.id],colors:[`#888`],style:`Line`,lineWidth:2,varyColorPerBar:!1,visible:!0}];function yj(e){return e.type===`Symbol`}function bj(e,t){let n=qu(e),r=F(yj(n)?n.curves:vj),i=t.uid??bt();P(t.uid)&&Iu(e,i);let a={uid:i,curves:r,expression:``,type:`Expression`,visible:!0};return ZA(a,t),pj(e,t).plots.push(a),e}function xj(e,t){let n=t.uid??bt();P(t.uid)&&Iu(e,n);let r={uid:n,curves:F(vj),offsets:[0],seasonal:``,type:`Seasonal`,visible:!0,main:!1};return ZA(r,t),pj(e,t).plots.push(r),e}var Sj={attributes:[`OpenVsClose`],colors:[`#b63400`,`#007f3e`,`#1664db`],fields:[`Open`,`High`,`Low`,`Close`,`Change`],style:`Candlestick`,varyColorPerBar:!0,lineWidth:1};function Cj(e,t){let n=qu(e),r=$().getDefaultMultiFieldCurve(),i=P(r)?r:Sj,a=n.curves?.length,o=a===t.curves.length&&a===1?(e=>F(e?n.curves:[i]))(yj(n)):t.curves,s=t.uid??bt();P(t.uid)&&Iu(e,s);let c={uid:s,curves:o,symbol:``,type:`Symbol`,visible:!0};return ZA(c,t),pj(e,t).plots.push(c),e}function wj(e,t){switch(t.type){case`Study`:return hj(e,t);case`IncomeStatement`:case`BalanceSheet`:return _j(e,t);case`Expression`:return bj(e,t);case`Symbol`:return Cj(e,t);case`Seasonal`:return xj(e,t);default:throw Error("Unexpected plot type '${type}', not supported currently")}}var Tj=0,Ej=z.AUTO_COLORS,Dj=`Symbol`,Oj=`Expression`,kj=`Seasonal`;function Aj(e,t){let n={attributes:[],colors:Ej.slice(Tj,Tj+1),fields:e?[W.Last.id]:[W.Close.id],style:`Line`,dashStyle:`Solid`,varyColorPerBar:!1,lineWidth:2,lineMarker:void 0,lineSmoothing:void 0},r={uid:t.uid??bt(),curves:[n]},{curves:i,oppositeScale:a,...o}=t;return ut(r,o),N(i)&&(r.curves=i.map(e=>{let t=F(e);return ut(t,n),t})),r.main=!1,Tj=(Tj+1)%Ej.length,r}function jj(e){return P(e.symbols)&&(I(`Use of 'symbols' for Compare API is deprecated. Please see docs for the latest version which supports more plot types`,`warn`),e.plots=e.symbols.map(e=>(e.type=Dj,e))),e.plots?.some(e=>P(e.leftScale))?(I(`Use of 'leftScale' for Compare API is deprecated. Please use 'oppositeScale'`,`warn`),e.plots.map(e=>{let t=e.leftScale;return delete e.leftScale,{...e,oppositeScale:t}})):e.plots}function Mj(e,t){let n=jj(t),r=n.map(e=>e.uid).filter(e=>typeof e==`string`),i=new Set;for(let t of r){if(i.has(t))throw Error(`Plot uid '${t}' is duplicated in the Compare request.`);i.add(t),Iu(e,t)}let{yes:a,no:o}=A(n,e=>e.oppositeScale??!1),{mainPane:s,mainAxis:c}=Ju(e);s.alignOnExpirations=t.alignOnExpirations||!1;let l=Pj(s,c),u=e=>![Dj,Oj,kj].includes(e.type);l.plots=l.plots.filter(u);let d=c.plots.filter(e=>e.main||u(e)),f=e.data.aggregation.unit===`Tick`;Tj=0;let p=se(Aj,f);return c.plots=d.concat(o.map(p)),a.length>0&&(l.plots.push(...a.map(p)),l.comparison=c.comparison,l.scale=c.scale),Ld(e)}var Nj=`..plots{(.type === "Symbol" || .type === "Expression" || .type === "Seasonal") && .main !== true}`;function Pj(e,t){let n=e.axes.find(e=>e!==t);return P(n)||(n=uj(),e.axes.push(n)),n}function Fj(e,t){let n=V(e,Nj),r=V(t,Nj),i=Math.max(0,4-r.length);if(i===0)return t;let a=n.filter(e=>!r.find(t=>e.symbol===t.symbol)).slice(0,i);if(a.length===0)return t;let{mainPane:o,mainAxis:s}=Ju(t),{mainAxis:c}=Ju(e);return a.forEach(e=>{c.plots.includes(e)?s.plots.push(e):Pj(o,s).plots.push(e)}),t}function Ij(e,t){let n=e.panes;return n.splice(t.to,0,n.splice(t.from,1)[0]),e}var Lj=()=>z.NULL_OBJECT;function Rj(e){return H(e,`..axes.annotations`,Lj)}function zj(e){return Ld(H(e,`..plots{.type === "Symbol" && .main !== true}`,Lj))}function Bj(e,t){let n=F(e);if(t.strip.main){let e=qu(n),t=e.type.toLowerCase();e[t]=z.PLACEHOLDER_SYMBOL_NAME}return t.strip.annotations&&(n=Rj(n)),t.strip.compare&&(n=zj(n)),n=H(n,`.data`,e=>(e.range&&(delete e.range,e.checkRange=!0),e)),n}function Vj(e,t,n){let r=JA(e,{main:!0},n)[0],i=r.title===z.PLACEHOLDER_SYMBOL_NAME,a=r.type===`Symbol`,o=r.type===`Expression`,s=wu(r.title),c=[];return o&&!Cu(s)?c=s.symbols:i||(c=[r.title]),{isTemplate:i,isDefinition:!i,main:{isSymbol:a,isExpression:o,symbols:c,title:i?null:r.title},compare:V(e,Nj).map(e=>e.symbol),annotations:V(e,`..annotations`).map(e=>e.id),studies:JA(e,{type:`Study`},n).map(e=>e.title)}}function Hj(e,t,n){let r=V(e,`..panes`).map((e,t)=>V(e,`..axes`).map((e,n)=>V(e,`.annotations`).map(e=>({...e,paneIndex:t,axisIndex:n})))).flat(2).map((e,t)=>({...e,index:t}));return P(t.index)&&Number.isFinite(t.index)?t.index<r.length?[r[t.index]]:z.EMPTY_ARRAY:r}function Uj(e,t,n){let r=V(e,`..panes{${Ku}}.axes.comparison`)[0],i=e.display,a=(e,t)=>rt(e,!1,t,`visible`),o=e=>$e(a(i.xAxis,e),a(i.yAxis,e)),s=rt(i.chart,!0,`showLegend`);return{comparison:r,gridLines:o(`gridLines`),minorGridLines:o(`minorGridLines`),newPaneHeight:i.chart.newPaneHeight,showLastValue:i.yAxis.showLastValue,showLegend:s,showMinMaxArc:i.chart.showMinMaxArc,allAnnotationsLocked:i.allAnnotationsLocked,exprSkipLeadingEmpty:e.data?.exprSkipLeadingEmpty??!1,extendedHours:e.data?.extendedHours??!1,realTimeCboeBzx:e.data?.realTimeCboeBzx??!1,buildContinuation:e.data?.buildContinuation??!1}}function Wj(e,t){let n=e,{backgroundColor:r,axis:{gridLinesColor:i,textColor:a,crosshairColor:o,gridLinesStyle:s},fontSize:c}=t,{chart:l,xAxis:u,yAxis:d}=c||{};if((r||l)&&(n=H(e,`.display.chart`,e=>(r&&(e.backgroundColor=r),l&&(e.fontSize=l),e))),i){let e=e=>(e.color=i,e);n=H(n,`.display.xAxis.gridLines`,e),n=H(n,`.display.yAxis.gridLines`,e),n=H(n,`.display.yAxis.minorGridLines`,e)}if(s){let e=e=>(e.dashStyle=s,e);n=H(n,`.display.xAxis.gridLines`,e),n=H(n,`.display.yAxis.gridLines`,e),n=H(n,`.display.yAxis.minorGridLines`,e)}if(a){let e=e=>(e.textColor=a,e);n=H(n,`.display.xAxis`,e),n=H(n,`.display.yAxis`,e)}if(o){let e=e=>(e.color=o,e);n=H(n,`.display.xAxis.crosshair`,e),n=H(n,`.display.yAxis.crosshair`,e)}if(u||d){let e=e=>t=>(t.fontSize=e,t);u&&(n=H(n,`.display.xAxis`,e(u))),d&&(n=H(n,`.display.yAxis`,e(d)))}return n}function Gj(e,t,n){let{chart:r,xAxis:i,yAxis:a}=e.display||{},{fontSize:o,backgroundColor:s}=r||{},{fontSize:c,gridLines:l,textColor:u,crosshair:d}=i||{},{color:f,dashStyle:p}=l||{},{fontSize:m}=a||{},{color:h}=d||{};return{backgroundColor:s,axis:{gridLinesColor:f,textColor:u,crosshairColor:h,gridLinesStyle:p},fontSize:{chart:o,xAxis:c,yAxis:m}}}function Kj(e,t,n){let{mainAxis:r}=Ju(e),i=V(e,`.display.xAxis`)[0],a=V(e,`.display.yAxis`)[0];return{scale:r.scale,marginBars:i.marginBars??0,preventLabelOverlap:a.preventLabelOverlap,preventVerticalLabelOverlap:a.preventLabelOverlap,preventHorizontalLabelOverlap:i.preventLabelOverlap,snapAnnotationsToPrices:a.snapAnnotationsToPrices,primaryOnTheLeft:a.primaryOnTheLeft??!1,nonEodLabelWithDate:i.nonEodLabelWithDate??!1,includePercentChangeWithLastValue:a.includePercentChangeWithLastValue??!1,ordinalName:i.ordinalName??``,contractTransition:i.contractTransition,cycleTransition:i.cycleTransition}}function qj(e,t,n){let r=t=>V(e,t)[0],i=r(`.display.chart`),a=r(`.display.xAxis.crosshair`),o=r(`.display.yAxis.crosshair`),s=`none`;return a.enabled&&o.enabled?s=`both`:a.enabled?s=`vertical`:o.enabled&&(s=`horizontal`),{crosshair:s,horizontal:{color:o.color,dashStyle:o.dashStyle},vertical:{color:a.color,dashStyle:a.dashStyle},haloTracking:i.plotHover}}function Jj(e,t,n){return F(e.data.aggregation)}function Yj(e,t){let n=V(e,Nj),{mainPane:r,mainAxis:i}=Ju(e),a=[];for(let e of n){let t=!i.plots.includes(e),n=e.type.toLowerCase(),r={curves:F(e.curves),type:e.type,[n]:e[n],oppositeScale:t,leftScale:t};a.push(r)}return{plots:a,alignOnExpirations:r.alignOnExpirations}}function Xj(e,t,n){let{paneIndex:r,annotations:i,studies:a}=t||{},o=`..panes${Number.isInteger(r)?`[${r}]`:``}`,s=e,c=e=>z.NULL_OBJECT;return i===!0&&(n.allAnnotations.forEach(e=>n.onAnnotationModifiedByTool(e,O.Deleted,!1)),s=H(s,`${o}..annotations`,c)),a===!0&&(s=H(s,`${o}..plots{.type=="Study"}`,c)),s=Ld(s),s}var Zj=`.display.chart.previous`;function Qj(e,t,n){return V(e,Zj)[0]}function $j(e,t,n){return H(e,Zj,e=>(lt(e,t),e))}function eM(e,t,n){let r=[],i=tj(e,t);if(i===void 0||$A(e,QA(i))?.type!==t.type)return r;let a=Ru(e,i);if(a===null)return r;let o=a.pane,s=o===0,c=o===e.panes.length-1,l=e.panes[o].axes.reduce((e,t)=>e+t.plots.length,0)===1;return s||r.push(`ExistingAbove`),l||r.push(`NewAbove`),c||r.push(`ExistingBelow`),l||r.push(`NewBelow`),r}function tM(e,t,n){if(!eM(e,t,n).includes(t.targetPane))return e;let r=tj(e,t);if(r===void 0)return e;let i=Ru(e,r);if(i===null)return e;let a=$A(e,QA(r));e.panes[i.pane].axes[i.axis].plots.splice(i.plot,1);let o=i.pane,s=!0;switch(t.targetPane){case`ExistingAbove`:o--;break;case`NewAbove`:e.panes.splice(o,0,dj(e)),s=!1;break;case`ExistingBelow`:o++;break;case`NewBelow`:o++,s=!1,e.panes.splice(o,0,dj(e));break}let{mainPane:c}=Ju(e),l=e.panes[o]===c;s&&l&&a?.type===`Study`&&a.study===`VOL`&&(a.detachedScale=!0);let u=e.panes[o];u.axes.length<2&&u.axes[0].plots.length>0&&u.axes.push(uj());let d=u.axes.findIndex(e=>e.plots.length===0),f=d===-1?u.axes.length-1:d;u.axes[f].plots.push(a);let p=Bu(e,i.pane);return p=Bu(p,o),Ld(p)}function nM(e,t,n){return P(t.period)&&t.period&&(delete e.display.period,rd(e),n&&(n.forceResetVisibleRange=!0)),e}function rM(e,t,n){let r=[],i=tj(e,t);if(i===void 0)return r;let a=$A(e,QA(i));if(a?.type!==t.type)return r;let o=Ru(e,i);if(o===null)return r;let s=e.panes[o.pane],c=o.axis===0,l=s.axes.some((e,t)=>e.plots.some((e,n)=>!(t===o.axis&&n===o.plot)&&!e.detachedScale)),u=a.detachedScale===!0;return(c||u)&&r.push(`SecondaryAxis`),(!c||u)&&r.push(`PrimaryAxis`),l&&r.push(`NoAxis`),r}function iM(e,t,n){if(!rM(e,t,n).includes(t.targetAxis))return e;let r=tj(e,t);if(r===void 0)return e;let i=-1;switch(t.targetAxis){case`PrimaryAxis`:i=0;break;case`SecondaryAxis`:i=1;break;case`NoAxis`:return Hu(e,r)}return Vu(e,r,i)}function aM(e,t,n){let r=V(e,`.display.tooltip`)[0];return{visible:r.visible,mode:r.mode,showMainTitle:r.showMainTitle,mainTitle:r.mainTitle}}var oM=`..plots{.type === "Seasonal" && .main === true}`,sM=`..plots{.type === "Seasonal" && .main !== true}`,cM=z.AUTO_COLORS;function lM(e){return JSON.parse(JSON.stringify(e))}function uM(e,t){let n=V(e,oM);if(n.length===0)return e;let r=n[0];if(!r.offsets||r.offsets.length===0)return e;let i=r.offsets,a=V(e,sM);for(let e of a){let t=e.offsets??[],n=e.curves??[],r=new Map;t.length===n.length?t.forEach((e,t)=>{let i=n[t];i&&r.set(e,lM(i))}):n.forEach((e,t)=>{let n=i[t];e&&P(n)&&r.set(n,lM(e))});let a=r.get(0);a?.colors?.[0];let o=i.map((e,t)=>{let n=r.get(e);if(n)return n;let i=cM[t%cM.length];return{...a?lM(a):{},colors:[i],fields:[`Close`],style:`Line`,dashStyle:`Solid`,varyColorPerBar:!1,lineWidth:2}});e.offsets=[...i],e.curves=o}return Ld(e)}var dM={MainPlot:nd,Aggregation:{Update:ad,Get:Jj},Period:{Update:Xl,Delete:nM},Crosshair:{Update:BA,Get:qj},Tooltip:{Update:VA,Get:aM},Events:HA,Scale:{Update:UA,Get:Kj},Other:{Update:WA,Get:Uj},Plot:{Add:wj,Get:JA,Delete:KA,Update:oj},Compare:{Update:Mj,Get:Yj},Annotation:{Get:Hj},MovePane:Ij,Template:Bj,Outline:Vj,Theme:{Update:Wj,Get:Gj},Clear:Xj,Previous:{Update:$j,Get:Qj},MovePlot:{Update:tM,Get:eM},PinPlot:{Update:iM,Get:rM},SeasonalOffsets:{Update:uM}};function fM(e){return typeof e==`function`}function pM(e,t){let n=dM[e];if(fM(n))return n;{let e=t===void 0?void 0:n[t];if(!fM(e)&&(e=n[z.DEFAULT_ACCESSOR_SUBACTION],!fM(e)))throw Error(`Invalid accesor id and/or sub id`);return e}}function mM(e,t,n){return pM(e.id,e.context.id)(t,e.context,n)}function hM(e){return{id:`MainPlot`,context:e}}var gM={id:`SeasonalOffsets`,context:{}};function _M(e){return Array.isArray(e)&&e.some(e=>e?.type===`Seasonal`)}function vM(e){let{id:t,context:n}=e;if(!P(n))return!1;if(t===`Compare`)return _M(n.plots);if(t!==z.ACTION_PLOT)return!1;let r=n.id;return r===`Add`||r===`Update`?n.type===`Seasonal`:r===z.ACTION_DELETE?_M(n.plots):!1}function yM(e){return e.some(vM)?e[e.length-1]?.id!==`SeasonalOffsets`:!1}var bM={keepOldAnnotations:!1,keepNewAnnotations:!0,keepOldCompare:!1,keepNewCompare:!0,keepOldAggregation:!1,keepNewBarWidth:!1},xM=Symbol.for(`__ias__`),SM=class{presenter;_model;constructor(e=!1){this.headless=e,this.presenter=e?null:new PA(this)}get elementId(){return this.headless?null:this.presenter?.elementId??null}get hostElement(){return this.headless?null:this.presenter?.hostElement??null}initialize(e,t=null){if(this.headless){I(`You cannot initialize a headless chart.`,`error`);return}if(this.presenter.initialize(e),N(t)){let e=typeof t==`string`;e?I(`Initializing the chart with symbol name is deprecated. Please use object form instead (see docs for details). This API will be removed in the future.`,`warn`):(t.template&&this.load(t.template),delete t.template);let n=e?{symbol:t}:t;this.change(hM(n))}}shutdown(){if(!this.headless){let e=this.presenter?.shutdown();return this.presenter=null,e}return!1}annotate(e,t=null,n=null){if(!this.headless)if(P(e)){Rc(e,t),Lc(e,t);let r=Dk(e,!1,t,n,this.presenter);r.isDrawingAnnotation&&this.presenter.view.setCursor(ee.Crosshair),this.presenter.activeTool=r,Ie()||this.presenter.view.mouseCanvas.focus({preventScroll:!0})}else this.presenter.resetActiveTool()}cancelAnnotation(){this.headless||this.presenter.resetActiveTool()}zoom(e){!this.headless&&typeof e==`boolean`&&(e?this.annotate(`ZoomIn`):this.presenter.defaultTool.resetView(this.presenter))}getDefaultTemplate(){return qM()}get model(){return(this.headless?this._model:this.presenter.getModel())||qM()}asTemplate(e={main:!0,annotations:!1,compare:!1}){return this.change({id:z.ACTION_TEMPLATE,context:{strip:e}})}change(...e){let t={chart:this,actions:e.filter(e=>!e[xM])};t.actions.length>0&&this.presenter?.notifyHost(G.CH_API_ACTIONS_RECEIVED,t);let n=$().config.validateInput,r=e.map(e=>n?Id(e,z.ACCESSOR_SCHEMA):e);if(r.length===1){let e=r[0];if(e.id===z.ACTION_TEMPLATE||e.context.id===z.ACTION_GET)return mM(e,this.model,this.presenter);if(!this.headless&&e.id===z.ANN_ACTION_ID)return this.presenter.handleAnnotationChange(e.context)}let{yes:i,no:a}=A(r,e=>e.id===z.ACTION_PLOT&&P(e.context)&&e.context.id===z.ACTION_DELETE),o=F(this.model),s=F(this.model),c=a;i.length>0&&c.push({id:z.ACTION_PLOT,context:{id:z.ACTION_DELETE,plots:i.map(e=>e.context)}}),c.forEach(e=>{if(s=mM(e,s,this.presenter),!P(s))throw Error(`Forgot to return model from accessor`)}),yM(c)&&(s=mM(gM,s,this.presenter)),this.fromModel(s,o)}async fromModel(e,t){let n=Id(e,z.CHART_SCHEMA);this.headless?this._model=n:await this.presenter?.fromModel(n,t)}async load(e,t){let n={...bM,...t},r=Id(JSON.parse(e),z.CHART_SCHEMA),i=this.model,a=F(i);if(P(i)){if(r=Yu(i,r,n.keepNewAnnotations),n.keepNewAnnotations||(r=Rj(r)),n.keepOldAnnotations&&(r=EA(i,r)),n.keepNewCompare||(r=zj(r)),n.keepOldCompare&&(r=Fj(i,r)),n.keepOldAggregation){let e={id:z.ACTION_AGGREGATION,context:i.data.aggregation},t=r.display.density;r=mM(e,r,this.presenter),n.keepNewBarWidth&&P(t)&&(r.display.density=t)}await this.fromModel(r,a),this.clearUndoRedo()}}save(){return JSON.stringify(this.model)}clearUndoRedo(){!this.headless&&this.presenter?.undoRedoManager&&this.presenter.undoRedoManager.clear(!0)}reset(e=!0){let t=qM();if(this.headless)this._model=t;else if(this.presenter.getModel()){let n=this.presenter.mainPlot,r=null,i=n;if(n.isSymbol?r={symbol:i.symbol}:n.isExpression?r={expression:i.expression}:n.isForward?r={forward:i.forward}:n.isSeasonal&&(r={seasonal:i.seasonal}),P(r)){let n=mM({id:`Theme`,context:{id:`Get`}},this.model,this.presenter),i=mM(hM(r),t,this.presenter);e&&(i=mM({id:`Theme`,context:n},i,this.presenter)),this.presenter?.fromModel(i)}}this.clearUndoRedo(),this.presenter?.notifyHost(G.CH_RESET,{elementId:this.elementId})}print(e={}){this.headless||this.presenter.print(e)}getSVGForExport(){I(`Obsolete: please use 'exportImage' method instead.`,`warn`)}setTitle(e){this.headless||this.presenter.setTitle(e)}getPaneBounds(e=!0){if(!this.headless)return this.presenter.panes.map(t=>e?t.getBounds():t.getBoundsWithoutScales())}exportData(e={}){return this.headless?null:jA.call(this.presenter,e)}exportImage(e={}){return this.headless?null:MA.call(this.presenter,e)}getDataStats(){return this.presenter.getDataStats()}get canUndo(){return!this.headless&&(this.presenter?.undoRedoManager?.canUndo??!1)}get canRedo(){return!this.headless&&(this.presenter?.undoRedoManager?.canRedo??!1)}undo(){this.canUndo&&this.presenter?.undoRedoManager?.undo()}redo(){this.canRedo&&this.presenter?.undoRedoManager?.redo()}pauseUndoRedo(){this.headless||this.presenter?.undoRedoManager?.pause()}resumeUndoRedo(e){this.headless||this.presenter?.undoRedoManager?.resume(e)}priceToY(e,t=0,n=0){let r=this.presenter;if(this.headless||t<0||n<0||t>r.panes.length)return null;let i=r.panes[t];return n>i.axes.length?null:i.axes[n].toY(e)}yToPrices(e){let t=this.presenter;if(this.headless)return null;for(let[n,r]of t.panes.entries()){let t=r.getBounds();if(P(t)&&e>=t.y&&e<=t.y+t.height)return{pane:n,prices:r.axes.map(t=>t.toPrice(e))}}return{pane:-1,prices:[]}}activate(){this.presenter?.notifyHost(G.CH_DIDBECOMEACTIVE,{chart:this})}};function CM(e){let t=e.split(`.`);if(!t||t.length!==4)return!1;let n=t.map(Number);if(!n.every(e=>Number.isFinite(e)&&e>=0&&e<=255))return!1;let[r,i]=n;return r===10||r===172&&i>=16&&i<=31||r===192&&i===168}function wM(){let e=globalThis.parent?.location?.hostname||``;return[``,`localhost`,`127.0.0.1`].includes(e)||CM(e)}function TM(){let e=document.domain,t=e.split(`.`),n=`__tld`+new Date().getTime(),r=0;for(;r<t.length-1&&document.cookie.indexOf(`${n}=${n}`)===-1;)e=t.slice(-1-++r).join(`.`),document.cookie=`${n}=${n};domain=${e};`;return document.cookie=`${n}=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=${e};`,e}function EM(e,t){return ot(t),`${e}/?${new URLSearchParams(t).toString()}`}var DM=`aHR0cHM6Ly9iYXJjaGFydHdpZGdldHMud2Vic29sLmJhcmNoYXJ0LmNvbQ==`,OM=`YXV0aGVudGljYXRlQ2hhcnRSZWZlcmVy`;function kM(e,t=``){return EM(atob(DM),{module:atob(OM),secret:t,referer:e})}function AM(e,t){return e+Math.random()*(t-e)}var jM=Function(atob(`Y29uc29sZS5sb2coIlBsZWFzZSBjb250YWN0IEJhcmNoYXJ0IGluIG9yZGVyIHRvIG9idGFpbiB0aGUgbGljZW5zZSBmb3IgdGhlIGNoYXJ0IGNvbXBvbmVudC4iKTsg`)),MM=Function(`f`,atob(`Zi5yZW1vdmVBbGxDaGFydHMoKTsg`)),NM=Function(`m`,atob(`cmV0dXJuIG0gPT09ICJJbnRlcm5hbEZlZWQiIHx8IG0gPT09ICJXaWRnZXQiIHx8IG0gPT09ICJGcmVlV2lkZ2V0IiB8fCBtID09PSAiRGVtb1NpdGUiOw==`)),PM=`YXV0aG9yaXplZA==`,FM=`ZGF0YS1lbmRwb2ludA==`,IM=`YWxsb3dDcmVkZW50aWFscw==`;async function LM(e,t){if(t&&!NM(e.mode))return;let n=!1,r=0,i=25;for(;!n&&r<5;){let t=wM()||e.mode===`FreeWidget`,a=t?e.apiKey:``;try{let i=kM(t?``:TM(),a),o=await fetch(i);if(!o.ok)r++;else{let t=await o.json(),r=t[atob(PM)];e.knownSite=r,r?(e.dataEndpoint=(t[atob(FM)]||``).replace(/\/$/g,``),e.allowCredentials=t[atob(IM)]):(e.dataEndpoint=``,e.allowCredentials=!1),n=!0;break}}catch{}r++,i*=2,await new Promise(e=>setTimeout(e,i))}(!n||!e.knownSite)&&RM()}function RM(){setTimeout(jM,AM(2e3,3e3)),setTimeout(()=>MM($()),AM(4e3,5e3))}var zM={major:2,minor:382,patch:2,prerelease:!1},BM={environment:`Browser`,validateInput:!1,throttleMillis:0,isAlt64:!0,defaultTemplate:`/${z.CHART_DEFINITION}`,cachedAnnotationsCount:0,showResizeHandles:!1,scrollBehavior:`wheel+shift`,bypassSmoothing:!1,showGoToLatest:void 0,tooltipMovement:`Auto`,tooltipHeaders:void 0,touchCrosshairTimeoutMillis:void 0,touchCrosshairDelayMillis:void 0,mode:`Unspecified`,hostingModel:`Page`,overrides:void 0,logo:void 0,logoClickable:void 0,noDataText:void 0,useAllFieldsForComparison:void 0,colorfulAnnotations:!1,baseUrl:{instruments:`/proxies/instruments`,futures:`/proxies/futures`,timeseries:`/proxies/timeseries`,timeseriesNew:`/proxies/new-timeseries`,ondemand:`/proxies/ondemand`,options:`/proxies/core-api`},credentials:void 0,apiKey:void 0,extensions:void 0,defaultVolumeBarColoring:void 0,defaultMainPlotBarColoring:void 0,async fetch(e,t){let n=this.baseUrl[e],r=`${n}${t}`;if(NM(this.mode)&&this.knownSite){let{username:i,password:a}=this.credentials||{},o=P(i,a),s=(e===`timeseries`||e===`timeseriesNew`)&&o&&this.allowCredentials?`&username=${i}&password=${a}`:``;r=`https://${this.dataEndpoint}${n}${t}${s}`}return await(await fetch(r)).text()},getCustomEventPopup:e=>null};async function VM(e,t){let n=$()?.config;if(!n||!n.fetch)throw Error(`You should call initFeed first`);let r=t;return e===`timeseries`?r=`/historical${t}`:e===`options`&&(r=`/options-historical${t}`),await n.fetch.call(n,e,r)}var HM=!1,UM=null;function WM(){let e=zM,t=e.prerelease?`-${e.prerelease.identifier}.${e.prerelease.ordinal}`:``;return`${e.major}.${e.minor}.${e.patch}${t}`}function GM(e){let t=e.extensions?.studyProvider;if(!P(t))return;let n=t.getFields(),r=t.getStudies(),i=F(ss(z.CHART_SCHEMA)),a=i.definitions,o=a.studyField.enum,s=a.study.enum;for(let e of n)if(o.includes(e.id))throw Error(`Field with id ${e.id} already exists`);for(let e of r)if(s.includes(e.id))throw Error(`Study with id ${e.id} already exists`);o.push(...n.map(e=>e.id)),s.push(...r.map(e=>e.id)),Md(z.CHART_SCHEMA,i),Hd(n),fs(r)}function KM(e,t={}){if(HM)throw Error(`You should only call initFeed once during page's lifetime`);HM=!0;let n=Object.assign(BM);return lt(n,t),N(n.logo)&&nO(n.logo,n.logoClickable??!1),GM(n),UM=new e(n),UM.version=WM(),I(`%cBarchart Chart version ${UM.version}`,`info`,`font-size: larger`),UM.cachesData&&(UM.subject?.subscribe(UM.onPerformInternalGc.bind(UM)),kv.default.subscribe(G.CH_ALL,UM.onChartChanged.bind(UM))),UM}function $(){return UM}function qM(){return F($()?.template)}function JM(){N(UM)&&(UM.shutdown(),HM=!1,UM=null)}function YM(){return new SM(!0)}function XM(e){let t=YM();return t.load(e),t.change({id:`Outline`,context:{id:`Get`}})}function ZM(e,t,n,r=null){return new Proxy(e,{get:function(e,i,a){return i===t?function(t){let a=r?t[r]:t;return(n.handlesRequestsFor(a)?n:e)[i](t)}:Reflect.get(e,i,a)}})}var QM=class{version;cachesData;timeSeriesSource;metaDataSource;recordSource;charts;pendingRedraw;template;ongoingAnimationCallbackId;_altDataSource;_subject;knowDefaultCurve;defaultOhlcCurve;knowDefaultAggregation;defaultAggregation;knowDefaultPeriod;defaultPeriod;knowDefaultDensity;defaultDensity;id;_mainFeed=null;onBrowserOnline;constructor(e){this.config=e,this.timeSeriesSource=this.metaDataSource=this.recordSource=null,this.charts=new Map,this.pendingRedraw=new Set,this.ongoingAnimationCallbackId=null,this.drawCharts=this.drawCharts.bind(this),this.template=null,this.cachesData=!1,this._altDataSource=null,this._subject=null,this.id=bt(),this.onBrowserOnline=()=>{!this.cachesData||this.isAuxiliary||(this.traceFeed(`refresh:online`),this.refreshCaches())},globalThis.addEventListener?.(`online`,this.onBrowserOnline)}traceFeed(e,t={}){Vm(e,{feedId:this.id,isAuxiliary:this.isAuxiliary,...t})}get subject(){return!this.isAuxiliary&&!N(this._subject)&&(this.traceFeed(`gc:stream:init`,{gcMillis:z.INTERNAL_GC_MILLIS}),this._subject=new ip().pipe(Bp(z.INTERNAL_GC_MILLIS),zp(e=>e.length>0))),this._subject}get isAuxiliary(){return window.opener!==null}setAltDataSource(e){this._altDataSource=e,this.timeSeriesSource=ZM(this.timeSeriesSource,`getTimeSeries`,e,`symbol`),this.metaDataSource=ZM(this.metaDataSource,`getMetaData`,e),this.recordSource=ZM(this.recordSource,`getRecord`,e)}replaceDataSources(e){this._altDataSource=e._altDataSource,this.timeSeriesSource=e.timeSeriesSource,this.metaDataSource=e.metaDataSource,this.recordSource=e.recordSource}getAltDataSource(){return this._altDataSource}getTimeSeriesDataSource(){if(!N(this.timeSeriesSource))throw Error(`No time series source defined`);return this.timeSeriesSource}getMetaDataSource(){if(!N(this.metaDataSource))throw Error(`No metadata source defined`);return this.metaDataSource}getRecordSource(){if(!N(this.recordSource))throw Error(`No record source defined`);return this.recordSource}async ready(){return Ai.call(this,async()=>{let e=this instanceof rN||this instanceof $M||this instanceof oN;await LM(this.config,e);let t=this.config.defaultTemplate;if(!t)throw Error(`Must provide a default template`);return typeof t==`string`&&(t=await(await fetch(t)).json()),this.template=Id(t,z.CHART_SCHEMA),!0})}getHeadlessChart(){return YM()}fixupRenderTo(e){if(!N(e))return null;if(e instanceof HTMLElement)return e;let t=xi(`#${e}`);if(N(t))return t;let n=[...this.charts.keys()].find(t=>t.id===e);return N(n)?n:null}checkChart(e,t){let n=this.fixupRenderTo(e),r=N(n)&&this.charts.has(n);return N(t)&&t!==r&&I(`There is ${t?`no`:`already a`} chart inside the element ${e}`,`error`),n}addChart(e,t=null){let n=this.checkChart(e,!1),r=new SM;return this.charts.set(n,r),r.initialize(e,t),r}removeChart(e){let t=this.checkChart(e,!0);N(t)&&(this.charts.get(t).shutdown(),this.charts.delete(t))}removeAllCharts(){for(let e of this.charts.keys())this.removeChart(e)}getChart(e){let t=this.checkChart(e);return N(t)?this.charts.get(t):null}redraw(e){let t=this.checkChart(e,!0);N(this.ongoingAnimationCallbackId)||(this.ongoingAnimationCallbackId=requestAnimationFrame(this.drawCharts)),N(t)&&this.pendingRedraw.add(t)}drawCharts(){this.ongoingAnimationCallbackId=null,this.pendingRedraw.forEach(e=>{let t=this.getChart(e);if(!N(t?.presenter?.view))return;let n=t.presenter.view;n.isHostElementVisible&&n.draw()}),this.pendingRedraw.clear()}get emptyEntities(){return{metaData:new Set,records:new Set,timeSeries:new Set}}getAllCacheableEntities(e){for(let t of this.charts.values())t.presenter.getCacheableEntities(e)}getCacheableEntities(){let e=this.emptyEntities;return this.getAllCacheableEntities(e),e.timeSeries.forEach(t=>{N(t)&&(N(t.record)&&e.records.add(t.record),N(t.records)&&Object.values(t.records).forEach(t=>e.records.add(t)))}),e}clearCaches(){this.evictUnused(this.emptyEntities)}refreshCaches(){let e=this.getCacheableEntities();this.traceFeed(`refresh:caches`,{metaData:e.metaData.size,records:e.records.size,timeSeries:e.timeSeries.size}),this.getMetaDataSource().refresh?.(),this.getRecordSource().refresh?.(e.records),e.timeSeries.forEach(e=>{e.isCached||e.refresh()}),this.getTimeSeriesDataSource().refresh(),Ge(G.DF_STREAMRECONNECTED,{})}evictUnused(e){this.getMetaDataSource().evictUnused(e.metaData),this.getRecordSource().evictUnused(e.records),this.getTimeSeriesDataSource().evictUnused(e.timeSeries)}onPerformInternalGc(){let e=this.getCacheableEntities();this.traceFeed(`gc:run`,{chartCount:this.charts.size,metaData:e.metaData.size,records:e.records.size,timeSeries:e.timeSeries.size}),this.evictUnused(e)}triggerGc(e=`unknown`){this.traceFeed(`gc:request`,{reason:e}),this.subject?.next()}onChartChanged(e,t){(e===G.CH_RECREATED||e===G.CH_SHUTDOWN)&&(this.isAuxiliary?this._mainFeed?.triggerGc(`${e}:aux:${this.id}`):this.triggerGc(e))}getDefaultMultiFieldCurve(){if(!N(this.template))return null;if(!this.knowDefaultCurve){let e=qu(this.template);e.curves.length===1&&Zl(e.curves[0].style)?this.defaultOhlcCurve=F(e.curves[0]):this.defaultOhlcCurve=null,this.knowDefaultCurve=!0}return this.defaultOhlcCurve}getDefaultAggregation(){return!this.knowDefaultAggregation&&this.template&&(this.defaultAggregation=F(this.template.data.aggregation),this.knowDefaultAggregation=!0),this.defaultAggregation}getDefaultPeriod(){return!this.knowDefaultPeriod&&this.template&&(this.defaultPeriod=this.template.display?.period,this.knowDefaultPeriod=!0),this.defaultPeriod}getDefaultDensity(){return!this.knowDefaultDensity&&this.template&&(this.defaultDensity=this.template.display?.density,this.knowDefaultDensity=!0),this.defaultDensity}shutdown(){globalThis.removeEventListener?.(`online`,this.onBrowserOnline),this.isAuxiliary||this.clearCaches(),this.removeAllCharts()}},$M=class extends QM{constructor(e){super(e),this.timeSeriesSource=new Ng(!1),this.metaDataSource=new ca,this.recordSource=new Gm}},eN=class extends QM{constructor(e){super(e),this.timeSeriesSource=new Ng(!0),this.metaDataSource=new ca,this.recordSource=new Km}},tN=class extends QM{constructor(e){super(e),this.cachesData=!0,this.timeSeriesSource=new Ng(!0),this.metaDataSource=new ca,this.recordSource=new Gm}},nN=[`drazen.dotlic@barchart.com`,`princec`,`b.hebert24@barchart.com`],rN=class extends QM{lastStreamingTimestamp=null;_isActivelyStreaming=null;needToResubscribe=!1;_connection;constructor(e){super(e),this.cachesData=!0,this.timeSeriesSource=new Ng(!0),this.metaDataSource=new la,this.recordSource=new qm,this.onEvents=this.onEvents.bind(this),this.onTimestamp=this.onTimestamp.bind(this),this.resetStreamingState()}resetStreamingState(){this.lastStreamingTimestamp=null,this._isActivelyStreaming=null,this.needToResubscribe=!1}get connection(){return this._connection}set connection(e){this._connection=e,N(e)&&this.initializeStreaming()}addChart(e,t=null){return this.needToResubscribe&&this.initializeStreaming(),super.addChart(e,t)}set isActivelyStreaming(e){N(this._isActivelyStreaming)&&!this._isActivelyStreaming&&e&&(this.debug(`need to refresh caches`),this.refreshCaches()),this._isActivelyStreaming=e}get isActivelyStreaming(){return this._isActivelyStreaming}initializeStreaming(){this.resetStreamingState(),this.connection.on(`events`,this.onEvents),this.connection.on(`timestamp`,this.onTimestamp)}onTimestamp(e){this.isActivelyStreaming&&(this.lastStreamingTimestamp=e)}debug(e){this.connection&&nN.includes(this.connection._username)&&I(`[chart] Connection ${e}, last timestamp ${this.lastStreamingTimestamp}`)}onEvents({event:e}){e===z.BC_EVENT_DISCONNECTED||e===z.BC_EVENT_FEED_PAUSED?(this.debug(e),this.isActivelyStreaming=!1):(e===z.BC_EVENT_LOGGED_IN||e===z.BC_EVENT_FEED_RESUMED)&&(this.debug(e),this.isActivelyStreaming=!0)}shutdown(){super.shutdown(),N(this._connection)&&(this.connection.off(`timestamp`,this.onTimestamp),this.connection.off(`events`,this.onEvents),this.resetStreamingState(),this.connection.disconnect(),this.connection=null)}};function iN(e,t){return new aN(e,t)}var aN=class{_client;_subscriptions=new Map;_listeners=new Set;constructor(e,t){this._client=e;let n=e=>e.find(e=>this._subscriptions.has(e))??null;t.onConnected=()=>{this._listeners.forEach(e=>e?.onConnected())},t.onMessageWithMetadata=(e,t)=>{let r=e.marketSnapshot;if(N(r)){let e=n(t);e!==null&&this._listeners.forEach(t=>t.onSnapshot?.(r,e))}let i=e.marketUpdate;if(N(i)){let e=n(t);e!==null&&this._listeners.forEach(t=>t.onUpdate?.(i,e))}},t.onDisconnected=()=>{this._listeners.forEach(e=>e?.onDisconnected())},t.onHeartBeat=e=>{this._listeners.forEach(t=>t.onHeartBeat?.(e))}}addListener(e){this._listeners.add(e)}removeListener(e){this._listeners.delete(e)}async ready(){return N(await this._client.connection)}shutdown(){N(this._client)&&(this._client.dispose(),this._subscriptions.clear(),this._listeners.clear())}subscribeToRealTime(e){if(this._subscriptions.has(e)||!N(this._client))return;let t=this._client.subscribe(1,5,0,[e],null,null,null);this._subscriptions.set(e,t)}unsubscribeFromRealTime(e){if(!this._subscriptions.has(e)||!N(this._client))return;let t=this._subscriptions.get(e);this._client.unsubscribe(t),this._subscriptions.delete(e)}async getInstrument(e){return await(await this._client.connection)?.getInstrument(e)??[]}},oN=class extends QM{_adapter=null;_auxFeeds=[];constructor(e){super(e),this.cachesData=!0,this.isAuxiliary||(this.timeSeriesSource=new Ng(!0),this.metaDataSource=new ua,this.recordSource=new Jm,kv.default.subscribe(G.TS_ALL,this.onTimeSeriesMessage.bind(this)))}onTimeSeriesMessage(e,t){if(!this.isAuxiliary)for(let n of this._auxFeeds)n.notifySeriesMessage(e,t)}notifySeriesMessage(e,t){this.isAuxiliary&&Ge(e,t)}getAdapter(){return this.isAuxiliary?this._mainFeed?._adapter:this._adapter}setAdapter(e){if(this.isAuxiliary)throw Error(`Cannot set adapter on auxiliary feed`);this._adapter=e,this._adapter.addListener(this)}async ready(){if(this.isAuxiliary){let e=await this._mainFeed?.ready()??!1;return e&&(this.template=this._mainFeed.template),e}return await super.ready(),await this._adapter?.ready()??!1}subscribe(e){this.traceFeed(`openfeed:subscribe`,{symbol:e}),this.getAdapter()?.subscribeToRealTime(e)}unsubscribe(e){this.traceFeed(`openfeed:unsubscribe`,{symbol:e}),this.getAdapter()?.unsubscribeFromRealTime(e)}shutdown(){super.shutdown(),this.isAuxiliary?(this._mainFeed?.removeAuxFeed(this),this._mainFeed=null):this._adapter?.shutdown()}onConnected(){this.refreshCaches()}onDisconnected(){}onHeartBeat(){}onUpdate(e,t){this.ofRecordSource.onUpdate(e,t)}onSnapshot(e,t){this.ofRecordSource.onSnapshot(e,t)}get ofRecordSource(){return this.recordSource}replaceDataSources(e){super.replaceDataSources(e),this._mainFeed=e}addAuxFeed(e){e.replaceDataSources(this),this._auxFeeds.push(e),this._adapter?.addListener(e)}removeAuxFeed(e){let t=this._auxFeeds.findIndex(t=>t.id==e.id);t!==-1&&(this._auxFeeds.splice(t,1),this._adapter?.removeListener(e),this.triggerGc(`removeAuxFeed:${e.id}`))}getAllCacheableEntities(e){if(super.getAllCacheableEntities(e),!this.isAuxiliary)for(let t of this._auxFeeds)t.getAllCacheableEntities(e)}},sN=kv.default;export{Ul as Aggregation,_ as AggregationSpec,g as AggregationUnit,$M as BarchartSiteDataFeed,QM as BaseDataFeed,Wm as BaseRecordSource,re as ChunkPart,wg as ContainerWrapperTimeSeries,xA as CustomEventPopup,Yd as EmptyRecord,u as ExpressionMissingBar,f as ExpressionNoDataApproach,d as ExpressionRecompute,jv as ExpressionSeries,zd as Field,b as FieldCategory,y as FieldFormat,v as FieldValueType,W as Fields,rN as MarketDataFeed,tN as MiniWidgetDataFeed,bh as OHLCDataPointBuilder,oN as OpenFeed,sN as PubSub,w as SeriesKind,eN as SnapshotDataFeed,q as StudySeries,Sh as TimeSeriesContainer,Ov as TimeSeriesQuery,G as Topics,iN as adaptOpenFeedClient,Ei as appendDOMElement,Ai as asyncReady,X as convertSeries,Au as doesExpressionHaveComputation,_s as doesStudyExist,Tu as evaluateExpression,Ou as formatExpression,Xi as formatPriceWithDecimals,bt as generateUid,hs as getAnnotationTraits,XM as getChartOutline,Zi as getCombinedMetaData,ku as getExpressionSymbols,$ as getFeed,Na as getLightness,jk as getStudyOptions,ws as getTaxonomies,si as hasOpenInterest,KM as initFeed,EE as linReg,Av as makeExpression,K as makeHelperField,tE as makeStudy,Z as mapSeries,J as movAvg,Y as movExp,oE as movHul,iE as movSmo,aE as movWei,ph as optionValueToDate,wu as parseExpression,ju as replaceExpressionSymbols,_E as roc,Ci as setAttributesDOMElement,JM as shutdownFeed,bE as stdDev,Si as styleDOMElement,fE as trueRange,gE as typical};