@devtable/dashboard 10.3.0 → 10.3.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.
@@ -1,4 +1,4 @@
1
- (function(D,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx"),require("mobx-react-lite"),require("crypto-js"),require("dayjs"),require("lodash"),require("numbro"),require("d3-array"),require("mathjs"),require("@faker-js/faker"),require("axios"),require("mobx-state-tree"),require("performant-array-to-tree"),require("jszip"),require("file-saver"),require("@tabler/icons"),require("@mantine/hooks"),require("@tanstack/react-table"),require("react-virtual"),require("eventemitter2"),require("chroma-js"),require("echarts-gl"),require("echarts/core"),require("echarts/components"),require("echarts/renderers"),require("echarts-for-react/lib/core"),require("react-hook-form"),require("tabler-icons-react"),require("echarts/charts"),require("@mantine/notifications"),require("popmotion"),require("@monaco-editor/react"),require("d3-regression"),require("@mantine/prism"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("prosemirror-keymap"),require("prosemirror-commands"),require("prosemirror-schema-list"),require("@mantine/dates"),require("rc-select"),require("rc-tree-select"),require("react-grid-layout"),require("react-router-dom"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx","mobx-react-lite","crypto-js","dayjs","lodash","numbro","d3-array","mathjs","@faker-js/faker","axios","mobx-state-tree","performant-array-to-tree","jszip","file-saver","@tabler/icons","@mantine/hooks","@tanstack/react-table","react-virtual","eventemitter2","chroma-js","echarts-gl","echarts/core","echarts/components","echarts/renderers","echarts-for-react/lib/core","react-hook-form","tabler-icons-react","echarts/charts","@mantine/notifications","popmotion","@monaco-editor/react","d3-regression","@mantine/prism","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","prosemirror-keymap","prosemirror-commands","prosemirror-schema-list","@mantine/dates","rc-select","rc-tree-select","react-grid-layout","react-router-dom","reactflow"],y):(D=typeof globalThis<"u"?globalThis:D||self,y(D.dashboard={},D.react,D["@mantine/core"],D["@mantine/modals"],D.ahooks,D.mobx,D["mobx-react-lite"],D.CryptoJS,D.dayjs,D._,D.numbro,D["d3-array"],D.mathjs,D["@faker-js/faker"],D.axios,D["mobx-state-tree"],D["performant-array-to-tree"],D.jszip,D["file-saver"],D["@tabler/icons"],D["@mantine/hooks"],D["@tanstack/react-table"],D["react-virtual"],D.eventemitter2,D["chroma-js"],D["echarts-gl"],D["echarts/core"],D["echarts/components"],D["echarts/renderers"],D["echarts-for-react/lib/core"],D["react-hook-form"],D["tabler-icons-react"],D["echarts/charts"],D["@mantine/notifications"],D.popmotion,D["@monaco-editor/react"],D["d3-regression"],D["@mantine/prism"],D["@mantine/tiptap"],D["@tiptap/extension-color"],D["@tiptap/extension-highlight"],D["@tiptap/extension-placeholder"],D["@tiptap/extension-subscript"],D["@tiptap/extension-superscript"],D["@tiptap/extension-text-align"],D["@tiptap/extension-text-style"],D["@tiptap/extension-table"],D["@tiptap/extension-table-cell"],D["@tiptap/extension-table-header"],D["@tiptap/extension-table-row"],D["@tiptap/extension-underline"],D["@tiptap/react"],D["@tiptap/starter-kit"],D["prosemirror-keymap"],D["prosemirror-commands"],D["prosemirror-schema-list"],D["@mantine/dates"],D["rc-select"],D["rc-tree-select"],D["react-grid-layout"],D["react-router-dom"],D.reactflow))})(this,function(D,y,s,Ke,J,ae,k,wa,Y,v,te,Yt,Rl,jl,pt,b,Yl,Ql,lr,O,Ie,Ue,Kl,Ca,at,zT,Ul,G,Ve,Ne,x,I,he,fn,At,ze,Xl,St,Z,Sa,_a,ka,Ta,Da,Ia,Ma,Ea,Aa,za,$a,La,Oa,Pa,$T,De,cr,Jl,Ba,Va,gn,Zl,Me){"use strict";var ET=Object.defineProperty;var AT=(D,y,s)=>y in D?ET(D,y,{enumerable:!0,configurable:!0,writable:!0,value:s}):D[y]=s;var N=(D,y,s)=>(AT(D,typeof y!="symbol"?y+"":y,s),s);function mn(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Hl=mn(Yt),yn=mn(Rl),ce=mn(Ul),ht=mn(Xl);var ne=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Qt={},ec={get exports(){return Qt},set exports(t){Qt=t}},Kt={};/**
1
+ (function(D,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx"),require("mobx-react-lite"),require("crypto-js"),require("dayjs"),require("lodash"),require("numbro"),require("d3-array"),require("mathjs"),require("@faker-js/faker"),require("axios"),require("mobx-state-tree"),require("performant-array-to-tree"),require("jszip"),require("file-saver"),require("@tabler/icons"),require("@mantine/hooks"),require("@tanstack/react-table"),require("react-virtual"),require("eventemitter2"),require("chroma-js"),require("echarts-gl"),require("echarts/core"),require("echarts/components"),require("echarts/renderers"),require("echarts-for-react/lib/core"),require("react-hook-form"),require("tabler-icons-react"),require("echarts/charts"),require("@mantine/notifications"),require("popmotion"),require("@monaco-editor/react"),require("d3-regression"),require("@mantine/prism"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("prosemirror-keymap"),require("prosemirror-commands"),require("prosemirror-schema-list"),require("@mantine/dates"),require("rc-select"),require("rc-tree-select"),require("react-grid-layout"),require("react-router-dom"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx","mobx-react-lite","crypto-js","dayjs","lodash","numbro","d3-array","mathjs","@faker-js/faker","axios","mobx-state-tree","performant-array-to-tree","jszip","file-saver","@tabler/icons","@mantine/hooks","@tanstack/react-table","react-virtual","eventemitter2","chroma-js","echarts-gl","echarts/core","echarts/components","echarts/renderers","echarts-for-react/lib/core","react-hook-form","tabler-icons-react","echarts/charts","@mantine/notifications","popmotion","@monaco-editor/react","d3-regression","@mantine/prism","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","prosemirror-keymap","prosemirror-commands","prosemirror-schema-list","@mantine/dates","rc-select","rc-tree-select","react-grid-layout","react-router-dom","reactflow"],y):(D=typeof globalThis<"u"?globalThis:D||self,y(D.dashboard={},D.react,D["@mantine/core"],D["@mantine/modals"],D.ahooks,D.mobx,D["mobx-react-lite"],D.CryptoJS,D.dayjs,D._,D.numbro,D["d3-array"],D.mathjs,D["@faker-js/faker"],D.axios,D["mobx-state-tree"],D["performant-array-to-tree"],D.jszip,D["file-saver"],D["@tabler/icons"],D["@mantine/hooks"],D["@tanstack/react-table"],D["react-virtual"],D.eventemitter2,D["chroma-js"],D["echarts-gl"],D["echarts/core"],D["echarts/components"],D["echarts/renderers"],D["echarts-for-react/lib/core"],D["react-hook-form"],D["tabler-icons-react"],D["echarts/charts"],D["@mantine/notifications"],D.popmotion,D["@monaco-editor/react"],D["d3-regression"],D["@mantine/prism"],D["@mantine/tiptap"],D["@tiptap/extension-color"],D["@tiptap/extension-highlight"],D["@tiptap/extension-placeholder"],D["@tiptap/extension-subscript"],D["@tiptap/extension-superscript"],D["@tiptap/extension-text-align"],D["@tiptap/extension-text-style"],D["@tiptap/extension-table"],D["@tiptap/extension-table-cell"],D["@tiptap/extension-table-header"],D["@tiptap/extension-table-row"],D["@tiptap/extension-underline"],D["@tiptap/react"],D["@tiptap/starter-kit"],D["prosemirror-keymap"],D["prosemirror-commands"],D["prosemirror-schema-list"],D["@mantine/dates"],D["rc-select"],D["rc-tree-select"],D["react-grid-layout"],D["react-router-dom"],D.reactflow))})(this,function(D,y,s,Ke,J,ae,k,wa,Y,v,te,Yt,Rl,jl,pt,b,Yl,Ql,lr,O,Ie,Ue,Kl,Ca,at,$T,Ul,G,Ve,Ne,x,I,he,fn,At,ze,Xl,St,Z,Sa,_a,ka,Ta,Da,Ia,Ma,Ea,Aa,za,$a,La,Oa,Pa,LT,De,cr,Jl,Ba,Va,gn,Zl,Me){"use strict";var AT=Object.defineProperty;var zT=(D,y,s)=>y in D?AT(D,y,{enumerable:!0,configurable:!0,writable:!0,value:s}):D[y]=s;var N=(D,y,s)=>(zT(D,typeof y!="symbol"?y+"":y,s),s);function mn(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Hl=mn(Yt),yn=mn(Rl),ce=mn(Ul),ht=mn(Xl);var ne=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Qt={},ec={get exports(){return Qt},set exports(t){Qt=t}},Kt={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -18,13 +18,13 @@
18
18
  `+Ft+S}}var Et=!1,wt;{var Gt=typeof WeakMap=="function"?WeakMap:Map;wt=new Gt}function Wt(S,A){if(!S||Et)return"";{var P=wt.get(S);if(P!==void 0)return P}var Q;Et=!0;var le=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var pe;pe=cn.current,cn.current=null,fa();try{if(A){var ie=function(){throw Error()};if(Object.defineProperty(ie.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ie,[])}catch(dt){Q=dt}Reflect.construct(S,[],ie)}else{try{ie.call()}catch(dt){Q=dt}S.call(ie.prototype)}}else{try{throw Error()}catch(dt){Q=dt}S()}}catch(dt){if(dt&&Q&&typeof dt.stack=="string"){for(var ee=dt.stack.split(`
19
19
  `),Be=Q.stack.split(`
20
20
  `),xe=ee.length-1,Se=Be.length-1;xe>=1&&Se>=0&&ee[xe]!==Be[Se];)Se--;for(;xe>=1&&Se>=0;xe--,Se--)if(ee[xe]!==Be[Se]){if(xe!==1||Se!==1)do if(xe--,Se--,Se<0||ee[xe]!==Be[Se]){var Qe=`
21
- `+ee[xe].replace(" at new "," at ");return S.displayName&&Qe.includes("<anonymous>")&&(Qe=Qe.replace("<anonymous>",S.displayName)),typeof S=="function"&&wt.set(S,Qe),Qe}while(xe>=1&&Se>=0);break}}}finally{Et=!1,cn.current=pe,ga(),Error.prepareStackTrace=le}var jt=S?S.displayName||S.name:"",Wl=jt?xt(jt):"";return typeof S=="function"&&wt.set(S,Wl),Wl}function un(S,A,P){return Wt(S,!1)}function dn(S){var A=S.prototype;return!!(A&&A.isReactComponent)}function Ct(S,A,P){if(S==null)return"";if(typeof S=="function")return Wt(S,dn(S));if(typeof S=="string")return xt(S);switch(S){case d:return xt("Suspense");case f:return xt("SuspenseList")}if(typeof S=="object")switch(S.$$typeof){case u:return un(S.render);case p:return Ct(S.type,A,P);case g:{var Q=S,le=Q._payload,pe=Q._init;try{return Ct(pe(le),A,P)}catch{}}}return""}var pn=Object.prototype.hasOwnProperty,Al={},zl=T.ReactDebugCurrentFrame;function or(S){if(S){var A=S._owner,P=Ct(S.type,S._source,A?A.type:null);zl.setExtraStackFrame(P)}else zl.setExtraStackFrame(null)}function uT(S,A,P,Q,le){{var pe=Function.call.bind(pn);for(var ie in S)if(pe(S,ie)){var ee=void 0;try{if(typeof S[ie]!="function"){var Be=Error((Q||"React class")+": "+P+" type `"+ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[ie]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Be.name="Invariant Violation",Be}ee=S[ie](A,ie,Q,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(xe){ee=xe}ee&&!(ee instanceof Error)&&(or(le),M("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Q||"React class",P,ie,typeof ee),or(null)),ee instanceof Error&&!(ee.message in Al)&&(Al[ee.message]=!0,or(le),M("Failed %s type: %s",P,ee.message),or(null))}}}var dT=Array.isArray;function ma(S){return dT(S)}function pT(S){{var A=typeof Symbol=="function"&&Symbol.toStringTag,P=A&&S[Symbol.toStringTag]||S.constructor.name||"Object";return P}}function hT(S){try{return $l(S),!1}catch{return!0}}function $l(S){return""+S}function Ll(S){if(hT(S))return M("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",pT(S)),$l(S)}var hn=T.ReactCurrentOwner,fT={key:!0,ref:!0,__self:!0,__source:!0},Ol,Pl,ya;ya={};function gT(S){if(pn.call(S,"ref")){var A=Object.getOwnPropertyDescriptor(S,"ref").get;if(A&&A.isReactWarning)return!1}return S.ref!==void 0}function mT(S){if(pn.call(S,"key")){var A=Object.getOwnPropertyDescriptor(S,"key").get;if(A&&A.isReactWarning)return!1}return S.key!==void 0}function yT(S,A){if(typeof S.ref=="string"&&hn.current&&A&&hn.current.stateNode!==A){var P=re(hn.current.type);ya[P]||(M('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',re(hn.current.type),S.ref),ya[P]=!0)}}function bT(S,A){{var P=function(){Ol||(Ol=!0,M("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};P.isReactWarning=!0,Object.defineProperty(S,"key",{get:P,configurable:!0})}}function vT(S,A){{var P=function(){Pl||(Pl=!0,M("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};P.isReactWarning=!0,Object.defineProperty(S,"ref",{get:P,configurable:!0})}}var xT=function(S,A,P,Q,le,pe,ie){var ee={$$typeof:e,type:S,key:A,ref:P,props:ie,_owner:pe};return ee._store={},Object.defineProperty(ee._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ee,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Q}),Object.defineProperty(ee,"_source",{configurable:!1,enumerable:!1,writable:!1,value:le}),Object.freeze&&(Object.freeze(ee.props),Object.freeze(ee)),ee};function wT(S,A,P,Q,le){{var pe,ie={},ee=null,Be=null;P!==void 0&&(Ll(P),ee=""+P),mT(A)&&(Ll(A.key),ee=""+A.key),gT(A)&&(Be=A.ref,yT(A,le));for(pe in A)pn.call(A,pe)&&!fT.hasOwnProperty(pe)&&(ie[pe]=A[pe]);if(S&&S.defaultProps){var xe=S.defaultProps;for(pe in xe)ie[pe]===void 0&&(ie[pe]=xe[pe])}if(ee||Be){var Se=typeof S=="function"?S.displayName||S.name||"Unknown":S;ee&&bT(ie,Se),Be&&vT(ie,Se)}return xT(S,ee,Be,le,Q,hn.current,ie)}}var ba=T.ReactCurrentOwner,Bl=T.ReactDebugCurrentFrame;function Rt(S){if(S){var A=S._owner,P=Ct(S.type,S._source,A?A.type:null);Bl.setExtraStackFrame(P)}else Bl.setExtraStackFrame(null)}var va;va=!1;function xa(S){return typeof S=="object"&&S!==null&&S.$$typeof===e}function Vl(){{if(ba.current){var S=re(ba.current.type);if(S)return`
21
+ `+ee[xe].replace(" at new "," at ");return S.displayName&&Qe.includes("<anonymous>")&&(Qe=Qe.replace("<anonymous>",S.displayName)),typeof S=="function"&&wt.set(S,Qe),Qe}while(xe>=1&&Se>=0);break}}}finally{Et=!1,cn.current=pe,ga(),Error.prepareStackTrace=le}var jt=S?S.displayName||S.name:"",Wl=jt?xt(jt):"";return typeof S=="function"&&wt.set(S,Wl),Wl}function un(S,A,P){return Wt(S,!1)}function dn(S){var A=S.prototype;return!!(A&&A.isReactComponent)}function Ct(S,A,P){if(S==null)return"";if(typeof S=="function")return Wt(S,dn(S));if(typeof S=="string")return xt(S);switch(S){case d:return xt("Suspense");case f:return xt("SuspenseList")}if(typeof S=="object")switch(S.$$typeof){case u:return un(S.render);case p:return Ct(S.type,A,P);case g:{var Q=S,le=Q._payload,pe=Q._init;try{return Ct(pe(le),A,P)}catch{}}}return""}var pn=Object.prototype.hasOwnProperty,Al={},zl=T.ReactDebugCurrentFrame;function or(S){if(S){var A=S._owner,P=Ct(S.type,S._source,A?A.type:null);zl.setExtraStackFrame(P)}else zl.setExtraStackFrame(null)}function dT(S,A,P,Q,le){{var pe=Function.call.bind(pn);for(var ie in S)if(pe(S,ie)){var ee=void 0;try{if(typeof S[ie]!="function"){var Be=Error((Q||"React class")+": "+P+" type `"+ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[ie]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Be.name="Invariant Violation",Be}ee=S[ie](A,ie,Q,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(xe){ee=xe}ee&&!(ee instanceof Error)&&(or(le),M("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Q||"React class",P,ie,typeof ee),or(null)),ee instanceof Error&&!(ee.message in Al)&&(Al[ee.message]=!0,or(le),M("Failed %s type: %s",P,ee.message),or(null))}}}var pT=Array.isArray;function ma(S){return pT(S)}function hT(S){{var A=typeof Symbol=="function"&&Symbol.toStringTag,P=A&&S[Symbol.toStringTag]||S.constructor.name||"Object";return P}}function fT(S){try{return $l(S),!1}catch{return!0}}function $l(S){return""+S}function Ll(S){if(fT(S))return M("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",hT(S)),$l(S)}var hn=T.ReactCurrentOwner,gT={key:!0,ref:!0,__self:!0,__source:!0},Ol,Pl,ya;ya={};function mT(S){if(pn.call(S,"ref")){var A=Object.getOwnPropertyDescriptor(S,"ref").get;if(A&&A.isReactWarning)return!1}return S.ref!==void 0}function yT(S){if(pn.call(S,"key")){var A=Object.getOwnPropertyDescriptor(S,"key").get;if(A&&A.isReactWarning)return!1}return S.key!==void 0}function bT(S,A){if(typeof S.ref=="string"&&hn.current&&A&&hn.current.stateNode!==A){var P=re(hn.current.type);ya[P]||(M('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',re(hn.current.type),S.ref),ya[P]=!0)}}function vT(S,A){{var P=function(){Ol||(Ol=!0,M("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};P.isReactWarning=!0,Object.defineProperty(S,"key",{get:P,configurable:!0})}}function xT(S,A){{var P=function(){Pl||(Pl=!0,M("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};P.isReactWarning=!0,Object.defineProperty(S,"ref",{get:P,configurable:!0})}}var wT=function(S,A,P,Q,le,pe,ie){var ee={$$typeof:e,type:S,key:A,ref:P,props:ie,_owner:pe};return ee._store={},Object.defineProperty(ee._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ee,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Q}),Object.defineProperty(ee,"_source",{configurable:!1,enumerable:!1,writable:!1,value:le}),Object.freeze&&(Object.freeze(ee.props),Object.freeze(ee)),ee};function CT(S,A,P,Q,le){{var pe,ie={},ee=null,Be=null;P!==void 0&&(Ll(P),ee=""+P),yT(A)&&(Ll(A.key),ee=""+A.key),mT(A)&&(Be=A.ref,bT(A,le));for(pe in A)pn.call(A,pe)&&!gT.hasOwnProperty(pe)&&(ie[pe]=A[pe]);if(S&&S.defaultProps){var xe=S.defaultProps;for(pe in xe)ie[pe]===void 0&&(ie[pe]=xe[pe])}if(ee||Be){var Se=typeof S=="function"?S.displayName||S.name||"Unknown":S;ee&&vT(ie,Se),Be&&xT(ie,Se)}return wT(S,ee,Be,le,Q,hn.current,ie)}}var ba=T.ReactCurrentOwner,Bl=T.ReactDebugCurrentFrame;function Rt(S){if(S){var A=S._owner,P=Ct(S.type,S._source,A?A.type:null);Bl.setExtraStackFrame(P)}else Bl.setExtraStackFrame(null)}var va;va=!1;function xa(S){return typeof S=="object"&&S!==null&&S.$$typeof===e}function Vl(){{if(ba.current){var S=re(ba.current.type);if(S)return`
22
22
 
23
- Check the render method of \``+S+"`."}return""}}function CT(S){{if(S!==void 0){var A=S.fileName.replace(/^.*[\\\/]/,""),P=S.lineNumber;return`
23
+ Check the render method of \``+S+"`."}return""}}function ST(S){{if(S!==void 0){var A=S.fileName.replace(/^.*[\\\/]/,""),P=S.lineNumber;return`
24
24
 
25
- Check your code at `+A+":"+P+"."}return""}}var Nl={};function ST(S){{var A=Vl();if(!A){var P=typeof S=="string"?S:S.displayName||S.name;P&&(A=`
25
+ Check your code at `+A+":"+P+"."}return""}}var Nl={};function _T(S){{var A=Vl();if(!A){var P=typeof S=="string"?S:S.displayName||S.name;P&&(A=`
26
26
 
27
- Check the top-level render call using <`+P+">.")}return A}}function ql(S,A){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var P=ST(A);if(Nl[P])return;Nl[P]=!0;var Q="";S&&S._owner&&S._owner!==ba.current&&(Q=" It was passed a child from "+re(S._owner.type)+"."),Rt(S),M('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',P,Q),Rt(null)}}function Fl(S,A){{if(typeof S!="object")return;if(ma(S))for(var P=0;P<S.length;P++){var Q=S[P];xa(Q)&&ql(Q,A)}else if(xa(S))S._store&&(S._store.validated=!0);else if(S){var le=_(S);if(typeof le=="function"&&le!==S.entries)for(var pe=le.call(S),ie;!(ie=pe.next()).done;)xa(ie.value)&&ql(ie.value,A)}}}function _T(S){{var A=S.type;if(A==null||typeof A=="string")return;var P;if(typeof A=="function")P=A.propTypes;else if(typeof A=="object"&&(A.$$typeof===u||A.$$typeof===p))P=A.propTypes;else return;if(P){var Q=re(A);uT(P,S.props,"prop",Q,S)}else if(A.PropTypes!==void 0&&!va){va=!0;var le=re(A);M("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",le||"Unknown")}typeof A.getDefaultProps=="function"&&!A.getDefaultProps.isReactClassApproved&&M("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function kT(S){{for(var A=Object.keys(S.props),P=0;P<A.length;P++){var Q=A[P];if(Q!=="children"&&Q!=="key"){Rt(S),M("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Q),Rt(null);break}}S.ref!==null&&(Rt(S),M("Invalid attribute `ref` supplied to `React.Fragment`."),Rt(null))}}function Gl(S,A,P,Q,le,pe){{var ie=U(S);if(!ie){var ee="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(ee+=" 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 Be=CT(le);Be?ee+=Be:ee+=Vl();var xe;S===null?xe="null":ma(S)?xe="array":S!==void 0&&S.$$typeof===e?(xe="<"+(re(S.type)||"Unknown")+" />",ee=" Did you accidentally export a JSX literal instead of a component?"):xe=typeof S,M("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",xe,ee)}var Se=wT(S,A,P,le,pe);if(Se==null)return Se;if(ie){var Qe=A.children;if(Qe!==void 0)if(Q)if(ma(Qe)){for(var jt=0;jt<Qe.length;jt++)Fl(Qe[jt],S);Object.freeze&&Object.freeze(Qe)}else M("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 Fl(Qe,S)}return S===r?kT(Se):_T(Se),Se}}function TT(S,A,P){return Gl(S,A,P,!0)}function DT(S,A,P){return Gl(S,A,P,!1)}var IT=DT,MT=TT;Ut.Fragment=r,Ut.jsx=IT,Ut.jsxs=MT}()),Ut}(function(t){process.env.NODE_ENV==="production"?t.exports=tc():t.exports=nc()})(ec);const q=Qt.Fragment,i=Qt.jsx,h=Qt.jsxs,zt={CryptoJS:wa,d3Array:Hl,dayjs:Y,lodash:v,numbro:te,mathjs:yn,faker:jl.faker},rc=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.0"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.7.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"}],ic=t=>`
27
+ Check the top-level render call using <`+P+">.")}return A}}function ql(S,A){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var P=_T(A);if(Nl[P])return;Nl[P]=!0;var Q="";S&&S._owner&&S._owner!==ba.current&&(Q=" It was passed a child from "+re(S._owner.type)+"."),Rt(S),M('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',P,Q),Rt(null)}}function Fl(S,A){{if(typeof S!="object")return;if(ma(S))for(var P=0;P<S.length;P++){var Q=S[P];xa(Q)&&ql(Q,A)}else if(xa(S))S._store&&(S._store.validated=!0);else if(S){var le=_(S);if(typeof le=="function"&&le!==S.entries)for(var pe=le.call(S),ie;!(ie=pe.next()).done;)xa(ie.value)&&ql(ie.value,A)}}}function kT(S){{var A=S.type;if(A==null||typeof A=="string")return;var P;if(typeof A=="function")P=A.propTypes;else if(typeof A=="object"&&(A.$$typeof===u||A.$$typeof===p))P=A.propTypes;else return;if(P){var Q=re(A);dT(P,S.props,"prop",Q,S)}else if(A.PropTypes!==void 0&&!va){va=!0;var le=re(A);M("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",le||"Unknown")}typeof A.getDefaultProps=="function"&&!A.getDefaultProps.isReactClassApproved&&M("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function TT(S){{for(var A=Object.keys(S.props),P=0;P<A.length;P++){var Q=A[P];if(Q!=="children"&&Q!=="key"){Rt(S),M("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Q),Rt(null);break}}S.ref!==null&&(Rt(S),M("Invalid attribute `ref` supplied to `React.Fragment`."),Rt(null))}}function Gl(S,A,P,Q,le,pe){{var ie=U(S);if(!ie){var ee="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(ee+=" 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 Be=ST(le);Be?ee+=Be:ee+=Vl();var xe;S===null?xe="null":ma(S)?xe="array":S!==void 0&&S.$$typeof===e?(xe="<"+(re(S.type)||"Unknown")+" />",ee=" Did you accidentally export a JSX literal instead of a component?"):xe=typeof S,M("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",xe,ee)}var Se=CT(S,A,P,le,pe);if(Se==null)return Se;if(ie){var Qe=A.children;if(Qe!==void 0)if(Q)if(ma(Qe)){for(var jt=0;jt<Qe.length;jt++)Fl(Qe[jt],S);Object.freeze&&Object.freeze(Qe)}else M("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 Fl(Qe,S)}return S===r?TT(Se):kT(Se),Se}}function DT(S,A,P){return Gl(S,A,P,!0)}function IT(S,A,P){return Gl(S,A,P,!1)}var MT=IT,ET=DT;Ut.Fragment=r,Ut.jsx=MT,Ut.jsxs=ET}()),Ut}(function(t){process.env.NODE_ENV==="production"?t.exports=tc():t.exports=nc()})(ec);const q=Qt.Fragment,i=Qt.jsx,h=Qt.jsxs,zt={CryptoJS:wa,d3Array:Hl,dayjs:Y,lodash:v,numbro:te,mathjs:yn,faker:jl.faker},rc=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.0"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.7.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"}],ic=t=>`
28
28
  <tr>
29
29
  <td><code>${t.name}</code></td>
30
30
  <td>
@@ -116,7 +116,7 @@ Check the top-level render call using <`+P+">.")}return A}}function ql(S,A){{if(
116
116
  SELECT count(*) AS total
117
117
  FROM ${n}.${e}
118
118
  `}})).actions(t=>({setPage(e){t.page=e},resetPage(){t.page=1},setLimit(e){t.limit=e}})).actions(t=>({afterCreate(){b.addDisposer(t,ae.reaction(()=>t.keywordString,t.resetPage,{fireImmediately:!1,delay:0})),b.addDisposer(t,ae.reaction(()=>t.limit,t.resetPage,{fireImmediately:!1,delay:0}))}})),Pc=b.types.model("DataSourceModel",{id:b.types.string,type:b.types.enumeration("DataSourceType",[be.HTTP,be.MySQL,be.Postgresql]),key:b.types.string,config:b.types.frozen(),tables:b.types.optional(Lc,{}),columns:b.types.optional(zc,{}),tableData:b.types.optional(Oc,{}),indexes:b.types.optional($c,{}),table_schema:b.types.optional(b.types.string,""),table_name:b.types.optional(b.types.string,"")}).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(t=>({setKeywords(e,n){t.table_schema=e,t.table_name=n}})).actions(t=>({initKeywords(){if(t.tables.empty)return;const e=Object.keys(t.tables.data)[0],n=t.tables.data[e][0].table_name;t.setKeywords(e,n)}})).actions(t=>{const e=b.flow(function*(){var n;(n=t.controllers.tables)==null||n.abort(),t.controllers.tables=new AbortController,t.tables.state="loading";try{const r=yield*b.toGenerator(qe.query(t.controllers.tables.signal)({type:t.type,key:t.key,query:t.tables.sql},{}));t.tables.data=v.groupBy(r,"table_schema"),t.tables.state="idle",t.tables.error=null,t.initKeywords()}catch(r){if(!pt.isCancel(r)){t.tables.data={};const a=v.get(r,"message","unkown error");t.tables.error=v.get(r,"response.data.detail.message",a),t.tables.state="error"}}});return{loadTables:e,loadTablesIfEmpty(){t.tables.empty&&e()},loadColumns:b.flow(function*(){var n;(n=t.controllers.columns)==null||n.abort(),t.controllers.columns=new AbortController,t.columns.state="loading";try{t.columns.data=yield*b.toGenerator(qe.query(t.controllers.columns.signal)({type:t.type,key:t.key,query:t.columns.sql},{})),t.columns.state="idle",t.columns.error=null}catch(r){if(pt.isCancel(r))t.columns.state="idle",t.columns.error=null;else{t.columns.data=[];const a=v.get(r,"message","unkown error");t.columns.error=v.get(r,"response.data.detail.message",a),t.columns.state="error"}}}),loadIndexes:b.flow(function*(){var n;(n=t.controllers.indexes)==null||n.abort(),t.controllers.indexes=new AbortController,t.indexes.state="loading";try{t.indexes.data=yield*b.toGenerator(qe.query(t.controllers.indexes.signal)({type:t.type,key:t.key,query:t.indexes.sql},{})),t.indexes.state="idle",t.indexes.error=null}catch(r){if(pt.isCancel(r))t.indexes.state="idle",t.indexes.error=null;else{t.indexes.data=[];const a=v.get(r,"message","unkown error");t.indexes.error=v.get(r,"response.data.detail.message",a),t.indexes.state="error"}}}),loadTableData:b.flow(function*(){var r;(r=t.controllers.tableData)==null||r.abort(),t.controllers.tableData=new AbortController;const n=t.tableData;n.state="loading";try{n.data=yield*b.toGenerator(qe.query(t.controllers.tableData.signal)({type:t.type,key:t.key,query:n.sql},{}));const[{total:a}]=yield*b.toGenerator(qe.query(t.controllers.tableData.signal)({type:t.type,key:t.key,query:n.countSql},{}));n.total=Number(a),n.state="idle",n.error=null}catch(a){if(pt.isCancel(a))n.state="idle",n.error=null;else{n.data=[];const o=v.get(a,"message","unkown error");n.error=v.get(a,"response.data.detail.message",o),n.state="error"}}})}}).actions(t=>({afterCreate(){b.addDisposer(t,ae.reaction(()=>t.columns.sql,t.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(t=>({afterCreate(){b.addDisposer(t,ae.reaction(()=>t.indexes.sql,t.loadIndexes,{fireImmediately:!1,delay:500})),b.addDisposer(t,ae.reaction(()=>t.tableData.sql,t.loadTableData,{fireImmediately:!1,delay:0}))}})),Bc=b.types.model("DataSourcesModel",{list:b.types.optional(b.types.array(Pc),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}}));function vn(t){return{label:t,value:t,_type:"ACTION",_action_type:t,Icon:null,children:null}}function Vc(t){switch(t._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",t.value];case"sql_snippet":return["_SQL_SNIPPETS_",t.value];case"query":return["_QUERIES_",t.value];case"view":return["_VIEWS_",t.value];case"panel":return t.parentID?["_VIEWS_",t.parentID,"_PANELS_",t.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const Nc=b.types.model("EditorModel",{path:b.types.optional(b.types.frozen(),[]),settings_open:b.types.optional(b.types.boolean,!1)}).views(t=>({get navOptions(){const{content:e}=b.getRoot(t),{filters:n,views:r,sqlSnippets:a,queries:o}=e;return[{label:"Query Variables",value:"_QUERY_VARS_",_type:"query_variables",Icon:O.IconVariable},{label:"Mock Context",value:"_MOCK_CONTEXT_",Icon:O.IconCodeDots,_type:"mock_context"},{label:"Filters",value:"_FILTERS_",Icon:O.IconFilter,children:[...n.options,vn("_Add_A_Filter_")],_type:"GROUP"},{label:"SQL Snippets",value:"_SQL_SNIPPETS_",Icon:O.IconCopy,children:[...a.options,vn("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"Queries",value:"_QUERIES_",Icon:O.IconDatabase,children:[...o.options,vn("_Add_A_QUERY_")],_type:"GROUP"},{label:"Views",value:"_VIEWS_",Icon:O.IconBoxMultiple,children:[...r.editorOptions,vn("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(e,n){return e.length===0?!1:e[e.length-1]===n.value},isOptionOpened(e){const{path:n}=t;return n.length===0||!e.children||e.children.length===0?!1:n.includes(e.value)}})).actions(t=>({setPath(e){t.path=e},setSettingsOpen(e){t.settings_open=e}})).actions(t=>({open(e){t.setPath(e),t.setSettingsOpen(!0)},close(){t.setSettingsOpen(!1)},navigate(e){const n=Vc(e);n&&t.setPath(n)}})),qc=b.types.model("MockContextModel",{current:b.types.optional(b.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},get(e){return t.current[e]},set(e,n){t.current[e]=n}})),Fc=b.types.model("VariableModel",{name:b.types.string,size:b.types.string,weight:b.types.string,color:b.types.union(b.types.model({type:b.types.literal("static"),staticColor:b.types.string}),b.types.model({type:b.types.literal("continuous"),valueRange:b.types.array(b.types.number),colorRange:b.types.array(b.types.string)}),b.types.model({type:b.types.literal("piecewise")})),formatter:b.types.model({output:b.types.enumeration("Output",["number","percent"]),average:b.types.optional(b.types.boolean,!1),mantissa:b.types.number,trimMantissa:b.types.optional(b.types.boolean,!1)}),data_field:b.types.string,aggregation:b.types.union(b.types.model({type:b.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:b.types.frozen()}),b.types.model({type:b.types.literal("quantile"),config:b.types.model({p:b.types.number})}))}).views(t=>({get json(){const{name:e,size:n,weight:r,color:a,formatter:o,data_field:l,aggregation:c}=t;return v.cloneDeep({name:e,size:n,color:a,weight:r,formatter:o,data_field:l,aggregation:c})}}));class Gc{constructor(e){N(this,"origin");N(this,"copy");this.origin=e,this.copy=b.clone(e),ae.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(b.getSnapshot(this.origin),b.getSnapshot(this.copy))}commit(){b.applySnapshot(this.origin,b.getSnapshot(this.copy))}update(e){b.applySnapshot(this.copy,e)}}const Wc=t=>new Gc(t);class Rc{constructor(){N(this,"migrations",[])}version(e,n){return this.migrations.push({version:e,handler:n}),this}run(e,n,r){var l;if(e.from===e.to)return n;if(e.from>e.to)throw new Error(`Can not downgrade from version '${e.from}' to (${e.to})`);const a=this.migrations.filter(c=>c.version>e.from&&c.version<=e.to),o=v.orderBy(a,"version","asc");if(((l=v.last(o))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return o.reduce((c,u)=>u.handler(c,r),n)}}class ve extends Rc{constructor(){super(),this.configVersions()}version(e,n){return super.version(e,(r,a)=>({version:e,...n(r,a)}))}async migrate({configData:e,panelModel:n}){const r=await e.getItem(null),a=v.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await e.setItem(null,o)}async needMigration({configData:e}){const n=await e.getItem(null);return v.get(n,"version",0)<this.VERSION}}var Xe=(t=>(t.string="string",t.number="number",t.eloc="eloc",t.percentage="percentage",t.custom="custom",t))(Xe||{});const ps=["function text({ value }) {"," // your code goes here"," return value","}"].join(`
119
- `),yr={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"};class $t{constructor(e,n){this.root=e,this.path=n}async deleteItem(e){e===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(n,e))}async getItem(e){const n=await this.root.getItem(this.path);return e===null?n:v.get(n,e)}async setItem(e,n){if(e===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[e]:n})}return await this.getItem(e)}watchItem(e,n,r){return e===null?this.root.watchItem(this.path,(a,o)=>{n(a,o)},r):this.root.watchItem(this.path,(a,o)=>{const l=v.get(a,e),c=v.get(o,e);l!==c&&n(l,c)},r)}}class br{constructor(e,n,r){N(this,"attachmentStorage");this.instance=e,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new $t(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new $t(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new $t(this.attachmentStorage,e))}async remove(e){await this.attachmentStorage.deleteItem(e)}async list(){const e=await this.attachmentStorage.getItem(null);return Promise.all(v.values(e).map(n=>this.constructInstance(new $t(this.attachmentStorage,n.id))))}}class hs{constructor(e){N(this,"rootRef");this.rootRef=ae.observable({current:e})}async deleteItem(e){ae.runInAction(()=>{v.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?ae.toJS(this.rootRef.current):v.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(v.isObject(n))ae.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{v.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return ae.reaction(()=>this.getValueFromRoot(e),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:v.get(r,"fireImmediately",!1)})}}class jc{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new Ca)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ca;return this.channels.set(e,r),r}}class Yc{constructor(e){N(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new jc,instanceData:new hs(e.viz.conf)};return this.instances.set(e.id,r),r}}function fs(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new hs({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Qc=t=>{const{panel:e,vizManager:n,data:r,variables:a}=t,o=n.resolveComponent(e.viz.type),l=n.getOrCreateInstance(e),c={...fs(l,r,n,a),viewport:{width:e.layout.w,height:e.layout.h}},u=o.viewRender;return i(u,{context:c,instance:l,...v.omit(t,["panel","vizManager","data"])})},Kc=t=>{const{vizManager:e,panel:n,panelInfoEditor:r,data:a,variables:o}=t,l=e.resolveComponent(n.viz.type),c=e.getOrCreateInstance(n),u={...fs(c,a,e,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:u,instance:c,...v.omit(t,["panel","vizManager","data","panelInfoEditor"])})},gs=(t,e)=>{const n=at.bezier(t),r=at.bezier(e);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},xn=t=>{const e=at.bezier(t);return function(n){return e(n/100).hex()}},Uc={type:"interpolation",displayName:"Red / Green",getColor:gs(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Xc={type:"interpolation",displayName:"Yellow / Blue",getColor:gs(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Jc={type:"interpolation",displayName:"Red",getColor:xn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Zc={type:"interpolation",displayName:"Green",getColor:xn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Hc={type:"interpolation",displayName:"Blue",getColor:xn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},eu={type:"interpolation",displayName:"Orange",getColor:xn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class tu{constructor(e){N(this,"symbol");this.symbol=Symbol(e)}}function st(t){return new tu(t)}class vr{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const e=new vr;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=v.get(e,"dispose");v.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const ms="10.3.0",nu=Object.freeze(Object.defineProperty({__proto__:null,version:ms},Symbol.toStringTag,{value:"Module"}));class ru{constructor(e){N(this,"staticColors",new Map);N(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class iu{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}const R=(t,e)=>{const[n,{setFalse:r}]=J.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(t.getItem(e).then(c=>{o(c),r()}),t.watchItem(e,c=>{o(c)})));const l=y.useCallback(async c=>{await t.setItem(e,c),o(c)},[t,e]);return{loading:n,value:a,set:l}},xr={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"}};function V(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function ot(t,e){var a;const{queryID:n,columnKey:r}=V(e);return n?r?((a=t[n])==null?void 0:a.map(o=>o[r]))??[]:t[n]:[]}function Xt(t,e){const{queryID:n}=V(e);return n?t[n]:[]}function au(t){return Object.values(t)[0]}function wn(t,e){const{queryID:n,columnKey:r}=V(e);return t[r]}ce.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function su({context:t}){const{value:e}=R(t.instanceData,"config"),n=t.data,{width:r,height:a}=t.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:f}=v.defaults({},e,xr),p=y.useMemo(()=>Xt(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:V(o),y:V(l),z:V(c)}),[o,l,c]),{min:w,max:_}=y.useMemo(()=>{const M=v.minBy(p,B=>B[C.columnKey]),L=v.maxBy(p,B=>B[C.columnKey]);return{min:v.get(M,C.columnKey),max:v.get(L,C.columnKey)}},[p,C]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:p.map(M=>[M[g.columnKey],M[m.columnKey],M[C.columnKey]])}]};return e?i(Ne,{echarts:ce,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const ys=y.createContext({panel:null,data:{},loading:!1,errors:[]}),wr=ys.Provider;function Ae(){const t=y.useContext(ys);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const ou={fullScreenPanelID:"",setFullScreenPanelID:v.noop},Cr=y.createContext(ou);function bs(){const t=y.useContext(Cr);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const j=k.observer(y.forwardRef(({label:t,required:e,value:n,onChange:r,clearable:a=!1,sx:o,...l},c)=>{const{panel:u}=Ae(),d=y.useMemo(()=>{const f=[...u.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[u.dataFieldOptions]);return i(s.Select,{ref:c,label:t,data:d,value:n,onChange:r,required:e,sx:o,...l})}));function lu({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=v.defaults({},e,xr),{control:a,handleSubmit:o,reset:l}=x.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[e]),e?i(s.Stack,{spacing:"xs",children:h("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),h(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"x_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"xAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),h(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"y_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"yAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),h(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"z_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"zAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:h(s.Button,{color:"blue",type:"submit",children:[i(I.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function cu(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class uu extends ve{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:cu(a,r)}})}}const du={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new uu,name:"bar-3d",viewRender:su,configRender:lu,createConfig(){return{version:2,config:v.cloneDeep(xr)}}};class Fe extends y.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return h(s.Box,{children:[i(s.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function pu({value:t,onChange:e},n){const r=c=>{e({...t,output:c})},a=c=>{const u=c===0?!1:t.trimMantissa;e({...t,mantissa:c,trimMantissa:u})},o=c=>{e({...t,trimMantissa:c.currentTarget.checked})},l=c=>{e({...t,average:c.currentTarget.checked})};return h(s.Stack,{ref:n,children:[h(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:t.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:h(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:t.average,onChange:l,disabled:t.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),h(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:o,disabled:t.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),h(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:h(s.Group,{position:"apart",children:[h(s.Text,{size:12,color:"gray",children:["123456789 ",i(I.ArrowRight,{size:9})," ",te(123456789).format(t)]}),h(s.Text,{size:12,color:"gray",children:["1234 ",i(I.ArrowRight,{size:9})," ",te(1234).format(t)]}),h(s.Text,{size:12,color:"gray",children:["0.1234 ",i(I.ArrowRight,{size:9})," ",te(.1234).format(t)]})]})})]})]})}const Je=y.forwardRef(pu),tt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
119
+ `),yr={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"};class $t{constructor(e,n){this.root=e,this.path=n}async deleteItem(e){e===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(n,e))}async getItem(e){const n=await this.root.getItem(this.path);return e===null?n:v.get(n,e)}async setItem(e,n){if(e===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[e]:n})}return await this.getItem(e)}watchItem(e,n,r){return e===null?this.root.watchItem(this.path,(a,o)=>{n(a,o)},r):this.root.watchItem(this.path,(a,o)=>{const l=v.get(a,e),c=v.get(o,e);l!==c&&n(l,c)},r)}}class br{constructor(e,n,r){N(this,"attachmentStorage");this.instance=e,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new $t(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new $t(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new $t(this.attachmentStorage,e))}async remove(e){await this.attachmentStorage.deleteItem(e)}async list(){const e=await this.attachmentStorage.getItem(null);return Promise.all(v.values(e).map(n=>this.constructInstance(new $t(this.attachmentStorage,n.id))))}}class hs{constructor(e){N(this,"rootRef");this.rootRef=ae.observable({current:e})}async deleteItem(e){ae.runInAction(()=>{v.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?ae.toJS(this.rootRef.current):v.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(v.isObject(n))ae.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{v.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return ae.reaction(()=>this.getValueFromRoot(e),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:v.get(r,"fireImmediately",!1)})}}class jc{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new Ca)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ca;return this.channels.set(e,r),r}}class Yc{constructor(e){N(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new jc,instanceData:new hs(e.viz.conf)};return this.instances.set(e.id,r),r}}function fs(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new hs({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Qc=t=>{const{panel:e,vizManager:n,data:r,variables:a}=t,o=n.resolveComponent(e.viz.type),l=n.getOrCreateInstance(e),c={...fs(l,r,n,a),viewport:{width:e.layout.w,height:e.layout.h}},u=o.viewRender;return i(u,{context:c,instance:l,...v.omit(t,["panel","vizManager","data"])})},Kc=t=>{const{vizManager:e,panel:n,panelInfoEditor:r,data:a,variables:o}=t,l=e.resolveComponent(n.viz.type),c=e.getOrCreateInstance(n),u={...fs(c,a,e,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:u,instance:c,...v.omit(t,["panel","vizManager","data","panelInfoEditor"])})},gs=(t,e)=>{const n=at.bezier(t),r=at.bezier(e);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},xn=t=>{const e=at.bezier(t);return function(n){return e(n/100).hex()}},Uc={type:"interpolation",displayName:"Red / Green",getColor:gs(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Xc={type:"interpolation",displayName:"Yellow / Blue",getColor:gs(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Jc={type:"interpolation",displayName:"Red",getColor:xn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Zc={type:"interpolation",displayName:"Green",getColor:xn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Hc={type:"interpolation",displayName:"Blue",getColor:xn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},eu={type:"interpolation",displayName:"Orange",getColor:xn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class tu{constructor(e){N(this,"symbol");this.symbol=Symbol(e)}}function st(t){return new tu(t)}class vr{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const e=new vr;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=v.get(e,"dispose");v.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const ms="10.3.1",nu=Object.freeze(Object.defineProperty({__proto__:null,version:ms},Symbol.toStringTag,{value:"Module"}));class ru{constructor(e){N(this,"staticColors",new Map);N(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class iu{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}const R=(t,e)=>{const[n,{setFalse:r}]=J.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(t.getItem(e).then(c=>{o(c),r()}),t.watchItem(e,c=>{o(c)})));const l=y.useCallback(async c=>{await t.setItem(e,c),o(c)},[t,e]);return{loading:n,value:a,set:l}},xr={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"}};function V(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function ot(t,e){var a;const{queryID:n,columnKey:r}=V(e);return n?r?((a=t[n])==null?void 0:a.map(o=>o[r]))??[]:t[n]:[]}function Xt(t,e){const{queryID:n}=V(e);return n?t[n]:[]}function au(t){return Object.values(t)[0]}function wn(t,e){const{queryID:n,columnKey:r}=V(e);return t[r]}ce.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function su({context:t}){const{value:e}=R(t.instanceData,"config"),n=t.data,{width:r,height:a}=t.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:f}=v.defaults({},e,xr),p=y.useMemo(()=>Xt(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:V(o),y:V(l),z:V(c)}),[o,l,c]),{min:w,max:_}=y.useMemo(()=>{const M=v.minBy(p,B=>B[C.columnKey]),L=v.maxBy(p,B=>B[C.columnKey]);return{min:v.get(M,C.columnKey),max:v.get(L,C.columnKey)}},[p,C]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:p.map(M=>[M[g.columnKey],M[m.columnKey],M[C.columnKey]])}]};return e?i(Ne,{echarts:ce,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const ys=y.createContext({panel:null,data:{},loading:!1,errors:[]}),wr=ys.Provider;function Ae(){const t=y.useContext(ys);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const ou={fullScreenPanelID:"",setFullScreenPanelID:v.noop},Cr=y.createContext(ou);function bs(){const t=y.useContext(Cr);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const j=k.observer(y.forwardRef(({label:t,required:e,value:n,onChange:r,clearable:a=!1,sx:o,...l},c)=>{const{panel:u}=Ae(),d=y.useMemo(()=>{const f=[...u.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[u.dataFieldOptions]);return i(s.Select,{ref:c,label:t,data:d,value:n,onChange:r,required:e,sx:o,...l})}));function lu({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=v.defaults({},e,xr),{control:a,handleSubmit:o,reset:l}=x.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[e]),e?i(s.Stack,{spacing:"xs",children:h("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),h(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"x_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"xAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),h(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"y_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"yAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),h(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(x.Controller,{name:"z_axis_data_key",control:a,render:({field:c})=>i(j,{label:"Data Field",required:!0,...c})}),i(x.Controller,{name:"zAxis3D.name",control:a,render:({field:c})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:h(s.Button,{color:"blue",type:"submit",children:[i(I.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function cu(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class uu extends ve{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:cu(a,r)}})}}const du={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new uu,name:"bar-3d",viewRender:su,configRender:lu,createConfig(){return{version:2,config:v.cloneDeep(xr)}}};class Fe extends y.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return h(s.Box,{children:[i(s.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function pu({value:t,onChange:e},n){const r=c=>{e({...t,output:c})},a=c=>{const u=c===0?!1:t.trimMantissa;e({...t,mantissa:c,trimMantissa:u})},o=c=>{e({...t,trimMantissa:c.currentTarget.checked})},l=c=>{e({...t,average:c.currentTarget.checked})};return h(s.Stack,{ref:n,children:[h(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:t.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:h(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:t.average,onChange:l,disabled:t.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),h(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:o,disabled:t.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),h(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:h(s.Group,{position:"apart",children:[h(s.Text,{size:12,color:"gray",children:["123456789 ",i(I.ArrowRight,{size:9})," ",te(123456789).format(t)]}),h(s.Text,{size:12,color:"gray",children:["1234 ",i(I.ArrowRight,{size:9})," ",te(1234).format(t)]}),h(s.Text,{size:12,color:"gray",children:["0.1234 ",i(I.ArrowRight,{size:9})," ",te(.1234).format(t)]})]})})]})]})}const Je=y.forwardRef(pu),tt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
120
120
  `)},vs={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:fu,configRender:hu,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 hu(t){return i(q,{})}function fu(t){return i(s.Text,{children:"Click chart's series"})}const gu=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],Cn=y.forwardRef(({sectionTitle:t,value:e,onChange:n},r)=>{const a=o=>l=>{const c=v.cloneDeep(e);v.set(c,o,l),n(c)};return h(s.Stack,{spacing:0,children:[t&&i(s.Divider,{mb:-5,mt:5,variant:"dotted",label:t,labelPosition:"right",labelProps:{color:"dimmed"}}),h(s.Group,{grow:!0,noWrap:!0,children:[i(s.NumberInput,{label:"Max Width",hideControls:!0,value:e.width,onChange:a("width")}),i(s.Select,{label:"Overflow",data:gu,value:e.overflow,onChange:a("overflow")}),i(s.TextInput,{label:"Ellipsis",value:e.ellipsis,disabled:!0})]})]})}),gt=y.forwardRef(({value:t,onChange:e},n)=>{const r=o=>{e({...t,on_axis:o})},a=o=>{e({...t,in_tooltip:o})};return h(s.Stack,{ref:n,spacing:0,children:[i(Cn,{sectionTitle:"Overflow on Axis",value:t.on_axis,onChange:r}),i(Cn,{sectionTitle:"Overflow in Tooltip",value:t.in_tooltip,onChange:a})]})}),Ze={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function mt({overflow:t,width:e}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[t],r=t==="truncate"?"nowrap":"initial",a={truncate:"ellipsis",break:"clip",breakAll:"clip"}[t];return`
121
121
  max-width: ${e}px;
122
122
  word-break: ${n};
@@ -477,14 +477,14 @@ Check the top-level render call using <`+P+">.")}return A}}function ql(S,A){{if(
477
477
  </tbody>
478
478
  </table>
479
479
  `}},show_in_legend:!0}))}function l0(t,e,n,r){const a=V(e.data_key),o=e.name,l=n.map(c=>{const u=v.sumBy(r[c],a.columnKey);return[c,u]});return{type:"line",name:o,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:l,show_in_legend:!1}}function c0(t,e,n,r){const l={barMinWidth:5,barMaxWidth:20};return[r0(t,n,r),a0(t,n,r,l),...o0(t,n,r,l),l0(t,e,n,r)]}function u0(t,e){const{axisLabel:n}=t.x_axis;return[{data:e,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:e,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:e,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:e,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...n,formatter:Ns(n.formatter)},axisLine:{show:!1}}]}function d0(t){return[{type:"category",name:"准确估算比例",nameRotate:0,nameGap:5,nameLocation:"end",nameTextStyle:{align:"left"},gridIndex:0,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"平均偏差",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:1,boundaryGap:[1,1],axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"数量占比",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:2,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1},min:0,max:1},{type:"value",gridIndex:3,position:"right",splitNumber:3,axisLabel:{show:!0,verticalAlign:"top",showMinLabel:!1,lineHeight:14},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:t.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function hi(t){return t==1||t==2?1:hi(t-2)+hi(t-1)}const p0=Array.from(new Array(20),(t,e)=>hi(e+1));function Bo(t){return t<=1?t:p0.findIndex(e=>t<=e)-1}function h0(t,e){const{x_axis:n,deviation:r}=t,a=V(n.data_key),o=V(r.data_keys.estimated_value),l=V(r.data_keys.actual_value);return e[a.queryID].map(c=>{const u=Bo(c[o.columnKey]),d=Bo(c[l.columnKey]),f=u-d;return{...c,level:{estimated:u,actual:d,diff:f}}})}function f0(t){return t==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function g0(t){return{show:!0,orient:"vertical",top:"middle",right:0,data:t.filter(n=>n.show_in_legend).reverse().map(n=>({name:`${n.name}`,color:n.color,itemStyle:f0(n.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const m0={tooltip:{trigger:"axis"}};function y0(t,e){const{deviation:n,metrics:r}=t,a=r.find(l=>l.data_key===e);if(a)return a;const o=n.data_keys.actual_value;return{id:o,name:n.name,data_key:o}}function b0(t,e,n){const r=h0(t,n),a=V(t.x_axis.data_key),o=v.uniqBy(n[a.queryID],a.columnKey).map(f=>f[a.columnKey]),l=v.groupBy(r,a.columnKey),c=y0(t,e),u=c0(t,c,o,l),d={xAxis:u0(t,o),yAxis:d0(c),series:u,grid:n0(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:g0(u)};return v.defaultsDeep({},d,m0)}const v0={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},x0=({conf:t,metricKey:e,setMetricKey:n})=>{const{deviation:r,metrics:a}=t,o=y.useMemo(()=>{const l=a.map(c=>({label:c.name,value:c.data_key}));return l.push({label:r.name?r.name:r.data_keys.actual_value,value:r.data_keys.actual_value}),l},[r,a]);return h(s.Group,{spacing:1,children:[i(s.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),i(s.NativeSelect,{size:"xs",data:o,value:e,onChange:l=>n(l.currentTarget.value),styles:v0})]})},w0={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function C0(){return h(s.HoverCard,{width:400,shadow:"md",children:[i(s.HoverCard.Target,{children:i(s.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:i(O.IconInfoCircle,{size:14}),children:"指标说明"})}),i(s.HoverCard.Dropdown,{children:i(s.Table,{fontSize:14,sx:w0,children:h("tbody",{children:[h("tr",{children:[i("th",{children:"估算偏差"}),i("td",{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),h("tr",{children:[i("th",{children:"准确估算比例"}),i("td",{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function S0(t){return h(s.Group,{position:"apart",children:[i(C0,{}),i(x0,{...t})]})}ce.use([he.BarChart,he.LineChart,he.HeatmapChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer,G.VisualMapComponent]);function _0({conf:t,data:e,width:n,height:r,metricKey:a}){const o=y.useMemo(()=>b0(t,a,e),[t,e,a]);return i(Ne,{echarts:ce,option:o,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})}function k0({context:t}){const{value:e}=R(t.instanceData,"config"),n=y.useMemo(()=>v.defaults({},e,pi),[e]),r=t.data,{width:a,height:o}=t.viewport,{x_axis:l,deviation:c}=n,{estimated_value:u,actual_value:d}=c.data_keys,[f,p]=y.useState(d);if(y.useEffect(()=>{p(C=>C||d)},[d]),!l.data_key||!u||!d||!a||!o)return null;const g=Math.max(a,300),m=Math.max(o,370);return h(s.Box,{sx:{overflow:"hidden",height:m,width:g},children:[i(S0,{conf:n,metricKey:f,setMetricKey:p}),i(_0,{width:g,height:m-30,data:r,conf:n,metricKey:f})]})}function T0({control:t,watch:e}){return e(["deviation"]),h(s.Stack,{children:[i(s.Group,{grow:!0,noWrap:!0,children:i(x.Controller,{name:"deviation.name",control:t,render:({field:n})=>i(s.TextInput,{label:"指标名称",sx:{flex:1},...n})})}),h(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"deviation.data_keys.estimated_value",control:t,render:({field:n})=>i(j,{label:"估算值字段",required:!0,sx:{flex:1},...n})}),i(x.Controller,{name:"deviation.data_keys.actual_value",control:t,render:({field:n})=>i(j,{label:"实际值字段",required:!0,sx:{flex:1},...n})})]})]})}const D0=({control:t,index:e,remove:n})=>h(s.Stack,{children:[h(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:`metrics.${e}.name`,control:t,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(x.Controller,{name:`metrics.${e}.data_key`,control:t,render:({field:r})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(I.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(e),sx:{top:15,right:5},children:"Delete this Metric"})]}),I0=({control:t,watch:e})=>{const{fields:n,append:r,remove:a}=x.useFieldArray({control:t,name:"metrics"}),o=e("metrics"),l=n.map((p,g)=>({...p,...o[g]})),c=()=>r({id:Date.now().toString(),data_key:"",name:""}),u=e("metrics.0.id"),[d,f]=y.useState(()=>u??null);return y.useEffect(()=>{u&&f(p=>p!==null?p:u)},[u]),h(q,{children:[h(s.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[i(I.InfoCircle,{size:14,color:"#888"}),i(s.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),i(s.Divider,{variant:"dashed",my:10}),h(s.Tabs,{value:d,onTabChange:p=>f(p),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[h(s.Tabs.List,{children:[l.map((p,g)=>i(s.Tabs.Tab,{value:p.id,children:p.name?p.name:g},p.id)),i(s.Tabs.Tab,{onClick:c,value:"add",children:i(I.Plus,{size:18,color:"#228be6"})})]}),l.map((p,g)=>i(s.Tabs.Panel,{value:p.id,children:i(D0,{control:t,index:g,remove:a},p.id)},p.id))]})]})};function M0({control:t,watch:e}){return e(["x_axis"]),h(s.Stack,{children:[h(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"x_axis.data_key",control:t,render:({field:n})=>i(j,{label:"数据字段",required:!0,sx:{flex:1},...n})}),i(x.Controller,{name:"x_axis.name",control:t,render:({field:n})=>i(s.TextInput,{label:"X轴名称",sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),h(s.Group,{grow:!0,noWrap:!0,children:[i(x.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:n})=>i(s.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(x.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:n})=>i(Gs,{...n})})]})]})}function E0({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=y.useMemo(()=>v.defaultsDeep({},e,pi),[e]),{control:a,handleSubmit:o,watch:l,getValues:c,reset:u}=x.useForm({defaultValues:r});y.useEffect(()=>{u(r)},[r]),l([]);const d=c(),f=y.useMemo(()=>!v.isEqual(d,r),[d,r]);return i(s.Stack,{spacing:"xs",children:h("form",{onSubmit:o(n),children:[h(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Merico Estimation Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:i(I.DeviceFloppy,{size:20})})]}),h(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X 轴"}),i(s.Tabs.Tab,{value:"Deviation",children:"偏差"}),i(s.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(M0,{control:a,watch:l})}),i(s.Tabs.Panel,{value:"Deviation",children:i(T0,{control:a,watch:l})}),i(s.Tabs.Panel,{value:"Additional Metrics",children:i(I0,{control:a,watch:l})})]})]})})}function A0(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis:a,deviation:o,metrics:l,...c}=t;return{...c,x_axis:{...a,data_key:r(a.data_key)},deviation:{...o,data_keys:{estimated_value:r(o.data_keys.estimated_value),actual_value:r(o.data_keys.actual_value)}},metrics:l.map(u=>({...u,data_key:r(u.data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class z0 extends ve{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:A0(a,r)}})}}const $0={displayName:"Merico Estimation Chart",displayGroup:"Merico suite",migrator:new z0,name:"mericoEstimationChart",viewRender:k0,configRender:E0,createConfig:()=>({version:2,config:pi})},L0=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(t=>({name:t.name,value:t.value,type:"single",category:"basic"})),O0=[Uc,Xc,Hc,Zc,Jc,eu],Vo=()=>({id:"dashboard",version:ms,manifest:{viz:[bi,iv,$v,Oy,Tv,og,t0,du,Md,Nh,gf,gx,Kf,mh,Yb,kg,em,Fv,$0,Wd],color:[...L0,...O0]}}),on=new iu,we={pluginManager:st("pluginManager"),vizManager:st("vizManager"),colorManager:st("colorManager"),instanceScope:{panelModel:st("panelModel"),vizInstance:st("vizInstance"),interactionManager:st("interactionManager"),migrator:st("migrator"),operationManager:st("operationManager"),triggerManager:st("triggerManager")}},fi=()=>{try{on.install(Vo())}catch{}const t=new Yc(on),e=new ru(on);return{pluginManager:on,vizManager:t,colorManager:e}},it=y.createContext(fi());try{on.install(Vo())}catch{}function P0(t,e){const{value:n,set:r}=R(t.operation.operationData,"config"),[a,o]=y.useState(v.defaults({},n,e)),l=async()=>{await r(a)};return y.useEffect(()=>{o(v.defaults({},n,e))},[n]),{config:a,setConfig:o,commit:l}}function B0(t){const{config:e,setConfig:n,commit:r}=P0(t,{urlTemplate:"",openInNewTab:!0});async function a(){await r()}async function o(c){n({...e,openInNewTab:c}),await r()}const l=c=>n({...e,urlTemplate:c.currentTarget.value});return h(s.Stack,{children:[i(s.TextInput,{label:"Url",value:e.urlTemplate,onChange:l,onBlur:a}),i(s.Switch,{label:"Open in new Tab",checked:e.openInNewTab,onChange:c=>o(c.currentTarget.checked)})]})}async function V0(t,e){const{urlTemplate:n,openInNewTab:r}=await e.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:n,openInNewTab:r,payload:t}}))}class N0 extends ve{constructor(){super(...arguments);N(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const q0={displayName:"Open Link",id:"builtin:op:open-link",configRender:B0,run:V0,migrator:new N0,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function F0(t){const{value:e,set:n}=R(t.operationData,"config"),r=a=>void n({template:a});return[(e==null?void 0:e.template)||"",r]}function G0(t){const[e,n]=F0(t.operation);return i(s.TextInput,{defaultValue:e,onBlur:r=>n(r.currentTarget.value),label:"console.log"})}async function W0(t,e){const n=await e.operationData.getItem("config"),r=v.template(n.template||"");console.log("run with payload",t),console.log(r(t))}const R0={displayName:"console.log (debug)",id:"builtin:op:debug",configRender:G0,run:W0},j0=k.observer(t=>{const e=K(),{value:n,set:r}=R(t.operation.operationData,"config");console.log({value:n,viewID:n==null?void 0:n.viewID});const a=(n==null?void 0:n.viewID)||"",o=l=>void r({viewID:l});return i(s.Select,{defaultValue:a,value:a,onChange:o,label:"View",data:e.views.options})});async function Y0(t,e){const r=(await e.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:r}}))}const Q0={displayName:"Open View",id:"builtin:op:open_view",configRender:j0,run:Y0},K0={"tbody tr":{opacity:.5,transition:"opacity 200ms ease"},"tr[data-affected=true]":{opacity:1}},U0=({value:t="",onChange:e})=>{const[n,r]=y.useState(t);y.useEffect(()=>{r(t)},[t]);const a=()=>{e(n)};return i(s.TextInput,{size:"xs",label:"",value:n,onChange:o=>r(o.currentTarget.value),sx:{flexGrow:1},rightSection:i(s.ActionIcon,{color:"green",size:"xs",onClick:a,disabled:n===t,children:i(O.IconDeviceFloppy,{})})})},X0={dictionary:{}},J0=k.observer(t=>{const e=K(),{value:n=X0,set:r}=R(t.operation.operationData,"config"),{dictionary:a={}}=n;console.log({value:{...n},dictionary:{...a},filters:[...e.filters.keyLabelOptions]});const o=(l,c)=>{if(c===""){const u={...a};delete u[l],r({dictionary:u});return}r({dictionary:{...a,[l]:c}})};return h(s.Table,{sx:K0,children:[i("thead",{children:h("tr",{children:[i("th",{children:"Set filter"}),i("th",{children:"with"})]})}),i("tbody",{children:[...e.filters.keyLabelOptions].map(l=>{const c=l.value in a;return h("tr",{"data-affected":c,children:[i("td",{children:l.label}),i("td",{children:i(U0,{value:a[l.value],onChange:u=>o(l.value,u)})})]},l.value)})})]})});async function Z0(t,e){const r=(await e.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:r,payload:t}}))}const H0={displayName:"Set Filter Values",id:"builtin:op:set_filter_values",configRender:J0,run:Z0},ew={filter_keys:[]},tw=k.observer(t=>{const e=K(),{value:n=ew,set:r}=R(t.operation.operationData,"config"),{filter_keys:a=[]}=n,o=c=>{r({filter_keys:[...c]})},l=y.useMemo(()=>e.filters.current.map(c=>({label:c.label,value:c.key})),[e.filters.values]);return i(s.Stack,{spacing:10,children:i(s.MultiSelect,{label:"Select Filters to Clear",data:l,value:a,onChange:o})})});async function nw(t,e){const r=(await e.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:r,payload:t}}))}const Un=[R0,q0,Q0,H0,{displayName:"Clear Filter Values",id:"builtin:op:clear_filter_values",configRender:tw,run:nw}];class rw{constructor(e,n=Un){N(this,"attachments");this.operations=n;const r=async a=>{const{id:o,schemaRef:l}=await a.getItem(null);return{id:o,schemaRef:l,operationData:new $t(a,"data")}};this.attachments=new br(e,"__OPERATIONS",r)}async runOperation(e,n){const r=await this.attachments.getInstance(e);if(!r){console.warn(`Operation '${e}' is not defined`);return}const a=this.tryGetSchema(r.schemaRef);if(!a){console.warn(`Operation schema '${r.schemaRef}' is not defined`);return}await a.run(n,r)}tryGetSchema(e){return this.operations.find(n=>n.id===e)}async needMigration(){const n=(await this.attachments.list()).map(async r=>{const a={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),l=o==null?void 0:o.migrator;return l&&await l.needMigration(a)});return(await Promise.all(n)).some(r=>r)}async runMigration(){const n=(await this.attachments.list()).map(async r=>{const a={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),l=o==null?void 0:o.migrator;l&&await l.needMigration(a)&&await l.migrate(a)});await Promise.all(n)}async createOrGetOperation(e,n){var l;if(!this.getOperationSchemaList().some(c=>c.id===n.id))throw new Error(`Operation schema '${n.id}' is not defined`);const a=await this.attachments.getInstance(e);return!a||a.schemaRef!==n.id?await this.attachments.create(e,{id:e,schemaRef:n.id,data:((l=n.createDefaultConfig)==null?void 0:l.call(n))??{}}):a}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(e){return this.attachments.remove(e)}async retrieveTrigger(e){return await this.attachments.getInstance(e)}}class gi{constructor(e,n,r){N(this,"operationManager");N(this,"triggerManager");N(this,"attachments");this.operationManager=new rw(e,r),this.triggerManager=new Lu(e,n);const a=async o=>{const{id:l,triggerRef:c,operationRef:u}=await o.getItem(null);return{id:l,triggerRef:c,operationRef:u}};this.attachments=new br(e,"__INTERACTIONS",a)}async addInteraction(e,n){const r=e.id,a=n.id,o=`[${r}]:[${a}]`;await this.attachments.create(o,{id:o,triggerRef:r,operationRef:a})}getInteractionList(){return this.attachments.list()}async removeInteraction(e){const n=await this.attachments.getInstance(e);if(!n)return;const{triggerRef:r,operationRef:a}=n;await this.getTriggerRefCount(r)<=1&&await this.triggerManager.removeTrigger(r),await this.getOperationRefCount(a)<=1&&await this.operationManager.removeOperation(a),await this.attachments.remove(e)}async getOperationRefCount(e){return(await this.getInteractionList()).filter(r=>r.operationRef===e).length}async getTriggerRefCount(e){return(await this.getInteractionList()).filter(r=>r.triggerRef===e).length}async runInteraction(e,n){const a=(await this.getInteractionList()).filter(o=>o.triggerRef===e);await Promise.all(a.map(async o=>{try{return await this.operationManager.runOperation(o.operationRef,n)}catch(l){console.warn(`Failed to run operation '${o.operationRef}'`,l)}}))}}const et=({vizManager:t,instance:e})=>J.useCreation(()=>new gi(e,t.resolveComponent(e.type),Un),[e,t]),No={left:"flex-start",center:"center",right:"flex-end"},iw=({header:t,cx:e})=>{const n=v.get(t.column.columnDef.meta,"align","left");return h(s.Text,{className:e("table-head-cell",{"table-head-cell--sortable":t.column.getCanSort()}),onClick:t.column.getToggleSortingHandler(),align:n,sx:{justifyContent:No[n]},children:[t.isPlaceholder?null:Ue.flexRender(t.column.columnDef.header,t.getContext()),i(aw,{direction:t.column.getIsSorted()})]})},aw=({direction:t})=>{switch(t){case"asc":return i(O.IconArrowUp,{size:16});case"desc":return i(O.IconArrowDown,{size:"1em"});default:return null}},mi={id:"builtin:table:click-cell-content",displayName:"Click Cell Content",nameRender:cw,configRender:ow,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},sw={column:""};function qo(t,e){const{value:n}=R(t.instanceData,"config"),r={columnsFromConfig:[],columnsFromData:[]};if(n&&(r.columnsFromConfig=n.columns.map((a,o)=>({label:a.label,value:o.toString()}))),!e)return r;if(n!=null&&n.id_field){const a=Xt(e,n.id_field);(a==null?void 0:a.length)>0&&(r.columnsFromData=Object.keys(a[0]).map(o=>({label:o,value:o})))}return r}function ow(t){const{columnsFromConfig:e,columnsFromData:n}=qo(t.instance,t.sampleData),r=e.length>0?e:n,{value:a,set:o}=R(t.trigger.triggerData,"config"),{column:l}=v.defaults({},a,sw),c=u=>{isNaN(+u)?o({column:u}):o({column:+u})};return i(s.Select,{clearable:!1,data:r,label:"Choose a column",value:l.toString(),onChange:c})}function lw(t,e){return t?v.isNumber(t.column)?`Click cell of ${e[t.column].label}`:`Click cell of ${t.column}`:"Click cell content (click to config)"}function cw(t){const{columnsFromConfig:e}=qo(t.instance),{value:n}=R(t.trigger.triggerData,"config");return i(s.Text,{children:lw(n,e)})}const uw=s.createStyles(t=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:t.colorScheme==="dark"?t.colors.dark[5]:t.colors.gray[0]}}},thead:{background:t.colorScheme==="dark"?t.colors.dark[7]:t.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),dw={tableLayout:"fixed","th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}};function Fo(t,e,n){return Math.min(Math.max(t,e),n)}class pw{constructor(e){this.steps=e;const n=[],r=new Set;for(const a of e)r.has(a.to)||(n.push(a),r.add(a.to));if(n.sort((a,o)=>a.from-o.from),n.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=n}getLinearFunction(e,n){const r=(n.to-e.to)/(n.from-e.from),a=e.to-r*e.from;return o=>r*o+a}getStepFunctionForValue(e){let n=v.findLastIndex(this.steps,r=>r.from<=e);return n=Fo(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(e){return Fo(this.getStepFunctionForValue(e)(e),0,100)}}class hw{constructor(e,n,r,a,o){this.getColIndex=e,this.cell=n,this.triggers=r,this.interactionManager=a,this.colorManager=o}getClickHandler(){const e=this.getRelatedTrigger();if(e.length!==0)return()=>{const n={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const r of e)this.interactionManager.runInteraction(r.id,n)}}getRelatedTrigger(){return this.triggers.filter(n=>n.schemaRef===mi.id).filter(n=>{const r=this.getColIndex(this.cell),a=v.get(this.cell.column.columnDef.meta,"value_field"),o=v.get(n.config,"column");return o==r||o==a})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const e=this.columnConf.cellBackgroundColor;if(!e||e==="none")return;if(v.isString(e))return e;const n=+this.cell.getValue();if(isFinite(n)){const r=this.colorManager.decodeInterpolation(e.interpolation),o=new pw(e.steps).mapValue(n);return r==null?void 0:r.getColor(o)}}}const fw=s.createStyles((t,e)=>({content:{display:"flex",alignItems:"center",justifyContent:No[e.align],".table-cell-text":{whiteSpace:"nowrap",cursor:e.clickable?"pointer":"default",textDecoration:e.clickable?"underline":"none"}}}));function gw(t){return t?at(t).oklch()[0]>.7?"black":"white":"inherit"}function mw(t){const e=t.tableCellContext.bgColor;return{backgroundColor:e,color:gw(e)}}function qt(t){const e=t.tableCellContext.isClickable(),n=fw({clickable:e,align:t.align});return i("div",{className:n.classes.content,style:{...mw(t)},children:i(s.Text,{className:"table-cell-text",onClick:t.tableCellContext.getClickHandler(),children:i("span",{title:t.children,children:t.children})})})}function yw(t){return i(qt,{...t,children:t.value})}function bw(t){const e=te(t.value).format({average:!0,mantissa:2,trimMantissa:!0});return i(qt,{...t,children:e})}function vw(t){const e=te(t.value).format({thousandSeparated:!0});return i(qt,{...t,children:e})}function xw(t){const e=te(t.value).format({output:"percent",mantissa:3});return i(qt,{...t,children:e})}function ww(t){const e=t.value,n=t.func_content;if(!n)return i(qt,{...t,children:e});const r=new Function(`return ${n}`)()({value:e});return i(qt,{...t,children:r})}function Cw(t){switch(t.type){case Xe.string:return i(yw,{...t});case Xe.eloc:return i(bw,{...t});case Xe.number:return i(vw,{...t});case Xe.percentage:return i(xw,{...t});case Xe.custom:return i(ww,{...t})}}const Sw=t=>{const e=et(t),n=He(e.triggerManager,mi.id),{colorManager:r}=y.useContext(it);return y.useCallback(a=>new hw(t.getColIndex,a,n,e,r),[n,e,t.getColIndex])};function _w({context:t,instance:e}){var de,Ce;const n=t.data,{height:r,width:a}=t.viewport,{value:o=yr}=R(t.instanceData,"config"),{id_field:l,use_raw_columns:c,columns:u,...d}=o,{classes:f,cx:p}=uw(),g=y.useMemo(()=>{if(!l)return[];const ye=V(l);return n[ye.queryID]},[n,l]),m=y.useMemo(()=>c?!Array.isArray(g)||g.length===0?[]:Object.keys(g[0]).map(ye=>({id:ye,label:ye,value_field:ye,value_type:Xe.string,align:"left"})):u,[c,u,g]),C=Sw({getColIndex:y.useCallback(ye=>m.indexOf(ye.column.columnDef.meta),[m]),vizManager:t.vizManager,instance:e}),w=y.useMemo(()=>{const ye=Ue.createColumnHelper();return m.map(fe=>{const Oe=V(fe.value_field);return ye.accessor(Oe.columnKey,{cell:Ye=>i(Cw,{tableCellContext:C(Ye.cell),value:Ye.getValue(),type:fe.value_type,...fe}),header:fe.label,enableSorting:!0,meta:fe,size:fe.width,minSize:fe.width})})},[m,C]),[_,T]=y.useState([]),M=Ue.useReactTable({data:g,state:{sorting:_},onSortingChange:T,columns:w,getCoreRowModel:Ue.getCoreRowModel(),getSortedRowModel:Ue.getSortedRowModel()}),{rows:L}=M.getRowModel(),B=y.useRef(null),F=Kl.useVirtual({parentRef:B,size:L.length,estimateSize:y.useCallback(()=>28,[]),overscan:20}),{virtualItems:$,totalSize:E}=F,z=$.length>0&&((de=$==null?void 0:$[0])==null?void 0:de.start)||0,W=$.length>0?E-(((Ce=$==null?void 0:$[$.length-1])==null?void 0:Ce.end)||0):0,U=L.length,X=U>0,oe=X?r-22:r,re=X?22:0;return!Array.isArray(g)||g.length===0?i(s.Text,{color:"gray",align:"center",children:"Empty Data"}):h("div",{ref:B,style:{height:r,width:a},"data-enable-scrollbar":!0,className:p(f.root,{"table-highlight-on-hover":o.highlightOnHover}),children:[U>0&&i(s.Box,{className:f.info_bar,sx:{height:22},children:h(s.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:["Total: ",U]})}),h(s.Table,{sx:{...dw,maxHeight:oe},...d,striped:o.striped,children:[i("thead",{className:f.thead,style:{top:re},children:M.getHeaderGroups().map(ye=>i("tr",{children:ye.headers.map(Te=>i("th",{style:{width:Te.getSize()},children:i(iw,{header:Te,cx:p})},Te.id))},ye.id))}),h("tbody",{children:[z>0&&i("tr",{children:i("td",{style:{height:`${z}px`}})}),$.map(ye=>{const Te=L[ye.index];return i("tr",{children:Te.getVisibleCells().map(fe=>i("td",{children:Ue.flexRender(fe.column.columnDef.cell,fe.getContext())},fe.id))},Te.id)}),W>0&&i("tr",{children:i("td",{style:{height:`${W}px`}})})]})]})]})}const Go=s.createStyles(()=>({palette:{display:"flex",flexFlow:"row nowrap"},paletteItem:{".palette-value":{height:24,overflow:"visible",width:36},".palette-item":{width:"36px",height:36*.618,cursor:"pointer",transition:"transform 100ms ease-in-out","&:hover":{boxShadow:"0 0 0 2px var(--shadow-color)",borderRadius:2,transform:"scale(1.2)"}}}})),kw=[{from:0,to:0},{from:100,to:100}];class Tw{constructor(){N(this,"steps",new Map);N(this,"interpolation");N(this,"onChange");ae.makeAutoObservable(this,{steps:ae.observable},{deep:!1}),ae.reaction(()=>ae.toJS(this.steps),()=>{this.notifyStepChange()})}setSteps(e){for(const n of e)this.steps.set(n.to,n.from)}notifyStepChange(){var e;(e=this.onChange)==null||e.call(this,Array.from(this.steps.entries()).map(([n,r])=>({to:n,from:r})).sort((n,r)=>n.to-r.to||n.from-r.from))}fromProps(e){e.steps.length<2?this.setSteps(kw):this.setSteps(e.steps),this.interpolation=e.interpolation,this.onChange=e.onChange}changeStep(e,n){e==null?this.steps.delete(n):this.steps.set(n,e)}getStepFromValue(e){return this.steps.get(e)}}function Dw(t){const{onChange:e,color:n,index:r,value:a}=t,{classes:o}=Go(),[l,c]=y.useState(a),[u,{setTrue:d,setFalse:f}]=J.useBoolean(!1),p=r%2===1,g=p&&a!=null,m=!p&&a!=null,C=`map ${a} to color ${r}`,w=()=>{c(a),f()},_=()=>{f(),e==null||e(l)},T=te(a).format({average:!0});return h("div",{"data-testid":`palette-item-${r}`,className:o.paletteItem,children:[i(s.Text,{title:C,style:{opacity:g?1:0},color:"dimmed",size:"sm",className:"palette-value--up palette-value",children:T}),h(s.Popover,{width:200,trapFocus:!0,opened:u,onClose:f,children:[i(s.Popover.Target,{children:i("div",{"data-testid":"palette-item-target",className:"palette-item",onClick:d,style:{"--shadow-color":at(n).alpha(.5).hex(),backgroundColor:n}})}),i(s.Popover.Dropdown,{children:h(s.Stack,{children:[i(s.NumberInput,{size:"xs",label:"Map a value to this color",value:l,onChange:c}),h(s.Group,{position:"right",children:[i(s.Button,{variant:"subtle",size:"xs",onClick:w,children:"Cancel"}),i(s.Button,{"data-testid":"palette-item-ok",size:"xs",onClick:_,children:"OK"})]})]})})]}),i(s.Text,{title:C,style:{opacity:m?1:0},color:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:T})]})}const Iw=k.observer(({model:t})=>{const{classes:e}=Go(),n=v.range(0,13,1).map(r=>100/12*r).map(r=>[t.interpolation.getColor(r),r]);return i("div",{className:e.palette,children:n.map(([r,a],o)=>i(Dw,{index:o,color:r,value:t.getStepFromValue(a),onChange:l=>t.changeStep(l,a)},r))})}),Mw=k.observer(function(e){const n=J.useCreation(()=>new Tw,[]);return y.useEffect(()=>{n.fromProps(e)}),n.interpolation==null?null:i(Iw,{model:n})}),Ew=t=>{const{value:e,onChange:n,colorManager:r}=t,a=r.getColorInterpolations(),[o,l]=y.useState(e),c=r.decodeInterpolation(o.interpolation)||a[0],[u,{setTrue:d,setFalse:f}]=J.useBoolean(),p=a.map(_=>({label:_.displayName,value:r.encodeColor(_),group:_.category}));function g(_){_&&l(T=>({...T,interpolation:_}))}const m=()=>{f(),n==null||n(ae.toJS(o))};function C(_){l(T=>({...T,steps:_}))}const w=()=>{f(),l(e)};return h(q,{children:[i(s.Button,{variant:"outline",onClick:d,children:c==null?void 0:c.displayName}),i(s.Modal,{size:508,title:"Setup color interpolation",opened:u,onClose:f,zIndex:320,children:u&&h(s.Stack,{"data-testid":"color-interpolation-modal",children:[i(s.Select,{label:"Color style",value:o.interpolation,data:p,onChange:g}),i(Mw,{steps:o.steps,interpolation:c,onChange:C}),h(s.Group,{position:"right",children:[i(s.Button,{onClick:w,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:m,children:"OK"})]})]})})]})},Aw=["static","interpolation","none"].map(t=>({label:v.capitalize(t),value:t})),zw=[{from:0,to:0},{from:100,to:100}];function Wo(t){return t?v.isString(t)?t==="none"?"none":"static":"interpolation":"none"}function $w(t,e){var n;return Wo(e)==="static"?e:(n=t.getStaticColors()[0])==null?void 0:n.value}function Lw(t,e){return v.isObject(e)?e:{steps:zw,interpolation:t.encodeColor(t.getColorInterpolations()[0])}}const Ow=y.forwardRef((t,e)=>{const{colorManager:n}=y.useContext(it),[r,a]=y.useState(Wo(t.value)),[o,l]=y.useState($w(n,t.value)),c=J.useLatest(o),[u,d]=y.useState(Lw(n,t.value)),f=J.useLatest(u),p=C=>{var w,_,T;a(C||"none"),C==="static"?(w=t.onChange)==null||w.call(t,c.current):C==="none"||!C?(_=t.onChange)==null||_.call(t,"none"):(T=t.onChange)==null||T.call(t,f.current)},g=C=>{var w;l(C),(w=t.onChange)==null||w.call(t,C)},m=C=>{var w;d(C),(w=t.onChange)==null||w.call(t,C)};return h(s.Stack,{align:"stretch",children:[i(s.Select,{label:"Cell background",value:r||"none",onChange:p,data:Aw}),r==="static"&&i(Pe,{value:o,onChange:g}),r==="interpolation"&&i(Ew,{colorManager:n,value:u,onChange:m})]})}),Pw={[Xe.eloc]:"ELOC"},Bw=Object.values(Xe).map(t=>({label:v.get(Pw,t,v.capitalize(t)),value:t})),Vw=y.forwardRef(({label:t,value:e,onChange:n,sx:r},a)=>i(s.Select,{ref:a,label:t,data:Bw,value:e,onChange:n,sx:r})),Nw=y.forwardRef(({value:t,onChange:e},n)=>{const[r,{setTrue:a,setFalse:o}]=J.useBoolean(),[l,c]=y.useState(t),u=()=>{o(),e(l)},d=()=>{o(),c(t)},f=()=>{c(ps)};return y.useEffect(()=>{c(t)},[t]),h(q,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Custom Cell Content"}),i(s.Modal,{size:800,title:"Custom cell content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&h(s.Stack,{children:[i(s.Box,{sx:{position:"relative"},children:i(ze,{height:"500px",defaultLanguage:"javascript",value:l,onChange:p=>c(p??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),h(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(I.Recycle,{size:20}),children:"Rest"}),h(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})}),qw=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],yi=()=>i(s.Text,{color:"dimmed",size:12,children:"px"}),Fw=({control:t,index:e,watch:n,remove:r,column:a})=>{const o=n(`columns.${e}.value_type`);return h(s.Stack,{my:0,sx:{position:"relative"},children:[h(s.Group,{grow:!0,children:[i(x.Controller,{name:`columns.${e}.label`,control:t,render:({field:l})=>i(s.TextInput,{label:"Label",required:!0,id:`col-label-${e}`,sx:{flex:1},...l})}),i(x.Controller,{name:`columns.${e}.value_field`,control:t,render:({field:l})=>i(j,{label:"Value Field",required:!0,...l})})]}),h(s.Group,{grow:!0,children:[i(x.Controller,{name:`columns.${e}.value_type`,control:t,render:({field:l})=>i(Vw,{label:"Value Type",sx:{flex:1},...l})}),o===Xe.custom&&i(x.Controller,{name:`columns.${e}.func_content`,control:t,render:({field:l})=>i(Nw,{value:l.value??ps,onChange:c=>l.onChange(c??"")})})]}),i(s.Divider,{mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),h(s.Group,{grow:!0,children:[i(s.NumberInput,{hideControls:!0,label:"Min Width",rightSection:i(yi,{}),disabled:!0}),i(x.Controller,{name:`columns.${e}.width`,control:t,render:({field:l})=>i(s.NumberInput,{hideControls:!0,label:"Width",rightSection:i(yi,{}),...l})}),i(s.NumberInput,{hideControls:!0,label:"Max Width",rightSection:i(yi,{}),disabled:!0})]}),i(s.Group,{grow:!0,noWrap:!0,children:i(x.Controller,{name:`columns.${e}.align`,control:t,render:({field:l})=>i(s.Select,{label:"Alignment",data:qw,...l})})}),i(x.Controller,{name:`columns.${e}.cellBackgroundColor`,control:t,render:({field:l})=>i(Ow,{...l})}),i(s.Divider,{mb:4,mt:12,variant:"dashed"}),i(s.Button,{leftIcon:i(I.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(e),children:"Delete this column"})]})},Gw=({control:t,watch:e})=>{const{fields:n,append:r,remove:a,update:o}=x.useFieldArray({control:t,name:"columns"}),l=()=>{const u=Ie.randomId();r({id:u,label:u,align:"center",value_field:"",value_type:Xe.string})};e("columns");const c=e("use_raw_columns");return h(q,{children:[i(x.Controller,{name:"use_raw_columns",control:t,render:({field:u})=>i(s.Switch,{mt:20,label:"Use Original Data Columns",checked:u.value,onChange:d=>u.onChange(d.currentTarget.checked)})}),i(s.Divider,{mt:20,mb:10,variant:"dashed"}),!c&&h(s.Stack,{children:[i(s.Text,{my:0,children:"Custom Columns"}),h(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[h(s.Tabs.List,{children:[n.map((u,d)=>i(s.Tabs.Tab,{value:d.toString(),children:d+1},u.id)),i(s.Tabs.Tab,{onClick:l,value:"add",children:i(I.Plus,{size:18,color:"#228be6"})})]}),n.map((u,d)=>i(s.Tabs.Panel,{value:d.toString(),children:i(Fw,{control:t,watch:e,index:d,column:u,remove:a},d)},u.id))]})]})]})};function Ww({control:t,watch:e}){return e(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),h(s.Stack,{spacing:"xs",children:[h(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[i(x.Controller,{name:"horizontalSpacing",control:t,render:({field:n})=>i(s.TextInput,{label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})}),i(x.Controller,{name:"verticalSpacing",control:t,render:({field:n})=>i(s.TextInput,{label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})})]}),i(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:i(x.Controller,{name:"fontSize",control:t,render:({field:n})=>i(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})})}),h(s.Group,{position:"apart",grow:!0,children:[i(x.Controller,{name:"striped",control:t,render:({field:n})=>i(s.Switch,{label:"Striped",checked:n.value,onChange:r=>n.onChange(r.currentTarget.checked)})}),i(x.Controller,{name:"highlightOnHover",control:t,render:({field:n})=>i(s.Switch,{label:"Highlight on hover",checked:n.value,onChange:r=>n.onChange(r.currentTarget.checked)})})]})]})}function Rw({columns:t,...e}){return{...e,columns:t.map(({id:n,...r})=>({id:n??Ie.randomId(),...r}))}}function jw({context:t}){const{value:e,set:n}=R(t.instanceData,"config"),r=y.useMemo(()=>v.defaultsDeep({},e,yr),[e]),a=y.useMemo(()=>Rw(r),[r]);y.useEffect(()=>{!v.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:c,getValues:u,reset:d}=x.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=u(),p=y.useMemo(()=>!v.isEqual(f,r),[f,r]);return c(["id_field"]),h("form",{onSubmit:l(n),children:[h(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Table Config"}),i(s.ActionIcon,{type:"submit","aria-label":"save config",mr:5,variant:"filled",color:"blue",disabled:!p,children:i(I.DeviceFloppy,{size:20})})]}),h(s.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Data",children:"Data"}),i(s.Tabs.Tab,{value:"Style",children:"Style"}),i(s.Tabs.Tab,{value:"Columns",children:"Columns"})]}),i(s.Tabs.Panel,{value:"Data",children:i(x.Controller,{name:"id_field",control:o,render:({field:g})=>i(j,{label:"ID Field",required:!0,...g})})}),i(s.Tabs.Panel,{value:"Style",children:i(Ww,{control:o,watch:c})}),i(s.Tabs.Panel,{value:"Columns",children:i(Gw,{control:o,watch:c})})]})]})}function Yw(t){const{columns:e,...n}=t;return{...t,columns:e.map(r=>({...r,align:r.align??"left"}))}}function Qw(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{id_field:a,columns:o,...l}=t;return{...l,id_field:r(a),columns:o.map(c=>({...c,value_field:r(c.value_field)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class Kw extends ve{constructor(){super(...arguments);N(this,"VERSION",4)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{columns:r,...a}=n.config;return{...n,version:2,config:{...a,columns:r.map(({id:o,...l})=>({id:o??Ie.randomId(),...l}))}}}),this.version(3,n=>({...n,version:3,config:Yw(n.config)})),this.version(4,(n,r)=>({...n,version:4,config:Qw(n.config,r)}))}}const bi={createConfig(){return{version:4,config:v.cloneDeep(yr)}},displayName:"Table",displayGroup:"Others",migrator:new Kw,name:"table",viewRender:_w,configRender:jw,triggers:[mi]},Uw=b.types.model("PanelLayoutModel",{x:b.types.number,y:b.types.maybeNull(b.types.number),w:b.types.number,h:b.types.number,moved:b.types.optional(b.types.boolean,!1),static:b.types.optional(b.types.boolean,!1)}).views(t=>({get json(){const{x:e,y:n,w:r,h:a,moved:o}=t;return{h:a,w:r,x:e,y:n===null?0:n,moved:o,static:t.static}}})).actions(t=>({set(e){const{x:n,y:r,w:a,h:o,moved:l}=e;t.x=n,t.y=r,t.w=a,t.h=o,t.moved=!!l,t.static=!!e.static}})),Xw=b.types.model("PanelStyleBorderModel",{enabled:b.types.boolean}).views(t=>({get json(){const{enabled:e}=t;return{enabled:e}}})).actions(t=>({setEnabled(e){t.enabled=e}})),Jw=b.types.model("PanelStyleModel",{border:Xw}).views(t=>({get json(){const{border:e}=t;return{border:e.json}}})).actions(t=>({})),Zw=b.types.model("PanelVizModel",{type:b.types.string,conf:b.types.frozen()}).views(t=>({get json(){return{conf:t.conf,type:t.type}}})).actions(t=>({setType(e){t.type=e},setConf(e){t.conf=e}})),Ro=b.types.model({id:b.types.string,title:b.types.string,description:b.types.string,layout:Uw,queryIDs:b.types.array(b.types.string),viz:Zw,style:Jw,variables:b.types.optional(b.types.array(Fc),[])}).views(t=>({get contentModel(){return b.getParentOfType(t,Xn)}})).views(t=>({get queryIDSet(){return new Set(t.queryIDs)},get queries(){return t.contentModel.queries.findByIDSet(this.queryIDSet)},get data(){return this.queries.reduce((e,n)=>(e[n.id]=n.data.toJSON(),e),{})},get dataLoading(){return this.queries.some(e=>e.state==="loading")},get queryStateMessages(){return this.queries.map(e=>e.stateMessage).filter(e=>!!e)},get queryErrors(){return this.queries.map(e=>e.error).filter(e=>!!e)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages.length===0&&!this.dataLoading},get json(){const{id:e,title:n,description:r,queryIDs:a}=t;return{id:e,viz:t.viz.json,style:t.style.json,title:n,layout:t.layout.json,queryIDs:[...a],variables:t.variables.map(o=>o.json),description:r}},get dataFieldOptions(){return t.queryIDs.length===0?[]:this.queries.map(e=>{const n=e.data;return n.length===0?[]:Object.keys(n[0]).map(a=>({label:a,value:`${e.id}.${a}`,group:e.name}))}).flat()}})).actions(t=>({setID(e){t.id=e},setTitle(e){t.title=e},setDescription(e){t.description=e},addQueryID(e){t.queryIDSet.has(e)||t.queryIDs.push(e)},removeQueryID(e){if(!t.queryIDSet.has(e))return;const n=new Set(t.queryIDSet);n.delete(e),t.queryIDs=b.cast(Array.from(n))},setQueryIDs(e){t.queryIDs=b.cast(e)},addVariable(e){t.variables.push(e)},removeVariable(e){t.variables.remove(e)},removeSelf(){b.getParent(t,2).removeByID(t.id)}})).actions(t=>({moveToView(e,n){b.getRoot(t).content.views.findByID(e).removePanelID(t.id),b.getRoot(t).content.views.findByID(n).appendPanelID(t.id),b.getRoot(t).editor.setPath(["_VIEWS_",n,"_PANELS_",t.id])},refreshData(){t.queries.forEach(e=>e.fetchData())},downloadData(){b.getRoot(t).content.queries.downloadDataByQueryIDs(t.queryIDs)}}));function jo(t){return{id:t,layout:{x:0,y:1/0,w:18,h:300},title:t,description:"<p></p>",queryIDs:[],viz:{type:bi.name,conf:bi.createConfig()},style:{border:{enabled:!0}}}}const Yo=b.types.model("PanelsModel",{list:b.types.optional(b.types.array(Ro),[])}).views(t=>({get json(){return t.list.map(e=>e.json)},findByID(e){return t.list.find(n=>n.id===e)},get idMap(){const e=new Map;return t.list.forEach(n=>{e.set(n.id,n)}),e}})).views(t=>({panelsByIDs(e){const n=[];e.forEach(a=>{const o=t.idMap.get(a);o?n.push(o):console.warn(`Panel is not found, id:${a}`)});const r=n.map(a=>({...a.layout.json,i:a.id}));return{panels:n,layouts:r}}})).views(t=>({editorOptions(e,n){const{panels:r}=t.panelsByIDs(n);r.length!==n.length&&console.warn(`Unfulfilled panels for View[${e}]`);const a=r.map(l=>({label:l.title?l.title:v.capitalize(l.viz.type),value:l.id,_type:"panel",parentID:e})),o="_Add_A_PANEL_";return a.push({label:o,value:o,_type:"ACTION",_action_type:o,parentID:e,Icon:null,children:null}),a}})).actions(t=>({replace(e){t.list=b.castToSnapshot(e)},append(e){t.list.push(e)},remove(e){t.list.splice(e,1)},removeByID(e){const n=t.list.findIndex(r=>r.id===e);n!==-1&&t.list.splice(n,1)},duplicateByID(e){const n=t.list.find(a=>a.id===e);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${e}]`));return}const r=new Date().getTime().toString();return t.list.push({...n.json,id:r,layout:{...n.layout,y:1/0,moved:!1}}),r},replaceByIndex(e,n){t.list.splice(e,1,n)}}));var Qo=(t=>(t.Use="use",t.Edit="edit",t))(Qo||{}),H=(t=>(t.Division="div",t.Modal="modal",t.Tabs="tabs",t))(H||{});const Hw={div:"Division",tabs:"Tabs",modal:"Modal"},Ko={div:"rgba(255, 0, 0, 0.2)",modal:"rgba(0, 0, 0, 0.2)",tabs:"rgba(255, 200, 100, 0.4)"},eC={div:"#ff4000",modal:"#000",tabs:"#ffad18"},tC={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:"div",config:{},panelIDs:[]}],panels:[],filters:[],version:"9.19.0"};var vi=(t=>(t.Select="select",t.TreeSelect="tree-select",t.MultiSelect="multi-select",t.TextInput="text-input",t.Checkbox="checkbox",t.DateRange="date-range",t))(vi||{});const Uo=b.types.model("ViewModel_Division",{_name:b.types.literal(H.Division)}).views(t=>({get json(){const{_name:e}=t;return{_name:e}}})).actions(t=>({})),nC=()=>Uo.create({_name:H.Division}),xi={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
480
- `)},rC=b.types.model("CustomModalTitleModel",{enabled:b.types.optional(b.types.boolean,!1),func_content:b.types.optional(b.types.string,"")}).views(t=>({get json(){const{enabled:e,func_content:n}=t;return{enabled:e,func_content:n}},get value(){const{enabled:e,func_content:n}=t,r=b.getParent(t,2),a=b.getRoot(t);if(!e)return r.name;try{const o={filters:a.content.filters.values,context:a.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(t=>({setEnabled(e){t.enabled=e},setFuncContent(e){t.func_content=e},replace({enabled:e,func_content:n}){t.enabled=e,t.func_content=n}})),Xo=b.types.model("ViewModel_Modal",{_name:b.types.literal(H.Modal),width:b.types.string,height:b.types.string,custom_modal_title:b.types.optional(rC,xi)}).views(t=>({get json(){const{_name:e,width:n,height:r,custom_modal_title:a}=t;return{_name:e,width:n,height:r,custom_modal_title:a.json}}})).actions(t=>({setWidth(e){t.width=e},setHeight(e){t.height=e}})),iC=()=>Xo.create({_name:H.Modal,width:"90vw",height:"90vh"}),aC=b.types.model("ViewModel_Tabs_Tab",{id:b.types.identifier,name:b.types.string,view_id:b.types.string,color:b.types.optional(b.types.string,"")}).views(t=>({get json(){const{id:e,name:n,view_id:r,color:a}=t;return{id:e,name:n,color:a,view_id:r}}})).actions(t=>({setName(e){t.name=e},setViewID(e){t.view_id=e},setColor(e){t.color=e}})),Jo=b.types.model("ViewModel_Tabs",{_name:b.types.literal(H.Modal),tabs:b.types.optional(b.types.array(aC),[]),variant:b.types.optional(b.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:b.types.optional(b.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:b.types.optional(b.types.boolean,!1)}).views(t=>({get json(){const{_name:e,variant:n,orientation:r,tabs:a,grow:o}=t;return{grow:o,tabs:a.map(l=>l.json),_name:e,variant:n,orientation:r}}})).actions(t=>({setVariant(e){t.variant=e},setOrientation(e){t.orientation=e},setGrow(e){t.grow=e},setTabs(e){t.tabs.length=0,t.tabs=b.cast(e)},addTab(){const e=Ie.randomId(),n={id:e,name:e,view_id:""};t.tabs.push(n)},removeTab(e){t.tabs.splice(e,1)}})),sC=()=>Jo.create({_name:H.Modal,tabs:[]}),Zo=b.types.model({id:b.types.identifier,name:b.types.string,type:b.types.enumeration("EViewComponentType",[H.Division,H.Modal,H.Tabs]),config:b.types.union(Uo,Xo,Jo),panelIDs:b.types.optional(b.types.array(b.types.string),[])}).views(t=>({get json(){const{id:e,name:n,type:r,config:a}=t;return{id:e,name:n,type:r,config:a.json,panelIDs:t.panelIDs}}})).actions(t=>({setName(e){t.name=e},setType(e){if(t.type!==e){switch(e){case H.Division:t.config=nC();break;case H.Modal:t.config=iC();break;case H.Tabs:t.config=sC();break}t.type=e}},appendPanelID(e){t.panelIDs.push(e)},removePanelID(e){const n=t.panelIDs.filter(r=>r!==e);t.panelIDs.length=0,t.panelIDs.push(...n)}})).actions(t=>({})),Ho=b.types.model("ViewsModel",{current:b.types.optional(b.types.array(Zo),[]),visibleViewIDs:b.types.array(b.types.string),idOfVIE:b.types.string}).views(t=>({get json(){return t.current.map(e=>bn(e.json))},get idMap(){const e=new Map;return t.current.forEach(n=>{e.set(n.id,n)}),e},findByID(e){return t.current.find(n=>n.id===e)},get isVIETheFirstView(){return t.current.length===0||!t.idOfVIE?!1:t.current[0].id===t.idOfVIE},get firstVisibleView(){const[e]=t.visibleViewIDs;return t.current.find(({id:n})=>n===e)},get visibleViews(){const e=new Set(t.visibleViewIDs);return t.current.filter(({id:n})=>e.has(n))},get VIE(){return t.current.find(({id:e})=>e===t.idOfVIE)},get options(){return t.current.map(e=>({label:e.name,value:e.id,type:e.type}))},get editorOptions(){const e=b.getRoot(t).content.panels;return t.current.map(n=>({label:n.name,value:n.id,_type:"view",children:e.editorOptions(n.id,n.panelIDs)}))}})).actions(t=>({replace(e){t.current.replace(e)},addANewView(e,n,r,a){t.current.push({id:e,name:n,type:r,config:a,panelIDs:[]})},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},removeByID(e){const n=t.current.findIndex(r=>r.id===e);n!==-1&&t.current.splice(n,1)},replaceByIndex(e,n){t.current.splice(e,1,n)},setIDOfVIE(e){t.idOfVIE=e,t.visibleViewIDs.length=0,t.visibleViewIDs.push(e)},appendToVisibles(e){new Set(t.visibleViewIDs.map(r=>r)).has(e)||t.visibleViewIDs.push(e)}})).actions(t=>({addARandomNewView(){const e=new Date().getTime().toString();t.addANewView(e,H.Division,H.Division,{_name:H.Division}),t.setIDOfVIE(e)},removeVIE(){t.current.length!==1&&(t.removeByID(t.idOfVIE),t.setIDOfVIE(t.current[0].id))},rmVisibleViewID(e){const n=t.visibleViewIDs.findIndex(r=>r===e);n!==-1&&t.visibleViewIDs.splice(n,1)}}));function wi(t){const e=t.length>0?[t[0].id]:[],n=t.length>0?t[0].id:"";return{current:t.map(a=>{const{_name:o=a.type}=a.config;return{...a,config:{...a.config,_name:o},panelIDs:a.panelIDs}}),visibleViewIDs:e,idOfVIE:n}}function el(t,e,n,r){return t.reduce((a,o)=>(a[o[e]]=ur(o[n],r),a),{})}const oC=b.types.model({id:b.types.string,name:b.types.string,dashboard_id:b.types.string,create_time:b.types.string,update_time:b.types.string,version:b.types.string,filters:ts,queries:ls,sqlSnippets:us,views:Ho,panels:Yo,mock_context:qc,origin:b.types.maybe(b.types.frozen())}).views(t=>({get json(){return{id:t.id,name:t.name,create_time:t.create_time,update_time:t.update_time,dashboard_id:t.dashboard_id,content:{views:t.views.json,panels:t.panels.json,filters:t.filters.json,version:t.version,definition:{queries:t.queries.json,sqlSnippets:t.sqlSnippets.json,mock_context:t.mock_context.current}}}},get filtersChanged(){const e="filters.current";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get queriesChanged(){const e="queries.current",n=b.getSnapshot(v.get(t,e)).map(r=>v.pick(r,["id","name","key","type","sql","run_by","react_to","pre_process","post_process"]));return!v.isEqual(n,v.get(t.origin,e))},get sqlSnippetsChanged(){const e="sqlSnippets.current";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get viewsChanged(){const e="views.current";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get panelsChanged(){const e="panels.list";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get mockContextChanged(){const e="mock_context.current";return!v.isEqual(v.get(t,e),v.get(t.origin,e))},get payloadForSQL(){const e=b.getParent(t).context.current,n=b.getParent(t).globalSQLSnippets,r={context:{...t.mock_context.current,...e},filters:t.filters.values};return{...r,sql_snippets:el(t.sqlSnippets.current,"key","value",r),global_sql_snippets:el(n.list,"id","content",r)}},get payloadForViz(){const e=b.getParent(t).context.current;return{context:{...t.mock_context.current,...e},filters:t.filters.values}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.mockContextChanged},get data(){return t.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(e){const n=t.queries.findByID(e);return n?{data:n.data.toJSON(),len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(t=>({findQueryUsage(e){const n=t.panels.idMap,r=t.views.current.flatMap(l=>l.panelIDs.map(c=>n.get(c)).filter(c=>(c==null?void 0:c.queryIDSet.has(e))??!1).map(c=>({type:"panel",id:c.id,label:c.title?c.title:c.viz.type,views:[{id:l.id,label:l.name}]}))),a=t.views.idMap,o=t.filters.current.filter(l=>v.get(l,"config.options_query_id")===e).map(l=>({type:"filter",id:l.id,label:l.label,views:l.visibleInViewsIDs.map(c=>{var u;return{id:c,label:((u=a.get(c))==null?void 0:u.name)??c}})}));return r.concat(o)}})).actions(t=>({duplicatePanelByID(e,n){var a;const r=t.panels.duplicateByID(e);r&&((a=t.views.findByID(n))==null||a.appendPanelID(r))},removePanelByID(e,n){var r;t.panels.removeByID(e),(r=t.views.findByID(n))==null||r.removePanelID(e)},addANewPanel(e){var r;const n=new Date().getTime().toString();t.panels.append(jo(n)),(r=t.views.findByID(e))==null||r.appendPanelID(n)}})).actions(t=>({reset(){b.applySnapshot(t.filters.current,t.origin.filters.current),b.applySnapshot(t.queries.current,t.origin.queries.current),b.applySnapshot(t.sqlSnippets.current,t.origin.sqlSnippets.current),b.applySnapshot(t.views.current,t.origin.views.current),b.applySnapshot(t.panels.list,t.origin.panels.list),t.mock_context.current=t.origin.mock_context.current},resetFilters(){b.applySnapshot(t.filters.current,t.origin.filters.current)},updateCurrent(e){const{id:n,name:r,content:a}=e;if(!a)throw new Error("unexpected null content when updating a content model");const{version:o,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:f,mock_context:p={}}}=a;t.id=n,t.name=r,t.version=o,b.applySnapshot(t.filters.current,l),b.applySnapshot(t.views.current,wi(c).current),b.applySnapshot(t.panels.list,u),b.applySnapshot(t.queries.current,d),b.applySnapshot(t.sqlSnippets.current,f),t.mock_context.current=p}})),Xn=b.types.snapshotProcessor(oC,{preProcessor(t){return{...t,origin:t}},postProcessor(t){delete t.origin;const e=b.castToSnapshot(t.queries.current.map(n=>v.pick(n,["id","key","type","sql"])));return v.defaults({},{queries:{current:e}},t)}});function lC(t,e){e.filters&&b.applySnapshot(t.filters.current,e.filters)}function tl({id:t,name:e,dashboard_id:n,create_time:r,update_time:a,content:o}){if(!o)throw new Error("unexpected null content when creating a content model");const{version:l,filters:c,views:u,panels:d,definition:{queries:f,sqlSnippets:p,mock_context:g={}}}=o;return Xn.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:a,version:l,filters:ns(c),queries:{current:f},sqlSnippets:{current:p},mock_context:{current:g},views:wi(u),panels:{list:d}})}const cC=b.types.model({id:b.types.string,content:b.types.string,create_time:b.types.string,update_time:b.types.string,is_preset:b.types.boolean}),uC=b.types.model("GlobalSQLSnippetsModel",{list:b.types.optional(b.types.array(cC),[])}).views(t=>({find(e){return t.list.find(n=>n.id===e)},get options(){return t.list.map(e=>({value:e.id,label:e.id}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}})),nl=b.types.model({id:b.types.identifier,name:b.types.string,group:b.types.string,content:Xn,content_id:b.types.string,datasources:Bc,globalSQLSnippets:uC,context:ds,editor:Nc}).views(t=>({get json(){return{id:t.id,name:t.name,group:t.group,content_id:t.content_id}}})).actions(t=>({updateCurrentContent(e){t.content.updateCurrent(e)},updateCurrent(e,n){const{id:r,name:a,group:o,content_id:l}=e;t.id=r,t.name=a,t.group=o,t.content_id=l,this.updateCurrentContent(n)}}));function Ci({id:t,name:e,group:n,content_id:r},a,o,l,c){return nl.create({id:t,name:e,group:n,content_id:r,content:tl(a),datasources:{list:o},globalSQLSnippets:{list:l},context:{current:c},editor:{}})}const Si=y.createContext(null);function Jn(t){const e=y.useContext(Si),n=J.useCreation(()=>t.configure(e||new vr),[t.configure]),r=J.usePrevious(n);return r&&r!==n&&r.dispose(),i(Si.Provider,{value:n,children:t.children})}function rl(){return y.useContext(Si)}const dC={viewPanelInFullScreen:v.noop,inFullScreen:!1},_i=y.createContext(dC),pC=({description:t,isDescriptionEmpty:e})=>e?null:i(s.Tooltip,{color:"white",label:i(Yn,{value:t,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:i(s.Box,{sx:{height:"16px",alignSelf:"center"},children:i(O.IconInfoCircle,{size:16,color:"gray"})})}),hC=k.observer(({label:t,config:{default_value:e,description:n,isDescriptionEmpty:r,...a},value:o,onChange:l})=>h(s.Box,{children:[i(s.Text,{children:" "}),i(s.Checkbox,{label:h(s.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[i(s.Box,{sx:{flexGrow:1},children:t}),i(pC,{description:n,isDescriptionEmpty:r})]}),checked:o||!1,onChange:c=>l(c.currentTarget.checked),...a,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),il=k.observer(({label:t,config:e,value:n=[null,null],onChange:r})=>{const a=Array.isArray(n)?n.map(u=>u?Y(u).toDate():null):[null,null],o=u=>{r(u.map(d=>d&&Y(d).format(e.inputFormat)))},l=e.getMinDate(a[0]),c=e.getMaxDate(a[0]);return i(Jl.DateRangePicker,{label:t,value:a,onChange:o,icon:i(I.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:l,maxDate:c,styles:{input:{borderColor:"#e9ecef"}},...e})}),fC=s.createStyles((t,{radius:e=4})=>({root:{borderRadius:t.fn.radius(e),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-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-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-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-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-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-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:t.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:t.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,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-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{flexGrow:1}}}})),al=({errorMessage:t})=>t?i(s.Text,{color:"red",size:12,children:t}):i(s.Text,{color:"dimmed",size:12,children:"Not found"}),gC=({disabled:t,classNames:e,styles:n,unstyled:r,radius:a,style:o,label:l,value:c,onChange:u,options:d,errorMessage:f})=>{const{classes:p,cx:g}=fC({radius:a},{name:"MultiSelectWidget",classNames:e,styles:n,unstyled:r}),[m,C]=y.useState(!1),w=B=>{C(B)},_=m&&(c==null?void 0:c.length)>0,[T,M]=y.useState(""),L=y.useMemo(()=>{if(!T)return d;const B=T.toLowerCase(),F=$=>{var E;return((E=$.description)==null?void 0:E.toLowerCase().includes(B))||$.label.toLowerCase().includes(B)};return d.filter(F)},[T,d]);return h(s.Stack,{spacing:3,children:[h(s.Group,{position:"apart",children:[i(s.Text,{className:p.label,children:l}),_&&i(s.Tooltip,{label:`${c.length} selected`,children:i(s.Badge,{children:c.length})})]}),i(Ba,{disabled:t,allowClear:!0,className:g(p.root,"check-select"),dropdownClassName:g(p.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>i(s.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:i(al,{errorMessage:f}),maxTagTextLength:10,maxTagPlaceholder:B=>`${B.length} selected`,searchValue:T,onSearch:M,filterOption:!1,children:L.map(B=>i(Ba.Option,{children:i(s.Group,{noWrap:!0,children:h("div",{children:[i(s.Text,{size:"sm","data-role":"label",children:B.label}),B.description&&i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:B.description})]})})},B.value))})]})},mC=k.observer(({label:t,config:e,value:n,onChange:r})=>{const a=K(),o=!!e.options_query_id,{state:l,error:c}=a.getDataStuffByID(e.options_query_id),u=l==="loading",d=e.min_width?e.min_width:"200px",f=o?u:!1,p=g=>r(g,!1);return i(gC,{label:t,options:e.options,style:{minWidth:"160px",width:d,maxWidth:f?d:"unset",borderColor:"#e9ecef"},disabled:f,value:n,onChange:p,errorMessage:c})}),yC=y.forwardRef(({label:t,description:e,...n},r)=>i("div",{ref:r,...n,children:i(s.Group,{noWrap:!0,children:h("div",{children:[i(s.Text,{size:"sm","data-role":"label",children:t}),i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:e})]})})})),bC=k.observer(({label:t,config:e,value:n,onChange:r})=>{const a=K(),o=!!e.options_query_id,{state:l,error:c}=a.getDataStuffByID(e.options_query_id),u=l==="loading";return y.useEffect(()=>{var p;const{default_selection_count:d}=e;if(!d)return;const f=((p=e.options[0])==null?void 0:p.value)??"";console.log("Selecting the first option by default. New value: ",f),r(f,!0)},[e.default_selection_count,e.options]),i(s.Select,{label:t,data:e.options,disabled:o?u:!1,value:n,onChange:r,error:!!c,placeholder:c,maxDropdownHeight:500,styles:{root:{width:e.width?e.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:yC})});function vC({label:t,config:e,value:n,onChange:r}){return i(s.TextInput,{label:t,value:n||"",onChange:a=>r(a.currentTarget.value),...e,styles:{input:{borderColor:"#e9ecef"}}})}const xC=({rotate:t,onClick:e})=>i("svg",{onClick:e,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(${t})`,children:i("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"})}),wC=({expanded:t,isLeaf:e,value:n,onClick:r,...a})=>(n==="0-0-value"&&console.log(a),e?i("span",{style:{width:"14px",display:"inline-block"}}):i(xC,{rotate:t?"0":"-90",onClick:r,...a})),CC=({onClick:t})=>h("svg",{onClick:t,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),i("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),i("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),i("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),SC=({onClick:t,...e})=>i(CC,{onClick:t,...e}),_C=s.createStyles((t,{radius:e=4})=>({root:{borderRadius:t.fn.radius(e),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:t.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:t.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"}}}})),kC=({disabled:t,classNames:e,styles:n,unstyled:r,radius:a,style:o,label:l,value:c,onChange:u,treeData:d,errorMessage:f})=>{const{classes:p,cx:g}=_C({radius:a},{name:"FilterTreeSelectWidget",classNames:e,styles:n,unstyled:r}),[m,C]=y.useState(!1),w=T=>{C(T)},_=m&&(c==null?void 0:c.length)>0;return h(s.Stack,{spacing:3,children:[h(s.Group,{position:"apart",children:[i(s.Text,{className:p.label,children:l}),_&&i(s.Tooltip,{label:`${c.length} selected`,children:i(s.Badge,{children:c.length})})]}),i(Va,{disabled:t,allowClear:!0,className:g(p.root,"check-select"),dropdownClassName:g(p.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>i(s.CloseButton,{}),switcherIcon:wC,treeIcon:SC,maxTagTextLength:10,value:c,treeData:d,notFoundContent:i(al,{errorMessage:f}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Va.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:T=>`${T.length} selected`})]})},TC=k.observer(({label:t,config:e,value:n,onChange:r})=>{const{treeData:a,treeDataLoading:o,errorMessage:l}=e,c=e.min_width?e.min_width:"200px",d=!!e.options_query_id?o:!1;return i(kC,{disabled:d,style:{minWidth:"160px",width:c,maxWidth:d?c:"unset",borderColor:"#e9ecef"},value:n,onChange:f=>r(f,!1),treeData:a,errorMessage:l,label:t})}),DC=k.observer(({filter:{type:t,config:e,key:n,...r},formFieldProps:a})=>{switch(t){case"select":return i(bC,{...r,...a,config:e});case"multi-select":return i(mC,{...r,...a,config:e});case"tree-select":return i(TC,{...r,...a,config:e});case"text-input":return i(vC,{...r,...a,config:e});case"date-range":return i(il,{...r,...a,config:e});case"checkbox":return i(hC,{...r,...a,config:e});default:return null}}),sl=k.observer(y.forwardRef(({filter:t,...e},n)=>i("div",{className:"filter-root",ref:n,children:i(Fe,{children:i(DC,{filter:t,formFieldProps:e})})}))),ol=k.observer(function({view:e}){const n=K(),{control:r,handleSubmit:a,reset:o}=x.useForm({defaultValues:n.filters.values,reValidateMode:"onBlur"}),l=x.useWatch({control:r});y.useEffect(()=>{o(n.filters.values)},[n.filters.values,o]),y.useEffect(()=>{n.filters.updatePreviewValues(l)},[l]);const c=n.filters.visibleInView(e.id),u=y.useMemo(()=>c.every(g=>g.should_auto_submit),[c]),d=y.useMemo(()=>c.filter(g=>v.get(g,"config.required",!1)),[c]),f=y.useMemo(()=>d.length===0?!1:d.some(g=>!g.requiredAndPass(l[g.key])),[l,d]);if(c.length===0)return null;const p=(g,m)=>(C,w)=>{m(C),(g.should_auto_submit||w)&&n.filters.setValueByKey(g.key,C)};return i("form",{onSubmit:a(n.filters.setValues),children:h(s.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:u?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[i(s.Group,{align:"flex-start",children:c.map(g=>i(x.Controller,{name:g.key,control:r,render:({field:m})=>i(sl,{filter:g,value:m.value,onChange:p(g,m.onChange)})},g.id))}),!u&&i(s.Group,{sx:{alignSelf:"flex-end"},children:i(s.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),jT="";function IC(t){return t?["<p><br></p>","<p></p>"].includes(t):!0}const ll=k.observer(()=>{const{freezeLayout:t}=y.useContext(ft),[e,n]=y.useState(!1),{panel:r}=Ae();return y.useEffect(()=>{t(e)},[e]),IC(r.description)?null:h(q,{children:[i(s.Modal,{opened:e,onClose:()=>n(!1),title:r.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:i(Yn,{value:r.description,styles:{root:{border:"none"},content:{padding:0}}})}),i(s.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(a=>!a),sx:{verticalAlign:"baseline",cursor:"pointer"},children:i(I.InfoCircle,{size:20})})})]})}),MC=k.observer(({view:t})=>{const e=ge(),n=K(),r=Ke.useModals(),{panel:a}=Ae(),{id:o}=a,{inEditMode:l}=y.useContext(ft),{viewPanelInFullScreen:c,inFullScreen:u}=y.useContext(_i),d=()=>{n.duplicatePanelByID(o,t.id)},f=()=>{e.editor.open(["_VIEWS_",t.id,"_PANELS_",o])},p=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.removePanelByID(o,t.id),confirmProps:{color:"red"},zIndex:320}),g=y.useCallback(()=>{c(o)},[o,c]),m=!u&&t.type!==H.Modal;return i(q,{children:i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:h(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),h(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:a.refreshData,icon:i(I.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:a.downloadData,icon:i(I.Download,{size:14}),children:"Download Data"}),m&&i(s.Menu.Item,{onClick:g,icon:i(I.ArrowsMaximize,{size:14}),disabled:l,children:"Full Screen"}),l&&h(q,{children:[i(s.Divider,{label:"Edit",labelPosition:"center"}),i(s.Menu.Item,{onClick:f,icon:i(I.Settings,{size:14}),children:"Settings"}),i(s.Menu.Item,{onClick:d,icon:i(I.Copy,{size:14}),children:"Duplicate"}),i(s.Menu.Item,{color:"red",onClick:p,icon:i(I.Trash,{size:14}),children:"Delete"})]})]})]})})})}),EC=k.observer(({panel:t})=>h(s.Stack,{children:[t.queryErrors.map((e,n)=>i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e},`${n}-${e}`)),t.queryStateMessages.map((e,n)=>i(s.Text,{color:"gray",align:"center",children:e},`${n}-${e}`))]}));var cl=(t=>(t.migrated="migrated",t.nothingToMigrate="nothingToMigrate",t.checkFailed="checkFailed",t.migrationFailed="migrationFailed",t))(cl||{}),Zn=(t=>(t.notStarted="notStarted",t.inProgress="inProgress",t.done="done",t))(Zn||{});class AC{constructor(e){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=e.getRequired(we.instanceScope.panelModel),this.vizInstance=e.getRequired(we.instanceScope.vizInstance),this.operationManager=e.getRequired(we.instanceScope.operationManager),this.triggerManager=e.getRequired(we.instanceScope.triggerManager),this.vizManager=e.getRequired(we.vizManager)}async createMigrationTask(){const e=[];try{await this.instanceNeedMigration()&&e.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&e.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(e.length===0)return"nothingToMigrate";try{return await Promise.all(e.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(e=>(this.status="done",e))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await e.migrator.migrate(n)}async instanceNeedMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return e.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function ul(t){const{panel:e}=Ae();return y.useCallback(n=>{const r=n.getRequired(we.vizManager),a=r.resolveComponent(t.viz.type);return n.createScoped().provideFactory(we.instanceScope.vizInstance,()=>r.getOrCreateInstance(t)).provideFactory(we.instanceScope.interactionManager,o=>{const l=o.getRequired(we.instanceScope.vizInstance);return new gi(l,a,Un)}).provideFactory(we.instanceScope.operationManager,o=>o.getRequired(we.instanceScope.interactionManager).operationManager).provideFactory(we.instanceScope.triggerManager,o=>o.getRequired(we.instanceScope.interactionManager).triggerManager).provideValue(we.instanceScope.panelModel,e).provideFactory(we.instanceScope.migrator,o=>new AC(o))},[t.viz.type,t.viz.conf])}function dl(t){const[e,n]=y.useState(!1),r=rl().getRequired(we.instanceScope.migrator);return J.useAsyncEffect(async()=>{const a=r.status===Zn.notStarted;n(r.status===Zn.done),r.status===Zn.notStarted&&r.runMigration().then(o=>{o===cl.migrated&&a&&(t==null||t())}).finally(()=>{n(!0)})},[r]),e}function pl(t,e){const n=rl().getRequired(we.instanceScope.vizInstance);return y.useEffect(()=>(n.instanceData.setItem(null,e.viz.conf),n.instanceData.watchItem(null,r=>{t(r)})),[t,e.viz.type]),n}function zC({setVizConf:t,...e}){const{panel:n}=e,r=pl(t,n),a=dl(()=>{fn.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return J.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),a?i(Kc,{...e}):i(s.Text,{children:"Checking update..."})}function $C(t){const{panel:e,setVizConf:n}=t;pl(n,e);const{inEditMode:r}=y.useContext(ft);return dl(()=>{r&&fn.showNotification({title:`${e.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?i(Qc,{...t}):i(s.Text,{children:"Checking update"})}const YT="";function LC(t,e){const{vizManager:n}=y.useContext(it),{panel:{viz:r,title:a,id:o,description:l,queryIDs:c,variables:u}}=Ae(),d={title:a,id:o,description:l,queryIDs:c,viz:r,layout:e},f=ul(d);try{return n.resolveComponent(r.type),i(Jn,{configure:f,children:i($C,{setVizConf:r.setConf,panel:d,data:t,variables:u,vizManager:n})})}catch(p){return console.info(v.get(p,"message")),null}}const OC=k.observer(function({data:e}){const{ref:n,width:r,height:a}=Ie.useElementSize(),o=LC(e,{w:r,h:a});return i("div",{className:"viz-root",ref:n,children:r&&a&&i(Fe,{children:o})})}),hl=k.observer(({panel:t,height:e})=>h(s.Flex,{direction:"column",sx:{height:e,position:"relative",width:"100%"},children:[i(s.LoadingOverlay,{visible:t.dataLoading,exitTransitionDuration:0}),!t.canRenderViz&&i(EC,{panel:t}),t.canRenderViz&&i(OC,{data:t.data})]})),QT="",PC=k.observer(function(){const{panel:e}=Ae(),{title:n}=e;return n?i(s.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:i(s.Text,{align:"center",lineClamp:1,weight:"bold",children:n})}):null}),BC={border:"1px solid #e9ecef"},VC={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function NC(t,e){return t.style.border.enabled?BC:e?VC:{border:"1px dashed transparent"}}const Hn=k.observer(function({panel:e,view:n}){const{inEditMode:r}=y.useContext(ft),a=e.title?"calc(100% - 25px - 5px)":"100%",o=NC(e,r);return i(wr,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors},children:h(s.Box,{className:"panel-root",p:5,pt:0,sx:{...o},children:[i(s.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:i(ll,{})}),i(MC,{view:n}),i(PC,{}),i(hl,{panel:e,height:a})]})})}),KT="",qC=y.forwardRef(({h:t},e)=>i(s.ActionIcon,{ref:e,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:t>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:i(I.ArrowsMove,{size:16})})),FC=y.forwardRef(({handleAxis:t,...e},n)=>i(s.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...e,children:i(I.ChevronDownRight,{size:16})})),GC=gn.WidthProvider(gn),WC=k.observer(({view:t,className:e="layout"})=>{const n=K(),{panels:r,layouts:a}=n.panels.panelsByIDs(t.panelIDs),o=y.useCallback(c=>{c.forEach(({i:u,...d})=>{const f=n.panels.findByID(u);f&&f.layout.set(d)})},[n]),l=(c,u,d,f)=>{d.h<30&&(d.h=30,f.h=30),d.w<4&&(d.w=4,f.w=4)};return i(GC,{onLayoutChange:o,className:`dashboard-layout ${e}`,rowHeight:1,cols:36,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,layout:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:i(FC,{}),onResize:l,children:r.map((c,u)=>h("div",{"data-grid":{...c.layout},className:"panel-grid-item",children:[i(qC,{h:c.layout.h}),i(Hn,{view:t,panel:c})]},c.id))})}),RC=gn.WidthProvider(gn),jC=k.observer(function({view:e,className:n="layout"}){const{panels:r,layouts:a}=K().panels.panelsByIDs(e.panelIDs);return i(RC,{className:`dashboard-layout ${n}`,cols:36,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,layout:a,children:r.map(o=>i("div",{"data-grid":{...o.layout},className:"panel-grid-item",children:i(Hn,{view:e,panel:o})},o.id))})}),YC=k.observer(({children:t})=>i(s.Box,{pt:10,pb:100,children:t})),QC=k.observer(({children:t,view:e})=>{const n=e.config;return i(s.Modal,{size:n.width,overflow:"inside",opened:!0,onClose:v.noop,withCloseButton:!1,title:n.custom_modal_title.value,trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},modal:{border:"1px solid #efefef"},body:{maxHeight:"calc(100vh - 325px)"}},withinPortal:!1,transitionDuration:0,children:t})}),KC=({variant:t,orientation:e})=>{const n={tab:{},panel:{padding:"16px"}};return t==="pills"&&e==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),e==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},UC=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},XC=k.observer(({children:t,view:e})=>{const n=Ke.useModals(),r=K(),a=y.useMemo(()=>r.views.options.filter(u=>u.type===H.Division),[e.id,r.views.options]),o=e.config,l=u=>n.openConfirmModal({title:"Delete this tab?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=o.tabs.length===0;return h(s.Box,{className:"preview-view-tabs",children:[h(s.Tabs,{variant:o.variant,orientation:o.orientation,defaultValue:o.tabs.length>0?o.tabs[0].id:"0",styles:KC(o),children:[h(s.Tabs.List,{grow:o.grow,children:[o.tabs.map(u=>i(s.Tabs.Tab,{value:u.id,sx:UC(u),children:u.name??u.id},u.id)),i(s.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:i(I.Plus,{size:18,color:"#228be6"})})]}),o.tabs.map((u,d)=>{const f=r.views.findByID(u.view_id);return h(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[h(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[i(s.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),h(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[i(s.TextInput,{label:"Tab Name",value:u.name,onChange:p=>u.setName(p.currentTarget.value)}),i(s.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:a}),i(s.ColorInput,{label:"Color",value:u.color,onChange:u.setColor,disabled:o.variant!=="default"}),f&&h(s.Button,{mt:20,variant:"gradient",leftIcon:i(O.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>r.views.setIDOfVIE(f.id),children:["Swith to View: ",f.name]}),i(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:i(O.IconTrash,{size:14}),children:"Delete This Tab"})]})]}),f&&i(er,{view:f})]},u.id)})]}),t]})}),JC=k.observer(({view:t,children:e})=>{switch(t.type){case H.Modal:return i(QC,{view:t,children:e});case H.Tabs:return i(XC,{view:t,children:e});case H.Division:default:return i(YC,{children:e})}}),fl=k.observer(function({view:e}){return i(_i.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:i(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:i(JC,{view:e,children:h(s.Box,{sx:{position:"relative"},children:[i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(ol,{view:e})}),i(WC,{view:e})]})})})})}),ZC={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},HC=k.observer(function({view:e,panel:n,exitFullScreen:r}){return i(s.Modal,{opened:!0,fullScreen:!0,onClose:r,title:i(s.Button,{color:"blue",size:"xs",onClick:r,leftIcon:i(I.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:ZC,children:i(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:i(Hn,{view:e,panel:n})})})});function e1(t,e,n){const{panels:r}=K(),a=t.id==="Main",[o,l]=y.useState(()=>a&&r.findByID(e)?e:null),c=y.useCallback(p=>{l(p),a&&n(p)},[a,n]),u=y.useCallback(()=>{l(null),a&&n("")},[a,n]),d=o?r.findByID(o):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const t1=k.observer(({children:t})=>i(s.Box,{children:t})),n1=k.observer(({children:t,view:e})=>{const n=K(),r=e.config,a=n.views.visibleViewIDs.includes(e.id),o=()=>n.views.rmVisibleViewID(e.id);return i(s.Modal,{size:r.width,centered:!0,overflow:"inside",opened:a,onClose:o,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:l=>{l.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:r.height,overflow:"auto"}},transitionDuration:0,children:t})}),r1=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},i1=k.observer(({children:t,view:e})=>{const n=K(),r=e.config;return h(s.Box,{className:"render-view-tabs",children:[h(s.Tabs,{variant:r.variant,orientation:r.orientation,defaultValue:r.tabs.length>0?r.tabs[0].id:"0",styles:{panel:{padding:r.orientation==="horizontal"?"16px 0px":"0"}},keepMounted:!1,children:[i(s.Tabs.List,{grow:r.grow,children:r.tabs.map(a=>i(s.Tabs.Tab,{value:a.id,sx:r1(a),disabled:!a.view_id,children:a.name??a.id},a.id))}),r.tabs.map(a=>{const o=n.views.findByID(a.view_id);return o?i(s.Tabs.Panel,{value:a.id,children:i(er,{view:o})},a.id):null})]}),t]})}),a1=k.observer(({view:t,children:e})=>{switch(t.type){case H.Modal:return i(n1,{view:t,children:e});case H.Tabs:return i(i1,{view:t,children:e});case H.Division:default:return i(t1,{children:e})}}),er=k.observer(function({view:e}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=bs(),{viewPanelInFullScreen:a,exitFullScreen:o,inFullScreen:l,fullScreenPanel:c}=e1(e,n,r);return i(_i.Provider,{value:{viewPanelInFullScreen:a,inFullScreen:l},children:h(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[l&&i(HC,{view:e,panel:c,exitFullScreen:o}),i(a1,{view:e,children:h(s.Box,{sx:{position:"relative"},children:[!l&&i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(ol,{view:e})}),!l&&i(jC,{view:e})]})})]})})});function ki(t){return y.useCallback(e=>e.provideValue(we.pluginManager,t.pluginManager).provideValue(we.vizManager,t.vizManager).provideValue(we.colorManager,t.colorManager),[])}const s1=k.observer(({headerMenuItems:t=null})=>{const e=ge(),n=K(),r=()=>{const a=JSON.stringify(n.json,null,2),o=`${e.name}__${n.name}`;kc(o,a)};return h(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:310,children:[i(s.Menu.Target,{children:i(s.ActionIcon,{variant:"light",color:"blue",children:i(O.IconMenu2,{size:14})})}),h(s.Menu.Dropdown,{children:[i(s.Menu.Item,{icon:i(O.IconDownload,{size:14}),onClick:n.queries.downloadAllData,children:"Download Data"}),i(s.Menu.Item,{icon:i(O.IconCode,{size:14}),onClick:r,children:"Download Schema"}),t]})]})}),o1=k.observer(({saveDashboardChanges:t})=>{const e=Ke.useModals(),n=K(),r=()=>{e.openConfirmModal({title:h(s.Group,{position:"left",children:[i(O.IconAlertTriangle,{size:18,color:"red"}),i(s.Text,{children:"You are reverting changes"})]}),labels:{confirm:"Confirm",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.reset(),zIndex:320,withCloseButton:!1})},a=n.changed;return h(s.Group,{spacing:0,children:[i(s.Button,{color:"green",variant:"filled",size:"xs",leftIcon:i(O.IconDeviceFloppy,{size:18}),onClick:t,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:"Save Changes"}),h(s.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[i(s.Menu.Target,{children:i(s.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:i(O.IconCaretDown,{size:18})})}),i(s.Menu.Dropdown,{children:i(s.Menu.Item,{icon:i(O.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:r,children:"Revert Changes"})})]})]})}),l1=k.observer(({saveDashboardChanges:t,headerSlot:e=null,headerMenuItems:n})=>{const r=Zl.useNavigate(),a=ge(),o=()=>{r(`/dashboard/${a.id}`)},l=Ke.useModals(),c=()=>{l.openConfirmModal({title:h(s.Group,{position:"left",children:[i(O.IconAlertTriangle,{size:18,color:"red"}),i(s.Text,{children:"There are unsaved changes"})]}),labels:{confirm:"Discard",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:o,zIndex:320,withCloseButton:!1})},u=a.content.changed;return i(s.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:h(s.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[h(s.Group,{children:[i(s.Button,{size:"xs",color:u?"red":"green",leftIcon:i(O.IconArrowLeft,{size:20}),onClick:u?c:o,children:h(s.Group,{spacing:4,children:["End Editing",i(s.Text,{td:"underline",children:a.name})]})}),i(o1,{saveDashboardChanges:t})]}),h(s.Group,{position:"right",sx:{flexGrow:1},children:[e,i(s1,{headerMenuItems:n})]})]})})}),c1={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},u1=k.observer(()=>{const t=K();return i(s.Box,{sx:c1,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:h(s.Group,{position:"apart",align:"center",sx:{height:"30px"},pr:16,children:[i(s.Button,{variant:"outline",color:"blue",radius:0,size:"xs",disabled:!t.views.VIE,onClick:()=>t.addANewPanel(t.views.idOfVIE),leftIcon:i(O.IconPlaylistAdd,{size:20}),sx:{height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef",background:"rgb(231, 245, 255)"},children:"Add a Panel"}),i(s.Box,{}),i(s.Box,{})]})})}),d1=k.observer(t=>h(q,{children:[i(l1,{...t}),i(u1,{})]})),UT="",XT="";function p1(t,e,n){const r=[];return t.filter(a=>"__INTERACTIONS"in a.viz.conf).forEach((a,o)=>{const l=e[a.id];l.data.interactions=v.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=a.viz.conf;Object.entries(u).forEach(([f,p])=>{const{schemaRef:g,data:m}=p,{config:C}=m;switch(g){case"builtin:op:open-link":let w=C.urlTemplate.substring(0,100);C.urlTemplate.length>=20&&(w+="..."),l.type="interaction",l.data.interactions.push({schemaRef:g,urlTemplate:C.urlTemplate,shortURLTemplate:w});return;case"builtin:op:open_view":r.push({id:`OPERATION--${f}`,source:a.id,target:C.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:Object.keys(C.dictionary).map(_=>({key:_,label:n[_]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:C.filter_keys.map(_=>({key:_,label:n[_]}))});return;default:return}})}),r}function h1(t,e){const n=t.filters.keyLabelMap;return{edges:p1(t.panels.list,e,n),edgeNodes:[]}}function gl(t,e,n){return t*e+t*n}function f1(t,e,n){return t*e+(t-1)*n}const tr=25,Ti=40,ml=25,Di=350,g1=150,m1=150,yl=150,bl=300,nr=40,vl=25,y1=300;function b1(t,e){const n=v.keyBy(e,a=>a.id),r=[];return t.current.forEach((a,o)=>{a.panelIDs.forEach((l,c)=>{const u=gl(c,nr,vl)+Ti,d=n[l];if(!d){r.push({id:l,_node_type:"panel",parentNode:a.id,data:{label:`!: ${l}`},position:{x:tr,y:u},sourcePosition:Me.Position.Right,targetPosition:Me.Position.Left,style:{width:bl,height:nr}});return}const f=d.title.trim()?`${d.title}`:d.viz.type;r.push({id:d.id,_node_type:"panel",parentNode:a.id,data:{label:f},position:{x:tr,y:u},sourcePosition:Me.Position.Right,targetPosition:Me.Position.Left,style:{width:bl,height:nr}})})}),r}const v1={[H.Division]:"Div",[H.Modal]:"Modal",[H.Tabs]:"Tabs"},x1=Ko;function w1(t){return t.current.map((n,r)=>{const a=f1(n.panelIDs.length,nr,vl)+Ti+ml;let o=[];return n.type===H.Tabs&&(o=n.config.tabs.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${v1[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Me.Position.Right,targetPosition:Me.Position.Left,className:"light",style:{backgroundColor:x1[n.type],width:Di,height:a}}})}function C1(t){const e=v.keyBy(t,n=>n.id);t.forEach(n=>{n._node_type!=="view-root"||n._view_type!==H.Tabs||n._tab_view_ids.forEach(r=>{e[r].parentNode=n.id})})}function S1(t){const e=w1(t.views);C1(e);const n=b1(t.views,t.panels.list);return[...e,...n]}function _1({nodeMap:t,nodes:e,edges:n}){e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==H.Tabs||(r.sourcePosition=Me.Position.Bottom,r.style.width=Di+tr*2,r.style.height=ml+r._tab_view_ids.reduce((a,o)=>{const l=t[o];l.position.y=a,l.position.x=tr;const c=l.style.height;return a+c+20},Ti))})}function k1({nodeMap:t,nodes:e,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const a=t[r.source],o=t[r.target];if(!a||!o||!a.parentNode)return;const l=t[a.parentNode];l._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+l._view_level,l._sub_view_ids.push(o.id))}),e.sort((r,a)=>r._node_type==="view-root"&&a._node_type==="view-root"?r._view_level-a._view_level:r._node_type!=="view-root"&&a._node_type!=="view-root"?0:r._node_type==="view-root"?-1:1)}function T1({nodeMap:t,nodes:e,edges:n}){const r={};n.forEach(a=>{if(a.label!=="Open View")return;const o=t[a.source],l=t[a.target];if(o&&l&&o.parentNode){const c=t[o.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),f=Number(c.style.width);l.position.x=u+f+y1,c._view_level===0&&l._sub_view_ids.length===0&&(o.sourcePosition=Me.Position.Left,l.targetPosition=Me.Position.Right,l.position.x*=-1);const g=l.position.x,m=v.get(r,g,0);l.position.y=m,r[g]=m+d+yl}})}function D1({nodeMap:t,nodes:e,edges:n}){const r=new Set,a=new Set;n.forEach(l=>{r.add(l.source),a.add(l.target)}),e.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!r.has(l.id)&&!a.has(l.id)).forEach((l,c)=>{l.position.x=gl(c,Di,m1),l.position.y=0-g1-yl})}function I1({nodeMap:t,nodes:e,edges:n}){const r={nodeMap:t,nodes:e,edges:n};return D1(r),k1(r),_1(r),T1(r),{nodes:e,edges:n}}function M1(t){const e=S1(t),n=v.keyBy(e,u=>u.id),{edges:r,edgeNodes:a}=h1(t,n),o=[...e,...a],l=v.keyBy(o,u=>u.id),c={edges:v.uniqBy(r,u=>u.id),nodes:o,nodeMap:l};return I1(c)}const JT="",Ii={"builtin:op:open-link":i(s.ThemeIcon,{color:"blue",size:20,radius:"xl",children:i(O.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":i(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:i(O.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":i(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:i(O.IconCircleOff,{size:14})})};function E1(t){const e=[];return t.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":e.push({key:n.urlTemplate,icon:Ii[n.schemaRef],text:h(s.Group,{spacing:4,children:[i(s.Text,{children:"Open: "}),i(s.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:a})=>{e.push({key:n.schemaRef+r,icon:Ii[n.schemaRef],text:i(s.Group,{spacing:4,children:h(s.Text,{children:["Set Filter: ",a]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:a})=>{e.push({key:n.schemaRef+r,icon:Ii[n.schemaRef],text:i(s.Group,{spacing:4,children:h(s.Text,{children:["Clear Filter: ",a]})})})});return}}),e}const A1=y.memo(({data:t,isConnectable:e,sourcePosition:n=Me.Position.Right,targetPosition:r=Me.Position.Left,...a})=>{const o=y.useMemo(()=>E1(t.interactions),[t.interactions]);return h(q,{children:[i(Me.Handle,{type:"target",position:r,isConnectable:e}),i(s.Box,{sx:{position:"absolute",top:0,right:0},children:i(I.ChevronsUpRight,{size:12})}),h(s.HoverCard,{shadow:"xl",withinPortal:!0,children:[i(s.HoverCard.Target,{children:i(s.Text,{children:t.label})}),i(s.HoverCard.Dropdown,{children:i(s.List,{spacing:"xs",size:"sm",center:!0,children:o.map(l=>i(s.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),i(Me.Handle,{type:"source",position:n,isConnectable:e})]})}),ZT="",z1={interaction:A1},$1=k.observer(()=>{const t=K(),{edges:e,nodes:n}=M1(t);return h(Me,{nodes:n,edges:e,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:z1,children:[i(Me.MiniMap,{}),i(Me.Controls,{}),i(Me.Background,{})]})}),L1=k.observer(({opened:t,close:e})=>{const{freezeLayout:n}=y.useContext(ft);return y.useEffect(()=>{n(t)},[t]),i(s.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:e,title:"Interactions",trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"90vh"},modal:{transform:"none !important"}},zIndex:300,children:i($1,{})})}),O1={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function P1({onClick:t,name:e,active:n,openSettings:r}){return h(s.Box,{sx:{position:"relative"},children:[i(s.UnstyledButton,{sx:a=>({display:"block",width:"100%",padding:a.spacing.xs,borderRadius:0,position:"relative",color:a.black,"&:hover":{backgroundColor:a.colors.gray[0]},backgroundColor:n?a.colors.gray[2]:"transparent"}),children:i(s.Group,{sx:{width:"calc(100% - 28px)"},onClick:t,children:i(s.Text,{size:"sm",children:e})})}),n&&i(s.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:i(s.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:i(O.IconAdjustments,{size:16})})})]})}const B1=k.observer(()=>{const t=ge(),e=K(),n=y.useCallback(a=>()=>e.views.setIDOfVIE(a),[e]),r=a=>{t.editor.open(["_VIEWS_",a])};return h(s.Box,{sx:{position:"relative"},children:[e.views.options.map(a=>i(P1,{active:e.views.idOfVIE===a.value,name:a.label,onClick:n(a.value),openSettings:()=>r(a.value)},a.value)),i(s.Divider,{variant:"dashed"}),i(s.Button,{variant:"subtle",rightIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:"Add a View"})]})}),V1=k.observer(()=>{const t=ge(),e=K(),n=()=>{if(!e.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",e.queries.firstID])},r=()=>{if(!e.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",e.filters.firstID])},[a,o]=y.useState(!1),l=()=>o(!0),c=()=>o(!1);return h(s.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[h(s.Navbar.Section,{children:[h(s.Group,{grow:!0,spacing:0,sx:{...O1,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[i(s.Tooltip,{label:"Filters",withinPortal:!0,children:i(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:r,children:i(O.IconFilter,{size:20})})}),i(s.Tooltip,{label:"Queries",withinPortal:!0,children:i(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:n,children:i(O.IconDatabase,{size:20})})}),i(s.Tooltip,{label:"Interactions Viewer",withinPortal:!0,children:i(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:l,children:i(O.IconLink,{size:20})})})]}),i(L1,{opened:a,close:c})]}),i(s.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:i(s.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Views"})}),i(s.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:i(B1,{})}),i(s.Navbar.Section,{children:i(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:i(s.Button,{size:"xs",leftIcon:i(O.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:"Settings"})})})]})}),N1=k.observer(function({config:e}){return h(q,{children:[i(s.Checkbox,{checked:e.default_value,onChange:n=>e.setDefaultValue(n.currentTarget.checked),label:"Default Checked"}),i(ri,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),q1=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],F1=k.observer(function({config:e}){return h(q,{children:[h(s.Group,{children:[i(s.Checkbox,{checked:e.required,onChange:n=>e.setRequired(n.currentTarget.checked),label:"Required"}),i(s.Checkbox,{checked:e.clearable,onChange:n=>e.setClearable(n.currentTarget.checked),disabled:e.max_days>0,label:"Clearable"}),i(s.Checkbox,{checked:e.allowSingleDateInRange,onChange:n=>e.setAllowSingleDateInRange(n.currentTarget.checked),label:"Allow choosing 1 day"})]}),i(s.Select,{data:q1,label:"Display Format",value:e.inputFormat,onChange:e.setInputFormat}),i(il,{label:"Default Value",config:e,value:e.default_value,onChange:e.setDefaultValue}),i(s.NumberInput,{label:"Max Days",description:h(s.Group,{position:"apart",children:[i(s.Text,{children:"Set 0 to disable."}),h(s.Group,{spacing:4,children:[i(s.Text,{children:"This feature requires"}),i(s.Text,{color:"blue",children:"Clearable"}),i(s.Text,{children:"to be checked"})]})]}),min:0,value:e.max_days,onChange:e.setMaxDays,hideControls:!0})]})}),Mi=k.observer(({value:t,onChange:e})=>{const n=K(),r=y.useMemo(()=>n.queries.options,[n.queries.current]),a=r.length===0;return i(s.Select,{label:"Pick a query",data:r,value:t,onChange:e,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:a,error:a?"You need to add a query in Data Settings":void 0})}),G1=`
480
+ `)},rC=b.types.model("CustomModalTitleModel",{enabled:b.types.optional(b.types.boolean,!1),func_content:b.types.optional(b.types.string,"")}).views(t=>({get json(){const{enabled:e,func_content:n}=t;return{enabled:e,func_content:n}},get value(){const{enabled:e,func_content:n}=t,r=b.getParent(t,2),a=b.getRoot(t);if(!e)return r.name;try{const o={filters:a.content.filters.values,context:a.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(t=>({setEnabled(e){t.enabled=e},setFuncContent(e){t.func_content=e},replace({enabled:e,func_content:n}){t.enabled=e,t.func_content=n}})),Xo=b.types.model("ViewModel_Modal",{_name:b.types.literal(H.Modal),width:b.types.string,height:b.types.string,custom_modal_title:b.types.optional(rC,xi)}).views(t=>({get json(){const{_name:e,width:n,height:r,custom_modal_title:a}=t;return{_name:e,width:n,height:r,custom_modal_title:a.json}}})).actions(t=>({setWidth(e){t.width=e},setHeight(e){t.height=e}})),iC=()=>Xo.create({_name:H.Modal,width:"90vw",height:"90vh"}),aC=b.types.model("ViewModel_Tabs_Tab",{id:b.types.identifier,name:b.types.string,view_id:b.types.string,color:b.types.optional(b.types.string,"")}).views(t=>({get json(){const{id:e,name:n,view_id:r,color:a}=t;return{id:e,name:n,color:a,view_id:r}}})).actions(t=>({setName(e){t.name=e},setViewID(e){t.view_id=e},setColor(e){t.color=e}})),Jo=b.types.model("ViewModel_Tabs",{_name:b.types.literal(H.Modal),tabs:b.types.optional(b.types.array(aC),[]),variant:b.types.optional(b.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:b.types.optional(b.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:b.types.optional(b.types.boolean,!1)}).views(t=>({get json(){const{_name:e,variant:n,orientation:r,tabs:a,grow:o}=t;return{grow:o,tabs:a.map(l=>l.json),_name:e,variant:n,orientation:r}}})).actions(t=>({setVariant(e){t.variant=e},setOrientation(e){t.orientation=e},setGrow(e){t.grow=e},setTabs(e){t.tabs.length=0,t.tabs=b.cast(e)},addTab(){const e=Ie.randomId(),n={id:e,name:e,view_id:""};t.tabs.push(n)},removeTab(e){t.tabs.splice(e,1)}})),sC=()=>Jo.create({_name:H.Modal,tabs:[]}),Zo=b.types.model({id:b.types.identifier,name:b.types.string,type:b.types.enumeration("EViewComponentType",[H.Division,H.Modal,H.Tabs]),config:b.types.union(Uo,Xo,Jo),panelIDs:b.types.optional(b.types.array(b.types.string),[])}).views(t=>({get json(){const{id:e,name:n,type:r,config:a}=t;return{id:e,name:n,type:r,config:a.json,panelIDs:t.panelIDs}}})).actions(t=>({setName(e){t.name=e},setType(e){if(t.type!==e){switch(e){case H.Division:t.config=nC();break;case H.Modal:t.config=iC();break;case H.Tabs:t.config=sC();break}t.type=e}},appendPanelID(e){t.panelIDs.push(e)},removePanelID(e){const n=t.panelIDs.filter(r=>r!==e);t.panelIDs.length=0,t.panelIDs.push(...n)}})).actions(t=>({})),Ho=b.types.model("ViewsModel",{current:b.types.optional(b.types.array(Zo),[]),visibleViewIDs:b.types.array(b.types.string),idOfVIE:b.types.string}).views(t=>({get json(){return t.current.map(e=>bn(e.json))},get idMap(){const e=new Map;return t.current.forEach(n=>{e.set(n.id,n)}),e},findByID(e){return t.current.find(n=>n.id===e)},get isVIETheFirstView(){return t.current.length===0||!t.idOfVIE?!1:t.current[0].id===t.idOfVIE},get firstVisibleView(){const[e]=t.visibleViewIDs;return t.current.find(({id:n})=>n===e)},get visibleViews(){const e=new Set(t.visibleViewIDs);return t.current.filter(({id:n})=>e.has(n))},get VIE(){return t.current.find(({id:e})=>e===t.idOfVIE)},get options(){return t.current.map(e=>({label:e.name,value:e.id,type:e.type}))},get editorOptions(){const e=b.getRoot(t).content.panels;return t.current.map(n=>({label:n.name,value:n.id,_type:"view",children:e.editorOptions(n.id,n.panelIDs)}))}})).actions(t=>({replace(e){t.current.replace(e)},addANewView(e,n,r,a){t.current.push({id:e,name:n,type:r,config:a,panelIDs:[]})},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},removeByID(e){const n=t.current.findIndex(r=>r.id===e);n!==-1&&t.current.splice(n,1)},replaceByIndex(e,n){t.current.splice(e,1,n)},setIDOfVIE(e){t.idOfVIE=e,t.visibleViewIDs.length=0,t.visibleViewIDs.push(e)},appendToVisibles(e){new Set(t.visibleViewIDs.map(r=>r)).has(e)||t.visibleViewIDs.push(e)}})).actions(t=>({addARandomNewView(){const e=new Date().getTime().toString();t.addANewView(e,H.Division,H.Division,{_name:H.Division}),t.setIDOfVIE(e)},removeVIE(){t.current.length!==1&&(t.removeByID(t.idOfVIE),t.setIDOfVIE(t.current[0].id))},rmVisibleViewID(e){const n=t.visibleViewIDs.findIndex(r=>r===e);n!==-1&&t.visibleViewIDs.splice(n,1)}}));function wi(t){const e=t.length>0?[t[0].id]:[],n=t.length>0?t[0].id:"";return{current:t.map(a=>{const{_name:o=a.type}=a.config;return{...a,config:{...a.config,_name:o},panelIDs:a.panelIDs}}),visibleViewIDs:e,idOfVIE:n}}function el(t,e,n,r){return t.reduce((a,o)=>(a[o[e]]=ur(o[n],r),a),{})}const oC=b.types.model({id:b.types.string,name:b.types.string,dashboard_id:b.types.string,create_time:b.types.string,update_time:b.types.string,version:b.types.string,filters:ts,queries:ls,sqlSnippets:us,views:Ho,panels:Yo,mock_context:qc,origin:b.types.maybe(b.types.frozen())}).views(t=>({get json(){return{id:t.id,name:t.name,create_time:t.create_time,update_time:t.update_time,dashboard_id:t.dashboard_id,content:{views:t.views.json,panels:t.panels.json,filters:t.filters.json,version:t.version,definition:{queries:t.queries.json,sqlSnippets:t.sqlSnippets.json,mock_context:t.mock_context.current}}}},get filtersChanged(){const e="filters.current";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get queriesChanged(){const e="queries.current",n=b.getSnapshot(v.get(t,e)).map(r=>v.pick(r,["id","name","key","type","sql","run_by","react_to","pre_process","post_process"]));return!v.isEqual(n,v.get(t.origin,e))},get sqlSnippetsChanged(){const e="sqlSnippets.current";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get viewsChanged(){const e="views.current";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get panelsChanged(){const e="panels.list";return!v.isEqual(b.getSnapshot(v.get(t,e)),v.get(t.origin,e))},get mockContextChanged(){const e="mock_context.current";return!v.isEqual(v.get(t,e),v.get(t.origin,e))},get payloadForSQL(){const e=b.getParent(t).context.current,n=b.getParent(t).globalSQLSnippets,r={context:{...t.mock_context.current,...e},filters:t.filters.values};return{...r,sql_snippets:el(t.sqlSnippets.current,"key","value",r),global_sql_snippets:el(n.list,"id","content",r)}},get payloadForViz(){const e=b.getParent(t).context.current;return{context:{...t.mock_context.current,...e},filters:t.filters.values}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.mockContextChanged},get data(){return t.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(e){const n=t.queries.findByID(e);return n?{data:n.data.toJSON(),len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(t=>({findQueryUsage(e){const n=t.panels.idMap,r=t.views.current.flatMap(l=>l.panelIDs.map(c=>n.get(c)).filter(c=>(c==null?void 0:c.queryIDSet.has(e))??!1).map(c=>({type:"panel",id:c.id,label:c.title?c.title:c.viz.type,views:[{id:l.id,label:l.name}]}))),a=t.views.idMap,o=t.filters.current.filter(l=>v.get(l,"config.options_query_id")===e).map(l=>({type:"filter",id:l.id,label:l.label,views:l.visibleInViewsIDs.map(c=>{var u;return{id:c,label:((u=a.get(c))==null?void 0:u.name)??c}})}));return r.concat(o)}})).actions(t=>({duplicatePanelByID(e,n){var a;const r=t.panels.duplicateByID(e);r&&((a=t.views.findByID(n))==null||a.appendPanelID(r))},removePanelByID(e,n){var r;t.panels.removeByID(e),(r=t.views.findByID(n))==null||r.removePanelID(e)},addANewPanel(e){var r;const n=new Date().getTime().toString();t.panels.append(jo(n)),(r=t.views.findByID(e))==null||r.appendPanelID(n)}})).actions(t=>({reset(){b.applySnapshot(t.filters.current,t.origin.filters.current),b.applySnapshot(t.queries.current,t.origin.queries.current),b.applySnapshot(t.sqlSnippets.current,t.origin.sqlSnippets.current),b.applySnapshot(t.views.current,t.origin.views.current),b.applySnapshot(t.panels.list,t.origin.panels.list),t.mock_context.current=t.origin.mock_context.current},resetFilters(){b.applySnapshot(t.filters.current,t.origin.filters.current)},updateCurrent(e){const{id:n,name:r,content:a}=e;if(!a)throw new Error("unexpected null content when updating a content model");const{version:o,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:f,mock_context:p={}}}=a;t.id=n,t.name=r,t.version=o,b.applySnapshot(t.filters.current,l),b.applySnapshot(t.views.current,wi(c).current),b.applySnapshot(t.panels.list,u),b.applySnapshot(t.queries.current,d),b.applySnapshot(t.sqlSnippets.current,f),t.mock_context.current=p}})),Xn=b.types.snapshotProcessor(oC,{preProcessor(t){return{...t,origin:t}},postProcessor(t){delete t.origin;const e=b.castToSnapshot(t.queries.current.map(n=>v.pick(n,["id","key","type","sql"])));return v.defaults({},{queries:{current:e}},t)}});function lC(t,e){e.filters&&b.applySnapshot(t.filters.current,e.filters)}function tl({id:t,name:e,dashboard_id:n,create_time:r,update_time:a,content:o}){if(!o)throw new Error("unexpected null content when creating a content model");const{version:l,filters:c,views:u,panels:d,definition:{queries:f,sqlSnippets:p,mock_context:g={}}}=o;return Xn.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:a,version:l,filters:ns(c),queries:{current:f},sqlSnippets:{current:p},mock_context:{current:g},views:wi(u),panels:{list:d}})}const cC=b.types.model({id:b.types.string,content:b.types.string,create_time:b.types.string,update_time:b.types.string,is_preset:b.types.boolean}),uC=b.types.model("GlobalSQLSnippetsModel",{list:b.types.optional(b.types.array(cC),[])}).views(t=>({find(e){return t.list.find(n=>n.id===e)},get options(){return t.list.map(e=>({value:e.id,label:e.id}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}})),nl=b.types.model({id:b.types.identifier,name:b.types.string,group:b.types.string,content:Xn,content_id:b.types.string,datasources:Bc,globalSQLSnippets:uC,context:ds,editor:Nc}).views(t=>({get json(){return{id:t.id,name:t.name,group:t.group,content_id:t.content_id}}})).actions(t=>({updateCurrentContent(e){t.content.updateCurrent(e)},updateCurrent(e,n){const{id:r,name:a,group:o,content_id:l}=e;t.id=r,t.name=a,t.group=o,t.content_id=l,this.updateCurrentContent(n)}}));function Ci({id:t,name:e,group:n,content_id:r},a,o,l,c){return nl.create({id:t,name:e,group:n,content_id:r,content:tl(a),datasources:{list:o},globalSQLSnippets:{list:l},context:{current:c},editor:{}})}const Si=y.createContext(null);function Jn(t){const e=y.useContext(Si),n=J.useCreation(()=>t.configure(e||new vr),[t.configure]),r=J.usePrevious(n);return r&&r!==n&&r.dispose(),i(Si.Provider,{value:n,children:t.children})}function rl(){return y.useContext(Si)}const dC={viewPanelInFullScreen:v.noop,inFullScreen:!1},_i=y.createContext(dC),pC=({description:t,isDescriptionEmpty:e})=>e?null:i(s.Tooltip,{color:"white",label:i(Yn,{value:t,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:i(s.Box,{sx:{height:"16px",alignSelf:"center"},children:i(O.IconInfoCircle,{size:16,color:"gray"})})}),hC=k.observer(({label:t,config:{default_value:e,description:n,isDescriptionEmpty:r,...a},value:o,onChange:l})=>h(s.Box,{children:[i(s.Text,{children:" "}),i(s.Checkbox,{label:h(s.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[i(s.Box,{sx:{flexGrow:1},children:t}),i(pC,{description:n,isDescriptionEmpty:r})]}),checked:o||!1,onChange:c=>l(c.currentTarget.checked),...a,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),il=k.observer(({label:t,config:e,value:n=[null,null],onChange:r})=>{const a=Array.isArray(n)?n.map(u=>u?Y(u).toDate():null):[null,null],o=u=>{r(u.map(d=>d&&Y(d).format(e.inputFormat)))},l=e.getMinDate(a[0]),c=e.getMaxDate(a[0]);return i(Jl.DateRangePicker,{label:t,value:a,onChange:o,icon:i(I.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:l,maxDate:c,styles:{input:{borderColor:"#e9ecef"}},...e})}),fC=s.createStyles((t,{radius:e=4})=>({root:{borderRadius:t.fn.radius(e),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-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-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-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-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-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-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:t.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:t.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,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-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{flexGrow:1}}}})),al=({errorMessage:t})=>t?i(s.Text,{color:"red",size:12,children:t}):i(s.Text,{color:"dimmed",size:12,children:"Not found"}),gC=({disabled:t,classNames:e,styles:n,unstyled:r,radius:a,style:o,label:l,value:c,onChange:u,options:d,errorMessage:f})=>{const{classes:p,cx:g}=fC({radius:a},{name:"MultiSelectWidget",classNames:e,styles:n,unstyled:r}),[m,C]=y.useState(!1),w=B=>{C(B)},_=m&&(c==null?void 0:c.length)>0,[T,M]=y.useState(""),L=y.useMemo(()=>{if(!T)return d;const B=T.toLowerCase(),F=$=>{var E;return((E=$.description)==null?void 0:E.toLowerCase().includes(B))||$.label.toLowerCase().includes(B)};return d.filter(F)},[T,d]);return h(s.Stack,{spacing:3,children:[h(s.Group,{position:"apart",children:[i(s.Text,{className:p.label,children:l}),_&&i(s.Tooltip,{label:`${c.length} selected`,children:i(s.Badge,{children:c.length})})]}),i(Ba,{disabled:t,allowClear:!0,className:g(p.root,"check-select"),dropdownClassName:g(p.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>i(s.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:i(al,{errorMessage:f}),maxTagTextLength:10,maxTagPlaceholder:B=>`${B.length} selected`,searchValue:T,onSearch:M,filterOption:!1,children:L.map(B=>i(Ba.Option,{children:i(s.Group,{noWrap:!0,children:h("div",{children:[i(s.Text,{size:"sm","data-role":"label",children:B.label}),B.description&&i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:B.description})]})})},B.value))})]})},mC=k.observer(({label:t,config:e,value:n,onChange:r})=>{const a=K(),o=!!e.options_query_id,{state:l,error:c}=a.getDataStuffByID(e.options_query_id),u=l==="loading",d=e.min_width?e.min_width:"200px",f=o?u:!1,p=g=>r(g,!1);return i(gC,{label:t,options:e.options,style:{minWidth:"160px",width:d,maxWidth:f?d:"unset",borderColor:"#e9ecef"},disabled:f,value:n,onChange:p,errorMessage:c})}),yC=y.forwardRef(({label:t,description:e,...n},r)=>i("div",{ref:r,...n,children:i(s.Group,{noWrap:!0,children:h("div",{children:[i(s.Text,{size:"sm","data-role":"label",children:t}),i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:e})]})})})),bC=k.observer(({label:t,config:e,value:n,onChange:r})=>{const a=K(),o=!!e.options_query_id,{state:l,error:c}=a.getDataStuffByID(e.options_query_id),u=l==="loading";return y.useEffect(()=>{var p;const{default_selection_count:d}=e;if(!d)return;const f=((p=e.options[0])==null?void 0:p.value)??"";console.log("Selecting the first option by default. New value: ",f),r(f,!0)},[e.default_selection_count,e.options]),i(s.Select,{label:t,data:e.options,disabled:o?u:!1,value:n,onChange:r,error:!!c,placeholder:c,maxDropdownHeight:500,styles:{root:{width:e.width?e.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:yC})});function vC({label:t,config:e,value:n,onChange:r}){return i(s.TextInput,{label:t,value:n||"",onChange:a=>r(a.currentTarget.value),...e,styles:{input:{borderColor:"#e9ecef"}}})}const xC=({rotate:t,onClick:e})=>i("svg",{onClick:e,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(${t})`,children:i("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"})}),wC=({expanded:t,isLeaf:e,value:n,onClick:r,...a})=>(n==="0-0-value"&&console.log(a),e?i("span",{style:{width:"14px",display:"inline-block"}}):i(xC,{rotate:t?"0":"-90",onClick:r,...a})),CC=({onClick:t})=>h("svg",{onClick:t,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),i("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),i("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),i("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),SC=({onClick:t,...e})=>i(CC,{onClick:t,...e}),_C=s.createStyles((t,{radius:e=4})=>({root:{borderRadius:t.fn.radius(e),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:t.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:t.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"}}}})),kC=({disabled:t,classNames:e,styles:n,unstyled:r,radius:a,style:o,label:l,value:c,onChange:u,treeData:d,errorMessage:f})=>{const{classes:p,cx:g}=_C({radius:a},{name:"FilterTreeSelectWidget",classNames:e,styles:n,unstyled:r}),[m,C]=y.useState(!1),w=T=>{C(T)},_=m&&(c==null?void 0:c.length)>0;return h(s.Stack,{spacing:3,children:[h(s.Group,{position:"apart",children:[i(s.Text,{className:p.label,children:l}),_&&i(s.Tooltip,{label:`${c.length} selected`,children:i(s.Badge,{children:c.length})})]}),i(Va,{disabled:t,allowClear:!0,className:g(p.root,"check-select"),dropdownClassName:g(p.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>i(s.CloseButton,{}),switcherIcon:wC,treeIcon:SC,maxTagTextLength:10,value:c,treeData:d,notFoundContent:i(al,{errorMessage:f}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Va.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:T=>`${T.length} selected`})]})},TC=k.observer(({label:t,config:e,value:n,onChange:r})=>{const{treeData:a,treeDataLoading:o,errorMessage:l}=e,c=e.min_width?e.min_width:"200px",d=!!e.options_query_id?o:!1;return i(kC,{disabled:d,style:{minWidth:"160px",width:c,maxWidth:d?c:"unset",borderColor:"#e9ecef"},value:n,onChange:f=>r(f,!1),treeData:a,errorMessage:l,label:t})}),DC=k.observer(({filter:{type:t,config:e,key:n,...r},formFieldProps:a})=>{switch(t){case"select":return i(bC,{...r,...a,config:e});case"multi-select":return i(mC,{...r,...a,config:e});case"tree-select":return i(TC,{...r,...a,config:e});case"text-input":return i(vC,{...r,...a,config:e});case"date-range":return i(il,{...r,...a,config:e});case"checkbox":return i(hC,{...r,...a,config:e});default:return null}}),sl=k.observer(y.forwardRef(({filter:t,...e},n)=>i("div",{className:"filter-root",ref:n,children:i(Fe,{children:i(DC,{filter:t,formFieldProps:e})})}))),ol=k.observer(function({view:e}){const n=K(),{control:r,handleSubmit:a,reset:o}=x.useForm({defaultValues:n.filters.values,reValidateMode:"onBlur"}),l=x.useWatch({control:r});y.useEffect(()=>{o(n.filters.values)},[n.filters.values,o]),y.useEffect(()=>{n.filters.updatePreviewValues(l)},[l]);const c=n.filters.visibleInView(e.id),u=y.useMemo(()=>c.every(g=>g.should_auto_submit),[c]),d=y.useMemo(()=>c.filter(g=>v.get(g,"config.required",!1)),[c]),f=y.useMemo(()=>d.length===0?!1:d.some(g=>!g.requiredAndPass(l[g.key])),[l,d]);if(c.length===0)return null;const p=(g,m)=>(C,w)=>{m(C),(g.should_auto_submit||w)&&n.filters.setValueByKey(g.key,C)};return i("form",{onSubmit:a(n.filters.setValues),children:h(s.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:u?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[i(s.Group,{align:"flex-start",children:c.map(g=>i(x.Controller,{name:g.key,control:r,render:({field:m})=>i(sl,{filter:g,value:m.value,onChange:p(g,m.onChange)})},g.id))}),!u&&i(s.Group,{sx:{alignSelf:"flex-end"},children:i(s.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),YT="";function IC(t){return t?["<p><br></p>","<p></p>"].includes(t):!0}const ll=k.observer(()=>{const{freezeLayout:t}=y.useContext(ft),[e,n]=y.useState(!1),{panel:r}=Ae();return y.useEffect(()=>{t(e)},[e]),IC(r.description)?null:h(q,{children:[i(s.Modal,{opened:e,onClose:()=>n(!1),title:r.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:i(Yn,{value:r.description,styles:{root:{border:"none"},content:{padding:0}}})}),i(s.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(a=>!a),sx:{verticalAlign:"baseline",cursor:"pointer"},children:i(I.InfoCircle,{size:20})})})]})}),MC=k.observer(({view:t})=>{const e=ge(),n=K(),r=Ke.useModals(),{panel:a}=Ae(),{id:o}=a,{inEditMode:l}=y.useContext(ft),{viewPanelInFullScreen:c,inFullScreen:u}=y.useContext(_i),d=()=>{n.duplicatePanelByID(o,t.id)},f=()=>{e.editor.open(["_VIEWS_",t.id,"_PANELS_",o])},p=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.removePanelByID(o,t.id),confirmProps:{color:"red"},zIndex:320}),g=y.useCallback(()=>{c(o)},[o,c]),m=!u&&t.type!==H.Modal;return i(q,{children:i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:h(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),h(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:a.refreshData,icon:i(I.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:a.downloadData,icon:i(I.Download,{size:14}),children:"Download Data"}),m&&i(s.Menu.Item,{onClick:g,icon:i(I.ArrowsMaximize,{size:14}),disabled:l,children:"Full Screen"}),l&&h(q,{children:[i(s.Divider,{label:"Edit",labelPosition:"center"}),i(s.Menu.Item,{onClick:f,icon:i(I.Settings,{size:14}),children:"Settings"}),i(s.Menu.Item,{onClick:d,icon:i(I.Copy,{size:14}),children:"Duplicate"}),i(s.Menu.Item,{color:"red",onClick:p,icon:i(I.Trash,{size:14}),children:"Delete"})]})]})]})})})}),EC=k.observer(({panel:t})=>h(s.Stack,{children:[t.queryErrors.map((e,n)=>i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e},`${n}-${e}`)),t.queryStateMessages.map((e,n)=>i(s.Text,{color:"gray",align:"center",children:e},`${n}-${e}`))]}));var cl=(t=>(t.migrated="migrated",t.nothingToMigrate="nothingToMigrate",t.checkFailed="checkFailed",t.migrationFailed="migrationFailed",t))(cl||{}),Zn=(t=>(t.notStarted="notStarted",t.inProgress="inProgress",t.done="done",t))(Zn||{});class AC{constructor(e){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=e.getRequired(we.instanceScope.panelModel),this.vizInstance=e.getRequired(we.instanceScope.vizInstance),this.operationManager=e.getRequired(we.instanceScope.operationManager),this.triggerManager=e.getRequired(we.instanceScope.triggerManager),this.vizManager=e.getRequired(we.vizManager)}async createMigrationTask(){const e=[];try{await this.instanceNeedMigration()&&e.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&e.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(e.length===0)return"nothingToMigrate";try{return await Promise.all(e.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(e=>(this.status="done",e))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await e.migrator.migrate(n)}async instanceNeedMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return e.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function ul(t){const{panel:e}=Ae();return y.useCallback(n=>{const r=n.getRequired(we.vizManager),a=r.resolveComponent(t.viz.type);return n.createScoped().provideFactory(we.instanceScope.vizInstance,()=>r.getOrCreateInstance(t)).provideFactory(we.instanceScope.interactionManager,o=>{const l=o.getRequired(we.instanceScope.vizInstance);return new gi(l,a,Un)}).provideFactory(we.instanceScope.operationManager,o=>o.getRequired(we.instanceScope.interactionManager).operationManager).provideFactory(we.instanceScope.triggerManager,o=>o.getRequired(we.instanceScope.interactionManager).triggerManager).provideValue(we.instanceScope.panelModel,e).provideFactory(we.instanceScope.migrator,o=>new AC(o))},[t.viz.type,t.viz.conf])}function dl(t){const[e,n]=y.useState(!1),r=rl().getRequired(we.instanceScope.migrator);return J.useAsyncEffect(async()=>{const a=r.status===Zn.notStarted;n(r.status===Zn.done),r.status===Zn.notStarted&&r.runMigration().then(o=>{o===cl.migrated&&a&&(t==null||t())}).finally(()=>{n(!0)})},[r]),e}function pl(t,e){const n=rl().getRequired(we.instanceScope.vizInstance);return y.useEffect(()=>(n.instanceData.setItem(null,e.viz.conf),n.instanceData.watchItem(null,r=>{t(r)})),[t,e.viz.type]),n}function zC({setVizConf:t,...e}){const{panel:n}=e,r=pl(t,n),a=dl(()=>{fn.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return J.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),a?i(Kc,{...e}):i(s.Text,{children:"Checking update..."})}function $C(t){const{panel:e,setVizConf:n}=t;pl(n,e);const{inEditMode:r}=y.useContext(ft);return dl(()=>{r&&fn.showNotification({title:`${e.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?i(Qc,{...t}):i(s.Text,{children:"Checking update"})}const QT="";function LC(t,e){const{vizManager:n}=y.useContext(it),{panel:{viz:r,title:a,id:o,description:l,queryIDs:c,variables:u}}=Ae(),d={title:a,id:o,description:l,queryIDs:c,viz:r,layout:e},f=ul(d);try{return n.resolveComponent(r.type),i(Jn,{configure:f,children:i($C,{setVizConf:r.setConf,panel:d,data:t,variables:u,vizManager:n})})}catch(p){return console.info(v.get(p,"message")),null}}const OC=k.observer(function({data:e}){const{ref:n,width:r,height:a}=Ie.useElementSize(),o=LC(e,{w:r,h:a});return i("div",{className:"viz-root",ref:n,children:r&&a&&i(Fe,{children:o})})}),hl=k.observer(({panel:t,height:e})=>h(s.Flex,{direction:"column",sx:{height:e,position:"relative",width:"100%"},children:[i(s.LoadingOverlay,{visible:t.dataLoading,exitTransitionDuration:0}),!t.canRenderViz&&i(EC,{panel:t}),t.canRenderViz&&i(OC,{data:t.data})]})),KT="",PC=k.observer(function(){const{panel:e}=Ae(),{title:n}=e;return n?i(s.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:i(s.Text,{align:"center",lineClamp:1,weight:"bold",children:n})}):null});function BC(t){return!["richText","button"].includes(t)}const VC={border:"1px solid #e9ecef"},NC={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function qC(t,e){return t.style.border.enabled?VC:e?NC:{border:"1px dashed transparent"}}const Hn=k.observer(function({panel:e,view:n}){const{inEditMode:r}=y.useContext(ft),a=e.title?"calc(100% - 25px - 5px)":"100%",o=qC(e,r),c=BC(e.viz.type)||r;return i(wr,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors},children:h(s.Box,{className:"panel-root",p:5,pt:0,sx:{...o},children:[i(s.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:i(ll,{})}),c&&i(MC,{view:n}),i(PC,{}),i(hl,{panel:e,height:a})]})})}),UT="",FC=y.forwardRef(({h:t},e)=>i(s.ActionIcon,{ref:e,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:t>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:i(I.ArrowsMove,{size:16})})),GC=y.forwardRef(({handleAxis:t,...e},n)=>i(s.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...e,children:i(I.ChevronDownRight,{size:16})})),WC=gn.WidthProvider(gn),RC=k.observer(({view:t,className:e="layout"})=>{const n=K(),{panels:r,layouts:a}=n.panels.panelsByIDs(t.panelIDs),o=y.useCallback(c=>{c.forEach(({i:u,...d})=>{const f=n.panels.findByID(u);f&&f.layout.set(d)})},[n]),l=(c,u,d,f)=>{d.h<30&&(d.h=30,f.h=30),d.w<4&&(d.w=4,f.w=4)};return i(WC,{onLayoutChange:o,className:`dashboard-layout ${e}`,rowHeight:1,cols:36,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,layout:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:i(GC,{}),onResize:l,children:r.map((c,u)=>h("div",{"data-grid":{...c.layout},className:"panel-grid-item",children:[i(FC,{h:c.layout.h}),i(Hn,{view:t,panel:c})]},c.id))})}),jC=gn.WidthProvider(gn),YC=k.observer(function({view:e,className:n="layout"}){const{panels:r,layouts:a}=K().panels.panelsByIDs(e.panelIDs);return i(jC,{className:`dashboard-layout ${n}`,cols:36,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,layout:a,children:r.map(o=>i("div",{"data-grid":{...o.layout},className:"panel-grid-item",children:i(Hn,{view:e,panel:o})},o.id))})}),QC=k.observer(({children:t})=>i(s.Box,{pt:10,pb:100,children:t})),KC=k.observer(({children:t,view:e})=>{const n=e.config;return i(s.Modal,{size:n.width,overflow:"inside",opened:!0,onClose:v.noop,withCloseButton:!1,title:n.custom_modal_title.value,trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},modal:{border:"1px solid #efefef"},body:{maxHeight:"calc(100vh - 325px)"}},withinPortal:!1,transitionDuration:0,children:t})}),UC=({variant:t,orientation:e})=>{const n={tab:{},panel:{padding:"16px"}};return t==="pills"&&e==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),e==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},XC=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},JC=k.observer(({children:t,view:e})=>{const n=Ke.useModals(),r=K(),a=y.useMemo(()=>r.views.options.filter(u=>u.type===H.Division),[e.id,r.views.options]),o=e.config,l=u=>n.openConfirmModal({title:"Delete this tab?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=o.tabs.length===0;return h(s.Box,{className:"preview-view-tabs",children:[h(s.Tabs,{variant:o.variant,orientation:o.orientation,defaultValue:o.tabs.length>0?o.tabs[0].id:"0",styles:UC(o),children:[h(s.Tabs.List,{grow:o.grow,children:[o.tabs.map(u=>i(s.Tabs.Tab,{value:u.id,sx:XC(u),children:u.name??u.id},u.id)),i(s.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:i(I.Plus,{size:18,color:"#228be6"})})]}),o.tabs.map((u,d)=>{const f=r.views.findByID(u.view_id);return h(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[h(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[i(s.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),h(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[i(s.TextInput,{label:"Tab Name",value:u.name,onChange:p=>u.setName(p.currentTarget.value)}),i(s.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:a}),i(s.ColorInput,{label:"Color",value:u.color,onChange:u.setColor,disabled:o.variant!=="default"}),f&&h(s.Button,{mt:20,variant:"gradient",leftIcon:i(O.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>r.views.setIDOfVIE(f.id),children:["Swith to View: ",f.name]}),i(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:i(O.IconTrash,{size:14}),children:"Delete This Tab"})]})]}),f&&i(er,{view:f})]},u.id)})]}),t]})}),ZC=k.observer(({view:t,children:e})=>{switch(t.type){case H.Modal:return i(KC,{view:t,children:e});case H.Tabs:return i(JC,{view:t,children:e});case H.Division:default:return i(QC,{children:e})}}),fl=k.observer(function({view:e}){return i(_i.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:i(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:i(ZC,{view:e,children:h(s.Box,{sx:{position:"relative"},children:[i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(ol,{view:e})}),i(RC,{view:e})]})})})})}),HC={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},e1=k.observer(function({view:e,panel:n,exitFullScreen:r}){return i(s.Modal,{opened:!0,fullScreen:!0,onClose:r,title:i(s.Button,{color:"blue",size:"xs",onClick:r,leftIcon:i(I.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:HC,children:i(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:i(Hn,{view:e,panel:n})})})});function t1(t,e,n){const{panels:r}=K(),a=t.id==="Main",[o,l]=y.useState(()=>a&&r.findByID(e)?e:null),c=y.useCallback(p=>{l(p),a&&n(p)},[a,n]),u=y.useCallback(()=>{l(null),a&&n("")},[a,n]),d=o?r.findByID(o):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const n1=k.observer(({children:t})=>i(s.Box,{children:t})),r1=k.observer(({children:t,view:e})=>{const n=K(),r=e.config,a=n.views.visibleViewIDs.includes(e.id),o=()=>n.views.rmVisibleViewID(e.id);return i(s.Modal,{size:r.width,centered:!0,overflow:"inside",opened:a,onClose:o,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:l=>{l.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:r.height,overflow:"auto"}},transitionDuration:0,children:t})}),i1=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},a1=k.observer(({children:t,view:e})=>{const n=K(),r=e.config;return h(s.Box,{className:"render-view-tabs",children:[h(s.Tabs,{variant:r.variant,orientation:r.orientation,defaultValue:r.tabs.length>0?r.tabs[0].id:"0",styles:{panel:{padding:r.orientation==="horizontal"?"16px 0px":"0"}},keepMounted:!1,children:[i(s.Tabs.List,{grow:r.grow,children:r.tabs.map(a=>i(s.Tabs.Tab,{value:a.id,sx:i1(a),disabled:!a.view_id,children:a.name??a.id},a.id))}),r.tabs.map(a=>{const o=n.views.findByID(a.view_id);return o?i(s.Tabs.Panel,{value:a.id,children:i(er,{view:o})},a.id):null})]}),t]})}),s1=k.observer(({view:t,children:e})=>{switch(t.type){case H.Modal:return i(r1,{view:t,children:e});case H.Tabs:return i(a1,{view:t,children:e});case H.Division:default:return i(n1,{children:e})}}),er=k.observer(function({view:e}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=bs(),{viewPanelInFullScreen:a,exitFullScreen:o,inFullScreen:l,fullScreenPanel:c}=t1(e,n,r);return i(_i.Provider,{value:{viewPanelInFullScreen:a,inFullScreen:l},children:h(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[l&&i(e1,{view:e,panel:c,exitFullScreen:o}),i(s1,{view:e,children:h(s.Box,{sx:{position:"relative"},children:[!l&&i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(ol,{view:e})}),!l&&i(YC,{view:e})]})})]})})});function ki(t){return y.useCallback(e=>e.provideValue(we.pluginManager,t.pluginManager).provideValue(we.vizManager,t.vizManager).provideValue(we.colorManager,t.colorManager),[])}const o1=k.observer(({headerMenuItems:t=null})=>{const e=ge(),n=K(),r=()=>{const a=JSON.stringify(n.json,null,2),o=`${e.name}__${n.name}`;kc(o,a)};return h(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:310,children:[i(s.Menu.Target,{children:i(s.ActionIcon,{variant:"light",color:"blue",children:i(O.IconMenu2,{size:14})})}),h(s.Menu.Dropdown,{children:[i(s.Menu.Item,{icon:i(O.IconDownload,{size:14}),onClick:n.queries.downloadAllData,children:"Download Data"}),i(s.Menu.Item,{icon:i(O.IconCode,{size:14}),onClick:r,children:"Download Schema"}),t]})]})}),l1=k.observer(({saveDashboardChanges:t})=>{const e=Ke.useModals(),n=K(),r=()=>{e.openConfirmModal({title:h(s.Group,{position:"left",children:[i(O.IconAlertTriangle,{size:18,color:"red"}),i(s.Text,{children:"You are reverting changes"})]}),labels:{confirm:"Confirm",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.reset(),zIndex:320,withCloseButton:!1})},a=n.changed;return h(s.Group,{spacing:0,children:[i(s.Button,{color:"green",variant:"filled",size:"xs",leftIcon:i(O.IconDeviceFloppy,{size:18}),onClick:t,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:"Save Changes"}),h(s.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[i(s.Menu.Target,{children:i(s.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:i(O.IconCaretDown,{size:18})})}),i(s.Menu.Dropdown,{children:i(s.Menu.Item,{icon:i(O.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:r,children:"Revert Changes"})})]})]})}),c1=k.observer(({saveDashboardChanges:t,headerSlot:e=null,headerMenuItems:n})=>{const r=Zl.useNavigate(),a=ge(),o=()=>{r(`/dashboard/${a.id}`)},l=Ke.useModals(),c=()=>{l.openConfirmModal({title:h(s.Group,{position:"left",children:[i(O.IconAlertTriangle,{size:18,color:"red"}),i(s.Text,{children:"There are unsaved changes"})]}),labels:{confirm:"Discard",cancel:"Cancel"},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:o,zIndex:320,withCloseButton:!1})},u=a.content.changed;return i(s.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:h(s.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[h(s.Group,{children:[i(s.Button,{size:"xs",color:u?"red":"green",leftIcon:i(O.IconArrowLeft,{size:20}),onClick:u?c:o,children:h(s.Group,{spacing:4,children:["End Editing",i(s.Text,{td:"underline",children:a.name})]})}),i(l1,{saveDashboardChanges:t})]}),h(s.Group,{position:"right",sx:{flexGrow:1},children:[e,i(o1,{headerMenuItems:n})]})]})})}),u1={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},d1=k.observer(()=>{const t=K();return i(s.Box,{sx:u1,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:h(s.Group,{position:"apart",align:"center",sx:{height:"30px"},pr:16,children:[i(s.Button,{variant:"outline",color:"blue",radius:0,size:"xs",disabled:!t.views.VIE,onClick:()=>t.addANewPanel(t.views.idOfVIE),leftIcon:i(O.IconPlaylistAdd,{size:20}),sx:{height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef",background:"rgb(231, 245, 255)"},children:"Add a Panel"}),i(s.Box,{}),i(s.Box,{})]})})}),p1=k.observer(t=>h(q,{children:[i(c1,{...t}),i(d1,{})]})),XT="",JT="";function h1(t,e,n){const r=[];return t.filter(a=>"__INTERACTIONS"in a.viz.conf).forEach((a,o)=>{const l=e[a.id];l.data.interactions=v.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=a.viz.conf;Object.entries(u).forEach(([f,p])=>{const{schemaRef:g,data:m}=p,{config:C}=m;switch(g){case"builtin:op:open-link":let w=C.urlTemplate.substring(0,100);C.urlTemplate.length>=20&&(w+="..."),l.type="interaction",l.data.interactions.push({schemaRef:g,urlTemplate:C.urlTemplate,shortURLTemplate:w});return;case"builtin:op:open_view":r.push({id:`OPERATION--${f}`,source:a.id,target:C.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:Object.keys(C.dictionary).map(_=>({key:_,label:n[_]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:C.filter_keys.map(_=>({key:_,label:n[_]}))});return;default:return}})}),r}function f1(t,e){const n=t.filters.keyLabelMap;return{edges:h1(t.panels.list,e,n),edgeNodes:[]}}function gl(t,e,n){return t*e+t*n}function g1(t,e,n){return t*e+(t-1)*n}const tr=25,Ti=40,ml=25,Di=350,m1=150,y1=150,yl=150,bl=300,nr=40,vl=25,b1=300;function v1(t,e){const n=v.keyBy(e,a=>a.id),r=[];return t.current.forEach((a,o)=>{a.panelIDs.forEach((l,c)=>{const u=gl(c,nr,vl)+Ti,d=n[l];if(!d){r.push({id:l,_node_type:"panel",parentNode:a.id,data:{label:`!: ${l}`},position:{x:tr,y:u},sourcePosition:Me.Position.Right,targetPosition:Me.Position.Left,style:{width:bl,height:nr}});return}const f=d.title.trim()?`${d.title}`:d.viz.type;r.push({id:d.id,_node_type:"panel",parentNode:a.id,data:{label:f},position:{x:tr,y:u},sourcePosition:Me.Position.Right,targetPosition:Me.Position.Left,style:{width:bl,height:nr}})})}),r}const x1={[H.Division]:"Div",[H.Modal]:"Modal",[H.Tabs]:"Tabs"},w1=Ko;function C1(t){return t.current.map((n,r)=>{const a=g1(n.panelIDs.length,nr,vl)+Ti+ml;let o=[];return n.type===H.Tabs&&(o=n.config.tabs.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${x1[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Me.Position.Right,targetPosition:Me.Position.Left,className:"light",style:{backgroundColor:w1[n.type],width:Di,height:a}}})}function S1(t){const e=v.keyBy(t,n=>n.id);t.forEach(n=>{n._node_type!=="view-root"||n._view_type!==H.Tabs||n._tab_view_ids.forEach(r=>{e[r].parentNode=n.id})})}function _1(t){const e=C1(t.views);S1(e);const n=v1(t.views,t.panels.list);return[...e,...n]}function k1({nodeMap:t,nodes:e,edges:n}){e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==H.Tabs||(r.sourcePosition=Me.Position.Bottom,r.style.width=Di+tr*2,r.style.height=ml+r._tab_view_ids.reduce((a,o)=>{const l=t[o];l.position.y=a,l.position.x=tr;const c=l.style.height;return a+c+20},Ti))})}function T1({nodeMap:t,nodes:e,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const a=t[r.source],o=t[r.target];if(!a||!o||!a.parentNode)return;const l=t[a.parentNode];l._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+l._view_level,l._sub_view_ids.push(o.id))}),e.sort((r,a)=>r._node_type==="view-root"&&a._node_type==="view-root"?r._view_level-a._view_level:r._node_type!=="view-root"&&a._node_type!=="view-root"?0:r._node_type==="view-root"?-1:1)}function D1({nodeMap:t,nodes:e,edges:n}){const r={};n.forEach(a=>{if(a.label!=="Open View")return;const o=t[a.source],l=t[a.target];if(o&&l&&o.parentNode){const c=t[o.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),f=Number(c.style.width);l.position.x=u+f+b1,c._view_level===0&&l._sub_view_ids.length===0&&(o.sourcePosition=Me.Position.Left,l.targetPosition=Me.Position.Right,l.position.x*=-1);const g=l.position.x,m=v.get(r,g,0);l.position.y=m,r[g]=m+d+yl}})}function I1({nodeMap:t,nodes:e,edges:n}){const r=new Set,a=new Set;n.forEach(l=>{r.add(l.source),a.add(l.target)}),e.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!r.has(l.id)&&!a.has(l.id)).forEach((l,c)=>{l.position.x=gl(c,Di,y1),l.position.y=0-m1-yl})}function M1({nodeMap:t,nodes:e,edges:n}){const r={nodeMap:t,nodes:e,edges:n};return I1(r),T1(r),k1(r),D1(r),{nodes:e,edges:n}}function E1(t){const e=_1(t),n=v.keyBy(e,u=>u.id),{edges:r,edgeNodes:a}=f1(t,n),o=[...e,...a],l=v.keyBy(o,u=>u.id),c={edges:v.uniqBy(r,u=>u.id),nodes:o,nodeMap:l};return M1(c)}const ZT="",Ii={"builtin:op:open-link":i(s.ThemeIcon,{color:"blue",size:20,radius:"xl",children:i(O.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":i(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:i(O.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":i(s.ThemeIcon,{color:"orange",size:20,radius:"xl",children:i(O.IconCircleOff,{size:14})})};function A1(t){const e=[];return t.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":e.push({key:n.urlTemplate,icon:Ii[n.schemaRef],text:h(s.Group,{spacing:4,children:[i(s.Text,{children:"Open: "}),i(s.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:a})=>{e.push({key:n.schemaRef+r,icon:Ii[n.schemaRef],text:i(s.Group,{spacing:4,children:h(s.Text,{children:["Set Filter: ",a]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:a})=>{e.push({key:n.schemaRef+r,icon:Ii[n.schemaRef],text:i(s.Group,{spacing:4,children:h(s.Text,{children:["Clear Filter: ",a]})})})});return}}),e}const z1=y.memo(({data:t,isConnectable:e,sourcePosition:n=Me.Position.Right,targetPosition:r=Me.Position.Left,...a})=>{const o=y.useMemo(()=>A1(t.interactions),[t.interactions]);return h(q,{children:[i(Me.Handle,{type:"target",position:r,isConnectable:e}),i(s.Box,{sx:{position:"absolute",top:0,right:0},children:i(I.ChevronsUpRight,{size:12})}),h(s.HoverCard,{shadow:"xl",withinPortal:!0,children:[i(s.HoverCard.Target,{children:i(s.Text,{children:t.label})}),i(s.HoverCard.Dropdown,{children:i(s.List,{spacing:"xs",size:"sm",center:!0,children:o.map(l=>i(s.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),i(Me.Handle,{type:"source",position:n,isConnectable:e})]})}),HT="",$1={interaction:z1},L1=k.observer(()=>{const t=K(),{edges:e,nodes:n}=E1(t);return h(Me,{nodes:n,edges:e,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:$1,children:[i(Me.MiniMap,{}),i(Me.Controls,{}),i(Me.Background,{})]})}),O1=k.observer(({opened:t,close:e})=>{const{freezeLayout:n}=y.useContext(ft);return y.useEffect(()=>{n(t)},[t]),i(s.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:e,title:"Interactions",trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"90vh"},modal:{transform:"none !important"}},zIndex:300,children:i(L1,{})})}),P1={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function B1({onClick:t,name:e,active:n,openSettings:r}){return h(s.Box,{sx:{position:"relative"},children:[i(s.UnstyledButton,{sx:a=>({display:"block",width:"100%",padding:a.spacing.xs,borderRadius:0,position:"relative",color:a.black,"&:hover":{backgroundColor:a.colors.gray[0]},backgroundColor:n?a.colors.gray[2]:"transparent"}),children:i(s.Group,{sx:{width:"calc(100% - 28px)"},onClick:t,children:i(s.Text,{size:"sm",children:e})})}),n&&i(s.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:i(s.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:i(O.IconAdjustments,{size:16})})})]})}const V1=k.observer(()=>{const t=ge(),e=K(),n=y.useCallback(a=>()=>e.views.setIDOfVIE(a),[e]),r=a=>{t.editor.open(["_VIEWS_",a])};return h(s.Box,{sx:{position:"relative"},children:[e.views.options.map(a=>i(B1,{active:e.views.idOfVIE===a.value,name:a.label,onClick:n(a.value),openSettings:()=>r(a.value)},a.value)),i(s.Divider,{variant:"dashed"}),i(s.Button,{variant:"subtle",rightIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:"Add a View"})]})}),N1=k.observer(()=>{const t=ge(),e=K(),n=()=>{if(!e.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",e.queries.firstID])},r=()=>{if(!e.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",e.filters.firstID])},[a,o]=y.useState(!1),l=()=>o(!0),c=()=>o(!1);return h(s.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[h(s.Navbar.Section,{children:[h(s.Group,{grow:!0,spacing:0,sx:{...P1,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[i(s.Tooltip,{label:"Filters",withinPortal:!0,children:i(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:r,children:i(O.IconFilter,{size:20})})}),i(s.Tooltip,{label:"Queries",withinPortal:!0,children:i(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:n,children:i(O.IconDatabase,{size:20})})}),i(s.Tooltip,{label:"Interactions Viewer",withinPortal:!0,children:i(s.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:l,children:i(O.IconLink,{size:20})})})]}),i(O1,{opened:a,close:c})]}),i(s.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:i(s.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Views"})}),i(s.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:i(V1,{})}),i(s.Navbar.Section,{children:i(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:i(s.Button,{size:"xs",leftIcon:i(O.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:"Settings"})})})]})}),q1=k.observer(function({config:e}){return h(q,{children:[i(s.Checkbox,{checked:e.default_value,onChange:n=>e.setDefaultValue(n.currentTarget.checked),label:"Default Checked"}),i(ri,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),F1=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],G1=k.observer(function({config:e}){return h(q,{children:[h(s.Group,{children:[i(s.Checkbox,{checked:e.required,onChange:n=>e.setRequired(n.currentTarget.checked),label:"Required"}),i(s.Checkbox,{checked:e.clearable,onChange:n=>e.setClearable(n.currentTarget.checked),disabled:e.max_days>0,label:"Clearable"}),i(s.Checkbox,{checked:e.allowSingleDateInRange,onChange:n=>e.setAllowSingleDateInRange(n.currentTarget.checked),label:"Allow choosing 1 day"})]}),i(s.Select,{data:F1,label:"Display Format",value:e.inputFormat,onChange:e.setInputFormat}),i(il,{label:"Default Value",config:e,value:e.default_value,onChange:e.setDefaultValue}),i(s.NumberInput,{label:"Max Days",description:h(s.Group,{position:"apart",children:[i(s.Text,{children:"Set 0 to disable."}),h(s.Group,{spacing:4,children:[i(s.Text,{children:"This feature requires"}),i(s.Text,{color:"blue",children:"Clearable"}),i(s.Text,{children:"to be checked"})]})]}),min:0,value:e.max_days,onChange:e.setMaxDays,hideControls:!0})]})}),Mi=k.observer(({value:t,onChange:e})=>{const n=K(),r=y.useMemo(()=>n.queries.options,[n.queries.current]),a=r.length===0;return i(s.Select,{label:"Pick a query",data:r,value:t,onChange:e,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:a,error:a?"You need to add a query in Data Settings":void 0})}),W1=`
481
481
  // row
482
482
  {
483
483
  label: string;
484
484
  value: string;
485
485
  description?: string; // optional
486
486
  }
487
- `,xl=()=>{const[t,e]=y.useState(!1);return h(q,{children:[i(s.Button,{variant:"subtle",compact:!0,onClick:()=>e(n=>!n),children:t?"Close":"Click to see expected data structure"}),i(s.Collapse,{in:t,children:i(St.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:G1})})]})},W1=k.observer(function({config:e}){const n=()=>{e.addStaticOption({label:"",value:""})},r=e.static_options,a=[...r];return h(q,{children:[i(s.TextInput,{label:"Width",description:"At least 160px",value:e.min_width,onChange:o=>e.setMinWidth(o.currentTarget.value),placeholder:"default: 200px"}),i(s.Divider,{label:"Configure options",labelPosition:"center"}),h(s.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[e.usingQuery&&h(q,{children:[i(s.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),i(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:i(s.Text,{color:"white",size:16,children:"Using query"})})]}),r.length>0&&i(s.MultiSelect,{label:"Default Selection",data:a,value:[...e.default_value],onChange:e.setDefaultValue}),r.map((o,l)=>h(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[i(s.TextInput,{label:"Label",required:!0,value:e.static_options[l].label,onChange:c=>{e.static_options[l].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.TextInput,{label:"Value",required:!0,value:e.static_options[l].value,onChange:c=>{e.static_options[l].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(l),sx:{position:"absolute",top:28,right:5},children:i(I.Trash,{size:16})})]},l)),i(s.Button,{mt:10,size:"xs",color:"blue",leftIcon:i(I.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"})]}),i(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),i(s.NumberInput,{value:e.default_selection_count,onChange:e.setDefaultSelectionCount,label:"Select first N options by default"}),i(Mi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(xl,{})]})}),R1=k.observer(function({config:e}){const n=()=>{e.addStaticOption({label:"",value:""})},r=e.static_options,a=[{label:"No default selection",value:""},...r];return h(q,{children:[i(s.Checkbox,{checked:e.required,onChange:o=>e.setRequired(o.currentTarget.checked),label:"Required"}),i(s.TextInput,{label:"Width",value:e.width,onChange:o=>e.setWidth(o.currentTarget.value),placeholder:"200px"}),i(s.Divider,{label:"Configure options",labelPosition:"center"}),h(s.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[e.usingQuery&&h(q,{children:[i(s.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),i(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:i(s.Text,{color:"white",size:16,children:"Using query"})})]}),r.length>0&&i(s.Select,{label:"Default Selection",data:a,value:e.default_value,onChange:e.setDefaultValue}),r.map((o,l)=>h(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[i(s.TextInput,{label:"Label",required:!0,value:e.static_options[l].label,onChange:c=>{e.static_options[l].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.TextInput,{label:"Value",required:!0,value:e.static_options[l].value,onChange:c=>{e.static_options[l].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(l),sx:{position:"absolute",top:28,right:5},children:i(I.Trash,{size:16})})]},l)),i(s.Button,{size:"xs",color:"blue",leftIcon:i(I.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"})]}),i(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),i(s.Checkbox,{checked:e.default_selection_count===1,onChange:o=>e.setDefaultSelectionCount(o.currentTarget.checked?1:0),label:"Select the first option by default"}),i(Mi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(xl,{})]})}),j1=k.observer(function({config:e}){return h(q,{children:[i(s.TextInput,{label:"Default Value",value:e.default_value,onChange:n=>{e.setDefaultValue(n.currentTarget.value)}}),i(s.Checkbox,{checked:e.required,onChange:n=>e.setRequired(n.currentTarget.checked),label:"Required"})]})}),Y1=`
487
+ `,xl=()=>{const[t,e]=y.useState(!1);return h(q,{children:[i(s.Button,{variant:"subtle",compact:!0,onClick:()=>e(n=>!n),children:t?"Close":"Click to see expected data structure"}),i(s.Collapse,{in:t,children:i(St.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:W1})})]})},R1=k.observer(function({config:e}){const n=()=>{e.addStaticOption({label:"",value:""})},r=e.static_options,a=[...r];return h(q,{children:[i(s.TextInput,{label:"Width",description:"At least 160px",value:e.min_width,onChange:o=>e.setMinWidth(o.currentTarget.value),placeholder:"default: 200px"}),i(s.Divider,{label:"Configure options",labelPosition:"center"}),h(s.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[e.usingQuery&&h(q,{children:[i(s.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),i(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:i(s.Text,{color:"white",size:16,children:"Using query"})})]}),r.length>0&&i(s.MultiSelect,{label:"Default Selection",data:a,value:[...e.default_value],onChange:e.setDefaultValue}),r.map((o,l)=>h(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[i(s.TextInput,{label:"Label",required:!0,value:e.static_options[l].label,onChange:c=>{e.static_options[l].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.TextInput,{label:"Value",required:!0,value:e.static_options[l].value,onChange:c=>{e.static_options[l].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(l),sx:{position:"absolute",top:28,right:5},children:i(I.Trash,{size:16})})]},l)),i(s.Button,{mt:10,size:"xs",color:"blue",leftIcon:i(I.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"})]}),i(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),i(s.NumberInput,{value:e.default_selection_count,onChange:e.setDefaultSelectionCount,label:"Select first N options by default"}),i(Mi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(xl,{})]})}),j1=k.observer(function({config:e}){const n=()=>{e.addStaticOption({label:"",value:""})},r=e.static_options,a=[{label:"No default selection",value:""},...r];return h(q,{children:[i(s.Checkbox,{checked:e.required,onChange:o=>e.setRequired(o.currentTarget.checked),label:"Required"}),i(s.TextInput,{label:"Width",value:e.width,onChange:o=>e.setWidth(o.currentTarget.value),placeholder:"200px"}),i(s.Divider,{label:"Configure options",labelPosition:"center"}),h(s.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[e.usingQuery&&h(q,{children:[i(s.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),i(s.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:i(s.Text,{color:"white",size:16,children:"Using query"})})]}),r.length>0&&i(s.Select,{label:"Default Selection",data:a,value:e.default_value,onChange:e.setDefaultValue}),r.map((o,l)=>h(s.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[i(s.TextInput,{label:"Label",required:!0,value:e.static_options[l].label,onChange:c=>{e.static_options[l].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.TextInput,{label:"Value",required:!0,value:e.static_options[l].value,onChange:c=>{e.static_options[l].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),i(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(l),sx:{position:"absolute",top:28,right:5},children:i(I.Trash,{size:16})})]},l)),i(s.Button,{size:"xs",color:"blue",leftIcon:i(I.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"})]}),i(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),i(s.Checkbox,{checked:e.default_selection_count===1,onChange:o=>e.setDefaultSelectionCount(o.currentTarget.checked?1:0),label:"Select the first option by default"}),i(Mi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(xl,{})]})}),Y1=k.observer(function({config:e}){return h(q,{children:[i(s.TextInput,{label:"Default Value",value:e.default_value,onChange:n=>{e.setDefaultValue(n.currentTarget.value)}}),i(s.Checkbox,{checked:e.required,onChange:n=>e.setRequired(n.currentTarget.checked),label:"Required"})]})}),Q1=`
488
488
  // row
489
489
  {
490
490
  label: string;
@@ -492,7 +492,7 @@ Check the top-level render call using <`+P+">.")}return A}}function ql(S,A){{if(
492
492
  parent_value: string;
493
493
  description?: string;
494
494
  }
495
- `,Q1=()=>{const[t,e]=y.useState(!1);return h(q,{children:[i(s.Button,{variant:"subtle",compact:!0,onClick:()=>e(n=>!n),children:t?"Close":"Click to see expected data structure"}),i(s.Collapse,{in:t,children:i(St.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:Y1})})]})},K1=k.observer(function({config:e}){return h(q,{children:[i(s.TextInput,{label:"Min-width",value:e.min_width,onChange:n=>e.setMinWidth(n.currentTarget.value),placeholder:"200px"}),i(s.Divider,{label:"Fetch options from database",labelPosition:"center"}),i(s.NumberInput,{value:e.default_selection_count,onChange:e.setDefaultSelectionCount,label:"Select first N options by default"}),i(Mi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(Q1,{})]})}),U1=k.observer(function({filter:e}){const[n,r]=y.useState(e.plainDefaultValue);return y.useEffect(()=>{r(e.plainDefaultValue)},[e]),h(s.Box,{sx:{maxWidth:"480px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Preview"}),i(sl,{filter:e,value:n,onChange:r}),i(s.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),i(St.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),X1={select:R1,"multi-select":W1,"tree-select":K1,"text-input":j1,checkbox:N1,"date-range":F1},J1=[{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"}],Z1=k.observer(function({filter:e}){const n=K(),r=y.useMemo(()=>X1[e.type],[e.type]);return h(s.Group,{grow:!0,spacing:20,align:"top",children:[h(s.Box,{sx:{maxWidth:"600px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Edit"}),h(s.Stack,{children:[h(s.Group,{noWrap:!0,children:[i(s.NumberInput,{label:"Placement Order",required:!0,value:e.order,onChange:e.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),e.auto_submit_supported&&i(s.Checkbox,{label:"Submit automatically",checked:e.auto_submit,onChange:a=>e.setAutoSubmit(a.currentTarget.checked),mt:22})]}),i(s.MultiSelect,{label:"Visible in...",data:n.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),i(s.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:e.key,onChange:a=>{e.setKey(a.currentTarget.value)}}),i(s.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:e.label,onChange:a=>{e.setLabel(a.currentTarget.value)}}),i(s.Select,{label:"Widget",data:J1,required:!0,value:e.type,onChange:e.setType}),i(r,{config:e.config})]})]}),i(U1,{filter:e})]})}),H1=k.observer(({id:t})=>{const e=Ke.useModals(),n=ge(),r=K();if(t==="")return null;const a=r.filters.findByID(t);if(!a)return h(s.Text,{size:14,children:["Filter by ID[",t,"] is not found"]});const o=()=>{n.editor.setPath(["_FILTERS_",""])},l=()=>{e.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.filters.removeByID(t),o()},confirmProps:{color:"red"},zIndex:320})};return h(s.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(I.Trash,{size:16}),onClick:l,children:"Delete this filter"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(Z1,{filter:a})})]})}),eS=k.observer(()=>{const t=K(),[e,n]=y.useState(()=>JSON.stringify(t.mock_context.current,null,4)),r=()=>{try{t.mock_context.replace(JSON.parse(e))}catch(o){fn.showNotification({title:"Failed",message:o.message,color:"red"})}},a=y.useMemo(()=>{try{return JSON.stringify(JSON.parse(e))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[e,t.mock_context.current]);return h(s.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[i(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:i(s.Text,{weight:500,children:"Mock Context"})}),h(s.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[h(s.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[i(s.Text,{children:"A valid json string is required"}),i(s.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:e,onChange:n,sx:{flexGrow:1}})]}),i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:r,children:i(I.DeviceFloppy,{size:20})})]})]})}),tS=k.observer(()=>{const{panel:t}=Ae();return i(ri,{label:"Description",value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),nS=k.observer(()=>{const{panel:t}=Ae(),{style:e}=t;return i(q,{children:i(s.Switch,{label:"Border",checked:e.border.enabled,onChange:n=>e.border.setEnabled(n.currentTarget.checked)})})}),rS=k.observer(()=>{const{panel:t}=Ae(),{title:e,setTitle:n}=t,[r,a]=Ie.useInputState(e),o=e!==r,l=y.useCallback(()=>{o&&n(r)},[o,r]);return y.useEffect(()=>{a(e)},[e]),i(s.TextInput,{value:r,onChange:a,label:h(s.Group,{children:[i(s.Text,{children:"Panel Title"}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:l,children:i(I.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function iS(){return h(s.Stack,{sx:{height:"100%"},children:[i(s.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),i(nS,{}),i(s.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),i(rS,{}),i(tS,{})]})}const aS=({queryID:t})=>{const e=K(),{state:n,error:r}=e.getDataStuffByID(t),a=y.useMemo(()=>e.queries.findByID(t),[e,t]);return n==="loading"?null:r?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):a!=null&&a.stateMessage?i(s.Text,{color:"gray",align:"center",children:a.stateMessage}):null},sS={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 wl({data:t}){const e=y.useMemo(()=>{if(!Array.isArray(t)||t.length===0)return[];const r=Ue.createColumnHelper();return Object.keys(t[0]).map(a=>r.accessor(a,{cell:o=>o.getValue()}))},[t]),n=Ue.useReactTable({data:t,columns:e,columnResizeMode:"onChange",getCoreRowModel:Ue.getCoreRowModel()});return t.length===0?i(s.Box,{sx:{height:"5em"}}):i(Fe,{children:h(s.Table,{sx:sS,children:[i("thead",{children:n.getHeaderGroups().map(r=>i("tr",{children:r.headers.map(a=>h("th",{style:{width:a.getSize()},children:[a.isPlaceholder?null:Ue.flexRender(a.column.columnDef.header,a.getContext()),i(s.ActionIcon,{onMouseDown:a.getResizeHandler(),onTouchStart:a.getResizeHandler(),className:`resizer ${a.column.getIsResizing()?"isResizing":""}`,children:i(I.ArrowBarToRight,{})})]},a.id))},r.id))}),i("tbody",{children:n.getRowModel().rows.map(r=>i("tr",{children:r.getVisibleCells().map(a=>i("td",{children:i(Fe,{children:Ue.flexRender(a.column.columnDef.cell,a.getContext())})},a.id))},r.id))})]})})}const Ei=k.observer(function({id:e,moreActions:n=null}){const r=K(),{data:a,state:o}=r.getDataStuffByID(e),l=o==="loading",c=()=>{r.queries.refetchDataByQueryID(e)},u=()=>{r.queries.downloadDataByQueryID(e)},d=y.useMemo(()=>Array.isArray(a)?a.slice(0,10):[],[a]),f=!Array.isArray(a)||a.length===0;return h(s.Stack,{sx:{border:"1px solid #eee"},children:[h(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[h(s.Group,{position:"left",children:[i(s.Text,{weight:500,children:"Preview Data"}),a.length>10&&h(s.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",a.length]})]}),h(s.Group,{pr:15,children:[n,i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l,onClick:c,children:i(I.Refresh,{size:16})}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l||f,onClick:u,children:i(I.Download,{size:16})})]})]}),h(s.Box,{sx:{position:"relative",overflow:"auto"},children:[i(s.LoadingOverlay,{visible:l}),i(aS,{queryID:e}),i(wl,{data:d})]})]})}),oS=k.observer(function(){const e=ge(),n=K(),{panel:r}=Ae(),[a,o]=y.useState(!1),l=c=>{e.editor.setPath(["_QUERIES_",c])};return h(q,{children:[i(s.Drawer,{opened:a,onClose:()=>o(!1),title:"Choose queries",padding:"xl",size:"xl",zIndex:320,children:i(s.Checkbox.Group,{orientation:"vertical",value:[...r.queryIDs],onChange:r.setQueryIDs,children:n.queries.options.map(c=>i(s.Checkbox,{label:c.label,value:c.value},c.value))})}),h(s.Stack,{spacing:6,children:[i(s.Group,{position:"right",children:i(s.Button,{variant:"light",size:"sm",leftIcon:i(O.IconLine,{size:16}),onClick:()=>o(!0),children:"Click me to choose queries for this panel"})}),r.queryIDs.length===1&&i(Ei,{id:r.queryIDs[0],moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(r.queryIDs[0]),children:i(O.IconArrowCurveRight,{size:16})})})}),r.queryIDs.length>1&&h(s.Tabs,{defaultValue:r.queryIDs[0],children:[i(s.Tabs.List,{children:r.queries.map(c=>i(s.Tabs.Tab,{value:c.id,children:c.name},c.id))}),r.queries.map(c=>i(s.Tabs.Panel,{value:c.id,children:i(Ei,{id:c.id,moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(c.id),children:i(O.IconArrowCurveRight,{size:16})})})})},c.id))]})]})]})}),lS=k.observer(()=>{const{panel:t}=Ae();return i(Fe,{children:i(s.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:h(s.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.style.border.enabled?"1px":"0px"},children:[h(s.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[i(s.Group,{children:i(ll,{})}),i(s.Group,{grow:!0,position:"center",children:i(s.Text,{lineClamp:1,weight:"bold",children:t.title})}),i(s.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),i(s.Group,{px:5,pb:5,sx:{flexGrow:1},children:i(hl,{panel:t,height:"410px"})})]})})})}),Ai={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 cS{constructor(e){N(this,"panel");N(this,"selected");this.panel=e,ae.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const e=this.panel.variables.filter(n=>n.name.startsWith(Ai.name)).length;this.panel.addVariable(v.cloneDeep({...Ai,name:`${Ai.name}${e||""}`})),this.selected=v.last(this.panel.variables)}select(e){this.selected=e}remove(e){this.selected===e&&(this.selected=void 0);const n=this.panel.variables.indexOf(e);if(this.panel.removeVariable(e),!this.selected&&!v.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function uS(){const{panel:t}=Ae();return J.useCreation(()=>new cS(t),[t])}const Cl=s.createStyles(t=>({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}})),dS=y.forwardRef(function({value:e,onChange:n,data:r,withStyle:a=!0},o){const l=(c,u)=>{const d=v.cloneDeep(e);v.set(d,c,u),n(d)};return h(s.Box,{px:"sm",py:"md",ref:o,children:[h(s.Group,{grow:!0,noWrap:!0,children:[i(s.TextInput,{label:"Name",required:!0,value:e.name,onChange:c=>l("name",c.currentTarget.value)}),i(j,{label:"Data Field",required:!0,value:e.data_field,onChange:c=>l("data_field",c)})]}),i(Sn,{label:"Aggregation",value:e.aggregation,onChange:c=>l("aggregation",c)}),i(s.Divider,{my:"xs",label:"Format",labelPosition:"center"}),i(Je,{value:e.formatter,onChange:c=>l("formatter",c)}),a&&i(Ss,{value:e,onChange:n})]})}),pS=t=>{const{uiModel:e}=t;return i(s.Stack,{className:"var-list",children:e.variables.map(n=>i(s.Button,{variant:e.selected===n?"filled":"subtle",color:"gray",onClick:()=>e.select(n),children:n.name},n.name))})},hS=k.observer(pS),fS=({variable:t,data:e})=>i(s.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:i(s.Paper,{withBorder:!0,p:"md",children:_s(t,e)})}),gS=k.observer(fS),mS=t=>{const e=J.useCreation(()=>Wc(t.variable),[t.variable]),{classes:n}=Cl(),{data:r}=Ae();return h(s.Group,{style:{height:"100%"},align:"start",children:[h(s.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[h(s.Group,{position:"right",children:[i(s.ActionIcon,{variant:"filled",disabled:!e.changed,color:"primary",onClick:e.commit,children:i(O.IconDeviceFloppy,{size:18})}),i(s.ActionIcon,{color:"red",onClick:()=>t.uiModel.remove(t.variable),children:i(O.IconTrash,{size:18})})]}),i(dS,{value:b.getSnapshot(e.copy),onChange:e.update,data:r})]}),i(gS,{variable:b.getSnapshot(e.copy),data:r})]})},yS=k.observer(mS),bS=()=>{const t=uS(),{classes:e}=Cl();return h(s.Group,{className:e.root,noWrap:!0,align:"start",children:[i(s.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:h(s.Stack,{justify:"space-between",children:[i(s.Box,{className:"var-list-actions",children:i(s.Button,{variant:"light",size:"sm",onClick:t.addNew,fullWidth:!0,children:"Add Variable"})}),i(hS,{uiModel:t})]})}),t.selected?i(q,{children:i(yS,{uiModel:t,variable:t.selected})}):i("span",{children:"Select or create a new variable on right side"})]})},vS=k.observer(bS);function xS(){const{vizManager:t}=y.useContext(it);return y.useMemo(()=>{const e=t.availableVizList.map(n=>({value:n.name,label:n.displayName??n.name,group:n.displayGroup??""}));return v.orderBy(e,[n=>n.group,n=>n.label],["asc","asc"])},[t])}const wS=k.observer(({value:t,submit:e})=>{const[n,r]=Ie.useInputState(t);y.useEffect(()=>{r(t)},[t]);const a=xS(),o=t!==n;return i(s.Select,{label:"Visualization",value:n,searchable:!0,onChange:r,data:a,rightSection:i(s.ActionIcon,{disabled:!o,onClick:()=>e(n),children:i(I.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Sl=[];function CS(t,e){try{return t.resolveComponent(e).createConfig()}catch{return null}}function SS(){const{data:t,panel:{variables:e,viz:n,title:r,queryIDs:a,description:o,setDescription:l,setTitle:c,addQueryID:u,removeQueryID:d,id:f}}=Ae(),{vizManager:p}=y.useContext(it),g={title:r,description:o,viz:n,queryIDs:a,id:f},m={setDescription:l,addQueryID:u,removeQueryID:d,setTitle:c},C=ul(g);try{return p.resolveComponent(g.viz.type),i(Jn,{configure:C,children:i(zC,{variables:e,setVizConf:n.setConf,panel:g,panelInfoEditor:m,vizManager:p,data:t})})}catch(w){return console.info(v.get(w,"message")),null}}const _S=k.observer(()=>{const{data:t,panel:{viz:e}}=Ae(),{vizManager:n}=y.useContext(it),r=y.useCallback(d=>{if(d===e.type)return;const f=CS(n,d);e.setType(d),e.setConf(f||{})},[e.type]),a=d=>{try{e.setConf(JSON.parse(d))}catch(f){console.error(f)}},o=y.useMemo(()=>{var d;return(d=Sl.find(f=>f.value===e.type))==null?void 0:d.Panel},[e.type,Sl]),l=SS(),c=o?y.createElement(o,{data:t,conf:e.conf,setConf:e.setConf}):null,u=l||c;return h(s.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[i(wS,{submit:r,value:e.type}),h(Fe,{children:[i(s.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&i(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:a})]})]})}),kS=k.observer(({panel:t,sourceViewID:e})=>{const n=K(),[r,a]=y.useState(e);y.useEffect(()=>{a(e)},[e]);const[o,{open:l,close:c}]=Ie.useDisclosure(!1),u=()=>{t.moveToView(e,r),c()};return h(q,{children:[i(s.Button,{size:"xs",variant:"subtle",color:"blue",onClick:l,leftIcon:i(O.IconBoxMultiple,{size:14}),children:"Move into Another View"}),i(s.Modal,{opened:o,onClose:c,title:"Move panel into another view",zIndex:320,overflow:"inside",children:h(s.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[i(s.Radio.Group,{value:r,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:i(s.Stack,{spacing:"xs",children:n.views.options.map(d=>i(s.Radio,{value:d.value,label:d.label},d.value))})}),h(s.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[i(s.Button,{size:"xs",color:"red",leftIcon:i(O.IconX,{size:14}),onClick:c,children:"Cancel"}),i(s.Button,{size:"xs",color:"blue",leftIcon:i(O.IconDeviceFloppy,{size:14}),onClick:u,disabled:r===e,children:"Confirm"})]})]})})]})}),TS={root:{flexGrow:1,width:"100%",overflow:"hidden"},panel:{width:"100%",height:"calc(100% - 44px)",padding:10,overflow:"scroll"}},_l=({children:t})=>h(s.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%"},children:[i(s.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:t}),i(lS,{})]});function DS(t){return!["richText","button"].includes(t)}const IS=k.observer(({panel:t})=>{const e=Ke.useModals(),n=ge(),r=K(),[a,o]=y.useState("Data"),l=t.queries,u=DS(t.viz.type)&&t.dataLoading,d=u||t.queryErrors.length>0||t.queryStateMessages.length>0||l.length===0,f=n.editor.path[1];y.useEffect(()=>{o(m=>d&&m==="Visualization"?"Data":m)},[t.id,d]);const p=()=>{n.editor.setPath(["_VIEWS_",f])},g=()=>e.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(t.id,f),p()},confirmProps:{color:"red"},zIndex:320});return h(wr,{value:{panel:t,data:t.data,loading:u,errors:t.queryErrors},children:[h(s.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[h(s.Text,{pt:9,pb:8,children:[t.title?t.title:t.viz.type," "]}),h(s.Group,{position:"right",noWrap:!0,children:[i(kS,{panel:t,sourceViewID:f}),i(s.Button,{size:"xs",variant:"subtle",color:"red",onClick:g,leftIcon:i(O.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),h(s.Tabs,{value:a,onTabChange:o,keepMounted:!1,styles:TS,children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Data",disabled:u,children:"Data"}),i(s.Tabs.Tab,{value:"Panel",children:"Panel"}),i(s.Tabs.Tab,{value:"Variables",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Variables"})})}),i(s.Tabs.Tab,{value:"Visualization",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Visualization"})})}),i(s.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),h(s.Tabs.Panel,{value:"Data",children:[i(s.LoadingOverlay,{visible:u,exitTransitionDuration:0}),i(oS,{})]}),i(s.Tabs.Panel,{value:"Panel",children:i(_l,{children:i(iS,{})})}),i(s.Tabs.Panel,{value:"Variables",children:i(vS,{})}),i(s.Tabs.Panel,{value:"Visualization",children:i(Fe,{children:i(_l,{children:i(_S,{})})})}),i(s.Tabs.Panel,{value:"Interactions",children:i(Fe,{children:i($u,{})})})]})]})}),MS=k.observer(({viewID:t,panelID:e})=>{const n=K();if(!n.views.findByID(t))return h(s.Text,{size:14,children:["View by ID[",t,"] is not found"]});const a=n.panels.findByID(e);return a?i(IS,{panel:a}):h(s.Text,{size:14,children:["Panel by ID[",e,"] is not found"]})}),kl=({width:t="calc(100% - 32px)",lastWidth:e="50%",height:n,count:r,spacing:a=16,pl:o=0})=>h(s.Stack,{spacing:a,mt:6,pl:o,children:[Array.from(new Array(r-1),(l,c)=>i(s.Skeleton,{width:t,height:n,radius:"xs"},c)),i(s.Skeleton,{width:e,height:n,radius:"xs"})]}),ln=({value:t})=>t===null||t===""?null:i(s.Tooltip,{label:t,disabled:!t,multiline:!0,children:i(s.ActionIcon,{children:i(O.IconInfoCircle,{size:14})})}),ES=({column:t})=>{const{column_key:e,column_key_text:n}=t;return e?i(s.Tooltip,{label:n,disabled:!n,children:i(s.Badge,{children:e})}):null},AS=k.observer(({dataSource:t})=>{const{columns:e}=t;return e.loading?i(kl,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):e.empty?null:h(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[h("colgroup",{children:[i("col",{style:{width:50}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:30}}),i("col",{style:{width:70}}),i("col",{style:{minWidth:300}}),i("col",{style:{minWidth:80,width:80}}),i("col",{style:{minWidth:120,width:120}})]}),i("thead",{children:h("tr",{children:[i("th",{children:"#"}),i("th",{children:"Column Name"}),i("th",{}),i("th",{}),i("th",{children:"Type"}),i("th",{children:"Nullable"}),i("th",{children:"Default Value"})]})}),i("tbody",{children:e.data.map(n=>h("tr",{children:[i("td",{children:n.ordinal_position}),i("td",{children:n.column_name}),i("td",{children:i(ln,{value:n.column_comment})}),i("td",{children:i(ES,{column:n})}),i("td",{children:n.column_type}),i("td",{children:n.is_nullable}),i("td",{children:i(ln,{value:n.column_default})})]},n.column_name))})]})}),zS=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return h(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[h("colgroup",{children:[i("col",{style:{width:100}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:150}}),i("col",{style:{width:250}})]}),i("thead",{children:h("tr",{children:[i("th",{children:"Index Length"}),i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Column Name"})]})}),i("tbody",{children:n.map(r=>h("tr",{children:[i("td",{children:r.index_length}),i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:r.column_name})]},r.index_name))})]})}),$S=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return h(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[h("colgroup",{children:[i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}})]}),i("thead",{children:h("tr",{children:[i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Definition"}),i("th",{children:"Condition"}),i("th",{children:"Comment"})]})}),i("tbody",{children:n.map(r=>h("tr",{children:[i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:i(ln,{value:r.index_definition})}),i("td",{children:i(ln,{value:r.condition})}),i("td",{children:i(ln,{value:r.comment})})]},r.index_name))})]})}),LS=k.observer(({dataSource:t})=>{const{indexes:e}=t;return e.loading||e.empty?null:t.type===be.MySQL?i(zS,{dataSource:t}):t.type===be.Postgresql?i($S,{dataSource:t}):null}),OS=k.observer(({dataSource:t})=>h(s.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[i(Fe,{children:i(AS,{dataSource:t})}),i(Fe,{children:i(LS,{dataSource:t})})]}));function PS({table_type:t}){return t==="VIEW"?i(O.IconEye,{size:14}):t==="BASE TABLE"?i(O.IconTable,{size:14}):null}const BS=k.observer(({dataSource:t})=>{const{tables:e}=t;return e.loading?i(kl,{height:"24px",lastWidth:"50%",count:15}):i(s.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(e.data).map(([n,r])=>i(s.NavLink,{label:n,icon:i(O.IconDatabase,{size:14}),defaultOpened:t.table_schema===n,pl:0,childrenOffset:14,children:r.map(a=>i(s.NavLink,{label:a.table_name,icon:i(PS,{table_type:a.table_type}),onClick:()=>{t.setKeywords(n,a.table_name)},active:t.table_name===a.table_name},a.table_name))},n))})}),VS=({visible:t})=>i(s.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:i(s.LoadingOverlay,{visible:t})}),NS=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],qS={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},FS=k.observer(({dataSource:t})=>{const{tableData:e}=t;return h(s.Group,{pt:10,px:10,position:"apart",children:[h(s.Group,{position:"left",children:[e.maxPage>1&&i(s.Pagination,{size:"sm",page:e.page,onChange:e.setPage,total:e.maxPage,withEdges:e.maxPage>7,styles:{item:{height:"30px"}}}),i(s.Select,{icon:i(s.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:qS,data:NS,value:String(e.limit),onChange:n=>e.setLimit(Number(n))})]}),i(s.Group,{position:"right",children:h(s.Text,{color:"dimmed",my:0,size:14,children:["Total ",e.total," rows"]})})]})}),GS=k.observer(({dataSource:t})=>{const e=t.tableData;return e.maxPage===0?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):e.error?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.error}):e.page===1&&e.loading?i(VS,{visible:!0}):h(Fe,{children:[i(FS,{dataSource:t}),h(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[i(s.LoadingOverlay,{visible:e.loading,overlayBlur:2}),i(wl,{data:e.data})]})]})}),WS={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},RS=k.observer(({dataSource:t})=>(y.useEffect(()=>{t.loadTablesIfEmpty()},[t]),t.tables.error?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.tables.error}):h(s.Flex,{sx:{height:"100%"},children:[i(s.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:i(Fe,{children:i(BS,{dataSource:t})})}),h(s.Tabs,{defaultValue:"structure",styles:WS,children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"structure",icon:i(O.IconColumns,{size:14}),children:"Structure"}),i(s.Tabs.Tab,{value:"data",icon:i(O.IconDatabase,{size:14}),children:"Data"})]}),i(s.Tabs.Panel,{value:"structure",children:i(OS,{dataSource:t})}),i(s.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:i(GS,{dataSource:t})})]})]}))),jS={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"}},Tl=k.observer(({dataSource:t,triggerButtonProps:e={}})=>{const[n,r]=y.useState(!1);return t.type==="http"?null:h(q,{children:[i(s.Modal,{opened:n,onClose:()=>r(!1),title:h(s.Group,{position:"apart",sx:{flexGrow:1},children:[i(s.Text,{fw:500,children:"Explorer Data Source"}),h(s.Group,{spacing:7,children:[i(s.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:t.key}),i(s.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:t.type})]})]}),zIndex:320,size:"96vw",overflow:"inside",styles:jS,children:i(s.Box,{sx:{height:"calc(100vh - 220px)"},children:i(RS,{dataSource:t})})}),i(s.Button,{variant:"subtle",onClick:()=>r(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...e,children:"See Table Structure"})]})}),YS=y.forwardRef(({label:t,type:e,...n},r)=>h(s.Group,{position:"apart",ref:r,...n,children:[i(s.Text,{children:t}),i(s.Text,{children:e})]})),QS=k.observer(({value:t,onChange:e})=>{const n=ge(),{data:r=[],loading:a}=J.useRequest(pr,{refreshDeps:[]},[]),o=y.useMemo(()=>r.map(d=>({label:d.key,value:d.key,type:d.type})),[r]),l=y.useMemo(()=>o.reduce((d,f)=>(d[f.value]=f.type,d),{}),[o]),c=d=>{d!==null&&e({key:d,type:l[d]})},u=y.useMemo(()=>n.datasources.find(t),[n,t]);return i(s.Select,{data:o,label:h(s.Group,{position:"apart",children:[i(s.Box,{children:"Data Source"}),u&&i(Tl,{dataSource:u,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:YS,rightSection:u?i(s.Text,{size:"xs",color:"dimmed",children:u.type}):void 0,rightSectionWidth:85,maxDropdownHeight:280,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:a,value:t.key,onChange:c})}),KS=t=>{const{queryModel:e}=t,n=ge(),r=K(),o=r.findQueryUsage(e.id).length>0,l=Ke.useModals(),c=()=>{l.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(e.id),n.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?i(s.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:i(s.Button,{color:"gray",size:"xs",leftIcon:i(O.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):i(s.Button,{color:"red",size:"xs",onClick:c,leftIcon:i(O.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},US=k.observer(KS),XS=k.observer(({queryModel:t})=>{const[e,n]=y.useState(t.name);return y.useEffect(()=>{n(t.name)},[t.name]),i(s.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:h(s.Stack,{spacing:10,sx:{width:"100%"},children:[i(s.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),i(s.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e,onChange:r=>{n(r.currentTarget.value)},rightSection:i(s.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>t.setName(e),disabled:e===t.name,children:i(O.IconDeviceFloppy,{size:16})}),onBlur:()=>{t.setName(e)}}),i(QS,{value:{type:t.type,key:t.key},onChange:({type:r,key:a})=>{t.setKey(a),t.setType(r)}}),i(s.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),i(s.MultiSelect,{label:"Run query when these are truthy",placeholder:"Always run this query on load",data:t.conditionOptions,value:[...t.run_by],onChange:t.setRunBy}),t.typedAsHTTP&&i(s.MultiSelect,{label:"Re-run query when these changed",placeholder:"Leave it empty to never re-run this query",data:t.conditionOptions,value:[...t.react_to],onChange:t.setReactTo}),i(s.Divider,{mt:20,mb:10,variant:"dashed"}),i(US,{queryModel:t})]})})});function JS(){const[t,{open:e,close:n}]=Ie.useDisclosure(!1);return h(q,{children:[i(s.Modal,{opened:t,onClose:n,title:"About FunctionUtils",zIndex:320,children:i(Yn,{value:ac,styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),i(s.Button,{variant:"light",color:"violet",size:"xs",onClick:e,leftIcon:i(O.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const ZS=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return i(s.Box,{sx:{position:"relative",flexGrow:1},children:i(ze,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},rr=y.forwardRef(({value:t,onChange:e,label:n,defaultValue:r},a)=>{const[o,l]=y.useState(t),c=()=>{e(o)},u=()=>{l(t)},d=()=>{l(r)};y.useEffect(()=>{l(t)},[t]);const f=o!==t;return h(s.Stack,{spacing:4,sx:{height:"100%"},children:[h(s.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[i(s.Group,{position:"left",children:i(JS,{})}),h(s.Group,{position:"right",children:[i(s.Button,{onClick:d,size:"xs",variant:"default",leftIcon:i(O.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),i(s.Button,{onClick:u,color:"red",size:"xs",disabled:!f,leftIcon:i(O.IconRecycle,{size:16}),children:"Revert Changes"}),i(s.Button,{size:"xs",onClick:c,disabled:!f,leftIcon:i(O.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),i(s.Text,{size:14,children:n}),i(ZS,{value:o,onChange:l})]})});function HS({content:t}){return h(s.HoverCard,{width:"60vw",shadow:"md",children:[i(s.HoverCard.Target,{children:i(s.ActionIcon,{size:16,color:"blue",children:i(O.IconEye,{})})}),i(s.HoverCard.Dropdown,{children:i(St.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:t})})]})}const e_=k.observer(()=>{const e=[...ge().globalSQLSnippets.list];return e.length===0?null:h(s.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[i("thead",{children:h("tr",{children:[i("th",{children:"Key"}),i("th",{children:"Value"})]})}),i("tbody",{children:e.map(n=>{const{id:r,content:a}=n;return h("tr",{children:[i("td",{children:r}),i("td",{width:200,children:i(HS,{content:a})})]},r)})})]})}),t_=`
495
+ `,K1=()=>{const[t,e]=y.useState(!1);return h(q,{children:[i(s.Button,{variant:"subtle",compact:!0,onClick:()=>e(n=>!n),children:t?"Close":"Click to see expected data structure"}),i(s.Collapse,{in:t,children:i(St.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:Q1})})]})},U1=k.observer(function({config:e}){return h(q,{children:[i(s.TextInput,{label:"Min-width",value:e.min_width,onChange:n=>e.setMinWidth(n.currentTarget.value),placeholder:"200px"}),i(s.Divider,{label:"Fetch options from database",labelPosition:"center"}),i(s.NumberInput,{value:e.default_selection_count,onChange:e.setDefaultSelectionCount,label:"Select first N options by default"}),i(Mi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(K1,{})]})}),X1=k.observer(function({filter:e}){const[n,r]=y.useState(e.plainDefaultValue);return y.useEffect(()=>{r(e.plainDefaultValue)},[e]),h(s.Box,{sx:{maxWidth:"480px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Preview"}),i(sl,{filter:e,value:n,onChange:r}),i(s.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),i(St.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),J1={select:j1,"multi-select":R1,"tree-select":U1,"text-input":Y1,checkbox:q1,"date-range":G1},Z1=[{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"}],H1=k.observer(function({filter:e}){const n=K(),r=y.useMemo(()=>J1[e.type],[e.type]);return h(s.Group,{grow:!0,spacing:20,align:"top",children:[h(s.Box,{sx:{maxWidth:"600px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Edit"}),h(s.Stack,{children:[h(s.Group,{noWrap:!0,children:[i(s.NumberInput,{label:"Placement Order",required:!0,value:e.order,onChange:e.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),e.auto_submit_supported&&i(s.Checkbox,{label:"Submit automatically",checked:e.auto_submit,onChange:a=>e.setAutoSubmit(a.currentTarget.checked),mt:22})]}),i(s.MultiSelect,{label:"Visible in...",data:n.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),i(s.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:e.key,onChange:a=>{e.setKey(a.currentTarget.value)}}),i(s.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:e.label,onChange:a=>{e.setLabel(a.currentTarget.value)}}),i(s.Select,{label:"Widget",data:Z1,required:!0,value:e.type,onChange:e.setType}),i(r,{config:e.config})]})]}),i(X1,{filter:e})]})}),eS=k.observer(({id:t})=>{const e=Ke.useModals(),n=ge(),r=K();if(t==="")return null;const a=r.filters.findByID(t);if(!a)return h(s.Text,{size:14,children:["Filter by ID[",t,"] is not found"]});const o=()=>{n.editor.setPath(["_FILTERS_",""])},l=()=>{e.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.filters.removeByID(t),o()},confirmProps:{color:"red"},zIndex:320})};return h(s.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(I.Trash,{size:16}),onClick:l,children:"Delete this filter"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(H1,{filter:a})})]})}),tS=k.observer(()=>{const t=K(),[e,n]=y.useState(()=>JSON.stringify(t.mock_context.current,null,4)),r=()=>{try{t.mock_context.replace(JSON.parse(e))}catch(o){fn.showNotification({title:"Failed",message:o.message,color:"red"})}},a=y.useMemo(()=>{try{return JSON.stringify(JSON.parse(e))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[e,t.mock_context.current]);return h(s.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[i(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:i(s.Text,{weight:500,children:"Mock Context"})}),h(s.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[h(s.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[i(s.Text,{children:"A valid json string is required"}),i(s.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:e,onChange:n,sx:{flexGrow:1}})]}),i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:r,children:i(I.DeviceFloppy,{size:20})})]})]})}),nS=k.observer(()=>{const{panel:t}=Ae();return i(ri,{label:"Description",value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),rS=k.observer(()=>{const{panel:t}=Ae(),{style:e}=t;return i(q,{children:i(s.Switch,{label:"Border",checked:e.border.enabled,onChange:n=>e.border.setEnabled(n.currentTarget.checked)})})}),iS=k.observer(()=>{const{panel:t}=Ae(),{title:e,setTitle:n}=t,[r,a]=Ie.useInputState(e),o=e!==r,l=y.useCallback(()=>{o&&n(r)},[o,r]);return y.useEffect(()=>{a(e)},[e]),i(s.TextInput,{value:r,onChange:a,label:h(s.Group,{children:[i(s.Text,{children:"Panel Title"}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:l,children:i(I.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function aS(){return h(s.Stack,{sx:{height:"100%"},children:[i(s.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),i(rS,{}),i(s.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),i(iS,{}),i(nS,{})]})}const sS=({queryID:t})=>{const e=K(),{state:n,error:r}=e.getDataStuffByID(t),a=y.useMemo(()=>e.queries.findByID(t),[e,t]);return n==="loading"?null:r?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):a!=null&&a.stateMessage?i(s.Text,{color:"gray",align:"center",children:a.stateMessage}):null},oS={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 wl({data:t}){const e=y.useMemo(()=>{if(!Array.isArray(t)||t.length===0)return[];const r=Ue.createColumnHelper();return Object.keys(t[0]).map(a=>r.accessor(a,{cell:o=>o.getValue()}))},[t]),n=Ue.useReactTable({data:t,columns:e,columnResizeMode:"onChange",getCoreRowModel:Ue.getCoreRowModel()});return t.length===0?i(s.Box,{sx:{height:"5em"}}):i(Fe,{children:h(s.Table,{sx:oS,children:[i("thead",{children:n.getHeaderGroups().map(r=>i("tr",{children:r.headers.map(a=>h("th",{style:{width:a.getSize()},children:[a.isPlaceholder?null:Ue.flexRender(a.column.columnDef.header,a.getContext()),i(s.ActionIcon,{onMouseDown:a.getResizeHandler(),onTouchStart:a.getResizeHandler(),className:`resizer ${a.column.getIsResizing()?"isResizing":""}`,children:i(I.ArrowBarToRight,{})})]},a.id))},r.id))}),i("tbody",{children:n.getRowModel().rows.map(r=>i("tr",{children:r.getVisibleCells().map(a=>i("td",{children:i(Fe,{children:Ue.flexRender(a.column.columnDef.cell,a.getContext())})},a.id))},r.id))})]})})}const Ei=k.observer(function({id:e,moreActions:n=null}){const r=K(),{data:a,state:o}=r.getDataStuffByID(e),l=o==="loading",c=()=>{r.queries.refetchDataByQueryID(e)},u=()=>{r.queries.downloadDataByQueryID(e)},d=y.useMemo(()=>Array.isArray(a)?a.slice(0,10):[],[a]),f=!Array.isArray(a)||a.length===0;return h(s.Stack,{sx:{border:"1px solid #eee"},children:[h(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[h(s.Group,{position:"left",children:[i(s.Text,{weight:500,children:"Preview Data"}),a.length>10&&h(s.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",a.length]})]}),h(s.Group,{pr:15,children:[n,i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l,onClick:c,children:i(I.Refresh,{size:16})}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l||f,onClick:u,children:i(I.Download,{size:16})})]})]}),h(s.Box,{sx:{position:"relative",overflow:"auto"},children:[i(s.LoadingOverlay,{visible:l}),i(sS,{queryID:e}),i(wl,{data:d})]})]})}),lS=k.observer(function(){const e=ge(),n=K(),{panel:r}=Ae(),[a,o]=y.useState(!1),l=c=>{e.editor.setPath(["_QUERIES_",c])};return h(q,{children:[i(s.Drawer,{opened:a,onClose:()=>o(!1),title:"Choose queries",padding:"xl",size:"xl",zIndex:320,children:i(s.Checkbox.Group,{orientation:"vertical",value:[...r.queryIDs],onChange:r.setQueryIDs,children:n.queries.options.map(c=>i(s.Checkbox,{label:c.label,value:c.value},c.value))})}),h(s.Stack,{spacing:6,children:[i(s.Group,{position:"right",children:i(s.Button,{variant:"light",size:"sm",leftIcon:i(O.IconLine,{size:16}),onClick:()=>o(!0),children:"Click me to choose queries for this panel"})}),r.queryIDs.length===1&&i(Ei,{id:r.queryIDs[0],moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(r.queryIDs[0]),children:i(O.IconArrowCurveRight,{size:16})})})}),r.queryIDs.length>1&&h(s.Tabs,{defaultValue:r.queryIDs[0],children:[i(s.Tabs.List,{children:r.queries.map(c=>i(s.Tabs.Tab,{value:c.id,children:c.name},c.id))}),r.queries.map(c=>i(s.Tabs.Panel,{value:c.id,children:i(Ei,{id:c.id,moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(c.id),children:i(O.IconArrowCurveRight,{size:16})})})})},c.id))]})]})]})}),cS=k.observer(()=>{const{panel:t}=Ae();return i(Fe,{children:i(s.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:h(s.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.style.border.enabled?"1px":"0px"},children:[h(s.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[i(s.Group,{children:i(ll,{})}),i(s.Group,{grow:!0,position:"center",children:i(s.Text,{lineClamp:1,weight:"bold",children:t.title})}),i(s.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),i(s.Group,{px:5,pb:5,sx:{flexGrow:1},children:i(hl,{panel:t,height:"410px"})})]})})})}),Ai={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 uS{constructor(e){N(this,"panel");N(this,"selected");this.panel=e,ae.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const e=this.panel.variables.filter(n=>n.name.startsWith(Ai.name)).length;this.panel.addVariable(v.cloneDeep({...Ai,name:`${Ai.name}${e||""}`})),this.selected=v.last(this.panel.variables)}select(e){this.selected=e}remove(e){this.selected===e&&(this.selected=void 0);const n=this.panel.variables.indexOf(e);if(this.panel.removeVariable(e),!this.selected&&!v.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function dS(){const{panel:t}=Ae();return J.useCreation(()=>new uS(t),[t])}const Cl=s.createStyles(t=>({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}})),pS=y.forwardRef(function({value:e,onChange:n,data:r,withStyle:a=!0},o){const l=(c,u)=>{const d=v.cloneDeep(e);v.set(d,c,u),n(d)};return h(s.Box,{px:"sm",py:"md",ref:o,children:[h(s.Group,{grow:!0,noWrap:!0,children:[i(s.TextInput,{label:"Name",required:!0,value:e.name,onChange:c=>l("name",c.currentTarget.value)}),i(j,{label:"Data Field",required:!0,value:e.data_field,onChange:c=>l("data_field",c)})]}),i(Sn,{label:"Aggregation",value:e.aggregation,onChange:c=>l("aggregation",c)}),i(s.Divider,{my:"xs",label:"Format",labelPosition:"center"}),i(Je,{value:e.formatter,onChange:c=>l("formatter",c)}),a&&i(Ss,{value:e,onChange:n})]})}),hS=t=>{const{uiModel:e}=t;return i(s.Stack,{className:"var-list",children:e.variables.map(n=>i(s.Button,{variant:e.selected===n?"filled":"subtle",color:"gray",onClick:()=>e.select(n),children:n.name},n.name))})},fS=k.observer(hS),gS=({variable:t,data:e})=>i(s.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:i(s.Paper,{withBorder:!0,p:"md",children:_s(t,e)})}),mS=k.observer(gS),yS=t=>{const e=J.useCreation(()=>Wc(t.variable),[t.variable]),{classes:n}=Cl(),{data:r}=Ae();return h(s.Group,{style:{height:"100%"},align:"start",children:[h(s.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[h(s.Group,{position:"right",children:[i(s.ActionIcon,{variant:"filled",disabled:!e.changed,color:"primary",onClick:e.commit,children:i(O.IconDeviceFloppy,{size:18})}),i(s.ActionIcon,{color:"red",onClick:()=>t.uiModel.remove(t.variable),children:i(O.IconTrash,{size:18})})]}),i(pS,{value:b.getSnapshot(e.copy),onChange:e.update,data:r})]}),i(mS,{variable:b.getSnapshot(e.copy),data:r})]})},bS=k.observer(yS),vS=()=>{const t=dS(),{classes:e}=Cl();return h(s.Group,{className:e.root,noWrap:!0,align:"start",children:[i(s.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:h(s.Stack,{justify:"space-between",children:[i(s.Box,{className:"var-list-actions",children:i(s.Button,{variant:"light",size:"sm",onClick:t.addNew,fullWidth:!0,children:"Add Variable"})}),i(fS,{uiModel:t})]})}),t.selected?i(q,{children:i(bS,{uiModel:t,variable:t.selected})}):i("span",{children:"Select or create a new variable on right side"})]})},xS=k.observer(vS);function wS(){const{vizManager:t}=y.useContext(it);return y.useMemo(()=>{const e=t.availableVizList.map(n=>({value:n.name,label:n.displayName??n.name,group:n.displayGroup??""}));return v.orderBy(e,[n=>n.group,n=>n.label],["asc","asc"])},[t])}const CS=k.observer(({value:t,submit:e})=>{const[n,r]=Ie.useInputState(t);y.useEffect(()=>{r(t)},[t]);const a=wS(),o=t!==n;return i(s.Select,{label:"Visualization",value:n,searchable:!0,onChange:r,data:a,rightSection:i(s.ActionIcon,{disabled:!o,onClick:()=>e(n),children:i(I.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Sl=[];function SS(t,e){try{return t.resolveComponent(e).createConfig()}catch{return null}}function _S(){const{data:t,panel:{variables:e,viz:n,title:r,queryIDs:a,description:o,setDescription:l,setTitle:c,addQueryID:u,removeQueryID:d,id:f}}=Ae(),{vizManager:p}=y.useContext(it),g={title:r,description:o,viz:n,queryIDs:a,id:f},m={setDescription:l,addQueryID:u,removeQueryID:d,setTitle:c},C=ul(g);try{return p.resolveComponent(g.viz.type),i(Jn,{configure:C,children:i(zC,{variables:e,setVizConf:n.setConf,panel:g,panelInfoEditor:m,vizManager:p,data:t})})}catch(w){return console.info(v.get(w,"message")),null}}const kS=k.observer(()=>{const{data:t,panel:{viz:e}}=Ae(),{vizManager:n}=y.useContext(it),r=y.useCallback(d=>{if(d===e.type)return;const f=SS(n,d);e.setType(d),e.setConf(f||{})},[e.type]),a=d=>{try{e.setConf(JSON.parse(d))}catch(f){console.error(f)}},o=y.useMemo(()=>{var d;return(d=Sl.find(f=>f.value===e.type))==null?void 0:d.Panel},[e.type,Sl]),l=_S(),c=o?y.createElement(o,{data:t,conf:e.conf,setConf:e.setConf}):null,u=l||c;return h(s.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[i(CS,{submit:r,value:e.type}),h(Fe,{children:[i(s.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&i(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:a})]})]})}),TS=k.observer(({panel:t,sourceViewID:e})=>{const n=K(),[r,a]=y.useState(e);y.useEffect(()=>{a(e)},[e]);const[o,{open:l,close:c}]=Ie.useDisclosure(!1),u=()=>{t.moveToView(e,r),c()};return h(q,{children:[i(s.Button,{size:"xs",variant:"subtle",color:"blue",onClick:l,leftIcon:i(O.IconBoxMultiple,{size:14}),children:"Move into Another View"}),i(s.Modal,{opened:o,onClose:c,title:"Move panel into another view",zIndex:320,overflow:"inside",children:h(s.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[i(s.Radio.Group,{value:r,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:i(s.Stack,{spacing:"xs",children:n.views.options.map(d=>i(s.Radio,{value:d.value,label:d.label},d.value))})}),h(s.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[i(s.Button,{size:"xs",color:"red",leftIcon:i(O.IconX,{size:14}),onClick:c,children:"Cancel"}),i(s.Button,{size:"xs",color:"blue",leftIcon:i(O.IconDeviceFloppy,{size:14}),onClick:u,disabled:r===e,children:"Confirm"})]})]})})]})}),DS={root:{flexGrow:1,width:"100%",overflow:"hidden"},panel:{width:"100%",height:"calc(100% - 44px)",padding:10,overflow:"scroll"}},_l=({children:t})=>h(s.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%"},children:[i(s.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:t}),i(cS,{})]});function IS(t){return!["richText","button"].includes(t)}const MS=k.observer(({panel:t})=>{const e=Ke.useModals(),n=ge(),r=K(),[a,o]=y.useState("Data"),l=t.queries,u=IS(t.viz.type)&&t.dataLoading,d=u||t.queryErrors.length>0||t.queryStateMessages.length>0||l.length===0,f=n.editor.path[1];y.useEffect(()=>{o(m=>d&&m==="Visualization"?"Data":m)},[t.id,d]);const p=()=>{n.editor.setPath(["_VIEWS_",f])},g=()=>e.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(t.id,f),p()},confirmProps:{color:"red"},zIndex:320});return h(wr,{value:{panel:t,data:t.data,loading:u,errors:t.queryErrors},children:[h(s.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[h(s.Text,{pt:9,pb:8,children:[t.title?t.title:t.viz.type," "]}),h(s.Group,{position:"right",noWrap:!0,children:[i(TS,{panel:t,sourceViewID:f}),i(s.Button,{size:"xs",variant:"subtle",color:"red",onClick:g,leftIcon:i(O.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),h(s.Tabs,{value:a,onTabChange:o,keepMounted:!1,styles:DS,children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Data",disabled:u,children:"Data"}),i(s.Tabs.Tab,{value:"Panel",children:"Panel"}),i(s.Tabs.Tab,{value:"Variables",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Variables"})})}),i(s.Tabs.Tab,{value:"Visualization",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Visualization"})})}),i(s.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),h(s.Tabs.Panel,{value:"Data",children:[i(s.LoadingOverlay,{visible:u,exitTransitionDuration:0}),i(lS,{})]}),i(s.Tabs.Panel,{value:"Panel",children:i(_l,{children:i(aS,{})})}),i(s.Tabs.Panel,{value:"Variables",children:i(xS,{})}),i(s.Tabs.Panel,{value:"Visualization",children:i(Fe,{children:i(_l,{children:i(kS,{})})})}),i(s.Tabs.Panel,{value:"Interactions",children:i(Fe,{children:i($u,{})})})]})]})}),ES=k.observer(({viewID:t,panelID:e})=>{const n=K();if(!n.views.findByID(t))return h(s.Text,{size:14,children:["View by ID[",t,"] is not found"]});const a=n.panels.findByID(e);return a?i(MS,{panel:a}):h(s.Text,{size:14,children:["Panel by ID[",e,"] is not found"]})}),kl=({width:t="calc(100% - 32px)",lastWidth:e="50%",height:n,count:r,spacing:a=16,pl:o=0})=>h(s.Stack,{spacing:a,mt:6,pl:o,children:[Array.from(new Array(r-1),(l,c)=>i(s.Skeleton,{width:t,height:n,radius:"xs"},c)),i(s.Skeleton,{width:e,height:n,radius:"xs"})]}),ln=({value:t})=>t===null||t===""?null:i(s.Tooltip,{label:t,disabled:!t,multiline:!0,children:i(s.ActionIcon,{children:i(O.IconInfoCircle,{size:14})})}),AS=({column:t})=>{const{column_key:e,column_key_text:n}=t;return e?i(s.Tooltip,{label:n,disabled:!n,children:i(s.Badge,{children:e})}):null},zS=k.observer(({dataSource:t})=>{const{columns:e}=t;return e.loading?i(kl,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):e.empty?null:h(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[h("colgroup",{children:[i("col",{style:{width:50}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:30}}),i("col",{style:{width:70}}),i("col",{style:{minWidth:300}}),i("col",{style:{minWidth:80,width:80}}),i("col",{style:{minWidth:120,width:120}})]}),i("thead",{children:h("tr",{children:[i("th",{children:"#"}),i("th",{children:"Column Name"}),i("th",{}),i("th",{}),i("th",{children:"Type"}),i("th",{children:"Nullable"}),i("th",{children:"Default Value"})]})}),i("tbody",{children:e.data.map(n=>h("tr",{children:[i("td",{children:n.ordinal_position}),i("td",{children:n.column_name}),i("td",{children:i(ln,{value:n.column_comment})}),i("td",{children:i(AS,{column:n})}),i("td",{children:n.column_type}),i("td",{children:n.is_nullable}),i("td",{children:i(ln,{value:n.column_default})})]},n.column_name))})]})}),$S=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return h(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[h("colgroup",{children:[i("col",{style:{width:100}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:150}}),i("col",{style:{width:250}})]}),i("thead",{children:h("tr",{children:[i("th",{children:"Index Length"}),i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Column Name"})]})}),i("tbody",{children:n.map(r=>h("tr",{children:[i("td",{children:r.index_length}),i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:r.column_name})]},r.index_name))})]})}),LS=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return h(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[h("colgroup",{children:[i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}})]}),i("thead",{children:h("tr",{children:[i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Definition"}),i("th",{children:"Condition"}),i("th",{children:"Comment"})]})}),i("tbody",{children:n.map(r=>h("tr",{children:[i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:i(ln,{value:r.index_definition})}),i("td",{children:i(ln,{value:r.condition})}),i("td",{children:i(ln,{value:r.comment})})]},r.index_name))})]})}),OS=k.observer(({dataSource:t})=>{const{indexes:e}=t;return e.loading||e.empty?null:t.type===be.MySQL?i($S,{dataSource:t}):t.type===be.Postgresql?i(LS,{dataSource:t}):null}),PS=k.observer(({dataSource:t})=>h(s.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[i(Fe,{children:i(zS,{dataSource:t})}),i(Fe,{children:i(OS,{dataSource:t})})]}));function BS({table_type:t}){return t==="VIEW"?i(O.IconEye,{size:14}):t==="BASE TABLE"?i(O.IconTable,{size:14}):null}const VS=k.observer(({dataSource:t})=>{const{tables:e}=t;return e.loading?i(kl,{height:"24px",lastWidth:"50%",count:15}):i(s.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(e.data).map(([n,r])=>i(s.NavLink,{label:n,icon:i(O.IconDatabase,{size:14}),defaultOpened:t.table_schema===n,pl:0,childrenOffset:14,children:r.map(a=>i(s.NavLink,{label:a.table_name,icon:i(BS,{table_type:a.table_type}),onClick:()=>{t.setKeywords(n,a.table_name)},active:t.table_name===a.table_name},a.table_name))},n))})}),NS=({visible:t})=>i(s.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:i(s.LoadingOverlay,{visible:t})}),qS=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],FS={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},GS=k.observer(({dataSource:t})=>{const{tableData:e}=t;return h(s.Group,{pt:10,px:10,position:"apart",children:[h(s.Group,{position:"left",children:[e.maxPage>1&&i(s.Pagination,{size:"sm",page:e.page,onChange:e.setPage,total:e.maxPage,withEdges:e.maxPage>7,styles:{item:{height:"30px"}}}),i(s.Select,{icon:i(s.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:FS,data:qS,value:String(e.limit),onChange:n=>e.setLimit(Number(n))})]}),i(s.Group,{position:"right",children:h(s.Text,{color:"dimmed",my:0,size:14,children:["Total ",e.total," rows"]})})]})}),WS=k.observer(({dataSource:t})=>{const e=t.tableData;return e.maxPage===0?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):e.error?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.error}):e.page===1&&e.loading?i(NS,{visible:!0}):h(Fe,{children:[i(GS,{dataSource:t}),h(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[i(s.LoadingOverlay,{visible:e.loading,overlayBlur:2}),i(wl,{data:e.data})]})]})}),RS={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},jS=k.observer(({dataSource:t})=>(y.useEffect(()=>{t.loadTablesIfEmpty()},[t]),t.tables.error?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.tables.error}):h(s.Flex,{sx:{height:"100%"},children:[i(s.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:i(Fe,{children:i(VS,{dataSource:t})})}),h(s.Tabs,{defaultValue:"structure",styles:RS,children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"structure",icon:i(O.IconColumns,{size:14}),children:"Structure"}),i(s.Tabs.Tab,{value:"data",icon:i(O.IconDatabase,{size:14}),children:"Data"})]}),i(s.Tabs.Panel,{value:"structure",children:i(PS,{dataSource:t})}),i(s.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:i(WS,{dataSource:t})})]})]}))),YS={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"}},Tl=k.observer(({dataSource:t,triggerButtonProps:e={}})=>{const[n,r]=y.useState(!1);return t.type==="http"?null:h(q,{children:[i(s.Modal,{opened:n,onClose:()=>r(!1),title:h(s.Group,{position:"apart",sx:{flexGrow:1},children:[i(s.Text,{fw:500,children:"Explorer Data Source"}),h(s.Group,{spacing:7,children:[i(s.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:t.key}),i(s.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:t.type})]})]}),zIndex:320,size:"96vw",overflow:"inside",styles:YS,children:i(s.Box,{sx:{height:"calc(100vh - 220px)"},children:i(jS,{dataSource:t})})}),i(s.Button,{variant:"subtle",onClick:()=>r(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...e,children:"See Table Structure"})]})}),QS=y.forwardRef(({label:t,type:e,...n},r)=>h(s.Group,{position:"apart",ref:r,...n,children:[i(s.Text,{children:t}),i(s.Text,{children:e})]})),KS=k.observer(({value:t,onChange:e})=>{const n=ge(),{data:r=[],loading:a}=J.useRequest(pr,{refreshDeps:[]},[]),o=y.useMemo(()=>r.map(d=>({label:d.key,value:d.key,type:d.type})),[r]),l=y.useMemo(()=>o.reduce((d,f)=>(d[f.value]=f.type,d),{}),[o]),c=d=>{d!==null&&e({key:d,type:l[d]})},u=y.useMemo(()=>n.datasources.find(t),[n,t]);return i(s.Select,{data:o,label:h(s.Group,{position:"apart",children:[i(s.Box,{children:"Data Source"}),u&&i(Tl,{dataSource:u,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:QS,rightSection:u?i(s.Text,{size:"xs",color:"dimmed",children:u.type}):void 0,rightSectionWidth:85,maxDropdownHeight:280,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:a,value:t.key,onChange:c})}),US=t=>{const{queryModel:e}=t,n=ge(),r=K(),o=r.findQueryUsage(e.id).length>0,l=Ke.useModals(),c=()=>{l.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(e.id),n.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?i(s.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:i(s.Button,{color:"gray",size:"xs",leftIcon:i(O.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):i(s.Button,{color:"red",size:"xs",onClick:c,leftIcon:i(O.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},XS=k.observer(US),JS=k.observer(({queryModel:t})=>{const[e,n]=y.useState(t.name);return y.useEffect(()=>{n(t.name)},[t.name]),i(s.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:h(s.Stack,{spacing:10,sx:{width:"100%"},children:[i(s.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),i(s.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e,onChange:r=>{n(r.currentTarget.value)},rightSection:i(s.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>t.setName(e),disabled:e===t.name,children:i(O.IconDeviceFloppy,{size:16})}),onBlur:()=>{t.setName(e)}}),i(KS,{value:{type:t.type,key:t.key},onChange:({type:r,key:a})=>{t.setKey(a),t.setType(r)}}),i(s.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),i(s.MultiSelect,{label:"Run query when these are truthy",placeholder:"Always run this query on load",data:t.conditionOptions,value:[...t.run_by],onChange:t.setRunBy}),t.typedAsHTTP&&i(s.MultiSelect,{label:"Re-run query when these changed",placeholder:"Leave it empty to never re-run this query",data:t.conditionOptions,value:[...t.react_to],onChange:t.setReactTo}),i(s.Divider,{mt:20,mb:10,variant:"dashed"}),i(XS,{queryModel:t})]})})});function ZS(){const[t,{open:e,close:n}]=Ie.useDisclosure(!1);return h(q,{children:[i(s.Modal,{opened:t,onClose:n,title:"About FunctionUtils",zIndex:320,children:i(Yn,{value:ac,styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),i(s.Button,{variant:"light",color:"violet",size:"xs",onClick:e,leftIcon:i(O.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const HS=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return i(s.Box,{sx:{position:"relative",flexGrow:1},children:i(ze,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},rr=y.forwardRef(({value:t,onChange:e,label:n,defaultValue:r},a)=>{const[o,l]=y.useState(t),c=()=>{e(o)},u=()=>{l(t)},d=()=>{l(r)};y.useEffect(()=>{l(t)},[t]);const f=o!==t;return h(s.Stack,{spacing:4,sx:{height:"100%"},children:[h(s.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[i(s.Group,{position:"left",children:i(ZS,{})}),h(s.Group,{position:"right",children:[i(s.Button,{onClick:d,size:"xs",variant:"default",leftIcon:i(O.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),i(s.Button,{onClick:u,color:"red",size:"xs",disabled:!f,leftIcon:i(O.IconRecycle,{size:16}),children:"Revert Changes"}),i(s.Button,{size:"xs",onClick:c,disabled:!f,leftIcon:i(O.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),i(s.Text,{size:14,children:n}),i(HS,{value:o,onChange:l})]})});function e_({content:t}){return h(s.HoverCard,{width:"60vw",shadow:"md",children:[i(s.HoverCard.Target,{children:i(s.ActionIcon,{size:16,color:"blue",children:i(O.IconEye,{})})}),i(s.HoverCard.Dropdown,{children:i(St.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:t})})]})}const t_=k.observer(()=>{const e=[...ge().globalSQLSnippets.list];return e.length===0?null:h(s.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[i("thead",{children:h("tr",{children:[i("th",{children:"Key"}),i("th",{children:"Value"})]})}),i("tbody",{children:e.map(n=>{const{id:r,content:a}=n;return h("tr",{children:[i("td",{children:r}),i("td",{width:200,children:i(e_,{content:a})})]},r)})})]})}),n_=`
496
496
  -- You may reference query variables in SQL or VizConfig.
497
497
  SELECT *
498
498
  FROM commit
@@ -505,8 +505,8 @@ WHERE
505
505
  AND \${sql_snippets.author_email_condition}
506
506
  -- Global SQL snippets (shared between dashboards)
507
507
  AND \${global_sql_snippets.account_condition}
508
- `,Dl=k.observer(function({showSQLSnippets:e=!0,sx:n={}}){const r=ge(),a=K(),o=r.context.current,l=(()=>{const c={context:{...a.mock_context.current,...o},filters:a.filters.previewValues};return e&&(c.sql_snippets=a.sqlSnippets.record),JSON.stringify(c,null,2)})();return i(s.Stack,{sx:{overflow:"hidden",...n},children:h(s.Tabs,{defaultValue:"guide",keepMounted:!1,children:[h(s.Tabs.List,{grow:!0,children:[i(s.Tabs.Tab,{value:"guide",icon:i(O.IconAlertCircle,{size:14}),children:"Guide"}),i(s.Tabs.Tab,{value:"local_query_vars",icon:i(O.IconVariable,{size:14}),children:"Variables in this dashboard"}),i(s.Tabs.Tab,{value:"global_sql_snippets",icon:i(O.IconVariablePlus,{size:14}),children:"Global SQL Snippets"})]}),i(s.Tabs.Panel,{value:"guide",pt:"xs",children:i(St.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:t_})}),i(s.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:i(St.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l})}),i(s.Tabs.Panel,{value:"global_sql_snippets",pt:"xs",children:h(s.Stack,{spacing:10,children:[i(s.Alert,{icon:i(O.IconAlertCircle,{size:16}),title:"Global SQL Snippets",children:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."}),i(e_,{})]})})]})})}),zi=k.observer(()=>{const[t,e]=y.useState(!1);return h(q,{children:[i(s.Modal,{opened:t,onClose:()=>e(!1),title:"Query Variables",zIndex:320,size:"800px",children:i(Dl,{})}),i(s.Button,{variant:"subtle",onClick:()=>e(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:"See Query Variables"})]})}),Il={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
508
+ `,Dl=k.observer(function({showSQLSnippets:e=!0,sx:n={}}){const r=ge(),a=K(),o=r.context.current,l=(()=>{const c={context:{...a.mock_context.current,...o},filters:a.filters.previewValues};return e&&(c.sql_snippets=a.sqlSnippets.record),JSON.stringify(c,null,2)})();return i(s.Stack,{sx:{overflow:"hidden",...n},children:h(s.Tabs,{defaultValue:"guide",keepMounted:!1,children:[h(s.Tabs.List,{grow:!0,children:[i(s.Tabs.Tab,{value:"guide",icon:i(O.IconAlertCircle,{size:14}),children:"Guide"}),i(s.Tabs.Tab,{value:"local_query_vars",icon:i(O.IconVariable,{size:14}),children:"Variables in this dashboard"}),i(s.Tabs.Tab,{value:"global_sql_snippets",icon:i(O.IconVariablePlus,{size:14}),children:"Global SQL Snippets"})]}),i(s.Tabs.Panel,{value:"guide",pt:"xs",children:i(St.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:n_})}),i(s.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:i(St.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l})}),i(s.Tabs.Panel,{value:"global_sql_snippets",pt:"xs",children:h(s.Stack,{spacing:10,children:[i(s.Alert,{icon:i(O.IconAlertCircle,{size:16}),title:"Global SQL Snippets",children:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."}),i(t_,{})]})})]})})}),zi=k.observer(()=>{const[t,e]=y.useState(!1);return h(q,{children:[i(s.Modal,{opened:t,onClose:()=>e(!1),title:"Query Variables",zIndex:320,size:"800px",children:i(Dl,{})}),i(s.Button,{variant:"subtle",onClick:()=>e(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:"See Query Variables"})]})}),Il={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
509
509
  `),post:["function process_result(res, utils) {"," // your code goes here"," return data","}"].join(`
510
- `)},n_=k.observer(({queryModel:t})=>t.typedAsHTTP?h(s.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"pre_process",children:"Build Request"}),i(s.Tabs.Tab,{value:"post_process",children:"Process Result"}),i(zi,{})]}),i(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:i(rr,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:Il.pre})}),i(s.Tabs.Panel,{value:"post_process",p:"sm",children:i(rr,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:Il.post})})]}):null),r_=k.observer(({queryID:t,usage:e})=>{const n=ge().editor,r=o=>{if(o.type==="filter"){n.setPath(["_FILTERS_",o.id]);return}if(o.type==="panel"){const l=o.views[0].id;n.setPath(["_VIEWS_",l,"_PANELS_",o.id]);return}},a=o=>{n.setPath(["_VIEWS_",o])};return i(s.Stack,{py:"sm",px:"md",children:h(s.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[i("thead",{children:h("tr",{children:[i("th",{style:{width:100},children:"Type"}),i("th",{style:{width:"calc(50% - 50px)"},children:"Name"}),i("th",{children:"In View(s)"})]})}),i("tbody",{children:e.map(o=>h("tr",{children:[i("td",{children:v.capitalize(o.type)}),i("td",{children:i(s.Anchor,{component:"button",type:"button",onClick:()=>r(o),children:o.label})}),i("td",{children:h(s.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[o.views.map(l=>i(s.Anchor,{component:"button",type:"button",onClick:()=>a(l.id),children:i(s.Box,{children:l.label})})),o.views.length===0&&i(s.Box,{children:"--"})]})})]},o.id))})]})})}),$i=({value:t,onChange:e,height:n="200px",defaultLanguage:r="sql",theme:a="vs-dark"})=>{const o=c=>{console.log("changing"),e==null||e(c??"")},l=!e;return i(ze,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:t,onChange:l?void 0:o,theme:a,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!e,"semanticHighlighting.enabled":!0}})},i_=({value:t,height:e="200px",defaultLanguage:n="sql"})=>i(ze,{className:"preview-sql-in-monaco-editor",height:e,defaultLanguage:n,value:t,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),a_=k.observer(({value:t})=>{const n=K().payloadForSQL,r=y.useMemo(()=>dr(t,n),[t,n]);return i(i_,{height:"100%",value:r})}),Ml={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
510
+ `)},r_=k.observer(({queryModel:t})=>t.typedAsHTTP?h(s.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"pre_process",children:"Build Request"}),i(s.Tabs.Tab,{value:"post_process",children:"Process Result"}),i(zi,{})]}),i(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:i(rr,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:Il.pre})}),i(s.Tabs.Panel,{value:"post_process",p:"sm",children:i(rr,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:Il.post})})]}):null),i_=k.observer(({queryID:t,usage:e})=>{const n=ge().editor,r=o=>{if(o.type==="filter"){n.setPath(["_FILTERS_",o.id]);return}if(o.type==="panel"){const l=o.views[0].id;n.setPath(["_VIEWS_",l,"_PANELS_",o.id]);return}},a=o=>{n.setPath(["_VIEWS_",o])};return i(s.Stack,{py:"sm",px:"md",children:h(s.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[i("thead",{children:h("tr",{children:[i("th",{style:{width:100},children:"Type"}),i("th",{style:{width:"calc(50% - 50px)"},children:"Name"}),i("th",{children:"In View(s)"})]})}),i("tbody",{children:e.map(o=>h("tr",{children:[i("td",{children:v.capitalize(o.type)}),i("td",{children:i(s.Anchor,{component:"button",type:"button",onClick:()=>r(o),children:o.label})}),i("td",{children:h(s.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[o.views.map(l=>i(s.Anchor,{component:"button",type:"button",onClick:()=>a(l.id),children:i(s.Box,{children:l.label})})),o.views.length===0&&i(s.Box,{children:"--"})]})})]},o.id))})]})})}),$i=({value:t,onChange:e,height:n="200px",defaultLanguage:r="sql",theme:a="vs-dark"})=>{const o=c=>{console.log("changing"),e==null||e(c??"")},l=!e;return i(ze,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:t,onChange:l?void 0:o,theme:a,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!e,"semanticHighlighting.enabled":!0}})},a_=({value:t,height:e="200px",defaultLanguage:n="sql"})=>i(ze,{className:"preview-sql-in-monaco-editor",height:e,defaultLanguage:n,value:t,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),s_=k.observer(({value:t})=>{const n=K().payloadForSQL,r=y.useMemo(()=>dr(t,n),[t,n]);return i(a_,{height:"100%",value:r})}),Ml={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
511
511
  `),post:["function process_result(data, utils) {"," // process data and return the result"," return data","}"].join(`
512
- `)},s_=k.observer(({queryModel:t})=>{const[e,n]=y.useState(t.sql);y.useEffect(()=>{n(o=>o!==t.sql?t.sql:o)},[t.sql]);const r=e!==t.sql,a=()=>{t.setSQL(e)};return t.typedAsSQL?h(s.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Edit",children:h(s.Group,{spacing:14,position:"apart",children:["Edit SQL",i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!r,onClick:a,children:i(I.DeviceFloppy,{size:20})})]})}),i(s.Tabs.Tab,{value:"Preview",children:"Preview SQL"}),i(s.Tabs.Tab,{value:"pre_process",children:"Process Request"}),i(s.Tabs.Tab,{value:"post_process",children:"Process Result"}),i(zi,{}),t.datasource&&i(Tl,{dataSource:t.datasource})]}),i(s.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:i($i,{height:"100%",value:e,onChange:n,theme:"sql-dark",defaultLanguage:"sql"})}),i(s.Tabs.Panel,{value:"Preview",p:0,pl:4,children:i(a_,{value:t.sql})}),i(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:i(rr,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:Ml.pre})}),i(s.Tabs.Panel,{value:"post_process",p:"sm",children:i(rr,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:Ml.post})})]}):null}),ir={height:"calc(100% - 44px)",padding:0},o_=k.observer(({queryModel:t})=>{const e=K(),n=y.useMemo(()=>t.datasource?t.typedAsHTTP?"HTTP":"SQL":"Configurations",[t.datasource,t.typedAsHTTP]),[r,a]=y.useState(n);y.useEffect(()=>{a(c=>c!=="Configurations"&&n==="Configurations"?"Configurations":c)},[n]);const o=e.findQueryUsage(t.id),l=o.length===0;return i(s.Stack,{sx:{flexGrow:1},my:0,p:0,children:h(s.Tabs,{value:r,onTabChange:a,defaultValue:n,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[h(s.Tabs.List,{grow:!0,children:[i(s.Tabs.Tab,{value:"Configurations",children:"Configurations"}),t.typedAsSQL&&i(s.Tabs.Tab,{value:"SQL",children:"Request"}),t.typedAsHTTP&&i(s.Tabs.Tab,{value:"HTTP",children:"Request"}),i(s.Tabs.Tab,{value:"Data",disabled:!t.datasource,children:i(s.Tooltip,{label:"Need to pick a Data Source first",disabled:t.datasource,withinPortal:!0,children:i(s.Text,{children:"Data"})})}),i(s.Tabs.Tab,{value:"Usage",disabled:l,children:i(s.Tooltip,{label:"This query is not used for any filter or panel",disabled:!l,withinPortal:!0,children:i(s.Text,{children:"Usage"})})})]}),i(s.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:i(XS,{queryModel:t})}),t.typedAsSQL&&i(s.Tabs.Panel,{value:"SQL",sx:ir,children:i(s.Stack,{sx:{height:"100%"},children:i(s_,{queryModel:t})})}),t.typedAsHTTP&&i(s.Tabs.Panel,{value:"HTTP",sx:ir,children:i(s.Stack,{sx:{height:"100%"},children:i(n_,{queryModel:t})})}),i(s.Tabs.Panel,{value:"Data",sx:{...ir,overflow:"hidden"},children:i(Ei,{id:t.id})}),i(s.Tabs.Panel,{value:"Usage",sx:{...ir,overflow:"hidden"},children:i(r_,{queryID:t.id,usage:o})})]})})}),l_=k.observer(({id:t})=>{const n=K().queries.findByID(t);return t===""?null:n?i(s.Stack,{sx:{height:"100%"},spacing:"sm",children:i(o_,{queryModel:n})}):i(s.Text,{size:14,color:"red",children:"Invalid Query ID"})}),c_=k.observer(({value:t})=>{const n=K().payloadForSQL,r=y.useMemo(()=>dr(t,n),[t,n]);return i($i,{height:"100%",value:r})}),u_=k.observer(({item:t,remove:e,onKeyChanged:n})=>{const[r,a]=y.useState("SQL"),[o,l]=y.useState(t.key),c=()=>{t.setKey(o),n(o)},u=o!==t.key,d=t.isADuplicatedKey(o),[f,p]=y.useState(t.value),g=()=>{t.setValue(f)};y.useEffect(()=>{l(t.key),p(t.value)},[t]);const m=f!==t.value,C=Ke.useModals(),w=()=>{C.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:e,confirmProps:{color:"red"},zIndex:320})};return h(s.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[h(s.Group,{sx:{alignItems:"end"},spacing:40,children:[i(s.TextInput,{label:d?"This key is occupied by another snippet":"Key",value:o,onChange:_=>{l(_.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:i(s.ActionIcon,{color:"blue",variant:"subtle",onClick:c,disabled:!u||d,children:i(I.DeviceFloppy,{size:16})}),error:d}),i(s.Button,{leftIcon:i(I.Trash,{size:16}),color:"red",variant:"light",onClick:w,children:"Delete this SQL Snippet"})]}),h(s.Tabs,{value:r,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[h(s.Tabs.List,{sx:{position:"relative"},children:[i(s.Tabs.Tab,{value:"SQL",children:"SQL"}),i(s.Tabs.Tab,{value:"Preview",children:"Preview"}),i(zi,{}),i(s.ActionIcon,{color:"blue",variant:"filled",onClick:g,disabled:!m,sx:{position:"absolute",top:0,right:10},children:i(I.DeviceFloppy,{size:18})})]}),i(s.Tabs.Panel,{value:"SQL",pt:"sm",children:i($i,{height:"100%",value:f,onChange:p,defaultLanguage:"sql",theme:"sql-dark"})}),i(s.Tabs.Panel,{value:"Preview",pt:"sm",children:i(c_,{value:f})})]})]})}),d_=k.observer(({id:t})=>{const e=ge(),n=K(),r=y.useMemo(()=>n.sqlSnippets.findByKey(t),[t]);if(!t)return null;if(!r)return h(s.Text,{size:14,children:["SQL Snippet by key[",t,"] is not found"]});const a=()=>{e.editor.setPath(["_SQL_SNIPPETS_",""])};return i(u_,{item:r,remove:()=>{n.sqlSnippets.removeByKey(t),a()},onKeyChanged:c=>{e.editor.setPath(["_SQL_SNIPPETS_",c])}})}),p_=k.observer(({view:t})=>!t||t.type!==H.Division?null:h(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),i(s.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),h_=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],f_=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],g_=k.observer(({view:t})=>{if(!t||t.type!==H.Tabs)return null;const e=t.config;return h(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),i(s.Select,{label:"Variant",value:e.variant,onChange:e.setVariant,data:h_}),i(s.Select,{label:"Orientation",value:e.orientation,onChange:e.setOrientation,data:f_}),i(s.Switch,{label:"Grow Tabs",checked:e.grow,onChange:n=>e.setGrow(n.currentTarget.checked)})]})}),m_=({disabled:t,value:e,onChange:n})=>{const r=a=>{a&&n(a)};return h(s.Box,{sx:{position:"relative"},children:[t&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(ze,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})},y_=({value:t,onChange:e})=>{const[n,{setTrue:r,setFalse:a}]=J.useBoolean(),[o,l]=y.useState(t??xi),c=g=>{l({...o,enabled:g})},u=()=>{a();const{enabled:g,func_content:m}=o,C={enabled:g,func_content:m};l(C),e(C)},d=()=>{a(),l(t)},f=g=>{l(m=>({...m,func_content:g}))},p=()=>{f(xi.func_content)};return h(q,{children:[i(s.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:i(I.Settings,{size:14})}),i(s.Modal,{size:800,title:"Customize modal title",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&h(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:g=>c(g.currentTarget.checked)}),i(m_,{value:o.func_content,onChange:f,disabled:!o.enabled}),h(s.Group,{position:"apart",children:[i(s.Button,{onClick:p,color:"red",leftIcon:i(I.Recycle,{size:20}),children:"Rest"}),h(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},b_=k.observer(({view:t})=>{if(!t||t.type!==H.Modal)return null;const e=t.config,n=e.custom_modal_title.value;return h(s.Stack,{children:[i(s.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),h(s.Flex,{gap:10,children:[i(s.TextInput,{label:"Modal Title",value:n,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),i(y_,{value:e.custom_modal_title,onChange:e.custom_modal_title.replace})]}),h(s.Group,{grow:!0,children:[i(s.TextInput,{label:"Width",value:e.width,onChange:r=>e.setWidth(r.currentTarget.value),placeholder:"600px / 50vw"}),i(s.TextInput,{label:"Height",value:e.height,onChange:r=>e.setHeight(r.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),v_=k.observer(({view:t})=>h(q,{children:[i(p_,{view:t}),i(b_,{view:t}),i(g_,{view:t})]})),x_=[{label:"Division",value:H.Division},{label:"Modal",value:H.Modal},{label:"Tabs",value:H.Tabs}],w_=k.observer(({view:t})=>t?h(s.Stack,{sx:{position:"relative"},children:[i(s.TextInput,{label:"Name",value:t.name,onChange:e=>{t.setName(e.currentTarget.value)}}),i(s.Select,{label:"Type",withinPortal:!0,value:t.type,onChange:t.setType,data:x_}),i(v_,{view:t})]}):null),C_=k.observer(({id:t})=>{const e=Ke.useModals(),n=ge(),r=K();if(t==="")return null;const a=r.views.findByID(t);if(!a)return h(s.Text,{size:14,children:["View by ID[",t,"] is not found"]});const o=()=>{n.editor.setPath(["_VIEWS_",""])},l=()=>{e.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.views.removeByID(t),o()},zIndex:320})};return h(s.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(I.Trash,{size:16}),onClick:l,children:"Delete this view"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(w_,{view:a})})]})});function S_(t){return t.length===1&&t[0]==="_QUERY_VARS_"}function __(t){return t.length===1&&t[0]==="_MOCK_CONTEXT_"}function k_(t){return t.length===2&&t[0]==="_FILTERS_"}function T_(t){return t.length===2&&t[0]==="_SQL_SNIPPETS_"}function D_(t){return t.length===2&&t[0]==="_QUERIES_"}function I_(t){return t.length===2&&t[0]==="_VIEWS_"}function M_(t){return t.length===4&&t[0]==="_VIEWS_"&&t[2]==="_PANELS_"}const E_=k.observer(()=>i(s.Stack,{sx:{height:"100%"},p:"sm",children:i(Dl,{})})),A_=k.observer(()=>{const t=ge().editor,e=t.path;return S_(e)?i(E_,{}):__(e)?i(eS,{}):k_(e)?i(s.Box,{p:"xs",pl:20,children:i(H1,{id:e[1]})}):T_(e)?i(d_,{id:e[1]}):D_(e)?i(l_,{id:e[1]}):I_(e)?i(s.Box,{p:"xs",pl:20,children:i(C_,{id:e[1]})}):M_(e)?i(MS,{viewID:e[1],panelID:e[3]}):i(s.Box,{children:t.path})}),z_=k.observer(()=>i(A_,{})),$_=k.observer(()=>{const t=ge(),e=()=>{const n=new Date().getTime().toString(),r={id:n,key:n,label:n,order:t.content.filters.current.length+1,type:vi.TextInput,config:Ha(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(r),t.editor.setPath(["_FILTERS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),L_=k.observer(({parentID:t})=>{const e=K();if(!t)return null;const n=e.views.findByID(t);return n?i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>e.addANewPanel(n.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),O_=k.observer(()=>{const t=ge(),e=()=>{const n=new Date().getTime().toString(),r={id:n,name:n,type:be.Postgresql,key:"",sql:""};t.content.queries.append(r),t.editor.setPath(["_QUERIES_",n])};return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),P_=k.observer(()=>{const t=ge(),e=()=>{const n=new Date().getTime().toString(),r={key:n,value:""};t.content.sqlSnippets.append(r),t.editor.setPath(["_SQL_SNIPPETS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),B_=k.observer(()=>{const t=K();return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a View"})}),V_=k.observer(({action_type:t,parentID:e})=>(K(),t==="_Add_A_Filter_"?i($_,{}):t==="_Add_A_SQL_SNIPPET_"?i(P_,{}):t==="_Add_A_QUERY_"?i(O_,{}):t==="_Add_A_VIEW_"?i(B_,{}):t==="_Add_A_PANEL_"?i(L_,{parentID:e}):null)),El=k.observer(({option:t})=>{var d;const e=ge().editor,n=e.isOptionActive,r=n(e.path,t),a=e.isOptionOpened,o=e.navigate,l=a(t),[c,u]=y.useState(l);return y.useEffect(()=>{u(l)},[l]),i(s.NavLink,{active:r,defaultOpened:l,opened:c,onChange:u,label:t.label,onClick:()=>o(t),icon:t.Icon?i(t.Icon,{size:18}):null,children:(d=t.children)==null?void 0:d.map(f=>f._type==="ACTION"?i(V_,{action_type:f._action_type,parentID:f.parentID},`_ADD_${f.value}_`):i(El,{option:f},f.value))},t.label)}),N_=k.observer(()=>{const t=ge();return i(s.Box,{sx:{position:"relative"},children:t.editor.navOptions.map(e=>i(El,{option:e},e.value))})}),q_=k.observer(()=>{const t=ge();return h(s.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[i(s.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:i(s.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),i(s.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:i(N_,{})}),i(s.Navbar.Section,{children:i(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:i(s.Button,{size:"xs",color:"red",leftIcon:i(O.IconX,{size:18}),onClick:()=>t.editor.close(),children:"Close"})})})]})}),F_={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},G_=k.observer(()=>{const t=ge().editor;return i(s.Modal,{onClose:()=>t.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:t.settings_open,fullScreen:!0,title:null,transitionDuration:0,withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{modal:{padding:"0 !important"}},children:i(s.AppShell,{padding:0,navbar:i(q_,{}),styles:F_,children:i(z_,{})})})}),W_=t=>t.replace(/([^:])(\/\/+)/g,"$1/");function R_(t){y.useEffect(()=>{if(ze.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=W_(t);ze.loader.config({paths:{vs:n}}),ze.loader.init().then(r=>console.log("monaco instance:",r))},[])}Ls();const j_={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},Y_=({context:t,dashboard:e,content:n,update:r,className:a="dashboard",config:o,onChange:l,headerSlot:c,headerMenuItems:u},d)=>{R_(o.monacoPath),Fa(o);const{data:f=[]}=J.useRequest(pr),{data:p=[]}=J.useRequest(Ga),[g,m]=y.useState(!1),C=y.useMemo(()=>Ci(e,n,f,p,t),[e,n]);y.useImperativeHandle(d,()=>C,[C]),ja(C.content,!0),y.useEffect(()=>{C.context.replace(t)},[t]),y.useEffect(()=>{C.datasources.replace(f)},[f]),y.useEffect(()=>{C.globalSQLSnippets.replace(p)},[p]),y.useEffect(()=>ae.reaction(()=>ae.toJS(C.json),M=>{l==null||l(M)}),[C]);const w=async()=>{await r(C.json,C.content.json)},_=J.useCreation(fi,[]),T=ki(_);return i(Ke.ModalsProvider,{children:i(fr,{value:C,children:i(hr,{value:C.content,children:i(ft.Provider,{value:{layoutFrozen:g,freezeLayout:m,inEditMode:!0},children:i(it.Provider,{value:_,children:h(Jn,{configure:T,children:[i(s.AppShell,{padding:0,header:i(d1,{saveDashboardChanges:w,headerSlot:c,headerMenuItems:u}),navbar:i(V1,{}),styles:j_,children:i(s.Box,{className:`${a} dashboard-root`,sx:{position:"relative"},children:C.content.views.visibleViews.map(M=>i(fl,{view:M},M.id))})}),i(G_,{})]})})})})})})},Q_=k.observer(y.forwardRef(Y_)),HT="";Ls();const K_=k.observer(({context:t,dashboard:e,content:n,className:r="dashboard",config:a,fullScreenPanelID:o,setFullScreenPanelID:l})=>{Fa(a);const{data:c=[]}=J.useRequest(pr),{data:u=[]}=J.useRequest(Ga),d=y.useMemo(()=>Ci(e,n,c,u,t),[e,n]);ja(d.content,!1),y.useEffect(()=>{d.context.replace(t)},[t]),y.useEffect(()=>{d.datasources.replace(c)},[c]),y.useEffect(()=>{d.globalSQLSnippets.replace(u)},[u]);const f=J.useCreation(fi,[]),p=ki(f);return i(Ke.ModalsProvider,{children:i(fr,{value:d,children:i(hr,{value:d.content,children:i(Cr.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:i(ft.Provider,{value:{layoutFrozen:!0,freezeLayout:v.noop,inEditMode:!1},children:i(s.Box,{className:`${r} dashboard-root`,children:i(it.Provider,{value:f,children:i(Jn,{configure:p,children:d.content.views.visibleViews.map(g=>i(er,{view:g},g.id))})})})})})})})})});var Li={},U_={get exports(){return Li},set exports(t){Li=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var c=this,u=this.$locale();if(!this.isValid())return o.bind(this)(l);var d=this.$utils(),f=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(p){switch(p){case"Q":return Math.ceil((c.$M+1)/3);case"Do":return u.ordinal(c.$D);case"gggg":return c.weekYear();case"GGGG":return c.isoWeekYear();case"wo":return u.ordinal(c.week(),"W");case"w":case"ww":return d.s(c.week(),p==="w"?1:2,"0");case"W":case"WW":return d.s(c.isoWeek(),p==="W"?1:2,"0");case"k":case"kk":return d.s(String(c.$H===0?24:c.$H),p==="k"?1:2,"0");case"X":return Math.floor(c.$d.getTime()/1e3);case"x":return c.$d.getTime();case"z":return"["+c.offsetName()+"]";case"zzz":return"["+c.offsetName("long")+"]";default:return p}});return o.bind(this)(f)}}})})(U_);const X_=Li;var Oi={},J_={get exports(){return Oi},set exports(t){Oi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=r.prototype,l=function(u){var d=u.date,f=u.utc;return Array.isArray(d)?f?d.length?new Date(Date.UTC.apply(null,d)):new Date:d.length===1?a(String(d[0])).toDate():new(Function.prototype.bind.apply(Date,[null].concat(d))):d},c=o.parse;o.parse=function(u){u.date=l.bind(this)(u),c.bind(this)(u)}}})})(J_);const Z_=Oi;var Pi={},H_={get exports(){return Pi},set exports(t){Pi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype;a.$g=function(g,m,C){return this.$utils().u(g)?this[m]:this.$set(C,g)},a.set=function(g,m){return this.$set(g,m)};var o=a.startOf;a.startOf=function(g,m){return this.$d=o.bind(this)(g,m).toDate(),this.init(),this};var l=a.add;a.add=function(g,m){return this.$d=l.bind(this)(g,m).toDate(),this.init(),this};var c=a.locale;a.locale=function(g,m){return g?(this.$L=c.bind(this)(g,m).$L,this):this.$L};var u=a.daysInMonth;a.daysInMonth=function(){return u.bind(this.clone())()};var d=a.isSame;a.isSame=function(g,m){return d.bind(this.clone())(g,m)};var f=a.isBefore;a.isBefore=function(g,m){return f.bind(this.clone())(g,m)};var p=a.isAfter;a.isAfter=function(g,m){return p.bind(this.clone())(g,m)}}})})(H_);const ek=Pi;var Bi={},tk={get exports(){return Bi},set exports(t){Bi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var c=this,u=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/(\[[^\]]+])|BBBB|BB/g,function(d,f){var p,g=String(c.$y+543),m=d==="BB"?[g.slice(-2),2]:[g,4];return f||(p=c.$utils()).s.apply(p,m.concat(["0"]))});return o.bind(this)(u)}}})})(tk);const nk=Bi;var Vi={},rk={get exports(){return Vi},set exports(t){Vi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o="h:mm A",l={lastDay:"[Yesterday at] "+o,sameDay:"[Today at] "+o,nextDay:"[Tomorrow at] "+o,nextWeek:"dddd [at] "+o,lastWeek:"[Last] dddd [at] "+o,sameElse:"MM/DD/YYYY"};r.prototype.calendar=function(c,u){var d=u||this.$locale().calendar||l,f=a(c||void 0).startOf("d"),p=this.diff(f,"d",!0),g="sameElse",m=p<-6?g:p<-1?"lastWeek":p<0?"lastDay":p<1?"sameDay":p<2?"nextDay":p<7?"nextWeek":g,C=d[m]||l[m];return typeof C=="function"?C.call(this,a()):this.format(C)}}})})(rk);const ik=Vi;var Ni={},ak={get exports(){return Ni},set exports(t){Ni=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,a=/\d\d/,o=/\d\d?/,l=/\d*[^-_:/,()\s\d]+/,c={},u=function(w){return(w=+w)+(w>68?1900:2e3)},d=function(w){return function(_){this[w]=+_}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(w){(this.zone||(this.zone={})).offset=function(_){if(!_||_==="Z")return 0;var T=_.match(/([+-]|\d\d)/g),M=60*T[1]+(+T[2]||0);return M===0?0:T[0]==="+"?-M:M}(w)}],p=function(w){var _=c[w];return _&&(_.indexOf?_:_.s.concat(_.f))},g=function(w,_){var T,M=c.meridiem;if(M){for(var L=1;L<=24;L+=1)if(w.indexOf(M(L,0,_))>-1){T=L>12;break}}else T=w===(_?"pm":"PM");return T},m={A:[l,function(w){this.afternoon=g(w,!1)}],a:[l,function(w){this.afternoon=g(w,!0)}],S:[/\d/,function(w){this.milliseconds=100*+w}],SS:[a,function(w){this.milliseconds=10*+w}],SSS:[/\d{3}/,function(w){this.milliseconds=+w}],s:[o,d("seconds")],ss:[o,d("seconds")],m:[o,d("minutes")],mm:[o,d("minutes")],H:[o,d("hours")],h:[o,d("hours")],HH:[o,d("hours")],hh:[o,d("hours")],D:[o,d("day")],DD:[a,d("day")],Do:[l,function(w){var _=c.ordinal,T=w.match(/\d+/);if(this.day=T[0],_)for(var M=1;M<=31;M+=1)_(M).replace(/\[|\]/g,"")===w&&(this.day=M)}],M:[o,d("month")],MM:[a,d("month")],MMM:[l,function(w){var _=p("months"),T=(p("monthsShort")||_.map(function(M){return M.slice(0,3)})).indexOf(w)+1;if(T<1)throw new Error;this.month=T%12||T}],MMMM:[l,function(w){var _=p("months").indexOf(w)+1;if(_<1)throw new Error;this.month=_%12||_}],Y:[/[+-]?\d+/,d("year")],YY:[a,function(w){this.year=u(w)}],YYYY:[/\d{4}/,d("year")],Z:f,ZZ:f};function C(w){var _,T;_=w,T=c&&c.formats;for(var M=(w=_.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(W,U,X){var oe=X&&X.toUpperCase();return U||T[X]||n[X]||T[oe].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(re,de,Ce){return de||Ce.slice(1)})})).match(r),L=M.length,B=0;B<L;B+=1){var F=M[B],$=m[F],E=$&&$[0],z=$&&$[1];M[B]=z?{regex:E,parser:z}:F.replace(/^\[|\]$/g,"")}return function(W){for(var U={},X=0,oe=0;X<L;X+=1){var re=M[X];if(typeof re=="string")oe+=re.length;else{var de=re.regex,Ce=re.parser,ye=W.slice(oe),Te=de.exec(ye)[0];Ce.call(U,Te),W=W.replace(Te,"")}}return function(fe){var Oe=fe.afternoon;if(Oe!==void 0){var Ye=fe.hours;Oe?Ye<12&&(fe.hours+=12):Ye===12&&(fe.hours=0),delete fe.afternoon}}(U),U}}return function(w,_,T){T.p.customParseFormat=!0,w&&w.parseTwoDigitYear&&(u=w.parseTwoDigitYear);var M=_.prototype,L=M.parse;M.parse=function(B){var F=B.date,$=B.utc,E=B.args;this.$u=$;var z=E[1];if(typeof z=="string"){var W=E[2]===!0,U=E[3]===!0,X=W||U,oe=E[2];U&&(oe=E[2]),c=this.$locale(),!W&&oe&&(c=T.Ls[oe]),this.$d=function(ye,Te,fe){try{if(["x","X"].indexOf(Te)>-1)return new Date((Te==="X"?1e3:1)*ye);var Oe=C(Te)(ye),Ye=Oe.year,Mt=Oe.month,ar=Oe.day,sr=Oe.hours,fa=Oe.minutes,ga=Oe.seconds,cn=Oe.milliseconds,Ft=Oe.zone,xt=new Date,Et=ar||(Ye||Mt?1:xt.getDate()),wt=Ye||xt.getFullYear(),Gt=0;Ye&&!Mt||(Gt=Mt>0?Mt-1:xt.getMonth());var Wt=sr||0,un=fa||0,dn=ga||0,Ct=cn||0;return Ft?new Date(Date.UTC(wt,Gt,Et,Wt,un,dn,Ct+60*Ft.offset*1e3)):fe?new Date(Date.UTC(wt,Gt,Et,Wt,un,dn,Ct)):new Date(wt,Gt,Et,Wt,un,dn,Ct)}catch{return new Date("")}}(F,z,$),this.init(),oe&&oe!==!0&&(this.$L=this.locale(oe).$L),X&&F!=this.format(z)&&(this.$d=new Date("")),c={}}else if(z instanceof Array)for(var re=z.length,de=1;de<=re;de+=1){E[1]=z[de-1];var Ce=T.apply(this,E);if(Ce.isValid()){this.$d=Ce.$d,this.$L=Ce.$L,this.init();break}de===re&&(this.$d=new Date(""))}else L.call(this,B)}}})})(ak);const sk=Ni;var qi={},ok={get exports(){return qi},set exports(t){qi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.dayOfYear=function(o){var l=Math.round((a(this).startOf("day")-a(this).startOf("year"))/864e5)+1;return o==null?l:this.add(o-l,"day")}}})})(ok);const lk=qi;var Fi={},ck={get exports(){return Fi},set exports(t){Fi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n,r,a=1e3,o=6e4,l=36e5,c=864e5,u=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d=31536e6,f=2592e6,p=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,g={years:d,months:f,days:c,hours:l,minutes:o,seconds:a,milliseconds:1,weeks:6048e5},m=function($){return $ instanceof B},C=function($,E,z){return new B($,z,E.$l)},w=function($){return r.p($)+"s"},_=function($){return $<0},T=function($){return _($)?Math.ceil($):Math.floor($)},M=function($){return Math.abs($)},L=function($,E){return $?_($)?{negative:!0,format:""+M($)+E}:{negative:!1,format:""+$+E}:{negative:!1,format:""}},B=function(){function $(z,W,U){var X=this;if(this.$d={},this.$l=U,z===void 0&&(this.$ms=0,this.parseFromMilliseconds()),W)return C(z*g[w(W)],this);if(typeof z=="number")return this.$ms=z,this.parseFromMilliseconds(),this;if(typeof z=="object")return Object.keys(z).forEach(function(de){X.$d[w(de)]=z[de]}),this.calMilliseconds(),this;if(typeof z=="string"){var oe=z.match(p);if(oe){var re=oe.slice(2).map(function(de){return de!=null?Number(de):0});return this.$d.years=re[0],this.$d.months=re[1],this.$d.weeks=re[2],this.$d.days=re[3],this.$d.hours=re[4],this.$d.minutes=re[5],this.$d.seconds=re[6],this.calMilliseconds(),this}}return this}var E=$.prototype;return E.calMilliseconds=function(){var z=this;this.$ms=Object.keys(this.$d).reduce(function(W,U){return W+(z.$d[U]||0)*g[U]},0)},E.parseFromMilliseconds=function(){var z=this.$ms;this.$d.years=T(z/d),z%=d,this.$d.months=T(z/f),z%=f,this.$d.days=T(z/c),z%=c,this.$d.hours=T(z/l),z%=l,this.$d.minutes=T(z/o),z%=o,this.$d.seconds=T(z/a),z%=a,this.$d.milliseconds=z},E.toISOString=function(){var z=L(this.$d.years,"Y"),W=L(this.$d.months,"M"),U=+this.$d.days||0;this.$d.weeks&&(U+=7*this.$d.weeks);var X=L(U,"D"),oe=L(this.$d.hours,"H"),re=L(this.$d.minutes,"M"),de=this.$d.seconds||0;this.$d.milliseconds&&(de+=this.$d.milliseconds/1e3);var Ce=L(de,"S"),ye=z.negative||W.negative||X.negative||oe.negative||re.negative||Ce.negative,Te=oe.format||re.format||Ce.format?"T":"",fe=(ye?"-":"")+"P"+z.format+W.format+X.format+Te+oe.format+re.format+Ce.format;return fe==="P"||fe==="-P"?"P0D":fe},E.toJSON=function(){return this.toISOString()},E.format=function(z){var W=z||"YYYY-MM-DDTHH:mm:ss",U={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return W.replace(u,function(X,oe){return oe||String(U[X])})},E.as=function(z){return this.$ms/g[w(z)]},E.get=function(z){var W=this.$ms,U=w(z);return U==="milliseconds"?W%=1e3:W=U==="weeks"?T(W/g[U]):this.$d[U],W===0?0:W},E.add=function(z,W,U){var X;return X=W?z*g[w(W)]:m(z)?z.$ms:C(z,this).$ms,C(this.$ms+X*(U?-1:1),this)},E.subtract=function(z,W){return this.add(z,W,!0)},E.locale=function(z){var W=this.clone();return W.$l=z,W},E.clone=function(){return C(this.$ms,this)},E.humanize=function(z){return n().add(this.$ms,"ms").locale(this.$l).fromNow(!z)},E.valueOf=function(){return this.asMilliseconds()},E.milliseconds=function(){return this.get("milliseconds")},E.asMilliseconds=function(){return this.as("milliseconds")},E.seconds=function(){return this.get("seconds")},E.asSeconds=function(){return this.as("seconds")},E.minutes=function(){return this.get("minutes")},E.asMinutes=function(){return this.as("minutes")},E.hours=function(){return this.get("hours")},E.asHours=function(){return this.as("hours")},E.days=function(){return this.get("days")},E.asDays=function(){return this.as("days")},E.weeks=function(){return this.get("weeks")},E.asWeeks=function(){return this.as("weeks")},E.months=function(){return this.get("months")},E.asMonths=function(){return this.as("months")},E.years=function(){return this.get("years")},E.asYears=function(){return this.as("years")},$}(),F=function($,E,z){return $.add(E.years()*z,"y").add(E.months()*z,"M").add(E.days()*z,"d").add(E.hours()*z,"h").add(E.minutes()*z,"m").add(E.seconds()*z,"s").add(E.milliseconds()*z,"ms")};return function($,E,z){n=z,r=z().$utils(),z.duration=function(X,oe){var re=z.locale();return C(X,{$l:re},oe)},z.isDuration=m;var W=E.prototype.add,U=E.prototype.subtract;E.prototype.add=function(X,oe){return m(X)?F(this,X,1):W.bind(this)(X,oe)},E.prototype.subtract=function(X,oe){return m(X)?F(this,X,-1):U.bind(this)(X,oe)}}})})(ck);const uk=Fi;var Gi={},dk={get exports(){return Gi},set exports(t){Gi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isBetween=function(o,l,c,u){var d=a(o),f=a(l),p=(u=u||"()")[0]==="(",g=u[1]===")";return(p?this.isAfter(d,c):!this.isBefore(d,c))&&(g?this.isBefore(f,c):!this.isAfter(f,c))||(p?this.isBefore(d,c):!this.isAfter(d,c))&&(g?this.isAfter(f,c):!this.isBefore(f,c))}}})})(dk);const pk=Gi;var Wi={},hk={get exports(){return Wi},set exports(t){Wi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(hk);const fk=Wi;var Ri={},gk={get exports(){return Ri},set exports(t){Ri=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){a.isMoment=function(o){return a.isDayjs(o)}}})})(gk);const mk=Ri;var ji={},yk={get exports(){return ji},set exports(t){ji=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="day";return function(r,a,o){var l=function(d){return d.add(4-d.isoWeekday(),n)},c=a.prototype;c.isoWeekYear=function(){return l(this).year()},c.isoWeek=function(d){if(!this.$utils().u(d))return this.add(7*(d-this.isoWeek()),n);var f,p,g,m,C=l(this),w=(f=this.isoWeekYear(),p=this.$u,g=(p?o.utc:o)().year(f).startOf("year"),m=4-g.isoWeekday(),g.isoWeekday()>4&&(m+=7),g.add(m,n));return C.diff(w,"week")+1},c.isoWeekday=function(d){return this.$utils().u(d)?this.day()||7:this.day(this.day()%7?d:d-7)};var u=c.startOf;c.startOf=function(d,f){var p=this.$utils(),g=!!p.u(f)||f;return p.p(d)==="isoweek"?g?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):u.bind(this)(d,f)}}})})(yk);const bk=ji;var Yi={},vk={get exports(){return Yi},set exports(t){Yi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isoWeeksInYear=function(){var a=this.isLeapYear(),o=this.endOf("y").day();return o===4||a&&o===5?53:52}}})})(vk);const xk=Yi;var Qi={},wk={get exports(){return Qi},set exports(t){Qi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isSameOrAfter=function(a,o){return this.isSame(a,o)||this.isAfter(a,o)}}})})(wk);const Ck=Qi;var Ki={},Sk={get exports(){return Ki},set exports(t){Ki=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isSameOrBefore=function(a,o){return this.isSame(a,o)||this.isBefore(a,o)}}})})(Sk);const _k=Ki;var Ui={},kk={get exports(){return Ui},set exports(t){Ui=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isToday=function(){var o="YYYY-MM-DD",l=a();return this.format(o)===l.format(o)}}})})(kk);const Tk=Ui;var Xi={},Dk={get exports(){return Xi},set exports(t){Xi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isTomorrow=function(){var o="YYYY-MM-DD",l=a().add(1,"day");return this.format(o)===l.format(o)}}})})(Dk);const Ik=Xi;var Ji={},Mk={get exports(){return Ji},set exports(t){Ji=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isYesterday=function(){var o="YYYY-MM-DD",l=a().subtract(1,"day");return this.format(o)===l.format(o)}}})})(Mk);const Ek=Ji;var Zi={},Ak={get exports(){return Zi},set exports(t){Zi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=r.prototype,l=function(p){return p&&(p.indexOf?p:p.s)},c=function(p,g,m,C,w){var _=p.name?p:p.$locale(),T=l(_[g]),M=l(_[m]),L=T||M.map(function(F){return F.slice(0,C)});if(!w)return L;var B=_.weekStart;return L.map(function(F,$){return L[($+(B||0))%7]})},u=function(){return a.Ls[a.locale()]},d=function(p,g){return p.formats[g]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(C,w,_){return w||_.slice(1)})}(p.formats[g.toUpperCase()])},f=function(){var p=this;return{months:function(g){return g?g.format("MMMM"):c(p,"months")},monthsShort:function(g){return g?g.format("MMM"):c(p,"monthsShort","months",3)},firstDayOfWeek:function(){return p.$locale().weekStart||0},weekdays:function(g){return g?g.format("dddd"):c(p,"weekdays")},weekdaysMin:function(g){return g?g.format("dd"):c(p,"weekdaysMin","weekdays",2)},weekdaysShort:function(g){return g?g.format("ddd"):c(p,"weekdaysShort","weekdays",3)},longDateFormat:function(g){return d(p.$locale(),g)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};o.localeData=function(){return f.bind(this)()},a.localeData=function(){var p=u();return{firstDayOfWeek:function(){return p.weekStart||0},weekdays:function(){return a.weekdays()},weekdaysShort:function(){return a.weekdaysShort()},weekdaysMin:function(){return a.weekdaysMin()},months:function(){return a.months()},monthsShort:function(){return a.monthsShort()},longDateFormat:function(g){return d(p,g)},meridiem:p.meridiem,ordinal:p.ordinal}},a.months=function(){return c(u(),"months")},a.monthsShort=function(){return c(u(),"monthsShort","months",3)},a.weekdays=function(p){return c(u(),"weekdays",null,null,p)},a.weekdaysShort=function(p){return c(u(),"weekdaysShort","weekdays",3,p)},a.weekdaysMin=function(p){return c(u(),"weekdaysMin","weekdays",2,p)}}})})(Ak);const zk=Zi;var Hi={},$k={get exports(){return Hi},set exports(t){Hi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(r,a,o){var l=a.prototype,c=l.format;o.en.formats=n,l.format=function(u){u===void 0&&(u="YYYY-MM-DDTHH:mm:ssZ");var d=this.$locale().formats,f=function(p,g){return p.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(m,C,w){var _=w&&w.toUpperCase();return C||g[w]||n[w]||g[_].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(T,M,L){return M||L.slice(1)})})}(u,d===void 0?{}:d);return c.call(this,f)}}})})($k);const Lk=Hi;var ea={},Ok={get exports(){return ea},set exports(t){ea=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=function(l,c){if(!c||!c.length||c.length===1&&!c[0]||c.length===1&&Array.isArray(c[0])&&!c[0].length)return null;var u;c.length===1&&c[0].length>0&&(c=c[0]),u=(c=c.filter(function(f){return f}))[0];for(var d=1;d<c.length;d+=1)c[d].isValid()&&!c[d][l](u)||(u=c[d]);return u};a.max=function(){var l=[].slice.call(arguments,0);return o("isAfter",l)},a.min=function(){var l=[].slice.call(arguments,0);return o("isBefore",l)}}})})(Ok);const Pk=ea;var ta={},Bk={get exports(){return ta},set exports(t){ta=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=r.prototype,l=function(g){var m,C=g.date,w=g.utc,_={};if(!((m=C)===null||m instanceof Date||m instanceof Array||o.$utils().u(m)||m.constructor.name!=="Object")){if(!Object.keys(C).length)return new Date;var T=w?a.utc():a();Object.keys(C).forEach(function(W){var U,X;_[U=W,X=o.$utils().p(U),X==="date"?"day":X]=C[W]});var M=_.day||(_.year||_.month>=0?1:T.date()),L=_.year||T.year(),B=_.month>=0?_.month:_.year||_.day?0:T.month(),F=_.hour||0,$=_.minute||0,E=_.second||0,z=_.millisecond||0;return w?new Date(Date.UTC(L,B,M,F,$,E,z)):new Date(L,B,M,F,$,E,z)}return C},c=o.parse;o.parse=function(g){g.date=l.bind(this)(g),c.bind(this)(g)};var u=o.set,d=o.add,f=o.subtract,p=function(g,m,C,w){w===void 0&&(w=1);var _=Object.keys(m),T=this;return _.forEach(function(M){T=g.bind(T)(m[M]*w,M)}),T};o.set=function(g,m){return m=m===void 0?g:m,g.constructor.name==="Object"?p.bind(this)(function(C,w){return u.bind(this)(w,C)},m,g):u.bind(this)(g,m)},o.add=function(g,m){return g.constructor.name==="Object"?p.bind(this)(d,g,m):d.bind(this)(g,m)},o.subtract=function(g,m){return g.constructor.name==="Object"?p.bind(this)(d,g,m,-1):f.bind(this)(g,m)}}})})(Bk);const Vk=ta;var na={},Nk={get exports(){return na},set exports(t){na=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype;["milliseconds","seconds","minutes","hours","days","weeks","isoWeeks","months","quarters","years","dates"].forEach(function(o){a[o]=a[o.replace(/s$/,"")]})}})})(Nk);const qk=na;var ra={},Fk={get exports(){return ra},set exports(t){ra=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype.parse;r.prototype.parse=function(c){if(typeof c.date=="string"){var u=this.$locale();c.date=u&&u.preparse?u.preparse(c.date):c.date}return a.bind(this)(c)};var o=r.prototype.format;r.prototype.format=function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];var f=o.call.apply(o,[this].concat(u)),p=this.$locale();return p&&p.postformat?p.postformat(f):f};var l=r.prototype.fromToBase;l&&(r.prototype.fromToBase=function(c,u,d,f){var p=this.$locale()||d.$locale();return l.call(this,c,u,d,f,p&&p.postformat)})}})})(Fk);const Gk=ra;var ia={},Wk={get exports(){return ia},set exports(t){ia=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="month",r="quarter";return function(a,o){var l=o.prototype;l.quarter=function(d){return this.$utils().u(d)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(d-1))};var c=l.add;l.add=function(d,f){return d=Number(d),this.$utils().p(f)===r?this.add(3*d,n):c.bind(this)(d,f)};var u=l.startOf;l.startOf=function(d,f){var p=this.$utils(),g=!!p.u(f)||f;if(p.p(d)===r){var m=this.quarter()-1;return g?this.month(3*m).startOf(n).startOf("day"):this.month(3*m+2).endOf(n).endOf("day")}return u.bind(this)(d,f)}}})})(Wk);const Rk=ia;var aa={},jk={get exports(){return aa},set exports(t){aa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){n=n||{};var o=r.prototype,l={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function c(d,f,p,g){return o.fromToBase(d,f,p,g)}a.en.relativeTime=l,o.fromToBase=function(d,f,p,g,m){for(var C,w,_,T=p.$locale().relativeTime||l,M=n.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],L=M.length,B=0;B<L;B+=1){var F=M[B];F.d&&(C=g?a(d).diff(p,F.d,!0):p.diff(d,F.d,!0));var $=(n.rounding||Math.round)(Math.abs(C));if(_=C>0,$<=F.r||!F.r){$<=1&&B>0&&(F=M[B-1]);var E=T[F.l];m&&($=m(""+$)),w=typeof E=="string"?E.replace("%d",$):E($,f,F.l,_);break}}if(f)return w;var z=_?T.future:T.past;return typeof z=="function"?z(w):z.replace("%s",w)},o.to=function(d,f){return c(d,f,this,!0)},o.from=function(d,f){return c(d,f,this)};var u=function(d){return d.$u?a.utc():a()};o.toNow=function(d){return this.to(u(this),d)},o.fromNow=function(d){return this.from(u(this),d)}}})})(jk);const Yk=aa;var sa={},Qk={get exports(){return sa},set exports(t){sa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(a,o,l){var c,u=function(g,m,C){C===void 0&&(C={});var w=new Date(g),_=function(T,M){M===void 0&&(M={});var L=M.timeZoneName||"short",B=T+"|"+L,F=r[B];return F||(F=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:T,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:L}),r[B]=F),F}(m,C);return _.formatToParts(w)},d=function(g,m){for(var C=u(g,m),w=[],_=0;_<C.length;_+=1){var T=C[_],M=T.type,L=T.value,B=n[M];B>=0&&(w[B]=parseInt(L,10))}var F=w[3],$=F===24?0:F,E=w[0]+"-"+w[1]+"-"+w[2]+" "+$+":"+w[4]+":"+w[5]+":000",z=+g;return(l.utc(E).valueOf()-(z-=z%1e3))/6e4},f=o.prototype;f.tz=function(g,m){g===void 0&&(g=c);var C=this.utcOffset(),w=this.toDate(),_=w.toLocaleString("en-US",{timeZone:g}),T=Math.round((w-new Date(_))/1e3/60),M=l(_).$set("millisecond",this.$ms).utcOffset(15*-Math.round(w.getTimezoneOffset()/15)-T,!0);if(m){var L=M.utcOffset();M=M.add(C-L,"minute")}return M.$x.$timezone=g,M},f.offsetName=function(g){var m=this.$x.$timezone||l.tz.guess(),C=u(this.valueOf(),m,{timeZoneName:g}).find(function(w){return w.type.toLowerCase()==="timezonename"});return C&&C.value};var p=f.startOf;f.startOf=function(g,m){if(!this.$x||!this.$x.$timezone)return p.call(this,g,m);var C=l(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return p.call(C,g,m).tz(this.$x.$timezone,!0)},l.tz=function(g,m,C){var w=C&&m,_=C||m||c,T=d(+l(),_);if(typeof g!="string")return l(g).tz(_);var M=function($,E,z){var W=$-60*E*1e3,U=d(W,z);if(E===U)return[W,E];var X=d(W-=60*(U-E)*1e3,z);return U===X?[W,U]:[$-60*Math.min(U,X)*1e3,Math.max(U,X)]}(l.utc(g,w).valueOf(),T,_),L=M[0],B=M[1],F=l(L).utcOffset(B);return F.$x.$timezone=_,F},l.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},l.tz.setDefault=function(g){c=g}}})})(Qk);const Kk=sa;var oa={},Uk={get exports(){return oa},set exports(t){oa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]}}})})(Uk);const Xk=oa;var la={},Jk={get exports(){return la},set exports(t){la=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.toObject=function(){return{years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}}}})})(Jk);const Zk=la;var ca={},Hk={get exports(){return ca},set exports(t){ca=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){a.updateLocale=function(o,l){var c=a.Ls[o];if(c)return(l?Object.keys(l):[]).forEach(function(u){c[u]=l[u]}),c}}})})(Hk);const eT=ca;var ua={},tT={get exports(){return ua},set exports(t){ua=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,a=/([+-]|\d\d)/g;return function(o,l,c){var u=l.prototype;c.utc=function(w){var _={date:w,utc:!0,args:arguments};return new l(_)},u.utc=function(w){var _=c(this.toDate(),{locale:this.$L,utc:!0});return w?_.add(this.utcOffset(),n):_},u.local=function(){return c(this.toDate(),{locale:this.$L,utc:!1})};var d=u.parse;u.parse=function(w){w.utc&&(this.$u=!0),this.$utils().u(w.$offset)||(this.$offset=w.$offset),d.call(this,w)};var f=u.init;u.init=function(){if(this.$u){var w=this.$d;this.$y=w.getUTCFullYear(),this.$M=w.getUTCMonth(),this.$D=w.getUTCDate(),this.$W=w.getUTCDay(),this.$H=w.getUTCHours(),this.$m=w.getUTCMinutes(),this.$s=w.getUTCSeconds(),this.$ms=w.getUTCMilliseconds()}else f.call(this)};var p=u.utcOffset;u.utcOffset=function(w,_){var T=this.$utils().u;if(T(w))return this.$u?0:T(this.$offset)?p.call(this):this.$offset;if(typeof w=="string"&&(w=function(F){F===void 0&&(F="");var $=F.match(r);if(!$)return null;var E=(""+$[0]).match(a)||["-",0,0],z=E[0],W=60*+E[1]+ +E[2];return W===0?0:z==="+"?W:-W}(w),w===null))return this;var M=Math.abs(w)<=16?60*w:w,L=this;if(_)return L.$offset=M,L.$u=w===0,L;if(w!==0){var B=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(L=this.local().add(M+B,n)).$offset=M,L.$x.$localOffset=B}else L=this.utc();return L};var g=u.format;u.format=function(w){var _=w||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return g.call(this,_)},u.valueOf=function(){var w=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*w},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var m=u.toDate;u.toDate=function(w){return w==="s"&&this.$offset?c(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():m.call(this)};var C=u.diff;u.diff=function(w,_,T){if(w&&this.$u===w.$u)return C.call(this,w,_,T);var M=this.local(),L=c(w).local();return C.call(M,L,_,T)}}})})(tT);const nT=ua;var da={},rT={get exports(){return da},set exports(t){da=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.weekday=function(a){var o=this.$locale().weekStart||0,l=this.$W,c=(l<o?l+7:l)-o;return this.$utils().u(a)?c:this.subtract(c,"day").add(a,"day")}}})})(rT);const iT=da;var pa={},aT={get exports(){return pa},set exports(t){pa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="week",r="year";return function(a,o,l){var c=o.prototype;c.week=function(u){if(u===void 0&&(u=null),u!==null)return this.add(7*(u-this.week()),"day");var d=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var f=l(this).startOf(r).add(1,r).date(d),p=l(this).endOf(n);if(f.isBefore(p))return 1}var g=l(this).startOf(r).date(d).startOf(n).subtract(1,"millisecond"),m=this.diff(g,n,!0);return m<0?l(this).startOf("week").week():Math.ceil(m)},c.weeks=function(u){return u===void 0&&(u=null),this.week(u)}}})})(aT);const sT=pa;var ha={},oT={get exports(){return ha},set exports(t){ha=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.weekYear=function(){var a=this.month(),o=this.week(),l=this.year();return o===1&&a===11?l+1:a===0&&o>=52?l-1:l}}})})(oT);const lT=ha;Y.extend(X_),Y.extend(Z_),Y.extend(ek),Y.extend(nk),Y.extend(ik),Y.extend(sk),Y.extend(lk),Y.extend(uk),Y.extend(pk),Y.extend(fk),Y.extend(mk),Y.extend(Ck),Y.extend(_k),Y.extend(Tk),Y.extend(Ik),Y.extend(Ek),Y.extend(bk),Y.extend(xk),Y.extend(zk),Y.extend(Lk),Y.extend(Pk),Y.extend(Vk),Y.extend(qk),Y.extend(Gk),Y.extend(Rk),Y.extend(Yk),Y.extend(Kk),Y.extend(Xk),Y.extend(Zk),Y.extend(eT),Y.extend(nT),Y.extend(sT),Y.extend(lT),Y.extend(iT),Y.tz.setDefault("UTC");const cT=()=>Promise.resolve().then(()=>nu).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t));D.ContentModel=Xn,D.ContentModelContextProvider=hr,D.ContextModel=ds,D.DashboardEditor=Q_,D.DashboardFilterType=vi,D.DashboardMode=Qo,D.DashboardModel=nl,D.DashboardViewEditor=fl,D.DashboardViewRender=er,D.EViewComponentType=H,D.FilterModel=mr,D.FiltersModel=ts,D.FullScreenPanelContext=Cr,D.LayoutStateContext=ft,D.ModelContextProvider=fr,D.Panel=Hn,D.PanelContextProvider=wr,D.PanelModel=Ro,D.PanelsModel=Yo,D.QueriesModel=ls,D.QueryModel=os,D.ReadOnlyDashboard=K_,D.SQLSnippetModel=cs,D.SQLSnippetsModel=us,D.ViewComponentTypeBackground=Ko,D.ViewComponentTypeColor=eC,D.ViewComponentTypeName=Hw,D.ViewModel=Zo,D.ViewsModel=Ho,D.applyPartialDashboard=lC,D.createContentModel=tl,D.createDashboardModel=Ci,D.createDashboardViewsModel=wi,D.getInitialFiltersPayload=ns,D.getNewPanel=jo,D.getVersion=cT,D.initialDashboardContent=tC,D.useContentModelContext=K,D.useFullScreenPanelContext=bs,D.useModelContext=ge,D.usePanelContext=Ae,D.useTopLevelServices=ki,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
512
+ `)},o_=k.observer(({queryModel:t})=>{const[e,n]=y.useState(t.sql);y.useEffect(()=>{n(o=>o!==t.sql?t.sql:o)},[t.sql]);const r=e!==t.sql,a=()=>{t.setSQL(e)};return t.typedAsSQL?h(s.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[h(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Edit",children:h(s.Group,{spacing:14,position:"apart",children:["Edit SQL",i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!r,onClick:a,children:i(I.DeviceFloppy,{size:20})})]})}),i(s.Tabs.Tab,{value:"Preview",children:"Preview SQL"}),i(s.Tabs.Tab,{value:"pre_process",children:"Process Request"}),i(s.Tabs.Tab,{value:"post_process",children:"Process Result"}),i(zi,{}),t.datasource&&i(Tl,{dataSource:t.datasource})]}),i(s.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:i($i,{height:"100%",value:e,onChange:n,theme:"sql-dark",defaultLanguage:"sql"})}),i(s.Tabs.Panel,{value:"Preview",p:0,pl:4,children:i(s_,{value:t.sql})}),i(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:i(rr,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:Ml.pre})}),i(s.Tabs.Panel,{value:"post_process",p:"sm",children:i(rr,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:Ml.post})})]}):null}),ir={height:"calc(100% - 44px)",padding:0},l_=k.observer(({queryModel:t})=>{const e=K(),n=y.useMemo(()=>t.datasource?t.typedAsHTTP?"HTTP":"SQL":"Configurations",[t.datasource,t.typedAsHTTP]),[r,a]=y.useState(n);y.useEffect(()=>{a(c=>c!=="Configurations"&&n==="Configurations"?"Configurations":c)},[n]);const o=e.findQueryUsage(t.id),l=o.length===0;return i(s.Stack,{sx:{flexGrow:1},my:0,p:0,children:h(s.Tabs,{value:r,onTabChange:a,defaultValue:n,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[h(s.Tabs.List,{grow:!0,children:[i(s.Tabs.Tab,{value:"Configurations",children:"Configurations"}),t.typedAsSQL&&i(s.Tabs.Tab,{value:"SQL",children:"Request"}),t.typedAsHTTP&&i(s.Tabs.Tab,{value:"HTTP",children:"Request"}),i(s.Tabs.Tab,{value:"Data",disabled:!t.datasource,children:i(s.Tooltip,{label:"Need to pick a Data Source first",disabled:t.datasource,withinPortal:!0,children:i(s.Text,{children:"Data"})})}),i(s.Tabs.Tab,{value:"Usage",disabled:l,children:i(s.Tooltip,{label:"This query is not used for any filter or panel",disabled:!l,withinPortal:!0,children:i(s.Text,{children:"Usage"})})})]}),i(s.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:i(JS,{queryModel:t})}),t.typedAsSQL&&i(s.Tabs.Panel,{value:"SQL",sx:ir,children:i(s.Stack,{sx:{height:"100%"},children:i(o_,{queryModel:t})})}),t.typedAsHTTP&&i(s.Tabs.Panel,{value:"HTTP",sx:ir,children:i(s.Stack,{sx:{height:"100%"},children:i(r_,{queryModel:t})})}),i(s.Tabs.Panel,{value:"Data",sx:{...ir,overflow:"hidden"},children:i(Ei,{id:t.id})}),i(s.Tabs.Panel,{value:"Usage",sx:{...ir,overflow:"hidden"},children:i(i_,{queryID:t.id,usage:o})})]})})}),c_=k.observer(({id:t})=>{const n=K().queries.findByID(t);return t===""?null:n?i(s.Stack,{sx:{height:"100%"},spacing:"sm",children:i(l_,{queryModel:n})}):i(s.Text,{size:14,color:"red",children:"Invalid Query ID"})}),u_=k.observer(({value:t})=>{const n=K().payloadForSQL,r=y.useMemo(()=>dr(t,n),[t,n]);return i($i,{height:"100%",value:r})}),d_=k.observer(({item:t,remove:e,onKeyChanged:n})=>{const[r,a]=y.useState("SQL"),[o,l]=y.useState(t.key),c=()=>{t.setKey(o),n(o)},u=o!==t.key,d=t.isADuplicatedKey(o),[f,p]=y.useState(t.value),g=()=>{t.setValue(f)};y.useEffect(()=>{l(t.key),p(t.value)},[t]);const m=f!==t.value,C=Ke.useModals(),w=()=>{C.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:e,confirmProps:{color:"red"},zIndex:320})};return h(s.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[h(s.Group,{sx:{alignItems:"end"},spacing:40,children:[i(s.TextInput,{label:d?"This key is occupied by another snippet":"Key",value:o,onChange:_=>{l(_.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:i(s.ActionIcon,{color:"blue",variant:"subtle",onClick:c,disabled:!u||d,children:i(I.DeviceFloppy,{size:16})}),error:d}),i(s.Button,{leftIcon:i(I.Trash,{size:16}),color:"red",variant:"light",onClick:w,children:"Delete this SQL Snippet"})]}),h(s.Tabs,{value:r,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[h(s.Tabs.List,{sx:{position:"relative"},children:[i(s.Tabs.Tab,{value:"SQL",children:"SQL"}),i(s.Tabs.Tab,{value:"Preview",children:"Preview"}),i(zi,{}),i(s.ActionIcon,{color:"blue",variant:"filled",onClick:g,disabled:!m,sx:{position:"absolute",top:0,right:10},children:i(I.DeviceFloppy,{size:18})})]}),i(s.Tabs.Panel,{value:"SQL",pt:"sm",children:i($i,{height:"100%",value:f,onChange:p,defaultLanguage:"sql",theme:"sql-dark"})}),i(s.Tabs.Panel,{value:"Preview",pt:"sm",children:i(u_,{value:f})})]})]})}),p_=k.observer(({id:t})=>{const e=ge(),n=K(),r=y.useMemo(()=>n.sqlSnippets.findByKey(t),[t]);if(!t)return null;if(!r)return h(s.Text,{size:14,children:["SQL Snippet by key[",t,"] is not found"]});const a=()=>{e.editor.setPath(["_SQL_SNIPPETS_",""])};return i(d_,{item:r,remove:()=>{n.sqlSnippets.removeByKey(t),a()},onKeyChanged:c=>{e.editor.setPath(["_SQL_SNIPPETS_",c])}})}),h_=k.observer(({view:t})=>!t||t.type!==H.Division?null:h(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),i(s.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),f_=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],g_=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],m_=k.observer(({view:t})=>{if(!t||t.type!==H.Tabs)return null;const e=t.config;return h(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),i(s.Select,{label:"Variant",value:e.variant,onChange:e.setVariant,data:f_}),i(s.Select,{label:"Orientation",value:e.orientation,onChange:e.setOrientation,data:g_}),i(s.Switch,{label:"Grow Tabs",checked:e.grow,onChange:n=>e.setGrow(n.currentTarget.checked)})]})}),y_=({disabled:t,value:e,onChange:n})=>{const r=a=>{a&&n(a)};return h(s.Box,{sx:{position:"relative"},children:[t&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(ze,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})},b_=({value:t,onChange:e})=>{const[n,{setTrue:r,setFalse:a}]=J.useBoolean(),[o,l]=y.useState(t??xi),c=g=>{l({...o,enabled:g})},u=()=>{a();const{enabled:g,func_content:m}=o,C={enabled:g,func_content:m};l(C),e(C)},d=()=>{a(),l(t)},f=g=>{l(m=>({...m,func_content:g}))},p=()=>{f(xi.func_content)};return h(q,{children:[i(s.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:i(I.Settings,{size:14})}),i(s.Modal,{size:800,title:"Customize modal title",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&h(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:g=>c(g.currentTarget.checked)}),i(y_,{value:o.func_content,onChange:f,disabled:!o.enabled}),h(s.Group,{position:"apart",children:[i(s.Button,{onClick:p,color:"red",leftIcon:i(I.Recycle,{size:20}),children:"Rest"}),h(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},v_=k.observer(({view:t})=>{if(!t||t.type!==H.Modal)return null;const e=t.config,n=e.custom_modal_title.value;return h(s.Stack,{children:[i(s.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),h(s.Flex,{gap:10,children:[i(s.TextInput,{label:"Modal Title",value:n,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),i(b_,{value:e.custom_modal_title,onChange:e.custom_modal_title.replace})]}),h(s.Group,{grow:!0,children:[i(s.TextInput,{label:"Width",value:e.width,onChange:r=>e.setWidth(r.currentTarget.value),placeholder:"600px / 50vw"}),i(s.TextInput,{label:"Height",value:e.height,onChange:r=>e.setHeight(r.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),x_=k.observer(({view:t})=>h(q,{children:[i(h_,{view:t}),i(v_,{view:t}),i(m_,{view:t})]})),w_=[{label:"Division",value:H.Division},{label:"Modal",value:H.Modal},{label:"Tabs",value:H.Tabs}],C_=k.observer(({view:t})=>t?h(s.Stack,{sx:{position:"relative"},children:[i(s.TextInput,{label:"Name",value:t.name,onChange:e=>{t.setName(e.currentTarget.value)}}),i(s.Select,{label:"Type",withinPortal:!0,value:t.type,onChange:t.setType,data:w_}),i(x_,{view:t})]}):null),S_=k.observer(({id:t})=>{const e=Ke.useModals(),n=ge(),r=K();if(t==="")return null;const a=r.views.findByID(t);if(!a)return h(s.Text,{size:14,children:["View by ID[",t,"] is not found"]});const o=()=>{n.editor.setPath(["_VIEWS_",""])},l=()=>{e.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.views.removeByID(t),o()},zIndex:320})};return h(s.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(I.Trash,{size:16}),onClick:l,children:"Delete this view"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(C_,{view:a})})]})});function __(t){return t.length===1&&t[0]==="_QUERY_VARS_"}function k_(t){return t.length===1&&t[0]==="_MOCK_CONTEXT_"}function T_(t){return t.length===2&&t[0]==="_FILTERS_"}function D_(t){return t.length===2&&t[0]==="_SQL_SNIPPETS_"}function I_(t){return t.length===2&&t[0]==="_QUERIES_"}function M_(t){return t.length===2&&t[0]==="_VIEWS_"}function E_(t){return t.length===4&&t[0]==="_VIEWS_"&&t[2]==="_PANELS_"}const A_=k.observer(()=>i(s.Stack,{sx:{height:"100%"},p:"sm",children:i(Dl,{})})),z_=k.observer(()=>{const t=ge().editor,e=t.path;return __(e)?i(A_,{}):k_(e)?i(tS,{}):T_(e)?i(s.Box,{p:"xs",pl:20,children:i(eS,{id:e[1]})}):D_(e)?i(p_,{id:e[1]}):I_(e)?i(c_,{id:e[1]}):M_(e)?i(s.Box,{p:"xs",pl:20,children:i(S_,{id:e[1]})}):E_(e)?i(ES,{viewID:e[1],panelID:e[3]}):i(s.Box,{children:t.path})}),$_=k.observer(()=>i(z_,{})),L_=k.observer(()=>{const t=ge(),e=()=>{const n=new Date().getTime().toString(),r={id:n,key:n,label:n,order:t.content.filters.current.length+1,type:vi.TextInput,config:Ha(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(r),t.editor.setPath(["_FILTERS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),O_=k.observer(({parentID:t})=>{const e=K();if(!t)return null;const n=e.views.findByID(t);return n?i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>e.addANewPanel(n.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),P_=k.observer(()=>{const t=ge(),e=()=>{const n=new Date().getTime().toString(),r={id:n,name:n,type:be.Postgresql,key:"",sql:""};t.content.queries.append(r),t.editor.setPath(["_QUERIES_",n])};return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),B_=k.observer(()=>{const t=ge(),e=()=>{const n=new Date().getTime().toString(),r={key:n,value:""};t.content.sqlSnippets.append(r),t.editor.setPath(["_SQL_SNIPPETS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),V_=k.observer(()=>{const t=K();return i(s.Button,{variant:"subtle",leftIcon:i(O.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a View"})}),N_=k.observer(({action_type:t,parentID:e})=>(K(),t==="_Add_A_Filter_"?i(L_,{}):t==="_Add_A_SQL_SNIPPET_"?i(B_,{}):t==="_Add_A_QUERY_"?i(P_,{}):t==="_Add_A_VIEW_"?i(V_,{}):t==="_Add_A_PANEL_"?i(O_,{parentID:e}):null)),El=k.observer(({option:t})=>{var d;const e=ge().editor,n=e.isOptionActive,r=n(e.path,t),a=e.isOptionOpened,o=e.navigate,l=a(t),[c,u]=y.useState(l);return y.useEffect(()=>{u(l)},[l]),i(s.NavLink,{active:r,defaultOpened:l,opened:c,onChange:u,label:t.label,onClick:()=>o(t),icon:t.Icon?i(t.Icon,{size:18}):null,children:(d=t.children)==null?void 0:d.map(f=>f._type==="ACTION"?i(N_,{action_type:f._action_type,parentID:f.parentID},`_ADD_${f.value}_`):i(El,{option:f},f.value))},t.label)}),q_=k.observer(()=>{const t=ge();return i(s.Box,{sx:{position:"relative"},children:t.editor.navOptions.map(e=>i(El,{option:e},e.value))})}),F_=k.observer(()=>{const t=ge();return h(s.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[i(s.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:i(s.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),i(s.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:i(q_,{})}),i(s.Navbar.Section,{children:i(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:i(s.Button,{size:"xs",color:"red",leftIcon:i(O.IconX,{size:18}),onClick:()=>t.editor.close(),children:"Close"})})})]})}),G_={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},W_=k.observer(()=>{const t=ge().editor;return i(s.Modal,{onClose:()=>t.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:t.settings_open,fullScreen:!0,title:null,transitionDuration:0,withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{modal:{padding:"0 !important"}},children:i(s.AppShell,{padding:0,navbar:i(F_,{}),styles:G_,children:i($_,{})})})}),R_=t=>t.replace(/([^:])(\/\/+)/g,"$1/");function j_(t){y.useEffect(()=>{if(ze.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=R_(t);ze.loader.config({paths:{vs:n}}),ze.loader.init().then(r=>console.log("monaco instance:",r))},[])}Ls();const Y_={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},Q_=({context:t,dashboard:e,content:n,update:r,className:a="dashboard",config:o,onChange:l,headerSlot:c,headerMenuItems:u},d)=>{j_(o.monacoPath),Fa(o);const{data:f=[]}=J.useRequest(pr),{data:p=[]}=J.useRequest(Ga),[g,m]=y.useState(!1),C=y.useMemo(()=>Ci(e,n,f,p,t),[e,n]);y.useImperativeHandle(d,()=>C,[C]),ja(C.content,!0),y.useEffect(()=>{C.context.replace(t)},[t]),y.useEffect(()=>{C.datasources.replace(f)},[f]),y.useEffect(()=>{C.globalSQLSnippets.replace(p)},[p]),y.useEffect(()=>ae.reaction(()=>ae.toJS(C.json),M=>{l==null||l(M)}),[C]);const w=async()=>{await r(C.json,C.content.json)},_=J.useCreation(fi,[]),T=ki(_);return i(Ke.ModalsProvider,{children:i(fr,{value:C,children:i(hr,{value:C.content,children:i(ft.Provider,{value:{layoutFrozen:g,freezeLayout:m,inEditMode:!0},children:i(it.Provider,{value:_,children:h(Jn,{configure:T,children:[i(s.AppShell,{padding:0,header:i(p1,{saveDashboardChanges:w,headerSlot:c,headerMenuItems:u}),navbar:i(N1,{}),styles:Y_,children:i(s.Box,{className:`${a} dashboard-root`,sx:{position:"relative"},children:C.content.views.visibleViews.map(M=>i(fl,{view:M},M.id))})}),i(W_,{})]})})})})})})},K_=k.observer(y.forwardRef(Q_)),eD="";Ls();const U_=k.observer(({context:t,dashboard:e,content:n,className:r="dashboard",config:a,fullScreenPanelID:o,setFullScreenPanelID:l})=>{Fa(a);const{data:c=[]}=J.useRequest(pr),{data:u=[]}=J.useRequest(Ga),d=y.useMemo(()=>Ci(e,n,c,u,t),[e,n]);ja(d.content,!1),y.useEffect(()=>{d.context.replace(t)},[t]),y.useEffect(()=>{d.datasources.replace(c)},[c]),y.useEffect(()=>{d.globalSQLSnippets.replace(u)},[u]);const f=J.useCreation(fi,[]),p=ki(f);return i(Ke.ModalsProvider,{children:i(fr,{value:d,children:i(hr,{value:d.content,children:i(Cr.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:i(ft.Provider,{value:{layoutFrozen:!0,freezeLayout:v.noop,inEditMode:!1},children:i(s.Box,{className:`${r} dashboard-root`,children:i(it.Provider,{value:f,children:i(Jn,{configure:p,children:d.content.views.visibleViews.map(g=>i(er,{view:g},g.id))})})})})})})})})});var Li={},X_={get exports(){return Li},set exports(t){Li=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var c=this,u=this.$locale();if(!this.isValid())return o.bind(this)(l);var d=this.$utils(),f=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(p){switch(p){case"Q":return Math.ceil((c.$M+1)/3);case"Do":return u.ordinal(c.$D);case"gggg":return c.weekYear();case"GGGG":return c.isoWeekYear();case"wo":return u.ordinal(c.week(),"W");case"w":case"ww":return d.s(c.week(),p==="w"?1:2,"0");case"W":case"WW":return d.s(c.isoWeek(),p==="W"?1:2,"0");case"k":case"kk":return d.s(String(c.$H===0?24:c.$H),p==="k"?1:2,"0");case"X":return Math.floor(c.$d.getTime()/1e3);case"x":return c.$d.getTime();case"z":return"["+c.offsetName()+"]";case"zzz":return"["+c.offsetName("long")+"]";default:return p}});return o.bind(this)(f)}}})})(X_);const J_=Li;var Oi={},Z_={get exports(){return Oi},set exports(t){Oi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=r.prototype,l=function(u){var d=u.date,f=u.utc;return Array.isArray(d)?f?d.length?new Date(Date.UTC.apply(null,d)):new Date:d.length===1?a(String(d[0])).toDate():new(Function.prototype.bind.apply(Date,[null].concat(d))):d},c=o.parse;o.parse=function(u){u.date=l.bind(this)(u),c.bind(this)(u)}}})})(Z_);const H_=Oi;var Pi={},ek={get exports(){return Pi},set exports(t){Pi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype;a.$g=function(g,m,C){return this.$utils().u(g)?this[m]:this.$set(C,g)},a.set=function(g,m){return this.$set(g,m)};var o=a.startOf;a.startOf=function(g,m){return this.$d=o.bind(this)(g,m).toDate(),this.init(),this};var l=a.add;a.add=function(g,m){return this.$d=l.bind(this)(g,m).toDate(),this.init(),this};var c=a.locale;a.locale=function(g,m){return g?(this.$L=c.bind(this)(g,m).$L,this):this.$L};var u=a.daysInMonth;a.daysInMonth=function(){return u.bind(this.clone())()};var d=a.isSame;a.isSame=function(g,m){return d.bind(this.clone())(g,m)};var f=a.isBefore;a.isBefore=function(g,m){return f.bind(this.clone())(g,m)};var p=a.isAfter;a.isAfter=function(g,m){return p.bind(this.clone())(g,m)}}})})(ek);const tk=Pi;var Bi={},nk={get exports(){return Bi},set exports(t){Bi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var c=this,u=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/(\[[^\]]+])|BBBB|BB/g,function(d,f){var p,g=String(c.$y+543),m=d==="BB"?[g.slice(-2),2]:[g,4];return f||(p=c.$utils()).s.apply(p,m.concat(["0"]))});return o.bind(this)(u)}}})})(nk);const rk=Bi;var Vi={},ik={get exports(){return Vi},set exports(t){Vi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o="h:mm A",l={lastDay:"[Yesterday at] "+o,sameDay:"[Today at] "+o,nextDay:"[Tomorrow at] "+o,nextWeek:"dddd [at] "+o,lastWeek:"[Last] dddd [at] "+o,sameElse:"MM/DD/YYYY"};r.prototype.calendar=function(c,u){var d=u||this.$locale().calendar||l,f=a(c||void 0).startOf("d"),p=this.diff(f,"d",!0),g="sameElse",m=p<-6?g:p<-1?"lastWeek":p<0?"lastDay":p<1?"sameDay":p<2?"nextDay":p<7?"nextWeek":g,C=d[m]||l[m];return typeof C=="function"?C.call(this,a()):this.format(C)}}})})(ik);const ak=Vi;var Ni={},sk={get exports(){return Ni},set exports(t){Ni=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,a=/\d\d/,o=/\d\d?/,l=/\d*[^-_:/,()\s\d]+/,c={},u=function(w){return(w=+w)+(w>68?1900:2e3)},d=function(w){return function(_){this[w]=+_}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(w){(this.zone||(this.zone={})).offset=function(_){if(!_||_==="Z")return 0;var T=_.match(/([+-]|\d\d)/g),M=60*T[1]+(+T[2]||0);return M===0?0:T[0]==="+"?-M:M}(w)}],p=function(w){var _=c[w];return _&&(_.indexOf?_:_.s.concat(_.f))},g=function(w,_){var T,M=c.meridiem;if(M){for(var L=1;L<=24;L+=1)if(w.indexOf(M(L,0,_))>-1){T=L>12;break}}else T=w===(_?"pm":"PM");return T},m={A:[l,function(w){this.afternoon=g(w,!1)}],a:[l,function(w){this.afternoon=g(w,!0)}],S:[/\d/,function(w){this.milliseconds=100*+w}],SS:[a,function(w){this.milliseconds=10*+w}],SSS:[/\d{3}/,function(w){this.milliseconds=+w}],s:[o,d("seconds")],ss:[o,d("seconds")],m:[o,d("minutes")],mm:[o,d("minutes")],H:[o,d("hours")],h:[o,d("hours")],HH:[o,d("hours")],hh:[o,d("hours")],D:[o,d("day")],DD:[a,d("day")],Do:[l,function(w){var _=c.ordinal,T=w.match(/\d+/);if(this.day=T[0],_)for(var M=1;M<=31;M+=1)_(M).replace(/\[|\]/g,"")===w&&(this.day=M)}],M:[o,d("month")],MM:[a,d("month")],MMM:[l,function(w){var _=p("months"),T=(p("monthsShort")||_.map(function(M){return M.slice(0,3)})).indexOf(w)+1;if(T<1)throw new Error;this.month=T%12||T}],MMMM:[l,function(w){var _=p("months").indexOf(w)+1;if(_<1)throw new Error;this.month=_%12||_}],Y:[/[+-]?\d+/,d("year")],YY:[a,function(w){this.year=u(w)}],YYYY:[/\d{4}/,d("year")],Z:f,ZZ:f};function C(w){var _,T;_=w,T=c&&c.formats;for(var M=(w=_.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(W,U,X){var oe=X&&X.toUpperCase();return U||T[X]||n[X]||T[oe].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(re,de,Ce){return de||Ce.slice(1)})})).match(r),L=M.length,B=0;B<L;B+=1){var F=M[B],$=m[F],E=$&&$[0],z=$&&$[1];M[B]=z?{regex:E,parser:z}:F.replace(/^\[|\]$/g,"")}return function(W){for(var U={},X=0,oe=0;X<L;X+=1){var re=M[X];if(typeof re=="string")oe+=re.length;else{var de=re.regex,Ce=re.parser,ye=W.slice(oe),Te=de.exec(ye)[0];Ce.call(U,Te),W=W.replace(Te,"")}}return function(fe){var Oe=fe.afternoon;if(Oe!==void 0){var Ye=fe.hours;Oe?Ye<12&&(fe.hours+=12):Ye===12&&(fe.hours=0),delete fe.afternoon}}(U),U}}return function(w,_,T){T.p.customParseFormat=!0,w&&w.parseTwoDigitYear&&(u=w.parseTwoDigitYear);var M=_.prototype,L=M.parse;M.parse=function(B){var F=B.date,$=B.utc,E=B.args;this.$u=$;var z=E[1];if(typeof z=="string"){var W=E[2]===!0,U=E[3]===!0,X=W||U,oe=E[2];U&&(oe=E[2]),c=this.$locale(),!W&&oe&&(c=T.Ls[oe]),this.$d=function(ye,Te,fe){try{if(["x","X"].indexOf(Te)>-1)return new Date((Te==="X"?1e3:1)*ye);var Oe=C(Te)(ye),Ye=Oe.year,Mt=Oe.month,ar=Oe.day,sr=Oe.hours,fa=Oe.minutes,ga=Oe.seconds,cn=Oe.milliseconds,Ft=Oe.zone,xt=new Date,Et=ar||(Ye||Mt?1:xt.getDate()),wt=Ye||xt.getFullYear(),Gt=0;Ye&&!Mt||(Gt=Mt>0?Mt-1:xt.getMonth());var Wt=sr||0,un=fa||0,dn=ga||0,Ct=cn||0;return Ft?new Date(Date.UTC(wt,Gt,Et,Wt,un,dn,Ct+60*Ft.offset*1e3)):fe?new Date(Date.UTC(wt,Gt,Et,Wt,un,dn,Ct)):new Date(wt,Gt,Et,Wt,un,dn,Ct)}catch{return new Date("")}}(F,z,$),this.init(),oe&&oe!==!0&&(this.$L=this.locale(oe).$L),X&&F!=this.format(z)&&(this.$d=new Date("")),c={}}else if(z instanceof Array)for(var re=z.length,de=1;de<=re;de+=1){E[1]=z[de-1];var Ce=T.apply(this,E);if(Ce.isValid()){this.$d=Ce.$d,this.$L=Ce.$L,this.init();break}de===re&&(this.$d=new Date(""))}else L.call(this,B)}}})})(sk);const ok=Ni;var qi={},lk={get exports(){return qi},set exports(t){qi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.dayOfYear=function(o){var l=Math.round((a(this).startOf("day")-a(this).startOf("year"))/864e5)+1;return o==null?l:this.add(o-l,"day")}}})})(lk);const ck=qi;var Fi={},uk={get exports(){return Fi},set exports(t){Fi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n,r,a=1e3,o=6e4,l=36e5,c=864e5,u=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d=31536e6,f=2592e6,p=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,g={years:d,months:f,days:c,hours:l,minutes:o,seconds:a,milliseconds:1,weeks:6048e5},m=function($){return $ instanceof B},C=function($,E,z){return new B($,z,E.$l)},w=function($){return r.p($)+"s"},_=function($){return $<0},T=function($){return _($)?Math.ceil($):Math.floor($)},M=function($){return Math.abs($)},L=function($,E){return $?_($)?{negative:!0,format:""+M($)+E}:{negative:!1,format:""+$+E}:{negative:!1,format:""}},B=function(){function $(z,W,U){var X=this;if(this.$d={},this.$l=U,z===void 0&&(this.$ms=0,this.parseFromMilliseconds()),W)return C(z*g[w(W)],this);if(typeof z=="number")return this.$ms=z,this.parseFromMilliseconds(),this;if(typeof z=="object")return Object.keys(z).forEach(function(de){X.$d[w(de)]=z[de]}),this.calMilliseconds(),this;if(typeof z=="string"){var oe=z.match(p);if(oe){var re=oe.slice(2).map(function(de){return de!=null?Number(de):0});return this.$d.years=re[0],this.$d.months=re[1],this.$d.weeks=re[2],this.$d.days=re[3],this.$d.hours=re[4],this.$d.minutes=re[5],this.$d.seconds=re[6],this.calMilliseconds(),this}}return this}var E=$.prototype;return E.calMilliseconds=function(){var z=this;this.$ms=Object.keys(this.$d).reduce(function(W,U){return W+(z.$d[U]||0)*g[U]},0)},E.parseFromMilliseconds=function(){var z=this.$ms;this.$d.years=T(z/d),z%=d,this.$d.months=T(z/f),z%=f,this.$d.days=T(z/c),z%=c,this.$d.hours=T(z/l),z%=l,this.$d.minutes=T(z/o),z%=o,this.$d.seconds=T(z/a),z%=a,this.$d.milliseconds=z},E.toISOString=function(){var z=L(this.$d.years,"Y"),W=L(this.$d.months,"M"),U=+this.$d.days||0;this.$d.weeks&&(U+=7*this.$d.weeks);var X=L(U,"D"),oe=L(this.$d.hours,"H"),re=L(this.$d.minutes,"M"),de=this.$d.seconds||0;this.$d.milliseconds&&(de+=this.$d.milliseconds/1e3);var Ce=L(de,"S"),ye=z.negative||W.negative||X.negative||oe.negative||re.negative||Ce.negative,Te=oe.format||re.format||Ce.format?"T":"",fe=(ye?"-":"")+"P"+z.format+W.format+X.format+Te+oe.format+re.format+Ce.format;return fe==="P"||fe==="-P"?"P0D":fe},E.toJSON=function(){return this.toISOString()},E.format=function(z){var W=z||"YYYY-MM-DDTHH:mm:ss",U={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return W.replace(u,function(X,oe){return oe||String(U[X])})},E.as=function(z){return this.$ms/g[w(z)]},E.get=function(z){var W=this.$ms,U=w(z);return U==="milliseconds"?W%=1e3:W=U==="weeks"?T(W/g[U]):this.$d[U],W===0?0:W},E.add=function(z,W,U){var X;return X=W?z*g[w(W)]:m(z)?z.$ms:C(z,this).$ms,C(this.$ms+X*(U?-1:1),this)},E.subtract=function(z,W){return this.add(z,W,!0)},E.locale=function(z){var W=this.clone();return W.$l=z,W},E.clone=function(){return C(this.$ms,this)},E.humanize=function(z){return n().add(this.$ms,"ms").locale(this.$l).fromNow(!z)},E.valueOf=function(){return this.asMilliseconds()},E.milliseconds=function(){return this.get("milliseconds")},E.asMilliseconds=function(){return this.as("milliseconds")},E.seconds=function(){return this.get("seconds")},E.asSeconds=function(){return this.as("seconds")},E.minutes=function(){return this.get("minutes")},E.asMinutes=function(){return this.as("minutes")},E.hours=function(){return this.get("hours")},E.asHours=function(){return this.as("hours")},E.days=function(){return this.get("days")},E.asDays=function(){return this.as("days")},E.weeks=function(){return this.get("weeks")},E.asWeeks=function(){return this.as("weeks")},E.months=function(){return this.get("months")},E.asMonths=function(){return this.as("months")},E.years=function(){return this.get("years")},E.asYears=function(){return this.as("years")},$}(),F=function($,E,z){return $.add(E.years()*z,"y").add(E.months()*z,"M").add(E.days()*z,"d").add(E.hours()*z,"h").add(E.minutes()*z,"m").add(E.seconds()*z,"s").add(E.milliseconds()*z,"ms")};return function($,E,z){n=z,r=z().$utils(),z.duration=function(X,oe){var re=z.locale();return C(X,{$l:re},oe)},z.isDuration=m;var W=E.prototype.add,U=E.prototype.subtract;E.prototype.add=function(X,oe){return m(X)?F(this,X,1):W.bind(this)(X,oe)},E.prototype.subtract=function(X,oe){return m(X)?F(this,X,-1):U.bind(this)(X,oe)}}})})(uk);const dk=Fi;var Gi={},pk={get exports(){return Gi},set exports(t){Gi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isBetween=function(o,l,c,u){var d=a(o),f=a(l),p=(u=u||"()")[0]==="(",g=u[1]===")";return(p?this.isAfter(d,c):!this.isBefore(d,c))&&(g?this.isBefore(f,c):!this.isAfter(f,c))||(p?this.isBefore(d,c):!this.isAfter(d,c))&&(g?this.isAfter(f,c):!this.isBefore(f,c))}}})})(pk);const hk=Gi;var Wi={},fk={get exports(){return Wi},set exports(t){Wi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(fk);const gk=Wi;var Ri={},mk={get exports(){return Ri},set exports(t){Ri=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){a.isMoment=function(o){return a.isDayjs(o)}}})})(mk);const yk=Ri;var ji={},bk={get exports(){return ji},set exports(t){ji=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="day";return function(r,a,o){var l=function(d){return d.add(4-d.isoWeekday(),n)},c=a.prototype;c.isoWeekYear=function(){return l(this).year()},c.isoWeek=function(d){if(!this.$utils().u(d))return this.add(7*(d-this.isoWeek()),n);var f,p,g,m,C=l(this),w=(f=this.isoWeekYear(),p=this.$u,g=(p?o.utc:o)().year(f).startOf("year"),m=4-g.isoWeekday(),g.isoWeekday()>4&&(m+=7),g.add(m,n));return C.diff(w,"week")+1},c.isoWeekday=function(d){return this.$utils().u(d)?this.day()||7:this.day(this.day()%7?d:d-7)};var u=c.startOf;c.startOf=function(d,f){var p=this.$utils(),g=!!p.u(f)||f;return p.p(d)==="isoweek"?g?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):u.bind(this)(d,f)}}})})(bk);const vk=ji;var Yi={},xk={get exports(){return Yi},set exports(t){Yi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isoWeeksInYear=function(){var a=this.isLeapYear(),o=this.endOf("y").day();return o===4||a&&o===5?53:52}}})})(xk);const wk=Yi;var Qi={},Ck={get exports(){return Qi},set exports(t){Qi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isSameOrAfter=function(a,o){return this.isSame(a,o)||this.isAfter(a,o)}}})})(Ck);const Sk=Qi;var Ki={},_k={get exports(){return Ki},set exports(t){Ki=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.isSameOrBefore=function(a,o){return this.isSame(a,o)||this.isBefore(a,o)}}})})(_k);const kk=Ki;var Ui={},Tk={get exports(){return Ui},set exports(t){Ui=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isToday=function(){var o="YYYY-MM-DD",l=a();return this.format(o)===l.format(o)}}})})(Tk);const Dk=Ui;var Xi={},Ik={get exports(){return Xi},set exports(t){Xi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isTomorrow=function(){var o="YYYY-MM-DD",l=a().add(1,"day");return this.format(o)===l.format(o)}}})})(Ik);const Mk=Xi;var Ji={},Ek={get exports(){return Ji},set exports(t){Ji=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){r.prototype.isYesterday=function(){var o="YYYY-MM-DD",l=a().subtract(1,"day");return this.format(o)===l.format(o)}}})})(Ek);const Ak=Ji;var Zi={},zk={get exports(){return Zi},set exports(t){Zi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=r.prototype,l=function(p){return p&&(p.indexOf?p:p.s)},c=function(p,g,m,C,w){var _=p.name?p:p.$locale(),T=l(_[g]),M=l(_[m]),L=T||M.map(function(F){return F.slice(0,C)});if(!w)return L;var B=_.weekStart;return L.map(function(F,$){return L[($+(B||0))%7]})},u=function(){return a.Ls[a.locale()]},d=function(p,g){return p.formats[g]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(C,w,_){return w||_.slice(1)})}(p.formats[g.toUpperCase()])},f=function(){var p=this;return{months:function(g){return g?g.format("MMMM"):c(p,"months")},monthsShort:function(g){return g?g.format("MMM"):c(p,"monthsShort","months",3)},firstDayOfWeek:function(){return p.$locale().weekStart||0},weekdays:function(g){return g?g.format("dddd"):c(p,"weekdays")},weekdaysMin:function(g){return g?g.format("dd"):c(p,"weekdaysMin","weekdays",2)},weekdaysShort:function(g){return g?g.format("ddd"):c(p,"weekdaysShort","weekdays",3)},longDateFormat:function(g){return d(p.$locale(),g)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};o.localeData=function(){return f.bind(this)()},a.localeData=function(){var p=u();return{firstDayOfWeek:function(){return p.weekStart||0},weekdays:function(){return a.weekdays()},weekdaysShort:function(){return a.weekdaysShort()},weekdaysMin:function(){return a.weekdaysMin()},months:function(){return a.months()},monthsShort:function(){return a.monthsShort()},longDateFormat:function(g){return d(p,g)},meridiem:p.meridiem,ordinal:p.ordinal}},a.months=function(){return c(u(),"months")},a.monthsShort=function(){return c(u(),"monthsShort","months",3)},a.weekdays=function(p){return c(u(),"weekdays",null,null,p)},a.weekdaysShort=function(p){return c(u(),"weekdaysShort","weekdays",3,p)},a.weekdaysMin=function(p){return c(u(),"weekdaysMin","weekdays",2,p)}}})})(zk);const $k=Zi;var Hi={},Lk={get exports(){return Hi},set exports(t){Hi=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(r,a,o){var l=a.prototype,c=l.format;o.en.formats=n,l.format=function(u){u===void 0&&(u="YYYY-MM-DDTHH:mm:ssZ");var d=this.$locale().formats,f=function(p,g){return p.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(m,C,w){var _=w&&w.toUpperCase();return C||g[w]||n[w]||g[_].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(T,M,L){return M||L.slice(1)})})}(u,d===void 0?{}:d);return c.call(this,f)}}})})(Lk);const Ok=Hi;var ea={},Pk={get exports(){return ea},set exports(t){ea=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=function(l,c){if(!c||!c.length||c.length===1&&!c[0]||c.length===1&&Array.isArray(c[0])&&!c[0].length)return null;var u;c.length===1&&c[0].length>0&&(c=c[0]),u=(c=c.filter(function(f){return f}))[0];for(var d=1;d<c.length;d+=1)c[d].isValid()&&!c[d][l](u)||(u=c[d]);return u};a.max=function(){var l=[].slice.call(arguments,0);return o("isAfter",l)},a.min=function(){var l=[].slice.call(arguments,0);return o("isBefore",l)}}})})(Pk);const Bk=ea;var ta={},Vk={get exports(){return ta},set exports(t){ta=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){var o=r.prototype,l=function(g){var m,C=g.date,w=g.utc,_={};if(!((m=C)===null||m instanceof Date||m instanceof Array||o.$utils().u(m)||m.constructor.name!=="Object")){if(!Object.keys(C).length)return new Date;var T=w?a.utc():a();Object.keys(C).forEach(function(W){var U,X;_[U=W,X=o.$utils().p(U),X==="date"?"day":X]=C[W]});var M=_.day||(_.year||_.month>=0?1:T.date()),L=_.year||T.year(),B=_.month>=0?_.month:_.year||_.day?0:T.month(),F=_.hour||0,$=_.minute||0,E=_.second||0,z=_.millisecond||0;return w?new Date(Date.UTC(L,B,M,F,$,E,z)):new Date(L,B,M,F,$,E,z)}return C},c=o.parse;o.parse=function(g){g.date=l.bind(this)(g),c.bind(this)(g)};var u=o.set,d=o.add,f=o.subtract,p=function(g,m,C,w){w===void 0&&(w=1);var _=Object.keys(m),T=this;return _.forEach(function(M){T=g.bind(T)(m[M]*w,M)}),T};o.set=function(g,m){return m=m===void 0?g:m,g.constructor.name==="Object"?p.bind(this)(function(C,w){return u.bind(this)(w,C)},m,g):u.bind(this)(g,m)},o.add=function(g,m){return g.constructor.name==="Object"?p.bind(this)(d,g,m):d.bind(this)(g,m)},o.subtract=function(g,m){return g.constructor.name==="Object"?p.bind(this)(d,g,m,-1):f.bind(this)(g,m)}}})})(Vk);const Nk=ta;var na={},qk={get exports(){return na},set exports(t){na=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype;["milliseconds","seconds","minutes","hours","days","weeks","isoWeeks","months","quarters","years","dates"].forEach(function(o){a[o]=a[o.replace(/s$/,"")]})}})})(qk);const Fk=na;var ra={},Gk={get exports(){return ra},set exports(t){ra=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){var a=r.prototype.parse;r.prototype.parse=function(c){if(typeof c.date=="string"){var u=this.$locale();c.date=u&&u.preparse?u.preparse(c.date):c.date}return a.bind(this)(c)};var o=r.prototype.format;r.prototype.format=function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];var f=o.call.apply(o,[this].concat(u)),p=this.$locale();return p&&p.postformat?p.postformat(f):f};var l=r.prototype.fromToBase;l&&(r.prototype.fromToBase=function(c,u,d,f){var p=this.$locale()||d.$locale();return l.call(this,c,u,d,f,p&&p.postformat)})}})})(Gk);const Wk=ra;var ia={},Rk={get exports(){return ia},set exports(t){ia=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="month",r="quarter";return function(a,o){var l=o.prototype;l.quarter=function(d){return this.$utils().u(d)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(d-1))};var c=l.add;l.add=function(d,f){return d=Number(d),this.$utils().p(f)===r?this.add(3*d,n):c.bind(this)(d,f)};var u=l.startOf;l.startOf=function(d,f){var p=this.$utils(),g=!!p.u(f)||f;if(p.p(d)===r){var m=this.quarter()-1;return g?this.month(3*m).startOf(n).startOf("day"):this.month(3*m+2).endOf(n).endOf("day")}return u.bind(this)(d,f)}}})})(Rk);const jk=ia;var aa={},Yk={get exports(){return aa},set exports(t){aa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){n=n||{};var o=r.prototype,l={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function c(d,f,p,g){return o.fromToBase(d,f,p,g)}a.en.relativeTime=l,o.fromToBase=function(d,f,p,g,m){for(var C,w,_,T=p.$locale().relativeTime||l,M=n.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],L=M.length,B=0;B<L;B+=1){var F=M[B];F.d&&(C=g?a(d).diff(p,F.d,!0):p.diff(d,F.d,!0));var $=(n.rounding||Math.round)(Math.abs(C));if(_=C>0,$<=F.r||!F.r){$<=1&&B>0&&(F=M[B-1]);var E=T[F.l];m&&($=m(""+$)),w=typeof E=="string"?E.replace("%d",$):E($,f,F.l,_);break}}if(f)return w;var z=_?T.future:T.past;return typeof z=="function"?z(w):z.replace("%s",w)},o.to=function(d,f){return c(d,f,this,!0)},o.from=function(d,f){return c(d,f,this)};var u=function(d){return d.$u?a.utc():a()};o.toNow=function(d){return this.to(u(this),d)},o.fromNow=function(d){return this.from(u(this),d)}}})})(Yk);const Qk=aa;var sa={},Kk={get exports(){return sa},set exports(t){sa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(a,o,l){var c,u=function(g,m,C){C===void 0&&(C={});var w=new Date(g),_=function(T,M){M===void 0&&(M={});var L=M.timeZoneName||"short",B=T+"|"+L,F=r[B];return F||(F=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:T,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:L}),r[B]=F),F}(m,C);return _.formatToParts(w)},d=function(g,m){for(var C=u(g,m),w=[],_=0;_<C.length;_+=1){var T=C[_],M=T.type,L=T.value,B=n[M];B>=0&&(w[B]=parseInt(L,10))}var F=w[3],$=F===24?0:F,E=w[0]+"-"+w[1]+"-"+w[2]+" "+$+":"+w[4]+":"+w[5]+":000",z=+g;return(l.utc(E).valueOf()-(z-=z%1e3))/6e4},f=o.prototype;f.tz=function(g,m){g===void 0&&(g=c);var C=this.utcOffset(),w=this.toDate(),_=w.toLocaleString("en-US",{timeZone:g}),T=Math.round((w-new Date(_))/1e3/60),M=l(_).$set("millisecond",this.$ms).utcOffset(15*-Math.round(w.getTimezoneOffset()/15)-T,!0);if(m){var L=M.utcOffset();M=M.add(C-L,"minute")}return M.$x.$timezone=g,M},f.offsetName=function(g){var m=this.$x.$timezone||l.tz.guess(),C=u(this.valueOf(),m,{timeZoneName:g}).find(function(w){return w.type.toLowerCase()==="timezonename"});return C&&C.value};var p=f.startOf;f.startOf=function(g,m){if(!this.$x||!this.$x.$timezone)return p.call(this,g,m);var C=l(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return p.call(C,g,m).tz(this.$x.$timezone,!0)},l.tz=function(g,m,C){var w=C&&m,_=C||m||c,T=d(+l(),_);if(typeof g!="string")return l(g).tz(_);var M=function($,E,z){var W=$-60*E*1e3,U=d(W,z);if(E===U)return[W,E];var X=d(W-=60*(U-E)*1e3,z);return U===X?[W,U]:[$-60*Math.min(U,X)*1e3,Math.max(U,X)]}(l.utc(g,w).valueOf(),T,_),L=M[0],B=M[1],F=l(L).utcOffset(B);return F.$x.$timezone=_,F},l.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},l.tz.setDefault=function(g){c=g}}})})(Kk);const Uk=sa;var oa={},Xk={get exports(){return oa},set exports(t){oa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]}}})})(Xk);const Jk=oa;var la={},Zk={get exports(){return la},set exports(t){la=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.toObject=function(){return{years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}}}})})(Zk);const Hk=la;var ca={},eT={get exports(){return ca},set exports(t){ca=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r,a){a.updateLocale=function(o,l){var c=a.Ls[o];if(c)return(l?Object.keys(l):[]).forEach(function(u){c[u]=l[u]}),c}}})})(eT);const tT=ca;var ua={},nT={get exports(){return ua},set exports(t){ua=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,a=/([+-]|\d\d)/g;return function(o,l,c){var u=l.prototype;c.utc=function(w){var _={date:w,utc:!0,args:arguments};return new l(_)},u.utc=function(w){var _=c(this.toDate(),{locale:this.$L,utc:!0});return w?_.add(this.utcOffset(),n):_},u.local=function(){return c(this.toDate(),{locale:this.$L,utc:!1})};var d=u.parse;u.parse=function(w){w.utc&&(this.$u=!0),this.$utils().u(w.$offset)||(this.$offset=w.$offset),d.call(this,w)};var f=u.init;u.init=function(){if(this.$u){var w=this.$d;this.$y=w.getUTCFullYear(),this.$M=w.getUTCMonth(),this.$D=w.getUTCDate(),this.$W=w.getUTCDay(),this.$H=w.getUTCHours(),this.$m=w.getUTCMinutes(),this.$s=w.getUTCSeconds(),this.$ms=w.getUTCMilliseconds()}else f.call(this)};var p=u.utcOffset;u.utcOffset=function(w,_){var T=this.$utils().u;if(T(w))return this.$u?0:T(this.$offset)?p.call(this):this.$offset;if(typeof w=="string"&&(w=function(F){F===void 0&&(F="");var $=F.match(r);if(!$)return null;var E=(""+$[0]).match(a)||["-",0,0],z=E[0],W=60*+E[1]+ +E[2];return W===0?0:z==="+"?W:-W}(w),w===null))return this;var M=Math.abs(w)<=16?60*w:w,L=this;if(_)return L.$offset=M,L.$u=w===0,L;if(w!==0){var B=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(L=this.local().add(M+B,n)).$offset=M,L.$x.$localOffset=B}else L=this.utc();return L};var g=u.format;u.format=function(w){var _=w||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return g.call(this,_)},u.valueOf=function(){var w=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*w},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var m=u.toDate;u.toDate=function(w){return w==="s"&&this.$offset?c(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():m.call(this)};var C=u.diff;u.diff=function(w,_,T){if(w&&this.$u===w.$u)return C.call(this,w,_,T);var M=this.local(),L=c(w).local();return C.call(M,L,_,T)}}})})(nT);const rT=ua;var da={},iT={get exports(){return da},set exports(t){da=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.weekday=function(a){var o=this.$locale().weekStart||0,l=this.$W,c=(l<o?l+7:l)-o;return this.$utils().u(a)?c:this.subtract(c,"day").add(a,"day")}}})})(iT);const aT=da;var pa={},sT={get exports(){return pa},set exports(t){pa=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){var n="week",r="year";return function(a,o,l){var c=o.prototype;c.week=function(u){if(u===void 0&&(u=null),u!==null)return this.add(7*(u-this.week()),"day");var d=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var f=l(this).startOf(r).add(1,r).date(d),p=l(this).endOf(n);if(f.isBefore(p))return 1}var g=l(this).startOf(r).date(d).startOf(n).subtract(1,"millisecond"),m=this.diff(g,n,!0);return m<0?l(this).startOf("week").week():Math.ceil(m)},c.weeks=function(u){return u===void 0&&(u=null),this.week(u)}}})})(sT);const oT=pa;var ha={},lT={get exports(){return ha},set exports(t){ha=t}};(function(t,e){(function(n,r){t.exports=r()})(ne,function(){return function(n,r){r.prototype.weekYear=function(){var a=this.month(),o=this.week(),l=this.year();return o===1&&a===11?l+1:a===0&&o>=52?l-1:l}}})})(lT);const cT=ha;Y.extend(J_),Y.extend(H_),Y.extend(tk),Y.extend(rk),Y.extend(ak),Y.extend(ok),Y.extend(ck),Y.extend(dk),Y.extend(hk),Y.extend(gk),Y.extend(yk),Y.extend(Sk),Y.extend(kk),Y.extend(Dk),Y.extend(Mk),Y.extend(Ak),Y.extend(vk),Y.extend(wk),Y.extend($k),Y.extend(Ok),Y.extend(Bk),Y.extend(Nk),Y.extend(Fk),Y.extend(Wk),Y.extend(jk),Y.extend(Qk),Y.extend(Uk),Y.extend(Jk),Y.extend(Hk),Y.extend(tT),Y.extend(rT),Y.extend(oT),Y.extend(cT),Y.extend(aT),Y.tz.setDefault("UTC");const uT=()=>Promise.resolve().then(()=>nu).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t));D.ContentModel=Xn,D.ContentModelContextProvider=hr,D.ContextModel=ds,D.DashboardEditor=K_,D.DashboardFilterType=vi,D.DashboardMode=Qo,D.DashboardModel=nl,D.DashboardViewEditor=fl,D.DashboardViewRender=er,D.EViewComponentType=H,D.FilterModel=mr,D.FiltersModel=ts,D.FullScreenPanelContext=Cr,D.LayoutStateContext=ft,D.ModelContextProvider=fr,D.Panel=Hn,D.PanelContextProvider=wr,D.PanelModel=Ro,D.PanelsModel=Yo,D.QueriesModel=ls,D.QueryModel=os,D.ReadOnlyDashboard=U_,D.SQLSnippetModel=cs,D.SQLSnippetsModel=us,D.ViewComponentTypeBackground=Ko,D.ViewComponentTypeColor=eC,D.ViewComponentTypeName=Hw,D.ViewModel=Zo,D.ViewsModel=Ho,D.applyPartialDashboard=lC,D.createContentModel=tl,D.createDashboardModel=Ci,D.createDashboardViewsModel=wi,D.getInitialFiltersPayload=ns,D.getNewPanel=jo,D.getVersion=uT,D.initialDashboardContent=tC,D.useContentModelContext=K,D.useFullScreenPanelContext=bs,D.useModelContext=ge,D.usePanelContext=Ae,D.useTopLevelServices=ki,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});