diff --git a/frontend-components/plotly/src/components/PlotlyConfig.tsx b/frontend-components/plotly/src/components/PlotlyConfig.tsx index d18fcab9f52..822987812ae 100644 --- a/frontend-components/plotly/src/components/PlotlyConfig.tsx +++ b/frontend-components/plotly/src/components/PlotlyConfig.tsx @@ -13,7 +13,7 @@ export function hideModebar(hide: boolean = true) { } let includes_text = "display: none"; if (window.MODEBAR) { - if (window.MODEBAR.style.cssText.includes("display: none") && !hide) { + if (window.MODEBAR.style.cssText.includes("display: none") || !hide) { includes_text = "display: flex"; window.MODEBAR.style.cssText = `${window.MODEBAR.style.cssText}; display:flex;`; } else { @@ -61,7 +61,7 @@ export function PlotConfig({ { preventDefault: true } ); useHotkeys( - "ctrl+shift+h", + ["ctrl+shift+h", "ctrl+h"], () => { hideModebar(); }, diff --git a/openbb_terminal/core/plots/plotly.html b/openbb_terminal/core/plots/plotly.html index 30ee83b46b3..46f9e898d01 100644 --- a/openbb_terminal/core/plots/plotly.html +++ b/openbb_terminal/core/plots/plotly.html @@ -3698,7 +3698,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho `).map(N=>N.replace(/\r/g,""));const C=A[0].split(","),L=C.map(N=>N.trim().toLowerCase());let O={};for(let N=0;NL.includes(N))&&E("candlestick"),L.includes("close")&&(v({...d,y:C[L.indexOf("close")]}),O.y=C[L.indexOf("close")]);let U=[];for(let N=1;N2&&(j.test(N[0])?N.splice(0,2):j.test(N[N.length-2])&&N.splice(N.length-2,2),B=N.join("_").replace(/openbb_/g,""))}}catch(N){console.log(N)}l(B),v(O),n(C),i(U)},Fb.readAsText(m.target.files[0])},type:"file",id:"csv_file",accept:".csv",style:{marginLeft:10}})]}),ni("div",{style:{marginTop:15},children:[br("label",{htmlFor:"csv_trace_type",children:br("b",{children:"Display data type:"})}),ni("select",{onChange:m=>{E(m.target.value)},id:"csv_trace_type",style:Rw,defaultValue:b[D],children:[D&&br("option",{value:D,children:b[D]},D),Object.keys(b).map(m=>D!==m&&br("option",{value:m,children:b[m]},m))]})]}),ni("div",{style:{marginTop:12},children:[br("label",{htmlFor:"csv_name",children:br("b",{children:"Trace Name:"})}),br("textarea",{id:"csv_name",value:f,onChange:m=>{l(m.target.value)},style:{padding:"5px 2px 2px 5px",width:"100%",maxWidth:"100%",maxHeight:200,marginTop:2},rows:2,cols:20,placeholder:"Enter a name to give this trace"})]}),r.length>0&&ni(tg,{children:[["scatter","bar"].includes(D)&&br("div",{style:{marginTop:15,marginBottom:10},id:"csv_columns",className:"csv_column_container",children:["x","y"].map(m=>ni("div",{style:{marginTop:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[ni("label",{htmlFor:`csv_${m}`,style:{width:"100px"},children:[m.toUpperCase()," Axis"]}),ni("select",{onChange:k=>{a({...o,[m]:k.target.value}),v({...d,[m]:k.target.value})},id:`csv_${m}`,style:{width:"100%"},defaultValue:d[m],children:[d[m]&&br("option",{value:d[m],children:d[m]},m),r.map(k=>br("option",{value:k,children:k},k))]})]},m))}),D==="candlestick"&&br("div",{id:"csv_columns",className:"csv_column_container",style:{marginTop:15},children:["x","open","high","low","close"].map(m=>ni("div",{style:{marginTop:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[br("label",{htmlFor:`csv_${m}`,style:{width:"100px"},children:m.charAt(0).toUpperCase()+m.slice(1)}),ni("select",{onChange:k=>{a({...o,[m]:k.target.value}),v({...d,[m]:k.target.value})},id:`csv_${m}`,style:{width:"100%"},children:[d[m]&&br("option",{value:d[m],children:d[m]},m),r.map(k=>k!=d[k]&&br("option",{value:k,children:k},k))]})]},m))}),ni("div",{style:{marginTop:20},id:"csv_colors",children:[["scatter","bar"].includes(D)&&ni("div",{children:[br("label",{htmlFor:"csv_color",children:`${D.charAt(0).toUpperCase()}${D.slice(1)} color`}),br("input",{type:"color",id:"csv_color",defaultValue:"#FFDD00",style:{margin:"2px 2px 2px 10px"},onChange:m=>{console.log(m.target.value),_(m.target.value)}})]}),D==="candlestick"&&ni(tg,{children:[br("label",{htmlFor:"csv_increasing",children:"Increasing color"}),br("input",{type:"color",id:"csv_increasing",defaultValue:"#00ACFF",style:{margin:"2px 0px 2px 10px"},onChange:m=>{s(m.target.value)}}),br("label",{htmlFor:"csv_decreasing",style:{marginLeft:15},children:"Decreasing color"}),br("input",{style:{margin:"2px 0px 2px 10px"},type:"color",id:"csv_decreasing",defaultValue:"#FF0000",onChange:m=>{y(m.target.value)}})]})]}),ni("div",{style:{marginTop:20},id:"csv_plot_yaxis_options",children:[D!=="candlestick"&&ni(tg,{children:[br("input",{type:"checkbox",id:"csv_percent_change",name:"csv_plot_yaxis_check",style:{marginBottom:2},onChange:m=>{p({...u,percentChange:m.target.checked,sameYaxis:!1})},checked:!u.sameYaxis&&u.percentChange}),br("label",{htmlFor:"csv_percent_change",style:{marginLeft:5},children:"Plot as percent change from first value"}),br("br",{})]}),br("input",{style:{marginTop:2},type:"checkbox",id:"csv_same_yaxis",name:"csv_plot_yaxis_check",onChange:m=>{p({...u,sameYaxis:m.target.checked,percentChange:!1})},checked:!u.percentChange&&u.sameYaxis}),br("label",{htmlFor:"csv_same_yaxis",style:{marginLeft:5},children:"Share Y-axis"}),D==="bar"&&ni("div",{style:{marginTop:2},id:"csv_bar_orientation",children:[br("input",{type:"checkbox",id:"csv_bar_horizontal",onChange:m=>{v({...d,orientation:m.target.checked?"h":"v"})}}),br("label",{htmlFor:"csv_bar_horizontal",style:{marginLeft:5},children:"Plot horizontally"})]})]})]}),br("br",{}),ni("div",{style:{float:"right",marginTop:20},children:[br("button",{className:"_btn-tertiary",id:"csv_cancel",onClick:x,children:"Cancel"}),br("button",{className:"_btn",id:"csv_submit",onClick:g,children:"Submit"})]})]})})}function F7({csvData:P,plotlyData:F,yaxisOptions:J,traceType:ce,traceColor:Pe,traceName:D,options:E,increasingColor:e,decreasingColor:_}){let w=F.data[0];w.xaxis==null&&(w.xaxis="x"),w.yaxis==null&&(w.yaxis="y");let s=w.yaxis,T,f=Object.keys(F.layout).filter(r=>r.startsWith("yaxis")).map(r=>F.layout[r]).filter(r=>r.side=="left"&&(r.overlaying=="y"||r.fixedrange!=null&&r.fixedrange==!0)).length>0?" ":"";if(J.sameYaxis!==!0){const r=Object.keys(F.layout).filter(n=>n.startsWith("yaxis")).map(n=>F.layout[n]);T=`y${r.length+1}`,s=`yaxis${r.length+1}`,console.log(`yaxis: ${T} ${s}`),F.layout[s]={...z7,title:{text:D,font:{size:14},standoff:0},ticksuffix:f,layer:"below traces"}}else T=w.yaxis.replace("yaxis","y");const l={type:ce,name:D,showlegend:!0,yaxis:T};let t={};if(["scatter","bar"].includes(ce)){const r=P.findIndex(n=>n[E.y]!=null&&n[E.y]!=0);t={...l,x:P.map(n=>n[E.x]),y:P.map(function(n){return J.percentChange&&ce==="scatter"?(n[E.y]-P[r][E.y])/P[r][E.y]:n[E.y]}),customdata:P.map(n=>n[E.y]),hovertemplate:"%{customdata:.2f}",connectgaps:!0,marker:{color:Pe}},ce==="bar"&&(t.orientation=E.orientation,t.marker.opacity=.7,delete t.connectgaps,delete t.hovertemplate,delete t.customdata)}else ce==="candlestick"&&(t={...l,x:P.map(r=>r[E.x]),open:P.map(r=>r[E.open]),high:P.map(r=>r[E.high]),low:P.map(r=>r[E.low]),close:P.map(r=>r[E.close]),increasing:{line:{color:e}},decreasing:{line:{color:_}}});return{...F,data:[...F.data,t]}}function B7({plotlyData:P,open:F,close:J,defaultTitle:ce,updateTitle:Pe,updateAxesTitles:D}){const[E,e]=Un.useState(ce),_=Object.keys(P.layout||{}).filter(y=>y.startsWith("yaxis")&&P.layout[y].range!=null),w=Object.keys(P.layout||{}).filter(y=>{var f;return y.startsWith("xaxis")&&P.layout[y].showticklabels!=null&&((f=P.layout[y])==null?void 0:f.anchor)}),[s,T]=Un.useState({});return br(h1,{title:"Chart Titles",description:"Change the titles on the chart.",open:F,close:J,children:ni("div",{id:"popup_title",className:"popup_content",children:[ni("div",{style:{display:"flex",flexDirection:"column",gap:0},children:[ni("div",{children:[br("label",{htmlFor:"title_text",children:br("b",{children:"Title:"})}),br("textarea",{id:"title_text",style:{...Rw,width:"100%",maxWidth:"100%",maxHeight:"200px",marginTop:"8px",marginLeft:"0px"},rows:2,cols:20,value:E,onChange:y=>e(y.target.value)})]}),br("div",{id:"xaxis_div",className:"csv_column_container",style:{marginTop:5,marginBottom:-5},children:w.map((y,f)=>{var l,t;return ni("div",{style:{marginTop:5,marginBottom:5},children:[br("label",{htmlFor:`title_${y}`,children:f===0?br("b",{children:"X axis:"}):ni("b",{children:["X axis ",f+1,":"]})}),br("input",{id:`title_${y}`,style:{marginLeft:"0px",padding:"5px 2px 2px 5px"},type:"text",defaultValue:((t=(l=P==null?void 0:P.layout[y])==null?void 0:l.title)==null?void 0:t.text)||"",onChange:i=>{T({...s,[y]:i.target.value})}})]},y)})}),br("div",{id:"yaxis_div",className:"csv_column_container",style:{marginTop:5,marginBottom:5},children:_.map((y,f)=>{var l,t;return ni("div",{style:{marginTop:10},children:[br("label",{htmlFor:`title_${y}`,children:f===0?br("b",{children:"Y axis:"}):ni("b",{children:["Y axis ",f+1,":"]})}),br("input",{id:`title_${y}`,style:{marginLeft:"0px",padding:"5px 2px 2px 5px"},type:"text",defaultValue:((t=(l=P==null?void 0:P.layout[y])==null?void 0:l.title)==null?void 0:t.text)||"",onChange:i=>{T({...s,[y]:i.target.value})}})]},y)})})]}),ni("div",{style:{float:"right",marginTop:20},children:[br("button",{className:"_btn-tertiary ph-capture",id:"title_cancel",onClick:J,children:"Cancel"}),br("button",{className:"_btn ph-capture",id:"title_submit",onClick:()=>{Pe(E),D(s),J()},children:"Submit"})]})]})})}const Bb={padding:"5px 2px 2px 5px",margin:"2px 0"};function N7({open:P,close:F,addAnnotation:J,deleteAnnotation:ce,popupData:Pe}){var l,t,i,r,n;const D={text:"",color:"#0088CC",size:18,bordercolor:"#822661",yanchor:"above"},[E,e]=Un.useState(D),[_,w]=Un.useState(D);Pe&&Pe!==E&&Pe.annotation&&(Pe.annotation=(Pe==null?void 0:Pe.annotation)||{},e(Pe),w(Pe));function s(){console.log("closing"),e(D),w(D),F()}function T(o){console.log(o.target.id.replace("addtext_",""),o.target.value);const a=o.target.id.replace("addtext_",""),u=o.target.value;w({..._,[a]:u})}function y(){console.log("submitting",_),_.text!==""?(E!=null&&E.annotation&&w({..._,annotation:E.annotation}),J(_),F()):(document.getElementById("popup_textarea_warning").style.display="block",document.getElementById("addtext_text").style.border="1px solid red")}function f(){ce(E),s()}return br(h1,{title:"Add Text to Chart",description:"Change the titles on the chart.",open:P,close:s,children:ni("div",{id:"popup_title",className:"popup_content",children:[ni("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[ni("div",{style:{marginBottom:20},children:[ni("label",{htmlFor:"popup_text",children:[br("b",{children:"Text:"}),br("div",{id:"popup_textarea_warning",className:"popup_warning",children:"Text is required"})]}),br("textarea",{id:"addtext_text",style:{...Bb,width:"100%",maxWidth:"100%",maxHeight:"200px",marginTop:"8px"},rows:4,cols:50,placeholder:"Enter text here",onChange:T,defaultValue:((l=E==null?void 0:E.annotation)==null?void 0:l.text)||(_==null?void 0:_.text)})]}),ni("div",{style:{display:"flex",gap:15,alignItems:"center",flexWrap:"wrap",columnCount:2,justifyContent:"space-between",marginBottom:20},children:[br("label",{htmlFor:"addtext_color",children:br("b",{children:"Font color"})}),br("input",{type:"color",id:"addtext_color",style:{margin:"2px 2px 2px 15px"},defaultValue:((t=E==null?void 0:E.annotation)==null?void 0:t.color)||(_==null?void 0:_.color),onChange:T}),br("label",{htmlFor:"addtext_bordercolor",style:{marginLeft:20},children:br("b",{children:"Border color"})}),br("input",{type:"color",id:"addtext_bordercolor",style:{margin:"2px 2px 10px 15px"},defaultValue:((i=E==null?void 0:E.annotation)==null?void 0:i.bordercolor)||(_==null?void 0:_.bordercolor),onChange:T}),br("label",{htmlFor:"addtext_size",children:br("b",{children:"Font size"})}),br("input",{style:{...Bb,width:"52px",margin:"0px 0px 0px 2px"},type:"number",id:"addtext_size",onChange:T,defaultValue:((r=E==null?void 0:E.annotation)==null?void 0:r.size)||(_==null?void 0:_.size)}),ni("div",{children:[br("label",{htmlFor:"addtext_yanchor",style:{marginRight:31},children:br("b",{children:"Position"})}),ni("select",{id:"addtext_yanchor",name:"yanchor",style:{width:"100px"},defaultValue:((n=E==null?void 0:E.annotation)==null?void 0:n.yanchor)||(_==null?void 0:_.yanchor),onChange:T,children:[br("option",{value:"above",children:"Above"}),br("option",{value:"below",children:"Below"})]})]})]})]}),ni("div",{style:{float:"right",marginTop:20},children:[br("button",{className:"_btn-tertiary ph-capture",id:"title_cancel",onClick:s,children:"Cancel"}),br("button",{className:"_btn ph-capture",id:"title_delete",onClick:f,children:"Delete"}),br("button",{className:"_btn ph-capture",id:"title_submit",onClick:y,children:"Submit"})]})]})})}function j7({plotData:P,popup_data:F,current_text:J}){var _;let ce=F.x,Pe=F.y,D=F.yref,E=((_=P==null?void 0:P.layout)==null?void 0:_.annotations)||[],e=-1;for(let w=0;wx!=null)),P.layout.dragmode="pan",J({...P,...a.update}),s.removeAllListeners("plotly_click")};F.text=F.text.replace(/\n/g,"
");let y,f=!1;if(F.annotation){console.log("data",F),y={x:F.annotation.x,y:F.annotation.y,yref:F.annotation.yref,yanchor:F.annotation.yi.x==F.annotation.x&&i.y==F.annotation.y&&i.yref==F.annotation.yref);console.log("ohlcAnnotationIndex",t),t==-1?_([...e,l.annotation]):(e[t]=l.annotation,_(e))}D([...w,l.annotation].filter(t=>t!=null)),P.layout.dragmode="pan",J({...P,...l.update}),Pe({});return}s.on("plotly_clickannotation",l=>{console.log("plotly_clickannotation",l);let t=l.annotation;if(t.text==null){console.log("annotation.text is undefined");return}console.log("annotation.text",t.text),t.text=t.text.replace(/
/g,` `);let i={x:t.x,y:t.y,high:(t==null?void 0:t.high)??void 0,low:(t==null?void 0:t.low)??void 0,yanchor:t.y'),!0):F?P.some(function(J){return F.includes(J)})||P.includes("*"):!0}var X7=function(F,J,ce){ce===void 0&&(ce=!1);var Pe=J.alt,D=J.meta,E=J.mod,e=J.shift,_=J.ctrl,w=J.keys,s=F.key,T=F.code,y=F.ctrlKey,f=F.metaKey,l=F.shiftKey,t=F.altKey,i=sc(T),r=s.toLowerCase();if(!ce){if(Pe===!t&&r!=="alt"||e===!l&&r!=="shift")return!1;if(E){if(!f&&!y)return!1}else if(D===!f&&r!=="meta"&&r!=="os"||_===!y&&r!=="ctrl"&&r!=="control")return!1}return w&&w.length===1&&(w.includes(r)||w.includes(i))?!0:w?q7(w):!w},$7=Un.createContext(void 0),J7=function(){return Un.useContext($7)};function Nw(P,F){return P&&F&&typeof P=="object"&&typeof F=="object"?Object.keys(P).length===Object.keys(F).length&&Object.keys(P).reduce(function(J,ce){return J&&Nw(P[ce],F[ce])},!0):P===F}var K7=Un.createContext({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),Q7=function(){return Un.useContext(K7)};function e9(P){var F=Un.useRef(void 0);return Nw(F.current,P)||(F.current=P),F.current}var jb=function(F){F.stopPropagation(),F.preventDefault(),F.stopImmediatePropagation()},t9=typeof window<"u"?Un.useLayoutEffect:Un.useEffect;function Ku(P,F,J,ce){var Pe=Un.useRef(null),D=Un.useRef(!1),E=J instanceof Array?ce instanceof Array?void 0:ce:J,e=P instanceof Array?P.join(E==null?void 0:E.splitKey):P,_=J instanceof Array?J:ce instanceof Array?ce:void 0,w=Un.useCallback(F,_??[]),s=Un.useRef(w);_?s.current=w:s.current=F;var T=e9(E),y=Q7(),f=y.enabledScopes,l=J7();return t9(function(){if(!((T==null?void 0:T.enabled)===!1||!Y7(f,T==null?void 0:T.scopes))){var t=function(a,u){var p;if(u===void 0&&(u=!1),!(Z7(a)&&!Bw(a,T==null?void 0:T.enableOnFormTags))&&!(T!=null&&T.ignoreEventWhen!=null&&T.ignoreEventWhen(a))){if(Pe.current!==null&&document.activeElement!==Pe.current&&!Pe.current.contains(document.activeElement)){jb(a);return}(p=a.target)!=null&&p.isContentEditable&&!(T!=null&&T.enableOnContentEditable)||Bg(e,T==null?void 0:T.splitKey).forEach(function(c){var b,d=Ng(c,T==null?void 0:T.combinationKey);if(X7(a,d,T==null?void 0:T.ignoreModifiers)||(b=d.keys)!=null&&b.includes("*")){if(u&&D.current)return;if(G7(a,d,T==null?void 0:T.preventDefault),!W7(a,d,T==null?void 0:T.enabled)){jb(a);return}s.current(a,d),u||(D.current=!0)}})}},i=function(a){a.key!==void 0&&(Dw(sc(a.code)),((T==null?void 0:T.keydown)===void 0&&(T==null?void 0:T.keyup)!==!0||T!=null&&T.keydown)&&t(a))},r=function(a){a.key!==void 0&&(Fw(sc(a.code)),D.current=!1,T!=null&&T.keyup&&t(a,!0))},n=Pe.current||(E==null?void 0:E.document)||document;return n.addEventListener("keyup",r),n.addEventListener("keydown",i),l&&Bg(e,T==null?void 0:T.splitKey).forEach(function(o){return l.addHotkey(Ng(o,T==null?void 0:T.combinationKey,T==null?void 0:T.description))}),function(){n.removeEventListener("keyup",r),n.removeEventListener("keydown",i),l&&Bg(e,T==null?void 0:T.splitKey).forEach(function(o){return l.removeHotkey(Ng(o,T==null?void 0:T.combinationKey,T==null?void 0:T.description))})}}},[e,T,f]),Pe}var jw={exports:{}};(function(P){(function(F){var J=o(),ce=a(),Pe=u(),D=p(),E={imagePlaceholder:void 0,cacheBust:!1},e={toSvg:_,toPng:s,toJpeg:T,toBlob:y,toPixelData:w,impl:{fontFaces:Pe,images:D,util:J,inliner:ce,options:{}}};P.exports=e;function _(c,b){return b=b||{},f(b),Promise.resolve(c).then(function(v){return t(v,b.filter,!0)}).then(i).then(r).then(d).then(function(v){return n(v,b.width||J.width(c),b.height||J.height(c))});function d(v){return b.bgcolor&&(v.style.backgroundColor=b.bgcolor),b.width&&(v.style.width=b.width+"px"),b.height&&(v.style.height=b.height+"px"),b.style&&Object.keys(b.style).forEach(function(x){v.style[x]=b.style[x]}),v}}function w(c,b){return l(c,b||{}).then(function(d){return d.getContext("2d").getImageData(0,0,J.width(c),J.height(c)).data})}function s(c,b){return l(c,b||{}).then(function(d){return d.toDataURL()})}function T(c,b){return b=b||{},l(c,b).then(function(d){return d.toDataURL("image/jpeg",b.quality||1)})}function y(c,b){return l(c,b||{}).then(J.canvasToBlob)}function f(c){typeof c.imagePlaceholder>"u"?e.impl.options.imagePlaceholder=E.imagePlaceholder:e.impl.options.imagePlaceholder=c.imagePlaceholder,typeof c.cacheBust>"u"?e.impl.options.cacheBust=E.cacheBust:e.impl.options.cacheBust=c.cacheBust}function l(c,b){return _(c,b).then(J.makeImage).then(J.delay(100)).then(function(v){var x=d(c);return x.getContext("2d").drawImage(v,0,0),x});function d(v){var x=document.createElement("canvas");if(x.width=b.width||J.width(v),x.height=b.height||J.height(v),b.bgcolor){var g=x.getContext("2d");g.fillStyle=b.bgcolor,g.fillRect(0,0,x.width,x.height)}return x}}function t(c,b,d){if(!d&&b&&!b(c))return Promise.resolve();return Promise.resolve(c).then(v).then(function(m){return x(c,m,b)}).then(function(m){return g(c,m)});function v(m){return m instanceof HTMLCanvasElement?J.makeImage(m.toDataURL()):m.cloneNode(!1)}function x(m,k,h){var M=m.childNodes;if(M.length===0)return Promise.resolve(k);return A(k,J.asArray(M),h).then(function(){return k});function A(C,L,O){var I=Promise.resolve();return L.forEach(function(R){I=I.then(function(){return t(R,O)}).then(function(U){U&&C.appendChild(U)})}),I}}function g(m,k){if(!(k instanceof Element))return k;return Promise.resolve().then(h).then(M).then(A).then(C).then(function(){return k});function h(){L(window.getComputedStyle(m),k.style);function L(O,I){O.cssText?I.cssText=O.cssText:R(O,I);function R(U,B){J.asArray(U).forEach(function(G){B.setProperty(G,U.getPropertyValue(G),U.getPropertyPriority(G))})}}}function M(){[":before",":after"].forEach(function(O){L(O)});function L(O){var I=window.getComputedStyle(m,O),R=I.getPropertyValue("content");if(R===""||R==="none")return;var U=J.uid();k.className=k.className+" "+U;var B=document.createElement("style");B.appendChild(G(U,O,I)),k.appendChild(B);function G(N,j,V){var H="."+N+":"+j,ee=V.cssText?Q(V):X(V);return document.createTextNode(H+"{"+ee+"}");function Q(Y){var K=Y.getPropertyValue("content");return Y.cssText+" content: "+K+";"}function X(Y){return J.asArray(Y).map(K).join("; ")+";";function K(te){return te+": "+Y.getPropertyValue(te)+(Y.getPropertyPriority(te)?" !important":"")}}}}}function A(){m instanceof HTMLTextAreaElement&&(k.innerHTML=m.value),m instanceof HTMLInputElement&&k.setAttribute("value",m.value)}function C(){k instanceof SVGElement&&(k.setAttribute("xmlns","http://www.w3.org/2000/svg"),k instanceof SVGRectElement&&["width","height"].forEach(function(L){var O=k.getAttribute(L);O&&k.style.setProperty(L,O)}))}}}function i(c){return Pe.resolveAll().then(function(b){var d=document.createElement("style");return c.appendChild(d),d.appendChild(document.createTextNode(b)),c})}function r(c){return D.inlineAll(c).then(function(){return c})}function n(c,b,d){return Promise.resolve(c).then(function(v){return v.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(v)}).then(J.escapeXhtml).then(function(v){return''+v+""}).then(function(v){return''+v+""}).then(function(v){return"data:image/svg+xml;charset=utf-8,"+v})}function o(){return{escape:C,parseExtension:b,mimeType:d,dataAsUrl:A,isDataUrl:v,canvasToBlob:g,resolveUrl:m,getAndEncode:M,uid:k(),delay:L,asArray:O,escapeXhtml:I,makeImage:h,width:R,height:U};function c(){var G="application/font-woff",N="image/jpeg";return{woff:G,woff2:G,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:N,jpeg:N,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}function b(G){var N=/\.([^\.\/]*?)$/g.exec(G);return N?N[1]:""}function d(G){var N=b(G).toLowerCase();return c()[N]||""}function v(G){return G.search(/^(data:)/)!==-1}function x(G){return new Promise(function(N){for(var j=window.atob(G.toDataURL().split(",")[1]),V=j.length,H=new Uint8Array(V),ee=0;ee{if(P)return i9({fileHandle:P,blob:F})},i9=async({fileHandle:P,blob:F})=>{const J=await P.createWritable();await J.write(F),await J.close()},a9=[{description:"PNG Image",accept:{"image/png":[".png"]}},{description:"JPEG Image",accept:{"image/jpeg":[".jpeg"]}},{description:"SVG Image",accept:{"image/svg+xml":[".svg"]}}],Vw=({filename:P,is_image:F})=>{try{if("showSaveFilePicker"in window){const J={suggestedName:P,types:F?a9:[{description:"CSV File",accept:{"image/csv":[".csv"]}}],excludeAcceptAllOption:!0};return showSaveFilePicker(J)}}catch(J){console.error(J)}return new Promise(J=>{J(null)})},ty=(P,F,J)=>{try{if(J===null)throw new Error("Cannot access filesystem");return r9({fileHandle:J,blob:P})}catch(ce){console.error("oops, something went wrong!",ce);const Pe=URL.createObjectURL(P),D=document.createElement("a");D.setAttribute("href",Pe),D.setAttribute("download",F),D.style.visibility="hidden",document.body.appendChild(D),D.click(),document.body.removeChild(D)}return new Promise(ce=>{ce(!0)})};async function Ub(P,F){const J=P.data;let ce=[];const Pe=[],D="title"in P.layout.xaxis&&P.layout.xaxis.title.text!==void 0?P.layout.xaxis.title.text:"x",E="title"in P.layout.yaxis&&P.layout.yaxis.title.text!==void 0?P.layout.yaxis.title.text:"y";return J.forEach(function(e){e.type==="candlestick"&&(ce.length===0&&(ce=["Date","Open","High","Low","Close"]),e.x.forEach(function(_,w){Pe.push([_,e.open[w],e.high[w],e.low[w],e.close[w]])})),["scatter","bar"].includes(e.type)&&(ce.length===0&&ce.push(D),ce.push(e.name!==void 0?e.name:E),e.x.forEach(function(_,w){Pe[w]===void 0&&(Pe[w]=[_]),Pe[w].push(e.y[w])}))}),await o9(ce,Pe,F)}async function o9(P,F,J){const ce=P,Pe=F.map(w=>w.map(s=>s==null?"":typeof s=="object"?JSON.stringify(s):s.toString().replace(/"/g,'""'))),E=[ce,...Pe].map(w=>w.join(",")).join(` -`),e=new Blob([E],{type:"text/csv;charset=utf-8;"}),_=`${window.title}.csv`;try{const w=await Vw({filename:_});await Bp("Saving CSV"),Np(async function(){ty(e,_,w).then(async function(){await new Promise(s=>setTimeout(s,1500)),w||J(!0),await Bp("",!0)})},2)()}catch(w){console.error(w)}}function Bp(P,F){const J=window.document.getElementById("loading"),ce=window.document.getElementById("loading_text");return new Promise(Pe=>{F?J.classList.remove("show"):(ce.innerHTML=P,J.classList.add("show"));const D=setInterval(function(){(F?!J.classList.contains("show"):J.classList.contains("show"))&&(clearInterval(D),Pe(!0))},.01)})}const Np=(P,F)=>{let J;return function(){const ce=this,Pe=arguments;clearTimeout(J),J=setTimeout(()=>P.apply(ce,Pe),F)}},s9={yref:"paper",xref:"paper",x:1,y:0,text:"OpenBB Terminal",font_size:17,font_color:"gray",opacity:.5,xanchor:"right",yanchor:"bottom",yshift:-80,xshift:40};async function Vb(P,F,J=!1){const ce=document.getElementById("plotlyChart");J&&(ce.layout.annotations.push(s9),ce.globals.cmd_idx!==void 0&&ce.globals.cmd_src!==void 0&&(ce.layout.annotations[ce.globals.cmd_idx].text=ce.globals.cmd_src),Gs.relayout(ce,{"title.text":ce.globals.title,margin:ce.globals.old_margin})),J||(ce.globals.cmd_idx!==void 0&&ce.globals.cmd_src!==void 0&&(ce.layout.annotations[ce.globals.cmd_idx].text=""),ce.layout.annotations.splice(F,1),Gs.relayout(ce,{"title.text":"",margin:P}))}async function Hw(P,F,J){const ce=document.getElementById(P);if(["svg","pdf"].includes(J)){const Pe=document.getElementById("plotlyChart"),D=Pe.layout.margin,E=Pe.layout.annotations.length;await Vb(D,E,!0),Gs.downloadImage(Pe,{format:"svg",height:Pe.clientHeight,width:Pe.clientWidth,filename:window.title}),await Vb(D,E,!1),await Bp("",!0);return}Np(async function(){Uw.toBlob(ce).then(function(Pe){ty(Pe,F,null)})},2)()}async function Hb(P,F,J,ce){const Pe=document.getElementById(P),D=`${window.title}.png`;try{J(!0);const E=await Vw({filename:D,is_image:!0});let e="png";if(E!==null&&(e=E.name.split(".").pop()),await Bp(`Saving ${e.toUpperCase()}`),["svg","pdf"].includes(e)){await Hw(P,D,e),F(!1),J(!1),E||ce(!0);return}Np(async function(){Uw.toBlob(Pe).then(function(_){ty(_,D,E).then(async function(){await Bp("",!0),F(!1),J(!1),E||ce(!0)})})},2)()}catch(E){console.error(E),F(!1),J(!1)}}function rc(P=!0){return new Promise(F=>{window.MODEBAR||(window.MODEBAR=window.document.getElementsByClassName("modebar-container")[0],window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`),window.MODEBAR&&(window.MODEBAR.style.cssText.includes("display: none")&&!P?window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`:window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:none;`,F(!0))})}function l9({setModal:P,changeTheme:F,autoScaling:J,Loading:ce,changeColor:Pe,downloadFinished:D}){return Ku("ctrl+shift+t",()=>{P({name:"titleDialog"})},{preventDefault:!0}),Ku("ctrl+t",()=>{P({name:"textDialog"})},{preventDefault:!0}),Ku("ctrl+o",()=>{P({name:"overlayChart"})},{preventDefault:!0}),Ku("ctrl+shift+h",()=>{rc()},{preventDefault:!0}),Ku("ctrl+e",()=>{Pe(!0)},{preventDefault:!0}),Ku("ctrl+shift+s",async()=>{P({name:"downloadCsv"}),await Ub(document.getElementById("plotlyChart"),D)},{preventDefault:!0}),Ku("ctrl+s",async()=>{rc(),Hb("MainChart",rc,ce,D)},{preventDefault:!0}),Ku("ctrl+w",()=>{window.close()},{preventDefault:!0}),{plotGlPixelRatio:1,scrollZoom:!0,responsive:!0,displaylogo:!1,displayModeBar:!0,modeBarButtonsToRemove:["lasso2d","select2d","downloadImage"],modeBarButtons:[[{name:"Download CSV (Ctrl+Shift+S)",icon:Pu.downloadCsv,click:async function(e){await Ub(e,D)}},{name:"Download Chart as Image (Ctrl+S)",icon:Pu.downloadImage,click:async function(){rc(),await Hb("MainChart",rc,ce,D)}}],[{name:"Edit Color (Ctrl+E)",icon:Pu.changeColor,click:function(){Pe(!0)}},"drawline","drawopenpath","drawcircle","drawrect","eraseshape"],[{name:"Overlay chart from CSV (Ctrl+O)",icon:Pu.plotCsv,click:function(){P({name:"overlayChart"})}},{name:"Add Text (Ctrl+T)",icon:Pu.addText,click:function(){P({name:"textDialog",data:{text:""}})}},{name:"Change Titles (Ctrl+Shift+T)",icon:Pu.changeTitle,click:function(){P({name:"titleDialog"})}},{name:"Change Theme",icon:Pu.sunIcon,click:function(){F(!0)}}],["hoverClosestCartesian","hoverCompareCartesian","toggleSpikelines"],[{name:"Auto Scale (Ctrl+Shift+A)",icon:Gs.Icons.autoscale,click:function(){J(!0)}},"zoomIn2d","zoomOut2d","autoScale2d","zoom2d","pan2d"]]}}async function u9(P,F){try{if(P["xaxis.range[0]"]!=null){const J=P["xaxis.range[0]"],ce=P["xaxis.range[1]"];let Pe={},D,E;const e=F.data.filter(s=>s.yaxis!=null),_=[...new Set(e.map(s=>s.yaxis||s.y!=null||s.type=="candlestick"))],w=s=>F.data.filter(T=>T.yaxis==s&&(T.y||T.type=="candlestick"));return _.forEach(s=>{if(typeof s!="string")return;let T="yaxis"+s.replace("y",""),y=[],f=[],l=F.layout[T].type=="log";w(s).forEach(r=>{let n=r.x;l=F.layout[T].type=="log";let o=r.y!=null?r.y:[],a=r.type=="candlestick"?r.low:[],u=r.type=="candlestick"?r.high:[];l&&(o=o.map(Math.log10),r.type=="candlestick"&&(a=r.low.map(Math.log10),u=r.high.map(Math.log10)));let p=n.map((c,b)=>{let d=null;return c>=J&&c<=ce&&(r.y!=null&&(d=o[b]),r.type=="candlestick"&&(y.push(a[b]),y.push(u[b]))),d});f=f.concat(p)}),f=f.filter(r=>r!=null&&r!=null),D=Math.min(...f),E=Math.max(...f),y.length>0&&(y=y.filter(r=>r!=null&&r!=null),D=Math.min(...y),E=Math.max(...y));let t=E,i=F.layout[T].fixedrange!=null&&F.layout[T].fixedrange==!0;if(D!=null&&E!=null){let r=E-D,n=.15;if(y.length>0&&(n=.3),D-=r*n,E+=r*n,i){if(F.layout[T].tickvals!=null){let a=t,u=-3,p=Math.round(a*.2,u),c=[2,5,6,7,8,9,10],b=[1,4,5,6,7,8,9];for(let x=0;xc[x]&&(u=-b[x],p=Math.round(a*.2,u));let d=[Math.floor(p),Math.floor(p*2),Math.floor(p*3),Math.floor(p*4)],v=[0,Math.floor(a*7)];Pe[T+".tickvals"]=d,Pe[T+".range"]=v,Pe[T+".tickformat"]=".2s";return}D=0,E=F.layout[T].range[1]}Pe[T+".range"]=[D,E]}}),Pe}}catch(J){console.log(`Error in AutoScaling: ${J}`)}return{}}async function c9({plotData:P,volumeBars:F,setMaximizePlot:J}){const ce=Object.keys(P.layout).filter(s=>s.startsWith("xaxis")).filter(s=>P.layout[s].showticklabels||P.layout[s].matches==null),Pe=P.data.filter(s=>{var T;return(T=s==null?void 0:s.name)==null?void 0:T.startsWith("Volume")});let D={},E=F||{old_nticks:{}};const e=window.innerWidth,_=window.innerHeight;let w=_>420&&e<920?8:_>420&&e<500?9:7;return e<750?(Pe.forEach(s=>{s.type=="bar"&&(s.opacity=1,s.marker.line.width=.09,F.yaxis==null&&(E.yaxis="yaxis"+s.yaxis.replace("y",""),D[E.yaxis+".tickfont.size"]=w,E.tickfont=P.layout[E.yaxis].tickfont||{},P.layout.margin.l-=40))}),ce.forEach(s=>{var T;((T=F.old_nticks)==null?void 0:T[s])==null&&(D[s+".nticks"]=6,E.old_nticks[s]=P.layout[s].nticks||10)}),J(!0),await rc()):window.MODEBAR.style.cssText.includes("display: none")&&(await rc(!1),J(!1),F.old_nticks!=null&&ce.forEach(s=>{F.old_nticks[s]!=null&&(D[s+".nticks"]=E.old_nticks[s],E.old_nticks[s]=void 0)}),F.yaxis!=null&&Pe.forEach(s=>{s.type=="bar"&&(s.opacity=.5,s.marker.line.width=.2,D[E.yaxis+".tickfont.size"]=E.tickfont.size+3,P.layout.margin.l+=40,E.yaxis=void 0)})),{volume_update:E,layout_update:D,plotData:P}}function f9({open:P,onColorChange:F}){const[J,ce]=Un.useState(!1);function Pe(D){F(D)}return P&&!J&&ce(!0),!P&&J&&ce(!1),Un.useEffect(()=>{if(J){let D=function(e){let _=0,w=0,s=0,T=0;document.getElementById(e.id+"_header")?document.getElementById(e.id+"_header").onmousedown=y:e.onmousedown=y;function y(t){t=t||window.event,t.preventDefault(),s=t.clientX,T=t.clientY,document.onmouseup=l,document.onmousemove=f}function f(t){t=t||window.event,t.preventDefault(),_=s-t.clientX,w=T-t.clientY,s=t.clientX,T=t.clientY,e.style.top=e.offsetTop-w+"px",e.style.left=e.offsetLeft-_+"px"}function l(){document.onmouseup=null,document.onmousemove=null}},E=document.getElementById("changecolor");E.style.display="block",E.style.width=null,D(E)}else document.getElementById("changecolor").style.display="none"},[J]),br("div",{id:"changecolor",children:br("div",{id:"changecolor_header",children:br("input",{type:"color",id:"picked_color",value:"#00ACFF",onChange:D=>{let E=D.target.value;Pe(E)}})})})}function qw(P){var F,J,ce="";if(typeof P=="string"||typeof P=="number")ce+=P;else if(typeof P=="object")if(Array.isArray(P))for(F=0;F{ce.preventDefault(),window.pywry.open_file(J)},children:J})]})})}),br("div",{style:{float:"right",marginTop:20},children:br("button",{className:"_btn",style:{padding:"8px 16px",width:"100%"},onClick:F,children:"Close"})})]})})}const d9=QT(ZT);function g9({json:P,date:F,cmd:J,title:ce,globals:Pe,info:D}){var se,fe;const E=GT();Un.useEffect(()=>{E&&E.capture("chart",D)},[]),delete P.layout.width,delete P.layout.height,(fe=(se=P.layout)==null?void 0:se.title)!=null&&fe.text&&(P.layout.title.text="");const[e,_]=Un.useState({}),[w,s]=Un.useState(!1),[T,y]=Un.useState(ce),[f,l]=Un.useState({}),[t,i]=Un.useState(!1),[r,n]=Un.useState({name:""}),[o,a]=Un.useState(!1),[u,p]=Un.useState(null),[c,b]=Un.useState({old_nticks:{}}),[d,v]=Un.useState(!1),[x,g]=Un.useState(!1),[m,k]=Un.useState(P),[h,M]=Un.useState([]),[A,C]=Un.useState(!1),[L,O]=Un.useState(!0),[I,R]=Un.useState(!1),[U,B]=Un.useState(!1),[G,N]=Un.useState(!1),[j,V]=Un.useState({}),[H,ee]=Un.useState([]),Q=()=>n({name:""});function X(ye){var de,he,xe,Re,we;console.log("onDeleteAnnotation",ye);const pe=(he=(de=m==null?void 0:m.layout)==null?void 0:de.annotations)==null?void 0:he.findIndex(Ae=>Ae.text===ye.text);console.log("index",pe),pe>-1&&((Re=(xe=m==null?void 0:m.layout)==null?void 0:xe.annotations)==null||Re.splice(pe,1),k({...m}),M((we=m==null?void 0:m.layout)==null?void 0:we.annotations))}function Y(ye){U7({plotData:m,popupData:ye,setPlotData:k,setModal:n,setOnAnnotationClick:V,setAnnotations:M,onAnnotationClick:j,ohlcAnnotation:H,setOhlcAnnotation:ee,annotations:h,plotDiv:u})}Un.useEffect(()=>{x&&(n({name:"downloadFinished"}),g(!1))},[x]),Un.useEffect(()=>{f&&Object.keys(f).length>0&&(Object.keys(f).forEach(ye=>{m.layout[ye].title={...m.layout[ye].title||{},text:f[ye]},m.layout[ye].showticklabels=!0}),l({}))},[f]);function K(ye){let pe=u.layout.shapes;if(!pe||pe.length==0)return;let de=pe[pe.length-1];de.line.color=ye,Gs.update(u,{},{shapes:pe})}function te(ye,pe=!1){let de=e[ye]||document.querySelector(`[data-title="${ye}"]`);pe?(de.style.border="transparent",de.style.boxShadow="none"):(de.style.border="1px solid rgba(0, 151, 222, 1.0)",de.style.borderRadius="5px",de.style.borderpadding="5px",de.style.boxShadow="0 0 5px rgba(0, 151, 222, 1.0)"),_({...e,[ye]:de})}function ae(){let ye="Auto Scale (Ctrl+Shift+A)",pe=e[ye]||document.querySelector(`[data-title="${ye}"]`),de=!0;pe.style.border=="transparent"?(de=!1,u.on("plotly_relayout",Np(async function(he){if(he["xaxis.range[0]"]==null)return;let xe=await u9(he,u);Gs.update(u,{},xe)},100))):u.removeAllListeners("plotly_relayout"),te(ye,de)}function oe(){let ye="Edit Color (Ctrl+E)",pe=e[ye]||document.querySelector(`[data-title="${ye}"]`),de=!0;pe.style.border=="transparent"&&(de=!1),N(!de),te(ye,de)}return Un.useEffect(()=>{I&&(console.log("activateAutoScale",!I),ae(),R(!1))},[I]),Un.useEffect(()=>{U&&(oe(),B(!1))},[U]),Un.useEffect(()=>{if(A)try{console.log("changeTheme",A);const ye=m==null?void 0:m.data.filter(xe=>{var Re;return(Re=xe==null?void 0:xe.name)==null?void 0:Re.startsWith("Volume")});let pe=!L;window.document.body.style.backgroundColor=pe?"#000":"#fff",m.layout.font={...m.layout.font||{},color:pe?"#fff":"#000"};const de=pe?Pu.sunIcon:Pu.moonIcon;document.querySelector('[data-title="Change Theme"]').getElementsByTagName("path")[0].setAttribute("d",de.path),document.querySelector('[data-title="Change Theme"]').getElementsByTagName("svg")[0].setAttribute("viewBox",de.viewBox);const he={"#e4003a":"#c80000","#00ACFF":"#009600","#009600":"#00ACFF","#c80000":"#e4003a"};ye.forEach(xe=>{xe.type=="bar"&&(xe.marker.color=xe.marker.color.map(Re=>he[Re]||Re))}),m.layout.template=pe?ek:tk,k({...m}),Gs.react(u,m.data,m.layout),O(pe),C(!1)}catch(ye){console.log("error",ye)}},[A]),Un.useEffect(()=>{if(t){O(!0),R(!1);const ye=["Download CSV","Download Chart as Image","Overlay chart from CSV","Add Text","Change Titles","Auto Scale (Ctrl+Shift+A)","Reset Axes"],pe=document.querySelector('[data-title="Autoscale"]');pe&&(pe.getElementsByTagName("path")[0].setAttribute("d",Gs.Icons.home.path),pe.setAttribute("data-title","Reset Axes")),window.MODEBAR=document.getElementsByClassName("modebar-container")[0];const de=window.MODEBAR.getElementsByClassName("modebar-btn");if(window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`,de){let he={};for(let xe=0;xe0&&(k(Re),b(we),Gs.relayout(u,xe))})}},[t]),ni("div",{className:"relative h-full",children:[o&&br("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ni("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[br("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),br("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})}),ni("div",{id:"loading",className:"saving",children:[br("div",{id:"loading_text",className:"loading_text"}),br("div",{id:"loader",className:"loader"})]}),br(D7,{addOverlay:ye=>{console.log(ye),m.layout.showlegend=!0,k(ye),i(!1)},plotlyData:m,setLoading:a,open:r.name==="overlayChart",close:Q}),br(B7,{updateTitle:ye=>y(ye),updateAxesTitles:ye=>l(ye),defaultTitle:T,plotlyData:m,open:r.name==="titleDialog",close:Q}),br(N7,{popupData:r.name==="textDialog"?r==null?void 0:r.data:null,open:r.name==="textDialog",close:Q,addAnnotation:ye=>Y(ye),deleteAnnotation:ye=>X(ye)}),br(f9,{open:G,onColorChange:K}),br(p9,{open:r.name==="downloadFinished",close:Q}),ni("div",{className:"relative h-full",id:"MainChart",children:[ni("div",{className:"_header relative gap-4 py-2 text-center text-xs flex items-center justify-between px-4 text-white",children:[br("div",{className:"w-1/3",children:br("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"40",fill:"none",viewBox:"0 0 64 40",children:br("path",{fill:"#fff",d:"M61.283 3.965H33.608v27.757h25.699V19.826H37.561v-3.965H63.26V3.965h-1.977zM39.538 23.792h15.815v3.965H37.561v-3.965h1.977zM59.306 9.913v1.983H37.561V7.931h21.745v1.982zM33.606 0h-3.954v3.965H33.606V0zM25.7 3.966H0V15.86h25.7v3.965H3.953v11.896h25.7V3.966h-3.955zm0 21.808v1.983H7.907v-3.965h17.791v1.982zm0-15.86v1.982H3.953V7.931h21.745v1.982zM37.039 35.693v2.952l-.246-.246-.245-.245-.245-.247-.245-.246-.246-.246-.245-.245-.245-.247-.247-.246-.245-.246-.245-.246-.245-.246-.246-.246h-.49v3.936h.49v-3.198l.246.246.245.246.245.246.245.246.246.246.246.246.245.247.246.245.245.246.245.247.245.246.246.245.245.246h.245v-3.936h-.49zM44.938 37.17h-.491v-1.477h-2.944v3.937h3.93v-2.46h-.495zm-2.944-.246v-.739h1.962v.984h-1.962v-.245zm2.944.984v1.23h-2.944V37.66h2.944v.247zM52.835 37.17h-.49v-1.477h-2.946v3.937h3.925v-2.46h-.489zm-2.944-.246v-.739h1.963v.984h-1.965l.002-.245zm2.944.984v1.23H49.89V37.66h2.946v.247zM29.174 35.693H25.739v3.936H29.663v-.491H26.229v-.984h2.943v-.493H26.229v-1.476h3.434v-.492h-.489zM13.37 35.693H9.934v3.937h3.925v-3.937h-.49zm0 .738v2.709h-2.945v-2.955h2.943l.001.246zM21.276 35.693h-3.435v3.937h.491v-1.476h3.434v-2.461h-.49zm0 .738v1.23h-2.944v-1.476h2.944v.246z"})})}),br("p",{className:"font-bold w-1/3 flex flex-col gap-0.5 items-center",children:T}),ni("p",{className:"w-1/3 text-right text-xs",children:[new Intl.DateTimeFormat("en-GB",{dateStyle:"full",timeStyle:"long"}).format(F).replace(/:\d\d /," "),br("br",{}),br("span",{className:"text-grey-400",children:J})]})]}),br("div",{className:h9("w-full sm:pb-12",{"h-[calc(100%-10px)]":d,"h-[calc(100%-50px)]":!d}),children:br(d9,{onInitialized:()=>{if(!u){const ye=document.getElementById("plotlyChart");console.log("plot",ye),ye&&p(ye),ye.globals=Pe}t||i(!0)},className:"w-full h-full",divId:"plotlyChart",data:m.data,layout:m.layout,config:l9({setModal:n,changeTheme:C,autoScaling:R,Loading:a,changeColor:B,downloadFinished:g})})})]})]})}function v9(){const[P,F]=Un.useState(null),[J,ce]=Un.useState({});Un.useEffect(()=>{{const E=setInterval(()=>{if(window.json_data){const e=window.json_data;console.log(e),F(e),clearInterval(E)}},100);return()=>clearInterval(E)}},[]);const D=(E=>{var y,f,l,t;if(!E)return null;let e={added_traces:[],csv_yaxis_id:null,cmd_src_idx:null,cmd_idx:null,cmd_src:"",old_margin:null,title:""},_=(f=(y=E.layout)==null?void 0:y.title)==null?void 0:f.text.replace(/ -/g,"").replace(/-/g,"").replace(/|<\/b>/g,"").replace(/ /g,"_"),w=new Date().toISOString().slice(0,10).replace(/-/g,""),s=new Date().toISOString().slice(11,19).replace(/:/g,"");window.title=`openbb_${_}_${w}_${s}`,E.layout.annotations!=null&&E.layout.annotations.forEach(function(i){if(i.text!=null&&i.text[0]=="/"){e.cmd_src=i.text,e.cmd_idx=E.layout.annotations.indexOf(i),i.text="";let r=E.layout.margin;e.old_margin={...r},r.t!=null&&r.t>40&&(r.t=40),E.cmd=="/stocks/candle"&&(r.r-=50)}}),E.data.forEach(function(i){if(i.name!=null){const r=i.name.length;i.name=i.name+" ",i.hoverlabel={namelength:r}}});let T=((t=(l=E.layout)==null?void 0:l.title)==null?void 0:t.text)||"Interactive Chart";return e.title=T,{data:E,date:new Date,globals:e,cmd:E.command_location,posthog:E.posthog,python_version:E.python_version,pywry_version:E.pywry_version,terminal_version:E.terminal_version,title:T}})(P);if(D){D.posthog.collect_logs&&!J&&ce({api_host:"https://app.posthog.com",autocapture:{css_selector_allowlist:[".ph-capture"]},capture_pageview:!1,loaded:function(w){const s=(D==null?void 0:D.log_id)||"";s!=""&&s!="REPLACE_ME"&&w.identify(s),w.onFeatureFlags(function(){w.isFeatureEnabled("record-pywry",{send_event:!1})||w.stopSessionRecording(),w.isFeatureEnabled("collect-logs-pywry",{send_event:!1})?w.has_opted_out_capturing()&&w.opt_in_capturing():w.opt_out_capturing()})}});const E={INFO:{command:D.cmd,title:D.title,date:D.date,python_version:D.python_version,pywry_version:D.pywry_version,terminal_version:D.terminal_version}},e=br(g9,{json:D.data,date:D.date,cmd:D.cmd,title:D.title,globals:D.globals,info:E});return D.posthog.collect_logs&&J?br(qT,{apiKey:"phc_vhssDAMod5qIplznQ75Kdgz4aB1qPFmeVmfEOZ4hkRw",options:J,children:e}):e}else return br("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ni("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[br("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),br("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})})}z8.render(br(s_.StrictMode,{children:br(v9,{})}),document.getElementById("root")); +`),e=new Blob([E],{type:"text/csv;charset=utf-8;"}),_=`${window.title}.csv`;try{const w=await Vw({filename:_});await Bp("Saving CSV"),Np(async function(){ty(e,_,w).then(async function(){await new Promise(s=>setTimeout(s,1500)),w||J(!0),await Bp("",!0)})},2)()}catch(w){console.error(w)}}function Bp(P,F){const J=window.document.getElementById("loading"),ce=window.document.getElementById("loading_text");return new Promise(Pe=>{F?J.classList.remove("show"):(ce.innerHTML=P,J.classList.add("show"));const D=setInterval(function(){(F?!J.classList.contains("show"):J.classList.contains("show"))&&(clearInterval(D),Pe(!0))},.01)})}const Np=(P,F)=>{let J;return function(){const ce=this,Pe=arguments;clearTimeout(J),J=setTimeout(()=>P.apply(ce,Pe),F)}},s9={yref:"paper",xref:"paper",x:1,y:0,text:"OpenBB Terminal",font_size:17,font_color:"gray",opacity:.5,xanchor:"right",yanchor:"bottom",yshift:-80,xshift:40};async function Vb(P,F,J=!1){const ce=document.getElementById("plotlyChart");J&&(ce.layout.annotations.push(s9),ce.globals.cmd_idx!==void 0&&ce.globals.cmd_src!==void 0&&(ce.layout.annotations[ce.globals.cmd_idx].text=ce.globals.cmd_src),Gs.relayout(ce,{"title.text":ce.globals.title,margin:ce.globals.old_margin})),J||(ce.globals.cmd_idx!==void 0&&ce.globals.cmd_src!==void 0&&(ce.layout.annotations[ce.globals.cmd_idx].text=""),ce.layout.annotations.splice(F,1),Gs.relayout(ce,{"title.text":"",margin:P}))}async function Hw(P,F,J){const ce=document.getElementById(P);if(["svg","pdf"].includes(J)){const Pe=document.getElementById("plotlyChart"),D=Pe.layout.margin,E=Pe.layout.annotations.length;await Vb(D,E,!0),Gs.downloadImage(Pe,{format:"svg",height:Pe.clientHeight,width:Pe.clientWidth,filename:window.title}),await Vb(D,E,!1),await Bp("",!0);return}Np(async function(){Uw.toBlob(ce).then(function(Pe){ty(Pe,F,null)})},2)()}async function Hb(P,F,J,ce){const Pe=document.getElementById(P),D=`${window.title}.png`;try{J(!0);const E=await Vw({filename:D,is_image:!0});let e="png";if(E!==null&&(e=E.name.split(".").pop()),await Bp(`Saving ${e.toUpperCase()}`),["svg","pdf"].includes(e)){await Hw(P,D,e),F(!1),J(!1),E||ce(!0);return}Np(async function(){Uw.toBlob(Pe).then(function(_){ty(_,D,E).then(async function(){await Bp("",!0),F(!1),J(!1),E||ce(!0)})})},2)()}catch(E){console.error(E),F(!1),J(!1)}J(!1)}function rc(P=!0){return new Promise(F=>{window.MODEBAR||(window.MODEBAR=window.document.getElementsByClassName("modebar-container")[0],window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`),window.MODEBAR&&(window.MODEBAR.style.cssText.includes("display: none")||!P?window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`:window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:none;`,F(!0))})}function l9({setModal:P,changeTheme:F,autoScaling:J,Loading:ce,changeColor:Pe,downloadFinished:D}){return Ku("ctrl+shift+t",()=>{P({name:"titleDialog"})},{preventDefault:!0}),Ku("ctrl+t",()=>{P({name:"textDialog"})},{preventDefault:!0}),Ku("ctrl+o",()=>{P({name:"overlayChart"})},{preventDefault:!0}),Ku(["ctrl+shift+h","ctrl+h"],()=>{rc()},{preventDefault:!0}),Ku("ctrl+e",()=>{Pe(!0)},{preventDefault:!0}),Ku("ctrl+shift+s",async()=>{P({name:"downloadCsv"}),await Ub(document.getElementById("plotlyChart"),D)},{preventDefault:!0}),Ku("ctrl+s",async()=>{rc(),Hb("MainChart",rc,ce,D)},{preventDefault:!0}),Ku("ctrl+w",()=>{window.close()},{preventDefault:!0}),{plotGlPixelRatio:1,scrollZoom:!0,responsive:!0,displaylogo:!1,displayModeBar:!0,modeBarButtonsToRemove:["lasso2d","select2d","downloadImage"],modeBarButtons:[[{name:"Download CSV (Ctrl+Shift+S)",icon:Pu.downloadCsv,click:async function(e){await Ub(e,D)}},{name:"Download Chart as Image (Ctrl+S)",icon:Pu.downloadImage,click:async function(){rc(),await Hb("MainChart",rc,ce,D)}}],[{name:"Edit Color (Ctrl+E)",icon:Pu.changeColor,click:function(){Pe(!0)}},"drawline","drawopenpath","drawcircle","drawrect","eraseshape"],[{name:"Overlay chart from CSV (Ctrl+O)",icon:Pu.plotCsv,click:function(){P({name:"overlayChart"})}},{name:"Add Text (Ctrl+T)",icon:Pu.addText,click:function(){P({name:"textDialog",data:{text:""}})}},{name:"Change Titles (Ctrl+Shift+T)",icon:Pu.changeTitle,click:function(){P({name:"titleDialog"})}},{name:"Change Theme",icon:Pu.sunIcon,click:function(){F(!0)}}],["hoverClosestCartesian","hoverCompareCartesian","toggleSpikelines"],[{name:"Auto Scale (Ctrl+Shift+A)",icon:Gs.Icons.autoscale,click:function(){J(!0)}},"zoomIn2d","zoomOut2d","autoScale2d","zoom2d","pan2d"]]}}async function u9(P,F){try{if(P["xaxis.range[0]"]!=null){const J=P["xaxis.range[0]"],ce=P["xaxis.range[1]"];let Pe={},D,E;const e=F.data.filter(s=>s.yaxis!=null),_=[...new Set(e.map(s=>s.yaxis||s.y!=null||s.type=="candlestick"))],w=s=>F.data.filter(T=>T.yaxis==s&&(T.y||T.type=="candlestick"));return _.forEach(s=>{if(typeof s!="string")return;let T="yaxis"+s.replace("y",""),y=[],f=[],l=F.layout[T].type=="log";w(s).forEach(r=>{let n=r.x;l=F.layout[T].type=="log";let o=r.y!=null?r.y:[],a=r.type=="candlestick"?r.low:[],u=r.type=="candlestick"?r.high:[];l&&(o=o.map(Math.log10),r.type=="candlestick"&&(a=r.low.map(Math.log10),u=r.high.map(Math.log10)));let p=n.map((c,b)=>{let d=null;return c>=J&&c<=ce&&(r.y!=null&&(d=o[b]),r.type=="candlestick"&&(y.push(a[b]),y.push(u[b]))),d});f=f.concat(p)}),f=f.filter(r=>r!=null&&r!=null),D=Math.min(...f),E=Math.max(...f),y.length>0&&(y=y.filter(r=>r!=null&&r!=null),D=Math.min(...y),E=Math.max(...y));let t=E,i=F.layout[T].fixedrange!=null&&F.layout[T].fixedrange==!0;if(D!=null&&E!=null){let r=E-D,n=.15;if(y.length>0&&(n=.3),D-=r*n,E+=r*n,i){if(F.layout[T].tickvals!=null){let a=t,u=-3,p=Math.round(a*.2,u),c=[2,5,6,7,8,9,10],b=[1,4,5,6,7,8,9];for(let x=0;xc[x]&&(u=-b[x],p=Math.round(a*.2,u));let d=[Math.floor(p),Math.floor(p*2),Math.floor(p*3),Math.floor(p*4)],v=[0,Math.floor(a*7)];Pe[T+".tickvals"]=d,Pe[T+".range"]=v,Pe[T+".tickformat"]=".2s";return}D=0,E=F.layout[T].range[1]}Pe[T+".range"]=[D,E]}}),Pe}}catch(J){console.log(`Error in AutoScaling: ${J}`)}return{}}async function c9({plotData:P,volumeBars:F,setMaximizePlot:J}){const ce=Object.keys(P.layout).filter(s=>s.startsWith("xaxis")).filter(s=>P.layout[s].showticklabels||P.layout[s].matches==null),Pe=P.data.filter(s=>{var T;return(T=s==null?void 0:s.name)==null?void 0:T.startsWith("Volume")});let D={},E=F||{old_nticks:{}};const e=window.innerWidth,_=window.innerHeight;let w=_>420&&e<920?8:_>420&&e<500?9:7;return e<750?(Pe.forEach(s=>{s.type=="bar"&&(s.opacity=1,s.marker.line.width=.09,F.yaxis==null&&(E.yaxis="yaxis"+s.yaxis.replace("y",""),D[E.yaxis+".tickfont.size"]=w,E.tickfont=P.layout[E.yaxis].tickfont||{},P.layout.margin.l-=40))}),ce.forEach(s=>{var T;((T=F.old_nticks)==null?void 0:T[s])==null&&(D[s+".nticks"]=6,E.old_nticks[s]=P.layout[s].nticks||10)}),J(!0),await rc()):window.MODEBAR.style.cssText.includes("display: none")&&(await rc(!1),J(!1),F.old_nticks!=null&&ce.forEach(s=>{F.old_nticks[s]!=null&&(D[s+".nticks"]=E.old_nticks[s],E.old_nticks[s]=void 0)}),F.yaxis!=null&&Pe.forEach(s=>{s.type=="bar"&&(s.opacity=.5,s.marker.line.width=.2,D[E.yaxis+".tickfont.size"]=E.tickfont.size+3,P.layout.margin.l+=40,E.yaxis=void 0)})),{volume_update:E,layout_update:D,plotData:P}}function f9({open:P,onColorChange:F}){const[J,ce]=Un.useState(!1);function Pe(D){F(D)}return P&&!J&&ce(!0),!P&&J&&ce(!1),Un.useEffect(()=>{if(J){let D=function(e){let _=0,w=0,s=0,T=0;document.getElementById(e.id+"_header")?document.getElementById(e.id+"_header").onmousedown=y:e.onmousedown=y;function y(t){t=t||window.event,t.preventDefault(),s=t.clientX,T=t.clientY,document.onmouseup=l,document.onmousemove=f}function f(t){t=t||window.event,t.preventDefault(),_=s-t.clientX,w=T-t.clientY,s=t.clientX,T=t.clientY,e.style.top=e.offsetTop-w+"px",e.style.left=e.offsetLeft-_+"px"}function l(){document.onmouseup=null,document.onmousemove=null}},E=document.getElementById("changecolor");E.style.display="block",E.style.width=null,D(E)}else document.getElementById("changecolor").style.display="none"},[J]),br("div",{id:"changecolor",children:br("div",{id:"changecolor_header",children:br("input",{type:"color",id:"picked_color",value:"#00ACFF",onChange:D=>{let E=D.target.value;Pe(E)}})})})}function qw(P){var F,J,ce="";if(typeof P=="string"||typeof P=="number")ce+=P;else if(typeof P=="object")if(Array.isArray(P))for(F=0;F{ce.preventDefault(),window.pywry.open_file(J)},children:J})]})})}),br("div",{style:{float:"right",marginTop:20},children:br("button",{className:"_btn",style:{padding:"8px 16px",width:"100%"},onClick:F,children:"Close"})})]})})}const d9=QT(ZT);function g9({json:P,date:F,cmd:J,title:ce,globals:Pe,info:D}){var se,fe;const E=GT();Un.useEffect(()=>{E&&E.capture("chart",D)},[]),delete P.layout.width,delete P.layout.height,(fe=(se=P.layout)==null?void 0:se.title)!=null&&fe.text&&(P.layout.title.text="");const[e,_]=Un.useState({}),[w,s]=Un.useState(!1),[T,y]=Un.useState(ce),[f,l]=Un.useState({}),[t,i]=Un.useState(!1),[r,n]=Un.useState({name:""}),[o,a]=Un.useState(!1),[u,p]=Un.useState(null),[c,b]=Un.useState({old_nticks:{}}),[d,v]=Un.useState(!1),[x,g]=Un.useState(!1),[m,k]=Un.useState(P),[h,M]=Un.useState([]),[A,C]=Un.useState(!1),[L,O]=Un.useState(!0),[I,R]=Un.useState(!1),[U,B]=Un.useState(!1),[G,N]=Un.useState(!1),[j,V]=Un.useState({}),[H,ee]=Un.useState([]),Q=()=>n({name:""});function X(ye){var de,he,xe,Re,we;console.log("onDeleteAnnotation",ye);const pe=(he=(de=m==null?void 0:m.layout)==null?void 0:de.annotations)==null?void 0:he.findIndex(Ae=>Ae.text===ye.text);console.log("index",pe),pe>-1&&((Re=(xe=m==null?void 0:m.layout)==null?void 0:xe.annotations)==null||Re.splice(pe,1),k({...m}),M((we=m==null?void 0:m.layout)==null?void 0:we.annotations))}function Y(ye){U7({plotData:m,popupData:ye,setPlotData:k,setModal:n,setOnAnnotationClick:V,setAnnotations:M,onAnnotationClick:j,ohlcAnnotation:H,setOhlcAnnotation:ee,annotations:h,plotDiv:u})}Un.useEffect(()=>{x&&(n({name:"downloadFinished"}),g(!1))},[x]),Un.useEffect(()=>{f&&Object.keys(f).length>0&&(Object.keys(f).forEach(ye=>{m.layout[ye].title={...m.layout[ye].title||{},text:f[ye]},m.layout[ye].showticklabels=!0}),l({}))},[f]);function K(ye){let pe=u.layout.shapes;if(!pe||pe.length==0)return;let de=pe[pe.length-1];de.line.color=ye,Gs.update(u,{},{shapes:pe})}function te(ye,pe=!1){let de=e[ye]||document.querySelector(`[data-title="${ye}"]`);pe?(de.style.border="transparent",de.style.boxShadow="none"):(de.style.border="1px solid rgba(0, 151, 222, 1.0)",de.style.borderRadius="5px",de.style.borderpadding="5px",de.style.boxShadow="0 0 5px rgba(0, 151, 222, 1.0)"),_({...e,[ye]:de})}function ae(){let ye="Auto Scale (Ctrl+Shift+A)",pe=e[ye]||document.querySelector(`[data-title="${ye}"]`),de=!0;pe.style.border=="transparent"?(de=!1,u.on("plotly_relayout",Np(async function(he){if(he["xaxis.range[0]"]==null)return;let xe=await u9(he,u);Gs.update(u,{},xe)},100))):u.removeAllListeners("plotly_relayout"),te(ye,de)}function oe(){let ye="Edit Color (Ctrl+E)",pe=e[ye]||document.querySelector(`[data-title="${ye}"]`),de=!0;pe.style.border=="transparent"&&(de=!1),N(!de),te(ye,de)}return Un.useEffect(()=>{I&&(console.log("activateAutoScale",!I),ae(),R(!1))},[I]),Un.useEffect(()=>{U&&(oe(),B(!1))},[U]),Un.useEffect(()=>{if(A)try{console.log("changeTheme",A);const ye=m==null?void 0:m.data.filter(xe=>{var Re;return(Re=xe==null?void 0:xe.name)==null?void 0:Re.startsWith("Volume")});let pe=!L;window.document.body.style.backgroundColor=pe?"#000":"#fff",m.layout.font={...m.layout.font||{},color:pe?"#fff":"#000"};const de=pe?Pu.sunIcon:Pu.moonIcon;document.querySelector('[data-title="Change Theme"]').getElementsByTagName("path")[0].setAttribute("d",de.path),document.querySelector('[data-title="Change Theme"]').getElementsByTagName("svg")[0].setAttribute("viewBox",de.viewBox);const he={"#e4003a":"#c80000","#00ACFF":"#009600","#009600":"#00ACFF","#c80000":"#e4003a"};ye.forEach(xe=>{xe.type=="bar"&&(xe.marker.color=xe.marker.color.map(Re=>he[Re]||Re))}),m.layout.template=pe?ek:tk,k({...m}),Gs.react(u,m.data,m.layout),O(pe),C(!1)}catch(ye){console.log("error",ye)}},[A]),Un.useEffect(()=>{if(t){O(!0),R(!1);const ye=["Download CSV","Download Chart as Image","Overlay chart from CSV","Add Text","Change Titles","Auto Scale (Ctrl+Shift+A)","Reset Axes"],pe=document.querySelector('[data-title="Autoscale"]');pe&&(pe.getElementsByTagName("path")[0].setAttribute("d",Gs.Icons.home.path),pe.setAttribute("data-title","Reset Axes")),window.MODEBAR=document.getElementsByClassName("modebar-container")[0];const de=window.MODEBAR.getElementsByClassName("modebar-btn");if(window.MODEBAR.style.cssText=`${window.MODEBAR.style.cssText}; display:flex;`,de){let he={};for(let xe=0;xe0&&(k(Re),b(we),Gs.relayout(u,xe))})}},[t]),ni("div",{className:"relative h-full",children:[o&&br("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ni("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[br("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),br("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})}),ni("div",{id:"loading",className:"saving",children:[br("div",{id:"loading_text",className:"loading_text"}),br("div",{id:"loader",className:"loader"})]}),br(D7,{addOverlay:ye=>{console.log(ye),m.layout.showlegend=!0,k(ye),i(!1)},plotlyData:m,setLoading:a,open:r.name==="overlayChart",close:Q}),br(B7,{updateTitle:ye=>y(ye),updateAxesTitles:ye=>l(ye),defaultTitle:T,plotlyData:m,open:r.name==="titleDialog",close:Q}),br(N7,{popupData:r.name==="textDialog"?r==null?void 0:r.data:null,open:r.name==="textDialog",close:Q,addAnnotation:ye=>Y(ye),deleteAnnotation:ye=>X(ye)}),br(f9,{open:G,onColorChange:K}),br(p9,{open:r.name==="downloadFinished",close:Q}),ni("div",{className:"relative h-full",id:"MainChart",children:[ni("div",{className:"_header relative gap-4 py-2 text-center text-xs flex items-center justify-between px-4 text-white",children:[br("div",{className:"w-1/3",children:br("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"40",fill:"none",viewBox:"0 0 64 40",children:br("path",{fill:"#fff",d:"M61.283 3.965H33.608v27.757h25.699V19.826H37.561v-3.965H63.26V3.965h-1.977zM39.538 23.792h15.815v3.965H37.561v-3.965h1.977zM59.306 9.913v1.983H37.561V7.931h21.745v1.982zM33.606 0h-3.954v3.965H33.606V0zM25.7 3.966H0V15.86h25.7v3.965H3.953v11.896h25.7V3.966h-3.955zm0 21.808v1.983H7.907v-3.965h17.791v1.982zm0-15.86v1.982H3.953V7.931h21.745v1.982zM37.039 35.693v2.952l-.246-.246-.245-.245-.245-.247-.245-.246-.246-.246-.245-.245-.245-.247-.247-.246-.245-.246-.245-.246-.245-.246-.246-.246h-.49v3.936h.49v-3.198l.246.246.245.246.245.246.245.246.246.246.246.246.245.247.246.245.245.246.245.247.245.246.246.245.245.246h.245v-3.936h-.49zM44.938 37.17h-.491v-1.477h-2.944v3.937h3.93v-2.46h-.495zm-2.944-.246v-.739h1.962v.984h-1.962v-.245zm2.944.984v1.23h-2.944V37.66h2.944v.247zM52.835 37.17h-.49v-1.477h-2.946v3.937h3.925v-2.46h-.489zm-2.944-.246v-.739h1.963v.984h-1.965l.002-.245zm2.944.984v1.23H49.89V37.66h2.946v.247zM29.174 35.693H25.739v3.936H29.663v-.491H26.229v-.984h2.943v-.493H26.229v-1.476h3.434v-.492h-.489zM13.37 35.693H9.934v3.937h3.925v-3.937h-.49zm0 .738v2.709h-2.945v-2.955h2.943l.001.246zM21.276 35.693h-3.435v3.937h.491v-1.476h3.434v-2.461h-.49zm0 .738v1.23h-2.944v-1.476h2.944v.246z"})})}),br("p",{className:"font-bold w-1/3 flex flex-col gap-0.5 items-center",children:T}),ni("p",{className:"w-1/3 text-right text-xs",children:[new Intl.DateTimeFormat("en-GB",{dateStyle:"full",timeStyle:"long"}).format(F).replace(/:\d\d /," "),br("br",{}),br("span",{className:"text-grey-400",children:J})]})]}),br("div",{className:h9("w-full sm:pb-12",{"h-[calc(100%-10px)]":d,"h-[calc(100%-50px)]":!d}),children:br(d9,{onInitialized:()=>{if(!u){const ye=document.getElementById("plotlyChart");console.log("plot",ye),ye&&p(ye),ye.globals=Pe}t||i(!0)},className:"w-full h-full",divId:"plotlyChart",data:m.data,layout:m.layout,config:l9({setModal:n,changeTheme:C,autoScaling:R,Loading:a,changeColor:B,downloadFinished:g})})})]})]})}function v9(){const[P,F]=Un.useState(null),[J,ce]=Un.useState({});Un.useEffect(()=>{{const E=setInterval(()=>{if(window.json_data){const e=window.json_data;console.log(e),F(e),clearInterval(E)}},100);return()=>clearInterval(E)}},[]);const D=(E=>{var y,f,l,t;if(!E)return null;let e={added_traces:[],csv_yaxis_id:null,cmd_src_idx:null,cmd_idx:null,cmd_src:"",old_margin:null,title:""},_=(f=(y=E.layout)==null?void 0:y.title)==null?void 0:f.text.replace(/ -/g,"").replace(/-/g,"").replace(/|<\/b>/g,"").replace(/ /g,"_"),w=new Date().toISOString().slice(0,10).replace(/-/g,""),s=new Date().toISOString().slice(11,19).replace(/:/g,"");window.title=`openbb_${_}_${w}_${s}`,E.layout.annotations!=null&&E.layout.annotations.forEach(function(i){if(i.text!=null&&i.text[0]=="/"){e.cmd_src=i.text,e.cmd_idx=E.layout.annotations.indexOf(i),i.text="";let r=E.layout.margin;e.old_margin={...r},r.t!=null&&r.t>40&&(r.t=40),E.cmd=="/stocks/candle"&&(r.r-=50)}}),E.data.forEach(function(i){if(i.name!=null){const r=i.name.length;i.name=i.name+" ",i.hoverlabel={namelength:r}}});let T=((t=(l=E.layout)==null?void 0:l.title)==null?void 0:t.text)||"Interactive Chart";return e.title=T,{data:E,date:new Date,globals:e,cmd:E.command_location,posthog:E.posthog,python_version:E.python_version,pywry_version:E.pywry_version,terminal_version:E.terminal_version,title:T}})(P);if(D){D.posthog.collect_logs&&!J&&ce({api_host:"https://app.posthog.com",autocapture:{css_selector_allowlist:[".ph-capture"]},capture_pageview:!1,loaded:function(w){const s=(D==null?void 0:D.log_id)||"";s!=""&&s!="REPLACE_ME"&&w.identify(s),w.onFeatureFlags(function(){w.isFeatureEnabled("record-pywry",{send_event:!1})||w.stopSessionRecording(),w.isFeatureEnabled("collect-logs-pywry",{send_event:!1})?w.has_opted_out_capturing()&&w.opt_in_capturing():w.opt_out_capturing()})}});const E={INFO:{command:D.cmd,title:D.title,date:D.date,python_version:D.python_version,pywry_version:D.pywry_version,terminal_version:D.terminal_version}},e=br(g9,{json:D.data,date:D.date,cmd:D.cmd,title:D.title,globals:D.globals,info:E});return D.posthog.collect_logs&&J?br(qT,{apiKey:"phc_vhssDAMod5qIplznQ75Kdgz4aB1qPFmeVmfEOZ4hkRw",options:J,children:e}):e}else return br("div",{className:"absolute inset-0 flex items-center justify-center z-[100]",children:ni("svg",{className:"animate-spin h-20 w-20 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[br("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),br("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})})}z8.render(br(s_.StrictMode,{children:br(v9,{})}),document.getElementById("root"));