@devtable/dashboard 1.19.0 → 1.20.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.
- package/dist/dashboard.es.js +114 -37
- package/dist/dashboard.umd.js +8 -8
- package/dist/panel/viz/cartesian/panel/series/fields.bar.d.ts +9 -0
- package/dist/panel/viz/cartesian/panel/series/fields.line.d.ts +9 -0
- package/dist/panel/viz/cartesian/panel/{series.d.ts → series/index.d.ts} +1 -1
- package/dist/panel/viz/cartesian/panel/series/series-item.d.ts +16 -0
- package/dist/panel/viz/cartesian/type.d.ts +4 -1
- package/package.json +1 -1
- package/dist/panel/viz/bar-3d/type.d.ts +0 -4
package/dist/dashboard.es.js
CHANGED
|
@@ -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, SegmentedControl, NumberInput,
|
|
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";
|
|
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";
|
|
@@ -1913,6 +1913,98 @@ function _MantineColorSelector({
|
|
|
1913
1913
|
});
|
|
1914
1914
|
}
|
|
1915
1915
|
const MantineColorSelector = React.forwardRef(_MantineColorSelector);
|
|
1916
|
+
function BarFields({
|
|
1917
|
+
control,
|
|
1918
|
+
index: index2
|
|
1919
|
+
}) {
|
|
1920
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
1921
|
+
direction: "row",
|
|
1922
|
+
grow: true,
|
|
1923
|
+
align: "top",
|
|
1924
|
+
children: [/* @__PURE__ */ jsx(Controller, {
|
|
1925
|
+
name: `series.${index2}.stack`,
|
|
1926
|
+
control,
|
|
1927
|
+
render: ({
|
|
1928
|
+
field
|
|
1929
|
+
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
1930
|
+
label: "Stack",
|
|
1931
|
+
placeholder: "Stack bars by this ID",
|
|
1932
|
+
sx: {
|
|
1933
|
+
flexGrow: 1
|
|
1934
|
+
}
|
|
1935
|
+
}, field))
|
|
1936
|
+
}), /* @__PURE__ */ jsx(Controller, {
|
|
1937
|
+
name: `series.${index2}.barWidth`,
|
|
1938
|
+
control,
|
|
1939
|
+
render: ({
|
|
1940
|
+
field
|
|
1941
|
+
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
1942
|
+
label: "Bar Width",
|
|
1943
|
+
sx: {
|
|
1944
|
+
flexGrow: 1
|
|
1945
|
+
}
|
|
1946
|
+
}, field))
|
|
1947
|
+
})]
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
const stepOptions = [{
|
|
1951
|
+
label: "off",
|
|
1952
|
+
value: "false"
|
|
1953
|
+
}, {
|
|
1954
|
+
label: "start",
|
|
1955
|
+
value: "start"
|
|
1956
|
+
}, {
|
|
1957
|
+
label: "middle",
|
|
1958
|
+
value: "middle"
|
|
1959
|
+
}, {
|
|
1960
|
+
label: "end",
|
|
1961
|
+
value: "end"
|
|
1962
|
+
}];
|
|
1963
|
+
function LineFields({
|
|
1964
|
+
control,
|
|
1965
|
+
index: index2
|
|
1966
|
+
}) {
|
|
1967
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
1968
|
+
direction: "row",
|
|
1969
|
+
grow: true,
|
|
1970
|
+
align: "center",
|
|
1971
|
+
children: [/* @__PURE__ */ jsx(Controller, {
|
|
1972
|
+
name: `series.${index2}.step`,
|
|
1973
|
+
control,
|
|
1974
|
+
render: ({
|
|
1975
|
+
field
|
|
1976
|
+
}) => /* @__PURE__ */ jsx(Select, __spreadProps(__spreadValues({
|
|
1977
|
+
label: "Step",
|
|
1978
|
+
data: stepOptions,
|
|
1979
|
+
sx: {
|
|
1980
|
+
flexGrow: 1,
|
|
1981
|
+
maxWidth: "48%"
|
|
1982
|
+
}
|
|
1983
|
+
}, field), {
|
|
1984
|
+
value: String(field.value),
|
|
1985
|
+
onChange: (v) => {
|
|
1986
|
+
const step = v === "false" ? false : v;
|
|
1987
|
+
field.onChange(step);
|
|
1988
|
+
}
|
|
1989
|
+
}))
|
|
1990
|
+
}), /* @__PURE__ */ jsx(Controller, {
|
|
1991
|
+
name: `series.${index2}.smooth`,
|
|
1992
|
+
control,
|
|
1993
|
+
render: ({
|
|
1994
|
+
field
|
|
1995
|
+
}) => /* @__PURE__ */ jsx(Box, {
|
|
1996
|
+
sx: {
|
|
1997
|
+
flexGrow: 1
|
|
1998
|
+
},
|
|
1999
|
+
children: /* @__PURE__ */ jsx(Switch, {
|
|
2000
|
+
label: "Smooth Line",
|
|
2001
|
+
checked: field.value,
|
|
2002
|
+
onChange: (event) => field.onChange(event.currentTarget.checked)
|
|
2003
|
+
})
|
|
2004
|
+
})
|
|
2005
|
+
})]
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
1916
2008
|
const labelPositions = [{
|
|
1917
2009
|
label: "off",
|
|
1918
2010
|
value: ""
|
|
@@ -2064,34 +2156,12 @@ function SeriesItemField({
|
|
|
2064
2156
|
}));
|
|
2065
2157
|
}
|
|
2066
2158
|
})]
|
|
2067
|
-
}), type === "
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
control,
|
|
2074
|
-
render: ({
|
|
2075
|
-
field
|
|
2076
|
-
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2077
|
-
label: "Stack",
|
|
2078
|
-
placeholder: "Stack bars by this ID",
|
|
2079
|
-
sx: {
|
|
2080
|
-
flexGrow: 1
|
|
2081
|
-
}
|
|
2082
|
-
}, field))
|
|
2083
|
-
}), /* @__PURE__ */ jsx(Controller, {
|
|
2084
|
-
name: `series.${index2}.barWidth`,
|
|
2085
|
-
control,
|
|
2086
|
-
render: ({
|
|
2087
|
-
field
|
|
2088
|
-
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2089
|
-
label: "Bar Width",
|
|
2090
|
-
sx: {
|
|
2091
|
-
flexGrow: 1
|
|
2092
|
-
}
|
|
2093
|
-
}, field))
|
|
2094
|
-
})]
|
|
2159
|
+
}), type === "line" && /* @__PURE__ */ jsx(LineFields, {
|
|
2160
|
+
index: index2,
|
|
2161
|
+
control
|
|
2162
|
+
}), type === "bar" && /* @__PURE__ */ jsx(BarFields, {
|
|
2163
|
+
index: index2,
|
|
2164
|
+
control
|
|
2095
2165
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
2096
2166
|
name: `series.${index2}.label_position`,
|
|
2097
2167
|
control,
|
|
@@ -2144,7 +2214,7 @@ function SeriesField({
|
|
|
2144
2214
|
control,
|
|
2145
2215
|
name: "series"
|
|
2146
2216
|
});
|
|
2147
|
-
const watchFieldArray = watch("
|
|
2217
|
+
const watchFieldArray = watch("series");
|
|
2148
2218
|
const controlledFields = fields.map((field, index2) => {
|
|
2149
2219
|
return __spreadValues(__spreadValues({}, field), watchFieldArray[index2]);
|
|
2150
2220
|
});
|
|
@@ -2156,7 +2226,9 @@ function SeriesField({
|
|
|
2156
2226
|
yAxisIndex: 0,
|
|
2157
2227
|
label_position: "top",
|
|
2158
2228
|
stack: "",
|
|
2159
|
-
color: "#000"
|
|
2229
|
+
color: "#000",
|
|
2230
|
+
step: false,
|
|
2231
|
+
smooth: false
|
|
2160
2232
|
});
|
|
2161
2233
|
const yAxisOptions = React.useMemo(() => {
|
|
2162
2234
|
return getValues().y_axes.map(({
|
|
@@ -2362,7 +2434,9 @@ function withDefaults(series) {
|
|
|
2362
2434
|
label_position = "top",
|
|
2363
2435
|
stack = "1",
|
|
2364
2436
|
color: color2 = "black",
|
|
2365
|
-
barWidth = "30"
|
|
2437
|
+
barWidth = "30",
|
|
2438
|
+
smooth = false,
|
|
2439
|
+
step = false
|
|
2366
2440
|
}) {
|
|
2367
2441
|
return {
|
|
2368
2442
|
type,
|
|
@@ -2373,7 +2447,9 @@ function withDefaults(series) {
|
|
|
2373
2447
|
label_position,
|
|
2374
2448
|
stack,
|
|
2375
2449
|
color: color2,
|
|
2376
|
-
barWidth
|
|
2450
|
+
barWidth,
|
|
2451
|
+
smooth,
|
|
2452
|
+
step
|
|
2377
2453
|
};
|
|
2378
2454
|
}
|
|
2379
2455
|
return series.map(setDefaults);
|
|
@@ -2415,13 +2491,14 @@ function VizCartesianChartPanel({
|
|
|
2415
2491
|
control,
|
|
2416
2492
|
handleSubmit,
|
|
2417
2493
|
watch,
|
|
2418
|
-
formState: {
|
|
2419
|
-
isDirty
|
|
2420
|
-
},
|
|
2421
2494
|
getValues
|
|
2422
2495
|
} = useForm({
|
|
2423
2496
|
defaultValues
|
|
2424
2497
|
});
|
|
2498
|
+
const values = getValues();
|
|
2499
|
+
const changed = React.useMemo(() => {
|
|
2500
|
+
return !_.isEqual(values, conf);
|
|
2501
|
+
}, [values, conf]);
|
|
2425
2502
|
return /* @__PURE__ */ jsx(Group, {
|
|
2426
2503
|
direction: "column",
|
|
2427
2504
|
mt: "md",
|
|
@@ -2442,7 +2519,7 @@ function VizCartesianChartPanel({
|
|
|
2442
2519
|
mr: 5,
|
|
2443
2520
|
variant: "filled",
|
|
2444
2521
|
color: "blue",
|
|
2445
|
-
disabled: !
|
|
2522
|
+
disabled: !changed,
|
|
2446
2523
|
children: /* @__PURE__ */ jsx(DeviceFloppy, {
|
|
2447
2524
|
size: 20
|
|
2448
2525
|
})
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
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={};/**
|
|
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 o,l={},s=null,a=null;i!==void 0&&(s=""+i),n.key!==void 0&&(s=""+n.key),n.ref!==void 0&&(a=n.ref);for(o in n)Lt.call(n,o)&&!Dt.hasOwnProperty(o)&&(l[o]=n[o]);if(e&&e.defaultProps)for(o in n=e.defaultProps,n)l[o]===void 0&&(l[o]=n[o]);return{$$typeof:Pt,type:e,key:s,ref:a,props:l,_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),[o,l]=c.default.useState(!1),{description:s}=c.default.useContext(M);if(c.default.useEffect(()=>{i(o)},[o]),!s||s==="<p><br></p>")return null;const a=n==="click"?t(r.Tooltip,{label:"Click to see description",openDelay:500,children:t(C.InfoCircle,{size:20,onClick:()=>l(u=>!u),style:{verticalAlign:"baseline",cursor:"pointer"}})}):t(C.InfoCircle,{size:20,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{verticalAlign:"baseline",cursor:"pointer"}});return t(r.Popover,{opened:o,onClose:()=>l(!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(M),[i,o]=c.default.useState(e),l=e!==i,s=c.default.useCallback(()=>{!l||n(i)},[l,i]);return p(r.Group,{direction:"column",sx:{flexGrow:1},children:[p(r.Group,{align:"end",children:[t(r.Text,{children:"Description"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(C.DeviceFloppy,{size:20})})]}),t(Le.RichTextEditor,{value:i,onChange:o,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(M);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(M),[i,o]=E.useInputState(e),l=e!==i,s=c.default.useCallback(()=>{!l||n(i)},[l,i]);return t(r.TextInput,{value:i,onChange:o,label:p(r.Group,{align:"end",children:[t(r.Text,{children:"Panel Title"}),t(r.ActionIcon,{variant:"hover",color:"blue",disabled:!l,onClick:s,children:t(C.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(q),i=c.default.useContext(R),o=c.default.useMemo(()=>n.queries.find(u=>u.id===e),[n.queries,e]),{data:l=[],loading:s,refresh:a}=he.useRequest(Me({context:i,definitions:n,title:e,query:o}),{refreshDeps:[i,n,o]});return s?t(r.LoadingOverlay,{visible:s,exitTransitionDuration:0}):l.length===0?t(r.Table,{}):p(r.Group,{my:"xl",direction:"column",grow:!0,sx:{border:"1px solid #eee"},children:[p(r.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(r.Group,{position:"left",children:[t(r.Text,{weight:500,children:"Preview Data"}),l.length>10&&p(r.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",l.length]})]}),t(r.ActionIcon,{mr:15,variant:"hover",color:"blue",disabled:s,onClick:a,children:t(C.Refresh,{size:15})})]}),p(r.Table,{children:[t("thead",{children:t("tr",{children:Object.keys(l==null?void 0:l[0]).map(u=>t("th",{children:t(r.Text,{weight:700,color:"#000",children:u})},u))})}),t("tbody",{children:l.slice(0,10).map((u,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(q),{queryID:n,setQueryID:i,data:o,loading:l}=c.default.useContext(M),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:o}){const m=e,{label_field:l="name",value_field:s="value"}=m,a=P(m,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(g=>({name:g[l],value:Number(g[s])})),[n,l,s]),d=c.default.useMemo(()=>{var g,b;return(b=(g=z.default.maxBy(u,S=>S.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:o}})}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:o}){const l=c.default.useMemo(()=>{var f;const s=e.y_axes.reduce((x,{label_formatter:m},g)=>(x[g]=function(S){const v=typeof S=="object"?S.value:S;if(!m)return v;try{return K.default(v).format(m)}catch(O){return console.error(O),v}},x),{default:({value:x})=>x}),a=e.series.reduce((x,{yAxisIndex:m,name:g})=>(x[g]=m,x),{}),u=e.series.map(v=>{var O=v,{y_axis_data_key:x,yAxisIndex:m,label_position:g,name:b}=O,S=P(O,["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},S)}),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 S=b,{label_formatter:x}=S,m=P(S,["label_formatter"]);var v;return G(h({},m),{axisLabel:{show:!0,formatter:(v=s[g])!=null?v: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:S})=>{var A;if(!b)return S;const v=a[b],O=(A=s[v])!=null?A:s.default;return`${b}: ${O({value:S})}`});return g.unshift(`<strong>${m[0].name}</strong>`),g.join("<br />")}}};return z.default.merge({},Ft,d)},[e,n]);return!i||!o?null:t(le.default,{echarts:B,option:l,style:{width:i,height:o}})}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:o}){const x=e,{id_field:l,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:o}},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:S})=>t("td",{children:t(r.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:t(Wt,{value:m[b],type:S})})},`${b}--${m[b]}`))},l?m[l]:`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}),o=Object.keys(i),l=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...l)}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:o}=u,l=P(u,["template","size"]);return t(r.Text,G(h({},l),{sx:{fontSize:o},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:o}){const m=e,{x_axis_data_key:l,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[l],g[s],g[a]])}]});return t(le.default,{echarts:B,option:x,style:{width:i,height:o}})}var wr="";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:o}){const x=e,{label_field:l="name",value_field:s="value"}=x,a=P(x,["label_field","value_field"]),u=c.default.useMemo(()=>n.map(m=>({name:m[l],value:Number(m[s])})),[n,l,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:o}})}var Re=function(){};const Ht=(e,n,i)=>Math.min(Math.max(i,e),n),Fe=(e,n,i)=>{const o=n-e;return o===0?1:(i-e)/o},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)=>o=>{if(!ee(o))return o;const[l,s,a,u]=o.match(se);return{[e]:parseFloat(l),[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:o=1})=>"hsla("+Math.round(e)+", "+te.transform(H(n))+", "+te.transform(H(i))+", "+H(je.transform(o))+")"},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:o=1})=>"rgba("+Ce.transform(e)+", "+Ce.transform(n)+", "+Ce.transform(i)+", "+H(je.transform(o))+")"};function nn(e){let n="",i="",o="",l="";return e.length>5?(n=e.substr(1,2),i=e.substr(3,2),o=e.substr(5,2),l=e.substr(7,2)):(n=e.substr(1,1),i=e.substr(2,1),o=e.substr(3,1),l=e.substr(4,1),n+=n,i+=i,o+=o,l+=l),{red:parseInt(n,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:l?parseInt(l,16)/255:1}}const 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,o,l;return isNaN(e)&&ee(e)&&((i=(n=e.match(se))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)+((l=(o=e.match(be))===null||o===void 0?void 0:o.length)!==null&&l!==void 0?l:0)>0}function We(e){typeof e=="number"&&(e=`${e}`);const n=[];let i=0;const o=e.match(be);o&&(i=o.length,e=e.replace(be,Ve),n.push(...o.map(de.parse)));const l=e.match(se);return l&&(e=e.replace(se,Qe),n.push(...l.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:o}=We(e),l=n.length;return s=>{let a=o;for(let u=0;u<l;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:o}){e/=360,n/=100,i/=100;let l=0,s=0,a=0;if(!n)l=s=a=i;else{const u=i<.5?i*(1+n):i+n-i*n,d=2*i-u;l=we(d,u,e+1/3),s=we(d,u,e),a=we(d,u,e-1/3)}return{red:Math.round(l*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:o}}const an=(e,n,i)=>{const o=e*e,l=n*n;return Math.sqrt(Math.max(0,i*(l-o)+o))},sn=[Se,V,J],Ke=e=>sn.find(n=>n.test(e)),Ze=(e,n)=>{let i=Ke(e),o=Ke(n),l=i.parse(e),s=o.parse(n);i===J&&(l=Xe(l),i=V),o===J&&(s=Xe(s),o=V);const a=Object.assign({},l);return u=>{for(const d in a)d!=="alpha"&&(a[d]=an(l[d],s[d],u));return a.alpha=ge(l.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],o=i.length,l=e.map((s,a)=>et(s,n[a]));return s=>{for(let a=0;a<o;a++)i[a]=l[a](s);return i}},cn=(e,n)=>{const i=Object.assign(Object.assign({},e),n),o={};for(const l in i)e[l]!==void 0&&n[l]!==void 0&&(o[l]=et(e[l],n[l]));return l=>{for(const s in o)i[s]=o[s](l);return i}};function nt(e){const n=Ye.parse(e),i=n.length;let o=0,l=0,s=0;for(let a=0;a<i;a++)o||typeof n[a]=="number"?o++:n[a].hue!==void 0?s++:l++;return{parsed:n,numNumbers:o,numRGB:l,numHSL:s}}const rt=(e,n)=>{const i=Ye.createTransformer(n),o=nt(e),l=nt(n);return o.numHSL===l.numHSL&&o.numRGB===l.numRGB&&o.numNumbers>=l.numNumbers?He(tt(o.parsed,l.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 o=[],l=i||fn(e[0]),s=e.length-1;for(let a=0;a<s;a++){let u=l(e[a],e[a+1]);if(n){const d=Array.isArray(n)?n[a]:n;u=He(d,u)}o.push(u)}return o}function hn([e,n],[i]){return o=>i(Fe(e,n,o))}function xn(e,n){const i=e.length,o=i-1;return l=>{let s=0,a=!1;if(l<=e[0]?a=!0:l>=e[o]&&(s=o-1,a=!0),!a){let d=1;for(;d<i&&!(e[d]>l||d===o);d++);s=d-1}const u=Fe(e[s],e[s+1],l);return n[s](u)}}function gn(e,n,{clamp:i=!0,ease:o,mixer:l}={}){const s=e.length;Re(s===n.length),Re(!o||!Array.isArray(o)||o.length===s-1),e[0]>e[s-1]&&(e=[].concat(e),n=[].concat(n),e.reverse(),n.reverse());const a=mn(n,o,l),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),o=n[e.valueField];return i.getColor(o)}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,o=P(d,["content","size","color"]),{data:l}=a;const f=c.default.useMemo(()=>yn(i,l[0]),[i,l]),x=c.default.useMemo(()=>{var A;const{prefix:m,postfix:g,data_field:b,formatter:S}=e,v=(A=l==null?void 0:l[0])==null?void 0:A[b];return["string","number"].includes(typeof v)?[m,K.default(v).format(S),g].join(" "):Cn(v)},[e,l]);return t(r.Text,G(h({},o),{color:f,sx:{fontSize:n},children:x}))}function wn(e,n,i,o){const l={width:e,height:n,data:i,conf:o.conf};switch(o.type){case"sunburst":return t(Rt,h({},l));case"line-bar":case"cartesian":return t(Bt,h({},l));case"table":return t(Ut,h({},l));case"text":return t(Yt,h({},l));case"stats":return t(Sn,h({},l));case"bar-3d":return t(Xt,h({},l));case"pie":return t(Zt,h({},l));default:return null}}function it({viz:e,data:n,loading:i}){const{ref:o,width:l,height:s}=E.useElementSize(),a=c.default.useMemo(()=>!Array.isArray(n)||n.length===0,[n]);return i?t("div",{className:"viz-root",ref:o,children:t(r.LoadingOverlay,{visible:i,exitTransitionDuration:0})}):p("div",{className:"viz-root",ref:o,children:[a&&t(r.Text,{color:"gray",align:"center",children:"nothing to show"}),!a&&t(Ee,{children:wn(l,s,n,e)})]})}function vn({}){const{data:e,loading:n,viz:i}=c.default.useContext(M);return t(it,{viz:i,data:e,loading:n})}function Tn({label:e,required:n,value:i,onChange:o,data:l,sx:s},a){const u=c.default.useMemo(()=>!Array.isArray(l)||l.length===0?[]:Object.keys(l[0]).map(f=>({label:f,value:f})),[l]);return t(r.Select,{ref:a,label:e,data:u,value:i,onChange:o,required:n,sx:s})}const L=c.default.forwardRef(Tn);function Gn({conf:e,setConf:n,data:i}){const o=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:l,handleSubmit:s,formState:a}=w.useForm({defaultValues:o});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:l,render:({field:u})=>t(L,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"xAxis3D.name",control:l,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:l,render:({field:u})=>t(L,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"yAxis3D.name",control:l,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:l,render:({field:u})=>t(L,h({label:"Data Field",required:!0,data:i},u))}),t(w.Controller,{name:"zAxis3D.name",control:l,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(C.DeviceFloppy,{size:20}),t(r.Text,{ml:"md",children:"Save"})]})})]})})}function _n({value:e,onChange:n},i){const o=r.useMantineTheme(),l=c.default.useMemo(()=>Object.entries(o.colors).map(([a,u])=>({label:a,value:u[6]})),[o]),s=c.default.useMemo(()=>l.some(a=>a.value===e),[e,l]);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:l,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),zn=[{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 Pn({control:e,index:n,remove:i,seriesItem:o,yAxisOptions:l,data:s}){const a=o.type;return p(r.Group,{direction:"column",grow:!0,my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(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(L,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:l,disabled:l.length===0},f),{value:(b=u==null?void 0:u.toString())!=null?b:"",onChange:S=>{if(!S){d(0);return}d(Number(S))},sx:{flex:1}}))}})]}),a==="bar"&&p(r.Group,{direction:"row",grow:!0,align:"top",children:[t(w.Controller,{name:`series.${n}.stack`,control:e,render:({field:u})=>t(r.TextInput,h({label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1}},u))}),t(w.Controller,{name:`series.${n}.barWidth`,control:e,render:({field:u})=>t(r.TextInput,h({label:"Bar Width",sx:{flexGrow:1}},u))})]}),t(w.Controller,{name:`series.${n}.label_position`,control:e,render:({field:u})=>t(r.Select,h({label:"Label Position",data:zn},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(C.Trash,{size:16})})]},n)}function In({control:e,watch:n,getValues:i,data:o}){const{fields:l,append:s,remove:a}=w.useFieldArray({control:e,name:"series"}),u=n("y_axes"),d=l.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"}),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(Pn,{control:e,index:g,remove:a,seriesItem:m,yAxisOptions:x,data:o})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:f,children:"Add a Series"})})]})}const lt={mantissa:0,output:"number"};function Ln({value:e,onChange:n},i){const o=a=>{n(G(h({},e),{output:a}))},l=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:o}),t(r.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:l}),t(r.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:s,disabled:e.mantissa===0})]})})}const ot=c.default.forwardRef(Ln);function An({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:o})=>t(r.TextInput,h({label:"Name",required:!0,sx:{flex:1}},o))})}),t(r.Group,{direction:"column",grow:!0,noWrap:!0,children:t(w.Controller,{name:`y_axes.${n}.label_formatter`,control:e,render:({field:o})=>t(ot,h({},o))})}),t(r.ActionIcon,{color:"red",variant:"hover",onClick:()=>i(n),sx:{position:"absolute",top:15,right:5},disabled:n===0,children:t(C.Trash,{size:16})})]},n)}function Dn({control:e,watch:n}){const{fields:i,append:o,remove:l}=w.useFieldArray({control:e,name:"y_axes"}),s=n("y_axes"),a=i.map((d,f)=>h(h({},d),s[f])),u=()=>o({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(An,{control:e,index:f,remove:l})),t(r.Group,{position:"center",mt:"xs",children:t(r.Button,{onClick:u,children:"Add a Y Axis"})})]})}function Mn(e){function n({type:i,name:o,showSymbol:l,y_axis_data_key:s="value",yAxisIndex:a=0,label_position:u="top",stack:d="1",color:f="black",barWidth:x="30"}){return{type:i,name:o,showSymbol:l,y_axis_data_key:s,yAxisIndex:a,label_position:u,stack:d,color:f,barWidth:x}}return e.map(n)}function qn({conf:e,setConf:n,data:i}){const g=e,{series:o,y_axes:l}=g,s=P(g,["series","y_axes"]),a=c.default.useMemo(()=>{const v=s,{x_axis_name:b=""}=v,S=P(v,["x_axis_name"]);return h({series:Mn(o!=null?o:[]),x_axis_name:b,y_axes:l!=null?l:[{name:"Y Axis",label_formatter:lt}]},S)},[o,s]);c.default.useEffect(()=>{!z.default.isEqual(e,a)&&n(a)},[e,a]);const{control:u,handleSubmit:d,watch:f,formState:{isDirty:x},getValues:m}=w.useForm({defaultValues:a});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:!x,children:t(C.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:b})=>t(L,h({label:"X Axis Data Field",required:!0,data:i,sx:{flex:1}},b))}),t(w.Controller,{name:"x_axis_name",control:u,render:({field:b})=>t(r.TextInput,h({label:"X Axis Name"},b))})]}),t(Dn,{control:u,watch:f}),t(In,{control:u,watch:f,getValues:m,data:i})]})})}function On({conf:{label_field:e,value_field:n},setConf:i,data:o}){const l=$.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:l.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(C.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(L,h({label:"Label Field",required:!0,data:o},l.getInputProps("label_field"))),t(L,h({label:"Value Field",required:!0,data:o},l.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 kn({label:e,value:n,onChange:i},o){var a,u;const[l,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===l);d&&i(d.label)},[l]),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:l,onChange:s,step:25,placeholder:"Pick a font size",ref:o})]})}const at=c.default.forwardRef(kn);function En({label:e,value:n,onChange:i},o){const[l,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(l,n),[l,n]),f=()=>{i(l.map(x=>x.toString()))};return p(Z,{children:[p(r.Group,{position:"left",ref:o,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(C.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[l.map((x,m)=>t(r.TextInput,{value:x,onChange:g=>{const b=g.currentTarget.value;s(S=>(S.splice(m,1,b),[...S]))},rightSection:t(r.ActionIcon,{onClick:()=>u(m),color:"red",children:t(C.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(C.PlaylistAdd,{size:20})})]})]})}const $n=c.default.forwardRef(En);function Rn({label:e,value:n,onChange:i},o){const[l,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(l,n),[l,n]),f=()=>{i(l.map(g=>g.toString()))},x=r.useMantineTheme(),m=c.default.useMemo(()=>Object.entries(x.colors).map(([g,b])=>b[6]),[x]);return p(Z,{children:[p(r.Group,{position:"left",ref:o,children:[t(r.Text,{children:e}),t(r.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:t(C.DeviceFloppy,{size:20})})]}),p(r.Group,{children:[l.map((g,b)=>t(r.ColorInput,{value:g,onChange:S=>{s(v=>(v.splice(b,1,S),[...v]))},swatches:m,rightSection:t(r.ActionIcon,{onClick:()=>u(b),color:"red",children:t(C.Trash,{size:14})}),sx:{width:"45%"}})),t(r.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:t(C.PlaylistAdd,{size:20})})]})]})}const Fn=c.default.forwardRef(Rn);function Bn({conf:e,setConf:n,data:i}){const o=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:l,handleSubmit:s,watch:a,formState:{isDirty:u}}=w.useForm({defaultValues:o}),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(C.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:l,render:({field:f})=>t(r.TextInput,h({label:"Prefix",sx:{flexGrow:1}},f))}),t(w.Controller,{name:"content.data_field",control:l,render:({field:f})=>t(L,h({label:"Data Field",required:!0,data:i},f))}),t(w.Controller,{name:"content.postfix",control:l,render:({field:f})=>t(r.TextInput,h({label:"Postfix",sx:{flexGrow:1}},f))})]}),t(w.Controller,{name:"content.formatter",control:l,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:l,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:l,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:l,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:l,render:({field:f})=>t(ve,h({},f))}),d==="continuous"&&p(Z,{children:[t(w.Controller,{name:"color.valueField",control:l,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:l,render:({field:f})=>t($n,h({label:"Value Range"},f))}),t(w.Controller,{name:"color.colorRange",control:l,render:({field:f})=>t(Fn,h({label:"Color Range"},f))})]})]})})]})]})})}function jn({conf:{label_field:e,value_field:n},setConf:i,data:o}){const l=$.useForm({initialValues:{label_field:e,value_field:n}});return t(r.Group,{direction:"column",mt:"md",spacing:"xs",grow:!0,children:p("form",{onSubmit:l.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(C.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(L,h({label:"Label Field",required:!0,data:o},l.getInputProps("label_field"))),t(L,h({label:"Value Field",required:!0,data:o},l.getInputProps("value_field")))]})]})})}const Nn=Object.values(N).map(e=>({label:e,value:e}));function Vn({label:e,value:n,onChange:i,sx:o}){return t(r.Select,{label:e,data:Nn,value:n,onChange:i,sx:o})}function Qn(l){var s=l,{conf:a}=s,u=a,{columns:e}=u,n=P(u,["columns"]),{setConf:i,data:o}=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(C.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(L,h({label:"ID Field",required:!0,data:o},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(L,h({label:"Value Field",required:!0,data:o},d.getListInputProps("columns",m,"value_field"))),t(Vn,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(C.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 Wn({conf:e,setConf:n}){var l;const i=$.useForm({initialValues:{paragraphs:$.formList((l=e.paragraphs)!=null?l:st)}}),o=()=>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(C.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(C.Trash,{size:16})})]},a)),t(r.Group,{position:"center",mt:"md",children:t(r.Button,{onClick:o,children:"Add a Paragraph"})}),t(r.Text,{size:"sm",weight:500,mt:"md",children:"Current Configuration:"}),t(k.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Te=[{value:"text",label:"Text",Panel:Wn},{value:"stats",label:"Stats",Panel:Bn},{value:"table",label:"Table",Panel:Qn},{value:"sunburst",label:"Sunburst",Panel:jn},{value:"bar-3d",label:"Bar Chart (3D)",Panel:Gn},{value:"cartesian",label:"Cartesian Chart",Panel:qn},{value:"pie",label:"Pie Chart",Panel:On}];function Un(){const{data:e,viz:n,setViz:i}=c.default.useContext(M),[o,l]=E.useInputState(n.type),s=n.type!==o,a=c.default.useCallback(()=>{!s||i(x=>G(h({},x),{type:o}))},[s,o]),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===o))==null?void 0:x.Panel},[o,Te]);return p(Z,{children:[t(r.Select,{label:"Visualization",value:o,onChange:l,data:Te,rightSection:t(r.ActionIcon,{disabled:!s,onClick:a,children:t(C.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 Jn({}){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(Un,{})}),t(r.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:t(vn,{})})]})}function Yn({opened:e,close:n}){const{freezeLayout:i}=c.default.useContext(j),{data:o,loading:l,viz:s,title:a}=c.default.useContext(M);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:l,exitTransitionDuration:0}),t(Et,{})]}),t(r.Tabs.Tab,{label:"Panel",children:t(kt,{})}),t(r.Tabs.Tab,{label:"Visualization",children:t(Jn,{})})]})})})}var Tr="";function Xn({}){const[e,n]=c.default.useState(!1),i=()=>n(!0),o=()=>n(!1),{title:l,refreshData:s}=c.default.useContext(M),{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:l}),placement:"center",children:[t(r.Menu.Item,{onClick:s,icon:t(C.Refresh,{size:14}),children:"Refresh"}),a&&t(r.Menu.Item,{onClick:i,icon:t(C.Settings,{size:14}),children:"Settings"}),t(r.Divider,{}),t(r.Menu.Item,{color:"red",disabled:!0,icon:t(C.Trash,{size:14}),children:"Delete"})]})}),a&&t(Yn,{opened:e,close:o})]})}var Gr="";function Ge({viz:e,queryID:n,title:i,description:o,update:l,layout:s,id:a}){const u=c.default.useContext(R),d=c.default.useContext(q),[f,x]=c.default.useState(i),[m,g]=c.default.useState(o),[b,S]=c.default.useState(n),[v,O]=c.default.useState(e),A=c.default.useMemo(()=>{if(!!b)return d.queries.find(Pe=>Pe.id===b)},[b,d.queries]);c.default.useEffect(()=>{l==null||l({id:a,layout:s,title:f,description:m,queryID:b,viz:v})},[f,m,A,v,a,s,b]);const{data:X=[],loading:pe,refresh:ne}=he.useRequest(Me({context:u,definitions:d,title:f,query:A}),{refreshDeps:[u,d,A]}),ze=ne;return t(M.Provider,{value:{data:X,loading:pe,title:f,setTitle:x,description:m,setDescription:g,queryID:b,setQueryID:S,viz:v,setViz:O,refreshData:ze},children:p(r.Container,{className:"panel-root",children:[t(Xn,{}),t(it,{viz:v,data:X,loading:pe})]})})}var _r="";const Kn=I.WidthProvider(Ae.default);function ut({panels:e,setPanels:n,className:i="layout",rowHeight:o=10,onRemoveItem:l,isDraggable:s,isResizable:a}){const u=c.default.useCallback(d=>{const f=new Map;d.forEach(b=>{var S=b,{i:m}=S,g=P(S,["i"]);f.set(m,g)});const x=e.map(m=>G(h({},m),{layout:f.get(m.id)}));n(x)},[e,n]);return t(Kn,{onLayoutChange:u,className:i,rowHeight:o,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:()=>l(d),update:b=>{n(S=>(S.splice(x,1,b),[...S]))}}))},d)})})}function _e(e,n){return p(r.Text,{sx:{svg:{verticalAlign:"text-bottom"}},children:[e," ",n]})}function Zn({mode:e,setMode:n}){return t(r.SegmentedControl,{value:e,onChange:n,data:[{label:_e(t(C.PlayerPlay,{size:20}),"Use"),value:D.Use},{label:_e(t(C.Resize,{size:20}),"Layout"),value:D.Layout},{label:_e(t(C.Paint,{size:20}),"Content"),value:D.Edit}]})}const Hn=`
|
|
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=`
|
|
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
|
|
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*
|
|
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
|
|
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 *
|
|
25
25
|
FROM commit
|
|
26
|
-
WHERE \${author_time_condition}`;function
|
|
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*
|
|
27
27
|
-- in SQL or VizConfig.
|
|
28
28
|
|
|
29
|
-
${
|
|
29
|
+
${pr}
|
|
30
30
|
|
|
31
31
|
-- where author_time_condition is:
|
|
32
32
|
author_time BETWEEN '\${timeRange?.[0].toISOString()}' AND '\${timeRange?.[1].toISOString()}'
|
|
33
|
-
`})})]})}function
|
|
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"}})});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Control } from "react-hook-form";
|
|
3
|
+
import { ICartesianChartConf } from "../../type";
|
|
4
|
+
interface IBarFields {
|
|
5
|
+
control: Control<ICartesianChartConf, any>;
|
|
6
|
+
index: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function BarFields({ control, index, }: IBarFields): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Control } from 'react-hook-form';
|
|
3
|
+
import { ICartesianChartConf } from '../../type';
|
|
4
|
+
interface ILineFields {
|
|
5
|
+
control: Control<ICartesianChartConf, any>;
|
|
6
|
+
index: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function LineFields({ control, index }: ILineFields): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Control, UseFormGetValues, UseFormWatch } from "react-hook-form";
|
|
3
|
-
import { ICartesianChartConf } from "
|
|
3
|
+
import { ICartesianChartConf } from "../../type";
|
|
4
4
|
interface ISeriesField {
|
|
5
5
|
control: Control<ICartesianChartConf, any>;
|
|
6
6
|
watch: UseFormWatch<ICartesianChartConf>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Control, UseFieldArrayRemove } from "react-hook-form";
|
|
3
|
+
import { ICartesianChartConf, ICartesianChartSeriesItem } from "../../type";
|
|
4
|
+
interface ISeriesItemField {
|
|
5
|
+
control: Control<ICartesianChartConf, any>;
|
|
6
|
+
index: number;
|
|
7
|
+
remove: UseFieldArrayRemove;
|
|
8
|
+
seriesItem: ICartesianChartSeriesItem;
|
|
9
|
+
yAxisOptions: {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
13
|
+
data: any[];
|
|
14
|
+
}
|
|
15
|
+
export declare function SeriesItemField({ control, index, remove, seriesItem, yAxisOptions, data }: ISeriesItemField): JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IVizPanelProps } from "../../../types";
|
|
1
2
|
import { TNumbroFormat } from "../../settings/common/numbro-format-selector";
|
|
2
3
|
export interface ICartesianChartSeriesItem {
|
|
3
4
|
type: 'line' | 'bar';
|
|
@@ -9,6 +10,8 @@ export interface ICartesianChartSeriesItem {
|
|
|
9
10
|
stack: string;
|
|
10
11
|
color?: string;
|
|
11
12
|
barWidth: string;
|
|
13
|
+
smooth: boolean;
|
|
14
|
+
step: false | 'start' | 'middle' | 'end';
|
|
12
15
|
}
|
|
13
16
|
export interface IYAxisConf {
|
|
14
17
|
name: string;
|
|
@@ -20,7 +23,7 @@ export interface ICartesianChartConf {
|
|
|
20
23
|
y_axes: IYAxisConf[];
|
|
21
24
|
series: ICartesianChartSeriesItem[];
|
|
22
25
|
}
|
|
23
|
-
export interface IVizCartesianChartPanel {
|
|
26
|
+
export interface IVizCartesianChartPanel extends Omit<IVizPanelProps, 'conf' | 'setConf'> {
|
|
24
27
|
conf: ICartesianChartConf;
|
|
25
28
|
setConf: (values: ICartesianChartConf) => void;
|
|
26
29
|
}
|
package/package.json
CHANGED