@devtable/dashboard 1.20.0 → 1.21.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.
@@ -36,7 +36,7 @@ var __publicField = (obj, key, value) => {
36
36
  import React from "react";
37
37
  import _ from "lodash";
38
38
  import RGL, { WidthProvider } from "react-grid-layout";
39
- import { Popover, Tooltip, Group, Text, ActionIcon, Box, Button, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, Switch, SegmentedControl, NumberInput, Slider, ColorInput, Accordion, JsonInput, Modal, AppShell, Tabs, Menu, Divider, Container, Textarea } from "@mantine/core";
39
+ import { Popover, Tooltip, Group, Text, ActionIcon, Box, Button, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, Switch, Slider, SegmentedControl, NumberInput, ColorInput, Accordion, JsonInput, Modal, AppShell, Tabs, Menu, Divider, Container, Textarea } from "@mantine/core";
40
40
  import { useRequest } from "ahooks";
41
41
  import axios from "axios";
42
42
  import { InfoCircle, DeviceFloppy, Refresh, Trash, PlaylistAdd, Settings, Resize, Paint, PlayerPlay, Database, Recycle, Share } from "tabler-icons-react";
@@ -44,7 +44,7 @@ import RichTextEditor, { RichTextEditor as RichTextEditor$1 } from "@mantine/rte
44
44
  import { useInputState, useElementSize, randomId } from "@mantine/hooks";
45
45
  import ReactEChartsCore from "echarts-for-react/lib/core";
46
46
  import * as echarts from "echarts/core";
47
- import { SunburstChart, BarChart, LineChart, PieChart } from "echarts/charts";
47
+ import { SunburstChart, BarChart, LineChart, ScatterChart, PieChart } from "echarts/charts";
48
48
  import { CanvasRenderer } from "echarts/renderers";
49
49
  import { GridComponent, LegendComponent, TooltipComponent, VisualMapComponent } from "echarts/components";
50
50
  import numbro from "numbro";
@@ -688,7 +688,7 @@ function Sunbrust({
688
688
  }
689
689
  });
690
690
  }
691
- echarts.use([BarChart, LineChart, GridComponent, LegendComponent, TooltipComponent, CanvasRenderer]);
691
+ echarts.use([BarChart, LineChart, ScatterChart, GridComponent, LegendComponent, TooltipComponent, CanvasRenderer]);
692
692
  const defaultOption$1 = {
693
693
  legend: {
694
694
  show: true,
@@ -2005,6 +2005,47 @@ function LineFields({
2005
2005
  })]
2006
2006
  });
2007
2007
  }
2008
+ const symbolSizeOptions = Array.from(new Array(9), (_2, i) => ({
2009
+ label: String(i + 1),
2010
+ value: i + 1
2011
+ }));
2012
+ function ScatterFields({
2013
+ control,
2014
+ index: index2
2015
+ }) {
2016
+ return /* @__PURE__ */ jsx(Group, {
2017
+ direction: "row",
2018
+ grow: true,
2019
+ align: "center",
2020
+ children: /* @__PURE__ */ jsx(Controller, {
2021
+ name: `series.${index2}.symbolSize`,
2022
+ control,
2023
+ render: ({
2024
+ field
2025
+ }) => /* @__PURE__ */ jsxs(Group, {
2026
+ direction: "column",
2027
+ noWrap: true,
2028
+ sx: {
2029
+ flexGrow: 1
2030
+ },
2031
+ pb: 16,
2032
+ spacing: 4,
2033
+ children: [/* @__PURE__ */ jsx(Text, {
2034
+ size: "sm",
2035
+ children: "Size"
2036
+ }), /* @__PURE__ */ jsx(Slider, __spreadProps(__spreadValues({
2037
+ min: 1,
2038
+ max: 10,
2039
+ marks: symbolSizeOptions
2040
+ }, field), {
2041
+ sx: {
2042
+ width: "100%"
2043
+ }
2044
+ }))]
2045
+ })
2046
+ })
2047
+ });
2048
+ }
2008
2049
  const labelPositions = [{
2009
2050
  label: "off",
2010
2051
  value: ""
@@ -2085,8 +2126,7 @@ function SeriesItemField({
2085
2126
  value: "bar"
2086
2127
  }, {
2087
2128
  label: "Scatter",
2088
- value: "scatter",
2089
- disabled: true
2129
+ value: "scatter"
2090
2130
  }, {
2091
2131
  label: "Boxplot",
2092
2132
  value: "boxplot",
@@ -2162,6 +2202,9 @@ function SeriesItemField({
2162
2202
  }), type === "bar" && /* @__PURE__ */ jsx(BarFields, {
2163
2203
  index: index2,
2164
2204
  control
2205
+ }), type === "scatter" && /* @__PURE__ */ jsx(ScatterFields, {
2206
+ index: index2,
2207
+ control
2165
2208
  }), /* @__PURE__ */ jsx(Controller, {
2166
2209
  name: `series.${index2}.label_position`,
2167
2210
  control,
@@ -2222,6 +2265,7 @@ function SeriesField({
2222
2265
  type: "bar",
2223
2266
  name: randomId(),
2224
2267
  showSymbol: false,
2268
+ symbolSize: 5,
2225
2269
  y_axis_data_key: "value",
2226
2270
  yAxisIndex: 0,
2227
2271
  label_position: "top",
@@ -2429,6 +2473,7 @@ function withDefaults(series) {
2429
2473
  type,
2430
2474
  name,
2431
2475
  showSymbol,
2476
+ symbolSize = 5,
2432
2477
  y_axis_data_key = "value",
2433
2478
  yAxisIndex = 0,
2434
2479
  label_position = "top",
@@ -2442,6 +2487,7 @@ function withDefaults(series) {
2442
2487
  type,
2443
2488
  name,
2444
2489
  showSymbol,
2490
+ symbolSize,
2445
2491
  y_axis_data_key,
2446
2492
  yAxisIndex,
2447
2493
  label_position,
@@ -1,4 +1,4 @@
1
- (function(b,v){typeof exports=="object"&&typeof module!="undefined"?v(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"],v):(b=typeof globalThis!="undefined"?globalThis:b||self,v(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,v,_,L,r,he,ft,S,Le,E,mt,ht,re,ie,W,xt,Tr,w,$,k){"use strict";var Sr=Object.defineProperty,wr=Object.defineProperties;var vr=Object.getOwnPropertyDescriptors;var me=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var Ie=(b,v,_)=>v in b?Sr(b,v,{enumerable:!0,configurable:!0,writable:!0,value:_}):b[v]=_,h=(b,v)=>{for(var _ in v||(v={}))dt.call(v,_)&&Ie(b,_,v[_]);if(me)for(var _ of me(v))ct.call(v,_)&&Ie(b,_,v[_]);return b},G=(b,v)=>wr(b,vr(v));var P=(b,v)=>{var _={};for(var L in b)dt.call(b,L)&&v.indexOf(L)<0&&(_[L]=b[L]);if(b!=null&&me)for(var L of me(b))v.indexOf(L)<0&&ct.call(b,L)&&(_[L]=b[L]);return _};var pt=(b,v,_)=>(Ie(b,typeof v!="symbol"?v+"":v,_),_);function U(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function gt(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 l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),n.default=e,Object.freeze(n)}var c=U(v),z=U(_),Ae=U(L),bt=U(ft),yt=U(Le),le=U(mt),B=gt(ht),K=U(xt),M=(e=>(e.Use="use",e.Layout="layout",e.Edit="edit",e))(M||{});const Ct={layoutFrozen:!1,freezeLayout:()=>{},mode:M.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},j=c.default.createContext(Ct);function St(e,n){const i=Object.keys(n),l=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(o){return console.error(o),o.message}}function xe(e,n){const i=Object.keys(n),l=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(o){throw i.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):o}}function De(e,n){const i=n.sqlSnippets.reduce((l,o)=>(l[o.key]=xe(o.value,e),l),{});return z.default.merge({},i,e)}function wt(e,n,i){try{const l=De(n,i);return xe(e,l)}catch(l){return console.error(l),l.message}}const Y={baseURL:"http://localhost:31200",getRequest(e){return(n,i,l={})=>{const o=h({"X-Requested-With":"XMLHttpRequest","Content-Type":l.string?"application/x-www-form-urlencoded":"application/json"},l.headers),s={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?i:l.params,headers:o};return e==="POST"&&(s.data=l.string?JSON.stringify(i):i),bt.default(s).then(a=>a.data).catch(a=>Promise.reject(a))}}},Me=({context:e,definitions:n,title:i,query:l})=>async()=>{if(!l||!l.sql)return[];const{type:o,key:s,sql:a}=l,u=a.includes("$");try{const d=De(e,n),f=xe(a,d);return u&&(console.groupCollapsed(`Final SQL for: ${i}`),console.log(f),console.groupEnd()),await Y.getRequest("POST")("/query",{type:o,key:s,sql:f})}catch(d){return console.error(d),[]}};async function vt(){try{return await Y.getRequest("GET")("/query/sources",{})}catch(e){return console.error(e),{}}}const qe={},Tt=qe,R=c.default.createContext(qe),Gt={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},queryID:"",setQueryID:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},q=c.default.createContext(Gt),_t={sqlSnippets:[],setSQLSnippets:()=>{},queries:[],setQueries:()=>{}},O=c.default.createContext(_t);var oe={exports:{}},ae={};/**
1
+ (function(y,v){typeof exports=="object"&&typeof module!="undefined"?v(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"],v):(y=typeof globalThis!="undefined"?globalThis:y||self,v(y.dashboard={},y.React,y._,y["react-grid-layout"],y["@mantine/core"],y.ahooks,y.axios,y["tabler-icons-react"],y["@mantine/rte"],y["@mantine/hooks"],y["echarts-for-react/lib/core"],y["echarts/core"],y["echarts/charts"],y["echarts/renderers"],y["echarts/components"],y.numbro,y["echarts-gl"],y["react-hook-form"],y["@mantine/form"],y["@mantine/prism"]))})(this,function(y,v,_,L,r,he,ft,S,Le,E,mt,ht,K,ie,Q,xt,_r,w,$,k){"use strict";var vr=Object.defineProperty,Tr=Object.defineProperties;var Gr=Object.getOwnPropertyDescriptors;var me=Object.getOwnPropertySymbols;var dt=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable;var Ie=(y,v,_)=>v in y?vr(y,v,{enumerable:!0,configurable:!0,writable:!0,value:_}):y[v]=_,h=(y,v)=>{for(var _ in v||(v={}))dt.call(v,_)&&Ie(y,_,v[_]);if(me)for(var _ of me(v))ct.call(v,_)&&Ie(y,_,v[_]);return y},G=(y,v)=>Tr(y,Gr(v));var P=(y,v)=>{var _={};for(var L in y)dt.call(y,L)&&v.indexOf(L)<0&&(_[L]=y[L]);if(y!=null&&me)for(var L of me(y))v.indexOf(L)<0&&ct.call(y,L)&&(_[L]=y[L]);return _};var pt=(y,v,_)=>(Ie(y,typeof v!="symbol"?v+"":v,_),_);function U(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function gt(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 l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),n.default=e,Object.freeze(n)}var c=U(v),z=U(_),Ae=U(L),bt=U(ft),yt=U(Le),le=U(mt),B=gt(ht),Z=U(xt),M=(e=>(e.Use="use",e.Layout="layout",e.Edit="edit",e))(M||{});const Ct={layoutFrozen:!1,freezeLayout:()=>{},mode:M.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},j=c.default.createContext(Ct);function St(e,n){const i=Object.keys(n),l=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(o){return console.error(o),o.message}}function xe(e,n){const i=Object.keys(n),l=Object.values(n);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(o){throw i.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):o}}function De(e,n){const i=n.sqlSnippets.reduce((l,o)=>(l[o.key]=xe(o.value,e),l),{});return z.default.merge({},i,e)}function wt(e,n,i){try{const l=De(n,i);return xe(e,l)}catch(l){return console.error(l),l.message}}const Y={baseURL:"http://localhost:31200",getRequest(e){return(n,i,l={})=>{const o=h({"X-Requested-With":"XMLHttpRequest","Content-Type":l.string?"application/x-www-form-urlencoded":"application/json"},l.headers),s={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?i:l.params,headers:o};return e==="POST"&&(s.data=l.string?JSON.stringify(i):i),bt.default(s).then(a=>a.data).catch(a=>Promise.reject(a))}}},Me=({context:e,definitions:n,title:i,query:l})=>async()=>{if(!l||!l.sql)return[];const{type:o,key:s,sql:a}=l,u=a.includes("$");try{const d=De(e,n),f=xe(a,d);return u&&(console.groupCollapsed(`Final SQL for: ${i}`),console.log(f),console.groupEnd()),await Y.getRequest("POST")("/query",{type:o,key:s,sql:f})}catch(d){return console.error(d),[]}};async function vt(){try{return await Y.getRequest("GET")("/query/sources",{})}catch(e){return console.error(e),{}}}const qe={},Tt=qe,R=c.default.createContext(qe),Gt={data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},queryID:"",setQueryID:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},q=c.default.createContext(Gt),_t={sqlSnippets:[],setSQLSnippets:()=>{},queries:[],setQueries:()=>{}},O=c.default.createContext(_t);var oe={exports:{}},ae={};/**
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 zt=c.default,Pt=Symbol.for("react.element"),It=Symbol.for("react.fragment"),Lt=Object.prototype.hasOwnProperty,At=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Dt={key:!0,ref:!0,__self:!0,__source:!0};function Oe(e,n,i){var l,o={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(l in n)Lt.call(n,l)&&!Dt.hasOwnProperty(l)&&(o[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps,n)o[l]===void 0&&(o[l]=n[l]);return{$$typeof:Pt,type:e,key:s,ref:a,props:o,_owner:At.current}}ae.Fragment=It,ae.jsx=Oe,ae.jsxs=Oe,oe.exports=ae;const t=oe.exports.jsx,p=oe.exports.jsxs,Z=oe.exports.Fragment;function ke({position:e="bottom",trigger:n="hover"}){const{freezeLayout:i}=c.default.useContext(j),[l,o]=c.default.useState(!1),{description:s}=c.default.useContext(q);if(c.default.useEffect(()=>{i(l)},[l]),!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:()=>o(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(S.InfoCircle,{size:20,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:l,onClose:()=>o(!1),withCloseButton:n==="click",withArrow:!0,trapFocus:!0,closeOnEscape:!1,placement:"center",position:e,target:a,width:"40vw",children:t(yt.default,{readOnly:!0,value:s,onChange:z.default.noop,sx:{border:"none"}})})}function Mt(){const{description:e,setDescription:n}=c.default.useContext(q),[i,l]=c.default.useState(e),o=e!==i,s=c.default.useCallback(()=>{!o||n(i)},[o,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:!o,onClick:s,children:t(S.DeviceFloppy,{size:20})})]}),t(Le.RichTextEditor,{value:i,onChange:l,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Ee extends c.default.Component{constructor(n){super(n),this.state={error:null}}componentDidCatch(n){this.setState({error:n})}render(){var n;if(this.state.error){const i=()=>{this.setState({error:null})};return p(r.Box,{children:[t(r.Text,{size:"xs",children:(n=this.state.error)==null?void 0:n.message}),t(r.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:i,children:"Retry"})]})}return this.props.children}}function qt(){const{title:e}=c.default.useContext(q);return t(Ee,{children:p(r.Group,{direction:"column",grow:!0,noWrap:!0,mx:"auto",mt:"xl",p:"5px",spacing:5,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:{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 Ot(){const{title:e,setTitle:n}=c.default.useContext(q),[i,l]=E.useInputState(e),o=e!==i,s=c.default.useCallback(()=>{!o||n(i)},[o,i]);return t(r.TextInput,{value:i,onChange:l,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!o,onClick:s,children:t(S.DeviceFloppy,{size:20})})]})})}function kt({}){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(Ot,{}),t(Mt,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(qt,{})})]})}function $e({id:e}){const n=c.default.useContext(O),i=c.default.useContext(R),l=c.default.useMemo(()=>n.queries.find(u=>u.id===e),[n.queries,e]),{data:o=[],loading:s,refresh:a}=he.useRequest(Me({context:i,definitions:n,title:e,query:l}),{refreshDeps:[i,n,l]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):o.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"}),o.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",o.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(o==null?void 0:o[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:o.slice(0,10).map((u,d)=>t("tr",{children:Object.values(u).map((f,x)=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:t(r.Text,{children:f})})},`${f}--${x}`))},`row-${d}`))})]})]})}function Et({}){const{queries:e}=c.default.useContext(O),{queryID:n,setQueryID:i,data:l,loading:o}=c.default.useContext(q),s=c.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 Query"}),t(r.Select,{data:s,value:n,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),t($e,{id:n})]})}B.use([re.SunburstChart,ie.CanvasRenderer]);const $t={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function Rt({conf:e,data:n,width:i,height:l}){const m=e,{label_field:o="name",value_field:s="value"}=m,a=P(m,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(g=>({name:g[o],value:Number(g[s])})),[n,o,s]),d=c.default.useMemo(()=>{var g,y;return(y=(g=z.default.maxBy(u,C=>C.value))==null?void 0:g.value)!=null?y:1},[u]),f=c.default.useMemo(()=>({series:{label:{formatter:({name:g,value:y})=>y/d<.2?" ":g}}}),[d]),x=z.default.merge({},$t,f,a,{series:{data:u}});return t(le.default,{echarts:B,option:x,style:{width:i,height:l}})}B.use([re.BarChart,re.LineChart,W.GridComponent,W.LegendComponent,W.TooltipComponent,ie.CanvasRenderer]);const Ft={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 Bt({conf:e,data:n,width:i,height:l}){const o=c.default.useMemo(()=>{var f;const s=e.y_axes.reduce((x,{label_formatter:m},g)=>(x[g]=function(C){const T=typeof C=="object"?C.value:C;if(!m)return T;try{return K.default(T).format(m)}catch(I){return console.error(I),T}},x),{default:({value:x})=>x}),a=e.series.reduce((x,{yAxisIndex:m,name:g})=>(x[g]=m,x),{}),u=e.series.map(T=>{var I=T,{y_axis_data_key:x,yAxisIndex:m,label_position:g,name:y}=I,C=P(I,["y_axis_data_key","yAxisIndex","label_position","name"]);return h({data:n.map(X=>X[x]),label:{show:!!g,position:g,formatter:s[m!=null?m:"default"]},name:y,yAxisIndex:m},C)}),d={xAxis:{data:n.map(x=>x[e.x_axis_data_key]),name:(f=e.x_axis_name)!=null?f:""},yAxis:e.y_axes.map((y,g)=>{var C=y,{label_formatter:x}=C,m=P(C,["label_formatter"]);var T;return G(h({},m),{axisLabel:{show:!0,formatter:(T=s[g])!=null?T:s.default}})}),dataset:{source:n},series:u,tooltip:{formatter:function(x){const m=Array.isArray(x)?x:[x];if(m.length===0)return"";const g=m.map(({seriesName:y,value:C})=>{var D;if(!y)return C;const T=a[y],I=(D=s[T])!=null?D:s.default;return`${y}: ${I({value:C})}`});return g.unshift(`<strong>${m[0].name}</strong>`),g.join("<br />")}}};return z.default.merge({},Ft,d)},[e,n]);return!i||!l?null:t(le.default,{echarts:B,option:o,style:{width:i,height:l}})}var N=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(N||{});function jt({value:e}){return t(r.Text,{component:"span",children:e})}function Nt({value:e}){return t(r.Text,{component:"span",children:e})}function Vt({value:e}){const n=K.default(e).format({thousandSeparated:!0});return t(r.Text,{component:"span",children:n})}function Qt({value:e}){const n=K.default(e).format({output:"percent",mantissa:3});return t(r.Text,{component:"span",children:n})}function Wt({value:e,type:n}){switch(n){case N.string:return t(jt,{value:e});case N.eloc:return t(Nt,{value:e});case N.number:return t(Vt,{value:e});case N.percentage:return t(Qt,{value:e})}}function Ut({conf:e,data:n=[],width:i,height:l}){const x=e,{id_field:o,use_raw_columns:s,columns:a}=x,u=P(x,["id_field","use_raw_columns","columns"]),d=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]):a.map(m=>m.label),[s,a,n]),f=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]).map(m=>({label:m,value_field:m,value_type:N.string})):a,[s,a,n]);return p(r.Table,G(h({sx:{maxHeight:l}},u),{children:[t("thead",{children:t("tr",{children:d.map(m=>t("th",{children:m},m))})}),t("tbody",{children:n.slice(0,30).map((m,g)=>t("tr",{children:f.map(({value_field:y,value_type:C})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(Wt,{value:m[y],type:C})})},`${y}--${m[y]}`))},o?m[o]:`row-${g}`))}),n.length>100&&t("tfoot",{children:t("tr",{children:t("td",{colSpan:d.length,children:t(r.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]}))}function Jt(e,n={}){const i=G(h({},n),{numbro:K.default}),l=Object.keys(i),o=Object.values(i);try{return new Function(...l,`return \`${e}\`;`)(...o)}catch(s){return s.message}}function Yt({conf:{paragraphs:e},data:n}){return t(Z,{children:e.map((a,s)=>{var u=a,{template:i,size:l}=u,o=P(u,["template","size"]);return t(r.Text,G(h({},o),{sx:{fontSize:l},children:Jt(i,n[0])}),`${i}---${s}`)})})}B.use([W.GridComponent,W.VisualMapComponent,W.LegendComponent,W.TooltipComponent,ie.CanvasRenderer]);function Xt({conf:e,data:n,width:i,height:l}){const m=e,{x_axis_data_key:o,y_axis_data_key:s,z_axis_data_key:a}=m,u=P(m,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),d=c.default.useMemo(()=>z.default.minBy(n,g=>g[a])[a],[n,a]),f=c.default.useMemo(()=>z.default.maxBy(n,g=>g[a])[a],[n,a]),x=G(h({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:d,max:f,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[o],g[s],g[a]])}]});return t(le.default,{echarts:B,option:x,style:{width:i,height:l}})}var Gr="";B.use([re.PieChart,ie.CanvasRenderer]);const Kt={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 Zt({conf:e,data:n,width:i,height:l}){const x=e,{label_field:o="name",value_field:s="value"}=x,a=P(x,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(m=>({name:m[o],value:Number(m[s])})),[n,o,s]),d=c.default.useMemo(()=>({series:{labelLayout:function(m){const g=m.labelRect.x<i/2,y=m.labelLinePoints;return y[2][0]=g?m.labelRect.x:m.labelRect.x+m.labelRect.width,{labelLinePoints:y}}}}),[i]),f=z.default.merge({},Kt,d,a,{series:{data:u}});return t(le.default,{echarts:B,option:f,style:{width:i,height:l}})}var Re=function(){};const Ht=(e,n,i)=>Math.min(Math.max(i,e),n),Fe=(e,n,i)=>{const l=n-e;return l===0?1:(i-e)/l},ge=(e,n,i)=>-i*e+i*n+e,Be=(e,n)=>i=>Math.max(Math.min(i,n),e),H=e=>e%1?Number(e.toFixed(5)):e,se=/(-)?([\d]*\.?[\d])+/g,be=/(#[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,en=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function ee(e){return typeof e=="string"}const ue={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},je=Object.assign(Object.assign({},ue),{transform:Be(0,1)});Object.assign(Object.assign({},ue),{default:1});const te=(e=>({test:n=>ee(n)&&n.endsWith(e)&&n.split(" ").length===1,parse:parseFloat,transform:n=>`${n}${e}`}))("%");Object.assign(Object.assign({},te),{parse:e=>te.parse(e)/100,transform:e=>te.transform(e*100)});const ye=(e,n)=>i=>Boolean(ee(i)&&en.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),Ne=(e,n,i)=>l=>{if(!ee(l))return l;const[o,s,a,u]=l.match(se);return{[e]:parseFloat(o),[n]:parseFloat(s),[i]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},J={test:ye("hsl","hue"),parse:Ne("hue","saturation","lightness"),transform:({hue:e,saturation:n,lightness:i,alpha:l=1})=>"hsla("+Math.round(e)+", "+te.transform(H(n))+", "+te.transform(H(i))+", "+H(je.transform(l))+")"},tn=Be(0,255),Ce=Object.assign(Object.assign({},ue),{transform:e=>Math.round(tn(e))}),V={test:ye("rgb","red"),parse:Ne("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:l=1})=>"rgba("+Ce.transform(e)+", "+Ce.transform(n)+", "+Ce.transform(i)+", "+H(je.transform(l))+")"};function nn(e){let n="",i="",l="",o="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),l=e.substr(5,2),o=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),l=e.substr(3,1),o=e.substr(4,1),n+=n,i+=i,l+=l,o+=o),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(l,16),alpha:o?parseInt(o,16)/255:1}}const Se={test:ye("#"),parse:nn,transform:V.transform},de={test:e=>V.test(e)||Se.test(e)||J.test(e),parse:e=>V.test(e)?V.parse(e):J.test(e)?J.parse(e):Se.parse(e),transform:e=>ee(e)?e:e.hasOwnProperty("red")?V.transform(e):J.transform(e)},Ve="${c}",Qe="${n}";function rn(e){var n,i,l,o;return isNaN(e)&&ee(e)&&((i=(n=e.match(se))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((o=(l=e.match(be))===null||l===void 0?void 0:l.length)!==null&&o!==void 0?o:0)>0}function We(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const l=e.match(be);l&&(i=l.length,e=e.replace(be,Ve),n.push(...l.map(de.parse)));const o=e.match(se);return o&&(e=e.replace(se,Qe),n.push(...o.map(ue.parse))),{values:n,numColors:i,tokenised:e}}function Ue(e){return We(e).values}function Je(e){const{values:n,numColors:i,tokenised:l}=We(e),o=n.length;return s=>{let a=l;for(let u=0;u<o;u++)a=a.replace(u<i?Ve:Qe,u<i?de.transform(s[u]):H(s[u]));return a}}const ln=e=>typeof e=="number"?0:e;function on(e){const n=Ue(e);return Je(e)(n.map(ln))}const Ye={test:rn,parse:Ue,createTransformer:Je,getAnimatableNone:on};function we(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 Xe({hue:e,saturation:n,lightness:i,alpha:l}){e/=360,n/=100,i/=100;let o=0,s=0,a=0;if(!n)o=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,d=2*i-u;o=we(d,u,e+1/3),s=we(d,u,e),a=we(d,u,e-1/3)}return{red:Math.round(o*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:l}}const an=(e,n,i)=>{const l=e*e,o=n*n;return Math.sqrt(Math.max(0,i*(o-l)+l))},sn=[Se,V,J],Ke=e=>sn.find(n=>n.test(e)),Ze=(e,n)=>{let i=Ke(e),l=Ke(n),o=i.parse(e),s=l.parse(n);i===J&&(o=Xe(o),i=V),l===J&&(s=Xe(s),l=V);const a=Object.assign({},o);return u=>{for(const d in a)d!=="alpha"&&(a[d]=an(o[d],s[d],u));return a.alpha=ge(o.alpha,s.alpha,u),i.transform(a)}},un=e=>typeof e=="number",dn=(e,n)=>i=>n(e(i)),He=(...e)=>e.reduce(dn);function et(e,n){return un(e)?i=>ge(e,n,i):de.test(e)?Ze(e,n):rt(e,n)}const tt=(e,n)=>{const i=[...e],l=i.length,o=e.map((s,a)=>et(s,n[a]));return s=>{for(let a=0;a<l;a++)i[a]=o[a](s);return i}},cn=(e,n)=>{const i=Object.assign(Object.assign({},e),n),l={};for(const o in i)e[o]!==void 0&&n[o]!==void 0&&(l[o]=et(e[o],n[o]));return o=>{for(const s in l)i[s]=l[s](o);return i}};function nt(e){const n=Ye.parse(e),i=n.length;let l=0,o=0,s=0;for(let a=0;a<i;a++)l||typeof n[a]=="number"?l++:n[a].hue!==void 0?s++:o++;return{parsed:n,numNumbers:l,numRGB:o,numHSL:s}}const rt=(e,n)=>{const i=Ye.createTransformer(n),l=nt(e),o=nt(n);return l.numHSL===o.numHSL&&l.numRGB===o.numRGB&&l.numNumbers>=o.numNumbers?He(tt(l.parsed,o.parsed),i):a=>`${a>0?n:e}`},pn=(e,n)=>i=>ge(e,n,i);function fn(e){if(typeof e=="number")return pn;if(typeof e=="string")return de.test(e)?Ze:rt;if(Array.isArray(e))return tt;if(typeof e=="object")return cn}function mn(e,n,i){const l=[],o=i||fn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=o(e[a],e[a+1]);if(n){const d=Array.isArray(n)?n[a]:n;u=He(d,u)}l.push(u)}return l}function hn([e,n],[i]){return l=>i(Fe(e,n,l))}function xn(e,n){const i=e.length,l=i-1;return o=>{let s=0,a=!1;if(o<=e[0]?a=!0:o>=e[l]&&(s=l-1,a=!0),!a){let d=1;for(;d<i&&!(e[d]>o||d===l);d++);s=d-1}const u=Fe(e[s],e[s+1],o);return n[s](u)}}function gn(e,n,{clamp:i=!0,ease:l,mixer:o}={}){const s=e.length;Re(s===n.length),Re(!l||!Array.isArray(l)||l.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=mn(n,l,o),u=s===2?hn(e,a):xn(e,a);return i?d=>u(Ht(e[0],e[s-1],d)):u}class bn{constructor({valueRange:n,colorRange:i}){pt(this,"mapper");this.mapper=gn(n,i)}getColor(n){return this.mapper(n)}}function yn(e,n){if(e.type==="static")return e.staticColor;if(e.type==="continuous"){const i=new bn(e),l=n[e.valueField];return i.getColor(l)}return"black"}function Cn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Sn(s){var a=s,{conf:u}=a,d=u,{content:e,size:n,color:i}=d,l=P(d,["content","size","color"]),{data:o}=a;const f=c.default.useMemo(()=>yn(i,o[0]),[i,o]),x=c.default.useMemo(()=>{var D;const{prefix:m,postfix:g,data_field:y,formatter:C}=e,T=(D=o==null?void 0:o[0])==null?void 0:D[y];return["string","number"].includes(typeof T)?[m,K.default(T).format(C),g].join(" "):Cn(T)},[e,o]);return t(r.Text,G(h({},l),{color:f,sx:{fontSize:n},children:x}))}function wn(e,n,i,l){const o={width:e,height:n,data:i,conf:l.conf};switch(l.type){case"sunburst":return t(Rt,h({},o));case"line-bar":case"cartesian":return t(Bt,h({},o));case"table":return t(Ut,h({},o));case"text":return t(Yt,h({},o));case"stats":return t(Sn,h({},o));case"bar-3d":return t(Xt,h({},o));case"pie":return t(Zt,h({},o));default:return null}}function it({viz:e,data:n,loading:i}){const{ref:l,width:o,height:s}=E.useElementSize(),a=c.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:l,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:l,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&t(Ee,{children:wn(o,s,n,e)})]})}function vn({}){const{data:e,loading:n,viz:i}=c.default.useContext(q);return t(it,{viz:i,data:e,loading:n})}function Tn({label:e,required:n,value:i,onChange:l,data:o,sx:s},a){const u=c.default.useMemo(()=>!Array.isArray(o)||o.length===0?[]:Object.keys(o[0]).map(f=>({label:f,value:f})),[o]);return t(r.Select,{ref:a,label:e,data:u,value:i,onChange:l,required:n,sx:s})}const A=c.default.forwardRef(Tn);function Gn({conf:e,setConf:n,data:i}){const l=z.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:s,formState:a}=w.useForm({defaultValues:l});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:s(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(w.Controller,{name:"x_axis_data_key",control:o,render:({field:u})=>t(A,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"xAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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(w.Controller,{name:"y_axis_data_key",control:o,render:({field:u})=>t(A,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"yAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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(w.Controller,{name:"z_axis_data_key",control:o,render:({field:u})=>t(A,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"zAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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 _n({value:e,onChange:n},i){const l=r.useMantineTheme(),o=c.default.useMemo(()=>Object.entries(l.colors).map(([a,u])=>({label:a,value:u[6]})),[l]),s=c.default.useMemo(()=>o.some(a=>a.value===e),[e,o]);return p(r.Group,{position:"apart",spacing:"xs",children:[t(r.TextInput,{placeholder:"Set any color",value:s?"":e,onChange:a=>n(a.currentTarget.value),rightSection:t(r.ColorSwatch,{color:s?"transparent":e,radius:4}),variant:s?"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:s?"default":"filled",placeholder:"Pick a theme color",icon:t(r.ColorSwatch,{color:s?e:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}const ve=c.default.forwardRef(_n);function zn({control:e,index:n}){return p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(w.Controller,{name:`series.${n}.stack`,control:e,render:({field:i})=>t(r.TextInput,h({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},i))}),t(w.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:i})=>t(r.TextInput,h({label:"Bar Width",sx:{flexGrow:1}},i))})]})}const Pn=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}];function In({control:e,index:n}){return p(r.Group,{direction:"row",grow:!0,align:"center",children:[t(w.Controller,{name:`series.${n}.step`,control:e,render:({field:i})=>t(r.Select,G(h({label:"Step",data:Pn,sx:{flexGrow:1,maxWidth:"48%"}},i),{value:String(i.value),onChange:l=>{const o=l==="false"?!1:l;i.onChange(o)}}))}),t(w.Controller,{name:`series.${n}.smooth`,control:e,render:({field:i})=>t(r.Box,{sx:{flexGrow:1},children:t(r.Switch,{label:"Smooth Line",checked:i.value,onChange:l=>i.onChange(l.currentTarget.checked)})})})]})}const Ln=[{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 An({control:e,index:n,remove:i,seriesItem:l,yAxisOptions:o,data:s}){const a=l.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(w.Controller,{name:`series.${n}.type`,control:e,render:({field:u})=>t(r.SegmentedControl,h({data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter",disabled:!0},{label:"Boxplot",value:"boxplot",disabled:!0}]},u))})}),t(w.Controller,{name:`series.${n}.name`,control:e,render:({field:u})=>t(r.TextInput,h({label:"Name",required:!0,sx:{flex:1}},u))}),p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(w.Controller,{name:`series.${n}.y_axis_data_key`,control:e,render:({field:u})=>t(A,h({label:"Value Field",required:!0,data:s,sx:{flex:1}},u))}),t(w.Controller,{name:`series.${n}.yAxisIndex`,control:e,render:x=>{var{field:m}=x,g=m,{value:u,onChange:d}=g,f=P(g,["value","onChange"]);var y;return t(r.Select,G(h({label:"Y Axis",data:o,disabled:o.length===0},f),{value:(y=u==null?void 0:u.toString())!=null?y:"",onChange:C=>{if(!C){d(0);return}d(Number(C))},sx:{flex:1}}))}})]}),a==="line"&&t(In,{index:n,control:e}),a==="bar"&&t(zn,{index:n,control:e}),t(w.Controller,{name:`series.${n}.label_position`,control:e,render:({field:u})=>t(r.Select,h({label:"Label Position",data:Ln},u))}),p(r.Group,{direction:"column",grow:!0,spacing:4,children:[t(r.Text,{size:"sm",children:"Color"}),t(w.Controller,{name:`series.${n}.color`,control:e,render:({field:u})=>t(ve,h({},u))})]}),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 Dn({control:e,watch:n,getValues:i,data:l}){const{fields:o,append:s,remove:a}=w.useFieldArray({control:e,name:"series"}),u=n("series"),d=o.map((m,g)=>h(h({},m),u[g])),f=()=>s({type:"bar",name:E.randomId(),showSymbol:!1,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000",step:!1,smooth:!1}),x=c.default.useMemo(()=>i().y_axes.map(({name:m},g)=>({label:m,value:g.toString()})),[i]);return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Series"}),d.map((m,g)=>t(An,{control:e,index:g,remove:a,seriesItem:m,yAxisOptions:x,data:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:f,children:"Add a Series"})})]})}const lt={mantissa:0,output:"number"};function Mn({value:e,onChange:n},i){const l=a=>{n(G(h({},e),{output:a}))},o=a=>{const u=a===0?!1:e.trimMantissa;n(G(h({},e),{mantissa:a,trimMantissa:u}))},s=a=>{n(G(h({},e),{trimMantissa:a.currentTarget.checked}))};return t(r.Group,{direction:"column",grow:!0,noWrap:!0,ref:i,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:l}),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:s,disabled:e.mantissa===0})]})})}const ot=c.default.forwardRef(Mn);function qn({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(w.Controller,{name:`y_axes.${n}.name`,control:e,render:({field:l})=>t(r.TextInput,h({label:"Name",required:!0,sx:{flex:1}},l))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(w.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:l})=>t(ot,h({},l))})}),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 On({control:e,watch:n}){const{fields:i,append:l,remove:o}=w.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((d,f)=>h(h({},d),s[f])),u=()=>l({name:"",label_formatter:lt});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((d,f)=>t(qn,{control:e,index:f,remove:o})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function kn(e){function n({type:i,name:l,showSymbol:o,y_axis_data_key:s="value",yAxisIndex:a=0,label_position:u="top",stack:d="1",color:f="black",barWidth:x="30",smooth:m=!1,step:g=!1}){return{type:i,name:l,showSymbol:o,y_axis_data_key:s,yAxisIndex:a,label_position:u,stack:d,color:f,barWidth:x,smooth:m,step:g}}return e.map(n)}function En({conf:e,setConf:n,data:i}){const y=e,{series:l,y_axes:o}=y,s=P(y,["series","y_axes"]),a=c.default.useMemo(()=>{const I=s,{x_axis_name:C=""}=I,T=P(I,["x_axis_name"]);return h({series:kn(l!=null?l:[]),x_axis_name:C,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:lt}]},T)},[l,s]);c.default.useEffect(()=>{!z.default.isEqual(e,a)&&n(a)},[e,a]);const{control:u,handleSubmit:d,watch:f,getValues:x}=w.useForm({defaultValues:a}),m=x(),g=c.default.useMemo(()=>!z.default.isEqual(m,e),[m,e]);return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:d(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:!g,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",grow:!0,noWrap:!0,mb:"lg",children:[t(w.Controller,{name:"x_axis_data_key",control:u,render:({field:C})=>t(A,h({label:"X Axis Data Field",required:!0,data:i,sx:{flex:1}},C))}),t(w.Controller,{name:"x_axis_name",control:u,render:({field:C})=>t(r.TextInput,h({label:"X Axis Name"},C))})]}),t(On,{control:u,watch:f}),t(Dn,{control:u,watch:f,getValues:x,data:i})]})})}function $n({conf:{label_field:e,value_field:n},setConf:i,data:l}){const o=$.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(A,h({label:"Label Field",required:!0,data:l},o.getInputProps("label_field"))),t(A,h({label:"Value Field",required:!0,data:l},o.getInputProps("value_field")))]})]})})}const ce=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function Rn({label:e,value:n,onChange:i},l){var a,u;const[o,s]=c.default.useState((u=(a=ce.find(d=>d.label===n))==null?void 0:a.value)!=null?u:ce[0].value);return c.default.useEffect(()=>{const d=ce.find(f=>f.value===o);d&&i(d.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:ce,value:o,onChange:s,step:25,placeholder:"Pick a font size",ref:l})]})}const at=c.default.forwardRef(Rn);function Fn({label:e,value:n,onChange:i},l){const[o,s]=c.default.useState(Array.isArray(n)?[...n]:[]),a=c.default.useCallback(()=>{s(x=>[...x,""])},[s]),u=c.default.useCallback(x=>{s(m=>(m.splice(x,1),[...m]))},[s]),d=c.default.useMemo(()=>!z.default.isEqual(o,n),[o,n]),f=()=>{i(o.map(x=>x.toString()))};return p(Z,{children:[p(r.Group,{position:"left",ref:l,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((x,m)=>t(r.TextInput,{value:x,onChange:g=>{const y=g.currentTarget.value;s(C=>(C.splice(m,1,y),[...C]))},rightSection:t(r.ActionIcon,{onClick:()=>u(m),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}const Bn=c.default.forwardRef(Fn);function jn({label:e,value:n,onChange:i},l){const[o,s]=c.default.useState(Array.isArray(n)?[...n]:[]),a=c.default.useCallback(()=>{s(g=>[...g,""])},[s]),u=c.default.useCallback(g=>{s(y=>(y.splice(g,1),[...y]))},[s]),d=c.default.useMemo(()=>!z.default.isEqual(o,n),[o,n]),f=()=>{i(o.map(g=>g.toString()))},x=r.useMantineTheme(),m=c.default.useMemo(()=>Object.entries(x.colors).map(([g,y])=>y[6]),[x]);return p(Z,{children:[p(r.Group,{position:"left",ref:l,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((g,y)=>t(r.ColorInput,{value:g,onChange:C=>{s(T=>(T.splice(y,1,C),[...T]))},swatches:m,rightSection:t(r.ActionIcon,{onClick:()=>u(y),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}const Nn=c.default.forwardRef(jn);function Vn({conf:e,setConf:n,data:i}){const l=z.default.merge({},{align:"center",size:"100px",weight:"bold",color:{type:"static",staticColor:"red"},content:{prefix:"",data_field:"",formatter:{output:"number",mantissa:0},postfix:""}},e),{control:o,handleSubmit:s,watch:a,formState:{isDirty:u}}=w.useForm({defaultValues:l}),d=a("color.type");return a("color.valueField"),t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,noWrap:!0,children:p("form",{onSubmit:s(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:!u,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:p(r.Group,{direction:"column",grow:!0,children:[p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(w.Controller,{name:"content.prefix",control:o,render:({field:f})=>t(r.TextInput,h({label:"Prefix",sx:{flexGrow:1}},f))}),t(w.Controller,{name:"content.data_field",control:o,render:({field:f})=>t(A,h({label:"Data Field",required:!0,data:i},f))}),t(w.Controller,{name:"content.postfix",control:o,render:({field:f})=>t(r.TextInput,h({label:"Postfix",sx:{flexGrow:1}},f))})]}),t(w.Controller,{name:"content.formatter",control:o,render:({field:f})=>t(ot,h({},f))})]})}),p(r.Accordion.Item,{label:"Font",children:[t(r.Group,{direction:"column",grow:!0,children:t(w.Controller,{name:"size",control:o,render:({field:f})=>t(r.TextInput,h({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},f))})}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(w.Controller,{name:"weight",control:o,render:({field:f})=>t(at,h({label:"Font Weight"},f))})})]}),t(r.Accordion.Item,{label:"Color",children:p(r.Group,{direction:"column",grow:!0,children:[t(w.Controller,{name:"color.type",control:o,render:({field:f})=>t(r.Select,h({label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}]},f))}),d==="static"&&t(w.Controller,{name:"color.staticColor",control:o,render:({field:f})=>t(ve,h({},f))}),d==="continuous"&&p(Z,{children:[t(w.Controller,{name:"color.valueField",control:o,defaultValue:"",render:({field:f})=>t(r.TextInput,h({placeholder:"Calculate color with this field",label:"Value Field",required:!0,sx:{flex:1}},f))}),t(w.Controller,{name:"color.valueRange",control:o,render:({field:f})=>t(Bn,h({label:"Value Range"},f))}),t(w.Controller,{name:"color.colorRange",control:o,render:({field:f})=>t(Nn,h({label:"Color Range"},f))})]})]})})]})]})})}function Qn({conf:{label_field:e,value_field:n},setConf:i,data:l}){const o=$.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(A,h({label:"Label Field",required:!0,data:l},o.getInputProps("label_field"))),t(A,h({label:"Value Field",required:!0,data:l},o.getInputProps("value_field")))]})]})})}const Wn=Object.values(N).map(e=>({label:e,value:e}));function Un({label:e,value:n,onChange:i,sx:l}){return t(r.Select,{label:e,data:Wn,value:n,onChange:i,sx:l})}function Jn(o){var s=o,{conf:a}=s,u=a,{columns:e}=u,n=P(u,["columns"]),{setConf:i,data:l}=s;const d=$.useForm({initialValues:h({id_field:"id",use_raw_columns:!0,columns:$.formList(e!=null?e:[]),fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},n)}),f=()=>d.addListItem("columns",{label:E.randomId(),value_field:"value",value_type:N.string});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:d.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(A,h({label:"ID Field",required:!0,data:l},d.getInputProps("id_field"))),p(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[t(r.TextInput,h({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.getInputProps("horizontalSpacing"))),t(r.TextInput,h({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.getInputProps("verticalSpacing")))]}),t(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:t(r.TextInput,h({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.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,h({label:"Striped"},d.getInputProps("striped",{type:"checkbox"}))),t(r.Switch,h({label:"Highlight on hover"},d.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,h({label:"Use Original Data Columns"},d.getInputProps("use_raw_columns",{type:"checkbox"}))),!d.values.use_raw_columns&&p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Custom Columns"}),d.values.columns.map((x,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,children:[t(r.TextInput,h({label:"Label",required:!0,sx:{flex:1}},d.getListInputProps("columns",m,"label"))),t(A,h({label:"Value Field",required:!0,data:l},d.getListInputProps("columns",m,"value_field"))),t(Un,h({label:"Value Type",sx:{flex:1}},d.getListInputProps("columns",m,"value_type")))]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>d.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:f,children:"Add a Column"})})]})]}),t(r.Text,{weight:500,mb:"md",children:"Current Configuration:"}),t(k.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(d.values,null,2)})]})})}const st=[{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 Yn({conf:e,setConf:n}){var o;const i=$.useForm({initialValues:{paragraphs:$.formList((o=e.paragraphs)!=null?o:st)}}),l=()=>i.addListItem("paragraphs",G(h({},st[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,h({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(ve,h({},i.getListInputProps("paragraphs",a,"color")))]}),t(r.Group,{direction:"column",grow:!0,children:t(r.TextInput,h({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(at,h({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:l,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(k.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Te=[{value:"text",label:"Text",Panel:Yn},{value:"stats",label:"Stats",Panel:Vn},{value:"table",label:"Table",Panel:Jn},{value:"sunburst",label:"Sunburst",Panel:Qn},{value:"bar-3d",label:"Bar Chart (3D)",Panel:Gn},{value:"cartesian",label:"Cartesian Chart",Panel:En},{value:"pie",label:"Pie Chart",Panel:$n}];function Xn(){const{data:e,viz:n,setViz:i}=c.default.useContext(q),[l,o]=E.useInputState(n.type),s=n.type!==l,a=c.default.useCallback(()=>{!s||i(x=>G(h({},x),{type:l}))},[s,l]),u=x=>{i(m=>G(h({},m),{conf:x}))},d=x=>{try{u(JSON.parse(x))}catch(m){console.error(m)}},f=c.default.useMemo(()=>{var x;return(x=Te.find(m=>m.value===l))==null?void 0:x.Panel},[l,Te]);return p(Z,{children:[t(r.Select,{label:"Visualization",value:l,onChange:o,data:Te,rightSection:t(r.ActionIcon,{disabled:!s,onClick:a,children:t(S.DeviceFloppy,{size:20})})}),f&&t(f,{conf:n.conf,setConf:u,data:e}),!f&&t(r.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(n.conf,null,2),onChange:d})]})}function Kn({}){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(Xn,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(vn,{})})]})}function Zn({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(j),{data:l,loading:o,viz:s,title:a}=c.default.useContext(q);return c.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",children:[t(r.LoadingOverlay,{visible:o,exitTransitionDuration:0}),t(Et,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(kt,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Kn,{})})]})})})}var zr="";function Hn({}){const[e,n]=c.default.useState(!1),i=()=>n(!0),l=()=>n(!1),{title:o,refreshData:s}=c.default.useContext(q),{inEditMode:a}=c.default.useContext(j);return p(r.Box,{sx:{position:"relative"},children:[t(r.Box,{sx:{position:"absolute",left:0,top:0,height:28},children:t(ke,{})}),t(r.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:p(r.Menu,{control:t(r.Text,{lineClamp:1,weight:"bold",children:o}),placement:"center",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(Zn,{opened:e,close:l})]})}var Pr="";function Ge({viz:e,queryID:n,title:i,description:l,update:o,layout:s,id:a}){const u=c.default.useContext(R),d=c.default.useContext(O),[f,x]=c.default.useState(i),[m,g]=c.default.useState(l),[y,C]=c.default.useState(n),[T,I]=c.default.useState(e),D=c.default.useMemo(()=>{if(!!y)return d.queries.find(Pe=>Pe.id===y)},[y,d.queries]);c.default.useEffect(()=>{o==null||o({id:a,layout:s,title:f,description:m,queryID:y,viz:T})},[f,m,D,T,a,s,y]);const{data:X=[],loading:pe,refresh:ne}=he.useRequest(Me({context:u,definitions:d,title:f,query:D}),{refreshDeps:[u,d,D]}),ze=ne;return t(q.Provider,{value:{data:X,loading:pe,title:f,setTitle:x,description:m,setDescription:g,queryID:y,setQueryID:C,viz:T,setViz:I,refreshData:ze},children:p(r.Container,{className:"panel-root",children:[t(Hn,{}),t(it,{viz:T,data:X,loading:pe})]})})}var Ir="";const er=L.WidthProvider(Ae.default);function ut({panels:e,setPanels:n,className:i="layout",rowHeight:l=10,onRemoveItem:o,isDraggable:s,isResizable:a}){const u=c.default.useCallback(d=>{const f=new Map;d.forEach(y=>{var C=y,{i:m}=C,g=P(C,["i"]);f.set(m,g)});const x=e.map(m=>G(h({},m),{layout:f.get(m.id)}));n(x)},[e,n]);return t(er,{onLayoutChange:u,className:i,rowHeight:l,isDraggable:s,isResizable:a,children:e.map((m,x)=>{var g=m,{id:d}=g,f=P(g,["id"]);return t("div",{"data-grid":f.layout,children:t(Ge,G(h({id:d},f),{destroy:()=>o(d),update:y=>{n(C=>(C.splice(x,1,y),[...C]))}}))},d)})})}function _e(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function tr({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:_e(t(S.PlayerPlay,{size:20}),"Use"),value:M.Use},{label:_e(t(S.Resize,{size:20}),"Layout"),value:M.Layout},{label:_e(t(S.Paint,{size:20}),"Content"),value:M.Edit}]})}const nr=`
9
+ */var zt=c.default,Pt=Symbol.for("react.element"),It=Symbol.for("react.fragment"),Lt=Object.prototype.hasOwnProperty,At=zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Dt={key:!0,ref:!0,__self:!0,__source:!0};function Oe(e,n,i){var l,o={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(l in n)Lt.call(n,l)&&!Dt.hasOwnProperty(l)&&(o[l]=n[l]);if(e&&e.defaultProps)for(l in n=e.defaultProps,n)o[l]===void 0&&(o[l]=n[l]);return{$$typeof:Pt,type:e,key:s,ref:a,props:o,_owner:At.current}}ae.Fragment=It,ae.jsx=Oe,ae.jsxs=Oe,oe.exports=ae;const t=oe.exports.jsx,p=oe.exports.jsxs,H=oe.exports.Fragment;function ke({position:e="bottom",trigger:n="hover"}){const{freezeLayout:i}=c.default.useContext(j),[l,o]=c.default.useState(!1),{description:s}=c.default.useContext(q);if(c.default.useEffect(()=>{i(l)},[l]),!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:()=>o(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(S.InfoCircle,{size:20,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:l,onClose:()=>o(!1),withCloseButton:n==="click",withArrow:!0,trapFocus:!0,closeOnEscape:!1,placement:"center",position:e,target:a,width:"40vw",children:t(yt.default,{readOnly:!0,value:s,onChange:z.default.noop,sx:{border:"none"}})})}function Mt(){const{description:e,setDescription:n}=c.default.useContext(q),[i,l]=c.default.useState(e),o=e!==i,s=c.default.useCallback(()=>{!o||n(i)},[o,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:!o,onClick:s,children:t(S.DeviceFloppy,{size:20})})]}),t(Le.RichTextEditor,{value:i,onChange:l,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Ee extends c.default.Component{constructor(n){super(n),this.state={error:null}}componentDidCatch(n){this.setState({error:n})}render(){var n;if(this.state.error){const i=()=>{this.setState({error:null})};return p(r.Box,{children:[t(r.Text,{size:"xs",children:(n=this.state.error)==null?void 0:n.message}),t(r.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:i,children:"Retry"})]})}return this.props.children}}function qt(){const{title:e}=c.default.useContext(q);return t(Ee,{children:p(r.Group,{direction:"column",grow:!0,noWrap:!0,mx:"auto",mt:"xl",p:"5px",spacing:5,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:{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 Ot(){const{title:e,setTitle:n}=c.default.useContext(q),[i,l]=E.useInputState(e),o=e!==i,s=c.default.useCallback(()=>{!o||n(i)},[o,i]);return t(r.TextInput,{value:i,onChange:l,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!o,onClick:s,children:t(S.DeviceFloppy,{size:20})})]})})}function kt({}){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(Ot,{}),t(Mt,{})]}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(qt,{})})]})}function $e({id:e}){const n=c.default.useContext(O),i=c.default.useContext(R),l=c.default.useMemo(()=>n.queries.find(u=>u.id===e),[n.queries,e]),{data:o=[],loading:s,refresh:a}=he.useRequest(Me({context:i,definitions:n,title:e,query:l}),{refreshDeps:[i,n,l]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):o.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"}),o.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",o.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(o==null?void 0:o[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:o.slice(0,10).map((u,d)=>t("tr",{children:Object.values(u).map((f,x)=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:t(r.Text,{children:f})})},`${f}--${x}`))},`row-${d}`))})]})]})}function Et({}){const{queries:e}=c.default.useContext(O),{queryID:n,setQueryID:i,data:l,loading:o}=c.default.useContext(q),s=c.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 Query"}),t(r.Select,{data:s,value:n,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),t($e,{id:n})]})}B.use([K.SunburstChart,ie.CanvasRenderer]);const $t={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function Rt({conf:e,data:n,width:i,height:l}){const m=e,{label_field:o="name",value_field:s="value"}=m,a=P(m,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(g=>({name:g[o],value:Number(g[s])})),[n,o,s]),d=c.default.useMemo(()=>{var g,b;return(b=(g=z.default.maxBy(u,C=>C.value))==null?void 0:g.value)!=null?b:1},[u]),f=c.default.useMemo(()=>({series:{label:{formatter:({name:g,value:b})=>b/d<.2?" ":g}}}),[d]),x=z.default.merge({},$t,f,a,{series:{data:u}});return t(le.default,{echarts:B,option:x,style:{width:i,height:l}})}B.use([K.BarChart,K.LineChart,K.ScatterChart,Q.GridComponent,Q.LegendComponent,Q.TooltipComponent,ie.CanvasRenderer]);const Ft={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 Bt({conf:e,data:n,width:i,height:l}){const o=c.default.useMemo(()=>{var f;const s=e.y_axes.reduce((x,{label_formatter:m},g)=>(x[g]=function(C){const T=typeof C=="object"?C.value:C;if(!m)return T;try{return Z.default(T).format(m)}catch(I){return console.error(I),T}},x),{default:({value:x})=>x}),a=e.series.reduce((x,{yAxisIndex:m,name:g})=>(x[g]=m,x),{}),u=e.series.map(T=>{var I=T,{y_axis_data_key:x,yAxisIndex:m,label_position:g,name:b}=I,C=P(I,["y_axis_data_key","yAxisIndex","label_position","name"]);return h({data:n.map(X=>X[x]),label:{show:!!g,position:g,formatter:s[m!=null?m:"default"]},name:b,yAxisIndex:m},C)}),d={xAxis:{data:n.map(x=>x[e.x_axis_data_key]),name:(f=e.x_axis_name)!=null?f:""},yAxis:e.y_axes.map((b,g)=>{var C=b,{label_formatter:x}=C,m=P(C,["label_formatter"]);var T;return G(h({},m),{axisLabel:{show:!0,formatter:(T=s[g])!=null?T:s.default}})}),dataset:{source:n},series:u,tooltip:{formatter:function(x){const m=Array.isArray(x)?x:[x];if(m.length===0)return"";const g=m.map(({seriesName:b,value:C})=>{var D;if(!b)return C;const T=a[b],I=(D=s[T])!=null?D:s.default;return`${b}: ${I({value:C})}`});return g.unshift(`<strong>${m[0].name}</strong>`),g.join("<br />")}}};return z.default.merge({},Ft,d)},[e,n]);return!i||!l?null:t(le.default,{echarts:B,option:o,style:{width:i,height:l}})}var N=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(N||{});function jt({value:e}){return t(r.Text,{component:"span",children:e})}function Nt({value:e}){return t(r.Text,{component:"span",children:e})}function Vt({value:e}){const n=Z.default(e).format({thousandSeparated:!0});return t(r.Text,{component:"span",children:n})}function Wt({value:e}){const n=Z.default(e).format({output:"percent",mantissa:3});return t(r.Text,{component:"span",children:n})}function Qt({value:e,type:n}){switch(n){case N.string:return t(jt,{value:e});case N.eloc:return t(Nt,{value:e});case N.number:return t(Vt,{value:e});case N.percentage:return t(Wt,{value:e})}}function Ut({conf:e,data:n=[],width:i,height:l}){const x=e,{id_field:o,use_raw_columns:s,columns:a}=x,u=P(x,["id_field","use_raw_columns","columns"]),d=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]):a.map(m=>m.label),[s,a,n]),f=c.default.useMemo(()=>s?Object.keys(n==null?void 0:n[0]).map(m=>({label:m,value_field:m,value_type:N.string})):a,[s,a,n]);return p(r.Table,G(h({sx:{maxHeight:l}},u),{children:[t("thead",{children:t("tr",{children:d.map(m=>t("th",{children:m},m))})}),t("tbody",{children:n.slice(0,30).map((m,g)=>t("tr",{children:f.map(({value_field:b,value_type:C})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(Qt,{value:m[b],type:C})})},`${b}--${m[b]}`))},o?m[o]:`row-${g}`))}),n.length>100&&t("tfoot",{children:t("tr",{children:t("td",{colSpan:d.length,children:t(r.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]}))}function Jt(e,n={}){const i=G(h({},n),{numbro:Z.default}),l=Object.keys(i),o=Object.values(i);try{return new Function(...l,`return \`${e}\`;`)(...o)}catch(s){return s.message}}function Yt({conf:{paragraphs:e},data:n}){return t(H,{children:e.map((a,s)=>{var u=a,{template:i,size:l}=u,o=P(u,["template","size"]);return t(r.Text,G(h({},o),{sx:{fontSize:l},children:Jt(i,n[0])}),`${i}---${s}`)})})}B.use([Q.GridComponent,Q.VisualMapComponent,Q.LegendComponent,Q.TooltipComponent,ie.CanvasRenderer]);function Xt({conf:e,data:n,width:i,height:l}){const m=e,{x_axis_data_key:o,y_axis_data_key:s,z_axis_data_key:a}=m,u=P(m,["x_axis_data_key","y_axis_data_key","z_axis_data_key"]),d=c.default.useMemo(()=>z.default.minBy(n,g=>g[a])[a],[n,a]),f=c.default.useMemo(()=>z.default.maxBy(n,g=>g[a])[a],[n,a]),x=G(h({tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:d,max:f,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[o],g[s],g[a]])}]});return t(le.default,{echarts:B,option:x,style:{width:i,height:l}})}var zr="";B.use([K.PieChart,ie.CanvasRenderer]);const Kt={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 Zt({conf:e,data:n,width:i,height:l}){const x=e,{label_field:o="name",value_field:s="value"}=x,a=P(x,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(m=>({name:m[o],value:Number(m[s])})),[n,o,s]),d=c.default.useMemo(()=>({series:{labelLayout:function(m){const g=m.labelRect.x<i/2,b=m.labelLinePoints;return b[2][0]=g?m.labelRect.x:m.labelRect.x+m.labelRect.width,{labelLinePoints:b}}}}),[i]),f=z.default.merge({},Kt,d,a,{series:{data:u}});return t(le.default,{echarts:B,option:f,style:{width:i,height:l}})}var Re=function(){};const Ht=(e,n,i)=>Math.min(Math.max(i,e),n),Fe=(e,n,i)=>{const l=n-e;return l===0?1:(i-e)/l},ge=(e,n,i)=>-i*e+i*n+e,Be=(e,n)=>i=>Math.max(Math.min(i,n),e),ee=e=>e%1?Number(e.toFixed(5)):e,se=/(-)?([\d]*\.?[\d])+/g,be=/(#[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,en=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function te(e){return typeof e=="string"}const ue={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},je=Object.assign(Object.assign({},ue),{transform:Be(0,1)});Object.assign(Object.assign({},ue),{default:1});const ne=(e=>({test:n=>te(n)&&n.endsWith(e)&&n.split(" ").length===1,parse:parseFloat,transform:n=>`${n}${e}`}))("%");Object.assign(Object.assign({},ne),{parse:e=>ne.parse(e)/100,transform:e=>ne.transform(e*100)});const ye=(e,n)=>i=>Boolean(te(i)&&en.test(i)&&i.startsWith(e)||n&&Object.prototype.hasOwnProperty.call(i,n)),Ne=(e,n,i)=>l=>{if(!te(l))return l;const[o,s,a,u]=l.match(se);return{[e]:parseFloat(o),[n]:parseFloat(s),[i]:parseFloat(a),alpha:u!==void 0?parseFloat(u):1}},J={test:ye("hsl","hue"),parse:Ne("hue","saturation","lightness"),transform:({hue:e,saturation:n,lightness:i,alpha:l=1})=>"hsla("+Math.round(e)+", "+ne.transform(ee(n))+", "+ne.transform(ee(i))+", "+ee(je.transform(l))+")"},tn=Be(0,255),Ce=Object.assign(Object.assign({},ue),{transform:e=>Math.round(tn(e))}),V={test:ye("rgb","red"),parse:Ne("red","green","blue"),transform:({red:e,green:n,blue:i,alpha:l=1})=>"rgba("+Ce.transform(e)+", "+Ce.transform(n)+", "+Ce.transform(i)+", "+ee(je.transform(l))+")"};function nn(e){let n="",i="",l="",o="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),l=e.substr(5,2),o=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),l=e.substr(3,1),o=e.substr(4,1),n+=n,i+=i,l+=l,o+=o),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(l,16),alpha:o?parseInt(o,16)/255:1}}const Se={test:ye("#"),parse:nn,transform:V.transform},de={test:e=>V.test(e)||Se.test(e)||J.test(e),parse:e=>V.test(e)?V.parse(e):J.test(e)?J.parse(e):Se.parse(e),transform:e=>te(e)?e:e.hasOwnProperty("red")?V.transform(e):J.transform(e)},Ve="${c}",We="${n}";function rn(e){var n,i,l,o;return isNaN(e)&&te(e)&&((i=(n=e.match(se))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((o=(l=e.match(be))===null||l===void 0?void 0:l.length)!==null&&o!==void 0?o:0)>0}function Qe(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const l=e.match(be);l&&(i=l.length,e=e.replace(be,Ve),n.push(...l.map(de.parse)));const o=e.match(se);return o&&(e=e.replace(se,We),n.push(...o.map(ue.parse))),{values:n,numColors:i,tokenised:e}}function Ue(e){return Qe(e).values}function Je(e){const{values:n,numColors:i,tokenised:l}=Qe(e),o=n.length;return s=>{let a=l;for(let u=0;u<o;u++)a=a.replace(u<i?Ve:We,u<i?de.transform(s[u]):ee(s[u]));return a}}const ln=e=>typeof e=="number"?0:e;function on(e){const n=Ue(e);return Je(e)(n.map(ln))}const Ye={test:rn,parse:Ue,createTransformer:Je,getAnimatableNone:on};function we(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 Xe({hue:e,saturation:n,lightness:i,alpha:l}){e/=360,n/=100,i/=100;let o=0,s=0,a=0;if(!n)o=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,d=2*i-u;o=we(d,u,e+1/3),s=we(d,u,e),a=we(d,u,e-1/3)}return{red:Math.round(o*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:l}}const an=(e,n,i)=>{const l=e*e,o=n*n;return Math.sqrt(Math.max(0,i*(o-l)+l))},sn=[Se,V,J],Ke=e=>sn.find(n=>n.test(e)),Ze=(e,n)=>{let i=Ke(e),l=Ke(n),o=i.parse(e),s=l.parse(n);i===J&&(o=Xe(o),i=V),l===J&&(s=Xe(s),l=V);const a=Object.assign({},o);return u=>{for(const d in a)d!=="alpha"&&(a[d]=an(o[d],s[d],u));return a.alpha=ge(o.alpha,s.alpha,u),i.transform(a)}},un=e=>typeof e=="number",dn=(e,n)=>i=>n(e(i)),He=(...e)=>e.reduce(dn);function et(e,n){return un(e)?i=>ge(e,n,i):de.test(e)?Ze(e,n):rt(e,n)}const tt=(e,n)=>{const i=[...e],l=i.length,o=e.map((s,a)=>et(s,n[a]));return s=>{for(let a=0;a<l;a++)i[a]=o[a](s);return i}},cn=(e,n)=>{const i=Object.assign(Object.assign({},e),n),l={};for(const o in i)e[o]!==void 0&&n[o]!==void 0&&(l[o]=et(e[o],n[o]));return o=>{for(const s in l)i[s]=l[s](o);return i}};function nt(e){const n=Ye.parse(e),i=n.length;let l=0,o=0,s=0;for(let a=0;a<i;a++)l||typeof n[a]=="number"?l++:n[a].hue!==void 0?s++:o++;return{parsed:n,numNumbers:l,numRGB:o,numHSL:s}}const rt=(e,n)=>{const i=Ye.createTransformer(n),l=nt(e),o=nt(n);return l.numHSL===o.numHSL&&l.numRGB===o.numRGB&&l.numNumbers>=o.numNumbers?He(tt(l.parsed,o.parsed),i):a=>`${a>0?n:e}`},pn=(e,n)=>i=>ge(e,n,i);function fn(e){if(typeof e=="number")return pn;if(typeof e=="string")return de.test(e)?Ze:rt;if(Array.isArray(e))return tt;if(typeof e=="object")return cn}function mn(e,n,i){const l=[],o=i||fn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=o(e[a],e[a+1]);if(n){const d=Array.isArray(n)?n[a]:n;u=He(d,u)}l.push(u)}return l}function hn([e,n],[i]){return l=>i(Fe(e,n,l))}function xn(e,n){const i=e.length,l=i-1;return o=>{let s=0,a=!1;if(o<=e[0]?a=!0:o>=e[l]&&(s=l-1,a=!0),!a){let d=1;for(;d<i&&!(e[d]>o||d===l);d++);s=d-1}const u=Fe(e[s],e[s+1],o);return n[s](u)}}function gn(e,n,{clamp:i=!0,ease:l,mixer:o}={}){const s=e.length;Re(s===n.length),Re(!l||!Array.isArray(l)||l.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=mn(n,l,o),u=s===2?hn(e,a):xn(e,a);return i?d=>u(Ht(e[0],e[s-1],d)):u}class bn{constructor({valueRange:n,colorRange:i}){pt(this,"mapper");this.mapper=gn(n,i)}getColor(n){return this.mapper(n)}}function yn(e,n){if(e.type==="static")return e.staticColor;if(e.type==="continuous"){const i=new bn(e),l=n[e.valueField];return i.getColor(l)}return"black"}function Cn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Sn(s){var a=s,{conf:u}=a,d=u,{content:e,size:n,color:i}=d,l=P(d,["content","size","color"]),{data:o}=a;const f=c.default.useMemo(()=>yn(i,o[0]),[i,o]),x=c.default.useMemo(()=>{var D;const{prefix:m,postfix:g,data_field:b,formatter:C}=e,T=(D=o==null?void 0:o[0])==null?void 0:D[b];return["string","number"].includes(typeof T)?[m,Z.default(T).format(C),g].join(" "):Cn(T)},[e,o]);return t(r.Text,G(h({},l),{color:f,sx:{fontSize:n},children:x}))}function wn(e,n,i,l){const o={width:e,height:n,data:i,conf:l.conf};switch(l.type){case"sunburst":return t(Rt,h({},o));case"line-bar":case"cartesian":return t(Bt,h({},o));case"table":return t(Ut,h({},o));case"text":return t(Yt,h({},o));case"stats":return t(Sn,h({},o));case"bar-3d":return t(Xt,h({},o));case"pie":return t(Zt,h({},o));default:return null}}function it({viz:e,data:n,loading:i}){const{ref:l,width:o,height:s}=E.useElementSize(),a=c.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:l,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:l,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&t(Ee,{children:wn(o,s,n,e)})]})}function vn({}){const{data:e,loading:n,viz:i}=c.default.useContext(q);return t(it,{viz:i,data:e,loading:n})}function Tn({label:e,required:n,value:i,onChange:l,data:o,sx:s},a){const u=c.default.useMemo(()=>!Array.isArray(o)||o.length===0?[]:Object.keys(o[0]).map(f=>({label:f,value:f})),[o]);return t(r.Select,{ref:a,label:e,data:u,value:i,onChange:l,required:n,sx:s})}const A=c.default.forwardRef(Tn);function Gn({conf:e,setConf:n,data:i}){const l=z.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:s,formState:a}=w.useForm({defaultValues:l});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:s(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(w.Controller,{name:"x_axis_data_key",control:o,render:({field:u})=>t(A,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"xAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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(w.Controller,{name:"y_axis_data_key",control:o,render:({field:u})=>t(A,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"yAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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(w.Controller,{name:"z_axis_data_key",control:o,render:({field:u})=>t(A,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"zAxis3D.name",control:o,render:({field:u})=>t(r.TextInput,h({sx:{flexGrow:1},size:"md",label:"Name"},u))})]}),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 _n({value:e,onChange:n},i){const l=r.useMantineTheme(),o=c.default.useMemo(()=>Object.entries(l.colors).map(([a,u])=>({label:a,value:u[6]})),[l]),s=c.default.useMemo(()=>o.some(a=>a.value===e),[e,o]);return p(r.Group,{position:"apart",spacing:"xs",children:[t(r.TextInput,{placeholder:"Set any color",value:s?"":e,onChange:a=>n(a.currentTarget.value),rightSection:t(r.ColorSwatch,{color:s?"transparent":e,radius:4}),variant:s?"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:s?"default":"filled",placeholder:"Pick a theme color",icon:t(r.ColorSwatch,{color:s?e:"transparent",radius:4}),sx:{maxWidth:"100%",flexGrow:1}})]})}const ve=c.default.forwardRef(_n);function zn({control:e,index:n}){return p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(w.Controller,{name:`series.${n}.stack`,control:e,render:({field:i})=>t(r.TextInput,h({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},i))}),t(w.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:i})=>t(r.TextInput,h({label:"Bar Width",sx:{flexGrow:1}},i))})]})}const Pn=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}];function In({control:e,index:n}){return p(r.Group,{direction:"row",grow:!0,align:"center",children:[t(w.Controller,{name:`series.${n}.step`,control:e,render:({field:i})=>t(r.Select,G(h({label:"Step",data:Pn,sx:{flexGrow:1,maxWidth:"48%"}},i),{value:String(i.value),onChange:l=>{const o=l==="false"?!1:l;i.onChange(o)}}))}),t(w.Controller,{name:`series.${n}.smooth`,control:e,render:({field:i})=>t(r.Box,{sx:{flexGrow:1},children:t(r.Switch,{label:"Smooth Line",checked:i.value,onChange:l=>i.onChange(l.currentTarget.checked)})})})]})}const Ln=Array.from(new Array(9),(e,n)=>({label:String(n+1),value:n+1}));function An({control:e,index:n}){return t(r.Group,{direction:"row",grow:!0,align:"center",children:t(w.Controller,{name:`series.${n}.symbolSize`,control:e,render:({field:i})=>p(r.Group,{direction:"column",noWrap:!0,sx:{flexGrow:1},pb:16,spacing:4,children:[t(r.Text,{size:"sm",children:"Size"}),t(r.Slider,G(h({min:1,max:10,marks:Ln},i),{sx:{width:"100%"}}))]})})})}const Dn=[{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 Mn({control:e,index:n,remove:i,seriesItem:l,yAxisOptions:o,data:s}){const a=l.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(w.Controller,{name:`series.${n}.type`,control:e,render:({field:u})=>t(r.SegmentedControl,h({data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter"},{label:"Boxplot",value:"boxplot",disabled:!0}]},u))})}),t(w.Controller,{name:`series.${n}.name`,control:e,render:({field:u})=>t(r.TextInput,h({label:"Name",required:!0,sx:{flex:1}},u))}),p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(w.Controller,{name:`series.${n}.y_axis_data_key`,control:e,render:({field:u})=>t(A,h({label:"Value Field",required:!0,data:s,sx:{flex:1}},u))}),t(w.Controller,{name:`series.${n}.yAxisIndex`,control:e,render:x=>{var{field:m}=x,g=m,{value:u,onChange:d}=g,f=P(g,["value","onChange"]);var b;return t(r.Select,G(h({label:"Y Axis",data:o,disabled:o.length===0},f),{value:(b=u==null?void 0:u.toString())!=null?b:"",onChange:C=>{if(!C){d(0);return}d(Number(C))},sx:{flex:1}}))}})]}),a==="line"&&t(In,{index:n,control:e}),a==="bar"&&t(zn,{index:n,control:e}),a==="scatter"&&t(An,{index:n,control:e}),t(w.Controller,{name:`series.${n}.label_position`,control:e,render:({field:u})=>t(r.Select,h({label:"Label Position",data:Dn},u))}),p(r.Group,{direction:"column",grow:!0,spacing:4,children:[t(r.Text,{size:"sm",children:"Color"}),t(w.Controller,{name:`series.${n}.color`,control:e,render:({field:u})=>t(ve,h({},u))})]}),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 qn({control:e,watch:n,getValues:i,data:l}){const{fields:o,append:s,remove:a}=w.useFieldArray({control:e,name:"series"}),u=n("series"),d=o.map((m,g)=>h(h({},m),u[g])),f=()=>s({type:"bar",name:E.randomId(),showSymbol:!1,symbolSize:5,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000",step:!1,smooth:!1}),x=c.default.useMemo(()=>i().y_axes.map(({name:m},g)=>({label:m,value:g.toString()})),[i]);return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Series"}),d.map((m,g)=>t(Mn,{control:e,index:g,remove:a,seriesItem:m,yAxisOptions:x,data:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:f,children:"Add a Series"})})]})}const lt={mantissa:0,output:"number"};function On({value:e,onChange:n},i){const l=a=>{n(G(h({},e),{output:a}))},o=a=>{const u=a===0?!1:e.trimMantissa;n(G(h({},e),{mantissa:a,trimMantissa:u}))},s=a=>{n(G(h({},e),{trimMantissa:a.currentTarget.checked}))};return t(r.Group,{direction:"column",grow:!0,noWrap:!0,ref:i,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:l}),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:s,disabled:e.mantissa===0})]})})}const ot=c.default.forwardRef(On);function kn({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(w.Controller,{name:`y_axes.${n}.name`,control:e,render:({field:l})=>t(r.TextInput,h({label:"Name",required:!0,sx:{flex:1}},l))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(w.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:l})=>t(ot,h({},l))})}),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 En({control:e,watch:n}){const{fields:i,append:l,remove:o}=w.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((d,f)=>h(h({},d),s[f])),u=()=>l({name:"",label_formatter:lt});return p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Y Axes"}),a.map((d,f)=>t(kn,{control:e,index:f,remove:o})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function $n(e){function n({type:i,name:l,showSymbol:o,symbolSize:s=5,y_axis_data_key:a="value",yAxisIndex:u=0,label_position:d="top",stack:f="1",color:x="black",barWidth:m="30",smooth:g=!1,step:b=!1}){return{type:i,name:l,showSymbol:o,symbolSize:s,y_axis_data_key:a,yAxisIndex:u,label_position:d,stack:f,color:x,barWidth:m,smooth:g,step:b}}return e.map(n)}function Rn({conf:e,setConf:n,data:i}){const b=e,{series:l,y_axes:o}=b,s=P(b,["series","y_axes"]),a=c.default.useMemo(()=>{const I=s,{x_axis_name:C=""}=I,T=P(I,["x_axis_name"]);return h({series:$n(l!=null?l:[]),x_axis_name:C,y_axes:o!=null?o:[{name:"Y Axis",label_formatter:lt}]},T)},[l,s]);c.default.useEffect(()=>{!z.default.isEqual(e,a)&&n(a)},[e,a]);const{control:u,handleSubmit:d,watch:f,getValues:x}=w.useForm({defaultValues:a}),m=x(),g=c.default.useMemo(()=>!z.default.isEqual(m,e),[m,e]);return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:d(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:!g,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",grow:!0,noWrap:!0,mb:"lg",children:[t(w.Controller,{name:"x_axis_data_key",control:u,render:({field:C})=>t(A,h({label:"X Axis Data Field",required:!0,data:i,sx:{flex:1}},C))}),t(w.Controller,{name:"x_axis_name",control:u,render:({field:C})=>t(r.TextInput,h({label:"X Axis Name"},C))})]}),t(En,{control:u,watch:f}),t(qn,{control:u,watch:f,getValues:x,data:i})]})})}function Fn({conf:{label_field:e,value_field:n},setConf:i,data:l}){const o=$.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(A,h({label:"Label Field",required:!0,data:l},o.getInputProps("label_field"))),t(A,h({label:"Value Field",required:!0,data:l},o.getInputProps("value_field")))]})]})})}const ce=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function Bn({label:e,value:n,onChange:i},l){var a,u;const[o,s]=c.default.useState((u=(a=ce.find(d=>d.label===n))==null?void 0:a.value)!=null?u:ce[0].value);return c.default.useEffect(()=>{const d=ce.find(f=>f.value===o);d&&i(d.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:ce,value:o,onChange:s,step:25,placeholder:"Pick a font size",ref:l})]})}const at=c.default.forwardRef(Bn);function jn({label:e,value:n,onChange:i},l){const[o,s]=c.default.useState(Array.isArray(n)?[...n]:[]),a=c.default.useCallback(()=>{s(x=>[...x,""])},[s]),u=c.default.useCallback(x=>{s(m=>(m.splice(x,1),[...m]))},[s]),d=c.default.useMemo(()=>!z.default.isEqual(o,n),[o,n]),f=()=>{i(o.map(x=>x.toString()))};return p(H,{children:[p(r.Group,{position:"left",ref:l,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((x,m)=>t(r.TextInput,{value:x,onChange:g=>{const b=g.currentTarget.value;s(C=>(C.splice(m,1,b),[...C]))},rightSection:t(r.ActionIcon,{onClick:()=>u(m),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}const Nn=c.default.forwardRef(jn);function Vn({label:e,value:n,onChange:i},l){const[o,s]=c.default.useState(Array.isArray(n)?[...n]:[]),a=c.default.useCallback(()=>{s(g=>[...g,""])},[s]),u=c.default.useCallback(g=>{s(b=>(b.splice(g,1),[...b]))},[s]),d=c.default.useMemo(()=>!z.default.isEqual(o,n),[o,n]),f=()=>{i(o.map(g=>g.toString()))},x=r.useMantineTheme(),m=c.default.useMemo(()=>Object.entries(x.colors).map(([g,b])=>b[6]),[x]);return p(H,{children:[p(r.Group,{position:"left",ref:l,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[o.map((g,b)=>t(r.ColorInput,{value:g,onChange:C=>{s(T=>(T.splice(b,1,C),[...T]))},swatches:m,rightSection:t(r.ActionIcon,{onClick:()=>u(b),color:"red",children:t(S.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(S.PlaylistAdd,{size:20})})]})]})}const Wn=c.default.forwardRef(Vn);function Qn({conf:e,setConf:n,data:i}){const l=z.default.merge({},{align:"center",size:"100px",weight:"bold",color:{type:"static",staticColor:"red"},content:{prefix:"",data_field:"",formatter:{output:"number",mantissa:0},postfix:""}},e),{control:o,handleSubmit:s,watch:a,formState:{isDirty:u}}=w.useForm({defaultValues:l}),d=a("color.type");return a("color.valueField"),t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,noWrap:!0,children:p("form",{onSubmit:s(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:!u,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:p(r.Group,{direction:"column",grow:!0,children:[p(r.Group,{direction:"row",grow:!0,noWrap:!0,children:[t(w.Controller,{name:"content.prefix",control:o,render:({field:f})=>t(r.TextInput,h({label:"Prefix",sx:{flexGrow:1}},f))}),t(w.Controller,{name:"content.data_field",control:o,render:({field:f})=>t(A,h({label:"Data Field",required:!0,data:i},f))}),t(w.Controller,{name:"content.postfix",control:o,render:({field:f})=>t(r.TextInput,h({label:"Postfix",sx:{flexGrow:1}},f))})]}),t(w.Controller,{name:"content.formatter",control:o,render:({field:f})=>t(ot,h({},f))})]})}),p(r.Accordion.Item,{label:"Font",children:[t(r.Group,{direction:"column",grow:!0,children:t(w.Controller,{name:"size",control:o,render:({field:f})=>t(r.TextInput,h({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1}},f))})}),t(r.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:t(w.Controller,{name:"weight",control:o,render:({field:f})=>t(at,h({label:"Font Weight"},f))})})]}),t(r.Accordion.Item,{label:"Color",children:p(r.Group,{direction:"column",grow:!0,children:[t(w.Controller,{name:"color.type",control:o,render:({field:f})=>t(r.Select,h({label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}]},f))}),d==="static"&&t(w.Controller,{name:"color.staticColor",control:o,render:({field:f})=>t(ve,h({},f))}),d==="continuous"&&p(H,{children:[t(w.Controller,{name:"color.valueField",control:o,defaultValue:"",render:({field:f})=>t(r.TextInput,h({placeholder:"Calculate color with this field",label:"Value Field",required:!0,sx:{flex:1}},f))}),t(w.Controller,{name:"color.valueRange",control:o,render:({field:f})=>t(Nn,h({label:"Value Range"},f))}),t(w.Controller,{name:"color.colorRange",control:o,render:({field:f})=>t(Wn,h({label:"Color Range"},f))})]})]})})]})]})})}function Un({conf:{label_field:e,value_field:n},setConf:i,data:l}){const o=$.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(A,h({label:"Label Field",required:!0,data:l},o.getInputProps("label_field"))),t(A,h({label:"Value Field",required:!0,data:l},o.getInputProps("value_field")))]})]})})}const Jn=Object.values(N).map(e=>({label:e,value:e}));function Yn({label:e,value:n,onChange:i,sx:l}){return t(r.Select,{label:e,data:Jn,value:n,onChange:i,sx:l})}function Xn(o){var s=o,{conf:a}=s,u=a,{columns:e}=u,n=P(u,["columns"]),{setConf:i,data:l}=s;const d=$.useForm({initialValues:h({id_field:"id",use_raw_columns:!0,columns:$.formList(e!=null?e:[]),fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1},n)}),f=()=>d.addListItem("columns",{label:E.randomId(),value_field:"value",value_type:N.string});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:d.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(A,h({label:"ID Field",required:!0,data:l},d.getInputProps("id_field"))),p(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[t(r.TextInput,h({label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.getInputProps("horizontalSpacing"))),t(r.TextInput,h({label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.getInputProps("verticalSpacing")))]}),t(r.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:t(r.TextInput,h({label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1}},d.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,h({label:"Striped"},d.getInputProps("striped",{type:"checkbox"}))),t(r.Switch,h({label:"Highlight on hover"},d.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,h({label:"Use Original Data Columns"},d.getInputProps("use_raw_columns",{type:"checkbox"}))),!d.values.use_raw_columns&&p(r.Group,{direction:"column",grow:!0,children:[t(r.Text,{mt:"xl",mb:0,children:"Custom Columns"}),d.values.columns.map((x,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,children:[t(r.TextInput,h({label:"Label",required:!0,sx:{flex:1}},d.getListInputProps("columns",m,"label"))),t(A,h({label:"Value Field",required:!0,data:l},d.getListInputProps("columns",m,"value_field"))),t(Yn,h({label:"Value Type",sx:{flex:1}},d.getListInputProps("columns",m,"value_type")))]}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>d.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:f,children:"Add a Column"})})]})]}),t(r.Text,{weight:500,mb:"md",children:"Current Configuration:"}),t(k.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(d.values,null,2)})]})})}const st=[{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 Kn({conf:e,setConf:n}){var o;const i=$.useForm({initialValues:{paragraphs:$.formList((o=e.paragraphs)!=null?o:st)}}),l=()=>i.addListItem("paragraphs",G(h({},st[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,h({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(ve,h({},i.getListInputProps("paragraphs",a,"color")))]}),t(r.Group,{direction:"column",grow:!0,children:t(r.TextInput,h({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(at,h({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:l,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(k.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Te=[{value:"text",label:"Text",Panel:Kn},{value:"stats",label:"Stats",Panel:Qn},{value:"table",label:"Table",Panel:Xn},{value:"sunburst",label:"Sunburst",Panel:Un},{value:"bar-3d",label:"Bar Chart (3D)",Panel:Gn},{value:"cartesian",label:"Cartesian Chart",Panel:Rn},{value:"pie",label:"Pie Chart",Panel:Fn}];function Zn(){const{data:e,viz:n,setViz:i}=c.default.useContext(q),[l,o]=E.useInputState(n.type),s=n.type!==l,a=c.default.useCallback(()=>{!s||i(x=>G(h({},x),{type:l}))},[s,l]),u=x=>{i(m=>G(h({},m),{conf:x}))},d=x=>{try{u(JSON.parse(x))}catch(m){console.error(m)}},f=c.default.useMemo(()=>{var x;return(x=Te.find(m=>m.value===l))==null?void 0:x.Panel},[l,Te]);return p(H,{children:[t(r.Select,{label:"Visualization",value:l,onChange:o,data:Te,rightSection:t(r.ActionIcon,{disabled:!s,onClick:a,children:t(S.DeviceFloppy,{size:20})})}),f&&t(f,{conf:n.conf,setConf:u,data:e}),!f&&t(r.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(n.conf,null,2),onChange:d})]})}function Hn({}){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(Zn,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(vn,{})})]})}function er({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(j),{data:l,loading:o,viz:s,title:a}=c.default.useContext(q);return c.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",children:[t(r.LoadingOverlay,{visible:o,exitTransitionDuration:0}),t(Et,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(kt,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Hn,{})})]})})})}var Ir="";function tr({}){const[e,n]=c.default.useState(!1),i=()=>n(!0),l=()=>n(!1),{title:o,refreshData:s}=c.default.useContext(q),{inEditMode:a}=c.default.useContext(j);return p(r.Box,{sx:{position:"relative"},children:[t(r.Box,{sx:{position:"absolute",left:0,top:0,height:28},children:t(ke,{})}),t(r.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:p(r.Menu,{control:t(r.Text,{lineClamp:1,weight:"bold",children:o}),placement:"center",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(er,{opened:e,close:l})]})}var Lr="";function Ge({viz:e,queryID:n,title:i,description:l,update:o,layout:s,id:a}){const u=c.default.useContext(R),d=c.default.useContext(O),[f,x]=c.default.useState(i),[m,g]=c.default.useState(l),[b,C]=c.default.useState(n),[T,I]=c.default.useState(e),D=c.default.useMemo(()=>{if(!!b)return d.queries.find(Pe=>Pe.id===b)},[b,d.queries]);c.default.useEffect(()=>{o==null||o({id:a,layout:s,title:f,description:m,queryID:b,viz:T})},[f,m,D,T,a,s,b]);const{data:X=[],loading:pe,refresh:re}=he.useRequest(Me({context:u,definitions:d,title:f,query:D}),{refreshDeps:[u,d,D]}),ze=re;return t(q.Provider,{value:{data:X,loading:pe,title:f,setTitle:x,description:m,setDescription:g,queryID:b,setQueryID:C,viz:T,setViz:I,refreshData:ze},children:p(r.Container,{className:"panel-root",children:[t(tr,{}),t(it,{viz:T,data:X,loading:pe})]})})}var Ar="";const nr=L.WidthProvider(Ae.default);function ut({panels:e,setPanels:n,className:i="layout",rowHeight:l=10,onRemoveItem:o,isDraggable:s,isResizable:a}){const u=c.default.useCallback(d=>{const f=new Map;d.forEach(b=>{var C=b,{i:m}=C,g=P(C,["i"]);f.set(m,g)});const x=e.map(m=>G(h({},m),{layout:f.get(m.id)}));n(x)},[e,n]);return t(nr,{onLayoutChange:u,className:i,rowHeight:l,isDraggable:s,isResizable:a,children:e.map((m,x)=>{var g=m,{id:d}=g,f=P(g,["id"]);return t("div",{"data-grid":f.layout,children:t(Ge,G(h({id:d},f),{destroy:()=>o(d),update:b=>{n(C=>(C.splice(x,1,b),[...C]))}}))},d)})})}function _e(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function rr({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:_e(t(S.PlayerPlay,{size:20}),"Use"),value:M.Use},{label:_e(t(S.Resize,{size:20}),"Layout"),value:M.Layout},{label:_e(t(S.Paint,{size:20}),"Content"),value:M.Edit}]})}const ir=`
11
11
  -- You may reference context data or SQL snippets *by name*
12
12
  -- in SQL or VizConfig.
13
13
  SELECT *
@@ -18,16 +18,16 @@ WHERE
18
18
  -- SQL snippets
19
19
  AND \${author_email_condition}
20
20
  \${order_by_clause}
21
- `;function rr({}){const e=c.default.useContext(R),{sqlSnippets:n}=c.default.useContext(O),i=c.default.useMemo(()=>{const o=n.reduce((s,a)=>(s[a.key]=a.value,s),{});return JSON.stringify(o,null,2)},[n]),l=c.default.useMemo(()=>JSON.stringify(e,null,2),[e]);return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Context"})}),p(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:[t(k.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:nr}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context"}),t(k.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable SQL Snippets"}),t(k.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:i})]})]})}function ir({value:e}){const n=c.default.useContext(R),i=c.default.useContext(O),l=c.default.useMemo(()=>wt(e,n,i),[e,n,i]);return t(k.Prism,{language:"sql",colorScheme:"light",children:l})}function lr({value:e,onChange:n}){const i=$.useForm({initialValues:e}),l=c.default.useCallback(f=>{n(f)},[n]),o=c.default.useMemo(()=>!z.default.isEqual(e,i.values),[e,i.values]);c.default.useEffect(()=>{i.reset()},[e]);const{data:s={},loading:a}=he.useRequest(vt,{refreshDeps:[]},[]),u=c.default.useMemo(()=>Object.keys(s).map(f=>({label:f,value:f})),[s]),d=c.default.useMemo(()=>{const f=s[i.values.type];return f?f.map(x=>({label:x,value:x})):[]},[s,i.values.type]);return t(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",flexGrow:1},children:p("form",{onSubmit:i.onSubmit(l),children:[p(r.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[t(r.Text,{weight:500,children:"Edit Query"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!o||a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,children:[p(r.Group,{grow:!0,children:[t(r.TextInput,h({placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:a},i.getInputProps("id"))),t(r.Select,h({label:"Data Source Type",data:u,sx:{flex:1},disabled:a},i.getInputProps("type"))),t(r.Select,h({label:"Data Source Key",data:d,sx:{flex:1},disabled:a},i.getInputProps("key")))]}),p(r.Tabs,{children:[t(r.Tabs.Tab,{label:"SQL",children:t(r.Textarea,G(h({autosize:!0,minRows:12,maxRows:24},i.getInputProps("sql")),{className:"code-textarea"}))}),t(r.Tabs.Tab,{label:"Preview",children:t(ir,{value:i.values.sql})})]})]})]})})}function or({id:e,setID:n}){const{queries:i,setQueries:l}=c.default.useContext(O),o=c.default.useMemo(()=>i.find(a=>a.id===e),[i,e]),s=c.default.useCallback(a=>{if(i.findIndex(d=>d.id===e)===-1){console.error(new Error("Invalid data source id when updating by id"));return}l(d=>{const f=d.findIndex(x=>x.id===e);return d.splice(f,1,a),[...d]}),n(a.id)},[e,i,l,n]);return e?o?t(lr,{value:o,onChange:s}):t("span",{children:"Invalid Data Source ID"}):null}function ar({id:e,setID:n}){const{queries:i,setQueries:l}=c.default.useContext(O),o=c.default.useCallback(()=>{var u,d;n((d=(u=i[0])==null?void 0:u.id)!=null?d:"")},[n,i]);c.default.useEffect(()=>{if(!e){o();return}i.findIndex(d=>d.id===e)===-1&&o()},[e,i,o]);const s=c.default.useMemo(()=>i.map(u=>({value:u.id,label:u.id})),[i]),a=c.default.useCallback(()=>{const u={id:E.randomId(),type:"postgresql",key:"",sql:""};l(d=>[...d,u]),n(u.id)},[l,n]);return t(r.Group,{pb:"xl",children:p(r.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[t(r.Text,{children:"Select a Query"}),t(r.Select,{data:s,value:e,onChange:n,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}}),t(r.Text,{children:"or"}),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:a,children:"Add a Query"})})]})})}function sr({}){const[e,n]=c.default.useState("");return p(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".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:[p(r.Group,{direction:"column",grow:!0,sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[t(ar,{id:e,setID:n}),t(or,{id:e,setID:n})]}),t(rr,{})]}),t($e,{id:e})]})}function ur({}){const e=c.default.useContext(R),n="SELECT *\nFROM commit\nWHERE author_time BETWEEN '${timeRange?.[0].toISOString()}' AND '${timeRange?.[1].toISOString()}'";return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Context"})}),p(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:[t(k.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:`-- You may refer context data *by name*
21
+ `;function lr({}){const e=c.default.useContext(R),{sqlSnippets:n}=c.default.useContext(O),i=c.default.useMemo(()=>{const o=n.reduce((s,a)=>(s[a.key]=a.value,s),{});return JSON.stringify(o,null,2)},[n]),l=c.default.useMemo(()=>JSON.stringify(e,null,2),[e]);return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Context"})}),p(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:[t(k.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:ir}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context"}),t(k.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable SQL Snippets"}),t(k.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:i})]})]})}function or({value:e}){const n=c.default.useContext(R),i=c.default.useContext(O),l=c.default.useMemo(()=>wt(e,n,i),[e,n,i]);return t(k.Prism,{language:"sql",colorScheme:"light",children:l})}function ar({value:e,onChange:n}){const i=$.useForm({initialValues:e}),l=c.default.useCallback(f=>{n(f)},[n]),o=c.default.useMemo(()=>!z.default.isEqual(e,i.values),[e,i.values]);c.default.useEffect(()=>{i.reset()},[e]);const{data:s={},loading:a}=he.useRequest(vt,{refreshDeps:[]},[]),u=c.default.useMemo(()=>Object.keys(s).map(f=>({label:f,value:f})),[s]),d=c.default.useMemo(()=>{const f=s[i.values.type];return f?f.map(x=>({label:x,value:x})):[]},[s,i.values.type]);return t(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",flexGrow:1},children:p("form",{onSubmit:i.onSubmit(l),children:[p(r.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[t(r.Text,{weight:500,children:"Edit Query"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!o||a,children:t(S.DeviceFloppy,{size:20})})]}),p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,children:[p(r.Group,{grow:!0,children:[t(r.TextInput,h({placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:a},i.getInputProps("id"))),t(r.Select,h({label:"Data Source Type",data:u,sx:{flex:1},disabled:a},i.getInputProps("type"))),t(r.Select,h({label:"Data Source Key",data:d,sx:{flex:1},disabled:a},i.getInputProps("key")))]}),p(r.Tabs,{children:[t(r.Tabs.Tab,{label:"SQL",children:t(r.Textarea,G(h({autosize:!0,minRows:12,maxRows:24},i.getInputProps("sql")),{className:"code-textarea"}))}),t(r.Tabs.Tab,{label:"Preview",children:t(or,{value:i.values.sql})})]})]})]})})}function sr({id:e,setID:n}){const{queries:i,setQueries:l}=c.default.useContext(O),o=c.default.useMemo(()=>i.find(a=>a.id===e),[i,e]),s=c.default.useCallback(a=>{if(i.findIndex(d=>d.id===e)===-1){console.error(new Error("Invalid data source id when updating by id"));return}l(d=>{const f=d.findIndex(x=>x.id===e);return d.splice(f,1,a),[...d]}),n(a.id)},[e,i,l,n]);return e?o?t(ar,{value:o,onChange:s}):t("span",{children:"Invalid Data Source ID"}):null}function ur({id:e,setID:n}){const{queries:i,setQueries:l}=c.default.useContext(O),o=c.default.useCallback(()=>{var u,d;n((d=(u=i[0])==null?void 0:u.id)!=null?d:"")},[n,i]);c.default.useEffect(()=>{if(!e){o();return}i.findIndex(d=>d.id===e)===-1&&o()},[e,i,o]);const s=c.default.useMemo(()=>i.map(u=>({value:u.id,label:u.id})),[i]),a=c.default.useCallback(()=>{const u={id:E.randomId(),type:"postgresql",key:"",sql:""};l(d=>[...d,u]),n(u.id)},[l,n]);return t(r.Group,{pb:"xl",children:p(r.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[t(r.Text,{children:"Select a Query"}),t(r.Select,{data:s,value:e,onChange:n,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}}),t(r.Text,{children:"or"}),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:a,children:"Add a Query"})})]})})}function dr({}){const[e,n]=c.default.useState("");return p(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".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:[p(r.Group,{direction:"column",grow:!0,sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[t(ur,{id:e,setID:n}),t(sr,{id:e,setID:n})]}),t(lr,{})]}),t($e,{id:e})]})}function cr({}){const e=c.default.useContext(R),n="SELECT *\nFROM commit\nWHERE author_time BETWEEN '${timeRange?.[0].toISOString()}' AND '${timeRange?.[1].toISOString()}'";return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Context"})}),p(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:[t(k.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:`-- You may refer context data *by name*
22
22
  -- in SQL or VizConfig.
23
23
 
24
- ${n}`}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context entries"}),t(k.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:JSON.stringify(e,null,2)})]})]})}function dr({value:e}){const n=c.default.useContext(R),i=c.default.useMemo(()=>St(e,n),[e,n]);return p(r.Group,{direction:"column",noWrap:!0,grow:!0,children:[t(r.Text,{children:"Preview"}),t(k.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:i})]})}function cr({}){const{sqlSnippets:e,setSQLSnippets:n}=c.default.useContext(O),i=c.default.useMemo(()=>({snippets:$.formList(e!=null?e:[])}),[e]),l=$.useForm({initialValues:i}),o=()=>l.addListItem("snippets",{key:E.randomId(),value:""}),s=c.default.useMemo(()=>!z.default.isEqual(l.values,i),[l.values,i]),a=({snippets:u})=>{n(u)};return t(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",flexGrow:1},children:p("form",{onSubmit:l.onSubmit(a),children:[p(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:[t(r.Text,{weight:500,children:"SQL Snippets"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!s,children:t(S.DeviceFloppy,{size:20})})]}),t(r.Group,{px:"md",pb:"md",pt:"md",children:p(r.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:[l.values.snippets.map((u,d)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,h({label:"Key",required:!0},l.getListInputProps("snippets",d,"key"))),t(r.Textarea,G(h({minRows:3,label:"Value",required:!0},l.getListInputProps("snippets",d,"value")),{className:"code-textarea"})),t(dr,{value:l.values.snippets[d].value}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("snippets",d),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},d)),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:t(r.Button,{variant:"default",onClick:o,children:"Add a snippet"})})]})})]})})}const pr=`SELECT *
24
+ ${n}`}),t(r.Text,{weight:500,sx:{flexGrow:0},children:"Avaiable context entries"}),t(k.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:JSON.stringify(e,null,2)})]})]})}function pr({value:e}){const n=c.default.useContext(R),i=c.default.useMemo(()=>St(e,n),[e,n]);return p(r.Group,{direction:"column",noWrap:!0,grow:!0,children:[t(r.Text,{children:"Preview"}),t(k.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:i})]})}function fr({}){const{sqlSnippets:e,setSQLSnippets:n}=c.default.useContext(O),i=c.default.useMemo(()=>({snippets:$.formList(e!=null?e:[])}),[e]),l=$.useForm({initialValues:i}),o=()=>l.addListItem("snippets",{key:E.randomId(),value:""}),s=c.default.useMemo(()=>!z.default.isEqual(l.values,i),[l.values,i]),a=({snippets:u})=>{n(u)};return t(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",flexGrow:1},children:p("form",{onSubmit:l.onSubmit(a),children:[p(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:[t(r.Text,{weight:500,children:"SQL Snippets"}),t(r.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!s,children:t(S.DeviceFloppy,{size:20})})]}),t(r.Group,{px:"md",pb:"md",pt:"md",children:p(r.Group,{direction:"column",sx:{width:"100%",position:"relative"},grow:!0,children:[l.values.snippets.map((u,d)=>p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.TextInput,h({label:"Key",required:!0},l.getListInputProps("snippets",d,"key"))),t(r.Textarea,G(h({minRows:3,label:"Value",required:!0},l.getListInputProps("snippets",d,"value")),{className:"code-textarea"})),t(pr,{value:l.values.snippets[d].value}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>l.removeListItem("snippets",d),sx:{position:"absolute",top:15,right:5},children:t(S.Trash,{size:16})})]},d)),t(r.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:t(r.Button,{variant:"default",onClick:o,children:"Add a snippet"})})]})})]})})}const mr=`SELECT *
25
25
  FROM commit
26
- WHERE \${author_time_condition}`;function fr(){return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Guide"})}),t(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:t(k.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,trim:!1,colorScheme:"dark",children:`-- You may refer context data *by name*
26
+ WHERE \${author_time_condition}`;function hr(){return p(r.Group,{direction:"column",grow:!0,sx:{border:"1px solid #eee",overflow:"hidden"},children:[t(r.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:t(r.Text,{weight:500,children:"Guide"})}),t(r.Group,{direction:"column",px:"md",pb:"md",sx:{width:"100%"},children:t(k.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,trim:!1,colorScheme:"dark",children:`-- You may refer context data *by name*
27
27
  -- in SQL or VizConfig.
28
28
 
29
- ${pr}
29
+ ${mr}
30
30
 
31
31
  -- where author_time_condition is:
32
32
  author_time BETWEEN '\${timeRange?.[0].toISOString()}' AND '\${timeRange?.[1].toISOString()}'
33
- `})})]})}function mr({}){return t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".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(cr,{}),p(r.Group,{direction:"column",grow:!0,noWrap:!0,sx:{maxWidth:"40%"},children:[t(fr,{}),t(ur,{})]})]})})}function hr({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(j);return c.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:"Data Settings",trapFocus:!0,onDragStart:l=>{l.stopPropagation()},children:p(r.Tabs,{children:[t(r.Tabs.Tab,{label:"SQL Snippet",children:t(mr,{})}),t(r.Tabs.Tab,{label:"Queries",children:t(sr,{})})]})})}function xr({mode:e,setMode:n,hasChanges:i,addPanel:l,saveChanges:o}){const{inLayoutMode:s,inEditMode:a,inUseMode:u}=c.default.useContext(j),[d,f]=c.default.useState(!1),x=()=>f(!0),m=()=>f(!1);return p(r.Group,{position:"apart",pt:"sm",pb:"xs",children:[t(r.Group,{position:"left",children:t(tr,{mode:e,setMode:n})}),p(r.Group,{position:"right",children:[!u&&t(r.Button,{variant:"default",size:"sm",onClick:l,leftIcon:t(S.PlaylistAdd,{size:20}),children:"Add a Panel"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:x,leftIcon:t(S.Database,{size:20}),children:"Data Settings"}),!u&&t(r.Button,{variant:"default",size:"sm",onClick:o,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(hr,{opened:d,close:m}),u&&t(r.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:t(S.Share,{size:20}),children:"Share"})]})}function gr({context:e,dashboard:n,update:i,className:l="dashboard",config:o}){Y.baseURL!==o.apiBaseURL&&(Y.baseURL=o.apiBaseURL);const[s,a]=c.default.useState(!1),[u,d]=c.default.useState(n.panels),[f,x]=c.default.useState(n.definition.sqlSnippets),[m,g]=c.default.useState(n.definition.queries),[y,C]=c.default.useState(M.Edit),T=c.default.useMemo(()=>{const F=Q=>JSON.parse(JSON.stringify(Q));return!z.default.isEqual(F(u),F(n.panels))||!z.default.isEqual(f,n.definition.sqlSnippets)?!0:!z.default.isEqual(m,n.definition.queries)},[n,u,f,m]),I=async()=>{const F=G(h({},n),{panels:u,definition:{sqlSnippets:f,queries:m}});await i(F)},D=()=>{const F=E.randomId(),fe={id:F,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${F}`,description:"<p><br></p>",queryID:"",viz:{type:"text",conf:{}}};d(Q=>[...Q,fe])},X=F=>{const fe=u.findIndex(Q=>Q.id===F);d(Q=>(Q.splice(fe,1),[...Q]))},pe=y===M.Edit,ne=y===M.Layout,ze=y===M.Use,Pe=c.default.useMemo(()=>({sqlSnippets:f,setSQLSnippets:x,queries:m,setQueries:g}),[f,x,m,g]);return t(R.Provider,{value:e,children:t("div",{className:l,children:t(O.Provider,{value:Pe,children:p(j.Provider,{value:{layoutFrozen:s,freezeLayout:a,mode:y,inEditMode:pe,inLayoutMode:ne,inUseMode:ze},children:[t(xr,{mode:y,setMode:C,hasChanges:T,addPanel:D,saveChanges:I}),t(ut,{panels:u,setPanels:d,isDraggable:ne,isResizable:ne,onRemoveItem:X})]})})})})}const br=L.WidthProvider(Ae.default);function yr({panels:e,className:n="layout",rowHeight:i=10}){return t(br,{className:n,rowHeight:i,isDraggable:!1,isResizable:!1,children:e.map(s=>{var a=s,{id:l}=a,o=P(a,["id"]);return t("div",{"data-grid":o.layout,children:t(Ge,h({id:l},o))},l)})})}function Cr({context:e,dashboard:n,className:i="dashboard",config:l}){Y.baseURL!==l.apiBaseURL&&(Y.baseURL=l.apiBaseURL);const o=c.default.useMemo(()=>G(h({},n.definition),{setSQLSnippets:()=>{},setQueries:()=>{}}),[n]);return t(R.Provider,{value:e,children:t("div",{className:i,children:t(O.Provider,{value:o,children:t(j.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:M.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:t(yr,{panels:n.panels})})})})})}b.ContextInfoContext=R,b.Dashboard=gr,b.DashboardLayout=ut,b.DashboardMode=M,b.DefinitionContext=O,b.LayoutStateContext=j,b.Panel=Ge,b.PanelContext=q,b.ReadOnlyDashboard=Cr,b.initialContextInfoContext=Tt,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
33
+ `})})]})}function xr({}){return t(r.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".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(fr,{}),p(r.Group,{direction:"column",grow:!0,noWrap:!0,sx:{maxWidth:"40%"},children:[t(hr,{}),t(cr,{})]})]})})}function gr({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(j);return c.default.useEffect(()=>{i(e)},[e]),t(r.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:n,title:"Data Settings",trapFocus:!0,onDragStart:l=>{l.stopPropagation()},children:p(r.Tabs,{children:[t(r.Tabs.Tab,{label:"SQL Snippet",children:t(xr,{})}),t(r.Tabs.Tab,{label:"Queries",children:t(dr,{})})]})})}function br({mode:e,setMode:n,hasChanges:i,addPanel:l,saveChanges:o}){const{inLayoutMode:s,inEditMode:a,inUseMode:u}=c.default.useContext(j),[d,f]=c.default.useState(!1),x=()=>f(!0),m=()=>f(!1);return p(r.Group,{position:"apart",pt:"sm",pb:"xs",children:[t(r.Group,{position:"left",children:t(rr,{mode:e,setMode:n})}),p(r.Group,{position:"right",children:[!u&&t(r.Button,{variant:"default",size:"sm",onClick:l,leftIcon:t(S.PlaylistAdd,{size:20}),children:"Add a Panel"}),a&&t(r.Button,{variant:"default",size:"sm",onClick:x,leftIcon:t(S.Database,{size:20}),children:"Data Settings"}),!u&&t(r.Button,{variant:"default",size:"sm",onClick:o,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(gr,{opened:d,close:m}),u&&t(r.Button,{variant:"default",size:"sm",disabled:!0,leftIcon:t(S.Share,{size:20}),children:"Share"})]})}function yr({context:e,dashboard:n,update:i,className:l="dashboard",config:o}){Y.baseURL!==o.apiBaseURL&&(Y.baseURL=o.apiBaseURL);const[s,a]=c.default.useState(!1),[u,d]=c.default.useState(n.panels),[f,x]=c.default.useState(n.definition.sqlSnippets),[m,g]=c.default.useState(n.definition.queries),[b,C]=c.default.useState(M.Edit),T=c.default.useMemo(()=>{const F=W=>JSON.parse(JSON.stringify(W));return!z.default.isEqual(F(u),F(n.panels))||!z.default.isEqual(f,n.definition.sqlSnippets)?!0:!z.default.isEqual(m,n.definition.queries)},[n,u,f,m]),I=async()=>{const F=G(h({},n),{panels:u,definition:{sqlSnippets:f,queries:m}});await i(F)},D=()=>{const F=E.randomId(),fe={id:F,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${F}`,description:"<p><br></p>",queryID:"",viz:{type:"text",conf:{}}};d(W=>[...W,fe])},X=F=>{const fe=u.findIndex(W=>W.id===F);d(W=>(W.splice(fe,1),[...W]))},pe=b===M.Edit,re=b===M.Layout,ze=b===M.Use,Pe=c.default.useMemo(()=>({sqlSnippets:f,setSQLSnippets:x,queries:m,setQueries:g}),[f,x,m,g]);return t(R.Provider,{value:e,children:t("div",{className:l,children:t(O.Provider,{value:Pe,children:p(j.Provider,{value:{layoutFrozen:s,freezeLayout:a,mode:b,inEditMode:pe,inLayoutMode:re,inUseMode:ze},children:[t(br,{mode:b,setMode:C,hasChanges:T,addPanel:D,saveChanges:I}),t(ut,{panels:u,setPanels:d,isDraggable:re,isResizable:re,onRemoveItem:X})]})})})})}const Cr=L.WidthProvider(Ae.default);function Sr({panels:e,className:n="layout",rowHeight:i=10}){return t(Cr,{className:n,rowHeight:i,isDraggable:!1,isResizable:!1,children:e.map(s=>{var a=s,{id:l}=a,o=P(a,["id"]);return t("div",{"data-grid":o.layout,children:t(Ge,h({id:l},o))},l)})})}function wr({context:e,dashboard:n,className:i="dashboard",config:l}){Y.baseURL!==l.apiBaseURL&&(Y.baseURL=l.apiBaseURL);const o=c.default.useMemo(()=>G(h({},n.definition),{setSQLSnippets:()=>{},setQueries:()=>{}}),[n]);return t(R.Provider,{value:e,children:t("div",{className:i,children:t(O.Provider,{value:o,children:t(j.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:M.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:t(Sr,{panels:n.panels})})})})})}y.ContextInfoContext=R,y.Dashboard=yr,y.DashboardLayout=ut,y.DashboardMode=M,y.DefinitionContext=O,y.LayoutStateContext=j,y.Panel=Ge,y.PanelContext=q,y.ReadOnlyDashboard=wr,y.initialContextInfoContext=Tt,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Control } from 'react-hook-form';
3
+ import { ICartesianChartConf } from '../../type';
4
+ interface IScatterFields {
5
+ control: Control<ICartesianChartConf, any>;
6
+ index: number;
7
+ }
8
+ export declare function ScatterFields({ control, index }: IScatterFields): JSX.Element;
9
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"