@deephaven/embed-chart 0.37.4-relative-base.7 → 0.38.1-beta.0

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.
@@ -1,2 +1,2 @@
1
- var ge=Object.defineProperty;var me=(E,s,e)=>s in E?ge(E,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):E[s]=e;var d=(E,s,e)=>(me(E,typeof s!="symbol"?s+"":s,e),e);import{H as he,A as B,G as ce,I as fe,J as j,C as X,K as Ee,L as Y}from"./vendor-b7e5da9f.js";import{L as se,d as ye,v as Se,a as Te,b as De}from"./index-26fbf48a.js";import{s as a,a as q,T as oe,D as Ae,F as re,b as Fe,u as be,C as Ne}from"./useConnection-d9df6d19.js";import{P as te,b as xe,h as we,p as Pe,o as Le,s as Ie,t as Oe,c as ne}from"./plotly-c2893d76.js";import"./helpers-042e6b4d.js";te.register([xe,we,Pe,Le,Ie,Oe]);const Me=typeof ne=="function"?ne(te):ne.default(te),I=class{constructor(){d(this,"listeners");d(this,"formatter");d(this,"rect");d(this,"isDownsamplingDisabled");d(this,"title");this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(s){}close(){}setFormatter(s){this.formatter=s}setDownsamplingDisabled(s){this.isDownsamplingDisabled=s}setDimensions(s){this.rect=s}setTitle(s){this.title=s}subscribe(s){this.listeners.push(s)}unsubscribe(s){this.listeners=this.listeners.filter(e=>e!==s)}fireEvent(s){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](s)}fireUpdate(s){this.fireEvent(new CustomEvent(I.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(I.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(I.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(I.EVENT_LOADFINISHED))}};let w=I;d(w,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),d(w,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),d(w,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),d(w,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),d(w,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),d(w,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),d(w,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),d(w,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const C=w,Re="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Ce="#403e41",ve="#5b5a5c",ke="#c0bfbf",_e="#4878ea",Ve="rgba(91, 90, 92, 0.7)",D={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Re,gridcolor:Ce,linecolor:ve,zerolinecolor:ke,activecolor:_e,rangebgcolor:Ve,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},O=Object.freeze({paper_bgcolor:D["paper-bgcolor"],plot_bgcolor:D["plot-bgcolor"],title_color:D["title-color"],colorway:D.colorway,gridcolor:D.gridcolor,linecolor:D.linecolor,zerolinecolor:D.zerolinecolor,activecolor:D.activecolor,rangebgcolor:D.rangebgcolor,area_color:D["area-color"],trend_color:D["trend-color"],line_color:D["line-color"],error_band_line_color:D["error-band-line-color"],error_band_fill_color:D["error-band-fill-color"],ohlc_increasing:D["ohlc-increasing"],ohlc_decreasing:D["ohlc-decreasing"]}),K=se.module("ChartUtils"),k=Object.freeze(a.calendar.DayOfWeek.values()),ue="io.deephaven.time.DateTime",He=36e5,$e=1e6;function Ue(E){return E.asDate!==void 0}function Be(E){return E.asNumber!==void 0}function de(E){return E.dhTimeZone!==void 0}function Xe(E){return E!=null&&E.range!=null&&(E.autorange===!1||E.autorange===void 0)}const c=class{static getPlotlyChartType(s,e){switch(s){case a.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case a.plot.SeriesPlotStyle.LINE:return"scatter";case a.plot.SeriesPlotStyle.BAR:case a.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case a.plot.SeriesPlotStyle.PIE:return"pie";case a.plot.SeriesPlotStyle.TREEMAP:return"treemap";case a.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case a.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(s,e,t){const i=new Set;switch(s){case a.plot.SeriesPlotStyle.SCATTER:(e??!1)&&i.add(c.MODE_LINES),(t??!0)&&i.add(c.MODE_MARKERS);break;case a.plot.SeriesPlotStyle.LINE:(e??!0)&&i.add(c.MODE_LINES),(t??!1)&&i.add(c.MODE_MARKERS);break}return i.size>0?[...i].join("+"):void 0}static getPlotlyProperty(s,e){switch(s){case a.plot.SeriesPlotStyle.PIE:switch(e){case a.plot.SourceType.X:return"labels";case a.plot.SourceType.Y:return"values"}break;case a.plot.SeriesPlotStyle.OHLC:switch(e){case a.plot.SourceType.TIME:return"x"}break;case a.plot.SeriesPlotStyle.TREEMAP:switch(e){case a.plot.SourceType.X:return"ids";case a.plot.SourceType.Y:return"values";case a.plot.SourceType.LABEL:return"labels";case a.plot.SourceType.PARENT:return"parents";case a.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case a.plot.SourceType.X:return"x";case a.plot.SourceType.Y:return"y";case a.plot.SourceType.Z:return"z";case a.plot.SourceType.X_LOW:return"xLow";case a.plot.SourceType.X_HIGH:return"xHigh";case a.plot.SourceType.Y_LOW:return"yLow";case a.plot.SourceType.Y_HIGH:return"yHigh";case a.plot.SourceType.TIME:return"time";case a.plot.SourceType.OPEN:return"open";case a.plot.SourceType.HIGH:return"high";case a.plot.SourceType.LOW:return"low";case a.plot.SourceType.CLOSE:return"close";case a.plot.SourceType.SHAPE:return"shape";case a.plot.SourceType.SIZE:return"size";case a.plot.SourceType.LABEL:return"label";case a.plot.SourceType.COLOR:return"color";case a.plot.SourceType.PARENT:return"parent";case a.plot.SourceType.HOVER_TEXT:return"hovertext";case a.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(s){var t,i;const{sources:e}=s;return e.length===2&&((i=(t=e[0])==null?void 0:t.axis)==null?void 0:i.type)===a.plot.AxisType.Y?c.ORIENTATION.HORIZONTAL:c.ORIENTATION.VERTICAL}static getPlotlyErrorBars(s,e,t){const i=t.map((o,n)=>o-s[n]),r=e.map((o,n)=>s[n]-o);return{type:"data",symmetric:!1,array:i,arrayminus:r}}static getPlotlyDateFormat(s,e,t){const i=t==null?void 0:t.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let r;const o=s==null?void 0:s.getColumnTypeFormatter(e);return o!=null&&de(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(r=a.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:i,ticksuffix:r,automargin:!0}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const r=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);q(r);const[,o,n,u,,l,p,h,g,m]=r,f=u.replace(",","").length,b=n.indexOf(",")>=0||u.indexOf(",")>=0?",":"",S=h!=null&&h!==""?"e":"f",P=g!==""?g:S,N=l.length+p.length,x=`0${f}${b}.${N}${P}`,M=c.convertNumberPrefix(o),R=c.convertNumberPrefix(m);return{tickformat:x,tickprefix:M,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(s,e=null){const{axis:t,columnType:i}=s,{formatPattern:r}=t;let o=null;return oe.isDateType(i)?(o=c.getPlotlyDateFormat(e,i,r),o=c.addTickSpacing(o,t,!0)):oe.isNumberType(i)&&(o=c.getPlotlyNumberFormat(e,i,r),o=c.addTickSpacing(o,t,!1)),t.formatType===a.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:i}=e;if(i>0){const r=s||{};let o=i;return t&&(o=i/$e),e.log&&(o=Math.log(o)),r.tickmode="linear",r.dtick=o,r}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const i=s.series[t];for(let r=0;r<i.sources.length;r+=1){const o=i.sources[r];if(o.axis===e)return o}}return null}static getSeriesVisibility(s,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(s)?"legendonly":!0}static getHiddenLabels(s){return s!=null&&s.hiddenSeries?[...s.hiddenSeries]:[]}static makeSeriesData(s,e,t,i,r=c.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:r,showlegend:i??void 0}}static makeSeriesDataFromSeries(s,e,t,i=null,r=O){const{name:o,isLinesVisible:n,isShapesVisible:u,plotStyle:l,lineColor:p,shapeColor:h,sources:g,shape:m,shapeSize:f}=s,F=g.some(v=>{var x;return(x=v.axis)==null?void 0:x.businessCalendar}),b=c.getChartType(l,F),S=c.getPlotlyChartMode(l,n??void 0,u??void 0),P=c.getPlotlySeriesOrientation(s),N=c.makeSeriesData(b,S,o,i,P);return c.addSourcesToSeriesData(N,l,g,e),c.addStylingToSeriesData(N,l,r,p,h,m,f,t),N}static addSourcesToSeriesData(s,e,t,i){const r=s;for(let o=0;o<t.length;o+=1){const n=t[o],{axis:u,type:l}=n,p=c.getPlotlyProperty(e,l);he(r,p,[]);const h=u!=null?c.getAxisPropertyName(u.type):null;if(h!=null){const g=i.get(u.type);if(g){const m=g.indexOf(u),f=m>0?`${m+1}`:"";r[`${h}axis`]=`${h}${f}`}}}}static addStylingToSeriesData(s,e,t=O,i=null,r=null,o=null,n=null,u=null){const l=s;if(l.marker={line:{}},l.line={width:1},e===a.plot.SeriesPlotStyle.AREA?l.fill="tozeroy":e===a.plot.SeriesPlotStyle.STACKED_AREA?l.stackgroup="stack":e===a.plot.SeriesPlotStyle.STEP?l.line.shape="hv":e===a.plot.SeriesPlotStyle.HISTOGRAM?(l.width=[],l.marker.line!==void 0&&Object.assign(l.marker.line,{color:t.paper_bgcolor,width:1})):e===a.plot.SeriesPlotStyle.OHLC?(l.increasing={line:{color:t.ohlc_increasing}},l.decreasing={line:{color:t.ohlc_decreasing}}):e===a.plot.SeriesPlotStyle.PIE?(l.textinfo="label+percent",l.outsidetextfont={color:t.title_color}):e===a.plot.SeriesPlotStyle.TREEMAP&&(l.hoverinfo="text",l.textinfo="label+text",l.tiling={packing:"squarify",pad:0},l.textposition="middle center",l.outsidetextfont={color:t.title_color}),i!=null&&(e===a.plot.SeriesPlotStyle.BAR?l.marker.color=i:l.line.color=i),r!=null&&(l.marker.color=r),o!=null&&o.length>0)try{l.marker.symbol=c.getMarkerSymbol(o)}catch(p){K.warn("Unable to handle shape",o,":",p)}n!=null&&(l.marker.size=n*c.DEFAULT_MARKER_SIZE),u!=null&&e!==a.plot.SeriesPlotStyle.PIE&&(l.visible=u)}static getMarkerSymbol(s){switch(s){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${s}`)}}static getAxisFormats(s,e){const t=new Map,i={tickformat:null,ticksuffix:null},r=c.getAllAxes(s),o=c.groupArray(r,"type"),{charts:n}=s;for(let u=0;u<n.length;u+=1){const l=n[u];for(let p=0;p<l.series.length;p+=1){const h=l.series[p],{sources:g}=h,m=g.filter(f=>f.axis);for(let f=0;f<m.length;f+=1){const F=m[f],{axis:b}=F,{type:S}=b,P=o.get(S);q(P);const N=P.indexOf(b),v=c.getAxisPropertyName(S);if(v!=null){const x=c.getAxisLayoutProperty(v,N);if(t.has(x))K.debug(`${x} already added.`);else{K.debug(`Adding ${x} to axisFormats.`);const M=c.getPlotlyAxisFormat(F,e);if(M===null)t.set(x,i);else{t.set(x,M);const{businessCalendar:R}=b;if(R!=null){const L=[],{businessPeriods:ie,businessDays:H,holidays:$,timeZone:Z}=R,W=e==null?void 0:e.getColumnTypeFormatter(ue);let U;de(W)&&(U=W.dhTimeZone);const G=U?(Z.standardOffset-U.standardOffset)/60:0;$.length>0&&L.push(...c.createRangeBreakValuesFromHolidays($,Z,U)),ie.forEach(V=>L.push({pattern:"hour",bounds:[c.periodToDecimal(V.close)+G,c.periodToDecimal(V.open)+G]})),H.length<k.length&&c.createBoundsFromDays(H).forEach(V=>L.push({pattern:"day of week",bounds:V})),M.rangebreaks=L}if(t.size===l.axes.length)return t}}}}}}return t}static getChartType(s,e){switch(s){case a.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return c.getPlotlyChartType(s,e)}}static getAxisPropertyName(s){switch(s){case a.plot.AxisType.X:return"x";case a.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(s){switch(s){case a.plot.AxisPosition.BOTTOM:return"bottom";case a.plot.AxisPosition.TOP:return"top";case a.plot.AxisPosition.LEFT:return"left";case a.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(s){return s.charts.reduce((e,t)=>[...e,...t.axes],[])}static getChartForSeries(s,e){const{charts:t}=s;for(let i=0;i<t.length;i+=1){const r=t[i];for(let o=0;o<r.series.length;o+=1)if(e===r.series[o])return r}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(i=>i.indexOf("axis")>=0);for(let i=0;i<t.length;i+=1){const r=t[i],o=s[r];Xe(o)&&(e[r]=[...o.range])}return e}static updateFigureAxes(s,e,t,i=0,r=0,o=O){const n=s,u=c.getAllAxes(e);for(let l=0;l<e.charts.length;l+=1){const p=e.charts[l],h=t==null?void 0:t(p),g=c.getChartBounds(e,p,i,r);c.updateLayoutAxes(n,p.axes,u,i,r,g,h,o)}c.removeStaleAxes(n,u)}static getChartBounds(s,e,t,i){const{cols:r,rows:o}=s,{column:n,colspan:u,row:l,rowspan:p}=e,h=n+u,g=l+p,m=1/r,f=1/o,F=c.AXIS_SIZE_PX/t,b=c.AXIS_SIZE_PX/i,S={bottom:(o-g)*f+(g<o?b/2:0),top:(o-l)*f-(l>0?b/2:0),left:n*m+(n>0?F/2:0),right:h*m-(h<r?F/2:0)};return(c.groupArray(e.axes,"position").get(a.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?S.right-=(S.right-S.left)*Math.max(0,Math.min(c.LEGEND_WIDTH_PX/t,c.MAX_LEGEND_SIZE)):S.right-=(S.right-S.left)*c.DEFAULT_AXIS_SIZE),S}static updateLayoutAxes(s,e,t,i=0,r=0,o={left:0,top:0,right:1,bottom:1},n,u=O){const l=i>0?Math.max(c.MIN_AXIS_SIZE,Math.min(c.AXIS_SIZE_PX/r,c.MAX_AXIS_SIZE)):c.DEFAULT_AXIS_SIZE,p=r>0?Math.max(c.MIN_AXIS_SIZE,Math.min(c.AXIS_SIZE_PX/i,c.MAX_AXIS_SIZE)):c.DEFAULT_AXIS_SIZE,h=s,g=c.groupArray(e,"position"),m=c.groupArray(e,"type"),f=[...m.keys()],F=c.groupArray(t,"type");for(let b=0;b<f.length;b+=1){const S=f[b],P=c.getAxisPropertyName(S);if(P!=null){const N=m.get(S),v=F.get(S),M=S===a.plot.AxisType.Y?r:i;q(N),q(v);for(let R=0;R<N.length;R+=1){const L=N[R],ie=v.indexOf(L),H=c.getAxisLayoutProperty(P,ie);h[H]==null&&(h[H]=c.makeLayoutAxis(S,u));const $=h[H];if($!=null){c.updateLayoutAxis($,L,R,g,l,p,o);const{range:Z,autorange:W}=$;if(n!=null&&Z!==void 0&&(W===void 0||W===!1)){const U=n(L),[G,V]=U(Z);K.debug("Setting downsample range",M,G,V),L.range(M,G,V)}else L.range(M)}}}}}static removeStaleAxes(s,e){const t=s,i=c.groupArray(e,"type"),r=[...i.keys()];for(let o=0;o<r.length;o+=1){const n=r[o],u=i.get(n);q(u);let l=u.length;const p=c.getAxisPropertyName(n);if(p!=null){let h=c.getAxisLayoutProperty(p,l);for(;t[h]!=null;)delete t[h],l+=1,h=c.getAxisLayoutProperty(p,l)}}}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static updateLayoutAxis(s,e,t,i,r,o,n){const l=e.type===a.plot.AxisType.Y?o:r,p=s,h=e.label??"";if(p.title!==void 0&&typeof p.title!="string"?p.title.text=h:p.title={text:h},e.log&&(p.type="log"),p.side=c.getAxisSide(e.position),t>0){p.overlaying=c.getAxisPropertyName(e.type)??void 0;const g=i.get(e.position)??[],m=g.indexOf(e);m>0&&(p.anchor="free",e.position===a.plot.AxisPosition.RIGHT?p.position=n.right+(m-g.length+1)*l:e.position===a.plot.AxisPosition.TOP?p.position=n.top+(m-g.length+1)*l:e.position===a.plot.AxisPosition.BOTTOM?p.position=n.bottom+(g.length-m+1)*l:e.position===a.plot.AxisPosition.LEFT&&(p.position=n.left+(g.length-m+1)*l))}else if(e.type===a.plot.AxisType.X){const g=i.get(a.plot.AxisPosition.LEFT)||[],m=i.get(a.plot.AxisPosition.RIGHT)||[],f=Math.max(n.left,n.left+(g.length-1)*o),F=Math.min(n.right-(m.length-1)*o,n.right);p.domain=[f,F]}else if(e.type===a.plot.AxisType.Y){const g=i.get(a.plot.AxisPosition.BOTTOM)||[],m=i.get(a.plot.AxisPosition.TOP)||[],f=Math.max(n.bottom,n.bottom+(g.length-1)*r),F=Math.min(n.top-(m.length-1)*r,n.top);p.domain=[f,F]}}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(s){const e=s.map(o=>k.indexOf(o)),t=k.filter(o=>!s.includes(o)).map(o=>k.indexOf(o)),i=new Set;t.forEach(o=>{for(let n=o+1;n<o+k.length;n+=1){const u=n%k.length;if(e.includes(u)){i.add(u);break}}});const r=[];return i.forEach(o=>{for(let n=o-1;n>o-k.length;n-=1){const u=n<0?n+k.length:n;if(e.includes(u)){const l=(u+1)%7;r.push([l,o]);break}}}),r}static createRangeBreakValuesFromHolidays(s,e,t){const i=[],r=[];return s.forEach(o=>{o.businessPeriods.length>0?r.push(...c.createPartialHoliday(o,e,t)):i.push(c.createFullHoliday(o,e,t))}),[{values:i},...r]}static createFullHoliday(s,e,t){return c.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}static createPartialHoliday(s,e,t){const i=s.date.toString(),r=["00:00"];s.businessPeriods.forEach(n=>{r.push(n.open),r.push(n.close)}),r.push("24:00");const o=[];for(let n=0;n<r.length;n+=2){const u=r[n],l=r[n+1];if(u!==l){const p=[c.adjustDateForTimeZone(`${i} ${u}:00.000000`,e,t)],h=He*(c.periodToDecimal(l)-c.periodToDecimal(u));o.push({values:p,dvalue:h})}}return o}static adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?c.unwrapValue(c.wrapValue(s,ue,e),t):s}static groupArray(s,e){return s.reduce((t,i)=>{const r=i[e],o=t.get(r)??[];return o.push(i),t.set(r,o),t},new Map)}static unwrapValue(s,e){if(s!=null){if(Ue(s))return a.i18n.DateTimeFormat.format(c.DATE_FORMAT,s,e);if(Be(s))return s.asNumber()}return s}static wrapValue(s,e,t=null){if(oe.isDateType(e)&&typeof s=="string"){const i=s,r=c.DATE_FORMAT.substr(0,s.length),o=a.i18n.DateTimeFormat.parse(r,i);if(!t)return o;const n=`${r} Z`,u=a.i18n.DateTimeFormat.format("Z",o,t),l=a.i18n.DateTimeFormat.parse(n,`${i} ${u}`),p=a.i18n.DateTimeFormat.format("Z",l,t);return a.i18n.DateTimeFormat.parse(n,`${i} ${p}`)}return s}static makeLayoutAxis(s,e=O){const t={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return s===a.plot.AxisType.X?Object.assign(t,{showgrid:!0}):s===a.plot.AxisType.Y&&Object.assign(t,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),t}static getColorwayFromTheme(s=O){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):K.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static makeDefaultLayout(s=O){const e={...s,autosize:!0,colorway:c.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:s.title_color},yanchor:"top",pad:{...c.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...c.DEFAULT_MARGIN},xaxis:c.makeLayoutAxis(a.plot.AxisType.X,s),yaxis:c.makeLayoutAxis(a.plot.AxisType.Y,s)};return e.datarevision=0,e}static hydrateSettings(s){return{...s,type:s.type!=null?a.plot.SeriesPlotStyle[s.type]:void 0}}static titleFromSettings(s){const{series:e,xAxis:t,title:i=`${(e??[]).join(", ")} by ${t}`}=s;return i}static makeFigureSettings(s,e){const{series:t,xAxis:i,type:r}=s,o=c.titleFromSettings(s),n={formatType:`${a.plot.AxisFormatType.NUMBER}`,type:`${a.plot.AxisType.X}`,position:`${a.plot.AxisPosition.BOTTOM}`},u={formatType:`${a.plot.AxisFormatType.NUMBER}`,type:`${a.plot.AxisType.Y}`,position:`${a.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${a.plot.ChartType.XY}`,axes:[n,u],series:(t??[]).map(l=>({plotStyle:`${r}`,name:l,dataSources:[{type:`${a.plot.SourceType.X}`,columnName:i??"",axis:n,table:e},{type:`${a.plot.SourceType.Y}`,columnName:l,axis:u,table:e}]}))}],title:o}}};let T=c;d(T,"DEFAULT_AXIS_SIZE",.15),d(T,"MIN_AXIS_SIZE",.025),d(T,"MAX_AXIS_SIZE",.2),d(T,"AXIS_SIZE_PX",75),d(T,"LEGEND_WIDTH_PX",50),d(T,"MAX_LEGEND_SIZE",.25),d(T,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),d(T,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),d(T,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),d(T,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),d(T,"SUBTITLE_LINE_HEIGHT",25),d(T,"DEFAULT_MARKER_SIZE",6),d(T,"MODE_MARKERS","markers"),d(T,"MODE_LINES","lines");const y=T;const _=se.module("Chart"),z=class extends B.Component{constructor(e){super(e);d(this,"currentSeries");d(this,"plot");d(this,"plotWrapper");d(this,"columnFormats");d(this,"dateTimeFormatterOptions");d(this,"decimalFormatOptions");d(this,"integerFormatOptions");d(this,"rect");d(this,"ranges");d(this,"isSubscribed");d(this,"isLoadedFired");d(this,"getCachedConfig",fe((e,t,i,r)=>{const o=[],n=Boolean(e);if(n&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:z.convertIcon(ye),attr:"fill-warning"}),t||i||r||n){const u=z.downsampleButtonTitle(i,r),l=z.downsampleButtonAttr(i,r),p=i?Se:Te;o.push({name:u,icon:z.convertIcon(p),click:this.handleDownsampleClick,attr:l})}return{displaylogo:!1,displayModeBar:i||n?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}));this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=ce.createRef(),this.plotWrapper=ce.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,i]=e.icon,r=`${i}`;return{width:t,path:r,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:i}=this.props;this.updateFormatterSettings(i),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e;return((e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){_.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){const{type:t,detail:i}=e;switch(_.debug2("Received data update",t,i),t){case C.EVENT_UPDATED:{this.currentSeries+=1,this.setState(o=>{const{layout:n,revision:u}=o;return typeof n.datarevision=="number"&&(n.datarevision+=1),{data:i,layout:n,revision:u+1}});const{onUpdate:r}=this.props;r({isLoading:!this.isLoadedFired});break}case C.EVENT_LOADFINISHED:{const{onUpdate:r}=this.props;this.isLoadedFired=!0,r({isLoading:!1});break}case C.EVENT_DISCONNECT:{const{onDisconnect:r}=this.props;r();break}case C.EVENT_RECONNECT:{const{onReconnect:r}=this.props;r();break}case C.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case C.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case C.EVENT_DOWNSAMPLENEEDED:case C.EVENT_DOWNSAMPLEFAILED:{const r=i.message??i;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:r});const{onError:o}=this.props;o(new Error(r));break}default:_.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,i=y.getLayoutRanges(t);!j(i,this.ranges)&&(this.ranges=i,this.updateModelDimensions(!0))}handleRelayout(e){if(_.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,i=[...e.hiddenlabels];t({hiddenSeries:i})}this.updateModelDimensions()}handleRestyle([e,t]){if(_.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:i}=this.state,{onSettingsChanged:r}=this.props;if(i!=null){const o=i.reduce((n,{name:u,visible:l})=>u!=null&&l==="legendonly"?[...n,u]:n,[]);r({hiddenSeries:o})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){_.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:r,model:o}=this.props;o.setDimensions(t),r&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=re.getColumnFormats(e),i=re.getDateTimeFormatterOptions(e),{decimalFormatOptions:r={},integerFormatOptions:o={}}=e;(!j(this.columnFormats,t)||!j(this.dateTimeFormatterOptions,i)||!j(this.decimalFormatOptions,r)||!j(this.integerFormatOptions,o))&&(this.columnFormats=re.getColumnFormats(e),this.dateTimeFormatterOptions=i,this.decimalFormatOptions=r,this.integerFormatOptions=o,this.updateFormatter())}updateFormatter(){const e=new Fe(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&te.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{_.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:i,isDownsampleInProgress:r,isDownsamplingDisabled:o,layout:n,revision:u}=this.state,l=this.getCachedConfig(t,i,r,o),p=e!=null;return X.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:p&&X.jsx(Me,{ref:this.plot,data:e,layout:n,revision:u,config:l,onAfterPlot:this.handleAfterPlot,onError:_.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let J=z;d(J,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Ae.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const ze=J,A=se.module("FigureChartModel"),le=class extends C{constructor(e,t={},i=O){super();d(this,"figure");d(this,"settings");d(this,"theme");d(this,"data");d(this,"layout");d(this,"seriesDataMap");d(this,"pendingSeries");d(this,"oneClicks");d(this,"filterColumnMap");d(this,"lastFilter");d(this,"isConnected");d(this,"seriesToProcess");d(this,"addPendingSeries",Ee(()=>{const e=y.getAllAxes(this.figure),{pendingSeries:t}=this;for(let i=0;i<t.length;i+=1){const r=t[i],o=this.figure.charts.find(n=>n.series.includes(r));this.addSeries(r,e,(o==null?void 0:o.showLegend)??null),r.subscribe()}this.pendingSeries=[]},le.ADD_SERIES_DEBOUNCE));d(this,"getTimeZone",Y((e,t)=>{if(t!=null){const i=t.getColumnTypeFormatter(e);if(i!=null)return i.dhTimeZone}}));d(this,"getValueTranslator",Y((e,t)=>{const i=this.getTimeZone(e,t);return r=>y.unwrapValue(r,i)}));d(this,"getValueParser",Y((e,t)=>{const i=this.getTimeZone(e,t);return r=>y.wrapValue(r,e,i)}));d(this,"getRangeParser",Y((e,t)=>i=>{let[r,o]=i;const n=this.getValueParser(e,t);return r=n(r),o=n(o),[r,o]}));d(this,"getAxisRangeParser",Y((e,t)=>i=>{const r=y.getSourceForAxis(e,i);return r?this.getRangeParser(r.columnType,t):o=>o}));this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=i,this.data=[];const r={data:{},layout:y.makeDefaultLayout(i)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:r},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=y.getAllAxes(this.figure),i=[];for(let n=0;n<e.length;n+=1){const u=e[n];for(let l=0;l<u.series.length;l+=1){const p=u.series[l];i.push(p.name),this.addSeries(p,t,u.showLegend)}}const o=[...this.seriesDataMap.keys()].filter(n=>i.indexOf(n)<0);for(let n=0;n<o.length;n+=1){const u=o[n];this.seriesDataMap.delete(u)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,i){const r=y.groupArray(t,"type"),o=y.makeSeriesDataFromSeries(e,r,y.getSeriesVisibility(e.name,this.settings),i,this.theme);if(this.seriesDataMap.set(e.name,o),this.data=[...this.seriesDataMap.values()],e.plotStyle===a.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===a.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=y.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===a.plot.SeriesPlotStyle.PIE?i??void 0:!1,e.oneClick!=null){const{oneClick:n}=e,{columns:u}=n;for(let l=0;l<u.length;l+=1)this.filterColumnMap.set(u[l].name,u[l]);this.oneClicks.push(n)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){A.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?a.plot.DownsampleOptions.DISABLE:a.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(a.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(a.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(a.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(a.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(a.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(a.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(a.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(a.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(a.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(a.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){A.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){A.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){A.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){A.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:i}=t;A.debug2("handleFigureUpdated",i);for(let o=0;o<i.length;o+=1){const n=i[o];A.debug2("handleFigureUpdated updating series",n.name);const{sources:u}=n;for(let l=0;l<u.length;l+=1){const p=u[l],{columnType:h,type:g}=p,m=this.getValueTranslator(h,this.formatter),f=t.getArray(n,g,m);this.setDataArrayForSeries(n,g,f)}this.seriesToProcess.delete(n.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(n)}const{data:r}=this;this.fireUpdate(r)}handleRequestFailed(e){A.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){A.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){A.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;A.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var r;super.setTitle(e);const t=((r=(e??"").match(/<br>/g))==null?void 0:r.length)??0,i=y.DEFAULT_MARGIN.t+t*y.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=y.DEFAULT_TITLE_PADDING.t+t*y.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(((e=this.layout.margin)==null?void 0:e.l)??0)-(((t=this.layout.margin)==null?void 0:t.r)??0),0)}getPlotHeight(){var e,t;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(((e=this.layout.margin)==null?void 0:e.t)??0)-(((t=this.layout.margin)==null?void 0:t.b)??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();y.updateFigureAxes(this.layout,this.figure,i=>this.getAxisRangeParser(i,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;y.getAxisFormats(this.figure,this.formatter).forEach((t,i)=>{A.debug(`Assigning ${i}`,this.layout[i],t);const r=this.layout[i];r!=null?Object.assign(r,t):A.debug(`Ignoring null layout.${i}`)})}setDataArrayForSeries(e,t,i){const{name:r,plotStyle:o}=e,n=this.seriesDataMap.get(r),u=y.getPlotlyProperty(o,t);n&&he(n,u,i)}cleanSeries(e){const{name:t,plotStyle:i}=e,r=this.seriesDataMap.get(t);if(r!=null){if(i===a.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:o,xHigh:n}=r;if(o&&n&&o.length===n.length){const u=[];for(let l=0;l<o.length;l+=1)u.push(n[l]-o[l]);r.width=u}}else if(i===a.plot.SeriesPlotStyle.LINE){const{x:o,xLow:n,xHigh:u,y:l,yLow:p,yHigh:h}=r;n&&u&&n!==o&&(r.error_x=y.getPlotlyErrorBars(o,n,u)),p&&h&&p!==l&&(r.error_y=y.getPlotlyErrorBars(l,p,h))}else if(i===a.plot.SeriesPlotStyle.TREEMAP){const{ids:o,labels:n}=r;o!==void 0&&n===void 0&&(r.labels=o)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){A.warn("Trying to set a filter, but no one click!");return}A.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const i=this.oneClicks[t],{columns:r}=i;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(n=>{const u=e.get(n);this.lastFilter.get(n)!==u&&r.find(l=>l.name===n)!=null&&i.setValueForColumn(n,u)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let ee=le;d(ee,"ADD_SERIES_DEBOUNCE",50);const pe=ee;class ae{static async makeModelFromSettings(s,e,t=O){const i=await ae.makeFigureFromSettings(s,e);return new pe(i,s,t)}static async makeFigureFromSettings(s,e){const t=await e.copy();return t.applyCustomColumns(e.customColumns),t.applyFilter(e.filter),t.applySort(e.sort),a.plot.Figure.create(y.makeFigureSettings(s,t))}static async makeModel(s,e,t=O){return new pe(e,s,t)}}const Ze=ae;const Q=se.module("EmbedChart.App");async function We(E,s){Q.info(`Fetching figure ${s}...`);const e={name:s,type:a.VariableType.FIGURE};return E.getObject(e)}function Je(){const[E,s]=B.useState(),[e,t]=B.useState(),[i,r]=B.useState(!0),o=B.useMemo(()=>new URLSearchParams(window.location.search),[]),n=be();B.useEffect(function(){async function p(){try{const h=o.get("name");if(h==null)throw new Error("No name param provided");Q.debug("Loading figure",h,"...");const g=await We(n,h);Q.debug("Creating model...");const m=await Ze.makeModel(void 0,g);s(m),Q.debug("Figure successfully loaded!")}catch(h){Q.error("Unable to load figure",h),t(`${h}`)}r(!1)}p()},[n,o]);const u=E!=null;return X.jsxs("div",{className:"App",children:[u&&X.jsx(ze,{model:E}),!u&&X.jsx(De,{isLoaded:u,isLoading:i,errorMessage:e??null}),X.jsx(Ne,{})]})}export{Je as default};
2
- //# sourceMappingURL=App-a28df60d.js.map
1
+ var ge=Object.defineProperty;var me=(E,s,e)=>s in E?ge(E,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):E[s]=e;var d=(E,s,e)=>(me(E,typeof s!="symbol"?s+"":s,e),e);import{H as he,A as B,G as ce,I as fe,J as j,C as X,K as Ee,L as Y}from"./vendor-b7e5da9f.js";import{L as se,d as ye,v as Se,a as Te,b as De}from"./index-2cf14df3.js";import{s as a,a as q,T as oe,D as Ae,F as re,b as Fe,u as be,C as Ne}from"./useConnection-44488217.js";import{P as te,b as xe,h as we,p as Pe,o as Le,s as Ie,t as Oe,c as ne}from"./plotly-c2893d76.js";import"./helpers-042e6b4d.js";te.register([xe,we,Pe,Le,Ie,Oe]);const Me=typeof ne=="function"?ne(te):ne.default(te),I=class{constructor(){d(this,"listeners");d(this,"formatter");d(this,"rect");d(this,"isDownsamplingDisabled");d(this,"title");this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(s){}close(){}setFormatter(s){this.formatter=s}setDownsamplingDisabled(s){this.isDownsamplingDisabled=s}setDimensions(s){this.rect=s}setTitle(s){this.title=s}subscribe(s){this.listeners.push(s)}unsubscribe(s){this.listeners=this.listeners.filter(e=>e!==s)}fireEvent(s){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](s)}fireUpdate(s){this.fireEvent(new CustomEvent(I.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(I.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(I.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(I.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(I.EVENT_LOADFINISHED))}};let w=I;d(w,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),d(w,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),d(w,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),d(w,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),d(w,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),d(w,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),d(w,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),d(w,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const C=w,Re="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Ce="#403e41",ve="#5b5a5c",ke="#c0bfbf",_e="#4878ea",Ve="rgba(91, 90, 92, 0.7)",D={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Re,gridcolor:Ce,linecolor:ve,zerolinecolor:ke,activecolor:_e,rangebgcolor:Ve,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},O=Object.freeze({paper_bgcolor:D["paper-bgcolor"],plot_bgcolor:D["plot-bgcolor"],title_color:D["title-color"],colorway:D.colorway,gridcolor:D.gridcolor,linecolor:D.linecolor,zerolinecolor:D.zerolinecolor,activecolor:D.activecolor,rangebgcolor:D.rangebgcolor,area_color:D["area-color"],trend_color:D["trend-color"],line_color:D["line-color"],error_band_line_color:D["error-band-line-color"],error_band_fill_color:D["error-band-fill-color"],ohlc_increasing:D["ohlc-increasing"],ohlc_decreasing:D["ohlc-decreasing"]}),K=se.module("ChartUtils"),k=Object.freeze(a.calendar.DayOfWeek.values()),ue="io.deephaven.time.DateTime",He=36e5,$e=1e6;function Ue(E){return E.asDate!==void 0}function Be(E){return E.asNumber!==void 0}function de(E){return E.dhTimeZone!==void 0}function Xe(E){return E!=null&&E.range!=null&&(E.autorange===!1||E.autorange===void 0)}const c=class{static getPlotlyChartType(s,e){switch(s){case a.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case a.plot.SeriesPlotStyle.LINE:return"scatter";case a.plot.SeriesPlotStyle.BAR:case a.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case a.plot.SeriesPlotStyle.PIE:return"pie";case a.plot.SeriesPlotStyle.TREEMAP:return"treemap";case a.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case a.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(s,e,t){const i=new Set;switch(s){case a.plot.SeriesPlotStyle.SCATTER:(e??!1)&&i.add(c.MODE_LINES),(t??!0)&&i.add(c.MODE_MARKERS);break;case a.plot.SeriesPlotStyle.LINE:(e??!0)&&i.add(c.MODE_LINES),(t??!1)&&i.add(c.MODE_MARKERS);break}return i.size>0?[...i].join("+"):void 0}static getPlotlyProperty(s,e){switch(s){case a.plot.SeriesPlotStyle.PIE:switch(e){case a.plot.SourceType.X:return"labels";case a.plot.SourceType.Y:return"values"}break;case a.plot.SeriesPlotStyle.OHLC:switch(e){case a.plot.SourceType.TIME:return"x"}break;case a.plot.SeriesPlotStyle.TREEMAP:switch(e){case a.plot.SourceType.X:return"ids";case a.plot.SourceType.Y:return"values";case a.plot.SourceType.LABEL:return"labels";case a.plot.SourceType.PARENT:return"parents";case a.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case a.plot.SourceType.X:return"x";case a.plot.SourceType.Y:return"y";case a.plot.SourceType.Z:return"z";case a.plot.SourceType.X_LOW:return"xLow";case a.plot.SourceType.X_HIGH:return"xHigh";case a.plot.SourceType.Y_LOW:return"yLow";case a.plot.SourceType.Y_HIGH:return"yHigh";case a.plot.SourceType.TIME:return"time";case a.plot.SourceType.OPEN:return"open";case a.plot.SourceType.HIGH:return"high";case a.plot.SourceType.LOW:return"low";case a.plot.SourceType.CLOSE:return"close";case a.plot.SourceType.SHAPE:return"shape";case a.plot.SourceType.SIZE:return"size";case a.plot.SourceType.LABEL:return"label";case a.plot.SourceType.COLOR:return"color";case a.plot.SourceType.PARENT:return"parent";case a.plot.SourceType.HOVER_TEXT:return"hovertext";case a.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(s){var t,i;const{sources:e}=s;return e.length===2&&((i=(t=e[0])==null?void 0:t.axis)==null?void 0:i.type)===a.plot.AxisType.Y?c.ORIENTATION.HORIZONTAL:c.ORIENTATION.VERTICAL}static getPlotlyErrorBars(s,e,t){const i=t.map((o,n)=>o-s[n]),r=e.map((o,n)=>s[n]-o);return{type:"data",symmetric:!1,array:i,arrayminus:r}}static getPlotlyDateFormat(s,e,t){const i=t==null?void 0:t.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let r;const o=s==null?void 0:s.getColumnTypeFormatter(e);return o!=null&&de(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(r=a.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:i,ticksuffix:r,automargin:!0}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const r=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);q(r);const[,o,n,u,,l,p,h,g,m]=r,f=u.replace(",","").length,b=n.indexOf(",")>=0||u.indexOf(",")>=0?",":"",S=h!=null&&h!==""?"e":"f",P=g!==""?g:S,N=l.length+p.length,x=`0${f}${b}.${N}${P}`,M=c.convertNumberPrefix(o),R=c.convertNumberPrefix(m);return{tickformat:x,tickprefix:M,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(s,e=null){const{axis:t,columnType:i}=s,{formatPattern:r}=t;let o=null;return oe.isDateType(i)?(o=c.getPlotlyDateFormat(e,i,r),o=c.addTickSpacing(o,t,!0)):oe.isNumberType(i)&&(o=c.getPlotlyNumberFormat(e,i,r),o=c.addTickSpacing(o,t,!1)),t.formatType===a.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:i}=e;if(i>0){const r=s||{};let o=i;return t&&(o=i/$e),e.log&&(o=Math.log(o)),r.tickmode="linear",r.dtick=o,r}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const i=s.series[t];for(let r=0;r<i.sources.length;r+=1){const o=i.sources[r];if(o.axis===e)return o}}return null}static getSeriesVisibility(s,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(s)?"legendonly":!0}static getHiddenLabels(s){return s!=null&&s.hiddenSeries?[...s.hiddenSeries]:[]}static makeSeriesData(s,e,t,i,r=c.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:r,showlegend:i??void 0}}static makeSeriesDataFromSeries(s,e,t,i=null,r=O){const{name:o,isLinesVisible:n,isShapesVisible:u,plotStyle:l,lineColor:p,shapeColor:h,sources:g,shape:m,shapeSize:f}=s,F=g.some(v=>{var x;return(x=v.axis)==null?void 0:x.businessCalendar}),b=c.getChartType(l,F),S=c.getPlotlyChartMode(l,n??void 0,u??void 0),P=c.getPlotlySeriesOrientation(s),N=c.makeSeriesData(b,S,o,i,P);return c.addSourcesToSeriesData(N,l,g,e),c.addStylingToSeriesData(N,l,r,p,h,m,f,t),N}static addSourcesToSeriesData(s,e,t,i){const r=s;for(let o=0;o<t.length;o+=1){const n=t[o],{axis:u,type:l}=n,p=c.getPlotlyProperty(e,l);he(r,p,[]);const h=u!=null?c.getAxisPropertyName(u.type):null;if(h!=null){const g=i.get(u.type);if(g){const m=g.indexOf(u),f=m>0?`${m+1}`:"";r[`${h}axis`]=`${h}${f}`}}}}static addStylingToSeriesData(s,e,t=O,i=null,r=null,o=null,n=null,u=null){const l=s;if(l.marker={line:{}},l.line={width:1},e===a.plot.SeriesPlotStyle.AREA?l.fill="tozeroy":e===a.plot.SeriesPlotStyle.STACKED_AREA?l.stackgroup="stack":e===a.plot.SeriesPlotStyle.STEP?l.line.shape="hv":e===a.plot.SeriesPlotStyle.HISTOGRAM?(l.width=[],l.marker.line!==void 0&&Object.assign(l.marker.line,{color:t.paper_bgcolor,width:1})):e===a.plot.SeriesPlotStyle.OHLC?(l.increasing={line:{color:t.ohlc_increasing}},l.decreasing={line:{color:t.ohlc_decreasing}}):e===a.plot.SeriesPlotStyle.PIE?(l.textinfo="label+percent",l.outsidetextfont={color:t.title_color}):e===a.plot.SeriesPlotStyle.TREEMAP&&(l.hoverinfo="text",l.textinfo="label+text",l.tiling={packing:"squarify",pad:0},l.textposition="middle center",l.outsidetextfont={color:t.title_color}),i!=null&&(e===a.plot.SeriesPlotStyle.BAR?l.marker.color=i:l.line.color=i),r!=null&&(l.marker.color=r),o!=null&&o.length>0)try{l.marker.symbol=c.getMarkerSymbol(o)}catch(p){K.warn("Unable to handle shape",o,":",p)}n!=null&&(l.marker.size=n*c.DEFAULT_MARKER_SIZE),u!=null&&e!==a.plot.SeriesPlotStyle.PIE&&(l.visible=u)}static getMarkerSymbol(s){switch(s){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${s}`)}}static getAxisFormats(s,e){const t=new Map,i={tickformat:null,ticksuffix:null},r=c.getAllAxes(s),o=c.groupArray(r,"type"),{charts:n}=s;for(let u=0;u<n.length;u+=1){const l=n[u];for(let p=0;p<l.series.length;p+=1){const h=l.series[p],{sources:g}=h,m=g.filter(f=>f.axis);for(let f=0;f<m.length;f+=1){const F=m[f],{axis:b}=F,{type:S}=b,P=o.get(S);q(P);const N=P.indexOf(b),v=c.getAxisPropertyName(S);if(v!=null){const x=c.getAxisLayoutProperty(v,N);if(t.has(x))K.debug(`${x} already added.`);else{K.debug(`Adding ${x} to axisFormats.`);const M=c.getPlotlyAxisFormat(F,e);if(M===null)t.set(x,i);else{t.set(x,M);const{businessCalendar:R}=b;if(R!=null){const L=[],{businessPeriods:ie,businessDays:H,holidays:$,timeZone:Z}=R,W=e==null?void 0:e.getColumnTypeFormatter(ue);let U;de(W)&&(U=W.dhTimeZone);const G=U?(Z.standardOffset-U.standardOffset)/60:0;$.length>0&&L.push(...c.createRangeBreakValuesFromHolidays($,Z,U)),ie.forEach(V=>L.push({pattern:"hour",bounds:[c.periodToDecimal(V.close)+G,c.periodToDecimal(V.open)+G]})),H.length<k.length&&c.createBoundsFromDays(H).forEach(V=>L.push({pattern:"day of week",bounds:V})),M.rangebreaks=L}if(t.size===l.axes.length)return t}}}}}}return t}static getChartType(s,e){switch(s){case a.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return c.getPlotlyChartType(s,e)}}static getAxisPropertyName(s){switch(s){case a.plot.AxisType.X:return"x";case a.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(s){switch(s){case a.plot.AxisPosition.BOTTOM:return"bottom";case a.plot.AxisPosition.TOP:return"top";case a.plot.AxisPosition.LEFT:return"left";case a.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(s){return s.charts.reduce((e,t)=>[...e,...t.axes],[])}static getChartForSeries(s,e){const{charts:t}=s;for(let i=0;i<t.length;i+=1){const r=t[i];for(let o=0;o<r.series.length;o+=1)if(e===r.series[o])return r}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(i=>i.indexOf("axis")>=0);for(let i=0;i<t.length;i+=1){const r=t[i],o=s[r];Xe(o)&&(e[r]=[...o.range])}return e}static updateFigureAxes(s,e,t,i=0,r=0,o=O){const n=s,u=c.getAllAxes(e);for(let l=0;l<e.charts.length;l+=1){const p=e.charts[l],h=t==null?void 0:t(p),g=c.getChartBounds(e,p,i,r);c.updateLayoutAxes(n,p.axes,u,i,r,g,h,o)}c.removeStaleAxes(n,u)}static getChartBounds(s,e,t,i){const{cols:r,rows:o}=s,{column:n,colspan:u,row:l,rowspan:p}=e,h=n+u,g=l+p,m=1/r,f=1/o,F=c.AXIS_SIZE_PX/t,b=c.AXIS_SIZE_PX/i,S={bottom:(o-g)*f+(g<o?b/2:0),top:(o-l)*f-(l>0?b/2:0),left:n*m+(n>0?F/2:0),right:h*m-(h<r?F/2:0)};return(c.groupArray(e.axes,"position").get(a.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?S.right-=(S.right-S.left)*Math.max(0,Math.min(c.LEGEND_WIDTH_PX/t,c.MAX_LEGEND_SIZE)):S.right-=(S.right-S.left)*c.DEFAULT_AXIS_SIZE),S}static updateLayoutAxes(s,e,t,i=0,r=0,o={left:0,top:0,right:1,bottom:1},n,u=O){const l=i>0?Math.max(c.MIN_AXIS_SIZE,Math.min(c.AXIS_SIZE_PX/r,c.MAX_AXIS_SIZE)):c.DEFAULT_AXIS_SIZE,p=r>0?Math.max(c.MIN_AXIS_SIZE,Math.min(c.AXIS_SIZE_PX/i,c.MAX_AXIS_SIZE)):c.DEFAULT_AXIS_SIZE,h=s,g=c.groupArray(e,"position"),m=c.groupArray(e,"type"),f=[...m.keys()],F=c.groupArray(t,"type");for(let b=0;b<f.length;b+=1){const S=f[b],P=c.getAxisPropertyName(S);if(P!=null){const N=m.get(S),v=F.get(S),M=S===a.plot.AxisType.Y?r:i;q(N),q(v);for(let R=0;R<N.length;R+=1){const L=N[R],ie=v.indexOf(L),H=c.getAxisLayoutProperty(P,ie);h[H]==null&&(h[H]=c.makeLayoutAxis(S,u));const $=h[H];if($!=null){c.updateLayoutAxis($,L,R,g,l,p,o);const{range:Z,autorange:W}=$;if(n!=null&&Z!==void 0&&(W===void 0||W===!1)){const U=n(L),[G,V]=U(Z);K.debug("Setting downsample range",M,G,V),L.range(M,G,V)}else L.range(M)}}}}}static removeStaleAxes(s,e){const t=s,i=c.groupArray(e,"type"),r=[...i.keys()];for(let o=0;o<r.length;o+=1){const n=r[o],u=i.get(n);q(u);let l=u.length;const p=c.getAxisPropertyName(n);if(p!=null){let h=c.getAxisLayoutProperty(p,l);for(;t[h]!=null;)delete t[h],l+=1,h=c.getAxisLayoutProperty(p,l)}}}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static updateLayoutAxis(s,e,t,i,r,o,n){const l=e.type===a.plot.AxisType.Y?o:r,p=s,h=e.label??"";if(p.title!==void 0&&typeof p.title!="string"?p.title.text=h:p.title={text:h},e.log&&(p.type="log"),p.side=c.getAxisSide(e.position),t>0){p.overlaying=c.getAxisPropertyName(e.type)??void 0;const g=i.get(e.position)??[],m=g.indexOf(e);m>0&&(p.anchor="free",e.position===a.plot.AxisPosition.RIGHT?p.position=n.right+(m-g.length+1)*l:e.position===a.plot.AxisPosition.TOP?p.position=n.top+(m-g.length+1)*l:e.position===a.plot.AxisPosition.BOTTOM?p.position=n.bottom+(g.length-m+1)*l:e.position===a.plot.AxisPosition.LEFT&&(p.position=n.left+(g.length-m+1)*l))}else if(e.type===a.plot.AxisType.X){const g=i.get(a.plot.AxisPosition.LEFT)||[],m=i.get(a.plot.AxisPosition.RIGHT)||[],f=Math.max(n.left,n.left+(g.length-1)*o),F=Math.min(n.right-(m.length-1)*o,n.right);p.domain=[f,F]}else if(e.type===a.plot.AxisType.Y){const g=i.get(a.plot.AxisPosition.BOTTOM)||[],m=i.get(a.plot.AxisPosition.TOP)||[],f=Math.max(n.bottom,n.bottom+(g.length-1)*r),F=Math.min(n.top-(m.length-1)*r,n.top);p.domain=[f,F]}}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(s){const e=s.map(o=>k.indexOf(o)),t=k.filter(o=>!s.includes(o)).map(o=>k.indexOf(o)),i=new Set;t.forEach(o=>{for(let n=o+1;n<o+k.length;n+=1){const u=n%k.length;if(e.includes(u)){i.add(u);break}}});const r=[];return i.forEach(o=>{for(let n=o-1;n>o-k.length;n-=1){const u=n<0?n+k.length:n;if(e.includes(u)){const l=(u+1)%7;r.push([l,o]);break}}}),r}static createRangeBreakValuesFromHolidays(s,e,t){const i=[],r=[];return s.forEach(o=>{o.businessPeriods.length>0?r.push(...c.createPartialHoliday(o,e,t)):i.push(c.createFullHoliday(o,e,t))}),[{values:i},...r]}static createFullHoliday(s,e,t){return c.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}static createPartialHoliday(s,e,t){const i=s.date.toString(),r=["00:00"];s.businessPeriods.forEach(n=>{r.push(n.open),r.push(n.close)}),r.push("24:00");const o=[];for(let n=0;n<r.length;n+=2){const u=r[n],l=r[n+1];if(u!==l){const p=[c.adjustDateForTimeZone(`${i} ${u}:00.000000`,e,t)],h=He*(c.periodToDecimal(l)-c.periodToDecimal(u));o.push({values:p,dvalue:h})}}return o}static adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?c.unwrapValue(c.wrapValue(s,ue,e),t):s}static groupArray(s,e){return s.reduce((t,i)=>{const r=i[e],o=t.get(r)??[];return o.push(i),t.set(r,o),t},new Map)}static unwrapValue(s,e){if(s!=null){if(Ue(s))return a.i18n.DateTimeFormat.format(c.DATE_FORMAT,s,e);if(Be(s))return s.asNumber()}return s}static wrapValue(s,e,t=null){if(oe.isDateType(e)&&typeof s=="string"){const i=s,r=c.DATE_FORMAT.substr(0,s.length),o=a.i18n.DateTimeFormat.parse(r,i);if(!t)return o;const n=`${r} Z`,u=a.i18n.DateTimeFormat.format("Z",o,t),l=a.i18n.DateTimeFormat.parse(n,`${i} ${u}`),p=a.i18n.DateTimeFormat.format("Z",l,t);return a.i18n.DateTimeFormat.parse(n,`${i} ${p}`)}return s}static makeLayoutAxis(s,e=O){const t={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return s===a.plot.AxisType.X?Object.assign(t,{showgrid:!0}):s===a.plot.AxisType.Y&&Object.assign(t,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),t}static getColorwayFromTheme(s=O){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):K.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static makeDefaultLayout(s=O){const e={...s,autosize:!0,colorway:c.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:s.title_color},yanchor:"top",pad:{...c.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...c.DEFAULT_MARGIN},xaxis:c.makeLayoutAxis(a.plot.AxisType.X,s),yaxis:c.makeLayoutAxis(a.plot.AxisType.Y,s)};return e.datarevision=0,e}static hydrateSettings(s){return{...s,type:s.type!=null?a.plot.SeriesPlotStyle[s.type]:void 0}}static titleFromSettings(s){const{series:e,xAxis:t,title:i=`${(e??[]).join(", ")} by ${t}`}=s;return i}static makeFigureSettings(s,e){const{series:t,xAxis:i,type:r}=s,o=c.titleFromSettings(s),n={formatType:`${a.plot.AxisFormatType.NUMBER}`,type:`${a.plot.AxisType.X}`,position:`${a.plot.AxisPosition.BOTTOM}`},u={formatType:`${a.plot.AxisFormatType.NUMBER}`,type:`${a.plot.AxisType.Y}`,position:`${a.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${a.plot.ChartType.XY}`,axes:[n,u],series:(t??[]).map(l=>({plotStyle:`${r}`,name:l,dataSources:[{type:`${a.plot.SourceType.X}`,columnName:i??"",axis:n,table:e},{type:`${a.plot.SourceType.Y}`,columnName:l,axis:u,table:e}]}))}],title:o}}};let T=c;d(T,"DEFAULT_AXIS_SIZE",.15),d(T,"MIN_AXIS_SIZE",.025),d(T,"MAX_AXIS_SIZE",.2),d(T,"AXIS_SIZE_PX",75),d(T,"LEGEND_WIDTH_PX",50),d(T,"MAX_LEGEND_SIZE",.25),d(T,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),d(T,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),d(T,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),d(T,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),d(T,"SUBTITLE_LINE_HEIGHT",25),d(T,"DEFAULT_MARKER_SIZE",6),d(T,"MODE_MARKERS","markers"),d(T,"MODE_LINES","lines");const y=T;const _=se.module("Chart"),z=class extends B.Component{constructor(e){super(e);d(this,"currentSeries");d(this,"plot");d(this,"plotWrapper");d(this,"columnFormats");d(this,"dateTimeFormatterOptions");d(this,"decimalFormatOptions");d(this,"integerFormatOptions");d(this,"rect");d(this,"ranges");d(this,"isSubscribed");d(this,"isLoadedFired");d(this,"getCachedConfig",fe((e,t,i,r)=>{const o=[],n=Boolean(e);if(n&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:z.convertIcon(ye),attr:"fill-warning"}),t||i||r||n){const u=z.downsampleButtonTitle(i,r),l=z.downsampleButtonAttr(i,r),p=i?Se:Te;o.push({name:u,icon:z.convertIcon(p),click:this.handleDownsampleClick,attr:l})}return{displaylogo:!1,displayModeBar:i||n?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}));this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=ce.createRef(),this.plotWrapper=ce.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,i]=e.icon,r=`${i}`;return{width:t,path:r,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:i}=this.props;this.updateFormatterSettings(i),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e;return((e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){_.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){const{type:t,detail:i}=e;switch(_.debug2("Received data update",t,i),t){case C.EVENT_UPDATED:{this.currentSeries+=1,this.setState(o=>{const{layout:n,revision:u}=o;return typeof n.datarevision=="number"&&(n.datarevision+=1),{data:i,layout:n,revision:u+1}});const{onUpdate:r}=this.props;r({isLoading:!this.isLoadedFired});break}case C.EVENT_LOADFINISHED:{const{onUpdate:r}=this.props;this.isLoadedFired=!0,r({isLoading:!1});break}case C.EVENT_DISCONNECT:{const{onDisconnect:r}=this.props;r();break}case C.EVENT_RECONNECT:{const{onReconnect:r}=this.props;r();break}case C.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case C.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case C.EVENT_DOWNSAMPLENEEDED:case C.EVENT_DOWNSAMPLEFAILED:{const r=i.message??i;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:r});const{onError:o}=this.props;o(new Error(r));break}default:_.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,i=y.getLayoutRanges(t);!j(i,this.ranges)&&(this.ranges=i,this.updateModelDimensions(!0))}handleRelayout(e){if(_.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,i=[...e.hiddenlabels];t({hiddenSeries:i})}this.updateModelDimensions()}handleRestyle([e,t]){if(_.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:i}=this.state,{onSettingsChanged:r}=this.props;if(i!=null){const o=i.reduce((n,{name:u,visible:l})=>u!=null&&l==="legendonly"?[...n,u]:n,[]);r({hiddenSeries:o})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){_.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:r,model:o}=this.props;o.setDimensions(t),r&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=re.getColumnFormats(e),i=re.getDateTimeFormatterOptions(e),{decimalFormatOptions:r={},integerFormatOptions:o={}}=e;(!j(this.columnFormats,t)||!j(this.dateTimeFormatterOptions,i)||!j(this.decimalFormatOptions,r)||!j(this.integerFormatOptions,o))&&(this.columnFormats=re.getColumnFormats(e),this.dateTimeFormatterOptions=i,this.decimalFormatOptions=r,this.integerFormatOptions=o,this.updateFormatter())}updateFormatter(){const e=new Fe(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&te.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{_.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:i,isDownsampleInProgress:r,isDownsamplingDisabled:o,layout:n,revision:u}=this.state,l=this.getCachedConfig(t,i,r,o),p=e!=null;return X.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:p&&X.jsx(Me,{ref:this.plot,data:e,layout:n,revision:u,config:l,onAfterPlot:this.handleAfterPlot,onError:_.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let J=z;d(J,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Ae.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const ze=J,A=se.module("FigureChartModel"),le=class extends C{constructor(e,t={},i=O){super();d(this,"figure");d(this,"settings");d(this,"theme");d(this,"data");d(this,"layout");d(this,"seriesDataMap");d(this,"pendingSeries");d(this,"oneClicks");d(this,"filterColumnMap");d(this,"lastFilter");d(this,"isConnected");d(this,"seriesToProcess");d(this,"addPendingSeries",Ee(()=>{const e=y.getAllAxes(this.figure),{pendingSeries:t}=this;for(let i=0;i<t.length;i+=1){const r=t[i],o=this.figure.charts.find(n=>n.series.includes(r));this.addSeries(r,e,(o==null?void 0:o.showLegend)??null),r.subscribe()}this.pendingSeries=[]},le.ADD_SERIES_DEBOUNCE));d(this,"getTimeZone",Y((e,t)=>{if(t!=null){const i=t.getColumnTypeFormatter(e);if(i!=null)return i.dhTimeZone}}));d(this,"getValueTranslator",Y((e,t)=>{const i=this.getTimeZone(e,t);return r=>y.unwrapValue(r,i)}));d(this,"getValueParser",Y((e,t)=>{const i=this.getTimeZone(e,t);return r=>y.wrapValue(r,e,i)}));d(this,"getRangeParser",Y((e,t)=>i=>{let[r,o]=i;const n=this.getValueParser(e,t);return r=n(r),o=n(o),[r,o]}));d(this,"getAxisRangeParser",Y((e,t)=>i=>{const r=y.getSourceForAxis(e,i);return r?this.getRangeParser(r.columnType,t):o=>o}));this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=i,this.data=[];const r={data:{},layout:y.makeDefaultLayout(i)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:r},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=y.getAllAxes(this.figure),i=[];for(let n=0;n<e.length;n+=1){const u=e[n];for(let l=0;l<u.series.length;l+=1){const p=u.series[l];i.push(p.name),this.addSeries(p,t,u.showLegend)}}const o=[...this.seriesDataMap.keys()].filter(n=>i.indexOf(n)<0);for(let n=0;n<o.length;n+=1){const u=o[n];this.seriesDataMap.delete(u)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,i){const r=y.groupArray(t,"type"),o=y.makeSeriesDataFromSeries(e,r,y.getSeriesVisibility(e.name,this.settings),i,this.theme);if(this.seriesDataMap.set(e.name,o),this.data=[...this.seriesDataMap.values()],e.plotStyle===a.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===a.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=y.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===a.plot.SeriesPlotStyle.PIE?i??void 0:!1,e.oneClick!=null){const{oneClick:n}=e,{columns:u}=n;for(let l=0;l<u.length;l+=1)this.filterColumnMap.set(u[l].name,u[l]);this.oneClicks.push(n)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){A.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?a.plot.DownsampleOptions.DISABLE:a.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(a.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(a.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(a.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(a.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(a.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(a.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(a.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(a.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(a.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(a.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(a.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(a.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){A.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){A.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){A.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){A.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:i}=t;A.debug2("handleFigureUpdated",i);for(let o=0;o<i.length;o+=1){const n=i[o];A.debug2("handleFigureUpdated updating series",n.name);const{sources:u}=n;for(let l=0;l<u.length;l+=1){const p=u[l],{columnType:h,type:g}=p,m=this.getValueTranslator(h,this.formatter),f=t.getArray(n,g,m);this.setDataArrayForSeries(n,g,f)}this.seriesToProcess.delete(n.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(n)}const{data:r}=this;this.fireUpdate(r)}handleRequestFailed(e){A.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){A.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){A.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;A.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var r;super.setTitle(e);const t=((r=(e??"").match(/<br>/g))==null?void 0:r.length)??0,i=y.DEFAULT_MARGIN.t+t*y.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=y.DEFAULT_TITLE_PADDING.t+t*y.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(((e=this.layout.margin)==null?void 0:e.l)??0)-(((t=this.layout.margin)==null?void 0:t.r)??0),0)}getPlotHeight(){var e,t;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(((e=this.layout.margin)==null?void 0:e.t)??0)-(((t=this.layout.margin)==null?void 0:t.b)??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();y.updateFigureAxes(this.layout,this.figure,i=>this.getAxisRangeParser(i,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;y.getAxisFormats(this.figure,this.formatter).forEach((t,i)=>{A.debug(`Assigning ${i}`,this.layout[i],t);const r=this.layout[i];r!=null?Object.assign(r,t):A.debug(`Ignoring null layout.${i}`)})}setDataArrayForSeries(e,t,i){const{name:r,plotStyle:o}=e,n=this.seriesDataMap.get(r),u=y.getPlotlyProperty(o,t);n&&he(n,u,i)}cleanSeries(e){const{name:t,plotStyle:i}=e,r=this.seriesDataMap.get(t);if(r!=null){if(i===a.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:o,xHigh:n}=r;if(o&&n&&o.length===n.length){const u=[];for(let l=0;l<o.length;l+=1)u.push(n[l]-o[l]);r.width=u}}else if(i===a.plot.SeriesPlotStyle.LINE){const{x:o,xLow:n,xHigh:u,y:l,yLow:p,yHigh:h}=r;n&&u&&n!==o&&(r.error_x=y.getPlotlyErrorBars(o,n,u)),p&&h&&p!==l&&(r.error_y=y.getPlotlyErrorBars(l,p,h))}else if(i===a.plot.SeriesPlotStyle.TREEMAP){const{ids:o,labels:n}=r;o!==void 0&&n===void 0&&(r.labels=o)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){A.warn("Trying to set a filter, but no one click!");return}A.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const i=this.oneClicks[t],{columns:r}=i;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(n=>{const u=e.get(n);this.lastFilter.get(n)!==u&&r.find(l=>l.name===n)!=null&&i.setValueForColumn(n,u)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let ee=le;d(ee,"ADD_SERIES_DEBOUNCE",50);const pe=ee;class ae{static async makeModelFromSettings(s,e,t=O){const i=await ae.makeFigureFromSettings(s,e);return new pe(i,s,t)}static async makeFigureFromSettings(s,e){const t=await e.copy();return t.applyCustomColumns(e.customColumns),t.applyFilter(e.filter),t.applySort(e.sort),a.plot.Figure.create(y.makeFigureSettings(s,t))}static async makeModel(s,e,t=O){return new pe(e,s,t)}}const Ze=ae;const Q=se.module("EmbedChart.App");async function We(E,s){Q.info(`Fetching figure ${s}...`);const e={name:s,type:a.VariableType.FIGURE};return E.getObject(e)}function Je(){const[E,s]=B.useState(),[e,t]=B.useState(),[i,r]=B.useState(!0),o=B.useMemo(()=>new URLSearchParams(window.location.search),[]),n=be();B.useEffect(function(){async function p(){try{const h=o.get("name");if(h==null)throw new Error("No name param provided");Q.debug("Loading figure",h,"...");const g=await We(n,h);Q.debug("Creating model...");const m=await Ze.makeModel(void 0,g);s(m),Q.debug("Figure successfully loaded!")}catch(h){Q.error("Unable to load figure",h),t(`${h}`)}r(!1)}p()},[n,o]);const u=E!=null;return X.jsxs("div",{className:"App",children:[u&&X.jsx(ze,{model:E}),!u&&X.jsx(De,{isLoaded:u,isLoading:i,errorMessage:e??null}),X.jsx(Ne,{})]})}export{Je as default};
2
+ //# sourceMappingURL=App-4ecfe080.js.map