import{r as t,g as s}from"./p-823ca21f.js";import{GcPromise as i}from"../gc-core-assets/lib/GcPromise";import{GcUtils as e}from"../gc-core-assets/lib/GcUtils";import{ParentRegistry as r}from"../gc-widget-base/lib/GcWidget";import{G as a}from"./p-5d57e98d.js";import"./p-2ae9b527.js";import"../gc-core-assets/lib/GcFiles";import"../gc-core-assets/lib/GcConsole";import"../gc-core-assets/lib/GcLocalStorage";import"../gc-widget-message-dialog/lib/GcMessageDialog";let h=class{constructor(s){t(this,s);this.id="";this.series={type:"bar",x:[],y:[]};this.parentRegistry=new r(a.widgetType);this.childIndex=-1;this.valuesStreamingDataListener=t=>{t=typeof t==="string"?JSON.parse(t):t;if(Array.isArray(t[0])){const s=e.transposeMatrix(t);this.series.x=s[0];this.series.y=s[1]}this.fireData();return};this.deferredWidgetReady=i.defer();this.cssPropertyNameToSetterMap={"--gc-bar-color":t=>this.restyle({"markder.color":t})};this.capacity=200;this.legend="auto"}get sortingOrder(){return r.getChildElementIndex(this.el)}barModeHandler(){this.relayout({barmode:this.barMode})}valuesHandler(t){this.valuesStreamingDataListener(t)}showLegendHandler(t){this.restyle({showlegend:t})}legendNameHandler(t){this.restyle({name:t})}fireData(){this.parentRegistry.parent?.replot()}async waitForWidgetReady(){return this.deferredWidgetReady.promise}async restyle(t){if(!this.parentRegistry.parent){a.mergeRecords(a.flattenRecord(t),this.series)}else{this.parentRegistry.parent.restyle(this,t)}}async relayout(t){if(this.parentRegistry.parent){this.parentRegistry.parent.relayout(t)}}connectedCallback(){this.el["barStreamingDataListener"]=this.valuesStreamingDataListener;if(this.deferredWidgetReady.promise.isPending){this.deferredWidgetReady.resolve()}this.id=this.el.id;this.parentRegistry.register(this.el.parentElement,this)}disconnectedCallback(){this.parentRegistry.unregister(this)}async componentWillLoad(){if(this.values){this.valuesStreamingDataListener(this.values)}this.series.name=this.legendName??this.el.id;this.series.showlegend=this.legend==="hide"?false:this.legend==="show"?true:undefined;for(const t in this.cssPropertyNameToSetterMap){const s=await this.getCSSProperty(t);s&&await this.setCSSProperty(t,s)}this.el["series"]=this.series;this.barModeHandler()}async setCSSProperty(t,s){s=s.trim();this.el.style.setProperty(t,s);const i=this.cssPropertyNameToSetterMap[t];if(i!==undefined){i(s)}}async getCSSProperty(t){return window.getComputedStyle(this.el).getPropertyValue(t)}get el(){return s(this)}static get watchers(){return{barMode:["barModeHandler"],values:["valuesHandler"],legend:["showLegendHandler"],legendName:["legendNameHandler"]}}};export{h as gc_widget_plot_data_bargraph};
//# sourceMappingURL=p-f8d7d6b4.entry.js.map