@devtable/dashboard 1.12.0 → 1.13.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.
@@ -927,7 +927,7 @@ function VizTable({
927
927
  type: value_type
928
928
  })
929
929
  })
930
- }, row[value_field]))
930
+ }, `${value_field}--${row[value_field]}`))
931
931
  }, id_field ? row[id_field] : `row-${index2}`))
932
932
  }), data.length > 100 && /* @__PURE__ */ jsx("tfoot", {
933
933
  children: /* @__PURE__ */ jsx("tr", {
@@ -4314,7 +4314,7 @@ function DashboardActions({
4314
4314
  })
4315
4315
  }), /* @__PURE__ */ jsxs(Group, {
4316
4316
  position: "right",
4317
- children: [inLayoutMode && /* @__PURE__ */ jsx(Button, {
4317
+ children: [!inUseMode && /* @__PURE__ */ jsx(Button, {
4318
4318
  variant: "default",
4319
4319
  size: "sm",
4320
4320
  onClick: addPanel,
@@ -4415,13 +4415,13 @@ function Dashboard({
4415
4415
  x: 0,
4416
4416
  y: Infinity,
4417
4417
  w: 3,
4418
- h: 4
4418
+ h: 15
4419
4419
  },
4420
4420
  title: `New Panel - ${id}`,
4421
- description: "description goes here",
4421
+ description: "",
4422
4422
  dataSourceID: "",
4423
4423
  viz: {
4424
- type: "table",
4424
+ type: "text",
4425
4425
  conf: {}
4426
4426
  }
4427
4427
  };
@@ -1,4 +1,4 @@
1
- (function(b,w){typeof exports=="object"&&typeof module!="undefined"?w(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("ahooks"),require("axios"),require("tabler-icons-react"),require("@mantine/rte"),require("@mantine/hooks"),require("echarts-for-react/lib/core"),require("echarts/core"),require("echarts/charts"),require("echarts/renderers"),require("echarts/components"),require("numbro"),require("echarts-gl"),require("react-hook-form"),require("@mantine/form"),require("@mantine/prism")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","ahooks","axios","tabler-icons-react","@mantine/rte","@mantine/hooks","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts/components","numbro","echarts-gl","react-hook-form","@mantine/form","@mantine/prism"],w):(b=typeof globalThis!="undefined"?globalThis:b||self,w(b.dashboard={},b.React,b._,b["react-grid-layout"],b["@mantine/core"],b.ahooks,b.axios,b["tabler-icons-react"],b["@mantine/rte"],b["@mantine/hooks"],b["echarts-for-react/lib/core"],b["echarts/core"],b["echarts/charts"],b["echarts/renderers"],b["echarts/components"],b.numbro,b["echarts-gl"],b["react-hook-form"],b["@mantine/form"],b["@mantine/prism"]))})(this,function(b,w,G,P,r,pe,dt,S,De,E,ct,pt,ee,te,W,ft,cr,v,q,B){"use strict";var sr=Object.defineProperty,ur=Object.defineProperties;var dr=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var Ie=(b,w,G)=>w in b?sr(b,w,{enumerable:!0,configurable:!0,writable:!0,value:G}):b[w]=G,f=(b,w)=>{for(var G in w||(w={}))at.call(w,G)&&Ie(b,G,w[G]);if(ce)for(var G of ce(w))st.call(w,G)&&Ie(b,G,w[G]);return b},z=(b,w)=>ur(b,dr(w));var D=(b,w)=>{var G={};for(var P in b)at.call(b,P)&&w.indexOf(P)<0&&(G[P]=b[P]);if(b!=null&&ce)for(var P of ce(b))w.indexOf(P)<0&&st.call(b,P)&&(G[P]=b[P]);return G};var ut=(b,w,G)=>(Ie(b,typeof w!="symbol"?w+"":w,G),G);function J(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function mt(e){if(e&&e.__esModule)return e;var n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(i){if(i!=="default"){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}}),n.default=e,Object.freeze(n)}var d=J(w),I=J(G),ht=J(dt),xt=J(De),ne=J(ct),V=mt(pt),Y=J(ft),M=(e=>(e.Use="use",e.Layout="layout",e.Edit="edit",e))(M||{});const gt={layoutFrozen:!1,freezeLayout:()=>{},mode:M.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},$=d.default.createContext(gt),Pe=e=>(n,i,o={})=>{const l=f({"X-Requested-With":"XMLHttpRequest","Content-Type":o.string?"application/x-www-form-urlencoded":"application/json"},o.headers),s={baseURL:"http://localhost:31200",method:e,url:n,params:e==="GET"?i:o.params,headers:l};return e==="POST"&&(s.data=o.string?JSON.stringify(i):i),ht.default(s).then(a=>a.data).catch(a=>Promise.reject(a))},bt=Pe("GET"),yt=Pe("POST");function Ae(e,n){const i=Object.keys(n),o=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...o)}catch(l){throw i.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):l}}function St(e,n){const i=n.sqlSnippets.reduce((o,l)=>(o[l.key]=Ae(l.value,e),o),{});return I.default.merge({},i,e)}const Le=({context:e,definitions:n,title:i,dataSource:o})=>async()=>{if(!o||!o.sql)return[];const{type:l,key:s,sql:a}=o,u=a.includes("$");try{const c=St(e,n),h=Ae(a,c);return u&&(console.groupCollapsed(`Final SQL for: ${i}`),console.log(h),console.groupEnd()),await yt("/query",{type:l,key:s,sql:h})}catch(c){return console.error(c),[]}};async function Ct(){try{return await bt("/query/sources",{})}catch(e){return console.error(e),{}}}const Me={},vt=Me,Q=d.default.createContext(Me),wt={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},dataSourceID:"",setDataSourceID:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},O=d.default.createContext(wt),Tt={sqlSnippets:[],setSQLSnippets:()=>{},dataSources:[],setDataSources:()=>{}},k=d.default.createContext(Tt);var re={exports:{}},ie={};/**
1
+ (function(b,w){typeof exports=="object"&&typeof module!="undefined"?w(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("ahooks"),require("axios"),require("tabler-icons-react"),require("@mantine/rte"),require("@mantine/hooks"),require("echarts-for-react/lib/core"),require("echarts/core"),require("echarts/charts"),require("echarts/renderers"),require("echarts/components"),require("numbro"),require("echarts-gl"),require("react-hook-form"),require("@mantine/form"),require("@mantine/prism")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","ahooks","axios","tabler-icons-react","@mantine/rte","@mantine/hooks","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts/components","numbro","echarts-gl","react-hook-form","@mantine/form","@mantine/prism"],w):(b=typeof globalThis!="undefined"?globalThis:b||self,w(b.dashboard={},b.React,b._,b["react-grid-layout"],b["@mantine/core"],b.ahooks,b.axios,b["tabler-icons-react"],b["@mantine/rte"],b["@mantine/hooks"],b["echarts-for-react/lib/core"],b["echarts/core"],b["echarts/charts"],b["echarts/renderers"],b["echarts/components"],b.numbro,b["echarts-gl"],b["react-hook-form"],b["@mantine/form"],b["@mantine/prism"]))})(this,function(b,w,G,P,r,pe,dt,S,De,E,ct,pt,ee,te,W,ft,cr,v,q,B){"use strict";var sr=Object.defineProperty,ur=Object.defineProperties;var dr=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var at=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var Ie=(b,w,G)=>w in b?sr(b,w,{enumerable:!0,configurable:!0,writable:!0,value:G}):b[w]=G,f=(b,w)=>{for(var G in w||(w={}))at.call(w,G)&&Ie(b,G,w[G]);if(ce)for(var G of ce(w))st.call(w,G)&&Ie(b,G,w[G]);return b},_=(b,w)=>ur(b,dr(w));var D=(b,w)=>{var G={};for(var P in b)at.call(b,P)&&w.indexOf(P)<0&&(G[P]=b[P]);if(b!=null&&ce)for(var P of ce(b))w.indexOf(P)<0&&st.call(b,P)&&(G[P]=b[P]);return G};var ut=(b,w,G)=>(Ie(b,typeof w!="symbol"?w+"":w,G),G);function J(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function mt(e){if(e&&e.__esModule)return e;var n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(i){if(i!=="default"){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}}),n.default=e,Object.freeze(n)}var d=J(w),I=J(G),ht=J(dt),xt=J(De),ne=J(ct),V=mt(pt),Y=J(ft),M=(e=>(e.Use="use",e.Layout="layout",e.Edit="edit",e))(M||{});const gt={layoutFrozen:!1,freezeLayout:()=>{},mode:M.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},$=d.default.createContext(gt),Pe=e=>(n,i,o={})=>{const l=f({"X-Requested-With":"XMLHttpRequest","Content-Type":o.string?"application/x-www-form-urlencoded":"application/json"},o.headers),s={baseURL:"http://localhost:31200",method:e,url:n,params:e==="GET"?i:o.params,headers:l};return e==="POST"&&(s.data=o.string?JSON.stringify(i):i),ht.default(s).then(a=>a.data).catch(a=>Promise.reject(a))},bt=Pe("GET"),yt=Pe("POST");function Ae(e,n){const i=Object.keys(n),o=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...o)}catch(l){throw i.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):l}}function St(e,n){const i=n.sqlSnippets.reduce((o,l)=>(o[l.key]=Ae(l.value,e),o),{});return I.default.merge({},i,e)}const Le=({context:e,definitions:n,title:i,dataSource:o})=>async()=>{if(!o||!o.sql)return[];const{type:l,key:s,sql:a}=o,u=a.includes("$");try{const c=St(e,n),h=Ae(a,c);return u&&(console.groupCollapsed(`Final SQL for: ${i}`),console.log(h),console.groupEnd()),await yt("/query",{type:l,key:s,sql:h})}catch(c){return console.error(c),[]}};async function Ct(){try{return await bt("/query/sources",{})}catch(e){return console.error(e),{}}}const Me={},vt=Me,Q=d.default.createContext(Me),wt={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},dataSourceID:"",setDataSourceID:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},O=d.default.createContext(wt),Tt={sqlSnippets:[],setSQLSnippets:()=>{},dataSources:[],setDataSources:()=>{}},k=d.default.createContext(Tt);var re={exports:{}},ie={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,8 +6,8 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Gt=d.default,_t=Symbol.for("react.element"),zt=Symbol.for("react.fragment"),It=Object.prototype.hasOwnProperty,Dt=Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Pt={key:!0,ref:!0,__self:!0,__source:!0};function Oe(e,n,i){var o,l={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(o in n)It.call(n,o)&&!Pt.hasOwnProperty(o)&&(l[o]=n[o]);if(e&&e.defaultProps)for(o in n=e.defaultProps,n)l[o]===void 0&&(l[o]=n[o]);return{$$typeof:_t,type:e,key:s,ref:a,props:l,_owner:Dt.current}}ie.Fragment=zt,ie.jsx=Oe,ie.jsxs=Oe,re.exports=ie;const t=re.exports.jsx,p=re.exports.jsxs,K=re.exports.Fragment;function ke({position:e,trigger:n="click"}){const{freezeLayout:i}=d.default.useContext($),[o,l]=d.default.useState(!1),{description:s}=d.default.useContext(O);if(d.default.useEffect(()=>{i(o)},[o]),!s||s==="<p><br></p>")return null;const a=n==="click"?t(r.Tooltip,{label:"Click to see description",openDelay:500,children:t(S.InfoCircle,{size:20,onClick:()=>l(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(S.InfoCircle,{size:20,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:o,onClose:()=>l(!1),withCloseButton:!0,withArrow:!0,trapFocus:!0,closeOnEscape:!1,placement:"center",position:e,target:a,children:t(xt.default,{readOnly:!0,value:s,onChange:I.default.noop,sx:{border:"none"}})})}function At(){const{description:e,setDescription:n}=d.default.useContext(O),[i,o]=d.default.useState(e),l=e!==i,s=d.default.useCallback(()=>{!l||n(i)},[l,i]);return p(r.Group,{direction:"column",sx:{flexGrow:1},children:[p(r.Group,{align:"end",children:[t(r.Text,{children:"Description"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]}),t(De.RichTextEditor,{value:i,onChange:o,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class fe extends d.default.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t("h1",{children:"Something went wrong."}):this.props.children}}function Lt(){const{title:e}=d.default.useContext(O);return t(fe,{children:p(r.Group,{direction:"column",grow:!0,noWrap:!0,mx:"auto",mt:"xl",p:"5px",spacing:"xs",sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px",flexGrow:0,flexShrink:0},children:[t(r.Group,{children:t(ke,{position:"bottom",trigger:"hover"})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:e})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),t(r.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function Mt(){const{title:e,setTitle:n}=d.default.useContext(O),[i,o]=E.useInputState(e),l=e!==i,s=d.default.useCallback(()=>{!l||n(i)},[l,i]);return t(r.TextInput,{value:i,onChange:o,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]})})}function Ot({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[p(r.Group,{grow:!0,direction:"column",sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[t(Mt,{}),t(At,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Lt,{})})]})}function Ee({id:e}){const n=d.default.useContext(k),i=d.default.useContext(Q),o=d.default.useMemo(()=>n.dataSources.find(u=>u.id===e),[n.dataSources,e]),{data:l=[],loading:s,refresh:a}=pe.useRequest(Le({context:i,definitions:n,title:e,dataSource:o}),{refreshDeps:[i,n,o]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):l.length===0?t(r.Table,{}):p(r.Group,{my:"xl",direction:"column",grow:!0,sx:{border:"1px solid #eee"},children:[p(r.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(r.Group,{position:"left",children:[t(r.Text,{weight:500,children:"Preview Data"}),l.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",l.length]})]}),t(r.ActionIcon,{mr:15,variant:"hover",color:"blue",disabled:s,onClick:a,children:t(S.Refresh,{size:15})})]}),p(r.Table,{children:[t("thead",{children:t("tr",{children:Object.keys(l==null?void 0:l[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:l.slice(0,10).map((u,c)=>t("tr",{children:Object.values(u).map((h,m)=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:t(r.Text,{children:h})})},`${h}--${m}`))},`row-${c}`))})]})]})}function kt({}){const{dataSources:e}=d.default.useContext(k),{dataSourceID:n,setDataSourceID:i,data:o,loading:l}=d.default.useContext(O),s=d.default.useMemo(()=>e.map(a=>({value:a.id,label:a.id})),[e]);return p(r.Group,{direction:"column",grow:!0,noWrap:!0,children:[p(r.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[t(r.Text,{children:"Select a Data Source"}),t(r.Select,{data:s,value:n,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),t(Ee,{id:n})]})}V.use([ee.SunburstChart,te.CanvasRenderer]);const Et={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function qt({conf:e,data:n,width:i,height:o}){const x=e,{label_field:l="name",value_field:s="value"}=x,a=D(x,["label_field","value_field"]),u=d.default.useMemo(()=>n.map(g=>({name:g[l],value:Number(g[s])})),[n,l,s]),c=d.default.useMemo(()=>{var g,y;return(y=(g=I.default.maxBy(u,C=>C.value))==null?void 0:g.value)!=null?y:1},[u]),h=d.default.useMemo(()=>({series:{label:{formatter:({name:g,value:y})=>y/c<.2?" ":g}}}),[c]),m=I.default.merge({},Et,h,a,{series:{data:u}});return t(ne.default,{echarts:V,option:m,style:{width:i,height:o}})}V.use([ee.BarChart,ee.LineChart,W.GridComponent,W.LegendComponent,W.TooltipComponent,te.CanvasRenderer]);const $t={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:30,left:15,right:15,bottom:30,containLabel:!0}};function Ft({conf:e,data:n,width:i,height:o}){const l=d.default.useMemo(()=>{var h;const s=e.y_axes.reduce((m,{label_formatter:x},g)=>(m[g]=function(C){const T=typeof C=="object"?C.value:C;if(!x)return T;try{return Y.default(T).format(x)}catch(_){return console.error(_),T}},m),{default:({value:m})=>m}),a=e.series.reduce((m,{yAxisIndex:x,name:g})=>(m[g]=x,m),{}),u=e.series.map(T=>{var _=T,{y_axis_data_key:m,yAxisIndex:x,label_position:g,name:y}=_,C=D(_,["y_axis_data_key","yAxisIndex","label_position","name"]);return f({data:n.map(L=>L[m]),label:{show:!!g,position:g,formatter:s[x!=null?x:"default"]},name:y,yAxisIndex:x},C)}),c={xAxis:{data:n.map(m=>m[e.x_axis_data_key]),name:(h=e.x_axis_name)!=null?h:""},yAxis:e.y_axes.map((y,g)=>{var C=y,{label_formatter:m}=C,x=D(C,["label_formatter"]);var T;return z(f({},x),{axisLabel:{show:!0,formatter:(T=s[g])!=null?T:s.default}})}),dataset:{source:n},series:u,tooltip:{formatter:function(m){const x=Array.isArray(m)?m:[m];if(x.length===0)return"";const g=x.map(({seriesName:y,value:C})=>{var A;if(!y)return C;const T=a[y],_=(A=s[T])!=null?A:s.default;return`${y}: ${_({value:C})}`});return g.unshift(`<strong>${x[0].name}</strong>`),g.join("<br />")}}};return I.default.merge({},$t,c)},[e,n]);return!i||!o?null:t(ne.default,{echarts:V,option:l,style:{width:i,height:o}})}var j=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(j||{});function Bt({value:e}){return t(r.Text,{component:"span",children:e})}function Vt({value:e}){return t(r.Text,{component:"span",children:e})}function jt({value:e}){const n=Y.default(e).format({thousandSeparated:!0});return t(r.Text,{component:"span",children:n})}function Nt({value:e}){const n=Y.default(e).format({output:"percent",mantissa:3});return t(r.Text,{component:"span",children:n})}function Rt({value:e,type:n}){switch(n){case j.string:return t(Bt,{value:e});case j.eloc:return t(Vt,{value:e});case j.number:return t(jt,{value:e});case j.percentage:return t(Nt,{value:e})}}function Wt({conf:e,data:n=[],width:i,height:o}){const m=e,{id_field:l,use_raw_columns:s,columns:a}=m,u=D(m,["id_field","use_raw_columns","columns"]),c=d.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]):a.map(x=>x.label),[s,a,n]),h=d.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]).map(x=>({label:x,value_field:x,value_type:j.string})):a,[s,a,n]);return p(r.Table,z(f({sx:{maxHeight:o}},u),{children:[t("thead",{children:t("tr",{children:c.map(x=>t("th",{children:x},x))})}),t("tbody",{children:n.slice(0,30).map((x,g)=>t("tr",{children:h.map(({value_field:y,value_type:C})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(Rt,{value:x[y],type:C})})},x[y]))},l?x[l]:`row-${g}`))}),n.length>100&&t("tfoot",{children:t("tr",{children:t("td",{colSpan:c.length,children:t(r.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]}))}function Qt(e,n={}){const i=z(f({},n),{numbro:Y.default}),o=Object.keys(i),l=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...l)}catch(s){return s.message}}function Ut({conf:{paragraphs:e},data:n}){return t(K,{children:e.map((a,s)=>{var u=a,{template:i,size:o}=u,l=D(u,["template","size"]);return t(r.Text,z(f({},l),{sx:{fontSize:o},children:Qt(i,n[0])}),`${i}---${s}`)})})}V.use([W.GridComponent,W.VisualMapComponent,W.LegendComponent,W.TooltipComponent,te.CanvasRenderer]);function Jt({conf:e,data:n,width:i,height:o}){const x=e,{x_axis_data_key:l,y_axis_data_key:s,z_axis_data_key:a}=x,u=D(x,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),c=d.default.useMemo(()=>I.default.minBy(n,g=>g[a])[a],[n,a]),h=d.default.useMemo(()=>I.default.maxBy(n,g=>g[a])[a],[n,a]),m=z(f({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:c,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:{type:"value"},yAxis3D:{type:"value"},zAxis3D:{type:"value"},grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}}},u),{series:[{type:"bar3D",wireframe:{},data:n.map(g=>[g[l],g[s],g[a]])}]});return t(ne.default,{echarts:V,option:m,style:{width:i,height:o}})}var pr="";V.use([ee.PieChart,te.CanvasRenderer]);const Yt={tooltip:{show:!0},series:{type:"pie",radius:["50%","80%"],label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
10
- {percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function Kt({conf:e,data:n,width:i,height:o}){const m=e,{label_field:l="name",value_field:s="value"}=m,a=D(m,["label_field","value_field"]),u=d.default.useMemo(()=>n.map(x=>({name:x[l],value:Number(x[s])})),[n,l,s]),c=d.default.useMemo(()=>({series:{labelLayout:function(x){const g=x.labelRect.x<i/2,y=x.labelLinePoints;return y[2][0]=g?x.labelRect.x:x.labelRect.x+x.labelRect.width,{labelLinePoints:y}}}}),[i]),h=I.default.merge({},Yt,c,a,{series:{data:u}});return t(ne.default,{echarts:V,option:h,style:{width:i,height:o}})}var qe=function(){};const Xt=(e,n,i)=>Math.min(Math.max(i,e),n),$e=(e,n,i)=>{const o=n-e;return o===0?1:(i-e)/o},me=(e,n,i)=>-i*e+i*n+e,Fe=(e,n)=>i=>Math.max(Math.min(i,n),e),X=e=>e%1?Number(e.toFixed(5)):e,oe=/(-)?([\d]*\.?[\d])+/g,he=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Zt=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function Z(e){return typeof e=="string"}const le={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Be=Object.assign(Object.assign({},le),{transform:Fe(0,1)});Object.assign(Object.assign({},le),{default:1});const H=(e=>({test:n=>Z(n)&&n.endsWith(e)&&n.split(" ").length===1,parse:parseFloat,transform:n=>`${n}${e}`}))("%");Object.assign(Object.assign({},H),{parse:e=>H.parse(e)/100,transform:e=>H.transform(e*100)});const xe=(e,n)=>i=>Boolean(Z(i)&&Zt.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),Ve=(e,n,i)=>o=>{if(!Z(o))return o;const[l,s,a,u]=o.match(oe);return{[e]:parseFloat(l),[n]:parseFloat(s),[i]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},U={test:xe("hsl","hue"),parse:Ve("hue","saturation","lightness"),transform:({hue:e,saturation:n,lightness:i,alpha:o=1})=>"hsla("+Math.round(e)+", "+H.transform(X(n))+", "+H.transform(X(i))+", "+X(Be.transform(o))+")"},Ht=Fe(0,255),ge=Object.assign(Object.assign({},le),{transform:e=>Math.round(Ht(e))}),N={test:xe("rgb","red"),parse:Ve("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:o=1})=>"rgba("+ge.transform(e)+", "+ge.transform(n)+", "+ge.transform(i)+", "+X(Be.transform(o))+")"};function en(e){let n="",i="",o="",l="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),o=e.substr(5,2),l=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),o=e.substr(3,1),l=e.substr(4,1),n+=n,i+=i,o+=o,l+=l),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:l?parseInt(l,16)/255:1}}const be={test:xe("#"),parse:en,transform:N.transform},ae={test:e=>N.test(e)||be.test(e)||U.test(e),parse:e=>N.test(e)?N.parse(e):U.test(e)?U.parse(e):be.parse(e),transform:e=>Z(e)?e:e.hasOwnProperty("red")?N.transform(e):U.transform(e)},je="${c}",Ne="${n}";function tn(e){var n,i,o,l;return isNaN(e)&&Z(e)&&((i=(n=e.match(oe))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((l=(o=e.match(he))===null||o===void 0?void 0:o.length)!==null&&l!==void 0?l:0)>0}function Re(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const o=e.match(he);o&&(i=o.length,e=e.replace(he,je),n.push(...o.map(ae.parse)));const l=e.match(oe);return l&&(e=e.replace(oe,Ne),n.push(...l.map(le.parse))),{values:n,numColors:i,tokenised:e}}function We(e){return Re(e).values}function Qe(e){const{values:n,numColors:i,tokenised:o}=Re(e),l=n.length;return s=>{let a=o;for(let u=0;u<l;u++)a=a.replace(u<i?je:Ne,u<i?ae.transform(s[u]):X(s[u]));return a}}const nn=e=>typeof e=="number"?0:e;function rn(e){const n=We(e);return Qe(e)(n.map(nn))}const Ue={test:tn,parse:We,createTransformer:Qe,getAnimatableNone:rn};function ye(e,n,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(n-e)*6*i:i<1/2?n:i<2/3?e+(n-e)*(2/3-i)*6:e}function Je({hue:e,saturation:n,lightness:i,alpha:o}){e/=360,n/=100,i/=100;let l=0,s=0,a=0;if(!n)l=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,c=2*i-u;l=ye(c,u,e+1/3),s=ye(c,u,e),a=ye(c,u,e-1/3)}return{red:Math.round(l*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:o}}const on=(e,n,i)=>{const o=e*e,l=n*n;return Math.sqrt(Math.max(0,i*(l-o)+o))},ln=[be,N,U],Ye=e=>ln.find(n=>n.test(e)),Ke=(e,n)=>{let i=Ye(e),o=Ye(n),l=i.parse(e),s=o.parse(n);i===U&&(l=Je(l),i=N),o===U&&(s=Je(s),o=N);const a=Object.assign({},l);return u=>{for(const c in a)c!=="alpha"&&(a[c]=on(l[c],s[c],u));return a.alpha=me(l.alpha,s.alpha,u),i.transform(a)}},an=e=>typeof e=="number",sn=(e,n)=>i=>n(e(i)),Xe=(...e)=>e.reduce(sn);function Ze(e,n){return an(e)?i=>me(e,n,i):ae.test(e)?Ke(e,n):tt(e,n)}const He=(e,n)=>{const i=[...e],o=i.length,l=e.map((s,a)=>Ze(s,n[a]));return s=>{for(let a=0;a<o;a++)i[a]=l[a](s);return i}},un=(e,n)=>{const i=Object.assign(Object.assign({},e),n),o={};for(const l in i)e[l]!==void 0&&n[l]!==void 0&&(o[l]=Ze(e[l],n[l]));return l=>{for(const s in o)i[s]=o[s](l);return i}};function et(e){const n=Ue.parse(e),i=n.length;let o=0,l=0,s=0;for(let a=0;a<i;a++)o||typeof n[a]=="number"?o++:n[a].hue!==void 0?s++:l++;return{parsed:n,numNumbers:o,numRGB:l,numHSL:s}}const tt=(e,n)=>{const i=Ue.createTransformer(n),o=et(e),l=et(n);return o.numHSL===l.numHSL&&o.numRGB===l.numRGB&&o.numNumbers>=l.numNumbers?Xe(He(o.parsed,l.parsed),i):a=>`${a>0?n:e}`},dn=(e,n)=>i=>me(e,n,i);function cn(e){if(typeof e=="number")return dn;if(typeof e=="string")return ae.test(e)?Ke:tt;if(Array.isArray(e))return He;if(typeof e=="object")return un}function pn(e,n,i){const o=[],l=i||cn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=l(e[a],e[a+1]);if(n){const c=Array.isArray(n)?n[a]:n;u=Xe(c,u)}o.push(u)}return o}function fn([e,n],[i]){return o=>i($e(e,n,o))}function mn(e,n){const i=e.length,o=i-1;return l=>{let s=0,a=!1;if(l<=e[0]?a=!0:l>=e[o]&&(s=o-1,a=!0),!a){let c=1;for(;c<i&&!(e[c]>l||c===o);c++);s=c-1}const u=$e(e[s],e[s+1],l);return n[s](u)}}function hn(e,n,{clamp:i=!0,ease:o,mixer:l}={}){const s=e.length;qe(s===n.length),qe(!o||!Array.isArray(o)||o.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=pn(n,o,l),u=s===2?fn(e,a):mn(e,a);return i?c=>u(Xt(e[0],e[s-1],c)):u}class xn{constructor({valueRange:n,colorRange:i}){ut(this,"mapper");this.mapper=hn(n,i)}getColor(n){return this.mapper(n)}}function gn(e,n={}){const i=z(f({},n),{numbro:Y.default}),o=Object.keys(i),l=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...l)}catch(s){return s.message}}function bn(e,n){if(e.type==="static")return e.staticColor;if(e.type==="continuous"){const i=new xn(e),o=n[e.valueField];return i.getColor(o)}return"black"}function yn(s){var a=s,{conf:u}=a,c=u,{template:e,size:n,color:i}=c,o=D(c,["template","size","color"]),{data:l}=a;const h=d.default.useMemo(()=>bn(i,l[0]),[i,l]);return t(r.Text,z(f({},o),{color:h,sx:{fontSize:n},children:gn(e,l[0])}))}function Sn(e,n,i,o){const l={width:e,height:n,data:i,conf:o.conf};switch(o.type){case"sunburst":return t(qt,f({},l));case"line-bar":case"cartesian":return t(Ft,f({},l));case"table":return t(Wt,f({},l));case"text":return t(Ut,f({},l));case"stats":return t(yn,f({},l));case"bar-3d":return t(Jt,f({},l));case"pie":return t(Kt,f({},l));default:return null}}function nt({viz:e,data:n,loading:i}){const{ref:o,width:l,height:s}=E.useElementSize(),a=d.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:o,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:o,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&Sn(l,s,n,e)]})}function Cn({}){const{data:e,loading:n,viz:i}=d.default.useContext(O);return t(fe,{children:t(nt,{viz:i,data:e,loading:n})})}function vn({conf:e,setConf:n}){const i=I.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},e),{control:o,handleSubmit:l,formState:s}=v.useForm({defaultValues:i});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:l(n),children:[t(r.Text,{children:"X Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"x_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"xAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Y Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"y_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"yAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Z Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"z_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"zAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(r.Button,{color:"blue",type:"submit",children:[t(S.DeviceFloppy,{size:20}),t(r.Text,{ml:"md",children:"Save"})]})})]})})}function Se({value:e,onChange:n}){const i=r.useMantineTheme(),o=d.default.useMemo(()=>Object.entries(i.colors).map(([s,a])=>({label:s,value:a[6]})),[i]),l=d.default.useMemo(()=>o.some(s=>s.value===e),[e,o]);return p(r.Group,{position:"apart",spacing:"xs",children:[t(r.TextInput,{placeholder:"Set any color",value:l?"":e,onChange:s=>n(s.currentTarget.value),rightSection:t(r.ColorSwatch,{color:l?"transparent":e,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"100%",flexGrow:1}}),t(r.Text,{sx:{flexGrow:0},children:"or"}),t(r.Select,{data:o,value:e,onChange:n,variant:l?"default":"filled",placeholder:"Pick a theme color",icon:t(r.ColorSwatch,{color:l?e:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}const wn=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function Tn({control:e,index:n,remove:i,seriesItem:o,yAxisOptions:l}){const s=o.type;return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(v.Controller,{name:`series.${n}.type`,control:e,render:({field:a})=>t(r.SegmentedControl,f({data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter",disabled:!0},{label:"Boxplot",value:"boxplot",disabled:!0}]},a))})}),t(v.Controller,{name:`series.${n}.name`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},a))}),p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(v.Controller,{name:`series.${n}.y_axis_data_key`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Value key",required:!0,sx:{flex:1}},a))}),t(v.Controller,{name:`series.${n}.yAxisIndex`,control:e,render:h=>{var{field:m}=h,x=m,{value:a,onChange:u}=x,c=D(x,["value","onChange"]);var g;return t(r.Select,z(f({label:"Y Axis",data:l,disabled:l.length===0},c),{value:(g=a==null?void 0:a.toString())!=null?g:"",onChange:y=>{if(!y){u(0);return}u(Number(y))},sx:{flex:1}}))}})]}),s==="bar"&&p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(v.Controller,{name:`series.${n}.stack`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},a))}),t(v.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Bar Width",sx:{flexGrow:1}},a))})]}),t(v.Controller,{name:`series.${n}.label_position`,control:e,render:({field:a})=>t(r.Select,f({label:"Label Position",data:wn},a))}),p(r.Group,{direction:"column",grow:!0,spacing:4,children:[t(r.Text,{size:"sm",children:"Color"}),t(v.Controller,{name:`series.${n}.color`,control:e,render:({field:a})=>t(Se,f({},a))})]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},n)}function Gn({control:e,watch:n,getValues:i}){const{fields:o,append:l,remove:s}=v.useFieldArray({control:e,name:"series"}),a=n("y_axes"),u=o.map((m,x)=>f(f({},m),a[x])),c=()=>l({type:"bar",name:E.randomId(),showSymbol:!1,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000"}),h=d.default.useMemo(()=>i().y_axes.map(({name:m},x)=>({label:m,value:x.toString()})),[i]);return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Series"}),u.map((m,x)=>t(Tn,{control:e,index:x,remove:s,seriesItem:m,yAxisOptions:h})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:c,children:"Add a Series"})})]})}const rt={mantissa:0,output:"number"};function _n({value:e,onChange:n}){const i=s=>{n(z(f({},e),{output:s}))},o=s=>{const a=s===0?!1:e.trimMantissa;n(z(f({},e),{mantissa:s,trimMantissa:a}))},l=s=>{n(z(f({},e),{trimMantissa:s.currentTarget.checked}))};return t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:p(r.Group,{direction:"row",grow:!0,children:[t(r.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i}),t(r.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:o}),t(r.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:l,disabled:e.mantissa===0})]})})}function zn({control:e,index:n,remove:i}){return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"row",grow:!0,noWrap:!0,children:t(v.Controller,{name:`y_axes.${n}.name`,control:e,render:({field:o})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},o))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(v.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:o})=>t(_n,f({},o))})}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},disabled:n===0,children:t(S.Trash,{size:16})})]},n)}function In({control:e,watch:n}){const{fields:i,append:o,remove:l}=v.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((c,h)=>f(f({},c),s[h])),u=()=>o({name:"",label_formatter:rt});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((c,h)=>t(zn,{control:e,index:h,remove:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function Dn(e){function n({type:i,name:o,showSymbol:l,y_axis_data_key:s="value",yAxisIndex:a=0,label_position:u="top",stack:c="1",color:h="black",barWidth:m="30"}){return{type:i,name:o,showSymbol:l,y_axis_data_key:s,yAxisIndex:a,label_position:u,stack:c,color:h,barWidth:m}}return e.map(n)}function Pn({conf:e,setConf:n}){const x=e,{series:i,y_axes:o}=x,l=D(x,["series","y_axes"]),s=d.default.useMemo(()=>{const C=l,{x_axis_name:g=""}=C,y=D(C,["x_axis_name"]);return f({series:Dn(i!=null?i:[]),x_axis_name:g,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:rt}]},y)},[i,l]);d.default.useEffect(()=>{!I.default.isEqual(e,s)&&n(s)},[e,s]);const{control:a,handleSubmit:u,watch:c,formState:{isDirty:h},getValues:m}=v.useForm({defaultValues:s});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u(n),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Chart Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:t(S.DeviceFloppy,{size:20})})]}),t(v.Controller,{name:"x_axis_data_key",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",mb:"lg",label:"X Axis Data Key"},g))}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,mb:"lg",children:t(v.Controller,{name:"x_axis_name",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",label:"X Axis Name"},g))})}),t(In,{control:a,watch:c}),t(Gn,{control:a,watch:c,getValues:m})]})})}function An({conf:{label_field:e,value_field:n},setConf:i}){const o=q.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Pie Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const se=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function it({label:e,value:n,onChange:i}){var s,a;const[o,l]=d.default.useState((a=(s=se.find(u=>u.label===n))==null?void 0:s.value)!=null?a:se[0].value);return d.default.useEffect(()=>{const u=se.find(c=>c.value===o);u&&i(u.label)},[o]),p(r.Group,{direction:"column",grow:!0,spacing:"xs",mb:"lg",children:[t(r.Text,{children:e}),t(r.Slider,{label:null,marks:se,value:o,onChange:l,step:25,placeholder:"Pick a font size"})]})}function Ln({label:e,value:n,onChange:i}){const[o,l]=d.default.useState(Array.isArray(n)?[...n]:[]),s=d.default.useCallback(()=>{l(h=>[...h,""])},[l]),a=d.default.useCallback(h=>{l(m=>(m.splice(h,1),[...m]))},[l]),u=d.default.useMemo(()=>!I.default.isEqual(o,n),[o,n]),c=()=>{i(o.map(h=>h.toString()))};return p(K,{children:[p(r.Group,{position:"left",children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:c,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((h,m)=>t(r.TextInput,{value:h,onChange:x=>{const g=x.currentTarget.value;l(y=>(y.splice(m,1,g),[...y]))},rightSection:t(r.ActionIcon,{onClick:()=>a(m),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}function Mn({label:e,value:n,onChange:i}){const[o,l]=d.default.useState(Array.isArray(n)?[...n]:[]),s=d.default.useCallback(()=>{l(x=>[...x,""])},[l]),a=d.default.useCallback(x=>{l(g=>(g.splice(x,1),[...g]))},[l]),u=d.default.useMemo(()=>!I.default.isEqual(o,n),[o,n]),c=()=>{i(o.map(x=>x.toString()))},h=r.useMantineTheme(),m=d.default.useMemo(()=>Object.entries(h.colors).map(([x,g])=>g[6]),[h]);return p(K,{children:[p(r.Group,{position:"left",children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:c,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((x,g)=>t(r.ColorInput,{value:x,onChange:y=>{l(C=>(C.splice(g,1,y),[...C]))},swatches:m,rightSection:t(r.ActionIcon,{onClick:()=>a(g),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}function On({conf:e,setConf:n}){const i=I.default.merge({},{align:"center",size:"100px",template:"",weight:"bold",color:{type:"static",staticColor:"red"}},e),{control:o,handleSubmit:l,watch:s,formState:{isDirty:a}}=v.useForm({defaultValues:i}),u=s("color.type");return s("color.valueField"),t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,noWrap:!0,children:p("form",{onSubmit:l(n),children:[p(r.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[t(r.Text,{weight:500,children:"Stats Configurations"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Accordion,{offsetIcon:!1,multiple:!0,initialState:{0:!0,2:!0},children:[t(r.Accordion.Item,{label:"Content",children:t(r.Group,{direction:"column",grow:!0,children:t(v.Controller,{name:"template",control:o,render:({field:c})=>t(r.TextInput,f({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},c))})})}),p(r.Accordion.Item,{label:"Font",children:[t(r.Group,{direction:"column",grow:!0,children:t(v.Controller,{name:"size",control:o,render:({field:c})=>t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},c))})}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(v.Controller,{name:"weight",control:o,render:({field:c})=>t(it,f({label:"Font Weight"},c))})})]}),t(r.Accordion.Item,{label:"Color",children:p(r.Group,{direction:"column",grow:!0,children:[t(v.Controller,{name:"color.type",control:o,render:({field:c})=>t(r.Select,f({label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}]},c))}),u==="static"&&t(v.Controller,{name:"color.staticColor",control:o,render:({field:c})=>t(Se,f({},c))}),u==="continuous"&&p(K,{children:[t(v.Controller,{name:"color.valueField",control:o,defaultValue:"",render:({field:c})=>t(r.TextInput,f({placeholder:"Calculate color with this field",label:"Value Field",required:!0,sx:{flex:1}},c))}),t(v.Controller,{name:"color.valueRange",control:o,render:({field:c})=>t(Ln,f({label:"Value Range"},c))}),t(v.Controller,{name:"color.colorRange",control:o,render:({field:c})=>t(Mn,f({label:"Color Range"},c))})]})]})})]})]})})}function kn({conf:{label_field:e,value_field:n},setConf:i}){const o=q.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Sunburst Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const En=Object.values(j).map(e=>({label:e,value:e}));function qn({label:e,value:n,onChange:i,sx:o}){return t(r.Select,{label:e,data:En,value:n,onChange:i,sx:o})}function $n(o){var l=o,{conf:s}=l,a=s,{columns:e}=a,n=D(a,["columns"]),{setConf:i}=l;const u=q.useForm({initialValues:f({id_field:"id",use_raw_columns:!0,columns:q.formList(e!=null?e:[]),fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},n)}),c=()=>u.addListItem("columns",{label:E.randomId(),value_field:"value",value_type:j.string});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Table Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({size:"md",mb:"lg",label:"ID Field"},u.getInputProps("id_field"))),p(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[t(r.TextInput,f({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("horizontalSpacing"))),t(r.TextInput,f({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("verticalSpacing")))]}),t(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("fontSize")))}),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Other"}),p(r.Group,{position:"apart",grow:!0,children:[t(r.Switch,f({label:"Striped"},u.getInputProps("striped",{type:"checkbox"}))),t(r.Switch,f({label:"Highlight on hover"},u.getInputProps("highlightOnHover",{type:"checkbox"})))]})]})]}),p(r.Group,{direction:"column",mt:"xs",spacing:"xs",grow:!0,p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.Switch,f({label:"Use Original Data Columns"},u.getInputProps("use_raw_columns",{type:"checkbox"}))),!u.values.use_raw_columns&&p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Custom Columns"}),u.values.columns.map((h,m)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[p(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:[t(r.TextInput,f({label:"Label",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"label"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"value_field"))),t(qn,f({label:"Value Type",sx:{flex:1}},u.getListInputProps("columns",m,"value_type")))]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>u.removeListItem("columns",m),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},m)),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:c,children:"Add a Column"})})]})]}),t(r.Text,{weight:500,mb:"md",children:"Current Configuration:"}),t(B.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(u.values,null,2)})]})})}const ot=[{align:"center",size:"xl",weight:"bold",color:"black",template:"Time: ${new Date().toISOString()}"},{align:"center",size:"md",weight:"bold",color:"red",template:"Platform: ${navigator.userAgentData.platform}."}];function Fn({conf:e,setConf:n}){var l;const i=q.useForm({initialValues:{paragraphs:q.formList((l=e.paragraphs)!=null?l:ot)}}),o=()=>i.addListItem("paragraphs",z(f({},ot[0]),{template:E.randomId()}));return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:i.onSubmit(n),children:[i.values.paragraphs.length===0&&t(r.Text,{color:"dimmed",align:"center",children:"Empty"}),p(r.Group,{position:"apart",mb:"xs",sx:{" + .mantine-Group-root":{marginTop:0}},children:[t(r.Text,{children:"Paragraphs"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),i.values.paragraphs.map((s,a)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},i.getListInputProps("paragraphs",a,"template"))),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Color"}),t(Se,f({},i.getListInputProps("paragraphs",a,"color")))]}),t(r.Group,{direction:"column",grow:!0,children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},i.getListInputProps("paragraphs",a,"size")))}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(it,f({label:"Font Weight"},i.getListInputProps("paragraphs",a,"weight")))}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i.removeListItem("paragraphs",a),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},a)),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:o,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(B.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Ce=[{value:"text",label:"Text",Panel:Fn},{value:"stats",label:"Stats",Panel:On},{value:"table",label:"Table",Panel:$n},{value:"sunburst",label:"Sunburst",Panel:kn},{value:"bar-3d",label:"Bar Chart (3D)",Panel:vn},{value:"cartesian",label:"Cartesian Chart",Panel:Pn},{value:"pie",label:"Pie Chart",Panel:An}];function Bn(){const{viz:e,setViz:n}=d.default.useContext(O),[i,o]=E.useInputState(e.type),l=e.type!==i,s=d.default.useCallback(()=>{!l||n(h=>z(f({},h),{type:i}))},[l,i]),a=h=>{n(m=>z(f({},m),{conf:h}))},u=h=>{try{a(JSON.parse(h))}catch(m){console.error(m)}},c=d.default.useMemo(()=>{var h;return(h=Ce.find(m=>m.value===i))==null?void 0:h.Panel},[i,Ce]);return p(K,{children:[t(r.Select,{label:"Visualization",value:i,onChange:o,data:Ce,rightSection:t(r.ActionIcon,{disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})}),c&&t(c,{conf:e.conf,setConf:a}),!c&&t(r.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:u})]})}function Vn({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[t(r.Group,{grow:!0,direction:"column",noWrap:!0,sx:{width:"40%",flexShrink:0,flexGrow:0},children:t(Bn,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Cn,{})})]})}function jn({opened:e,close:n}){const{freezeLayout:i}=d.default.useContext($),{data:o,loading:l,viz:s,title:a}=d.default.useContext(O);return d.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:a,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%"}},padding:"md",children:p(r.Tabs,{initialTab:2,children:[p(r.Tabs.Tab,{label:"Data Source",children:[t(r.LoadingOverlay,{visible:l,exitTransitionDuration:0}),t(kt,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(Ot,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Vn,{})})]})})})}function Nn({}){const[e,n]=d.default.useState(!1),i=()=>n(!0),o=()=>n(!1),{title:l,refreshData:s}=d.default.useContext(O),{inEditMode:a}=d.default.useContext($);return p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px"},children:[t(r.Group,{children:t(ke,{})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:l})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"},children:p(r.Menu,{children:[t(r.Menu.Item,{onClick:s,icon:t(S.Refresh,{size:14}),children:"Refresh"}),a&&t(r.Menu.Item,{onClick:i,icon:t(S.Settings,{size:14}),children:"Settings"}),t(r.Divider,{}),t(r.Menu.Item,{color:"red",disabled:!0,icon:t(S.Trash,{size:14}),children:"Delete"})]})}),a&&t(jn,{opened:e,close:o})]})}var mr="";function ve({viz:e,dataSourceID:n,title:i,description:o,update:l,layout:s,id:a}){const u=d.default.useContext(Q),c=d.default.useContext(k),[h,m]=d.default.useState(i),[x,g]=d.default.useState(o),[y,C]=d.default.useState(n),[T,_]=d.default.useState(e),A=d.default.useMemo(()=>{if(!!y)return c.dataSources.find(_e=>_e.id===y)},[y,c.dataSources]);d.default.useEffect(()=>{l==null||l({id:a,layout:s,title:h,description:x,dataSourceID:y,viz:T})},[h,x,A,T,a,s,y]);const{data:L=[],loading:ue,refresh:Te}=pe.useRequest(Le({context:u,definitions:c,title:h,dataSource:A}),{refreshDeps:[u,c,A]}),Ge=Te;return t(O.Provider,{value:{data:L,loading:ue,title:h,setTitle:m,description:x,setDescription:g,dataSourceID:y,setDataSourceID:C,viz:T,setViz:_,refreshData:Ge},children:p(r.Container,{className:"panel-root",children:[t(Nn,{}),t(fe,{children:t(nt,{viz:T,data:L,loading:ue})})]})})}var hr="";const Rn=P.WidthProvider(P.Responsive);function lt({panels:e,setPanels:n,className:i="layout",cols:o={lg:12,md:10,sm:8,xs:6,xxs:4},rowHeight:l=10,onRemoveItem:s,isDraggable:a,isResizable:u,setLocalCols:c,setBreakpoint:h}){const m=(g,y)=>{h(g),c(y)},x=d.default.useCallback(g=>{const y=new Map;g.forEach(A=>{var L=A,{i:T}=L,_=D(L,["i"]);y.set(T,_)});const C=e.map(T=>z(f({},T),{layout:y.get(T.id)}));n(C)},[e,n]);return t(Rn,{onBreakpointChange:m,onLayoutChange:x,className:i,cols:o,rowHeight:l,isDraggable:a,isResizable:u,children:e.map((T,C)=>{var _=T,{id:g}=_,y=D(_,["id"]);return t("div",{"data-grid":y.layout,children:t(ve,z(f({id:g},y),{destroy:()=>s(g),update:A=>{n(L=>(L.splice(C,1,A),[...L]))}}))},g)})})}function we(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function Wn({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:we(t(S.PlayerPlay,{size:20}),"Use"),value:M.Use},{label:we(t(S.Resize,{size:20}),"Layout"),value:M.Layout},{label:we(t(S.Paint,{size:20}),"Content"),value:M.Edit}]})}const Qn=`
9
+ */var Gt=d.default,zt=Symbol.for("react.element"),_t=Symbol.for("react.fragment"),It=Object.prototype.hasOwnProperty,Dt=Gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Pt={key:!0,ref:!0,__self:!0,__source:!0};function Oe(e,n,i){var o,l={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(o in n)It.call(n,o)&&!Pt.hasOwnProperty(o)&&(l[o]=n[o]);if(e&&e.defaultProps)for(o in n=e.defaultProps,n)l[o]===void 0&&(l[o]=n[o]);return{$$typeof:zt,type:e,key:s,ref:a,props:l,_owner:Dt.current}}ie.Fragment=_t,ie.jsx=Oe,ie.jsxs=Oe,re.exports=ie;const t=re.exports.jsx,p=re.exports.jsxs,K=re.exports.Fragment;function ke({position:e,trigger:n="click"}){const{freezeLayout:i}=d.default.useContext($),[o,l]=d.default.useState(!1),{description:s}=d.default.useContext(O);if(d.default.useEffect(()=>{i(o)},[o]),!s||s==="<p><br></p>")return null;const a=n==="click"?t(r.Tooltip,{label:"Click to see description",openDelay:500,children:t(S.InfoCircle,{size:20,onClick:()=>l(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(S.InfoCircle,{size:20,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:o,onClose:()=>l(!1),withCloseButton:!0,withArrow:!0,trapFocus:!0,closeOnEscape:!1,placement:"center",position:e,target:a,children:t(xt.default,{readOnly:!0,value:s,onChange:I.default.noop,sx:{border:"none"}})})}function At(){const{description:e,setDescription:n}=d.default.useContext(O),[i,o]=d.default.useState(e),l=e!==i,s=d.default.useCallback(()=>{!l||n(i)},[l,i]);return p(r.Group,{direction:"column",sx:{flexGrow:1},children:[p(r.Group,{align:"end",children:[t(r.Text,{children:"Description"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]}),t(De.RichTextEditor,{value:i,onChange:o,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class fe extends d.default.Component{constructor(n){super(n),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t("h1",{children:"Something went wrong."}):this.props.children}}function Lt(){const{title:e}=d.default.useContext(O);return t(fe,{children:p(r.Group,{direction:"column",grow:!0,noWrap:!0,mx:"auto",mt:"xl",p:"5px",spacing:"xs",sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px",flexGrow:0,flexShrink:0},children:[t(r.Group,{children:t(ke,{position:"bottom",trigger:"hover"})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:e})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),t(r.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function Mt(){const{title:e,setTitle:n}=d.default.useContext(O),[i,o]=E.useInputState(e),l=e!==i,s=d.default.useCallback(()=>{!l||n(i)},[l,i]);return t(r.TextInput,{value:i,onChange:o,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})]})})}function Ot({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[p(r.Group,{grow:!0,direction:"column",sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[t(Mt,{}),t(At,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Lt,{})})]})}function Ee({id:e}){const n=d.default.useContext(k),i=d.default.useContext(Q),o=d.default.useMemo(()=>n.dataSources.find(u=>u.id===e),[n.dataSources,e]),{data:l=[],loading:s,refresh:a}=pe.useRequest(Le({context:i,definitions:n,title:e,dataSource:o}),{refreshDeps:[i,n,o]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):l.length===0?t(r.Table,{}):p(r.Group,{my:"xl",direction:"column",grow:!0,sx:{border:"1px solid #eee"},children:[p(r.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(r.Group,{position:"left",children:[t(r.Text,{weight:500,children:"Preview Data"}),l.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",l.length]})]}),t(r.ActionIcon,{mr:15,variant:"hover",color:"blue",disabled:s,onClick:a,children:t(S.Refresh,{size:15})})]}),p(r.Table,{children:[t("thead",{children:t("tr",{children:Object.keys(l==null?void 0:l[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:l.slice(0,10).map((u,c)=>t("tr",{children:Object.values(u).map((h,m)=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:t(r.Text,{children:h})})},`${h}--${m}`))},`row-${c}`))})]})]})}function kt({}){const{dataSources:e}=d.default.useContext(k),{dataSourceID:n,setDataSourceID:i,data:o,loading:l}=d.default.useContext(O),s=d.default.useMemo(()=>e.map(a=>({value:a.id,label:a.id})),[e]);return p(r.Group,{direction:"column",grow:!0,noWrap:!0,children:[p(r.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[t(r.Text,{children:"Select a Data Source"}),t(r.Select,{data:s,value:n,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),t(Ee,{id:n})]})}V.use([ee.SunburstChart,te.CanvasRenderer]);const Et={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function qt({conf:e,data:n,width:i,height:o}){const x=e,{label_field:l="name",value_field:s="value"}=x,a=D(x,["label_field","value_field"]),u=d.default.useMemo(()=>n.map(g=>({name:g[l],value:Number(g[s])})),[n,l,s]),c=d.default.useMemo(()=>{var g,y;return(y=(g=I.default.maxBy(u,C=>C.value))==null?void 0:g.value)!=null?y:1},[u]),h=d.default.useMemo(()=>({series:{label:{formatter:({name:g,value:y})=>y/c<.2?" ":g}}}),[c]),m=I.default.merge({},Et,h,a,{series:{data:u}});return t(ne.default,{echarts:V,option:m,style:{width:i,height:o}})}V.use([ee.BarChart,ee.LineChart,W.GridComponent,W.LegendComponent,W.TooltipComponent,te.CanvasRenderer]);const $t={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:30,left:15,right:15,bottom:30,containLabel:!0}};function Ft({conf:e,data:n,width:i,height:o}){const l=d.default.useMemo(()=>{var h;const s=e.y_axes.reduce((m,{label_formatter:x},g)=>(m[g]=function(C){const T=typeof C=="object"?C.value:C;if(!x)return T;try{return Y.default(T).format(x)}catch(z){return console.error(z),T}},m),{default:({value:m})=>m}),a=e.series.reduce((m,{yAxisIndex:x,name:g})=>(m[g]=x,m),{}),u=e.series.map(T=>{var z=T,{y_axis_data_key:m,yAxisIndex:x,label_position:g,name:y}=z,C=D(z,["y_axis_data_key","yAxisIndex","label_position","name"]);return f({data:n.map(L=>L[m]),label:{show:!!g,position:g,formatter:s[x!=null?x:"default"]},name:y,yAxisIndex:x},C)}),c={xAxis:{data:n.map(m=>m[e.x_axis_data_key]),name:(h=e.x_axis_name)!=null?h:""},yAxis:e.y_axes.map((y,g)=>{var C=y,{label_formatter:m}=C,x=D(C,["label_formatter"]);var T;return _(f({},x),{axisLabel:{show:!0,formatter:(T=s[g])!=null?T:s.default}})}),dataset:{source:n},series:u,tooltip:{formatter:function(m){const x=Array.isArray(m)?m:[m];if(x.length===0)return"";const g=x.map(({seriesName:y,value:C})=>{var A;if(!y)return C;const T=a[y],z=(A=s[T])!=null?A:s.default;return`${y}: ${z({value:C})}`});return g.unshift(`<strong>${x[0].name}</strong>`),g.join("<br />")}}};return I.default.merge({},$t,c)},[e,n]);return!i||!o?null:t(ne.default,{echarts:V,option:l,style:{width:i,height:o}})}var j=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(j||{});function Bt({value:e}){return t(r.Text,{component:"span",children:e})}function Vt({value:e}){return t(r.Text,{component:"span",children:e})}function jt({value:e}){const n=Y.default(e).format({thousandSeparated:!0});return t(r.Text,{component:"span",children:n})}function Nt({value:e}){const n=Y.default(e).format({output:"percent",mantissa:3});return t(r.Text,{component:"span",children:n})}function Rt({value:e,type:n}){switch(n){case j.string:return t(Bt,{value:e});case j.eloc:return t(Vt,{value:e});case j.number:return t(jt,{value:e});case j.percentage:return t(Nt,{value:e})}}function Wt({conf:e,data:n=[],width:i,height:o}){const m=e,{id_field:l,use_raw_columns:s,columns:a}=m,u=D(m,["id_field","use_raw_columns","columns"]),c=d.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]):a.map(x=>x.label),[s,a,n]),h=d.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]).map(x=>({label:x,value_field:x,value_type:j.string})):a,[s,a,n]);return p(r.Table,_(f({sx:{maxHeight:o}},u),{children:[t("thead",{children:t("tr",{children:c.map(x=>t("th",{children:x},x))})}),t("tbody",{children:n.slice(0,30).map((x,g)=>t("tr",{children:h.map(({value_field:y,value_type:C})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(Rt,{value:x[y],type:C})})},`${y}--${x[y]}`))},l?x[l]:`row-${g}`))}),n.length>100&&t("tfoot",{children:t("tr",{children:t("td",{colSpan:c.length,children:t(r.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]}))}function Qt(e,n={}){const i=_(f({},n),{numbro:Y.default}),o=Object.keys(i),l=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...l)}catch(s){return s.message}}function Ut({conf:{paragraphs:e},data:n}){return t(K,{children:e.map((a,s)=>{var u=a,{template:i,size:o}=u,l=D(u,["template","size"]);return t(r.Text,_(f({},l),{sx:{fontSize:o},children:Qt(i,n[0])}),`${i}---${s}`)})})}V.use([W.GridComponent,W.VisualMapComponent,W.LegendComponent,W.TooltipComponent,te.CanvasRenderer]);function Jt({conf:e,data:n,width:i,height:o}){const x=e,{x_axis_data_key:l,y_axis_data_key:s,z_axis_data_key:a}=x,u=D(x,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),c=d.default.useMemo(()=>I.default.minBy(n,g=>g[a])[a],[n,a]),h=d.default.useMemo(()=>I.default.maxBy(n,g=>g[a])[a],[n,a]),m=_(f({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:c,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:{type:"value"},yAxis3D:{type:"value"},zAxis3D:{type:"value"},grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}}},u),{series:[{type:"bar3D",wireframe:{},data:n.map(g=>[g[l],g[s],g[a]])}]});return t(ne.default,{echarts:V,option:m,style:{width:i,height:o}})}var pr="";V.use([ee.PieChart,te.CanvasRenderer]);const Yt={tooltip:{show:!0},series:{type:"pie",radius:["50%","80%"],label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
10
+ {percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function Kt({conf:e,data:n,width:i,height:o}){const m=e,{label_field:l="name",value_field:s="value"}=m,a=D(m,["label_field","value_field"]),u=d.default.useMemo(()=>n.map(x=>({name:x[l],value:Number(x[s])})),[n,l,s]),c=d.default.useMemo(()=>({series:{labelLayout:function(x){const g=x.labelRect.x<i/2,y=x.labelLinePoints;return y[2][0]=g?x.labelRect.x:x.labelRect.x+x.labelRect.width,{labelLinePoints:y}}}}),[i]),h=I.default.merge({},Yt,c,a,{series:{data:u}});return t(ne.default,{echarts:V,option:h,style:{width:i,height:o}})}var qe=function(){};const Xt=(e,n,i)=>Math.min(Math.max(i,e),n),$e=(e,n,i)=>{const o=n-e;return o===0?1:(i-e)/o},me=(e,n,i)=>-i*e+i*n+e,Fe=(e,n)=>i=>Math.max(Math.min(i,n),e),X=e=>e%1?Number(e.toFixed(5)):e,oe=/(-)?([\d]*\.?[\d])+/g,he=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Zt=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function Z(e){return typeof e=="string"}const le={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Be=Object.assign(Object.assign({},le),{transform:Fe(0,1)});Object.assign(Object.assign({},le),{default:1});const H=(e=>({test:n=>Z(n)&&n.endsWith(e)&&n.split(" ").length===1,parse:parseFloat,transform:n=>`${n}${e}`}))("%");Object.assign(Object.assign({},H),{parse:e=>H.parse(e)/100,transform:e=>H.transform(e*100)});const xe=(e,n)=>i=>Boolean(Z(i)&&Zt.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),Ve=(e,n,i)=>o=>{if(!Z(o))return o;const[l,s,a,u]=o.match(oe);return{[e]:parseFloat(l),[n]:parseFloat(s),[i]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},U={test:xe("hsl","hue"),parse:Ve("hue","saturation","lightness"),transform:({hue:e,saturation:n,lightness:i,alpha:o=1})=>"hsla("+Math.round(e)+", "+H.transform(X(n))+", "+H.transform(X(i))+", "+X(Be.transform(o))+")"},Ht=Fe(0,255),ge=Object.assign(Object.assign({},le),{transform:e=>Math.round(Ht(e))}),N={test:xe("rgb","red"),parse:Ve("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:o=1})=>"rgba("+ge.transform(e)+", "+ge.transform(n)+", "+ge.transform(i)+", "+X(Be.transform(o))+")"};function en(e){let n="",i="",o="",l="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),o=e.substr(5,2),l=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),o=e.substr(3,1),l=e.substr(4,1),n+=n,i+=i,o+=o,l+=l),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:l?parseInt(l,16)/255:1}}const be={test:xe("#"),parse:en,transform:N.transform},ae={test:e=>N.test(e)||be.test(e)||U.test(e),parse:e=>N.test(e)?N.parse(e):U.test(e)?U.parse(e):be.parse(e),transform:e=>Z(e)?e:e.hasOwnProperty("red")?N.transform(e):U.transform(e)},je="${c}",Ne="${n}";function tn(e){var n,i,o,l;return isNaN(e)&&Z(e)&&((i=(n=e.match(oe))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((l=(o=e.match(he))===null||o===void 0?void 0:o.length)!==null&&l!==void 0?l:0)>0}function Re(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const o=e.match(he);o&&(i=o.length,e=e.replace(he,je),n.push(...o.map(ae.parse)));const l=e.match(oe);return l&&(e=e.replace(oe,Ne),n.push(...l.map(le.parse))),{values:n,numColors:i,tokenised:e}}function We(e){return Re(e).values}function Qe(e){const{values:n,numColors:i,tokenised:o}=Re(e),l=n.length;return s=>{let a=o;for(let u=0;u<l;u++)a=a.replace(u<i?je:Ne,u<i?ae.transform(s[u]):X(s[u]));return a}}const nn=e=>typeof e=="number"?0:e;function rn(e){const n=We(e);return Qe(e)(n.map(nn))}const Ue={test:tn,parse:We,createTransformer:Qe,getAnimatableNone:rn};function ye(e,n,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(n-e)*6*i:i<1/2?n:i<2/3?e+(n-e)*(2/3-i)*6:e}function Je({hue:e,saturation:n,lightness:i,alpha:o}){e/=360,n/=100,i/=100;let l=0,s=0,a=0;if(!n)l=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,c=2*i-u;l=ye(c,u,e+1/3),s=ye(c,u,e),a=ye(c,u,e-1/3)}return{red:Math.round(l*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:o}}const on=(e,n,i)=>{const o=e*e,l=n*n;return Math.sqrt(Math.max(0,i*(l-o)+o))},ln=[be,N,U],Ye=e=>ln.find(n=>n.test(e)),Ke=(e,n)=>{let i=Ye(e),o=Ye(n),l=i.parse(e),s=o.parse(n);i===U&&(l=Je(l),i=N),o===U&&(s=Je(s),o=N);const a=Object.assign({},l);return u=>{for(const c in a)c!=="alpha"&&(a[c]=on(l[c],s[c],u));return a.alpha=me(l.alpha,s.alpha,u),i.transform(a)}},an=e=>typeof e=="number",sn=(e,n)=>i=>n(e(i)),Xe=(...e)=>e.reduce(sn);function Ze(e,n){return an(e)?i=>me(e,n,i):ae.test(e)?Ke(e,n):tt(e,n)}const He=(e,n)=>{const i=[...e],o=i.length,l=e.map((s,a)=>Ze(s,n[a]));return s=>{for(let a=0;a<o;a++)i[a]=l[a](s);return i}},un=(e,n)=>{const i=Object.assign(Object.assign({},e),n),o={};for(const l in i)e[l]!==void 0&&n[l]!==void 0&&(o[l]=Ze(e[l],n[l]));return l=>{for(const s in o)i[s]=o[s](l);return i}};function et(e){const n=Ue.parse(e),i=n.length;let o=0,l=0,s=0;for(let a=0;a<i;a++)o||typeof n[a]=="number"?o++:n[a].hue!==void 0?s++:l++;return{parsed:n,numNumbers:o,numRGB:l,numHSL:s}}const tt=(e,n)=>{const i=Ue.createTransformer(n),o=et(e),l=et(n);return o.numHSL===l.numHSL&&o.numRGB===l.numRGB&&o.numNumbers>=l.numNumbers?Xe(He(o.parsed,l.parsed),i):a=>`${a>0?n:e}`},dn=(e,n)=>i=>me(e,n,i);function cn(e){if(typeof e=="number")return dn;if(typeof e=="string")return ae.test(e)?Ke:tt;if(Array.isArray(e))return He;if(typeof e=="object")return un}function pn(e,n,i){const o=[],l=i||cn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=l(e[a],e[a+1]);if(n){const c=Array.isArray(n)?n[a]:n;u=Xe(c,u)}o.push(u)}return o}function fn([e,n],[i]){return o=>i($e(e,n,o))}function mn(e,n){const i=e.length,o=i-1;return l=>{let s=0,a=!1;if(l<=e[0]?a=!0:l>=e[o]&&(s=o-1,a=!0),!a){let c=1;for(;c<i&&!(e[c]>l||c===o);c++);s=c-1}const u=$e(e[s],e[s+1],l);return n[s](u)}}function hn(e,n,{clamp:i=!0,ease:o,mixer:l}={}){const s=e.length;qe(s===n.length),qe(!o||!Array.isArray(o)||o.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=pn(n,o,l),u=s===2?fn(e,a):mn(e,a);return i?c=>u(Xt(e[0],e[s-1],c)):u}class xn{constructor({valueRange:n,colorRange:i}){ut(this,"mapper");this.mapper=hn(n,i)}getColor(n){return this.mapper(n)}}function gn(e,n={}){const i=_(f({},n),{numbro:Y.default}),o=Object.keys(i),l=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...l)}catch(s){return s.message}}function bn(e,n){if(e.type==="static")return e.staticColor;if(e.type==="continuous"){const i=new xn(e),o=n[e.valueField];return i.getColor(o)}return"black"}function yn(s){var a=s,{conf:u}=a,c=u,{template:e,size:n,color:i}=c,o=D(c,["template","size","color"]),{data:l}=a;const h=d.default.useMemo(()=>bn(i,l[0]),[i,l]);return t(r.Text,_(f({},o),{color:h,sx:{fontSize:n},children:gn(e,l[0])}))}function Sn(e,n,i,o){const l={width:e,height:n,data:i,conf:o.conf};switch(o.type){case"sunburst":return t(qt,f({},l));case"line-bar":case"cartesian":return t(Ft,f({},l));case"table":return t(Wt,f({},l));case"text":return t(Ut,f({},l));case"stats":return t(yn,f({},l));case"bar-3d":return t(Jt,f({},l));case"pie":return t(Kt,f({},l));default:return null}}function nt({viz:e,data:n,loading:i}){const{ref:o,width:l,height:s}=E.useElementSize(),a=d.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:o,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:o,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&Sn(l,s,n,e)]})}function Cn({}){const{data:e,loading:n,viz:i}=d.default.useContext(O);return t(fe,{children:t(nt,{viz:i,data:e,loading:n})})}function vn({conf:e,setConf:n}){const i=I.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},e),{control:o,handleSubmit:l,formState:s}=v.useForm({defaultValues:i});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:l(n),children:[t(r.Text,{children:"X Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"x_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"xAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Y Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"y_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"yAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Text,{mt:"lg",children:"Z Axis"}),p(r.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[t(v.Controller,{name:"z_axis_data_key",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Data Key"},a))}),t(v.Controller,{name:"zAxis3D.name",control:o,render:({field:a})=>t(r.TextInput,f({sx:{flexGrow:1},size:"md",label:"Name"},a))})]}),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(r.Button,{color:"blue",type:"submit",children:[t(S.DeviceFloppy,{size:20}),t(r.Text,{ml:"md",children:"Save"})]})})]})})}function Se({value:e,onChange:n}){const i=r.useMantineTheme(),o=d.default.useMemo(()=>Object.entries(i.colors).map(([s,a])=>({label:s,value:a[6]})),[i]),l=d.default.useMemo(()=>o.some(s=>s.value===e),[e,o]);return p(r.Group,{position:"apart",spacing:"xs",children:[t(r.TextInput,{placeholder:"Set any color",value:l?"":e,onChange:s=>n(s.currentTarget.value),rightSection:t(r.ColorSwatch,{color:l?"transparent":e,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"100%",flexGrow:1}}),t(r.Text,{sx:{flexGrow:0},children:"or"}),t(r.Select,{data:o,value:e,onChange:n,variant:l?"default":"filled",placeholder:"Pick a theme color",icon:t(r.ColorSwatch,{color:l?e:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}const wn=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function Tn({control:e,index:n,remove:i,seriesItem:o,yAxisOptions:l}){const s=o.type;return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(v.Controller,{name:`series.${n}.type`,control:e,render:({field:a})=>t(r.SegmentedControl,f({data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter",disabled:!0},{label:"Boxplot",value:"boxplot",disabled:!0}]},a))})}),t(v.Controller,{name:`series.${n}.name`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},a))}),p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(v.Controller,{name:`series.${n}.y_axis_data_key`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Value key",required:!0,sx:{flex:1}},a))}),t(v.Controller,{name:`series.${n}.yAxisIndex`,control:e,render:h=>{var{field:m}=h,x=m,{value:a,onChange:u}=x,c=D(x,["value","onChange"]);var g;return t(r.Select,_(f({label:"Y Axis",data:l,disabled:l.length===0},c),{value:(g=a==null?void 0:a.toString())!=null?g:"",onChange:y=>{if(!y){u(0);return}u(Number(y))},sx:{flex:1}}))}})]}),s==="bar"&&p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(v.Controller,{name:`series.${n}.stack`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},a))}),t(v.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:a})=>t(r.TextInput,f({label:"Bar Width",sx:{flexGrow:1}},a))})]}),t(v.Controller,{name:`series.${n}.label_position`,control:e,render:({field:a})=>t(r.Select,f({label:"Label Position",data:wn},a))}),p(r.Group,{direction:"column",grow:!0,spacing:4,children:[t(r.Text,{size:"sm",children:"Color"}),t(v.Controller,{name:`series.${n}.color`,control:e,render:({field:a})=>t(Se,f({},a))})]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},n)}function Gn({control:e,watch:n,getValues:i}){const{fields:o,append:l,remove:s}=v.useFieldArray({control:e,name:"series"}),a=n("y_axes"),u=o.map((m,x)=>f(f({},m),a[x])),c=()=>l({type:"bar",name:E.randomId(),showSymbol:!1,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000"}),h=d.default.useMemo(()=>i().y_axes.map(({name:m},x)=>({label:m,value:x.toString()})),[i]);return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Series"}),u.map((m,x)=>t(Tn,{control:e,index:x,remove:s,seriesItem:m,yAxisOptions:h})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:c,children:"Add a Series"})})]})}const rt={mantissa:0,output:"number"};function zn({value:e,onChange:n}){const i=s=>{n(_(f({},e),{output:s}))},o=s=>{const a=s===0?!1:e.trimMantissa;n(_(f({},e),{mantissa:s,trimMantissa:a}))},l=s=>{n(_(f({},e),{trimMantissa:s.currentTarget.checked}))};return t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:p(r.Group,{direction:"row",grow:!0,children:[t(r.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i}),t(r.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:o}),t(r.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:l,disabled:e.mantissa===0})]})})}function _n({control:e,index:n,remove:i}){return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"row",grow:!0,noWrap:!0,children:t(v.Controller,{name:`y_axes.${n}.name`,control:e,render:({field:o})=>t(r.TextInput,f({label:"Name",required:!0,sx:{flex:1}},o))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(v.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:o})=>t(zn,f({},o))})}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},disabled:n===0,children:t(S.Trash,{size:16})})]},n)}function In({control:e,watch:n}){const{fields:i,append:o,remove:l}=v.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((c,h)=>f(f({},c),s[h])),u=()=>o({name:"",label_formatter:rt});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((c,h)=>t(_n,{control:e,index:h,remove:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function Dn(e){function n({type:i,name:o,showSymbol:l,y_axis_data_key:s="value",yAxisIndex:a=0,label_position:u="top",stack:c="1",color:h="black",barWidth:m="30"}){return{type:i,name:o,showSymbol:l,y_axis_data_key:s,yAxisIndex:a,label_position:u,stack:c,color:h,barWidth:m}}return e.map(n)}function Pn({conf:e,setConf:n}){const x=e,{series:i,y_axes:o}=x,l=D(x,["series","y_axes"]),s=d.default.useMemo(()=>{const C=l,{x_axis_name:g=""}=C,y=D(C,["x_axis_name"]);return f({series:Dn(i!=null?i:[]),x_axis_name:g,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:rt}]},y)},[i,l]);d.default.useEffect(()=>{!I.default.isEqual(e,s)&&n(s)},[e,s]);const{control:a,handleSubmit:u,watch:c,formState:{isDirty:h},getValues:m}=v.useForm({defaultValues:s});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u(n),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Chart Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:t(S.DeviceFloppy,{size:20})})]}),t(v.Controller,{name:"x_axis_data_key",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",mb:"lg",label:"X Axis Data Key"},g))}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,mb:"lg",children:t(v.Controller,{name:"x_axis_name",control:a,render:({field:g})=>t(r.TextInput,f({size:"md",label:"X Axis Name"},g))})}),t(In,{control:a,watch:c}),t(Gn,{control:a,watch:c,getValues:m})]})})}function An({conf:{label_field:e,value_field:n},setConf:i}){const o=q.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Pie Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const se=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function it({label:e,value:n,onChange:i}){var s,a;const[o,l]=d.default.useState((a=(s=se.find(u=>u.label===n))==null?void 0:s.value)!=null?a:se[0].value);return d.default.useEffect(()=>{const u=se.find(c=>c.value===o);u&&i(u.label)},[o]),p(r.Group,{direction:"column",grow:!0,spacing:"xs",mb:"lg",children:[t(r.Text,{children:e}),t(r.Slider,{label:null,marks:se,value:o,onChange:l,step:25,placeholder:"Pick a font size"})]})}function Ln({label:e,value:n,onChange:i}){const[o,l]=d.default.useState(Array.isArray(n)?[...n]:[]),s=d.default.useCallback(()=>{l(h=>[...h,""])},[l]),a=d.default.useCallback(h=>{l(m=>(m.splice(h,1),[...m]))},[l]),u=d.default.useMemo(()=>!I.default.isEqual(o,n),[o,n]),c=()=>{i(o.map(h=>h.toString()))};return p(K,{children:[p(r.Group,{position:"left",children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:c,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((h,m)=>t(r.TextInput,{value:h,onChange:x=>{const g=x.currentTarget.value;l(y=>(y.splice(m,1,g),[...y]))},rightSection:t(r.ActionIcon,{onClick:()=>a(m),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}function Mn({label:e,value:n,onChange:i}){const[o,l]=d.default.useState(Array.isArray(n)?[...n]:[]),s=d.default.useCallback(()=>{l(x=>[...x,""])},[l]),a=d.default.useCallback(x=>{l(g=>(g.splice(x,1),[...g]))},[l]),u=d.default.useMemo(()=>!I.default.isEqual(o,n),[o,n]),c=()=>{i(o.map(x=>x.toString()))},h=r.useMantineTheme(),m=d.default.useMemo(()=>Object.entries(h.colors).map(([x,g])=>g[6]),[h]);return p(K,{children:[p(r.Group,{position:"left",children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:c,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((x,g)=>t(r.ColorInput,{value:x,onChange:y=>{l(C=>(C.splice(g,1,y),[...C]))},swatches:m,rightSection:t(r.ActionIcon,{onClick:()=>a(g),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}function On({conf:e,setConf:n}){const i=I.default.merge({},{align:"center",size:"100px",template:"",weight:"bold",color:{type:"static",staticColor:"red"}},e),{control:o,handleSubmit:l,watch:s,formState:{isDirty:a}}=v.useForm({defaultValues:i}),u=s("color.type");return s("color.valueField"),t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,noWrap:!0,children:p("form",{onSubmit:l(n),children:[p(r.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[t(r.Text,{weight:500,children:"Stats Configurations"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Accordion,{offsetIcon:!1,multiple:!0,initialState:{0:!0,2:!0},children:[t(r.Accordion.Item,{label:"Content",children:t(r.Group,{direction:"column",grow:!0,children:t(v.Controller,{name:"template",control:o,render:({field:c})=>t(r.TextInput,f({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},c))})})}),p(r.Accordion.Item,{label:"Font",children:[t(r.Group,{direction:"column",grow:!0,children:t(v.Controller,{name:"size",control:o,render:({field:c})=>t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},c))})}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(v.Controller,{name:"weight",control:o,render:({field:c})=>t(it,f({label:"Font Weight"},c))})})]}),t(r.Accordion.Item,{label:"Color",children:p(r.Group,{direction:"column",grow:!0,children:[t(v.Controller,{name:"color.type",control:o,render:({field:c})=>t(r.Select,f({label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}]},c))}),u==="static"&&t(v.Controller,{name:"color.staticColor",control:o,render:({field:c})=>t(Se,f({},c))}),u==="continuous"&&p(K,{children:[t(v.Controller,{name:"color.valueField",control:o,defaultValue:"",render:({field:c})=>t(r.TextInput,f({placeholder:"Calculate color with this field",label:"Value Field",required:!0,sx:{flex:1}},c))}),t(v.Controller,{name:"color.valueRange",control:o,render:({field:c})=>t(Ln,f({label:"Value Range"},c))}),t(v.Controller,{name:"color.colorRange",control:o,render:({field:c})=>t(Mn,f({label:"Color Range"},c))})]})]})})]})]})})}function kn({conf:{label_field:e,value_field:n},setConf:i}){const o=q.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:o.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Sunburst Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({label:"Label Field",required:!0,sx:{flex:1}},o.getInputProps("label_field"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},o.getInputProps("value_field")))]})]})})}const En=Object.values(j).map(e=>({label:e,value:e}));function qn({label:e,value:n,onChange:i,sx:o}){return t(r.Select,{label:e,data:En,value:n,onChange:i,sx:o})}function $n(o){var l=o,{conf:s}=l,a=s,{columns:e}=a,n=D(a,["columns"]),{setConf:i}=l;const u=q.useForm({initialValues:f({id_field:"id",use_raw_columns:!0,columns:q.formList(e!=null?e:[]),fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},n)}),c=()=>u.addListItem("columns",{label:E.randomId(),value_field:"value",value_type:j.string});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:u.onSubmit(i),children:[p(r.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[t(r.Text,{children:"Table Config"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.TextInput,f({size:"md",mb:"lg",label:"ID Field"},u.getInputProps("id_field"))),p(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[t(r.TextInput,f({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("horizontalSpacing"))),t(r.TextInput,f({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("verticalSpacing")))]}),t(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},u.getInputProps("fontSize")))}),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Other"}),p(r.Group,{position:"apart",grow:!0,children:[t(r.Switch,f({label:"Striped"},u.getInputProps("striped",{type:"checkbox"}))),t(r.Switch,f({label:"Highlight on hover"},u.getInputProps("highlightOnHover",{type:"checkbox"})))]})]})]}),p(r.Group,{direction:"column",mt:"xs",spacing:"xs",grow:!0,p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[t(r.Switch,f({label:"Use Original Data Columns"},u.getInputProps("use_raw_columns",{type:"checkbox"}))),!u.values.use_raw_columns&&p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Custom Columns"}),u.values.columns.map((h,m)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[p(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:[t(r.TextInput,f({label:"Label",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"label"))),t(r.TextInput,f({label:"Value Field",placeholder:"get column value by this field",required:!0,sx:{flex:1}},u.getListInputProps("columns",m,"value_field"))),t(qn,f({label:"Value Type",sx:{flex:1}},u.getListInputProps("columns",m,"value_type")))]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>u.removeListItem("columns",m),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},m)),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:c,children:"Add a Column"})})]})]}),t(r.Text,{weight:500,mb:"md",children:"Current Configuration:"}),t(B.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(u.values,null,2)})]})})}const ot=[{align:"center",size:"xl",weight:"bold",color:"black",template:"Time: ${new Date().toISOString()}"},{align:"center",size:"md",weight:"bold",color:"red",template:"Platform: ${navigator.userAgentData.platform}."}];function Fn({conf:e,setConf:n}){var l;const i=q.useForm({initialValues:{paragraphs:q.formList((l=e.paragraphs)!=null?l:ot)}}),o=()=>i.addListItem("paragraphs",_(f({},ot[0]),{template:E.randomId()}));return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:i.onSubmit(n),children:[i.values.paragraphs.length===0&&t(r.Text,{color:"dimmed",align:"center",children:"Empty"}),p(r.Group,{position:"apart",mb:"xs",sx:{" + .mantine-Group-root":{marginTop:0}},children:[t(r.Text,{children:"Paragraphs"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:t(S.DeviceFloppy,{size:20})})]}),i.values.paragraphs.map((s,a)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({placeholder:"Time: ${new Date().toISOString()}",label:"Content Template",required:!0,sx:{flex:1}},i.getListInputProps("paragraphs",a,"template"))),p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{children:"Color"}),t(Se,f({},i.getListInputProps("paragraphs",a,"color")))]}),t(r.Group,{direction:"column",grow:!0,children:t(r.TextInput,f({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},i.getListInputProps("paragraphs",a,"size")))}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(it,f({label:"Font Weight"},i.getListInputProps("paragraphs",a,"weight")))}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i.removeListItem("paragraphs",a),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},a)),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:o,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(B.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Ce=[{value:"text",label:"Text",Panel:Fn},{value:"stats",label:"Stats",Panel:On},{value:"table",label:"Table",Panel:$n},{value:"sunburst",label:"Sunburst",Panel:kn},{value:"bar-3d",label:"Bar Chart (3D)",Panel:vn},{value:"cartesian",label:"Cartesian Chart",Panel:Pn},{value:"pie",label:"Pie Chart",Panel:An}];function Bn(){const{viz:e,setViz:n}=d.default.useContext(O),[i,o]=E.useInputState(e.type),l=e.type!==i,s=d.default.useCallback(()=>{!l||n(h=>_(f({},h),{type:i}))},[l,i]),a=h=>{n(m=>_(f({},m),{conf:h}))},u=h=>{try{a(JSON.parse(h))}catch(m){console.error(m)}},c=d.default.useMemo(()=>{var h;return(h=Ce.find(m=>m.value===i))==null?void 0:h.Panel},[i,Ce]);return p(K,{children:[t(r.Select,{label:"Visualization",value:i,onChange:o,data:Ce,rightSection:t(r.ActionIcon,{disabled:!l,onClick:s,children:t(S.DeviceFloppy,{size:20})})}),c&&t(c,{conf:e.conf,setConf:a}),!c&&t(r.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:u})]})}function Vn({}){return p(r.Group,{direction:"row",grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[t(r.Group,{grow:!0,direction:"column",noWrap:!0,sx:{width:"40%",flexShrink:0,flexGrow:0},children:t(Bn,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(Cn,{})})]})}function jn({opened:e,close:n}){const{freezeLayout:i}=d.default.useContext($),{data:o,loading:l,viz:s,title:a}=d.default.useContext(O);return d.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:a,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%"}},padding:"md",children:p(r.Tabs,{initialTab:2,children:[p(r.Tabs.Tab,{label:"Data Source",children:[t(r.LoadingOverlay,{visible:l,exitTransitionDuration:0}),t(kt,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(Ot,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Vn,{})})]})})})}function Nn({}){const[e,n]=d.default.useState(!1),i=()=>n(!0),o=()=>n(!1),{title:l,refreshData:s}=d.default.useContext(O),{inEditMode:a}=d.default.useContext($);return p(r.Group,{position:"apart",noWrap:!0,sx:{borderBottom:"1px solid #eee",paddingBottom:"5px"},children:[t(r.Group,{children:t(ke,{})}),t(r.Group,{grow:!0,position:"center",children:t(r.Text,{lineClamp:1,weight:"bold",children:l})}),t(r.Group,{position:"right",spacing:0,sx:{height:"28px"},children:p(r.Menu,{children:[t(r.Menu.Item,{onClick:s,icon:t(S.Refresh,{size:14}),children:"Refresh"}),a&&t(r.Menu.Item,{onClick:i,icon:t(S.Settings,{size:14}),children:"Settings"}),t(r.Divider,{}),t(r.Menu.Item,{color:"red",disabled:!0,icon:t(S.Trash,{size:14}),children:"Delete"})]})}),a&&t(jn,{opened:e,close:o})]})}var mr="";function ve({viz:e,dataSourceID:n,title:i,description:o,update:l,layout:s,id:a}){const u=d.default.useContext(Q),c=d.default.useContext(k),[h,m]=d.default.useState(i),[x,g]=d.default.useState(o),[y,C]=d.default.useState(n),[T,z]=d.default.useState(e),A=d.default.useMemo(()=>{if(!!y)return c.dataSources.find(ze=>ze.id===y)},[y,c.dataSources]);d.default.useEffect(()=>{l==null||l({id:a,layout:s,title:h,description:x,dataSourceID:y,viz:T})},[h,x,A,T,a,s,y]);const{data:L=[],loading:ue,refresh:Te}=pe.useRequest(Le({context:u,definitions:c,title:h,dataSource:A}),{refreshDeps:[u,c,A]}),Ge=Te;return t(O.Provider,{value:{data:L,loading:ue,title:h,setTitle:m,description:x,setDescription:g,dataSourceID:y,setDataSourceID:C,viz:T,setViz:z,refreshData:Ge},children:p(r.Container,{className:"panel-root",children:[t(Nn,{}),t(fe,{children:t(nt,{viz:T,data:L,loading:ue})})]})})}var hr="";const Rn=P.WidthProvider(P.Responsive);function lt({panels:e,setPanels:n,className:i="layout",cols:o={lg:12,md:10,sm:8,xs:6,xxs:4},rowHeight:l=10,onRemoveItem:s,isDraggable:a,isResizable:u,setLocalCols:c,setBreakpoint:h}){const m=(g,y)=>{h(g),c(y)},x=d.default.useCallback(g=>{const y=new Map;g.forEach(A=>{var L=A,{i:T}=L,z=D(L,["i"]);y.set(T,z)});const C=e.map(T=>_(f({},T),{layout:y.get(T.id)}));n(C)},[e,n]);return t(Rn,{onBreakpointChange:m,onLayoutChange:x,className:i,cols:o,rowHeight:l,isDraggable:a,isResizable:u,children:e.map((T,C)=>{var z=T,{id:g}=z,y=D(z,["id"]);return t("div",{"data-grid":y.layout,children:t(ve,_(f({id:g},y),{destroy:()=>s(g),update:A=>{n(L=>(L.splice(C,1,A),[...L]))}}))},g)})})}function we(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function Wn({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:we(t(S.PlayerPlay,{size:20}),"Use"),value:M.Use},{label:we(t(S.Resize,{size:20}),"Layout"),value:M.Layout},{label:we(t(S.Paint,{size:20}),"Content"),value:M.Edit}]})}const Qn=`
11
11
  -- You may reference context data or SQL snippets *by name*
12
12
  -- in SQL or VizConfig.
13
13
  SELECT *
@@ -30,4 +30,4 @@ ${i}
30
30
 
31
31
  -- where author_time_condition is:
32
32
  author_time BETWEEN '\${timeRange?.[0].toISOString()}' AND '\${timeRange?.[1].toISOString()}'
33
- `}),p(r.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:[l.values.snippets.map((c,h)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({label:"Key",required:!0},l.getListInputProps("snippets",h,"key"))),t(r.Textarea,f({minRows:3,label:"Value",required:!0},l.getListInputProps("snippets",h,"value"))),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("snippets",h),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},h)),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:t(r.Button,{variant:"default",onClick:s,children:"Add a snippet"})})]})]})]})})}function er({opened:e,close:n}){const{freezeLayout:i}=d.default.useContext($);return d.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:"SQL Snippets",trapFocus:!0,onDragStart:o=>{o.stopPropagation()},children:t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:p(r.Group,{direction:"row",position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[t(Hn,{}),t(Zn,{})]})})})}function tr({mode:e,setMode:n,hasChanges:i,addPanel:o,saveChanges:l}){const{inLayoutMode:s,inEditMode:a,inUseMode:u}=d.default.useContext($),[c,h]=d.default.useState(!1),m=()=>h(!0),x=()=>h(!1),[g,y]=d.default.useState(!1),C=()=>y(!0),T=()=>y(!1);return p(r.Group,{position:"apart",pt:"sm",pb:"xs",children:[t(r.Group,{position:"left",children:t(Wn,{mode:e,setMode:n})}),p(r.Group,{position:"right",children:[s&&t(r.Button,{variant:"default",size:"sm",onClick:o,leftIcon:t(S.PlaylistAdd,{size:20}),children:"Add a Panel"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:C,leftIcon:t(S.ClipboardText,{size:20}),children:"SQL Snippets"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:m,leftIcon:t(S.Database,{size:20}),children:"Data Sources"}),!u&&t(r.Button,{variant:"default",size:"sm",onClick:l,disabled:!i,leftIcon:t(S.DeviceFloppy,{size:20}),children:"Save Changes"}),!u&&t(r.Button,{color:"red",size:"sm",disabled:!i,leftIcon:t(S.Recycle,{size:20}),children:"Revert Changes"})]}),t(Xn,{opened:c,close:x}),t(er,{opened:g,close:T}),u&&t(r.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:t(S.Share,{size:20}),children:"Share"})]})}function nr({context:e,dashboard:n,update:i,className:o="dashboard"}){const[l,s]=d.default.useState(!1),[a,u]=d.default.useState(),[c,h]=d.default.useState(),[m,x]=d.default.useState(n.panels),[g,y]=d.default.useState(n.definition.sqlSnippets),[C,T]=d.default.useState(n.definition.dataSources),[_,A]=d.default.useState(M.Edit),L=d.default.useMemo(()=>{const F=R=>JSON.parse(JSON.stringify(R));return!I.default.isEqual(F(m),F(n.panels))||!I.default.isEqual(g,n.definition.sqlSnippets)?!0:!I.default.isEqual(C,n.definition.dataSources)},[n,m,g,C]),ue=async()=>{const F=z(f({},n),{panels:m,definition:{sqlSnippets:g,dataSources:C}});await i(F)},Te=()=>{const F=E.randomId(),de={id:F,layout:{x:0,y:1/0,w:3,h:4},title:`New Panel - ${F}`,description:"description goes here",dataSourceID:"",viz:{type:"table",conf:{}}};x(R=>[...R,de])},Ge=F=>{const de=m.findIndex(R=>R.id===F);x(R=>(R.splice(de,1),[...R]))},_e=_===M.Edit,ze=_===M.Layout,lr=_===M.Use,ar=d.default.useMemo(()=>({sqlSnippets:g,setSQLSnippets:y,dataSources:C,setDataSources:T}),[g,y,C,T]);return t(Q.Provider,{value:e,children:t("div",{className:o,children:t(k.Provider,{value:ar,children:p($.Provider,{value:{layoutFrozen:l,freezeLayout:s,mode:_,inEditMode:_e,inLayoutMode:ze,inUseMode:lr},children:[t(tr,{mode:_,setMode:A,hasChanges:L,addPanel:Te,saveChanges:ue}),t(lt,{panels:m,setPanels:x,isDraggable:ze,isResizable:ze,onRemoveItem:Ge,setLocalCols:h,setBreakpoint:u})]})})})})}const rr=P.WidthProvider(P.Responsive);function ir({panels:e,className:n="layout",cols:i={lg:12,md:10,sm:8,xs:6,xxs:4},rowHeight:o=10}){return t(rr,{className:n,cols:i,rowHeight:o,isDraggable:!1,isResizable:!1,children:e.map(a=>{var u=a,{id:l}=u,s=D(u,["id"]);return t("div",{"data-grid":s.layout,children:t(ve,f({id:l},s))},l)})})}function or({context:e,dashboard:n,className:i="dashboard"}){const o=d.default.useMemo(()=>z(f({},n.definition),{setSQLSnippets:()=>{},setDataSources:()=>{}}),[n]);return t(Q.Provider,{value:e,children:t("div",{className:i,children:t(k.Provider,{value:o,children:t($.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:M.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:t(ir,{panels:n.panels})})})})})}b.ContextInfoContext=Q,b.Dashboard=nr,b.DashboardLayout=lt,b.DashboardMode=M,b.DefinitionContext=k,b.LayoutStateContext=$,b.Panel=ve,b.PanelContext=O,b.ReadOnlyDashboard=or,b.initialContextInfoContext=vt,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
33
+ `}),p(r.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:[l.values.snippets.map((c,h)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,f({label:"Key",required:!0},l.getListInputProps("snippets",h,"key"))),t(r.Textarea,f({minRows:3,label:"Value",required:!0},l.getListInputProps("snippets",h,"value"))),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("snippets",h),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},h)),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:t(r.Button,{variant:"default",onClick:s,children:"Add a snippet"})})]})]})]})})}function er({opened:e,close:n}){const{freezeLayout:i}=d.default.useContext($);return d.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:"SQL Snippets",trapFocus:!0,onDragStart:o=>{o.stopPropagation()},children:t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:p(r.Group,{direction:"row",position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[t(Hn,{}),t(Zn,{})]})})})}function tr({mode:e,setMode:n,hasChanges:i,addPanel:o,saveChanges:l}){const{inLayoutMode:s,inEditMode:a,inUseMode:u}=d.default.useContext($),[c,h]=d.default.useState(!1),m=()=>h(!0),x=()=>h(!1),[g,y]=d.default.useState(!1),C=()=>y(!0),T=()=>y(!1);return p(r.Group,{position:"apart",pt:"sm",pb:"xs",children:[t(r.Group,{position:"left",children:t(Wn,{mode:e,setMode:n})}),p(r.Group,{position:"right",children:[!u&&t(r.Button,{variant:"default",size:"sm",onClick:o,leftIcon:t(S.PlaylistAdd,{size:20}),children:"Add a Panel"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:C,leftIcon:t(S.ClipboardText,{size:20}),children:"SQL Snippets"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:m,leftIcon:t(S.Database,{size:20}),children:"Data Sources"}),!u&&t(r.Button,{variant:"default",size:"sm",onClick:l,disabled:!i,leftIcon:t(S.DeviceFloppy,{size:20}),children:"Save Changes"}),!u&&t(r.Button,{color:"red",size:"sm",disabled:!i,leftIcon:t(S.Recycle,{size:20}),children:"Revert Changes"})]}),t(Xn,{opened:c,close:x}),t(er,{opened:g,close:T}),u&&t(r.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:t(S.Share,{size:20}),children:"Share"})]})}function nr({context:e,dashboard:n,update:i,className:o="dashboard"}){const[l,s]=d.default.useState(!1),[a,u]=d.default.useState(),[c,h]=d.default.useState(),[m,x]=d.default.useState(n.panels),[g,y]=d.default.useState(n.definition.sqlSnippets),[C,T]=d.default.useState(n.definition.dataSources),[z,A]=d.default.useState(M.Edit),L=d.default.useMemo(()=>{const F=R=>JSON.parse(JSON.stringify(R));return!I.default.isEqual(F(m),F(n.panels))||!I.default.isEqual(g,n.definition.sqlSnippets)?!0:!I.default.isEqual(C,n.definition.dataSources)},[n,m,g,C]),ue=async()=>{const F=_(f({},n),{panels:m,definition:{sqlSnippets:g,dataSources:C}});await i(F)},Te=()=>{const F=E.randomId(),de={id:F,layout:{x:0,y:1/0,w:3,h:15},title:`New Panel - ${F}`,description:"",dataSourceID:"",viz:{type:"text",conf:{}}};x(R=>[...R,de])},Ge=F=>{const de=m.findIndex(R=>R.id===F);x(R=>(R.splice(de,1),[...R]))},ze=z===M.Edit,_e=z===M.Layout,lr=z===M.Use,ar=d.default.useMemo(()=>({sqlSnippets:g,setSQLSnippets:y,dataSources:C,setDataSources:T}),[g,y,C,T]);return t(Q.Provider,{value:e,children:t("div",{className:o,children:t(k.Provider,{value:ar,children:p($.Provider,{value:{layoutFrozen:l,freezeLayout:s,mode:z,inEditMode:ze,inLayoutMode:_e,inUseMode:lr},children:[t(tr,{mode:z,setMode:A,hasChanges:L,addPanel:Te,saveChanges:ue}),t(lt,{panels:m,setPanels:x,isDraggable:_e,isResizable:_e,onRemoveItem:Ge,setLocalCols:h,setBreakpoint:u})]})})})})}const rr=P.WidthProvider(P.Responsive);function ir({panels:e,className:n="layout",cols:i={lg:12,md:10,sm:8,xs:6,xxs:4},rowHeight:o=10}){return t(rr,{className:n,cols:i,rowHeight:o,isDraggable:!1,isResizable:!1,children:e.map(a=>{var u=a,{id:l}=u,s=D(u,["id"]);return t("div",{"data-grid":s.layout,children:t(ve,f({id:l},s))},l)})})}function or({context:e,dashboard:n,className:i="dashboard"}){const o=d.default.useMemo(()=>_(f({},n.definition),{setSQLSnippets:()=>{},setDataSources:()=>{}}),[n]);return t(Q.Provider,{value:e,children:t("div",{className:i,children:t(k.Provider,{value:o,children:t($.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:M.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:t(ir,{panels:n.panels})})})})})}b.ContextInfoContext=Q,b.Dashboard=nr,b.DashboardLayout=lt,b.DashboardMode=M,b.DefinitionContext=k,b.LayoutStateContext=$,b.Panel=ve,b.PanelContext=O,b.ReadOnlyDashboard=or,b.initialContextInfoContext=vt,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,16 +1,18 @@
1
+ import { TNumbroFormat } from "../../settings/common/numbro-format-selector";
1
2
  export interface ICartesianChartSeriesItem {
2
3
  type: 'line' | 'bar';
3
4
  name: string;
4
5
  showSymbol: false;
5
6
  y_axis_data_key: string;
7
+ yAxisIndex: number;
6
8
  label_position?: string;
7
9
  stack: string;
8
10
  color?: string;
11
+ barWidth: string;
9
12
  }
10
13
  export interface IYAxisConf {
11
- id: string;
12
14
  name: string;
13
- label_formatter: string;
15
+ label_formatter: TNumbroFormat;
14
16
  }
15
17
  export interface ICartesianChartConf {
16
18
  x_axis_data_key: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
File without changes