@devtable/dashboard 8.57.2 → 8.58.1

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.
@@ -1914,7 +1914,7 @@ const gu = (e) => {
1914
1914
  getColor: gr(["#fff7f1", "darkorange", "#b60000"]),
1915
1915
  name: "orange",
1916
1916
  category: "sequential"
1917
- }, _s = "@devtable/dashboard", Bi = "8.57.2", Cs = "Apache-2.0", Ss = {
1917
+ }, _s = "@devtable/dashboard", Bi = "8.58.1", Cs = "Apache-2.0", Ss = {
1918
1918
  access: "public",
1919
1919
  registry: "https://registry.npmjs.org/"
1920
1920
  }, ks = [
@@ -19989,7 +19989,9 @@ const pC = D(({
19989
19989
  const t = e.tableData;
19990
19990
  return t.maxPage === 0 ? /* @__PURE__ */ n(C, { mt: 20, color: "red", size: "md", align: "center", sx: {
19991
19991
  fontFamily: "monospace"
19992
- }, children: "This table is empty" }) : (t.error && (C, t.error), t.page === 1 && t.loading ? /* @__PURE__ */ n(mC, { visible: !0 }) : /* @__PURE__ */ u(Xe, { children: [
19992
+ }, children: "This table is empty" }) : t.error ? /* @__PURE__ */ n(C, { mt: 20, color: "red", size: "md", align: "center", sx: {
19993
+ fontFamily: "monospace"
19994
+ }, children: t.error }) : t.page === 1 && t.loading ? /* @__PURE__ */ n(mC, { visible: !0 }) : /* @__PURE__ */ u(Xe, { children: [
19993
19995
  /* @__PURE__ */ n(bC, { dataSource: e }),
19994
19996
  /* @__PURE__ */ u(P, { py: 10, sx: {
19995
19997
  width: "100%",
@@ -20000,7 +20002,7 @@ const pC = D(({
20000
20002
  /* @__PURE__ */ n(Gt, { visible: t.loading, overlayBlur: 2 }),
20001
20003
  /* @__PURE__ */ n(Fl, { data: t.data })
20002
20004
  ] })
20003
- ] }));
20005
+ ] });
20004
20006
  }), yC = {
20005
20007
  root: {
20006
20008
  flexGrow: 1,
@@ -24,7 +24,7 @@ Check the render method of \``+_+"`."}return""}}function K0(_){{if(_!==void 0){v
24
24
 
25
25
  Check your code at `+I+":"+E+"."}return""}}var Fs={};function J0(_){{var I=qs();if(!I){var E=typeof _=="string"?_:_.displayName||_.name;E&&(I=`
26
26
 
27
- Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=J0(I);if(Fs[E])return;Fs[E]=!0;var Y="";_&&_._owner&&_._owner!==ni.current&&(Y=" It was passed a child from "+se(_._owner.type)+"."),gt(_),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,Y),gt(null)}}function Rs(_,I){{if(typeof _!="object")return;if(ei(_))for(var E=0;E<_.length;E++){var Y=_[E];ii(Y)&&Ws(Y,I)}else if(ii(_))_._store&&(_._store.validated=!0);else if(_){var ie=S(_);if(typeof ie=="function"&&ie!==_.entries)for(var le=ie.call(_),ee;!(ee=le.next()).done;)ii(ee.value)&&Ws(ee.value,I)}}}function H0(_){{var I=_.type;if(I==null||typeof I=="string")return;var E;if(typeof I=="function")E=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===d||I.$$typeof===g))E=I.propTypes;else return;if(E){var Y=se(I);N0(E,_.props,"prop",Y,_)}else if(I.PropTypes!==void 0&&!ri){ri=!0;var ie=se(I);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ew(_){{for(var I=Object.keys(_.props),E=0;E<I.length;E++){var Y=I[E];if(Y!=="children"&&Y!=="key"){gt(_),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),gt(null);break}}_.ref!==null&&(gt(_),z("Invalid attribute `ref` supplied to `React.Fragment`."),gt(null))}}function Ys(_,I,E,Y,ie,le){{var ee=j(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Te=K0(ie);Te?J+=Te:J+=qs();var fe;_===null?fe="null":ei(_)?fe="array":_!==void 0&&_.$$typeof===t?(fe="<"+(se(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof _,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,J)}var be=Z0(_,I,E,ie,le);if(be==null)return be;if(ee){var $e=I.children;if($e!==void 0)if(Y)if(ei($e)){for(var mt=0;mt<$e.length;mt++)Rs($e[mt],_);Object.freeze&&Object.freeze($e)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Rs($e,_)}return _===i?ew(be):H0(be),be}}function tw(_,I,E){return Ys(_,I,E,!0)}function nw(_,I,E){return Ys(_,I,E,!1)}var rw=nw,iw=tw;xt.Fragment=i,xt.jsx=rw,xt.jsxs=iw}()),xt}(function(e){process.env.NODE_ENV==="production"?e.exports=ro():e.exports=io()})(no);const O=vt.Fragment,n=vt.jsx,p=vt.jsxs;function Si(e,t){m.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),m.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,y.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),m.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=y.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),m.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return y.cloneDeepWith(g,b=>{if(u&&typeof b=="string")return encodeURIComponent(b)})}const f=y.template(s||"")(d({...l,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class ao{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new ao(e)}class hn{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new hn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fn=m.createContext(null);function Bt(e){const t=m.useContext(fn),r=Z.useCreation(()=>e.configure(t||new hn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(fn.Provider,{value:r,children:e.children})}function Ti(){return m.useContext(fn)}const so={viewPanelInFullScreen:y.noop,inFullScreen:!1},gn=m.createContext(so),Di=m.createContext(null),mn=Di.Provider;function B(){const e=m.useContext(Di);if(!e)throw new Error("Please use ModelContextProvider");return e}class Ae extends m.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return p(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const bn={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},Nt=({value:e,styles:t={}})=>{const r=bi.useEditor({extensions:[vi,mi,X.Link,ui,li,si,pi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),gi,fi,hi,di.configure({types:["heading","paragraph"]}),oi.configure({placeholder:"This is placeholder"}),ci,ai.Color],content:e,editable:!1});m.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=m.useMemo(()=>y.defaultsDeep({},{content:bn},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},oo=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(Nt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),lo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(oo,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),ki=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?W(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&W(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(Qs.DateRangePicker,{label:e,value:s,onChange:o,icon:n(D.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),uo={layoutFrozen:!1,freezeLayout:y.noop,inEditMode:!1},Xe=m.createContext(uo),Ii=m.createContext({panel:null,data:[],loading:!1}),vn=Ii.Provider;function xe(){const e=m.useContext(Ii);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const co={fullScreenPanelID:"",setFullScreenPanelID:y.noop},yn=m.createContext(co);function Mi(){const e=m.useContext(yn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const Ai=m.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),po=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(a.MultiSelect,{label:e,data:t.options,disabled:c,value:r,onChange:i,styles:{root:{minWidth:d,maxWidth:c?d:"unset"},input:{borderColor:"#e9ecef"}},itemComponent:Ai})}),ho=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return m.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:Ai})});function fo({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function go(e){return Us.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const mo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),bo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(mo,{rotate:e?"0":"-90",onClick:i,...s})),vo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),yo=({onClick:e,...t})=>n(vo,{onClick:e,...t}),xo=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),Co=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=xo({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,b]=m.useState((l==null?void 0:l.length)>0),w=S=>{b(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(yi,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:bo,treeIcon:yo,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:yi.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function wo(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const _o=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=m.useMemo(()=>{if(!u)return[];const b=[...u],w=wo(b);return go(w)},[u,l]);m.useEffect(()=>{const{default_selection_count:b}=t;if(!b)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,b).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${b} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(Co,{disabled:h,style:{minWidth:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:b=>i(b,!1),treeData:c,label:e})}),So=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(ho,{...i,...s,config:t});case"multi-select":return n(po,{...i,...s,config:t});case"tree-select":return n(_o,{...i,...s,config:t});case"text-input":return n(fo,{...i,...s,config:t});case"date-range":return n(ki,{...i,...s,config:t});case"checkbox":return n(lo,{...i,...s,config:t});default:return null}}),zi=T.observer(m.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(Ae,{children:n(So,{filter:e,formFieldProps:t})})}))),$i=T.observer(function({view:t}){const r=B(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});m.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),m.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=m.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=m.useMemo(()=>l.filter(h=>y.get(h,"config.required",!1)),[l]),f=m.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,b)=>(w,C)=>{b(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:b})=>n(zi,{filter:h,value:b.value,onChange:g(h,b.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),lw="";function To(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Ei=T.observer(()=>{const{freezeLayout:e}=m.useContext(Xe),[t,r]=m.useState(!1),{panel:i}=xe();return m.useEffect(()=>{e(t)},[t]),To(i.description)?null:p(O,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(Nt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(D.InfoCircle,{size:20})})})]})}),Do=T.observer(({view:e})=>{const t=B(),r=Pe.useModals(),{panel:i}=xe(),{id:s,query:o}=i,{inEditMode:u}=m.useContext(Xe),l=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:d,inFullScreen:c}=m.useContext(gn),f=()=>{t.duplicatePanelByID(s,e.id)},g=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",s])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>t.removePanelByID(s,e.id),confirmProps:{color:"red"},zIndex:320}),b=m.useCallback(()=>{d(s)},[s,d]),w=!c&&e.type!==K.Modal;return n(O,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:l,icon:n(D.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID((o==null?void 0:o.id)??""),icon:n(D.Download,{size:14}),children:"Download Data"}),w&&n(a.Menu.Item,{onClick:b,icon:n(D.ArrowsMaximize,{size:14}),disabled:u,children:"Full Screen"}),u&&p(O,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:g,icon:n(D.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:f,icon:n(D.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:h,icon:n(D.Trash,{size:14}),children:"Delete"})]})]})]})})})}),uw="",ko=T.observer(function(){const{panel:t}=xe(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Oe=(e,t)=>{const[r,i]=m.useState([]);return m.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class st{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=y.get(s,t),l=y.get(o,t);u!==l&&r(u,l)},i)}}class xn{constructor(t,r,i){P(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new st(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new st(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new st(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(y.values(t).map(r=>this.constructInstance(new st(this.attachmentStorage,r.id))))}}class Li{constructor(t){P(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))ae.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ae.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:y.get(i,"fireImmediately",!1)})}}class Io{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new xi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new xi;return this.channels.set(t,i),i}}class Mo{constructor(t){P(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Io,instanceData:new Li(t.viz.conf)};return this.instances.set(t.id,i),i}}function Pi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Li({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const Ao=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Pi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...y.omit(e,["panel","vizManager","data"])})},zo=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Pi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...y.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Oi=(e,t)=>{const r=Fe.bezier(e),i=Fe.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Gt=e=>{const t=Fe.bezier(e);return function(r){return t(r/100).hex()}},$o={type:"interpolation",displayName:"Red / Green",getColor:Oi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Eo={type:"interpolation",displayName:"Yellow / Blue",getColor:Oi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Lo={type:"interpolation",displayName:"Red",getColor:Gt(["#fff7f1","darkred"]),name:"red",category:"sequential"},Po={type:"interpolation",displayName:"Green",getColor:Gt(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Oo={type:"interpolation",displayName:"Blue",getColor:Gt(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Vo={type:"interpolation",displayName:"Orange",getColor:Gt(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Vi="@devtable/dashboard",Cn="8.57.2",Bi="Apache-2.0",Ni={access:"public",registry:"https://registry.npmjs.org/"},Gi=["dist"],qi="./dist/dashboard.umd.js",Fi="./dist/dashboard.es.js",Wi="./dist/index.d.ts",Ri={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Yi={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},ji={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.7.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Qi={"@emotion/babel-plugin":"11.7.2","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.3","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Ui={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.0","d3-regression":"1.2.8",dayjs:"1.11.6",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},Bo=Object.freeze(Object.defineProperty({__proto__:null,default:{name:Vi,version:Cn,license:Bi,publishConfig:Ni,files:Gi,main:qi,module:Fi,types:Wi,exports:Ri,scripts:Yi,dependencies:ji,devDependencies:Qi,peerDependencies:Ui},dependencies:ji,devDependencies:Qi,exports:Ri,files:Gi,license:Bi,main:qi,module:Fi,name:Vi,peerDependencies:Ui,publishConfig:Ni,scripts:Yi,types:Wi,version:Cn},Symbol.toStringTag,{value:"Module"}));class No{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Go{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class qo{constructor(){P(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,i){var u;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const s=this.migrations.filter(l=>l.version>t.from&&l.version<=t.to),o=y.orderBy(s,"version","asc");if(((u=y.last(o))==null?void 0:u.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((l,d)=>d.handler(l,i),r)}}class ge extends qo{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(i,s)=>({version:t,...r(i,s)}))}async migrate({configData:t,panelModel:r}){const i=await t.getItem(null),s=y.get(i,"version",0),o=this.run({from:s,to:this.VERSION},i,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return y.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:i}]=Z.useBoolean(!0),[s,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=m.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},wn={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};oe.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Ie.CanvasRenderer]);function Fo({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:c,zAxis3D:f}=y.defaults({},t,wn),g=m.useMemo(()=>{const w=y.minBy(r,C=>C[l]);return y.get(w,l)},[r,l]),h=m.useMemo(()=>{const w=y.maxBy(r,C=>C[l]);return y.get(w,l)},[r,l]),b={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Me,{echarts:oe,option:b,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function Wo({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=m.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:c,value:r,onChange:i,required:t,sx:u,...l})}const U=m.forwardRef(Wo);function Ro({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),i=e.data,s=y.defaults({},t,wn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(a.Button,{color:"blue",type:"submit",children:[n(D.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class Yo extends ge{constructor(){super(...arguments);P(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const jo={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new Yo,name:"bar-3d",viewRender:Fo,configRender:Ro,createConfig(){return{version:1,config:y.cloneDeep(wn)}}},De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Qo({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return p(a.Stack,{ref:r,children:[p(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:p(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(Ae,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(D.ArrowRight,{size:9})," ",ue(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(D.ArrowRight,{size:9})," ",ue(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(D.ArrowRight,{size:9})," ",ue(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(Qo),Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
27
+ Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=J0(I);if(Fs[E])return;Fs[E]=!0;var Y="";_&&_._owner&&_._owner!==ni.current&&(Y=" It was passed a child from "+se(_._owner.type)+"."),gt(_),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,Y),gt(null)}}function Rs(_,I){{if(typeof _!="object")return;if(ei(_))for(var E=0;E<_.length;E++){var Y=_[E];ii(Y)&&Ws(Y,I)}else if(ii(_))_._store&&(_._store.validated=!0);else if(_){var ie=S(_);if(typeof ie=="function"&&ie!==_.entries)for(var le=ie.call(_),ee;!(ee=le.next()).done;)ii(ee.value)&&Ws(ee.value,I)}}}function H0(_){{var I=_.type;if(I==null||typeof I=="string")return;var E;if(typeof I=="function")E=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===d||I.$$typeof===g))E=I.propTypes;else return;if(E){var Y=se(I);N0(E,_.props,"prop",Y,_)}else if(I.PropTypes!==void 0&&!ri){ri=!0;var ie=se(I);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ew(_){{for(var I=Object.keys(_.props),E=0;E<I.length;E++){var Y=I[E];if(Y!=="children"&&Y!=="key"){gt(_),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),gt(null);break}}_.ref!==null&&(gt(_),z("Invalid attribute `ref` supplied to `React.Fragment`."),gt(null))}}function Ys(_,I,E,Y,ie,le){{var ee=j(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Te=K0(ie);Te?J+=Te:J+=qs();var fe;_===null?fe="null":ei(_)?fe="array":_!==void 0&&_.$$typeof===t?(fe="<"+(se(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof _,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,J)}var be=Z0(_,I,E,ie,le);if(be==null)return be;if(ee){var $e=I.children;if($e!==void 0)if(Y)if(ei($e)){for(var mt=0;mt<$e.length;mt++)Rs($e[mt],_);Object.freeze&&Object.freeze($e)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Rs($e,_)}return _===i?ew(be):H0(be),be}}function tw(_,I,E){return Ys(_,I,E,!0)}function nw(_,I,E){return Ys(_,I,E,!1)}var rw=nw,iw=tw;xt.Fragment=i,xt.jsx=rw,xt.jsxs=iw}()),xt}(function(e){process.env.NODE_ENV==="production"?e.exports=ro():e.exports=io()})(no);const O=vt.Fragment,n=vt.jsx,p=vt.jsxs;function Si(e,t){m.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),m.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,y.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),m.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=y.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),m.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return y.cloneDeepWith(g,b=>{if(u&&typeof b=="string")return encodeURIComponent(b)})}const f=y.template(s||"")(d({...l,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class ao{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new ao(e)}class hn{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new hn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fn=m.createContext(null);function Bt(e){const t=m.useContext(fn),r=Z.useCreation(()=>e.configure(t||new hn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(fn.Provider,{value:r,children:e.children})}function Ti(){return m.useContext(fn)}const so={viewPanelInFullScreen:y.noop,inFullScreen:!1},gn=m.createContext(so),Di=m.createContext(null),mn=Di.Provider;function B(){const e=m.useContext(Di);if(!e)throw new Error("Please use ModelContextProvider");return e}class Ae extends m.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return p(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const bn={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},Nt=({value:e,styles:t={}})=>{const r=bi.useEditor({extensions:[vi,mi,X.Link,ui,li,si,pi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),gi,fi,hi,di.configure({types:["heading","paragraph"]}),oi.configure({placeholder:"This is placeholder"}),ci,ai.Color],content:e,editable:!1});m.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=m.useMemo(()=>y.defaultsDeep({},{content:bn},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},oo=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(Nt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),lo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(oo,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),ki=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?W(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&W(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(Qs.DateRangePicker,{label:e,value:s,onChange:o,icon:n(D.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),uo={layoutFrozen:!1,freezeLayout:y.noop,inEditMode:!1},Xe=m.createContext(uo),Ii=m.createContext({panel:null,data:[],loading:!1}),vn=Ii.Provider;function xe(){const e=m.useContext(Ii);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const co={fullScreenPanelID:"",setFullScreenPanelID:y.noop},yn=m.createContext(co);function Mi(){const e=m.useContext(yn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const Ai=m.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),po=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(a.MultiSelect,{label:e,data:t.options,disabled:c,value:r,onChange:i,styles:{root:{minWidth:d,maxWidth:c?d:"unset"},input:{borderColor:"#e9ecef"}},itemComponent:Ai})}),ho=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return m.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:Ai})});function fo({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function go(e){return Us.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const mo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),bo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(mo,{rotate:e?"0":"-90",onClick:i,...s})),vo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),yo=({onClick:e,...t})=>n(vo,{onClick:e,...t}),xo=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),Co=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=xo({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,b]=m.useState((l==null?void 0:l.length)>0),w=S=>{b(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(yi,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:bo,treeIcon:yo,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:yi.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function wo(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const _o=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=m.useMemo(()=>{if(!u)return[];const b=[...u],w=wo(b);return go(w)},[u,l]);m.useEffect(()=>{const{default_selection_count:b}=t;if(!b)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,b).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${b} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(Co,{disabled:h,style:{minWidth:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:b=>i(b,!1),treeData:c,label:e})}),So=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(ho,{...i,...s,config:t});case"multi-select":return n(po,{...i,...s,config:t});case"tree-select":return n(_o,{...i,...s,config:t});case"text-input":return n(fo,{...i,...s,config:t});case"date-range":return n(ki,{...i,...s,config:t});case"checkbox":return n(lo,{...i,...s,config:t});default:return null}}),zi=T.observer(m.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(Ae,{children:n(So,{filter:e,formFieldProps:t})})}))),$i=T.observer(function({view:t}){const r=B(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});m.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),m.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=m.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=m.useMemo(()=>l.filter(h=>y.get(h,"config.required",!1)),[l]),f=m.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,b)=>(w,C)=>{b(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:b})=>n(zi,{filter:h,value:b.value,onChange:g(h,b.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),lw="";function To(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Ei=T.observer(()=>{const{freezeLayout:e}=m.useContext(Xe),[t,r]=m.useState(!1),{panel:i}=xe();return m.useEffect(()=>{e(t)},[t]),To(i.description)?null:p(O,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(Nt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(D.InfoCircle,{size:20})})})]})}),Do=T.observer(({view:e})=>{const t=B(),r=Pe.useModals(),{panel:i}=xe(),{id:s,query:o}=i,{inEditMode:u}=m.useContext(Xe),l=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:d,inFullScreen:c}=m.useContext(gn),f=()=>{t.duplicatePanelByID(s,e.id)},g=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",s])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>t.removePanelByID(s,e.id),confirmProps:{color:"red"},zIndex:320}),b=m.useCallback(()=>{d(s)},[s,d]),w=!c&&e.type!==K.Modal;return n(O,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:l,icon:n(D.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID((o==null?void 0:o.id)??""),icon:n(D.Download,{size:14}),children:"Download Data"}),w&&n(a.Menu.Item,{onClick:b,icon:n(D.ArrowsMaximize,{size:14}),disabled:u,children:"Full Screen"}),u&&p(O,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:g,icon:n(D.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:f,icon:n(D.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:h,icon:n(D.Trash,{size:14}),children:"Delete"})]})]})]})})})}),uw="",ko=T.observer(function(){const{panel:t}=xe(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Oe=(e,t)=>{const[r,i]=m.useState([]);return m.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class st{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=y.get(s,t),l=y.get(o,t);u!==l&&r(u,l)},i)}}class xn{constructor(t,r,i){P(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new st(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new st(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new st(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(y.values(t).map(r=>this.constructInstance(new st(this.attachmentStorage,r.id))))}}class Li{constructor(t){P(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))ae.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ae.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:y.get(i,"fireImmediately",!1)})}}class Io{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new xi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new xi;return this.channels.set(t,i),i}}class Mo{constructor(t){P(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Io,instanceData:new Li(t.viz.conf)};return this.instances.set(t.id,i),i}}function Pi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Li({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const Ao=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Pi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...y.omit(e,["panel","vizManager","data"])})},zo=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Pi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...y.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Oi=(e,t)=>{const r=Fe.bezier(e),i=Fe.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Gt=e=>{const t=Fe.bezier(e);return function(r){return t(r/100).hex()}},$o={type:"interpolation",displayName:"Red / Green",getColor:Oi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Eo={type:"interpolation",displayName:"Yellow / Blue",getColor:Oi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Lo={type:"interpolation",displayName:"Red",getColor:Gt(["#fff7f1","darkred"]),name:"red",category:"sequential"},Po={type:"interpolation",displayName:"Green",getColor:Gt(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Oo={type:"interpolation",displayName:"Blue",getColor:Gt(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Vo={type:"interpolation",displayName:"Orange",getColor:Gt(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Vi="@devtable/dashboard",Cn="8.58.1",Bi="Apache-2.0",Ni={access:"public",registry:"https://registry.npmjs.org/"},Gi=["dist"],qi="./dist/dashboard.umd.js",Fi="./dist/dashboard.es.js",Wi="./dist/index.d.ts",Ri={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Yi={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},ji={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.7.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Qi={"@emotion/babel-plugin":"11.7.2","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.3","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Ui={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.1","@tiptap/extension-color":"2.0.1","@tiptap/extension-highlight":"2.0.1","@tiptap/extension-link":"2.0.1","@tiptap/extension-placeholder":"2.0.1","@tiptap/extension-subscript":"2.0.1","@tiptap/extension-superscript":"2.0.1","@tiptap/extension-table":"2.0.1","@tiptap/extension-table-cell":"2.0.1","@tiptap/extension-table-header":"2.0.1","@tiptap/extension-table-row":"2.0.1","@tiptap/extension-text-align":"2.0.1","@tiptap/extension-text-style":"2.0.1","@tiptap/extension-underline":"2.0.1","@tiptap/pm":"2.0.1","@tiptap/react":"2.0.1","@tiptap/starter-kit":"2.0.1",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.0","d3-regression":"1.2.8",dayjs:"1.11.6",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},Bo=Object.freeze(Object.defineProperty({__proto__:null,default:{name:Vi,version:Cn,license:Bi,publishConfig:Ni,files:Gi,main:qi,module:Fi,types:Wi,exports:Ri,scripts:Yi,dependencies:ji,devDependencies:Qi,peerDependencies:Ui},dependencies:ji,devDependencies:Qi,exports:Ri,files:Gi,license:Bi,main:qi,module:Fi,name:Vi,peerDependencies:Ui,publishConfig:Ni,scripts:Yi,types:Wi,version:Cn},Symbol.toStringTag,{value:"Module"}));class No{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Go{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class qo{constructor(){P(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,i){var u;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const s=this.migrations.filter(l=>l.version>t.from&&l.version<=t.to),o=y.orderBy(s,"version","asc");if(((u=y.last(o))==null?void 0:u.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((l,d)=>d.handler(l,i),r)}}class ge extends qo{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(i,s)=>({version:t,...r(i,s)}))}async migrate({configData:t,panelModel:r}){const i=await t.getItem(null),s=y.get(i,"version",0),o=this.run({from:s,to:this.VERSION},i,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return y.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:i}]=Z.useBoolean(!0),[s,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=m.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},wn={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};oe.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Ie.CanvasRenderer]);function Fo({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:c,zAxis3D:f}=y.defaults({},t,wn),g=m.useMemo(()=>{const w=y.minBy(r,C=>C[l]);return y.get(w,l)},[r,l]),h=m.useMemo(()=>{const w=y.maxBy(r,C=>C[l]);return y.get(w,l)},[r,l]),b={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Me,{echarts:oe,option:b,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function Wo({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=m.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:c,value:r,onChange:i,required:t,sx:u,...l})}const U=m.forwardRef(Wo);function Ro({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),i=e.data,s=y.defaults({},t,wn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(U,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(a.Button,{color:"blue",type:"submit",children:[n(D.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class Yo extends ge{constructor(){super(...arguments);P(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const jo={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new Yo,name:"bar-3d",viewRender:Fo,configRender:Ro,createConfig(){return{version:1,config:y.cloneDeep(wn)}}},De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Qo({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return p(a.Stack,{ref:r,children:[p(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:p(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(Ae,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(D.ArrowRight,{size:9})," ",ue(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(D.ArrowRight,{size:9})," ",ue(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(D.ArrowRight,{size:9})," ",ue(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(Qo),Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
28
28
  `)},Xi={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:Xo,configRender:Uo,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Uo(e){return n(O,{})}function Xo(e){return n(a.Text,{children:"Click chart's series"})}const Zo=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],qt=m.forwardRef(({sectionTitle:e,value:t,onChange:r},i)=>{const s=o=>u=>{const l=y.cloneDeep(t);y.set(l,o,u),r(l)};return p(a.Stack,{spacing:0,children:[e&&n(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),p(a.Group,{grow:!0,noWrap:!0,children:[n(a.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:s("width")}),n(a.Select,{label:"Overflow",data:Zo,value:t.overflow,onChange:s("overflow")}),n(a.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),nt=m.forwardRef(({value:e,onChange:t},r)=>{const i=o=>{t({...e,on_axis:o})},s=o=>{t({...e,in_tooltip:o})};return p(a.Stack,{ref:r,spacing:0,children:[n(qt,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:i}),n(qt,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:s})]})}),Re={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function Ze({overflow:e,width:t}){const r={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],i=e==="truncate"?"nowrap":"initial",s={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
29
29
  max-width: ${t}px;
30
30
  word-break: ${r};
@@ -371,7 +371,7 @@ Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(
371
371
  parent_value: string;
372
372
  description?: string;
373
373
  }
374
- `,_y=()=>{const[e,t]=m.useState(!1);return p(O,{children:[n(a.Button,{variant:"subtle",compact:!0,onClick:()=>t(r=>!r),children:e?"Close":"Click to see expected data structure"}),n(a.Collapse,{in:e,children:n(at.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:wy})})]})},Sy=T.observer(function({config:t}){return p(O,{children:[n(a.TextInput,{label:"Min-width",value:t.min_width,onChange:r=>t.setMinWidth(r.currentTarget.value),placeholder:"200px"}),n(a.Divider,{label:"Fetch options from database",labelPosition:"center"}),n(a.NumberInput,{value:t.default_selection_count,onChange:t.setDefaultSelectionCount,label:"Select first N options by default"}),n(fr,{value:t.options_query_id,onChange:t.setOptionsQueryID}),n(_y,{})]})}),Ty=T.observer(function({filter:t}){const[r,i]=m.useState(t.plainDefaultValue);return m.useEffect(()=>{i(t.plainDefaultValue)},[t]),p(a.Box,{sx:{maxWidth:"480px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Preview"}),n(zi,{filter:t,value:r,onChange:i}),n(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(at.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),Dy={select:xy,"multi-select":yy,"tree-select":Sy,"text-input":Cy,checkbox:gy,"date-range":by},ky=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Tree Select",value:"tree-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],Iy=T.observer(function({filter:t}){const r=B(),i=m.useMemo(()=>Dy[t.type],[t.type]);return p(a.Group,{grow:!0,spacing:20,align:"top",children:[p(a.Box,{sx:{maxWidth:"600px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Edit"}),p(a.Stack,{children:[p(a.Group,{noWrap:!0,children:[n(a.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&n(a.Checkbox,{label:"Submit automatically",checked:t.auto_submit,onChange:s=>t.setAutoSubmit(s.currentTarget.checked),mt:22})]}),n(a.MultiSelect,{label:"Visible in...",data:r.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),n(a.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:s=>{t.setKey(s.currentTarget.value)}}),n(a.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:s=>{t.setLabel(s.currentTarget.value)}}),n(a.Select,{label:"Widget",data:ky,required:!0,value:t.type,onChange:t.setType}),n(i,{config:t.config})]})]}),n(Ty,{filter:t})]})}),My=T.observer(({id:e})=>{const t=Pe.useModals(),r=B();if(e==="")return null;const i=r.filters.findByID(e);if(!i)return p(a.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const s=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.filters.removeByID(e),zIndex:320})};return p(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[n(a.Group,{position:"right",pt:10,children:n(a.Button,{size:"xs",color:"red",leftIcon:n(D.Trash,{size:16}),onClick:s,children:"Delete this filter"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(Iy,{filter:i})})]})}),Ay=T.observer(()=>{const e=B(),[t,r]=m.useState(()=>JSON.stringify(e.mock_context.current,null,4)),i=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){Lt.showNotification({title:"Failed",message:o.message,color:"red"})}},s=m.useMemo(()=>{try{return JSON.stringify(JSON.parse(t))!==JSON.stringify(e.mock_context.current)}catch{return!1}},[t,e.mock_context.current]);return p(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(a.Text,{weight:500,children:"Mock Context"})}),p(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[p(a.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[n(a.Text,{children:"A valid json string is required"}),n(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:t,onChange:r,sx:{flexGrow:1}})]}),n(a.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!s,onClick:i,children:n(D.DeviceFloppy,{size:20})})]})]})}),zy=T.observer(()=>{const{panel:e}=xe();return n(Nn,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),$y=T.observer(()=>{const{panel:e}=xe(),{style:t}=e;return n(O,{children:n(a.Switch,{label:"Border",checked:t.border.enabled,onChange:r=>t.border.setEnabled(r.currentTarget.checked)})})}),Ey=T.observer(()=>{const{panel:e}=xe(),{title:t,setTitle:r}=e,[i,s]=ve.useInputState(t),o=t!==i,u=m.useCallback(()=>{o&&r(i)},[o,i]);return m.useEffect(()=>{s(t)},[t]),n(a.TextInput,{value:i,onChange:s,label:p(a.Group,{children:[n(a.Text,{children:"Panel Title"}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:u,children:n(D.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function Ly(){return p(a.Stack,{sx:{height:"100%"},children:[n(a.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),n($y,{}),n(a.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),n(Ey,{}),n(zy,{})]})}const Py=({queryID:e})=>{const t=B(),{state:r,error:i}=t.getDataStuffByID(e),s=m.useMemo(()=>t.queries.findByID(e),[t,e]);return r==="loading"?null:i?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:i}):s!=null&&s.stateMessage?n(a.Text,{color:"gray",align:"center",children:s.stateMessage}):null},Oy={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function Cs({data:e}){const t=m.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const i=Ee.createColumnHelper();return Object.keys(e[0]).map(s=>i.accessor(s,{cell:o=>o.getValue()}))},[e]),r=Ee.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Ee.getCoreRowModel()});return e.length===0?n(a.Box,{sx:{height:"5em"}}):n(Ae,{children:p(a.Table,{sx:Oy,children:[n("thead",{children:r.getHeaderGroups().map(i=>n("tr",{children:i.headers.map(s=>p("th",{style:{width:s.getSize()},children:[s.isPlaceholder?null:Ee.flexRender(s.column.columnDef.header,s.getContext()),n(a.ActionIcon,{onMouseDown:s.getResizeHandler(),onTouchStart:s.getResizeHandler(),className:`resizer ${s.column.getIsResizing()?"isResizing":""}`,children:n(D.ArrowBarToRight,{})})]},s.id))},i.id))}),n("tbody",{children:r.getRowModel().rows.map(i=>n("tr",{children:i.getVisibleCells().map(s=>n("td",{children:n(Ae,{children:Ee.flexRender(s.column.columnDef.cell,s.getContext())})},s.id))},i.id))})]})})}const ws=T.observer(function({id:t}){const r=B(),{data:i,state:s}=r.getDataStuffByID(t),o=s==="loading",u=()=>{r.queries.refetchDataByQueryID(t)},l=()=>{r.queries.downloadDataByQueryID(t)},d=m.useMemo(()=>Array.isArray(i)?i.slice(0,10):[],[i]),c=!Array.isArray(i)||i.length===0;return p(a.Stack,{sx:{border:"1px solid #eee"},children:[p(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(a.Group,{position:"left",children:[n(a.Text,{weight:500,children:"Preview Data"}),i.length>10&&p(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",i.length]})]}),p(a.Group,{pr:15,children:[n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:u,children:n(D.Refresh,{size:15})}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o||c,onClick:l,children:n(D.Download,{size:15})})]})]}),p(a.Box,{sx:{position:"relative",overflow:"auto"},children:[n(a.LoadingOverlay,{visible:o}),n(Py,{queryID:t}),n(Cs,{data:d})]})]})}),Vy=T.observer(function(){const t=B(),{panel:{queryID:r,setQueryID:i}}=xe(),s=m.useMemo(()=>t.queries.current.map(u=>({value:u.id,label:u.name})),[t.queries.current]),o=()=>{t.editor.setPath(["_QUERIES_",r])};return p(a.Stack,{children:[p(a.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(a.Text,{children:"Use query"}),n(a.Select,{data:s,value:r,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:r&&n(a.Tooltip,{label:"Open this query",children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:o,children:n(V.IconArrowCurveRight,{size:16})})})})]}),n(ws,{id:r})]})}),By=T.observer(({height:e})=>{const t=B(),{data:r,loading:i,error:s,panel:{viz:o,queryID:u}}=xe(),l=t.queries.findByID(u);return n(La,{viz:o,data:r,loading:i,error:s,query:l,height:e})}),Ny=T.observer(()=>{const{panel:{title:e,style:{border:t}}}=xe();return n(Ae,{children:n(a.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:p(a.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[p(a.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(a.Group,{children:n(Ei,{})}),n(a.Group,{grow:!0,position:"center",children:n(a.Text,{lineClamp:1,weight:"bold",children:e})}),n(a.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),n(a.Group,{px:5,pb:5,sx:{flexGrow:1},children:n(By,{height:"410px"})})]})})})}),gr={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class Gy{constructor(t){P(this,"panel");P(this,"selected");this.panel=t,ae.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(gr.name)).length;this.panel.addVariable(y.cloneDeep({...gr,name:`${gr.name}${t||""}`})),this.selected=y.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const r=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!y.isEmpty(this.panel.variables)){const i=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[i]}}}function qy(){const{panel:e}=xe();return Z.useCreation(()=>new Gy(e),[e])}const Fy=m.forwardRef(function({value:t,onChange:r,data:i,withStyle:s=!0},o){const u=(l,d)=>{const c=y.cloneDeep(t);y.set(c,l,d),r(c)};return p(a.Box,{px:"sm",py:"md",ref:o,children:[p(a.Group,{grow:!0,noWrap:!0,children:[n(a.TextInput,{label:"Name",required:!0,value:t.name,onChange:l=>u("name",l.currentTarget.value)}),n(U,{label:"Data Field",required:!0,data:i,value:t.data_field,onChange:l=>u("data_field",l)})]}),n(Ft,{label:"Aggregation",value:t.aggregation,onChange:l=>u("aggregation",l)}),n(a.Divider,{my:"xs",label:"Format",labelPosition:"center"}),n(Ve,{value:t.formatter,onChange:l=>u("formatter",l)}),s&&n(Ki,{value:t,onChange:r})]})}),_s=a.createStyles(e=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),Wy=e=>{const{uiModel:t}=e;return n(a.Stack,{className:"var-list",children:t.variables.map(r=>n(a.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})},Ry=T.observer(Wy),Yy=({variable:e,data:t})=>n(a.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:n(a.Paper,{withBorder:!0,p:"md",children:Ji(e,t)})}),jy=T.observer(Yy),Qy=e=>{const t=Z.useCreation(()=>Lv(e.variable),[e.variable]),{classes:r}=_s(),{data:i}=xe();return p(a.Group,{style:{height:"100%"},align:"start",children:[p(a.Stack,{"data-testid":"variable-editor",align:"stretch",className:r.config,children:[p(a.Group,{position:"right",children:[n(a.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:n(V.IconDeviceFloppy,{size:18})}),n(a.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:n(V.IconTrash,{size:18})})]}),n(Fy,{value:v.getSnapshot(t.copy),onChange:t.update,data:i})]}),n(jy,{variable:v.getSnapshot(t.copy),data:i})]})},Uy=T.observer(Qy),Xy=()=>{const e=qy(),{classes:t}=_s();return p(a.Group,{className:t.root,noWrap:!0,align:"start",children:[n(a.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:p(a.Stack,{justify:"space-between",children:[n(a.Box,{className:"var-list-actions",children:n(a.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),n(Ry,{uiModel:e})]})}),e.selected?n(O,{children:n(Uy,{uiModel:e,variable:e.selected})}):n("span",{children:"Select or create a new variable on right side"})]})},Zy=T.observer(Xy);function Ky(){const{vizManager:e}=m.useContext(Ne);return m.useMemo(()=>{const t=e.availableVizList.map(r=>({value:r.name,label:r.displayName??r.name,group:r.displayGroup??""}));return y.orderBy(t,[r=>r.group,r=>r.label],["asc","asc"])},[e])}const Jy=T.observer(({value:e,submit:t})=>{const[r,i]=ve.useInputState(e);m.useEffect(()=>{i(e)},[e]);const s=Ky(),o=e!==r;return n(a.Select,{label:"Visualization",value:r,searchable:!0,onChange:i,data:s,rightSection:n(a.ActionIcon,{disabled:!o,onClick:()=>t(r),children:n(D.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Ss=[];function Hy(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function ex(){const{data:e,panel:{variables:t,viz:r,title:i,queryID:s,description:o,setDescription:u,setTitle:l,setQueryID:d,id:c}}=xe(),{vizManager:f}=m.useContext(Ne),g={title:i,description:o,viz:r,queryID:s,id:c},h={setDescription:u,setQueryID:d,setTitle:l},b=za(g);try{return f.resolveComponent(g.viz.type),n(Bt,{configure:b,children:n(mb,{variables:t,setVizConf:r.setConf,panel:g,panelInfoEditor:h,vizManager:f,data:e})})}catch(w){return console.info(y.get(w,"message")),null}}const tx=T.observer(()=>{const{data:e,panel:{viz:t}}=xe(),{vizManager:r}=m.useContext(Ne),i=m.useCallback(c=>{if(c===t.type)return;const f=Hy(r,c);t.setType(c),t.setConf(f||{})},[t.type]),s=c=>{try{t.setConf(JSON.parse(c))}catch(f){console.error(f)}},o=m.useMemo(()=>{var c;return(c=Ss.find(f=>f.value===t.type))==null?void 0:c.Panel},[t.type,Ss]),u=ex(),l=o?m.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,d=u||l;return p(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n(Jy,{submit:i,value:t.type}),n(a.Stack,{pb:50,sx:{flexGrow:1,maxHeight:"calc(100% - 80px)",overflow:"auto"},children:d}),!d&&n(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})}),nx=T.observer(({panel:e,sourceViewID:t})=>{const r=B(),[i,s]=m.useState(t);m.useEffect(()=>{s(t)},[t]);const[o,{open:u,close:l}]=ve.useDisclosure(!1),d=()=>{e.moveToView(t,i),l()};return p(O,{children:[n(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:u,leftIcon:n(V.IconBoxMultiple,{size:14}),children:"Move into Another View"}),n(a.Modal,{opened:o,onClose:l,title:"Move panel into another view",zIndex:320,overflow:"inside",children:p(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n(a.Radio.Group,{value:i,onChange:s,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n(a.Stack,{spacing:"xs",children:r.views.options.map(c=>n(a.Radio,{value:c.value,label:c.label},c.value))})}),p(a.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[n(a.Button,{size:"xs",color:"red",leftIcon:n(V.IconX,{size:14}),onClick:l,children:"Cancel"}),n(a.Button,{size:"xs",color:"blue",leftIcon:n(V.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:"Confirm"})]})]})})]})}),rx={root:{flexGrow:1,width:"100%",height:"100%"},panel:{width:"100%",height:"100%",padding:10}},Ts=({children:e})=>p(a.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"calc(100% - 36px)"},children:[n(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n(Ny,{})]});function ix(e){return!["richText","button"].includes(e)}const ax=T.observer(({panel:e})=>{const t=Pe.useModals(),r=B(),[i,s]=m.useState("Data"),{data:o,state:u,error:l}=r.getDataStuffByID(e.queryID),d=r.queries.findByID(e.queryID),f=ix(e.viz.type)&&u==="loading",g=f||l||!d||!!d.stateMessage,h=r.editor.path[1];m.useEffect(()=>{s(C=>g&&C==="Visualization"?"Data":C)},[e.id,g]);const b=()=>{r.editor.setPath(["_VIEWS_",h])},w=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(e.id,h),b()},confirmProps:{color:"red"},zIndex:320});return p(vn,{value:{panel:e,data:o,loading:f,error:l},children:[p(a.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[p(a.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),p(a.Group,{position:"right",noWrap:!0,children:[n(nx,{panel:e,sourceViewID:h}),n(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftIcon:n(V.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),p(a.Tabs,{value:i,onTabChange:s,keepMounted:!1,styles:rx,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Data",disabled:f,children:"Data"}),n(a.Tabs.Tab,{value:"Panel",children:"Panel"}),n(a.Tabs.Tab,{value:"Variables",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Variables"})})}),n(a.Tabs.Tab,{value:"Visualization",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Visualization"})})}),n(a.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),p(a.Tabs.Panel,{value:"Data",children:[n(a.LoadingOverlay,{visible:f,exitTransitionDuration:0}),n(Vy,{})]}),n(a.Tabs.Panel,{value:"Panel",children:n(Ts,{children:n(Ly,{})})}),n(a.Tabs.Panel,{value:"Variables",children:n(Zy,{})}),n(a.Tabs.Panel,{value:"Visualization",children:n(Ae,{children:n(Ts,{children:n(tx,{})})})}),n(a.Tabs.Panel,{value:"Interactions",children:n(Ae,{children:n(fb,{})})})]})]})}),sx=T.observer(({viewID:e,panelID:t})=>{const r=B();if(!r.views.findByID(e))return p(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=r.panels.findByID(t);return s?n(ax,{panel:s}):p(a.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),Ds=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:i,spacing:s=16,pl:o=0})=>p(a.Stack,{spacing:s,mt:6,pl:o,children:[Array.from(new Array(i-1),(u,l)=>n(a.Skeleton,{width:e,height:r,radius:"xs"},l)),n(a.Skeleton,{width:t,height:r,radius:"xs"})]}),kt=({value:e})=>e===null||e===""?null:n(a.Tooltip,{label:e,disabled:!e,multiline:!0,children:n(a.ActionIcon,{children:n(V.IconInfoCircle,{size:14})})}),ox=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n(a.Tooltip,{label:r,disabled:!r,children:n(a.Badge,{children:t})}):null},lx=T.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?n(Ds,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[n("col",{style:{width:50}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:30}}),n("col",{style:{width:70}}),n("col",{style:{minWidth:300}}),n("col",{style:{minWidth:80,width:80}}),n("col",{style:{minWidth:120,width:120}})]}),n("thead",{children:p("tr",{children:[n("th",{children:"#"}),n("th",{children:"Column Name"}),n("th",{}),n("th",{}),n("th",{children:"Type"}),n("th",{children:"Nullable"}),n("th",{children:"Default Value"})]})}),n("tbody",{children:t.data.map(r=>p("tr",{children:[n("td",{children:r.ordinal_position}),n("td",{children:r.column_name}),n("td",{children:n(kt,{value:r.column_comment})}),n("td",{children:n(ox,{column:r})}),n("td",{children:r.column_type}),n("td",{children:r.is_nullable}),n("td",{children:n(kt,{value:r.column_default})})]},r.column_name))})]})}),ux=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[n("col",{style:{width:100}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:150}}),n("col",{style:{width:250}})]}),n("thead",{children:p("tr",{children:[n("th",{children:"Index Length"}),n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Column Name"})]})}),n("tbody",{children:r.map(i=>p("tr",{children:[n("td",{children:i.index_length}),n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:i.column_name})]},i.index_name))})]})}),dx=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}})]}),n("thead",{children:p("tr",{children:[n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Definition"}),n("th",{children:"Condition"}),n("th",{children:"Comment"})]})}),n("tbody",{children:r.map(i=>p("tr",{children:[n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:n(kt,{value:i.index_definition})}),n("td",{children:n(kt,{value:i.condition})}),n("td",{children:n(kt,{value:i.comment})})]},i.index_name))})]})}),cx=T.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ce.MySQL?n(ux,{dataSource:e}):e.type===ce.Postgresql?n(dx,{dataSource:e}):null}),px=T.observer(({dataSource:e})=>p(a.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n(Ae,{children:n(lx,{dataSource:e})}),n(Ae,{children:n(cx,{dataSource:e})})]}));function hx({table_type:e}){return e==="VIEW"?n(V.IconEye,{size:14}):e==="BASE TABLE"?n(V.IconTable,{size:14}):null}const fx=T.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?n(Ds,{height:"24px",lastWidth:"50%",count:15}):n(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([r,i])=>n(a.NavLink,{label:r,icon:n(V.IconDatabase,{size:14}),defaultOpened:e.table_schema===r,pl:0,childrenOffset:14,children:i.map(s=>n(a.NavLink,{label:s.table_name,icon:n(hx,{table_type:s.table_type}),onClick:()=>{e.setKeywords(r,s.table_name)},active:e.table_name===s.table_name},s.table_name))},r))})}),gx=({visible:e})=>n(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n(a.LoadingOverlay,{visible:e})}),mx=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],bx={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},vx=T.observer(({dataSource:e})=>{const{tableData:t}=e;return p(a.Group,{pt:10,px:10,position:"apart",children:[p(a.Group,{position:"left",children:[t.maxPage>1&&n(a.Pagination,{size:"sm",page:t.page,onChange:t.setPage,total:t.maxPage,withEdges:t.maxPage>7,styles:{item:{height:"30px"}}}),n(a.Select,{icon:n(a.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:bx,data:mx,value:String(t.limit),onChange:r=>t.setLimit(Number(r))})]}),n(a.Group,{position:"right",children:p(a.Text,{color:"dimmed",my:0,size:14,children:["Total ",t.total," rows"]})})]})}),yx=T.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?n(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):(t.error&&(a.Text,t.error),t.page===1&&t.loading?n(gx,{visible:!0}):p(Ae,{children:[n(vx,{dataSource:e}),p(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n(a.LoadingOverlay,{visible:t.loading,overlayBlur:2}),n(Cs,{data:t.data})]})]}))}),xx={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},Cx=T.observer(({dataSource:e})=>(m.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.tables.error}):p(a.Flex,{sx:{height:"100%"},children:[n(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n(Ae,{children:n(fx,{dataSource:e})})}),p(a.Tabs,{defaultValue:"structure",styles:xx,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"structure",icon:n(V.IconColumns,{size:14}),children:"Structure"}),n(a.Tabs.Tab,{value:"data",icon:n(V.IconDatabase,{size:14}),children:"Data"})]}),n(a.Tabs.Panel,{value:"structure",children:n(px,{dataSource:e})}),n(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n(yx,{dataSource:e})})]})]}))),wx={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"0 20px 10px",borderBottom:"1px solid #efefef"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},ks=T.observer(({dataSource:e,triggerButtonProps:t={}})=>{const[r,i]=m.useState(!1);return p(O,{children:[n(a.Modal,{opened:r,onClose:()=>i(!1),title:p(a.Group,{position:"apart",sx:{flexGrow:1},children:[n(a.Text,{fw:500,children:"Explorer Data Source"}),p(a.Group,{spacing:7,children:[n(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",overflow:"inside",styles:wx,children:n(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n(Cx,{dataSource:e})})}),n(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:"See Table Structure"})]})}),_x=m.forwardRef(({label:e,type:t,...r},i)=>p(a.Group,{position:"apart",ref:i,...r,children:[n(a.Text,{children:e}),n(a.Text,{children:t})]})),Sx=T.observer(({value:e,onChange:t})=>{const r=B(),{data:i=[],loading:s}=Z.useRequest(sr,{refreshDeps:[]},[]),o=m.useMemo(()=>i.map(c=>({label:c.key,value:c.key,type:c.type})),[i]),u=m.useMemo(()=>o.reduce((c,f)=>(c[f.value]=f.type,c),{}),[o]),l=c=>{c!==null&&t({key:c,type:u[c]})},d=m.useMemo(()=>r.datasources.find(e),[r,e]);return n(a.Select,{data:o,label:p(a.Group,{position:"apart",children:[n(a.Box,{children:"Data Source"}),d&&n(ks,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:_x,rightSection:d?n(a.Text,{size:"xs",color:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:280,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",".mantine-Text-root":{userSelect:"none"}}},disabled:s,value:e.key,onChange:l})}),Tx=e=>{const{queryModel:t}=e,r=B(),s=r.findQueryUsage(t.id).length>0,o=Pe.useModals(),u=()=>{o.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(t.id),r.editor.setPath(["_QUERIES_",""])},zIndex:320})};return s?n(a.Tooltip,{label:"Can't delete this query for it's being used, check out Usage tab for details",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,children:n(a.Button,{color:"gray",size:"xs",leftIcon:n(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):n(a.Button,{color:"red",size:"xs",onClick:u,leftIcon:n(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},Dx=T.observer(Tx),kx=T.observer(({queryModel:e})=>n(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:p(a.Stack,{spacing:10,sx:{width:"100%"},children:[n(a.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),n(a.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),n(Sx,{value:{type:e.type,key:e.key},onChange:({type:t,key:r})=>{e.setKey(r),e.setType(t)}}),n(a.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),n(a.MultiSelect,{label:"Run query when these are truthy",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),n(a.Divider,{mt:20,mb:10,variant:"dashed"}),n(Dx,{queryModel:e})]})}));function Ix(){const[e,{open:t,close:r}]=ve.useDisclosure(!1);return p(O,{children:[n(a.Modal,{opened:e,onClose:r,title:"About FunctionUtils",zIndex:320,children:n(Nt,{value:sv,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Button,{variant:"light",color:"violet",size:"xs",onClick:t,leftIcon:n(V.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const Mx=({value:e,onChange:t})=>{const r=i=>{i&&t(i)};return n(a.Box,{sx:{position:"relative",flexGrow:1},children:n(_e,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},on=m.forwardRef(({value:e,onChange:t,label:r,defaultValue:i},s)=>{const[o,u]=m.useState(e),l=()=>{t(o)},d=()=>{u(e)},c=()=>{u(i)};m.useEffect(()=>{u(e)},[e]);const f=o!==e;return p(a.Stack,{spacing:4,sx:{height:"100%"},children:[p(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[n(a.Group,{position:"left",children:n(Ix,{})}),p(a.Group,{position:"right",children:[n(a.Button,{onClick:c,size:"xs",variant:"default",leftIcon:n(V.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),n(a.Button,{onClick:d,color:"red",size:"xs",disabled:!f,leftIcon:n(V.IconRecycle,{size:16}),children:"Revert Changes"}),n(a.Button,{size:"xs",onClick:l,disabled:!f,leftIcon:n(V.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),n(a.Text,{size:14,children:r}),n(Mx,{value:o,onChange:u})]})}),Ax=`
374
+ `,_y=()=>{const[e,t]=m.useState(!1);return p(O,{children:[n(a.Button,{variant:"subtle",compact:!0,onClick:()=>t(r=>!r),children:e?"Close":"Click to see expected data structure"}),n(a.Collapse,{in:e,children:n(at.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:wy})})]})},Sy=T.observer(function({config:t}){return p(O,{children:[n(a.TextInput,{label:"Min-width",value:t.min_width,onChange:r=>t.setMinWidth(r.currentTarget.value),placeholder:"200px"}),n(a.Divider,{label:"Fetch options from database",labelPosition:"center"}),n(a.NumberInput,{value:t.default_selection_count,onChange:t.setDefaultSelectionCount,label:"Select first N options by default"}),n(fr,{value:t.options_query_id,onChange:t.setOptionsQueryID}),n(_y,{})]})}),Ty=T.observer(function({filter:t}){const[r,i]=m.useState(t.plainDefaultValue);return m.useEffect(()=>{i(t.plainDefaultValue)},[t]),p(a.Box,{sx:{maxWidth:"480px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Preview"}),n(zi,{filter:t,value:r,onChange:i}),n(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(at.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),Dy={select:xy,"multi-select":yy,"tree-select":Sy,"text-input":Cy,checkbox:gy,"date-range":by},ky=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Tree Select",value:"tree-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],Iy=T.observer(function({filter:t}){const r=B(),i=m.useMemo(()=>Dy[t.type],[t.type]);return p(a.Group,{grow:!0,spacing:20,align:"top",children:[p(a.Box,{sx:{maxWidth:"600px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Edit"}),p(a.Stack,{children:[p(a.Group,{noWrap:!0,children:[n(a.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&n(a.Checkbox,{label:"Submit automatically",checked:t.auto_submit,onChange:s=>t.setAutoSubmit(s.currentTarget.checked),mt:22})]}),n(a.MultiSelect,{label:"Visible in...",data:r.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),n(a.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:s=>{t.setKey(s.currentTarget.value)}}),n(a.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:s=>{t.setLabel(s.currentTarget.value)}}),n(a.Select,{label:"Widget",data:ky,required:!0,value:t.type,onChange:t.setType}),n(i,{config:t.config})]})]}),n(Ty,{filter:t})]})}),My=T.observer(({id:e})=>{const t=Pe.useModals(),r=B();if(e==="")return null;const i=r.filters.findByID(e);if(!i)return p(a.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const s=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.filters.removeByID(e),zIndex:320})};return p(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[n(a.Group,{position:"right",pt:10,children:n(a.Button,{size:"xs",color:"red",leftIcon:n(D.Trash,{size:16}),onClick:s,children:"Delete this filter"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(Iy,{filter:i})})]})}),Ay=T.observer(()=>{const e=B(),[t,r]=m.useState(()=>JSON.stringify(e.mock_context.current,null,4)),i=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){Lt.showNotification({title:"Failed",message:o.message,color:"red"})}},s=m.useMemo(()=>{try{return JSON.stringify(JSON.parse(t))!==JSON.stringify(e.mock_context.current)}catch{return!1}},[t,e.mock_context.current]);return p(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(a.Text,{weight:500,children:"Mock Context"})}),p(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[p(a.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[n(a.Text,{children:"A valid json string is required"}),n(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:t,onChange:r,sx:{flexGrow:1}})]}),n(a.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!s,onClick:i,children:n(D.DeviceFloppy,{size:20})})]})]})}),zy=T.observer(()=>{const{panel:e}=xe();return n(Nn,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),$y=T.observer(()=>{const{panel:e}=xe(),{style:t}=e;return n(O,{children:n(a.Switch,{label:"Border",checked:t.border.enabled,onChange:r=>t.border.setEnabled(r.currentTarget.checked)})})}),Ey=T.observer(()=>{const{panel:e}=xe(),{title:t,setTitle:r}=e,[i,s]=ve.useInputState(t),o=t!==i,u=m.useCallback(()=>{o&&r(i)},[o,i]);return m.useEffect(()=>{s(t)},[t]),n(a.TextInput,{value:i,onChange:s,label:p(a.Group,{children:[n(a.Text,{children:"Panel Title"}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:u,children:n(D.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function Ly(){return p(a.Stack,{sx:{height:"100%"},children:[n(a.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),n($y,{}),n(a.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),n(Ey,{}),n(zy,{})]})}const Py=({queryID:e})=>{const t=B(),{state:r,error:i}=t.getDataStuffByID(e),s=m.useMemo(()=>t.queries.findByID(e),[t,e]);return r==="loading"?null:i?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:i}):s!=null&&s.stateMessage?n(a.Text,{color:"gray",align:"center",children:s.stateMessage}):null},Oy={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function Cs({data:e}){const t=m.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const i=Ee.createColumnHelper();return Object.keys(e[0]).map(s=>i.accessor(s,{cell:o=>o.getValue()}))},[e]),r=Ee.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Ee.getCoreRowModel()});return e.length===0?n(a.Box,{sx:{height:"5em"}}):n(Ae,{children:p(a.Table,{sx:Oy,children:[n("thead",{children:r.getHeaderGroups().map(i=>n("tr",{children:i.headers.map(s=>p("th",{style:{width:s.getSize()},children:[s.isPlaceholder?null:Ee.flexRender(s.column.columnDef.header,s.getContext()),n(a.ActionIcon,{onMouseDown:s.getResizeHandler(),onTouchStart:s.getResizeHandler(),className:`resizer ${s.column.getIsResizing()?"isResizing":""}`,children:n(D.ArrowBarToRight,{})})]},s.id))},i.id))}),n("tbody",{children:r.getRowModel().rows.map(i=>n("tr",{children:i.getVisibleCells().map(s=>n("td",{children:n(Ae,{children:Ee.flexRender(s.column.columnDef.cell,s.getContext())})},s.id))},i.id))})]})})}const ws=T.observer(function({id:t}){const r=B(),{data:i,state:s}=r.getDataStuffByID(t),o=s==="loading",u=()=>{r.queries.refetchDataByQueryID(t)},l=()=>{r.queries.downloadDataByQueryID(t)},d=m.useMemo(()=>Array.isArray(i)?i.slice(0,10):[],[i]),c=!Array.isArray(i)||i.length===0;return p(a.Stack,{sx:{border:"1px solid #eee"},children:[p(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(a.Group,{position:"left",children:[n(a.Text,{weight:500,children:"Preview Data"}),i.length>10&&p(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",i.length]})]}),p(a.Group,{pr:15,children:[n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:u,children:n(D.Refresh,{size:15})}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o||c,onClick:l,children:n(D.Download,{size:15})})]})]}),p(a.Box,{sx:{position:"relative",overflow:"auto"},children:[n(a.LoadingOverlay,{visible:o}),n(Py,{queryID:t}),n(Cs,{data:d})]})]})}),Vy=T.observer(function(){const t=B(),{panel:{queryID:r,setQueryID:i}}=xe(),s=m.useMemo(()=>t.queries.current.map(u=>({value:u.id,label:u.name})),[t.queries.current]),o=()=>{t.editor.setPath(["_QUERIES_",r])};return p(a.Stack,{children:[p(a.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(a.Text,{children:"Use query"}),n(a.Select,{data:s,value:r,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:r&&n(a.Tooltip,{label:"Open this query",children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:o,children:n(V.IconArrowCurveRight,{size:16})})})})]}),n(ws,{id:r})]})}),By=T.observer(({height:e})=>{const t=B(),{data:r,loading:i,error:s,panel:{viz:o,queryID:u}}=xe(),l=t.queries.findByID(u);return n(La,{viz:o,data:r,loading:i,error:s,query:l,height:e})}),Ny=T.observer(()=>{const{panel:{title:e,style:{border:t}}}=xe();return n(Ae,{children:n(a.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:p(a.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[p(a.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(a.Group,{children:n(Ei,{})}),n(a.Group,{grow:!0,position:"center",children:n(a.Text,{lineClamp:1,weight:"bold",children:e})}),n(a.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),n(a.Group,{px:5,pb:5,sx:{flexGrow:1},children:n(By,{height:"410px"})})]})})})}),gr={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class Gy{constructor(t){P(this,"panel");P(this,"selected");this.panel=t,ae.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(gr.name)).length;this.panel.addVariable(y.cloneDeep({...gr,name:`${gr.name}${t||""}`})),this.selected=y.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const r=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!y.isEmpty(this.panel.variables)){const i=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[i]}}}function qy(){const{panel:e}=xe();return Z.useCreation(()=>new Gy(e),[e])}const Fy=m.forwardRef(function({value:t,onChange:r,data:i,withStyle:s=!0},o){const u=(l,d)=>{const c=y.cloneDeep(t);y.set(c,l,d),r(c)};return p(a.Box,{px:"sm",py:"md",ref:o,children:[p(a.Group,{grow:!0,noWrap:!0,children:[n(a.TextInput,{label:"Name",required:!0,value:t.name,onChange:l=>u("name",l.currentTarget.value)}),n(U,{label:"Data Field",required:!0,data:i,value:t.data_field,onChange:l=>u("data_field",l)})]}),n(Ft,{label:"Aggregation",value:t.aggregation,onChange:l=>u("aggregation",l)}),n(a.Divider,{my:"xs",label:"Format",labelPosition:"center"}),n(Ve,{value:t.formatter,onChange:l=>u("formatter",l)}),s&&n(Ki,{value:t,onChange:r})]})}),_s=a.createStyles(e=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),Wy=e=>{const{uiModel:t}=e;return n(a.Stack,{className:"var-list",children:t.variables.map(r=>n(a.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})},Ry=T.observer(Wy),Yy=({variable:e,data:t})=>n(a.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:n(a.Paper,{withBorder:!0,p:"md",children:Ji(e,t)})}),jy=T.observer(Yy),Qy=e=>{const t=Z.useCreation(()=>Lv(e.variable),[e.variable]),{classes:r}=_s(),{data:i}=xe();return p(a.Group,{style:{height:"100%"},align:"start",children:[p(a.Stack,{"data-testid":"variable-editor",align:"stretch",className:r.config,children:[p(a.Group,{position:"right",children:[n(a.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:n(V.IconDeviceFloppy,{size:18})}),n(a.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:n(V.IconTrash,{size:18})})]}),n(Fy,{value:v.getSnapshot(t.copy),onChange:t.update,data:i})]}),n(jy,{variable:v.getSnapshot(t.copy),data:i})]})},Uy=T.observer(Qy),Xy=()=>{const e=qy(),{classes:t}=_s();return p(a.Group,{className:t.root,noWrap:!0,align:"start",children:[n(a.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:p(a.Stack,{justify:"space-between",children:[n(a.Box,{className:"var-list-actions",children:n(a.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),n(Ry,{uiModel:e})]})}),e.selected?n(O,{children:n(Uy,{uiModel:e,variable:e.selected})}):n("span",{children:"Select or create a new variable on right side"})]})},Zy=T.observer(Xy);function Ky(){const{vizManager:e}=m.useContext(Ne);return m.useMemo(()=>{const t=e.availableVizList.map(r=>({value:r.name,label:r.displayName??r.name,group:r.displayGroup??""}));return y.orderBy(t,[r=>r.group,r=>r.label],["asc","asc"])},[e])}const Jy=T.observer(({value:e,submit:t})=>{const[r,i]=ve.useInputState(e);m.useEffect(()=>{i(e)},[e]);const s=Ky(),o=e!==r;return n(a.Select,{label:"Visualization",value:r,searchable:!0,onChange:i,data:s,rightSection:n(a.ActionIcon,{disabled:!o,onClick:()=>t(r),children:n(D.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Ss=[];function Hy(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function ex(){const{data:e,panel:{variables:t,viz:r,title:i,queryID:s,description:o,setDescription:u,setTitle:l,setQueryID:d,id:c}}=xe(),{vizManager:f}=m.useContext(Ne),g={title:i,description:o,viz:r,queryID:s,id:c},h={setDescription:u,setQueryID:d,setTitle:l},b=za(g);try{return f.resolveComponent(g.viz.type),n(Bt,{configure:b,children:n(mb,{variables:t,setVizConf:r.setConf,panel:g,panelInfoEditor:h,vizManager:f,data:e})})}catch(w){return console.info(y.get(w,"message")),null}}const tx=T.observer(()=>{const{data:e,panel:{viz:t}}=xe(),{vizManager:r}=m.useContext(Ne),i=m.useCallback(c=>{if(c===t.type)return;const f=Hy(r,c);t.setType(c),t.setConf(f||{})},[t.type]),s=c=>{try{t.setConf(JSON.parse(c))}catch(f){console.error(f)}},o=m.useMemo(()=>{var c;return(c=Ss.find(f=>f.value===t.type))==null?void 0:c.Panel},[t.type,Ss]),u=ex(),l=o?m.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,d=u||l;return p(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n(Jy,{submit:i,value:t.type}),n(a.Stack,{pb:50,sx:{flexGrow:1,maxHeight:"calc(100% - 80px)",overflow:"auto"},children:d}),!d&&n(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})}),nx=T.observer(({panel:e,sourceViewID:t})=>{const r=B(),[i,s]=m.useState(t);m.useEffect(()=>{s(t)},[t]);const[o,{open:u,close:l}]=ve.useDisclosure(!1),d=()=>{e.moveToView(t,i),l()};return p(O,{children:[n(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:u,leftIcon:n(V.IconBoxMultiple,{size:14}),children:"Move into Another View"}),n(a.Modal,{opened:o,onClose:l,title:"Move panel into another view",zIndex:320,overflow:"inside",children:p(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n(a.Radio.Group,{value:i,onChange:s,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n(a.Stack,{spacing:"xs",children:r.views.options.map(c=>n(a.Radio,{value:c.value,label:c.label},c.value))})}),p(a.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[n(a.Button,{size:"xs",color:"red",leftIcon:n(V.IconX,{size:14}),onClick:l,children:"Cancel"}),n(a.Button,{size:"xs",color:"blue",leftIcon:n(V.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:"Confirm"})]})]})})]})}),rx={root:{flexGrow:1,width:"100%",height:"100%"},panel:{width:"100%",height:"100%",padding:10}},Ts=({children:e})=>p(a.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"calc(100% - 36px)"},children:[n(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n(Ny,{})]});function ix(e){return!["richText","button"].includes(e)}const ax=T.observer(({panel:e})=>{const t=Pe.useModals(),r=B(),[i,s]=m.useState("Data"),{data:o,state:u,error:l}=r.getDataStuffByID(e.queryID),d=r.queries.findByID(e.queryID),f=ix(e.viz.type)&&u==="loading",g=f||l||!d||!!d.stateMessage,h=r.editor.path[1];m.useEffect(()=>{s(C=>g&&C==="Visualization"?"Data":C)},[e.id,g]);const b=()=>{r.editor.setPath(["_VIEWS_",h])},w=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(e.id,h),b()},confirmProps:{color:"red"},zIndex:320});return p(vn,{value:{panel:e,data:o,loading:f,error:l},children:[p(a.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[p(a.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),p(a.Group,{position:"right",noWrap:!0,children:[n(nx,{panel:e,sourceViewID:h}),n(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftIcon:n(V.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),p(a.Tabs,{value:i,onTabChange:s,keepMounted:!1,styles:rx,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Data",disabled:f,children:"Data"}),n(a.Tabs.Tab,{value:"Panel",children:"Panel"}),n(a.Tabs.Tab,{value:"Variables",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Variables"})})}),n(a.Tabs.Tab,{value:"Visualization",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Visualization"})})}),n(a.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),p(a.Tabs.Panel,{value:"Data",children:[n(a.LoadingOverlay,{visible:f,exitTransitionDuration:0}),n(Vy,{})]}),n(a.Tabs.Panel,{value:"Panel",children:n(Ts,{children:n(Ly,{})})}),n(a.Tabs.Panel,{value:"Variables",children:n(Zy,{})}),n(a.Tabs.Panel,{value:"Visualization",children:n(Ae,{children:n(Ts,{children:n(tx,{})})})}),n(a.Tabs.Panel,{value:"Interactions",children:n(Ae,{children:n(fb,{})})})]})]})}),sx=T.observer(({viewID:e,panelID:t})=>{const r=B();if(!r.views.findByID(e))return p(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=r.panels.findByID(t);return s?n(ax,{panel:s}):p(a.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),Ds=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:i,spacing:s=16,pl:o=0})=>p(a.Stack,{spacing:s,mt:6,pl:o,children:[Array.from(new Array(i-1),(u,l)=>n(a.Skeleton,{width:e,height:r,radius:"xs"},l)),n(a.Skeleton,{width:t,height:r,radius:"xs"})]}),kt=({value:e})=>e===null||e===""?null:n(a.Tooltip,{label:e,disabled:!e,multiline:!0,children:n(a.ActionIcon,{children:n(V.IconInfoCircle,{size:14})})}),ox=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n(a.Tooltip,{label:r,disabled:!r,children:n(a.Badge,{children:t})}):null},lx=T.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?n(Ds,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[n("col",{style:{width:50}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:30}}),n("col",{style:{width:70}}),n("col",{style:{minWidth:300}}),n("col",{style:{minWidth:80,width:80}}),n("col",{style:{minWidth:120,width:120}})]}),n("thead",{children:p("tr",{children:[n("th",{children:"#"}),n("th",{children:"Column Name"}),n("th",{}),n("th",{}),n("th",{children:"Type"}),n("th",{children:"Nullable"}),n("th",{children:"Default Value"})]})}),n("tbody",{children:t.data.map(r=>p("tr",{children:[n("td",{children:r.ordinal_position}),n("td",{children:r.column_name}),n("td",{children:n(kt,{value:r.column_comment})}),n("td",{children:n(ox,{column:r})}),n("td",{children:r.column_type}),n("td",{children:r.is_nullable}),n("td",{children:n(kt,{value:r.column_default})})]},r.column_name))})]})}),ux=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[n("col",{style:{width:100}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:150}}),n("col",{style:{width:250}})]}),n("thead",{children:p("tr",{children:[n("th",{children:"Index Length"}),n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Column Name"})]})}),n("tbody",{children:r.map(i=>p("tr",{children:[n("td",{children:i.index_length}),n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:i.column_name})]},i.index_name))})]})}),dx=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}})]}),n("thead",{children:p("tr",{children:[n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Definition"}),n("th",{children:"Condition"}),n("th",{children:"Comment"})]})}),n("tbody",{children:r.map(i=>p("tr",{children:[n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:n(kt,{value:i.index_definition})}),n("td",{children:n(kt,{value:i.condition})}),n("td",{children:n(kt,{value:i.comment})})]},i.index_name))})]})}),cx=T.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ce.MySQL?n(ux,{dataSource:e}):e.type===ce.Postgresql?n(dx,{dataSource:e}):null}),px=T.observer(({dataSource:e})=>p(a.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n(Ae,{children:n(lx,{dataSource:e})}),n(Ae,{children:n(cx,{dataSource:e})})]}));function hx({table_type:e}){return e==="VIEW"?n(V.IconEye,{size:14}):e==="BASE TABLE"?n(V.IconTable,{size:14}):null}const fx=T.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?n(Ds,{height:"24px",lastWidth:"50%",count:15}):n(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([r,i])=>n(a.NavLink,{label:r,icon:n(V.IconDatabase,{size:14}),defaultOpened:e.table_schema===r,pl:0,childrenOffset:14,children:i.map(s=>n(a.NavLink,{label:s.table_name,icon:n(hx,{table_type:s.table_type}),onClick:()=>{e.setKeywords(r,s.table_name)},active:e.table_name===s.table_name},s.table_name))},r))})}),gx=({visible:e})=>n(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n(a.LoadingOverlay,{visible:e})}),mx=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],bx={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},vx=T.observer(({dataSource:e})=>{const{tableData:t}=e;return p(a.Group,{pt:10,px:10,position:"apart",children:[p(a.Group,{position:"left",children:[t.maxPage>1&&n(a.Pagination,{size:"sm",page:t.page,onChange:t.setPage,total:t.maxPage,withEdges:t.maxPage>7,styles:{item:{height:"30px"}}}),n(a.Select,{icon:n(a.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:bx,data:mx,value:String(t.limit),onChange:r=>t.setLimit(Number(r))})]}),n(a.Group,{position:"right",children:p(a.Text,{color:"dimmed",my:0,size:14,children:["Total ",t.total," rows"]})})]})}),yx=T.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?n(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):t.error?n(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.error}):t.page===1&&t.loading?n(gx,{visible:!0}):p(Ae,{children:[n(vx,{dataSource:e}),p(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n(a.LoadingOverlay,{visible:t.loading,overlayBlur:2}),n(Cs,{data:t.data})]})]})}),xx={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},Cx=T.observer(({dataSource:e})=>(m.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.tables.error}):p(a.Flex,{sx:{height:"100%"},children:[n(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n(Ae,{children:n(fx,{dataSource:e})})}),p(a.Tabs,{defaultValue:"structure",styles:xx,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"structure",icon:n(V.IconColumns,{size:14}),children:"Structure"}),n(a.Tabs.Tab,{value:"data",icon:n(V.IconDatabase,{size:14}),children:"Data"})]}),n(a.Tabs.Panel,{value:"structure",children:n(px,{dataSource:e})}),n(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n(yx,{dataSource:e})})]})]}))),wx={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"0 20px 10px",borderBottom:"1px solid #efefef"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},ks=T.observer(({dataSource:e,triggerButtonProps:t={}})=>{const[r,i]=m.useState(!1);return p(O,{children:[n(a.Modal,{opened:r,onClose:()=>i(!1),title:p(a.Group,{position:"apart",sx:{flexGrow:1},children:[n(a.Text,{fw:500,children:"Explorer Data Source"}),p(a.Group,{spacing:7,children:[n(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",overflow:"inside",styles:wx,children:n(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n(Cx,{dataSource:e})})}),n(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:"See Table Structure"})]})}),_x=m.forwardRef(({label:e,type:t,...r},i)=>p(a.Group,{position:"apart",ref:i,...r,children:[n(a.Text,{children:e}),n(a.Text,{children:t})]})),Sx=T.observer(({value:e,onChange:t})=>{const r=B(),{data:i=[],loading:s}=Z.useRequest(sr,{refreshDeps:[]},[]),o=m.useMemo(()=>i.map(c=>({label:c.key,value:c.key,type:c.type})),[i]),u=m.useMemo(()=>o.reduce((c,f)=>(c[f.value]=f.type,c),{}),[o]),l=c=>{c!==null&&t({key:c,type:u[c]})},d=m.useMemo(()=>r.datasources.find(e),[r,e]);return n(a.Select,{data:o,label:p(a.Group,{position:"apart",children:[n(a.Box,{children:"Data Source"}),d&&n(ks,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:_x,rightSection:d?n(a.Text,{size:"xs",color:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:280,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",".mantine-Text-root":{userSelect:"none"}}},disabled:s,value:e.key,onChange:l})}),Tx=e=>{const{queryModel:t}=e,r=B(),s=r.findQueryUsage(t.id).length>0,o=Pe.useModals(),u=()=>{o.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(t.id),r.editor.setPath(["_QUERIES_",""])},zIndex:320})};return s?n(a.Tooltip,{label:"Can't delete this query for it's being used, check out Usage tab for details",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,children:n(a.Button,{color:"gray",size:"xs",leftIcon:n(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):n(a.Button,{color:"red",size:"xs",onClick:u,leftIcon:n(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},Dx=T.observer(Tx),kx=T.observer(({queryModel:e})=>n(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:p(a.Stack,{spacing:10,sx:{width:"100%"},children:[n(a.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),n(a.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),n(Sx,{value:{type:e.type,key:e.key},onChange:({type:t,key:r})=>{e.setKey(r),e.setType(t)}}),n(a.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),n(a.MultiSelect,{label:"Run query when these are truthy",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),n(a.Divider,{mt:20,mb:10,variant:"dashed"}),n(Dx,{queryModel:e})]})}));function Ix(){const[e,{open:t,close:r}]=ve.useDisclosure(!1);return p(O,{children:[n(a.Modal,{opened:e,onClose:r,title:"About FunctionUtils",zIndex:320,children:n(Nt,{value:sv,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Button,{variant:"light",color:"violet",size:"xs",onClick:t,leftIcon:n(V.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const Mx=({value:e,onChange:t})=>{const r=i=>{i&&t(i)};return n(a.Box,{sx:{position:"relative",flexGrow:1},children:n(_e,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},on=m.forwardRef(({value:e,onChange:t,label:r,defaultValue:i},s)=>{const[o,u]=m.useState(e),l=()=>{t(o)},d=()=>{u(e)},c=()=>{u(i)};m.useEffect(()=>{u(e)},[e]);const f=o!==e;return p(a.Stack,{spacing:4,sx:{height:"100%"},children:[p(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[n(a.Group,{position:"left",children:n(Ix,{})}),p(a.Group,{position:"right",children:[n(a.Button,{onClick:c,size:"xs",variant:"default",leftIcon:n(V.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),n(a.Button,{onClick:d,color:"red",size:"xs",disabled:!f,leftIcon:n(V.IconRecycle,{size:16}),children:"Revert Changes"}),n(a.Button,{size:"xs",onClick:l,disabled:!f,leftIcon:n(V.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),n(a.Text,{size:14,children:r}),n(Mx,{value:o,onChange:u})]})}),Ax=`
375
375
  -- You may reference global variables in SQL or VizConfig.
376
376
  SELECT *
377
377
  FROM commit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "8.57.2",
3
+ "version": "8.58.1",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",